freedreno/a6xx: Do clip-plane lowering in backend
authorRob Clark <robdclark@chromium.org>
Mon, 4 Jul 2022 14:55:43 +0000 (07:55 -0700)
committerMarge Bot <emma+marge@anholt.net>
Fri, 8 Jul 2022 20:32:35 +0000 (20:32 +0000)
Our GS-lowered-to-quasi-VS confuses core nir passes, so handle clip-
plane lowering ourself.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17341>

src/freedreno/ci/freedreno-a630-fails.txt
src/freedreno/ir3/ir3_compiler_nir.c
src/gallium/drivers/freedreno/a6xx/fd6_draw.c
src/gallium/drivers/freedreno/freedreno_screen.c

index 77feb4c..156a407 100644 (file)
@@ -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
index 7ac829a..6d1bcfc 100644 (file)
@@ -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;
 
index fc844d7..c3ebcc0 100644 (file)
@@ -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),
index d8b82ac..45e7dad 100644 (file)
@@ -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: