=?UTF-8?Q?J=C3=B3zef=20Kucia=20?=: vkd3d: Implement dual source blending.

Alexandre Julliard julliard at winehq.org
Mon Dec 17 12:29:00 CST 2018


Module: vkd3d
Branch: master
Commit: c93d9bc714d7062eff268327436acbeac613ba15
URL:    https://source.winehq.org/git/vkd3d.git/?a=commit;h=c93d9bc714d7062eff268327436acbeac613ba15

Author: Józef Kucia <jkucia at codeweavers.com>
Date:   Thu Dec 13 10:28:37 2018 +0100

vkd3d: Implement dual source blending.

Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 libs/vkd3d/state.c | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/libs/vkd3d/state.c b/libs/vkd3d/state.c
index 64c2158..9c2d3ac 100644
--- a/libs/vkd3d/state.c
+++ b/libs/vkd3d/state.c
@@ -1783,6 +1783,21 @@ static void blend_attachment_from_d3d12(struct VkPipelineColorBlendAttachmentSta
         FIXME("Ignoring LogicOpEnable %#x.\n", d3d12_desc->LogicOpEnable);
 }
 
+static bool is_dual_source_blending_blend(D3D12_BLEND b)
+{
+    return b == D3D12_BLEND_SRC1_COLOR || b == D3D12_BLEND_INV_SRC1_COLOR
+            || b == D3D12_BLEND_SRC1_ALPHA || b == D3D12_BLEND_INV_SRC1_ALPHA;
+}
+
+static bool is_dual_source_blending(const D3D12_RENDER_TARGET_BLEND_DESC *desc)
+{
+    return desc->BlendEnable
+        && (is_dual_source_blending_blend(desc->SrcBlend)
+        || is_dual_source_blending_blend(desc->DestBlend)
+        || is_dual_source_blending_blend(desc->SrcBlendAlpha)
+        || is_dual_source_blending_blend(desc->DestBlendAlpha));
+}
+
 static HRESULT compute_input_layout_offsets(const D3D12_INPUT_LAYOUT_DESC *input_layout_desc,
         uint32_t *offsets)
 {
@@ -2063,9 +2078,29 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s
     ps_compile_args.type = VKD3D_SHADER_STRUCTURE_TYPE_COMPILE_ARGUMENTS;
     ps_compile_args.next = NULL;
     ps_compile_args.target = VKD3D_SHADER_TARGET_SPIRV_VULKAN_1_0;
+    ps_compile_args.dual_source_blending = is_dual_source_blending(&desc->BlendState.RenderTarget[0]);
     ps_compile_args.output_swizzles = ps_output_swizzle;
     ps_compile_args.output_swizzle_count = rt_count;
 
+    if (ps_compile_args.dual_source_blending && rt_count > 1)
+    {
+        WARN("Only one render target is allowed when dual source blending is used.\n");
+        hr = E_INVALIDARG;
+        goto fail;
+    }
+    if (ps_compile_args.dual_source_blending && desc->BlendState.IndependentBlendEnable)
+    {
+        for (i = 1; i < ARRAY_SIZE(desc->BlendState.RenderTarget); ++i)
+        {
+            if (desc->BlendState.RenderTarget[i].BlendEnable)
+            {
+                WARN("Blend enable cannot be set for render target %u when dual source blending is used.\n", i);
+                hr = E_INVALIDARG;
+                goto fail;
+            }
+        }
+    }
+
     shader_interface.type = VKD3D_SHADER_STRUCTURE_TYPE_SHADER_INTERFACE;
     shader_interface.next = NULL;
     shader_interface.bindings = root_signature->descriptor_mapping;




More information about the wine-cvs mailing list