[PATCH 2/5] wined3d: Get rid of unnecessary enum wined3d_data_type values.

Matteo Bruni mbruni at codeweavers.com
Tue Jun 12 11:41:12 CDT 2018


Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
---
This is what eventually came out of trying to rework
https://source.winehq.org/patches/data/147005 to use
shader_glsl_sprintf_cast(). Tests seem to still pass.

Aside from that, I don't know if there is any plan to use the values
I'm dropping in this patch in the future. If so, just shoot this
patch (and the next) down.

 dlls/wined3d/glsl_shader.c     | 12 -----------
 dlls/wined3d/shader.c          | 12 -----------
 dlls/wined3d/shader_sm4.c      | 48 ++++++++++++++++++------------------------
 dlls/wined3d/wined3d_private.h |  6 ------
 4 files changed, 21 insertions(+), 57 deletions(-)

diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index 86259ae4755..ffe0c2d7e14 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -2523,8 +2523,6 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont
         switch (reg_maps->resource_info[entry->resource_idx].data_type)
         {
             case WINED3D_DATA_FLOAT:
-            case WINED3D_DATA_UNORM:
-            case WINED3D_DATA_SNORM:
                 sampler_type_prefix = "";
                 break;
 
@@ -2641,8 +2639,6 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont
         switch (reg_maps->uav_resource_info[i].data_type)
         {
             case WINED3D_DATA_FLOAT:
-            case WINED3D_DATA_UNORM:
-            case WINED3D_DATA_SNORM:
                 image_type_prefix = "";
                 read_format = "r32f";
                 break;
@@ -3093,8 +3089,6 @@ static void shader_glsl_get_register_name(const struct wined3d_shader_register *
                         case WINED3D_DATA_INT:
                             sprintf(register_name, "%#x", reg->u.immconst_data[0]);
                             break;
-                        case WINED3D_DATA_RESOURCE:
-                        case WINED3D_DATA_SAMPLER:
                         case WINED3D_DATA_UINT:
                             sprintf(register_name, "%#xu", reg->u.immconst_data[0]);
                             break;
@@ -3129,8 +3123,6 @@ static void shader_glsl_get_register_name(const struct wined3d_shader_register *
                                     reg->u.immconst_data[0], reg->u.immconst_data[1],
                                     reg->u.immconst_data[2], reg->u.immconst_data[3]);
                             break;
-                        case WINED3D_DATA_RESOURCE:
-                        case WINED3D_DATA_SAMPLER:
                         case WINED3D_DATA_UINT:
                             sprintf(register_name, "uvec4(%#xu, %#xu, %#xu, %#xu)",
                                     reg->u.immconst_data[0], reg->u.immconst_data[1],
@@ -3342,8 +3334,6 @@ static void shader_glsl_sprintf_cast(struct wined3d_string_buffer *dst_param, co
             case WINED3D_DATA_INT:
                 string_buffer_sprintf(dst_param, "floatBitsToInt(%s)", src_param);
                 return;
-            case WINED3D_DATA_RESOURCE:
-            case WINED3D_DATA_SAMPLER:
             case WINED3D_DATA_UINT:
                 string_buffer_sprintf(dst_param, "floatBitsToUint(%s)", src_param);
                 return;
@@ -3457,8 +3447,6 @@ static DWORD shader_glsl_append_dst_ext(struct wined3d_string_buffer *buffer,
                 shader_addline(buffer, "%s%s = %sintBitsToFloat(",
                         glsl_dst.reg_name, glsl_dst.mask_str, shift_glsl_tab[dst->shift]);
                 break;
-            case WINED3D_DATA_RESOURCE:
-            case WINED3D_DATA_SAMPLER:
             case WINED3D_DATA_UINT:
                 shader_addline(buffer, "%s%s = %suintBitsToFloat(",
                         glsl_dst.reg_name, glsl_dst.mask_str, shift_glsl_tab[dst->shift]);
diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c
index 20d4f0773dd..a2c3f00559a 100644
--- a/dlls/wined3d/shader.c
+++ b/dlls/wined3d/shader.c
@@ -2134,14 +2134,6 @@ static void shader_dump_decl_usage(struct wined3d_string_buffer *buffer,
                 shader_addline(buffer, " (uint)");
                 break;
 
-            case WINED3D_DATA_UNORM:
-                shader_addline(buffer, " (unorm)");
-                break;
-
-            case WINED3D_DATA_SNORM:
-                shader_addline(buffer, " (snorm)");
-                break;
-
             default:
                 shader_addline(buffer, " (unknown)");
                 break;
@@ -2448,8 +2440,6 @@ static void shader_dump_register(struct wined3d_string_buffer *buffer,
                     case WINED3D_DATA_INT:
                         shader_addline(buffer, "%d", reg->u.immconst_data[0]);
                         break;
-                    case WINED3D_DATA_RESOURCE:
-                    case WINED3D_DATA_SAMPLER:
                     case WINED3D_DATA_UINT:
                         shader_addline(buffer, "%u", reg->u.immconst_data[0]);
                         break;
@@ -2472,8 +2462,6 @@ static void shader_dump_register(struct wined3d_string_buffer *buffer,
                                 reg->u.immconst_data[0], reg->u.immconst_data[1],
                                 reg->u.immconst_data[2], reg->u.immconst_data[3]);
                         break;
-                    case WINED3D_DATA_RESOURCE:
-                    case WINED3D_DATA_SAMPLER:
                     case WINED3D_DATA_UINT:
                         shader_addline(buffer, "%u, %u, %u, %u",
                                 reg->u.immconst_data[0], reg->u.immconst_data[1],
diff --git a/dlls/wined3d/shader_sm4.c b/dlls/wined3d/shader_sm4.c
index b119e8feaa8..69947d21c14 100644
--- a/dlls/wined3d/shader_sm4.c
+++ b/dlls/wined3d/shader_sm4.c
@@ -509,8 +509,8 @@ static const enum wined3d_shader_resource_type resource_type_table[] =
 static const enum wined3d_data_type data_type_table[] =
 {
     /* 0 */                         WINED3D_DATA_FLOAT,
-    /* WINED3D_SM4_DATA_UNORM */    WINED3D_DATA_UNORM,
-    /* WINED3D_SM4_DATA_SNORM */    WINED3D_DATA_SNORM,
+    /* WINED3D_SM4_DATA_UNORM */    WINED3D_DATA_FLOAT,
+    /* WINED3D_SM4_DATA_SNORM */    WINED3D_DATA_FLOAT,
     /* WINED3D_SM4_DATA_INT */      WINED3D_DATA_INT,
     /* WINED3D_SM4_DATA_UINT */     WINED3D_DATA_UINT,
     /* WINED3D_SM4_DATA_FLOAT */    WINED3D_DATA_FLOAT,
@@ -565,8 +565,8 @@ static void shader_sm4_read_dcl_resource(struct wined3d_shader_instruction *ins,
 {
     enum wined3d_sm4_resource_type resource_type;
     enum wined3d_sm4_data_type data_type;
-    enum wined3d_data_type reg_data_type;
     DWORD components;
+    BOOL uav;
 
     resource_type = (opcode_token & WINED3D_SM4_RESOURCE_TYPE_MASK) >> WINED3D_SM4_RESOURCE_TYPE_SHIFT;
     if (!resource_type || (resource_type >= ARRAY_SIZE(resource_type_table)))
@@ -578,8 +578,8 @@ static void shader_sm4_read_dcl_resource(struct wined3d_shader_instruction *ins,
     {
         ins->declaration.semantic.resource_type = resource_type_table[resource_type];
     }
-    reg_data_type = opcode == WINED3D_SM4_OP_DCL_RESOURCE ? WINED3D_DATA_RESOURCE : WINED3D_DATA_UAV;
-    shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], reg_data_type, &ins->declaration.semantic.reg);
+    uav = opcode != WINED3D_SM4_OP_DCL_RESOURCE;
+    shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_UINT, &ins->declaration.semantic.reg);
 
     components = *tokens++;
     if ((components & 0xfff0) != (components & 0xf) * 0x1110)
@@ -596,7 +596,7 @@ static void shader_sm4_read_dcl_resource(struct wined3d_shader_instruction *ins,
         ins->declaration.semantic.resource_data_type = data_type_table[data_type];
     }
 
-    if (reg_data_type == WINED3D_DATA_UAV)
+    if (uav)
         ins->flags = (opcode_token & WINED3D_SM5_UAV_FLAGS_MASK) >> WINED3D_SM5_UAV_FLAGS_SHIFT;
 }
 
@@ -616,14 +616,14 @@ static void shader_sm4_read_dcl_sampler(struct wined3d_shader_instruction *ins,
     ins->flags = (opcode_token & WINED3D_SM4_SAMPLER_MODE_MASK) >> WINED3D_SM4_SAMPLER_MODE_SHIFT;
     if (ins->flags & ~WINED3D_SM4_SAMPLER_COMPARISON)
         FIXME("Unhandled sampler mode %#x.\n", ins->flags);
-    shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_SAMPLER, &ins->declaration.dst);
+    shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_UINT, &ins->declaration.dst);
 }
 
 static void shader_sm4_read_dcl_index_range(struct wined3d_shader_instruction *ins,
         DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count,
         struct wined3d_sm4_data *priv)
 {
-    shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_OPAQUE,
+    shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_UINT,
             &ins->declaration.index_range.first_register);
     ins->declaration.index_range.last_register = *tokens;
 }
@@ -731,7 +731,7 @@ static void shader_sm5_read_fcall(struct wined3d_shader_instruction *ins,
         struct wined3d_sm4_data *priv)
 {
     priv->src_param[0].reg.u.fp_body_idx = *tokens++;
-    shader_sm4_read_src_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_OPAQUE, &priv->src_param[0]);
+    shader_sm4_read_src_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_UINT, &priv->src_param[0]);
 }
 
 static void shader_sm5_read_dcl_function_body(struct wined3d_shader_instruction *ins,
@@ -812,7 +812,7 @@ static void shader_sm5_read_dcl_uav_raw(struct wined3d_shader_instruction *ins,
         DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count,
         struct wined3d_sm4_data *priv)
 {
-    shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_UAV, &ins->declaration.dst);
+    shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_UINT, &ins->declaration.dst);
     ins->flags = (opcode_token & WINED3D_SM5_UAV_FLAGS_MASK) >> WINED3D_SM5_UAV_FLAGS_SHIFT;
 }
 
@@ -820,7 +820,7 @@ static void shader_sm5_read_dcl_uav_structured(struct wined3d_shader_instruction
         DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count,
         struct wined3d_sm4_data *priv)
 {
-    shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_UAV,
+    shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_UINT,
             &ins->declaration.structured_resource.reg);
     ins->flags = (opcode_token & WINED3D_SM5_UAV_FLAGS_MASK) >> WINED3D_SM5_UAV_FLAGS_SHIFT;
     ins->declaration.structured_resource.byte_stride = *tokens;
@@ -854,7 +854,7 @@ static void shader_sm5_read_dcl_resource_structured(struct wined3d_shader_instru
         DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count,
         struct wined3d_sm4_data *priv)
 {
-    shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_RESOURCE,
+    shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_UINT,
             &ins->declaration.structured_resource.reg);
     ins->declaration.structured_resource.byte_stride = *tokens;
     if (ins->declaration.structured_resource.byte_stride % 4)
@@ -865,7 +865,7 @@ static void shader_sm5_read_dcl_resource_raw(struct wined3d_shader_instruction *
         DWORD opcode, DWORD opcode_token, const DWORD *tokens, unsigned int token_count,
         struct wined3d_sm4_data *priv)
 {
-    shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_RESOURCE, &ins->declaration.dst);
+    shader_sm4_read_dst_param(priv, &tokens, &tokens[token_count], WINED3D_DATA_UINT, &ins->declaration.dst);
 }
 
 static void shader_sm5_read_sync(struct wined3d_shader_instruction *ins,
@@ -875,15 +875,13 @@ static void shader_sm5_read_sync(struct wined3d_shader_instruction *ins,
     ins->flags = (opcode_token & WINED3D_SM5_SYNC_FLAGS_MASK) >> WINED3D_SM5_SYNC_FLAGS_SHIFT;
 }
 
-/*
- * f -> WINED3D_DATA_FLOAT
- * i -> WINED3D_DATA_INT
- * u -> WINED3D_DATA_UINT
- * O -> WINED3D_DATA_OPAQUE
- * R -> WINED3D_DATA_RESOURCE
- * S -> WINED3D_DATA_SAMPLER
- * U -> WINED3D_DATA_UAV
- */
+/* f -> FLOAT
+ * i -> INT
+ * u -> UINT
+ * O -> OPAQUE
+ * R -> RESOURCE
+ * S -> SAMPLER
+ * U -> UAV */
 static const struct wined3d_sm4_opcode_info opcode_table[] =
 {
     {WINED3D_SM4_OP_ADD,                              WINED3DSIH_ADD,                              "f",    "ff"},
@@ -1207,15 +1205,11 @@ static enum wined3d_data_type map_data_type(char t)
         case 'i':
             return WINED3D_DATA_INT;
         case 'u':
-            return WINED3D_DATA_UINT;
         case 'O':
-            return WINED3D_DATA_OPAQUE;
         case 'R':
-            return WINED3D_DATA_RESOURCE;
         case 'S':
-            return WINED3D_DATA_SAMPLER;
         case 'U':
-            return WINED3D_DATA_UAV;
+            return WINED3D_DATA_UINT;
         default:
             ERR("Invalid data type '%c'.\n", t);
             return WINED3D_DATA_FLOAT;
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index d190f7ccfd6..3d637005353 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -503,13 +503,7 @@ enum wined3d_data_type
 {
     WINED3D_DATA_FLOAT,
     WINED3D_DATA_INT,
-    WINED3D_DATA_RESOURCE,
-    WINED3D_DATA_SAMPLER,
-    WINED3D_DATA_UAV,
     WINED3D_DATA_UINT,
-    WINED3D_DATA_UNORM,
-    WINED3D_DATA_SNORM,
-    WINED3D_DATA_OPAQUE,
 };
 
 enum wined3d_immconst_type
-- 
2.16.1




More information about the wine-devel mailing list