diff options
author | Eric Anholt <anholt@FreeBSD.org> | 2004-10-07 23:30:29 +0000 |
---|---|---|
committer | Eric Anholt <anholt@FreeBSD.org> | 2004-10-07 23:30:29 +0000 |
commit | d09209f5530e8bba78e4e0ec62b2027c588cc8f3 (patch) | |
tree | 0c7bdde2064bcf0c880e8bf259a8ef80dbc933a0 /src/mesa/drivers/dri/i915 | |
parent | 554e5a2eaf4b681b5c43b6aeb66f100a66da4a42 (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/i915')
-rw-r--r-- | src/mesa/drivers/dri/i915/i830_texstate.c | 19 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i915/i915_texstate.c | 18 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i915/intel_context.c | 10 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i915/intel_context.h | 5 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i915/intel_screen.c | 13 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i915/intel_screen.h | 7 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i915/intel_tex.c | 29 |
7 files changed, 97 insertions, 4 deletions
diff --git a/src/mesa/drivers/dri/i915/i830_texstate.c b/src/mesa/drivers/dri/i915/i830_texstate.c index a393fd1d52..ba452279ba 100644 --- a/src/mesa/drivers/dri/i915/i830_texstate.c +++ b/src/mesa/drivers/dri/i915/i830_texstate.c @@ -125,6 +125,25 @@ static GLboolean i830SetTexImages( i830ContextPtr i830, textureFormat = MAPSURF_COMPRESSED | MT_COMPRESS_FXT1; break; + case MESA_FORMAT_RGBA_DXT1: + case MESA_FORMAT_RGB_DXT1: + /* + * DXTn pitches are Width/4 * blocksize in bytes + * for DXT1: blocksize=8 so Width/4*8 = Width * 2 + * for DXT3/5: blocksize=16 so Width/4*16 = Width * 4 + */ + t->intel.texelBytes = 2; + textureFormat = (MAPSURF_COMPRESSED | MT_COMPRESS_DXT1); + break; + case MESA_FORMAT_RGBA_DXT3: + t->intel.texelBytes = 4; + textureFormat = (MAPSURF_COMPRESSED | MT_COMPRESS_DXT2_3); + break; + case MESA_FORMAT_RGBA_DXT5: + t->intel.texelBytes = 4; + textureFormat = (MAPSURF_COMPRESSED | MT_COMPRESS_DXT4_5); + break; + default: fprintf(stderr, "%s: bad image format\n", __FUNCTION__); abort(); diff --git a/src/mesa/drivers/dri/i915/i915_texstate.c b/src/mesa/drivers/dri/i915/i915_texstate.c index 60ba062952..2f94e6743a 100644 --- a/src/mesa/drivers/dri/i915/i915_texstate.c +++ b/src/mesa/drivers/dri/i915/i915_texstate.c @@ -127,6 +127,24 @@ static void i915SetTexImages( i915ContextPtr i915, t->intel.texelBytes = 2; textureFormat = (MAPSURF_COMPRESSED | MT_COMPRESS_FXT1); break; + case MESA_FORMAT_RGBA_DXT1: + case MESA_FORMAT_RGB_DXT1: + /* + * DXTn pitches are Width/4 * blocksize in bytes + * for DXT1: blocksize=8 so Width/4*8 = Width * 2 + * for DXT3/5: blocksize=16 so Width/4*16 = Width * 4 + */ + t->intel.texelBytes = 2; + textureFormat = (MAPSURF_COMPRESSED | MT_COMPRESS_DXT1); + break; + case MESA_FORMAT_RGBA_DXT3: + t->intel.texelBytes = 4; + textureFormat = (MAPSURF_COMPRESSED | MT_COMPRESS_DXT2_3); + break; + case MESA_FORMAT_RGBA_DXT5: + t->intel.texelBytes = 4; + textureFormat = (MAPSURF_COMPRESSED | MT_COMPRESS_DXT4_5); + break; default: fprintf(stderr, "%s: bad image format\n", __FUNCTION__); diff --git a/src/mesa/drivers/dri/i915/intel_context.c b/src/mesa/drivers/dri/i915/intel_context.c index c1559e9567..302ddfa840 100644 --- a/src/mesa/drivers/dri/i915/intel_context.c +++ b/src/mesa/drivers/dri/i915/intel_context.c @@ -72,7 +72,7 @@ int prevLockLine; * Mesa's Driver Functions ***************************************/ -#define DRIVER_DATE "20040919" +#define DRIVER_DATE "20041007" const GLubyte *intelGetString( GLcontext *ctx, GLenum name ) { @@ -354,6 +354,14 @@ GLboolean intelInitContext( intelContextPtr intel, driInitExtensions( ctx, card_extensions, GL_TRUE ); + if (intel->ctx.Mesa_DXTn) { + _mesa_enable_extension( ctx, "GL_EXT_texture_compression_s3tc" ); + _mesa_enable_extension( ctx, "GL_S3_s3tc" ); + } + else if (driQueryOptionb (&intelScreen->optionCache, "force_s3tc_enable")) { + _mesa_enable_extension( ctx, "GL_EXT_texture_compression_s3tc" ); + } + /* driInitTextureObjects( ctx, & intel->swapped, */ /* DRI_TEXMGR_DO_TEXTURE_1D | */ /* DRI_TEXMGR_DO_TEXTURE_2D | */ diff --git a/src/mesa/drivers/dri/i915/intel_context.h b/src/mesa/drivers/dri/i915/intel_context.h index 839062921b..625e96f580 100644 --- a/src/mesa/drivers/dri/i915/intel_context.h +++ b/src/mesa/drivers/dri/i915/intel_context.h @@ -230,6 +230,11 @@ struct intel_context __DRIscreenPrivate *driScreen; intelScreenPrivate *intelScreen; drmI830Sarea *sarea; + + /** + * Configuration cache + */ + driOptionCache optionCache; }; diff --git a/src/mesa/drivers/dri/i915/intel_screen.c b/src/mesa/drivers/dri/i915/intel_screen.c index e7e9b12915..8007ff48c2 100644 --- a/src/mesa/drivers/dri/i915/intel_screen.c +++ b/src/mesa/drivers/dri/i915/intel_screen.c @@ -30,6 +30,7 @@ #include "matrix.h" #include "simple_list.h" #include "utils.h" +#include "xmlpool.h" #include "intel_screen.h" @@ -43,8 +44,13 @@ #include "i830_dri.h" -const char __driConfigOptions[] = { 0 }; -const GLuint __driNConfigOptions = 0; +const char __driConfigOptions[] = +DRI_CONF_BEGIN + DRI_CONF_SECTION_PERFORMANCE + DRI_CONF_FORCE_S3TC_ENABLE(false) + DRI_CONF_SECTION_END +DRI_CONF_END; +const GLuint __driNConfigOptions = 1; #ifdef USE_NEW_INTERFACE static PFNGLXCREATECONTEXTMODES create_context_modes = NULL; @@ -78,6 +84,9 @@ static GLboolean intelInitDriver(__DRIscreenPrivate *sPriv) fprintf(stderr,"\nERROR! Allocating private area failed\n"); return GL_FALSE; } + /* parse information in __driConfigOptions */ + driParseOptionInfo (&intelScreen->optionCache, + __driConfigOptions, __driNConfigOptions); intelScreen->driScrnPriv = sPriv; sPriv->private = (void *)intelScreen; diff --git a/src/mesa/drivers/dri/i915/intel_screen.h b/src/mesa/drivers/dri/i915/intel_screen.h index ffe5e8e50d..f2fb1c6bc9 100644 --- a/src/mesa/drivers/dri/i915/intel_screen.h +++ b/src/mesa/drivers/dri/i915/intel_screen.h @@ -30,7 +30,7 @@ #include <sys/time.h> #include "dri_util.h" - +#include "xmlconfig.h" typedef struct { drm_handle_t handle; @@ -76,6 +76,11 @@ typedef struct int irq_active; int allow_batchbuffer; + + /** + * Configuration cache with default values for all contexts + */ + driOptionCache optionCache; } intelScreenPrivate; diff --git a/src/mesa/drivers/dri/i915/intel_tex.c b/src/mesa/drivers/dri/i915/intel_tex.c index 4e22d7e3f7..b6b8188275 100644 --- a/src/mesa/drivers/dri/i915/intel_tex.c +++ b/src/mesa/drivers/dri/i915/intel_tex.c @@ -554,6 +554,22 @@ intelChooseTextureFormat( GLcontext *ctx, GLint internalFormat, case GL_COMPRESSED_RGBA_FXT1_3DFX: return &_mesa_texformat_rgba_fxt1; + case GL_RGB_S3TC: + case GL_RGB4_S3TC: + case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: + return &_mesa_texformat_rgb_dxt1; + + case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: + return &_mesa_texformat_rgba_dxt1; + + case GL_RGBA_S3TC: + case GL_RGBA4_S3TC: + case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: + return &_mesa_texformat_rgba_dxt3; + + case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: + return &_mesa_texformat_rgba_dxt5; + default: fprintf(stderr, "unexpected texture format in %s\n", __FUNCTION__); return NULL; @@ -628,11 +644,24 @@ static void intelUploadTexImage( intelContextPtr intel, { case GL_COMPRESSED_RGB_FXT1_3DFX: case GL_COMPRESSED_RGBA_FXT1_3DFX: + case GL_RGB_S3TC: + case GL_RGB4_S3TC: + case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: + case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: for (j = 0 ; j < image->Height/4 ; j++, dst += (t->Pitch)) { __memcpy(dst, src, row_len ); src += row_len; } break; + case GL_RGBA_S3TC: + case GL_RGBA4_S3TC: + case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: + case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: + for (j = 0 ; j < image->Height/4 ; j++, dst += (t->Pitch)) { + __memcpy(dst, src, (image->Width*4) ); + src += image->Width*4; + } + break; default: fprintf(stderr,"Internal Compressed format not supported %d\n", image->IntFormat); break; |