@@ -44,7 +44,7 @@ impl AllocatorVisualizer {
44
44
}
45
45
46
46
fn render_main_window ( & mut self , ui : & imgui:: Ui , alloc : & Allocator ) {
47
- imgui:: Window :: new ( imgui :: im_str! ( "Allocator visualization" ) )
47
+ imgui:: Window :: new ( "Allocator visualization" )
48
48
. collapsed ( true , Condition :: FirstUseEver )
49
49
. size ( [ 512.0 , 512.0 ] , imgui:: Condition :: FirstUseEver )
50
50
. build ( ui, || {
@@ -56,11 +56,10 @@ impl AllocatorVisualizer {
56
56
) ) ;
57
57
58
58
let heap_count = alloc. memory_heaps . len ( ) ;
59
- if CollapsingHeader :: new ( & im_str ! ( "Memory Heaps ({} heaps)" , heap_count) ) . build ( ui)
60
- {
59
+ if CollapsingHeader :: new ( format ! ( "Memory Heaps ({} heaps)" , heap_count) ) . build ( ui) {
61
60
for ( i, heap) in alloc. memory_heaps . iter ( ) . enumerate ( ) {
62
61
ui. indent ( ) ;
63
- if CollapsingHeader :: new ( & im_str ! ( "Heap: {}" , i) ) . build ( ui) {
62
+ if CollapsingHeader :: new ( format ! ( "Heap: {}" , i) ) . build ( ui) {
64
63
ui. indent ( ) ;
65
64
ui. text ( format ! ( "flags: {:?}" , heap. flags) ) ;
66
65
ui. text ( format ! (
@@ -73,7 +72,7 @@ impl AllocatorVisualizer {
73
72
}
74
73
}
75
74
76
- if CollapsingHeader :: new ( & im_str ! (
75
+ if CollapsingHeader :: new ( format ! (
77
76
"Memory Types: ({} types)" ,
78
77
alloc. memory_types. len( )
79
78
) )
@@ -82,8 +81,8 @@ impl AllocatorVisualizer {
82
81
{
83
82
ui. indent ( ) ;
84
83
for ( mem_type_i, mem_type) in alloc. memory_types . iter ( ) . enumerate ( ) {
85
- if CollapsingHeader :: new ( & im_str ! (
86
- "Type: {} ({} blocks)### Type{}" ,
84
+ if CollapsingHeader :: new ( format ! (
85
+ "Type: {} ({} blocks)##Type{}" ,
87
86
mem_type_i,
88
87
mem_type. memory_blocks. len( ) ,
89
88
mem_type_i,
@@ -109,13 +108,7 @@ impl AllocatorVisualizer {
109
108
ui. text ( format ! ( "block count: {}" , active_block_count) ) ;
110
109
for ( block_i, block) in mem_type. memory_blocks . iter ( ) . enumerate ( ) {
111
110
if let Some ( block) = block {
112
- TreeNode :: new ( & im_str ! (
113
- "Block: {}##memtype({})" ,
114
- block_i,
115
- mem_type_i
116
- ) )
117
- . label ( & im_str ! ( "Block: {}" , block_i) )
118
- . build ( ui, || {
111
+ TreeNode :: new ( format ! ( "Block: {}" , block_i) ) . build ( ui, || {
119
112
use ash:: vk:: Handle ;
120
113
ui. indent ( ) ;
121
114
ui. text ( format ! ( "size: {} KiB" , block. size / 1024 ) ) ;
@@ -134,32 +127,21 @@ impl AllocatorVisualizer {
134
127
135
128
block. sub_allocator . draw_base_info ( ui) ;
136
129
137
- if block. sub_allocator . supports_visualization ( ) {
138
- let button_name = format ! (
139
- "visualize##memtype({})block({})" ,
140
- mem_type_i, block_i
141
- ) ;
142
- if ui. small_button ( & ImString :: new ( button_name) ) {
143
- match self
144
- . selected_blocks
145
- . iter ( )
146
- . enumerate ( )
147
- . find_map ( |( i, x) | {
148
- if x. memory_type_index == mem_type_i
149
- && x. block_index == block_i
150
- {
151
- Some ( ( i, ( x) ) )
152
- } else {
153
- None
154
- }
155
- } ) {
156
- Some ( x) => self . focus = Some ( x. 0 ) ,
157
- None => self . selected_blocks . push (
158
- AllocatorVisualizerBlockWindow :: new (
159
- mem_type_i, block_i,
160
- ) ,
130
+ if block. sub_allocator . supports_visualization ( )
131
+ && ui. small_button ( "visualize" )
132
+ {
133
+ match self . selected_blocks . iter ( ) . enumerate ( ) . find (
134
+ |( _, x) | {
135
+ x. memory_type_index == mem_type_i
136
+ && x. block_index == block_i
137
+ } ,
138
+ ) {
139
+ Some ( x) => self . focus = Some ( x. 0 ) ,
140
+ None => self . selected_blocks . push (
141
+ AllocatorVisualizerBlockWindow :: new (
142
+ mem_type_i, block_i,
161
143
) ,
162
- }
144
+ ) ,
163
145
}
164
146
}
165
147
ui. unindent ( ) ;
@@ -174,7 +156,6 @@ impl AllocatorVisualizer {
174
156
}
175
157
176
158
fn render_memory_block_windows ( & mut self , ui : & imgui:: Ui , alloc : & Allocator ) {
177
- use imgui:: * ;
178
159
// Copy here to workaround the borrow checker.
179
160
let focus_opt = self . focus ;
180
161
// Keep track of a list of windows that are signaled by imgui to be closed.
@@ -189,10 +170,9 @@ impl AllocatorVisualizer {
189
170
false
190
171
} ;
191
172
let mut is_open = true ;
192
- imgui:: Window :: new ( & imgui :: im_str !(
173
+ imgui:: Window :: new ( format ! (
193
174
"Block Visualizer##memtype({})block({})" ,
194
- window. memory_type_index,
195
- window. block_index
175
+ window. memory_type_index, window. block_index
196
176
) )
197
177
. size ( [ 1920.0 * 0.5 , 1080.0 * 0.5 ] , imgui:: Condition :: FirstUseEver )
198
178
. title_bar ( true )
@@ -215,13 +195,13 @@ impl AllocatorVisualizer {
215
195
) ) ;
216
196
217
197
if alloc. debug_settings . store_stack_traces {
218
- ui. checkbox ( im_str ! ( "Show backtraces" ) , & mut window. show_backtraces ) ;
198
+ ui. checkbox ( "Show backtraces" , & mut window. show_backtraces ) ;
219
199
}
220
200
// Slider for changing the 'zoom' level of the visualizer.
221
201
const BYTES_PER_UNIT_MIN : i32 = 1 ;
222
202
const BYTES_PER_UNIT_MAX : i32 = 1024 * 1024 ;
223
- Drag :: new ( im_str ! ( "Bytes per Pixel (zoom)" ) )
224
- . range ( BYTES_PER_UNIT_MIN ..= BYTES_PER_UNIT_MAX )
203
+ Drag :: new ( "Bytes per Pixel (zoom)" )
204
+ . range ( BYTES_PER_UNIT_MIN , BYTES_PER_UNIT_MAX )
225
205
. speed ( 10.0f32 )
226
206
. build ( ui, & mut window. bytes_per_unit ) ;
227
207
@@ -232,10 +212,9 @@ impl AllocatorVisualizer {
232
212
. max ( BYTES_PER_UNIT_MIN ) ;
233
213
234
214
// Draw the visualization in a child window.
235
- imgui:: ChildWindow :: new ( & im_str ! (
215
+ imgui:: ChildWindow :: new ( & format ! (
236
216
"Visualization Sub-window##memtype({})block({})" ,
237
- window. memory_type_index,
238
- window. block_index
217
+ window. memory_type_index, window. block_index
239
218
) )
240
219
. scrollable ( true )
241
220
. scroll_bar ( true )
0 commit comments