summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2017-05-10 20:39:26 -0700
committerKenneth Graunke <[email protected]>2017-05-29 21:46:30 -0700
commit7f4645e89cb61d856f386d148566002652d2d4fd (patch)
treed5c20d522c21268afd03a7dda1158315861697f4
parent1e3880544e8605fc0ae7afb5787dce53d9e30e87 (diff)
i965: Port CC_VIEWPORT to genxml.
Reviewed-by: Topi Pohjolainen <[email protected]>
-rw-r--r--src/mesa/drivers/dri/i965/brw_cc.c47
-rw-r--r--src/mesa/drivers/dri/i965/brw_state.h1
-rw-r--r--src/mesa/drivers/dri/i965/genX_state_upload.c59
3 files changed, 55 insertions, 52 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_cc.c b/src/mesa/drivers/dri/i965/brw_cc.c
index 62e81253cc9..78d3bc86d13 100644
--- a/src/mesa/drivers/dri/i965/brw_cc.c
+++ b/src/mesa/drivers/dri/i965/brw_cc.c
@@ -38,53 +38,6 @@
#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
*
diff --git a/src/mesa/drivers/dri/i965/brw_state.h b/src/mesa/drivers/dri/i965/brw_state.h
index 954969c4bf8..bec7b03c42f 100644
--- a/src/mesa/drivers/dri/i965/brw_state.h
+++ b/src/mesa/drivers/dri/i965/brw_state.h
@@ -42,7 +42,6 @@ extern "C" {
enum intel_msaa_layout;
extern const struct brw_tracked_state brw_blend_constant_color;
-extern const struct brw_tracked_state brw_cc_vp;
extern const struct brw_tracked_state brw_cc_unit;
extern const struct brw_tracked_state brw_clip_unit;
extern const struct brw_tracked_state brw_vs_pull_constants;
diff --git a/src/mesa/drivers/dri/i965/genX_state_upload.c b/src/mesa/drivers/dri/i965/genX_state_upload.c
index 0d02b3fb884..d13043f64d4 100644
--- a/src/mesa/drivers/dri/i965/genX_state_upload.c
+++ b/src/mesa/drivers/dri/i965/genX_state_upload.c
@@ -1896,6 +1896,57 @@ static const struct brw_tracked_state genX(vs_state) = {
/* ---------------------------------------------------------------------- */
+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,
@@ -4113,7 +4164,7 @@ genX(init_atoms)(struct brw_context *brw)
&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
@@ -4168,7 +4219,7 @@ genX(init_atoms)(struct brw_context *brw)
/* Command packets: */
- &brw_cc_vp,
+ &genX(cc_vp),
&genX(viewport_state), /* must do after *_vp stages */
&gen6_urb,
@@ -4231,7 +4282,7 @@ genX(init_atoms)(struct brw_context *brw)
{
/* Command packets: */
- &brw_cc_vp,
+ &genX(cc_vp),
&genX(sf_clip_viewport),
&gen7_l3_state,
@@ -4321,7 +4372,7 @@ genX(init_atoms)(struct brw_context *brw)
#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,