[PATCH 4/7] wined3d: Implement SM5 store_uav_typed instruction.

Józef Kucia jkucia at codeweavers.com
Wed Jan 25 04:17:57 CST 2017


Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---
 dlls/d3d11/tests/d3d11.c   | 10 +++++-----
 dlls/wined3d/glsl_shader.c | 36 ++++++++++++++++++++++++++++++++++--
 2 files changed, 39 insertions(+), 7 deletions(-)

diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c
index ee8c6e0..331fdf8 100644
--- a/dlls/d3d11/tests/d3d11.c
+++ b/dlls/d3d11/tests/d3d11.c
@@ -12601,18 +12601,18 @@ static void test_ps_cs_uav_binding(void)
     check_texture_float(ps_texture, 0.0f, 2);
     draw_quad(&test_context);
     todo_wine check_texture_float(cs_texture, 1.0f, 2);
-    todo_wine check_texture_float(ps_texture, 1.0f, 2);
+    check_texture_float(ps_texture, 1.0f, 2);
 
     input.x = 0.5f;
     ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)cs_cb, 0, NULL, &input, 0, 0);
     ID3D11DeviceContext_Dispatch(context, 1, 1, 1);
     todo_wine check_texture_float(cs_texture, 0.5f, 2);
-    todo_wine check_texture_float(ps_texture, 1.0f, 2);
+    check_texture_float(ps_texture, 1.0f, 2);
     input.x = 2.0f;
     ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)ps_cb, 0, NULL, &input, 0, 0);
     draw_quad(&test_context);
     todo_wine check_texture_float(cs_texture, 0.5f, 2);
-    todo_wine check_texture_float(ps_texture, 2.0f, 2);
+    check_texture_float(ps_texture, 2.0f, 2);
 
     input.x = 8.0f;
     ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)cs_cb, 0, NULL, &input, 0, 0);
@@ -12620,10 +12620,10 @@ static void test_ps_cs_uav_binding(void)
     ID3D11DeviceContext_UpdateSubresource(context, (ID3D11Resource *)ps_cb, 0, NULL, &input, 0, 0);
     ID3D11DeviceContext_Dispatch(context, 1, 1, 1);
     todo_wine check_texture_float(cs_texture, 8.0f, 2);
-    todo_wine check_texture_float(ps_texture, 2.0f, 2);
+    check_texture_float(ps_texture, 2.0f, 2);
     draw_quad(&test_context);
     todo_wine check_texture_float(cs_texture, 8.0f, 2);
-    todo_wine check_texture_float(ps_texture, 4.0f, 2);
+    check_texture_float(ps_texture, 4.0f, 2);
 
     check_texture_color(test_context.backbuffer, 0xffffffff, 2);
 
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index a8d208e..aac9083 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -4811,7 +4811,7 @@ static void shader_glsl_ld_uav(const struct wined3d_shader_instruction *ins)
     if (resource_type >= ARRAY_SIZE(resource_type_info))
     {
         ERR("Unexpected resource type %#x.\n", resource_type);
-        resource_type = WINED3D_SHADER_RESOURCE_TEXTURE_2D;
+        return;
     }
     data_type = reg_maps->uav_resource_info[uav_idx].data_type;
     coord_mask = (1u << resource_type_info[resource_type].coord_size) - 1;
@@ -4824,6 +4824,38 @@ static void shader_glsl_ld_uav(const struct wined3d_shader_instruction *ins)
             shader_glsl_get_prefix(version->type), uav_idx, image_coord_param.param_str, dst_swizzle);
 }
 
+static void shader_glsl_store_uav(const struct wined3d_shader_instruction *ins)
+{
+    const struct wined3d_shader_reg_maps *reg_maps = ins->ctx->reg_maps;
+    const struct wined3d_shader_version *version = &reg_maps->shader_version;
+    struct glsl_src_param image_coord_param, image_data_param;
+    enum wined3d_shader_resource_type resource_type;
+    enum wined3d_data_type data_type;
+    unsigned int uav_idx;
+    DWORD coord_mask;
+
+    uav_idx = ins->dst[0].reg.idx[0].offset;
+    if (uav_idx >= ARRAY_SIZE(reg_maps->uav_resource_info))
+    {
+        ERR("Invalid UAV index %u.\n", uav_idx);
+        return;
+    }
+    resource_type = reg_maps->uav_resource_info[uav_idx].type;
+    if (resource_type >= ARRAY_SIZE(resource_type_info))
+    {
+        ERR("Unexpected resource type %#x.\n", resource_type);
+        return;
+    }
+    data_type = reg_maps->uav_resource_info[uav_idx].data_type;
+    coord_mask = (1u << resource_type_info[resource_type].coord_size) - 1;
+
+    shader_glsl_add_src_param(ins, &ins->src[0], coord_mask, &image_coord_param);
+    shader_glsl_add_src_param_ext(ins, &ins->src[1], WINED3DSP_WRITEMASK_ALL, &image_data_param, data_type);
+    shader_addline(ins->ctx->buffer, "imageStore(%s_image%u, %s, %s);\n",
+            shader_glsl_get_prefix(version->type), uav_idx,
+            image_coord_param.param_str, image_data_param.param_str);
+}
+
 static void shader_glsl_resinfo(const struct wined3d_shader_instruction *ins)
 {
     const struct wined3d_shader_version *version = &ins->ctx->reg_maps->shader_version;
@@ -9105,7 +9137,7 @@ static const SHADER_HANDLER shader_glsl_instruction_handler_table[WINED3DSIH_TAB
     /* WINED3DSIH_SQRT                             */ shader_glsl_map2gl,
     /* WINED3DSIH_STORE_RAW                        */ NULL,
     /* WINED3DSIH_STORE_STRUCTURED                 */ NULL,
-    /* WINED3DSIH_STORE_UAV_TYPED                  */ NULL,
+    /* WINED3DSIH_STORE_UAV_TYPED                  */ shader_glsl_store_uav,
     /* WINED3DSIH_SUB                              */ shader_glsl_binop,
     /* WINED3DSIH_SWAPC                            */ NULL,
     /* WINED3DSIH_SWITCH                           */ shader_glsl_switch,
-- 
2.10.2




More information about the wine-patches mailing list