=?UTF-8?Q?J=C3=B3zef=20Kucia=20?=: wined3d: Generate GLSL declarations for UAVs.

Alexandre Julliard julliard at winehq.org
Thu Nov 24 16:27:58 CST 2016


Module: wine
Branch: master
Commit: 7b770efe8cca517867a8de8d33a13401b17c5022
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=7b770efe8cca517867a8de8d33a13401b17c5022

Author: Józef Kucia <jkucia at codeweavers.com>
Date:   Wed Nov 23 14:36:04 2016 +0100

wined3d: Generate GLSL declarations for UAVs.

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>

---

 dlls/wined3d/glsl_shader.c     | 54 +++++++++++++++++++++++++++++++++++++++++-
 dlls/wined3d/shader.c          | 13 +++++++++-
 dlls/wined3d/wined3d_private.h |  2 ++
 3 files changed, 67 insertions(+), 2 deletions(-)

diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index 41ace75..747883b 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -2040,6 +2040,56 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont
                 sampler_type_prefix, sampler_type, prefix, entry->bind_idx);
     }
 
+    /* Declare images */
+    for (i = 0; i < ARRAY_SIZE(reg_maps->uav_resource_info); ++i)
+    {
+        const char *image_type_prefix, *image_type;
+
+        if (!reg_maps->uav_resource_info[i].type)
+            continue;
+
+        switch (reg_maps->uav_resource_info[i].data_type)
+        {
+            case WINED3D_DATA_FLOAT:
+            case WINED3D_DATA_UNORM:
+            case WINED3D_DATA_SNORM:
+                image_type_prefix = "";
+                break;
+
+            case WINED3D_DATA_INT:
+                image_type_prefix = "i";
+                break;
+
+            case WINED3D_DATA_UINT:
+                image_type_prefix = "u";
+                break;
+
+            default:
+                image_type_prefix = "";
+                ERR("Unhandled resource data type %#x.\n", reg_maps->uav_resource_info[i].data_type);
+                break;
+        }
+
+        switch (reg_maps->uav_resource_info[i].type)
+        {
+            case WINED3D_SHADER_RESOURCE_TEXTURE_2D:
+                image_type = "image2D";
+                break;
+
+            case WINED3D_SHADER_RESOURCE_TEXTURE_3D:
+                image_type = "image3D";
+                break;
+
+            default:
+                image_type = "unsupported_image";
+                FIXME("Unhandled resource type %#x.\n", reg_maps->uav_resource_info[i].type);
+                break;
+        }
+
+        shader_addline(buffer, "writeonly uniform %s%s %s_image%u;\n",
+                image_type_prefix, image_type, prefix, i);
+    }
+
     /* Declare uniforms for NP2 texcoord fixup:
      * This is NOT done inside the loop that declares the texture samplers
      * since the NP2 fixup code is currently only used for the GeforceFX
@@ -5879,6 +5929,8 @@ static void shader_glsl_enable_extensions(struct wined3d_string_buffer *buffer,
 {
     if (gl_info->supported[ARB_SHADER_BIT_ENCODING])
         shader_addline(buffer, "#extension GL_ARB_shader_bit_encoding : enable\n");
+    if (gl_info->supported[ARB_SHADER_IMAGE_LOAD_STORE])
+        shader_addline(buffer, "#extension GL_ARB_shader_image_load_store : enable\n");
     if (gl_info->supported[ARB_TEXTURE_QUERY_LEVELS])
         shader_addline(buffer, "#extension GL_ARB_texture_query_levels : enable\n");
     if (gl_info->supported[ARB_UNIFORM_BUFFER_OBJECT])
@@ -8732,7 +8784,7 @@ static const SHADER_HANDLER shader_glsl_instruction_handler_table[WINED3DSIH_TAB
     /* WINED3DSIH_DCL_TGSM_RAW                     */ NULL,
     /* WINED3DSIH_DCL_TGSM_STRUCTURED              */ NULL,
     /* WINED3DSIH_DCL_THREAD_GROUP                 */ NULL,
-    /* WINED3DSIH_DCL_UAV_TYPED                    */ NULL,
+    /* WINED3DSIH_DCL_UAV_TYPED                    */ shader_glsl_nop,
     /* WINED3DSIH_DCL_VERTICES_OUT                 */ shader_glsl_nop,
     /* WINED3DSIH_DEF                              */ shader_glsl_nop,
     /* WINED3DSIH_DEFAULT                          */ shader_glsl_default,
diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c
index abaa77c..4201db3 100644
--- a/dlls/wined3d/shader.c
+++ b/dlls/wined3d/shader.c
@@ -889,7 +889,8 @@ static HRESULT shader_get_registers_used(struct wined3d_shader *shader, const st
         }
 
         /* Handle declarations. */
-        if (ins.handler_idx == WINED3DSIH_DCL)
+        if (ins.handler_idx == WINED3DSIH_DCL
+                || ins.handler_idx == WINED3DSIH_DCL_UAV_TYPED)
         {
             struct wined3d_shader_semantic *semantic = &ins.declaration.semantic;
             unsigned int reg_idx = semantic->reg.reg.idx[0].offset;
@@ -937,6 +938,16 @@ static HRESULT shader_get_registers_used(struct wined3d_shader *shader, const st
                     reg_maps->resource_info[reg_idx].data_type = semantic->resource_data_type;
                     break;
 
+                case WINED3DSPR_UAV:
+                    if (reg_idx >= ARRAY_SIZE(reg_maps->uav_resource_info))
+                    {
+                        ERR("Invalid UAV resource index %u.\n", reg_idx);
+                        break;
+                    }
+                    reg_maps->uav_resource_info[reg_idx].type = semantic->resource_type;
+                    reg_maps->uav_resource_info[reg_idx].data_type = semantic->resource_data_type;
+                    break;
+
                 default:
                     TRACE("Not recording DCL register type %#x.\n", semantic->reg.reg.type);
                     break;
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 24c10fa..02d2f58 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -184,6 +184,7 @@ static inline enum complex_fixup get_complex_fixup(struct color_fixup_desc fixup
 #define MAX_CONSTANT_BUFFERS        15
 #define MAX_SAMPLER_OBJECTS         16
 #define MAX_SHADER_RESOURCE_VIEWS   128
+#define MAX_UNORDERED_ACCESS_VIEWS  8
 #define MAX_VERTEX_BLENDS           4
 #define MAX_MULTISAMPLE_TYPES       8
 
@@ -836,6 +837,7 @@ struct wined3d_shader_reg_maps
     DWORD sampler_comparison_mode;
     BYTE bumpmat;                                   /* MAX_TEXTURES, 8 */
     BYTE luminanceparams;                           /* MAX_TEXTURES, 8 */
+    struct wined3d_shader_resource_info uav_resource_info[MAX_UNORDERED_ACCESS_VIEWS];
 
     WORD usesnrm        : 1;
     WORD vpos           : 1;




More information about the wine-cvs mailing list