[WINED3D 4/9] Added more declarations to GLSL
Jason Green
jave27 at gmail.com
Fri Jun 9 02:34:44 CDT 2006
-------------- next part --------------
From nobody Mon Sep 17 00:00:00 2001
From: Jason <jason at jave02.(none)>
Date: Fri, 9 Jun 2006 03:17:59 -0400
Subject: [PATCH 4/9] 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)
---
dlls/wined3d/baseshader.c | 23 +++++++++++++++++++----
dlls/wined3d/pixelshader.c | 2 +-
2 files changed, 20 insertions(+), 5 deletions(-)
6c418db5db48d87c42ca8c2932bc52e1b2b7f1a6
diff --git a/dlls/wined3d/baseshader.c b/dlls/wined3d/baseshader.c
index da81351..8d1f759 100644
--- a/dlls/wined3d/baseshader.c
+++ b/dlls/wined3d/baseshader.c
@@ -575,16 +575,21 @@ 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 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 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 */
@@ -593,6 +598,16 @@ void generate_glsl_declarations(
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);
+ }
+
+ /* 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");
}
diff --git a/dlls/wined3d/pixelshader.c b/dlls/wined3d/pixelshader.c
index 4c52a25..65a81c5 100644
--- a/dlls/wined3d/pixelshader.c
+++ b/dlls/wined3d/pixelshader.c
@@ -1290,7 +1290,7 @@ #endif
/* 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);
--
1.3.3
More information about the wine-patches
mailing list