Henri Verbeet : wined3d: Store used pixel shader input registers as a bitmap (AFL).

Alexandre Julliard julliard at winehq.org
Tue Feb 21 16:56:12 CST 2017


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

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Tue Feb 21 00:40:06 2017 +0100

wined3d: Store used pixel shader input registers as a bitmap (AFL).

Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/wined3d/glsl_shader.c     | 11 +++--------
 dlls/wined3d/shader.c          | 23 ++++++++---------------
 dlls/wined3d/wined3d_private.h |  2 +-
 3 files changed, 12 insertions(+), 24 deletions(-)

diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index f312f15..7bfd52f 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -1856,11 +1856,11 @@ static BOOL glsl_is_color_reg_read(const struct wined3d_shader *shader, unsigned
 {
     const struct wined3d_shader_signature *input_signature = &shader->input_signature;
     const struct wined3d_shader_reg_maps *reg_maps = &shader->reg_maps;
-    const BOOL *input_reg_used = shader->u.ps.input_reg_used;
+    DWORD input_reg_used = shader->u.ps.input_reg_used;
     unsigned int i;
 
     if (reg_maps->shader_version.major < 3)
-        return input_reg_used[idx];
+        return input_reg_used & (1u << idx);
 
     for (i = 0; i < input_signature->element_count; ++i)
     {
@@ -1871,12 +1871,7 @@ static BOOL glsl_is_color_reg_read(const struct wined3d_shader *shader, unsigned
 
         if (shader_match_semantic(input->semantic_name, WINED3D_DECL_USAGE_COLOR)
                 && input->semantic_idx == idx)
-        {
-            if (input_reg_used[input->register_idx])
-                return TRUE;
-            else
-                return FALSE;
-        }
+            return input_reg_used & (1u << input->register_idx);
     }
     return FALSE;
 }
diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c
index a3b3c3d..6278392 100644
--- a/dlls/wined3d/shader.c
+++ b/dlls/wined3d/shader.c
@@ -709,21 +709,14 @@ static BOOL shader_record_register_usage(struct wined3d_shader *shader, struct w
         case WINED3DSPR_INPUT:
             if (shader_type == WINED3D_SHADER_TYPE_PIXEL)
             {
+                /* If relative addressing is used, we must assume that all
+                 * registers are used. Even if it is a construct like v3[aL],
+                 * we can't assume that v0, v1 and v2 aren't read because aL
+                 * can be negative. */
                 if (reg->idx[0].rel_addr)
-                {
-                    /* If relative addressing is used, we must assume that all registers
-                     * are used. Even if it is a construct like v3[aL], we can't assume
-                     * that v0, v1 and v2 aren't read because aL can be negative */
-                    unsigned int i;
-                    for (i = 0; i < MAX_REG_INPUT; ++i)
-                    {
-                        shader->u.ps.input_reg_used[i] = TRUE;
-                    }
-                }
+                    shader->u.ps.input_reg_used = ~0u;
                 else
-                {
-                    shader->u.ps.input_reg_used[reg->idx[0].offset] = TRUE;
-                }
+                    shader->u.ps.input_reg_used |= 1u << reg->idx[0].offset;
             }
             else
                 reg_maps->input_registers |= 1u << reg->idx[0].offset;
@@ -3493,7 +3486,7 @@ static HRESULT pixel_shader_init(struct wined3d_shader *shader, struct wined3d_d
 
     for (i = 0; i < MAX_REG_INPUT; ++i)
     {
-        if (shader->u.ps.input_reg_used[i])
+        if (shader->u.ps.input_reg_used & (1u << i))
         {
             ++num_regs_used;
             highest_reg_used = i;
@@ -3526,7 +3519,7 @@ static HRESULT pixel_shader_init(struct wined3d_shader *shader, struct wined3d_d
         shader->u.ps.declared_in_count = 0;
         for (i = 0; i < MAX_REG_INPUT; ++i)
         {
-            if (shader->u.ps.input_reg_used[i])
+            if (shader->u.ps.input_reg_used & (1u << i))
                 shader->u.ps.input_reg_map[i] = shader->u.ps.declared_in_count++;
             else shader->u.ps.input_reg_map[i] = ~0U;
         }
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 485bc38..fd03674 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -3572,7 +3572,7 @@ struct wined3d_pixel_shader
 {
     /* Pixel shader input semantics */
     DWORD input_reg_map[MAX_REG_INPUT];
-    BOOL input_reg_used[MAX_REG_INPUT];
+    DWORD input_reg_used; /* MAX_REG_INPUT, 32 */
     unsigned int declared_in_count;
 
     /* Some information about the shader behavior */




More information about the wine-cvs mailing list