summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuc Verhaegen <libv@skynet.be>2009-11-12 20:32:56 +0100
committerLuc Verhaegen <libv@skynet.be>2009-11-18 09:52:34 +0100
commit7653ada7f2a21ca420373f71123067ce7edf2f38 (patch)
tree6cb56cbbf5ff3069ef0244b1b25a4e5834c03d8c
parent51da8456cda9463031536b1daa3b204a97968db7 (diff)
DRI: Build and run against debian Squeeze's Mesa 7.6
-rw-r--r--.gitignore10
-rw-r--r--Makefile.am2
-rw-r--r--configure.ac7
-rw-r--r--dri/Makefile31
-rw-r--r--dri/Makefile.am44
-rw-r--r--dri/via_context.c25
-rw-r--r--dri/via_context.h4
-rw-r--r--dri/via_dri.h (renamed from src/via_dri.h)0
-rw-r--r--dri/via_ioctl.c2
-rw-r--r--dri/via_screen.c28
-rw-r--r--dri/via_screen.h4
-rw-r--r--dri/via_span.c46
-rw-r--r--dri/via_state.c10
-rw-r--r--dri/via_tex.c347
-rw-r--r--drm/Makefile11
-rw-r--r--src/via_dri.c2
16 files changed, 491 insertions, 82 deletions
diff --git a/.gitignore b/.gitignore
index 2b2ef0e..9635799 100644
--- a/.gitignore
+++ b/.gitignore
@@ -37,3 +37,13 @@ debian/xf86-video-unichrome.substvars
debian/xf86-video-unichrome
compile
*.pc
+dri/common
+dri/common2
+drm/*.cmd
+drm/.tmp_versions/
+drm/Module.markers
+drm/Module.symvers
+drm/modules.order
+drm/via.ko
+drm/via.mod.c
+
diff --git a/Makefile.am b/Makefile.am
index 3bdb643..bfef912 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -8,7 +8,7 @@ if BUILD_XVMCLIB
LIB_DIR = lib
endif
-SUBDIRS = src drm man $(LIB_DIR) $(WRAPPER_DIR)
+SUBDIRS = src drm dri man $(LIB_DIR) $(WRAPPER_DIR)
EXTRA_DIST = git_version.sh
BUILT_SOURCES = git_version.h
diff --git a/configure.ac b/configure.ac
index d7fcb01..4c29a2a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -28,7 +28,11 @@ if test "x$GCC" = "xyes"; then
CFLAGS="$CFLAGS -Wall -pedantic -std=gnu99"
fi
-AH_TOP([#include "xorg-server.h"])
+AH_TOP([
+#ifndef IN_DRI_DRIVER
+#include "xorg-server.h"
+#endif
+])
AC_ARG_WITH(xorg-module-dir,
AC_HELP_STRING([--with-xorg-module-dir=DIR],
@@ -264,5 +268,6 @@ XORG_RELEASE_VERSION
AC_OUTPUT([
Makefile
src/Makefile
+ dri/Makefile
man/Makefile
])
diff --git a/dri/Makefile b/dri/Makefile
deleted file mode 100644
index 344d34f..0000000
--- a/dri/Makefile
+++ /dev/null
@@ -1,31 +0,0 @@
-# src/mesa/drivers/dri/unichrome/Makefile
-
-TOP = ../../../../..
-include $(TOP)/configs/current
-
-LIBNAME = unichrome_dri.so
-
-MINIGLX_SOURCES = server/via_dri.c
-
-DRIVER_SOURCES = \
- via_context.c \
- via_fb.c \
- via_tex.c \
- via_ioctl.c \
- via_memcpy.c \
- via_render.c \
- via_screen.c \
- via_span.c \
- via_state.c \
- via_texcombine.c \
- via_tris.c
-
-C_SOURCES = \
- $(COMMON_SOURCES) \
- $(DRIVER_SOURCES)
-
-ASM_SOURCES =
-
-
-include ../Makefile.template
-
diff --git a/dri/Makefile.am b/dri/Makefile.am
new file mode 100644
index 0000000..e29834c
--- /dev/null
+++ b/dri/Makefile.am
@@ -0,0 +1,44 @@
+MESA_DIR = /root/debian/mesa-7.6/src/mesa
+#MESA_DIR = /usr/src/packages/BUILD/Mesa-7.2/src/mesa
+
+AM_CFLAGS = -DIN_DRI_DRIVER -D_GNU_SOURCE -g -O0
+AM_CFLAGS += -DUSE_X86_64_ASM -DPTHREADS -DHAVE_POSIX_MEMALIGN
+AM_CFLAGS += -DUSE_EXTERNAL_DXTN_LIB=1 -DGLX_DIRECT_RENDERING
+AM_CFLAGS += -DGLX_INDIRECT_RENDERING -DHAVE_ALIAS
+# -DREWORKED_TEXFORMAT
+
+AM_CFLAGS += -I/usr/include/drm -I$(MESA_DIR)/../../include/
+AM_CFLAGS += -I$(MESA_DIR) -I$(MESA_DIR)/main -I$(MESA_DIR)/glapi
+
+common: $(MESA_DIR)/drivers/dri/common
+ rm -f common
+ ln -fs $(MESA_DIR)/drivers/dri/common common
+common2: $(MESA_DIR)/drivers/common
+ rm -f common2
+ ln -fs $(MESA_DIR)/drivers/common common2
+BUILT_SOURCES = common common2
+
+unichrome_dri_la_LTLIBRARIES = unichrome_dri.la
+unichrome_dri_la_LDFLAGS = -module -noprefix -ldrm -lexpat -lm -lpthread -ldl
+unichrome_dri_la_LIBADD = $(MESA_DIR)/libmesa.a
+unichrome_dri_ladir = @libdir@/dri
+unichrome_dri_la_SOURCES = \
+ common/utils.c \
+ common/texmem.c \
+ common/vblank.c \
+ common/dri_util.c \
+ common/xmlconfig.c \
+ common/drirenderbuffer.c \
+ common/dri_metaops.c \
+ common2/driverfuncs.c \
+ via_context.c \
+ via_fb.c \
+ via_tex.c \
+ via_ioctl.c \
+ via_memcpy.c \
+ via_render.c \
+ via_screen.c \
+ via_span.c \
+ via_state.c \
+ via_texcombine.c \
+ via_tris.c
diff --git a/dri/via_context.c b/dri/via_context.c
index 0524bec..e61fd95 100644
--- a/dri/via_context.c
+++ b/dri/via_context.c
@@ -32,7 +32,8 @@
#include "main/glheader.h"
#include "main/context.h"
-#include "main/formats.h"
+//#include "main/formats.h"
+#include "main/texformat.h"
#include "main/matrix.h"
#include "main/state.h"
#include "main/simple_list.h"
@@ -61,17 +62,18 @@
#include <stdio.h>
#include "main/macros.h"
-#include "drirenderbuffer.h"
+#include "common/drirenderbuffer.h"
#define need_GL_ARB_point_parameters
#define need_GL_EXT_fog_coord
#define need_GL_EXT_secondary_color
-#include "main/remap_helper.h"
+//#include "main/remap_helper.h"
+#include "common/extension_helper.h"
#define DRIVER_DATE "20060710"
-#include "vblank.h"
-#include "utils.h"
+#include "common/vblank.h"
+#include "common/utils.h"
GLuint VIA_DEBUG = 0;
@@ -164,28 +166,28 @@ viaInitRenderbuffer(struct via_renderbuffer *vrb, GLenum format,
if (format == GL_RGBA) {
/* Color */
rb->_BaseFormat = GL_RGBA;
- rb->Format = MESA_FORMAT_ARGB8888;
+ //rb->Format = MESA_FORMAT_ARGB8888;
rb->DataType = GL_UNSIGNED_BYTE;
}
else if (format == GL_DEPTH_COMPONENT16) {
/* Depth */
rb->_BaseFormat = GL_DEPTH_COMPONENT;
/* we always Get/Put 32-bit Z values */
- rb->Format = MESA_FORMAT_Z16;
+ //rb->Format = MESA_FORMAT_Z16;
rb->DataType = GL_UNSIGNED_INT;
}
else if (format == GL_DEPTH_COMPONENT24) {
/* Depth */
rb->_BaseFormat = GL_DEPTH_COMPONENT;
/* we always Get/Put 32-bit Z values */
- rb->Format = MESA_FORMAT_Z32;
+ //rb->Format = MESA_FORMAT_Z32;
rb->DataType = GL_UNSIGNED_INT;
}
else {
/* Stencil */
ASSERT(format == GL_STENCIL_INDEX8_EXT);
rb->_BaseFormat = GL_STENCIL_INDEX;
- rb->Format = MESA_FORMAT_S8;
+ //rb->Format = MESA_FORMAT_S8;
rb->DataType = GL_UNSIGNED_BYTE;
}
@@ -367,7 +369,10 @@ void viaReAllocateBuffers(GLcontext *ctx, GLframebuffer *drawbuffer,
/* Extension strings exported by the Unichrome driver.
*/
-static const struct dri_extension card_extensions[] =
+#if 0
+static
+#endif
+const struct dri_extension card_extensions[] =
{
{ "GL_ARB_multitexture", NULL },
{ "GL_ARB_point_parameters", GL_ARB_point_parameters_functions },
diff --git a/dri/via_context.h b/dri/via_context.h
index 4cc9e47..bed0822 100644
--- a/dri/via_context.h
+++ b/dri/via_context.h
@@ -26,9 +26,9 @@
#ifndef _VIACONTEXT_H
#define _VIACONTEXT_H
-#include "dri_util.h"
+#include "common/dri_util.h"
-#include "drm.h"
+#include "drm/drm.h"
#include "main/mtypes.h"
#include "main/mm.h"
diff --git a/src/via_dri.h b/dri/via_dri.h
index 8d89a01..8d89a01 100644
--- a/src/via_dri.h
+++ b/dri/via_dri.h
diff --git a/dri/via_ioctl.c b/dri/via_ioctl.c
index b34c133..e169517 100644
--- a/dri/via_ioctl.c
+++ b/dri/via_ioctl.c
@@ -38,7 +38,7 @@
#include "via_fb.h"
#include "via_3d_reg.h"
-#include "vblank.h"
+#include "common/vblank.h"
#include "drm.h"
#include "xf86drm.h"
#include <sys/ioctl.h>
diff --git a/dri/via_screen.c b/dri/via_screen.c
index e0bf58c..ac6dd98 100644
--- a/dri/via_screen.c
+++ b/dri/via_screen.c
@@ -24,15 +24,15 @@
#include <stdio.h>
-#include "dri_util.h"
-#include "utils.h"
+#include "common/dri_util.h"
+#include "common/utils.h"
#include "main/glheader.h"
#include "main/context.h"
#include "main/framebuffer.h"
#include "main/renderbuffer.h"
#include "main/matrix.h"
#include "main/simple_list.h"
-#include "vblank.h"
+#include "common/vblank.h"
#include "via_state.h"
#include "via_tex.h"
@@ -44,9 +44,9 @@
#include "via_dri.h"
#include "GL/internal/dri_interface.h"
-#include "drirenderbuffer.h"
+#include "common/drirenderbuffer.h"
-#include "xmlpool.h"
+#include "common/xmlpool.h"
PUBLIC const char __driConfigOptions[] =
DRI_CONF_BEGIN
@@ -62,6 +62,10 @@ DRI_CONF_BEGIN
DRI_CONF_END;
static const GLuint __driNConfigOptions = 3;
+#if 1
+extern const struct dri_extension card_extensions[];
+#endif
+
static drmBufMapPtr via_create_empty_buffers(void)
{
drmBufMapPtr retval;
@@ -396,6 +400,20 @@ viaInitScreen(__DRIscreenPrivate *psp)
if (!viaInitDriver(psp))
return NULL;
+#if 1
+ /* Calling driInitExtensions here, with a NULL context pointer,
+ * does not actually enable the extensions. It just makes sure
+ * that all the dispatch offsets for all the extensions that
+ * *might* be enables are known. This is needed because the
+ * dispatch offsets need to be known when _mesa_context_create is
+ * called, but we can't enable the extensions until we have a
+ * context pointer.
+ *
+ * Hello chicken. Hello egg. How are you two today?
+ */
+ driInitExtensions( NULL, card_extensions, GL_FALSE );
+#endif
+
return viaFillInModes( psp, dri_priv->bytesPerPixel * 8, GL_TRUE );
}
diff --git a/dri/via_screen.h b/dri/via_screen.h
index c3ef722..bf25d5d 100644
--- a/dri/via_screen.h
+++ b/dri/via_screen.h
@@ -26,9 +26,9 @@
#define _VIAINIT_H
#include <sys/time.h>
-#include "dri_util.h"
+#include "common/dri_util.h"
#include "via_dri.h"
-#include "xmlconfig.h"
+#include "common/xmlconfig.h"
typedef struct {
viaRegion regs;
diff --git a/dri/via_span.c b/dri/via_span.c
index e847164..2c66bd2 100644
--- a/dri/via_span.c
+++ b/dri/via_span.c
@@ -23,7 +23,13 @@
*/
#include "main/glheader.h"
+
+#ifdef REWORKED_TEXFORMATS
#include "main/formats.h"
+#else
+#include "main/texformat.h"
+#endif
+
#include "main/macros.h"
#include "main/mtypes.h"
#include "main/colormac.h"
@@ -62,7 +68,7 @@
#define TAG(x) via##x##_565
#define TAG2(x,y) via##x##_565##y
-#include "spantmp2.h"
+#include "common/spantmp2.h"
/* 32 bit, ARGB8888 color spanline and pixel functions
@@ -73,7 +79,7 @@
#define TAG(x) via##x##_8888
#define TAG2(x,y) via##x##_8888##y
-#include "spantmp2.h"
+#include "common/spantmp2.h"
/* 16 bit depthbuffer functions.
@@ -96,7 +102,7 @@
d = *(volatile GLushort *)(buf + (_x) * 2 + (_y) * depth_pitch);
#define TAG(x) via##x##_z16
-#include "depthtmp.h"
+#include "common/depthtmp.h"
/* 32 bit depthbuffer functions.
*/
@@ -109,7 +115,7 @@
d = *(volatile GLuint *)(buf + (_x) * 4 + (_y) * depth_pitch);
#define TAG(x) via##x##_z32
-#include "depthtmp.h"
+#include "common/depthtmp.h"
@@ -129,7 +135,7 @@
#define TAG(x) via##x##_z24_s8
-#include "depthtmp.h"
+#include "common/depthtmp.h"
#define WRITE_STENCIL( _x, _y, d ) { \
GLuint tmp = *(GLuint *)(buf + (_x)*4 + (_y)*depth_pitch); \
@@ -142,7 +148,7 @@
d = *(GLuint *)(buf + (_x)*4 + (_y)*depth_pitch) & 0xff;
#define TAG(x) via##x##_z24_s8
-#include "stenciltmp.h"
+#include "common/stenciltmp.h"
@@ -175,6 +181,7 @@ void viaInitSpanFuncs(GLcontext *ctx)
/**
* Plug in the Get/Put routines for the given driRenderbuffer.
*/
+#ifdef REWORKED_TEXFORMAT
void
viaSetSpanFunctions(struct via_renderbuffer *vrb, const GLvisual *vis)
{
@@ -197,3 +204,30 @@ viaSetSpanFunctions(struct via_renderbuffer *vrb, const GLvisual *vis)
viaInitStencilPointers_z24_s8(&vrb->Base);
}
}
+#else /* REWORKED_TEXFORMAT */
+void
+viaSetSpanFunctions(struct via_renderbuffer *vrb, const GLvisual *vis)
+{
+ if (vrb->Base.InternalFormat == GL_RGBA) {
+ if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) {
+ viaInitPointers_565(&vrb->Base);
+ }
+ else {
+ viaInitPointers_8888(&vrb->Base);
+ }
+ }
+ else if (vrb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
+ viaInitDepthPointers_z16(&vrb->Base);
+ }
+ else if (vrb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
+ viaInitDepthPointers_z24_s8(&vrb->Base);
+ }
+ else if (vrb->Base.InternalFormat == GL_DEPTH_COMPONENT32) {
+ viaInitDepthPointers_z32(&vrb->Base);
+ }
+ else if (vrb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
+ viaInitStencilPointers_z24_s8(&vrb->Base);
+ }
+}
+#endif /* REWORKED_TEXFORMAT */
+
diff --git a/dri/via_state.c b/dri/via_state.c
index 840e4e4..e13b308 100644
--- a/dri/via_state.c
+++ b/dri/via_state.c
@@ -1341,8 +1341,14 @@ static void viaChoosePolygonState(GLcontext *ctx)
static void viaChooseStencilState(GLcontext *ctx)
{
struct via_context *vmesa = VIA_CONTEXT(ctx);
-
- if (ctx->Stencil._Enabled) {
+
+ if
+#if 1
+ (ctx->Stencil._Enabled)
+#else
+ (ctx->Stencil.Enabled)
+#endif
+ {
GLuint temp;
vmesa->regEnable |= HC_HenST_MASK;
diff --git a/dri/via_tex.c b/dri/via_tex.c
index 24924d2..9f002e7 100644
--- a/dri/via_tex.c
+++ b/dri/via_tex.c
@@ -22,7 +22,6 @@
* DEALINGS IN THE SOFTWARE.
*/
-
#include <stdlib.h>
#include <stdio.h>
@@ -30,7 +29,6 @@
#include "main/macros.h"
#include "main/mtypes.h"
#include "main/enums.h"
-#include "main/formats.h"
#include "main/colortab.h"
#include "main/convolve.h"
#include "main/context.h"
@@ -38,6 +36,13 @@
#include "main/mm.h"
#include "main/simple_list.h"
#include "main/texcompress.h"
+
+#ifdef REWORKED_TEXFORMAT
+#include "main/formats.h"
+#else
+#include "main/texformat.h"
+#endif
+
#include "main/texobj.h"
#include "main/texstore.h"
@@ -48,6 +53,7 @@
#include "via_ioctl.h"
#include "via_3d_reg.h"
+#ifdef REWORKED_TEXFORMAT
static gl_format
viaChooseTexFormat( GLcontext *ctx, GLint internalFormat,
GLenum format, GLenum type )
@@ -199,6 +205,160 @@ viaChooseTexFormat( GLcontext *ctx, GLint internalFormat,
return MESA_FORMAT_NONE; /* never get here */
}
+#else /* REWORKED_TEXFORMAT */
+
+static const struct gl_texture_format *
+viaChooseTexFormat( GLcontext *ctx, GLint internalFormat,
+ GLenum format, GLenum type )
+{
+ struct via_context *vmesa = VIA_CONTEXT(ctx);
+ const GLboolean do32bpt = ( vmesa->viaScreen->bitsPerPixel == 32
+/* && vmesa->viaScreen->textureSize > 4*1024*1024 */
+ );
+
+
+ switch ( internalFormat ) {
+ case 4:
+ case GL_RGBA:
+ case GL_COMPRESSED_RGBA:
+ if ( format == GL_BGRA ) {
+ if ( type == GL_UNSIGNED_INT_8_8_8_8_REV ||
+ type == GL_UNSIGNED_BYTE ) {
+ return &_mesa_texformat_argb8888;
+ }
+ else if ( type == GL_UNSIGNED_SHORT_4_4_4_4_REV ) {
+ return &_mesa_texformat_argb4444;
+ }
+ else if ( type == GL_UNSIGNED_SHORT_1_5_5_5_REV ) {
+ return &_mesa_texformat_argb1555;
+ }
+ }
+ else if ( type == GL_UNSIGNED_BYTE ||
+ type == GL_UNSIGNED_INT_8_8_8_8_REV ||
+ type == GL_UNSIGNED_INT_8_8_8_8 ) {
+ return &_mesa_texformat_argb8888;
+ }
+ return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444;
+
+ case 3:
+ case GL_RGB:
+ case GL_COMPRESSED_RGB:
+ if ( format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5 ) {
+ return &_mesa_texformat_rgb565;
+ }
+ else if ( type == GL_UNSIGNED_BYTE ) {
+ return &_mesa_texformat_argb8888;
+ }
+ return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_rgb565;
+
+ case GL_RGBA8:
+ case GL_RGB10_A2:
+ case GL_RGBA12:
+ case GL_RGBA16:
+ return &_mesa_texformat_argb8888;
+
+ case GL_RGBA4:
+ case GL_RGBA2:
+ return &_mesa_texformat_argb4444;
+
+ case GL_RGB5_A1:
+ return &_mesa_texformat_argb1555;
+
+ case GL_RGB8:
+ case GL_RGB10:
+ case GL_RGB12:
+ case GL_RGB16:
+ return &_mesa_texformat_argb8888;
+
+ case GL_RGB5:
+ case GL_RGB4:
+ case GL_R3_G3_B2:
+ return &_mesa_texformat_rgb565;
+
+ case GL_ALPHA:
+ case GL_ALPHA4:
+ case GL_ALPHA8:
+ case GL_ALPHA12:
+ case GL_ALPHA16:
+ case GL_COMPRESSED_ALPHA:
+ return &_mesa_texformat_a8;
+
+ case 1:
+ case GL_LUMINANCE:
+ case GL_LUMINANCE4:
+ case GL_LUMINANCE8:
+ case GL_LUMINANCE12:
+ case GL_LUMINANCE16:
+ case GL_COMPRESSED_LUMINANCE:
+ return &_mesa_texformat_l8;
+
+ case 2:
+ case GL_LUMINANCE_ALPHA:
+ case GL_LUMINANCE4_ALPHA4:
+ case GL_LUMINANCE6_ALPHA2:
+ case GL_LUMINANCE8_ALPHA8:
+ case GL_LUMINANCE12_ALPHA4:
+ case GL_LUMINANCE12_ALPHA12:
+ case GL_LUMINANCE16_ALPHA16:
+ case GL_COMPRESSED_LUMINANCE_ALPHA:
+ return &_mesa_texformat_al88;
+
+ case GL_INTENSITY:
+ case GL_INTENSITY4:
+ case GL_INTENSITY8:
+ case GL_INTENSITY12:
+ case GL_INTENSITY16:
+ case GL_COMPRESSED_INTENSITY:
+ return &_mesa_texformat_i8;
+
+ case GL_YCBCR_MESA:
+ if (type == GL_UNSIGNED_SHORT_8_8_MESA ||
+ type == GL_UNSIGNED_BYTE)
+ return &_mesa_texformat_ycbcr;
+ else
+ return &_mesa_texformat_ycbcr_rev;
+
+ case GL_COMPRESSED_RGB_FXT1_3DFX:
+ return &_mesa_texformat_rgb_fxt1;
+ 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;
+
+ case GL_COLOR_INDEX:
+ case GL_COLOR_INDEX1_EXT:
+ case GL_COLOR_INDEX2_EXT:
+ case GL_COLOR_INDEX4_EXT:
+ case GL_COLOR_INDEX8_EXT:
+ case GL_COLOR_INDEX12_EXT:
+ case GL_COLOR_INDEX16_EXT:
+ return &_mesa_texformat_ci8;
+
+ default:
+ fprintf(stderr, "unexpected texture format %s in %s\n",
+ _mesa_lookup_enum_by_nr(internalFormat),
+ __FUNCTION__);
+ return NULL;
+ }
+
+ return NULL; /* never get here */
+}
+#endif /* REWORKED_TEXFORMAT */
+
static int logbase2(int n)
{
GLint i = 1;
@@ -457,7 +617,12 @@ static GLboolean viaSetTexImages(GLcontext *ctx,
GLuint widthExp = 0;
GLuint heightExp = 0;
- switch (baseImage->image.TexFormat) {
+#ifdef REWORKED_TEXFORMAT
+ switch (baseImage->image.TexFormat)
+#else
+ switch (baseImage->image.TexFormat->MesaFormat)
+#endif
+ {
case MESA_FORMAT_ARGB8888:
texFormat = HC_HTXnFM_ARGB8888;
break;
@@ -648,12 +813,7 @@ GLboolean viaUpdateTextureState( GLcontext *ctx )
return GL_TRUE;
}
-
-
-
-
-
-
+#ifdef REWORKED_TEXFORMAT
static void viaTexImage(GLcontext *ctx,
GLint dims,
@@ -807,6 +967,175 @@ static void viaTexImage(GLcontext *ctx,
_mesa_unmap_teximage_pbo(ctx, packing);
}
+#else /* REWORKED_TEXFORMAT */
+
+static void viaTexImage(GLcontext *ctx,
+ GLint dims,
+ GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint height, GLint border,
+ GLenum format, GLenum type, const void *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage)
+{
+ struct via_context *vmesa = VIA_CONTEXT(ctx);
+ GLint postConvWidth = width;
+ GLint postConvHeight = height;
+ GLint texelBytes, sizeInBytes;
+ struct via_texture_object *viaObj = (struct via_texture_object *)texObj;
+ struct via_texture_image *viaImage = (struct via_texture_image *)texImage;
+ int heaps[3], nheaps, i;
+
+ if (!is_empty_list(&vmesa->freed_tex_buffers)) {
+ viaCheckBreadcrumb(vmesa, 0);
+ via_release_pending_textures(vmesa);
+ }
+
+ if (ctx->_ImageTransferState & IMAGE_CONVOLUTION_BIT) {
+ _mesa_adjust_image_for_convolution(ctx, dims, &postConvWidth,
+ &postConvHeight);
+ }
+
+ /* choose the texture format */
+ texImage->TexFormat = viaChooseTexFormat(ctx, internalFormat,
+ format, type);
+
+ assert(texImage->TexFormat);
+
+ if (dims == 1) {
+ texImage->FetchTexelc = texImage->TexFormat->FetchTexel1D;
+ texImage->FetchTexelf = texImage->TexFormat->FetchTexel1Df;
+ }
+ else {
+ texImage->FetchTexelc = texImage->TexFormat->FetchTexel2D;
+ texImage->FetchTexelf = texImage->TexFormat->FetchTexel2Df;
+ }
+ texelBytes = texImage->TexFormat->TexelBytes;
+
+ if (texelBytes == 0) {
+ /* compressed format */
+ texImage->IsCompressed = GL_TRUE;
+ texImage->CompressedSize =
+ ctx->Driver.CompressedTextureSize(ctx, texImage->Width,
+ texImage->Height, texImage->Depth,
+ texImage->TexFormat->MesaFormat);
+ }
+
+ /* Minimum pitch of 32 bytes */
+ if (postConvWidth * texelBytes < 32) {
+ postConvWidth = 32 / texelBytes;
+ texImage->RowStride = postConvWidth;
+ }
+
+ assert(texImage->RowStride == postConvWidth);
+ viaImage->pitchLog2 = logbase2(postConvWidth * texelBytes);
+
+ /* allocate memory */
+ if (texImage->IsCompressed)
+ sizeInBytes = texImage->CompressedSize;
+ else
+ sizeInBytes = postConvWidth * postConvHeight * texelBytes;
+
+
+ /* Attempt to allocate texture memory directly, otherwise use main
+ * memory and this texture will always be a fallback. FIXME!
+ *
+ * TODO: make room in agp if this fails.
+ * TODO: use fb ram for textures as well.
+ */
+
+
+ switch (viaObj->memType) {
+ case VIA_MEM_UNKNOWN:
+ heaps[0] = VIA_MEM_AGP;
+ heaps[1] = VIA_MEM_VIDEO;
+ heaps[2] = VIA_MEM_SYSTEM;
+ nheaps = 3;
+ break;
+ case VIA_MEM_AGP:
+ case VIA_MEM_VIDEO:
+ heaps[0] = viaObj->memType;
+ heaps[1] = VIA_MEM_SYSTEM;
+ nheaps = 2;
+ break;
+ case VIA_MEM_MIXED:
+ case VIA_MEM_SYSTEM:
+ default:
+ heaps[0] = VIA_MEM_SYSTEM;
+ nheaps = 1;
+ break;
+ }
+
+ for (i = 0; i < nheaps && !viaImage->texMem; i++) {
+ if (VIA_DEBUG & DEBUG_TEXTURE)
+ fprintf(stderr, "try %s (obj %s)\n", get_memtype_name(heaps[i]),
+ get_memtype_name(viaObj->memType));
+ viaImage->texMem = via_alloc_texture(vmesa, sizeInBytes, heaps[i]);
+ }
+
+ if (!viaImage->texMem) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage");
+ return;
+ }
+
+ if (VIA_DEBUG & DEBUG_TEXTURE)
+ fprintf(stderr, "upload %d bytes to %s\n", sizeInBytes,
+ get_memtype_name(viaImage->texMem->memType));
+
+ viaImage->texMem->image = viaImage;
+ texImage->Data = viaImage->texMem->bufAddr;
+
+ if (viaObj->memType == VIA_MEM_UNKNOWN)
+ viaObj->memType = viaImage->texMem->memType;
+ else if (viaObj->memType != viaImage->texMem->memType)
+ viaObj->memType = VIA_MEM_MIXED;
+
+ if (VIA_DEBUG & DEBUG_TEXTURE)
+ fprintf(stderr, "%s, obj %s, image : %s\n",
+ __FUNCTION__,
+ get_memtype_name(viaObj->memType),
+ get_memtype_name(viaImage->texMem->memType));
+
+ vmesa->clearTexCache = 1;
+
+ pixels = _mesa_validate_pbo_teximage(ctx, dims, width, height, 1,
+ format, type,
+ pixels, packing, "glTexImage");
+ if (!pixels) {
+ /* Note: we check for a NULL image pointer here, _after_ we allocated
+ * memory for the texture. That's what the GL spec calls for.
+ */
+ return;
+ }
+ else {
+ GLint dstRowStride;
+ GLboolean success;
+ if (texImage->IsCompressed) {
+ dstRowStride = _mesa_compressed_row_stride(texImage->TexFormat->MesaFormat, width);
+ }
+ else {
+ dstRowStride = postConvWidth * texImage->TexFormat->TexelBytes;
+ }
+ ASSERT(texImage->TexFormat->StoreImage);
+ success = texImage->TexFormat->StoreImage(ctx, dims,
+ texImage->_BaseFormat,
+ texImage->TexFormat,
+ texImage->Data,
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ dstRowStride,
+ texImage->ImageOffsets,
+ width, height, 1,
+ format, type, pixels, packing);
+ if (!success) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage");
+ }
+ }
+
+ _mesa_unmap_teximage_pbo(ctx, packing);
+}
+#endif /* REWORKED_TEXFORMAT */
+
static void viaTexImage2D(GLcontext *ctx,
GLenum target, GLint level,
GLint internalFormat,
diff --git a/drm/Makefile b/drm/Makefile
deleted file mode 100644
index f661ed6..0000000
--- a/drm/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-KERNELDIR := /lib/modules/`uname -r`/build
-
-all:
- $(MAKE) -C $(KERNELDIR) V=1 M=`pwd` modules
-
-install:
- $(MAKE) -C $(KERNELDIR) M=`pwd` modules_install
-
-clean:
- $(MAKE) -C $(KERNELDIR) M=`pwd` clean
-
diff --git a/src/via_dri.c b/src/via_dri.c
index 0a63100..ef6480b 100644
--- a/src/via_dri.c
+++ b/src/via_dri.c
@@ -50,7 +50,7 @@
#include "via_driver.h"
#include "../drm/via_drm.h"
-#include "via_dri.h"
+#include "../dri/via_dri.h"
#include "via_id.h"
#include "xf86drm.h"