aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/common/meta.h
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2016-03-15 10:51:55 -0700
committerKenneth Graunke <[email protected]>2016-03-16 23:57:11 -0700
commit9c1e01c4a883ac4a738f6f8c17c0236621101e28 (patch)
tree95e41d3ec1ace577cc60f381ce94f9ba06e6a167 /src/mesa/drivers/common/meta.h
parent0fe254168be26e71777dc2648e86976bdcd2e707 (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.h')
-rw-r--r--src/mesa/drivers/common/meta.h24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/mesa/drivers/common/meta.h b/src/mesa/drivers/common/meta.h
index c2efa50a33d..0a7321c9d88 100644
--- a/src/mesa/drivers/common/meta.h
+++ b/src/mesa/drivers/common/meta.h
@@ -218,7 +218,7 @@ struct blit_shader {
const char *type;
const char *func;
const char *texcoords;
- GLuint shader_prog;
+ struct gl_shader_program *shader_prog;
};
/**
@@ -302,7 +302,7 @@ struct blit_state
struct gl_buffer_object *buf_obj;
struct blit_shader_table shaders_with_depth;
struct blit_shader_table shaders_without_depth;
- GLuint msaa_shaders[BLIT_MSAA_SHADER_COUNT];
+ struct gl_shader_program *msaa_shaders[BLIT_MSAA_SHADER_COUNT];
struct temp_texture depthTex;
bool no_ctsi_fallback;
};
@@ -324,8 +324,8 @@ struct clear_state
{
GLuint VAO;
struct gl_buffer_object *buf_obj;
- GLuint ShaderProg;
- GLuint IntegerShaderProg;
+ struct gl_shader_program *ShaderProg;
+ struct gl_shader_program *IntegerShaderProg;
};
@@ -577,20 +577,25 @@ _mesa_meta_DrawTex(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z,
void
_mesa_meta_drawbuffers_from_bitfield(GLbitfield bits);
-GLuint
+struct gl_shader *
_mesa_meta_compile_shader_with_debug(struct gl_context *ctx, GLenum target,
const GLcharARB *source);
-GLuint
-_mesa_meta_link_program_with_debug(struct gl_context *ctx, GLuint program);
+void
+_mesa_meta_link_program_with_debug(struct gl_context *ctx,
+ struct gl_shader_program *sh_prog);
void
_mesa_meta_compile_and_link_program(struct gl_context *ctx,
const char *vs_source,
const char *fs_source,
const char *name,
- GLuint *program);
+ struct gl_shader_program **sh_prog_ptr);
+
+extern void
+_mesa_meta_use_program(struct gl_context *ctx,
+ struct gl_shader_program *sh_prog);
GLboolean
_mesa_meta_alloc_texture(struct temp_texture *tex,
@@ -655,7 +660,8 @@ void
_mesa_meta_glsl_blit_cleanup(struct gl_context *ctx, struct blit_state *blit);
void
-_mesa_meta_blit_shader_table_cleanup(struct blit_shader_table *table);
+_mesa_meta_blit_shader_table_cleanup(struct gl_context *ctx,
+ struct blit_shader_table *table);
void
_mesa_meta_glsl_generate_mipmap_cleanup(struct gl_context *ctx,