i965: add support for sample mask on Gen6+
authorChris Forbes <chrisf@ijw.co.nz>
Thu, 29 Nov 2012 09:24:43 +0000 (22:24 +1300)
committerChris Forbes <chrisf@ijw.co.nz>
Fri, 1 Mar 2013 22:35:17 +0000 (11:35 +1300)
Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/mesa/drivers/dri/i965/brw_context.h
src/mesa/drivers/dri/i965/gen6_blorp.cpp
src/mesa/drivers/dri/i965/gen6_multisample_state.c
src/mesa/drivers/dri/i965/gen7_blorp.cpp

index c173e49fefd8f11df98454a12876da28b09302ca..9758cfcf112d37662f43028db7b9cb0b23a95600 100644 (file)
@@ -1229,7 +1229,7 @@ gen6_emit_3dstate_multisample(struct brw_context *brw,
 void
 gen6_emit_3dstate_sample_mask(struct brw_context *brw,
                               unsigned num_samples, float coverage,
-                              bool coverage_invert);
+                              bool coverage_invert, unsigned sample_mask);
 
 /* gen7_urb.c */
 void
index 2b6db82951d3f6549ad24a67381792d8cf2dd18c..56e8994dc2499504ea587cfbf984f46cb36e8701 100644 (file)
@@ -1041,7 +1041,7 @@ gen6_blorp_exec(struct intel_context *intel,
    uint32_t prog_offset = params->get_wm_prog(brw, &prog_data);
    gen6_blorp_emit_batch_head(brw, params);
    gen6_emit_3dstate_multisample(brw, params->num_samples);
-   gen6_emit_3dstate_sample_mask(brw, params->num_samples, 1.0, false);
+   gen6_emit_3dstate_sample_mask(brw, params->num_samples, 1.0, false, ~0u);
    gen6_blorp_emit_state_base_address(brw, params);
    gen6_blorp_emit_vertices(brw, params);
    gen6_blorp_emit_urb_config(brw, params);
index 64ac292a8087a543198df8782cc4c42c7bcb24a0..844aad17bba23ded01d912b9870c9e109665233d 100644 (file)
@@ -116,7 +116,7 @@ gen6_emit_3dstate_multisample(struct brw_context *brw,
 void
 gen6_emit_3dstate_sample_mask(struct brw_context *brw,
                               unsigned num_samples, float coverage,
-                              bool coverage_invert)
+                              bool coverage_invert, unsigned sample_mask)
 {
    struct intel_context *intel = &brw->intel;
 
@@ -127,7 +127,7 @@ gen6_emit_3dstate_sample_mask(struct brw_context *brw,
       uint32_t coverage_bits = (1 << coverage_int) - 1;
       if (coverage_invert)
          coverage_bits ^= (1 << num_samples) - 1;
-      OUT_BATCH(coverage_bits);
+      OUT_BATCH(coverage_bits & sample_mask);
    } else {
       OUT_BATCH(1);
    }
@@ -141,21 +141,28 @@ static void upload_multisample_state(struct brw_context *brw)
    struct gl_context *ctx = &intel->ctx;
    float coverage = 1.0;
    float coverage_invert = false;
+   unsigned sample_mask = ~0u;
 
    /* _NEW_BUFFERS */
    unsigned num_samples = ctx->DrawBuffer->Visual.samples;
 
    /* _NEW_MULTISAMPLE */
-   if (ctx->Multisample._Enabled && ctx->Multisample.SampleCoverage) {
-      coverage = ctx->Multisample.SampleCoverageValue;
-      coverage_invert = ctx->Multisample.SampleCoverageInvert;
+   if (ctx->Multisample._Enabled) {
+      if (ctx->Multisample.SampleCoverage) {
+         coverage = ctx->Multisample.SampleCoverageValue;
+         coverage_invert = ctx->Multisample.SampleCoverageInvert;
+      }
+      if (ctx->Multisample.SampleMask) {
+         sample_mask = ctx->Multisample.SampleMaskValue;
+      }
    }
 
    /* 3DSTATE_MULTISAMPLE is nonpipelined. */
    intel_emit_post_sync_nonzero_flush(intel);
 
    gen6_emit_3dstate_multisample(brw, num_samples);
-   gen6_emit_3dstate_sample_mask(brw, num_samples, coverage, coverage_invert);
+   gen6_emit_3dstate_sample_mask(brw, num_samples, coverage,
+         coverage_invert, sample_mask);
 }
 
 
index b6719b73ed8ea5a2c212cf755c3082eb5bf7c003..27305322b69299e0987bb90967f496241eaa577e 100644 (file)
@@ -748,7 +748,7 @@ gen7_blorp_exec(struct intel_context *intel,
    gen6_blorp_emit_batch_head(brw, params);
    gen7_allocate_push_constants(brw);
    gen6_emit_3dstate_multisample(brw, params->num_samples);
-   gen6_emit_3dstate_sample_mask(brw, params->num_samples, 1.0, false);
+   gen6_emit_3dstate_sample_mask(brw, params->num_samples, 1.0, false, ~0u);
    gen6_blorp_emit_state_base_address(brw, params);
    gen6_blorp_emit_vertices(brw, params);
    gen7_blorp_emit_urb_config(brw, params);