From 70f409588c00f8c395b28e0b0aae5cd78ea74f2e Mon Sep 17 00:00:00 2001 From: baldurk Date: Thu, 9 Apr 2020 13:42:24 +0100 Subject: [PATCH] Add type to refer to a specific Bindpoint's element * This is very similar to Bindpoint but where that *declares* a binding with a given array size, this refers to a specific element within a (possibly arrayed) bindpoint. --- renderdoc/api/replay/shader_types.h | 56 +++++++++++++++++++ .../driver/vulkan/vk_bindless_feedback.cpp | 6 +- renderdoc/driver/vulkan/vk_replay.cpp | 8 +-- renderdoc/driver/vulkan/vk_replay.h | 30 +--------- 4 files changed, 64 insertions(+), 36 deletions(-) diff --git a/renderdoc/api/replay/shader_types.h b/renderdoc/api/replay/shader_types.h index 49f063c60..0c206647e 100644 --- a/renderdoc/api/replay/shader_types.h +++ b/renderdoc/api/replay/shader_types.h @@ -1286,6 +1286,62 @@ struct Bindpoint DECLARE_REFLECTION_STRUCT(Bindpoint); +DOCUMENT("References a particular element in a :class:`Bindpoint`."); +struct BindpointIndex +{ + DOCUMENT(""); + BindpointIndex() + { + bindset = 0; + bind = 0; + arrayIndex = 0; + } + BindpointIndex(const BindpointIndex &) = default; + BindpointIndex &operator=(const BindpointIndex &) = default; + + BindpointIndex(int32_t s, int32_t b) + { + bindset = s; + bind = b; + arrayIndex = 0; + } + BindpointIndex(int32_t s, int32_t b, uint32_t a) + { + bindset = s; + bind = b; + arrayIndex = a; + } + + bool operator<(const BindpointIndex &o) const + { + if(!(bindset == o.bindset)) + return bindset < o.bindset; + if(!(bind == o.bind)) + return bind < o.bind; + return arrayIndex < o.arrayIndex; + } + bool operator>(const BindpointIndex &o) const + { + if(!(bindset == o.bindset)) + return bindset > o.bindset; + if(!(bind == o.bind)) + return bind > o.bind; + return arrayIndex > o.arrayIndex; + } + bool operator==(const BindpointIndex &o) const + { + return bindset == o.bindset && bind == o.bind && arrayIndex == o.arrayIndex; + } + DOCUMENT("The binding set."); + int32_t bindset; + DOCUMENT("The binding index."); + int32_t bind; + DOCUMENT("If this is an arrayed binding, the element in the array being referenced."); + uint32_t arrayIndex; +}; + +DECLARE_REFLECTION_STRUCT(BindpointIndex); + DOCUMENT(R"(This structure goes hand in hand with :class:`ShaderReflection` to determine how to map from bindpoint indices in the resource lists there to API-specific binding points. The ``bindPoint`` member in :class:`ShaderResource` or :class:`ConstantBlock` refers to an index in these associated diff --git a/renderdoc/driver/vulkan/vk_bindless_feedback.cpp b/renderdoc/driver/vulkan/vk_bindless_feedback.cpp index a2f61d2af..81e9c49e6 100644 --- a/renderdoc/driver/vulkan/vk_bindless_feedback.cpp +++ b/renderdoc/driver/vulkan/vk_bindless_feedback.cpp @@ -884,15 +884,15 @@ void VulkanReplay::FetchShaderFeedback(uint32_t eventId) { uint32_t *feedbackData = (uint32_t *)(data.data() + it->second.offset); - BindIdx used; - used.set = it->first.set; + BindpointIndex used; + used.bindset = it->first.set; used.bind = it->first.binding; for(uint32_t i = 0; i < it->second.numEntries; i++) { if(feedbackData[i]) { - used.arrayidx = i; + used.arrayIndex = i; result.used.push_back(used); } diff --git a/renderdoc/driver/vulkan/vk_replay.cpp b/renderdoc/driver/vulkan/vk_replay.cpp index 4cabb709c..95d1a6c01 100644 --- a/renderdoc/driver/vulkan/vk_replay.cpp +++ b/renderdoc/driver/vulkan/vk_replay.cpp @@ -1543,7 +1543,7 @@ void VulkanReplay::SavePipelineState(uint32_t eventId) for(size_t p = 0; p < ARRAY_COUNT(srcs); p++) { bool hasUsedBinds = false; - const BindIdx *usedBindsData = NULL; + const BindpointIndex *usedBindsData = NULL; size_t usedBindsSize = 0; { @@ -1573,14 +1573,14 @@ void VulkanReplay::SavePipelineState(uint32_t eventId) } } - BindIdx curBind; + BindpointIndex curBind; for(size_t i = 0; i < srcs[p]->size(); i++) { ResourceId src = (*srcs[p])[i].descSet; VKPipe::DescriptorSet &dst = (*dsts[p])[i]; - curBind.set = (uint32_t)i; + curBind.bindset = (uint32_t)i; ResourceId layoutId = m_pDriver->m_DescriptorSetState[src].layout; @@ -1652,7 +1652,7 @@ void VulkanReplay::SavePipelineState(uint32_t eventId) { VKPipe::BindingElement &dstel = dst.bindings[b].binds[a]; - curBind.arrayidx = a; + curBind.arrayIndex = a; // if we have a list of used binds, and this is an array descriptor (so would be // expected to be in the list), check it for dynamic usage. diff --git a/renderdoc/driver/vulkan/vk_replay.h b/renderdoc/driver/vulkan/vk_replay.h index 39ba59b01..2e0ef6acf 100644 --- a/renderdoc/driver/vulkan/vk_replay.h +++ b/renderdoc/driver/vulkan/vk_replay.h @@ -197,38 +197,10 @@ struct VulkanPostVSData } }; -struct BindIdx -{ - uint32_t set, bind, arrayidx; - - bool operator<(const BindIdx &o) const - { - if(set != o.set) - return set < o.set; - else if(bind != o.bind) - return bind < o.bind; - return arrayidx < o.arrayidx; - } - - bool operator>(const BindIdx &o) const - { - if(set != o.set) - return set > o.set; - else if(bind != o.bind) - return bind > o.bind; - return arrayidx > o.arrayidx; - } - - bool operator==(const BindIdx &o) const - { - return set == o.set && bind == o.bind && arrayidx == o.arrayidx; - } -}; - struct DynamicUsedBinds { bool compute = false, valid = false; - rdcarray used; + rdcarray used; }; enum TexDisplayFlags