summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2011-03-14 16:37:15 +0100
committerMarek Olšák <[email protected]>2011-03-29 12:50:28 +0200
commit2e6a69939c26ab8cc27bcab29ed64cec5e9428ee (patch)
tree263a5f83772da41fc394876b099f2799c6233f0a /src/gallium
parentf03791467090db49e5c3d6111cd8d2a7cbe31d75 (diff)
r300g: finish up signed normalized textures and render targets
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/drivers/r300/r300_state_derived.c40
-rw-r--r--src/gallium/drivers/r300/r300_texture.c34
2 files changed, 46 insertions, 28 deletions
diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c
index ec00e2552ca..50cde5528ef 100644
--- a/src/gallium/drivers/r300/r300_state_derived.c
+++ b/src/gallium/drivers/r300/r300_state_derived.c
@@ -592,6 +592,13 @@ static void r300_update_rs_block(struct r300_context *r300)
}
}
+static void rgba_to_bgra(float color[4])
+{
+ float x = color[0];
+ color[0] = color[2];
+ color[2] = x;
+}
+
static uint32_t r300_get_border_color(enum pipe_format format,
const float border[4],
boolean is_r500)
@@ -625,13 +632,13 @@ static uint32_t r300_get_border_color(enum pipe_format format,
for (i = 0; i < 4; i++) {
switch (desc->swizzle[i]) {
case UTIL_FORMAT_SWIZZLE_X:
- border_swizzled[2] = border[i];
+ border_swizzled[0] = border[i];
break;
case UTIL_FORMAT_SWIZZLE_Y:
border_swizzled[1] = border[i];
break;
case UTIL_FORMAT_SWIZZLE_Z:
- border_swizzled[0] = border[i];
+ border_swizzled[2] = border[i];
break;
case UTIL_FORMAT_SWIZZLE_W:
border_swizzled[3] = border[i];
@@ -648,34 +655,36 @@ static uint32_t r300_get_border_color(enum pipe_format format,
case PIPE_FORMAT_LATC1_UNORM:
/* Add 1/32 to round the border color instead of truncating. */
/* The Y component is used for the border color. */
- border_swizzled[1] = border_swizzled[2] + 1.0f/32;
+ border_swizzled[1] = border_swizzled[0] + 1.0f/32;
util_pack_color(border_swizzled, PIPE_FORMAT_B4G4R4A4_UNORM, &uc);
return uc.ui;
case PIPE_FORMAT_RGTC2_SNORM:
case PIPE_FORMAT_LATC2_SNORM:
- border_swizzled[0] = border_swizzled[2];
util_pack_color(border_swizzled, PIPE_FORMAT_R8G8B8A8_SNORM, &uc);
return uc.ui;
case PIPE_FORMAT_RGTC2_UNORM:
case PIPE_FORMAT_LATC2_UNORM:
- util_pack_color(border_swizzled, PIPE_FORMAT_B8G8R8A8_UNORM, &uc);
+ util_pack_color(border_swizzled, PIPE_FORMAT_R8G8B8A8_UNORM, &uc);
return uc.ui;
default:
- util_pack_color(border_swizzled, PIPE_FORMAT_R8G8B8A8_UNORM, &uc);
+ util_pack_color(border_swizzled, PIPE_FORMAT_B8G8R8A8_UNORM, &uc);
return uc.ui;
}
}
switch (desc->channel[0].size) {
case 2:
+ rgba_to_bgra(border_swizzled);
util_pack_color(border_swizzled, PIPE_FORMAT_B2G3R3_UNORM, &uc);
break;
case 4:
+ rgba_to_bgra(border_swizzled);
util_pack_color(border_swizzled, PIPE_FORMAT_B4G4R4A4_UNORM, &uc);
break;
case 5:
+ rgba_to_bgra(border_swizzled);
if (desc->channel[1].size == 5) {
util_pack_color(border_swizzled, PIPE_FORMAT_B5G5R5A1_UNORM, &uc);
} else if (desc->channel[1].size == 6) {
@@ -687,32 +696,39 @@ static uint32_t r300_get_border_color(enum pipe_format format,
default:
case 8:
- util_pack_color(border_swizzled, PIPE_FORMAT_B8G8R8A8_UNORM, &uc);
+ if (desc->channel[0].type == UTIL_FORMAT_TYPE_SIGNED)
+ util_pack_color(border_swizzled, PIPE_FORMAT_R8G8B8A8_SNORM, &uc);
+ else
+ util_pack_color(border_swizzled, PIPE_FORMAT_R8G8B8A8_UNORM, &uc);
break;
case 10:
- util_pack_color(border_swizzled, PIPE_FORMAT_B10G10R10A2_UNORM, &uc);
+ util_pack_color(border_swizzled, PIPE_FORMAT_R10G10B10A2_UNORM, &uc);
break;
case 16:
if (desc->nr_channels <= 2) {
- border_swizzled[0] = border_swizzled[2];
if (desc->channel[0].type == UTIL_FORMAT_TYPE_FLOAT) {
util_pack_color(border_swizzled, PIPE_FORMAT_R16G16_FLOAT, &uc);
+ } else if (desc->channel[0].type == UTIL_FORMAT_TYPE_SIGNED) {
+ util_pack_color(border_swizzled, PIPE_FORMAT_R16G16_SNORM, &uc);
} else {
util_pack_color(border_swizzled, PIPE_FORMAT_R16G16_UNORM, &uc);
}
} else {
- util_pack_color(border_swizzled, PIPE_FORMAT_B8G8R8A8_UNORM, &uc);
+ if (desc->channel[0].type == UTIL_FORMAT_TYPE_SIGNED) {
+ util_pack_color(border_swizzled, PIPE_FORMAT_R8G8B8A8_SNORM, &uc);
+ } else {
+ util_pack_color(border_swizzled, PIPE_FORMAT_R8G8B8A8_UNORM, &uc);
+ }
}
break;
case 32:
if (desc->nr_channels == 1) {
- border_swizzled[0] = border_swizzled[2];
util_pack_color(border_swizzled, PIPE_FORMAT_R32_FLOAT, &uc);
} else {
- util_pack_color(border_swizzled, PIPE_FORMAT_B8G8R8A8_UNORM, &uc);
+ util_pack_color(border_swizzled, PIPE_FORMAT_R8G8B8A8_UNORM, &uc);
}
break;
}
diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c
index c650fb7ed37..57e0c6183ff 100644
--- a/src/gallium/drivers/r300/r300_texture.c
+++ b/src/gallium/drivers/r300/r300_texture.c
@@ -116,10 +116,10 @@ uint32_t r300_translate_texformat(enum pipe_format format,
unsigned i;
boolean uniform = TRUE;
const uint32_t sign_bit[4] = {
- R300_TX_FORMAT_SIGNED_X,
- R300_TX_FORMAT_SIGNED_Y,
- R300_TX_FORMAT_SIGNED_Z,
R300_TX_FORMAT_SIGNED_W,
+ R300_TX_FORMAT_SIGNED_Z,
+ R300_TX_FORMAT_SIGNED_Y,
+ R300_TX_FORMAT_SIGNED_X,
};
desc = util_format_description(format);
@@ -212,14 +212,14 @@ uint32_t r300_translate_texformat(enum pipe_format format,
switch (format) {
case PIPE_FORMAT_RGTC1_SNORM:
case PIPE_FORMAT_LATC1_SNORM:
- result |= sign_bit[1];
+ result |= sign_bit[2];
case PIPE_FORMAT_LATC1_UNORM:
case PIPE_FORMAT_RGTC1_UNORM:
return R500_TX_FORMAT_ATI1N | result;
case PIPE_FORMAT_RGTC2_SNORM:
case PIPE_FORMAT_LATC2_SNORM:
- result |= sign_bit[2] | sign_bit[3];
+ result |= sign_bit[1] | sign_bit[0];
case PIPE_FORMAT_RGTC2_UNORM:
case PIPE_FORMAT_LATC2_UNORM:
return R400_TX_FORMAT_ATI2N | result;
@@ -390,18 +390,18 @@ static uint32_t r300_translate_colorformat(enum pipe_format format)
switch (format) {
/* 8-bit buffers. */
case PIPE_FORMAT_A8_UNORM:
- /*case PIPE_FORMAT_A8_SNORM:*/
+ case PIPE_FORMAT_A8_SNORM:
case PIPE_FORMAT_I8_UNORM:
- /*case PIPE_FORMAT_I8_SNORM:*/
+ case PIPE_FORMAT_I8_SNORM:
case PIPE_FORMAT_L8_UNORM:
- /*case PIPE_FORMAT_L8_SNORM:*/
+ case PIPE_FORMAT_L8_SNORM:
case PIPE_FORMAT_R8_UNORM:
case PIPE_FORMAT_R8_SNORM:
return R300_COLOR_FORMAT_I8;
/* 16-bit buffers. */
case PIPE_FORMAT_L8A8_UNORM:
- /*case PIPE_FORMAT_L8A8_SNORM:*/
+ case PIPE_FORMAT_L8A8_SNORM:
case PIPE_FORMAT_R8G8_UNORM:
case PIPE_FORMAT_R8G8_SNORM:
return R300_COLOR_FORMAT_UV88;
@@ -490,9 +490,9 @@ static uint32_t r300_translate_out_fmt(enum pipe_format format)
unsigned i;
const struct util_format_description *desc;
static const uint32_t sign_bit[4] = {
- R300_OUT_SIGN(0x1),
- R300_OUT_SIGN(0x2),
R300_OUT_SIGN(0x4),
+ R300_OUT_SIGN(0x2),
+ R300_OUT_SIGN(0x1),
R300_OUT_SIGN(0x8),
};
@@ -538,23 +538,25 @@ static uint32_t r300_translate_out_fmt(enum pipe_format format)
/* 8-bit outputs, one channel.
* COLORFORMAT_I8 stores the C2 component. */
case PIPE_FORMAT_A8_UNORM:
- /*case PIPE_FORMAT_A8_SNORM:*/
+ case PIPE_FORMAT_A8_SNORM:
return modifier | R300_C2_SEL_A;
case PIPE_FORMAT_I8_UNORM:
- /*case PIPE_FORMAT_I8_SNORM:*/
+ case PIPE_FORMAT_I8_SNORM:
case PIPE_FORMAT_L8_UNORM:
- /*case PIPE_FORMAT_L8_SNORM:*/
+ case PIPE_FORMAT_L8_SNORM:
case PIPE_FORMAT_R8_UNORM:
case PIPE_FORMAT_R8_SNORM:
return modifier | R300_C2_SEL_R;
/* 16-bit outputs, two channels.
* COLORFORMAT_UV88 stores C2 and C0. */
+ case PIPE_FORMAT_L8A8_SNORM:
+ modifier |= sign_bit[2];
case PIPE_FORMAT_L8A8_UNORM:
- /*case PIPE_FORMAT_L8A8_SNORM:*/
return modifier | R300_C0_SEL_A | R300_C2_SEL_R;
- case PIPE_FORMAT_R8G8_UNORM:
case PIPE_FORMAT_R8G8_SNORM:
+ modifier |= sign_bit[2];
+ case PIPE_FORMAT_R8G8_UNORM:
return modifier | R300_C0_SEL_G | R300_C2_SEL_R;
/* BGRA outputs. */