summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mesa/slang/slang_codegen.c3
-rw-r--r--src/mesa/slang/slang_link.c12
2 files changed, 15 insertions, 0 deletions
diff --git a/src/mesa/slang/slang_codegen.c b/src/mesa/slang/slang_codegen.c
index b2fe5b1f86..8ebe298076 100644
--- a/src/mesa/slang/slang_codegen.c
+++ b/src/mesa/slang/slang_codegen.c
@@ -4191,6 +4191,9 @@ _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) {
+ /* Geometry shader set gl_VerticesIn at link time
+ * so we need to way with resolving this variable
+ * until then */
if (A->program->Target == MESA_GEOMETRY_PROGRAM &&
!strcmp((char*)name, "gl_VerticesIn") ){
A->UnresolvedRefs = GL_TRUE;
diff --git a/src/mesa/slang/slang_link.c b/src/mesa/slang/slang_link.c
index c89ab8b9f6..bc2bd31fda 100644
--- a/src/mesa/slang/slang_link.c
+++ b/src/mesa/slang/slang_link.c
@@ -810,6 +810,12 @@ remove_extra_version_directives(GLchar *source)
}
}
+/* Returns the number of vertices per geometry shader
+ * input primitive.
+ * XXX: duplicated in Gallium in u_vertices_per_prim
+ * method. Once Mesa core will start using Gallium
+ * this should be removed
+ */
static int
vertices_per_prim(int prim)
{
@@ -865,6 +871,8 @@ concat_shaders(struct gl_shader_program *shProg, GLenum shaderType)
return NULL;
}
+ /* Geometry shader will inject definition of
+ * const int gl_VerticesIn */
if (shaderType == GL_GEOMETRY_SHADER_ARB) {
totalLen += 32;
}
@@ -883,6 +891,10 @@ concat_shaders(struct gl_shader_program *shProg, GLenum shaderType)
len += shaderLengths[i];
}
}
+ /* if it's geometry shader we need to inject definition
+ * of "const int gl_VerticesIn = X;" where X is the number
+ * of vertices per input primitive
+ */
if (shaderType == GL_GEOMETRY_SHADER_ARB) {
GLchar gs_pre[32];
GLuint num_verts = vertices_per_prim(shProg->Geom.InputType);