aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2017-05-10 23:53:05 -0700
committerKenneth Graunke <[email protected]>2017-05-29 21:46:43 -0700
commit01cb6cd47303e618d22a3d00fbbad5a144064a6b (patch)
tree81659cccab50c889a40c5de23d8783c4b1617f95 /src/mesa/drivers
parent55862ed4775b24099a5f3b1978be7a552e71c439 (diff)
i965: Make a set_scissor_bits helper function.
Gen4-5 include a single SCISSOR_RECT in SF_VIEWPORT. Making a helper function will allow us to reuse this code for Gen4-5. Reviewed-by: Topi Pohjolainen <[email protected]>
Diffstat (limited to 'src/mesa/drivers')
-rw-r--r--src/mesa/drivers/dri/i965/genX_state_upload.c73
1 files changed, 40 insertions, 33 deletions
diff --git a/src/mesa/drivers/dri/i965/genX_state_upload.c b/src/mesa/drivers/dri/i965/genX_state_upload.c
index ca2b1959e29..90485613f46 100644
--- a/src/mesa/drivers/dri/i965/genX_state_upload.c
+++ b/src/mesa/drivers/dri/i965/genX_state_upload.c
@@ -1952,6 +1952,45 @@ const struct brw_tracked_state genX(cc_vp) = {
/* ---------------------------------------------------------------------- */
+static inline void
+set_scissor_bits(const struct gl_context *ctx, int i,
+ bool render_to_fbo, unsigned fb_width, unsigned fb_height,
+ struct GENX(SCISSOR_RECT) *sc)
+{
+ int bbox[4];
+
+ bbox[0] = MAX2(ctx->ViewportArray[i].X, 0);
+ bbox[1] = MIN2(bbox[0] + ctx->ViewportArray[i].Width, fb_width);
+ bbox[2] = MAX2(ctx->ViewportArray[i].Y, 0);
+ bbox[3] = MIN2(bbox[2] + ctx->ViewportArray[i].Height, fb_height);
+ _mesa_intersect_scissor_bounding_box(ctx, i, bbox);
+
+ if (bbox[0] == bbox[1] || bbox[2] == bbox[3]) {
+ /* If the scissor was out of bounds and got clamped to 0 width/height
+ * at the bounds, the subtraction of 1 from maximums could produce a
+ * negative number and thus not clip anything. Instead, just provide
+ * a min > max scissor inside the bounds, which produces the expected
+ * no rendering.
+ */
+ sc->ScissorRectangleXMin = 1;
+ sc->ScissorRectangleXMax = 0;
+ sc->ScissorRectangleYMin = 1;
+ sc->ScissorRectangleYMax = 0;
+ } else if (render_to_fbo) {
+ /* texmemory: Y=0=bottom */
+ sc->ScissorRectangleXMin = bbox[0];
+ sc->ScissorRectangleXMax = bbox[1] - 1;
+ sc->ScissorRectangleYMin = bbox[2];
+ sc->ScissorRectangleYMax = bbox[3] - 1;
+ } else {
+ /* memory: Y=0=top */
+ sc->ScissorRectangleXMin = bbox[0];
+ sc->ScissorRectangleXMax = bbox[1] - 1;
+ sc->ScissorRectangleYMin = fb_height - bbox[3];
+ sc->ScissorRectangleYMax = fb_height - bbox[2] - 1;
+ }
+}
+
#if GEN_GEN >= 6
static void
genX(upload_scissor_state)(struct brw_context *brw)
@@ -1981,39 +2020,7 @@ genX(upload_scissor_state)(struct brw_context *brw)
* inclusive but max is exclusive.
*/
for (unsigned i = 0; i < viewport_count; i++) {
- int bbox[4];
-
- bbox[0] = MAX2(ctx->ViewportArray[i].X, 0);
- bbox[1] = MIN2(bbox[0] + ctx->ViewportArray[i].Width, fb_width);
- bbox[2] = MAX2(ctx->ViewportArray[i].Y, 0);
- bbox[3] = MIN2(bbox[2] + ctx->ViewportArray[i].Height, fb_height);
- _mesa_intersect_scissor_bounding_box(ctx, i, bbox);
-
- if (bbox[0] == bbox[1] || bbox[2] == bbox[3]) {
- /* If the scissor was out of bounds and got clamped to 0 width/height
- * at the bounds, the subtraction of 1 from maximums could produce a
- * negative number and thus not clip anything. Instead, just provide
- * a min > max scissor inside the bounds, which produces the expected
- * no rendering.
- */
- scissor.ScissorRectangleXMin = 1;
- scissor.ScissorRectangleXMax = 0;
- scissor.ScissorRectangleYMin = 1;
- scissor.ScissorRectangleYMax = 0;
- } else if (render_to_fbo) {
- /* texmemory: Y=0=bottom */
- scissor.ScissorRectangleXMin = bbox[0];
- scissor.ScissorRectangleXMax = bbox[1] - 1;
- scissor.ScissorRectangleYMin = bbox[2];
- scissor.ScissorRectangleYMax = bbox[3] - 1;
- } else {
- /* memory: Y=0=top */
- scissor.ScissorRectangleXMin = bbox[0];
- scissor.ScissorRectangleXMax = bbox[1] - 1;
- scissor.ScissorRectangleYMin = fb_height - bbox[3];
- scissor.ScissorRectangleYMax = fb_height - bbox[2] - 1;
- }
-
+ set_scissor_bits(ctx, i, render_to_fbo, fb_width, fb_height, &scissor);
GENX(SCISSOR_RECT_pack)(
NULL, scissor_map + i * GENX(SCISSOR_RECT_length), &scissor);
}