diff options
-rw-r--r-- | src/mesa/main/mtypes.h | 22 | ||||
-rw-r--r-- | src/mesa/slang/library/slang_geometry_builtin.gc | 1 | ||||
-rw-r--r-- | src/mesa/slang/slang_builtin.c | 1 | ||||
-rw-r--r-- | src/mesa/slang/slang_codegen.c | 5 | ||||
-rw-r--r-- | src/mesa/slang/slang_link.c | 37 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_program.c | 11 |
6 files changed, 50 insertions, 27 deletions
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index a3f89f2f9b9..cbb9eb84f33 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -252,17 +252,16 @@ typedef enum */ typedef enum { - GEOM_ATTRIB_VERTICES = 0, /*gl_VerticesIn*/ - GEOM_ATTRIB_POSITION = 1, - GEOM_ATTRIB_COLOR0 = 2, - GEOM_ATTRIB_COLOR1 = 3, - GEOM_ATTRIB_SECONDARY_COLOR0 = 4, - GEOM_ATTRIB_SECONDARY_COLOR1 = 5, - GEOM_ATTRIB_FOG_FRAG_COORD = 6, - GEOM_ATTRIB_POINT_SIZE = 7, - GEOM_ATTRIB_CLIP_VERTEX = 8, - GEOM_ATTRIB_PRIMITIVE_ID = 9, - GEOM_ATTRIB_TEX_COORD = 10, + GEOM_ATTRIB_POSITION = 0, + GEOM_ATTRIB_COLOR0 = 1, + GEOM_ATTRIB_COLOR1 = 2, + GEOM_ATTRIB_SECONDARY_COLOR0 = 3, + GEOM_ATTRIB_SECONDARY_COLOR1 = 4, + GEOM_ATTRIB_FOG_FRAG_COORD = 5, + GEOM_ATTRIB_POINT_SIZE = 6, + GEOM_ATTRIB_CLIP_VERTEX = 7, + GEOM_ATTRIB_PRIMITIVE_ID = 8, + GEOM_ATTRIB_TEX_COORD = 9, GEOM_ATTRIB_VAR0 = 16, GEOM_ATTRIB_MAX = (GEOM_ATTRIB_VAR0 + MAX_VARYING) @@ -273,7 +272,6 @@ typedef enum * These are used in bitfields in many places. */ /*@{*/ -#define GEOM_BIT_VERTICES (1 << GEOM_ATTRIB_VERTICES) #define GEOM_BIT_COLOR0 (1 << GEOM_ATTRIB_COLOR0) #define GEOM_BIT_COLOR1 (1 << GEOM_ATTRIB_COLOR1) #define GEOM_BIT_SCOLOR0 (1 << GEOM_ATTRIB_SECONDARY_COLOR0) 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(). diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index 172d7dfe905..1d748965f80 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -490,10 +490,7 @@ st_translate_geometry_program(struct st_context *st, } /* which vertex output goes to the first geometry input */ - if (inputsRead & GEOM_BIT_VERTICES) - vslot = 0; - else - vslot = 1; + vslot = 0; /* * Convert Mesa program inputs to TGSI input register semantics. @@ -511,8 +508,7 @@ st_translate_geometry_program(struct st_context *st, stgp->index_to_input[vslot] = attr; ++vslot; - if (attr != GEOM_ATTRIB_VERTICES && - attr != GEOM_ATTRIB_PRIMITIVE_ID) { + if (attr != GEOM_ATTRIB_PRIMITIVE_ID) { gs_array_offset += 2; } else ++gs_builtin_inputs; @@ -523,9 +519,6 @@ st_translate_geometry_program(struct st_context *st, #endif switch (attr) { - case GEOM_ATTRIB_VERTICES: - debug_assert(0); - break; case GEOM_ATTRIB_PRIMITIVE_ID: stgp->input_semantic_name[slot] = TGSI_SEMANTIC_PRIMID; stgp->input_semantic_index[slot] = 0; |