struct gl_context *ctx = &brw->ctx;
struct brw_cc_viewport *ccv;
+ /* BRW_NEW_VIEWPORT_COUNT */
+ const unsigned viewport_count = brw->clip.viewport_count;
+
ccv = brw_state_batch(brw, AUB_TRACE_CC_VP_STATE,
- sizeof(*ccv) * ctx->Const.MaxViewports, 32,
+ sizeof(*ccv) * viewport_count, 32,
&brw->cc.vp_offset);
/* _NEW_TRANSFORM */
- for (unsigned i = 0; i < ctx->Const.MaxViewports; i++) {
+ for (unsigned i = 0; i < viewport_count; i++) {
if (ctx->Transform.DepthClamp) {
/* _NEW_VIEWPORT */
ccv[i].min_depth = MIN2(ctx->ViewportArray[i].Near,
.mesa = _NEW_TRANSFORM |
_NEW_VIEWPORT,
.brw = BRW_NEW_BATCH |
- BRW_NEW_BLORP,
+ BRW_NEW_BLORP |
+ BRW_NEW_VIEWPORT_COUNT,
},
.emit = brw_upload_cc_vp
};
brw->prim_restart.enable_cut_index = false;
brw->gs.enabled = false;
brw->sf.viewport_transform_enable = true;
+ brw->clip.viewport_count = 1;
brw->predicate.state = BRW_PREDICATE_STATE_RENDER;
BRW_STATE_URB_SIZE,
BRW_STATE_CC_STATE,
BRW_STATE_BLORP,
+ BRW_STATE_VIEWPORT_COUNT,
BRW_NUM_STATE_BITS
};
#define BRW_NEW_PROGRAM_CACHE (1ull << BRW_STATE_PROGRAM_CACHE)
#define BRW_NEW_STATE_BASE_ADDRESS (1ull << BRW_STATE_STATE_BASE_ADDRESS)
#define BRW_NEW_VUE_MAP_GEOM_OUT (1ull << BRW_STATE_VUE_MAP_GEOM_OUT)
+#define BRW_NEW_VIEWPORT_COUNT (1ull << BRW_STATE_VIEWPORT_COUNT)
#define BRW_NEW_TRANSFORM_FEEDBACK (1ull << BRW_STATE_TRANSFORM_FEEDBACK)
#define BRW_NEW_RASTERIZER_DISCARD (1ull << BRW_STATE_RASTERIZER_DISCARD)
#define BRW_NEW_STATS_WM (1ull << BRW_STATE_STATS_WM)
* instead of vp_bo.
*/
uint32_t vp_offset;
+
+ /**
+ * The number of viewports to use. If gl_ViewportIndex is written,
+ * we can have up to ctx->Const.MaxViewports viewports. If not,
+ * the viewport index is always 0, so we can only emit one.
+ */
+ uint8_t viewport_count;
} clip;
if (unlikely(INTEL_DEBUG & DEBUG_STATS))
gs->thread4.stats_enable = 1;
- gs->gs6.max_vp_index = brw->ctx.Const.MaxViewports - 1;
+ /* BRW_NEW_VIEWPORT_COUNT */
+ gs->gs6.max_vp_index = brw->clip.viewport_count - 1;
brw->ctx.NewDriverState |= BRW_NEW_GEN4_UNIT_STATE;
}
BRW_NEW_CURBE_OFFSETS |
BRW_NEW_FF_GS_PROG_DATA |
BRW_NEW_PROGRAM_CACHE |
- BRW_NEW_URB_FENCE,
+ BRW_NEW_URB_FENCE |
+ BRW_NEW_VIEWPORT_COUNT,
},
.emit = brw_upload_gs_unit,
};
DEFINE_BIT(BRW_NEW_URB_SIZE),
DEFINE_BIT(BRW_NEW_CC_STATE),
DEFINE_BIT(BRW_NEW_BLORP),
+ DEFINE_BIT(BRW_NEW_VIEWPORT_COUNT),
{0, 0, 0}
};
brw_upload_programs(struct brw_context *brw,
enum brw_pipeline pipeline)
{
+ struct gl_context *ctx = &brw->ctx;
+
if (pipeline == BRW_RENDER_PIPELINE) {
brw_upload_vs_prog(brw);
brw_upload_tess_programs(brw);
old_separate != brw->vue_map_geom_out.separate)
brw->ctx.NewDriverState |= BRW_NEW_VUE_MAP_GEOM_OUT;
+ if ((old_slots ^ brw->vue_map_geom_out.slots_valid) &
+ VARYING_BIT_VIEWPORT) {
+ ctx->NewDriverState |= BRW_NEW_VIEWPORT_COUNT;
+ brw->clip.viewport_count =
+ (brw->vue_map_geom_out.slots_valid & VARYING_BIT_VIEWPORT) ?
+ ctx->Const.MaxViewports : 1;
+ }
+
if (brw->gen < 6) {
brw_setup_vue_interpolation(brw);
brw_upload_clip_prog(brw);
dw2 |= GEN6_CLIP_GB_TEST;
+ /* BRW_NEW_VIEWPORT_COUNT */
+ const unsigned viewport_count = brw->clip.viewport_count;
+
/* We need to disable guardband clipping if the guardband (which we always
* program to the maximum screen-space bounding box of 8K x 8K) will be
* smaller than the viewport.
* "objects must have a screenspace bounding box not exceeding 8K in the X
* or Y direction" restriction. Instead, they're clipped.
*/
- for (unsigned i = 0; i < ctx->Const.MaxViewports; i++) {
+ for (unsigned i = 0; i < viewport_count; i++) {
if (ctx->ViewportArray[i].Width > 8192 ||
ctx->ViewportArray[i].Height > 8192) {
dw2 &= ~GEN6_CLIP_GB_TEST;
const float fb_width = (float)_mesa_geometric_width(fb);
const float fb_height = (float)_mesa_geometric_height(fb);
- for (unsigned i = 0; i < ctx->Const.MaxViewports; i++) {
+ for (unsigned i = 0; i < viewport_count; i++) {
if (ctx->ViewportArray[i].X != 0 ||
ctx->ViewportArray[i].Y != 0 ||
ctx->ViewportArray[i].Width != fb_width ||
if (!brw_is_drawing_points(brw) && !brw_is_drawing_lines(brw))
dw2 |= GEN6_CLIP_XY_TEST;
- /* BRW_NEW_VUE_MAP_GEOM_OUT */
- const int max_vp_index =
- (brw->vue_map_geom_out.slots_valid & VARYING_BIT_VIEWPORT) != 0 ?
- ctx->Const.MaxViewports : 1;
-
BEGIN_BATCH(4);
OUT_BATCH(_3DSTATE_CLIP << 16 | (4 - 2));
OUT_BATCH(dw1);
OUT_BATCH(U_FIXED(0.125, 3) << GEN6_CLIP_MIN_POINT_WIDTH_SHIFT |
U_FIXED(255.875, 3) << GEN6_CLIP_MAX_POINT_WIDTH_SHIFT |
(_mesa_geometric_layers(fb) > 0 ? 0 : GEN6_CLIP_FORCE_ZERO_RTAINDEX) |
- ((max_vp_index - 1) & GEN6_CLIP_MAX_VP_INDEX_MASK));
+ ((viewport_count - 1) & GEN6_CLIP_MAX_VP_INDEX_MASK));
ADVANCE_BATCH();
}
BRW_NEW_PRIMITIVE |
BRW_NEW_RASTERIZER_DISCARD |
BRW_NEW_TES_PROG_DATA |
- BRW_NEW_VUE_MAP_GEOM_OUT,
+ BRW_NEW_VIEWPORT_COUNT,
},
.emit = upload_clip_state,
};
const unsigned int fb_width= _mesa_geometric_width(ctx->DrawBuffer);
const unsigned int fb_height = _mesa_geometric_height(ctx->DrawBuffer);
+ /* BRW_NEW_VIEWPORT_COUNT */
+ const unsigned viewport_count = brw->clip.viewport_count;
+
scissor = brw_state_batch(brw, AUB_TRACE_SCISSOR_STATE,
- sizeof(*scissor) * ctx->Const.MaxViewports, 32,
+ sizeof(*scissor) * viewport_count, 32,
&scissor_state_offset);
/* _NEW_SCISSOR | _NEW_BUFFERS | _NEW_VIEWPORT */
* Note that the hardware's coordinates are inclusive, while Mesa's min is
* inclusive but max is exclusive.
*/
- for (unsigned i = 0; i < ctx->Const.MaxViewports; i++) {
+ for (unsigned i = 0; i < viewport_count; i++) {
int bbox[4];
bbox[0] = MAX2(ctx->ViewportArray[i].X, 0);
_NEW_SCISSOR |
_NEW_VIEWPORT,
.brw = BRW_NEW_BATCH |
- BRW_NEW_BLORP,
+ BRW_NEW_BLORP |
+ BRW_NEW_VIEWPORT_COUNT,
},
.emit = gen6_upload_scissor_state,
};
struct gl_context *ctx = &brw->ctx;
struct brw_clipper_viewport *vp;
+ /* BRW_NEW_VIEWPORT_COUNT */
+ const unsigned viewport_count = brw->clip.viewport_count;
+
vp = brw_state_batch(brw, AUB_TRACE_CLIP_VP_STATE,
- sizeof(*vp) * ctx->Const.MaxViewports, 32, &brw->clip.vp_offset);
+ sizeof(*vp) * viewport_count, 32, &brw->clip.vp_offset);
- for (unsigned i = 0; i < ctx->Const.MaxViewports; i++) {
+ for (unsigned i = 0; i < viewport_count; i++) {
/* According to the "Vertex X,Y Clamping and Quantization" section of the
* Strips and Fans documentation, objects must not have a screen-space
* extents of over 8192 pixels, or they may be mis-rasterized. The maximum
.dirty = {
.mesa = _NEW_VIEWPORT,
.brw = BRW_NEW_BATCH |
- BRW_NEW_BLORP,
+ BRW_NEW_BLORP |
+ BRW_NEW_VIEWPORT_COUNT,
},
.emit = gen6_upload_clip_vp,
};
GLfloat y_scale, y_bias;
const bool render_to_fbo = _mesa_is_user_fbo(ctx->DrawBuffer);
+ /* BRW_NEW_VIEWPORT_COUNT */
+ const unsigned viewport_count = brw->clip.viewport_count;
+
sfv = brw_state_batch(brw, AUB_TRACE_SF_VP_STATE,
- sizeof(*sfv) * ctx->Const.MaxViewports,
+ sizeof(*sfv) * viewport_count,
32, &brw->sf.vp_offset);
- memset(sfv, 0, sizeof(*sfv) * ctx->Const.MaxViewports);
+ memset(sfv, 0, sizeof(*sfv) * viewport_count);
/* _NEW_BUFFERS */
if (render_to_fbo) {
y_bias = (float)_mesa_geometric_height(ctx->DrawBuffer);
}
- for (unsigned i = 0; i < ctx->Const.MaxViewports; i++) {
+ for (unsigned i = 0; i < viewport_count; i++) {
float scale[3], translate[3];
/* _NEW_VIEWPORT */
.mesa = _NEW_BUFFERS |
_NEW_VIEWPORT,
.brw = BRW_NEW_BATCH |
- BRW_NEW_BLORP,
+ BRW_NEW_BLORP |
+ BRW_NEW_VIEWPORT_COUNT,
},
.emit = gen6_upload_sf_vp,
};
const bool render_to_fbo = _mesa_is_user_fbo(ctx->DrawBuffer);
struct gen7_sf_clip_viewport *vp;
+ /* BRW_NEW_VIEWPORT_COUNT */
+ const unsigned viewport_count = brw->clip.viewport_count;
+
vp = brw_state_batch(brw, AUB_TRACE_SF_VP_STATE,
- sizeof(*vp) * ctx->Const.MaxViewports, 64,
+ sizeof(*vp) * viewport_count, 64,
&brw->sf.vp_offset);
/* Also assign to clip.vp_offset in case something uses it. */
brw->clip.vp_offset = brw->sf.vp_offset;
y_bias = (float)_mesa_geometric_height(ctx->DrawBuffer);
}
- for (unsigned i = 0; i < ctx->Const.MaxViewports; i++) {
+ for (unsigned i = 0; i < viewport_count; i++) {
float scale[3], translate[3];
_mesa_get_viewport_xform(ctx, i, scale, translate);
.mesa = _NEW_BUFFERS |
_NEW_VIEWPORT,
.brw = BRW_NEW_BATCH |
- BRW_NEW_BLORP,
+ BRW_NEW_BLORP |
+ BRW_NEW_VIEWPORT_COUNT,
},
.emit = gen7_upload_sf_clip_viewport,
};
const float fb_height = (float)_mesa_geometric_height(ctx->DrawBuffer);
const bool render_to_fbo = _mesa_is_user_fbo(ctx->DrawBuffer);
+ /* BRW_NEW_VIEWPORT_COUNT */
+ const unsigned viewport_count = brw->clip.viewport_count;
+
float *vp = brw_state_batch(brw, AUB_TRACE_SF_VP_STATE,
- 16 * 4 * ctx->Const.MaxViewports,
+ 16 * 4 * viewport_count,
64, &brw->sf.vp_offset);
/* Also assign to clip.vp_offset in case something uses it. */
brw->clip.vp_offset = brw->sf.vp_offset;
y_bias = fb_height;
}
- for (unsigned i = 0; i < ctx->Const.MaxViewports; i++) {
+ for (unsigned i = 0; i < viewport_count; i++) {
float scale[3], translate[3];
_mesa_get_viewport_xform(ctx, i, scale, translate);
.mesa = _NEW_BUFFERS |
_NEW_VIEWPORT,
.brw = BRW_NEW_BATCH |
- BRW_NEW_BLORP,
+ BRW_NEW_BLORP |
+ BRW_NEW_VIEWPORT_COUNT,
},
.emit = gen8_upload_sf_clip_viewport,
};