1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-19 05: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 {
Rc<DxvkBuffer> buffer;
const DxsoShaderMetaInfo* meta = nullptr;
DxsoShaderMetaInfo meta = {};
bool dirty = true;
};

View File

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