[WINED3D 6/7] Added correct cast support for gl_FogFragCoord
and gl_PointSize output registers.
Jason Green
jave27 at gmail.com
Sat Jun 17 14:55:15 CDT 2006
Please use this patch instead. I forgot to modify the write mask in
the previous one. The next 2 patches will still apply cleanly.
On 6/16/06, Jason Green <jave27 at gmail.com> wrote:
>
>
>
>
-------------- next part --------------
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index 4ed71de..dbdfd20 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -380,17 +380,29 @@ static const char* shift_glsl_tab[] = {
"0.5 * " /* 15 (d2) */
};
-/** Print the beginning of the generated GLSL string. example: "reg_name.xyzw = vec4(" */
-static void shader_glsl_add_dst(DWORD param, const char* reg_name, const char* reg_mask, char* outStr) {
+/** Print the beginning of the generated GLSL string. example: "reg_name.xyzw = vec4("
+ * Will also change the reg_mask if necessary (not all register types are equal in DX vs GL) */
+static void shader_glsl_add_dst(DWORD param, const char* reg_name, char* reg_mask, char* outStr) {
int shift = (param & D3DSP_DSTSHIFT_MASK) >> D3DSP_DSTSHIFT_SHIFT;
-
- /* TODO: determine if destination is anything other than a float vector and accommodate*/
- if (reg_name[0] == 'A')
- sprintf(outStr, "%s%s = %sivec4(", reg_name, reg_mask, shift_glsl_tab[shift]);
- else
- sprintf(outStr, "%s%s = %svec4(", reg_name, reg_mask, shift_glsl_tab[shift]);
-
+ char cast[6];
+
+ if ((shader_get_regtype(param) == D3DSPR_RASTOUT)
+ && ((param & D3DSP_REGNUM_MASK) != 0)) {
+ /* gl_FogFragCoord or glPointSize - both floats */
+ strcpy(cast, "float");
+ strcpy(reg_mask, "");
+
+ } else if (reg_name[0] == 'A') {
+ /* Address register for vertex shaders (ivec4) */
+ strcpy(cast, "ivec4");
+
+ } else {
+ /* Everything else should be a 4 component float vector */
+ strcpy(cast, "vec4");
+ }
+
+ sprintf(outStr, "%s%s = %s%s(", reg_name, reg_mask, shift_glsl_tab[shift], cast);
}
/* Generate a GLSL parameter that does the input modifier computation and return the input register/mask to use */
More information about the wine-patches
mailing list