@@ -19,6 +19,7 @@ public partial class RenderGraphViewer
1919
2020 static partial class Names
2121 {
22+ public const string kPanelContainer = "panel-container" ;
2223 public const string kResourceListFoldout = "panel-resource-list" ;
2324 public const string kPassListFoldout = "panel-pass-list" ;
2425 public const string kResourceSearchField = "resource-search-field" ;
@@ -40,18 +41,31 @@ static partial class Classes
4041 const string k_SelectionColorBeginTag = "<mark=#3169ACAB>" ;
4142 const string k_SelectionColorEndTag = "</mark>" ;
4243
44+ TwoPaneSplitView m_SidePanelSplitView ;
4345 bool m_ResourceListExpanded = true ;
4446 bool m_PassListExpanded = true ;
47+ float m_SidePanelVerticalAspectRatio = 0.5f ;
48+ float m_SidePanelFixedPaneHeight = 0 ;
4549
4650 Dictionary < VisualElement , List < TextElement > > m_ResourceDescendantCache = new ( ) ;
4751 Dictionary < VisualElement , List < TextElement > > m_PassDescendantCache = new ( ) ;
4852
4953 void InitializeSidePanel ( )
5054 {
55+ m_SidePanelSplitView = rootVisualElement . Q < TwoPaneSplitView > ( Names . kPanelContainer ) ;
56+ rootVisualElement . RegisterCallback < GeometryChangedEvent > ( _ =>
57+ {
58+ SaveSplitViewFixedPaneHeight ( ) ; // Window resized - save the current pane height
59+ UpdatePanelHeights ( ) ;
60+ } ) ;
61+
5162 // Callbacks for dynamic height allocation between resource & pass lists
5263 HeaderFoldout resourceListFoldout = rootVisualElement . Q < HeaderFoldout > ( Names . kResourceListFoldout ) ;
5364 resourceListFoldout . RegisterValueChangedCallback ( evt =>
5465 {
66+ if ( m_ResourceListExpanded )
67+ SaveSplitViewFixedPaneHeight ( ) ; // Closing the foldout - save the current pane height
68+
5569 m_ResourceListExpanded = resourceListFoldout . value ;
5670 UpdatePanelHeights ( ) ;
5771 } ) ;
@@ -61,6 +75,9 @@ void InitializeSidePanel()
6175 HeaderFoldout passListFoldout = rootVisualElement . Q < HeaderFoldout > ( Names . kPassListFoldout ) ;
6276 passListFoldout . RegisterValueChangedCallback ( evt =>
6377 {
78+ if ( m_PassListExpanded )
79+ SaveSplitViewFixedPaneHeight ( ) ; // Closing the foldout - save the current pane height
80+
6481 m_PassListExpanded = passListFoldout . value ;
6582 UpdatePanelHeights ( ) ;
6683 } ) ;
@@ -247,8 +264,9 @@ void CreateTextElement(VisualElement parent, string text, string className = nul
247264 }
248265
249266 var passItem = new Foldout ( ) ;
250- passItem . text = string . Join ( ", " , passNames ) ;
251- passItem . Q < Toggle > ( ) . tooltip = passItem . text ;
267+ var passesText = string . Join ( ", " , passNames ) ;
268+ passItem . text = $ "<b>{ passesText } </b>";
269+ passItem . Q < Toggle > ( ) . tooltip = passesText ;
252270 passItem . value = false ;
253271 passItem . userData = m_PassIdToVisiblePassIndex [ visiblePassElement . passId ] ;
254272 passItem . AddToClassList ( Classes . kPanelListItem ) ;
@@ -270,71 +288,75 @@ void CreateTextElement(VisualElement parent, string text, string className = nul
270288 }
271289 else
272290 {
291+ CreateTextElement ( passItem , "Pass break reasoning" , Classes . kSubHeaderText ) ;
273292 var msg = $ "This is a { k_PassTypeNames [ ( int ) firstPassData . type ] } . Only Raster Render Passes can be merged.";
274293 msg = msg . Replace ( "a Unsafe" , "an Unsafe" ) ;
275294 CreateTextElement ( passItem , msg ) ;
276295 }
277296
278- CreateTextElement ( passItem , "Render Graph Pass Info" , Classes . kSubHeaderText ) ;
279- foreach ( int passId in groupedPassIds )
280- {
281- var pass = m_CurrentDebugData . passList [ passId ] ;
282- Debug . Assert ( pass . nrpInfo != null ) ; // This overlay currently assumes NRP compiler
283- var passFoldout = new Foldout ( ) ;
284- passFoldout . text = $ "{ pass . name } ({ k_PassTypeNames [ ( int ) pass . type ] } )";
285- passFoldout . AddToClassList ( Classes . kAttachmentInfoItem ) ;
286- passFoldout . AddToClassList ( Classes . kCustomFoldoutArrow ) ;
287- passFoldout . Q < Toggle > ( ) . tooltip = passFoldout . text ;
288-
289- var foldoutCheckmark = passFoldout . Q ( "unity-checkmark" ) ;
290- foldoutCheckmark . BringToFront ( ) ; // Move foldout checkmark to the right
291-
292- var lineBreak = new VisualElement ( ) ;
293- lineBreak . AddToClassList ( Classes . kPanelListLineBreak ) ;
294- passFoldout . Add ( lineBreak ) ;
295-
296- CreateTextElement ( passFoldout ,
297- $ "Attachment dimensions: { pass . nrpInfo . width } x{ pass . nrpInfo . height } x{ pass . nrpInfo . volumeDepth } ") ;
298- CreateTextElement ( passFoldout , $ "Has depth attachment: { pass . nrpInfo . hasDepth } ") ;
299- CreateTextElement ( passFoldout , $ "MSAA samples: { pass . nrpInfo . samples } ") ;
300- CreateTextElement ( passFoldout , $ "Async compute: { pass . async } ") ;
301-
302- passItem . Add ( passFoldout ) ;
303- }
304-
305- CreateTextElement ( passItem , "Attachment Load/Store Actions" , Classes . kSubHeaderText ) ;
306- if ( nativePassInfo != null && nativePassInfo . attachmentInfos . Count > 0 )
297+ if ( nativePassInfo != null )
307298 {
308- foreach ( var attachmentInfo in nativePassInfo . attachmentInfos )
299+ CreateTextElement ( passItem , "Render Graph Pass Info" , Classes . kSubHeaderText ) ;
300+ foreach ( int passId in groupedPassIds )
309301 {
310- var attachmentFoldout = new Foldout ( ) ;
311- attachmentFoldout . text = attachmentInfo . resourceName ;
312- attachmentFoldout . AddToClassList ( Classes . kAttachmentInfoItem ) ;
313- attachmentFoldout . AddToClassList ( Classes . kCustomFoldoutArrow ) ;
314- attachmentFoldout . Q < Toggle > ( ) . tooltip = attachmentFoldout . text ;
315-
316- var foldoutCheckmark = attachmentFoldout . Q ( "unity-checkmark" ) ;
302+ var pass = m_CurrentDebugData . passList [ passId ] ;
303+ Debug . Assert ( pass . nrpInfo != null ) ; // This overlay currently assumes NRP compiler
304+ var passFoldout = new Foldout ( ) ;
305+ passFoldout . text = $ "{ pass . name } ({ k_PassTypeNames [ ( int ) pass . type ] } )";
306+ passFoldout . AddToClassList ( Classes . kAttachmentInfoItem ) ;
307+ passFoldout . AddToClassList ( Classes . kCustomFoldoutArrow ) ;
308+ passFoldout . Q < Toggle > ( ) . tooltip = passFoldout . text ;
309+
310+ var foldoutCheckmark = passFoldout . Q ( "unity-checkmark" ) ;
317311 foldoutCheckmark . BringToFront ( ) ; // Move foldout checkmark to the right
318312
319313 var lineBreak = new VisualElement ( ) ;
320314 lineBreak . AddToClassList ( Classes . kPanelListLineBreak ) ;
321- attachmentFoldout . Add ( lineBreak ) ;
315+ passFoldout . Add ( lineBreak ) ;
322316
323- attachmentFoldout . Add ( new TextElement
324- {
325- text = $ "<b>Load action:</b> { attachmentInfo . loadAction } ({ attachmentInfo . loadReason } )"
326- } ) ;
327- attachmentFoldout . Add ( new TextElement
328- {
329- text = $ "<b>Store action:</b> { attachmentInfo . storeAction } ({ attachmentInfo . storeReason } )"
330- } ) ;
317+ CreateTextElement ( passFoldout ,
318+ $ "Attachment dimensions: { pass . nrpInfo . width } x{ pass . nrpInfo . height } x{ pass . nrpInfo . volumeDepth } ") ;
319+ CreateTextElement ( passFoldout , $ "Has depth attachment: { pass . nrpInfo . hasDepth } ") ;
320+ CreateTextElement ( passFoldout , $ "MSAA samples: { pass . nrpInfo . samples } ") ;
321+ CreateTextElement ( passFoldout , $ "Async compute: { pass . async } ") ;
331322
332- passItem . Add ( attachmentFoldout ) ;
323+ passItem . Add ( passFoldout ) ;
324+ }
325+
326+ CreateTextElement ( passItem , "Attachment Load/Store Actions" , Classes . kSubHeaderText ) ;
327+ if ( nativePassInfo != null && nativePassInfo . attachmentInfos . Count > 0 )
328+ {
329+ foreach ( var attachmentInfo in nativePassInfo . attachmentInfos )
330+ {
331+ var attachmentFoldout = new Foldout ( ) ;
332+ attachmentFoldout . text = attachmentInfo . resourceName ;
333+ attachmentFoldout . AddToClassList ( Classes . kAttachmentInfoItem ) ;
334+ attachmentFoldout . AddToClassList ( Classes . kCustomFoldoutArrow ) ;
335+ attachmentFoldout . Q < Toggle > ( ) . tooltip = attachmentFoldout . text ;
336+
337+ var foldoutCheckmark = attachmentFoldout . Q ( "unity-checkmark" ) ;
338+ foldoutCheckmark . BringToFront ( ) ; // Move foldout checkmark to the right
339+
340+ var lineBreak = new VisualElement ( ) ;
341+ lineBreak . AddToClassList ( Classes . kPanelListLineBreak ) ;
342+ attachmentFoldout . Add ( lineBreak ) ;
343+
344+ attachmentFoldout . Add ( new TextElement
345+ {
346+ text = $ "<b>Load action:</b> { attachmentInfo . loadAction } ({ attachmentInfo . loadReason } )"
347+ } ) ;
348+ attachmentFoldout . Add ( new TextElement
349+ {
350+ text = $ "<b>Store action:</b> { attachmentInfo . storeAction } ({ attachmentInfo . storeReason } )"
351+ } ) ;
352+
353+ passItem . Add ( attachmentFoldout ) ;
354+ }
355+ }
356+ else
357+ {
358+ CreateTextElement ( passItem , "No attachments." ) ;
333359 }
334- }
335- else
336- {
337- CreateTextElement ( passItem , "No attachments." ) ;
338360 }
339361
340362 content . Add ( passItem ) ;
@@ -343,32 +365,48 @@ void CreateTextElement(VisualElement parent, string text, string className = nul
343365 }
344366 }
345367
346- void UpdatePanelHeights ( )
368+ void SaveSplitViewFixedPaneHeight ( )
347369 {
348- HeaderFoldout resourceListFoldout = rootVisualElement . Q < HeaderFoldout > ( Names . kResourceListFoldout ) ;
349- HeaderFoldout passListFoldout = rootVisualElement . Q < HeaderFoldout > ( Names . kPassListFoldout ) ;
370+ m_SidePanelFixedPaneHeight = m_SidePanelSplitView . fixedPane ? . resolvedStyle ? . height ?? 0 ;
371+ }
350372
373+ void UpdatePanelHeights ( )
374+ {
351375 bool passListExpanded = m_PassListExpanded && ( m_CurrentDebugData != null && m_CurrentDebugData . isNRPCompiler ) ;
352376 const int kFoldoutHeaderHeightPx = 18 ;
353- if ( m_ResourceListExpanded && ! passListExpanded )
377+ const int kWindowExtraMarginPx = 6 ;
378+
379+ float panelHeightPx = focusedWindow . position . height - kHeaderContainerHeightPx - kWindowExtraMarginPx ;
380+ if ( ! m_ResourceListExpanded )
381+ {
382+ m_SidePanelSplitView . fixedPaneInitialDimension = kFoldoutHeaderHeightPx ;
383+ }
384+ else if ( ! passListExpanded )
354385 {
355- resourceListFoldout . style . maxHeight = Length . Percent ( 100 ) ;
356- passListFoldout . style . maxHeight = kFoldoutHeaderHeightPx ;
386+ m_SidePanelSplitView . fixedPaneInitialDimension = panelHeightPx - kFoldoutHeaderHeightPx ;
357387 }
358- else if ( ! m_ResourceListExpanded && passListExpanded )
388+ else
359389 {
360- resourceListFoldout . style . maxHeight = kFoldoutHeaderHeightPx ;
361- passListFoldout . style . maxHeight = Length . Percent ( 100 ) ;
390+ // Update aspect ratio in case user has dragged the split view
391+ if ( m_SidePanelFixedPaneHeight > kFoldoutHeaderHeightPx && m_SidePanelFixedPaneHeight < panelHeightPx - kFoldoutHeaderHeightPx )
392+ {
393+ m_SidePanelVerticalAspectRatio = m_SidePanelFixedPaneHeight / panelHeightPx ;
394+ }
395+ m_SidePanelSplitView . fixedPaneInitialDimension = panelHeightPx * m_SidePanelVerticalAspectRatio ;
362396 }
363- else if ( m_ResourceListExpanded && passListExpanded )
397+
398+ // Disable drag line when one of the foldouts is collapsed
399+ var dragLine = m_SidePanelSplitView . Q ( "unity-dragline" ) ;
400+ var dragLineAnchor = m_SidePanelSplitView . Q ( "unity-dragline-anchor" ) ;
401+ if ( ! m_ResourceListExpanded || ! passListExpanded )
364402 {
365- resourceListFoldout . style . maxHeight = Length . Percent ( 50 ) ;
366- passListFoldout . style . maxHeight = Length . Percent ( 50 ) ;
403+ dragLine . pickingMode = PickingMode . Ignore ;
404+ dragLineAnchor . pickingMode = PickingMode . Ignore ;
367405 }
368406 else
369407 {
370- resourceListFoldout . style . maxHeight = kFoldoutHeaderHeightPx ;
371- passListFoldout . style . maxHeight = kFoldoutHeaderHeightPx ;
408+ dragLine . pickingMode = PickingMode . Position ;
409+ dragLineAnchor . pickingMode = PickingMode . Position ;
372410 }
373411 }
374412
0 commit comments