wined3d: Added more declarations to GLSL.

- Declare more variable names for GLSL programs.
- Some of these won't need to be declared eventually, but it doesn't hurt to do it for now.
- Correct output name for pixel shaders (gl_FragColor instead of glFragColor).
This commit is contained in:
Jason Green 2006-06-09 03:34:44 -04:00 committed by Alexandre Julliard
parent ca70d13af4
commit 806aaa1287
2 changed files with 21 additions and 6 deletions

View File

@ -575,23 +575,38 @@ void generate_glsl_declarations(
/* Declare the constants (aka uniforms) */
shader_addline(buffer, "uniform vec4 C[%u];\n", This->baseShader.limits.constant_float);
/* Declare texture samplers
* TODO: Make this work for textures other than 2D */
for (i = 0; i < This->baseShader.limits.texture; i++) {
shader_addline(buffer, "uniform sampler2D mytex%lu;\n", i);
}
/* Declare address variables */
for (i = 0; i < This->baseShader.limits.address; i++) {
if (reg_maps->address & (1 << i))
shader_addline(buffer, "ivec4 A%ld;\n", i);
}
/* Declare texture temporaries */
for (i = 0; i < This->baseShader.limits.texture; i++) {
shader_addline(buffer, "vec4 T%lu = gl_TexCoord[%lu];\n", i, i);
}
/* Declare temporary variables */
for(i = 0; i < This->baseShader.limits.temporary; i++) {
if (reg_maps->temporary & (1 << i))
shader_addline(buffer, "vec4 R%lu;\n", i);
}
/* Declare all named attributes (TODO: Add this to the reg_maps
* and only declare those that are needed) */
for (i = 0; i < This->baseShader.limits.attributes; i++) {
shader_addline(buffer, "attribute vec4 attrib%i;\n", i);
}
/* Declare temporary variables */
for(i = 0; i < This->baseShader.limits.temporary; i++) {
if (reg_maps->temporary & (1 << i))
shader_addline(buffer, "vec4 R%lu;\n", i);
}
/* Temporary variables for matrix operations */
shader_addline(buffer, "vec4 tmp0;\n");
shader_addline(buffer, "vec4 tmp1;\n");
/* Start the main program */
shader_addline(buffer, "void main() {\n");

View File

@ -1290,7 +1290,7 @@ inline static VOID IWineD3DPixelShaderImpl_GenerateShader(
/* Pixel shaders < 2.0 place the resulting color in R0 implicitly */
if (This->baseShader.hex_version < D3DPS_VERSION(2,0))
shader_addline(&buffer, "glFragColor = R0;\n");
shader_addline(&buffer, "gl_FragColor = R0;\n");
shader_addline(&buffer, "}\n\0");
TRACE("Compiling shader object %u\n", shader_obj);