diff --git a/Common/GPU/D3D9/D3D9StateCache.cpp b/Common/GPU/D3D9/D3D9StateCache.cpp index a799713c9543..ae9e2bc2a4f1 100644 --- a/Common/GPU/D3D9/D3D9StateCache.cpp +++ b/Common/GPU/D3D9/D3D9StateCache.cpp @@ -50,9 +50,7 @@ void DirectXState::Restore() { stencilTest.restore(); count++; stencilOp.restore(); count++; stencilFunc.restore(); count++; - stencilMask.restore(); count++; - - dither.restore(); count++; + stencilWriteMask.restore(); count++; texMinFilter.restore(); count++; texMagFilter.restore(); count++; diff --git a/Common/GPU/D3D9/D3D9StateCache.h b/Common/GPU/D3D9/D3D9StateCache.h index 2a7a9cad897e..5231a6cbbefe 100644 --- a/Common/GPU/D3D9/D3D9StateCache.h +++ b/Common/GPU/D3D9/D3D9StateCache.h @@ -288,66 +288,6 @@ class DirectXState { } }; - class SavedColorMask { - DWORD mask; - public: - SavedColorMask() { - mask = D3DCOLORWRITEENABLE_RED | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_BLUE | D3DCOLORWRITEENABLE_ALPHA; - DirectXState::state_count++; - } - - inline void set(bool r, bool g, bool b, bool a) { - DWORD newmask = 0; - if (r) { - newmask |= D3DCOLORWRITEENABLE_RED; - } - if (g) { - newmask |= D3DCOLORWRITEENABLE_GREEN; - } - if (b) { - newmask |= D3DCOLORWRITEENABLE_BLUE; - } - if (a) { - newmask |= D3DCOLORWRITEENABLE_ALPHA; - } - if (mask != newmask) { - mask = newmask; - restore(); - } - } - void force(bool r, bool g, bool b, bool a) { - DWORD old = mask; - set(r, g, b, a); - mask = old; - } - inline void restore() { - pD3Ddevice->SetRenderState(D3DRS_COLORWRITEENABLE, mask); - } - }; - - - class BoolUnused { - public: - BoolUnused() { - DirectXState::state_count++; - } - inline void set(bool) { - // Nothing. - } - void force(bool) { - // Nothing. - } - inline void restore() { - // Nothing. - } - inline void enable() { - set(true); - } - inline void disable() { - set(false); - } - }; - class StateVp { D3DVIEWPORT9 viewport; public: @@ -404,36 +344,6 @@ class DirectXState { } }; - class CullMode { - DWORD cull; - public: - CullMode() : cull (D3DCULL_NONE) { - } - - inline void set(int wantcull, int cullmode) { - DWORD newcull; - if (!wantcull) { - // disable - newcull = D3DCULL_NONE; - } else { - // add front face ... - newcull = cullmode==0 ? D3DCULL_CW:D3DCULL_CCW; - } - if (cull != newcull) { - cull = newcull; - restore(); - } - } - void force(int wantcull, int cullmode) { - DWORD old = cull; - set(wantcull, cullmode); - cull = old; - } - inline void restore() { - pD3Ddevice->SetRenderState(D3DRS_CULLMODE, cull); - } - }; - bool initialized; public: @@ -451,9 +361,7 @@ class DirectXState { BoolState scissorTest; - BoolUnused dither; - - CullMode cullMode; + DxState1 cullMode; DxState1 shadeMode; BoolState depthTest; @@ -465,7 +373,7 @@ class DirectXState { DxState1 depthFunc; DxState1 depthWrite; - SavedColorMask colorMask; + DxState1 colorMask; StateVp viewport; StateScissor scissorRect; @@ -473,8 +381,10 @@ class DirectXState { BoolState stencilTest; DxState3 stencilOp; - DxState3 stencilFunc; - DxState1 stencilMask; + DxState1 stencilFunc; + DxState1 stencilRef; + DxState1 stencilWriteMask; + DxState1 stencilCompareMask; DxSampler0State1 texMinFilter; DxSampler0State1 texMagFilter; diff --git a/Common/GPU/D3D9/thin3d_d3d9.cpp b/Common/GPU/D3D9/thin3d_d3d9.cpp index f277d6ae95cb..e0242645c928 100644 --- a/Common/GPU/D3D9/thin3d_d3d9.cpp +++ b/Common/GPU/D3D9/thin3d_d3d9.cpp @@ -162,33 +162,35 @@ class D3D9DepthStencilState : public DepthStencilState { D3DSTENCILOP stencilZFail; D3DSTENCILOP stencilPass; D3DCMPFUNC stencilCompareOp; + uint8_t stencilCompareMask; uint8_t stencilWriteMask; - void Apply(LPDIRECT3DDEVICE9 device) { - device->SetRenderState(D3DRS_ZENABLE, depthTestEnabled); + void Apply(LPDIRECT3DDEVICE9 device, uint8_t stencilRef) { + using namespace DX9; + dxstate.depthTest.set(depthTestEnabled); if (depthTestEnabled) { - device->SetRenderState(D3DRS_ZWRITEENABLE, depthWriteEnabled); - device->SetRenderState(D3DRS_ZFUNC, depthCompare); + dxstate.depthWrite.set(depthWriteEnabled); + dxstate.depthFunc.set(depthCompare); } - device->SetRenderState(D3DRS_STENCILENABLE, stencilEnabled); + dxstate.stencilTest.set(stencilEnabled); if (stencilEnabled) { - device->SetRenderState(D3DRS_STENCILFAIL, stencilFail); - device->SetRenderState(D3DRS_STENCILZFAIL, stencilZFail); - device->SetRenderState(D3DRS_STENCILPASS, stencilPass); - device->SetRenderState(D3DRS_STENCILFUNC, stencilCompareOp); - device->SetRenderState(D3DRS_STENCILMASK, stencilCompareMask); - device->SetRenderState(D3DRS_STENCILWRITEMASK, stencilWriteMask); + dxstate.stencilOp.set(stencilFail, stencilZFail, stencilPass); + dxstate.stencilFunc.set(stencilCompareOp); + dxstate.stencilRef.set(stencilRef); + dxstate.stencilCompareMask.set(stencilCompareMask); + dxstate.stencilWriteMask.set(stencilWriteMask); } } }; class D3D9RasterState : public RasterState { public: - DWORD cullMode; + DWORD cullMode; // D3DCULL_* void Apply(LPDIRECT3DDEVICE9 device) { - device->SetRenderState(D3DRS_CULLMODE, cullMode); - device->SetRenderState(D3DRS_SCISSORTESTENABLE, TRUE); + using namespace DX9; + dxstate.cullMode.set(cullMode); + dxstate.scissorTest.enable(); } }; @@ -197,19 +199,14 @@ class D3D9BlendState : public BlendState { bool enabled; D3DBLENDOP eqCol, eqAlpha; D3DBLEND srcCol, srcAlpha, dstCol, dstAlpha; - uint32_t fixedColor; uint32_t colorMask; void Apply(LPDIRECT3DDEVICE9 device) { - device->SetRenderState(D3DRS_ALPHABLENDENABLE, (DWORD)enabled); - device->SetRenderState(D3DRS_BLENDOP, eqCol); - device->SetRenderState(D3DRS_BLENDOPALPHA, eqAlpha); - device->SetRenderState(D3DRS_SRCBLEND, srcCol); - device->SetRenderState(D3DRS_DESTBLEND, dstCol); - device->SetRenderState(D3DRS_SRCBLENDALPHA, srcAlpha); - device->SetRenderState(D3DRS_DESTBLENDALPHA, dstAlpha); - device->SetRenderState(D3DRS_COLORWRITEENABLE, colorMask); - // device->SetRenderState(, fixedColor); + using namespace DX9; + dxstate.blend.set(enabled); + dxstate.blendFunc.set(srcCol, dstCol, srcAlpha, dstAlpha); + dxstate.blendEquation.set(eqCol, eqAlpha); + dxstate.colorMask.set(colorMask); } }; @@ -219,11 +216,12 @@ class D3D9SamplerState : public SamplerState { D3DTEXTUREFILTERTYPE magFilt, minFilt, mipFilt; void Apply(LPDIRECT3DDEVICE9 device, int index) { - device->SetSamplerState(index, D3DSAMP_ADDRESSU, wrapS); - device->SetSamplerState(index, D3DSAMP_ADDRESSV, wrapT); - device->SetSamplerState(index, D3DSAMP_MAGFILTER, magFilt); - device->SetSamplerState(index, D3DSAMP_MINFILTER, minFilt); - device->SetSamplerState(index, D3DSAMP_MIPFILTER, mipFilt); + using namespace DX9; + dxstate.texAddressU.set(wrapS); + dxstate.texAddressV.set(wrapT); + dxstate.texMagFilter.set(magFilt); + dxstate.texMinFilter.set(minFilt); + dxstate.texMipFilter.set(mipFilt); } }; @@ -291,7 +289,7 @@ class D3D9Pipeline : public Pipeline { AutoRef raster; UniformBufferDesc dynamicUniforms; - void Apply(LPDIRECT3DDEVICE9 device); + void Apply(LPDIRECT3DDEVICE9 device, uint8_t stencilRef); }; class D3D9Texture : public Texture { @@ -558,7 +556,9 @@ class D3D9Context : public DrawContext { void SetScissorRect(int left, int top, int width, int height) override; void SetViewports(int count, Viewport *viewports) override; void SetBlendFactor(float color[4]) override; - void SetStencilRef(uint8_t ref) override; + void SetStencilRef(uint8_t ref) override { + stencilRef_ = ref; + } void Draw(int vertexCount, int offset) override; void DrawIndexed(int vertexCount, int offset) override; @@ -622,6 +622,9 @@ class D3D9Context : public DrawContext { LPDIRECT3DSURFACE9 deviceRTsurf = 0; LPDIRECT3DSURFACE9 deviceDSsurf = 0; bool supportsINTZ = false; + + // Dynamic state + uint8_t stencilRef_ = 0; }; void D3D9Context::InvalidateCachedState() { @@ -674,6 +677,8 @@ D3D9Context::D3D9Context(IDirect3D9 *d3d, IDirect3D9Ex *d3dEx, int adapterId, ID } shaderLanguageDesc_.Init(HLSL_D3D9); + + DX9::dxstate.Restore(); } D3D9Context::~D3D9Context() { @@ -951,23 +956,23 @@ void D3D9Context::UpdateBuffer(Buffer *buffer, const uint8_t *data, size_t offse } } -void D3D9Pipeline::Apply(LPDIRECT3DDEVICE9 device) { +void D3D9Pipeline::Apply(LPDIRECT3DDEVICE9 device, uint8_t stencilRef) { vshader->Apply(device); pshader->Apply(device); blend->Apply(device); - depthStencil->Apply(device); + depthStencil->Apply(device, stencilRef); raster->Apply(device); } void D3D9Context::Draw(int vertexCount, int offset) { device_->SetStreamSource(0, curVBuffers_[0]->vbuffer_, curVBufferOffsets_[0], curPipeline_->inputLayout->GetStride(0)); - curPipeline_->Apply(device_); + curPipeline_->Apply(device_, stencilRef_); curPipeline_->inputLayout->Apply(device_); device_->DrawPrimitive(curPipeline_->prim, offset, vertexCount / 3); } void D3D9Context::DrawIndexed(int vertexCount, int offset) { - curPipeline_->Apply(device_); + curPipeline_->Apply(device_, stencilRef_); curPipeline_->inputLayout->Apply(device_); device_->SetStreamSource(0, curVBuffers_[0]->vbuffer_, curVBufferOffsets_[0], curPipeline_->inputLayout->GetStride(0)); device_->SetIndices(curIBuffer_->ibuffer_); @@ -975,7 +980,7 @@ void D3D9Context::DrawIndexed(int vertexCount, int offset) { } void D3D9Context::DrawUP(const void *vdata, int vertexCount) { - curPipeline_->Apply(device_); + curPipeline_->Apply(device_, stencilRef_); curPipeline_->inputLayout->Apply(device_); device_->DrawPrimitiveUP(curPipeline_->prim, vertexCount / 3, vdata, curPipeline_->inputLayout->GetStride(0)); } @@ -998,6 +1003,7 @@ void D3D9Context::SetScissorRect(int left, int top, int width, int height) { using namespace DX9; dxstate.scissorRect.set(left, top, left + width, top + height); + dxstate.scissorTest.set(true); } void D3D9Context::SetViewports(int count, Viewport *viewports) { @@ -1015,11 +1021,8 @@ void D3D9Context::SetBlendFactor(float color[4]) { uint32_t g = (uint32_t)(color[1] * 255.0f); uint32_t b = (uint32_t)(color[2] * 255.0f); uint32_t a = (uint32_t)(color[3] * 255.0f); - device_->SetRenderState(D3DRS_BLENDFACTOR, r | (g << 8) | (b << 16) | (a << 24)); -} - -void D3D9Context::SetStencilRef(uint8_t ref) { - device_->SetRenderState(D3DRS_STENCILREF, (DWORD)ref); + using namespace DX9; + dxstate.blendColor.set(color); } bool D3D9ShaderModule::Compile(LPDIRECT3DDEVICE9 device, const uint8_t *data, size_t size) { diff --git a/GPU/Directx9/DrawEngineDX9.cpp b/GPU/Directx9/DrawEngineDX9.cpp index 216bc7a8a04b..4130d54cff30 100644 --- a/GPU/Directx9/DrawEngineDX9.cpp +++ b/GPU/Directx9/DrawEngineDX9.cpp @@ -598,7 +598,9 @@ void DrawEngineDX9::DoFlush() { if (result.action == SW_DRAW_PRIMITIVES) { if (result.setStencil) { - dxstate.stencilFunc.set(D3DCMP_ALWAYS, result.stencilValue, 255); + dxstate.stencilFunc.set(D3DCMP_ALWAYS); + dxstate.stencilRef.set(result.stencilValue); + dxstate.stencilCompareMask.set(255); } // TODO: Add a post-transform cache here for multi-RECTANGLES only. diff --git a/GPU/Directx9/FramebufferManagerDX9.cpp b/GPU/Directx9/FramebufferManagerDX9.cpp index 114feb54b843..47e86fc0a0a4 100644 --- a/GPU/Directx9/FramebufferManagerDX9.cpp +++ b/GPU/Directx9/FramebufferManagerDX9.cpp @@ -200,12 +200,12 @@ static const D3DVERTEXELEMENT9 g_FramebufferVertexElements[] = { dxstate.texMipLodBias.set(0.0f); dxstate.texMaxMipLevel.set(0); dxstate.blend.disable(); - dxstate.cullMode.set(false, false); + dxstate.cullMode.set(D3DCULL_NONE); dxstate.depthTest.disable(); dxstate.scissorTest.disable(); dxstate.stencilTest.disable(); - dxstate.colorMask.set(true, true, true, true); - dxstate.stencilMask.set(0xFF); + dxstate.colorMask.set(0xF); + dxstate.stencilWriteMask.set(0xFF); HRESULT hr = device_->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, coord, 5 * sizeof(float)); if (FAILED(hr)) { ERROR_LOG_REPORT(G3D, "DrawActiveTexture() failed: %08x", (uint32_t)hr); diff --git a/GPU/Directx9/GPU_DX9.cpp b/GPU/Directx9/GPU_DX9.cpp index f979ceb386e4..f9452bf840cd 100644 --- a/GPU/Directx9/GPU_DX9.cpp +++ b/GPU/Directx9/GPU_DX9.cpp @@ -256,7 +256,7 @@ void GPU_DX9::DeviceRestore() { void GPU_DX9::InitClear() { if (!framebufferManager_->UseBufferedRendering()) { dxstate.depthWrite.set(true); - dxstate.colorMask.set(true, true, true, true); + dxstate.colorMask.set(0xF); device_->Clear(0, NULL, D3DCLEAR_STENCIL|D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.f, 0); } } @@ -298,7 +298,7 @@ void GPU_DX9::SetDisplayFramebuffer(u32 framebuf, u32 stride, GEBufferFormat for void GPU_DX9::CopyDisplayToOutput(bool reallyDirty) { dxstate.depthWrite.set(true); - dxstate.colorMask.set(true, true, true, true); + dxstate.colorMask.set(0xF); drawEngine_.Flush(); diff --git a/GPU/Directx9/StateMappingDX9.cpp b/GPU/Directx9/StateMappingDX9.cpp index efbb0e0b460f..b3e3a6e189c3 100644 --- a/GPU/Directx9/StateMappingDX9.cpp +++ b/GPU/Directx9/StateMappingDX9.cpp @@ -119,11 +119,15 @@ void DrawEngineDX9::ApplyDrawState(int prim) { gstate_c.SetAllowFramebufferRead(false); if (gstate.isModeClear()) { dxstate.blend.disable(); - // Color Mask - bool colorMask = gstate.isClearModeColorMask(); - bool alphaMask = gstate.isClearModeAlphaMask(); - dxstate.colorMask.set(colorMask, colorMask, colorMask, alphaMask); + u32 mask = 0; + if (gstate.isClearModeColorMask()) { + mask |= 7; + } + if (gstate.isClearModeAlphaMask()) { + mask |= 8; + } + dxstate.colorMask.set(mask); } else { GenericMaskState maskState; ConvertMaskState(maskState, gstate_c.allowFramebufferRead); @@ -158,20 +162,27 @@ void DrawEngineDX9::ApplyDrawState(int prim) { dxstate.blend.disable(); } - dxstate.colorMask.set(maskState.rgba[0], maskState.rgba[1], maskState.rgba[2], maskState.rgba[3]); + u32 mask = 0; + for (int i = 0; i < 4; i++) { + if (maskState.rgba[i]) + mask |= 1 << i; + } + dxstate.colorMask.set(mask); } } if (gstate_c.IsDirty(DIRTY_RASTER_STATE)) { gstate_c.Clean(DIRTY_RASTER_STATE); - // Set Dither - if (gstate.isDitherEnabled()) { - dxstate.dither.enable(); + bool wantCull = !gstate.isModeClear() && prim != GE_PRIM_RECTANGLES && prim > GE_PRIM_LINE_STRIP && gstate.isCullEnabled(); + if (wantCull) { + if (gstate.getCullMode() == 1) { + dxstate.cullMode.set(D3DCULL_CCW); + } else { + dxstate.cullMode.set(D3DCULL_CW); + } } else { - dxstate.dither.disable(); + dxstate.cullMode.set(D3DCULL_NONE); } - bool wantCull = !gstate.isModeClear() && prim != GE_PRIM_RECTANGLES && prim > GE_PRIM_LINE_STRIP && gstate.isCullEnabled(); - dxstate.cullMode.set(wantCull, gstate.getCullMode()); if (gstate.isModeClear()) { // Well, probably doesn't matter... dxstate.shadeMode.set(D3DSHADE_GOURAUD); @@ -200,8 +211,10 @@ void DrawEngineDX9::ApplyDrawState(int prim) { if (alphaMask) { dxstate.stencilTest.enable(); dxstate.stencilOp.set(D3DSTENCILOP_REPLACE, D3DSTENCILOP_REPLACE, D3DSTENCILOP_REPLACE); - dxstate.stencilFunc.set(D3DCMP_ALWAYS, 255, 0xFF); - dxstate.stencilMask.set(stencilState.writeMask); + dxstate.stencilFunc.set(D3DCMP_ALWAYS); + dxstate.stencilRef.set(0xFF); + dxstate.stencilCompareMask.set(0xFF); + dxstate.stencilWriteMask.set(stencilState.writeMask); } else { dxstate.stencilTest.disable(); } @@ -222,9 +235,11 @@ void DrawEngineDX9::ApplyDrawState(int prim) { // Stencil Test if (stencilState.enabled) { dxstate.stencilTest.enable(); - dxstate.stencilFunc.set(ztests[stencilState.testFunc], stencilState.testRef, stencilState.testMask); + dxstate.stencilFunc.set(ztests[stencilState.testFunc]); + dxstate.stencilRef.set(stencilState.testRef); + dxstate.stencilCompareMask.set(stencilState.testMask); dxstate.stencilOp.set(stencilOps[stencilState.sFail], stencilOps[stencilState.zFail], stencilOps[stencilState.zPass]); - dxstate.stencilMask.set(stencilState.writeMask); + dxstate.stencilWriteMask.set(stencilState.writeMask); } else { dxstate.stencilTest.disable(); } diff --git a/GPU/Directx9/StencilBufferDX9.cpp b/GPU/Directx9/StencilBufferDX9.cpp index 2e0c2c446894..31ae6aa17dc6 100644 --- a/GPU/Directx9/StencilBufferDX9.cpp +++ b/GPU/Directx9/StencilBufferDX9.cpp @@ -117,7 +117,7 @@ bool FramebufferManagerDX9::NotifyStencilUpload(u32 addr, int size, StencilUploa // Let's not bother with the shader if it's just zero. dxstate.scissorTest.disable(); - dxstate.colorMask.set(false, false, false, true); + dxstate.colorMask.set(0x8); // TODO: Verify this clears only stencil/alpha. device_->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_STENCIL, D3DCOLOR_RGBA(0, 0, 0, 0), 0.0f, 0); @@ -181,7 +181,7 @@ bool FramebufferManagerDX9::NotifyStencilUpload(u32 addr, int size, StencilUploa shaderManager_->DirtyLastShader(); - dxstate.colorMask.set(false, false, false, true); + dxstate.colorMask.set(0x8); dxstate.stencilTest.enable(); dxstate.stencilOp.set(D3DSTENCILOP_REPLACE, D3DSTENCILOP_REPLACE, D3DSTENCILOP_REPLACE); @@ -202,7 +202,9 @@ bool FramebufferManagerDX9::NotifyStencilUpload(u32 addr, int size, StencilUploa // TODO: Ideally, we should clear alpha to zero here (but not RGB.) - dxstate.stencilFunc.set(D3DCMP_ALWAYS, 0xFF, 0xFF); + dxstate.stencilFunc.set(D3DCMP_ALWAYS); + dxstate.stencilRef.set(0xFF); + dxstate.stencilCompareMask.set(0xFF); float coord[20] = { -1.0f, 1.0f, 0.0f, 0.0f, 0.0f, @@ -228,15 +230,15 @@ bool FramebufferManagerDX9::NotifyStencilUpload(u32 addr, int size, StencilUploa continue; } if (dstBuffer->format == GE_FORMAT_4444) { - dxstate.stencilMask.set(i | (i << 4)); + dxstate.stencilWriteMask.set(i | (i << 4)); const float f[4] = {i * (16.0f / 255.0f)}; device_->SetPixelShaderConstantF(CONST_PS_STENCILVALUE, f, 1); } else if (dstBuffer->format == GE_FORMAT_5551) { - dxstate.stencilMask.set(0xFF); + dxstate.stencilWriteMask.set(0xFF); const float f[4] = {i * (128.0f / 255.0f)}; device_->SetPixelShaderConstantF(CONST_PS_STENCILVALUE, f, 1); } else { - dxstate.stencilMask.set(i); + dxstate.stencilWriteMask.set(i); const float f[4] = {i * (1.0f / 255.0f)}; device_->SetPixelShaderConstantF(CONST_PS_STENCILVALUE, f, 1); } @@ -247,7 +249,7 @@ bool FramebufferManagerDX9::NotifyStencilUpload(u32 addr, int size, StencilUploa } tex->Release(); - dxstate.stencilMask.set(0xFF); + dxstate.stencilWriteMask.set(0xFF); dxstate.viewport.restore(); RebindFramebuffer("RebindFramebuffer stencil"); gstate_c.Dirty(DIRTY_VIEWPORTSCISSOR_STATE | DIRTY_BLEND_STATE | DIRTY_RASTER_STATE | DIRTY_DEPTHSTENCIL_STATE | DIRTY_TEXTURE_IMAGE | DIRTY_TEXTURE_PARAMS); diff --git a/GPU/Directx9/TextureCacheDX9.cpp b/GPU/Directx9/TextureCacheDX9.cpp index e9673e872857..a2d9f7292264 100644 --- a/GPU/Directx9/TextureCacheDX9.cpp +++ b/GPU/Directx9/TextureCacheDX9.cpp @@ -304,6 +304,7 @@ class TextureShaderApplierDX9 { } void Shade() { + // Intentionally bypassing the dxstate cache here (and using .Restore to recover afterwards). Not sure if this is a good idea. device_->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); device_->SetRenderState(D3DRS_SEPARATEALPHABLENDENABLE, FALSE); device_->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_RED | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_BLUE | D3DCOLORWRITEENABLE_ALPHA); @@ -318,7 +319,6 @@ class TextureShaderApplierDX9 { if (FAILED(hr)) { ERROR_LOG_REPORT(G3D, "Depal render failed: %08x", (uint32_t)hr); } - dxstate.Restore(); }