From c2c2da91a8f468d7a5d6c8222634567016bde16a Mon Sep 17 00:00:00 2001 From: Rob Clark Date: Mon, 4 Jul 2022 07:55:43 -0700 Subject: [PATCH] freedreno/a6xx: Do clip-plane lowering in backend Our GS-lowered-to-quasi-VS confuses core nir passes, so handle clip- plane lowering ourself. Signed-off-by: Rob Clark Part-of: --- src/freedreno/ci/freedreno-a630-fails.txt | 20 ------------------- src/freedreno/ir3/ir3_compiler_nir.c | 8 ++++++-- src/gallium/drivers/freedreno/a6xx/fd6_draw.c | 1 + .../drivers/freedreno/freedreno_screen.c | 12 ++++++++++- 4 files changed, 18 insertions(+), 23 deletions(-) diff --git a/src/freedreno/ci/freedreno-a630-fails.txt b/src/freedreno/ci/freedreno-a630-fails.txt index 77feb4cc0a6..156a4070435 100644 --- a/src/freedreno/ci/freedreno-a630-fails.txt +++ b/src/freedreno/ci/freedreno-a630-fails.txt @@ -289,26 +289,6 @@ spec@ext_transform_feedback@tessellation triangle_fan flat_first,Fail spec@ext_transform_feedback@tessellation triangle_strip flat_first,Fail spec@glsl-1.30@execution@texelfetch fs sampler3d 1x129x9-98x129x9,Fail spec@glsl-1.30@execution@texelfetch fs sampler3d 98x1x9-98x129x9,Fail -spec@glsl-1.50@execution@compatibility@clipping@gs-clip-vertex-const-accept,Fail -spec@glsl-1.50@execution@compatibility@clipping@gs-clip-vertex-different-from-position,Fail -spec@glsl-1.50@execution@compatibility@clipping@gs-clip-vertex-enables,Fail -spec@glsl-1.50@execution@compatibility@clipping@gs-clip-vertex-equal-to-position,Fail -spec@glsl-1.50@execution@compatibility@clipping@gs-clip-vertex-homogeneity,Fail -spec@glsl-1.50@execution@compatibility@clipping@gs-clip-vertex-primitives-lines,Fail -spec@glsl-1.50@execution@compatibility@clipping@gs-clip-vertex-primitives-points,Fail -spec@glsl-1.50@execution@compatibility@clipping@gs-clip-vertex-primitives-triangle-strip,Fail - -# The precompile without UCP lowering triggers an assertion failure: -# "shader_io_get_unique_index: Assertion `!"illegal slot in get unique index\n"' -# failed." We shouldn't crash if clipvertex is written without actually doing -# clipping, we should just drop the output on the floor. -spec@glsl-1.50@execution@compatibility@clipping@vs-gs-clip-vertex-const-accept,Crash -spec@glsl-1.50@execution@compatibility@clipping@vs-gs-clip-vertex-const-reject,Crash -spec@glsl-1.50@execution@compatibility@clipping@vs-gs-clip-vertex-different-from-position,Crash -spec@glsl-1.50@execution@compatibility@clipping@vs-gs-clip-vertex-enables,Crash -spec@glsl-1.50@execution@compatibility@clipping@vs-gs-clip-vertex-equal-to-position,Crash -spec@glsl-1.50@execution@compatibility@clipping@vs-gs-clip-vertex-homogeneity,Crash -spec@glsl-1.50@execution@compatibility@clipping@vs-gs-clip-vertex-primitives-triangle-strip,Crash spec@glsl-1.50@execution@compatibility@vs-gs-texcoord-array-2,Crash spec@glsl-1.50@execution@compatibility@vs-gs-texcoord-array,Crash diff --git a/src/freedreno/ir3/ir3_compiler_nir.c b/src/freedreno/ir3/ir3_compiler_nir.c index 7ac829a49ce..6d1bcfc11d2 100644 --- a/src/freedreno/ir3/ir3_compiler_nir.c +++ b/src/freedreno/ir3/ir3_compiler_nir.c @@ -4369,8 +4369,12 @@ emit_instructions(struct ir3_context *ctx) ctx->so->num_samp = BITSET_LAST_BIT(ctx->s->info.textures_used) + ctx->s->info.num_images; - /* Save off clip+cull information. */ - ctx->so->clip_mask = MASK(ctx->s->info.clip_distance_array_size); + /* Save off clip+cull information. Note that in OpenGL clip planes may + * be individually enabled/disabled, and some gens handle lowering in + * backend, so we also need to consider the shader key: + */ + ctx->so->clip_mask = ctx->so->key.ucp_enables | + MASK(ctx->s->info.clip_distance_array_size); ctx->so->cull_mask = MASK(ctx->s->info.cull_distance_array_size) << ctx->s->info.clip_distance_array_size; diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_draw.c b/src/gallium/drivers/freedreno/a6xx/fd6_draw.c index fc844d7869b..c3ebcc051c1 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_draw.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_draw.c @@ -152,6 +152,7 @@ fd6_draw_vbo(struct fd_context *ctx, const struct pipe_draw_info *info, .fs = ctx->prog.fs, .key = { .rasterflat = ctx->rasterizer->flatshade, + .ucp_enables = ctx->rasterizer->clip_plane_enable, .layer_zero = !gs_info || !(gs_info->outputs_written & VARYING_BIT_LAYER), .sample_shading = (ctx->min_samples > 1), .msaa = (ctx->framebuffer.samples > 1), diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c b/src/gallium/drivers/freedreno/freedreno_screen.c index d8b82acc8cd..45e7dad8213 100644 --- a/src/gallium/drivers/freedreno/freedreno_screen.c +++ b/src/gallium/drivers/freedreno/freedreno_screen.c @@ -426,6 +426,14 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param) return is_a2xx(screen); case PIPE_CAP_CLIP_PLANES: + /* Gens that support GS, have GS lowered into a quasi-VS which confuses + * the frontend clip-plane lowering. So we handle this in the backend + * + */ + if (pscreen->get_shader_param(pscreen, PIPE_SHADER_GEOMETRY, + PIPE_SHADER_CAP_MAX_INSTRUCTIONS)) + return 1; + /* On a3xx, there is HW support for GL user clip planes that * occasionally has to fall back to shader key-based lowering to clip * distances in the VS, and we don't support clip distances so that is @@ -439,8 +447,10 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param) * On a5xx-a6xx, we have the HW clip distances hooked up, so we just let * mesa/st lower desktop GL's clip planes to clip distances in the last * vertex shader stage. + * + * NOTE: but see comment above about geometry shaders */ - return !is_a5xx(screen) && !is_a6xx(screen); + return !is_a5xx(screen); /* Stream output. */ case PIPE_CAP_MAX_STREAM_OUTPUT_BUFFERS: