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

Matteo Bruni matteo.mystral at gmail.com
Mon Jun 24 09:44:13 CDT 2013


2013/6/24 Christian Costa <titan.costa at gmail.com>:
> Le 24/06/2013 09:24, Henri Verbeet a écrit :
>
>> On 23 June 2013 21:57, Christian Costa <titan.costa at gmail.com> wrote:
>>>
>>> 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.
>>
>> This patch has several issues. Even without those, it should probably
>> be deferred anyway.
>>
>>
>>
> Even deferred, can you elaborate a bit so I can fix them. Unless you have
> already something.
>
>

I'm not Henri but I can mention a number of issues (which might or
might not match with Henri's).

+    for (stage = 0; stage < MAX_TEXTURES && settings->op[stage].cop
!= WINED3D_TOP_DISABLE; ++stage)

You probably want to generate this code only for texture stages
actually using constants.

+    {
+        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;

No need to open code it, the macro D3DCOLORTOGLFLOAT4 does just that.

+
+        shader_addline(buffer, "const vec4 const%d = ", stage);
+        shader_glsl_append_imm_vec4(
buffer, constant);
+        shader_addline(buffer, ";\n");

I assume it would be better to make these proper uniforms and update
their value in shader_glsl_load_constants() instead.

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;

You don't need this if you use uniforms.
Also adding a test would be nice probably.

That said, maybe Henri already has a patch for it.



More information about the wine-devel mailing list