[Mesa-dev] [PATCH 2/5] panfrost: Specify supported draw modes per-context
Alyssa Rosenzweig
alyssa at rosenzweig.io
Sat Feb 9 01:21:42 UTC 2019
Midgard has native support for QUADS and POLYGONS; Bifrost seemingly
does not. Thus, Midgard generally skips prim_convert whereas Bifrost
needs the pass; this patch allows the setting of allowed primitives to
occur on a per-context basis (for runtime hardware selection).
Signed-off-by: Alyssa Rosenzweig <alyssa at rosenzweig.io>
---
src/gallium/drivers/panfrost/pan_context.c | 20 ++++++++------------
src/gallium/drivers/panfrost/pan_context.h | 3 +++
2 files changed, 11 insertions(+), 12 deletions(-)
diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c
index b60d67da9b4..bc92933ccda 100644
--- a/src/gallium/drivers/panfrost/pan_context.c
+++ b/src/gallium/drivers/panfrost/pan_context.c
@@ -1595,14 +1595,10 @@ panfrost_draw_vbo(
int mode = info->mode;
-#if 0
- /* Fallback for non-ES draw modes */
- /* Primconvert not needed on Midgard anymore due to native
- * QUADS/POLYGONS. Bifrost/desktop-GL may need it though so not
- * removing */
+ /* Fallback for unsupported modes */
- if (info->mode >= PIPE_PRIM_QUADS) {
- if (info->mode == PIPE_PRIM_QUADS && info->count == 4 && ctx->rasterizer && !ctx->rasterizer->base.flatshade) {
+ if (!(ctx->draw_modes & mode)) {
+ if (mode == PIPE_PRIM_QUADS && info->count == 4 && ctx->rasterizer && !ctx->rasterizer->base.flatshade) {
mode = PIPE_PRIM_TRIANGLE_FAN;
} else {
if (info->count < 4) {
@@ -1615,7 +1611,6 @@ panfrost_draw_vbo(
return;
}
}
-#endif
ctx->payload_tiler.prefix.draw_mode = g2m_draw_mode(mode);
@@ -1629,7 +1624,7 @@ panfrost_draw_vbo(
* rendering artefacts. It's not clear what these values mean yet. */
ctx->payload_tiler.prefix.unknown_draw &= ~(0x3000 | 0x18000);
- ctx->payload_tiler.prefix.unknown_draw |= (info->mode == PIPE_PRIM_POINTS || ctx->vertex_count > 65535) ? 0x3000 : 0x18000;
+ ctx->payload_tiler.prefix.unknown_draw |= (mode == PIPE_PRIM_POINTS || ctx->vertex_count > 65535) ? 0x3000 : 0x18000;
if (info->index_size) {
/* Calculate the min/max index used so we can figure out how
@@ -2671,9 +2666,10 @@ panfrost_create_context(struct pipe_screen *screen, void *priv, unsigned flags)
gallium->const_uploader = gallium->stream_uploader;
assert(gallium->stream_uploader);
- ctx->primconvert = util_primconvert_create(gallium,
- (1 << PIPE_PRIM_QUADS) - 1);
- assert(ctx->primconvert);
+ /* Midgard supports ES modes, plus QUADS/QUAD_STRIPS/POLYGON */
+ ctx->draw_modes = (1 << PIPE_PRIM_LINES_ADJACENCY) - 1;
+
+ ctx->primconvert = util_primconvert_create(gallium, ctx->draw_modes);
ctx->blitter = util_blitter_create(gallium);
assert(ctx->blitter);
diff --git a/src/gallium/drivers/panfrost/pan_context.h b/src/gallium/drivers/panfrost/pan_context.h
index bda8155aac6..89f821318e1 100644
--- a/src/gallium/drivers/panfrost/pan_context.h
+++ b/src/gallium/drivers/panfrost/pan_context.h
@@ -106,6 +106,9 @@ struct panfrost_context {
/* Gallium context */
struct pipe_context base;
+ /* Bit mask for supported PIPE_DRAW for this hardware */
+ unsigned draw_modes;
+
struct pipe_framebuffer_state pipe_framebuffer;
/* The number of concurrent FBOs allowed depends on the number of pools
--
2.20.1
More information about the mesa-dev
mailing list