From 2b71b3d4666b076ef45d03b9b4b4c527bda21e1c Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 6 Sep 2013 15:41:19 -0700 Subject: mesa: Disallow relinking if a program is used by an active XFB object. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Paused transform feedback objects may refer to a program other than the current program. If any active objects refer to a program, LinkProgram must reject the request to relink. The code to detect this is ugly since _mesa_HashWalk is awkward to use, but unfortunately we can't use hash_table_foreach since there's no way to get at the underlying struct hash_table (and even then, we'd need to handle locking somehow). Fixes the last subcase of Piglit's new ARB_transform_feedback2 api-errors test. Signed-off-by: Kenneth Graunke Reviewed-by: Marek Olšák --- src/mesa/main/transformfeedback.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'src/mesa/main/transformfeedback.c') diff --git a/src/mesa/main/transformfeedback.c b/src/mesa/main/transformfeedback.c index 191e88c8033..bc9b52ab9d1 100644 --- a/src/mesa/main/transformfeedback.c +++ b/src/mesa/main/transformfeedback.c @@ -44,6 +44,41 @@ #include "program/prog_parameter.h" +struct using_program_tuple +{ + struct gl_shader_program *shProg; + bool found; +}; + +static void +active_xfb_object_references_program(GLuint key, void *data, void *user_data) +{ + struct using_program_tuple *callback_data = user_data; + struct gl_transform_feedback_object *obj = data; + if (obj->Active && obj->shader_program == callback_data->shProg) + callback_data->found = true; +} + +/** + * Return true if any active transform feedback object is using a program. + */ +bool +_mesa_transform_feedback_is_using_program(struct gl_context *ctx, + struct gl_shader_program *shProg) +{ + struct using_program_tuple callback_data; + callback_data.shProg = shProg; + callback_data.found = false; + + _mesa_HashWalk(ctx->TransformFeedback.Objects, + active_xfb_object_references_program, &callback_data); + + /* Also check DefaultObject, as it's not in the Objects hash table. */ + active_xfb_object_references_program(0, ctx->TransformFeedback.DefaultObject, + &callback_data); + + return callback_data.found; +} /** * Do reference counting of transform feedback buffers. -- cgit v1.2.3