<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Fri, Jan 11, 2019 at 6:53 PM Marek Olšák <<a href="mailto:maraeo@gmail.com">maraeo@gmail.com</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">From: Marek Olšák <<a href="mailto:marek.olsak@amd.com" target="_blank">marek.olsak@amd.com</a>><br>
<br>
This fixes an assertion failure with GLCTX when cts-runner is used.<br>
(not a specific test)<br>
<br>
Bugzilla: <a href="https://bugs.freedesktop.org/show_bug.cgi?id=108877" rel="noreferrer" target="_blank">https://bugs.freedesktop.org/show_bug.cgi?id=108877</a><br>
Cc: 18.3 <<a href="mailto:mesa-stable@lists.freedesktop.org" target="_blank">mesa-stable@lists.freedesktop.org</a>><br>
---<br>
.../drivers/radeonsi/si_state_viewport.c | 21 ++++++++++++++++---<br>
1 file changed, 18 insertions(+), 3 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 76c56447eb0..b8b6198610c 100644<br>
--- a/src/gallium/drivers/radeonsi/si_state_viewport.c<br>
+++ b/src/gallium/drivers/radeonsi/si_state_viewport.c<br>
@@ -139,20 +139,22 @@ static void si_emit_one_scissor(struct si_context *ctx,<br>
return;<br>
}<br>
<br>
radeon_emit(cs, S_028250_TL_X(final.minx) |<br>
S_028250_TL_Y(final.miny) |<br>
S_028250_WINDOW_OFFSET_DISABLE(1));<br>
radeon_emit(cs, S_028254_BR_X(final.maxx) |<br>
S_028254_BR_Y(final.maxy));<br>
}<br>
<br>
+#define MAX_PA_SU_HARDWARE_SCREEN_OFFSET 8176<br>
+<br>
static void si_emit_guardband(struct si_context *ctx)<br>
{<br>
const struct si_state_rasterizer *rs = ctx->queued.named.rasterizer;<br>
struct si_signed_scissor vp_as_scissor;<br>
struct pipe_viewport_state vp;<br>
float left, top, right, bottom, max_range, guardband_x, guardband_y;<br>
float discard_x, discard_y;<br>
<br>
if (ctx->vs_writes_viewport_index) {<br>
/* Shaders can draw to any viewport. Make a union of all<br>
@@ -172,27 +174,26 @@ static void si_emit_guardband(struct si_context *ctx)<br>
*/<br>
if (ctx->vs_disables_clipping_viewport)<br>
vp_as_scissor.quant_mode = SI_QUANT_MODE_16_8_FIXED_POINT_1_256TH;<br>
<br>
/* Determine the optimal hardware screen offset to center the viewport<br>
* within the viewport range in order to maximize the guardband size.<br>
*/<br>
int hw_screen_offset_x = (vp_as_scissor.maxx + vp_as_scissor.minx) / 2;<br>
int hw_screen_offset_y = (vp_as_scissor.maxy + vp_as_scissor.miny) / 2;<br>
<br>
- const unsigned hw_screen_offset_max = 8176;<br>
/* SI-CI need to align the offset to an ubertile consisting of all SEs. */<br>
const unsigned hw_screen_offset_alignment =<br>
ctx->chip_class >= VI ? 16 : MAX2(ctx->screen->se_tile_repeat, 16);<br>
<br>
- hw_screen_offset_x = CLAMP(hw_screen_offset_x, 0, hw_screen_offset_max);<br>
- hw_screen_offset_y = CLAMP(hw_screen_offset_y, 0, hw_screen_offset_max);<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>
/* Align the screen offset by dropping the low bits. */<br>
hw_screen_offset_x &= ~(hw_screen_offset_alignment - 1);<br>
hw_screen_offset_y &= ~(hw_screen_offset_alignment - 1);<br>
<br>
/* Apply the offset to center the viewport and maximize the guardband. */<br>
vp_as_scissor.minx -= hw_screen_offset_x;<br>
vp_as_scissor.maxx -= hw_screen_offset_x;<br>
vp_as_scissor.miny -= hw_screen_offset_y;<br>
vp_as_scissor.maxy -= hw_screen_offset_y;<br>
@@ -325,20 +326,34 @@ static void si_set_viewport_states(struct pipe_context *pctx,<br>
struct si_signed_scissor *scissor = &ctx->viewports.as_scissor[index];<br>
<br>
ctx->viewports.states[index] = state[i];<br>
<br>
si_get_scissor_from_viewport(ctx, &state[i], scissor);<br>
<br>
unsigned w = scissor->maxx - scissor->minx;<br>
unsigned h = scissor->maxy - scissor->miny;<br>
unsigned max_extent = MAX2(w, h);<br>
<br>
+ unsigned center_x = scissor->maxx + scissor->minx;<br>
+ unsigned center_y = scissor->maxy + scissor->miny;<br></blockquote><div><br></div><div>These two should be divided by 2. Fixed locally.</div><div><br></div><div>Marek<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+ unsigned max_center = MAX2(center_x, center_y);<br>
+<br>
+ /* PA_SU_HARDWARE_SCREEN_OFFSET can't center viewports whose<br>
+ * center start farther than MAX_PA_SU_HARDWARE_SCREEN_OFFSET.<br>
+ * (for example, a 1x1 viewport in the lower right corner of<br>
+ * 16Kx16K) Such viewports need a greater guardband, so they<br>
+ * have to use a worse quantization mode.<br>
+ */<br>
+ unsigned distance_off_center =<br>
+ MAX2(0, (int)max_center - MAX_PA_SU_HARDWARE_SCREEN_OFFSET);<br>
+ max_extent += distance_off_center;<br>
+<br>
/* Determine the best quantization mode (subpixel precision),<br>
* but also leave enough space for the guardband.<br>
*<br>
* Note that primitive binning requires QUANT_MODE == 16_8 on Vega10<br>
* and Raven1. What we do depends on the chip:<br>
* - Vega10: Never use primitive binning.<br>
* - Raven1: Always use QUANT_MODE == 16_8.<br>
*/<br>
if (ctx->family == CHIP_RAVEN)<br>
max_extent = 16384; /* Use QUANT_MODE == 16_8. */<br>
-- <br>
2.17.1<br>
<br>
</blockquote></div></div>