iris: add support for gl_ClipVertex in geometry shaders
This will enable us to support the OpenGL compat profile. Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:

committed by
Kenneth Graunke

parent
70dc017aec
commit
00b5bf2d72
@@ -468,12 +468,15 @@ struct iris_vtable {
|
||||
const struct brw_vue_map *vue_map);
|
||||
void (*populate_vs_key)(const struct iris_context *ice,
|
||||
const struct shader_info *info,
|
||||
gl_shader_stage last_stage,
|
||||
struct brw_vs_prog_key *key);
|
||||
void (*populate_tcs_key)(const struct iris_context *ice,
|
||||
struct brw_tcs_prog_key *key);
|
||||
void (*populate_tes_key)(const struct iris_context *ice,
|
||||
struct brw_tes_prog_key *key);
|
||||
void (*populate_gs_key)(const struct iris_context *ice,
|
||||
const struct shader_info *info,
|
||||
gl_shader_stage last_stage,
|
||||
struct brw_gs_prog_key *key);
|
||||
void (*populate_fs_key)(const struct iris_context *ice,
|
||||
const struct shader_info *info,
|
||||
|
@@ -869,6 +869,22 @@ iris_debug_recompile(struct iris_context *ice,
|
||||
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.
|
||||
@@ -968,7 +984,7 @@ iris_update_compiled_vs(struct iris_context *ice)
|
||||
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 =
|
||||
@@ -1341,6 +1357,15 @@ iris_compile_gs(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_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);
|
||||
|
||||
@@ -1403,7 +1428,7 @@ iris_update_compiled_gs(struct iris_context *ice)
|
||||
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);
|
||||
@@ -1526,23 +1551,6 @@ iris_update_compiled_fs(struct iris_context *ice)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the last enabled stage's VUE map.
|
||||
*
|
||||
@@ -2027,6 +2035,10 @@ iris_create_gs_state(struct pipe_context *ctx,
|
||||
struct iris_screen *screen = (void *) ctx->screen;
|
||||
struct iris_uncompiled_shader *ish = iris_create_shader_state(ctx, state);
|
||||
|
||||
/* 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_gs_prog_key key = { KEY_INIT(devinfo->gen) };
|
||||
|
@@ -2180,11 +2180,13 @@ 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];
|
||||
|
||||
memcpy(&ice->state.clip_planes, state, sizeof(*state));
|
||||
|
||||
ice->state.dirty |= IRIS_DIRTY_CONSTANTS_VS;
|
||||
ice->state.dirty |= IRIS_DIRTY_CONSTANTS_VS | IRIS_DIRTY_CONSTANTS_GS;
|
||||
shs->sysvals_need_upload = true;
|
||||
gshs->sysvals_need_upload = true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3336,12 +3338,14 @@ iris_emit_sbe(struct iris_batch *batch, const struct iris_context *ice)
|
||||
static void
|
||||
iris_populate_vs_key(const struct iris_context *ice,
|
||||
const struct shader_info *info,
|
||||
gl_shader_stage last_stage,
|
||||
struct brw_vs_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)))
|
||||
(info->outputs_written & (VARYING_BIT_POS | VARYING_BIT_CLIP_VERTEX)) &&
|
||||
last_stage == MESA_SHADER_VERTEX)
|
||||
key->nr_userclip_plane_consts = cso_rast->num_clip_plane_consts;
|
||||
}
|
||||
|
||||
@@ -3368,8 +3372,16 @@ iris_populate_tes_key(const struct iris_context *ice,
|
||||
*/
|
||||
static void
|
||||
iris_populate_gs_key(const struct iris_context *ice,
|
||||
const struct shader_info *info,
|
||||
gl_shader_stage last_stage,
|
||||
struct brw_gs_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_GEOMETRY)
|
||||
key->nr_userclip_plane_consts = cso_rast->num_clip_plane_consts;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -323,6 +323,15 @@ struct brw_tes_prog_key
|
||||
struct brw_gs_prog_key
|
||||
{
|
||||
struct brw_base_prog_key base;
|
||||
|
||||
/**
|
||||
* How many user clipping planes are being uploaded to the geometry shader
|
||||
* as push constants.
|
||||
*
|
||||
* These are used for lowering legacy gl_ClipVertex/gl_Position clipping to
|
||||
* clip distances.
|
||||
*/
|
||||
unsigned nr_userclip_plane_consts:4;
|
||||
};
|
||||
|
||||
enum brw_sf_primitive {
|
||||
|
Reference in New Issue
Block a user