#include "util/u_string.h"
#include "util/u_viewport.h"
-#include "common/freedreno_guardband.h"
#include "freedreno_query_hw.h"
#include "freedreno_resource.h"
#include "freedreno_state.h"
A6XX_GRAS_SC_VIEWPORT_SCISSOR_BR(0, .x = scissor->maxx,
.y = scissor->maxy));
- unsigned guardband_x = fd_calc_guardband(vp->translate[0],
- vp->scale[0], false);
- unsigned guardband_y = fd_calc_guardband(vp->translate[1],
- vp->scale[1], false);
-
- OUT_REG(ring, A6XX_GRAS_CL_GUARDBAND_CLIP_ADJ(.horz = guardband_x,
- .vert = guardband_y));
+ OUT_REG(ring, A6XX_GRAS_CL_GUARDBAND_CLIP_ADJ(.horz = ctx->guardband.x,
+ .vert = ctx->guardband.y));
}
/* The clamp ranges are only used when the rasterizer wants depth
struct pipe_poly_stipple stipple dt;
struct pipe_viewport_state viewport[PIPE_MAX_VIEWPORTS] dt;
struct pipe_scissor_state viewport_scissor[PIPE_MAX_VIEWPORTS] dt;
+ struct {
+ unsigned x, y;
+ } guardband dt;
struct fd_constbuf_stateobj constbuf[PIPE_SHADER_TYPES] dt;
struct fd_shaderbuf_stateobj shaderbuf[PIPE_SHADER_TYPES] dt;
struct fd_shaderimg_stateobj shaderimg[PIPE_SHADER_TYPES] dt;
#include "util/u_string.h"
#include "util/u_upload_mgr.h"
+#include "common/freedreno_guardband.h"
+
#include "freedreno_context.h"
#include "freedreno_gmem.h"
#include "freedreno_query_hw.h"
}
fd_context_dirty(ctx, FD_DIRTY_VIEWPORT);
+
+ /* Guardband is only used on a6xx so far: */
+ if (!is_a6xx(ctx->screen))
+ return;
+
+ ctx->guardband.x = ~0;
+ ctx->guardband.y = ~0;
+
+ bool is3x = is_a3xx(ctx->screen);
+
+ for (unsigned i = 0; i < PIPE_MAX_VIEWPORTS; i++) {
+ const struct pipe_viewport_state *vp = & ctx->viewport[i];
+
+ /* skip unused viewports: */
+ if (vp->scale[0] == 0)
+ continue;
+
+ unsigned gx = fd_calc_guardband(vp->translate[0], vp->scale[0], is3x);
+ unsigned gy = fd_calc_guardband(vp->translate[1], vp->scale[1], is3x);
+
+ ctx->guardband.x = MIN2(ctx->guardband.x, gx);
+ ctx->guardband.y = MIN2(ctx->guardband.y, gy);
+ }
}
static void