summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/common/meta.c
diff options
context:
space:
mode:
authorTopi Pohjolainen <[email protected]>2014-04-18 02:21:13 +0300
committerTopi Pohjolainen <[email protected]>2014-05-12 17:48:45 +0300
commitac4db0aa559ac07262d977f35915953f97875333 (patch)
tree746919c709ebfa34e9bcbe5107878ff0c22043e6 /src/mesa/drivers/common/meta.c
parent3a43cd0c3e611085347f67976a619b915dff07b7 (diff)
meta: Merge compiling and linking of blit program
Cc: "10.2" <[email protected]> Signed-off-by: Topi Pohjolainen <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/mesa/drivers/common/meta.c')
-rw-r--r--src/mesa/drivers/common/meta.c45
1 files changed, 29 insertions, 16 deletions
diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index b4c30564f93..3ef3f79714e 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -204,6 +204,31 @@ _mesa_meta_link_program_with_debug(struct gl_context *ctx, GLuint program)
return 0;
}
+void
+_mesa_meta_compile_and_link_program(struct gl_context *ctx,
+ const char *vs_source,
+ const char *fs_source,
+ const char *name,
+ GLuint *program)
+{
+ GLuint vs = _mesa_meta_compile_shader_with_debug(ctx, GL_VERTEX_SHADER,
+ vs_source);
+ GLuint fs = _mesa_meta_compile_shader_with_debug(ctx, GL_FRAGMENT_SHADER,
+ fs_source);
+
+ *program = _mesa_CreateProgram();
+ _mesa_AttachShader(*program, fs);
+ _mesa_DeleteShader(fs);
+ _mesa_AttachShader(*program, vs);
+ _mesa_DeleteShader(vs);
+ _mesa_BindAttribLocation(*program, 0, "position");
+ _mesa_BindAttribLocation(*program, 1, "texcoords");
+ _mesa_meta_link_program_with_debug(ctx, *program);
+ _mesa_ObjectLabel(GL_PROGRAM, *program, -1, name);
+
+ _mesa_UseProgram(*program);
+}
+
/**
* Generate a generic shader to blit from a texture to a framebuffer
*
@@ -219,10 +244,8 @@ _mesa_meta_setup_blit_shader(struct gl_context *ctx,
{
const char *vs_source;
char *fs_source;
- GLuint vs, fs;
void *const mem_ctx = ralloc_context(NULL);
struct blit_shader *shader = choose_blit_shader(target, table);
- char *name;
assert(shader != NULL);
@@ -282,22 +305,12 @@ _mesa_meta_setup_blit_shader(struct gl_context *ctx,
shader->texcoords);
}
- vs = _mesa_meta_compile_shader_with_debug(ctx, GL_VERTEX_SHADER, vs_source);
- fs = _mesa_meta_compile_shader_with_debug(ctx, GL_FRAGMENT_SHADER, fs_source);
- shader->shader_prog = _mesa_CreateProgram();
- _mesa_AttachShader(shader->shader_prog, fs);
- _mesa_DeleteShader(fs);
- _mesa_AttachShader(shader->shader_prog, vs);
- _mesa_DeleteShader(vs);
- _mesa_BindAttribLocation(shader->shader_prog, 0, "position");
- _mesa_BindAttribLocation(shader->shader_prog, 1, "texcoords");
- _mesa_meta_link_program_with_debug(ctx, shader->shader_prog);
- name = ralloc_asprintf(mem_ctx, "%s blit", shader->type);
- _mesa_ObjectLabel(GL_PROGRAM, shader->shader_prog, -1, name);
+ _mesa_meta_compile_and_link_program(ctx, vs_source, fs_source,
+ ralloc_asprintf(mem_ctx, "%s blit",
+ shader->type),
+ &shader->shader_prog);
ralloc_free(mem_ctx);
-
- _mesa_UseProgram(shader->shader_prog);
}
/**