Skip to content

Commit 39c951c

Browse files
dump: Fix GPU Dump Descriptor for samplers
1 parent b8e9784 commit 39c951c

1 file changed

Lines changed: 85 additions & 82 deletions

File tree

layers/gpu_dump/gpu_dump_descriptor.cpp

Lines changed: 85 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,8 @@ void CommandBufferSubState::DumpDescriptorHeap(std::ostringstream& ss, const Las
285285
void Print(const CommandBufferSubState& cb_sub_state, std::ostringstream& map_ss, const VkPhysicalDevice physical_device) {
286286
map_ss << " - Binding " << std::dec << resource_variable->decorations.binding << ", "
287287
<< string_VkDescriptorMappingSourceEXT(mapping->source) << " (from pMappings[" << mapping_index << "])\n";
288-
// TODO - should print both here
289-
const bool is_sampler = resource_variable->is_combined_image_sampler;
288+
const bool is_combined_image_sampler = resource_variable->is_combined_image_sampler;
289+
const char* main_heap_type = resource_variable->is_sampler ? "Sampler" : "Resource";
290290
const bool is_array = resource_variable->IsArray();
291291
uint32_t array_length = 0;
292292
if (is_array && !resource_variable->IsRuntimeArray() && resource_variable->array_length != spirv::kSpecConstant) {
@@ -308,10 +308,23 @@ void CommandBufferSubState::DumpDescriptorHeap(std::ostringstream& ss, const Las
308308
vvl::CommandBuffer::DescriptorHeap& heap = cb_sub_state.base.descriptor_heap;
309309
if (mapping->source == VK_DESCRIPTOR_MAPPING_SOURCE_HEAP_WITH_CONSTANT_OFFSET_EXT) {
310310
const VkDescriptorMappingSourceConstantOffsetEXT& map_data = mapping->sourceData.constantOffset;
311-
if (is_sampler) {
312-
map_ss << "samplerHeapOffset: 0x" << std::hex << map_data.samplerHeapOffset << ", samplerHeapArrayStride: 0x"
313-
<< map_data.samplerHeapArrayStride;
314-
map_ss << "\n Heap address: 0x" << heap.sampler_range.begin + map_data.samplerHeapOffset;
311+
312+
map_ss << "heapOffset: 0x" << std::hex << map_data.heapOffset << ", heapArrayStride: 0x"
313+
<< map_data.heapArrayStride;
314+
map_ss << "\n " << main_heap_type << " Heap address: 0x" << heap.resource_range.begin + map_data.heapOffset;
315+
if (is_array) {
316+
map_ss << " + (descriptor_index * 0x" << map_data.heapArrayStride << ")";
317+
if (array_length != 0) {
318+
warn_index_oob = ((map_data.heapOffset + ((array_length - 1) * map_data.heapArrayStride) +
319+
descriptor_size) > heap.resource_range.size());
320+
}
321+
}
322+
warn_oob |= (map_data.heapOffset + descriptor_size > heap.resource_range.size());
323+
324+
if (is_combined_image_sampler) {
325+
map_ss << "\n samplerHeapOffset: 0x" << std::hex << map_data.samplerHeapOffset
326+
<< ", samplerHeapArrayStride: 0x" << map_data.samplerHeapArrayStride;
327+
map_ss << "\n Sampler Heap address: 0x" << heap.sampler_range.begin + map_data.samplerHeapOffset;
315328
if (is_array) {
316329
map_ss << " + (descriptor_index * 0x" << map_data.samplerHeapArrayStride << ")";
317330
if (array_length != 0) {
@@ -320,30 +333,37 @@ void CommandBufferSubState::DumpDescriptorHeap(std::ostringstream& ss, const Las
320333
}
321334
}
322335
warn_oob |= (map_data.samplerHeapOffset + descriptor_size > heap.sampler_range.size());
323-
} else {
324-
map_ss << "heapOffset: 0x" << std::hex << map_data.heapOffset << ", heapArrayStride: 0x"
325-
<< map_data.heapArrayStride;
326-
map_ss << "\n Heap address: 0x" << heap.resource_range.begin + map_data.heapOffset;
327-
if (is_array) {
328-
map_ss << " + (descriptor_index * 0x" << map_data.heapArrayStride << ")";
329-
if (array_length != 0) {
330-
warn_index_oob = ((map_data.heapOffset + ((array_length - 1) * map_data.heapArrayStride) +
331-
descriptor_size) > heap.resource_range.size());
332-
}
333-
}
334-
warn_oob |= (map_data.heapOffset + descriptor_size > heap.resource_range.size());
335336
}
336337
} else if (mapping->source == VK_DESCRIPTOR_MAPPING_SOURCE_HEAP_WITH_PUSH_INDEX_EXT) {
337338
const VkDescriptorMappingSourcePushIndexEXT& map_data = mapping->sourceData.pushIndex;
338339
uint32_t push_index = *((uint32_t*)&cb_sub_state.push_data_value[map_data.pushOffset]);
339340

340-
if (is_sampler) {
341-
map_ss << "pushOffset: 0x" << std::hex << map_data.pushOffset << ", samplerHeapOffset: 0x"
341+
map_ss << "pushOffset: 0x" << std::hex << map_data.pushOffset << ", heapOffset: 0x" << map_data.heapOffset
342+
<< ", heapIndexStride: 0x" << map_data.heapIndexStride << ", heapArrayStride: 0x"
343+
<< map_data.heapArrayStride;
344+
map_ss << "\n pushIndex: 0x" << push_index;
345+
map_ss << "\n " << main_heap_type << " Heap address: 0x" << heap.resource_range.begin + map_data.heapOffset
346+
<< " + (0x" << push_index << " * 0x" << map_data.heapIndexStride << ")";
347+
if (is_array) {
348+
map_ss << " + (descriptor_index * 0x" << map_data.heapArrayStride << ")";
349+
if (array_length != 0) {
350+
warn_index_oob = ((map_data.heapOffset + ((array_length - 1) * map_data.heapArrayStride) +
351+
descriptor_size) > heap.resource_range.size());
352+
}
353+
} else {
354+
uint64_t final_offset = map_data.heapOffset + (push_index * map_data.heapIndexStride);
355+
map_ss << " [final address 0x" << (heap.resource_range.begin + final_offset) << "]";
356+
warn_oob |= (final_offset + descriptor_size > heap.resource_range.size());
357+
}
358+
warn_oob |= (map_data.heapOffset + descriptor_size > heap.resource_range.size());
359+
360+
if (is_combined_image_sampler) {
361+
map_ss << "\n pushOffset: 0x" << std::hex << map_data.pushOffset << ", samplerHeapOffset: 0x"
342362
<< map_data.samplerHeapOffset << ", samplerHeapIndexStride: 0x" << map_data.samplerHeapIndexStride
343363
<< ", samplerHeapArrayStride: 0x" << map_data.samplerHeapArrayStride;
344364
map_ss << "\n pushIndex: 0x" << push_index;
345-
map_ss << "\n Heap address: 0x" << heap.sampler_range.begin + map_data.samplerHeapOffset << " + (0x"
346-
<< push_index << " * 0x" << map_data.samplerHeapIndexStride << ")";
365+
map_ss << "\n Sampler Heap address: 0x" << heap.sampler_range.begin + map_data.samplerHeapOffset
366+
<< " + (0x" << push_index << " * 0x" << map_data.samplerHeapIndexStride << ")";
347367
if (is_array) {
348368
map_ss << " + (descriptor_index * 0x" << map_data.samplerHeapArrayStride << ")";
349369
if (array_length != 0) {
@@ -356,36 +376,33 @@ void CommandBufferSubState::DumpDescriptorHeap(std::ostringstream& ss, const Las
356376
warn_oob |= (final_offset + descriptor_size > heap.sampler_range.size());
357377
}
358378
warn_oob |= (map_data.samplerHeapOffset + descriptor_size > heap.sampler_range.size());
359-
} else {
360-
map_ss << "pushOffset: 0x" << std::hex << map_data.pushOffset << ", heapOffset: 0x" << map_data.heapOffset
361-
<< ", heapIndexStride: 0x" << map_data.heapIndexStride << ", heapArrayStride: 0x"
362-
<< map_data.heapArrayStride;
363-
map_ss << "\n pushIndex: 0x" << push_index;
364-
map_ss << "\n Heap address: 0x" << heap.resource_range.begin + map_data.heapOffset << " + (0x"
365-
<< push_index << " * 0x" << map_data.heapIndexStride << ")";
366-
if (is_array) {
367-
map_ss << " + (descriptor_index * 0x" << map_data.heapArrayStride << ")";
368-
if (array_length != 0) {
369-
warn_index_oob = ((map_data.heapOffset + ((array_length - 1) * map_data.heapArrayStride) +
370-
descriptor_size) > heap.resource_range.size());
371-
}
372-
} else {
373-
uint64_t final_offset = map_data.heapOffset + (push_index * map_data.heapIndexStride);
374-
map_ss << " [final address 0x" << (heap.resource_range.begin + final_offset) << "]";
375-
warn_oob |= (final_offset + descriptor_size > heap.resource_range.size());
376-
}
377-
warn_oob |= (map_data.heapOffset + descriptor_size > heap.resource_range.size());
378379
}
379380
} else if (mapping->source == VK_DESCRIPTOR_MAPPING_SOURCE_HEAP_WITH_INDIRECT_INDEX_EXT) {
380381
const VkDescriptorMappingSourceIndirectIndexEXT& map_data = mapping->sourceData.indirectIndex;
381382
uint64_t indirect_address = *((uint64_t*)&cb_sub_state.push_data_value[map_data.pushOffset]);
382383

383-
if (is_sampler) {
384-
map_ss << "pushOffset: 0x" << std::hex << map_data.pushOffset << ", addressOffset: 0x" << map_data.addressOffset
385-
<< ", samplerHeapOffset: 0x" << map_data.samplerHeapOffset << ", samplerHeapIndexStride: 0x"
386-
<< map_data.samplerHeapIndexStride << ", samplerHeapArrayStride: 0x" << map_data.samplerHeapArrayStride;
384+
map_ss << "pushOffset: 0x" << std::hex << map_data.pushOffset << ", addressOffset: 0x" << map_data.addressOffset
385+
<< ", heapOffset: 0x" << map_data.heapOffset << ", heapIndexStride: 0x" << map_data.heapIndexStride
386+
<< ", heapArrayStride: 0x" << map_data.heapArrayStride;
387+
map_ss << "\n indirectAddress: 0x" << indirect_address;
388+
map_ss << "\n " << main_heap_type << " Heap address: 0x" << heap.resource_range.begin + map_data.heapOffset
389+
<< " + (indirectIndex * 0x" << map_data.heapIndexStride << ")";
390+
if (is_array) {
391+
map_ss << " + (descriptor_index * 0x" << map_data.heapArrayStride << ")";
392+
if (array_length != 0) {
393+
warn_index_oob = ((map_data.heapOffset + ((array_length - 1) * map_data.heapArrayStride) +
394+
descriptor_size) > heap.resource_range.size());
395+
}
396+
}
397+
warn_oob |= (map_data.heapOffset + descriptor_size > heap.resource_range.size());
398+
399+
if (is_combined_image_sampler) {
400+
map_ss << "\n pushOffset: 0x" << std::hex << map_data.pushOffset << ", addressOffset: 0x"
401+
<< map_data.addressOffset << ", samplerHeapOffset: 0x" << map_data.samplerHeapOffset
402+
<< ", samplerHeapIndexStride: 0x" << map_data.samplerHeapIndexStride << ", samplerHeapArrayStride: 0x"
403+
<< map_data.samplerHeapArrayStride;
387404
map_ss << "\n indirectAddress: 0x" << indirect_address;
388-
map_ss << "\n Heap address: 0x" << heap.sampler_range.begin + map_data.samplerHeapOffset
405+
map_ss << "\n Sampler Heap address: 0x" << heap.sampler_range.begin + map_data.samplerHeapOffset
389406
<< " + (indirectIndex * 0x" << map_data.samplerHeapIndexStride << ")";
390407
if (is_array) {
391408
map_ss << " + (descriptor_index * 0x" << map_data.samplerHeapArrayStride << ")";
@@ -395,49 +412,35 @@ void CommandBufferSubState::DumpDescriptorHeap(std::ostringstream& ss, const Las
395412
}
396413
}
397414
warn_oob |= (map_data.samplerHeapOffset + descriptor_size > heap.sampler_range.size());
398-
} else {
399-
map_ss << "pushOffset: 0x" << std::hex << map_data.pushOffset << ", addressOffset: 0x" << map_data.addressOffset
400-
<< ", heapOffset: 0x" << map_data.heapOffset << ", heapIndexStride: 0x" << map_data.heapIndexStride
401-
<< ", heapArrayStride: 0x" << map_data.heapArrayStride;
402-
map_ss << "\n indirectAddress: 0x" << indirect_address;
403-
map_ss << "\n Heap address: 0x" << heap.resource_range.begin + map_data.heapOffset
404-
<< " + (indirectIndex * 0x" << map_data.heapIndexStride << ")";
405-
if (is_array) {
406-
map_ss << " + (descriptor_index * 0x" << map_data.heapArrayStride << ")";
407-
if (array_length != 0) {
408-
warn_index_oob = ((map_data.heapOffset + ((array_length - 1) * map_data.heapArrayStride) +
409-
descriptor_size) > heap.resource_range.size());
410-
}
411-
}
412-
warn_oob |= (map_data.heapOffset + descriptor_size > heap.resource_range.size());
413415
}
414416
} else if (mapping->source == VK_DESCRIPTOR_MAPPING_SOURCE_HEAP_WITH_INDIRECT_INDEX_ARRAY_EXT) {
415417
const VkDescriptorMappingSourceIndirectIndexArrayEXT& map_data = mapping->sourceData.indirectIndexArray;
416418
uint64_t indirect_address = *((uint64_t*)&cb_sub_state.push_data_value[map_data.pushOffset]);
417419

418-
if (is_sampler) {
419-
map_ss << "pushOffset: 0x" << std::hex << map_data.pushOffset << ", addressOffset: 0x" << map_data.addressOffset
420-
<< ", samplerHeapOffset: 0x" << map_data.samplerHeapOffset << ", samplerHeapIndexStride: 0x"
421-
<< map_data.samplerHeapIndexStride;
420+
map_ss << "pushOffset: 0x" << std::hex << map_data.pushOffset << ", addressOffset: 0x" << map_data.addressOffset
421+
<< ", heapOffset: 0x" << map_data.heapOffset << ", heapIndexStride: 0x" << map_data.heapIndexStride;
422+
map_ss << "\n indirectAddress: 0x" << indirect_address;
423+
map_ss << "\n " << main_heap_type << " Heap address: 0x" << heap.resource_range.begin + map_data.heapOffset
424+
<< " + (indirectIndex * 0x" << map_data.heapIndexStride << ")";
425+
warn_oob |= (map_data.heapOffset + descriptor_size > heap.resource_range.size());
426+
427+
if (is_combined_image_sampler) {
428+
map_ss << "\n pushOffset: 0x" << std::hex << map_data.pushOffset << ", addressOffset: 0x"
429+
<< map_data.addressOffset << ", samplerHeapOffset: 0x" << map_data.samplerHeapOffset
430+
<< ", samplerHeapIndexStride: 0x" << map_data.samplerHeapIndexStride;
422431
map_ss << "\n indirectAddress: 0x" << indirect_address;
423-
map_ss << "\n Heap address: 0x" << heap.sampler_range.begin + map_data.samplerHeapOffset
432+
map_ss << "\n Sampler Heap address: 0x" << heap.sampler_range.begin + map_data.samplerHeapOffset
424433
<< " + (indirectIndex * 0x" << map_data.samplerHeapIndexStride << ")";
425434
warn_oob |= (map_data.samplerHeapOffset + descriptor_size > heap.sampler_range.size());
426-
} else {
427-
map_ss << "pushOffset: 0x" << std::hex << map_data.pushOffset << ", addressOffset: 0x" << map_data.addressOffset
428-
<< ", heapOffset: 0x" << map_data.heapOffset << ", heapIndexStride: 0x" << map_data.heapIndexStride;
429-
map_ss << "\n indirectAddress: 0x" << indirect_address;
430-
map_ss << "\n Heap address: 0x" << heap.resource_range.begin + map_data.heapOffset
431-
<< " + (indirectIndex * 0x" << map_data.heapIndexStride << ")";
432-
warn_oob |= (map_data.heapOffset + descriptor_size > heap.resource_range.size());
433435
}
434436
} else if (mapping->source == VK_DESCRIPTOR_MAPPING_SOURCE_RESOURCE_HEAP_DATA_EXT) {
435437
const VkDescriptorMappingSourceHeapDataEXT& map_data = mapping->sourceData.heapData;
436438
uint32_t push_data = *((uint32_t*)&cb_sub_state.push_data_value[map_data.pushOffset]);
437439

438440
map_ss << "pushOffset: 0x" << std::hex << map_data.pushOffset << ", heapOffset: 0x" << map_data.heapOffset;
439441
map_ss << "\n Push data at 0x" << std::hex << map_data.pushOffset << ": 0x" << push_data;
440-
map_ss << "\n Heap address: 0x" << heap.resource_range.begin + map_data.heapOffset << " + 0x" << push_data;
442+
map_ss << "\n " << main_heap_type << " Heap address: 0x" << heap.resource_range.begin + map_data.heapOffset
443+
<< " + 0x" << push_data;
441444
uint64_t final_offset = map_data.heapOffset + push_data;
442445
map_ss << " [final address 0x" << (heap.resource_range.begin + final_offset) << "]";
443446
warn_oob |= (final_offset + descriptor_size > heap.resource_range.size());
@@ -455,14 +458,14 @@ void CommandBufferSubState::DumpDescriptorHeap(std::ostringstream& ss, const Las
455458
} else if (mapping->source == VK_DESCRIPTOR_MAPPING_SOURCE_HEAP_WITH_SHADER_RECORD_INDEX_EXT) {
456459
// TODO - Add address for RTX
457460
const VkDescriptorMappingSourceShaderRecordIndexEXT& map_data = mapping->sourceData.shaderRecordIndex;
458-
if (is_sampler) {
459-
map_ss << "samplerHeapOffset: 0x" << std::hex << map_data.samplerHeapOffset << ", samplerShaderRecordOffset: 0x"
460-
<< map_data.samplerShaderRecordOffset << ", samplerHeapIndexStride: 0x"
461-
<< map_data.samplerHeapIndexStride << ", samplerHeapArrayStride: 0x" << map_data.samplerHeapArrayStride;
462-
} else {
463-
map_ss << "heapOffset: 0x" << std::hex << map_data.heapOffset << ", shaderRecordOffset: 0x"
464-
<< map_data.shaderRecordOffset << ", heapIndexStride: 0x" << map_data.heapIndexStride
465-
<< ", heapArrayStride: 0x" << map_data.heapArrayStride;
461+
map_ss << "heapOffset: 0x" << std::hex << map_data.heapOffset << ", shaderRecordOffset: 0x"
462+
<< map_data.shaderRecordOffset << ", heapIndexStride: 0x" << map_data.heapIndexStride
463+
<< ", heapArrayStride: 0x" << map_data.heapArrayStride;
464+
if (is_combined_image_sampler) {
465+
map_ss << "\n samplerHeapOffset: 0x" << std::hex << map_data.samplerHeapOffset
466+
<< ", samplerShaderRecordOffset: 0x" << map_data.samplerShaderRecordOffset
467+
<< ", samplerHeapIndexStride: 0x" << map_data.samplerHeapIndexStride << ", samplerHeapArrayStride: 0x"
468+
<< map_data.samplerHeapArrayStride;
466469
}
467470
} else if (mapping->source == VK_DESCRIPTOR_MAPPING_SOURCE_SHADER_RECORD_DATA_EXT) {
468471
// TODO - Add more info probably

0 commit comments

Comments
 (0)