[WINED3D 8/7] Correct implementation of D3DSIO_LOOP

Jason Green jave27 at gmail.com
Fri Jun 16 22:01:20 CDT 2006


- I initially misread the specification.  src0.x is the iteration
count, not the max amount for the loop register.  This fixes that.
-------------- next part --------------
From nobody Mon Sep 17 00:00:00 2001
From: Jason <jason at jave02.(none)>
Date: Fri, 16 Jun 2006 22:59:55 -0400
Subject: [PATCH] Correct implementation of D3DSIO_LOOP

- I initially misread the specification.  src0.x is the iteration count, not the max amount for the loop register.  This fixes that.

---

 dlls/wined3d/glsl_shader.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

511d2834548225e2609113f33bc7e44d471eb514
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index e5f9d2c..7b611f4 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -333,8 +333,10 @@ void shader_generate_glsl_declarations(
     }
 
     /* Declare loop register aL */
-    if (reg_maps->loop)
+    if (reg_maps->loop) {
         shader_addline(buffer, "int aL;\n");
+        shader_addline(buffer, "int tmpInt;\n");
+    }
     
     /* Temporary variables for matrix operations */
     shader_addline(buffer, "vec4 tmp0;\n");
@@ -1154,7 +1156,8 @@ void shader_glsl_sincos(SHADER_OPCODE_AR
 
 /** Process the D3DSIO_LOOP instruction in GLSL:
  * Start a for() loop where src0.y is the initial value of aL,
- *  increment aL by src0.z while (aL < src0.x).
+ *  increment aL by src0.z for a total of src0.x iterations.
+ *  Need to use a temporary variable for this operation.
  */
 void shader_glsl_loop(SHADER_OPCODE_ARG* arg) {
     
@@ -1163,9 +1166,9 @@ void shader_glsl_loop(SHADER_OPCODE_ARG*
     char src0_mask[6];
     
     shader_glsl_add_param(arg, arg->src[0], arg->src_addr[0], TRUE, src0_reg, src0_mask, src0_str);
-    
-    shader_addline(arg->buffer, "for (aL = %s.y; aL < %s.x; aL += %s.z) {\n",
-            src0_reg, src0_reg, src0_reg);
+  
+    shader_addline(arg->buffer, "for (tmpInt = 0, aL = %s.y; tmpInt < %s.x; tmpInt++, aL += %s.z) {\n",
+                   src0_reg, src0_reg, src0_reg);
 }
 
 /** Process the D3DSIO_ENDLOOP instruction in GLSL:
-- 
1.3.3


More information about the wine-patches mailing list