#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)
struct pipe_context *ctx = &ice->ctx;
struct iris_screen *screen = (struct iris_screen *) ctx->screen;
- // XXX: these are not retained forever, use a separate uploader?
void *map =
upload_state(ice->state.surface_uploader, surf_state,
screen->isl_dev.ss.size, 64);
nir_deref_instr *deref = nir_src_as_deref(intrin->src[0]);
nir_variable *var = nir_deref_instr_get_variable(deref);
- /* XXX: var->data.binding is not set properly. We need to run
- * some form of gl_nir_lower_samplers_as_deref() to get it.
- * This breaks tests which use more than one image.
- */
if (img_idx[var->data.binding] == -1) {
/* GL only allows arrays of arrays of images. */
assert(glsl_type_is_image(glsl_without_array(var->type)));
nir_validate_shader(nir, "before remapping");
- /* Place the new params at the front of constant buffer 0. */
+ /* Uniforms are stored in constant buffer 0, the
+ * user-facing UBOs are indexed by one. So if any constant buffer is
+ * needed, the constant buffer 0 will be needed, so account for it.
+ */
+ unsigned num_cbufs = nir->info.num_ubos;
+ if (num_cbufs || nir->num_uniforms)
+ num_cbufs++;
+
+ /* Place the new params in a new cbuf. */
if (num_system_values > 0) {
- nir->num_uniforms += num_system_values * sizeof(uint32_t);
+ unsigned sysval_cbuf_index = num_cbufs;
+ num_cbufs++;
system_values = reralloc(mem_ctx, system_values, enum brw_param_builtin,
num_system_values);
assert(load->src[0].is_ssa);
if (load->src[0].ssa == temp_ubo_name) {
+ nir_ssa_def *imm = nir_imm_int(&b, sysval_cbuf_index);
nir_instr_rewrite_src(instr, &load->src[0],
- nir_src_for_ssa(nir_imm_int(&b, 0)));
- } else if (nir_src_is_const(load->src[0]) &&
- nir_src_as_uint(load->src[0]) == 0) {
- nir_ssa_def *offset =
- nir_iadd(&b, load->src[1].ssa,
- nir_imm_int(&b, 4 * num_system_values));
- nir_instr_rewrite_src(instr, &load->src[1],
- nir_src_for_ssa(offset));
+ nir_src_for_ssa(imm));
}
}
}
system_values = NULL;
}
+ 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
prog_data->nr_params = nir->num_uniforms / 4;
prog_data->param = rzalloc_array(mem_ctx, uint32_t, prog_data->nr_params);
- /* System values and uniforms are stored in constant buffer 0, the
- * user-facing UBOs are indexed by one. So if any constant buffer is
- * needed, the constant buffer 0 will be needed, so account for it.
- */
- unsigned num_cbufs = nir->info.num_ubos;
- if (num_cbufs || num_system_values || nir->num_uniforms)
- num_cbufs++;
-
/* 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.
*/
BITFIELD64_MASK(num_render_targets);
} else if (info->stage == MESA_SHADER_COMPUTE) {
bt->sizes[IRIS_SURFACE_GROUP_CS_WORK_GROUPS] = 1;
- bt->used_mask[IRIS_SURFACE_GROUP_CS_WORK_GROUPS] = 1;
}
bt->sizes[IRIS_SURFACE_GROUP_TEXTURE] = util_last_bit(info->textures_used);
nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);
switch (intrin->intrinsic) {
+ case nir_intrinsic_load_num_work_groups:
+ bt->used_mask[IRIS_SURFACE_GROUP_CS_WORK_GROUPS] = 1;
+ break;
+
case nir_intrinsic_image_size:
case nir_intrinsic_image_load:
case nir_intrinsic_image_store:
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;
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);
}
}
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;
}
static void
iris_update_compiled_vs(struct iris_context *ice)
{
+ 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;
IRIS_DIRTY_BINDINGS_VS |
IRIS_DIRTY_CONSTANTS_VS |
IRIS_DIRTY_VF_SGVS;
+ shs->sysvals_need_upload = true;
+
const struct brw_vs_prog_data *vs_prog_data =
(void *) shader->prog_data;
const bool uses_draw_params = vs_prog_data->uses_firstvertex ||
nir = brw_nir_create_passthrough_tcs(mem_ctx, compiler, options, key);
/* Reserve space for passing the default tess levels as constants. */
+ num_cbufs = 1;
num_system_values = 8;
system_values =
rzalloc_array(mem_ctx, enum brw_param_builtin, num_system_values);
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;
}
static void
iris_update_compiled_tcs(struct iris_context *ice)
{
+ struct iris_shader_state *shs = &ice->state.shaders[MESA_SHADER_TESS_CTRL];
struct iris_uncompiled_shader *tcs =
ice->shaders.uncompiled[MESA_SHADER_TESS_CTRL];
struct iris_screen *screen = (struct iris_screen *)ice->ctx.screen;
+ const struct brw_compiler *compiler = screen->compiler;
const struct gen_device_info *devinfo = &screen->devinfo;
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),
- .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,
+ .input_vertices =
+ !tcs || compiler->use_tcs_8_patch ? ice->state.vertices_per_patch : 0,
};
get_unified_tess_slots(ice, &key.outputs_written,
&key.patch_outputs_written);
ice->state.dirty |= IRIS_DIRTY_TCS |
IRIS_DIRTY_BINDINGS_TCS |
IRIS_DIRTY_CONSTANTS_TCS;
-
- if (!tcs) {
- /* We're binding a passthrough TCS, which doesn't have uniforms.
- * Since there's no actual TCS, the state tracker doesn't bother
- * to call set_constant_buffers to clear stale constant buffers.
- *
- * We do upload TCS constants for the default tesslevel system
- * values, however. In this case, we would see stale constant
- * data and try and read a dangling cbuf0->user_buffer pointer.
- * Just zero out the stale constants to avoid the upload.
- */
- struct iris_shader_state *shs =
- &ice->state.shaders[MESA_SHADER_TESS_CTRL];
-
- memset(&shs->cbuf0, 0, sizeof(shs->cbuf0));
- }
+ shs->sysvals_need_upload = true;
}
}
}
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;
}
static void
iris_update_compiled_tes(struct iris_context *ice)
{
+ 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;
ice->state.dirty |= IRIS_DIRTY_TES |
IRIS_DIRTY_BINDINGS_TES |
IRIS_DIRTY_CONSTANTS_TES;
+ shs->sysvals_need_upload = true;
}
/* TODO: Could compare and avoid flagging this. */
const struct shader_info *tes_info = &ish->nir->info;
if (tes_info->system_values_read & (1ull << SYSTEM_VALUE_VERTICES_IN)) {
ice->state.dirty |= IRIS_DIRTY_CONSTANTS_TES;
- ice->state.shaders[MESA_SHADER_TESS_EVAL].cbuf0_needs_upload = true;
+ ice->state.shaders[MESA_SHADER_TESS_EVAL].sysvals_need_upload = true;
}
}
}
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;
}
static void
iris_update_compiled_gs(struct iris_context *ice)
{
+ struct iris_shader_state *shs = &ice->state.shaders[MESA_SHADER_GEOMETRY];
struct iris_uncompiled_shader *ish =
ice->shaders.uncompiled[MESA_SHADER_GEOMETRY];
struct iris_compiled_shader *old = ice->shaders.prog[IRIS_CACHE_GS];
ice->state.dirty |= IRIS_DIRTY_GS |
IRIS_DIRTY_BINDINGS_GS |
IRIS_DIRTY_CONSTANTS_GS;
+ shs->sysvals_need_upload = true;
}
}
}
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;
}
static void
iris_update_compiled_fs(struct iris_context *ice)
{
+ struct iris_shader_state *shs = &ice->state.shaders[MESA_SHADER_FRAGMENT];
struct iris_uncompiled_shader *ish =
ice->shaders.uncompiled[MESA_SHADER_FRAGMENT];
struct iris_screen *screen = (struct iris_screen *)ice->ctx.screen;
const struct gen_device_info *devinfo = &screen->devinfo;
struct brw_wm_prog_key key = { KEY_INIT(devinfo->gen) };
- ice->vtbl.populate_fs_key(ice, &key);
+ ice->vtbl.populate_fs_key(ice, &ish->nir->info, &key);
if (ish->nos & (1ull << IRIS_NOS_LAST_VUE_MAP))
key.input_slots_valid = ice->shaders.last_vue_map->slots_valid;
IRIS_DIRTY_WM |
IRIS_DIRTY_CLIP |
IRIS_DIRTY_SBE;
+ shs->sysvals_need_upload = true;
}
}
(old_map ? old_map->slots_valid : 0ull) ^ vue_map->slots_valid;
if (changed_slots & VARYING_BIT_VIEWPORT) {
- // XXX: could use ctx->Const.MaxViewports for old API efficiency
ice->state.num_viewports =
(vue_map->slots_valid & VARYING_BIT_VIEWPORT) ? IRIS_MAX_VIEWPORTS : 1;
ice->state.dirty |= IRIS_DIRTY_CLIP |
IRIS_DIRTY_SCISSOR_RECT |
IRIS_DIRTY_UNCOMPILED_FS |
ice->state.dirty_for_nos[IRIS_NOS_LAST_VUE_MAP];
- // XXX: CC_VIEWPORT?
}
if (changed_slots || (old_map && old_map->separate != vue_map->separate)) {
}
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;
}
void
iris_update_compiled_compute_shader(struct iris_context *ice)
{
+ struct iris_shader_state *shs = &ice->state.shaders[MESA_SHADER_COMPUTE];
struct iris_uncompiled_shader *ish =
ice->shaders.uncompiled[MESA_SHADER_COMPUTE];
ice->state.dirty |= IRIS_DIRTY_CS |
IRIS_DIRTY_BINDINGS_CS |
IRIS_DIRTY_CONSTANTS_CS;
+ shs->sysvals_need_upload = true;
}
}
struct iris_uncompiled_shader *ish = iris_create_shader_state(ctx, state);
struct shader_info *info = &ish->nir->info;
- // XXX: NOS?
-
if (screen->precompile) {
const unsigned _GL_TRIANGLES = 0x0004;
const struct gen_device_info *devinfo = &screen->devinfo;
struct iris_uncompiled_shader *ish = iris_create_shader_state(ctx, state);
struct shader_info *info = &ish->nir->info;
- // XXX: NOS?
-
if (screen->precompile) {
const struct gen_device_info *devinfo = &screen->devinfo;
struct brw_tes_prog_key key = {
struct iris_screen *screen = (void *) ctx->screen;
struct iris_uncompiled_shader *ish = iris_create_shader_state(ctx, state);
- // XXX: NOS?
-
if (screen->precompile) {
const struct gen_device_info *devinfo = &screen->devinfo;
struct brw_gs_prog_key key = { KEY_INIT(devinfo->gen) };