Tobias Jakobi : wined3d: glsl: Enable load_np2fixup_constants.

Alexandre Julliard julliard at winehq.org
Fri Apr 10 08:10:15 CDT 2009


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

Author: Tobias Jakobi <liquid.acid at gmx.net>
Date:   Thu Apr  9 01:43:02 2009 +0200

wined3d: glsl: Enable load_np2fixup_constants.

---

 dlls/wined3d/arb_program_shader.c |    6 ++++
 dlls/wined3d/glsl_shader.c        |   52 +++++++++++++++++++++++-------------
 dlls/wined3d/state.c              |    7 ++---
 3 files changed, 42 insertions(+), 23 deletions(-)

diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c
index f046b6d..5cea411 100644
--- a/dlls/wined3d/arb_program_shader.c
+++ b/dlls/wined3d/arb_program_shader.c
@@ -670,6 +670,12 @@ static void shader_hw_sample(const struct wined3d_shader_instruction *ins, DWORD
             } else {
                 tex_type = "2D";
             }
+            if(shader_is_pshader_version(ins->reg_maps->shader_version)) {
+               const IWineD3DPixelShaderImpl* const ps = (const IWineD3DPixelShaderImpl*)This;
+               if(ps->cur_args->texrect_fixup & (1 << sampler_idx)) {
+                   FIXME("NP2 texcoord fixup is currently not implemented in ARB mode (use GLSL instead).");
+               }
+            }
             break;
 
         case WINED3DSTT_VOLUME:
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index 626bda3..5fa9915 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -489,7 +489,39 @@ static void shader_glsl_load_np2fixup_constants(
     IWineD3DDevice* device,
     char usePixelShader,
     char useVertexShader) {
-    /* not implemented */
+
+    const IWineD3DDeviceImpl* deviceImpl = (const IWineD3DDeviceImpl*) device;
+    const struct glsl_shader_prog_link* prog = ((struct shader_glsl_priv *)(deviceImpl->shader_priv))->glsl_program;
+
+    if (!prog) {
+        /* No GLSL program set - nothing to do. */
+        return;
+    }
+
+    if (!usePixelShader) {
+        /* NP2 texcoord fixup is (currently) only done for pixelshaders. */
+        return;
+    }
+
+    if (prog->ps_args.texrect_fixup) {
+        UINT i;
+        UINT fixup = prog->ps_args.texrect_fixup;
+        const WineD3D_GL_Info* gl_info = &deviceImpl->adapter->gl_info;
+        const IWineD3DStateBlockImpl* stateBlock = (const IWineD3DStateBlockImpl*) deviceImpl->stateBlock;
+
+        for (i = 0; fixup; fixup >>= 1, ++i) {
+            if (-1 != prog->rectFixup_location[i]) {
+                const IWineD3DBaseTextureImpl* const tex = (const IWineD3DBaseTextureImpl*) stateBlock->textures[i];
+                if (!tex) {
+                    FIXME("Non-existant texture is flagged for NP2 texcoord fixup\n");
+                    continue;
+                } else {
+                    const float tex_dim[2] = {tex->baseTexture.pow2Matrix[0], tex->baseTexture.pow2Matrix[5]};
+                    GL_EXTCALL(glUniform2fvARB(prog->rectFixup_location[i], 1, tex_dim));
+                }
+            }
+        }
+    }
 }
 
 /**
@@ -598,24 +630,6 @@ static void shader_glsl_load_constants(
             }
             GL_EXTCALL(glUniform4fvARB(prog->ycorrection_location, 1, correction_params));
         }
-
-        /* Constant loading for texture rect coord fixup. */
-        if (prog->ps_args.texrect_fixup) {
-            UINT fixup = prog->ps_args.texrect_fixup;
-
-            for (i = 0; fixup; fixup >>= 1, ++i) {
-                if (-1 != prog->rectFixup_location[i]) {
-                    const IWineD3DBaseTextureImpl* const tex = (const IWineD3DBaseTextureImpl*) stateBlock->textures[i];
-                    if (!tex) {
-                        FIXME("Non-existant texture is flagged for NP2 texcoord fixup\n");
-                        continue;
-                    } else {
-                        const float tex_dim[2] = {tex->baseTexture.pow2Matrix[0], tex->baseTexture.pow2Matrix[5]};
-                        GL_EXTCALL(glUniform2fvARB(prog->rectFixup_location[i], 1, tex_dim));
-                    }
-                }
-            }
-        }
     }
 
     if (priv->next_constant_version == UINT_MAX)
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
index 755698c..05e52b0 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -3367,11 +3367,10 @@ static void sampler(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DCont
 
         /* Trigger shader constant reloading (for NP2 texcoord fixup)
          * Only do this if pshaders are used (note: fixup is currently only implemented in GLSL). */
-        if (!tex_impl->baseTexture.pow2Matrix_identity && use_ps(stateblock)) {
+        if (!tex_impl->baseTexture.pow2Matrix_identity) {
             IWineD3DDeviceImpl* d3ddevice = stateblock->wineD3DDevice;
-            /* FIXME: add something like shader_load_rectfixup_consts to the backend to only reload the
-             * constants that are used for the fixup (and not the other ones too) */
-            d3ddevice->shader_backend->shader_load_constants((IWineD3DDevice*)d3ddevice, use_ps(stateblock), use_vs(stateblock));
+            d3ddevice->shader_backend->shader_load_np2fixup_constants(
+                (IWineD3DDevice*)d3ddevice, use_ps(stateblock), use_vs(stateblock));
         }
     } else if(mapped_stage < GL_LIMITS(textures)) {
         if(sampler < stateblock->lowest_disabled_stage) {




More information about the wine-cvs mailing list