*/
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)
* 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)
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;
};
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 },
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;
}
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 */
}
}
-
+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
return NULL;
}
+ if (shaderType == GL_GEOMETRY_SHADER_ARB) {
+ totalLen += 32;
+ }
+
source = (GLchar *) malloc(totalLen + 1);
if (!source) {
free(shaderLengths);
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);
return newShader;
}
-
/**
* Search the shader program's list of shaders to find the one that
* defines main().
}
/* 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.
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;
#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;