From 7fcf64a562e4f94c8b17dce0cae616c792ff124f Mon Sep 17 00:00:00 2001 From: baldurk Date: Fri, 31 Jan 2025 14:11:02 +0000 Subject: [PATCH] Add query for per-thread properties when shader debugging * This is distinct from input values or builtins because they're entirely internal for configuring the workgroup --- renderdoc/driver/shaders/spirv/spirv_debug.h | 14 ++++++++++++++ renderdoc/driver/vulkan/vk_shaderdebug.cpp | 12 ++++++++++++ 2 files changed, 26 insertions(+) diff --git a/renderdoc/driver/shaders/spirv/spirv_debug.h b/renderdoc/driver/shaders/spirv/spirv_debug.h index 70d40259c..7b00b463e 100644 --- a/renderdoc/driver/shaders/spirv/spirv_debug.h +++ b/renderdoc/driver/shaders/spirv/spirv_debug.h @@ -44,6 +44,18 @@ enum class GatherChannel : uint8_t Alpha = 3, }; +enum class ThreadProperty : uint32_t +{ + Helper, + QuadId, + QuadLane, + Active, + Elected, + Count, +}; + +ITERABLE_OPERATORS(ThreadProperty); + struct ThreadState; class DebugAPIWrapper @@ -72,6 +84,8 @@ public: virtual void FillInputValue(ShaderVariable &var, ShaderBuiltin builtin, uint32_t threadIndex, uint32_t location, uint32_t component) = 0; + virtual uint32_t GetThreadProperty(uint32_t threadIndex, ThreadProperty prop) = 0; + enum TextureType { Float_Texture = 0x00, diff --git a/renderdoc/driver/vulkan/vk_shaderdebug.cpp b/renderdoc/driver/vulkan/vk_shaderdebug.cpp index 583084dd9..751ec22e3 100644 --- a/renderdoc/driver/vulkan/vk_shaderdebug.cpp +++ b/renderdoc/driver/vulkan/vk_shaderdebug.cpp @@ -544,6 +544,16 @@ public: threadIndex, location, component); } + uint32_t GetThreadProperty(uint32_t threadIndex, rdcspv::ThreadProperty prop) override + { + if(prop >= rdcspv::ThreadProperty::Count) + return 0; + if(threadIndex >= thread_props.size()) + return 0; + + return thread_props[threadIndex][(size_t)prop]; + } + bool CalculateSampleGather(rdcspv::ThreadState &lane, rdcspv::Op opcode, DebugAPIWrapper::TextureType texType, ShaderBindIndex imageBind, ShaderBindIndex samplerBind, const ShaderVariable &uv, @@ -1456,6 +1466,8 @@ public: // per-thread custom inputs by location [thread][location] rdcarray> location_inputs; + rdcarray()>> thread_props; + private: WrappedVulkan *m_pDriver = NULL; ShaderDebugData &m_DebugData;