diff options
Diffstat (limited to 'src')
30 files changed, 183 insertions, 240 deletions
diff --git a/src/gallium/drivers/iris/iris_disk_cache.c b/src/gallium/drivers/iris/iris_disk_cache.c index 26fc917547b..325903c9861 100644 --- a/src/gallium/drivers/iris/iris_disk_cache.c +++ b/src/gallium/drivers/iris/iris_disk_cache.c @@ -51,15 +51,13 @@ iris_disk_cache_compute_key(struct disk_cache *cache, uint32_t prog_key_size, cache_key cache_key) { - gl_shader_stage stage = ish->nir->info.stage; - /* Create a copy of the program key with program_string_id zeroed out. * It's essentially random data which we don't want to include in our * hashing and comparisons. We'll set a proper value on a cache hit. */ union brw_any_prog_key prog_key; memcpy(&prog_key, orig_prog_key, prog_key_size); - brw_prog_key_set_id(&prog_key, stage, 0); + prog_key.base.program_string_id = 0; uint8_t data[sizeof(prog_key) + sizeof(ish->nir_sha1)]; uint32_t data_size = prog_key_size + sizeof(ish->nir_sha1); diff --git a/src/gallium/drivers/iris/iris_program.c b/src/gallium/drivers/iris/iris_program.c index 70188a9fae3..f16723caeb0 100644 --- a/src/gallium/drivers/iris/iris_program.c +++ b/src/gallium/drivers/iris/iris_program.c @@ -46,11 +46,11 @@ #include "iris_context.h" #include "nir/tgsi_to_nir.h" -#define KEY_INIT_NO_ID(gen) \ - .tex.swizzles[0 ... MAX_SAMPLERS - 1] = 0x688, \ - .tex.compressed_multisample_layout_mask = ~0, \ - .tex.msaa_16 = (gen >= 9 ? ~0 : 0) -#define KEY_INIT(gen) .program_string_id = ish->program_id, KEY_INIT_NO_ID(gen) +#define KEY_INIT_NO_ID(gen) \ + .base.tex.swizzles[0 ... MAX_SAMPLERS - 1] = 0x688, \ + .base.tex.compressed_multisample_layout_mask = ~0, \ + .base.tex.msaa_16 = (gen >= 9 ? ~0 : 0) +#define KEY_INIT(gen) .base.program_string_id = ish->program_id, KEY_INIT_NO_ID(gen) static unsigned get_new_program_id(struct iris_screen *screen) @@ -853,8 +853,7 @@ iris_setup_binding_table(struct nir_shader *nir, static void iris_debug_recompile(struct iris_context *ice, struct shader_info *info, - unsigned program_string_id, - const void *key) + const struct brw_base_prog_key *key) { struct iris_screen *screen = (struct iris_screen *) ice->ctx.screen; const struct brw_compiler *c = screen->compiler; @@ -868,7 +867,7 @@ iris_debug_recompile(struct iris_context *ice, info->label ? info->label : ""); const void *old_key = - iris_find_previous_compile(ice, info->stage, program_string_id); + iris_find_previous_compile(ice, info->stage, key->program_string_id); brw_debug_key_recompile(c, &ice->dbg, info->stage, old_key, key); } @@ -937,7 +936,7 @@ iris_compile_vs(struct iris_context *ice, } if (ish->compiled_once) { - iris_debug_recompile(ice, &nir->info, key->program_string_id, key); + iris_debug_recompile(ice, &nir->info, &key->base); } else { ish->compiled_once = true; } @@ -1148,7 +1147,7 @@ iris_compile_tcs(struct iris_context *ice, if (ish) { if (ish->compiled_once) { - iris_debug_recompile(ice, &nir->info, key->program_string_id, key); + iris_debug_recompile(ice, &nir->info, &key->base); } else { ish->compiled_once = true; } @@ -1184,7 +1183,7 @@ iris_update_compiled_tcs(struct iris_context *ice) iris_get_shader_info(ice, MESA_SHADER_TESS_EVAL); struct brw_tcs_prog_key key = { KEY_INIT_NO_ID(devinfo->gen), - .program_string_id = tcs ? tcs->program_id : 0, + .base.program_string_id = tcs ? tcs->program_id : 0, .tes_primitive_mode = tes_info->tess.primitive_mode, .input_vertices = ice->state.vertices_per_patch, }; @@ -1256,7 +1255,7 @@ iris_compile_tes(struct iris_context *ice, } if (ish->compiled_once) { - iris_debug_recompile(ice, &nir->info, key->program_string_id, key); + iris_debug_recompile(ice, &nir->info, &key->base); } else { ish->compiled_once = true; } @@ -1367,7 +1366,7 @@ iris_compile_gs(struct iris_context *ice, } if (ish->compiled_once) { - iris_debug_recompile(ice, &nir->info, key->program_string_id, key); + iris_debug_recompile(ice, &nir->info, &key->base); } else { ish->compiled_once = true; } @@ -1469,7 +1468,7 @@ iris_compile_fs(struct iris_context *ice, } if (ish->compiled_once) { - iris_debug_recompile(ice, &nir->info, key->program_string_id, key); + iris_debug_recompile(ice, &nir->info, &key->base); } else { ish->compiled_once = true; } @@ -1732,7 +1731,7 @@ iris_compile_cs(struct iris_context *ice, } if (ish->compiled_once) { - iris_debug_recompile(ice, &nir->info, key->program_string_id, key); + iris_debug_recompile(ice, &nir->info, &key->base); } else { ish->compiled_once = true; } diff --git a/src/gallium/drivers/iris/iris_program_cache.c b/src/gallium/drivers/iris/iris_program_cache.c index 4e6f4e28c0b..4ec2a52c2de 100644 --- a/src/gallium/drivers/iris/iris_program_cache.c +++ b/src/gallium/drivers/iris/iris_program_cache.c @@ -83,27 +83,6 @@ keybox_equals(const void *void_a, const void *void_b) return memcmp(a->data, b->data, a->size) == 0; } -static unsigned -get_program_string_id(enum iris_program_cache_id cache_id, const void *key) -{ - switch (cache_id) { - case IRIS_CACHE_VS: - return ((struct brw_vs_prog_key *) key)->program_string_id; - case IRIS_CACHE_TCS: - return ((struct brw_tcs_prog_key *) key)->program_string_id; - case IRIS_CACHE_TES: - return ((struct brw_tes_prog_key *) key)->program_string_id; - case IRIS_CACHE_GS: - return ((struct brw_gs_prog_key *) key)->program_string_id; - case IRIS_CACHE_CS: - return ((struct brw_cs_prog_key *) key)->program_string_id; - case IRIS_CACHE_FS: - return ((struct brw_wm_prog_key *) key)->program_string_id; - default: - unreachable("no program string id for this kind of program"); - } -} - struct iris_compiled_shader * iris_find_cached_shader(struct iris_context *ice, enum iris_program_cache_id cache_id, @@ -127,8 +106,9 @@ iris_find_previous_compile(const struct iris_context *ice, { hash_table_foreach(ice->shaders.cache, entry) { const struct keybox *keybox = entry->key; + const struct brw_base_prog_key *key = (const void *)keybox->data; if (keybox->cache_id == cache_id && - get_program_string_id(cache_id, keybox->data) == program_string_id) { + key->program_string_id == program_string_id) { return keybox->data; } } diff --git a/src/intel/blorp/blorp.c b/src/intel/blorp/blorp.c index 8f64f1af37c..1144e770b49 100644 --- a/src/intel/blorp/blorp.c +++ b/src/intel/blorp/blorp.c @@ -165,7 +165,7 @@ brw_blorp_init_wm_prog_key(struct brw_wm_prog_key *wm_key) memset(wm_key, 0, sizeof(*wm_key)); wm_key->nr_color_regions = 1; for (int i = 0; i < MAX_SAMPLERS; i++) - wm_key->tex.swizzles[i] = SWIZZLE_XYZW; + wm_key->base.tex.swizzles[i] = SWIZZLE_XYZW; } const unsigned * diff --git a/src/intel/blorp/blorp_blit.c b/src/intel/blorp/blorp_blit.c index 3b8a5b49862..78a47c9cbe5 100644 --- a/src/intel/blorp/blorp_blit.c +++ b/src/intel/blorp/blorp_blit.c @@ -1496,9 +1496,9 @@ brw_blorp_get_blit_kernel(struct blorp_batch *batch, struct brw_wm_prog_key wm_key; brw_blorp_init_wm_prog_key(&wm_key); - wm_key.tex.compressed_multisample_layout_mask = + wm_key.base.tex.compressed_multisample_layout_mask = prog_key->tex_aux_usage == ISL_AUX_USAGE_MCS; - wm_key.tex.msaa_16 = prog_key->tex_samples == 16; + wm_key.base.tex.msaa_16 = prog_key->tex_samples == 16; wm_key.multisample_fbo = prog_key->rt_samples > 1; program = blorp_compile_fs(blorp, mem_ctx, nir, &wm_key, false, diff --git a/src/intel/blorp/blorp_clear.c b/src/intel/blorp/blorp_clear.c index 00447aa9690..7e77e80565f 100644 --- a/src/intel/blorp/blorp_clear.c +++ b/src/intel/blorp/blorp_clear.c @@ -1002,8 +1002,8 @@ blorp_params_get_mcs_partial_resolve_kernel(struct blorp_batch *batch, struct brw_wm_prog_key wm_key; brw_blorp_init_wm_prog_key(&wm_key); - wm_key.tex.compressed_multisample_layout_mask = 1; - wm_key.tex.msaa_16 = blorp_key.num_samples == 16; + wm_key.base.tex.compressed_multisample_layout_mask = 1; + wm_key.base.tex.msaa_16 = blorp_key.num_samples == 16; wm_key.multisample_fbo = true; struct brw_wm_prog_data prog_data; diff --git a/src/intel/compiler/brw_compiler.c b/src/intel/compiler/brw_compiler.c index aacd9f2aca4..eb1f3808fbc 100644 --- a/src/intel/compiler/brw_compiler.c +++ b/src/intel/compiler/brw_compiler.c @@ -263,20 +263,3 @@ brw_prog_key_size(gl_shader_stage stage) assert((int)stage >= 0 && stage < ARRAY_SIZE(stage_sizes)); return stage_sizes[stage]; } - -void -brw_prog_key_set_id(union brw_any_prog_key *key, - gl_shader_stage stage, - unsigned id) -{ - static const unsigned stage_offsets[] = { - offsetof(struct brw_vs_prog_key, program_string_id), - offsetof(struct brw_tcs_prog_key, program_string_id), - offsetof(struct brw_tes_prog_key, program_string_id), - offsetof(struct brw_gs_prog_key, program_string_id), - offsetof(struct brw_wm_prog_key, program_string_id), - offsetof(struct brw_cs_prog_key, program_string_id), - }; - assert((int)stage >= 0 && stage < ARRAY_SIZE(stage_offsets)); - *(unsigned*)((uint8_t*)key + stage_offsets[stage]) = id; -} diff --git a/src/intel/compiler/brw_compiler.h b/src/intel/compiler/brw_compiler.h index 3c109c504b1..8f8cca79deb 100644 --- a/src/intel/compiler/brw_compiler.h +++ b/src/intel/compiler/brw_compiler.h @@ -203,6 +203,12 @@ struct brw_sampler_prog_key_data { float scale_factors[32]; }; +struct brw_base_prog_key { + unsigned program_string_id; + + struct brw_sampler_prog_key_data tex; +}; + /** * The VF can't natively handle certain types of attributes, such as GL_FIXED * or most 10_10_10_2 types. These flags enable various VS workarounds to @@ -225,7 +231,7 @@ struct brw_sampler_prog_key_data { /** The program key for Vertex Shaders. */ struct brw_vs_prog_key { - unsigned program_string_id; + struct brw_base_prog_key base; /** * Per-attribute workaround flags @@ -263,14 +269,12 @@ struct brw_vs_prog_key { * the VUE, even if they aren't written by the vertex shader. */ uint8_t point_coord_replace; - - struct brw_sampler_prog_key_data tex; }; /** The program key for Tessellation Control Shaders. */ struct brw_tcs_prog_key { - unsigned program_string_id; + struct brw_base_prog_key base; GLenum tes_primitive_mode; @@ -283,30 +287,24 @@ struct brw_tcs_prog_key uint64_t outputs_written; bool quads_workaround; - - struct brw_sampler_prog_key_data tex; }; /** The program key for Tessellation Evaluation Shaders. */ struct brw_tes_prog_key { - unsigned program_string_id; + struct brw_base_prog_key base; /** A bitfield of per-patch inputs read. */ uint32_t patch_inputs_read; /** A bitfield of per-vertex inputs read. */ uint64_t inputs_read; - - struct brw_sampler_prog_key_data tex; }; /** The program key for Geometry Shaders. */ struct brw_gs_prog_key { - unsigned program_string_id; - - struct brw_sampler_prog_key_data tex; + struct brw_base_prog_key base; }; enum brw_sf_primitive { @@ -394,6 +392,8 @@ enum brw_wm_aa_enable { /** The program key for Fragment/Pixel Shaders. */ struct brw_wm_prog_key { + struct brw_base_prog_key base; + /* Some collection of BRW_WM_IZ_* */ uint8_t iz_lookup; bool stats_wm:1; @@ -412,20 +412,17 @@ struct brw_wm_prog_key { uint8_t color_outputs_valid; uint64_t input_slots_valid; - unsigned program_string_id; GLenum alpha_test_func; /* < For Gen4/5 MRT alpha test */ float alpha_test_ref; - - struct brw_sampler_prog_key_data tex; }; struct brw_cs_prog_key { - uint32_t program_string_id; - struct brw_sampler_prog_key_data tex; + struct brw_base_prog_key base; }; /* brw_any_prog_key is any of the keys that map to an API stage */ union brw_any_prog_key { + struct brw_base_prog_key base; struct brw_vs_prog_key vs; struct brw_tcs_prog_key tcs; struct brw_tes_prog_key tes; @@ -1360,7 +1357,8 @@ brw_compile_cs(const struct brw_compiler *compiler, void *log_data, void brw_debug_key_recompile(const struct brw_compiler *c, void *log, gl_shader_stage stage, - const void *old_key, const void *key); + const struct brw_base_prog_key *old_key, + const struct brw_base_prog_key *key); static inline uint32_t encode_slm_size(unsigned gen, uint32_t bytes) diff --git a/src/intel/compiler/brw_debug_recompile.c b/src/intel/compiler/brw_debug_recompile.c index c9d9296b8fd..8d561a2bded 100644 --- a/src/intel/compiler/brw_debug_recompile.c +++ b/src/intel/compiler/brw_debug_recompile.c @@ -86,12 +86,20 @@ debug_sampler_recompile(const struct brw_compiler *c, void *log, return found; } +static bool +debug_base_recompile(const struct brw_compiler *c, void *log, + const struct brw_base_prog_key *old_key, + const struct brw_base_prog_key *key) +{ + return debug_sampler_recompile(c, log, &old_key->tex, &key->tex); +} + static void debug_vs_recompile(const struct brw_compiler *c, void *log, const struct brw_vs_prog_key *old_key, const struct brw_vs_prog_key *key) { - bool found = debug_sampler_recompile(c, log, &old_key->tex, &key->tex); + bool found = debug_base_recompile(c, log, &old_key->base, &key->base); for (unsigned i = 0; i < VERT_ATTRIB_MAX; i++) { found |= check("vertex attrib w/a flags", gl_attrib_wa_flags[i]); @@ -112,7 +120,7 @@ debug_tcs_recompile(const struct brw_compiler *c, void *log, const struct brw_tcs_prog_key *old_key, const struct brw_tcs_prog_key *key) { - bool found = debug_sampler_recompile(c, log, &old_key->tex, &key->tex); + bool found = debug_base_recompile(c, log, &old_key->base, &key->base); found |= check("input vertices", input_vertices); found |= check("outputs written", outputs_written); @@ -130,7 +138,7 @@ debug_tes_recompile(const struct brw_compiler *c, void *log, const struct brw_tes_prog_key *old_key, const struct brw_tes_prog_key *key) { - bool found = debug_sampler_recompile(c, log, &old_key->tex, &key->tex); + bool found = debug_base_recompile(c, log, &old_key->base, &key->base); found |= check("inputs read", inputs_read); found |= check("patch inputs read", patch_inputs_read); @@ -145,7 +153,7 @@ debug_gs_recompile(const struct brw_compiler *c, void *log, const struct brw_gs_prog_key *old_key, const struct brw_gs_prog_key *key) { - bool found = debug_sampler_recompile(c, log, &old_key->tex, &key->tex); + bool found = debug_base_recompile(c, log, &old_key->base, &key->base); if (!found) { c->shader_perf_log(log, " something else\n"); @@ -179,7 +187,7 @@ debug_fs_recompile(const struct brw_compiler *c, void *log, found |= check("mrt alpha test function", alpha_test_func); found |= check("mrt alpha test reference value", alpha_test_ref); - found |= debug_sampler_recompile(c, log, &old_key->tex, &key->tex); + found |= debug_base_recompile(c, log, &old_key->base, &key->base); if (!found) { c->shader_perf_log(log, " something else\n"); @@ -191,7 +199,7 @@ debug_cs_recompile(const struct brw_compiler *c, void *log, const struct brw_cs_prog_key *old_key, const struct brw_cs_prog_key *key) { - bool found = debug_sampler_recompile(c, log, &old_key->tex, &key->tex); + bool found = debug_base_recompile(c, log, &old_key->base, &key->base); if (!found) { c->shader_perf_log(log, " something else\n"); @@ -201,7 +209,8 @@ debug_cs_recompile(const struct brw_compiler *c, void *log, void brw_debug_key_recompile(const struct brw_compiler *c, void *log, gl_shader_stage stage, - const void *old_key, const void *key) + const struct brw_base_prog_key *old_key, + const struct brw_base_prog_key *key) { if (!old_key) { c->shader_perf_log(log, " No previous compile found...\n"); @@ -210,22 +219,28 @@ brw_debug_key_recompile(const struct brw_compiler *c, void *log, switch (stage) { case MESA_SHADER_VERTEX: - debug_vs_recompile(c, log, old_key, key); + debug_vs_recompile(c, log, (const struct brw_vs_prog_key *)old_key, + (const struct brw_vs_prog_key *)key); break; case MESA_SHADER_TESS_CTRL: - debug_tcs_recompile(c, log, old_key, key); + debug_tcs_recompile(c, log, (const struct brw_tcs_prog_key *)old_key, + (const struct brw_tcs_prog_key *)key); break; case MESA_SHADER_TESS_EVAL: - debug_tes_recompile(c, log, old_key, key); + debug_tes_recompile(c, log, (const struct brw_tes_prog_key *)old_key, + (const struct brw_tes_prog_key *)key); break; case MESA_SHADER_GEOMETRY: - debug_gs_recompile(c, log, old_key, key); + debug_gs_recompile(c, log, (const struct brw_gs_prog_key *)old_key, + (const struct brw_gs_prog_key *)key); break; case MESA_SHADER_FRAGMENT: - debug_fs_recompile(c, log, old_key, key); + debug_fs_recompile(c, log, (const struct brw_wm_prog_key *)old_key, + (const struct brw_wm_prog_key *)key); break; case MESA_SHADER_COMPUTE: - debug_cs_recompile(c, log, old_key, key); + debug_cs_recompile(c, log, (const struct brw_cs_prog_key *)old_key, + (const struct brw_cs_prog_key *)key); break; default: break; diff --git a/src/intel/compiler/brw_fs.cpp b/src/intel/compiler/brw_fs.cpp index bd0ac1a0718..a9273ebef2d 100644 --- a/src/intel/compiler/brw_fs.cpp +++ b/src/intel/compiler/brw_fs.cpp @@ -7961,7 +7961,7 @@ brw_compile_fs(const struct brw_compiler *compiler, void *log_data, { const struct gen_device_info *devinfo = compiler->devinfo; - brw_nir_apply_sampler_key(shader, compiler, &key->tex, true); + brw_nir_apply_sampler_key(shader, compiler, &key->base.tex, true); brw_nir_lower_fs_inputs(shader, devinfo, key); brw_nir_lower_fs_outputs(shader); @@ -8003,7 +8003,7 @@ brw_compile_fs(const struct brw_compiler *compiler, void *log_data, cfg_t *simd8_cfg = NULL, *simd16_cfg = NULL, *simd32_cfg = NULL; - fs_visitor v8(compiler, log_data, mem_ctx, key, + fs_visitor v8(compiler, log_data, mem_ctx, &key->base, &prog_data->base, prog, shader, 8, shader_time_index8); if (!v8.run_fs(allow_spilling, false /* do_rep_send */)) { @@ -8020,7 +8020,7 @@ brw_compile_fs(const struct brw_compiler *compiler, void *log_data, if (v8.max_dispatch_width >= 16 && likely(!(INTEL_DEBUG & DEBUG_NO16) || use_rep_send)) { /* Try a SIMD16 compile */ - fs_visitor v16(compiler, log_data, mem_ctx, key, + fs_visitor v16(compiler, log_data, mem_ctx, &key->base, &prog_data->base, prog, shader, 16, shader_time_index16); v16.import_uniforms(&v8); @@ -8040,7 +8040,7 @@ brw_compile_fs(const struct brw_compiler *compiler, void *log_data, compiler->devinfo->gen >= 6 && unlikely(INTEL_DEBUG & DEBUG_DO32)) { /* Try a SIMD32 compile */ - fs_visitor v32(compiler, log_data, mem_ctx, key, + fs_visitor v32(compiler, log_data, mem_ctx, &key->base, &prog_data->base, prog, shader, 32, shader_time_index32); v32.import_uniforms(&v8); @@ -8222,7 +8222,7 @@ compile_cs_to_nir(const struct brw_compiler *compiler, unsigned dispatch_width) { nir_shader *shader = nir_shader_clone(mem_ctx, src_shader); - brw_nir_apply_sampler_key(shader, compiler, &key->tex, true); + brw_nir_apply_sampler_key(shader, compiler, &key->base.tex, true); NIR_PASS_V(shader, brw_nir_lower_cs_intrinsics, dispatch_width); @@ -8267,7 +8267,8 @@ brw_compile_cs(const struct brw_compiler *compiler, void *log_data, if (min_dispatch_width <= 8) { nir_shader *nir8 = compile_cs_to_nir(compiler, mem_ctx, key, src_shader, 8); - v8 = new fs_visitor(compiler, log_data, mem_ctx, key, &prog_data->base, + v8 = new fs_visitor(compiler, log_data, mem_ctx, &key->base, + &prog_data->base, NULL, /* Never used in core profile */ nir8, 8, shader_time_index); if (!v8->run_cs(min_dispatch_width)) { @@ -8288,7 +8289,8 @@ brw_compile_cs(const struct brw_compiler *compiler, void *log_data, /* Try a SIMD16 compile */ nir_shader *nir16 = compile_cs_to_nir(compiler, mem_ctx, key, src_shader, 16); - v16 = new fs_visitor(compiler, log_data, mem_ctx, key, &prog_data->base, + v16 = new fs_visitor(compiler, log_data, mem_ctx, &key->base, + &prog_data->base, NULL, /* Never used in core profile */ nir16, 16, shader_time_index); if (v8) @@ -8321,7 +8323,8 @@ brw_compile_cs(const struct brw_compiler *compiler, void *log_data, /* Try a SIMD32 compile */ nir_shader *nir32 = compile_cs_to_nir(compiler, mem_ctx, key, src_shader, 32); - v32 = new fs_visitor(compiler, log_data, mem_ctx, key, &prog_data->base, + v32 = new fs_visitor(compiler, log_data, mem_ctx, &key->base, + &prog_data->base, NULL, /* Never used in core profile */ nir32, 32, shader_time_index); if (v8) diff --git a/src/intel/compiler/brw_fs.h b/src/intel/compiler/brw_fs.h index d93fb29d85d..4e7b5781827 100644 --- a/src/intel/compiler/brw_fs.h +++ b/src/intel/compiler/brw_fs.h @@ -62,7 +62,7 @@ class fs_visitor : public backend_shader public: fs_visitor(const struct brw_compiler *compiler, void *log_data, void *mem_ctx, - const void *key, + const brw_base_prog_key *key, struct brw_stage_prog_data *prog_data, struct gl_program *prog, const nir_shader *shader, @@ -304,7 +304,7 @@ public: void dump_instruction(backend_instruction *inst); void dump_instruction(backend_instruction *inst, FILE *file); - const void *const key; + const brw_base_prog_key *const key; const struct brw_sampler_prog_key_data *key_tex; struct brw_gs_compile *gs_compile; diff --git a/src/intel/compiler/brw_fs_visitor.cpp b/src/intel/compiler/brw_fs_visitor.cpp index 6509868f1c3..eb23b4087d0 100644 --- a/src/intel/compiler/brw_fs_visitor.cpp +++ b/src/intel/compiler/brw_fs_visitor.cpp @@ -969,7 +969,7 @@ fs_visitor::emit_barrier() fs_visitor::fs_visitor(const struct brw_compiler *compiler, void *log_data, void *mem_ctx, - const void *key, + const brw_base_prog_key *key, struct brw_stage_prog_data *prog_data, struct gl_program *prog, const nir_shader *shader, @@ -994,7 +994,7 @@ fs_visitor::fs_visitor(const struct brw_compiler *compiler, void *log_data, int shader_time_index) : backend_shader(compiler, log_data, mem_ctx, shader, &prog_data->base.base), - key(&c->key), gs_compile(c), + key(&c->key.base), gs_compile(c), prog_data(&prog_data->base.base), prog(NULL), dispatch_width(8), shader_time_index(shader_time_index), @@ -1007,28 +1007,7 @@ fs_visitor::fs_visitor(const struct brw_compiler *compiler, void *log_data, void fs_visitor::init() { - switch (stage) { - case MESA_SHADER_FRAGMENT: - key_tex = &((const brw_wm_prog_key *) key)->tex; - break; - case MESA_SHADER_VERTEX: - key_tex = &((const brw_vs_prog_key *) key)->tex; - break; - case MESA_SHADER_TESS_CTRL: - key_tex = &((const brw_tcs_prog_key *) key)->tex; - break; - case MESA_SHADER_TESS_EVAL: - key_tex = &((const brw_tes_prog_key *) key)->tex; - break; - case MESA_SHADER_GEOMETRY: - key_tex = &((const brw_gs_prog_key *) key)->tex; - break; - case MESA_SHADER_COMPUTE: - key_tex = &((const brw_cs_prog_key*) key)->tex; - break; - default: - unreachable("unhandled shader stage"); - } + this->key_tex = &key->tex; this->max_dispatch_width = 32; this->prog_data = this->stage_prog_data; diff --git a/src/intel/compiler/brw_shader.cpp b/src/intel/compiler/brw_shader.cpp index 643765c1b22..8403f19b831 100644 --- a/src/intel/compiler/brw_shader.cpp +++ b/src/intel/compiler/brw_shader.cpp @@ -1244,7 +1244,7 @@ brw_compile_tes(const struct brw_compiler *compiler, nir->info.inputs_read = key->inputs_read; nir->info.patch_inputs_read = key->patch_inputs_read; - brw_nir_apply_sampler_key(nir, compiler, &key->tex, is_scalar); + brw_nir_apply_sampler_key(nir, compiler, &key->base.tex, is_scalar); brw_nir_lower_tes_inputs(nir, input_vue_map); brw_nir_lower_vue_outputs(nir); brw_postprocess_nir(nir, compiler, is_scalar); @@ -1322,7 +1322,7 @@ brw_compile_tes(const struct brw_compiler *compiler, } if (is_scalar) { - fs_visitor v(compiler, log_data, mem_ctx, (void *) key, + fs_visitor v(compiler, log_data, mem_ctx, &key->base, &prog_data->base.base, NULL, nir, 8, shader_time_index, input_vue_map); if (!v.run_tes()) { diff --git a/src/intel/compiler/brw_vec4.cpp b/src/intel/compiler/brw_vec4.cpp index 26e2a0ecf5b..16ae576de37 100644 --- a/src/intel/compiler/brw_vec4.cpp +++ b/src/intel/compiler/brw_vec4.cpp @@ -2845,7 +2845,7 @@ brw_compile_vs(const struct brw_compiler *compiler, void *log_data, char **error_str) { const bool is_scalar = compiler->scalar_stage[MESA_SHADER_VERTEX]; - brw_nir_apply_sampler_key(shader, compiler, &key->tex, is_scalar); + brw_nir_apply_sampler_key(shader, compiler, &key->base.tex, is_scalar); const unsigned *assembly = NULL; @@ -2961,7 +2961,8 @@ brw_compile_vs(const struct brw_compiler *compiler, void *log_data, if (is_scalar) { prog_data->base.dispatch_mode = DISPATCH_MODE_SIMD8; - fs_visitor v(compiler, log_data, mem_ctx, key, &prog_data->base.base, + fs_visitor v(compiler, log_data, mem_ctx, &key->base, + &prog_data->base.base, NULL, /* prog; Only used for TEXTURE_RECTANGLE on gen < 8 */ shader, 8, shader_time_index); if (!v.run_vs()) { diff --git a/src/intel/compiler/brw_vec4_gs_visitor.cpp b/src/intel/compiler/brw_vec4_gs_visitor.cpp index 417daf1b493..208c0161657 100644 --- a/src/intel/compiler/brw_vec4_gs_visitor.cpp +++ b/src/intel/compiler/brw_vec4_gs_visitor.cpp @@ -44,7 +44,7 @@ vec4_gs_visitor::vec4_gs_visitor(const struct brw_compiler *compiler, void *mem_ctx, bool no_spills, int shader_time_index) - : vec4_visitor(compiler, log_data, &c->key.tex, + : vec4_visitor(compiler, log_data, &c->key.base.tex, &prog_data->base, shader, mem_ctx, no_spills, shader_time_index), c(c), @@ -639,7 +639,7 @@ brw_compile_gs(const struct brw_compiler *compiler, void *log_data, &c.input_vue_map, inputs_read, shader->info.separate_shader); - brw_nir_apply_sampler_key(shader, compiler, &key->tex, is_scalar); + brw_nir_apply_sampler_key(shader, compiler, &key->base.tex, is_scalar); brw_nir_lower_vue_inputs(shader, &c.input_vue_map); brw_nir_lower_vue_outputs(shader); brw_postprocess_nir(shader, compiler, is_scalar); diff --git a/src/intel/compiler/brw_vec4_tcs.cpp b/src/intel/compiler/brw_vec4_tcs.cpp index 39df2d5054b..b8f2a3bde0a 100644 --- a/src/intel/compiler/brw_vec4_tcs.cpp +++ b/src/intel/compiler/brw_vec4_tcs.cpp @@ -42,7 +42,7 @@ vec4_tcs_visitor::vec4_tcs_visitor(const struct brw_compiler *compiler, void *mem_ctx, int shader_time_index, const struct brw_vue_map *input_vue_map) - : vec4_visitor(compiler, log_data, &key->tex, &prog_data->base, + : vec4_visitor(compiler, log_data, &key->base.tex, &prog_data->base, nir, mem_ctx, false, shader_time_index), input_vue_map(input_vue_map), key(key) { @@ -397,7 +397,7 @@ brw_compile_tcs(const struct brw_compiler *compiler, nir->info.outputs_written, nir->info.patch_outputs_written); - brw_nir_apply_sampler_key(nir, compiler, &key->tex, is_scalar); + brw_nir_apply_sampler_key(nir, compiler, &key->base.tex, is_scalar); brw_nir_lower_vue_inputs(nir, &input_vue_map); brw_nir_lower_tcs_outputs(nir, &vue_prog_data->vue_map, key->tes_primitive_mode); @@ -475,7 +475,7 @@ brw_compile_tcs(const struct brw_compiler *compiler, } if (is_scalar) { - fs_visitor v(compiler, log_data, mem_ctx, (void *) key, + fs_visitor v(compiler, log_data, mem_ctx, &key->base, &prog_data->base.base, NULL, nir, 8, shader_time_index, &input_vue_map); if (!v.run_tcs()) { diff --git a/src/intel/compiler/brw_vec4_tes.cpp b/src/intel/compiler/brw_vec4_tes.cpp index 2ad5d06b539..51840b75ee6 100644 --- a/src/intel/compiler/brw_vec4_tes.cpp +++ b/src/intel/compiler/brw_vec4_tes.cpp @@ -40,7 +40,7 @@ vec4_tes_visitor::vec4_tes_visitor(const struct brw_compiler *compiler, const nir_shader *shader, void *mem_ctx, int shader_time_index) - : vec4_visitor(compiler, log_data, &key->tex, &prog_data->base, + : vec4_visitor(compiler, log_data, &key->base.tex, &prog_data->base, shader, mem_ctx, false, shader_time_index) { } diff --git a/src/intel/compiler/brw_vec4_vs_visitor.cpp b/src/intel/compiler/brw_vec4_vs_visitor.cpp index 6ee3cb4ac24..5aa1b9ac0b2 100644 --- a/src/intel/compiler/brw_vec4_vs_visitor.cpp +++ b/src/intel/compiler/brw_vec4_vs_visitor.cpp @@ -173,8 +173,8 @@ vec4_vs_visitor::vec4_vs_visitor(const struct brw_compiler *compiler, const nir_shader *shader, void *mem_ctx, int shader_time_index) - : vec4_visitor(compiler, log_data, &key->tex, &vs_prog_data->base, shader, - mem_ctx, false /* no_spills */, shader_time_index), + : vec4_visitor(compiler, log_data, &key->base.tex, &vs_prog_data->base, + shader, mem_ctx, false /* no_spills */, shader_time_index), key(key), vs_prog_data(vs_prog_data) { diff --git a/src/intel/vulkan/anv_pipeline.c b/src/intel/vulkan/anv_pipeline.c index f82ed677859..697c1850221 100644 --- a/src/intel/vulkan/anv_pipeline.c +++ b/src/intel/vulkan/anv_pipeline.c @@ -352,12 +352,19 @@ populate_sampler_prog_key(const struct gen_device_info *devinfo, } static void +populate_base_prog_key(const struct gen_device_info *devinfo, + struct brw_base_prog_key *key) +{ + populate_sampler_prog_key(devinfo, &key->tex); +} + +static void populate_vs_prog_key(const struct gen_device_info *devinfo, struct brw_vs_prog_key *key) { memset(key, 0, sizeof(*key)); - populate_sampler_prog_key(devinfo, &key->tex); + populate_base_prog_key(devinfo, &key->base); /* XXX: Handle vertex input work-arounds */ @@ -371,7 +378,7 @@ populate_tcs_prog_key(const struct gen_device_info *devinfo, { memset(key, 0, sizeof(*key)); - populate_sampler_prog_key(devinfo, &key->tex); + populate_base_prog_key(devinfo, &key->base); key->input_vertices = input_vertices; } @@ -382,7 +389,7 @@ populate_tes_prog_key(const struct gen_device_info *devinfo, { memset(key, 0, sizeof(*key)); - populate_sampler_prog_key(devinfo, &key->tex); + populate_base_prog_key(devinfo, &key->base); } static void @@ -391,7 +398,7 @@ populate_gs_prog_key(const struct gen_device_info *devinfo, { memset(key, 0, sizeof(*key)); - populate_sampler_prog_key(devinfo, &key->tex); + populate_base_prog_key(devinfo, &key->base); } static void @@ -402,7 +409,7 @@ populate_wm_prog_key(const struct gen_device_info *devinfo, { memset(key, 0, sizeof(*key)); - populate_sampler_prog_key(devinfo, &key->tex); + populate_base_prog_key(devinfo, &key->base); /* We set this to 0 here and set to the actual value before we call * brw_compile_fs. @@ -453,7 +460,7 @@ populate_cs_prog_key(const struct gen_device_info *devinfo, { memset(key, 0, sizeof(*key)); - populate_sampler_prog_key(devinfo, &key->tex); + populate_base_prog_key(devinfo, &key->base); } struct anv_pipeline_stage { diff --git a/src/mesa/drivers/dri/i965/brw_cs.c b/src/mesa/drivers/dri/i965/brw_cs.c index 58adbda2fb6..afa092191f1 100644 --- a/src/mesa/drivers/dri/i965/brw_cs.c +++ b/src/mesa/drivers/dri/i965/brw_cs.c @@ -105,7 +105,7 @@ brw_codegen_cs_prog(struct brw_context *brw, if (unlikely(brw->perf_debug)) { if (cp->compiled_once) { brw_debug_recompile(brw, MESA_SHADER_COMPUTE, cp->program.Id, - key->program_string_id, key); + &key->base); } cp->compiled_once = true; @@ -138,15 +138,11 @@ brw_cs_populate_key(struct brw_context *brw, struct brw_cs_prog_key *key) /* BRW_NEW_COMPUTE_PROGRAM */ const struct brw_program *cp = (struct brw_program *) brw->programs[MESA_SHADER_COMPUTE]; - const struct gl_program *prog = (struct gl_program *) cp; memset(key, 0, sizeof(*key)); /* _NEW_TEXTURE */ - brw_populate_sampler_prog_key_data(ctx, prog, &key->tex); - - /* The unique compute program ID */ - key->program_string_id = cp->id; + brw_populate_base_prog_key(ctx, cp, &key->base); } @@ -178,7 +174,7 @@ brw_upload_cs_prog(struct brw_context *brw) return; cp = (struct brw_program *) brw->programs[MESA_SHADER_COMPUTE]; - cp->id = key.program_string_id; + cp->id = key.base.program_string_id; MAYBE_UNUSED bool success = brw_codegen_cs_prog(brw, cp, &key); assert(success); @@ -191,9 +187,7 @@ brw_cs_populate_default_key(const struct brw_compiler *compiler, { const struct gen_device_info *devinfo = compiler->devinfo; memset(key, 0, sizeof(*key)); - key->program_string_id = brw_program(prog)->id; - - brw_setup_tex_for_precompile(devinfo, &key->tex, prog); + brw_populate_default_base_prog_key(devinfo, brw_program(prog), &key->base); } bool diff --git a/src/mesa/drivers/dri/i965/brw_disk_cache.c b/src/mesa/drivers/dri/i965/brw_disk_cache.c index e3a6d6f62e0..f7fe1e2aec8 100644 --- a/src/mesa/drivers/dri/i965/brw_disk_cache.c +++ b/src/mesa/drivers/dri/i965/brw_disk_cache.c @@ -118,7 +118,7 @@ read_and_upload(struct brw_context *brw, struct disk_cache *cache, * lookup, so set the id to 0 for the sha1 hashing. program_string_id will * be set below. */ - brw_prog_key_set_id(&prog_key, stage, 0); + prog_key.base.program_string_id = 0; gen_shader_sha1(prog, stage, &prog_key, binary_sha1); @@ -194,7 +194,7 @@ read_and_upload(struct brw_context *brw, struct disk_cache *cache, unreachable("Unsupported stage!"); } - brw_prog_key_set_id(&prog_key, stage, brw_program(prog)->id); + prog_key.base.program_string_id = brw_program(prog)->id; brw_alloc_stage_scratch(brw, stage_state, prog_data->total_scratch); @@ -301,7 +301,7 @@ brw_disk_cache_write_render_programs(struct brw_context *brw) if (prog && !prog->program_written_to_cache) { struct brw_vs_prog_key vs_key; brw_vs_populate_key(brw, &vs_key); - vs_key.program_string_id = 0; + vs_key.base.program_string_id = 0; write_program_data(brw, prog, &vs_key, brw->vs.base.prog_data, brw->vs.base.prog_offset, cache, @@ -312,7 +312,7 @@ brw_disk_cache_write_render_programs(struct brw_context *brw) if (prog && !prog->program_written_to_cache) { struct brw_tcs_prog_key tcs_key; brw_tcs_populate_key(brw, &tcs_key); - tcs_key.program_string_id = 0; + tcs_key.base.program_string_id = 0; write_program_data(brw, prog, &tcs_key, brw->tcs.base.prog_data, brw->tcs.base.prog_offset, cache, @@ -323,7 +323,7 @@ brw_disk_cache_write_render_programs(struct brw_context *brw) if (prog && !prog->program_written_to_cache) { struct brw_tes_prog_key tes_key; brw_tes_populate_key(brw, &tes_key); - tes_key.program_string_id = 0; + tes_key.base.program_string_id = 0; write_program_data(brw, prog, &tes_key, brw->tes.base.prog_data, brw->tes.base.prog_offset, cache, @@ -334,7 +334,7 @@ brw_disk_cache_write_render_programs(struct brw_context *brw) if (prog && !prog->program_written_to_cache) { struct brw_gs_prog_key gs_key; brw_gs_populate_key(brw, &gs_key); - gs_key.program_string_id = 0; + gs_key.base.program_string_id = 0; write_program_data(brw, prog, &gs_key, brw->gs.base.prog_data, brw->gs.base.prog_offset, cache, @@ -345,7 +345,7 @@ brw_disk_cache_write_render_programs(struct brw_context *brw) if (prog && !prog->program_written_to_cache) { struct brw_wm_prog_key wm_key; brw_wm_populate_key(brw, &wm_key); - wm_key.program_string_id = 0; + wm_key.base.program_string_id = 0; write_program_data(brw, prog, &wm_key, brw->wm.base.prog_data, brw->wm.base.prog_offset, cache, @@ -365,7 +365,7 @@ brw_disk_cache_write_compute_program(struct brw_context *brw) if (prog && !prog->program_written_to_cache) { struct brw_cs_prog_key cs_key; brw_cs_populate_key(brw, &cs_key); - cs_key.program_string_id = 0; + cs_key.base.program_string_id = 0; write_program_data(brw, prog, &cs_key, brw->cs.base.prog_data, brw->cs.base.prog_offset, cache, diff --git a/src/mesa/drivers/dri/i965/brw_gs.c b/src/mesa/drivers/dri/i965/brw_gs.c index 34e37373999..ef8b9239d79 100644 --- a/src/mesa/drivers/dri/i965/brw_gs.c +++ b/src/mesa/drivers/dri/i965/brw_gs.c @@ -105,7 +105,7 @@ brw_codegen_gs_prog(struct brw_context *brw, if (unlikely(brw->perf_debug)) { if (gp->compiled_once) { brw_debug_recompile(brw, MESA_SHADER_GEOMETRY, gp->program.Id, - key->program_string_id, key); + &key->base); } if (start_busy && !brw_bo_busy(brw->batch.last_bo)) { perf_debug("GS compile took %.03f ms and stalled the GPU\n", @@ -150,10 +150,7 @@ brw_gs_populate_key(struct brw_context *brw, memset(key, 0, sizeof(*key)); - key->program_string_id = gp->id; - - /* _NEW_TEXTURE */ - brw_populate_sampler_prog_key_data(ctx, &gp->program, &key->tex); + brw_populate_base_prog_key(ctx, gp, &key->base); } void @@ -179,7 +176,7 @@ brw_upload_gs_prog(struct brw_context *brw) return; gp = (struct brw_program *) brw->programs[MESA_SHADER_GEOMETRY]; - gp->id = key.program_string_id; + gp->id = key.base.program_string_id; MAYBE_UNUSED bool success = brw_codegen_gs_prog(brw, gp, &key); assert(success); @@ -194,8 +191,8 @@ brw_gs_populate_default_key(const struct brw_compiler *compiler, memset(key, 0, sizeof(*key)); - brw_setup_tex_for_precompile(devinfo, &key->tex, prog); - key->program_string_id = brw_program(prog)->id; + brw_populate_default_base_prog_key(devinfo, brw_program(prog), + &key->base); } bool diff --git a/src/mesa/drivers/dri/i965/brw_program.c b/src/mesa/drivers/dri/i965/brw_program.c index aa7961ff196..57fcf32efd1 100644 --- a/src/mesa/drivers/dri/i965/brw_program.c +++ b/src/mesa/drivers/dri/i965/brw_program.c @@ -778,7 +778,7 @@ brw_dump_arb_asm(const char *stage, struct gl_program *prog) void brw_setup_tex_for_precompile(const struct gen_device_info *devinfo, struct brw_sampler_prog_key_data *tex, - struct gl_program *prog) + const struct gl_program *prog) { const bool has_shader_channel_select = devinfo->is_haswell || devinfo->gen >= 8; unsigned sampler_count = util_last_bit(prog->SamplersUsed); @@ -912,8 +912,7 @@ void brw_debug_recompile(struct brw_context *brw, gl_shader_stage stage, unsigned api_id, - unsigned key_program_string_id, - void *key) + struct brw_base_prog_key *key) { const struct brw_compiler *compiler = brw->screen->compiler; enum brw_cache_id cache_id = brw_stage_cache_id(stage); @@ -922,7 +921,7 @@ brw_debug_recompile(struct brw_context *brw, _mesa_shader_stage_to_string(stage), api_id); const void *old_key = - brw_find_previous_compile(&brw->cache, cache_id, key_program_string_id); + brw_find_previous_compile(&brw->cache, cache_id, key->program_string_id); brw_debug_key_recompile(compiler, brw, stage, old_key, key); } diff --git a/src/mesa/drivers/dri/i965/brw_program.h b/src/mesa/drivers/dri/i965/brw_program.h index 9227329758a..a33f2a8394d 100644 --- a/src/mesa/drivers/dri/i965/brw_program.h +++ b/src/mesa/drivers/dri/i965/brw_program.h @@ -73,13 +73,17 @@ void brw_shader_gather_info(nir_shader *nir, struct gl_program *prog); void brw_setup_tex_for_precompile(const struct gen_device_info *devinfo, struct brw_sampler_prog_key_data *tex, - struct gl_program *prog); - -void brw_populate_sampler_prog_key_data(struct gl_context *ctx, - const struct gl_program *prog, - struct brw_sampler_prog_key_data *key); + const struct gl_program *prog); + +void brw_populate_base_prog_key(struct gl_context *ctx, + const struct brw_program *prog, + struct brw_base_prog_key *key); +void brw_populate_default_base_prog_key(const struct gen_device_info *devinfo, + const struct brw_program *prog, + struct brw_base_prog_key *key); void brw_debug_recompile(struct brw_context *brw, gl_shader_stage stage, - unsigned api_id, unsigned prog_string_id, void *key); + unsigned api_id, struct brw_base_prog_key *key); + uint32_t brw_assign_common_binding_table_offsets(const struct gen_device_info *devinfo, const struct gl_program *prog, diff --git a/src/mesa/drivers/dri/i965/brw_program_binary.c b/src/mesa/drivers/dri/i965/brw_program_binary.c index a1502695ac1..177050ed2f1 100644 --- a/src/mesa/drivers/dri/i965/brw_program_binary.c +++ b/src/mesa/drivers/dri/i965/brw_program_binary.c @@ -164,7 +164,7 @@ deserialize_gen_program(struct blob_reader *reader, struct gl_context *ctx, union brw_any_prog_key prog_key; blob_copy_bytes(reader, &prog_key, brw_prog_key_size(stage)); - brw_prog_key_set_id(&prog_key, stage, brw_program(prog)->id); + prog_key.base.program_string_id = brw_program(prog)->id; enum brw_cache_id cache_id = brw_stage_cache_id(stage); diff --git a/src/mesa/drivers/dri/i965/brw_program_cache.c b/src/mesa/drivers/dri/i965/brw_program_cache.c index 47b71a2e16f..88bb19792b0 100644 --- a/src/mesa/drivers/dri/i965/brw_program_cache.c +++ b/src/mesa/drivers/dri/i965/brw_program_cache.c @@ -70,7 +70,7 @@ struct brw_cache_item { /** for variable-sized keys */ GLuint key_size; GLuint prog_data_size; - const void *key; + const struct brw_base_prog_key *key; uint32_t offset; uint32_t size; @@ -93,27 +93,6 @@ brw_stage_cache_id(gl_shader_stage stage) return stage_ids[stage]; } -static unsigned -get_program_string_id(enum brw_cache_id cache_id, const void *key) -{ - switch (cache_id) { - case BRW_CACHE_VS_PROG: - return ((struct brw_vs_prog_key *) key)->program_string_id; - case BRW_CACHE_TCS_PROG: - return ((struct brw_tcs_prog_key *) key)->program_string_id; - case BRW_CACHE_TES_PROG: - return ((struct brw_tes_prog_key *) key)->program_string_id; - case BRW_CACHE_GS_PROG: - return ((struct brw_gs_prog_key *) key)->program_string_id; - case BRW_CACHE_CS_PROG: - return ((struct brw_cs_prog_key *) key)->program_string_id; - case BRW_CACHE_FS_PROG: - return ((struct brw_wm_prog_key *) key)->program_string_id; - default: - unreachable("no program string id for this kind of program"); - } -} - static GLuint hash_key(struct brw_cache_item *item) { @@ -320,7 +299,7 @@ brw_find_previous_compile(struct brw_cache *cache, for (unsigned i = 0; i < cache->size; i++) { for (struct brw_cache_item *c = cache->items[i]; c; c = c->next) { if (c->cache_id == cache_id && - get_program_string_id(cache_id, c->key) == program_string_id) { + c->key->program_string_id == program_string_id) { return c->key; } } diff --git a/src/mesa/drivers/dri/i965/brw_tcs.c b/src/mesa/drivers/dri/i965/brw_tcs.c index 1050850bb1c..08e4d1de0a3 100644 --- a/src/mesa/drivers/dri/i965/brw_tcs.c +++ b/src/mesa/drivers/dri/i965/brw_tcs.c @@ -127,7 +127,7 @@ brw_codegen_tcs_prog(struct brw_context *brw, struct brw_program *tcp, if (tcp) { if (tcp->compiled_once) { brw_debug_recompile(brw, MESA_SHADER_TESS_CTRL, tcp->program.Id, - key->program_string_id, key); + &key->base); } tcp->compiled_once = true; } @@ -192,10 +192,8 @@ brw_tcs_populate_key(struct brw_context *brw, tep->program.info.tess.spacing == TESS_SPACING_EQUAL; if (tcp) { - key->program_string_id = tcp->id; - /* _NEW_TEXTURE */ - brw_populate_sampler_prog_key_data(&brw->ctx, &tcp->program, &key->tex); + brw_populate_base_prog_key(&brw->ctx, tcp, &key->base); } } @@ -229,7 +227,7 @@ brw_upload_tcs_prog(struct brw_context *brw) tcp = (struct brw_program *) brw->programs[MESA_SHADER_TESS_CTRL]; if (tcp) - tcp->id = key.program_string_id; + tcp->id = key.base.program_string_id; MAYBE_UNUSED bool success = brw_codegen_tcs_prog(brw, tcp, tep, &key); assert(success); @@ -248,8 +246,7 @@ brw_tcs_populate_default_key(const struct brw_compiler *compiler, memset(key, 0, sizeof(*key)); - key->program_string_id = btcp->id; - brw_setup_tex_for_precompile(devinfo, &key->tex, prog); + brw_populate_default_base_prog_key(devinfo, btcp, &key->base); /* Guess that the input and output patches have the same dimensionality. */ if (devinfo->gen < 8 || compiler->use_tcs_8_patch) diff --git a/src/mesa/drivers/dri/i965/brw_tes.c b/src/mesa/drivers/dri/i965/brw_tes.c index 7a55251363c..a69cef075ed 100644 --- a/src/mesa/drivers/dri/i965/brw_tes.c +++ b/src/mesa/drivers/dri/i965/brw_tes.c @@ -91,7 +91,7 @@ brw_codegen_tes_prog(struct brw_context *brw, if (unlikely(brw->perf_debug)) { if (tep->compiled_once) { brw_debug_recompile(brw, MESA_SHADER_TESS_EVAL, tep->program.Id, - key->program_string_id, key); + &key->base); } if (start_busy && !brw_bo_busy(brw->batch.last_bo)) { perf_debug("TES compile took %.03f ms and stalled the GPU\n", @@ -132,7 +132,8 @@ brw_tes_populate_key(struct brw_context *brw, memset(key, 0, sizeof(*key)); - key->program_string_id = tep->id; + /* _NEW_TEXTURE */ + brw_populate_base_prog_key(&brw->ctx, tep, &key->base); /* The TCS may have additional outputs which aren't read by the * TES (possibly for cross-thread communication). These need to @@ -147,9 +148,6 @@ brw_tes_populate_key(struct brw_context *brw, key->inputs_read = per_vertex_slots; key->patch_inputs_read = per_patch_slots; - - /* _NEW_TEXTURE */ - brw_populate_sampler_prog_key_data(&brw->ctx, prog, &key->tex); } void @@ -177,7 +175,7 @@ brw_upload_tes_prog(struct brw_context *brw) return; tep = (struct brw_program *) brw->programs[MESA_SHADER_TESS_EVAL]; - tep->id = key.program_string_id; + tep->id = key.base.program_string_id; MAYBE_UNUSED bool success = brw_codegen_tes_prog(brw, tep, &key); assert(success); @@ -194,7 +192,8 @@ brw_tes_populate_default_key(const struct brw_compiler *compiler, memset(key, 0, sizeof(*key)); - key->program_string_id = btep->id; + brw_populate_default_base_prog_key(devinfo, btep, &key->base); + key->inputs_read = prog->nir->info.inputs_read; key->patch_inputs_read = prog->nir->info.patch_inputs_read; @@ -205,8 +204,6 @@ brw_tes_populate_default_key(const struct brw_compiler *compiler, ~(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 diff --git a/src/mesa/drivers/dri/i965/brw_vs.c b/src/mesa/drivers/dri/i965/brw_vs.c index c19a326a455..d15cd33ed3e 100644 --- a/src/mesa/drivers/dri/i965/brw_vs.c +++ b/src/mesa/drivers/dri/i965/brw_vs.c @@ -197,7 +197,7 @@ brw_codegen_vs_prog(struct brw_context *brw, if (unlikely(brw->perf_debug)) { if (vp->compiled_once) { brw_debug_recompile(brw, MESA_SHADER_VERTEX, vp->program.Id, - key->program_string_id, key); + &key->base); } if (start_busy && !brw_bo_busy(brw->batch.last_bo)) { perf_debug("VS compile took %.03f ms and stalled the GPU\n", @@ -252,7 +252,9 @@ brw_vs_populate_key(struct brw_context *brw, /* Just upload the program verbatim for now. Always send it all * the inputs it asks for, whether they are varying or not. */ - key->program_string_id = vp->id; + + /* _NEW_TEXTURE */ + brw_populate_base_prog_key(ctx, vp, &key->base); if (ctx->Transform.ClipPlanesEnabled != 0 && (ctx->API == API_OPENGL_COMPAT || ctx->API == API_OPENGLES) && @@ -279,9 +281,6 @@ brw_vs_populate_key(struct brw_context *brw, key->clamp_vertex_color = ctx->Light._ClampVertexColor; } - /* _NEW_TEXTURE */ - brw_populate_sampler_prog_key_data(ctx, prog, &key->tex); - /* BRW_NEW_VS_ATTRIB_WORKAROUNDS */ if (devinfo->gen < 8 && !devinfo->is_haswell) { memcpy(key->gl_attrib_wa_flags, brw->vb.attrib_wa_flags, @@ -311,7 +310,7 @@ brw_upload_vs_prog(struct brw_context *brw) return; vp = (struct brw_program *) brw->programs[MESA_SHADER_VERTEX]; - vp->id = key.program_string_id; + vp->id = key.base.program_string_id; MAYBE_UNUSED bool success = brw_codegen_vs_prog(brw, vp, &key); assert(success); @@ -327,8 +326,8 @@ brw_vs_populate_default_key(const struct brw_compiler *compiler, memset(key, 0, sizeof(*key)); - brw_setup_tex_for_precompile(devinfo, &key->tex, prog); - key->program_string_id = bvp->id; + brw_populate_default_base_prog_key(devinfo, bvp, &key->base); + key->clamp_vertex_color = (prog->info.outputs_written & (VARYING_BIT_COL0 | VARYING_BIT_COL1 | VARYING_BIT_BFC0 | diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c index bb0fd789d50..368499776b9 100644 --- a/src/mesa/drivers/dri/i965/brw_wm.c +++ b/src/mesa/drivers/dri/i965/brw_wm.c @@ -141,7 +141,7 @@ brw_codegen_wm_prog(struct brw_context *brw, if (unlikely(brw->perf_debug)) { if (fp->compiled_once) { brw_debug_recompile(brw, MESA_SHADER_FRAGMENT, fp->program.Id, - key->program_string_id, key); + &key->base); } fp->compiled_once = true; @@ -186,7 +186,7 @@ gen6_gather_workaround(GLenum internalformat) } } -void +static void brw_populate_sampler_prog_key_data(struct gl_context *ctx, const struct gl_program *prog, struct brw_sampler_prog_key_data *key) @@ -329,6 +329,24 @@ brw_populate_sampler_prog_key_data(struct gl_context *ctx, } } +void +brw_populate_base_prog_key(struct gl_context *ctx, + const struct brw_program *prog, + struct brw_base_prog_key *key) +{ + key->program_string_id = prog->id; + brw_populate_sampler_prog_key_data(ctx, &prog->program, &key->tex); +} + +void +brw_populate_default_base_prog_key(const struct gen_device_info *devinfo, + const struct brw_program *prog, + struct brw_base_prog_key *key) +{ + key->program_string_id = prog->id; + brw_setup_tex_for_precompile(devinfo, &key->tex, &prog->program); +} + static bool brw_wm_state_dirty(const struct brw_context *brw) { @@ -442,7 +460,7 @@ brw_wm_populate_key(struct brw_context *brw, struct brw_wm_prog_key *key) key->clamp_fragment_color = ctx->Color._ClampFragmentColor; /* _NEW_TEXTURE */ - brw_populate_sampler_prog_key_data(ctx, prog, &key->tex); + brw_populate_base_prog_key(ctx, fp, &key->base); /* _NEW_BUFFERS */ key->nr_color_regions = ctx->DrawBuffer->_NumColorDrawBuffers; @@ -488,9 +506,6 @@ brw_wm_populate_key(struct brw_context *brw, struct brw_wm_prog_key *key) key->alpha_test_ref = ctx->Color.AlphaRef; } - /* The unique fragment program ID */ - key->program_string_id = fp->id; - /* Whether reads from the framebuffer should behave coherently. */ key->coherent_fb_fetch = ctx->Extensions.EXT_shader_framebuffer_fetch; } @@ -516,7 +531,7 @@ brw_upload_wm_prog(struct brw_context *brw) return; fp = (struct brw_program *) brw->programs[MESA_SHADER_FRAGMENT]; - fp->id = key.program_string_id; + fp->id = key.base.program_string_id; MAYBE_UNUSED bool success = brw_codegen_wm_prog(brw, fp, &key, &brw->vue_map_geom_out); @@ -532,6 +547,9 @@ brw_wm_populate_default_key(const struct brw_compiler *compiler, memset(key, 0, sizeof(*key)); + brw_populate_default_base_prog_key(devinfo, brw_program(prog), + &key->base); + uint64_t outputs_written = prog->info.outputs_written; if (devinfo->gen < 6) { @@ -551,15 +569,11 @@ brw_wm_populate_default_key(const struct brw_compiler *compiler, key->input_slots_valid = prog->info.inputs_read | VARYING_BIT_POS; } - brw_setup_tex_for_precompile(devinfo, &key->tex, prog); - key->nr_color_regions = util_bitcount64(outputs_written & ~(BITFIELD64_BIT(FRAG_RESULT_DEPTH) | BITFIELD64_BIT(FRAG_RESULT_STENCIL) | BITFIELD64_BIT(FRAG_RESULT_SAMPLE_MASK))); - key->program_string_id = brw_program(prog)->id; - /* Whether reads from the framebuffer should behave coherently. */ key->coherent_fb_fetch = devinfo->gen >= 9; } |