From 20922cf3f00283ab2df1f4a0f4a7ea509296d926 Mon Sep 17 00:00:00 2001 From: hrydgard Date: Tue, 15 Sep 2009 21:49:15 +0000 Subject: [PATCH] D3D: More reset fixes git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4282 8ced0084-cf51-0410-be5f-012b33b47a6e --- .../VideoCommon/Src/PixelShaderManager.cpp | 21 ++++++---- .../Core/VideoCommon/Src/PixelShaderManager.h | 5 ++- .../VideoCommon/Src/VertexShaderManager.cpp | 42 +++++++++---------- .../VideoCommon/Src/VertexShaderManager.h | 25 +++++------ Source/Plugins/Plugin_VideoDX9/Src/Render.cpp | 7 +--- 5 files changed, 50 insertions(+), 50 deletions(-) diff --git a/Source/Core/VideoCommon/Src/PixelShaderManager.cpp b/Source/Core/VideoCommon/Src/PixelShaderManager.cpp index 3b3b6514a9..c6a3e3da08 100644 --- a/Source/Core/VideoCommon/Src/PixelShaderManager.cpp +++ b/Source/Core/VideoCommon/Src/PixelShaderManager.cpp @@ -47,19 +47,24 @@ static u32 s_texturemask = 0; void PixelShaderManager::Init() { - s_nColorsChanged[0] = s_nColorsChanged[1] = 15; - s_nTexDimsChanged = true; - s_nIndTexScaleChanged = true; - s_nIndTexMtxChanged = 15; - s_bAlphaChanged = s_bZBiasChanged = s_bZTextureTypeChanged = s_bDepthRangeChanged = true; - s_bFogColorChanged = s_bFogParamChanged = true; - memset(lastRGBAfull, 0, sizeof(lastRGBAfull)); - for (int i = 0; i < 8; i++) + for (int i = 0; i < 8; i++) lastCustomTexScale[i][0] = lastCustomTexScale[i][1] = 1.0f; lastAlpha = 0; memset(lastTexDims, 0, sizeof(lastTexDims)); lastZBias = 0; s_texturemask = 0; + memset(lastRGBAfull, 0, sizeof(lastRGBAfull)); + Dirty(); +} + +void PixelShaderManager::Dirty() +{ + s_nColorsChanged[0] = s_nColorsChanged[1] = 15; + s_nTexDimsChanged = true; + s_nIndTexScaleChanged = true; + s_nIndTexMtxChanged = 15; + s_bAlphaChanged = s_bZBiasChanged = s_bZTextureTypeChanged = s_bDepthRangeChanged = true; + s_bFogColorChanged = s_bFogParamChanged = true; } void PixelShaderManager::Shutdown() diff --git a/Source/Core/VideoCommon/Src/PixelShaderManager.h b/Source/Core/VideoCommon/Src/PixelShaderManager.h index 851a15f4bc..2e8935b69c 100644 --- a/Source/Core/VideoCommon/Src/PixelShaderManager.h +++ b/Source/Core/VideoCommon/Src/PixelShaderManager.h @@ -31,6 +31,7 @@ class PixelShaderManager static void SetPSTextureDims(int texid); public: static void Init(); + static void Dirty(); static void Shutdown(); static void SetConstants(); // sets pixel shader constants @@ -49,8 +50,8 @@ public: static void SetIndTexScaleChanged(u8 stagemask); static void SetTexturesUsed(u32 nonpow2tex); static void SetTexCoordChanged(u8 texmapid); - static void SetFogColorChanged(); - static void SetFogParamChanged(); + static void SetFogColorChanged(); + static void SetFogParamChanged(); static void SetColorMatrix(const float* pmatrix, const float* pfConstAdd); static u32 GetTextureMask(); }; diff --git a/Source/Core/VideoCommon/Src/VertexShaderManager.cpp b/Source/Core/VideoCommon/Src/VertexShaderManager.cpp index b19fb54a8a..c90e8531f9 100644 --- a/Source/Core/VideoCommon/Src/VertexShaderManager.cpp +++ b/Source/Core/VideoCommon/Src/VertexShaderManager.cpp @@ -58,39 +58,35 @@ void UpdateViewport(); void VertexShaderManager::Init() { - nTransformMatricesChanged[0] = nTransformMatricesChanged[1] = -1; - nNormalMatricesChanged[0] = nNormalMatricesChanged[1] = -1; - nPostTransformMatricesChanged[0] = nPostTransformMatricesChanged[1] = -1; - nLightsChanged[0] = nLightsChanged[1] = -1; - bTexMatricesChanged[0] = bTexMatricesChanged[1] = false; - bPosNormalMatrixChanged = bProjectionChanged = bViewportChanged = false; - nMaterialsChanged = 0; + Dirty(); - memset(&xfregs, 0, sizeof(xfregs)); - memset(xfmem, 0, sizeof(xfmem)); + memset(&xfregs, 0, sizeof(xfregs)); + memset(xfmem, 0, sizeof(xfmem)); - ResetView(); + ResetView(); } void VertexShaderManager::Shutdown() { } + +void VertexShaderManager::Dirty() +{ + nTransformMatricesChanged[0] = 0; nTransformMatricesChanged[1] = 256; + nNormalMatricesChanged[0] = 0; nNormalMatricesChanged[1] = 96; + nPostTransformMatricesChanged[0] = 0; nPostTransformMatricesChanged[1] = 256; + nLightsChanged[0] = 0; nLightsChanged[1] = 0x80; + bPosNormalMatrixChanged = true; + bTexMatricesChanged[0] = bTexMatricesChanged[1] = true; + bProjectionChanged = true; + bPosNormalMatrixChanged = bTexMatricesChanged[0] = bTexMatricesChanged[1] = true; + nMaterialsChanged = 15; +} + // Syncs the shader constant buffers with xfmem // TODO: A cleaner way to control the matricies without making a mess in the parameters field void VertexShaderManager::SetConstants() { - - // TODO: Is this still needed? - //nTransformMatricesChanged[0] = 0; nTransformMatricesChanged[1] = 256; - //nNormalMatricesChanged[0] = 0; nNormalMatricesChanged[1] = 96; - //nPostTransformMatricesChanged[0] = 0; nPostTransformMatricesChanged[1] = 256; - //nLightsChanged[0] = 0; nLightsChanged[1] = 0x80; - //bPosNormalMatrixChanged = true; - //bTexMatricesChanged[0] = bTexMatricesChanged[1] = true; - //bProjectionChanged = true; - //bPosNormalMatrixChanged = bTexMatricesChanged[0] = bTexMatricesChanged[1] = true; - //nMaterialsChanged = 15; - if (nTransformMatricesChanged[0] >= 0) { int startn = nTransformMatricesChanged[0] / 4; @@ -487,7 +483,7 @@ void VertexShaderManager::TranslateView(float x, float y) Matrix33::Multiply(s_viewInvRotationMatrix, vector, result); - for(int i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) s_fViewTranslationVector[i] += result[i]; bProjectionChanged = true; diff --git a/Source/Core/VideoCommon/Src/VertexShaderManager.h b/Source/Core/VideoCommon/Src/VertexShaderManager.h index 37af35b991..619c3af5de 100644 --- a/Source/Core/VideoCommon/Src/VertexShaderManager.h +++ b/Source/Core/VideoCommon/Src/VertexShaderManager.h @@ -24,23 +24,24 @@ class VertexShaderManager { public: - static void Init(); - static void Shutdown(); + static void Init(); + static void Dirty(); + static void Shutdown(); - // constant management + // constant management static void SetConstants(); - static void SetViewport(float* _Viewport); - static void SetViewportChanged(); - static void SetProjection(float* _pProjection, int constantIndex = -1); - static void InvalidateXFRange(int start, int end); - static void SetTexMatrixChangedA(u32 Value); - static void SetTexMatrixChangedB(u32 Value); + static void SetViewport(float* _Viewport); + static void SetViewportChanged(); + static void SetProjection(float* _pProjection, int constantIndex = -1); + static void InvalidateXFRange(int start, int end); + static void SetTexMatrixChangedA(u32 Value); + static void SetTexMatrixChangedB(u32 Value); static void SetMaterialColor(int index, u32 data); - static void TranslateView(float x, float y); - static void RotateView(float x, float y); - static void ResetView(); + static void TranslateView(float x, float y); + static void RotateView(float x, float y); + static void ResetView(); }; void SetVSConstant4f(int const_number, float f1, float f2, float f3, float f4); diff --git a/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp b/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp index b142a3639c..c744d7990d 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp @@ -69,8 +69,8 @@ void SetupDeviceObjects() VertexLoaderManager::Init(); FBManager::Create(); - VertexShaderManager::Init(); - PixelShaderManager::Init(); + VertexShaderManager::Dirty(); + PixelShaderManager::Dirty(); // Tex and shader caches will recreate themselves over time. } @@ -78,9 +78,6 @@ void SetupDeviceObjects() // Kill off all POOL_DEFAULT device objects. void TeardownDeviceObjects() { - VertexShaderManager::Shutdown(); - PixelShaderManager::Shutdown(); - D3D::dev->SetRenderTarget(0, D3D::GetBackBufferSurface()); D3D::dev->SetDepthStencilSurface(D3D::GetBackBufferDepthSurface()); FBManager::Destroy();