summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Olšák <maraeo@gmail.com>2010-04-01 02:14:52 +0200
committerMarek Olšák <maraeo@gmail.com>2010-04-01 02:14:52 +0200
commit3252651fb291d7e6e4af5fed8ab461f603574cd6 (patch)
treef5e7f6c743e15eb3047d7b409d6e4e3f3b88fe10
parent39e116e3a0dce1a13dbb4395585cd3873e5ed073 (diff)
r300g: add RGTC texture support
The CS checker already knows about this.
-rw-r--r--src/gallium/drivers/r300/r300_reg.h20
-rw-r--r--src/gallium/drivers/r300/r300_screen.c9
-rw-r--r--src/gallium/drivers/r300/r300_texture.c28
3 files changed, 56 insertions, 1 deletions
diff --git a/src/gallium/drivers/r300/r300_reg.h b/src/gallium/drivers/r300/r300_reg.h
index 1c2b252887..0d6b7654f3 100644
--- a/src/gallium/drivers/r300/r300_reg.h
+++ b/src/gallium/drivers/r300/r300_reg.h
@@ -1556,6 +1556,26 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
# define R300_TX_FORMAT_32F_32F 0x1C
# define R300_TX_FORMAT_32F_32F_32F_32F 0x1D
# define R300_TX_FORMAT_W24_FP 0x1E
+# define R400_TX_FORMAT_ATI2N 0x1F
+
+/* These need TX_FORMAT2_[0-15].TXFORMAT_MSB set.
+
+ My guess is the 10-bit formats are the 8-bit ones but with filtering being
+ performed with the precision of 10 bits per channel. This makes sense
+ with sRGB textures since the conversion to linear space reduces the precision
+ significantly so the shader gets approximately the 8-bit precision
+ in the end. It might also improve the quality of HDR rendering where
+ high-precision filtering is desirable.
+
+ Again, this is guessed, the formats might mean something entirely else.
+ The others should be fine. */
+# define R500_TX_FORMAT_X1 0x0
+# define R500_TX_FORMAT_X1_REV 0x1
+# define R500_TX_FORMAT_X10 0x2
+# define R500_TX_FORMAT_Y10X10 0x3
+# define R500_TX_FORMAT_W10Z10Y10X10 0x4
+# define R500_TX_FORMAT_ATI1N 0x5
+
# define R300_TX_FORMAT_SIGNED_W (1 << 5)
# define R300_TX_FORMAT_SIGNED_Z (1 << 6)
diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c
index 090964b025..50e5e9307e 100644
--- a/src/gallium/drivers/r300/r300_screen.c
+++ b/src/gallium/drivers/r300/r300_screen.c
@@ -207,9 +207,14 @@ static boolean r300_is_format_supported(struct pipe_screen* screen,
{
uint32_t retval = 0;
boolean is_r500 = r300_screen(screen)->caps->is_r500;
+ boolean is_r400 = r300_screen(screen)->caps->is_r400;
boolean is_z24 = format == PIPE_FORMAT_X8Z24_UNORM ||
format == PIPE_FORMAT_S8_USCALED_Z24_UNORM;
boolean is_color2101010 = format == PIPE_FORMAT_R10G10B10A2_UNORM;
+ boolean is_ati1n = format == PIPE_FORMAT_RGTC1_UNORM ||
+ format == PIPE_FORMAT_RGTC1_SNORM;
+ boolean is_ati2n = format == PIPE_FORMAT_RGTC2_UNORM ||
+ format == PIPE_FORMAT_RGTC2_SNORM;
if (target >= PIPE_MAX_TEXTURE_TYPES) {
fprintf(stderr, "r300: Implementation error: Received bogus texture "
@@ -221,6 +226,10 @@ static boolean r300_is_format_supported(struct pipe_screen* screen,
if ((usage & PIPE_TEXTURE_USAGE_SAMPLER) &&
/* Z24 cannot be sampled from on non-r5xx. */
(is_r500 || !is_z24) &&
+ /* ATI1N is r5xx-only. */
+ (is_r500 || !is_ati1n) &&
+ /* ATI2N is supported on r4xx-r5xx. */
+ (is_r400 || is_r500 || !is_ati2n) &&
r300_is_sampler_format_supported(format)) {
retval |= PIPE_TEXTURE_USAGE_SAMPLER;
}
diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c
index 92c29b53fd..d4a64092c7 100644
--- a/src/gallium/drivers/r300/r300_texture.c
+++ b/src/gallium/drivers/r300/r300_texture.c
@@ -158,7 +158,7 @@ static uint32_t r300_translate_texformat(enum pipe_format format)
}
}
- /* Compressed formats. */
+ /* S3TC formats. */
if (desc->layout == UTIL_FORMAT_LAYOUT_S3TC) {
switch (format) {
case PIPE_FORMAT_DXT1_RGB:
@@ -184,6 +184,20 @@ static uint32_t r300_translate_texformat(enum pipe_format format)
}
}
+ /* RGTC formats. */
+ if (desc->layout == UTIL_FORMAT_LAYOUT_RGTC) {
+ switch (format) {
+ case PIPE_FORMAT_RGTC1_UNORM:
+ case PIPE_FORMAT_RGTC1_SNORM:
+ return R500_TX_FORMAT_ATI1N | result;
+ case PIPE_FORMAT_RGTC2_UNORM:
+ case PIPE_FORMAT_RGTC2_SNORM:
+ return R400_TX_FORMAT_ATI2N | result;
+ default:
+ return ~0; /* Unsupported/unknown. */
+ }
+ }
+
/* See whether the components are of the same size. */
for (i = 1; i < desc->nr_channels; i++) {
uniform = uniform && desc->channel[0].size == desc->channel[i].size;
@@ -295,6 +309,17 @@ static uint32_t r300_translate_texformat(enum pipe_format format)
return ~0; /* Unsupported/unknown. */
}
+static uint32_t r500_tx_format_msb_bit(enum pipe_format format)
+{
+ switch (format) {
+ case PIPE_FORMAT_RGTC1_UNORM:
+ case PIPE_FORMAT_RGTC1_SNORM:
+ return R500_TXFORMAT_MSB;
+ default:
+ return 0;
+ }
+}
+
/* Buffer formats. */
/* Colorbuffer formats. This is the unswizzled format of the RB3D block's
@@ -520,6 +545,7 @@ static void r300_setup_texture_state(struct r300_screen* screen, struct r300_tex
if (pt->height0 > 2048) {
state->format2 |= R500_TXHEIGHT_BIT11;
}
+ state->format2 |= r500_tx_format_msb_bit(pt->format);
}
SCREEN_DBG(screen, DBG_TEX, "r300: Set texture state (%dx%d, %d levels)\n",