From 85e2bb58cafde2238797b98eec5f105b3a0a3c73 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Fri, 8 Feb 2019 02:28:12 +0000 Subject: [PATCH] panfrost: Specify supported draw modes per-context 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). v2: Use (POLYGONS + 1) instead of LINES_ADJACENCY. Signed-off-by: Alyssa Rosenzweig Reviewed-by: Robert Foss --- 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 f08461b03a6..565e6541b6c 100644 --- a/src/gallium/drivers/panfrost/pan_context.c +++ b/src/gallium/drivers/panfrost/pan_context.c @@ -1589,14 +1589,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) { @@ -1609,7 +1605,6 @@ panfrost_draw_vbo( return; } } -#endif ctx->payload_tiler.prefix.draw_mode = g2m_draw_mode(mode); @@ -1623,7 +1618,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 @@ -2665,9 +2660,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_POLYGON + 1)) - 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.30.2