diff options
author | Jordan Justen <[email protected]> | 2018-02-28 17:58:02 -0800 |
---|---|---|
committer | Jordan Justen <[email protected]> | 2018-07-09 23:02:33 -0700 |
commit | 36dd15f8b337e6a864d736ba502b8aa3d0ae6e4f (patch) | |
tree | 7b5ffb0bf1941b8c348f8bb04d1cfd3caffa434d | |
parent | 65f2014740eb26c1b740dab435b9964e4bdb1164 (diff) |
i965: Add brw_populate_default_key
We will need to populate the default key for ARB_get_program_binary to
allow us to retrieve the default gen program to store in the program
binary.
Signed-off-by: Jordan Justen <[email protected]>
Reviewed-by: Timothy Arceri <[email protected]>
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_cs.c | 15 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_cs.h | 4 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_gs.c | 16 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_gs.h | 4 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_program.c | 35 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_program.h | 15 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_tcs.c | 57 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_tes.c | 40 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_vs.c | 26 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_vs.h | 4 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_wm.c | 48 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_wm.h | 4 |
12 files changed, 195 insertions, 73 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_cs.c b/src/mesa/drivers/dri/i965/brw_cs.c index 9b1b0832b5a..614eb64bca9 100644 --- a/src/mesa/drivers/dri/i965/brw_cs.c +++ b/src/mesa/drivers/dri/i965/brw_cs.c @@ -184,6 +184,16 @@ brw_upload_cs_prog(struct brw_context *brw) assert(success); } +void +brw_cs_populate_default_key(const struct gen_device_info *devinfo, + struct brw_cs_prog_key *key, + struct gl_program *prog) +{ + memset(key, 0, sizeof(*key)); + key->program_string_id = brw_program(prog)->id; + + brw_setup_tex_for_precompile(devinfo, &key->tex, prog); +} bool brw_cs_precompile(struct gl_context *ctx, struct gl_program *prog) @@ -193,10 +203,7 @@ brw_cs_precompile(struct gl_context *ctx, struct gl_program *prog) struct brw_program *bcp = brw_program(prog); - memset(&key, 0, sizeof(key)); - key.program_string_id = bcp->id; - - brw_setup_tex_for_precompile(&brw->screen->devinfo, &key.tex, prog); + brw_cs_populate_default_key(&brw->screen->devinfo, &key, prog); uint32_t old_prog_offset = brw->cs.base.prog_offset; struct brw_stage_prog_data *old_prog_data = brw->cs.base.prog_data; diff --git a/src/mesa/drivers/dri/i965/brw_cs.h b/src/mesa/drivers/dri/i965/brw_cs.h index 60eb19c3594..669d4b544eb 100644 --- a/src/mesa/drivers/dri/i965/brw_cs.h +++ b/src/mesa/drivers/dri/i965/brw_cs.h @@ -34,6 +34,10 @@ brw_upload_cs_prog(struct brw_context *brw); void brw_cs_populate_key(struct brw_context *brw, struct brw_cs_prog_key *key); +void +brw_cs_populate_default_key(const struct gen_device_info *devinfo, + struct brw_cs_prog_key *key, + struct gl_program *prog); #ifdef __cplusplus } diff --git a/src/mesa/drivers/dri/i965/brw_gs.c b/src/mesa/drivers/dri/i965/brw_gs.c index f488fab009e..9d4dc942d34 100644 --- a/src/mesa/drivers/dri/i965/brw_gs.c +++ b/src/mesa/drivers/dri/i965/brw_gs.c @@ -208,6 +208,17 @@ brw_upload_gs_prog(struct brw_context *brw) assert(success); } +void +brw_gs_populate_default_key(const struct gen_device_info *devinfo, + struct brw_gs_prog_key *key, + struct gl_program *prog) +{ + memset(key, 0, sizeof(*key)); + + brw_setup_tex_for_precompile(devinfo, &key->tex, prog); + key->program_string_id = brw_program(prog)->id; +} + bool brw_gs_precompile(struct gl_context *ctx, struct gl_program *prog) { @@ -219,10 +230,7 @@ brw_gs_precompile(struct gl_context *ctx, struct gl_program *prog) struct brw_program *bgp = brw_program(prog); - memset(&key, 0, sizeof(key)); - - brw_setup_tex_for_precompile(&brw->screen->devinfo, &key.tex, prog); - key.program_string_id = bgp->id; + brw_gs_populate_default_key(&brw->screen->devinfo, &key, prog); success = brw_codegen_gs_prog(brw, bgp, &key); diff --git a/src/mesa/drivers/dri/i965/brw_gs.h b/src/mesa/drivers/dri/i965/brw_gs.h index 537a41679df..cff994a9323 100644 --- a/src/mesa/drivers/dri/i965/brw_gs.h +++ b/src/mesa/drivers/dri/i965/brw_gs.h @@ -40,6 +40,10 @@ brw_upload_gs_prog(struct brw_context *brw); void brw_gs_populate_key(struct brw_context *brw, struct brw_gs_prog_key *key); +void +brw_gs_populate_default_key(const struct gen_device_info *devinfo, + struct brw_gs_prog_key *key, + struct gl_program *prog); #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesa/drivers/dri/i965/brw_program.c b/src/mesa/drivers/dri/i965/brw_program.c index 4dd27d84676..9fa1b4b9bb7 100644 --- a/src/mesa/drivers/dri/i965/brw_program.c +++ b/src/mesa/drivers/dri/i965/brw_program.c @@ -48,6 +48,11 @@ #include "brw_defines.h" #include "intel_batchbuffer.h" +#include "brw_cs.h" +#include "brw_gs.h" +#include "brw_vs.h" +#include "brw_wm.h" + static bool brw_nir_lower_uniforms(nir_shader *nir, bool is_scalar) { @@ -853,3 +858,33 @@ brw_prog_key_set_id(union brw_any_prog_key *key, gl_shader_stage stage, assert((int)stage >= 0 && stage < ARRAY_SIZE(stage_offsets)); *(unsigned*)((uint8_t*)key + stage_offsets[stage]) = id; } + +void +brw_populate_default_key(const struct gen_device_info *devinfo, + union brw_any_prog_key *prog_key, + struct gl_shader_program *sh_prog, + struct gl_program *prog) +{ + switch (prog->info.stage) { + case MESA_SHADER_VERTEX: + brw_vs_populate_default_key(devinfo, &prog_key->vs, prog); + break; + case MESA_SHADER_TESS_CTRL: + brw_tcs_populate_default_key(devinfo, &prog_key->tcs, sh_prog, prog); + break; + case MESA_SHADER_TESS_EVAL: + brw_tes_populate_default_key(devinfo, &prog_key->tes, sh_prog, prog); + break; + case MESA_SHADER_GEOMETRY: + brw_gs_populate_default_key(devinfo, &prog_key->gs, prog); + break; + case MESA_SHADER_FRAGMENT: + brw_wm_populate_default_key(devinfo, &prog_key->wm, prog); + break; + case MESA_SHADER_COMPUTE: + brw_cs_populate_default_key(devinfo, &prog_key->cs, prog); + break; + default: + unreachable("Unsupported stage!"); + } +} diff --git a/src/mesa/drivers/dri/i965/brw_program.h b/src/mesa/drivers/dri/i965/brw_program.h index c8656fcff1f..32c87fa2321 100644 --- a/src/mesa/drivers/dri/i965/brw_program.h +++ b/src/mesa/drivers/dri/i965/brw_program.h @@ -82,11 +82,18 @@ brw_assign_common_binding_table_offsets(const struct gen_device_info *devinfo, const struct gl_program *prog, struct brw_stage_prog_data *stage_prog_data, uint32_t next_binding_table_offset); + void brw_prog_key_set_id(union brw_any_prog_key *key, gl_shader_stage stage, unsigned id); void +brw_populate_default_key(const struct gen_device_info *devinfo, + union brw_any_prog_key *prog_key, + struct gl_shader_program *sh_prog, + struct gl_program *prog); + +void brw_stage_prog_data_free(const void *prog_data); void @@ -108,9 +115,17 @@ GLboolean brw_link_shader(struct gl_context *ctx, struct gl_shader_program *prog void brw_upload_tcs_prog(struct brw_context *brw); void brw_tcs_populate_key(struct brw_context *brw, struct brw_tcs_prog_key *key); +void brw_tcs_populate_default_key(const struct gen_device_info *devinfo, + struct brw_tcs_prog_key *key, + struct gl_shader_program *sh_prog, + struct gl_program *prog); void brw_upload_tes_prog(struct brw_context *brw); void brw_tes_populate_key(struct brw_context *brw, struct brw_tes_prog_key *key); +void brw_tes_populate_default_key(const struct gen_device_info *devinfo, + struct brw_tes_prog_key *key, + struct gl_shader_program *sh_prog, + struct gl_program *prog); void brw_write_blob_program_data(struct blob *binary, gl_shader_stage stage, const void *program, diff --git a/src/mesa/drivers/dri/i965/brw_tcs.c b/src/mesa/drivers/dri/i965/brw_tcs.c index 70313fee8ac..eaea00e9e48 100644 --- a/src/mesa/drivers/dri/i965/brw_tcs.c +++ b/src/mesa/drivers/dri/i965/brw_tcs.c @@ -354,6 +354,37 @@ brw_upload_tcs_prog(struct brw_context *brw) assert(success); } +void +brw_tcs_populate_default_key(const struct gen_device_info *devinfo, + struct brw_tcs_prog_key *key, + struct gl_shader_program *sh_prog, + struct gl_program *prog) +{ + struct brw_program *btcp = brw_program(prog); + const struct gl_linked_shader *tes = + sh_prog->_LinkedShaders[MESA_SHADER_TESS_EVAL]; + + memset(key, 0, sizeof(*key)); + + key->program_string_id = btcp->id; + brw_setup_tex_for_precompile(devinfo, &key->tex, prog); + + /* Guess that the input and output patches have the same dimensionality. */ + if (devinfo->gen < 8) + key->input_vertices = prog->info.tess.tcs_vertices_out; + + if (tes) { + key->tes_primitive_mode = tes->Program->info.tess.primitive_mode; + key->quads_workaround = devinfo->gen < 9 && + tes->Program->info.tess.primitive_mode == GL_QUADS && + tes->Program->info.tess.spacing == TESS_SPACING_EQUAL; + } else { + key->tes_primitive_mode = GL_TRIANGLES; + } + + key->outputs_written = prog->nir->info.outputs_written; + key->patch_outputs_written = prog->nir->info.patch_outputs_written; +} bool brw_tcs_precompile(struct gl_context *ctx, @@ -369,31 +400,9 @@ brw_tcs_precompile(struct gl_context *ctx, struct brw_program *btcp = brw_program(prog); const struct gl_linked_shader *tes = shader_prog->_LinkedShaders[MESA_SHADER_TESS_EVAL]; - const struct gen_device_info *devinfo = &brw->screen->devinfo; - - memset(&key, 0, sizeof(key)); - - key.program_string_id = btcp->id; - brw_setup_tex_for_precompile(&brw->screen->devinfo, &key.tex, prog); - - /* Guess that the input and output patches have the same dimensionality. */ - if (devinfo->gen < 8) - key.input_vertices = prog->info.tess.tcs_vertices_out; - - struct brw_program *btep; - if (tes) { - btep = brw_program(tes->Program); - key.tes_primitive_mode = tes->Program->info.tess.primitive_mode; - key.quads_workaround = devinfo->gen < 9 && - tes->Program->info.tess.primitive_mode == GL_QUADS && - tes->Program->info.tess.spacing == TESS_SPACING_EQUAL; - } else { - btep = NULL; - key.tes_primitive_mode = GL_TRIANGLES; - } + struct brw_program *btep = tes ? brw_program(tes->Program) : NULL; - key.outputs_written = prog->nir->info.outputs_written; - key.patch_outputs_written = prog->nir->info.patch_outputs_written; + brw_tcs_populate_default_key(&brw->screen->devinfo, &key, shader_prog, prog); success = brw_codegen_tcs_prog(brw, btcp, btep, &key); diff --git a/src/mesa/drivers/dri/i965/brw_tes.c b/src/mesa/drivers/dri/i965/brw_tes.c index 72b218ac14f..2811dbd649a 100644 --- a/src/mesa/drivers/dri/i965/brw_tes.c +++ b/src/mesa/drivers/dri/i965/brw_tes.c @@ -211,6 +211,30 @@ brw_upload_tes_prog(struct brw_context *brw) assert(success); } +void +brw_tes_populate_default_key(const struct gen_device_info *devinfo, + struct brw_tes_prog_key *key, + struct gl_shader_program *sh_prog, + struct gl_program *prog) +{ + struct brw_program *btep = brw_program(prog); + + memset(key, 0, sizeof(*key)); + + key->program_string_id = btep->id; + key->inputs_read = prog->nir->info.inputs_read; + key->patch_inputs_read = prog->nir->info.patch_inputs_read; + + if (sh_prog->_LinkedShaders[MESA_SHADER_TESS_CTRL]) { + struct gl_program *tcp = + sh_prog->_LinkedShaders[MESA_SHADER_TESS_CTRL]->Program; + key->inputs_read |= tcp->nir->info.outputs_written & + ~(VARYING_BIT_TESS_LEVEL_INNER | VARYING_BIT_TESS_LEVEL_OUTER); + key->patch_inputs_read |= tcp->nir->info.patch_outputs_written; + } + + brw_setup_tex_for_precompile(devinfo, &key->tex, prog); +} bool brw_tes_precompile(struct gl_context *ctx, @@ -225,21 +249,7 @@ brw_tes_precompile(struct gl_context *ctx, struct brw_program *btep = brw_program(prog); - memset(&key, 0, sizeof(key)); - - key.program_string_id = btep->id; - key.inputs_read = prog->nir->info.inputs_read; - key.patch_inputs_read = prog->nir->info.patch_inputs_read; - - if (shader_prog->_LinkedShaders[MESA_SHADER_TESS_CTRL]) { - struct gl_program *tcp = - shader_prog->_LinkedShaders[MESA_SHADER_TESS_CTRL]->Program; - key.inputs_read |= tcp->nir->info.outputs_written & - ~(VARYING_BIT_TESS_LEVEL_INNER | VARYING_BIT_TESS_LEVEL_OUTER); - key.patch_inputs_read |= tcp->nir->info.patch_outputs_written; - } - - brw_setup_tex_for_precompile(&brw->screen->devinfo, &key.tex, prog); + brw_tes_populate_default_key(&brw->screen->devinfo, &key, shader_prog, prog); success = brw_codegen_tes_prog(brw, btep, &key); diff --git a/src/mesa/drivers/dri/i965/brw_vs.c b/src/mesa/drivers/dri/i965/brw_vs.c index f024c33c02d..21e75664ae9 100644 --- a/src/mesa/drivers/dri/i965/brw_vs.c +++ b/src/mesa/drivers/dri/i965/brw_vs.c @@ -356,6 +356,23 @@ brw_upload_vs_prog(struct brw_context *brw) assert(success); } +void +brw_vs_populate_default_key(const struct gen_device_info *devinfo, + struct brw_vs_prog_key *key, + struct gl_program *prog) +{ + struct brw_program *bvp = brw_program(prog); + + memset(key, 0, sizeof(*key)); + + brw_setup_tex_for_precompile(devinfo, &key->tex, prog); + key->program_string_id = bvp->id; + key->clamp_vertex_color = + (prog->info.outputs_written & + (VARYING_BIT_COL0 | VARYING_BIT_COL1 | VARYING_BIT_BFC0 | + VARYING_BIT_BFC1)); +} + bool brw_vs_precompile(struct gl_context *ctx, struct gl_program *prog) { @@ -367,14 +384,7 @@ brw_vs_precompile(struct gl_context *ctx, struct gl_program *prog) struct brw_program *bvp = brw_program(prog); - memset(&key, 0, sizeof(key)); - - brw_setup_tex_for_precompile(&brw->screen->devinfo, &key.tex, prog); - key.program_string_id = bvp->id; - key.clamp_vertex_color = - (prog->info.outputs_written & - (VARYING_BIT_COL0 | VARYING_BIT_COL1 | VARYING_BIT_BFC0 | - VARYING_BIT_BFC1)); + brw_vs_populate_default_key(&brw->screen->devinfo, &key, prog); success = brw_codegen_vs_prog(brw, bvp, &key); diff --git a/src/mesa/drivers/dri/i965/brw_vs.h b/src/mesa/drivers/dri/i965/brw_vs.h index 9d01aacb6a2..94419f3af0c 100644 --- a/src/mesa/drivers/dri/i965/brw_vs.h +++ b/src/mesa/drivers/dri/i965/brw_vs.h @@ -45,6 +45,10 @@ brw_upload_vs_prog(struct brw_context *brw); void brw_vs_populate_key(struct brw_context *brw, struct brw_vs_prog_key *key); +void +brw_vs_populate_default_key(const struct gen_device_info *devinfo, + struct brw_vs_prog_key *key, + struct gl_program *prog); #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c index 0fda9c5069d..a8cf07ce7e2 100644 --- a/src/mesa/drivers/dri/i965/brw_wm.c +++ b/src/mesa/drivers/dri/i965/brw_wm.c @@ -607,47 +607,59 @@ brw_upload_wm_prog(struct brw_context *brw) assert(success); } -bool -brw_fs_precompile(struct gl_context *ctx, struct gl_program *prog) +void +brw_wm_populate_default_key(const struct gen_device_info *devinfo, + struct brw_wm_prog_key *key, + struct gl_program *prog) { - struct brw_context *brw = brw_context(ctx); - const struct gen_device_info *devinfo = &brw->screen->devinfo; - struct brw_wm_prog_key key; - - struct brw_program *bfp = brw_program(prog); - - memset(&key, 0, sizeof(key)); + memset(key, 0, sizeof(*key)); uint64_t outputs_written = prog->info.outputs_written; if (devinfo->gen < 6) { if (prog->info.fs.uses_discard) - key.iz_lookup |= BRW_WM_IZ_PS_KILL_ALPHATEST_BIT; + key->iz_lookup |= BRW_WM_IZ_PS_KILL_ALPHATEST_BIT; if (outputs_written & BITFIELD64_BIT(FRAG_RESULT_DEPTH)) - key.iz_lookup |= BRW_WM_IZ_PS_COMPUTES_DEPTH_BIT; + key->iz_lookup |= BRW_WM_IZ_PS_COMPUTES_DEPTH_BIT; /* Just assume depth testing. */ - key.iz_lookup |= BRW_WM_IZ_DEPTH_TEST_ENABLE_BIT; - key.iz_lookup |= BRW_WM_IZ_DEPTH_WRITE_ENABLE_BIT; + key->iz_lookup |= BRW_WM_IZ_DEPTH_TEST_ENABLE_BIT; + key->iz_lookup |= BRW_WM_IZ_DEPTH_WRITE_ENABLE_BIT; } if (devinfo->gen < 6 || _mesa_bitcount_64(prog->info.inputs_read & BRW_FS_VARYING_INPUT_MASK) > 16) { - key.input_slots_valid = prog->info.inputs_read | VARYING_BIT_POS; + key->input_slots_valid = prog->info.inputs_read | VARYING_BIT_POS; } - brw_setup_tex_for_precompile(&brw->screen->devinfo, &key.tex, prog); + brw_setup_tex_for_precompile(devinfo, &key->tex, prog); - key.nr_color_regions = _mesa_bitcount_64(outputs_written & + key->nr_color_regions = _mesa_bitcount_64(outputs_written & ~(BITFIELD64_BIT(FRAG_RESULT_DEPTH) | BITFIELD64_BIT(FRAG_RESULT_STENCIL) | BITFIELD64_BIT(FRAG_RESULT_SAMPLE_MASK))); - key.program_string_id = bfp->id; + key->program_string_id = brw_program(prog)->id; /* Whether reads from the framebuffer should behave coherently. */ - key.coherent_fb_fetch = ctx->Extensions.EXT_shader_framebuffer_fetch; + key->coherent_fb_fetch = devinfo->gen >= 9; +} + +bool +brw_fs_precompile(struct gl_context *ctx, struct gl_program *prog) +{ + struct brw_context *brw = brw_context(ctx); + const struct gen_device_info *devinfo = &brw->screen->devinfo; + struct brw_wm_prog_key key; + + struct brw_program *bfp = brw_program(prog); + + brw_wm_populate_default_key(&brw->screen->devinfo, &key, prog); + + /* check brw_wm_populate_default_key coherent_fb_fetch setting */ + assert(key.coherent_fb_fetch == + ctx->Extensions.EXT_shader_framebuffer_fetch); uint32_t old_prog_offset = brw->wm.base.prog_offset; struct brw_stage_prog_data *old_prog_data = brw->wm.base.prog_data; diff --git a/src/mesa/drivers/dri/i965/brw_wm.h b/src/mesa/drivers/dri/i965/brw_wm.h index 113cdf33bbf..ea944972997 100644 --- a/src/mesa/drivers/dri/i965/brw_wm.h +++ b/src/mesa/drivers/dri/i965/brw_wm.h @@ -47,6 +47,10 @@ brw_upload_wm_prog(struct brw_context *brw); void brw_wm_populate_key(struct brw_context *brw, struct brw_wm_prog_key *key); +void +brw_wm_populate_default_key(const struct gen_device_info *devinfo, + struct brw_wm_prog_key *key, + struct gl_program *prog); #ifdef __cplusplus } // extern "C" |