diff options
author | Dave Airlie <[email protected]> | 2013-03-04 06:19:07 +1000 |
---|---|---|
committer | Dave Airlie <[email protected]> | 2013-04-11 21:09:29 +0100 |
commit | f024c724766b1040176a329fbedff7cd5dc47cca (patch) | |
tree | 1e1e29fd6785f1641e1b5db83854d2214cae7c72 /src/gallium/drivers/r600/r600_state.c | |
parent | f152da6bf990c330108da25972f28e08b2f233aa (diff) |
r600g: add get_sample_position support (v3)
v2: I rewrote this to use the sample positions properly.
v3: rewrite properly to use bitfield to cast back to signed ints
Signed-off-by: Dave Airlie <[email protected]>
Diffstat (limited to 'src/gallium/drivers/r600/r600_state.c')
-rw-r--r-- | src/gallium/drivers/r600/r600_state.c | 75 |
1 files changed, 59 insertions, 16 deletions
diff --git a/src/gallium/drivers/r600/r600_state.c b/src/gallium/drivers/r600/r600_state.c index a7e69238bbe..b30e053ce52 100644 --- a/src/gallium/drivers/r600/r600_state.c +++ b/src/gallium/drivers/r600/r600_state.c @@ -1686,24 +1686,65 @@ static void r600_set_framebuffer_state(struct pipe_context *ctx, (((s2x) & 0xf) << 16) | (((s2y) & 0xf) << 20) | \ (((s3x) & 0xf) << 24) | (((s3y) & 0xf) << 28)) + +static uint32_t sample_locs_2x[] = { + FILL_SREG(-4, 4, 4, -4, -4, 4, 4, -4), + FILL_SREG(-4, 4, 4, -4, -4, 4, 4, -4), +}; +static unsigned max_dist_2x = 4; + +static uint32_t sample_locs_4x[] = { + FILL_SREG(-2, -2, 2, 2, -6, 6, 6, -6), + FILL_SREG(-2, -2, 2, 2, -6, 6, 6, -6), +}; +static unsigned max_dist_4x = 6; +static uint32_t sample_locs_8x[] = { + FILL_SREG(-1, 1, 1, 5, 3, -5, 5, 3), + FILL_SREG(-7, -1, -3, -7, 7, -3, -5, 7), +}; +static unsigned max_dist_8x = 7; + +static void r600_get_sample_position(struct pipe_context *ctx, + unsigned sample_count, + unsigned sample_index, + float *out_value) +{ + int offset, index; + struct { + int idx:4; + } val; + switch (sample_count) { + case 1: + default: + out_value[0] = out_value[1] = 0.5; + break; + case 2: + offset = 4 * (sample_index * 2); + val.idx = (sample_locs_2x[0] >> offset) & 0xf; + out_value[0] = (float)(val.idx + 8) / 16.0f; + val.idx = (sample_locs_2x[0] >> (offset + 4)) & 0xf; + out_value[1] = (float)(val.idx + 8) / 16.0f; + break; + case 4: + offset = 4 * (sample_index * 2); + val.idx = (sample_locs_4x[0] >> offset) & 0xf; + out_value[0] = (float)(val.idx + 8) / 16.0f; + val.idx = (sample_locs_4x[0] >> (offset + 4)) & 0xf; + out_value[1] = (float)(val.idx + 8) / 16.0f; + break; + case 8: + offset = 4 * (sample_index % 4 * 2); + index = (sample_index / 4); + val.idx = (sample_locs_8x[index] >> offset) & 0xf; + out_value[0] = (float)(val.idx + 8) / 16.0f; + val.idx = (sample_locs_8x[index] >> (offset + 4)) & 0xf; + out_value[1] = (float)(val.idx + 8) / 16.0f; + break; + } +} + static void r600_emit_msaa_state(struct r600_context *rctx, int nr_samples) { - static uint32_t sample_locs_2x[] = { - FILL_SREG(-4, 4, 4, -4, -4, 4, 4, -4), - FILL_SREG(-4, 4, 4, -4, -4, 4, 4, -4), - }; - static unsigned max_dist_2x = 4; - static uint32_t sample_locs_4x[] = { - FILL_SREG(-2, -2, 2, 2, -6, 6, 6, -6), - FILL_SREG(-2, -2, 2, 2, -6, 6, 6, -6), - }; - static unsigned max_dist_4x = 6; - static uint32_t sample_locs_8x[] = { - FILL_SREG(-1, 1, 1, 5, 3, -5, 5, 3), - FILL_SREG(-7, -1, -3, -7, 7, -3, -5, 7), - }; - static unsigned max_dist_8x = 7; - struct radeon_winsys_cs *cs = rctx->rings.gfx.cs; unsigned max_dist = 0; @@ -3211,5 +3252,7 @@ void r600_init_state_functions(struct r600_context *rctx) rctx->context.set_framebuffer_state = r600_set_framebuffer_state; rctx->context.set_polygon_stipple = r600_set_polygon_stipple; rctx->context.set_scissor_state = r600_set_scissor_state; + + rctx->context.get_sample_position = r600_get_sample_position; } /* this function must be last */ |