diff options
author | Kenneth Graunke <[email protected]> | 2016-03-15 10:51:55 -0700 |
---|---|---|
committer | Kenneth Graunke <[email protected]> | 2016-03-16 23:57:11 -0700 |
commit | 9c1e01c4a883ac4a738f6f8c17c0236621101e28 (patch) | |
tree | 95e41d3ec1ace577cc60f381ce94f9ba06e6a167 /src/mesa/drivers/common/meta_blit.c | |
parent | 0fe254168be26e71777dc2648e86976bdcd2e707 (diff) |
meta: Don't use integer handles for shaders or programs.
Previously, we gave our internal clear/blit shaders actual GL handles
and stored them in the shader/program hash table. We used ordinary
GL API entrypoints to work with them.
We thought this shouldn't be a problem because GL doesn't allow
applications to invent their own names for shaders or programs.
GL allocates all names via glCreateShader and glCreateProgram.
However, having them in the hash table is a bit risky: if a broken
application guesses the name of our shaders or programs, it could
alter them, potentially screwing up future meta operations.
Also, test cases can observe the programs in the hash table. Running
a single dEQP process that executes the following test list:
dEQP-GLES3.functional.negative_api.buffer.clear
dEQP-GLES3.functional.negative_api.shader.compile_shader
dEQP-GLES3.functional.negative_api.shader.delete_shader
would result in the last two tests breaking. The compile_shader test
calls glCompileShader(9) straight away, and since it hasn't even created
any shaders or programs, it expects to get a GL_INVALID_VALUE error
because there's no such name. However, because the clear test ran
first, it created Meta programs, so an object named "9" did exist.
This patch reworks Meta to work with gl_shader and gl_shader_program
pointers directly. These internal programs have bogus names, and are
never stored in the hash tables, so they're invisible to applications.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94485
Signed-off-by: Kenneth Graunke <[email protected]>
Reviewed-by: Topi Pohjolainen <[email protected]>
Diffstat (limited to 'src/mesa/drivers/common/meta_blit.c')
-rw-r--r-- | src/mesa/drivers/common/meta_blit.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/mesa/drivers/common/meta_blit.c b/src/mesa/drivers/common/meta_blit.c index 179dc0d8630..0066f7f9184 100644 --- a/src/mesa/drivers/common/meta_blit.c +++ b/src/mesa/drivers/common/meta_blit.c @@ -105,12 +105,12 @@ setup_glsl_msaa_blit_scaled_shader(struct gl_context *ctx, } if (blit->msaa_shaders[shader_index]) { - _mesa_UseProgram(blit->msaa_shaders[shader_index]); + _mesa_meta_use_program(ctx, blit->msaa_shaders[shader_index]); /* Update the uniform values. */ loc_src_width = - _mesa_GetUniformLocation(blit->msaa_shaders[shader_index], "src_width"); + _mesa_program_resource_location(blit->msaa_shaders[shader_index], GL_UNIFORM, "src_width"); loc_src_height = - _mesa_GetUniformLocation(blit->msaa_shaders[shader_index], "src_height"); + _mesa_program_resource_location(blit->msaa_shaders[shader_index], GL_UNIFORM, "src_height"); _mesa_Uniform1f(loc_src_width, src_rb->Width); _mesa_Uniform1f(loc_src_height, src_rb->Height); return; @@ -237,9 +237,9 @@ setup_glsl_msaa_blit_scaled_shader(struct gl_context *ctx, _mesa_meta_compile_and_link_program(ctx, vs_source, fs_source, name, &blit->msaa_shaders[shader_index]); loc_src_width = - _mesa_GetUniformLocation(blit->msaa_shaders[shader_index], "src_width"); + _mesa_program_resource_location(blit->msaa_shaders[shader_index], GL_UNIFORM, "src_width"); loc_src_height = - _mesa_GetUniformLocation(blit->msaa_shaders[shader_index], "src_height"); + _mesa_program_resource_location(blit->msaa_shaders[shader_index], GL_UNIFORM, "src_height"); _mesa_Uniform1f(loc_src_width, src_rb->Width); _mesa_Uniform1f(loc_src_height, src_rb->Height); @@ -347,7 +347,7 @@ setup_glsl_msaa_blit_shader(struct gl_context *ctx, } if (blit->msaa_shaders[shader_index]) { - _mesa_UseProgram(blit->msaa_shaders[shader_index]); + _mesa_meta_use_program(ctx, blit->msaa_shaders[shader_index]); return; } @@ -1037,8 +1037,8 @@ _mesa_meta_glsl_blit_cleanup(struct gl_context *ctx, struct blit_state *blit) _mesa_reference_buffer_object(ctx, &blit->buf_obj, NULL); } - _mesa_meta_blit_shader_table_cleanup(&blit->shaders_with_depth); - _mesa_meta_blit_shader_table_cleanup(&blit->shaders_without_depth); + _mesa_meta_blit_shader_table_cleanup(ctx, &blit->shaders_with_depth); + _mesa_meta_blit_shader_table_cleanup(ctx, &blit->shaders_without_depth); _mesa_DeleteTextures(1, &blit->depthTex.TexObj); blit->depthTex.TexObj = 0; |