diff options
| author | Anthony <Helios747@users.noreply.github.com> | 2017-07-30 01:00:16 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-07-30 01:00:16 -0700 |
| commit | ba57605266b9ab178963bf56e146f355d1b93cd4 (patch) | |
| tree | 0ddc89cfca6db3d343d317c18b7c07c9ab83e9c4 /Source/Core/VideoCommon/VertexShaderManager.cpp | |
| parent | 5bad2ee4a4129e734ff4f4d861cedc4cd573df55 (diff) | |
| parent | b154edb4fbdb327920a33b44f35f34cdf2636d6f (diff) | |
Merge pull request #5702 from stenzek/ubershaders
Ubershaders 2.0
Diffstat (limited to 'Source/Core/VideoCommon/VertexShaderManager.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/VertexShaderManager.cpp | 54 |
1 files changed, 53 insertions, 1 deletions
diff --git a/Source/Core/VideoCommon/VertexShaderManager.cpp b/Source/Core/VideoCommon/VertexShaderManager.cpp index ea2e8a528d..ad20ab2332 100644 --- a/Source/Core/VideoCommon/VertexShaderManager.cpp +++ b/Source/Core/VideoCommon/VertexShaderManager.cpp @@ -30,6 +30,7 @@ alignas(16) static float g_fProjectionMatrix[16]; // track changes static bool bTexMatricesChanged[2], bPosNormalMatrixChanged, bProjectionChanged, bViewportChanged; +static bool bTexMtxInfoChanged, bLightingConfigChanged; static BitSet32 nMaterialsChanged; static int nTransformMatricesChanged[2]; // min,max static int nNormalMatricesChanged[2]; // min,max @@ -193,8 +194,10 @@ void VertexShaderManager::Init() bPosNormalMatrixChanged = false; bProjectionChanged = true; bViewportChanged = false; + bTexMtxInfoChanged = false; + bLightingConfigChanged = false; - xfmem = {}; + std::memset(&xfmem, 0, sizeof(xfmem)); constants = {}; ResetView(); @@ -561,6 +564,32 @@ void VertexShaderManager::SetConstants() dirty = true; } + + if (bTexMtxInfoChanged) + { + bTexMtxInfoChanged = false; + constants.xfmem_dualTexInfo = xfmem.dualTexTrans.enabled; + for (size_t i = 0; i < ArraySize(xfmem.texMtxInfo); i++) + constants.xfmem_pack1[i][0] = xfmem.texMtxInfo[i].hex; + for (size_t i = 0; i < ArraySize(xfmem.postMtxInfo); i++) + constants.xfmem_pack1[i][1] = xfmem.postMtxInfo[i].hex; + + dirty = true; + } + + if (bLightingConfigChanged) + { + bLightingConfigChanged = false; + + for (size_t i = 0; i < 2; i++) + { + constants.xfmem_pack1[i][2] = xfmem.color[i].hex; + constants.xfmem_pack1[i][3] = xfmem.alpha[i].hex; + } + constants.xfmem_numColorChans = xfmem.numChan.numColorChans; + + dirty = true; + } } void VertexShaderManager::InvalidateXFRange(int start, int end) @@ -758,6 +787,27 @@ void VertexShaderManager::ResetView() bProjectionChanged = true; } +void VertexShaderManager::SetVertexFormat(u32 components) +{ + if (components != constants.components) + { + constants.components = components; + dirty = true; + } +} + +void VertexShaderManager::SetTexMatrixInfoChanged(int index) +{ + // TODO: Should we track this with more precision, like which indices changed? + // The whole vertex constants are probably going to be uploaded regardless. + bTexMtxInfoChanged = true; +} + +void VertexShaderManager::SetLightingConfigChanged() +{ + bLightingConfigChanged = true; +} + void VertexShaderManager::TransformToClipSpace(const float* data, float* out, u32 MtxIdx) { const float* world_matrix = &xfmem.posMatrices[(MtxIdx & 0x3f) * 4]; @@ -800,6 +850,8 @@ void VertexShaderManager::DoState(PointerWrap& p) p.Do(bPosNormalMatrixChanged); p.Do(bProjectionChanged); p.Do(bViewportChanged); + p.Do(bTexMtxInfoChanged); + p.Do(bLightingConfigChanged); p.Do(constants); |
