X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fgallium%2Fdrivers%2Ffreedreno%2Ffreedreno_gmem.c;h=648db9baee5f6b180b5dc9455ba0bd2142a14acc;hb=aab3912f21508b0681962c68fdaca1435c06b2ea;hp=7f6c8476cdb1a8614cd477686d4ff02c75449580;hpb=01b757e2b0fb97a146b0ef278b449cecab0d15e8;p=mesa.git diff --git a/src/gallium/drivers/freedreno/freedreno_gmem.c b/src/gallium/drivers/freedreno/freedreno_gmem.c index 7f6c8476cdb..648db9baee5 100644 --- a/src/gallium/drivers/freedreno/freedreno_gmem.c +++ b/src/gallium/drivers/freedreno/freedreno_gmem.c @@ -69,11 +69,39 @@ static uint32_t bin_width(struct fd_context *ctx) { - if (ctx->screen->gpu_id >= 300) + if (is_a4xx(ctx->screen)) + return 1024; + if (is_a3xx(ctx->screen)) return 992; return 512; } +static uint32_t +total_size(uint8_t cbuf_cpp[], uint8_t zsbuf_cpp[2], + uint32_t bin_w, uint32_t bin_h, struct fd_gmem_stateobj *gmem) +{ + uint32_t total = 0, i; + + for (i = 0; i < MAX_RENDER_TARGETS; i++) { + if (cbuf_cpp[i]) { + gmem->cbuf_base[i] = align(total, 0x4000); + total = gmem->cbuf_base[i] + cbuf_cpp[i] * bin_w * bin_h; + } + } + + if (zsbuf_cpp[0]) { + gmem->zsbuf_base[0] = align(total, 0x4000); + total = gmem->zsbuf_base[0] + zsbuf_cpp[0] * bin_w * bin_h; + } + + if (zsbuf_cpp[1]) { + gmem->zsbuf_base[1] = align(total, 0x4000); + total = gmem->zsbuf_base[1] + zsbuf_cpp[1] * bin_w * bin_h; + } + + return total; +} + static void calculate_tiles(struct fd_context *ctx) { @@ -85,27 +113,33 @@ calculate_tiles(struct fd_context *ctx) uint32_t nbins_x = 1, nbins_y = 1; uint32_t bin_w, bin_h; uint32_t max_width = bin_width(ctx); - uint32_t cpp = 4; + uint8_t cbuf_cpp[MAX_RENDER_TARGETS] = {0}, zsbuf_cpp[2] = {0}; uint32_t i, j, t, xoff, yoff; uint32_t tpp_x, tpp_y; bool has_zs = !!(ctx->resolve & (FD_BUFFER_DEPTH | FD_BUFFER_STENCIL)); + int tile_n[ARRAY_SIZE(ctx->pipe)]; - if (pfb->cbufs[0]) - cpp = util_format_get_blocksize(pfb->cbufs[0]->format); + if (has_zs) { + struct fd_resource *rsc = fd_resource(pfb->zsbuf->texture); + zsbuf_cpp[0] = rsc->cpp; + if (rsc->stencil) + zsbuf_cpp[1] = rsc->stencil->cpp; + } + for (i = 0; i < pfb->nr_cbufs; i++) { + if (pfb->cbufs[i]) + cbuf_cpp[i] = util_format_get_blocksize(pfb->cbufs[i]->format); + else + cbuf_cpp[i] = 4; + } - if ((gmem->cpp == cpp) && (gmem->has_zs == has_zs) && - !memcmp(&gmem->scissor, scissor, sizeof(gmem->scissor))) { + if (!memcmp(gmem->zsbuf_cpp, zsbuf_cpp, sizeof(zsbuf_cpp)) && + !memcmp(gmem->cbuf_cpp, cbuf_cpp, sizeof(cbuf_cpp)) && + !memcmp(&gmem->scissor, scissor, sizeof(gmem->scissor))) { /* everything is up-to-date */ return; } - /* if have depth/stencil, we need to leave room: */ - if (has_zs) { - gmem_size /= 2; - max_width /= 2; - } - - if (fd_mesa_debug & FD_DBG_DSCIS) { + if (fd_mesa_debug & FD_DBG_NOSCIS) { minx = 0; miny = 0; width = pfb->width; @@ -128,10 +162,18 @@ calculate_tiles(struct fd_context *ctx) bin_w = align(width / nbins_x, 32); } + if (fd_mesa_debug & FD_DBG_MSGS) { + debug_printf("binning input: cbuf cpp:"); + for (i = 0; i < pfb->nr_cbufs; i++) + debug_printf(" %d", cbuf_cpp[i]); + debug_printf(", zsbuf cpp: %d; %dx%d\n", + zsbuf_cpp[0], width, height); + } + /* then find a bin width/height that satisfies the memory * constraints: */ - while ((bin_w * bin_h * cpp) > gmem_size) { + while (total_size(cbuf_cpp, zsbuf_cpp, bin_w, bin_h, gmem) > gmem_size) { if (bin_w > bin_h) { nbins_x++; bin_w = align(width / nbins_x, 32); @@ -144,8 +186,8 @@ calculate_tiles(struct fd_context *ctx) DBG("using %d bins of size %dx%d", nbins_x*nbins_y, bin_w, bin_h); gmem->scissor = *scissor; - gmem->cpp = cpp; - gmem->has_zs = has_zs; + memcpy(gmem->cbuf_cpp, cbuf_cpp, sizeof(cbuf_cpp)); + memcpy(gmem->zsbuf_cpp, zsbuf_cpp, sizeof(zsbuf_cpp)); gmem->bin_h = bin_h; gmem->bin_w = bin_w; gmem->nbins_x = nbins_x; @@ -211,6 +253,7 @@ calculate_tiles(struct fd_context *ctx) /* configure tiles: */ t = 0; yoff = miny; + memset(tile_n, 0, sizeof(tile_n)); for (i = 0; i < nbins_y; i++) { uint32_t bw, bh; @@ -221,20 +264,17 @@ calculate_tiles(struct fd_context *ctx) for (j = 0; j < nbins_x; j++) { struct fd_tile *tile = &ctx->tile[t]; - uint32_t n, p; + uint32_t p; assert(t < ARRAY_SIZE(ctx->tile)); /* pipe number: */ p = ((i / tpp_y) * div_round_up(nbins_x, tpp_x)) + (j / tpp_x); - /* slot number: */ - n = ((i % tpp_y) * tpp_x) + (j % tpp_x); - /* clip bin width: */ bw = MIN2(bin_w, minx + width - xoff); - tile->n = n; + tile->n = tile_n[p]++; tile->p = p; tile->bin_w = bw; tile->bin_h = bh; @@ -317,14 +357,13 @@ void fd_gmem_render_tiles(struct fd_context *ctx) { struct pipe_framebuffer_state *pfb = &ctx->framebuffer; - uint32_t timestamp = 0; bool sysmem = false; if (ctx->emit_sysmem_prep) { if (ctx->cleared || ctx->gmem_reason || (ctx->num_draws > 5)) { DBG("GMEM: cleared=%x, gmem_reason=%x, num_draws=%u", ctx->cleared, ctx->gmem_reason, ctx->num_draws); - } else if (!(fd_mesa_debug & FD_DBG_DBYPASS)) { + } else if (!(fd_mesa_debug & FD_DBG_NOBYPASS)) { sysmem = true; } } @@ -369,13 +408,6 @@ fd_gmem_render_tiles(struct fd_context *ctx) fd_reset_wfi(ctx); - /* update timestamps on render targets: */ - timestamp = fd_ringbuffer_timestamp(ctx->ring); - if (pfb->cbufs[0]) - fd_resource(pfb->cbufs[0]->texture)->timestamp = timestamp; - if (pfb->zsbuf) - fd_resource(pfb->zsbuf->texture)->timestamp = timestamp; - /* reset maximal bounds: */ ctx->max_scissor.minx = ctx->max_scissor.miny = ~0; ctx->max_scissor.maxx = ctx->max_scissor.maxy = 0;