Henri Verbeet : wined3d: Explicitly pass parameters to shader_load_np2fixup_constants().

Alexandre Julliard julliard at winehq.org
Mon Oct 25 10:58:22 CDT 2010


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

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Mon Oct 25 12:33:40 2010 +0200

wined3d: Explicitly pass parameters to shader_load_np2fixup_constants().

---

 dlls/wined3d/arb_program_shader.c |   26 ++++++++++----------------
 dlls/wined3d/glsl_shader.c        |   36 +++++++++++++++---------------------
 dlls/wined3d/shader.c             |    3 ++-
 dlls/wined3d/state.c              |   11 +++++------
 dlls/wined3d/wined3d_private.h    |    4 +++-
 5 files changed, 35 insertions(+), 45 deletions(-)

diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c
index 2623b57..dac1f4a 100644
--- a/dlls/wined3d/arb_program_shader.c
+++ b/dlls/wined3d/arb_program_shader.c
@@ -480,20 +480,13 @@ static unsigned int shader_arb_load_constantsF(IWineD3DBaseShaderImpl *This, con
 /**
  * Loads the texture dimensions for NP2 fixup into the currently set ARB_[vertex/fragment]_programs.
  */
-static void shader_arb_load_np2fixup_constants(
-    IWineD3DDevice* device,
-    char usePixelShader,
-    char useVertexShader) {
+static void shader_arb_load_np2fixup_constants(void *shader_priv,
+        const struct wined3d_gl_info *gl_info, const struct wined3d_state *state)
+{
+    const struct shader_arb_priv * priv = shader_priv;
 
-    IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl *) device;
-    const struct shader_arb_priv* const priv = (const struct shader_arb_priv *) deviceImpl->shader_priv;
-    IWineD3DStateBlockImpl* stateBlock = deviceImpl->stateBlock;
-    const struct wined3d_gl_info *gl_info = &deviceImpl->adapter->gl_info;
-
-    if (!usePixelShader) {
-        /* NP2 texcoord fixup is (currently) only done for pixelshaders. */
-        return;
-    }
+    /* NP2 texcoord fixup is (currently) only done for pixelshaders. */
+    if (!use_ps(state)) return;
 
     if (priv->compiled_fprog && priv->compiled_fprog->np2fixup_info.super.active) {
         const struct arb_ps_np2fixup_info* const fixup = &priv->compiled_fprog->np2fixup_info;
@@ -501,9 +494,10 @@ static void shader_arb_load_np2fixup_constants(
         WORD active = fixup->super.active;
         GLfloat np2fixup_constants[4 * MAX_FRAGMENT_SAMPLERS];
 
-        for (i = 0; active; active >>= 1, ++i) {
+        for (i = 0; active; active >>= 1, ++i)
+        {
+            const IWineD3DBaseTextureImpl *tex = state->textures[i];
             const unsigned char idx = fixup->super.idx[i];
-            const IWineD3DBaseTextureImpl *tex = stateBlock->state.textures[i];
             GLfloat *tex_dim = &np2fixup_constants[(idx >> 1) * 4];
 
             if (!(active & 1)) continue;
@@ -4574,7 +4568,7 @@ static void shader_arb_select(const struct wined3d_context *context, BOOL usePS,
 
         /* Force constant reloading for the NP2 fixup (see comment in shader_glsl_select for more info) */
         if (compiled->np2fixup_info.super.active)
-            shader_arb_load_np2fixup_constants((IWineD3DDevice *)This, usePS, useVS);
+            shader_arb_load_np2fixup_constants(priv, gl_info, state);
     }
     else if (gl_info->supported[ARB_FRAGMENT_PROGRAM] && !priv->use_arbfp_fixed_func)
     {
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index 85b1a28..f24f309 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -681,34 +681,28 @@ static void reset_program_constant_version(struct wine_rb_entry *entry, void *co
  * Loads the texture dimensions for NP2 fixup into the currently set GLSL program.
  */
 /* GL locking is done by the caller (state handler) */
-static void shader_glsl_load_np2fixup_constants(
-    IWineD3DDevice* device,
-    char usePixelShader,
-    char useVertexShader) {
-
-    const IWineD3DDeviceImpl* deviceImpl = (const IWineD3DDeviceImpl*) device;
-    const struct glsl_shader_prog_link* prog = ((struct shader_glsl_priv *)(deviceImpl->shader_priv))->glsl_program;
+static void shader_glsl_load_np2fixup_constants(void *shader_priv,
+        const struct wined3d_gl_info *gl_info, const struct wined3d_state *state)
+{
+    struct shader_glsl_priv *glsl_priv = shader_priv;
+    const struct glsl_shader_prog_link *prog = glsl_priv->glsl_program;
 
-    if (!prog) {
-        /* No GLSL program set - nothing to do. */
-        return;
-    }
+    /* No GLSL program set - nothing to do. */
+    if (!prog) return;
 
-    if (!usePixelShader) {
-        /* NP2 texcoord fixup is (currently) only done for pixelshaders. */
-        return;
-    }
+    /* NP2 texcoord fixup is (currently) only done for pixelshaders. */
+    if (!use_ps(state)) return;
 
-    if (prog->ps_args.np2_fixup && -1 != prog->np2Fixup_location) {
-        const struct wined3d_gl_info *gl_info = &deviceImpl->adapter->gl_info;
-        const IWineD3DStateBlockImpl* stateBlock = (const IWineD3DStateBlockImpl*) deviceImpl->stateBlock;
+    if (prog->ps_args.np2_fixup && prog->np2Fixup_location != -1)
+    {
         UINT i;
         UINT fixup = prog->ps_args.np2_fixup;
         GLfloat np2fixup_constants[4 * MAX_FRAGMENT_SAMPLERS];
 
-        for (i = 0; fixup; fixup >>= 1, ++i) {
+        for (i = 0; fixup; fixup >>= 1, ++i)
+        {
+            const IWineD3DBaseTextureImpl *tex = state->textures[i];
             const unsigned char idx = prog->np2Fixup_info->idx[i];
-            const IWineD3DBaseTextureImpl *tex = stateBlock->state.textures[i];
             GLfloat *tex_dim = &np2fixup_constants[(idx >> 1) * 4];
 
             if (!tex)
@@ -4619,7 +4613,7 @@ static void shader_glsl_select(const struct wined3d_context *context, BOOL usePS
      * called between selecting the shader and using it, which results in wrong fixup for some frames. */
     if (priv->glsl_program && priv->glsl_program->np2Fixup_info)
     {
-        shader_glsl_load_np2fixup_constants((IWineD3DDevice *)device, usePS, useVS);
+        shader_glsl_load_np2fixup_constants(priv, gl_info, &device->stateBlock->state);
     }
 }
 
diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c
index 77ffacb..e0af2bc 100644
--- a/dlls/wined3d/shader.c
+++ b/dlls/wined3d/shader.c
@@ -1508,7 +1508,8 @@ static void shader_none_deselect_depth_blt(IWineD3DDevice *iface) {}
 static void shader_none_update_float_vertex_constants(IWineD3DDevice *iface, UINT start, UINT count) {}
 static void shader_none_update_float_pixel_constants(IWineD3DDevice *iface, UINT start, UINT count) {}
 static void shader_none_load_constants(const struct wined3d_context *context, char usePS, char useVS) {}
-static void shader_none_load_np2fixup_constants(IWineD3DDevice *iface, char usePS, char useVS) {}
+static void shader_none_load_np2fixup_constants(void *shader_priv,
+        const struct wined3d_gl_info *gl_info, const struct wined3d_state *state) {}
 static void shader_none_destroy(IWineD3DBaseShader *iface) {}
 static HRESULT shader_none_alloc(IWineD3DDevice *iface) {return WINED3D_OK;}
 static void shader_none_free(IWineD3DDevice *iface) {}
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
index 6a415ee..52fc819 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -3614,7 +3614,8 @@ static void sampler_texmatrix(DWORD state, IWineD3DStateBlockImpl *stateblock, s
 static void sampler(DWORD state_id, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
 {
     DWORD sampler = state_id - STATE_SAMPLER(0);
-    DWORD mapped_stage = stateblock->device->texUnitMap[sampler];
+    IWineD3DDeviceImpl *device = stateblock->device;
+    DWORD mapped_stage = device->texUnitMap[sampler];
     const struct wined3d_gl_info *gl_info = context->gl_info;
     const struct wined3d_state *state = &stateblock->state;
     union {
@@ -3673,9 +3674,7 @@ static void sampler(DWORD state_id, IWineD3DStateBlockImpl *stateblock, struct w
         /* Trigger shader constant reloading (for NP2 texcoord fixup) */
         if (!state->textures[sampler]->baseTexture.pow2Matrix_identity)
         {
-            IWineD3DDeviceImpl *d3ddevice = stateblock->device;
-            d3ddevice->shader_backend->shader_load_np2fixup_constants(
-                (IWineD3DDevice*)d3ddevice, use_ps(state), use_vs(state));
+            device->shader_backend->shader_load_np2fixup_constants(device->shader_priv, gl_info, state);
         }
     }
     else if (mapped_stage < gl_info->limits.textures)
@@ -3691,8 +3690,8 @@ static void sampler(DWORD state_id, IWineD3DStateBlockImpl *stateblock, struct w
                 state_alpha(WINED3DRS_COLORKEYENABLE, stateblock, context);
             }
         } /* Otherwise tex_colorop disables the stage */
-        glBindTexture(GL_TEXTURE_2D, stateblock->device->dummyTextureName[sampler]);
-        checkGLcall("glBindTexture(GL_TEXTURE_2D, stateblock->device->dummyTextureName[sampler])");
+        glBindTexture(GL_TEXTURE_2D, device->dummyTextureName[sampler]);
+        checkGLcall("glBindTexture(GL_TEXTURE_2D, device->dummyTextureName[sampler])");
     }
 }
 
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 329bee1..2d791ce 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -723,6 +723,7 @@ struct vs_compile_args {
 };
 
 struct wined3d_context;
+struct wined3d_state;
 
 typedef struct {
     void (*shader_handle_instruction)(const struct wined3d_shader_instruction *);
@@ -732,7 +733,8 @@ typedef struct {
     void (*shader_update_float_vertex_constants)(IWineD3DDevice *iface, UINT start, UINT count);
     void (*shader_update_float_pixel_constants)(IWineD3DDevice *iface, UINT start, UINT count);
     void (*shader_load_constants)(const struct wined3d_context *context, char usePS, char useVS);
-    void (*shader_load_np2fixup_constants)(IWineD3DDevice *iface, char usePS, char useVS);
+    void (*shader_load_np2fixup_constants)(void *shader_priv, const struct wined3d_gl_info *gl_info,
+            const struct wined3d_state *state);
     void (*shader_destroy)(IWineD3DBaseShader *iface);
     HRESULT (*shader_alloc_private)(IWineD3DDevice *iface);
     void (*shader_free_private)(IWineD3DDevice *iface);




More information about the wine-cvs mailing list