1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-31 14:52:11 +01:00

[d3d9] Store copy of shader metadata in constant set

Reduces pointer chasing when updating shader constants.
This commit is contained in:
Philip Rebohle 2020-02-05 17:07:08 +01:00 committed by Joshie
parent 69b04c609a
commit aa70369671
2 changed files with 15 additions and 15 deletions

View File

@ -40,7 +40,7 @@ namespace dxvk {
struct D3D9ConstantSets { struct D3D9ConstantSets {
Rc<DxvkBuffer> buffer; Rc<DxvkBuffer> buffer;
const DxsoShaderMetaInfo* meta = nullptr; DxsoShaderMetaInfo meta = {};
bool dirty = true; bool dirty = true;
}; };

View File

@ -2644,7 +2644,7 @@ namespace dxvk {
bool newCopies = newShader && newShader->GetMeta().needsConstantCopies; bool newCopies = newShader && newShader->GetMeta().needsConstantCopies;
m_consts[DxsoProgramTypes::VertexShader].dirty |= oldCopies || newCopies || !oldShader; m_consts[DxsoProgramTypes::VertexShader].dirty |= oldCopies || newCopies || !oldShader;
m_consts[DxsoProgramTypes::VertexShader].meta = newShader ? &newShader->GetMeta() : nullptr; m_consts[DxsoProgramTypes::VertexShader].meta = newShader ? newShader->GetMeta() : DxsoShaderMetaInfo();
if (newShader && oldShader) { if (newShader && oldShader) {
m_consts[DxsoProgramTypes::VertexShader].dirty m_consts[DxsoProgramTypes::VertexShader].dirty
@ -2970,7 +2970,7 @@ namespace dxvk {
bool newCopies = newShader && newShader->GetMeta().needsConstantCopies; bool newCopies = newShader && newShader->GetMeta().needsConstantCopies;
m_consts[DxsoProgramTypes::PixelShader].dirty |= oldCopies || newCopies || !oldShader; m_consts[DxsoProgramTypes::PixelShader].dirty |= oldCopies || newCopies || !oldShader;
m_consts[DxsoProgramTypes::PixelShader].meta = newShader ? &newShader->GetMeta() : nullptr; m_consts[DxsoProgramTypes::PixelShader].meta = newShader ? newShader->GetMeta() : DxsoShaderMetaInfo();
if (newShader && oldShader) { if (newShader && oldShader) {
m_consts[DxsoProgramTypes::PixelShader].dirty m_consts[DxsoProgramTypes::PixelShader].dirty
@ -4461,10 +4461,10 @@ namespace dxvk {
auto* dst = reinterpret_cast<HardwareLayoutType*>(pData); auto* dst = reinterpret_cast<HardwareLayoutType*>(pData);
if (constSet.meta->maxConstIndexF) if (constSet.meta.maxConstIndexF)
std::memcpy(dst->fConsts, Src.fConsts, constSet.meta->maxConstIndexF * sizeof(Vector4)); std::memcpy(dst->fConsts, Src.fConsts, constSet.meta.maxConstIndexF * sizeof(Vector4));
if (constSet.meta->maxConstIndexI) if (constSet.meta.maxConstIndexI)
std::memcpy(dst->iConsts, Src.iConsts, constSet.meta->maxConstIndexI * sizeof(Vector4i)); std::memcpy(dst->iConsts, Src.iConsts, constSet.meta.maxConstIndexI * sizeof(Vector4i));
} }
@ -4474,11 +4474,11 @@ namespace dxvk {
auto dst = reinterpret_cast<uint8_t*>(pData); auto dst = reinterpret_cast<uint8_t*>(pData);
if (constSet.meta->maxConstIndexF) if (constSet.meta.maxConstIndexF)
std::memcpy(dst + Layout.floatOffset(), Src.fConsts, constSet.meta->maxConstIndexF * sizeof(Vector4)); std::memcpy(dst + Layout.floatOffset(), Src.fConsts, constSet.meta.maxConstIndexF * sizeof(Vector4));
if (constSet.meta->maxConstIndexI) if (constSet.meta.maxConstIndexI)
std::memcpy(dst + Layout.intOffset(), Src.iConsts, constSet.meta->maxConstIndexI * sizeof(Vector4i)); std::memcpy(dst + Layout.intOffset(), Src.iConsts, constSet.meta.maxConstIndexI * sizeof(Vector4i));
if (constSet.meta->maxConstIndexB) if (constSet.meta.maxConstIndexB)
std::memcpy(dst + Layout.bitmaskOffset(), Src.bConsts, Layout.bitmaskSize()); std::memcpy(dst + Layout.bitmaskOffset(), Src.bConsts, Layout.bitmaskSize());
} }
@ -4508,7 +4508,7 @@ namespace dxvk {
else else
UploadSoftwareConstantSet(slice.mapPtr, Src, Layout, Shader); UploadSoftwareConstantSet(slice.mapPtr, Src, Layout, Shader);
if (constSet.meta->needsConstantCopies) { if (constSet.meta.needsConstantCopies) {
Vector4* data = reinterpret_cast<Vector4*>(slice.mapPtr); Vector4* data = reinterpret_cast<Vector4*>(slice.mapPtr);
auto& shaderConsts = GetCommonShader(Shader)->GetConstants(); auto& shaderConsts = GetCommonShader(Shader)->GetConstants();
@ -5448,7 +5448,7 @@ namespace dxvk {
if (likely(!CanSWVP())) { if (likely(!CanSWVP())) {
UpdateBoolSpecConstantVertex( UpdateBoolSpecConstantVertex(
m_state.vsConsts.bConsts[0] & m_state.vsConsts.bConsts[0] &
GetCommonShader(m_state.vertexShader)->GetMeta().boolConstantMask); m_consts[DxsoProgramType::VertexShader].meta.boolConstantMask);
} else } else
UpdateBoolSpecConstantVertex(0); UpdateBoolSpecConstantVertex(0);
} }
@ -5478,7 +5478,7 @@ namespace dxvk {
UpdateBoolSpecConstantPixel( UpdateBoolSpecConstantPixel(
m_state.psConsts.bConsts[0] & m_state.psConsts.bConsts[0] &
GetCommonShader(m_state.pixelShader)->GetMeta().boolConstantMask); m_consts[DxsoProgramType::PixelShader].meta.boolConstantMask);
} }
else { else {
UpdateBoolSpecConstantPixel(0); UpdateBoolSpecConstantPixel(0);