diff options
author | Alyssa Rosenzweig <[email protected]> | 2019-07-31 12:24:32 -0700 |
---|---|---|
committer | Alyssa Rosenzweig <[email protected]> | 2019-08-01 16:15:03 -0700 |
commit | e9139868681157f9e6a356144eb6facce0226836 (patch) | |
tree | ee842087a2164bd30e4a2e0b96efe2070d3e2132 | |
parent | f3e15122d4b4b3fbeb33790b7a26826d69066ae9 (diff) |
panfrost: Implement gl_FrontFacing
Interestingly, this requires no compiler changes. It's just exposed as a
special varying.
Signed-off-by: Alyssa Rosenzweig <[email protected]>
-rw-r--r-- | src/gallium/drivers/panfrost/pan_assemble.c | 6 | ||||
-rw-r--r-- | src/gallium/drivers/panfrost/pan_context.c | 15 | ||||
-rw-r--r-- | src/gallium/drivers/panfrost/pan_context.h | 1 | ||||
-rw-r--r-- | src/gallium/drivers/panfrost/pan_screen.c | 5 |
4 files changed, 27 insertions, 0 deletions
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 @@ -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)); 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; |