glsl: add more vertex/fragment output info helpers

This commit is contained in:
Brian Paul
2010-04-01 22:15:16 -06:00
parent 2a090ae80a
commit ee91c1e367
2 changed files with 64 additions and 13 deletions
+54 -13
View File
@@ -839,27 +839,28 @@ struct output_info
{
const char *Name;
GLuint Attrib;
GLenum Type;
};
/** Predefined vertex shader outputs */
static const struct output_info vertOutputs[] = {
{ "gl_Position", VERT_RESULT_HPOS },
{ "gl_FrontColor", VERT_RESULT_COL0 },
{ "gl_BackColor", VERT_RESULT_BFC0 },
{ "gl_FrontSecondaryColor", VERT_RESULT_COL1 },
{ "gl_BackSecondaryColor", VERT_RESULT_BFC1 },
{ "gl_TexCoord", VERT_RESULT_TEX0 },
{ "gl_FogFragCoord", VERT_RESULT_FOGC },
{ "gl_PointSize", VERT_RESULT_PSIZ },
{ NULL, 0 }
{ "gl_Position", VERT_RESULT_HPOS, GL_FLOAT_VEC4 },
{ "gl_FrontColor", VERT_RESULT_COL0, GL_FLOAT_VEC4 },
{ "gl_BackColor", VERT_RESULT_BFC0, GL_FLOAT_VEC4 },
{ "gl_FrontSecondaryColor", VERT_RESULT_COL1, GL_FLOAT_VEC4 },
{ "gl_BackSecondaryColor", VERT_RESULT_BFC1, GL_FLOAT_VEC4 },
{ "gl_TexCoord", VERT_RESULT_TEX0, GL_FLOAT_VEC4 },
{ "gl_FogFragCoord", VERT_RESULT_FOGC, GL_FLOAT },
{ "gl_PointSize", VERT_RESULT_PSIZ, GL_FLOAT },
{ NULL, 0, GL_NONE }
};
/** Predefined fragment shader outputs */
static const struct output_info fragOutputs[] = {
{ "gl_FragColor", FRAG_RESULT_COLOR },
{ "gl_FragDepth", FRAG_RESULT_DEPTH },
{ "gl_FragData", FRAG_RESULT_DATA0 },
{ NULL, 0 }
{ "gl_FragColor", FRAG_RESULT_COLOR, GL_FLOAT_VEC4 },
{ "gl_FragDepth", FRAG_RESULT_DEPTH, GL_FLOAT },
{ "gl_FragData", FRAG_RESULT_DATA0, GL_FLOAT_VEC4 },
{ NULL, 0, GL_NONE }
};
@@ -895,3 +896,43 @@ _slang_output_index(const char *name, GLenum target)
}
return -1;
}
/**
* Given a VERT_RESULT_x index, return the corresponding string name.
*/
const char *
_slang_vertex_output_name(gl_vert_result index)
{
if (index < Elements(vertOutputs))
return vertOutputs[index].Name;
else
return NULL;
}
/**
* Given a FRAG_RESULT_x index, return the corresponding string name.
*/
const char *
_slang_fragment_output_name(gl_frag_result index)
{
if (index < Elements(fragOutputs))
return fragOutputs[index].Name;
else
return NULL;
}
/**
* Given a VERT_RESULT_x index, return the corresponding varying
* var's datatype.
*/
GLenum
_slang_vertex_output_type(gl_vert_result index)
{
if (index < Elements(vertOutputs))
return vertOutputs[index].Type;
else
return GL_NONE;
}
+10
View File
@@ -51,4 +51,14 @@ extern GLenum
_slang_vert_attrib_type(GLuint attrib);
const char *
_slang_vertex_output_name(gl_vert_result index);
const char *
_slang_fragment_output_name(gl_frag_result index);
GLenum
_slang_vertex_output_type(gl_vert_result index);
#endif /* SLANG_BUILTIN_H */