util: remove LIST_IS_EMPTY macro
[mesa.git] / src / gallium / drivers / radeonsi / si_state_msaa.c
index b6504d53a2aff0a2925c87f3689db3b3648e2e62..0fa38918b20dd48e93553f0c150b072250b84fa7 100644 (file)
  *   Right half: {1,3,5,7,9,11,13,15}
  */
 
+/* Important note: We have to use the standard DX positions, because
+ * the primitive discard compute shader relies on them.
+ */
+
 /* 1x MSAA */
 static const uint32_t sample_locs_1x =
        FILL_SREG( 0, 0,   0, 0,   0, 0,   0, 0); /* S1, S2, S3 fields are not used by 1x */
 static const uint64_t centroid_priority_1x = 0x0000000000000000ull;
 
-/* 2x MSAA */
+/* 2x MSAA (the positions are sorted for EQAA) */
 static const uint32_t sample_locs_2x =
        FILL_SREG(-4,-4,   4, 4,   0, 0,   0, 0); /* S2 & S3 fields are not used by 2x MSAA */
 static const uint64_t centroid_priority_2x = 0x1010101010101010ull;
 
-/* 8x MSAA */
+/* 4x MSAA (the positions are sorted for EQAA) */
+static const uint32_t sample_locs_4x =
+       FILL_SREG(-2,-6,   2, 6,   -6, 2,  6,-2);
+static const uint64_t centroid_priority_4x = 0x3210321032103210ull;
+
+/* 8x MSAA (the positions are sorted for EQAA) */
 static const uint32_t sample_locs_8x[] = {
-       FILL_SREG(-3,-5,   5, 1,  -5, 5,   7,-7),
-       FILL_SREG(-7,-1,   3, 7,  -1, 3,   1,-3),
-       FILL_SREG( 0, 0,   0, 0,   0, 0,   0, 0), /* S8, S9 etc. are not used by 8x */
-       FILL_SREG( 0, 0,   0, 0,   0, 0,   0, 0),
+       FILL_SREG(-3,-5,   5, 1,  -1, 3,   7,-7),
+       FILL_SREG(-7,-1,   3, 7,  -5, 5,   1,-3),
+       /* The following are unused by hardware, but we emit them to IBs
+        * instead of multiple SET_CONTEXT_REG packets. */
+       0,
+       0,
 };
-static const uint64_t centroid_priority_8x = 0x3542017635420176ull;
+static const uint64_t centroid_priority_8x = 0x3546012735460127ull;
 
-/* 4x and 16x MSAA
- * (the first 4 locations happen to be optimal for 4x MSAA, better than
- *  the standard DX 4x locations)
- */
-static const uint32_t sample_locs_4x_16x[] = {
+/* 16x MSAA (the positions are sorted for EQAA) */
+static const uint32_t sample_locs_16x[] = {
        FILL_SREG(-5,-2,   5, 3,  -2, 6,   3,-5),
-       FILL_SREG(-7,-8,   1, 1,  -6, 4,   7,-4),
+       FILL_SREG(-4,-6,   1, 1,  -6, 4,   7,-4),
        FILL_SREG(-1,-3,   6, 7,  -3, 2,   0,-7),
-       FILL_SREG(-4,-6,   2, 5,  -8, 0,   4,-1),
+       FILL_SREG(-7,-8,   2, 5,  -8, 0,   4,-1),
 };
-static const uint64_t centroid_priority_4x = 0x2310231023102310ull;
-static const uint64_t centroid_priority_16x = 0x497ec6b231d0fa85ull;
+static const uint64_t centroid_priority_16x = 0xc97e64b231d0fa85ull;
 
 static void si_get_sample_position(struct pipe_context *ctx, unsigned sample_count,
                                   unsigned sample_index, float *out_value)
@@ -128,13 +135,13 @@ static void si_get_sample_position(struct pipe_context *ctx, unsigned sample_cou
                sample_locs = &sample_locs_2x;
                break;
        case 4:
-               sample_locs = sample_locs_4x_16x;
+               sample_locs = &sample_locs_4x;
                break;
        case 8:
                sample_locs = sample_locs_8x;
                break;
        case 16:
-               sample_locs = sample_locs_4x_16x;
+               sample_locs = sample_locs_16x;
                break;
        }
 
@@ -142,7 +149,7 @@ static void si_get_sample_position(struct pipe_context *ctx, unsigned sample_cou
        out_value[1] = (GET_SY(sample_locs, sample_index) + 8) / 16.0f;
 }
 
-static void si_emit_max_4_sample_locs(struct radeon_winsys_cs *cs,
+static void si_emit_max_4_sample_locs(struct radeon_cmdbuf *cs,
                                      uint64_t centroid_priority,
                                      uint32_t sample_locs)
 {
@@ -155,7 +162,7 @@ static void si_emit_max_4_sample_locs(struct radeon_winsys_cs *cs,
        radeon_set_context_reg(cs, R_028C28_PA_SC_AA_SAMPLE_LOCS_PIXEL_X1Y1_0, sample_locs);
 }
 
-static void si_emit_max_16_sample_locs(struct radeon_winsys_cs *cs,
+static void si_emit_max_16_sample_locs(struct radeon_cmdbuf *cs,
                                       uint64_t centroid_priority,
                                       const uint32_t *sample_locs,
                                       unsigned num_samples)
@@ -171,7 +178,7 @@ static void si_emit_max_16_sample_locs(struct radeon_winsys_cs *cs,
        radeon_emit_array(cs, sample_locs, num_samples == 8 ? 2 : 4);
 }
 
-void si_emit_sample_locations(struct radeon_winsys_cs *cs, int nr_samples)
+void si_emit_sample_locations(struct radeon_cmdbuf *cs, int nr_samples)
 {
        switch (nr_samples) {
        default:
@@ -182,13 +189,13 @@ void si_emit_sample_locations(struct radeon_winsys_cs *cs, int nr_samples)
                si_emit_max_4_sample_locs(cs, centroid_priority_2x, sample_locs_2x);
                break;
        case 4:
-               si_emit_max_4_sample_locs(cs, centroid_priority_4x, sample_locs_4x_16x[0]);
+               si_emit_max_4_sample_locs(cs, centroid_priority_4x, sample_locs_4x);
                break;
        case 8:
                si_emit_max_16_sample_locs(cs, centroid_priority_8x, sample_locs_8x, 8);
                break;
        case 16:
-               si_emit_max_16_sample_locs(cs, centroid_priority_16x, sample_locs_4x_16x, 16);
+               si_emit_max_16_sample_locs(cs, centroid_priority_16x, sample_locs_16x, 16);
                break;
        }
 }
@@ -199,14 +206,14 @@ void si_init_msaa_functions(struct si_context *sctx)
 
        sctx->b.get_sample_position = si_get_sample_position;
 
-       si_get_sample_position(&sctx->b, 1, 0, sctx->sample_locations_1x[0]);
+       si_get_sample_position(&sctx->b, 1, 0, sctx->sample_positions.x1[0]);
 
        for (i = 0; i < 2; i++)
-               si_get_sample_position(&sctx->b, 2, i, sctx->sample_locations_2x[i]);
+               si_get_sample_position(&sctx->b, 2, i, sctx->sample_positions.x2[i]);
        for (i = 0; i < 4; i++)
-               si_get_sample_position(&sctx->b, 4, i, sctx->sample_locations_4x[i]);
+               si_get_sample_position(&sctx->b, 4, i, sctx->sample_positions.x4[i]);
        for (i = 0; i < 8; i++)
-               si_get_sample_position(&sctx->b, 8, i, sctx->sample_locations_8x[i]);
+               si_get_sample_position(&sctx->b, 8, i, sctx->sample_positions.x8[i]);
        for (i = 0; i < 16; i++)
-               si_get_sample_position(&sctx->b, 16, i, sctx->sample_locations_16x[i]);
+               si_get_sample_position(&sctx->b, 16, i, sctx->sample_positions.x16[i]);
 }