#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.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)
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)));
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);
}
+/**
+ * Get the shader for the last enabled geometry stage.
+ *
+ * This stage is the one which will feed stream output and the rasterizer.
+ */
+static gl_shader_stage
+last_vue_stage(struct iris_context *ice)
+{
+ if (ice->shaders.uncompiled[MESA_SHADER_GEOMETRY])
+ return MESA_SHADER_GEOMETRY;
+
+ if (ice->shaders.uncompiled[MESA_SHADER_TESS_EVAL])
+ return MESA_SHADER_TESS_EVAL;
+
+ return MESA_SHADER_VERTEX;
+}
/**
* Compile a vertex shader, and upload the assembly.
}
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;
}
const struct gen_device_info *devinfo = &screen->devinfo;
struct brw_vs_prog_key key = { KEY_INIT(devinfo->gen) };
- ice->vtbl.populate_vs_key(ice, &ish->nir->info, &key);
+ 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];
struct iris_compiled_shader *shader =
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;
}
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);
nir_shader *nir = nir_shader_clone(mem_ctx, ish->nir);
+ if (key->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_io_to_temporaries(nir, impl, true, false);
+ nir_lower_global_vars_to_local(nir);
+ nir_lower_vars_to_ssa(nir);
+ nir_shader_gather_info(nir, impl);
+ }
+
iris_setup_uniforms(compiler, mem_ctx, nir, prog_data, &system_values,
&num_system_values, &num_cbufs);
}
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;
}
struct brw_tes_prog_key key = { KEY_INIT(devinfo->gen) };
get_unified_tess_slots(ice, &key.inputs_read, &key.patch_inputs_read);
- ice->vtbl.populate_tes_key(ice, &key);
+ ice->vtbl.populate_tes_key(ice, &ish->nir->info, last_vue_stage(ice), &key);
struct iris_compiled_shader *old = ice->shaders.prog[IRIS_CACHE_TES];
struct iris_compiled_shader *shader =
nir_shader *nir = nir_shader_clone(mem_ctx, ish->nir);
+ if (key->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_io_to_temporaries(nir, impl, true, false);
+ nir_lower_global_vars_to_local(nir);
+ nir_lower_vars_to_ssa(nir);
+ nir_shader_gather_info(nir, impl);
+ }
+
iris_setup_uniforms(compiler, mem_ctx, nir, prog_data, &system_values,
&num_system_values, &num_cbufs);
}
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;
}
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) };
- ice->vtbl.populate_gs_key(ice, &key);
+ ice->vtbl.populate_gs_key(ice, &ish->nir->info, last_vue_stage(ice), &key);
shader =
iris_find_cached_shader(ice, IRIS_CACHE_GS, sizeof(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;
}
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;
}
}
-/**
- * Get the compiled shader for the last enabled geometry stage.
- *
- * This stage is the one which will feed stream output and the rasterizer.
- */
-static gl_shader_stage
-last_vue_stage(struct iris_context *ice)
-{
- if (ice->shaders.prog[MESA_SHADER_GEOMETRY])
- return MESA_SHADER_GEOMETRY;
-
- if (ice->shaders.prog[MESA_SHADER_TESS_EVAL])
- return MESA_SHADER_TESS_EVAL;
-
- return MESA_SHADER_VERTEX;
-}
-
/**
* Update the last enabled stage's VUE map.
*
(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;
}
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?
+ /* User clip planes */
+ if (ish->nir->info.clip_distance_array_size == 0)
+ ish->nos |= (1ull << IRIS_NOS_RASTERIZER);
if (screen->precompile) {
const struct gen_device_info *devinfo = &screen->devinfo;
struct iris_screen *screen = (void *) ctx->screen;
struct iris_uncompiled_shader *ish = iris_create_shader_state(ctx, state);
- // XXX: NOS?
+ /* User clip planes */
+ if (ish->nir->info.clip_distance_array_size == 0)
+ ish->nos |= (1ull << IRIS_NOS_RASTERIZER);
if (screen->precompile) {
const struct gen_device_info *devinfo = &screen->devinfo;
static void
iris_bind_vs_state(struct pipe_context *ctx, void *state)
{
+ struct iris_context *ice = (struct iris_context *)ctx;
+ struct iris_uncompiled_shader *new_ish = state;
+
+ if (new_ish &&
+ ice->state.window_space_position !=
+ new_ish->nir->info.vs.window_space_position) {
+ ice->state.window_space_position =
+ new_ish->nir->info.vs.window_space_position;
+
+ ice->state.dirty |= IRIS_DIRTY_CLIP |
+ IRIS_DIRTY_RASTER |
+ IRIS_DIRTY_CC_VIEWPORT;
+ }
+
bind_shader_state((void *) ctx, state, MESA_SHADER_VERTEX);
}