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.
This commit is contained in:
baldurk
2020-04-09 13:42:24 +01:00
parent 73c05536e0
commit 70f409588c
4 changed files with 64 additions and 36 deletions
+56
View File
@@ -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
@@ -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);
}
+4 -4
View File
@@ -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.
+1 -29
View File
@@ -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<BindIdx> used;
rdcarray<BindpointIndex> used;
};
enum TexDisplayFlags