diff --git a/src/d3d11/d3d11_blend.cpp b/src/d3d11/d3d11_blend.cpp index c3deb82c..d22b0469 100644 --- a/src/d3d11/d3d11_blend.cpp +++ b/src/d3d11/d3d11_blend.cpp @@ -76,24 +76,24 @@ namespace dxvk { DxvkBlendMode D3D11BlendState::DecodeBlendMode( - const D3D11_RENDER_TARGET_BLEND_DESC& blendDesc) { + const D3D11_RENDER_TARGET_BLEND_DESC& BlendDesc) { DxvkBlendMode mode; - mode.enableBlending = blendDesc.BlendEnable; - mode.colorSrcFactor = DecodeBlendFactor(blendDesc.SrcBlend, false); - mode.colorDstFactor = DecodeBlendFactor(blendDesc.DestBlend, false); - mode.colorBlendOp = DecodeBlendOp(blendDesc.BlendOp); - mode.alphaSrcFactor = DecodeBlendFactor(blendDesc.SrcBlendAlpha, true); - mode.alphaDstFactor = DecodeBlendFactor(blendDesc.DestBlendAlpha, true); - mode.alphaBlendOp = DecodeBlendOp(blendDesc.BlendOpAlpha); + mode.enableBlending = BlendDesc.BlendEnable; + mode.colorSrcFactor = DecodeBlendFactor(BlendDesc.SrcBlend, false); + mode.colorDstFactor = DecodeBlendFactor(BlendDesc.DestBlend, false); + mode.colorBlendOp = DecodeBlendOp(BlendDesc.BlendOp); + mode.alphaSrcFactor = DecodeBlendFactor(BlendDesc.SrcBlendAlpha, true); + mode.alphaDstFactor = DecodeBlendFactor(BlendDesc.DestBlendAlpha, true); + mode.alphaBlendOp = DecodeBlendOp(BlendDesc.BlendOpAlpha); // TODO find out if D3D11 wants us to apply the write mask if blending // is disabled as well. This is standard behaviour in Vulkan. - mode.writeMask = blendDesc.RenderTargetWriteMask; + mode.writeMask = BlendDesc.RenderTargetWriteMask; return mode; } - VkBlendFactor D3D11BlendState::DecodeBlendFactor(D3D11_BLEND blendFactor, bool isAlpha) { - switch (blendFactor) { + VkBlendFactor D3D11BlendState::DecodeBlendFactor(D3D11_BLEND BlendFactor, bool IsAlpha) { + switch (BlendFactor) { case D3D11_BLEND_ZERO: return VK_BLEND_FACTOR_ZERO; case D3D11_BLEND_ONE: return VK_BLEND_FACTOR_ONE; case D3D11_BLEND_SRC_COLOR: return VK_BLEND_FACTOR_SRC_COLOR; @@ -105,21 +105,22 @@ namespace dxvk { case D3D11_BLEND_DEST_COLOR: return VK_BLEND_FACTOR_DST_COLOR; case D3D11_BLEND_INV_DEST_COLOR: return VK_BLEND_FACTOR_ONE_MINUS_DST_COLOR; case D3D11_BLEND_SRC_ALPHA_SAT: return VK_BLEND_FACTOR_SRC_ALPHA_SATURATE; - case D3D11_BLEND_BLEND_FACTOR: return isAlpha ? VK_BLEND_FACTOR_CONSTANT_ALPHA : VK_BLEND_FACTOR_CONSTANT_COLOR; - case D3D11_BLEND_INV_BLEND_FACTOR: return isAlpha ? VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA : VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR; + case D3D11_BLEND_BLEND_FACTOR: return IsAlpha ? VK_BLEND_FACTOR_CONSTANT_ALPHA : VK_BLEND_FACTOR_CONSTANT_COLOR; + case D3D11_BLEND_INV_BLEND_FACTOR: return IsAlpha ? VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA : VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR; case D3D11_BLEND_SRC1_COLOR: return VK_BLEND_FACTOR_SRC1_COLOR; case D3D11_BLEND_INV_SRC1_COLOR: return VK_BLEND_FACTOR_ONE_MINUS_SRC1_COLOR; case D3D11_BLEND_SRC1_ALPHA: return VK_BLEND_FACTOR_SRC1_ALPHA; case D3D11_BLEND_INV_SRC1_ALPHA: return VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA; } - Logger::err(str::format("D3D11: Invalid blend factor: ", blendFactor)); + if (BlendFactor != 0) // prevent log spamming when apps use ZeroMemory + Logger::err(str::format("D3D11: Invalid blend factor: ", BlendFactor)); return VK_BLEND_FACTOR_ZERO; } - VkBlendOp D3D11BlendState::DecodeBlendOp(D3D11_BLEND_OP blendOp) { - switch (blendOp) { + VkBlendOp D3D11BlendState::DecodeBlendOp(D3D11_BLEND_OP BlendOp) { + switch (BlendOp) { case D3D11_BLEND_OP_ADD: return VK_BLEND_OP_ADD; case D3D11_BLEND_OP_SUBTRACT: return VK_BLEND_OP_SUBTRACT; case D3D11_BLEND_OP_REV_SUBTRACT: return VK_BLEND_OP_REVERSE_SUBTRACT; @@ -127,7 +128,8 @@ namespace dxvk { case D3D11_BLEND_OP_MAX: return VK_BLEND_OP_MAX; } - Logger::err(str::format("D3D11: Invalid blend op: ", blendOp)); + if (BlendOp != 0) // prevent log spamming when apps use ZeroMemory + Logger::err(str::format("D3D11: Invalid blend op: ", BlendOp)); return VK_BLEND_OP_ADD; } diff --git a/src/d3d11/d3d11_blend.h b/src/d3d11/d3d11_blend.h index 33cbbbce..25d243e4 100644 --- a/src/d3d11/d3d11_blend.h +++ b/src/d3d11/d3d11_blend.h @@ -44,14 +44,14 @@ namespace dxvk { DxvkLogicOpState m_loState; static DxvkBlendMode DecodeBlendMode( - const D3D11_RENDER_TARGET_BLEND_DESC& blendDesc); + const D3D11_RENDER_TARGET_BLEND_DESC& BlendDesc); static VkBlendFactor DecodeBlendFactor( - D3D11_BLEND blendFactor, - bool isAlpha); + D3D11_BLEND BlendFactor, + bool IsAlpha); static VkBlendOp DecodeBlendOp( - D3D11_BLEND_OP blendOp); + D3D11_BLEND_OP BlendOp); }; diff --git a/src/d3d11/d3d11_depth_stencil.cpp b/src/d3d11/d3d11_depth_stencil.cpp index 8bf8a374..f15d63fd 100644 --- a/src/d3d11/d3d11_depth_stencil.cpp +++ b/src/d3d11/d3d11_depth_stencil.cpp @@ -54,30 +54,30 @@ namespace dxvk { VkStencilOpState D3D11DepthStencilState::DecodeStencilOpState( - const D3D11_DEPTH_STENCILOP_DESC& stencilDesc, - const D3D11_DEPTH_STENCIL_DESC& desc) const { + const D3D11_DEPTH_STENCILOP_DESC& StencilDesc, + const D3D11_DEPTH_STENCIL_DESC& Desc) const { VkStencilOpState result; result.failOp = VK_STENCIL_OP_KEEP; result.passOp = VK_STENCIL_OP_KEEP; result.depthFailOp = VK_STENCIL_OP_KEEP; result.compareOp = VK_COMPARE_OP_ALWAYS; - result.compareMask = desc.StencilReadMask; - result.writeMask = desc.StencilWriteMask; + result.compareMask = Desc.StencilReadMask; + result.writeMask = Desc.StencilWriteMask; result.reference = 0; - if (desc.StencilEnable) { - result.failOp = DecodeStencilOp(stencilDesc.StencilFailOp); - result.passOp = DecodeStencilOp(stencilDesc.StencilPassOp); - result.depthFailOp = DecodeStencilOp(stencilDesc.StencilDepthFailOp); - result.compareOp = DecodeCompareOp(stencilDesc.StencilFunc); + if (Desc.StencilEnable) { + result.failOp = DecodeStencilOp(StencilDesc.StencilFailOp); + result.passOp = DecodeStencilOp(StencilDesc.StencilPassOp); + result.depthFailOp = DecodeStencilOp(StencilDesc.StencilDepthFailOp); + result.compareOp = DecodeCompareOp(StencilDesc.StencilFunc); } return result; } - VkStencilOp D3D11DepthStencilState::DecodeStencilOp(D3D11_STENCIL_OP op) const { - switch (op) { + VkStencilOp D3D11DepthStencilState::DecodeStencilOp(D3D11_STENCIL_OP Op) const { + switch (Op) { case D3D11_STENCIL_OP_KEEP: return VK_STENCIL_OP_KEEP; case D3D11_STENCIL_OP_ZERO: return VK_STENCIL_OP_ZERO; case D3D11_STENCIL_OP_REPLACE: return VK_STENCIL_OP_REPLACE; @@ -88,7 +88,8 @@ namespace dxvk { case D3D11_STENCIL_OP_DECR: return VK_STENCIL_OP_DECREMENT_AND_WRAP; } - Logger::err(str::format("D3D11: Invalid stencil op: ", op)); + if (Op != 0) + Logger::err(str::format("D3D11: Invalid stencil op: ", Op)); return VK_STENCIL_OP_KEEP; } diff --git a/src/d3d11/d3d11_depth_stencil.h b/src/d3d11/d3d11_depth_stencil.h index c4f3ee6d..c1d171eb 100644 --- a/src/d3d11/d3d11_depth_stencil.h +++ b/src/d3d11/d3d11_depth_stencil.h @@ -40,11 +40,11 @@ namespace dxvk { DxvkDepthStencilState m_state; VkStencilOpState DecodeStencilOpState( - const D3D11_DEPTH_STENCILOP_DESC& stencilDesc, - const D3D11_DEPTH_STENCIL_DESC& desc) const; + const D3D11_DEPTH_STENCILOP_DESC& StencilDesc, + const D3D11_DEPTH_STENCIL_DESC& Desc) const; VkStencilOp DecodeStencilOp( - D3D11_STENCIL_OP op) const; + D3D11_STENCIL_OP Op) const; }; diff --git a/src/d3d11/d3d11_util.cpp b/src/d3d11/d3d11_util.cpp index 367ac4a7..b9e41523 100644 --- a/src/d3d11/d3d11_util.cpp +++ b/src/d3d11/d3d11_util.cpp @@ -53,11 +53,11 @@ namespace dxvk { case D3D11_COMPARISON_NOT_EQUAL: return VK_COMPARE_OP_NOT_EQUAL; case D3D11_COMPARISON_GREATER_EQUAL: return VK_COMPARE_OP_GREATER_OR_EQUAL; case D3D11_COMPARISON_ALWAYS: return VK_COMPARE_OP_ALWAYS; - - default: - Logger::err(str::format("D3D11: Unsupported compare op: ", Mode)); - return VK_COMPARE_OP_ALWAYS; } + + if (Mode != 0) // prevent log spamming when apps use ZeroMemory + Logger::err(str::format("D3D11: Unsupported compare op: ", Mode)); + return VK_COMPARE_OP_NEVER; }