<div dir="ltr"><div>Pushed, thanks!</div><div><br></div><div>Marek<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Feb 12, 2019 at 2:55 PM Oscar Blumberg <<a href="mailto:carnaval@12-10e.me">carnaval@12-10e.me</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Stop using 12.12 quantization for viewports that are not contained in<br>
the lower 4k corner of the render target as the hardware needs to keep<br>
both absolute and relative coordinates representable.<br>
---<br>
.../drivers/radeonsi/si_state_viewport.c | 30 +++++++++++++++++--<br>
1 file changed, 28 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/src/gallium/drivers/radeonsi/si_state_viewport.c b/src/gallium/drivers/radeonsi/si_state_viewport.c<br>
index dac90df1c4f..64bb956b200 100644<br>
--- a/src/gallium/drivers/radeonsi/si_state_viewport.c<br>
+++ b/src/gallium/drivers/radeonsi/si_state_viewport.c<br>
@@ -185,6 +185,16 @@ static void si_emit_guardband(struct si_context *ctx)<br>
const unsigned hw_screen_offset_alignment =<br>
ctx->chip_class >= VI ? 16 : MAX2(ctx->screen->se_tile_repeat, 16);<br>
<br>
+ /* Indexed by quantization modes */<br>
+ static unsigned max_viewport_size[] = {65535, 16383, 4095};<br>
+<br>
+ /* Ensure that the whole viewport stays representable in<br>
+ * absolute coordinates.<br>
+ * See comment in si_set_viewport_states.<br>
+ */<br>
+ assert(vp_as_scissor.maxx <= max_viewport_size[vp_as_scissor.quant_mode] &&<br>
+ vp_as_scissor.maxy <= max_viewport_size[vp_as_scissor.quant_mode]);<br>
+<br>
hw_screen_offset_x = CLAMP(hw_screen_offset_x, 0, MAX_PA_SU_HARDWARE_SCREEN_OFFSET);<br>
hw_screen_offset_y = CLAMP(hw_screen_offset_y, 0, MAX_PA_SU_HARDWARE_SCREEN_OFFSET);<br>
<br>
@@ -219,7 +229,6 @@ static void si_emit_guardband(struct si_context *ctx)<br>
*<br>
* The viewport range is [-max_viewport_size/2, max_viewport_size/2].<br>
*/<br>
- static unsigned max_viewport_size[] = {65535, 16383, 4095};<br>
assert(vp_as_scissor.quant_mode < ARRAY_SIZE(max_viewport_size));<br>
max_range = max_viewport_size[vp_as_scissor.quant_mode] / 2;<br>
left = (-max_range - vp.translate[0]) / vp.scale[0];<br>
@@ -333,6 +342,8 @@ static void si_set_viewport_states(struct pipe_context *pctx,<br>
unsigned h = scissor->maxy - scissor->miny;<br>
unsigned max_extent = MAX2(w, h);<br>
<br>
+ int max_corner = MAX2(scissor->maxx, scissor->maxy);<br>
+<br>
unsigned center_x = (scissor->maxx + scissor->minx) / 2;<br>
unsigned center_y = (scissor->maxy + scissor->miny) / 2;<br>
unsigned max_center = MAX2(center_x, center_y);<br>
@@ -358,7 +369,22 @@ static void si_set_viewport_states(struct pipe_context *pctx,<br>
if (ctx->family == CHIP_RAVEN)<br>
max_extent = 16384; /* Use QUANT_MODE == 16_8. */<br>
<br>
- if (max_extent <= 1024) /* 4K scanline area for guardband */<br>
+ /* Another constraint is that all coordinates in the viewport<br>
+ * are representable in fixed point with respect to the<br>
+ * surface origin.<br>
+ *<br>
+ * It means that PA_SU_HARDWARE_SCREEN_OFFSET can't be given<br>
+ * an offset that would make the upper corner of the viewport<br>
+ * greater than the maximum representable number post<br>
+ * quantization, ie 2^quant_bits.<br>
+ *<br>
+ * This does not matter for 14.10 and 16.8 formats since the<br>
+ * offset is already limited at 8k, but it means we can't use<br>
+ * 12.12 if we are drawing to some pixels outside the lower<br>
+ * 4k x 4k of the render target.<br>
+ */<br>
+<br>
+ if (max_extent <= 1024 && max_corner < 4096) /* 4K scanline area for guardband */<br>
scissor->quant_mode = SI_QUANT_MODE_12_12_FIXED_POINT_1_4096TH;<br>
else if (max_extent <= 4096) /* 16K scanline area for guardband */<br>
scissor->quant_mode = SI_QUANT_MODE_14_10_FIXED_POINT_1_1024TH;<br>
-- <br>
2.20.1<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a></blockquote></div>