summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTimothy Arceri <[email protected]>2019-06-28 22:25:57 +1000
committerKenneth Graunke <[email protected]>2019-08-01 16:12:37 -0700
commit2afedfaf9aa161f8e8acbd1e8048a540db5fcfc8 (patch)
treecc4718ac28d97ab70241e1d1221015d524e4e8bb /src
parent00b5bf2d729f6c23525c4496552036c71d05479e (diff)
iris: add support for gl_ClipVertex in tess eval shaders
Required for OpenGL compat support. Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/iris/iris_context.h2
-rw-r--r--src/gallium/drivers/iris/iris_program.c15
-rw-r--r--src/gallium/drivers/iris/iris_state.c13
-rw-r--r--src/intel/compiler/brw_compiler.h9
4 files changed, 37 insertions, 2 deletions
diff --git a/src/gallium/drivers/iris/iris_context.h b/src/gallium/drivers/iris/iris_context.h
index ed8ffc008aa..8a098f50b20 100644
--- a/src/gallium/drivers/iris/iris_context.h
+++ b/src/gallium/drivers/iris/iris_context.h
@@ -473,6 +473,8 @@ struct iris_vtable {
void (*populate_tcs_key)(const struct iris_context *ice,
struct brw_tcs_prog_key *key);
void (*populate_tes_key)(const struct iris_context *ice,
+ const struct shader_info *info,
+ gl_shader_stage last_stage,
struct brw_tes_prog_key *key);
void (*populate_gs_key)(const struct iris_context *ice,
const struct shader_info *info,
diff --git a/src/gallium/drivers/iris/iris_program.c b/src/gallium/drivers/iris/iris_program.c
index 1453390b02d..d5986f4809c 100644
--- a/src/gallium/drivers/iris/iris_program.c
+++ b/src/gallium/drivers/iris/iris_program.c
@@ -1246,6 +1246,15 @@ iris_compile_tes(struct iris_context *ice,
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);
@@ -1307,7 +1316,7 @@ iris_update_compiled_tes(struct iris_context *ice)
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 =
@@ -2011,6 +2020,10 @@ iris_create_tes_state(struct pipe_context *ctx,
struct iris_uncompiled_shader *ish = iris_create_shader_state(ctx, state);
struct shader_info *info = &ish->nir->info;
+ /* 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 brw_tes_prog_key key = {
diff --git a/src/gallium/drivers/iris/iris_state.c b/src/gallium/drivers/iris/iris_state.c
index 60b30739df8..2c3b18b19bc 100644
--- a/src/gallium/drivers/iris/iris_state.c
+++ b/src/gallium/drivers/iris/iris_state.c
@@ -2181,12 +2181,15 @@ iris_set_clip_state(struct pipe_context *ctx,
struct iris_context *ice = (struct iris_context *) ctx;
struct iris_shader_state *shs = &ice->state.shaders[MESA_SHADER_VERTEX];
struct iris_shader_state *gshs = &ice->state.shaders[MESA_SHADER_GEOMETRY];
+ struct iris_shader_state *tshs = &ice->state.shaders[MESA_SHADER_TESS_EVAL];
memcpy(&ice->state.clip_planes, state, sizeof(*state));
- ice->state.dirty |= IRIS_DIRTY_CONSTANTS_VS | IRIS_DIRTY_CONSTANTS_GS;
+ ice->state.dirty |= IRIS_DIRTY_CONSTANTS_VS | IRIS_DIRTY_CONSTANTS_GS |
+ IRIS_DIRTY_CONSTANTS_TES;
shs->sysvals_need_upload = true;
gshs->sysvals_need_upload = true;
+ tshs->sysvals_need_upload = true;
}
/**
@@ -3363,8 +3366,16 @@ iris_populate_tcs_key(const struct iris_context *ice,
*/
static void
iris_populate_tes_key(const struct iris_context *ice,
+ const struct shader_info *info,
+ gl_shader_stage last_stage,
struct brw_tes_prog_key *key)
{
+ const struct iris_rasterizer_state *cso_rast = ice->state.cso_rast;
+
+ if (info->clip_distance_array_size == 0 &&
+ (info->outputs_written & (VARYING_BIT_POS | VARYING_BIT_CLIP_VERTEX)) &&
+ last_stage == MESA_SHADER_TESS_EVAL)
+ key->nr_userclip_plane_consts = cso_rast->num_clip_plane_consts;
}
/**
diff --git a/src/intel/compiler/brw_compiler.h b/src/intel/compiler/brw_compiler.h
index 781e357f2f2..614410e3fb7 100644
--- a/src/intel/compiler/brw_compiler.h
+++ b/src/intel/compiler/brw_compiler.h
@@ -317,6 +317,15 @@ struct brw_tes_prog_key
/** A bitfield of per-vertex inputs read. */
uint64_t inputs_read;
+
+ /**
+ * How many user clipping planes are being uploaded to the tessellation
+ * evaluation shader as push constants.
+ *
+ * These are used for lowering legacy gl_ClipVertex/gl_Position clipping to
+ * clip distances.
+ */
+ unsigned nr_userclip_plane_consts:4;
};
/** The program key for Geometry Shaders. */