From f92877b7b8e03a352a2cb9c397c9e626cde76993 Mon Sep 17 00:00:00 2001 From: Rob Clark Date: Sat, 31 Jul 2021 11:27:04 -0700 Subject: [PATCH] freedreno: Reduce use of screen->gpu_id Newer GPU's are moving away from using gpu_id, including the code landing upstream for "7c Gen 3". But most of the places in the gallium driver where we were looking at gpu_id, we only cared about the major generation. So convert those to use screen->gen instead. Signed-off-by: Rob Clark Part-of: --- src/gallium/drivers/freedreno/freedreno_batch.c | 6 +++--- src/gallium/drivers/freedreno/freedreno_context.c | 2 +- src/gallium/drivers/freedreno/freedreno_draw.c | 2 +- src/gallium/drivers/freedreno/freedreno_program.c | 12 ++++++------ src/gallium/drivers/freedreno/freedreno_resource.c | 4 ++-- src/gallium/drivers/freedreno/freedreno_screen.c | 5 +++-- src/gallium/drivers/freedreno/freedreno_screen.h | 11 ++++++----- src/gallium/drivers/freedreno/freedreno_state.c | 6 +++--- src/gallium/drivers/freedreno/ir3/ir3_const.h | 2 +- 9 files changed, 26 insertions(+), 24 deletions(-) diff --git a/src/gallium/drivers/freedreno/freedreno_batch.c b/src/gallium/drivers/freedreno/freedreno_batch.c index eb206af..5a089bc 100644 --- a/src/gallium/drivers/freedreno/freedreno_batch.c +++ b/src/gallium/drivers/freedreno/freedreno_batch.c @@ -71,7 +71,7 @@ batch_init(struct fd_batch *batch) batch->draw = alloc_ring(batch, 0x100000, 0); /* a6xx+ re-uses draw rb for both draw and binning pass: */ - if (ctx->screen->gpu_id < 600) { + if (ctx->screen->gen < 6) { batch->binning = alloc_ring(batch, 0x100000, 0); } } @@ -83,7 +83,7 @@ batch_init(struct fd_batch *batch) * by always creating a fence to request that the submit is flushed * immediately: */ - if (ctx->screen->gpu_id < 600) + if (ctx->screen->gen < 6) batch->fence = fd_fence_create(batch); batch->cleared = 0; @@ -551,7 +551,7 @@ void fd_wfi(struct fd_batch *batch, struct fd_ringbuffer *ring) { if (batch->needs_wfi) { - if (batch->ctx->screen->gpu_id >= 500) + if (batch->ctx->screen->gen >= 5) OUT_WFI5(ring); else OUT_WFI(ring); diff --git a/src/gallium/drivers/freedreno/freedreno_context.c b/src/gallium/drivers/freedreno/freedreno_context.c index 79a2299..e40736c 100644 --- a/src/gallium/drivers/freedreno/freedreno_context.c +++ b/src/gallium/drivers/freedreno/freedreno_context.c @@ -244,7 +244,7 @@ fd_emit_string_marker(struct pipe_context *pctx, const char *string, fd_batch_needs_flush(batch); - if (ctx->screen->gpu_id >= 500) { + if (ctx->screen->gen >= 5) { fd_emit_string5(batch->draw, string, len); } else { fd_emit_string(batch->draw, string, len); diff --git a/src/gallium/drivers/freedreno/freedreno_draw.c b/src/gallium/drivers/freedreno/freedreno_draw.c index e22da55..88b4ce2 100644 --- a/src/gallium/drivers/freedreno/freedreno_draw.c +++ b/src/gallium/drivers/freedreno/freedreno_draw.c @@ -231,7 +231,7 @@ update_draw_stats(struct fd_context *ctx, const struct pipe_draw_info *info, { ctx->stats.draw_calls++; - if (ctx->screen->gpu_id < 600) { + if (ctx->screen->gen < 6) { /* Counting prims in sw doesn't work for GS and tesselation. For older * gens we don't have those stages and don't have the hw counters enabled, * so keep the count accurate for non-patch geometry. diff --git a/src/gallium/drivers/freedreno/freedreno_program.c b/src/gallium/drivers/freedreno/freedreno_program.c index 85747ed..4068edb 100644 --- a/src/gallium/drivers/freedreno/freedreno_program.c +++ b/src/gallium/drivers/freedreno/freedreno_program.c @@ -198,18 +198,18 @@ fd_prog_init(struct pipe_context *pctx) ctx->solid_prog.fs = assemble_tgsi(pctx, solid_fs, true); ctx->solid_prog.vs = assemble_tgsi(pctx, solid_vs, false); - if (ctx->screen->gpu_id >= 600) { + if (ctx->screen->gen >= 6) { ctx->solid_layered_prog.fs = assemble_tgsi(pctx, solid_fs, true); ctx->solid_layered_prog.vs = util_make_layered_clear_vertex_shader(pctx); } - if (ctx->screen->gpu_id >= 500) + if (ctx->screen->gen >= 5) return; ctx->blit_prog[0].vs = fd_prog_blit_vs(pctx); ctx->blit_prog[0].fs = fd_prog_blit_fs(pctx, 1, false); - if (ctx->screen->gpu_id < 300) + if (ctx->screen->gen < 3) return; for (i = 1; i < ctx->screen->max_rts; i++) { @@ -232,18 +232,18 @@ fd_prog_fini(struct pipe_context *pctx) pctx->delete_vs_state(pctx, ctx->solid_prog.vs); pctx->delete_fs_state(pctx, ctx->solid_prog.fs); - if (ctx->screen->gpu_id >= 600) { + if (ctx->screen->gen >= 6) { pctx->delete_vs_state(pctx, ctx->solid_layered_prog.vs); pctx->delete_fs_state(pctx, ctx->solid_layered_prog.fs); } - if (ctx->screen->gpu_id >= 500) + if (ctx->screen->gen >= 5) return; pctx->delete_vs_state(pctx, ctx->blit_prog[0].vs); pctx->delete_fs_state(pctx, ctx->blit_prog[0].fs); - if (ctx->screen->gpu_id < 300) + if (ctx->screen->gen < 3) return; for (i = 1; i < ctx->screen->max_rts; i++) diff --git a/src/gallium/drivers/freedreno/freedreno_resource.c b/src/gallium/drivers/freedreno/freedreno_resource.c index bf2f351..eec22c7 100644 --- a/src/gallium/drivers/freedreno/freedreno_resource.c +++ b/src/gallium/drivers/freedreno/freedreno_resource.c @@ -580,7 +580,7 @@ fd_alloc_staging(struct fd_context *ctx, struct fd_resource *rsc, /* We cannot currently do stencil export on earlier gens, and * u_blitter cannot do blits involving stencil otherwise: */ - if ((ctx->screen->gpu_id < 600) && !ctx->blit && + if ((ctx->screen->gen < 6) && !ctx->blit && (util_format_get_mask(tmpl.format) & PIPE_MASK_S)) return NULL; @@ -1565,7 +1565,7 @@ void fd_resource_screen_init(struct pipe_screen *pscreen) { struct fd_screen *screen = fd_screen(pscreen); - bool fake_rgtc = screen->gpu_id < 400; + bool fake_rgtc = screen->gen < 4; pscreen->resource_create = u_transfer_helper_resource_create; /* NOTE: u_transfer_helper does not yet support the _with_modifiers() diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c b/src/gallium/drivers/freedreno/freedreno_screen.c index 566b79a..00fd10b 100644 --- a/src/gallium/drivers/freedreno/freedreno_screen.c +++ b/src/gallium/drivers/freedreno/freedreno_screen.c @@ -995,6 +995,7 @@ fd_screen_create(struct fd_device *dev, struct renderonly *ro, ((core & 0xff) << 24); } screen->chip_id = val; + screen->gen = screen->chip_id >> 24; if (fd_pipe_get_param(screen->pipe, FD_NR_RINGS, &val)) { DBG("could not get # of rings"); @@ -1039,7 +1040,7 @@ fd_screen_create(struct fd_device *dev, struct renderonly *ro, * of the cases below and see what happens. And if it works, please * send a patch ;-) */ - switch (screen->gpu_id / 100) { + switch (screen->gen) { case 2: fd2_screen_init(pscreen); break; @@ -1056,7 +1057,7 @@ fd_screen_create(struct fd_device *dev, struct renderonly *ro, fd6_screen_init(pscreen); break; default: - mesa_loge("unsupported GPU: a%03d", screen->gpu_id); + mesa_loge("unsupported GPU generation: a%uxx", screen->gen); goto fail; } diff --git a/src/gallium/drivers/freedreno/freedreno_screen.h b/src/gallium/drivers/freedreno/freedreno_screen.h index c1041ae..d024ae9 100644 --- a/src/gallium/drivers/freedreno/freedreno_screen.h +++ b/src/gallium/drivers/freedreno/freedreno_screen.h @@ -81,6 +81,7 @@ struct fd_screen { uint64_t gmem_base; uint32_t gmemsize_bytes; + uint8_t gen; /* GPU (major) generation */ uint32_t gpu_id; /* 220, 305, etc */ uint32_t chip_id; /* coreid:8 majorrev:8 minorrev:8 patch:8 */ uint32_t max_freq; @@ -191,7 +192,7 @@ is_a20x(struct fd_screen *screen) static inline boolean is_a2xx(struct fd_screen *screen) { - return (screen->gpu_id >= 200) && (screen->gpu_id < 300); + return screen->gen == 2; } /* is a3xx patch revision 0? */ @@ -205,25 +206,25 @@ is_a3xx_p0(struct fd_screen *screen) static inline boolean is_a3xx(struct fd_screen *screen) { - return (screen->gpu_id >= 300) && (screen->gpu_id < 400); + return screen->gen == 3; } static inline boolean is_a4xx(struct fd_screen *screen) { - return (screen->gpu_id >= 400) && (screen->gpu_id < 500); + return screen->gen == 4; } static inline boolean is_a5xx(struct fd_screen *screen) { - return (screen->gpu_id >= 500) && (screen->gpu_id < 600); + return screen->gen == 5; } static inline boolean is_a6xx(struct fd_screen *screen) { - return (screen->gpu_id >= 600) && (screen->gpu_id < 700); + return screen->gen == 6; } /* is it using the ir3 compiler (shader isa introduced with a3xx)? */ diff --git a/src/gallium/drivers/freedreno/freedreno_state.c b/src/gallium/drivers/freedreno/freedreno_state.c index 46e8a7c..5d5b942 100644 --- a/src/gallium/drivers/freedreno/freedreno_state.c +++ b/src/gallium/drivers/freedreno/freedreno_state.c @@ -352,7 +352,7 @@ fd_set_viewport_states(struct pipe_context *pctx, unsigned start_slot, swap(miny, maxy); } - const float max_dims = ctx->screen->gpu_id >= 400 ? 16384.f : 4096.f; + const float max_dims = ctx->screen->gen >= 4 ? 16384.f : 4096.f; /* Clamp, convert to integer and round up the max bounds. */ scissor->minx = CLAMP(minx, 0.f, max_dims); @@ -377,7 +377,7 @@ fd_set_vertex_buffers(struct pipe_context *pctx, unsigned start_slot, * we need to mark VTXSTATE as dirty as well to trigger patching * and re-emitting the vtx shader: */ - if (ctx->screen->gpu_id < 300) { + if (ctx->screen->gen < 3) { for (i = 0; i < count; i++) { bool new_enabled = vb && vb[i].buffer.resource; bool old_enabled = so->vb[i].buffer.resource != NULL; @@ -560,7 +560,7 @@ fd_set_stream_output_targets(struct pipe_context *pctx, unsigned num_targets, debug_assert(num_targets <= ARRAY_SIZE(so->targets)); /* Older targets need sw stats enabled for streamout emulation in VS: */ - if (ctx->screen->gpu_id < 500) { + if (ctx->screen->gen < 5) { if (num_targets && !so->num_targets) { ctx->stats_users++; } else if (so->num_targets && !num_targets) { diff --git a/src/gallium/drivers/freedreno/ir3/ir3_const.h b/src/gallium/drivers/freedreno/ir3/ir3_const.h index bdef67d..247167a 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_const.h +++ b/src/gallium/drivers/freedreno/ir3/ir3_const.h @@ -210,7 +210,7 @@ ir3_emit_ubos(struct fd_context *ctx, const struct ir3_shader_variant *v, /* a6xx+ uses UBO state and ldc instead of pointers emitted in * const state and ldg: */ - if (ctx->screen->gpu_id >= 600) + if (ctx->screen->gen >= 6) return; if (v->constlen > offset) { -- 2.7.4