summaryrefslogtreecommitdiffstats
path: root/src/mesa/slang
diff options
context:
space:
mode:
authorZack Rusin <[email protected]>2010-07-07 00:54:33 -0400
committerZack Rusin <[email protected]>2010-07-08 00:28:29 -0400
commit7c42390453e611367cf1ba11446692ec04e0abfb (patch)
tree379033d3f7659d4214c0808bbc276072685a504c /src/mesa/slang
parent6988f65e43297ae63bbce30bf882f870b370096c (diff)
gs: inject const int gl_VerticesIn at link time
Diffstat (limited to 'src/mesa/slang')
-rw-r--r--src/mesa/slang/library/slang_geometry_builtin.gc1
-rw-r--r--src/mesa/slang/slang_builtin.c1
-rw-r--r--src/mesa/slang/slang_codegen.c5
-rw-r--r--src/mesa/slang/slang_link.c37
4 files changed, 38 insertions, 6 deletions
diff --git a/src/mesa/slang/library/slang_geometry_builtin.gc b/src/mesa/slang/library/slang_geometry_builtin.gc
index c349a6acc04..07524912ba1 100644
--- a/src/mesa/slang/library/slang_geometry_builtin.gc
+++ b/src/mesa/slang/library/slang_geometry_builtin.gc
@@ -21,7 +21,6 @@
const int _mesa_VerticesInMax = 6;
-__fixed_input int gl_VerticesIn;
__fixed_input int gl_PrimitiveIDIn;
__fixed_output int gl_PrimitiveID;
__fixed_output int gl_Layer;
diff --git a/src/mesa/slang/slang_builtin.c b/src/mesa/slang/slang_builtin.c
index 5c1a0406608..bb6fd662ccc 100644
--- a/src/mesa/slang/slang_builtin.c
+++ b/src/mesa/slang/slang_builtin.c
@@ -746,7 +746,6 @@ static const struct input_info vertInputs[] = {
};
static const struct input_info geomInputs[] = {
- { "gl_VerticesIn", GEOM_ATTRIB_VERTICES, GL_FLOAT, SWIZZLE_NOOP },
{ "gl_PrimitiveIDIn", GEOM_ATTRIB_PRIMITIVE_ID, GL_FLOAT, SWIZZLE_NOOP },
{ "gl_FrontColorIn", GEOM_ATTRIB_COLOR0, GL_FLOAT_VEC4, SWIZZLE_NOOP },
{ "gl_BackColorIn", GEOM_ATTRIB_COLOR1, GL_FLOAT_VEC4, SWIZZLE_NOOP },
diff --git a/src/mesa/slang/slang_codegen.c b/src/mesa/slang/slang_codegen.c
index 494901dc1c8..b2fe5b1f863 100644
--- a/src/mesa/slang/slang_codegen.c
+++ b/src/mesa/slang/slang_codegen.c
@@ -4191,6 +4191,11 @@ _slang_gen_variable(slang_assemble_ctx * A, slang_operation *oper)
slang_variable *var = _slang_variable_locate(oper->locals, name, GL_TRUE);
slang_ir_node *n;
if (!var || !var->declared) {
+ if (A->program->Target == MESA_GEOMETRY_PROGRAM &&
+ !strcmp((char*)name, "gl_VerticesIn") ){
+ A->UnresolvedRefs = GL_TRUE;
+ return NULL;
+ }
slang_info_log_error(A->log, "undefined variable '%s'", (char *) name);
return NULL;
}
diff --git a/src/mesa/slang/slang_link.c b/src/mesa/slang/slang_link.c
index 8aa007bd1ec..c89ab8b9f66 100644
--- a/src/mesa/slang/slang_link.c
+++ b/src/mesa/slang/slang_link.c
@@ -661,8 +661,8 @@ get_inputs_read_mask(GLenum target, GLuint index, GLboolean relAddr)
else if (target == MESA_GEOMETRY_PROGRAM) {
switch (index) {
case GEOM_ATTRIB_VAR0:
- mask = ((1U << (GEOM_ATTRIB_VAR0 + MAX_VARYING)) - 1)
- - ((1U << GEOM_ATTRIB_VAR0) - 1);
+ mask = ((1ULL << (GEOM_ATTRIB_VAR0 + MAX_VARYING)) - 1)
+ - ((1ULL << GEOM_ATTRIB_VAR0) - 1);
break;
default:
; /* a non-array input attribute */
@@ -810,7 +810,25 @@ remove_extra_version_directives(GLchar *source)
}
}
-
+static int
+vertices_per_prim(int prim)
+{
+ switch (prim) {
+ case GL_POINTS:
+ return 1;
+ case GL_LINES:
+ return 2;
+ case GL_TRIANGLES:
+ return 3;
+ case GL_LINES_ADJACENCY_ARB:
+ return 4;
+ case GL_TRIANGLES_ADJACENCY_ARB:
+ return 6;
+ default:
+ ASSERT(!"Bad primitive");
+ return 3;
+ }
+}
/**
* Return a new shader whose source code is the concatenation of
@@ -847,6 +865,10 @@ concat_shaders(struct gl_shader_program *shProg, GLenum shaderType)
return NULL;
}
+ if (shaderType == GL_GEOMETRY_SHADER_ARB) {
+ totalLen += 32;
+ }
+
source = (GLchar *) malloc(totalLen + 1);
if (!source) {
free(shaderLengths);
@@ -861,6 +883,14 @@ concat_shaders(struct gl_shader_program *shProg, GLenum shaderType)
len += shaderLengths[i];
}
}
+ if (shaderType == GL_GEOMETRY_SHADER_ARB) {
+ GLchar gs_pre[32];
+ GLuint num_verts = vertices_per_prim(shProg->Geom.InputType);
+ _mesa_snprintf(gs_pre, 31,
+ "const int gl_VerticesIn = %d;\n", num_verts);
+ memcpy(source + len, gs_pre, strlen(gs_pre));
+ len += strlen(gs_pre);
+ }
source[len] = '\0';
/*
printf("---NEW CONCATENATED SHADER---:\n%s\n------------\n", source);
@@ -883,7 +913,6 @@ concat_shaders(struct gl_shader_program *shProg, GLenum shaderType)
return newShader;
}
-
/**
* Search the shader program's list of shaders to find the one that
* defines main().