summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChia-I Wu <[email protected]>2015-01-26 14:00:25 +0800
committerChia-I Wu <[email protected]>2015-02-12 07:56:10 +0800
commit1d07055b5087bf7c0cca50b7b5a5635bfdd85885 (patch)
treeb2bc5b96870ce6d238fcf64641bcf4d773e85595 /src
parent69ad5fd4ce33aeab73d9eb546072d77e73e3a730 (diff)
ilo: clean up sample patterns
Use signed int for sample positions and add helpers to access them. Call them patterns instead of positions.
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/ilo/ilo_builder_3d_bottom.h9
-rw-r--r--src/gallium/drivers/ilo/ilo_render.c89
-rw-r--r--src/gallium/drivers/ilo/ilo_render_gen.h6
-rw-r--r--src/gallium/drivers/ilo/ilo_render_gen6.c14
-rw-r--r--src/gallium/drivers/ilo/ilo_render_gen7.c21
5 files changed, 71 insertions, 68 deletions
diff --git a/src/gallium/drivers/ilo/ilo_builder_3d_bottom.h b/src/gallium/drivers/ilo/ilo_builder_3d_bottom.h
index a66ed0b7af9..f137232bcaa 100644
--- a/src/gallium/drivers/ilo/ilo_builder_3d_bottom.h
+++ b/src/gallium/drivers/ilo/ilo_builder_3d_bottom.h
@@ -524,8 +524,7 @@ gen7_3DSTATE_SAMPLER_STATE_POINTERS_PS(struct ilo_builder *builder,
static inline void
gen6_3DSTATE_MULTISAMPLE(struct ilo_builder *builder,
- int num_samples,
- const uint32_t *packed_sample_pos,
+ int num_samples, const uint32_t *pattern,
bool pixel_location_center)
{
const uint8_t cmd_len = (ilo_dev_gen(builder->dev) >= ILO_GEN(7)) ? 4 : 3;
@@ -545,14 +544,14 @@ gen6_3DSTATE_MULTISAMPLE(struct ilo_builder *builder,
break;
case 4:
dw1 |= GEN6_MULTISAMPLE_DW1_NUMSAMPLES_4;
- dw2 = packed_sample_pos[0];
+ dw2 = pattern[0];
dw3 = 0;
break;
case 8:
assert(ilo_dev_gen(builder->dev) >= ILO_GEN(7));
dw1 |= GEN7_MULTISAMPLE_DW1_NUMSAMPLES_8;
- dw2 = packed_sample_pos[0];
- dw3 = packed_sample_pos[1];
+ dw2 = pattern[0];
+ dw3 = pattern[1];
break;
default:
assert(!"unsupported sample count");
diff --git a/src/gallium/drivers/ilo/ilo_render.c b/src/gallium/drivers/ilo/ilo_render.c
index 00b57b808ad..c48a50defb4 100644
--- a/src/gallium/drivers/ilo/ilo_render.c
+++ b/src/gallium/drivers/ilo/ilo_render.c
@@ -35,34 +35,47 @@
#include "ilo_query.h"
#include "ilo_render_gen.h"
-/* in U0.4 */
+/* in S1.3 */
struct sample_position {
- uint8_t x, y;
+ int8_t x, y;
};
-/* \see gen6_get_sample_position() */
-static const struct sample_position sample_position_1x[1] = {
- { 8, 8 },
+static const struct sample_position ilo_sample_pattern_1x[1] = {
+ { 0, 0 },
};
-static const struct sample_position sample_position_4x[4] = {
- { 6, 2 }, /* distance from the center is sqrt(40) */
- { 14, 6 }, /* distance from the center is sqrt(40) */
- { 2, 10 }, /* distance from the center is sqrt(40) */
- { 10, 14 }, /* distance from the center is sqrt(40) */
+static const struct sample_position ilo_sample_pattern_4x[4] = {
+ { -2, -6 },
+ { 6, -2 },
+ { -6, 2 },
+ { 2, 6 },
};
-static const struct sample_position sample_position_8x[8] = {
- { 7, 9 }, /* distance from the center is sqrt(2) */
- { 9, 13 }, /* distance from the center is sqrt(26) */
- { 11, 3 }, /* distance from the center is sqrt(34) */
- { 13, 11 }, /* distance from the center is sqrt(34) */
- { 1, 7 }, /* distance from the center is sqrt(50) */
- { 5, 1 }, /* distance from the center is sqrt(58) */
- { 15, 5 }, /* distance from the center is sqrt(58) */
- { 3, 15 }, /* distance from the center is sqrt(74) */
+/* \see brw_multisample_positions_8x */
+static const struct sample_position ilo_sample_pattern_8x[8] = {
+ { -1, 1 },
+ { 1, 5 },
+ { 3, -5 },
+ { 5, 3 },
+ { -7, -1 },
+ { -3, -7 },
+ { 7, -3 },
+ { -5, 7 },
};
+static uint8_t
+pack_sample_position(const struct sample_position *pos)
+{
+ return (pos->x + 8) << 4 | (pos->y + 8);
+}
+
+static void
+get_sample_position(const struct sample_position *pos, float *x, float *y)
+{
+ *x = (float) (pos->x + 8) / 16.0f;
+ *y = (float) (pos->y + 8) / 16.0f;
+}
+
struct ilo_render *
ilo_render_create(struct ilo_builder *builder)
{
@@ -84,23 +97,16 @@ ilo_render_create(struct ilo_builder *builder)
return NULL;
}
- render->packed_sample_position_1x =
- sample_position_1x[0].x << 4 |
- sample_position_1x[0].y;
-
/* pack into dwords */
+ render->sample_pattern_1x = pack_sample_position(ilo_sample_pattern_1x);
for (i = 0; i < 4; i++) {
- render->packed_sample_position_4x |=
- sample_position_4x[i].x << (8 * i + 4) |
- sample_position_4x[i].y << (8 * i);
-
- render->packed_sample_position_8x[0] |=
- sample_position_8x[i].x << (8 * i + 4) |
- sample_position_8x[i].y << (8 * i);
+ render->sample_pattern_4x |=
+ pack_sample_position(&ilo_sample_pattern_4x[i]) << (8 * i);
- render->packed_sample_position_8x[1] |=
- sample_position_8x[4 + i].x << (8 * i + 4) |
- sample_position_8x[4 + i].y << (8 * i);
+ render->sample_pattern_8x[0] |=
+ pack_sample_position(&ilo_sample_pattern_8x[i]) << (8 * i);
+ render->sample_pattern_8x[1] |=
+ pack_sample_position(&ilo_sample_pattern_8x[i + 4]) << (8 * i);
}
ilo_render_invalidate_hw(render);
@@ -124,20 +130,20 @@ ilo_render_get_sample_position(const struct ilo_render *render,
unsigned sample_index,
float *x, float *y)
{
- const struct sample_position *pos;
+ const struct sample_position *pattern;
switch (sample_count) {
case 1:
- assert(sample_index < Elements(sample_position_1x));
- pos = sample_position_1x;
+ assert(sample_index < Elements(ilo_sample_pattern_1x));
+ pattern = ilo_sample_pattern_1x;
break;
case 4:
- assert(sample_index < Elements(sample_position_4x));
- pos = sample_position_4x;
+ assert(sample_index < Elements(ilo_sample_pattern_4x));
+ pattern = ilo_sample_pattern_4x;
break;
case 8:
- assert(sample_index < Elements(sample_position_8x));
- pos = sample_position_8x;
+ assert(sample_index < Elements(ilo_sample_pattern_8x));
+ pattern = ilo_sample_pattern_8x;
break;
default:
assert(!"unknown sample count");
@@ -147,8 +153,7 @@ ilo_render_get_sample_position(const struct ilo_render *render,
break;
}
- *x = (float) pos[sample_index].x / 16.0f;
- *y = (float) pos[sample_index].y / 16.0f;
+ get_sample_position(&pattern[sample_index], x, y);
}
void
diff --git a/src/gallium/drivers/ilo/ilo_render_gen.h b/src/gallium/drivers/ilo/ilo_render_gen.h
index 28d5030b9ae..fef01f43591 100644
--- a/src/gallium/drivers/ilo/ilo_render_gen.h
+++ b/src/gallium/drivers/ilo/ilo_render_gen.h
@@ -47,9 +47,9 @@ struct ilo_render {
struct intel_bo *workaround_bo;
- uint32_t packed_sample_position_1x;
- uint32_t packed_sample_position_4x;
- uint32_t packed_sample_position_8x[2];
+ uint32_t sample_pattern_1x;
+ uint32_t sample_pattern_4x;
+ uint32_t sample_pattern_8x[2];
bool hw_ctx_changed;
diff --git a/src/gallium/drivers/ilo/ilo_render_gen6.c b/src/gallium/drivers/ilo/ilo_render_gen6.c
index e548287ccc4..20bab20dce1 100644
--- a/src/gallium/drivers/ilo/ilo_render_gen6.c
+++ b/src/gallium/drivers/ilo/ilo_render_gen6.c
@@ -717,10 +717,10 @@ gen6_draw_wm_multisample(struct ilo_render *r,
{
/* 3DSTATE_MULTISAMPLE and 3DSTATE_SAMPLE_MASK */
if (DIRTY(SAMPLE_MASK) || DIRTY(FB)) {
- const uint32_t *packed_sample_pos;
+ const uint32_t *pattern;
- packed_sample_pos = (vec->fb.num_samples > 1) ?
- &r->packed_sample_position_4x : &r->packed_sample_position_1x;
+ pattern = (vec->fb.num_samples > 1) ?
+ &r->sample_pattern_4x : &r->sample_pattern_1x;
if (ilo_dev_gen(r->dev) == ILO_GEN(6)) {
gen6_wa_pre_non_pipelined(r);
@@ -728,7 +728,7 @@ gen6_draw_wm_multisample(struct ilo_render *r,
}
gen6_3DSTATE_MULTISAMPLE(r->builder,
- vec->fb.num_samples, packed_sample_pos,
+ vec->fb.num_samples, pattern,
vec->rasterizer->state.half_pixel_center);
gen6_3DSTATE_SAMPLE_MASK(r->builder,
@@ -920,13 +920,13 @@ static void
gen6_rectlist_wm_multisample(struct ilo_render *r,
const struct ilo_blitter *blitter)
{
- const uint32_t *packed_sample_pos = (blitter->fb.num_samples > 1) ?
- &r->packed_sample_position_4x : &r->packed_sample_position_1x;
+ const uint32_t *pattern = (blitter->fb.num_samples > 1) ?
+ &r->sample_pattern_4x : &r->sample_pattern_1x;
gen6_wa_pre_3dstate_multisample(r);
gen6_3DSTATE_MULTISAMPLE(r->builder, blitter->fb.num_samples,
- packed_sample_pos, true);
+ pattern, true);
gen6_3DSTATE_SAMPLE_MASK(r->builder,
(1 << blitter->fb.num_samples) - 1);
diff --git a/src/gallium/drivers/ilo/ilo_render_gen7.c b/src/gallium/drivers/ilo/ilo_render_gen7.c
index 0c75afc2489..cc6d8c98041 100644
--- a/src/gallium/drivers/ilo/ilo_render_gen7.c
+++ b/src/gallium/drivers/ilo/ilo_render_gen7.c
@@ -611,17 +611,16 @@ gen7_draw_wm_multisample(struct ilo_render *r,
{
/* 3DSTATE_MULTISAMPLE and 3DSTATE_SAMPLE_MASK */
if (DIRTY(SAMPLE_MASK) || DIRTY(FB)) {
- const uint32_t *packed_sample_pos;
+ const uint32_t *pattern;
gen7_wa_pre_3dstate_multisample(r);
- packed_sample_pos =
- (vec->fb.num_samples > 4) ? r->packed_sample_position_8x :
- (vec->fb.num_samples > 1) ? &r->packed_sample_position_4x :
- &r->packed_sample_position_1x;
+ pattern = (vec->fb.num_samples > 4) ? r->sample_pattern_8x :
+ (vec->fb.num_samples > 1) ? &r->sample_pattern_4x :
+ &r->sample_pattern_1x;
gen6_3DSTATE_MULTISAMPLE(r->builder,
- vec->fb.num_samples, packed_sample_pos,
+ vec->fb.num_samples, pattern,
vec->rasterizer->state.half_pixel_center);
gen7_3DSTATE_SAMPLE_MASK(r->builder,
@@ -807,15 +806,15 @@ static void
gen7_rectlist_wm_multisample(struct ilo_render *r,
const struct ilo_blitter *blitter)
{
- const uint32_t *packed_sample_pos =
- (blitter->fb.num_samples > 4) ? r->packed_sample_position_8x :
- (blitter->fb.num_samples > 1) ? &r->packed_sample_position_4x :
- &r->packed_sample_position_1x;
+ const uint32_t *pattern =
+ (blitter->fb.num_samples > 4) ? r->sample_pattern_8x :
+ (blitter->fb.num_samples > 1) ? &r->sample_pattern_4x :
+ &r->sample_pattern_1x;
gen7_wa_pre_3dstate_multisample(r);
gen6_3DSTATE_MULTISAMPLE(r->builder, blitter->fb.num_samples,
- packed_sample_pos, true);
+ pattern, true);
gen7_3DSTATE_SAMPLE_MASK(r->builder,
(1 << blitter->fb.num_samples) - 1, blitter->fb.num_samples);