wined3d: Added correct cast support for gl_FogFragCoord and gl_PointSize output registers.

This commit is contained in:
Jason Green 2006-06-17 15:55:15 -04:00 committed by Alexandre Julliard
parent 406ec20459
commit 9afa540eb5
1 changed files with 20 additions and 8 deletions

View File

@ -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;
char cast[6];
/* 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]);
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 */