mesa: add link_program() and link_program_error() helpers
And call link_program_error() from _mesa_link_program(). Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
This commit is contained in:
+33
-13
@@ -1130,21 +1130,24 @@ _mesa_compile_shader(struct gl_context *ctx, struct gl_shader *sh)
|
||||
/**
|
||||
* Link a program's shaders.
|
||||
*/
|
||||
void
|
||||
_mesa_link_program(struct gl_context *ctx, struct gl_shader_program *shProg)
|
||||
static ALWAYS_INLINE void
|
||||
link_program(struct gl_context *ctx, struct gl_shader_program *shProg,
|
||||
bool no_error)
|
||||
{
|
||||
if (!shProg)
|
||||
return;
|
||||
|
||||
/* From the ARB_transform_feedback2 specification:
|
||||
* "The error INVALID_OPERATION is generated by LinkProgram if <program> is
|
||||
* the name of a program being used by one or more transform feedback
|
||||
* objects, even if the objects are not currently bound or are paused."
|
||||
*/
|
||||
if (_mesa_transform_feedback_is_using_program(ctx, shProg)) {
|
||||
_mesa_error(ctx, GL_INVALID_OPERATION,
|
||||
"glLinkProgram(transform feedback is using the program)");
|
||||
return;
|
||||
if (!no_error) {
|
||||
/* From the ARB_transform_feedback2 specification:
|
||||
* "The error INVALID_OPERATION is generated by LinkProgram if <program>
|
||||
* is the name of a program being used by one or more transform feedback
|
||||
* objects, even if the objects are not currently bound or are paused."
|
||||
*/
|
||||
if (_mesa_transform_feedback_is_using_program(ctx, shProg)) {
|
||||
_mesa_error(ctx, GL_INVALID_OPERATION,
|
||||
"glLinkProgram(transform feedback is using the program)");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned programs_in_use = 0;
|
||||
@@ -1232,6 +1235,20 @@ _mesa_link_program(struct gl_context *ctx, struct gl_shader_program *shProg)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
link_program_error(struct gl_context *ctx, struct gl_shader_program *shProg)
|
||||
{
|
||||
link_program(ctx, shProg, false);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
_mesa_link_program(struct gl_context *ctx, struct gl_shader_program *shProg)
|
||||
{
|
||||
link_program_error(ctx, shProg);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Print basic shader info (for debug).
|
||||
*/
|
||||
@@ -1689,10 +1706,13 @@ void GLAPIENTRY
|
||||
_mesa_LinkProgram(GLuint programObj)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
|
||||
if (MESA_VERBOSE & VERBOSE_API)
|
||||
_mesa_debug(ctx, "glLinkProgram %u\n", programObj);
|
||||
_mesa_link_program(ctx, _mesa_lookup_shader_program_err(ctx, programObj,
|
||||
"glLinkProgram"));
|
||||
|
||||
struct gl_shader_program *shProg =
|
||||
_mesa_lookup_shader_program_err(ctx, programObj, "glLinkProgram");
|
||||
link_program_error(ctx, shProg);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_SHADER_CACHE
|
||||
|
||||
Reference in New Issue
Block a user