summaryrefslogtreecommitdiffstats
path: root/src/mesa/program/ir_to_mesa.cpp
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2010-08-10 20:11:44 -0700
committerEric Anholt <[email protected]>2010-08-13 17:54:42 -0700
commitd19eecef54384c163af27a470496ed885a5a271b (patch)
tree350937a634dbf44545781b2618544d8b94668327 /src/mesa/program/ir_to_mesa.cpp
parent013bbbbb0ac52a12d1e4413700dc40dee70186f8 (diff)
glsl2: Move ir_to_mesa handling to driver CompileShader and LinkShader hooks.
This lets drivers override ir_to_mesa with their own codegen, or at least have a native alternative.
Diffstat (limited to 'src/mesa/program/ir_to_mesa.cpp')
-rw-r--r--src/mesa/program/ir_to_mesa.cpp126
1 files changed, 74 insertions, 52 deletions
diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index c8c655b2967..7490ffa4fe7 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -2543,6 +2543,72 @@ get_mesa_program(GLcontext *ctx, struct gl_shader_program *shader_program,
}
extern "C" {
+GLboolean
+_mesa_ir_compile_shader(GLcontext *ctx, struct gl_shader *shader)
+{
+ assert(shader->CompileStatus);
+
+ return GL_TRUE;
+}
+
+GLboolean
+_mesa_ir_link_shader(GLcontext *ctx, struct gl_shader_program *prog)
+{
+ assert(prog->LinkStatus);
+
+ for (unsigned i = 0; i < prog->_NumLinkedShaders; i++) {
+ bool progress;
+ exec_list *ir = prog->_LinkedShaders[i]->ir;
+
+ do {
+ progress = false;
+
+ /* Lowering */
+ do_mat_op_to_vec(ir);
+ do_mod_to_fract(ir);
+ do_div_to_mul_rcp(ir);
+ do_explog_to_explog2(ir);
+
+ progress = do_common_optimization(ir, true) || progress;
+
+ if (ctx->Shader.EmitNoIfs)
+ progress = do_if_to_cond_assign(ir) || progress;
+
+ progress = do_vec_index_to_cond_assign(ir) || progress;
+ } while (progress);
+
+ validate_ir_tree(ir);
+ }
+
+ for (unsigned i = 0; i < prog->_NumLinkedShaders; i++) {
+ struct gl_program *linked_prog;
+ bool ok = true;
+
+ linked_prog = get_mesa_program(ctx, prog, prog->_LinkedShaders[i]);
+
+ link_uniforms_to_shared_uniform_list(prog->Uniforms, linked_prog);
+
+ switch (prog->_LinkedShaders[i]->Type) {
+ case GL_VERTEX_SHADER:
+ _mesa_reference_vertprog(ctx, &prog->VertexProgram,
+ (struct gl_vertex_program *)linked_prog);
+ ok = ctx->Driver.ProgramStringNotify(ctx, GL_VERTEX_PROGRAM_ARB,
+ linked_prog);
+ break;
+ case GL_FRAGMENT_SHADER:
+ _mesa_reference_fragprog(ctx, &prog->FragmentProgram,
+ (struct gl_fragment_program *)linked_prog);
+ ok = ctx->Driver.ProgramStringNotify(ctx, GL_FRAGMENT_PROGRAM_ARB,
+ linked_prog);
+ break;
+ }
+ if (!ok) {
+ return GL_FALSE;
+ }
+ }
+
+ return GL_TRUE;
+}
void
_mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *shader)
@@ -2604,7 +2670,12 @@ _mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *shader)
reparent_ir(shader->ir, shader);
talloc_free(state);
- }
+
+ if (shader->CompileStatus) {
+ if (!ctx->Driver.CompileShader(ctx, shader))
+ shader->CompileStatus = GL_FALSE;
+ }
+}
void
_mesa_glsl_link_shader(GLcontext *ctx, struct gl_shader_program *prog)
@@ -2639,57 +2710,8 @@ _mesa_glsl_link_shader(GLcontext *ctx, struct gl_shader_program *prog)
}
if (prog->LinkStatus) {
- for (unsigned i = 0; i < prog->_NumLinkedShaders; i++) {
- bool progress;
- exec_list *ir = prog->_LinkedShaders[i]->ir;
-
- do {
- progress = false;
-
- /* Lowering */
- do_mat_op_to_vec(ir);
- do_mod_to_fract(ir);
- do_div_to_mul_rcp(ir);
- do_explog_to_explog2(ir);
-
- progress = do_common_optimization(ir, true) || progress;
-
- if (ctx->Shader.EmitNoIfs)
- progress = do_if_to_cond_assign(ir) || progress;
-
- progress = do_vec_index_to_cond_assign(ir) || progress;
- } while (progress);
- }
- }
-
- if (prog->LinkStatus) {
- for (i = 0; i < prog->_NumLinkedShaders; i++) {
- struct gl_program *linked_prog;
- bool ok = true;
-
- linked_prog = get_mesa_program(ctx, prog,
- prog->_LinkedShaders[i]);
-
- link_uniforms_to_shared_uniform_list(prog->Uniforms, linked_prog);
-
- switch (prog->_LinkedShaders[i]->Type) {
- case GL_VERTEX_SHADER:
- _mesa_reference_vertprog(ctx, &prog->VertexProgram,
- (struct gl_vertex_program *)linked_prog);
- ok = ctx->Driver.ProgramStringNotify(ctx, GL_VERTEX_PROGRAM_ARB,
- linked_prog);
- break;
- case GL_FRAGMENT_SHADER:
- _mesa_reference_fragprog(ctx, &prog->FragmentProgram,
- (struct gl_fragment_program *)linked_prog);
- ok = ctx->Driver.ProgramStringNotify(ctx, GL_FRAGMENT_PROGRAM_ARB,
- linked_prog);
- break;
- }
- if (!ok) {
- prog->LinkStatus = GL_FALSE;
- }
- }
+ if (!ctx->Driver.LinkShader(ctx, prog))
+ prog->LinkStatus = GL_FALSE;
}
}