wined3d: Don't define nameless structs or unions.

Francois Gouget fgouget at free.fr
Mon Aug 31 04:52:07 CDT 2009


Fixes compilation on systems that don't support nameless unions or structs.
---

There is no reason to use nameless unions or structs in our own private 
structures. One may want to review the names I gave to these structs / 
unions. Maybe better names can be found.


 dlls/wined3d/arb_program_shader.c |   88 ++++++++++++++++++------------------
 1 files changed, 44 insertions(+), 44 deletions(-)

diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c
index dd35113..8cc51b5 100644
--- a/dlls/wined3d/arb_program_shader.c
+++ b/dlls/wined3d/arb_program_shader.c
@@ -105,9 +105,9 @@ struct control_frame
     BOOL                            outer_loop;
     union
     {
-        unsigned int                loop_no;
-        unsigned int                ifc_no;
-    };
+        unsigned int                loop;
+        unsigned int                ifc;
+    } no;
     struct wined3d_shader_loop_control loop_control;
     BOOL                            had_else;
 };
@@ -159,13 +159,13 @@ struct arb_vs_compile_args
             char                    clip_control[2];
         }                           boolclip;
         DWORD                       boolclip_compare;
-    };
+    } clip;
     DWORD                           ps_signature;
     union
     {
-        unsigned char               vertex_samplers[4];
-        DWORD                       vertex_samplers_compare;
-    };
+        unsigned char               samplers[4];
+        DWORD                       samplers_compare;
+    } vertex;
     unsigned char                   loop_ctrl[MAX_CONST_I][3];
 };
 
@@ -1241,7 +1241,7 @@ static void shader_hw_sample(const struct wined3d_shader_instruction *ins, DWORD
     /* Fragment samplers always have indentity mapping */
     if(sampler_idx >= MAX_FRAGMENT_SAMPLERS)
     {
-        sampler_idx = priv->cur_vs_args->vertex_samplers[sampler_idx - MAX_FRAGMENT_SAMPLERS];
+        sampler_idx = priv->cur_vs_args->vertex.samplers[sampler_idx - MAX_FRAGMENT_SAMPLERS];
     }
 
     if (flags & TEX_DERIV)
@@ -2590,8 +2590,8 @@ static void shader_hw_loop(const struct wined3d_shader_instruction *ins)
         if(priv->loop_depth > 1) shader_addline(buffer, "PUSHA aL;\n");
         /* The constant loader makes sure to load -1 into iX.w */
         shader_addline(buffer, "ARLC aL, %s.xywz;\n", src_name);
-        shader_addline(buffer, "BRA loop_%u_end (LE.x);\n", control_frame->loop_no);
-        shader_addline(buffer, "loop_%u_start:\n", control_frame->loop_no);
+        shader_addline(buffer, "BRA loop_%u_end (LE.x);\n", control_frame->no.loop);
+        shader_addline(buffer, "loop_%u_start:\n", control_frame->no.loop);
     }
     else
     {
@@ -2617,8 +2617,8 @@ static void shader_hw_rep(const struct wined3d_shader_instruction *ins)
         if(priv->loop_depth > 1) shader_addline(buffer, "PUSHA aL;\n");
 
         shader_addline(buffer, "ARLC aL, %s.xywz;\n", src_name);
-        shader_addline(buffer, "BRA loop_%u_end (LE.x);\n", control_frame->loop_no);
-        shader_addline(buffer, "loop_%u_start:\n", control_frame->loop_no);
+        shader_addline(buffer, "BRA loop_%u_end (LE.x);\n", control_frame->no.loop);
+        shader_addline(buffer, "loop_%u_start:\n", control_frame->no.loop);
     }
     else
     {
@@ -2638,8 +2638,8 @@ static void shader_hw_endloop(const struct wined3d_shader_instruction *ins)
         struct control_frame *control_frame = LIST_ENTRY(e, struct control_frame, entry);
 
         shader_addline(buffer, "ARAC aL.xy, aL;\n");
-        shader_addline(buffer, "BRA loop_%u_start (GT.x);\n", control_frame->loop_no);
-        shader_addline(buffer, "loop_%u_end:\n", control_frame->loop_no);
+        shader_addline(buffer, "BRA loop_%u_start (GT.x);\n", control_frame->no.loop);
+        shader_addline(buffer, "loop_%u_end:\n", control_frame->no.loop);
 
         if(priv->loop_depth > 1) shader_addline(buffer, "POPA aL;\n");
     }
@@ -2661,8 +2661,8 @@ static void shader_hw_endrep(const struct wined3d_shader_instruction *ins)
         struct control_frame *control_frame = LIST_ENTRY(e, struct control_frame, entry);
 
         shader_addline(buffer, "ARAC aL.xy, aL;\n");
-        shader_addline(buffer, "BRA loop_%u_start (GT.x);\n", control_frame->loop_no);
-        shader_addline(buffer, "loop_%u_end:\n", control_frame->loop_no);
+        shader_addline(buffer, "BRA loop_%u_start (GT.x);\n", control_frame->no.loop);
+        shader_addline(buffer, "loop_%u_end:\n", control_frame->no.loop);
 
         if(priv->loop_depth > 1) shader_addline(buffer, "POPA aL;\n");
     }
@@ -2692,7 +2692,7 @@ static void shader_hw_break(const struct wined3d_shader_instruction *ins)
 
     if(vshader)
     {
-        shader_addline(buffer, "BRA loop_%u_end;\n", control_frame->loop_no);
+        shader_addline(buffer, "BRA loop_%u_end;\n", control_frame->no.loop);
     }
     else
     {
@@ -2750,7 +2750,7 @@ static void shader_hw_breakc(const struct wined3d_shader_instruction *ins)
          * away the subtraction result
          */
         shader_addline(buffer, "SUBC TA, %s, %s;\n", src_name0, src_name1);
-        shader_addline(buffer, "BRA loop_%u_end (%s.x);\n", control_frame->loop_no, comp);
+        shader_addline(buffer, "BRA loop_%u_end (%s.x);\n", control_frame->no.loop, comp);
     }
     else
     {
@@ -2778,7 +2778,7 @@ static void shader_hw_ifc(const struct wined3d_shader_instruction *ins)
         /* Invert the flag. We jump to the else label if the condition is NOT true */
         comp = get_compare(invert_compare(ins->flags));
         shader_addline(buffer, "SUBC TA, %s, %s;\n", src_name0, src_name1);
-        shader_addline(buffer, "BRA ifc_%u_else (%s.x);\n", control_frame->ifc_no, comp);
+        shader_addline(buffer, "BRA ifc_%u_else (%s.x);\n", control_frame->no.ifc, comp);
     }
     else
     {
@@ -2798,8 +2798,8 @@ static void shader_hw_else(const struct wined3d_shader_instruction *ins)
 
     if(vshader)
     {
-        shader_addline(buffer, "BRA ifc_%u_endif;\n", control_frame->ifc_no);
-        shader_addline(buffer, "ifc_%u_else:\n", control_frame->ifc_no);
+        shader_addline(buffer, "BRA ifc_%u_endif;\n", control_frame->no.ifc);
+        shader_addline(buffer, "ifc_%u_else:\n", control_frame->no.ifc);
         control_frame->had_else = TRUE;
     }
     else
@@ -2820,12 +2820,12 @@ static void shader_hw_endif(const struct wined3d_shader_instruction *ins)
     {
         if(control_frame->had_else)
         {
-            shader_addline(buffer, "ifc_%u_endif:\n", control_frame->ifc_no);
+            shader_addline(buffer, "ifc_%u_endif:\n", control_frame->no.ifc);
         }
         else
         {
             shader_addline(buffer, "#No else branch. else is endif\n");
-            shader_addline(buffer, "ifc_%u_else:\n", control_frame->ifc_no);
+            shader_addline(buffer, "ifc_%u_else:\n", control_frame->no.ifc);
         }
     }
     else
@@ -2920,14 +2920,14 @@ static void vshader_add_footer(IWineD3DVertexShaderImpl *This, struct wined3d_sh
             shader_addline(buffer, "DP4 result.clip[%u].x, TMP_OUT, state.clip[%u].plane;\n", i, i);
         }
     }
-    else if(args->boolclip.clip_control[0])
+    else if(args->clip.boolclip.clip_control[0])
     {
         unsigned int cur_clip = 0;
         char component[4] = {'x', 'y', 'z', 'w'};
 
         for(i = 0; i < GL_LIMITS(clipplanes); i++)
         {
-            if(args->boolclip.clip_control[1] & (1 << i))
+            if(args->clip.boolclip.clip_control[1] & (1 << i))
             {
                 shader_addline(buffer, "DP4 TA.%c, TMP_OUT, state.clip[%u].plane;\n",
                                component[cur_clip++], i);
@@ -2949,7 +2949,7 @@ static void vshader_add_footer(IWineD3DVertexShaderImpl *This, struct wined3d_sh
                 break;
         }
         shader_addline(buffer, "MOV result.texcoord[%u], TA;\n",
-                       args->boolclip.clip_control[0] - 1);
+                       args->clip.boolclip.clip_control[0] - 1);
     }
 
     /* Z coord [0;1]->[-1;1] mapping, see comment in transform_projection in state.c
@@ -3997,9 +3997,9 @@ static inline BOOL vs_args_equal(const struct arb_vs_compile_args *stored, const
                                  const DWORD use_map, BOOL skip_int) {
     if((stored->super.swizzle_map & use_map) != new->super.swizzle_map) return FALSE;
     if(stored->super.fog_src != new->super.fog_src) return FALSE;
-    if(stored->boolclip_compare != new->boolclip_compare) return FALSE;
+    if(stored->clip.boolclip_compare != new->clip.boolclip_compare) return FALSE;
     if(stored->ps_signature != new->ps_signature) return FALSE;
-    if(stored->vertex_samplers_compare != new->vertex_samplers_compare) return FALSE;
+    if(stored->vertex.samplers_compare != new->vertex.samplers_compare) return FALSE;
     if(skip_int) return TRUE;
 
     return memcmp(stored->loop_ctrl, new->loop_ctrl, sizeof(stored->loop_ctrl)) == 0;
@@ -4118,46 +4118,46 @@ static inline void find_arb_vs_compile_args(IWineD3DVertexShaderImpl *shader, IW
     const struct wined3d_gl_info *gl_info = &dev->adapter->gl_info;
     find_vs_compile_args(shader, stateblock, &args->super);
 
-    args->boolclip_compare = 0;
+    args->clip.boolclip_compare = 0;
     if(use_ps(stateblock))
     {
         IWineD3DPixelShaderImpl *ps = (IWineD3DPixelShaderImpl *) stateblock->pixelShader;
         struct arb_pshader_private *shader_priv = ps->backend_priv;
         args->ps_signature = shader_priv->input_signature_idx;
 
-        args->boolclip.clip_control[0] = shader_priv->clipplane_emulation + 1;
+        args->clip.boolclip.clip_control[0] = shader_priv->clipplane_emulation + 1;
     }
     else
     {
         args->ps_signature = ~0;
         if(!dev->vs_clipping)
         {
-            args->boolclip.clip_control[0] = ffp_clip_emul(stateblock) ? GL_LIMITS(texture_stages) : 0;
+            args->clip.boolclip.clip_control[0] = ffp_clip_emul(stateblock) ? GL_LIMITS(texture_stages) : 0;
         }
-        /* Otherwise: Setting boolclip_compare set clip_control[0] to 0 */
+        /* Otherwise: Setting clip.boolclip_compare set clip_control[0] to 0 */
     }
 
-    if(args->boolclip.clip_control[0])
+    if(args->clip.boolclip.clip_control[0])
     {
         if(stateblock->renderState[WINED3DRS_CLIPPING])
         {
-            args->boolclip.clip_control[1] = stateblock->renderState[WINED3DRS_CLIPPLANEENABLE];
+            args->clip.boolclip.clip_control[1] = stateblock->renderState[WINED3DRS_CLIPPLANEENABLE];
         }
-        /* clip_control[1] was set to 0 by setting boolclip_compare to 0 */
+        /* clip_control[1] was set to 0 by setting clip.boolclip_compare to 0 */
     }
 
     /* This forces all local boolean constants to 1 to make them stateblock independent */
-    args->boolclip.bools = shader->baseShader.reg_maps.local_bool_consts;
+    args->clip.boolclip.bools = shader->baseShader.reg_maps.local_bool_consts;
     /* TODO: Figure out if it would be better to store bool constants as bitmasks in the stateblock */
     for(i = 0; i < MAX_CONST_B; i++)
     {
-        if(stateblock->vertexShaderConstantB[i]) args->boolclip.bools |= ( 1 << i);
+        if(stateblock->vertexShaderConstantB[i]) args->clip.boolclip.bools |= ( 1 << i);
     }
 
-    args->vertex_samplers[0] = dev->texUnitMap[MAX_FRAGMENT_SAMPLERS + 0];
-    args->vertex_samplers[1] = dev->texUnitMap[MAX_FRAGMENT_SAMPLERS + 1];
-    args->vertex_samplers[2] = dev->texUnitMap[MAX_FRAGMENT_SAMPLERS + 2];
-    args->vertex_samplers[3] = 0;
+    args->vertex.samplers[0] = dev->texUnitMap[MAX_FRAGMENT_SAMPLERS + 0];
+    args->vertex.samplers[1] = dev->texUnitMap[MAX_FRAGMENT_SAMPLERS + 1];
+    args->vertex.samplers[2] = dev->texUnitMap[MAX_FRAGMENT_SAMPLERS + 2];
+    args->vertex.samplers[3] = 0;
 
     /* Skip if unused or local */
     int_skip = ~shader->baseShader.reg_maps.integer_constants | shader->baseShader.reg_maps.local_int_consts;
@@ -4643,7 +4643,7 @@ static inline BOOL get_bool_const(const struct wined3d_shader_instruction *ins,
     }
     else
     {
-        if(vshader) bools = priv->cur_vs_args->boolclip.bools;
+        if(vshader) bools = priv->cur_vs_args->clip.boolclip.bools;
         else bools = priv->cur_ps_args->bools;
         return bools & flag;
     }
@@ -4804,7 +4804,7 @@ static void shader_arb_handle_instruction(const struct wined3d_shader_instructio
 
         if(priv->target_version >= NV2)
         {
-            control_frame->loop_no = priv->num_loops++;
+            control_frame->no.loop = priv->num_loops++;
             priv->loop_depth++;
         }
         else
@@ -4933,7 +4933,7 @@ static void shader_arb_handle_instruction(const struct wined3d_shader_instructio
         /* IF(bool) and if_cond(a, b) use the same ELSE and ENDIF tokens */
         control_frame = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*control_frame));
         control_frame->type = IFC;
-        control_frame->ifc_no = priv->num_ifcs++;
+        control_frame->no.ifc = priv->num_ifcs++;
         list_add_head(&priv->control_frames, &control_frame->entry);
     }
     else if(ins->handler_idx == WINED3DSIH_ELSE)
-- 
1.6.3.3




More information about the wine-patches mailing list