summaryrefslogtreecommitdiff
path: root/src/sna/gen6_render.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2012-07-14 14:54:27 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2012-07-14 14:54:27 +0100
commitfffbc34e4621898eee9b80bf8b6b3699bcade52a (patch)
tree36d3365792863b6bb3aa7addb95b50fb9a9baffb /src/sna/gen6_render.c
parent95fdd9af5c8a8360d02debc400e75869c36f05ca (diff)
sna/gen4+: Translate to card format using a switch
GCC produces faster code than a walk over the format tables. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src/sna/gen6_render.c')
-rw-r--r--src/sna/gen6_render.c50
1 files changed, 22 insertions, 28 deletions
diff --git a/src/sna/gen6_render.c b/src/sna/gen6_render.c
index ccf27be4..ab3e4d66 100644
--- a/src/sna/gen6_render.c
+++ b/src/sna/gen6_render.c
@@ -188,28 +188,6 @@ static const struct blendinfo {
*/
#define GEN6_BLENDFACTOR_COUNT (GEN6_BLENDFACTOR_INV_DST_ALPHA + 1)
-/* FIXME: surface format defined in gen6_defines.h, shared Sampling engine
- * 1.7.2
- */
-static const struct formatinfo {
- CARD32 pict_fmt;
- uint32_t card_fmt;
-} gen6_tex_formats[] = {
- {PICT_a8, GEN6_SURFACEFORMAT_A8_UNORM},
- {PICT_a8r8g8b8, GEN6_SURFACEFORMAT_B8G8R8A8_UNORM},
- {PICT_x8r8g8b8, GEN6_SURFACEFORMAT_B8G8R8X8_UNORM},
- {PICT_a8b8g8r8, GEN6_SURFACEFORMAT_R8G8B8A8_UNORM},
- {PICT_x8b8g8r8, GEN6_SURFACEFORMAT_R8G8B8X8_UNORM},
- {PICT_r8g8b8, GEN6_SURFACEFORMAT_R8G8B8_UNORM},
- {PICT_r5g6b5, GEN6_SURFACEFORMAT_B5G6R5_UNORM},
- {PICT_a1r5g5b5, GEN6_SURFACEFORMAT_B5G5R5A1_UNORM},
- {PICT_a2r10g10b10, GEN6_SURFACEFORMAT_B10G10R10A2_UNORM},
- {PICT_x2r10g10b10, GEN6_SURFACEFORMAT_B10G10R10X2_UNORM},
- {PICT_a2b10g10r10, GEN6_SURFACEFORMAT_R10G10B10A2_UNORM},
- {PICT_x2r10g10b10, GEN6_SURFACEFORMAT_B10G10R10X2_UNORM},
- {PICT_a4r4g4b4, GEN6_SURFACEFORMAT_B4G4R4A4_UNORM},
-};
-
#define GEN6_BLEND_STATE_PADDED_SIZE ALIGN(sizeof(struct gen6_blend_state), 64)
#define BLEND_OFFSET(s, d) \
@@ -1140,13 +1118,29 @@ static uint32_t gen6_create_cc_viewport(struct sna_static_stream *stream)
static uint32_t gen6_get_card_format(PictFormat format)
{
- unsigned int i;
-
- for (i = 0; i < ARRAY_SIZE(gen6_tex_formats); i++) {
- if (gen6_tex_formats[i].pict_fmt == format)
- return gen6_tex_formats[i].card_fmt;
+ switch (format) {
+ default:
+ return -1;
+ case PICT_a8r8g8b8:
+ case PICT_x8r8g8b8:
+ return GEN6_SURFACEFORMAT_B8G8R8A8_UNORM;
+ case PICT_a8b8g8r8:
+ case PICT_x8b8g8r8:
+ return GEN6_SURFACEFORMAT_R8G8B8A8_UNORM;
+ case PICT_a2r10g10b10:
+ case PICT_x2r10g10b10:
+ return GEN6_SURFACEFORMAT_B10G10R10A2_UNORM;
+ case PICT_r5g6b5:
+ return GEN6_SURFACEFORMAT_B5G6R5_UNORM;
+ case PICT_x1r5g5b5:
+ case PICT_a1r5g5b5:
+ return GEN6_SURFACEFORMAT_B5G5R5A1_UNORM;
+ case PICT_a8:
+ return GEN6_SURFACEFORMAT_A8_UNORM;
+ case PICT_a4r4g4b4:
+ case PICT_x4r4g4b4:
+ return GEN6_SURFACEFORMAT_B4G4R4A4_UNORM;
}
- return -1;
}
static uint32_t