From e9139868681157f9e6a356144eb6facce0226836 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Wed, 31 Jul 2019 12:24:32 -0700 Subject: [PATCH] panfrost: Implement gl_FrontFacing Interestingly, this requires no compiler changes. It's just exposed as a special varying. Signed-off-by: Alyssa Rosenzweig --- src/gallium/drivers/panfrost/pan_assemble.c | 6 ++++++ src/gallium/drivers/panfrost/pan_context.c | 15 +++++++++++++++ src/gallium/drivers/panfrost/pan_context.h | 1 + src/gallium/drivers/panfrost/pan_screen.c | 5 +++++ 4 files changed, 27 insertions(+) diff --git a/src/gallium/drivers/panfrost/pan_assemble.c b/src/gallium/drivers/panfrost/pan_assemble.c index 8b831b8f52d..4d69cd136bd 100644 --- a/src/gallium/drivers/panfrost/pan_assemble.c +++ b/src/gallium/drivers/panfrost/pan_assemble.c @@ -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; } diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c index b37c95bcf5b..9447c1690b5 100644 --- a/src/gallium/drivers/panfrost/pan_context.c +++ b/src/gallium/drivers/panfrost/pan_context.c @@ -516,6 +516,12 @@ panfrost_emit_point_coord(union mali_attr *slot) slot->stride = slot->size = slot->shift = slot->extra_flags = 0; } +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, @@ -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)); diff --git a/src/gallium/drivers/panfrost/pan_context.h b/src/gallium/drivers/panfrost/pan_context.h index 1b2689db3ad..e6d6ec48cc2 100644 --- a/src/gallium/drivers/panfrost/pan_context.h +++ b/src/gallium/drivers/panfrost/pan_context.h @@ -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]; diff --git a/src/gallium/drivers/panfrost/pan_screen.c b/src/gallium/drivers/panfrost/pan_screen.c index aa39a35e9c3..d8aa6e34103 100644 --- a/src/gallium/drivers/panfrost/pan_screen.c +++ b/src/gallium/drivers/panfrost/pan_screen.c @@ -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; -- 2.30.2