[PATCH] wined3d: Implement per-stage constant in glsl fixed fonction pipeline.

Christian Costa titan.costa at gmail.com
Sun Jun 23 14:57:07 CDT 2013


When D3DTA_CONSTANT is use in a texture stage, the generated shader uses variables that are not defined making thus the compilation to fail.
This patch declare these variables with the value from the related texture stage state D3D_TSS_CONSTANT.
This fixes the text display in Spin Tires demo.
---
 dlls/wined3d/glsl_shader.c     |   14 +++++++++++++-
 dlls/wined3d/utils.c           |    2 ++
 dlls/wined3d/wined3d_private.h |    2 ++
 3 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index ad9be6a..26a3773 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -5160,7 +5160,6 @@ static const char *shader_glsl_get_ffp_fragment_op_arg(struct wined3d_shader_buf
             break;
 
         case WINED3DTA_CONSTANT:
-            FIXME("Per-stage constants not implemented.\n");
             switch (stage)
             {
                 case 0: ret = "const0"; break;
@@ -5437,6 +5436,19 @@ static GLuint shader_glsl_generate_ffp_fragment_shader(struct wined3d_shader_buf
     if (tempreg_used || settings->sRGB_write)
         shader_addline(buffer, "vec4 temp_reg;\n");
     shader_addline(buffer, "vec4 arg0, arg1, arg2;\n");
+    for (stage = 0; stage < MAX_TEXTURES && settings->op[stage].cop != WINED3D_TOP_DISABLE; ++stage)
+    {
+        float constant[4];
+
+        constant[0] = ((settings->op[stage].constant >> 16) & 0xff) / 255.0f;
+        constant[1] = ((settings->op[stage].constant >> 8)  & 0xff) / 255.0f;
+        constant[2] = ( settings->op[stage].constant        & 0xff) / 255.0f;
+        constant[3] = ((settings->op[stage].constant >> 24) & 0xff) / 255.0f;
+
+        shader_addline(buffer, "const vec4 const%d = ", stage);
+        shader_glsl_append_imm_vec4(buffer, constant);
+        shader_addline(buffer, ";\n");
+    }
 
     for (stage = 0; stage < MAX_TEXTURES; ++stage)
     {
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index 5b7fb3c..083a0d7 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -3312,6 +3312,8 @@ void gen_ffp_frag_op(const struct wined3d_context *context, const struct wined3d
         settings->op[i].aarg1 = aarg1;
         settings->op[i].aarg2 = aarg2;
 
+        settings->op[i].constant = state->texture_states[i][WINED3D_TSS_CONSTANT];
+
         if (state->texture_states[i][WINED3D_TSS_RESULT_ARG] == WINED3DTA_TEMP)
             settings->op[i].dst = tempreg;
         else
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index dca0d61..c1d6c91 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1673,6 +1673,8 @@ struct texture_stage_op
     unsigned                aarg2 : 8;
     unsigned                aarg0 : 8;
 
+    DWORD                   constant;
+
     struct color_fixup_desc color_fixup;
     unsigned                tex_type : 3;
     unsigned                dst : 1;




More information about the wine-patches mailing list