From 832de34b27d8e38c2011c6d2877e17d83893d46d Mon Sep 17 00:00:00 2001 From: Jonathan Gray Date: Tue, 19 Feb 2019 03:50:58 +0000 Subject: Import Mesa 18.3.4 --- lib/mesa/src/gallium/drivers/radeonsi/si_buffer.c | 7 ++- .../gallium/drivers/radeonsi/si_state_viewport.c | 51 +++++++++++++++++++--- 2 files changed, 51 insertions(+), 7 deletions(-) (limited to 'lib/mesa') diff --git a/lib/mesa/src/gallium/drivers/radeonsi/si_buffer.c b/lib/mesa/src/gallium/drivers/radeonsi/si_buffer.c index c7260e06c..f460cf07b 100644 --- a/lib/mesa/src/gallium/drivers/radeonsi/si_buffer.c +++ b/lib/mesa/src/gallium/drivers/radeonsi/si_buffer.c @@ -521,10 +521,13 @@ static void si_buffer_do_flush_region(struct pipe_context *ctx, struct r600_resource *rbuffer = r600_resource(transfer->resource); if (stransfer->staging) { + unsigned src_offset = stransfer->offset + + transfer->box.x % SI_MAP_BUFFER_ALIGNMENT + + (box->x - transfer->box.x); + /* Copy the staging buffer into the original one. */ si_copy_buffer((struct si_context*)ctx, transfer->resource, - &stransfer->staging->b.b, box->x, - stransfer->offset + box->x % SI_MAP_BUFFER_ALIGNMENT, + &stransfer->staging->b.b, box->x, src_offset, box->width); } diff --git a/lib/mesa/src/gallium/drivers/radeonsi/si_state_viewport.c b/lib/mesa/src/gallium/drivers/radeonsi/si_state_viewport.c index 76c56447e..64bb956b2 100644 --- a/lib/mesa/src/gallium/drivers/radeonsi/si_state_viewport.c +++ b/lib/mesa/src/gallium/drivers/radeonsi/si_state_viewport.c @@ -146,6 +146,8 @@ static void si_emit_one_scissor(struct si_context *ctx, S_028254_BR_Y(final.maxy)); } +#define MAX_PA_SU_HARDWARE_SCREEN_OFFSET 8176 + static void si_emit_guardband(struct si_context *ctx) { const struct si_state_rasterizer *rs = ctx->queued.named.rasterizer; @@ -179,13 +181,22 @@ static void si_emit_guardband(struct si_context *ctx) int hw_screen_offset_x = (vp_as_scissor.maxx + vp_as_scissor.minx) / 2; int hw_screen_offset_y = (vp_as_scissor.maxy + vp_as_scissor.miny) / 2; - const unsigned hw_screen_offset_max = 8176; /* SI-CI need to align the offset to an ubertile consisting of all SEs. */ const unsigned hw_screen_offset_alignment = ctx->chip_class >= VI ? 16 : MAX2(ctx->screen->se_tile_repeat, 16); - hw_screen_offset_x = CLAMP(hw_screen_offset_x, 0, hw_screen_offset_max); - hw_screen_offset_y = CLAMP(hw_screen_offset_y, 0, hw_screen_offset_max); + /* Indexed by quantization modes */ + static unsigned max_viewport_size[] = {65535, 16383, 4095}; + + /* Ensure that the whole viewport stays representable in + * absolute coordinates. + * See comment in si_set_viewport_states. + */ + assert(vp_as_scissor.maxx <= max_viewport_size[vp_as_scissor.quant_mode] && + vp_as_scissor.maxy <= max_viewport_size[vp_as_scissor.quant_mode]); + + hw_screen_offset_x = CLAMP(hw_screen_offset_x, 0, MAX_PA_SU_HARDWARE_SCREEN_OFFSET); + hw_screen_offset_y = CLAMP(hw_screen_offset_y, 0, MAX_PA_SU_HARDWARE_SCREEN_OFFSET); /* Align the screen offset by dropping the low bits. */ hw_screen_offset_x &= ~(hw_screen_offset_alignment - 1); @@ -218,7 +229,6 @@ static void si_emit_guardband(struct si_context *ctx) * * The viewport range is [-max_viewport_size/2, max_viewport_size/2]. */ - static unsigned max_viewport_size[] = {65535, 16383, 4095}; assert(vp_as_scissor.quant_mode < ARRAY_SIZE(max_viewport_size)); max_range = max_viewport_size[vp_as_scissor.quant_mode] / 2; left = (-max_range - vp.translate[0]) / vp.scale[0]; @@ -332,6 +342,22 @@ static void si_set_viewport_states(struct pipe_context *pctx, unsigned h = scissor->maxy - scissor->miny; unsigned max_extent = MAX2(w, h); + int max_corner = MAX2(scissor->maxx, scissor->maxy); + + unsigned center_x = (scissor->maxx + scissor->minx) / 2; + unsigned center_y = (scissor->maxy + scissor->miny) / 2; + unsigned max_center = MAX2(center_x, center_y); + + /* PA_SU_HARDWARE_SCREEN_OFFSET can't center viewports whose + * center start farther than MAX_PA_SU_HARDWARE_SCREEN_OFFSET. + * (for example, a 1x1 viewport in the lower right corner of + * 16Kx16K) Such viewports need a greater guardband, so they + * have to use a worse quantization mode. + */ + unsigned distance_off_center = + MAX2(0, (int)max_center - MAX_PA_SU_HARDWARE_SCREEN_OFFSET); + max_extent += distance_off_center; + /* Determine the best quantization mode (subpixel precision), * but also leave enough space for the guardband. * @@ -343,7 +369,22 @@ static void si_set_viewport_states(struct pipe_context *pctx, if (ctx->family == CHIP_RAVEN) max_extent = 16384; /* Use QUANT_MODE == 16_8. */ - if (max_extent <= 1024) /* 4K scanline area for guardband */ + /* Another constraint is that all coordinates in the viewport + * are representable in fixed point with respect to the + * surface origin. + * + * It means that PA_SU_HARDWARE_SCREEN_OFFSET can't be given + * an offset that would make the upper corner of the viewport + * greater than the maximum representable number post + * quantization, ie 2^quant_bits. + * + * This does not matter for 14.10 and 16.8 formats since the + * offset is already limited at 8k, but it means we can't use + * 12.12 if we are drawing to some pixels outside the lower + * 4k x 4k of the render target. + */ + + if (max_extent <= 1024 && max_corner < 4096) /* 4K scanline area for guardband */ scissor->quant_mode = SI_QUANT_MODE_12_12_FIXED_POINT_1_4096TH; else if (max_extent <= 4096) /* 16K scanline area for guardband */ scissor->quant_mode = SI_QUANT_MODE_14_10_FIXED_POINT_1_1024TH; -- cgit v1.2.3