summaryrefslogtreecommitdiffstats
path: root/src/mesa/shader/slang
diff options
context:
space:
mode:
authorBrian <[email protected]>2007-10-24 11:37:05 -0600
committerBrian <[email protected]>2007-10-24 11:37:05 -0600
commite48f0b09abe42aa3393a492af07e53b76ad0ff3c (patch)
tree9a3883b6ca306e2f68caae650c6ae1edd120f042 /src/mesa/shader/slang
parentc9d495c6f064aacd1e072033b9c17a83b8c37fa1 (diff)
Implement gl_PointCoord attribute for GLSL fragment shaders.
Contains the normalized fragment position within a point sprite.
Diffstat (limited to 'src/mesa/shader/slang')
-rw-r--r--src/mesa/shader/slang/slang_codegen.c6
-rw-r--r--src/mesa/shader/slang/slang_compile.c11
2 files changed, 16 insertions, 1 deletions
diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c
index d368009ca50..a44e42b6d6d 100644
--- a/src/mesa/shader/slang/slang_codegen.c
+++ b/src/mesa/shader/slang/slang_codegen.c
@@ -282,6 +282,8 @@ sampler_to_texture_index(const slang_type_specifier_type type)
}
+#define SWIZZLE_ZWWW MAKE_SWIZZLE4(SWIZZLE_Z, SWIZZLE_W, SWIZZLE_W, SWIZZLE_W)
+
/**
* Return the VERT_ATTRIB_* or FRAG_ATTRIB_* value that corresponds to
* a vertex or fragment program input variable. Return -1 if the input
@@ -316,9 +318,11 @@ _slang_input_index(const char *name, GLenum target, GLuint *swizzleOut)
{ "gl_FragCoord", FRAG_ATTRIB_WPOS, SWIZZLE_NOOP },
{ "gl_Color", FRAG_ATTRIB_COL0, SWIZZLE_NOOP },
{ "gl_SecondaryColor", FRAG_ATTRIB_COL1, SWIZZLE_NOOP },
- { "gl_FogFragCoord", FRAG_ATTRIB_FOGC, SWIZZLE_XXXX },
{ "gl_TexCoord", FRAG_ATTRIB_TEX0, SWIZZLE_NOOP },
+ /* note: we're packing several quantities into the fogcoord vector */
+ { "gl_FogFragCoord", FRAG_ATTRIB_FOGC, SWIZZLE_XXXX },
{ "gl_FrontFacing", FRAG_ATTRIB_FOGC, SWIZZLE_YYYY }, /*XXX*/
+ { "gl_PointCoord", FRAG_ATTRIB_FOGC, SWIZZLE_ZWWW },
{ NULL, 0, SWIZZLE_NOOP }
};
GLuint i;
diff --git a/src/mesa/shader/slang/slang_compile.c b/src/mesa/shader/slang/slang_compile.c
index 4e29e8dcc90..2be89a5ce05 100644
--- a/src/mesa/shader/slang/slang_compile.c
+++ b/src/mesa/shader/slang/slang_compile.c
@@ -1983,6 +1983,10 @@ static const byte slang_120_core_gc[] = {
#include "library/slang_120_core_gc.h"
};
+static const byte slang_120_fragment_gc[] = {
+#include "library/slang_builtin_120_fragment_gc.h"
+};
+
static const byte slang_common_builtin_gc[] = {
#include "library/slang_common_builtin_gc.h"
};
@@ -2059,6 +2063,13 @@ compile_object(grammar * id, const char *source, slang_code_object * object,
SLANG_UNIT_FRAGMENT_BUILTIN, infolog, NULL,
&object->builtin[SLANG_BUILTIN_COMMON], NULL))
return GL_FALSE;
+#if FEATURE_ARB_shading_language_120
+ if (!compile_binary(slang_120_fragment_gc,
+ &object->builtin[SLANG_BUILTIN_TARGET],
+ SLANG_UNIT_FRAGMENT_BUILTIN, infolog, NULL,
+ &object->builtin[SLANG_BUILTIN_COMMON], NULL))
+ return GL_FALSE;
+#endif
}
else if (type == SLANG_UNIT_VERTEX_SHADER) {
if (!compile_binary(slang_vertex_builtin_gc,