Skip to content

Commit cc0e7cb

Browse files
layers: Upstream misc DebugDescriptor
1 parent 4be46d8 commit cc0e7cb

4 files changed

Lines changed: 79 additions & 60 deletions

File tree

layers/gpu_dump/gpu_dump_descriptor.cpp

Lines changed: 1 addition & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
* limitations under the License.
1515
*/
1616

17-
#include "containers/custom_containers.h"
1817
#include "containers/limits.h"
1918
#include "gpu_dump_state.h"
2019
#include "gpu_dump.h"
@@ -36,66 +35,10 @@
3635
#include "state_tracker/shader_object_state.h"
3736
#include "state_tracker/shader_stage_state.h"
3837
#include "state_tracker/state_tracker.h"
38+
#include "utils/vk_api_utils.h"
3939

4040
namespace gpudump {
4141

42-
static size_t GetDescriptorBufferSize(const VkPhysicalDeviceDescriptorBufferPropertiesEXT& props, bool robust,
43-
VkDescriptorType type) {
44-
switch (type) {
45-
case VK_DESCRIPTOR_TYPE_SAMPLER:
46-
return props.samplerDescriptorSize;
47-
case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
48-
return props.combinedImageSamplerDescriptorSize;
49-
case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
50-
return props.sampledImageDescriptorSize;
51-
case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
52-
return props.storageImageDescriptorSize;
53-
case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
54-
return robust ? props.robustUniformTexelBufferDescriptorSize : props.uniformTexelBufferDescriptorSize;
55-
case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
56-
return robust ? props.robustStorageTexelBufferDescriptorSize : props.storageTexelBufferDescriptorSize;
57-
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
58-
return robust ? props.robustUniformBufferDescriptorSize : props.uniformBufferDescriptorSize;
59-
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
60-
return robust ? props.robustStorageBufferDescriptorSize : props.storageBufferDescriptorSize;
61-
case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
62-
return props.inputAttachmentDescriptorSize;
63-
case VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR:
64-
return props.accelerationStructureDescriptorSize;
65-
default:
66-
break;
67-
}
68-
return 0;
69-
}
70-
71-
static const char* DescribeDescriptorBufferSize(bool robust, VkDescriptorType type) {
72-
switch (type) {
73-
case VK_DESCRIPTOR_TYPE_SAMPLER:
74-
return "samplerDescriptorSize";
75-
case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
76-
return "combinedImageSamplerDescriptorSize";
77-
case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
78-
return "sampledImageDescriptorSize";
79-
case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
80-
return "storageImageDescriptorSize";
81-
case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
82-
return robust ? "robustUniformTexelBufferDescriptorSize" : "uniformTexelBufferDescriptorSize";
83-
case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
84-
return robust ? "robustStorageTexelBufferDescriptorSize" : "storageTexelBufferDescriptorSize";
85-
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
86-
return robust ? "robustUniformBufferDescriptorSize" : "uniformBufferDescriptorSize";
87-
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
88-
return robust ? "robustStorageBufferDescriptorSize" : "storageBufferDescriptorSize";
89-
case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
90-
return "inputAttachmentDescriptorSize";
91-
case VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR:
92-
return "accelerationStructureDescriptorSize";
93-
default:
94-
break;
95-
}
96-
return "[Unknown]";
97-
}
98-
9942
void CommandBufferSubState::DumpDescriptorBuffer(std::ostringstream& ss, const LastBound& last_bound) const {
10043
const vvl::CommandBuffer& cb_state = last_bound.cb_state;
10144
ss << "vkCmdBindDescriptorBuffersEXT last bound the following descriptor buffers:\n";

layers/gpuav/core/gpuav_setup.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,17 @@ struct RayTracingBuffersConsistency : public Setting {
438438
"gpuav_ray_tracing_buffers_consistency]\n";
439439
}
440440
};
441+
442+
struct DebugDescriptor : public Setting {
443+
bool IsEnabled(const GpuAVSettings& settings) { return settings.debug_descriptor_enabled; }
444+
bool HasRequiredFeatures(const DeviceFeatures& features) { return features.shaderInt64; }
445+
void Disable(GpuAVSettings& settings) { settings.debug_descriptor_enabled = false; }
446+
std::string DisableMessage() {
447+
return "\tDebug Descriptor option was enabled, but the shaderInt64 feature is not supported. [Disabling "
448+
"debug_descriptor]\n";
449+
}
450+
};
451+
441452
} // namespace setting
442453

443454
// At this point extensions/features may have been turned on by us in PreCallRecord.
@@ -451,8 +462,10 @@ void Validator::InitSettings(const Location& loc) {
451462
setting::BufferContent buffer_content;
452463
setting::AccelerationStructuresBuild as_builds;
453464
setting::RayTracingBuffersConsistency rt_buffers_consistency;
454-
std::array<setting::Setting*, 8> all_settings = {&buffer_device_address, &ray_query, &trace_ray, &mesh_shading,
455-
&buffer_copies, &buffer_content, &as_builds, &rt_buffers_consistency};
465+
setting::DebugDescriptor debug_descriptor;
466+
std::array<setting::Setting*, 9> all_settings = {&buffer_device_address, &ray_query, &trace_ray, &mesh_shading,
467+
&buffer_copies, &buffer_content, &as_builds, &rt_buffers_consistency,
468+
&debug_descriptor};
456469

457470
std::string adjustment_warnings;
458471
for (auto& setting_object : all_settings) {

layers/gpuav/spirv/debug_descriptor_pass.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ void DebugDescriptorPass::CreateFunctionCall(BasicBlock& block, InstructionIt* i
5050
}
5151

5252
bool DebugDescriptorPass::Instrument() {
53+
if (module_.interface_.descriptor_mode != vvl::DescriptorModeBuffer &&
54+
module_.interface_.descriptor_mode != vvl::DescriptorModeHeap) {
55+
return false;
56+
}
57+
5358
for (const auto& inst : module_.ext_inst_imports_) {
5459
const char* import_string = inst->GetAsString(2);
5560
if (strcmp(import_string, "NonSemantic.DebugDescriptor") == 0) {

layers/utils/vk_api_utils.h

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
// This file should not need to include anything else, the goal of this file is utils that "could" be in the Vulkan-Headers
2323
#include <vulkan/vulkan_core.h>
24+
#include <vulkan/utility/vk_struct_helper.hpp>
2425

2526
// It is very rare to have more than 3 stages (really only geo/tess) and better to save memory/time for the 99% use cases
2627
static const uint32_t kCommonMaxGraphicsShaderStages = 3;
@@ -209,3 +210,60 @@ static constexpr bool IsDescriptorHeapImage(const VkDescriptorType type) {
209210
static constexpr bool IsDescriptorHeapTensor(const VkDescriptorType type) {
210211
return (type == VK_DESCRIPTOR_TYPE_TENSOR_ARM);
211212
}
213+
214+
static inline size_t GetDescriptorBufferSize(const VkPhysicalDeviceDescriptorBufferPropertiesEXT& props, bool robust,
215+
VkDescriptorType type) {
216+
switch (type) {
217+
case VK_DESCRIPTOR_TYPE_SAMPLER:
218+
return props.samplerDescriptorSize;
219+
case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
220+
return props.combinedImageSamplerDescriptorSize;
221+
case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
222+
return props.sampledImageDescriptorSize;
223+
case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
224+
return props.storageImageDescriptorSize;
225+
case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
226+
return robust ? props.robustUniformTexelBufferDescriptorSize : props.uniformTexelBufferDescriptorSize;
227+
case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
228+
return robust ? props.robustStorageTexelBufferDescriptorSize : props.storageTexelBufferDescriptorSize;
229+
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
230+
return robust ? props.robustUniformBufferDescriptorSize : props.uniformBufferDescriptorSize;
231+
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
232+
return robust ? props.robustStorageBufferDescriptorSize : props.storageBufferDescriptorSize;
233+
case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
234+
return props.inputAttachmentDescriptorSize;
235+
case VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR:
236+
return props.accelerationStructureDescriptorSize;
237+
default:
238+
break;
239+
}
240+
return 0;
241+
}
242+
243+
static inline const char* DescribeDescriptorBufferSize(bool robust, VkDescriptorType type) {
244+
switch (type) {
245+
case VK_DESCRIPTOR_TYPE_SAMPLER:
246+
return "samplerDescriptorSize";
247+
case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
248+
return "combinedImageSamplerDescriptorSize";
249+
case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
250+
return "sampledImageDescriptorSize";
251+
case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
252+
return "storageImageDescriptorSize";
253+
case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
254+
return robust ? "robustUniformTexelBufferDescriptorSize" : "uniformTexelBufferDescriptorSize";
255+
case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
256+
return robust ? "robustStorageTexelBufferDescriptorSize" : "storageTexelBufferDescriptorSize";
257+
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
258+
return robust ? "robustUniformBufferDescriptorSize" : "uniformBufferDescriptorSize";
259+
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
260+
return robust ? "robustStorageBufferDescriptorSize" : "storageBufferDescriptorSize";
261+
case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
262+
return "inputAttachmentDescriptorSize";
263+
case VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR:
264+
return "accelerationStructureDescriptorSize";
265+
default:
266+
break;
267+
}
268+
return "[Unknown]";
269+
}

0 commit comments

Comments
 (0)