mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-12-12 22:08:59 +01:00
[dxvk] Order descriptors by type and binding
Reduces the number of unique descriptor set layouts further, which may help with descriptor pool usage, and also makes branching more predictable for the CPU.
This commit is contained in:
parent
1fcd5dc0af
commit
d6253aeae6
@ -25,19 +25,8 @@ namespace dxvk {
|
||||
}
|
||||
|
||||
|
||||
bool DxvkBindingInfo::canMerge(const DxvkBindingInfo& binding) const {
|
||||
if ((stages & VK_SHADER_STAGE_FRAGMENT_BIT) != (binding.stages & VK_SHADER_STAGE_FRAGMENT_BIT))
|
||||
return false;
|
||||
|
||||
return descriptorType == binding.descriptorType
|
||||
&& resourceBinding == binding.resourceBinding
|
||||
&& viewType == binding.viewType;
|
||||
}
|
||||
|
||||
|
||||
void DxvkBindingInfo::merge(const DxvkBindingInfo& binding) {
|
||||
stages |= binding.stages;
|
||||
access |= binding.access;
|
||||
uint32_t DxvkBindingInfo::value() const {
|
||||
return (uint32_t(descriptorType) << 24) | resourceBinding;
|
||||
}
|
||||
|
||||
|
||||
@ -72,14 +61,12 @@ namespace dxvk {
|
||||
|
||||
|
||||
void DxvkBindingList::addBinding(const DxvkBindingInfo& binding) {
|
||||
for (auto& b : m_bindings) {
|
||||
if (b.canMerge(binding)) {
|
||||
b.merge(binding);
|
||||
return;
|
||||
}
|
||||
}
|
||||
auto iter = m_bindings.begin();
|
||||
|
||||
m_bindings.push_back(binding);
|
||||
while (iter != m_bindings.end() && iter->value() <= binding.value())
|
||||
iter++;
|
||||
|
||||
m_bindings.insert(iter, binding);
|
||||
}
|
||||
|
||||
|
||||
|
@ -43,24 +43,12 @@ namespace dxvk {
|
||||
uint32_t computeSetIndex() const;
|
||||
|
||||
/**
|
||||
* \brief Checks whether bindings can be merged
|
||||
* \brief Numeric value of the binding
|
||||
*
|
||||
* Bindings can be merged if they access the same resource with
|
||||
* the same view and descriptor type and are part of the same
|
||||
* descriptor set.
|
||||
* \param [in] binding The binding to probe
|
||||
* \returns \c true if the bindings can be merged
|
||||
* Used when sorting bindings.
|
||||
* \returns Numeric value
|
||||
*/
|
||||
bool canMerge(const DxvkBindingInfo& binding) const;
|
||||
|
||||
/**
|
||||
* \brief Merges bindings
|
||||
*
|
||||
* Merges the stage and access flags of two
|
||||
* otherwise identical binding declarations.
|
||||
* \param [in] binding The binding to merge
|
||||
*/
|
||||
void merge(const DxvkBindingInfo& binding);
|
||||
uint32_t value() const;
|
||||
|
||||
/**
|
||||
* \brief Checks for equality
|
||||
|
Loading…
Reference in New Issue
Block a user