panfrost: Implement gl_FrontFacing
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Wed, 31 Jul 2019 19:24:32 +0000 (12:24 -0700)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Thu, 1 Aug 2019 23:15:03 +0000 (16:15 -0700)
Interestingly, this requires no compiler changes. It's just exposed as a
special varying.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
src/gallium/drivers/panfrost/pan_assemble.c
src/gallium/drivers/panfrost/pan_context.c
src/gallium/drivers/panfrost/pan_context.h
src/gallium/drivers/panfrost/pan_screen.c

index 8b831b8..4d69cd1 100644 (file)
@@ -144,6 +144,12 @@ panfrost_shader_compile(struct panfrost_context *ctx, struct mali_shader_meta *m
                         v.swizzle = default_vec2_swizzle;
 
                         state->reads_point_coord = true;
+                } else if (location == VARYING_SLOT_FACE) {
+                        v.index = 4;
+                        v.format = MALI_R32I;
+                        v.swizzle = default_vec1_swizzle;
+
+                        state->reads_face = true;
                 } else {
                         v.index = 0;
                 }
index b37c95b..9447c16 100644 (file)
@@ -517,6 +517,12 @@ panfrost_emit_point_coord(union mali_attr *slot)
 }
 
 static void
+panfrost_emit_front_face(union mali_attr *slot)
+{
+        slot->elements = MALI_VARYING_FRONT_FACING | MALI_ATTR_INTERNAL;
+}
+
+static void
 panfrost_emit_varying_descriptor(
         struct panfrost_context *ctx,
         unsigned vertex_count)
@@ -618,11 +624,20 @@ panfrost_emit_varying_descriptor(
                 ctx->payload_tiler.primitive_size.pointer =
                         panfrost_emit_varyings(ctx, &varyings[idx++],
                                                2, vertex_count);
+        } else if (fs->reads_face) {
+                /* Dummy to advance index */
+                ++idx;
         }
 
         if (fs->reads_point_coord) {
                 /* Special descriptor */
                 panfrost_emit_point_coord(&varyings[idx++]);
+        } else if (fs->reads_face) {
+                ++idx;
+        }
+
+        if (fs->reads_face) {
+                panfrost_emit_front_face(&varyings[idx++]);
         }
 
         mali_ptr varyings_p = panfrost_upload_transient(ctx, &varyings, idx * sizeof(union mali_attr));
index 1b2689d..e6d6ec4 100644 (file)
@@ -218,6 +218,7 @@ struct panfrost_shader_state {
         bool can_discard;
         bool writes_point_size;
         bool reads_point_coord;
+        bool reads_face;
 
         struct mali_attr_meta varyings[PIPE_MAX_ATTRIBS];
         gl_varying_slot varyings_loc[PIPE_MAX_ATTRIBS];
index aa39a35..d8aa6e3 100644 (file)
@@ -168,6 +168,11 @@ panfrost_get_param(struct pipe_screen *screen, enum pipe_cap param)
         case PIPE_CAP_GENERATE_MIPMAP:
                 return 1;
 
+        /* We would prefer varyings */
+        case PIPE_CAP_TGSI_FS_FACE_IS_INTEGER_SYSVAL:
+        case PIPE_CAP_TGSI_FS_POSITION_IS_SYSVAL:
+                return 0;
+
         case PIPE_CAP_SEAMLESS_CUBE_MAP:
         case PIPE_CAP_SEAMLESS_CUBE_MAP_PER_TEXTURE:
                 return 1;