summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri/common/texmem.c
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2004-06-19 17:44:23 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2004-06-19 17:44:23 +0000
commitf252f64430ccb957698fcf85e84c9d64008147eb (patch)
tree7c1de4462f2a91d6713cb52181f78b00b03211bf /src/mesa/drivers/dri/common/texmem.c
parent07694b8935f69f69352648dd7ebf59a7222f1c8e (diff)
Big-endian texture fixes from Michel Dänzer.
Diffstat (limited to 'src/mesa/drivers/dri/common/texmem.c')
-rw-r--r--src/mesa/drivers/dri/common/texmem.c56
1 files changed, 52 insertions, 4 deletions
diff --git a/src/mesa/drivers/dri/common/texmem.c b/src/mesa/drivers/dri/common/texmem.c
index c76d371682..48a8f5c74e 100644
--- a/src/mesa/drivers/dri/common/texmem.c
+++ b/src/mesa/drivers/dri/common/texmem.c
@@ -47,6 +47,7 @@
#include "simple_list.h"
#include "imports.h"
#include "macros.h"
+#include "texformat.h"
#include <assert.h>
@@ -64,11 +65,10 @@ static unsigned dummy_swap_counter;
* \param n Value whose \f$\log_2\f$ is to be calculated
*/
-static unsigned
-driLog2( unsigned n )
+static GLuint
+driLog2( GLuint n )
{
- unsigned log2;
-
+ GLuint log2;
for ( log2 = 1 ; n > 1 ; log2++ ) {
n >>= 1;
@@ -1228,3 +1228,51 @@ driCalculateTextureFirstLastLevel( driTextureObject * t )
t->firstLevel = firstLevel;
t->lastLevel = lastLevel;
}
+
+
+
+
+/**
+ * \name DRI texture formats. Pointers initialized to either the big- or
+ * little-endian Mesa formats.
+ */
+/*@{*/
+const struct gl_texture_format *_dri_texformat_rgba8888 = NULL;
+const struct gl_texture_format *_dri_texformat_argb8888 = NULL;
+const struct gl_texture_format *_dri_texformat_rgb565 = NULL;
+const struct gl_texture_format *_dri_texformat_argb4444 = NULL;
+const struct gl_texture_format *_dri_texformat_argb1555 = NULL;
+const struct gl_texture_format *_dri_texformat_al88 = NULL;
+const struct gl_texture_format *_dri_texformat_a8 = &_mesa_texformat_a8;
+const struct gl_texture_format *_dri_texformat_ci8 = &_mesa_texformat_ci8;
+const struct gl_texture_format *_dri_texformat_i8 = &_mesa_texformat_i8;
+const struct gl_texture_format *_dri_texformat_l8 = &_mesa_texformat_l8;
+/*@}*/
+
+
+/**
+ * Initialize little endian target, host byte order independent texture formats
+ */
+void
+driInitTextureFormats(void)
+{
+ const GLuint ui = 1;
+ const GLubyte littleEndian = *((const GLubyte *) &ui);
+
+ if (littleEndian) {
+ _dri_texformat_rgba8888 = &_mesa_texformat_rgba8888;
+ _dri_texformat_argb8888 = &_mesa_texformat_argb8888;
+ _dri_texformat_rgb565 = &_mesa_texformat_rgb565;
+ _dri_texformat_argb4444 = &_mesa_texformat_argb4444;
+ _dri_texformat_argb1555 = &_mesa_texformat_argb1555;
+ _dri_texformat_al88 = &_mesa_texformat_al88;
+ }
+ else {
+ _dri_texformat_rgba8888 = &_mesa_texformat_rgba8888_rev;
+ _dri_texformat_argb8888 = &_mesa_texformat_argb8888_rev;
+ _dri_texformat_rgb565 = &_mesa_texformat_rgb565_rev;
+ _dri_texformat_argb4444 = &_mesa_texformat_argb4444_rev;
+ _dri_texformat_argb1555 = &_mesa_texformat_argb1555_rev;
+ _dri_texformat_al88 = &_mesa_texformat_al88_rev;
+ }
+}