Henri Verbeet : wined3d: Pas a wined3d_vec4 structure to shader_arb_load_constants_f().

Alexandre Julliard julliard at wine.codeweavers.com
Tue Apr 26 10:33:42 CDT 2016


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

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Mon Apr 25 17:19:33 2016 +0200

wined3d: Pas a wined3d_vec4 structure to shader_arb_load_constants_f().

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

---

 dlls/wined3d/arb_program_shader.c | 91 +++++++++++++++++++++++----------------
 dlls/wined3d/utils.c              |  8 ++++
 dlls/wined3d/wined3d_private.h    |  3 +-
 3 files changed, 65 insertions(+), 37 deletions(-)

diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c
index fac97fe..a48773f 100644
--- a/dlls/wined3d/arb_program_shader.c
+++ b/dlls/wined3d/arb_program_shader.c
@@ -360,21 +360,20 @@ static unsigned int reserved_vs_const(const struct arb_vshader_private *shader_d
  *  or GL_FRAGMENT_PROGRAM_ARB (for pixel shaders)
  */
 /* Context activation is done by the caller. */
-static unsigned int shader_arb_load_constantsF(const struct wined3d_shader *shader,
+static unsigned int shader_arb_load_constants_f(const struct wined3d_shader *shader,
         const struct wined3d_gl_info *gl_info, GLuint target_type, unsigned int max_constants,
-        const float *constants, char *dirty_consts)
+        const struct wined3d_vec4 *constants, char *dirty_consts)
 {
     struct wined3d_shader_lconst *lconst;
-    DWORD i, j;
-    unsigned int ret;
+    unsigned int ret, i, j;
 
     if (TRACE_ON(d3d_constants))
     {
-        for(i = 0; i < max_constants; i++) {
-            if(!dirty_consts[i]) continue;
-            TRACE_(d3d_constants)("Loading constants %i: %f, %f, %f, %f\n", i,
-                        constants[i * 4 + 0], constants[i * 4 + 1],
-                        constants[i * 4 + 2], constants[i * 4 + 3]);
+        for (i = 0; i < max_constants; ++i)
+        {
+            if (!dirty_consts[i])
+                continue;
+            TRACE_(d3d_constants)("Loading constant %u: %s.\n", i, debug_vec4(&constants[i]));
         }
     }
 
@@ -387,26 +386,39 @@ static unsigned int shader_arb_load_constantsF(const struct wined3d_shader *shad
         /* ps 1.x supports only 8 constants, clamp only those. When switching between 1.x and higher
          * shaders, the first 8 constants are marked dirty for reload
          */
-        for(; i < min(8, max_constants); i++) {
-            if(!dirty_consts[i]) continue;
+        for (; i < min(8, max_constants); ++i)
+        {
+            if (!dirty_consts[i])
+                continue;
             dirty_consts[i] = 0;
 
-            j = 4 * i;
-            if (constants[j + 0] > 1.0f) lcl_const[0] = 1.0f;
-            else if (constants[j + 0] < -1.0f) lcl_const[0] = -1.0f;
-            else lcl_const[0] = constants[j + 0];
+            if (constants[i].x > 1.0f)
+                lcl_const[0] = 1.0f;
+            else if (constants[i].x < -1.0f)
+                lcl_const[0] = -1.0f;
+            else
+                lcl_const[0] = constants[i].x;
 
-            if (constants[j + 1] > 1.0f) lcl_const[1] = 1.0f;
-            else if (constants[j + 1] < -1.0f) lcl_const[1] = -1.0f;
-            else lcl_const[1] = constants[j + 1];
+            if (constants[i].y > 1.0f)
+                lcl_const[1] = 1.0f;
+            else if (constants[i].y < -1.0f)
+                lcl_const[1] = -1.0f;
+            else
+                lcl_const[1] = constants[i].y;
 
-            if (constants[j + 2] > 1.0f) lcl_const[2] = 1.0f;
-            else if (constants[j + 2] < -1.0f) lcl_const[2] = -1.0f;
-            else lcl_const[2] = constants[j + 2];
+            if (constants[i].z > 1.0f)
+                lcl_const[2] = 1.0f;
+            else if (constants[i].z < -1.0f)
+                lcl_const[2] = -1.0f;
+            else
+                lcl_const[2] = constants[i].z;
 
-            if (constants[j + 3] > 1.0f) lcl_const[3] = 1.0f;
-            else if (constants[j + 3] < -1.0f) lcl_const[3] = -1.0f;
-            else lcl_const[3] = constants[j + 3];
+            if (constants[i].w > 1.0f)
+                lcl_const[3] = 1.0f;
+            else if (constants[i].w < -1.0f)
+                lcl_const[3] = -1.0f;
+            else
+                lcl_const[3] = constants[i].w;
 
             GL_EXTCALL(glProgramEnvParameter4fvARB(target_type, i, lcl_const));
         }
@@ -427,23 +439,30 @@ static unsigned int shader_arb_load_constantsF(const struct wined3d_shader *shad
          *
         GL_EXTCALL(glProgramEnvParameters4fvEXT(target_type, i, max_constants, constants + (i * 4)));
          */
-        for(; i < max_constants; i++) {
-            if(!dirty_consts[i]) continue;
+        for (; i < max_constants; ++i)
+        {
+            if (!dirty_consts[i])
+                continue;
 
             /* Find the next block of dirty constants */
             dirty_consts[i] = 0;
             j = i;
-            for(i++; (i < max_constants) && dirty_consts[i]; i++) {
+            for (++i; (i < max_constants) && dirty_consts[i]; ++i)
+            {
                 dirty_consts[i] = 0;
             }
 
-            GL_EXTCALL(glProgramEnvParameters4fvEXT(target_type, j, i - j, constants + (j * 4)));
+            GL_EXTCALL(glProgramEnvParameters4fvEXT(target_type, j, i - j, &constants[j].x));
         }
-    } else {
-        for(; i < max_constants; i++) {
-            if(dirty_consts[i]) {
+    }
+    else
+    {
+        for (; i < max_constants; ++i)
+        {
+            if (dirty_consts[i])
+            {
                 dirty_consts[i] = 0;
-                GL_EXTCALL(glProgramEnvParameter4fvARB(target_type, i, constants + (i * 4)));
+                GL_EXTCALL(glProgramEnvParameter4fvARB(target_type, i, &constants[i].x));
             }
         }
     }
@@ -675,8 +694,8 @@ static void shader_arb_load_constants_internal(struct shader_arb_priv *priv,
         const struct arb_vs_compiled_shader *gl_shader = priv->compiled_vprog;
 
         /* Load DirectX 9 float constants for vertex shader */
-        priv->highest_dirty_vs_const = shader_arb_load_constantsF(vshader, gl_info, GL_VERTEX_PROGRAM_ARB,
-                priv->highest_dirty_vs_const, state->vs_consts_f, priv->vshader_const_dirty);
+        priv->highest_dirty_vs_const = shader_arb_load_constants_f(vshader, gl_info, GL_VERTEX_PROGRAM_ARB,
+                priv->highest_dirty_vs_const, (struct wined3d_vec4 *)state->vs_consts_f, priv->vshader_const_dirty);
         shader_arb_vs_local_constants(gl_shader, context, state);
     }
 
@@ -687,8 +706,8 @@ static void shader_arb_load_constants_internal(struct shader_arb_priv *priv,
         UINT rt_height = state->fb->render_targets[0]->height;
 
         /* Load DirectX 9 float constants for pixel shader */
-        priv->highest_dirty_ps_const = shader_arb_load_constantsF(pshader, gl_info, GL_FRAGMENT_PROGRAM_ARB,
-                priv->highest_dirty_ps_const, state->ps_consts_f, priv->pshader_const_dirty);
+        priv->highest_dirty_ps_const = shader_arb_load_constants_f(pshader, gl_info, GL_FRAGMENT_PROGRAM_ARB,
+                priv->highest_dirty_ps_const, (struct wined3d_vec4 *)state->ps_consts_f, priv->pshader_const_dirty);
         shader_arb_ps_local_constants(gl_shader, context, state, rt_height);
 
         if (context->constant_update_mask & WINED3D_SHADER_CONST_PS_NP2_FIXUP)
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index c7bf5bb..e2e3ec9 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -3365,6 +3365,14 @@ const char *debug_color(const struct wined3d_color *color)
             color->r, color->g, color->b, color->a);
 }
 
+const char *debug_vec4(const struct wined3d_vec4 *v)
+{
+    if (!v)
+        return "(null)";
+    return wine_dbg_sprintf("{%.8e, %.8e, %.8e, %.8e}",
+            v->x, v->y, v->z, v->w);
+}
+
 const char *debug_d3dformat(enum wined3d_format_id format_id)
 {
     switch (format_id)
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 3cc7ece..9ce2281 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -3095,13 +3095,14 @@ const char *debug_d3dsamplerstate(enum wined3d_sampler_state state) DECLSPEC_HID
 const char *debug_d3dstate(DWORD state) DECLSPEC_HIDDEN;
 const char *debug_d3dtexturefiltertype(enum wined3d_texture_filter_type filter_type) DECLSPEC_HIDDEN;
 const char *debug_d3dtexturestate(enum wined3d_texture_stage_state state) DECLSPEC_HIDDEN;
+const char *debug_d3dtop(enum wined3d_texture_op d3dtop) DECLSPEC_HIDDEN;
 const char *debug_d3dtstype(enum wined3d_transform_state tstype) DECLSPEC_HIDDEN;
 const char *debug_d3dpool(enum wined3d_pool pool) DECLSPEC_HIDDEN;
 const char *debug_fboattachment(GLenum attachment) DECLSPEC_HIDDEN;
 const char *debug_fbostatus(GLenum status) DECLSPEC_HIDDEN;
 const char *debug_glerror(GLenum error) DECLSPEC_HIDDEN;
-const char *debug_d3dtop(enum wined3d_texture_op d3dtop) DECLSPEC_HIDDEN;
 const char *debug_shader_type(enum wined3d_shader_type shader_type) DECLSPEC_HIDDEN;
+const char *debug_vec4(const struct wined3d_vec4 *v) DECLSPEC_HIDDEN;
 void dump_color_fixup_desc(struct color_fixup_desc fixup) DECLSPEC_HIDDEN;
 
 BOOL is_invalid_op(const struct wined3d_state *state, int stage,




More information about the wine-cvs mailing list