summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri/r200/r200_texstate.c
diff options
context:
space:
mode:
authorEric Anholt <anholt@FreeBSD.org>2004-10-07 23:30:29 +0000
committerEric Anholt <anholt@FreeBSD.org>2004-10-07 23:30:29 +0000
commitd09209f5530e8bba78e4e0ec62b2027c588cc8f3 (patch)
tree0c7bdde2064bcf0c880e8bf259a8ef80dbc933a0 /src/mesa/drivers/dri/r200/r200_texstate.c
parent554e5a2eaf4b681b5c43b6aeb66f100a66da4a42 (diff)
Add Roland Scheidegger's S3TC patch. This patch does not implement the
(patented) S3TC/DXTC algorithms, but adds an option to dlopen a library module providing functions to do so. Because it uses dlopen, it is only enabled if USE_EXTERNAL_DXTN_LIB=1 is defined (which is only in linux-dri config, so far). It adds support for S3TC to several DRI drivers, and adds a DRI config option to force enabling S3TC even if the software compression/decompression is unavailable. This may allow people to use apps that require S3TC even though they don't have a license to implement the patented material themselves, if those apps use precompressed textures. Ideally we would get permission from the current holder of the patents to implement the algorithm in Mesa, at which point the dlopen mess could go away. Until then, this allows some to run applications they couldn't otherwise, and hopefully will provide us with more push to get the final step of getting that permission done.
Diffstat (limited to 'src/mesa/drivers/dri/r200/r200_texstate.c')
-rw-r--r--src/mesa/drivers/dri/r200/r200_texstate.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/src/mesa/drivers/dri/r200/r200_texstate.c b/src/mesa/drivers/dri/r200/r200_texstate.c
index 003c1e3e47..f6df2c4f82 100644
--- a/src/mesa/drivers/dri/r200/r200_texstate.c
+++ b/src/mesa/drivers/dri/r200/r200_texstate.c
@@ -53,6 +53,10 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define R200_TXFORMAT_AL88 R200_TXFORMAT_AI88
#define R200_TXFORMAT_YCBCR R200_TXFORMAT_YVYU422
#define R200_TXFORMAT_YCBCR_REV R200_TXFORMAT_VYUY422
+#define R200_TXFORMAT_RGB_DXT1 R200_TXFORMAT_DXT1
+#define R200_TXFORMAT_RGBA_DXT1 R200_TXFORMAT_DXT1
+#define R200_TXFORMAT_RGBA_DXT3 R200_TXFORMAT_DXT23
+#define R200_TXFORMAT_RGBA_DXT5 R200_TXFORMAT_DXT45
#define _COLOR(f) \
[ MESA_FORMAT_ ## f ] = { R200_TXFORMAT_ ## f, 0 }
@@ -66,7 +70,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
[ MESA_FORMAT_ ## f ] = { R200_TXFORMAT_ ## f, R200_YUV_TO_RGB }
#define _INVALID(f) \
[ MESA_FORMAT_ ## f ] = { 0xffffffff, 0 }
-#define VALID_FORMAT(f) ( ((f) <= MESA_FORMAT_YCBCR_REV) \
+#define VALID_FORMAT(f) ( ((f) <= MESA_FORMAT_RGBA_DXT5) \
&& (tx_table[f].format != 0xffffffff) )
static const struct {
@@ -93,6 +97,12 @@ tx_table[] =
_INVALID(CI8),
_YUV(YCBCR),
_YUV(YCBCR_REV),
+ _INVALID(RGB_FXT1),
+ _INVALID(RGBA_FXT1),
+ _COLOR(RGB_DXT1),
+ _ALPHA(RGBA_DXT1),
+ _ALPHA(RGBA_DXT3),
+ _ALPHA(RGBA_DXT5),
};
#undef _COLOR
@@ -165,7 +175,24 @@ static void r200SetTexImages( r200ContextPtr rmesa,
/* find image size in bytes */
if (texImage->IsCompressed) {
- size = texImage->CompressedSize;
+ /* need to calculate the size AFTER padding even though the texture is
+ submitted without padding.
+ Only handle pot textures currently - don't know if npot is even possible,
+ size calculation would certainly need (trivial) adjustments.
+ Align (and later pad) to 32byte, not sure what that 64byte blit width is
+ good for? */
+ if ((t->pp_txformat & R200_TXFORMAT_FORMAT_MASK) == R200_TXFORMAT_DXT1) {
+ /* RGB_DXT1/RGBA_DXT1, 8 bytes per block */
+ if ((texImage->Width + 3) < 8) /* width one block */
+ size = texImage->CompressedSize * 4;
+ else if ((texImage->Width + 3) < 16)
+ size = texImage->CompressedSize * 2;
+ else size = texImage->CompressedSize;
+ }
+ else /* DXT3/5, 16 bytes per block */
+ if ((texImage->Width + 3) < 8)
+ size = texImage->CompressedSize * 2;
+ else size = texImage->CompressedSize;
}
else if (tObj->Target == GL_TEXTURE_RECTANGLE_NV) {
size = ((texImage->Width * texImage->TexFormat->TexelBytes + 63)