Mesa (master): i965: Duplicate less code in GetSamplePositions driver hook.
Kenneth Graunke
kwg at kemper.freedesktop.org
Mon Feb 10 16:22:33 UTC 2014
Module: Mesa
Branch: master
Commit: 16f7510ad30070b7bd4eff494f7937f6ee257547
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=16f7510ad30070b7bd4eff494f7937f6ee257547
Author: Kenneth Graunke <kenneth at whitecape.org>
Date: Sun Feb 9 16:29:41 2014 -0800
i965: Duplicate less code in GetSamplePositions driver hook.
The 4x and 8x cases contained identical code for extracting the X and
Y sample offset values and converting them from U0.4 back to float.
Without this refactoring, we'd have to duplicate it a third time in
order to support 2x MSAA.
Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
Reviewed-by: Chris Forbes <chrisf at ijw.co.nz>
---
src/mesa/drivers/dri/i965/gen6_multisample_state.c | 23 ++++++++++----------
1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/gen6_multisample_state.c b/src/mesa/drivers/dri/i965/gen6_multisample_state.c
index f28e880..fd3dd0e 100644
--- a/src/mesa/drivers/dri/i965/gen6_multisample_state.c
+++ b/src/mesa/drivers/dri/i965/gen6_multisample_state.c
@@ -32,25 +32,26 @@ gen6_get_sample_position(struct gl_context *ctx,
struct gl_framebuffer *fb,
GLuint index, GLfloat *result)
{
+ uint8_t bits;
+
switch (fb->Visual.samples) {
case 1:
result[0] = result[1] = 0.5f;
+ return;
+ case 4:
+ bits = brw_multisample_positions_4x[0] >> (8 * index);
break;
- case 4: {
- uint8_t val = (uint8_t)(brw_multisample_positions_4x[0] >> (8*index));
- result[0] = ((val >> 4) & 0xf) / 16.0f;
- result[1] = (val & 0xf) / 16.0f;
- break;
- }
- case 8: {
- uint8_t val = (uint8_t)(brw_multisample_positions_8x[index>>2] >> (8*(index & 3)));
- result[0] = ((val >> 4) & 0xf) / 16.0f;
- result[1] = (val & 0xf) / 16.0f;
+ case 8:
+ bits = brw_multisample_positions_8x[index >> 2] >> (8 * (index & 3));
break;
- }
default:
assert(!"Not implemented");
+ return;
}
+
+ /* Convert from U0.4 back to a floating point coordinate. */
+ result[0] = ((bits >> 4) & 0xf) / 16.0f;
+ result[1] = (bits & 0xf) / 16.0f;
}
/**
More information about the mesa-commit
mailing list