From: Kenneth Graunke Date: Wed, 21 Nov 2012 00:21:27 +0000 (-0800) Subject: i965/fs: Move uses of brw_compile from do_wm_prog to brw_wm_fs_emit. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4d09fe938e72b26d814b6b52caee5112cf6f1103;p=mesa.git i965/fs: Move uses of brw_compile from do_wm_prog to brw_wm_fs_emit. The brw_compile structure is closely tied to the Gen4-7 hardware encoding. However, do_wm_prog is very generic: it just calls out to get a compiled program and then uploads it. This isn't ultimately where we want it, but it's a step in the right direction: it's now closer to the code generator. Reviewed-by: Eric Anholt Reviewed-by: Paul Berry --- diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index 6b19d1b908e..e2873ce9756 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -2145,15 +2145,18 @@ fs_visitor::run() return !failed; } -bool +const unsigned * brw_wm_fs_emit(struct brw_context *brw, struct brw_wm_compile *c, struct gl_fragment_program *fp, - struct gl_shader_program *prog) + struct gl_shader_program *prog, + unsigned *final_assembly_size) { struct intel_context *intel = &brw->intel; bool start_busy = false; float start_time = 0; + brw_init_compile(brw, &c->func, c); + if (unlikely(INTEL_DEBUG & DEBUG_PERF)) { start_busy = (intel->batch.last_bo && drm_intel_bo_busy(intel->batch.last_bo)); @@ -2186,7 +2189,7 @@ brw_wm_fs_emit(struct brw_context *brw, struct brw_wm_compile *c, _mesa_problem(NULL, "Failed to compile fragment shader: %s\n", v.fail_msg); - return false; + return NULL; } if (intel->gen >= 5 && c->prog_data.nr_pull_params == 0) { @@ -2211,7 +2214,7 @@ brw_wm_fs_emit(struct brw_context *brw, struct brw_wm_compile *c, } } - return true; + return brw_get_program(&c->func, final_assembly_size); } bool diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c index f22960330cf..289156705a0 100644 --- a/src/mesa/drivers/dri/i965/brw_wm.c +++ b/src/mesa/drivers/dri/i965/brw_wm.c @@ -168,13 +168,13 @@ bool do_wm_prog(struct brw_context *brw, memcpy(&c->key, key, sizeof(*key)); - brw_init_compile(brw, &c->func, c); - c->prog_data.barycentric_interp_modes = brw_compute_barycentric_interp_modes(brw, c->key.flat_shade, &fp->program); - brw_wm_fs_emit(brw, c, &fp->program, prog); + program = brw_wm_fs_emit(brw, c, &fp->program, prog, &program_size); + if (program == NULL) + return false; /* Scratch space is used for register spilling */ if (c->last_scratch) { @@ -191,10 +191,6 @@ bool do_wm_prog(struct brw_context *brw, if (unlikely(INTEL_DEBUG & DEBUG_WM)) fprintf(stderr, "\n"); - /* get the program - */ - program = brw_get_program(&c->func, &program_size); - brw_upload_cache(&brw->cache, BRW_WM_PROG, &c->key, sizeof(c->key), program, program_size, diff --git a/src/mesa/drivers/dri/i965/brw_wm.h b/src/mesa/drivers/dri/i965/brw_wm.h index adc05a497f2..478be866fa1 100644 --- a/src/mesa/drivers/dri/i965/brw_wm.h +++ b/src/mesa/drivers/dri/i965/brw_wm.h @@ -93,9 +93,16 @@ struct brw_wm_compile { GLuint last_scratch; }; -bool brw_wm_fs_emit(struct brw_context *brw, struct brw_wm_compile *c, - struct gl_fragment_program *fp, - struct gl_shader_program *prog); +/** + * Compile a fragment shader. + * + * Returns the final assembly and the program's size. + */ +const unsigned *brw_wm_fs_emit(struct brw_context *brw, + struct brw_wm_compile *c, + struct gl_fragment_program *fp, + struct gl_shader_program *prog, + unsigned *final_assembly_size); GLboolean brw_link_shader(struct gl_context *ctx, struct gl_shader_program *prog); struct gl_shader *brw_new_shader(struct gl_context *ctx, GLuint name, GLuint type);