i965: Pass gl_program pointers into precompile functions.
We'd like to do precompiling for ARB vertex and fragment programs, which only have gl_program structures - gl_shader_program is NULL. This patch makes the various precompile functions take a gl_program parameter directly, rather than accessing it via gl_shader_program. Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Kristian Høgsberg <krh@bitplanet.net> Reviewed-by: Matt Turner <mattst88@gmail.com>
This commit is contained in:
parent
d54925df9c
commit
62b425448c
|
@ -3749,16 +3749,14 @@ brw_wm_fs_emit(struct brw_context *brw,
|
|||
}
|
||||
|
||||
bool
|
||||
brw_fs_precompile(struct gl_context *ctx, struct gl_shader_program *prog)
|
||||
brw_fs_precompile(struct gl_context *ctx,
|
||||
struct gl_shader_program *shader_prog,
|
||||
struct gl_program *prog)
|
||||
{
|
||||
struct brw_context *brw = brw_context(ctx);
|
||||
struct brw_wm_prog_key key;
|
||||
|
||||
if (!prog->_LinkedShaders[MESA_SHADER_FRAGMENT])
|
||||
return true;
|
||||
|
||||
struct gl_fragment_program *fp = (struct gl_fragment_program *)
|
||||
prog->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program;
|
||||
struct gl_fragment_program *fp = (struct gl_fragment_program *) prog;
|
||||
struct brw_fragment_program *bfp = brw_fragment_program(fp);
|
||||
bool program_uses_dfdy = fp->UsesDFdy;
|
||||
|
||||
|
@ -3816,7 +3814,7 @@ brw_fs_precompile(struct gl_context *ctx, struct gl_shader_program *prog)
|
|||
uint32_t old_prog_offset = brw->wm.base.prog_offset;
|
||||
struct brw_wm_prog_data *old_prog_data = brw->wm.prog_data;
|
||||
|
||||
bool success = do_wm_prog(brw, prog, bfp, &key);
|
||||
bool success = do_wm_prog(brw, shader_prog, bfp, &key);
|
||||
|
||||
brw->wm.base.prog_offset = old_prog_offset;
|
||||
brw->wm.prog_data = old_prog_data;
|
||||
|
|
|
@ -797,6 +797,8 @@ private:
|
|||
|
||||
bool brw_do_channel_expressions(struct exec_list *instructions);
|
||||
bool brw_do_vector_splitting(struct exec_list *instructions);
|
||||
bool brw_fs_precompile(struct gl_context *ctx, struct gl_shader_program *prog);
|
||||
bool brw_fs_precompile(struct gl_context *ctx,
|
||||
struct gl_shader_program *shader_prog,
|
||||
struct gl_program *prog);
|
||||
|
||||
struct brw_reg brw_reg_from_fs_reg(fs_reg *reg);
|
||||
|
|
|
@ -374,7 +374,9 @@ const struct brw_tracked_state brw_gs_prog = {
|
|||
|
||||
|
||||
bool
|
||||
brw_gs_precompile(struct gl_context *ctx, struct gl_shader_program *prog)
|
||||
brw_gs_precompile(struct gl_context *ctx,
|
||||
struct gl_shader_program *shader_prog,
|
||||
struct gl_program *prog)
|
||||
{
|
||||
struct brw_context *brw = brw_context(ctx);
|
||||
struct brw_gs_prog_key key;
|
||||
|
@ -382,11 +384,7 @@ brw_gs_precompile(struct gl_context *ctx, struct gl_shader_program *prog)
|
|||
struct brw_gs_prog_data *old_prog_data = brw->gs.prog_data;
|
||||
bool success;
|
||||
|
||||
if (!prog->_LinkedShaders[MESA_SHADER_GEOMETRY])
|
||||
return true;
|
||||
|
||||
struct gl_geometry_program *gp = (struct gl_geometry_program *)
|
||||
prog->_LinkedShaders[MESA_SHADER_GEOMETRY]->Program;
|
||||
struct gl_geometry_program *gp = (struct gl_geometry_program *) prog;
|
||||
struct brw_geometry_program *bgp = brw_geometry_program(gp);
|
||||
|
||||
memset(&key, 0, sizeof(key));
|
||||
|
@ -398,7 +396,7 @@ brw_gs_precompile(struct gl_context *ctx, struct gl_shader_program *prog)
|
|||
*/
|
||||
key.input_varyings = gp->Base.InputsRead;
|
||||
|
||||
success = do_gs_prog(brw, prog, bgp, &key);
|
||||
success = do_gs_prog(brw, shader_prog, bgp, &key);
|
||||
|
||||
brw->gs.base.prog_offset = old_prog_offset;
|
||||
brw->gs.prog_data = old_prog_data;
|
||||
|
|
|
@ -32,8 +32,11 @@ extern "C" {
|
|||
|
||||
struct gl_context;
|
||||
struct gl_shader_program;
|
||||
struct gl_program;
|
||||
|
||||
bool brw_gs_precompile(struct gl_context *ctx, struct gl_shader_program *prog);
|
||||
bool brw_gs_precompile(struct gl_context *ctx,
|
||||
struct gl_shader_program *shader_prog,
|
||||
struct gl_program *prog);
|
||||
bool brw_gs_prog_data_compare(const void *a, const void *b);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -55,17 +55,20 @@ brw_new_shader(struct gl_context *ctx, GLuint name, GLuint type)
|
|||
* the eventual NOS used, and thus allows us to produce link failures.
|
||||
*/
|
||||
static bool
|
||||
brw_shader_precompile(struct gl_context *ctx, struct gl_shader_program *prog)
|
||||
brw_shader_precompile(struct gl_context *ctx,
|
||||
struct gl_shader_program *sh_prog)
|
||||
{
|
||||
struct brw_context *brw = brw_context(ctx);
|
||||
struct gl_shader *vs = sh_prog->_LinkedShaders[MESA_SHADER_VERTEX];
|
||||
struct gl_shader *gs = sh_prog->_LinkedShaders[MESA_SHADER_GEOMETRY];
|
||||
struct gl_shader *fs = sh_prog->_LinkedShaders[MESA_SHADER_FRAGMENT];
|
||||
|
||||
if (!brw_fs_precompile(ctx, prog))
|
||||
if (fs && !brw_fs_precompile(ctx, sh_prog, fs->Program))
|
||||
return false;
|
||||
|
||||
if (!brw_gs_precompile(ctx, prog))
|
||||
if (gs && !brw_gs_precompile(ctx, sh_prog, gs->Program))
|
||||
return false;
|
||||
|
||||
if (!brw_vs_precompile(ctx, prog))
|
||||
if (vs && !brw_vs_precompile(ctx, sh_prog, vs->Program))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
|
|
@ -523,7 +523,9 @@ const struct brw_tracked_state brw_vs_prog = {
|
|||
};
|
||||
|
||||
bool
|
||||
brw_vs_precompile(struct gl_context *ctx, struct gl_shader_program *prog)
|
||||
brw_vs_precompile(struct gl_context *ctx,
|
||||
struct gl_shader_program *shader_prog,
|
||||
struct gl_program *prog)
|
||||
{
|
||||
struct brw_context *brw = brw_context(ctx);
|
||||
struct brw_vs_prog_key key;
|
||||
|
@ -531,18 +533,14 @@ brw_vs_precompile(struct gl_context *ctx, struct gl_shader_program *prog)
|
|||
struct brw_vs_prog_data *old_prog_data = brw->vs.prog_data;
|
||||
bool success;
|
||||
|
||||
if (!prog->_LinkedShaders[MESA_SHADER_VERTEX])
|
||||
return true;
|
||||
|
||||
struct gl_vertex_program *vp = (struct gl_vertex_program *)
|
||||
prog->_LinkedShaders[MESA_SHADER_VERTEX]->Program;
|
||||
struct gl_vertex_program *vp = (struct gl_vertex_program *) prog;
|
||||
struct brw_vertex_program *bvp = brw_vertex_program(vp);
|
||||
|
||||
memset(&key, 0, sizeof(key));
|
||||
|
||||
brw_vec4_setup_prog_key_for_precompile(ctx, &key.base, bvp->id, &vp->Base);
|
||||
|
||||
success = do_vs_prog(brw, prog, bvp, &key);
|
||||
success = do_vs_prog(brw, shader_prog, bvp, &key);
|
||||
|
||||
brw->vs.base.prog_offset = old_prog_offset;
|
||||
brw->vs.prog_data = old_prog_data;
|
||||
|
|
|
@ -89,7 +89,9 @@ const unsigned *brw_vs_emit(struct brw_context *brw,
|
|||
struct brw_vs_prog_data *prog_data,
|
||||
void *mem_ctx,
|
||||
unsigned *program_size);
|
||||
bool brw_vs_precompile(struct gl_context *ctx, struct gl_shader_program *prog);
|
||||
bool brw_vs_precompile(struct gl_context *ctx,
|
||||
struct gl_shader_program *shader_prog,
|
||||
struct gl_program *prog);
|
||||
void brw_vs_debug_recompile(struct brw_context *brw,
|
||||
struct gl_shader_program *prog,
|
||||
const struct brw_vs_prog_key *key);
|
||||
|
|
Loading…
Reference in New Issue