mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-03-01 10:54:14 +01:00
[d3d11] Chjeck whether input layouts are identical
Prevents redundant state changes when a game switches between identical input layouts. Reduces the the number of Vulkan calls in Grim Dawn by ~30%.
This commit is contained in:
parent
de9ffdcfa3
commit
8cd97959f2
@ -1235,7 +1235,17 @@ namespace dxvk {
|
|||||||
auto inputLayout = static_cast<D3D11InputLayout*>(pInputLayout);
|
auto inputLayout = static_cast<D3D11InputLayout*>(pInputLayout);
|
||||||
|
|
||||||
if (m_state.ia.inputLayout != inputLayout) {
|
if (m_state.ia.inputLayout != inputLayout) {
|
||||||
|
bool equal = false;
|
||||||
|
|
||||||
|
// Some games (e.g. Grim Dawn) create lots and lots of
|
||||||
|
// identical input layouts, so we'll only apply the state
|
||||||
|
// if the input layouts has actually changed between calls.
|
||||||
|
if (m_state.ia.inputLayout != nullptr && inputLayout != nullptr)
|
||||||
|
equal = m_state.ia.inputLayout->Compare(inputLayout);
|
||||||
|
|
||||||
m_state.ia.inputLayout = inputLayout;
|
m_state.ia.inputLayout = inputLayout;
|
||||||
|
|
||||||
|
if (!equal)
|
||||||
ApplyInputLayout();
|
ApplyInputLayout();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,4 +55,25 @@ namespace dxvk {
|
|||||||
m_bindings.data());
|
m_bindings.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool D3D11InputLayout::Compare(const D3D11InputLayout* pOther) const {
|
||||||
|
bool eq = m_attributes.size() == pOther->m_attributes.size()
|
||||||
|
&& m_bindings.size() == pOther->m_bindings.size();
|
||||||
|
|
||||||
|
for (uint32_t i = 0; eq && i < m_attributes.size(); i++) {
|
||||||
|
eq &= m_attributes[i].location == pOther->m_attributes[i].location
|
||||||
|
&& m_attributes[i].binding == pOther->m_attributes[i].binding
|
||||||
|
&& m_attributes[i].format == pOther->m_attributes[i].format
|
||||||
|
&& m_attributes[i].offset == pOther->m_attributes[i].offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (uint32_t i = 0; eq && i < m_bindings.size(); i++) {
|
||||||
|
eq &= m_bindings[i].binding == pOther->m_bindings[i].binding
|
||||||
|
&& m_bindings[i].fetchRate == pOther->m_bindings[i].fetchRate
|
||||||
|
&& m_bindings[i].inputRate == pOther->m_bindings[i].inputRate;
|
||||||
|
}
|
||||||
|
|
||||||
|
return eq;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,9 @@ namespace dxvk {
|
|||||||
void BindToContext(
|
void BindToContext(
|
||||||
const Rc<DxvkContext>& ctx);
|
const Rc<DxvkContext>& ctx);
|
||||||
|
|
||||||
|
bool Compare(
|
||||||
|
const D3D11InputLayout* pOther) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Com<D3D11Device> m_device;
|
Com<D3D11Device> m_device;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user