panfrost: Lower point sprites on Bifrost
authorAlyssa Rosenzweig <alyssa@collabora.com>
Tue, 26 Apr 2022 18:50:00 +0000 (14:50 -0400)
committerAlyssa Rosenzweig <alyssa@collabora.com>
Mon, 2 May 2022 13:55:49 +0000 (09:55 -0400)
Use the common pass. This only should trigger when drawing points, so we need
some extra tracking to ensure this.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16173>

src/gallium/drivers/panfrost/pan_assemble.c
src/gallium/drivers/panfrost/pan_cmdstream.c
src/gallium/drivers/panfrost/pan_context.c
src/gallium/drivers/panfrost/pan_context.h
src/panfrost/ci/panfrost-g52-fails.txt

index 6d10b2d..ac34c46 100644 (file)
@@ -48,9 +48,17 @@ panfrost_shader_compile(struct pipe_screen *pscreen,
         nir_shader *s = nir_shader_clone(NULL, ir);
 
         /* Lower this early so the backends don't have to worry about it */
-        if (s->info.stage == MESA_SHADER_FRAGMENT)
+        if (s->info.stage == MESA_SHADER_FRAGMENT) {
                 NIR_PASS_V(s, nir_lower_fragcolor, state->key.fs.nr_cbufs);
 
+                if (state->key.fs.sprite_coord_enable) {
+                        NIR_PASS_V(s, nir_lower_texcoord_replace,
+                                   state->key.fs.sprite_coord_enable,
+                                   true /* point coord is sysval */,
+                                   false /* Y-invert */);
+                }
+        }
+
         /* Call out to Midgard compiler given the above NIR */
         struct panfrost_compile_inputs inputs = {
                 .gpu_id = dev->gpu_id,
index e2d7242..1823144 100644 (file)
@@ -3467,6 +3467,19 @@ panfrost_direct_draw(struct panfrost_batch *batch,
 
         struct panfrost_context *ctx = batch->ctx;
 
+        /* If we change whether we're drawing points, or whether point sprites
+         * are enabled (specified in the rasterizer), we may need to rebind
+         * shaders accordingly. This implicitly covers the case of rebinding
+         * framebuffers, because all dirty flags are set there.
+         */
+        if ((ctx->dirty & PAN_DIRTY_RASTERIZER) ||
+            ((ctx->active_prim == PIPE_PRIM_POINTS) ^
+             (info->mode       == PIPE_PRIM_POINTS))) {
+
+                ctx->active_prim = info->mode;
+                panfrost_update_shader_variant(ctx, PIPE_SHADER_FRAGMENT);
+        }
+
         /* Take into account a negative bias */
         ctx->indirect_draw = false;
         ctx->vertex_count = draw->count + (info->index_size ? abs(draw->index_bias) : 0);
index 757c6ef..4f52ae0 100644 (file)
@@ -371,9 +371,15 @@ panfrost_build_key(struct panfrost_context *ctx,
 
         struct panfrost_device *dev = pan_device(ctx->base.screen);
         struct pipe_framebuffer_state *fb = &ctx->pipe_framebuffer;
+        struct pipe_rasterizer_state *rast = (void *) ctx->rasterizer;
 
         key->fs.nr_cbufs = fb->nr_cbufs;
 
+        /* Point sprite lowering needed on Bifrost and newer */
+        if (dev->arch >= 6 && rast && ctx->active_prim == PIPE_PRIM_POINTS) {
+                key->fs.sprite_coord_enable = rast->sprite_coord_enable;
+        }
+
         if (dev->arch <= 5) {
                 u_foreach_bit(i, (nir->info.outputs_read >> FRAG_RESULT_DATA0)) {
                         enum pipe_format fmt = PIPE_FORMAT_R8G8B8A8_UNORM;
@@ -673,13 +679,6 @@ panfrost_set_framebuffer_state(struct pipe_context *pctx,
                 if (ctx->pipe_framebuffer.cbufs[i])
                         ctx->fb_rt_mask |= BITFIELD_BIT(i);
         }
-
-        /* We may need to generate a new variant if the fragment shader is
-         * keyed to the framebuffer format or render target count */
-        struct panfrost_shader_variants *fs = ctx->shader[PIPE_SHADER_FRAGMENT];
-
-        if (fs && fs->variant_count)
-                ctx->base.bind_fs_state(&ctx->base, fs);
 }
 
 static void
index b6465e1..ee6268a 100644 (file)
@@ -70,6 +70,7 @@ enum pan_dirty_3d {
         PAN_DIRTY_MSAA           = BITFIELD_BIT(8),
         PAN_DIRTY_OQ             = BITFIELD_BIT(9),
         PAN_DIRTY_RASTERIZER     = BITFIELD_BIT(10),
+        PAN_DIRTY_POINTS         = BITFIELD_BIT(11),
 };
 
 enum pan_dirty_shader {
@@ -262,6 +263,9 @@ struct panfrost_fs_key {
          * non-blendable formats
          */
         enum pipe_format rt_formats[8];
+
+        /* From rasterize state, to lower point sprites */
+        uint16_t sprite_coord_enable;
 };
 
 struct panfrost_shader_key {
index 68a2d67..e4650e4 100644 (file)
@@ -73,7 +73,6 @@ spec@arb_get_program_binary@restore-sso-program,Fail
 spec@arb_pixel_buffer_object@fbo-pbo-readpixels-small,Fail
 spec@arb_pixel_buffer_object@fbo-pbo-readpixels-small@GL_DEPTH32F_STENCIL8-GL_DEPTH_STENCIL,Fail
 spec@arb_pixel_buffer_object@fbo-pbo-readpixels-small@GL_DEPTH32F_STENCIL8-GL_STENCIL_INDEX,Fail
-spec@arb_point_sprite@arb_point_sprite-checkerboard,Fail
 spec@arb_point_sprite@arb_point_sprite-mipmap,Fail
 spec@arb_sample_shading@samplemask 2@0.250000 mask_in_one,Fail
 spec@arb_sample_shading@samplemask 2@0.500000 mask_in_one,Fail
@@ -587,7 +586,6 @@ spec@!opengl 3.1@primitive-restart-xfb flush,Fail
 spec@!opengl 3.1@primitive-restart-xfb generated,Fail
 spec@!opengl 3.1@primitive-restart-xfb written,Fail
 spec@!opengl 3.1@required-texture-attachment-formats,Fail
-spec@!opengl 3.2@coord-replace-doesnt-eliminate-frag-tex-coords,Fail
 spec@!opengl es 3.0@gles-3.0-transform-feedback-uniform-buffer-object,Fail
 
 # VK-GL-CTS 1.3.1.0 uprev, aka when we dropped the custom caselist file.