i965/fs: add support for gl_SampleMaskIn[]
authorChris Forbes <chrisf@ijw.co.nz>
Sun, 8 Dec 2013 07:29:43 +0000 (20:29 +1300)
committerChris Forbes <chrisf@ijw.co.nz>
Sat, 14 Dec 2013 03:28:11 +0000 (16:28 +1300)
v2: - add assert so we don't run into trouble on Gen6.
    - adjust for Tapani's rearrangement of ir_variable

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/dri/i965/brw_fs.cpp
src/mesa/drivers/dri/i965/brw_fs.h
src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
src/mesa/drivers/dri/i965/brw_wm.h
src/mesa/drivers/dri/i965/gen7_wm_state.c

index 63b005e33c0d8e03f3c21ce2693ec12c8277df5c..baf9220125cebab17083dc9c97f079ff6df7b1b3 100644 (file)
@@ -1255,6 +1255,16 @@ fs_visitor::emit_sampleid_setup(ir_variable *ir)
    return reg;
 }
 
+fs_reg *
+fs_visitor::emit_samplemaskin_setup(ir_variable *ir)
+{
+   assert(brw->gen >= 7);
+   this->current_annotation = "compute gl_SampleMaskIn";
+   fs_reg *reg = new(this->mem_ctx) fs_reg(this, ir->type);
+   emit(MOV(*reg, fs_reg(retype(brw_vec8_grf(c->sample_mask_reg, 0), BRW_REGISTER_TYPE_D))));
+   return reg;
+}
+
 fs_reg
 fs_visitor::fix_math_operand(fs_reg src)
 {
@@ -3073,7 +3083,18 @@ fs_visitor::setup_payload_gen6()
       c->nr_payload_regs++;
    }
 
-   /* R32-: bary for 32-pixel. */
+   /* R32: MSAA input coverage mask */
+   if (fp->Base.SystemValuesRead & SYSTEM_BIT_SAMPLE_MASK_IN) {
+      assert(brw->gen >= 7);
+      c->sample_mask_reg = c->nr_payload_regs;
+      c->nr_payload_regs++;
+      if (dispatch_width == 16) {
+         /* R33: input coverage mask if not 8-wide. */
+         c->nr_payload_regs++;
+      }
+   }
+
+   /* R34-: bary for 32-pixel. */
    /* R58-59: interp W for 32-pixel. */
 
    if (fp->Base.OutputsWritten & BITFIELD64_BIT(FRAG_RESULT_DEPTH)) {
index e516046686f2b22f81a6edbb355bed8544134dce..9bef07c276c245880dccc9d14e680bcb1258a67c 100644 (file)
@@ -340,6 +340,7 @@ public:
    fs_reg *emit_frontfacing_interpolation(ir_variable *ir);
    fs_reg *emit_samplepos_setup(ir_variable *ir);
    fs_reg *emit_sampleid_setup(ir_variable *ir);
+   fs_reg *emit_samplemaskin_setup(ir_variable *ir);
    fs_reg *emit_general_interpolation(ir_variable *ir);
    void emit_interpolation_setup_gen4();
    void emit_interpolation_setup_gen6();
index 47cf71e3c53ee62edaa27926c4a2b3ecce5afc90..8e516a5812b2ea3c8b1153f6b0dea090a92a40c0 100644 (file)
@@ -136,6 +136,8 @@ fs_visitor::visit(ir_variable *ir)
         reg = emit_samplepos_setup(ir);
       } else if (ir->data.location == SYSTEM_VALUE_SAMPLE_ID) {
         reg = emit_sampleid_setup(ir);
+      } else if (ir->data.location == SYSTEM_VALUE_SAMPLE_MASK_IN) {
+         reg = emit_samplemaskin_setup(ir);
       }
    }
 
index 556b5aee672c94b225e966cc32c58e8b9db92609..2ee126ba0d9fee4f3d667e842955e4a547cdce01 100644 (file)
@@ -88,6 +88,7 @@ struct brw_wm_compile {
    uint8_t aa_dest_stencil_reg;
    uint8_t dest_depth_reg;
    uint8_t sample_pos_reg;
+   uint8_t sample_mask_reg;
    uint8_t barycentric_coord_reg[BRW_WM_BARYCENTRIC_INTERP_MODE_COUNT];
    uint8_t nr_payload_regs;
    GLuint source_depth_to_render_target:1;
index abbc73c21426bda6c7bdc36c5f7d0e5874562d39..b6561bbaf2b425b6c0347f29cb9a4aa38a5e039c 100644 (file)
@@ -112,6 +112,10 @@ upload_wm_state(struct brw_context *brw)
       dw2 |= GEN7_WM_MSDISPMODE_PERSAMPLE;
    }
 
+   if (fp->program.Base.SystemValuesRead & SYSTEM_BIT_SAMPLE_MASK_IN) {
+      dw1 |= GEN7_WM_USES_INPUT_COVERAGE_MASK;
+   }
+
    BEGIN_BATCH(3);
    OUT_BATCH(_3DSTATE_WM << 16 | (3 - 2));
    OUT_BATCH(dw1);