#include "main/stencil.h"
#include "intel_batchbuffer.h"
-static void
-brw_upload_cc_vp(struct brw_context *brw)
-{
- 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, sizeof(*ccv) * viewport_count, 32,
- &brw->cc.vp_offset);
-
- /* _NEW_TRANSFORM */
- for (unsigned i = 0; i < viewport_count; i++) {
- if (ctx->Transform.DepthClamp) {
- /* _NEW_VIEWPORT */
- ccv[i].min_depth = MIN2(ctx->ViewportArray[i].Near,
- ctx->ViewportArray[i].Far);
- ccv[i].max_depth = MAX2(ctx->ViewportArray[i].Near,
- ctx->ViewportArray[i].Far);
- } else {
- ccv[i].min_depth = 0.0;
- ccv[i].max_depth = 1.0;
- }
- }
-
- if (brw->gen >= 7) {
- BEGIN_BATCH(2);
- OUT_BATCH(_3DSTATE_VIEWPORT_STATE_POINTERS_CC << 16 | (2 - 2));
- OUT_BATCH(brw->cc.vp_offset);
- ADVANCE_BATCH();
- } else {
- brw->ctx.NewDriverState |= BRW_NEW_CC_VP;
- }
-}
-
-const struct brw_tracked_state brw_cc_vp = {
- .dirty = {
- .mesa = _NEW_TRANSFORM |
- _NEW_VIEWPORT,
- .brw = BRW_NEW_BATCH |
- BRW_NEW_BLORP |
- BRW_NEW_VIEWPORT_COUNT,
- },
- .emit = brw_upload_cc_vp
-};
-
/**
* Modify blend function to force destination alpha to 1.0
*
/* ---------------------------------------------------------------------- */
+static void
+genX(upload_cc_viewport)(struct brw_context *brw)
+{
+ struct gl_context *ctx = &brw->ctx;
+
+ /* BRW_NEW_VIEWPORT_COUNT */
+ const unsigned viewport_count = brw->clip.viewport_count;
+
+ struct GENX(CC_VIEWPORT) ccv;
+ uint32_t cc_vp_offset;
+ uint32_t *cc_map =
+ brw_state_batch(brw, 4 * GENX(CC_VIEWPORT_length) * viewport_count,
+ 32, &cc_vp_offset);
+
+ for (unsigned i = 0; i < viewport_count; i++) {
+ /* _NEW_VIEWPORT | _NEW_TRANSFORM */
+ const struct gl_viewport_attrib *vp = &ctx->ViewportArray[i];
+ if (ctx->Transform.DepthClamp) {
+ ccv.MinimumDepth = MIN2(vp->Near, vp->Far);
+ ccv.MaximumDepth = MAX2(vp->Near, vp->Far);
+ } else {
+ ccv.MinimumDepth = 0.0;
+ ccv.MaximumDepth = 1.0;
+ }
+ GENX(CC_VIEWPORT_pack)(NULL, cc_map, &ccv);
+ cc_map += GENX(CC_VIEWPORT_length);
+ }
+
+#if GEN_GEN >= 7
+ brw_batch_emit(brw, GENX(3DSTATE_VIEWPORT_STATE_POINTERS_CC), ptr) {
+ ptr.CCViewportPointer = cc_vp_offset;
+ }
+#else
+ brw->cc.vp_offset = cc_vp_offset;
+ ctx->NewDriverState |= BRW_NEW_CC_VP;
+#endif
+}
+
+const struct brw_tracked_state genX(cc_vp) = {
+ .dirty = {
+ .mesa = _NEW_TRANSFORM |
+ _NEW_VIEWPORT,
+ .brw = BRW_NEW_BATCH |
+ BRW_NEW_BLORP |
+ BRW_NEW_VIEWPORT_COUNT,
+ },
+ .emit = genX(upload_cc_viewport)
+};
+
+/* ---------------------------------------------------------------------- */
+
#if GEN_GEN >= 6
static void
brw_calculate_guardband_size(const struct gen_device_info *devinfo,
&brw_curbe_offsets,
&brw_recalculate_urb_fence,
- &brw_cc_vp,
+ &genX(cc_vp),
&brw_cc_unit,
/* Surface state setup. Must come before the VS/WM unit. The binding
/* Command packets: */
- &brw_cc_vp,
+ &genX(cc_vp),
&genX(viewport_state), /* must do after *_vp stages */
&gen6_urb,
{
/* Command packets: */
- &brw_cc_vp,
+ &genX(cc_vp),
&genX(sf_clip_viewport),
&gen7_l3_state,
#elif GEN_GEN >= 8
static const struct brw_tracked_state *render_atoms[] =
{
- &brw_cc_vp,
+ &genX(cc_vp),
&genX(sf_clip_viewport),
&gen7_l3_state,