#include "iris_context.h"
#include "nir/tgsi_to_nir.h"
-#define KEY_INIT_NO_ID(gen) \
+#define KEY_ID(prefix) .prefix.program_string_id = ish->program_id
+#define BRW_KEY_INIT(gen, prog_id) \
+ .base.program_string_id = prog_id, \
.base.subgroup_size_type = BRW_SUBGROUP_SIZE_UNIFORM, \
.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)
return p_atomic_inc_return(&screen->program_id);
}
+static struct brw_vs_prog_key
+iris_to_brw_vs_key(const struct gen_device_info *devinfo,
+ const struct iris_vs_prog_key *key)
+{
+ return (struct brw_vs_prog_key) {
+ BRW_KEY_INIT(devinfo->gen, key->vue.base.program_string_id),
+
+ /* Don't tell the backend about our clip plane constants, we've
+ * already lowered them in NIR and don't want it doing it again.
+ */
+ .nr_userclip_plane_consts = 0,
+ };
+}
+
+static struct brw_tcs_prog_key
+iris_to_brw_tcs_key(const struct gen_device_info *devinfo,
+ const struct iris_tcs_prog_key *key)
+{
+ return (struct brw_tcs_prog_key) {
+ BRW_KEY_INIT(devinfo->gen, key->vue.base.program_string_id),
+ .tes_primitive_mode = key->tes_primitive_mode,
+ .input_vertices = key->input_vertices,
+ .patch_outputs_written = key->patch_outputs_written,
+ .outputs_written = key->outputs_written,
+ .quads_workaround = key->quads_workaround,
+ };
+}
+
+static struct brw_tes_prog_key
+iris_to_brw_tes_key(const struct gen_device_info *devinfo,
+ const struct iris_tes_prog_key *key)
+{
+ return (struct brw_tes_prog_key) {
+ BRW_KEY_INIT(devinfo->gen, key->vue.base.program_string_id),
+ .patch_inputs_read = key->patch_inputs_read,
+ .inputs_read = key->inputs_read,
+ };
+}
+
+static struct brw_gs_prog_key
+iris_to_brw_gs_key(const struct gen_device_info *devinfo,
+ const struct iris_gs_prog_key *key)
+{
+ return (struct brw_gs_prog_key) {
+ BRW_KEY_INIT(devinfo->gen, key->vue.base.program_string_id),
+ };
+}
+
+static struct brw_wm_prog_key
+iris_to_brw_fs_key(const struct gen_device_info *devinfo,
+ const struct iris_fs_prog_key *key)
+{
+ return (struct brw_wm_prog_key) {
+ BRW_KEY_INIT(devinfo->gen, key->base.program_string_id),
+ .nr_color_regions = key->nr_color_regions,
+ .flat_shade = key->flat_shade,
+ .alpha_test_replicate_alpha = key->alpha_test_replicate_alpha,
+ .alpha_to_coverage = key->alpha_to_coverage,
+ .clamp_fragment_color = key->clamp_fragment_color,
+ .persample_interp = key->persample_interp,
+ .multisample_fbo = key->multisample_fbo,
+ .force_dual_color_blend = key->force_dual_color_blend,
+ .coherent_fb_fetch = key->coherent_fb_fetch,
+ .color_outputs_valid = key->color_outputs_valid,
+ .input_slots_valid = key->input_slots_valid,
+ };
+}
+
+static struct brw_cs_prog_key
+iris_to_brw_cs_key(const struct gen_device_info *devinfo,
+ const struct iris_cs_prog_key *key)
+{
+ return (struct brw_cs_prog_key) {
+ BRW_KEY_INIT(devinfo->gen, key->base.program_string_id),
+ };
+}
+
static void *
upload_state(struct u_upload_mgr *uploader,
struct iris_state_ref *ref,
: ISL_FORMAT_R32G32B32A32_FLOAT,
.swizzle = ISL_SWIZZLE_IDENTITY,
.stride_B = 1,
- .mocs = ice->vtbl.mocs(res->bo));
+ .mocs = iris_mocs(res->bo, &screen->isl_dev));
}
static nir_ssa_def *
}
}
-// XXX: need unify_interfaces() at link time...
+/**
+ * Undo nir_lower_passthrough_edgeflags but keep the inputs_read flag.
+ */
+static bool
+iris_fix_edge_flags(nir_shader *nir)
+{
+ if (nir->info.stage != MESA_SHADER_VERTEX)
+ return false;
+
+ nir_variable *var = NULL;
+ nir_foreach_variable(v, &nir->outputs) {
+ if (v->data.location == VARYING_SLOT_EDGE) {
+ var = v;
+ break;
+ }
+ }
+
+ if (!var)
+ return false;
+
+ exec_node_remove(&var->node);
+ var->data.mode = nir_var_shader_temp;
+ exec_list_push_tail(&nir->globals, &var->node);
+ nir->info.outputs_written &= ~VARYING_BIT_EDGE;
+ nir->info.inputs_read &= ~VERT_BIT_EDGEFLAG;
+ nir_fixup_deref_modes(nir);
+
+ nir_foreach_function(f, nir) {
+ if (f->impl) {
+ nir_metadata_preserve(f->impl, nir_metadata_block_index |
+ nir_metadata_dominance |
+ nir_metadata_live_ssa_defs |
+ nir_metadata_loop_analysis);
+ }
+ }
+
+ return true;
+}
/**
* Fix an uncompiled shader's stream output info.
{
UNUSED const struct gen_device_info *devinfo = compiler->devinfo;
- /* The intel compiler assumes that num_uniforms is in bytes. For
- * scalar that means 4 bytes per uniform slot.
- *
- * Ref: brw_nir_lower_uniforms, type_size_scalar_bytes.
- */
- nir->num_uniforms *= 4;
-
const unsigned IRIS_MAX_SYSTEM_VALUES =
PIPE_MAX_SHADER_IMAGES * BRW_IMAGE_PARAM_SIZE;
enum brw_param_builtin *system_values =
load_ubo->num_components = intrin->num_components;
load_ubo->src[0] = nir_src_for_ssa(temp_const_ubo_name);
load_ubo->src[1] = nir_src_for_ssa(offset);
+ nir_intrinsic_set_align(load_ubo,
+ nir_intrinsic_align_mul(intrin),
+ nir_intrinsic_align_offset(intrin));
nir_ssa_dest_init(&load_ubo->instr, &load_ubo->dest,
intrin->dest.ssa.num_components,
intrin->dest.ssa.bit_size,
load->num_components = comps;
load->src[0] = nir_src_for_ssa(temp_ubo_name);
load->src[1] = nir_src_for_ssa(offset);
+ nir_intrinsic_set_align(load, 4, 0);
nir_ssa_dest_init(&load->instr, &load->dest, comps, 32, NULL);
nir_builder_instr_insert(&b, &load->instr);
nir_ssa_def_rewrite_uses(&intrin->dest.ssa,
assert(num_cbufs < PIPE_MAX_CONSTANT_BUFFERS);
nir_validate_shader(nir, "after remap");
- /* We don't use params[], but fs_visitor::nir_setup_uniforms() asserts
- * about it for compute shaders, so go ahead and make some fake ones
- * which the backend will dead code eliminate.
+ /* We don't use params[] but gallium leaves num_uniforms set. We use this
+ * to detect when cbuf0 exists but we don't need it anymore when we get
+ * here. Instead, zero it out so that the back-end doesn't get confused
+ * when nr_params * 4 != num_uniforms != nr_params * 4.
*/
- prog_data->nr_params = nir->num_uniforms / 4;
- prog_data->param = rzalloc_array(mem_ctx, uint32_t, prog_data->nr_params);
+ nir->num_uniforms = 0;
/* Constant loads (if any) need to go at the end of the constant buffers so
* we need to know num_cbufs before we can lower to them.
const struct brw_base_prog_key *key)
{
struct iris_screen *screen = (struct iris_screen *) ice->ctx.screen;
+ const struct gen_device_info *devinfo = &screen->devinfo;
const struct brw_compiler *c = screen->compiler;
if (!info)
info->name ? info->name : "(no identifier)",
info->label ? info->label : "");
- const void *old_key =
+ const void *old_iris_key =
iris_find_previous_compile(ice, info->stage, key->program_string_id);
- brw_debug_key_recompile(c, &ice->dbg, info->stage, old_key, key);
+ union brw_any_prog_key old_key;
+
+ switch (info->stage) {
+ case MESA_SHADER_VERTEX:
+ old_key.vs = iris_to_brw_vs_key(devinfo, old_iris_key);
+ break;
+ case MESA_SHADER_TESS_CTRL:
+ old_key.tcs = iris_to_brw_tcs_key(devinfo, old_iris_key);
+ break;
+ case MESA_SHADER_TESS_EVAL:
+ old_key.tes = iris_to_brw_tes_key(devinfo, old_iris_key);
+ break;
+ case MESA_SHADER_GEOMETRY:
+ old_key.gs = iris_to_brw_gs_key(devinfo, old_iris_key);
+ break;
+ case MESA_SHADER_FRAGMENT:
+ old_key.wm = iris_to_brw_fs_key(devinfo, old_iris_key);
+ break;
+ case MESA_SHADER_COMPUTE:
+ old_key.cs = iris_to_brw_cs_key(devinfo, old_iris_key);
+ break;
+ default:
+ unreachable("invalid shader stage");
+ }
+
+ brw_debug_key_recompile(c, &ice->dbg, info->stage, &old_key.base, key);
}
/**
static struct iris_compiled_shader *
iris_compile_vs(struct iris_context *ice,
struct iris_uncompiled_shader *ish,
- const struct brw_vs_prog_key *key)
+ const struct iris_vs_prog_key *key)
{
struct iris_screen *screen = (struct iris_screen *)ice->ctx.screen;
const struct brw_compiler *compiler = screen->compiler;
nir_shader *nir = nir_shader_clone(mem_ctx, ish->nir);
- if (key->nr_userclip_plane_consts) {
+ if (key->vue.nr_userclip_plane_consts) {
nir_function_impl *impl = nir_shader_get_entrypoint(nir);
- nir_lower_clip_vs(nir, (1 << key->nr_userclip_plane_consts) - 1, true);
+ nir_lower_clip_vs(nir, (1 << key->vue.nr_userclip_plane_consts) - 1,
+ true, false, NULL);
nir_lower_io_to_temporaries(nir, impl, true, false);
nir_lower_global_vars_to_local(nir);
nir_lower_vars_to_ssa(nir);
brw_compute_vue_map(devinfo,
&vue_prog_data->vue_map, nir->info.outputs_written,
- nir->info.separate_shader);
+ nir->info.separate_shader, /* pos_slots */ 1);
- /* Don't tell the backend about our clip plane constants, we've already
- * lowered them in NIR and we don't want it doing it again.
- */
- struct brw_vs_prog_key key_no_ucp = *key;
- key_no_ucp.nr_userclip_plane_consts = 0;
+ struct brw_vs_prog_key brw_key = iris_to_brw_vs_key(devinfo, key);
char *error_str = NULL;
const unsigned *program =
- brw_compile_vs(compiler, &ice->dbg, mem_ctx, &key_no_ucp, vs_prog_data,
+ brw_compile_vs(compiler, &ice->dbg, mem_ctx, &brw_key, vs_prog_data,
nir, -1, NULL, &error_str);
if (program == NULL) {
dbg_printf("Failed to compile vertex shader: %s\n", error_str);
}
if (ish->compiled_once) {
- iris_debug_recompile(ice, &nir->info, &key->base);
+ iris_debug_recompile(ice, &nir->info, &brw_key.base);
} else {
ish->compiled_once = true;
}
struct iris_shader_state *shs = &ice->state.shaders[MESA_SHADER_VERTEX];
struct iris_uncompiled_shader *ish =
ice->shaders.uncompiled[MESA_SHADER_VERTEX];
- struct iris_screen *screen = (struct iris_screen *)ice->ctx.screen;
- const struct gen_device_info *devinfo = &screen->devinfo;
- struct brw_vs_prog_key key = { KEY_INIT(devinfo->gen) };
+ struct iris_vs_prog_key key = { KEY_ID(vue.base) };
ice->vtbl.populate_vs_key(ice, &ish->nir->info, last_vue_stage(ice), &key);
struct iris_compiled_shader *old = ice->shaders.prog[IRIS_CACHE_VS];
const bool needs_sgvs_element = uses_draw_params ||
vs_prog_data->uses_instanceid ||
vs_prog_data->uses_vertexid;
- bool needs_edge_flag = false;
- nir_foreach_variable(var, &ish->nir->inputs) {
- if (var->data.location == VERT_ATTRIB_EDGEFLAG)
- needs_edge_flag = true;
- }
if (ice->state.vs_uses_draw_params != uses_draw_params ||
ice->state.vs_uses_derived_draw_params != uses_derived_draw_params ||
- ice->state.vs_needs_edge_flag != needs_edge_flag) {
+ ice->state.vs_needs_edge_flag != ish->needs_edge_flag) {
ice->state.dirty |= IRIS_DIRTY_VERTEX_BUFFERS |
IRIS_DIRTY_VERTEX_ELEMENTS;
}
ice->state.vs_uses_draw_params = uses_draw_params;
ice->state.vs_uses_derived_draw_params = uses_derived_draw_params;
ice->state.vs_needs_sgvs_element = needs_sgvs_element;
- ice->state.vs_needs_edge_flag = needs_edge_flag;
+ ice->state.vs_needs_edge_flag = ish->needs_edge_flag;
}
}
static struct iris_compiled_shader *
iris_compile_tcs(struct iris_context *ice,
struct iris_uncompiled_shader *ish,
- const struct brw_tcs_prog_key *key)
+ const struct iris_tcs_prog_key *key)
{
struct iris_screen *screen = (struct iris_screen *)ice->ctx.screen;
const struct brw_compiler *compiler = screen->compiler;
struct iris_binding_table bt;
+ struct brw_tcs_prog_key brw_key = iris_to_brw_tcs_key(devinfo, key);
+
if (ish) {
nir = nir_shader_clone(mem_ctx, ish->nir);
num_system_values, num_cbufs);
brw_nir_analyze_ubo_ranges(compiler, nir, NULL, prog_data->ubo_ranges);
} else {
- nir = brw_nir_create_passthrough_tcs(mem_ctx, compiler, options, key);
+ nir =
+ brw_nir_create_passthrough_tcs(mem_ctx, compiler, options, &brw_key);
/* Reserve space for passing the default tess levels as constants. */
num_cbufs = 1;
char *error_str = NULL;
const unsigned *program =
- brw_compile_tcs(compiler, &ice->dbg, mem_ctx, key, tcs_prog_data, nir,
- -1, NULL, &error_str);
+ brw_compile_tcs(compiler, &ice->dbg, mem_ctx, &brw_key, tcs_prog_data,
+ nir, -1, NULL, &error_str);
if (program == NULL) {
dbg_printf("Failed to compile control shader: %s\n", error_str);
ralloc_free(mem_ctx);
if (ish) {
if (ish->compiled_once) {
- iris_debug_recompile(ice, &nir->info, &key->base);
+ iris_debug_recompile(ice, &nir->info, &brw_key.base);
} else {
ish->compiled_once = true;
}
const struct shader_info *tes_info =
iris_get_shader_info(ice, MESA_SHADER_TESS_EVAL);
- struct brw_tcs_prog_key key = {
- KEY_INIT_NO_ID(devinfo->gen),
- .base.program_string_id = tcs ? tcs->program_id : 0,
+ struct iris_tcs_prog_key key = {
+ .vue.base.program_string_id = tcs ? tcs->program_id : 0,
.tes_primitive_mode = tes_info->tess.primitive_mode,
.input_vertices =
!tcs || compiler->use_tcs_8_patch ? ice->state.vertices_per_patch : 0,
+ .quads_workaround = devinfo->gen < 9 &&
+ tes_info->tess.primitive_mode == GL_QUADS &&
+ tes_info->tess.spacing == TESS_SPACING_EQUAL,
};
get_unified_tess_slots(ice, &key.outputs_written,
&key.patch_outputs_written);
static struct iris_compiled_shader *
iris_compile_tes(struct iris_context *ice,
struct iris_uncompiled_shader *ish,
- const struct brw_tes_prog_key *key)
+ const struct iris_tes_prog_key *key)
{
struct iris_screen *screen = (struct iris_screen *)ice->ctx.screen;
const struct brw_compiler *compiler = screen->compiler;
nir_shader *nir = nir_shader_clone(mem_ctx, ish->nir);
- if (key->nr_userclip_plane_consts) {
+ if (key->vue.nr_userclip_plane_consts) {
nir_function_impl *impl = nir_shader_get_entrypoint(nir);
- nir_lower_clip_vs(nir, (1 << key->nr_userclip_plane_consts) - 1, true);
+ nir_lower_clip_vs(nir, (1 << key->vue.nr_userclip_plane_consts) - 1,
+ true, false, NULL);
nir_lower_io_to_temporaries(nir, impl, true, false);
nir_lower_global_vars_to_local(nir);
nir_lower_vars_to_ssa(nir);
brw_compute_tess_vue_map(&input_vue_map, key->inputs_read,
key->patch_inputs_read);
+ struct brw_tes_prog_key brw_key = iris_to_brw_tes_key(devinfo, key);
+
char *error_str = NULL;
const unsigned *program =
- brw_compile_tes(compiler, &ice->dbg, mem_ctx, key, &input_vue_map,
+ brw_compile_tes(compiler, &ice->dbg, mem_ctx, &brw_key, &input_vue_map,
tes_prog_data, nir, -1, NULL, &error_str);
if (program == NULL) {
dbg_printf("Failed to compile evaluation shader: %s\n", error_str);
}
if (ish->compiled_once) {
- iris_debug_recompile(ice, &nir->info, &key->base);
+ iris_debug_recompile(ice, &nir->info, &brw_key.base);
} else {
ish->compiled_once = true;
}
struct iris_shader_state *shs = &ice->state.shaders[MESA_SHADER_TESS_EVAL];
struct iris_uncompiled_shader *ish =
ice->shaders.uncompiled[MESA_SHADER_TESS_EVAL];
- struct iris_screen *screen = (struct iris_screen *)ice->ctx.screen;
- const struct gen_device_info *devinfo = &screen->devinfo;
- struct brw_tes_prog_key key = { KEY_INIT(devinfo->gen) };
+ struct iris_tes_prog_key key = { KEY_ID(vue.base) };
get_unified_tess_slots(ice, &key.inputs_read, &key.patch_inputs_read);
ice->vtbl.populate_tes_key(ice, &ish->nir->info, last_vue_stage(ice), &key);
static struct iris_compiled_shader *
iris_compile_gs(struct iris_context *ice,
struct iris_uncompiled_shader *ish,
- const struct brw_gs_prog_key *key)
+ const struct iris_gs_prog_key *key)
{
struct iris_screen *screen = (struct iris_screen *)ice->ctx.screen;
const struct brw_compiler *compiler = screen->compiler;
nir_shader *nir = nir_shader_clone(mem_ctx, ish->nir);
- if (key->nr_userclip_plane_consts) {
+ if (key->vue.nr_userclip_plane_consts) {
nir_function_impl *impl = nir_shader_get_entrypoint(nir);
- nir_lower_clip_gs(nir, (1 << key->nr_userclip_plane_consts) - 1);
+ nir_lower_clip_gs(nir, (1 << key->vue.nr_userclip_plane_consts) - 1,
+ false, NULL);
nir_lower_io_to_temporaries(nir, impl, true, false);
nir_lower_global_vars_to_local(nir);
nir_lower_vars_to_ssa(nir);
brw_compute_vue_map(devinfo,
&vue_prog_data->vue_map, nir->info.outputs_written,
- nir->info.separate_shader);
+ nir->info.separate_shader, /* pos_slots */ 1);
+
+ struct brw_gs_prog_key brw_key = iris_to_brw_gs_key(devinfo, key);
char *error_str = NULL;
const unsigned *program =
- brw_compile_gs(compiler, &ice->dbg, mem_ctx, key, gs_prog_data, nir,
- NULL, -1, NULL, &error_str);
+ brw_compile_gs(compiler, &ice->dbg, mem_ctx, &brw_key, gs_prog_data,
+ nir, NULL, -1, NULL, &error_str);
if (program == NULL) {
dbg_printf("Failed to compile geometry shader: %s\n", error_str);
ralloc_free(mem_ctx);
}
if (ish->compiled_once) {
- iris_debug_recompile(ice, &nir->info, &key->base);
+ iris_debug_recompile(ice, &nir->info, &brw_key.base);
} else {
ish->compiled_once = true;
}
struct iris_compiled_shader *shader = NULL;
if (ish) {
- struct iris_screen *screen = (struct iris_screen *)ice->ctx.screen;
- const struct gen_device_info *devinfo = &screen->devinfo;
- struct brw_gs_prog_key key = { KEY_INIT(devinfo->gen) };
+ struct iris_gs_prog_key key = { KEY_ID(vue.base) };
ice->vtbl.populate_gs_key(ice, &ish->nir->info, last_vue_stage(ice), &key);
shader =
static struct iris_compiled_shader *
iris_compile_fs(struct iris_context *ice,
struct iris_uncompiled_shader *ish,
- const struct brw_wm_prog_key *key,
+ const struct iris_fs_prog_key *key,
struct brw_vue_map *vue_map)
{
struct iris_screen *screen = (struct iris_screen *)ice->ctx.screen;
brw_nir_analyze_ubo_ranges(compiler, nir, NULL, prog_data->ubo_ranges);
+ struct brw_wm_prog_key brw_key = iris_to_brw_fs_key(devinfo, key);
+
char *error_str = NULL;
const unsigned *program =
- brw_compile_fs(compiler, &ice->dbg, mem_ctx, key, fs_prog_data,
+ brw_compile_fs(compiler, &ice->dbg, mem_ctx, &brw_key, fs_prog_data,
nir, -1, -1, -1, true, false, vue_map,
NULL, &error_str);
if (program == NULL) {
}
if (ish->compiled_once) {
- iris_debug_recompile(ice, &nir->info, &key->base);
+ iris_debug_recompile(ice, &nir->info, &brw_key.base);
} else {
ish->compiled_once = true;
}
static void
iris_update_compiled_fs(struct iris_context *ice)
{
- struct iris_screen *screen = (struct iris_screen *)ice->ctx.screen;
- const struct gen_device_info *devinfo = &screen->devinfo;
struct iris_shader_state *shs = &ice->state.shaders[MESA_SHADER_FRAGMENT];
struct iris_uncompiled_shader *ish =
ice->shaders.uncompiled[MESA_SHADER_FRAGMENT];
- struct brw_wm_prog_key key = { KEY_INIT(devinfo->gen) };
+ struct iris_fs_prog_key key = { KEY_ID(base) };
ice->vtbl.populate_fs_key(ice, &ish->nir->info, &key);
if (ish->nos & (1ull << IRIS_NOS_LAST_VUE_MAP))
static struct iris_compiled_shader *
iris_compile_cs(struct iris_context *ice,
struct iris_uncompiled_shader *ish,
- const struct brw_cs_prog_key *key)
+ const struct iris_cs_prog_key *key)
{
struct iris_screen *screen = (struct iris_screen *)ice->ctx.screen;
const struct brw_compiler *compiler = screen->compiler;
iris_setup_binding_table(devinfo, nir, &bt, /* num_render_targets */ 0,
num_system_values, num_cbufs);
+ struct brw_cs_prog_key brw_key = iris_to_brw_cs_key(devinfo, key);
+
char *error_str = NULL;
const unsigned *program =
- brw_compile_cs(compiler, &ice->dbg, mem_ctx, key, cs_prog_data,
+ brw_compile_cs(compiler, &ice->dbg, mem_ctx, &brw_key, cs_prog_data,
nir, -1, NULL, &error_str);
if (program == NULL) {
dbg_printf("Failed to compile compute shader: %s\n", error_str);
}
if (ish->compiled_once) {
- iris_debug_recompile(ice, &nir->info, &key->base);
+ iris_debug_recompile(ice, &nir->info, &brw_key.base);
} else {
ish->compiled_once = true;
}
struct iris_uncompiled_shader *ish =
ice->shaders.uncompiled[MESA_SHADER_COMPUTE];
- struct iris_screen *screen = (struct iris_screen *)ice->ctx.screen;
- const struct gen_device_info *devinfo = &screen->devinfo;
- struct brw_cs_prog_key key = { KEY_INIT(devinfo->gen) };
+ struct iris_cs_prog_key key = { KEY_ID(base) };
ice->vtbl.populate_cs_key(ice, &key);
struct iris_compiled_shader *old = ice->shaders.prog[IRIS_CACHE_CS];
* as well. This is not currently documented at all.
*
* This hack is no longer necessary on Gen11+.
+ *
+ * For, Gen11+, scratch space allocation is based on the number of threads
+ * in the base configuration.
*/
unsigned subslice_total = screen->subslice_total;
- if (devinfo->gen < 11)
+ if (devinfo->gen >= 12)
+ subslice_total = devinfo->num_subslices[0];
+ else if (devinfo->gen == 11)
+ subslice_total = 8;
+ else if (devinfo->gen < 11)
subslice_total = 4 * devinfo->num_slices;
assert(subslice_total >= screen->subslice_total);
if (!*bop) {
unsigned scratch_ids_per_subslice = devinfo->max_cs_threads;
+
+ if (devinfo->gen >= 12) {
+ /* Same as ICL below, but with 16 EUs. */
+ scratch_ids_per_subslice = 16 * 8;
+ } else if (devinfo->gen == 11) {
+ /* The MEDIA_VFE_STATE docs say:
+ *
+ * "Starting with this configuration, the Maximum Number of
+ * Threads must be set to (#EU * 8) for GPGPU dispatches.
+ *
+ * Although there are only 7 threads per EU in the configuration,
+ * the FFTID is calculated as if there are 8 threads per EU,
+ * which in turn requires a larger amount of Scratch Space to be
+ * allocated by the driver."
+ */
+ scratch_ids_per_subslice = 8 * 8;
+ }
+
uint32_t max_threads[] = {
[MESA_SHADER_VERTEX] = devinfo->max_vs_threads,
[MESA_SHADER_TESS_CTRL] = devinfo->max_tcs_threads,
if (!ish)
return NULL;
+ NIR_PASS(ish->needs_edge_flag, nir, iris_fix_edge_flags);
+
brw_preprocess_nir(screen->compiler, nir, NULL);
- NIR_PASS_V(nir, brw_nir_lower_image_load_store, devinfo);
+ NIR_PASS_V(nir, brw_nir_lower_image_load_store, devinfo,
+ &ish->uses_atomic_load_store);
NIR_PASS_V(nir, iris_lower_storage_image_derefs);
nir_sweep(nir);
if (screen->disk_cache) {
/* Serialize the NIR to a binary blob that we can hash for the disk
- * cache. First, drop unnecessary information (like variable names)
+ * cache. Drop unnecessary information (like variable names)
* so the serialized NIR is smaller, and also to let us detect more
- * isomorphic shaders when hashing, increasing cache hits. We clone
- * the NIR before stripping away this info because it can be useful
- * when inspecting and debugging shaders.
+ * isomorphic shaders when hashing, increasing cache hits.
*/
- nir_shader *clone = nir_shader_clone(NULL, nir);
- nir_strip(clone);
-
struct blob blob;
blob_init(&blob);
- nir_serialize(&blob, clone);
+ nir_serialize(&blob, nir, true);
_mesa_sha1_compute(blob.data, blob.size, ish->nir_sha1);
blob_finish(&blob);
-
- ralloc_free(clone);
}
return ish;
ish->nos |= (1ull << IRIS_NOS_RASTERIZER);
if (screen->precompile) {
- const struct gen_device_info *devinfo = &screen->devinfo;
- struct brw_vs_prog_key key = { KEY_INIT(devinfo->gen) };
+ struct iris_vs_prog_key key = { KEY_ID(vue.base) };
if (!iris_disk_cache_retrieve(ice, ish, &key, sizeof(key)))
iris_compile_vs(ice, ish, &key);
if (screen->precompile) {
const unsigned _GL_TRIANGLES = 0x0004;
- const struct gen_device_info *devinfo = &screen->devinfo;
- struct brw_tcs_prog_key key = {
- KEY_INIT(devinfo->gen),
+ struct iris_tcs_prog_key key = {
+ KEY_ID(vue.base),
// XXX: make sure the linker fills this out from the TES...
.tes_primitive_mode =
info->tess.primitive_mode ? info->tess.primitive_mode
ish->nos |= (1ull << IRIS_NOS_RASTERIZER);
if (screen->precompile) {
- const struct gen_device_info *devinfo = &screen->devinfo;
- struct brw_tes_prog_key key = {
- KEY_INIT(devinfo->gen),
+ struct iris_tes_prog_key key = {
+ KEY_ID(vue.base),
// XXX: not ideal, need TCS output/TES input unification
.inputs_read = info->inputs_read,
.patch_inputs_read = info->patch_inputs_read,
ish->nos |= (1ull << IRIS_NOS_RASTERIZER);
if (screen->precompile) {
- const struct gen_device_info *devinfo = &screen->devinfo;
- struct brw_gs_prog_key key = { KEY_INIT(devinfo->gen) };
+ struct iris_gs_prog_key key = { KEY_ID(vue.base) };
if (!iris_disk_cache_retrieve(ice, ish, &key, sizeof(key)))
iris_compile_gs(ice, ish, &key);
util_bitcount64(info->inputs_read & BRW_FS_VARYING_INPUT_MASK) <= 16;
const struct gen_device_info *devinfo = &screen->devinfo;
- struct brw_wm_prog_key key = {
- KEY_INIT(devinfo->gen),
+ struct iris_fs_prog_key key = {
+ KEY_ID(base),
.nr_color_regions = util_bitcount(color_outputs),
.coherent_fb_fetch = devinfo->gen >= 9,
.input_slots_valid =
// XXX: disallow more than 64KB of shared variables
if (screen->precompile) {
- const struct gen_device_info *devinfo = &screen->devinfo;
- struct brw_cs_prog_key key = { KEY_INIT(devinfo->gen) };
+ struct iris_cs_prog_key key = { KEY_ID(base) };
if (!iris_disk_cache_retrieve(ice, ish, &key, sizeof(key)))
iris_compile_cs(ice, ish, &key);
iris_bind_fs_state(struct pipe_context *ctx, void *state)
{
struct iris_context *ice = (struct iris_context *) ctx;
+ struct iris_screen *screen = (struct iris_screen *) ctx->screen;
+ const struct gen_device_info *devinfo = &screen->devinfo;
struct iris_uncompiled_shader *old_ish =
ice->shaders.uncompiled[MESA_SHADER_FRAGMENT];
struct iris_uncompiled_shader *new_ish = state;
(new_ish->nir->info.outputs_written & color_bits))
ice->state.dirty |= IRIS_DIRTY_PS_BLEND;
+ if (devinfo->gen == 8)
+ ice->state.dirty |= IRIS_DIRTY_PMA_FIX;
+
bind_shader_state((void *) ctx, state, MESA_SHADER_FRAGMENT);
}