From f6ed6bcefa78e19d351ba897c1160b54492e28f1 Mon Sep 17 00:00:00 2001 From: narzoul Date: Fri, 18 Dec 2020 12:04:33 +0100 Subject: [PATCH] Added optimization for D3DDDITSS_TEXTURECOLORKEYVAL --- DDrawCompat/D3dDdi/DeviceState.cpp | 19 +++++++++++++++++++ DDrawCompat/D3dDdi/DeviceState.h | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/DDrawCompat/D3dDdi/DeviceState.cpp b/DDrawCompat/D3dDdi/DeviceState.cpp index e8d4965..139ffb7 100644 --- a/DDrawCompat/D3dDdi/DeviceState.cpp +++ b/DDrawCompat/D3dDdi/DeviceState.cpp @@ -96,6 +96,25 @@ namespace D3dDdi HRESULT DeviceState::pfnSetTextureStageState(const D3DDDIARG_TEXTURESTAGESTATE* data) { + if (D3DDDITSS_TEXTURECOLORKEYVAL == data->State) + { + if (1 == m_textureStageState[data->Stage][D3DDDITSS_DISABLETEXTURECOLORKEY]) + { + m_textureStageState[data->Stage][D3DDDITSS_DISABLETEXTURECOLORKEY] = 0; + } + else if (data->Value == m_textureStageState[data->Stage][D3DDDITSS_TEXTURECOLORKEYVAL]) + { + return S_OK; + } + + m_device.flushPrimitives(); + HRESULT result = m_device.getOrigVtable().pfnSetTextureStageState(m_device, data); + if (SUCCEEDED(result)) + { + m_textureStageState[data->Stage][D3DDDITSS_TEXTURECOLORKEYVAL] = data->Value; + } + return result; + } return setStateArray(data, m_textureStageState[data->Stage], m_device.getOrigVtable().pfnSetTextureStageState); } diff --git a/DDrawCompat/D3dDdi/DeviceState.h b/DDrawCompat/D3dDdi/DeviceState.h index 4a084f5..fdf7931 100644 --- a/DDrawCompat/D3dDdi/DeviceState.h +++ b/DDrawCompat/D3dDdi/DeviceState.h @@ -59,7 +59,7 @@ namespace D3dDdi std::vector m_pixelShaderConstI; std::array m_renderState; std::array m_textures; - std::array, 8> m_textureStageState; + std::array, 8> m_textureStageState; std::vector m_vertexShaderConst; std::vector m_vertexShaderConstB; std::vector m_vertexShaderConstI;