summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/drivers/dri')
-rw-r--r--src/mesa/drivers/dri/Makefile2
-rw-r--r--src/mesa/drivers/dri/Makefile.template14
-rw-r--r--src/mesa/drivers/dri/common/dri_util.c3
-rw-r--r--src/mesa/drivers/dri/common/dri_util.h6
-rw-r--r--src/mesa/drivers/dri/common/extension_helper.h14
-rw-r--r--src/mesa/drivers/dri/ffb/ffb_tris.c8
-rw-r--r--src/mesa/drivers/dri/i915/i830_state.c9
-rw-r--r--src/mesa/drivers/dri/i915/i915_fragprog.c8
-rw-r--r--src/mesa/drivers/dri/i915/i915_state.c11
-rw-r--r--src/mesa/drivers/dri/i915/i915_texstate.c27
-rw-r--r--src/mesa/drivers/dri/i915/intel_context.c103
-rw-r--r--src/mesa/drivers/dri/i915/intel_context.h5
-rw-r--r--src/mesa/drivers/dri/i915/intel_screen.c4
-rw-r--r--src/mesa/drivers/dri/i915/intel_tex.c40
-rw-r--r--src/mesa/drivers/dri/i915tex/i830_reg.h1
-rw-r--r--src/mesa/drivers/dri/i915tex/i830_state.c4
-rw-r--r--src/mesa/drivers/dri/i915tex/i830_texstate.c41
-rw-r--r--src/mesa/drivers/dri/i915tex/i915_fragprog.c8
-rw-r--r--src/mesa/drivers/dri/i915tex/i915_state.c4
-rw-r--r--src/mesa/drivers/dri/i915tex/i915_tex_layout.c6
-rw-r--r--src/mesa/drivers/dri/i915tex/i915_texstate.c49
-rw-r--r--src/mesa/drivers/dri/i915tex/i915_vtbl.c6
-rw-r--r--src/mesa/drivers/dri/i915tex/intel_context.c12
-rw-r--r--src/mesa/drivers/dri/i915tex/intel_context.h9
-rw-r--r--src/mesa/drivers/dri/i915tex/intel_mipmap_tree.c4
-rw-r--r--src/mesa/drivers/dri/i915tex/intel_screen.c7
-rw-r--r--src/mesa/drivers/dri/i915tex/intel_state.c94
-rw-r--r--src/mesa/drivers/dri/i915tex/intel_tex.h3
-rw-r--r--src/mesa/drivers/dri/i915tex/intel_tex_image.c24
-rw-r--r--src/mesa/drivers/dri/i915tex/intel_tex_validate.c17
-rw-r--r--src/mesa/drivers/dri/i965/brw_draw.c1
-rw-r--r--src/mesa/drivers/dri/i965/brw_vs_tnl.c22
-rw-r--r--src/mesa/drivers/dri/i965/intel_context.c13
-rw-r--r--src/mesa/drivers/dri/i965/intel_context.h2
-rw-r--r--src/mesa/drivers/dri/i965/intel_state.c96
-rw-r--r--src/mesa/drivers/dri/intel/intel_tex_layout.c2
-rw-r--r--src/mesa/drivers/dri/mach64/mach64_native_vb.c18
-rw-r--r--src/mesa/drivers/dri/r200/r200_cmdbuf.c1
-rw-r--r--src/mesa/drivers/dri/r200/r200_context.c2
-rw-r--r--src/mesa/drivers/dri/r200/r200_context.h1
-rw-r--r--src/mesa/drivers/dri/r200/r200_ioctl.c1
-rw-r--r--src/mesa/drivers/dri/r200/r200_ioctl.h1
-rw-r--r--src/mesa/drivers/dri/r200/r200_lock.c1
-rw-r--r--src/mesa/drivers/dri/r200/r200_lock.h1
-rw-r--r--src/mesa/drivers/dri/r200/r200_maos.h1
-rw-r--r--src/mesa/drivers/dri/r200/r200_maos_arrays.c1
-rw-r--r--src/mesa/drivers/dri/r200/r200_pixel.c1
-rw-r--r--src/mesa/drivers/dri/r200/r200_pixel.h1
-rw-r--r--src/mesa/drivers/dri/r200/r200_reg.h1
-rw-r--r--src/mesa/drivers/dri/r200/r200_sanity.c1
-rw-r--r--src/mesa/drivers/dri/r200/r200_span.c1
-rw-r--r--src/mesa/drivers/dri/r200/r200_span.h1
-rw-r--r--src/mesa/drivers/dri/r200/r200_state.c1
-rw-r--r--src/mesa/drivers/dri/r200/r200_state.h1
-rw-r--r--src/mesa/drivers/dri/r200/r200_state_init.c1
-rw-r--r--src/mesa/drivers/dri/r200/r200_swtcl.c1
-rw-r--r--src/mesa/drivers/dri/r200/r200_swtcl.h1
-rw-r--r--src/mesa/drivers/dri/r200/r200_tcl.c1
-rw-r--r--src/mesa/drivers/dri/r200/r200_tcl.h1
-rw-r--r--src/mesa/drivers/dri/r200/r200_tex.c7
-rw-r--r--src/mesa/drivers/dri/r200/r200_tex.h1
-rw-r--r--src/mesa/drivers/dri/r200/r200_texmem.c1
-rw-r--r--src/mesa/drivers/dri/r200/r200_texstate.c1
-rw-r--r--src/mesa/drivers/dri/r300/Makefile2
-rw-r--r--src/mesa/drivers/dri/r300/r300_cmdbuf.c356
-rw-r--r--src/mesa/drivers/dri/r300/r300_cmdbuf.h8
-rw-r--r--src/mesa/drivers/dri/r300/r300_context.c11
-rw-r--r--src/mesa/drivers/dri/r300/r300_context.h95
-rw-r--r--src/mesa/drivers/dri/r300/r300_emit.c534
-rw-r--r--src/mesa/drivers/dri/r300/r300_emit.h73
-rw-r--r--src/mesa/drivers/dri/r300/r300_fragprog.c2
-rw-r--r--src/mesa/drivers/dri/r300/r300_ioctl.c91
-rw-r--r--src/mesa/drivers/dri/r300/r300_ioctl.h3
-rw-r--r--src/mesa/drivers/dri/r300/r300_maos.c665
-rw-r--r--src/mesa/drivers/dri/r300/r300_maos.h50
-rw-r--r--src/mesa/drivers/dri/r300/r300_mem.c397
-rw-r--r--src/mesa/drivers/dri/r300/r300_mem.h7
-rw-r--r--src/mesa/drivers/dri/r300/r300_reg.h30
-rw-r--r--src/mesa/drivers/dri/r300/r300_render.c233
-rw-r--r--src/mesa/drivers/dri/r300/r300_shader.c20
-rw-r--r--src/mesa/drivers/dri/r300/r300_state.c849
-rw-r--r--src/mesa/drivers/dri/r300/r300_state.h8
-rw-r--r--src/mesa/drivers/dri/r300/r300_tex.c113
-rw-r--r--src/mesa/drivers/dri/r300/r300_tex.h4
-rw-r--r--src/mesa/drivers/dri/r300/r300_texmem.c44
-rw-r--r--src/mesa/drivers/dri/r300/r300_texstate.c187
-rw-r--r--src/mesa/drivers/dri/r300/r300_vertprog.c2
-rw-r--r--src/mesa/drivers/dri/r300/radeon_lock.c113
-rw-r--r--src/mesa/drivers/dri/r300/radeon_lock.h56
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_context.c2
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_lock.c117
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_lock.h26
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_screen.c4
-rw-r--r--src/mesa/drivers/dri/s3v/s3v_tritmp.h46
-rw-r--r--src/mesa/drivers/dri/tdfx/tdfx_tris.c16
95 files changed, 2044 insertions, 2850 deletions
diff --git a/src/mesa/drivers/dri/Makefile b/src/mesa/drivers/dri/Makefile
index 4abcc16c1bc..f466ce6c3cc 100644
--- a/src/mesa/drivers/dri/Makefile
+++ b/src/mesa/drivers/dri/Makefile
@@ -32,7 +32,7 @@ install:
clean:
@for dir in $(DRI_DIRS) ; do \
if [ -d $$dir ] ; then \
- (cd $$dir && $(MAKE) clean ; \
+ (cd $$dir && $(MAKE) clean) ; \
fi \
done
-rm -f common/*.o
diff --git a/src/mesa/drivers/dri/Makefile.template b/src/mesa/drivers/dri/Makefile.template
index 26f9bb74c87..6f2314ee8cb 100644
--- a/src/mesa/drivers/dri/Makefile.template
+++ b/src/mesa/drivers/dri/Makefile.template
@@ -25,6 +25,7 @@ OBJECTS = $(C_SOURCES:.c=.o) \
$(ASM_SOURCES:.S=.o)
else
+# miniglx
WINOBJ=
WINLIB=-L$(MESA)/src/glx/mini
MINIGLX_INCLUDES = -I$(TOP)/src/glx/mini
@@ -55,7 +56,8 @@ SHARED_INCLUDES = \
-I$(TOP)/src/mesa/swrast_setup \
-I$(TOP)/src/egl/main \
-I$(TOP)/src/egl/drivers/dri \
- `pkg-config --cflags libdrm`
+ $(LIBDRM_CFLAGS)
+
##### RULES #####
@@ -71,11 +73,6 @@ SHARED_INCLUDES = \
default: depend symlinks $(LIBNAME) $(TOP)/$(LIB_DIR)/$(LIBNAME)
-#$(TOP)/$(LIB_DIR)/$(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(WINOBJ) Makefile
-# @echo BUILDING FOR: $(WINDOW_SYSTEM)
-# $(TOP)/bin/mklib -o $(LIBNAME) -noprefix -install $(TOP)/$(LIB_DIR) \
-# $(WINLIB) $(LIB_DEPS) $(WINOBJ) $(MESA_MODULES) $(OBJECTS)
-
$(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(WINOBJ) Makefile $(TOP)/src/mesa/drivers/dri/Makefile.template
$(TOP)/bin/mklib -noprefix -o $@ \
$(OBJECTS) $(MESA_MODULES) $(WINOBJ) $(DRI_LIB_DEPS)
@@ -85,9 +82,6 @@ $(TOP)/$(LIB_DIR)/$(LIBNAME): $(LIBNAME)
$(INSTALL) $(LIBNAME) $(TOP)/$(LIB_DIR)
-
-# Run 'make depend' to update the dependencies if you change
-# what's included by any source file.
depend: $(C_SOURCES) $(ASM_SOURCES) $(SYMLINKS)
touch depend
$(MKDEP) $(MKDEP_OPTIONS) $(DRIVER_DEFINES) $(INCLUDES) $(C_SOURCES) \
@@ -104,8 +98,10 @@ clean:
-rm -f *.o */*.o *~ *.so *~ server/*.o $(SYMLINKS)
-rm -f depend depend.bak
+
install: $(LIBNAME)
$(INSTALL) -d $(DRI_DRIVER_INSTALL_DIR)
$(INSTALL) -m 755 $(LIBNAME) $(DRI_DRIVER_INSTALL_DIR)
+
include depend
diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c
index 07ac4c7cd5f..dd52f7e9151 100644
--- a/src/mesa/drivers/dri/common/dri_util.c
+++ b/src/mesa/drivers/dri/common/dri_util.c
@@ -995,6 +995,9 @@ __driUtilCreateNewScreen(__DRInativeDisplay *dpy, int scrn, __DRIscreen *psc,
psc->getMSC = driGetMSC;
psc->createNewContext = driCreateNewContext;
+ if (internal_api_version >= 20070121)
+ psc->setTexOffset = psp->DriverAPI.setTexOffset;
+
if ( (psp->DriverAPI.InitDriver != NULL)
&& !(*psp->DriverAPI.InitDriver)(psp) ) {
_mesa_free( psp );
diff --git a/src/mesa/drivers/dri/common/dri_util.h b/src/mesa/drivers/dri/common/dri_util.h
index 8639535abb2..539d28d1149 100644
--- a/src/mesa/drivers/dri/common/dri_util.h
+++ b/src/mesa/drivers/dri/common/dri_util.h
@@ -189,6 +189,12 @@ struct __DriverAPIRec {
/*@}*/
void (*CopySubBuffer)(__DRIdrawablePrivate *driDrawPriv,
int x, int y, int w, int h);
+
+ /**
+ * See corresponding field in \c __DRIscreenRec.
+ */
+ void (*setTexOffset)(__DRIcontext *pDRICtx, GLint texname,
+ unsigned long long offset, GLint depth, GLuint pitch);
};
diff --git a/src/mesa/drivers/dri/common/extension_helper.h b/src/mesa/drivers/dri/common/extension_helper.h
index c7984964255..10f75edaaa4 100644
--- a/src/mesa/drivers/dri/common/extension_helper.h
+++ b/src/mesa/drivers/dri/common/extension_helper.h
@@ -440,6 +440,13 @@ static const char Color4ubVertex3fvSUN_names[] =
"";
#endif
+#if defined(need_GL_EXT_texture_array)
+static const char FramebufferTextureLayerEXT_names[] =
+ "iiiii\0" /* Parameter signature */
+ "glFramebufferTextureLayerEXT\0"
+ "";
+#endif
+
#if defined(need_GL_SGIX_list_priority)
static const char GetListParameterivSGIX_names[] =
"iip\0" /* Parameter signature */
@@ -5479,6 +5486,13 @@ static const struct dri_extension_function GL_EXT_texture3D_functions[] = {
};
#endif
+#if defined(need_GL_EXT_texture_array)
+static const struct dri_extension_function GL_EXT_texture_array_functions[] = {
+ { FramebufferTextureLayerEXT_names, FramebufferTextureLayerEXT_remap_index, -1 },
+ { NULL, 0, 0 }
+};
+#endif
+
#if defined(need_GL_EXT_texture_object)
static const struct dri_extension_function GL_EXT_texture_object_functions[] = {
{ PrioritizeTextures_names, -1, 331 },
diff --git a/src/mesa/drivers/dri/ffb/ffb_tris.c b/src/mesa/drivers/dri/ffb/ffb_tris.c
index ca0e514dc0e..9fae8c8283e 100644
--- a/src/mesa/drivers/dri/ffb/ffb_tris.c
+++ b/src/mesa/drivers/dri/ffb/ffb_tris.c
@@ -138,10 +138,10 @@ static void ffb_translate_vertex(GLcontext *ctx, const ffb_vertex *src,
const GLfloat ty = m[13];
const GLfloat tz = m[14];
- dst->win[0] = sx * src->x + tx;
- dst->win[1] = sy * src->y + ty;
- dst->win[2] = sz * src->z + tz;
- dst->win[3] = 1.0;
+ dst->attrib[FRAG_ATTRIB_WPOS][0] = sx * src->x + tx;
+ dst->attrib[FRAG_ATTRIB_WPOS][1] = sy * src->y + ty;
+ dst->attrib[FRAG_ATTRIB_WPOS][2] = sz * src->z + tz;
+ dst->attrib[FRAG_ATTRIB_WPOS][3] = 1.0;
dst->color[0] = FFB_UBYTE_FROM_COLOR(src->color[0].red);
dst->color[1] = FFB_UBYTE_FROM_COLOR(src->color[0].green);
diff --git a/src/mesa/drivers/dri/i915/i830_state.c b/src/mesa/drivers/dri/i915/i830_state.c
index 95125190108..f7980201f9a 100644
--- a/src/mesa/drivers/dri/i915/i830_state.c
+++ b/src/mesa/drivers/dri/i915/i830_state.c
@@ -34,6 +34,8 @@
#include "texmem.h"
+#include "drivers/common/driverfuncs.h"
+
#include "intel_screen.h"
#include "intel_batchbuffer.h"
@@ -1074,7 +1076,7 @@ void i830InitState( i830ContextPtr i830 )
i830_init_packets( i830 );
- intelInitState( ctx );
+ _mesa_init_driver_state(ctx);
memcpy( &i830->initial, &i830->state, sizeof(i830->state) );
@@ -1085,8 +1087,3 @@ void i830InitState( i830ContextPtr i830 )
I830_UPLOAD_CTX |
I830_UPLOAD_BUFFERS);
}
-
-
-
-
-
diff --git a/src/mesa/drivers/dri/i915/i915_fragprog.c b/src/mesa/drivers/dri/i915/i915_fragprog.c
index a28c8bb6fc2..702b8788282 100644
--- a/src/mesa/drivers/dri/i915/i915_fragprog.c
+++ b/src/mesa/drivers/dri/i915/i915_fragprog.c
@@ -857,11 +857,6 @@ static void i915BindProgram( GLcontext *ctx,
assert(p->on_hardware == 0);
assert(p->params_uptodate == 0);
- /* Hack: make sure fog is correctly enabled according to this
- * fragment program's fog options.
- */
- ctx->Driver.Enable( ctx, GL_FRAGMENT_PROGRAM_ARB,
- ctx->FragmentProgram.Enabled );
}
}
@@ -935,9 +930,6 @@ static void i915ProgramStringNotify( GLcontext *ctx,
/* Hack: make sure fog is correctly enabled according to this
* fragment program's fog options.
*/
- ctx->Driver.Enable( ctx, GL_FRAGMENT_PROGRAM_ARB,
- ctx->FragmentProgram.Enabled );
-
if (p->FragProg.FogOption) {
/* add extra instructions to do fog, then turn off FogOption field */
_mesa_append_fog_code(ctx, &p->FragProg);
diff --git a/src/mesa/drivers/dri/i915/i915_state.c b/src/mesa/drivers/dri/i915/i915_state.c
index 0d5ca32969a..1c4ec747558 100644
--- a/src/mesa/drivers/dri/i915/i915_state.c
+++ b/src/mesa/drivers/dri/i915/i915_state.c
@@ -36,6 +36,8 @@
#include "texmem.h"
+#include "drivers/common/driverfuncs.h"
+
#include "intel_screen.h"
#include "intel_batchbuffer.h"
@@ -961,15 +963,8 @@ void i915InitState( i915ContextPtr i915 )
i915_init_packets( i915 );
- intelInitState( ctx );
+ _mesa_init_driver_state(ctx);
memcpy( &i915->initial, &i915->state, sizeof(i915->state) );
i915->current = &i915->state;
}
-
-
-
-
-
-
-
diff --git a/src/mesa/drivers/dri/i915/i915_texstate.c b/src/mesa/drivers/dri/i915/i915_texstate.c
index 3b639e71443..a19d4b65840 100644
--- a/src/mesa/drivers/dri/i915/i915_texstate.c
+++ b/src/mesa/drivers/dri/i915/i915_texstate.c
@@ -172,12 +172,8 @@ static void i915LayoutTextureImages( i915ContextPtr i915,
t->intel.image[0][i].offset = total_height * pitch;
t->intel.image[0][i].internalFormat = baseImage->_BaseFormat;
- if (t->intel.image[0][i].image->IsCompressed)
- {
- if (t->intel.image[0][i].image->Height > 4)
- total_height += t->intel.image[0][i].image->Height/4;
- else
- total_height += 1;
+ if (t->intel.image[0][i].image->IsCompressed) {
+ total_height += (t->intel.image[0][i].image->Height + 3) / 4;
}
else
total_height += MAX2(2, t->intel.image[0][i].image->Height);
@@ -495,12 +491,19 @@ static void i915SetTexImages( i915ContextPtr i915,
abort();
}
-
- if (i915->intel.intelScreen->deviceID == PCI_CHIP_I945_G ||
- i915->intel.intelScreen->deviceID == PCI_CHIP_I945_GM)
- i945LayoutTextureImages( i915, tObj );
- else
- i915LayoutTextureImages( i915, tObj );
+ switch (i915->intel.intelScreen->deviceID) {
+ case PCI_CHIP_I945_G:
+ case PCI_CHIP_I945_GM:
+ case PCI_CHIP_I945_GME:
+ case PCI_CHIP_G33_G:
+ case PCI_CHIP_Q33_G:
+ case PCI_CHIP_Q35_G:
+ i945LayoutTextureImages( i915, tObj );
+ break;
+ default:
+ i915LayoutTextureImages( i915, tObj );
+ break;
+ }
t->Setup[I915_TEXREG_MS3] =
(((tObj->Image[0][t->intel.base.firstLevel]->Height - 1) << MS3_HEIGHT_SHIFT) |
diff --git a/src/mesa/drivers/dri/i915/intel_context.c b/src/mesa/drivers/dri/i915/intel_context.c
index e1e7cdb7233..11c23f24a1b 100644
--- a/src/mesa/drivers/dri/i915/intel_context.c
+++ b/src/mesa/drivers/dri/i915/intel_context.c
@@ -123,6 +123,14 @@ const GLubyte *intelGetString( GLcontext *ctx, GLenum name )
chipset = "Intel(R) 945G"; break;
case PCI_CHIP_I945_GM:
chipset = "Intel(R) 945GM"; break;
+ case PCI_CHIP_I945_GME:
+ chipset = "Intel(R) 945GME"; break;
+ case PCI_CHIP_G33_G:
+ chipset = "Intel(R) G33"; break;
+ case PCI_CHIP_Q35_G:
+ chipset = "Intel(R) Q35"; break;
+ case PCI_CHIP_Q33_G:
+ chipset = "Intel(R) Q33"; break;
default:
chipset = "Unknown Intel Chipset"; break;
}
@@ -766,98 +774,3 @@ void intelCopySubBuffer( __DRIdrawablePrivate *dPriv,
fprintf(stderr, "%s: drawable has no context!\n", __FUNCTION__);
}
}
-
-void intelInitState( GLcontext *ctx )
-{
- /* Mesa should do this for us:
- */
- ctx->Driver.AlphaFunc( ctx,
- ctx->Color.AlphaFunc,
- ctx->Color.AlphaRef);
-
- ctx->Driver.BlendColor( ctx,
- ctx->Color.BlendColor );
-
- ctx->Driver.BlendEquationSeparate( ctx,
- ctx->Color.BlendEquationRGB,
- ctx->Color.BlendEquationA);
-
- ctx->Driver.BlendFuncSeparate( ctx,
- ctx->Color.BlendSrcRGB,
- ctx->Color.BlendDstRGB,
- ctx->Color.BlendSrcA,
- ctx->Color.BlendDstA);
-
- ctx->Driver.ColorMask( ctx,
- ctx->Color.ColorMask[RCOMP],
- ctx->Color.ColorMask[GCOMP],
- ctx->Color.ColorMask[BCOMP],
- ctx->Color.ColorMask[ACOMP]);
-
- ctx->Driver.CullFace( ctx, ctx->Polygon.CullFaceMode );
- ctx->Driver.DepthFunc( ctx, ctx->Depth.Func );
- ctx->Driver.DepthMask( ctx, ctx->Depth.Mask );
-
- ctx->Driver.Enable( ctx, GL_ALPHA_TEST, ctx->Color.AlphaEnabled );
- ctx->Driver.Enable( ctx, GL_BLEND, ctx->Color.BlendEnabled );
- ctx->Driver.Enable( ctx, GL_COLOR_LOGIC_OP, ctx->Color.ColorLogicOpEnabled );
- ctx->Driver.Enable( ctx, GL_COLOR_SUM, ctx->Fog.ColorSumEnabled );
- ctx->Driver.Enable( ctx, GL_CULL_FACE, ctx->Polygon.CullFlag );
- ctx->Driver.Enable( ctx, GL_DEPTH_TEST, ctx->Depth.Test );
- ctx->Driver.Enable( ctx, GL_DITHER, ctx->Color.DitherFlag );
- ctx->Driver.Enable( ctx, GL_FOG, ctx->Fog.Enabled );
- ctx->Driver.Enable( ctx, GL_LIGHTING, ctx->Light.Enabled );
- ctx->Driver.Enable( ctx, GL_LINE_SMOOTH, ctx->Line.SmoothFlag );
- ctx->Driver.Enable( ctx, GL_POLYGON_STIPPLE, ctx->Polygon.StippleFlag );
- ctx->Driver.Enable( ctx, GL_SCISSOR_TEST, ctx->Scissor.Enabled );
- ctx->Driver.Enable( ctx, GL_STENCIL_TEST, ctx->Stencil.Enabled );
- ctx->Driver.Enable( ctx, GL_TEXTURE_1D, GL_FALSE );
- ctx->Driver.Enable( ctx, GL_TEXTURE_2D, GL_FALSE );
- ctx->Driver.Enable( ctx, GL_TEXTURE_RECTANGLE_NV, GL_FALSE );
- ctx->Driver.Enable( ctx, GL_TEXTURE_3D, GL_FALSE );
- ctx->Driver.Enable( ctx, GL_TEXTURE_CUBE_MAP, GL_FALSE );
-
- ctx->Driver.Fogfv( ctx, GL_FOG_COLOR, ctx->Fog.Color );
- ctx->Driver.Fogfv( ctx, GL_FOG_MODE, 0 );
- ctx->Driver.Fogfv( ctx, GL_FOG_DENSITY, &ctx->Fog.Density );
- ctx->Driver.Fogfv( ctx, GL_FOG_START, &ctx->Fog.Start );
- ctx->Driver.Fogfv( ctx, GL_FOG_END, &ctx->Fog.End );
-
- ctx->Driver.FrontFace( ctx, ctx->Polygon.FrontFace );
-
- {
- GLfloat f = (GLfloat)ctx->Light.Model.ColorControl;
- ctx->Driver.LightModelfv( ctx, GL_LIGHT_MODEL_COLOR_CONTROL, &f );
- }
-
- ctx->Driver.LineWidth( ctx, ctx->Line.Width );
- ctx->Driver.LogicOpcode( ctx, ctx->Color.LogicOp );
- ctx->Driver.PointSize( ctx, ctx->Point.Size );
- ctx->Driver.PolygonStipple( ctx, (const GLubyte *)ctx->PolygonStipple );
- ctx->Driver.Scissor( ctx, ctx->Scissor.X, ctx->Scissor.Y,
- ctx->Scissor.Width, ctx->Scissor.Height );
- ctx->Driver.ShadeModel( ctx, ctx->Light.ShadeModel );
- ctx->Driver.StencilFuncSeparate( ctx, GL_FRONT,
- ctx->Stencil.Function[0],
- ctx->Stencil.Ref[0],
- ctx->Stencil.ValueMask[0] );
- ctx->Driver.StencilFuncSeparate( ctx, GL_BACK,
- ctx->Stencil.Function[1],
- ctx->Stencil.Ref[1],
- ctx->Stencil.ValueMask[1] );
- ctx->Driver.StencilMaskSeparate( ctx, GL_FRONT, ctx->Stencil.WriteMask[0] );
- ctx->Driver.StencilMaskSeparate( ctx, GL_BACK, ctx->Stencil.WriteMask[1] );
- ctx->Driver.StencilOpSeparate( ctx, GL_FRONT,
- ctx->Stencil.FailFunc[0],
- ctx->Stencil.ZFailFunc[0],
- ctx->Stencil.ZPassFunc[0]);
- ctx->Driver.StencilOpSeparate( ctx, GL_BACK,
- ctx->Stencil.FailFunc[1],
- ctx->Stencil.ZFailFunc[1],
- ctx->Stencil.ZPassFunc[1]);
-
-
- ctx->Driver.DrawBuffer( ctx, ctx->Color.DrawBuffer[0] );
-}
-
-
diff --git a/src/mesa/drivers/dri/i915/intel_context.h b/src/mesa/drivers/dri/i915/intel_context.h
index 05195e76d65..3b50107d73f 100644
--- a/src/mesa/drivers/dri/i915/intel_context.h
+++ b/src/mesa/drivers/dri/i915/intel_context.h
@@ -454,6 +454,10 @@ extern int INTEL_DEBUG;
#define PCI_CHIP_I915_GM 0x2592
#define PCI_CHIP_I945_G 0x2772
#define PCI_CHIP_I945_GM 0x27A2
+#define PCI_CHIP_I945_GME 0x27AE
+#define PCI_CHIP_G33_G 0x29C2
+#define PCI_CHIP_Q35_G 0x29B2
+#define PCI_CHIP_Q33_G 0x29D2
/* ================================================================
@@ -473,7 +477,6 @@ extern void intelSetBackClipRects(intelContextPtr intel);
extern void intelSetFrontClipRects(intelContextPtr intel);
extern void intelWindowMoved( intelContextPtr intel );
-extern void intelInitState( GLcontext *ctx );
extern const GLubyte *intelGetString( GLcontext *ctx, GLenum name );
diff --git a/src/mesa/drivers/dri/i915/intel_screen.c b/src/mesa/drivers/dri/i915/intel_screen.c
index 67e176a1c6f..ca8610b4965 100644
--- a/src/mesa/drivers/dri/i915/intel_screen.c
+++ b/src/mesa/drivers/dri/i915/intel_screen.c
@@ -514,6 +514,10 @@ static GLboolean intelCreateContext( const __GLcontextModes *mesaVis,
case PCI_CHIP_I915_GM:
case PCI_CHIP_I945_G:
case PCI_CHIP_I945_GM:
+ case PCI_CHIP_I945_GME:
+ case PCI_CHIP_G33_G:
+ case PCI_CHIP_Q35_G:
+ case PCI_CHIP_Q33_G:
return i915CreateContext( mesaVis, driContextPriv,
sharedContextPrivate );
diff --git a/src/mesa/drivers/dri/i915/intel_tex.c b/src/mesa/drivers/dri/i915/intel_tex.c
index 6012d3e7999..5bd280652af 100644
--- a/src/mesa/drivers/dri/i915/intel_tex.c
+++ b/src/mesa/drivers/dri/i915/intel_tex.c
@@ -634,18 +634,12 @@ static void intelUploadTexImage( intelContextPtr intel,
image->Height);
}
else if (image->IsCompressed) {
- GLuint row_len = image->Width * 2;
+ GLuint row_len = 0;
GLubyte *dst = (GLubyte *)(t->BufAddr + offset);
GLubyte *src = (GLubyte *)image->Data;
GLuint j;
- if (INTEL_DEBUG & DEBUG_TEXTURE)
- fprintf(stderr,
- "Upload image %dx%dx%d offset %xm row_len %x "
- "pitch %x depth_pitch %x\n",
- image->Width, image->Height, image->Depth, offset,
- row_len, t->Pitch, t->depth_pitch);
-
+ /* must always copy whole blocks (8/16 bytes) */
switch (image->InternalFormat) {
case GL_COMPRESSED_RGB_FXT1_3DFX:
case GL_COMPRESSED_RGBA_FXT1_3DFX:
@@ -653,29 +647,41 @@ static void intelUploadTexImage( intelContextPtr intel,
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;
- }
+ row_len = (image->Width * 2 + 7) & ~7;
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;
- }
+ row_len = (image->Width * 4 + 15) & ~15;
break;
default:
fprintf(stderr,"Internal Compressed format not supported %d\n", image->InternalFormat);
break;
}
+
+ if (INTEL_DEBUG & DEBUG_TEXTURE)
+ fprintf(stderr,
+ "Upload image %dx%dx%d offset %xm row_len %x "
+ "pitch %x depth_pitch %x\n",
+ image->Width, image->Height, image->Depth, offset,
+ row_len, t->Pitch, t->depth_pitch);
+
+ if (row_len) {
+ for (j = 0 ; j < (image->Height + 3)/4 ; j++, dst += (t->Pitch)) {
+ __memcpy(dst, src, row_len );
+ src += row_len;
+ }
+ }
}
/* Time for another vtbl entry:
*/
else if (intel->intelScreen->deviceID == PCI_CHIP_I945_G ||
- intel->intelScreen->deviceID == PCI_CHIP_I945_GM) {
+ intel->intelScreen->deviceID == PCI_CHIP_I945_GM ||
+ intel->intelScreen->deviceID == PCI_CHIP_I945_GME ||
+ intel->intelScreen->deviceID == PCI_CHIP_G33_G ||
+ intel->intelScreen->deviceID == PCI_CHIP_Q33_G ||
+ intel->intelScreen->deviceID == PCI_CHIP_Q35_G) {
GLuint row_len = image->Width * image->TexFormat->TexelBytes;
GLubyte *dst = (GLubyte *)(t->BufAddr + offset);
GLubyte *src = (GLubyte *)image->Data;
diff --git a/src/mesa/drivers/dri/i915tex/i830_reg.h b/src/mesa/drivers/dri/i915tex/i830_reg.h
index 24ac5245005..41280bca7ce 100644
--- a/src/mesa/drivers/dri/i915tex/i830_reg.h
+++ b/src/mesa/drivers/dri/i915tex/i830_reg.h
@@ -575,6 +575,7 @@
#define MT_16BIT_DIB_RGB565_8888 (7<<3)
#define MT_32BIT_ARGB8888 (0<<3) /* SURFACE_32BIT */
#define MT_32BIT_ABGR8888 (1<<3)
+#define MT_32BIT_XRGB8888 (2<<3) /* XXX: Guess from i915_reg.h */
#define MT_32BIT_BUMP_XLDVDU_8888 (6<<3)
#define MT_32BIT_DIB_8888 (7<<3)
#define MT_411_YUV411 (0<<3) /* SURFACE_411 */
diff --git a/src/mesa/drivers/dri/i915tex/i830_state.c b/src/mesa/drivers/dri/i915tex/i830_state.c
index 812daa65246..3c149e69055 100644
--- a/src/mesa/drivers/dri/i915tex/i830_state.c
+++ b/src/mesa/drivers/dri/i915tex/i830_state.c
@@ -34,6 +34,8 @@
#include "texmem.h"
+#include "drivers/common/driverfuncs.h"
+
#include "intel_screen.h"
#include "intel_batchbuffer.h"
#include "intel_fbo.h"
@@ -1101,7 +1103,7 @@ i830InitState(struct i830_context *i830)
i830_init_packets(i830);
- intelInitState(ctx);
+ _mesa_init_driver_state(ctx);
memcpy(&i830->initial, &i830->state, sizeof(i830->state));
diff --git a/src/mesa/drivers/dri/i915tex/i830_texstate.c b/src/mesa/drivers/dri/i915tex/i830_texstate.c
index e3f34e3944a..0d3f053226f 100644
--- a/src/mesa/drivers/dri/i915tex/i830_texstate.c
+++ b/src/mesa/drivers/dri/i915tex/i830_texstate.c
@@ -117,7 +117,7 @@ i830_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
struct gl_texture_object *tObj = ctx->Texture.Unit[unit]._Current;
struct intel_texture_object *intelObj = intel_texture_object(tObj);
struct gl_texture_image *firstImage;
- GLuint *state = i830->state.Tex[unit];
+ GLuint *state = i830->state.Tex[unit], format, pitch;
memset(state, 0, sizeof(state));
@@ -128,7 +128,7 @@ i830_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
i830->state.tex_buffer[unit] = NULL;
}
- if (!intel_finalize_mipmap_tree(intel, unit))
+ if (!intelObj->imageOverride && !intel_finalize_mipmap_tree(intel, unit))
return GL_FALSE;
/* Get first image here, since intelObj->firstLevel will get set in
@@ -136,11 +136,34 @@ i830_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
*/
firstImage = tObj->Image[0][intelObj->firstLevel];
- i830->state.tex_buffer[unit] = driBOReference(intelObj->mt->region->buffer);
- i830->state.tex_offset[unit] = intel_miptree_image_offset(intelObj->mt, 0,
- intelObj->
- firstLevel);
+ if (intelObj->imageOverride) {
+ i830->state.tex_buffer[unit] = NULL;
+ i830->state.tex_offset[unit] = intelObj->textureOffset;
+ switch (intelObj->depthOverride) {
+ case 32:
+ format = MAPSURF_32BIT | MT_32BIT_ARGB8888;
+ break;
+ case 24:
+ default:
+ format = MAPSURF_32BIT | MT_32BIT_XRGB8888;
+ break;
+ case 16:
+ format = MAPSURF_16BIT | MT_16BIT_RGB565;
+ break;
+ }
+
+ pitch = intelObj->pitchOverride;
+ } else {
+ i830->state.tex_buffer[unit] = driBOReference(intelObj->mt->region->
+ buffer);
+ i830->state.tex_offset[unit] = intel_miptree_image_offset(intelObj->mt,
+ 0, intelObj->
+ firstLevel);
+
+ format = translate_texture_format(firstImage->TexFormat->MesaFormat);
+ pitch = intelObj->mt->pitch * intelObj->mt->cpp;
+ }
state[I830_TEXREG_TM0LI] = (_3DSTATE_LOAD_STATE_IMMEDIATE_2 |
(LOAD_TEXTURE_MAP0 << unit) | 4);
@@ -151,12 +174,10 @@ i830_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
state[I830_TEXREG_TM0S1] =
(((firstImage->Height - 1) << TM0S1_HEIGHT_SHIFT) |
- ((firstImage->Width - 1) << TM0S1_WIDTH_SHIFT) |
- translate_texture_format(firstImage->TexFormat->MesaFormat));
+ ((firstImage->Width - 1) << TM0S1_WIDTH_SHIFT) | format);
state[I830_TEXREG_TM0S2] =
- (((((intelObj->mt->pitch * intelObj->mt->cpp) / 4) -
- 1) << TM0S2_PITCH_SHIFT) | TM0S2_CUBE_FACE_ENA_MASK);
+ ((((pitch / 4) - 1) << TM0S2_PITCH_SHIFT) | TM0S2_CUBE_FACE_ENA_MASK);
{
if (tObj->Target == GL_TEXTURE_CUBE_MAP)
diff --git a/src/mesa/drivers/dri/i915tex/i915_fragprog.c b/src/mesa/drivers/dri/i915tex/i915_fragprog.c
index cbea6092a81..a4b22a0c32c 100644
--- a/src/mesa/drivers/dri/i915tex/i915_fragprog.c
+++ b/src/mesa/drivers/dri/i915tex/i915_fragprog.c
@@ -849,11 +849,6 @@ i915BindProgram(GLcontext * ctx, GLenum target, struct gl_program *prog)
assert(p->on_hardware == 0);
assert(p->params_uptodate == 0);
- /* Hack: make sure fog is correctly enabled according to this
- * fragment program's fog options.
- */
- ctx->Driver.Enable(ctx, GL_FRAGMENT_PROGRAM_ARB,
- ctx->FragmentProgram.Enabled);
}
}
@@ -926,9 +921,6 @@ i915ProgramStringNotify(GLcontext * ctx,
/* Hack: make sure fog is correctly enabled according to this
* fragment program's fog options.
*/
- ctx->Driver.Enable(ctx, GL_FRAGMENT_PROGRAM_ARB,
- ctx->FragmentProgram.Enabled);
-
if (p->FragProg.FogOption) {
/* add extra instructions to do fog, then turn off FogOption field */
_mesa_append_fog_code(ctx, &p->FragProg);
diff --git a/src/mesa/drivers/dri/i915tex/i915_state.c b/src/mesa/drivers/dri/i915tex/i915_state.c
index d3217fa0caa..e5d8d279936 100644
--- a/src/mesa/drivers/dri/i915tex/i915_state.c
+++ b/src/mesa/drivers/dri/i915tex/i915_state.c
@@ -36,6 +36,8 @@
#include "texmem.h"
+#include "drivers/common/driverfuncs.h"
+
#include "intel_fbo.h"
#include "intel_screen.h"
#include "intel_batchbuffer.h"
@@ -1005,7 +1007,7 @@ i915InitState(struct i915_context *i915)
i915_init_packets(i915);
- intelInitState(ctx);
+ _mesa_init_driver_state(ctx);
memcpy(&i915->initial, &i915->state, sizeof(i915->state));
i915->current = &i915->state;
diff --git a/src/mesa/drivers/dri/i915tex/i915_tex_layout.c b/src/mesa/drivers/dri/i915tex/i915_tex_layout.c
index 2e1600cfdfa..7b761a7b221 100644
--- a/src/mesa/drivers/dri/i915tex/i915_tex_layout.c
+++ b/src/mesa/drivers/dri/i915tex/i915_tex_layout.c
@@ -113,7 +113,7 @@ i915_miptree_layout(struct intel_mipmap_tree * mt)
*/
for (level = mt->first_level; level <= MAX2(8, mt->last_level);
level++) {
- intel_miptree_set_level_info(mt, level, 1, 0, mt->total_height,
+ intel_miptree_set_level_info(mt, level, depth, 0, mt->total_height,
width, height, depth);
@@ -161,11 +161,9 @@ i915_miptree_layout(struct intel_mipmap_tree * mt)
if (mt->compressed)
img_height = MAX2(1, height / 4);
else
- img_height = MAX2(2, height);
+ img_height = (MAX2(2, height) + 1) & ~1;
mt->total_height += img_height;
- mt->total_height += 1;
- mt->total_height &= ~1;
width = minify(width);
height = minify(height);
diff --git a/src/mesa/drivers/dri/i915tex/i915_texstate.c b/src/mesa/drivers/dri/i915tex/i915_texstate.c
index e0ecdfde24a..3d68187cf88 100644
--- a/src/mesa/drivers/dri/i915tex/i915_texstate.c
+++ b/src/mesa/drivers/dri/i915tex/i915_texstate.c
@@ -122,7 +122,7 @@ i915_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
struct gl_texture_object *tObj = ctx->Texture.Unit[unit]._Current;
struct intel_texture_object *intelObj = intel_texture_object(tObj);
struct gl_texture_image *firstImage;
- GLuint *state = i915->state.Tex[unit];
+ GLuint *state = i915->state.Tex[unit], format, pitch;
memset(state, 0, sizeof(state));
@@ -133,7 +133,7 @@ i915_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
i915->state.tex_buffer[unit] = NULL;
}
- if (!intel_finalize_mipmap_tree(intel, unit))
+ if (!intelObj->imageOverride && !intel_finalize_mipmap_tree(intel, unit))
return GL_FALSE;
/* Get first image here, since intelObj->firstLevel will get set in
@@ -141,24 +141,45 @@ i915_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
*/
firstImage = tObj->Image[0][intelObj->firstLevel];
- i915->state.tex_buffer[unit] = driBOReference(intelObj->mt->region->buffer);
- i915->state.tex_offset[unit] = intel_miptree_image_offset(intelObj->mt, 0,
- intelObj->
- firstLevel);
+ if (intelObj->imageOverride) {
+ i915->state.tex_buffer[unit] = NULL;
+ i915->state.tex_offset[unit] = intelObj->textureOffset;
+
+ switch (intelObj->depthOverride) {
+ case 32:
+ format = MAPSURF_32BIT | MT_32BIT_ARGB8888;
+ break;
+ case 24:
+ default:
+ format = MAPSURF_32BIT | MT_32BIT_XRGB8888;
+ break;
+ case 16:
+ format = MAPSURF_16BIT | MT_16BIT_RGB565;
+ break;
+ }
+
+ pitch = intelObj->pitchOverride;
+ } else {
+ i915->state.tex_buffer[unit] = driBOReference(intelObj->mt->region->
+ buffer);
+ i915->state.tex_offset[unit] = intel_miptree_image_offset(intelObj->mt,
+ 0, intelObj->
+ firstLevel);
+
+ format = translate_texture_format(firstImage->TexFormat->MesaFormat);
+ pitch = intelObj->mt->pitch * intelObj->mt->cpp;
+ }
state[I915_TEXREG_MS3] =
(((firstImage->Height - 1) << MS3_HEIGHT_SHIFT) |
- ((firstImage->Width - 1) << MS3_WIDTH_SHIFT) |
- translate_texture_format(firstImage->TexFormat->MesaFormat) |
+ ((firstImage->Width - 1) << MS3_WIDTH_SHIFT) | format |
MS3_USE_FENCE_REGS);
state[I915_TEXREG_MS4] =
- (((((intelObj->mt->pitch * intelObj->mt->cpp) / 4) -
- 1) << MS4_PITCH_SHIFT) | MS4_CUBE_FACE_ENA_MASK |
- ((((intelObj->lastLevel -
- intelObj->firstLevel) *
- 4)) << MS4_MAX_LOD_SHIFT) | ((firstImage->Depth -
- 1) << MS4_VOLUME_DEPTH_SHIFT));
+ ((((pitch / 4) - 1) << MS4_PITCH_SHIFT) | MS4_CUBE_FACE_ENA_MASK |
+ ((((intelObj->lastLevel - intelObj->firstLevel) * 4)) <<
+ MS4_MAX_LOD_SHIFT) | ((firstImage->Depth - 1) <<
+ MS4_VOLUME_DEPTH_SHIFT));
{
diff --git a/src/mesa/drivers/dri/i915tex/i915_vtbl.c b/src/mesa/drivers/dri/i915tex/i915_vtbl.c
index 52db9a95e6b..f80e8d6327f 100644
--- a/src/mesa/drivers/dri/i915tex/i915_vtbl.c
+++ b/src/mesa/drivers/dri/i915tex/i915_vtbl.c
@@ -381,11 +381,13 @@ i915_emit_state(struct intel_context *intel)
DRM_BO_MASK_MEM | DRM_BO_FLAG_READ,
state->tex_offset[i]);
}
- else {
+ else if (state == &i915->meta) {
assert(i == 0);
- assert(state == &i915->meta);
OUT_BATCH(0);
}
+ else {
+ OUT_BATCH(state->tex_offset[i]);
+ }
OUT_BATCH(state->Tex[i][I915_TEXREG_MS3]);
OUT_BATCH(state->Tex[i][I915_TEXREG_MS4]);
diff --git a/src/mesa/drivers/dri/i915tex/intel_context.c b/src/mesa/drivers/dri/i915tex/intel_context.c
index 20b2b41ef24..c927dca8e5a 100644
--- a/src/mesa/drivers/dri/i915tex/intel_context.c
+++ b/src/mesa/drivers/dri/i915tex/intel_context.c
@@ -130,6 +130,18 @@ intelGetString(GLcontext * ctx, GLenum name)
case PCI_CHIP_I945_GM:
chipset = "Intel(R) 945GM";
break;
+ case PCI_CHIP_I945_GME:
+ chipset = "Intel(R) 945GME";
+ break;
+ case PCI_CHIP_G33_G:
+ chipset = "Intel(R) G33";
+ break;
+ case PCI_CHIP_Q35_G:
+ chipset = "Intel(R) Q35";
+ break;
+ case PCI_CHIP_Q33_G:
+ chipset = "Intel(R) Q33";
+ break;
default:
chipset = "Unknown Intel Chipset";
break;
diff --git a/src/mesa/drivers/dri/i915tex/intel_context.h b/src/mesa/drivers/dri/i915tex/intel_context.h
index 44c20af7f80..9d060eb866f 100644
--- a/src/mesa/drivers/dri/i915tex/intel_context.h
+++ b/src/mesa/drivers/dri/i915tex/intel_context.h
@@ -92,6 +92,10 @@ struct intel_texture_object
* regions will be copied to this region and the old storage freed.
*/
struct intel_mipmap_tree *mt;
+
+ GLboolean imageOverride;
+ GLint depthOverride;
+ GLuint pitchOverride;
};
@@ -381,6 +385,10 @@ extern int INTEL_DEBUG;
#define PCI_CHIP_I915_GM 0x2592
#define PCI_CHIP_I945_G 0x2772
#define PCI_CHIP_I945_GM 0x27A2
+#define PCI_CHIP_I945_GME 0x27AE
+#define PCI_CHIP_G33_G 0x29C2
+#define PCI_CHIP_Q35_G 0x29B2
+#define PCI_CHIP_Q33_G 0x29D2
/* ================================================================
@@ -395,7 +403,6 @@ extern GLboolean intelInitContext(struct intel_context *intel,
extern void intelGetLock(struct intel_context *intel, GLuint flags);
-extern void intelInitState(GLcontext * ctx);
extern void intelFinish(GLcontext * ctx);
extern void intelFlush(GLcontext * ctx);
diff --git a/src/mesa/drivers/dri/i915tex/intel_mipmap_tree.c b/src/mesa/drivers/dri/i915tex/intel_mipmap_tree.c
index 8e83028b26c..843a78eb82b 100644
--- a/src/mesa/drivers/dri/i915tex/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/i915tex/intel_mipmap_tree.c
@@ -79,6 +79,10 @@ intel_miptree_create(struct intel_context *intel,
switch (intel->intelScreen->deviceID) {
case PCI_CHIP_I945_G:
case PCI_CHIP_I945_GM:
+ case PCI_CHIP_I945_GME:
+ case PCI_CHIP_G33_G:
+ case PCI_CHIP_Q33_G:
+ case PCI_CHIP_Q35_G:
ok = i945_miptree_layout(mt);
break;
case PCI_CHIP_I915_G:
diff --git a/src/mesa/drivers/dri/i915tex/intel_screen.c b/src/mesa/drivers/dri/i915tex/intel_screen.c
index dd01161b5bb..2acdead63d5 100644
--- a/src/mesa/drivers/dri/i915tex/intel_screen.c
+++ b/src/mesa/drivers/dri/i915tex/intel_screen.c
@@ -752,6 +752,10 @@ intelCreateContext(const __GLcontextModes * mesaVis,
case PCI_CHIP_I915_GM:
case PCI_CHIP_I945_G:
case PCI_CHIP_I945_GM:
+ case PCI_CHIP_I945_GME:
+ case PCI_CHIP_G33_G:
+ case PCI_CHIP_Q35_G:
+ case PCI_CHIP_Q33_G:
return i915CreateContext(mesaVis, driContextPriv, sharedContextPrivate);
default:
@@ -776,7 +780,8 @@ static const struct __DriverAPIRec intelAPI = {
.WaitForMSC = driWaitForMSC32,
.WaitForSBC = NULL,
.SwapBuffersMSC = NULL,
- .CopySubBuffer = intelCopySubBuffer
+ .CopySubBuffer = intelCopySubBuffer,
+ .setTexOffset = intelSetTexOffset,
};
diff --git a/src/mesa/drivers/dri/i915tex/intel_state.c b/src/mesa/drivers/dri/i915tex/intel_state.c
index f85d8ef8353..271511037e9 100644
--- a/src/mesa/drivers/dri/i915tex/intel_state.c
+++ b/src/mesa/drivers/dri/i915tex/intel_state.c
@@ -267,97 +267,3 @@ intelInitStateFuncs(struct dd_function_table *functions)
functions->DepthRange = intelDepthRange;
functions->ClearColor = intelClearColor;
}
-
-
-
-
-void
-intelInitState(GLcontext * ctx)
-{
- /* Mesa should do this for us:
- */
- ctx->Driver.AlphaFunc(ctx, ctx->Color.AlphaFunc, ctx->Color.AlphaRef);
-
- ctx->Driver.BlendColor(ctx, ctx->Color.BlendColor);
-
- ctx->Driver.BlendEquationSeparate(ctx,
- ctx->Color.BlendEquationRGB,
- ctx->Color.BlendEquationA);
-
- ctx->Driver.BlendFuncSeparate(ctx,
- ctx->Color.BlendSrcRGB,
- ctx->Color.BlendDstRGB,
- ctx->Color.BlendSrcA, ctx->Color.BlendDstA);
-
- ctx->Driver.ColorMask(ctx,
- ctx->Color.ColorMask[RCOMP],
- ctx->Color.ColorMask[GCOMP],
- ctx->Color.ColorMask[BCOMP],
- ctx->Color.ColorMask[ACOMP]);
-
- ctx->Driver.CullFace(ctx, ctx->Polygon.CullFaceMode);
- ctx->Driver.DepthFunc(ctx, ctx->Depth.Func);
- ctx->Driver.DepthMask(ctx, ctx->Depth.Mask);
-
- ctx->Driver.Enable(ctx, GL_ALPHA_TEST, ctx->Color.AlphaEnabled);
- ctx->Driver.Enable(ctx, GL_BLEND, ctx->Color.BlendEnabled);
- ctx->Driver.Enable(ctx, GL_COLOR_LOGIC_OP, ctx->Color.ColorLogicOpEnabled);
- ctx->Driver.Enable(ctx, GL_COLOR_SUM, ctx->Fog.ColorSumEnabled);
- ctx->Driver.Enable(ctx, GL_CULL_FACE, ctx->Polygon.CullFlag);
- ctx->Driver.Enable(ctx, GL_DEPTH_TEST, ctx->Depth.Test);
- ctx->Driver.Enable(ctx, GL_DITHER, ctx->Color.DitherFlag);
- ctx->Driver.Enable(ctx, GL_FOG, ctx->Fog.Enabled);
- ctx->Driver.Enable(ctx, GL_LIGHTING, ctx->Light.Enabled);
- ctx->Driver.Enable(ctx, GL_LINE_SMOOTH, ctx->Line.SmoothFlag);
- ctx->Driver.Enable(ctx, GL_POLYGON_STIPPLE, ctx->Polygon.StippleFlag);
- ctx->Driver.Enable(ctx, GL_SCISSOR_TEST, ctx->Scissor.Enabled);
- ctx->Driver.Enable(ctx, GL_STENCIL_TEST, ctx->Stencil.Enabled);
- ctx->Driver.Enable(ctx, GL_TEXTURE_1D, GL_FALSE);
- ctx->Driver.Enable(ctx, GL_TEXTURE_2D, GL_FALSE);
- ctx->Driver.Enable(ctx, GL_TEXTURE_RECTANGLE_NV, GL_FALSE);
- ctx->Driver.Enable(ctx, GL_TEXTURE_3D, GL_FALSE);
- ctx->Driver.Enable(ctx, GL_TEXTURE_CUBE_MAP, GL_FALSE);
-
- ctx->Driver.Fogfv(ctx, GL_FOG_COLOR, ctx->Fog.Color);
- ctx->Driver.Fogfv(ctx, GL_FOG_MODE, 0);
- ctx->Driver.Fogfv(ctx, GL_FOG_DENSITY, &ctx->Fog.Density);
- ctx->Driver.Fogfv(ctx, GL_FOG_START, &ctx->Fog.Start);
- ctx->Driver.Fogfv(ctx, GL_FOG_END, &ctx->Fog.End);
-
- ctx->Driver.FrontFace(ctx, ctx->Polygon.FrontFace);
-
- {
- GLfloat f = (GLfloat) ctx->Light.Model.ColorControl;
- ctx->Driver.LightModelfv(ctx, GL_LIGHT_MODEL_COLOR_CONTROL, &f);
- }
-
- ctx->Driver.LineWidth(ctx, ctx->Line.Width);
- ctx->Driver.LogicOpcode(ctx, ctx->Color.LogicOp);
- ctx->Driver.PointSize(ctx, ctx->Point.Size);
- ctx->Driver.PolygonStipple(ctx, (const GLubyte *) ctx->PolygonStipple);
- ctx->Driver.Scissor(ctx, ctx->Scissor.X, ctx->Scissor.Y,
- ctx->Scissor.Width, ctx->Scissor.Height);
- ctx->Driver.ShadeModel(ctx, ctx->Light.ShadeModel);
- ctx->Driver.StencilFuncSeparate(ctx, GL_FRONT,
- ctx->Stencil.Function[0],
- ctx->Stencil.Ref[0],
- ctx->Stencil.ValueMask[0]);
- ctx->Driver.StencilFuncSeparate(ctx, GL_BACK,
- ctx->Stencil.Function[1],
- ctx->Stencil.Ref[1],
- ctx->Stencil.ValueMask[1]);
- ctx->Driver.StencilMaskSeparate(ctx, GL_FRONT, ctx->Stencil.WriteMask[0]);
- ctx->Driver.StencilMaskSeparate(ctx, GL_BACK, ctx->Stencil.WriteMask[1]);
- ctx->Driver.StencilOpSeparate(ctx, GL_FRONT,
- ctx->Stencil.FailFunc[0],
- ctx->Stencil.ZFailFunc[0],
- ctx->Stencil.ZPassFunc[0]);
- ctx->Driver.StencilOpSeparate(ctx, GL_BACK,
- ctx->Stencil.FailFunc[1],
- ctx->Stencil.ZFailFunc[1],
- ctx->Stencil.ZPassFunc[1]);
-
-
- /* XXX this isn't really needed */
- ctx->Driver.DrawBuffer(ctx, ctx->Color.DrawBuffer[0]);
-}
diff --git a/src/mesa/drivers/dri/i915tex/intel_tex.h b/src/mesa/drivers/dri/i915tex/intel_tex.h
index 6e9938fe534..b77d7a1d8af 100644
--- a/src/mesa/drivers/dri/i915tex/intel_tex.h
+++ b/src/mesa/drivers/dri/i915tex/intel_tex.h
@@ -135,6 +135,9 @@ void intelGetCompressedTexImage(GLcontext *ctx, GLenum target, GLint level,
const struct gl_texture_object *texObj,
const struct gl_texture_image *texImage);
+void intelSetTexOffset(__DRIcontext *pDRICtx, GLint texname,
+ unsigned long long offset, GLint depth, GLuint pitch);
+
GLuint intel_finalize_mipmap_tree(struct intel_context *intel, GLuint unit);
void intel_tex_map_images(struct intel_context *intel,
diff --git a/src/mesa/drivers/dri/i915tex/intel_tex_image.c b/src/mesa/drivers/dri/i915tex/intel_tex_image.c
index 42679ef9db7..f790b1e6f73 100644
--- a/src/mesa/drivers/dri/i915tex/intel_tex_image.c
+++ b/src/mesa/drivers/dri/i915tex/intel_tex_image.c
@@ -385,7 +385,6 @@ intelTexImage(GLcontext * ctx,
}
}
-
assert(!intelImage->mt);
if (intelObj->mt &&
@@ -667,3 +666,26 @@ intelGetCompressedTexImage(GLcontext *ctx, GLenum target, GLint level,
texObj, texImage, 1);
}
+
+void
+intelSetTexOffset(__DRIcontext *pDRICtx, GLint texname,
+ unsigned long long offset, GLint depth, GLuint pitch)
+{
+ struct intel_context *intel = (struct intel_context*)
+ ((__DRIcontextPrivate*)pDRICtx->private)->driverPrivate;
+ struct gl_texture_object *tObj = _mesa_lookup_texture(&intel->ctx, texname);
+ struct intel_texture_object *intelObj = intel_texture_object(tObj);
+
+ if (!intelObj)
+ return;
+
+ if (intelObj->mt)
+ intel_miptree_release(intel, &intelObj->mt);
+
+ intelObj->imageOverride = GL_TRUE;
+ intelObj->depthOverride = depth;
+ intelObj->pitchOverride = pitch;
+
+ if (offset)
+ intelObj->textureOffset = offset;
+}
diff --git a/src/mesa/drivers/dri/i915tex/intel_tex_validate.c b/src/mesa/drivers/dri/i915tex/intel_tex_validate.c
index 79d587a1744..0ae4fee1ba0 100644
--- a/src/mesa/drivers/dri/i915tex/intel_tex_validate.c
+++ b/src/mesa/drivers/dri/i915tex/intel_tex_validate.c
@@ -105,6 +105,8 @@ intel_finalize_mipmap_tree(struct intel_context *intel, GLuint unit)
{
struct gl_texture_object *tObj = intel->ctx.Texture.Unit[unit]._Current;
struct intel_texture_object *intelObj = intel_texture_object(tObj);
+ int comp_byte = 0;
+ int cpp;
GLuint face, i;
GLuint nr_faces = 0;
@@ -148,6 +150,12 @@ intel_finalize_mipmap_tree(struct intel_context *intel, GLuint unit)
intel_miptree_reference(&intelObj->mt, firstImage->mt);
}
+ if (firstImage->base.IsCompressed) {
+ comp_byte = intel_compressed_num_bytes(firstImage->base.TexFormat->MesaFormat);
+ cpp = comp_byte;
+ }
+ else cpp = firstImage->base.TexFormat->TexelBytes;
+
/* Check tree can hold all active levels. Check tree matches
* target, imageFormat, etc.
*
@@ -165,7 +173,7 @@ intel_finalize_mipmap_tree(struct intel_context *intel, GLuint unit)
intelObj->mt->width0 != firstImage->base.Width ||
intelObj->mt->height0 != firstImage->base.Height ||
intelObj->mt->depth0 != firstImage->base.Depth ||
- intelObj->mt->cpp != firstImage->base.TexFormat->TexelBytes ||
+ intelObj->mt->cpp != cpp ||
intelObj->mt->compressed != firstImage->base.IsCompressed)) {
intel_miptree_release(intel, &intelObj->mt);
}
@@ -174,10 +182,6 @@ intel_finalize_mipmap_tree(struct intel_context *intel, GLuint unit)
/* May need to create a new tree:
*/
if (!intelObj->mt) {
- int comp_byte = 0;
-
- if (firstImage->base.IsCompressed)
- comp_byte = intel_compressed_num_bytes(firstImage->base.TexFormat->MesaFormat);
intelObj->mt = intel_miptree_create(intel,
intelObj->base.Target,
firstImage->base.InternalFormat,
@@ -186,8 +190,7 @@ intel_finalize_mipmap_tree(struct intel_context *intel, GLuint unit)
firstImage->base.Width,
firstImage->base.Height,
firstImage->base.Depth,
- firstImage->base.TexFormat->
- TexelBytes,
+ cpp,
comp_byte);
}
diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c
index c7798b14a93..0c64d7e756d 100644
--- a/src/mesa/drivers/dri/i965/brw_draw.c
+++ b/src/mesa/drivers/dri/i965/brw_draw.c
@@ -47,6 +47,7 @@
#include "tnl/tnl.h"
#include "vbo/vbo_context.h"
#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
diff --git a/src/mesa/drivers/dri/i965/brw_vs_tnl.c b/src/mesa/drivers/dri/i965/brw_vs_tnl.c
index 35adc4846a0..b69be350a92 100644
--- a/src/mesa/drivers/dri/i965/brw_vs_tnl.c
+++ b/src/mesa/drivers/dri/i965/brw_vs_tnl.c
@@ -1154,7 +1154,9 @@ static void build_fog( struct tnl_program *p )
{
struct ureg fog = register_output(p, VERT_RESULT_FOGC);
struct ureg input;
-
+ GLuint useabs = p->state->fog_source_is_depth && p->state->fog_option &&
+ (p->state->fog_option != FOG_EXP2);
+
if (p->state->fog_source_is_depth) {
input = swizzle1(get_eye_position(p), Z);
}
@@ -1171,26 +1173,30 @@ static void build_fog( struct tnl_program *p )
emit_op1(p, OPCODE_MOV, fog, 0, id);
+ if (useabs) {
+ emit_op1(p, OPCODE_ABS, tmp, 0, input);
+ }
+
switch (p->state->fog_option) {
case FOG_LINEAR: {
- emit_op1(p, OPCODE_ABS, tmp, 0, input);
- emit_op3(p, OPCODE_MAD, tmp, 0, tmp, swizzle1(params,X), swizzle1(params,Y));
+ emit_op3(p, OPCODE_MAD, tmp, 0, useabs ? tmp : input,
+ swizzle1(params,X), swizzle1(params,Y));
emit_op2(p, OPCODE_MAX, tmp, 0, tmp, swizzle1(id,X)); /* saturate */
emit_op2(p, OPCODE_MIN, fog, WRITEMASK_X, tmp, swizzle1(id,W));
break;
}
case FOG_EXP:
- emit_op1(p, OPCODE_ABS, tmp, 0, input);
- emit_op2(p, OPCODE_MUL, tmp, 0, tmp, swizzle1(params,Z));
+ emit_op2(p, OPCODE_MUL, tmp, 0, useabs ? tmp : input,
+ swizzle1(params,Z));
emit_op1(p, OPCODE_EX2, fog, WRITEMASK_X, ureg_negate(tmp));
break;
case FOG_EXP2:
emit_op2(p, OPCODE_MUL, tmp, 0, input, swizzle1(params,W));
- emit_op2(p, OPCODE_MUL, tmp, 0, tmp, tmp);
+ emit_op2(p, OPCODE_MUL, tmp, 0, tmp, tmp);
emit_op1(p, OPCODE_EX2, fog, WRITEMASK_X, ureg_negate(tmp));
break;
}
-
+
release_temp(p, tmp);
}
else {
@@ -1198,7 +1204,7 @@ static void build_fog( struct tnl_program *p )
*
* KW: Is it really necessary to do anything in this case?
*/
- emit_op1(p, OPCODE_MOV, fog, 0, input);
+ emit_op1(p, useabs ? OPCODE_ABS : OPCODE_MOV, fog, 0, input);
}
}
diff --git a/src/mesa/drivers/dri/i965/intel_context.c b/src/mesa/drivers/dri/i965/intel_context.c
index 10eb9a2e28d..4f51fefe0f6 100644
--- a/src/mesa/drivers/dri/i965/intel_context.c
+++ b/src/mesa/drivers/dri/i965/intel_context.c
@@ -106,20 +106,23 @@ static const GLubyte *intelGetString( GLcontext *ctx, GLenum name )
case GL_RENDERER:
switch (intel_context(ctx)->intelScreen->deviceID) {
case PCI_CHIP_I965_Q:
- chipset = "Intel(R) 965Q"; break;
+ chipset = "Intel(R) 965Q";
break;
case PCI_CHIP_I965_G:
case PCI_CHIP_I965_G_1:
- chipset = "Intel(R) 965G"; break;
+ chipset = "Intel(R) 965G";
break;
case PCI_CHIP_I946_GZ:
- chipset = "Intel(R) 946GZ"; break;
+ chipset = "Intel(R) 946GZ";
break;
case PCI_CHIP_I965_GM:
- chipset = "Intel(R) 965GM"; break;
+ chipset = "Intel(R) 965GM";
+ break;
+ case PCI_CHIP_I965_GME:
+ chipset = "Intel(R) 965GME/GLE";
break;
default:
- chipset = "Unknown Intel Chipset"; break;
+ chipset = "Unknown Intel Chipset";
}
(void) driGetRendererString( buffer, chipset, DRIVER_VERSION, 0 );
diff --git a/src/mesa/drivers/dri/i965/intel_context.h b/src/mesa/drivers/dri/i965/intel_context.h
index 808512f7fd5..406f8483dce 100644
--- a/src/mesa/drivers/dri/i965/intel_context.h
+++ b/src/mesa/drivers/dri/i965/intel_context.h
@@ -385,6 +385,7 @@ extern int INTEL_DEBUG;
#define PCI_CHIP_I965_G_1 0x2982
#define PCI_CHIP_I946_GZ 0x2972
#define PCI_CHIP_I965_GM 0x2A02
+#define PCI_CHIP_I965_GME 0x2A12
/* ================================================================
@@ -399,7 +400,6 @@ extern GLboolean intelInitContext( struct intel_context *intel,
extern void intelGetLock(struct intel_context *intel, GLuint flags);
-extern void intelInitState( GLcontext *ctx );
extern void intelFinish( GLcontext *ctx );
extern void intelFlush( GLcontext *ctx );
diff --git a/src/mesa/drivers/dri/i965/intel_state.c b/src/mesa/drivers/dri/i965/intel_state.c
index ec6e0465d4a..2e442db6198 100644
--- a/src/mesa/drivers/dri/i965/intel_state.c
+++ b/src/mesa/drivers/dri/i965/intel_state.c
@@ -197,99 +197,3 @@ void intelInitStateFuncs( struct dd_function_table *functions )
functions->RenderMode = intelRenderMode;
functions->ClearColor = intelClearColor;
}
-
-
-
-
-void intelInitState( GLcontext *ctx )
-{
- /* Mesa should do this for us:
- */
- ctx->Driver.AlphaFunc( ctx,
- ctx->Color.AlphaFunc,
- ctx->Color.AlphaRef);
-
- ctx->Driver.BlendColor( ctx,
- ctx->Color.BlendColor );
-
- ctx->Driver.BlendEquationSeparate( ctx,
- ctx->Color.BlendEquationRGB,
- ctx->Color.BlendEquationA);
-
- ctx->Driver.BlendFuncSeparate( ctx,
- ctx->Color.BlendSrcRGB,
- ctx->Color.BlendDstRGB,
- ctx->Color.BlendSrcA,
- ctx->Color.BlendDstA);
-
- ctx->Driver.ColorMask( ctx,
- ctx->Color.ColorMask[RCOMP],
- ctx->Color.ColorMask[GCOMP],
- ctx->Color.ColorMask[BCOMP],
- ctx->Color.ColorMask[ACOMP]);
-
- ctx->Driver.CullFace( ctx, ctx->Polygon.CullFaceMode );
- ctx->Driver.DepthFunc( ctx, ctx->Depth.Func );
- ctx->Driver.DepthMask( ctx, ctx->Depth.Mask );
-
- ctx->Driver.Enable( ctx, GL_ALPHA_TEST, ctx->Color.AlphaEnabled );
- ctx->Driver.Enable( ctx, GL_BLEND, ctx->Color.BlendEnabled );
- ctx->Driver.Enable( ctx, GL_COLOR_LOGIC_OP, ctx->Color.ColorLogicOpEnabled );
- ctx->Driver.Enable( ctx, GL_COLOR_SUM, ctx->Fog.ColorSumEnabled );
- ctx->Driver.Enable( ctx, GL_CULL_FACE, ctx->Polygon.CullFlag );
- ctx->Driver.Enable( ctx, GL_DEPTH_TEST, ctx->Depth.Test );
- ctx->Driver.Enable( ctx, GL_DITHER, ctx->Color.DitherFlag );
- ctx->Driver.Enable( ctx, GL_FOG, ctx->Fog.Enabled );
- ctx->Driver.Enable( ctx, GL_LIGHTING, ctx->Light.Enabled );
- ctx->Driver.Enable( ctx, GL_LINE_SMOOTH, ctx->Line.SmoothFlag );
- ctx->Driver.Enable( ctx, GL_POLYGON_STIPPLE, ctx->Polygon.StippleFlag );
- ctx->Driver.Enable( ctx, GL_SCISSOR_TEST, ctx->Scissor.Enabled );
- ctx->Driver.Enable( ctx, GL_STENCIL_TEST, ctx->Stencil.Enabled );
- ctx->Driver.Enable( ctx, GL_TEXTURE_1D, GL_FALSE );
- ctx->Driver.Enable( ctx, GL_TEXTURE_2D, GL_FALSE );
- ctx->Driver.Enable( ctx, GL_TEXTURE_RECTANGLE_NV, GL_FALSE );
- ctx->Driver.Enable( ctx, GL_TEXTURE_3D, GL_FALSE );
- ctx->Driver.Enable( ctx, GL_TEXTURE_CUBE_MAP, GL_FALSE );
-
- ctx->Driver.Fogfv( ctx, GL_FOG_COLOR, ctx->Fog.Color );
- ctx->Driver.Fogfv( ctx, GL_FOG_MODE, 0 );
- ctx->Driver.Fogfv( ctx, GL_FOG_DENSITY, &ctx->Fog.Density );
- ctx->Driver.Fogfv( ctx, GL_FOG_START, &ctx->Fog.Start );
- ctx->Driver.Fogfv( ctx, GL_FOG_END, &ctx->Fog.End );
-
- ctx->Driver.FrontFace( ctx, ctx->Polygon.FrontFace );
-
- {
- GLfloat f = (GLfloat)ctx->Light.Model.ColorControl;
- ctx->Driver.LightModelfv( ctx, GL_LIGHT_MODEL_COLOR_CONTROL, &f );
- }
-
- ctx->Driver.LineWidth( ctx, ctx->Line.Width );
- ctx->Driver.LogicOpcode( ctx, ctx->Color.LogicOp );
- ctx->Driver.PointSize( ctx, ctx->Point.Size );
- ctx->Driver.PolygonStipple( ctx, (const GLubyte *)ctx->PolygonStipple );
- ctx->Driver.Scissor( ctx, ctx->Scissor.X, ctx->Scissor.Y,
- ctx->Scissor.Width, ctx->Scissor.Height );
- ctx->Driver.ShadeModel( ctx, ctx->Light.ShadeModel );
- ctx->Driver.StencilFuncSeparate( ctx, GL_FRONT,
- ctx->Stencil.Function[0],
- ctx->Stencil.Ref[0],
- ctx->Stencil.ValueMask[0] );
- ctx->Driver.StencilFuncSeparate( ctx, GL_BACK,
- ctx->Stencil.Function[1],
- ctx->Stencil.Ref[1],
- ctx->Stencil.ValueMask[1] );
- ctx->Driver.StencilMaskSeparate( ctx, GL_FRONT, ctx->Stencil.WriteMask[0] );
- ctx->Driver.StencilMaskSeparate( ctx, GL_BACK, ctx->Stencil.WriteMask[1] );
- ctx->Driver.StencilOpSeparate( ctx, GL_FRONT,
- ctx->Stencil.FailFunc[0],
- ctx->Stencil.ZFailFunc[0],
- ctx->Stencil.ZPassFunc[0]);
- ctx->Driver.StencilOpSeparate( ctx, GL_BACK,
- ctx->Stencil.FailFunc[1],
- ctx->Stencil.ZFailFunc[1],
- ctx->Stencil.ZPassFunc[1]);
-
-
- ctx->Driver.DrawBuffer( ctx, ctx->Color.DrawBuffer[0] );
-}
diff --git a/src/mesa/drivers/dri/intel/intel_tex_layout.c b/src/mesa/drivers/dri/intel/intel_tex_layout.c
index f3564802171..fcb5cc39068 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_layout.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_layout.c
@@ -74,7 +74,7 @@ void i945_miptree_layout_2d( struct intel_mipmap_tree *mt )
GLuint img_height;
intel_miptree_set_level_info(mt, level, 1, x, y, width,
- mt->compressed ? height/4 : height, 1);
+ height, 1);
if (mt->compressed)
img_height = MAX2(1, height/4);
diff --git a/src/mesa/drivers/dri/mach64/mach64_native_vb.c b/src/mesa/drivers/dri/mach64/mach64_native_vb.c
index 81bcf802c71..75cf0e2ed2d 100644
--- a/src/mesa/drivers/dri/mach64/mach64_native_vb.c
+++ b/src/mesa/drivers/dri/mach64/mach64_native_vb.c
@@ -44,7 +44,7 @@ void TAG(translate_vertex)(GLcontext *ctx,
UNVIEWPORT_VARS;
CARD32 *p = (CARD32 *)src + 10 - mmesa->vertex_size;
- dst->win[3] = 1.0;
+ dst->attrib[FRAG_ATTRIB_WPOS][3] = 1.0;
switch ( format ) {
case TEX1_VERTEX_FORMAT:
@@ -75,17 +75,17 @@ void TAG(translate_vertex)(GLcontext *ctx,
dst->attrib[FRAG_ATTRIB_TEX0][1] = LE32_IN_FLOAT( p++ );
#endif
dst->attrib[FRAG_ATTRIB_TEX0][3] = 1.0;
- dst->win[3] = LE32_IN_FLOAT( p++ );
+ dst->attrib[FRAG_ATTRIB_WPOS][3] = LE32_IN_FLOAT( p++ );
case NOTEX_VERTEX_FORMAT:
- dst->specular[2] = ((GLubyte *)p)[0];
- dst->specular[1] = ((GLubyte *)p)[1];
- dst->specular[0] = ((GLubyte *)p)[2];
- dst->attrib[FRAG_ATTRIB_FOGC][0] = ((GLubyte *)p)[3];
+ dst->attrib[FRAG_ATTRIB_COL1][2] = UBYTE_TO_FLOAT(((GLubyte *)p)[0]);
+ dst->attrib[FRAG_ATTRIB_COL1][1] = UBYTE_TO_FLOAT(((GLubyte *)p)[1]);
+ dst->attrib[FRAG_ATTRIB_COL1][0] = UBYTE_TO_FLOAT(((GLubyte *)p)[2]);
+ dst->attrib[FRAG_ATTRIB_FOGC][0] = ((GLubyte *)p)[3]; /*XXX int->float?*/
p++;
case TINY_VERTEX_FORMAT:
- dst->win[2] = UNVIEWPORT_Z( LE32_IN( p++ ) );
+ dst->attrib[FRAG_ATTRIB_WPOS][2] = UNVIEWPORT_Z( LE32_IN( p++ ) );
dst->color[2] = ((GLubyte *)p)[0];
dst->color[1] = ((GLubyte *)p)[1];
@@ -96,8 +96,8 @@ void TAG(translate_vertex)(GLcontext *ctx,
{
GLuint xy = LE32_IN( p );
- dst->win[0] = UNVIEWPORT_X( (GLfloat)(GLshort)( xy >> 16 ) );
- dst->win[1] = UNVIEWPORT_Y( (GLfloat)(GLshort)( xy & 0xffff ) );
+ dst->attrib[FRAG_ATTRIB_WPOS][0] = UNVIEWPORT_X( (GLfloat)(GLshort)( xy >> 16 ) );
+ dst->attrib[FRAG_ATTRIB_WPOS][1] = UNVIEWPORT_Y( (GLfloat)(GLshort)( xy & 0xffff ) );
}
}
diff --git a/src/mesa/drivers/dri/r200/r200_cmdbuf.c b/src/mesa/drivers/dri/r200/r200_cmdbuf.c
index 2920ceafd30..c1d51e87001 100644
--- a/src/mesa/drivers/dri/r200/r200_cmdbuf.c
+++ b/src/mesa/drivers/dri/r200/r200_cmdbuf.c
@@ -1,4 +1,3 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_cmdbuf.c,v 1.1 2002/10/30 12:51:51 alanh Exp $ */
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
diff --git a/src/mesa/drivers/dri/r200/r200_context.c b/src/mesa/drivers/dri/r200/r200_context.c
index 0507eb86e69..5a178442bdb 100644
--- a/src/mesa/drivers/dri/r200/r200_context.c
+++ b/src/mesa/drivers/dri/r200/r200_context.c
@@ -1,4 +1,3 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_context.c,v 1.3 2003/05/06 23:52:08 daenzer Exp $ */
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
@@ -679,7 +678,6 @@ r200MakeCurrent( __DRIcontextPrivate *driContextPriv,
newCtx->dri.drawable = driDrawPriv;
r200SetCliprects(newCtx);
- r200UpdateWindow( newCtx->glCtx );
r200UpdateViewportOffset( newCtx->glCtx );
}
diff --git a/src/mesa/drivers/dri/r200/r200_context.h b/src/mesa/drivers/dri/r200/r200_context.h
index e840a502c0b..bec09e8ef6a 100644
--- a/src/mesa/drivers/dri/r200/r200_context.h
+++ b/src/mesa/drivers/dri/r200/r200_context.h
@@ -1,4 +1,3 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_context.h,v 1.2 2002/12/16 16:18:54 dawes Exp $ */
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
diff --git a/src/mesa/drivers/dri/r200/r200_ioctl.c b/src/mesa/drivers/dri/r200/r200_ioctl.c
index 463bd64415b..2366bde5250 100644
--- a/src/mesa/drivers/dri/r200/r200_ioctl.c
+++ b/src/mesa/drivers/dri/r200/r200_ioctl.c
@@ -1,4 +1,3 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_ioctl.c,v 1.4 2002/12/17 00:32:56 dawes Exp $ */
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
diff --git a/src/mesa/drivers/dri/r200/r200_ioctl.h b/src/mesa/drivers/dri/r200/r200_ioctl.h
index f53752739d2..5ed1555f6a3 100644
--- a/src/mesa/drivers/dri/r200/r200_ioctl.h
+++ b/src/mesa/drivers/dri/r200/r200_ioctl.h
@@ -1,4 +1,3 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_ioctl.h,v 1.1 2002/10/30 12:51:52 alanh Exp $ */
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
diff --git a/src/mesa/drivers/dri/r200/r200_lock.c b/src/mesa/drivers/dri/r200/r200_lock.c
index b050dd7802b..f89b526a312 100644
--- a/src/mesa/drivers/dri/r200/r200_lock.c
+++ b/src/mesa/drivers/dri/r200/r200_lock.c
@@ -1,4 +1,3 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_lock.c,v 1.1 2002/10/30 12:51:52 alanh Exp $ */
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
diff --git a/src/mesa/drivers/dri/r200/r200_lock.h b/src/mesa/drivers/dri/r200/r200_lock.h
index e4c3a7e9352..4ff98907fbf 100644
--- a/src/mesa/drivers/dri/r200/r200_lock.h
+++ b/src/mesa/drivers/dri/r200/r200_lock.h
@@ -1,4 +1,3 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_lock.h,v 1.1 2002/10/30 12:51:52 alanh Exp $ */
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
diff --git a/src/mesa/drivers/dri/r200/r200_maos.h b/src/mesa/drivers/dri/r200/r200_maos.h
index 4998f67445c..d3ed06d4021 100644
--- a/src/mesa/drivers/dri/r200/r200_maos.h
+++ b/src/mesa/drivers/dri/r200/r200_maos.h
@@ -1,4 +1,3 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_maos.h,v 1.1 2002/10/30 12:51:52 alanh Exp $ */
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
diff --git a/src/mesa/drivers/dri/r200/r200_maos_arrays.c b/src/mesa/drivers/dri/r200/r200_maos_arrays.c
index 3162b508c23..7bc05e2f0bd 100644
--- a/src/mesa/drivers/dri/r200/r200_maos_arrays.c
+++ b/src/mesa/drivers/dri/r200/r200_maos_arrays.c
@@ -1,4 +1,3 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_maos_arrays.c,v 1.3 2003/02/23 23:59:01 dawes Exp $ */
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
diff --git a/src/mesa/drivers/dri/r200/r200_pixel.c b/src/mesa/drivers/dri/r200/r200_pixel.c
index 7b060f9cf0d..2f5aab0744b 100644
--- a/src/mesa/drivers/dri/r200/r200_pixel.c
+++ b/src/mesa/drivers/dri/r200/r200_pixel.c
@@ -1,4 +1,3 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_pixel.c,v 1.2 2002/12/16 16:18:54 dawes Exp $ */
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
diff --git a/src/mesa/drivers/dri/r200/r200_pixel.h b/src/mesa/drivers/dri/r200/r200_pixel.h
index 8f3923b6b16..e62aa05d749 100644
--- a/src/mesa/drivers/dri/r200/r200_pixel.h
+++ b/src/mesa/drivers/dri/r200/r200_pixel.h
@@ -1,4 +1,3 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_pixel.h,v 1.1 2002/10/30 12:51:52 alanh Exp $ */
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
diff --git a/src/mesa/drivers/dri/r200/r200_reg.h b/src/mesa/drivers/dri/r200/r200_reg.h
index a88ea4cec26..5ce287f7a5f 100644
--- a/src/mesa/drivers/dri/r200/r200_reg.h
+++ b/src/mesa/drivers/dri/r200/r200_reg.h
@@ -1,4 +1,3 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_reg.h,v 1.2 2002/12/16 16:18:54 dawes Exp $ */
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
diff --git a/src/mesa/drivers/dri/r200/r200_sanity.c b/src/mesa/drivers/dri/r200/r200_sanity.c
index 3f2a8665309..00d2f65c998 100644
--- a/src/mesa/drivers/dri/r200/r200_sanity.c
+++ b/src/mesa/drivers/dri/r200/r200_sanity.c
@@ -1,4 +1,3 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_sanity.c,v 1.1 2002/10/30 12:51:52 alanh Exp $ */
/**************************************************************************
Copyright 2002 ATI Technologies Inc., Ontario, Canada, and
diff --git a/src/mesa/drivers/dri/r200/r200_span.c b/src/mesa/drivers/dri/r200/r200_span.c
index 6e99dfe159b..fe427bdcdec 100644
--- a/src/mesa/drivers/dri/r200/r200_span.c
+++ b/src/mesa/drivers/dri/r200/r200_span.c
@@ -1,4 +1,3 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_span.c,v 1.1 2002/10/30 12:51:52 alanh Exp $ */
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
diff --git a/src/mesa/drivers/dri/r200/r200_span.h b/src/mesa/drivers/dri/r200/r200_span.h
index 5e7d3e4282c..bae56443092 100644
--- a/src/mesa/drivers/dri/r200/r200_span.h
+++ b/src/mesa/drivers/dri/r200/r200_span.h
@@ -1,4 +1,3 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_span.h,v 1.1 2002/10/30 12:51:52 alanh Exp $ */
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
diff --git a/src/mesa/drivers/dri/r200/r200_state.c b/src/mesa/drivers/dri/r200/r200_state.c
index 16726d7d55a..2115799b9b6 100644
--- a/src/mesa/drivers/dri/r200/r200_state.c
+++ b/src/mesa/drivers/dri/r200/r200_state.c
@@ -1,4 +1,3 @@
-/* $XFree86$ */
/**************************************************************************
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
diff --git a/src/mesa/drivers/dri/r200/r200_state.h b/src/mesa/drivers/dri/r200/r200_state.h
index f34090b619b..a917163a00a 100644
--- a/src/mesa/drivers/dri/r200/r200_state.h
+++ b/src/mesa/drivers/dri/r200/r200_state.h
@@ -1,4 +1,3 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_state.h,v 1.2 2002/11/05 17:46:08 tsi Exp $ */
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
diff --git a/src/mesa/drivers/dri/r200/r200_state_init.c b/src/mesa/drivers/dri/r200/r200_state_init.c
index b40d0bdcb7c..0c36cefc161 100644
--- a/src/mesa/drivers/dri/r200/r200_state_init.c
+++ b/src/mesa/drivers/dri/r200/r200_state_init.c
@@ -1,4 +1,3 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_state_init.c,v 1.4 2003/02/22 06:21:11 dawes Exp $ */
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
diff --git a/src/mesa/drivers/dri/r200/r200_swtcl.c b/src/mesa/drivers/dri/r200/r200_swtcl.c
index 25d229d8ed6..a1ea0198bee 100644
--- a/src/mesa/drivers/dri/r200/r200_swtcl.c
+++ b/src/mesa/drivers/dri/r200/r200_swtcl.c
@@ -1,4 +1,3 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_swtcl.c,v 1.5 2003/05/06 23:52:08 daenzer Exp $ */
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
diff --git a/src/mesa/drivers/dri/r200/r200_swtcl.h b/src/mesa/drivers/dri/r200/r200_swtcl.h
index ccf817988c5..7458c549288 100644
--- a/src/mesa/drivers/dri/r200/r200_swtcl.h
+++ b/src/mesa/drivers/dri/r200/r200_swtcl.h
@@ -1,4 +1,3 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_swtcl.h,v 1.3 2003/05/06 23:52:08 daenzer Exp $ */
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
diff --git a/src/mesa/drivers/dri/r200/r200_tcl.c b/src/mesa/drivers/dri/r200/r200_tcl.c
index e0c32b26d92..2ad35d43906 100644
--- a/src/mesa/drivers/dri/r200/r200_tcl.c
+++ b/src/mesa/drivers/dri/r200/r200_tcl.c
@@ -1,4 +1,3 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_tcl.c,v 1.2 2002/12/16 16:18:55 dawes Exp $ */
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
diff --git a/src/mesa/drivers/dri/r200/r200_tcl.h b/src/mesa/drivers/dri/r200/r200_tcl.h
index ac5bc119468..f191ddc7eb9 100644
--- a/src/mesa/drivers/dri/r200/r200_tcl.h
+++ b/src/mesa/drivers/dri/r200/r200_tcl.h
@@ -1,4 +1,3 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_tcl.h,v 1.2 2002/12/16 16:18:55 dawes Exp $ */
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
diff --git a/src/mesa/drivers/dri/r200/r200_tex.c b/src/mesa/drivers/dri/r200/r200_tex.c
index 6c6450c681f..e7a37dd4c99 100644
--- a/src/mesa/drivers/dri/r200/r200_tex.c
+++ b/src/mesa/drivers/dri/r200/r200_tex.c
@@ -1,4 +1,3 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_tex.c,v 1.2 2002/11/05 17:46:08 tsi Exp $ */
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
@@ -182,7 +181,7 @@ static void r200SetTexMaxAnisotropy( r200TexObjPtr t, GLfloat max )
{
t->pp_txfilter &= ~R200_MAX_ANISO_MASK;
- if ( max == 1.0 ) {
+ if ( max <= 1.0 ) {
t->pp_txfilter |= R200_MAX_ANISO_1_TO_1;
} else if ( max <= 2.0 ) {
t->pp_txfilter |= R200_MAX_ANISO_2_TO_1;
@@ -483,7 +482,7 @@ r200ValidateClientStorage( GLcontext *ctx, GLenum target,
{
r200ContextPtr rmesa = R200_CONTEXT(ctx);
- if (0)
+ if ( R200_DEBUG & DEBUG_TEXTURE )
fprintf(stderr, "intformat %s format %s type %s\n",
_mesa_lookup_enum_by_nr( internalFormat ),
_mesa_lookup_enum_by_nr( format ),
@@ -549,7 +548,7 @@ r200ValidateClientStorage( GLcontext *ctx, GLenum target,
format, type);
- if (0)
+ if ( R200_DEBUG & DEBUG_TEXTURE )
fprintf(stderr, "%s: srcRowStride %d/%x\n",
__FUNCTION__, srcRowStride, srcRowStride);
diff --git a/src/mesa/drivers/dri/r200/r200_tex.h b/src/mesa/drivers/dri/r200/r200_tex.h
index 4438cc02a82..e6c0e00eb07 100644
--- a/src/mesa/drivers/dri/r200/r200_tex.h
+++ b/src/mesa/drivers/dri/r200/r200_tex.h
@@ -1,4 +1,3 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_tex.h,v 1.1 2002/10/30 12:51:53 alanh Exp $ */
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
diff --git a/src/mesa/drivers/dri/r200/r200_texmem.c b/src/mesa/drivers/dri/r200/r200_texmem.c
index 28988c97556..d926313d576 100644
--- a/src/mesa/drivers/dri/r200/r200_texmem.c
+++ b/src/mesa/drivers/dri/r200/r200_texmem.c
@@ -1,4 +1,3 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_texmem.c,v 1.5 2002/12/17 00:32:56 dawes Exp $ */
/**************************************************************************
Copyright (C) Tungsten Graphics 2002. All Rights Reserved.
diff --git a/src/mesa/drivers/dri/r200/r200_texstate.c b/src/mesa/drivers/dri/r200/r200_texstate.c
index 875d3bab73f..ae02ec4b638 100644
--- a/src/mesa/drivers/dri/r200/r200_texstate.c
+++ b/src/mesa/drivers/dri/r200/r200_texstate.c
@@ -1,4 +1,3 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_texstate.c,v 1.3 2003/02/15 22:18:47 dawes Exp $ */
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
diff --git a/src/mesa/drivers/dri/r300/Makefile b/src/mesa/drivers/dri/r300/Makefile
index 9e60f970d67..c1d223c7600 100644
--- a/src/mesa/drivers/dri/r300/Makefile
+++ b/src/mesa/drivers/dri/r300/Makefile
@@ -40,7 +40,7 @@ DRIVER_SOURCES = \
r300_vertprog.c \
r300_fragprog.c \
r300_shader.c \
- r300_maos.c \
+ r300_emit.c \
$(EGL_SOURCES)
C_SOURCES = $(COMMON_SOURCES) $(DRIVER_SOURCES)
diff --git a/src/mesa/drivers/dri/r300/r300_cmdbuf.c b/src/mesa/drivers/dri/r300/r300_cmdbuf.c
index 48f5ea4c562..7055286ba95 100644
--- a/src/mesa/drivers/dri/r300/r300_cmdbuf.c
+++ b/src/mesa/drivers/dri/r300/r300_cmdbuf.c
@@ -128,18 +128,20 @@ int r300FlushCmdBuf(r300ContextPtr r300, const char *caller)
return ret;
}
-void r300PrintStateAtom(r300ContextPtr r300, struct r300_state_atom *state)
+static void r300PrintStateAtom(r300ContextPtr r300, struct r300_state_atom *state)
{
int i;
int dwords = (*state->check) (r300, state);
- fprintf(stderr, " emit %s/%d/%d\n", state->name, dwords,
+ fprintf(stderr, " emit %s %d/%d\n", state->name, dwords,
state->cmd_size);
- if (RADEON_DEBUG & DEBUG_VERBOSE)
- for (i = 0; i < dwords; i++)
- fprintf(stderr, " %s[%d]: %08X\n",
+ if (RADEON_DEBUG & DEBUG_VERBOSE) {
+ for (i = 0; i < dwords; i++) {
+ fprintf(stderr, " %s[%d]: %08x\n",
state->name, i, state->cmd[i]);
+ }
+ }
}
/**
@@ -148,28 +150,14 @@ void r300PrintStateAtom(r300ContextPtr r300, struct r300_state_atom *state)
* The caller must have ensured that there is enough space in the command
* buffer.
*/
-static __inline__ void r300DoEmitState(r300ContextPtr r300, GLboolean dirty)
+static inline void r300EmitAtoms(r300ContextPtr r300, GLboolean dirty)
{
struct r300_state_atom *atom;
uint32_t *dest;
+ int dwords;
dest = r300->cmdbuf.cmd_buf + r300->cmdbuf.count_used;
- if (DEBUG_CMDBUF && RADEON_DEBUG & DEBUG_STATE) {
- foreach(atom, &r300->hw.atomlist) {
- if ((atom->dirty || r300->hw.all_dirty) == dirty) {
- int dwords = (*atom->check) (r300, atom);
-
- if (dwords)
- r300PrintStateAtom(r300, atom);
- else
- fprintf(stderr,
- " skip state %s\n",
- atom->name);
- }
- }
- }
-
/* Emit WAIT */
*dest = cmdwait(R300_WAIT_3D | R300_WAIT_3D_CLEAN);
dest++;
@@ -193,13 +181,20 @@ static __inline__ void r300DoEmitState(r300ContextPtr r300, GLboolean dirty)
foreach(atom, &r300->hw.atomlist) {
if ((atom->dirty || r300->hw.all_dirty) == dirty) {
- int dwords = (*atom->check) (r300, atom);
-
+ dwords = (*atom->check) (r300, atom);
if (dwords) {
+ if (DEBUG_CMDBUF && RADEON_DEBUG & DEBUG_STATE) {
+ r300PrintStateAtom(r300, atom);
+ }
memcpy(dest, atom->cmd, dwords * 4);
dest += dwords;
r300->cmdbuf.count_used += dwords;
atom->dirty = GL_FALSE;
+ } else {
+ if (DEBUG_CMDBUF && RADEON_DEBUG & DEBUG_STATE) {
+ fprintf(stderr, " skip state %s\n",
+ atom->name);
+ }
}
}
}
@@ -230,14 +225,14 @@ void r300EmitState(r300ContextPtr r300)
if (RADEON_DEBUG & DEBUG_STATE)
fprintf(stderr, "Begin reemit state\n");
- r300DoEmitState(r300, GL_FALSE);
+ r300EmitAtoms(r300, GL_FALSE);
r300->cmdbuf.count_reemit = r300->cmdbuf.count_used;
}
if (RADEON_DEBUG & DEBUG_STATE)
fprintf(stderr, "Begin dirty state\n");
- r300DoEmitState(r300, GL_TRUE);
+ r300EmitAtoms(r300, GL_TRUE);
assert(r300->cmdbuf.count_used < r300->cmdbuf.size);
@@ -245,31 +240,38 @@ void r300EmitState(r300ContextPtr r300)
r300->hw.all_dirty = GL_FALSE;
}
-#define CHECK( NM, COUNT ) \
-static int check_##NM( r300ContextPtr r300, \
- struct r300_state_atom* atom ) \
-{ \
- (void) atom; (void) r300; \
- return (COUNT); \
-}
-
#define packet0_count(ptr) (((drm_r300_cmd_header_t*)(ptr))->packet0.count)
#define vpu_count(ptr) (((drm_r300_cmd_header_t*)(ptr))->vpu.count)
-CHECK(always, atom->cmd_size)
- CHECK(variable, packet0_count(atom->cmd) ? (1 + packet0_count(atom->cmd)) : 0)
- CHECK(vpu, vpu_count(atom->cmd) ? (1 + vpu_count(atom->cmd) * 4) : 0)
-#undef packet0_count
-#undef vpu_count
-#define ALLOC_STATE( ATOM, CHK, SZ, NM, IDX ) \
+static int check_always(r300ContextPtr r300, struct r300_state_atom *atom)
+{
+ return atom->cmd_size;
+}
+
+static int check_variable(r300ContextPtr r300, struct r300_state_atom *atom)
+{
+ int cnt;
+ cnt = packet0_count(atom->cmd);
+ return cnt ? cnt + 1 : 0;
+}
+
+static int check_vpu(r300ContextPtr r300, struct r300_state_atom *atom)
+{
+ int cnt;
+ cnt = vpu_count(atom->cmd);
+ return cnt ? (cnt * 4) + 1 : 0;
+}
+
+#define ALLOC_STATE( ATOM, CHK, SZ, IDX ) \
do { \
r300->hw.ATOM.cmd_size = (SZ); \
r300->hw.ATOM.cmd = (uint32_t*)CALLOC((SZ) * sizeof(uint32_t)); \
- r300->hw.ATOM.name = (NM); \
+ r300->hw.ATOM.name = #ATOM; \
r300->hw.ATOM.idx = (IDX); \
r300->hw.ATOM.check = check_##CHK; \
r300->hw.ATOM.dirty = GL_FALSE; \
r300->hw.max_state_size += (SZ); \
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.ATOM); \
} while (0)
/**
* Allocate memory for the command buffer and initialize the state atom
@@ -290,276 +292,195 @@ void r300InitCmdBuf(r300ContextPtr r300)
fprintf(stderr, "Using %d maximum texture units..\n", mtu);
}
+ /* Setup the atom linked list */
+ make_empty_list(&r300->hw.atomlist);
+ r300->hw.atomlist.name = "atom-list";
+
/* Initialize state atoms */
- ALLOC_STATE(vpt, always, R300_VPT_CMDSIZE, "vpt", 0);
+ ALLOC_STATE(vpt, always, R300_VPT_CMDSIZE, 0);
r300->hw.vpt.cmd[R300_VPT_CMD_0] = cmdpacket0(R300_SE_VPORT_XSCALE, 6);
- ALLOC_STATE(vap_cntl, always, 2, "vap_cntl", 0);
+ ALLOC_STATE(vap_cntl, always, 2, 0);
r300->hw.vap_cntl.cmd[0] = cmdpacket0(R300_VAP_CNTL, 1);
- ALLOC_STATE(vte, always, 3, "vte", 0);
+ ALLOC_STATE(vte, always, 3, 0);
r300->hw.vte.cmd[0] = cmdpacket0(R300_SE_VTE_CNTL, 2);
- ALLOC_STATE(unk2134, always, 3, "unk2134", 0);
+ ALLOC_STATE(unk2134, always, 3, 0);
r300->hw.unk2134.cmd[0] = cmdpacket0(0x2134, 2);
- ALLOC_STATE(vap_cntl_status, always, 2, "vap_cntl_status", 0);
+ ALLOC_STATE(vap_cntl_status, always, 2, 0);
r300->hw.vap_cntl_status.cmd[0] = cmdpacket0(R300_VAP_CNTL_STATUS, 1);
- ALLOC_STATE(vir[0], variable, R300_VIR_CMDSIZE, "vir/0", 0);
+ ALLOC_STATE(vir[0], variable, R300_VIR_CMDSIZE, 0);
r300->hw.vir[0].cmd[R300_VIR_CMD_0] =
cmdpacket0(R300_VAP_INPUT_ROUTE_0_0, 1);
- ALLOC_STATE(vir[1], variable, R300_VIR_CMDSIZE, "vir/1", 1);
+ ALLOC_STATE(vir[1], variable, R300_VIR_CMDSIZE, 1);
r300->hw.vir[1].cmd[R300_VIR_CMD_0] =
cmdpacket0(R300_VAP_INPUT_ROUTE_1_0, 1);
- ALLOC_STATE(vic, always, R300_VIC_CMDSIZE, "vic", 0);
+ ALLOC_STATE(vic, always, R300_VIC_CMDSIZE, 0);
r300->hw.vic.cmd[R300_VIC_CMD_0] = cmdpacket0(R300_VAP_INPUT_CNTL_0, 2);
- ALLOC_STATE(unk21DC, always, 2, "unk21DC", 0);
+ ALLOC_STATE(unk21DC, always, 2, 0);
r300->hw.unk21DC.cmd[0] = cmdpacket0(0x21DC, 1);
- ALLOC_STATE(unk221C, always, 2, "unk221C", 0);
+ ALLOC_STATE(unk221C, always, 2, 0);
r300->hw.unk221C.cmd[0] = cmdpacket0(R300_VAP_UNKNOWN_221C, 1);
- ALLOC_STATE(unk2220, always, 5, "unk2220", 0);
- r300->hw.unk2220.cmd[0] = cmdpacket0(0x2220, 4);
- ALLOC_STATE(unk2288, always, 2, "unk2288", 0);
+ ALLOC_STATE(vap_clip, always, 5, 0);
+ r300->hw.vap_clip.cmd[0] = cmdpacket0(R300_VAP_CLIP_X_0, 4);
+ ALLOC_STATE(unk2288, always, 2, 0);
r300->hw.unk2288.cmd[0] = cmdpacket0(R300_VAP_UNKNOWN_2288, 1);
- ALLOC_STATE(vof, always, R300_VOF_CMDSIZE, "vof", 0);
+ ALLOC_STATE(vof, always, R300_VOF_CMDSIZE, 0);
r300->hw.vof.cmd[R300_VOF_CMD_0] =
cmdpacket0(R300_VAP_OUTPUT_VTX_FMT_0, 2);
if (has_tcl) {
- ALLOC_STATE(pvs, always, R300_PVS_CMDSIZE, "pvs", 0);
+ ALLOC_STATE(pvs, always, R300_PVS_CMDSIZE, 0);
r300->hw.pvs.cmd[R300_PVS_CMD_0] =
cmdpacket0(R300_VAP_PVS_CNTL_1, 3);
}
- ALLOC_STATE(gb_enable, always, 2, "gb_enable", 0);
+ ALLOC_STATE(gb_enable, always, 2, 0);
r300->hw.gb_enable.cmd[0] = cmdpacket0(R300_GB_ENABLE, 1);
- ALLOC_STATE(gb_misc, always, R300_GB_MISC_CMDSIZE, "gb_misc", 0);
+ ALLOC_STATE(gb_misc, always, R300_GB_MISC_CMDSIZE, 0);
r300->hw.gb_misc.cmd[0] = cmdpacket0(R300_GB_MSPOS0, 5);
- ALLOC_STATE(txe, always, R300_TXE_CMDSIZE, "txe", 0);
+ ALLOC_STATE(txe, always, R300_TXE_CMDSIZE, 0);
r300->hw.txe.cmd[R300_TXE_CMD_0] = cmdpacket0(R300_TX_ENABLE, 1);
- ALLOC_STATE(unk4200, always, 5, "unk4200", 0);
+ ALLOC_STATE(unk4200, always, 5, 0);
r300->hw.unk4200.cmd[0] = cmdpacket0(0x4200, 4);
- ALLOC_STATE(unk4214, always, 2, "unk4214", 0);
+ ALLOC_STATE(unk4214, always, 2, 0);
r300->hw.unk4214.cmd[0] = cmdpacket0(0x4214, 1);
- ALLOC_STATE(ps, always, R300_PS_CMDSIZE, "ps", 0);
+ ALLOC_STATE(ps, always, R300_PS_CMDSIZE, 0);
r300->hw.ps.cmd[0] = cmdpacket0(R300_RE_POINTSIZE, 1);
- ALLOC_STATE(unk4230, always, 4, "unk4230", 0);
+ ALLOC_STATE(unk4230, always, 4, 0);
r300->hw.unk4230.cmd[0] = cmdpacket0(0x4230, 3);
- ALLOC_STATE(lcntl, always, 2, "lcntl", 0);
+ ALLOC_STATE(lcntl, always, 2, 0);
r300->hw.lcntl.cmd[0] = cmdpacket0(R300_RE_LINE_CNT, 1);
- ALLOC_STATE(unk4260, always, 4, "unk4260", 0);
+ ALLOC_STATE(unk4260, always, 4, 0);
r300->hw.unk4260.cmd[0] = cmdpacket0(0x4260, 3);
- ALLOC_STATE(shade, always, 5, "shade", 0);
+ ALLOC_STATE(shade, always, 5, 0);
r300->hw.shade.cmd[0] = cmdpacket0(R300_RE_SHADE, 4);
- ALLOC_STATE(polygon_mode, always, 4, "polygon_mode", 0);
+ ALLOC_STATE(polygon_mode, always, 4, 0);
r300->hw.polygon_mode.cmd[0] = cmdpacket0(R300_RE_POLYGON_MODE, 3);
- ALLOC_STATE(fogp, always, 3, "fogp", 0);
+ ALLOC_STATE(fogp, always, 3, 0);
r300->hw.fogp.cmd[0] = cmdpacket0(R300_RE_FOG_SCALE, 2);
- ALLOC_STATE(zbias_cntl, always, 2, "zbias_cntl", 0);
+ ALLOC_STATE(zbias_cntl, always, 2, 0);
r300->hw.zbias_cntl.cmd[0] = cmdpacket0(R300_RE_ZBIAS_CNTL, 1);
- ALLOC_STATE(zbs, always, R300_ZBS_CMDSIZE, "zbs", 0);
+ ALLOC_STATE(zbs, always, R300_ZBS_CMDSIZE, 0);
r300->hw.zbs.cmd[R300_ZBS_CMD_0] =
cmdpacket0(R300_RE_ZBIAS_T_FACTOR, 4);
- ALLOC_STATE(occlusion_cntl, always, 2, "occlusion_cntl", 0);
+ ALLOC_STATE(occlusion_cntl, always, 2, 0);
r300->hw.occlusion_cntl.cmd[0] = cmdpacket0(R300_RE_OCCLUSION_CNTL, 1);
- ALLOC_STATE(cul, always, R300_CUL_CMDSIZE, "cul", 0);
+ ALLOC_STATE(cul, always, R300_CUL_CMDSIZE, 0);
r300->hw.cul.cmd[R300_CUL_CMD_0] = cmdpacket0(R300_RE_CULL_CNTL, 1);
- ALLOC_STATE(unk42C0, always, 3, "unk42C0", 0);
+ ALLOC_STATE(unk42C0, always, 3, 0);
r300->hw.unk42C0.cmd[0] = cmdpacket0(0x42C0, 2);
- ALLOC_STATE(rc, always, R300_RC_CMDSIZE, "rc", 0);
+ ALLOC_STATE(rc, always, R300_RC_CMDSIZE, 0);
r300->hw.rc.cmd[R300_RC_CMD_0] = cmdpacket0(R300_RS_CNTL_0, 2);
- ALLOC_STATE(ri, always, R300_RI_CMDSIZE, "ri", 0);
+ ALLOC_STATE(ri, always, R300_RI_CMDSIZE, 0);
r300->hw.ri.cmd[R300_RI_CMD_0] = cmdpacket0(R300_RS_INTERP_0, 8);
- ALLOC_STATE(rr, variable, R300_RR_CMDSIZE, "rr", 0);
+ ALLOC_STATE(rr, variable, R300_RR_CMDSIZE, 0);
r300->hw.rr.cmd[R300_RR_CMD_0] = cmdpacket0(R300_RS_ROUTE_0, 1);
- ALLOC_STATE(unk43A4, always, 3, "unk43A4", 0);
+ ALLOC_STATE(unk43A4, always, 3, 0);
r300->hw.unk43A4.cmd[0] = cmdpacket0(0x43A4, 2);
- ALLOC_STATE(unk43E8, always, 2, "unk43E8", 0);
+ ALLOC_STATE(unk43E8, always, 2, 0);
r300->hw.unk43E8.cmd[0] = cmdpacket0(0x43E8, 1);
- ALLOC_STATE(fp, always, R300_FP_CMDSIZE, "fp", 0);
+ ALLOC_STATE(fp, always, R300_FP_CMDSIZE, 0);
r300->hw.fp.cmd[R300_FP_CMD_0] = cmdpacket0(R300_PFS_CNTL_0, 3);
r300->hw.fp.cmd[R300_FP_CMD_1] = cmdpacket0(R300_PFS_NODE_0, 4);
- ALLOC_STATE(fpt, variable, R300_FPT_CMDSIZE, "fpt", 0);
+ ALLOC_STATE(fpt, variable, R300_FPT_CMDSIZE, 0);
r300->hw.fpt.cmd[R300_FPT_CMD_0] = cmdpacket0(R300_PFS_TEXI_0, 0);
- ALLOC_STATE(unk46A4, always, 6, "unk46A4", 0);
+ ALLOC_STATE(unk46A4, always, 6, 0);
r300->hw.unk46A4.cmd[0] = cmdpacket0(0x46A4, 5);
- ALLOC_STATE(fpi[0], variable, R300_FPI_CMDSIZE, "fpi/0", 0);
+ ALLOC_STATE(fpi[0], variable, R300_FPI_CMDSIZE, 0);
r300->hw.fpi[0].cmd[R300_FPI_CMD_0] = cmdpacket0(R300_PFS_INSTR0_0, 1);
- ALLOC_STATE(fpi[1], variable, R300_FPI_CMDSIZE, "fpi/1", 1);
+ ALLOC_STATE(fpi[1], variable, R300_FPI_CMDSIZE, 1);
r300->hw.fpi[1].cmd[R300_FPI_CMD_0] = cmdpacket0(R300_PFS_INSTR1_0, 1);
- ALLOC_STATE(fpi[2], variable, R300_FPI_CMDSIZE, "fpi/2", 2);
+ ALLOC_STATE(fpi[2], variable, R300_FPI_CMDSIZE, 2);
r300->hw.fpi[2].cmd[R300_FPI_CMD_0] = cmdpacket0(R300_PFS_INSTR2_0, 1);
- ALLOC_STATE(fpi[3], variable, R300_FPI_CMDSIZE, "fpi/3", 3);
+ ALLOC_STATE(fpi[3], variable, R300_FPI_CMDSIZE, 3);
r300->hw.fpi[3].cmd[R300_FPI_CMD_0] = cmdpacket0(R300_PFS_INSTR3_0, 1);
- ALLOC_STATE(fogs, always, R300_FOGS_CMDSIZE, "fogs", 0);
+ ALLOC_STATE(fogs, always, R300_FOGS_CMDSIZE, 0);
r300->hw.fogs.cmd[R300_FOGS_CMD_0] = cmdpacket0(R300_RE_FOG_STATE, 1);
- ALLOC_STATE(fogc, always, R300_FOGC_CMDSIZE, "fogc", 0);
+ ALLOC_STATE(fogc, always, R300_FOGC_CMDSIZE, 0);
r300->hw.fogc.cmd[R300_FOGC_CMD_0] = cmdpacket0(R300_FOG_COLOR_R, 3);
- ALLOC_STATE(at, always, R300_AT_CMDSIZE, "at", 0);
+ ALLOC_STATE(at, always, R300_AT_CMDSIZE, 0);
r300->hw.at.cmd[R300_AT_CMD_0] = cmdpacket0(R300_PP_ALPHA_TEST, 2);
- ALLOC_STATE(unk4BD8, always, 2, "unk4BD8", 0);
+ ALLOC_STATE(unk4BD8, always, 2, 0);
r300->hw.unk4BD8.cmd[0] = cmdpacket0(0x4BD8, 1);
- ALLOC_STATE(fpp, variable, R300_FPP_CMDSIZE, "fpp", 0);
+ ALLOC_STATE(fpp, variable, R300_FPP_CMDSIZE, 0);
r300->hw.fpp.cmd[R300_FPP_CMD_0] = cmdpacket0(R300_PFS_PARAM_0_X, 0);
- ALLOC_STATE(unk4E00, always, 2, "unk4E00", 0);
+ ALLOC_STATE(unk4E00, always, 2, 0);
r300->hw.unk4E00.cmd[0] = cmdpacket0(0x4E00, 1);
- ALLOC_STATE(bld, always, R300_BLD_CMDSIZE, "bld", 0);
+ ALLOC_STATE(bld, always, R300_BLD_CMDSIZE, 0);
r300->hw.bld.cmd[R300_BLD_CMD_0] = cmdpacket0(R300_RB3D_CBLEND, 2);
- ALLOC_STATE(cmk, always, R300_CMK_CMDSIZE, "cmk", 0);
+ ALLOC_STATE(cmk, always, R300_CMK_CMDSIZE, 0);
r300->hw.cmk.cmd[R300_CMK_CMD_0] = cmdpacket0(R300_RB3D_COLORMASK, 1);
- ALLOC_STATE(blend_color, always, 4, "blend_color", 0);
+ ALLOC_STATE(blend_color, always, 4, 0);
r300->hw.blend_color.cmd[0] = cmdpacket0(R300_RB3D_BLEND_COLOR, 3);
- ALLOC_STATE(cb, always, R300_CB_CMDSIZE, "cb", 0);
+ ALLOC_STATE(cb, always, R300_CB_CMDSIZE, 0);
r300->hw.cb.cmd[R300_CB_CMD_0] = cmdpacket0(R300_RB3D_COLOROFFSET0, 1);
r300->hw.cb.cmd[R300_CB_CMD_1] = cmdpacket0(R300_RB3D_COLORPITCH0, 1);
- ALLOC_STATE(unk4E50, always, 10, "unk4E50", 0);
+ ALLOC_STATE(unk4E50, always, 10, 0);
r300->hw.unk4E50.cmd[0] = cmdpacket0(0x4E50, 9);
- ALLOC_STATE(unk4E88, always, 2, "unk4E88", 0);
+ ALLOC_STATE(unk4E88, always, 2, 0);
r300->hw.unk4E88.cmd[0] = cmdpacket0(0x4E88, 1);
- ALLOC_STATE(unk4EA0, always, 3, "unk4EA0 R350 only", 0);
+ ALLOC_STATE(unk4EA0, always, 3, 0);
r300->hw.unk4EA0.cmd[0] = cmdpacket0(0x4EA0, 2);
- ALLOC_STATE(zs, always, R300_ZS_CMDSIZE, "zstencil", 0);
+ ALLOC_STATE(zs, always, R300_ZS_CMDSIZE, 0);
r300->hw.zs.cmd[R300_ZS_CMD_0] =
cmdpacket0(R300_RB3D_ZSTENCIL_CNTL_0, 3);
- ALLOC_STATE(zstencil_format, always, 5, "zstencil_format", 0);
+ ALLOC_STATE(zstencil_format, always, 5, 0);
r300->hw.zstencil_format.cmd[0] =
cmdpacket0(R300_RB3D_ZSTENCIL_FORMAT, 4);
- ALLOC_STATE(zb, always, R300_ZB_CMDSIZE, "zb", 0);
+ ALLOC_STATE(zb, always, R300_ZB_CMDSIZE, 0);
r300->hw.zb.cmd[R300_ZB_CMD_0] = cmdpacket0(R300_RB3D_DEPTHOFFSET, 2);
- ALLOC_STATE(unk4F28, always, 2, "unk4F28", 0);
+ ALLOC_STATE(unk4F28, always, 2, 0);
r300->hw.unk4F28.cmd[0] = cmdpacket0(0x4F28, 1);
- ALLOC_STATE(unk4F30, always, 3, "unk4F30", 0);
+ ALLOC_STATE(unk4F30, always, 3, 0);
r300->hw.unk4F30.cmd[0] = cmdpacket0(0x4F30, 2);
- ALLOC_STATE(unk4F44, always, 2, "unk4F44", 0);
+ ALLOC_STATE(unk4F44, always, 2, 0);
r300->hw.unk4F44.cmd[0] = cmdpacket0(0x4F44, 1);
- ALLOC_STATE(unk4F54, always, 2, "unk4F54", 0);
+ ALLOC_STATE(unk4F54, always, 2, 0);
r300->hw.unk4F54.cmd[0] = cmdpacket0(0x4F54, 1);
/* VPU only on TCL */
if (has_tcl) {
- ALLOC_STATE(vpi, vpu, R300_VPI_CMDSIZE, "vpi", 0);
+ ALLOC_STATE(vpi, vpu, R300_VPI_CMDSIZE, 0);
r300->hw.vpi.cmd[R300_VPI_CMD_0] =
cmdvpu(R300_PVS_UPLOAD_PROGRAM, 0);
- ALLOC_STATE(vpp, vpu, R300_VPP_CMDSIZE, "vpp", 0);
+ ALLOC_STATE(vpp, vpu, R300_VPP_CMDSIZE, 0);
r300->hw.vpp.cmd[R300_VPP_CMD_0] =
cmdvpu(R300_PVS_UPLOAD_PARAMETERS, 0);
- ALLOC_STATE(vps, vpu, R300_VPS_CMDSIZE, "vps", 0);
+ ALLOC_STATE(vps, vpu, R300_VPS_CMDSIZE, 0);
r300->hw.vps.cmd[R300_VPS_CMD_0] =
cmdvpu(R300_PVS_UPLOAD_POINTSIZE, 1);
}
/* Textures */
- ALLOC_STATE(tex.filter, variable, mtu + 1, "tex_filter", 0);
+ ALLOC_STATE(tex.filter, variable, mtu + 1, 0);
r300->hw.tex.filter.cmd[R300_TEX_CMD_0] =
cmdpacket0(R300_TX_FILTER_0, 0);
- ALLOC_STATE(tex.filter_1, variable, mtu + 1, "tex_filter_1", 0);
+ ALLOC_STATE(tex.filter_1, variable, mtu + 1, 0);
r300->hw.tex.filter_1.cmd[R300_TEX_CMD_0] =
cmdpacket0(R300_TX_FILTER1_0, 0);
- ALLOC_STATE(tex.size, variable, mtu + 1, "tex_size", 0);
+ ALLOC_STATE(tex.size, variable, mtu + 1, 0);
r300->hw.tex.size.cmd[R300_TEX_CMD_0] = cmdpacket0(R300_TX_SIZE_0, 0);
- ALLOC_STATE(tex.format, variable, mtu + 1, "tex_format", 0);
+ ALLOC_STATE(tex.format, variable, mtu + 1, 0);
r300->hw.tex.format.cmd[R300_TEX_CMD_0] =
cmdpacket0(R300_TX_FORMAT_0, 0);
- ALLOC_STATE(tex.pitch, variable, mtu + 1, "tex_pitch", 0);
+ ALLOC_STATE(tex.pitch, variable, mtu + 1, 0);
r300->hw.tex.pitch.cmd[R300_TEX_CMD_0] = cmdpacket0(R300_TX_PITCH_0, 0);
- ALLOC_STATE(tex.offset, variable, mtu + 1, "tex_offset", 0);
+ ALLOC_STATE(tex.offset, variable, mtu + 1, 0);
r300->hw.tex.offset.cmd[R300_TEX_CMD_0] =
cmdpacket0(R300_TX_OFFSET_0, 0);
- ALLOC_STATE(tex.chroma_key, variable, mtu + 1, "tex_chroma_key", 0);
+ ALLOC_STATE(tex.chroma_key, variable, mtu + 1, 0);
r300->hw.tex.chroma_key.cmd[R300_TEX_CMD_0] =
cmdpacket0(R300_TX_CHROMA_KEY_0, 0);
- ALLOC_STATE(tex.border_color, variable, mtu + 1, "tex_border_color", 0);
+ ALLOC_STATE(tex.border_color, variable, mtu + 1, 0);
r300->hw.tex.border_color.cmd[R300_TEX_CMD_0] =
cmdpacket0(R300_TX_BORDER_COLOR_0, 0);
- /* Setup the atom linked list */
- make_empty_list(&r300->hw.atomlist);
- r300->hw.atomlist.name = "atom-list";
-
- insert_at_tail(&r300->hw.atomlist, &r300->hw.vpt);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.vap_cntl);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.vte);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.unk2134);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.vap_cntl_status);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.vir[0]);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.vir[1]);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.vic);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.unk21DC);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.unk221C);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.unk2220);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.unk2288);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.vof);
-
- if (has_tcl)
- insert_at_tail(&r300->hw.atomlist, &r300->hw.pvs);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.gb_enable);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.gb_misc);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.txe);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4200);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4214);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.ps);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4230);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.lcntl);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4260);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.shade);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.polygon_mode);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.fogp);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.zbias_cntl);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.zbs);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.occlusion_cntl);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.cul);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.unk42C0);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.rc);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.ri);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.rr);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.unk43A4);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.unk43E8);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.fp);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.fpt);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.unk46A4);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.fpi[0]);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.fpi[1]);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.fpi[2]);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.fpi[3]);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.fogs);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.fogc);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.at);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4BD8);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.fpp);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4E00);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.bld);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.cmk);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.blend_color);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.cb);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4E50);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4E88);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4EA0);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.zs);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.zstencil_format);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.zb);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4F28);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4F30);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4F44);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4F54);
-
- if (has_tcl) {
- insert_at_tail(&r300->hw.atomlist, &r300->hw.vpi);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.vpp);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.vps);
- }
-
- insert_at_tail(&r300->hw.atomlist, &r300->hw.tex.filter);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.tex.filter_1);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.tex.size);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.tex.format);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.tex.pitch);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.tex.offset);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.tex.chroma_key);
- insert_at_tail(&r300->hw.atomlist, &r300->hw.tex.border_color);
-
r300->hw.is_dirty = GL_TRUE;
r300->hw.all_dirty = GL_TRUE;
@@ -659,38 +580,3 @@ void r300EmitWait(r300ContextPtr rmesa, GLuint flags)
cmd[0].wait.cmd_type = R300_CMD_WAIT;
cmd[0].wait.flags = flags;
}
-
-void r300EmitAOS(r300ContextPtr rmesa, GLuint nr, GLuint offset)
-{
- int sz = 1 + (nr >> 1) * 3 + (nr & 1) * 2;
- int i;
- int cmd_reserved = 0;
- int cmd_written = 0;
- drm_radeon_cmd_header_t *cmd = NULL;
-
- if (RADEON_DEBUG & DEBUG_VERTS)
- fprintf(stderr, "%s: nr=%d, ofs=0x%08x\n", __func__, nr,
- offset);
-
- start_packet3(RADEON_CP_PACKET3_3D_LOAD_VBPNTR, sz - 1);
- e32(nr);
- for (i = 0; i + 1 < nr; i += 2) {
- e32((rmesa->state.aos[i].aos_size << 0)
- | (rmesa->state.aos[i].aos_stride << 8)
- | (rmesa->state.aos[i + 1].aos_size << 16)
- | (rmesa->state.aos[i + 1].aos_stride << 24)
- );
- e32(rmesa->state.aos[i].aos_offset +
- offset * 4 * rmesa->state.aos[i].aos_stride);
- e32(rmesa->state.aos[i + 1].aos_offset +
- offset * 4 * rmesa->state.aos[i + 1].aos_stride);
- }
-
- if (nr & 1) {
- e32((rmesa->state.aos[nr - 1].aos_size << 0)
- | (rmesa->state.aos[nr - 1].aos_stride << 8)
- );
- e32(rmesa->state.aos[nr - 1].aos_offset +
- offset * 4 * rmesa->state.aos[nr - 1].aos_stride);
- }
-}
diff --git a/src/mesa/drivers/dri/r300/r300_cmdbuf.h b/src/mesa/drivers/dri/r300/r300_cmdbuf.h
index 3c336e1589b..acb6e38c6df 100644
--- a/src/mesa/drivers/dri/r300/r300_cmdbuf.h
+++ b/src/mesa/drivers/dri/r300/r300_cmdbuf.h
@@ -46,15 +46,13 @@ extern void r300EmitState(r300ContextPtr r300);
extern void r300InitCmdBuf(r300ContextPtr r300);
extern void r300DestroyCmdBuf(r300ContextPtr r300);
-extern void r300EmitAOS(r300ContextPtr rmesa, GLuint nr, GLuint offset);
-
/**
* Make sure that enough space is available in the command buffer
* by flushing if necessary.
*
* \param dwords The number of dwords we need to be free on the command buffer
*/
-static __inline__ void r300EnsureCmdBufSpace(r300ContextPtr r300,
+static inline void r300EnsureCmdBufSpace(r300ContextPtr r300,
int dwords, const char *caller)
{
assert(dwords < r300->cmdbuf.size);
@@ -70,7 +68,7 @@ static __inline__ void r300EnsureCmdBufSpace(r300ContextPtr r300,
* causes state reemission after a flush. This is necessary to ensure
* correct hardware state after an unlock.
*/
-static __inline__ uint32_t *r300RawAllocCmdBuf(r300ContextPtr r300,
+static inline uint32_t *r300RawAllocCmdBuf(r300ContextPtr r300,
int dwords, const char *caller)
{
uint32_t *ptr;
@@ -82,7 +80,7 @@ static __inline__ uint32_t *r300RawAllocCmdBuf(r300ContextPtr r300,
return ptr;
}
-static __inline__ uint32_t *r300AllocCmdBuf(r300ContextPtr r300,
+static inline uint32_t *r300AllocCmdBuf(r300ContextPtr r300,
int dwords, const char *caller)
{
uint32_t *ptr;
diff --git a/src/mesa/drivers/dri/r300/r300_context.c b/src/mesa/drivers/dri/r300/r300_context.c
index 4f70d7055a4..9ea14ab4c78 100644
--- a/src/mesa/drivers/dri/r300/r300_context.c
+++ b/src/mesa/drivers/dri/r300/r300_context.c
@@ -62,7 +62,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "r300_state.h"
#include "r300_ioctl.h"
#include "r300_tex.h"
-#include "r300_maos.h"
+#include "r300_emit.h"
#ifdef USER_BUFFERS
#include "r300_mem.h"
@@ -447,15 +447,6 @@ static void r300FreeGartAllocations(r300ContextPtr r300)
r300->rmm->u_list[i].pending = 0;
r300->rmm->u_list[i].ptr = NULL;
- if (r300->rmm->u_list[i].fb) {
- LOCK_HARDWARE(&(r300->radeon));
- ret = mmFreeMem(r300->rmm->u_list[i].fb);
- UNLOCK_HARDWARE(&(r300->radeon));
- if (ret)
- fprintf(stderr, "failed to free!\n");
- r300->rmm->u_list[i].fb = NULL;
- }
- r300->rmm->u_list[i].ref_count = 0;
}
}
r300->rmm->u_head = i;
diff --git a/src/mesa/drivers/dri/r300/r300_context.h b/src/mesa/drivers/dri/r300/r300_context.h
index c287871b370..076bb49a006 100644
--- a/src/mesa/drivers/dri/r300/r300_context.h
+++ b/src/mesa/drivers/dri/r300/r300_context.h
@@ -49,13 +49,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define USER_BUFFERS
-/* We don't handle 16 bits elts swapping yet */
-#ifdef MESA_BIG_ENDIAN
-#define FORCE_32BITS_ELTS
-#endif
-
-//#define OPTIMIZE_ELTS
-
struct r300_context;
typedef struct r300_context r300ContextRec;
typedef struct r300_context *r300ContextPtr;
@@ -63,13 +56,10 @@ typedef struct r300_context *r300ContextPtr;
#include "radeon_lock.h"
#include "mm.h"
-/* Checkpoint.. for convenience */
-#define CPT { fprintf(stderr, "%s:%s line %d\n", __FILE__, __FUNCTION__, __LINE__); }
/* From http://gcc.gnu.org/onlinedocs/gcc-3.2.3/gcc/Variadic-Macros.html .
I suppose we could inline this and use macro to fetch out __LINE__ and stuff in case we run into trouble
with other compilers ... GLUE!
*/
-#if 1
#define WARN_ONCE(a, ...) { \
static int warn##__LINE__=1; \
if(warn##__LINE__){ \
@@ -81,9 +71,6 @@ typedef struct r300_context *r300ContextPtr;
warn##__LINE__=0;\
} \
}
-#else
-#define WARN_ONCE(a, ...) {}
-#endif
#include "r300_vertprog.h"
#include "r300_fragprog.h"
@@ -91,7 +78,7 @@ typedef struct r300_context *r300ContextPtr;
/**
* This function takes a float and packs it into a uint32_t
*/
-static __inline__ uint32_t r300PackFloat32(float fl)
+static inline uint32_t r300PackFloat32(float fl)
{
union {
float fl;
@@ -102,6 +89,37 @@ static __inline__ uint32_t r300PackFloat32(float fl)
return u.u;
}
+/* This is probably wrong for some values, I need to test this
+ * some more. Range checking would be a good idea also..
+ *
+ * But it works for most things. I'll fix it later if someone
+ * else with a better clue doesn't
+ */
+static inline uint32_t r300PackFloat24(float f)
+{
+ float mantissa;
+ int exponent;
+ uint32_t float24 = 0;
+
+ if (f == 0.0)
+ return 0;
+
+ mantissa = frexpf(f, &exponent);
+
+ /* Handle -ve */
+ if (mantissa < 0) {
+ float24 |= (1 << 23);
+ mantissa = mantissa * -1.0;
+ }
+ /* Handle exponent, bias of 63 */
+ exponent += 62;
+ float24 |= (exponent << 16);
+ /* Kill 7 LSB of mantissa */
+ float24 |= (r300PackFloat32(mantissa) & 0x7FFFFF) >> 7;
+
+ return float24;
+}
+
/************ DMA BUFFERS **************/
/* Need refcounting on dma buffers:
@@ -129,7 +147,6 @@ struct r300_dma_region {
int aos_offset; /* address in GART memory */
int aos_stride; /* distance between elements, in dwords */
int aos_size; /* number of components (1-4) */
- int aos_reg; /* VAP register assignment */
};
struct r300_dma {
@@ -171,6 +188,8 @@ struct r300_tex_obj {
drm_radeon_tex_image_t image[6][RADEON_MAX_TEXTURE_LEVELS];
/* Six, for the cube faces */
+ GLboolean image_override; /* Image overridden by GLX_EXT_tfp */
+
GLuint pitch; /* this isn't sent to hardware just used in calculations */
/* hardware register values */
/* Note that R200 has 8 registers per texture and R300 only 7 */
@@ -433,7 +452,7 @@ struct r300_hw_state {
struct r300_state_atom vic; /* vap input control (2180) */
struct r300_state_atom unk21DC; /* (21DC) */
struct r300_state_atom unk221C; /* (221C) */
- struct r300_state_atom unk2220; /* (2220) */
+ struct r300_state_atom vap_clip;
struct r300_state_atom unk2288; /* (2288) */
struct r300_state_atom pvs; /* pvs_cntl (22D0) */
struct r300_state_atom gb_enable; /* (4008) */
@@ -761,50 +780,10 @@ struct r300_fragment_program {
#define R300_MAX_AOS_ARRAYS 16
-#define AOS_FORMAT_USHORT 0
-#define AOS_FORMAT_FLOAT 1
-#define AOS_FORMAT_UBYTE 2
-#define AOS_FORMAT_FLOAT_COLOR 3
-
#define REG_COORDS 0
#define REG_COLOR0 1
#define REG_TEX0 2
-struct dt {
- GLint size;
- GLenum type;
- GLsizei stride;
- void *data;
-};
-
-struct radeon_vertex_buffer {
- int Count;
- void *Elts;
- int elt_size;
- int elt_min, elt_max; /* debug */
-
- struct dt AttribPtr[VERT_ATTRIB_MAX];
-
- const struct _mesa_prim *Primitive;
- GLuint PrimitiveCount;
- GLint LockFirst;
- GLsizei LockCount;
- int lock_uptodate;
-};
-
-struct r300_aos_rec {
- GLuint offset;
- int element_size; /* in dwords */
- int stride; /* distance between elements, in dwords */
-
- int format;
-
- int ncomponents; /* number of components - between 1 and 4, inclusive */
-
- int reg; /* which register they are assigned to. */
-
-};
-
struct r300_state {
struct r300_depthbuffer_state depth;
struct r300_texture_state texture;
@@ -813,7 +792,6 @@ struct r300_state {
struct r300_pfs_compile_state pfs_compile;
struct r300_dma_region aos[R300_MAX_AOS_ARRAYS];
int aos_count;
- struct radeon_vertex_buffer VB;
GLuint *Elts;
struct r300_dma_region elt_dma;
@@ -865,9 +843,10 @@ struct r300_context {
#ifdef USER_BUFFERS
struct r300_memory_manager *rmm;
+#endif
+
GLvector4f dummy_attrib[_TNL_ATTRIB_MAX];
GLvector4f *temp_attrib[_TNL_ATTRIB_MAX];
-#endif
GLboolean disable_lowimpact_fallback;
};
diff --git a/src/mesa/drivers/dri/r300/r300_emit.c b/src/mesa/drivers/dri/r300/r300_emit.c
new file mode 100644
index 00000000000..4670c28a02f
--- /dev/null
+++ b/src/mesa/drivers/dri/r300/r300_emit.c
@@ -0,0 +1,534 @@
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial
+portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/**
+ * \file
+ *
+ * \author Keith Whitwell <[email protected]>
+ */
+
+#include "glheader.h"
+#include "mtypes.h"
+#include "colormac.h"
+#include "imports.h"
+#include "macros.h"
+#include "image.h"
+
+#include "swrast_setup/swrast_setup.h"
+#include "math/m_translate.h"
+#include "tnl/tnl.h"
+#include "tnl/t_context.h"
+
+#include "r300_context.h"
+#include "radeon_ioctl.h"
+#include "r300_state.h"
+#include "r300_emit.h"
+#include "r300_ioctl.h"
+
+#ifdef USER_BUFFERS
+#include "r300_mem.h"
+#endif
+
+#if SWIZZLE_X != R300_INPUT_ROUTE_SELECT_X || \
+ SWIZZLE_Y != R300_INPUT_ROUTE_SELECT_Y || \
+ SWIZZLE_Z != R300_INPUT_ROUTE_SELECT_Z || \
+ SWIZZLE_W != R300_INPUT_ROUTE_SELECT_W || \
+ SWIZZLE_ZERO != R300_INPUT_ROUTE_SELECT_ZERO || \
+ SWIZZLE_ONE != R300_INPUT_ROUTE_SELECT_ONE
+#error Cannot change these!
+#endif
+
+#define DEBUG_ALL DEBUG_VERTS
+
+#if defined(USE_X86_ASM)
+#define COPY_DWORDS( dst, src, nr ) \
+do { \
+ int __tmp; \
+ __asm__ __volatile__( "rep ; movsl" \
+ : "=%c" (__tmp), "=D" (dst), "=S" (__tmp) \
+ : "0" (nr), \
+ "D" ((long)dst), \
+ "S" ((long)src) ); \
+} while (0)
+#else
+#define COPY_DWORDS( dst, src, nr ) \
+do { \
+ int j; \
+ for ( j = 0 ; j < nr ; j++ ) \
+ dst[j] = ((int *)src)[j]; \
+ dst += nr; \
+} while (0)
+#endif
+
+static void r300EmitVec4(GLcontext * ctx, struct r300_dma_region *rvb,
+ GLvoid * data, int stride, int count)
+{
+ int i;
+ int *out = (int *)(rvb->address + rvb->start);
+
+ if (RADEON_DEBUG & DEBUG_VERTS)
+ fprintf(stderr, "%s count %d stride %d out %p data %p\n",
+ __FUNCTION__, count, stride, (void *)out, (void *)data);
+
+ if (stride == 4)
+ COPY_DWORDS(out, data, count);
+ else
+ for (i = 0; i < count; i++) {
+ out[0] = *(int *)data;
+ out++;
+ data += stride;
+ }
+}
+
+static void r300EmitVec8(GLcontext * ctx, struct r300_dma_region *rvb,
+ GLvoid * data, int stride, int count)
+{
+ int i;
+ int *out = (int *)(rvb->address + rvb->start);
+
+ if (RADEON_DEBUG & DEBUG_VERTS)
+ fprintf(stderr, "%s count %d stride %d out %p data %p\n",
+ __FUNCTION__, count, stride, (void *)out, (void *)data);
+
+ if (stride == 8)
+ COPY_DWORDS(out, data, count * 2);
+ else
+ for (i = 0; i < count; i++) {
+ out[0] = *(int *)data;
+ out[1] = *(int *)(data + 4);
+ out += 2;
+ data += stride;
+ }
+}
+
+static void r300EmitVec12(GLcontext * ctx, struct r300_dma_region *rvb,
+ GLvoid * data, int stride, int count)
+{
+ int i;
+ int *out = (int *)(rvb->address + rvb->start);
+
+ if (RADEON_DEBUG & DEBUG_VERTS)
+ fprintf(stderr, "%s count %d stride %d out %p data %p\n",
+ __FUNCTION__, count, stride, (void *)out, (void *)data);
+
+ if (stride == 12)
+ COPY_DWORDS(out, data, count * 3);
+ else
+ for (i = 0; i < count; i++) {
+ out[0] = *(int *)data;
+ out[1] = *(int *)(data + 4);
+ out[2] = *(int *)(data + 8);
+ out += 3;
+ data += stride;
+ }
+}
+
+static void r300EmitVec16(GLcontext * ctx, struct r300_dma_region *rvb,
+ GLvoid * data, int stride, int count)
+{
+ int i;
+ int *out = (int *)(rvb->address + rvb->start);
+
+ if (RADEON_DEBUG & DEBUG_VERTS)
+ fprintf(stderr, "%s count %d stride %d out %p data %p\n",
+ __FUNCTION__, count, stride, (void *)out, (void *)data);
+
+ if (stride == 16)
+ COPY_DWORDS(out, data, count * 4);
+ else
+ for (i = 0; i < count; i++) {
+ out[0] = *(int *)data;
+ out[1] = *(int *)(data + 4);
+ out[2] = *(int *)(data + 8);
+ out[3] = *(int *)(data + 12);
+ out += 4;
+ data += stride;
+ }
+}
+
+static void r300EmitVec(GLcontext * ctx, struct r300_dma_region *rvb,
+ GLvoid * data, int size, int stride, int count)
+{
+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
+
+ if (stride == 0) {
+ r300AllocDmaRegion(rmesa, rvb, size * 4, 4);
+ count = 1;
+ rvb->aos_offset = GET_START(rvb);
+ rvb->aos_stride = 0;
+ } else {
+ r300AllocDmaRegion(rmesa, rvb, size * count * 4, 4);
+ rvb->aos_offset = GET_START(rvb);
+ rvb->aos_stride = size;
+ }
+
+ switch (size) {
+ case 1:
+ r300EmitVec4(ctx, rvb, data, stride, count);
+ break;
+ case 2:
+ r300EmitVec8(ctx, rvb, data, stride, count);
+ break;
+ case 3:
+ r300EmitVec12(ctx, rvb, data, stride, count);
+ break;
+ case 4:
+ r300EmitVec16(ctx, rvb, data, stride, count);
+ break;
+ default:
+ assert(0);
+ break;
+ }
+}
+
+static GLuint r300VAPInputRoute0(uint32_t * dst, GLvector4f ** attribptr,
+ int *inputs, GLint * tab, GLuint nr)
+{
+ GLuint i, dw;
+
+ /* type, inputs, stop bit, size */
+ for (i = 0; i + 1 < nr; i += 2) {
+ dw = R300_INPUT_ROUTE_FLOAT | (inputs[tab[i]] << 8) | (attribptr[tab[i]]->size - 1);
+ dw |= (R300_INPUT_ROUTE_FLOAT | (inputs[tab[i + 1]] << 8) | (attribptr[tab[i + 1]]->size - 1)) << 16;
+ if (i + 2 == nr) {
+ dw |= (1 << (13 + 16));
+ }
+ dst[i >> 1] = dw;
+ }
+
+ if (nr & 1) {
+ dw = R300_INPUT_ROUTE_FLOAT | (inputs[tab[nr - 1]] << 8) | (attribptr[tab[nr - 1]]->size - 1);
+ dw |= 1 << 13;
+ dst[nr >> 1] = dw;
+ }
+
+ return (nr + 1) >> 1;
+}
+
+static GLuint r300VAPInputRoute1Swizzle(int swizzle[4])
+{
+ return (swizzle[0] << R300_INPUT_ROUTE_X_SHIFT) |
+ (swizzle[1] << R300_INPUT_ROUTE_Y_SHIFT) |
+ (swizzle[2] << R300_INPUT_ROUTE_Z_SHIFT) |
+ (swizzle[3] << R300_INPUT_ROUTE_W_SHIFT);
+}
+
+static GLuint r300VAPInputRoute1(uint32_t * dst, int swizzle[][4], GLuint nr)
+{
+ GLuint i;
+
+ for (i = 0; i + 1 < nr; i += 2) {
+ dst[i >> 1] = r300VAPInputRoute1Swizzle(swizzle[i]) | R300_INPUT_ROUTE_ENABLE;
+ dst[i >> 1] |= (r300VAPInputRoute1Swizzle(swizzle[i + 1]) | R300_INPUT_ROUTE_ENABLE) << 16;
+ }
+
+ if (nr & 1) {
+ dst[nr >> 1] = r300VAPInputRoute1Swizzle(swizzle[nr - 1]) | R300_INPUT_ROUTE_ENABLE;
+ }
+
+ return (nr + 1) >> 1;
+}
+
+static GLuint r300VAPInputCntl0(GLcontext * ctx, GLuint InputsRead)
+{
+ /* No idea what this value means. I have seen other values written to
+ * this register... */
+ return 0x5555;
+}
+
+static GLuint r300VAPInputCntl1(GLcontext * ctx, GLuint InputsRead)
+{
+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
+ GLuint i, vic_1 = 0;
+
+ if (InputsRead & (1 << VERT_ATTRIB_POS))
+ vic_1 |= R300_INPUT_CNTL_POS;
+
+ if (InputsRead & (1 << VERT_ATTRIB_NORMAL))
+ vic_1 |= R300_INPUT_CNTL_NORMAL;
+
+ if (InputsRead & (1 << VERT_ATTRIB_COLOR0))
+ vic_1 |= R300_INPUT_CNTL_COLOR;
+
+ rmesa->state.texture.tc_count = 0;
+ for (i = 0; i < ctx->Const.MaxTextureUnits; i++)
+ if (InputsRead & (1 << (VERT_ATTRIB_TEX0 + i))) {
+ rmesa->state.texture.tc_count++;
+ vic_1 |= R300_INPUT_CNTL_TC0 << i;
+ }
+
+ return vic_1;
+}
+
+static GLuint r300VAPOutputCntl0(GLcontext * ctx, GLuint OutputsWritten)
+{
+ GLuint ret = 0;
+
+ if (OutputsWritten & (1 << VERT_RESULT_HPOS))
+ ret |= R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT;
+
+ if (OutputsWritten & (1 << VERT_RESULT_COL0))
+ ret |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_PRESENT;
+
+ if (OutputsWritten & (1 << VERT_RESULT_COL1))
+ ret |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_1_PRESENT;
+
+#if 0
+ if (OutputsWritten & (1 << VERT_RESULT_BFC0))
+ ret |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_2_PRESENT;
+
+ if (OutputsWritten & (1 << VERT_RESULT_BFC1))
+ ret |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_3_PRESENT;
+
+ if (OutputsWritten & (1 << VERT_RESULT_FOGC)) ;
+#endif
+
+ if (OutputsWritten & (1 << VERT_RESULT_PSIZ))
+ ret |= R300_VAP_OUTPUT_VTX_FMT_0__PT_SIZE_PRESENT;
+
+ return ret;
+}
+
+static GLuint r300VAPOutputCntl1(GLcontext * ctx, GLuint OutputsWritten)
+{
+ GLuint i, ret = 0;
+
+ for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
+ if (OutputsWritten & (1 << (VERT_RESULT_TEX0 + i))) {
+ ret |= (4 << (3 * i));
+ }
+ }
+
+ return ret;
+}
+
+/* Emit vertex data to GART memory
+ * Route inputs to the vertex processor
+ * This function should never return R300_FALLBACK_TCL when using software tcl.
+ */
+int r300EmitArrays(GLcontext * ctx)
+{
+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *vb = &tnl->vb;
+ GLuint nr;
+ GLuint count = vb->Count;
+ GLuint i;
+ GLuint InputsRead = 0, OutputsWritten = 0;
+ int *inputs = NULL;
+ int vir_inputs[VERT_ATTRIB_MAX];
+ GLint tab[VERT_ATTRIB_MAX];
+ int swizzle[VERT_ATTRIB_MAX][4];
+ struct r300_vertex_program *prog =
+ (struct r300_vertex_program *)CURRENT_VERTEX_SHADER(ctx);
+
+ if (hw_tcl_on) {
+ inputs = prog->inputs;
+ InputsRead = prog->key.InputsRead;
+ OutputsWritten = prog->key.OutputsWritten;
+ } else {
+ inputs = rmesa->state.sw_tcl_inputs;
+
+ DECLARE_RENDERINPUTS(render_inputs_bitset);
+ RENDERINPUTS_COPY(render_inputs_bitset, tnl->render_inputs_bitset);
+
+ assert(RENDERINPUTS_TEST(render_inputs_bitset, _TNL_ATTRIB_POS));
+ assert(RENDERINPUTS_TEST(render_inputs_bitset, _TNL_ATTRIB_NORMAL) == 0);
+ assert(RENDERINPUTS_TEST(render_inputs_bitset, _TNL_ATTRIB_COLOR0));
+
+ if (RENDERINPUTS_TEST(render_inputs_bitset, _TNL_ATTRIB_POS)) {
+ InputsRead |= 1 << VERT_ATTRIB_POS;
+ OutputsWritten |= 1 << VERT_RESULT_HPOS;
+ }
+
+ if (RENDERINPUTS_TEST(render_inputs_bitset, _TNL_ATTRIB_COLOR0)) {
+ InputsRead |= 1 << VERT_ATTRIB_COLOR0;
+ OutputsWritten |= 1 << VERT_RESULT_COL0;
+ }
+
+ if (RENDERINPUTS_TEST(render_inputs_bitset, _TNL_ATTRIB_COLOR1)) {
+ InputsRead |= 1 << VERT_ATTRIB_COLOR1;
+ OutputsWritten |= 1 << VERT_RESULT_COL1;
+ }
+
+ for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
+ if (RENDERINPUTS_TEST(render_inputs_bitset, _TNL_ATTRIB_TEX(i))) {
+ InputsRead |= 1 << (VERT_ATTRIB_TEX0 + i);
+ OutputsWritten |= 1 << (VERT_RESULT_TEX0 + i);
+ }
+ }
+
+ for (i = 0, nr = 0; i < VERT_ATTRIB_MAX; i++) {
+ if (InputsRead & (1 << i)) {
+ inputs[i] = nr++;
+ } else {
+ inputs[i] = -1;
+ }
+ }
+
+ if (!(rmesa->radeon.radeonScreen->chip_flags & RADEON_CHIPSET_TCL)) {
+ /* Fixed, apply to vir0 only */
+ memcpy(vir_inputs, inputs, VERT_ATTRIB_MAX * sizeof(int));
+ inputs = vir_inputs;
+ if (InputsRead & VERT_ATTRIB_POS)
+ inputs[VERT_ATTRIB_POS] = 0;
+ if (InputsRead & (1 << VERT_ATTRIB_COLOR0))
+ inputs[VERT_ATTRIB_COLOR0] = 2;
+ if (InputsRead & (1 << VERT_ATTRIB_COLOR1))
+ inputs[VERT_ATTRIB_COLOR1] = 3;
+ for (i = VERT_ATTRIB_TEX0; i <= VERT_ATTRIB_TEX7; i++)
+ if (InputsRead & (1 << i))
+ inputs[i] = 6 + (i - VERT_ATTRIB_TEX0);
+ }
+
+ RENDERINPUTS_COPY(rmesa->state.render_inputs_bitset, render_inputs_bitset);
+ }
+
+ assert(InputsRead);
+ assert(OutputsWritten);
+
+ for (i = 0, nr = 0; i < VERT_ATTRIB_MAX; i++) {
+ if (InputsRead & (1 << i)) {
+ tab[nr++] = i;
+ }
+ }
+
+ if (nr > R300_MAX_AOS_ARRAYS) {
+ return R300_FALLBACK_TCL;
+ }
+
+ for (i = 0; i < nr; i++) {
+ int ci, fix, found = 0;
+
+ swizzle[i][0] = SWIZZLE_ZERO;
+ swizzle[i][1] = SWIZZLE_ZERO;
+ swizzle[i][2] = SWIZZLE_ZERO;
+ swizzle[i][3] = SWIZZLE_ONE;
+
+ for (ci = 0; ci < vb->AttribPtr[tab[i]]->size; ci++) {
+ swizzle[i][ci] = ci;
+ }
+
+ if (r300IsGartMemory(rmesa, vb->AttribPtr[tab[i]]->data, 4)) {
+ if (vb->AttribPtr[tab[i]]->stride % 4) {
+ return R300_FALLBACK_TCL;
+ }
+ rmesa->state.aos[i].address = (void *)(vb->AttribPtr[tab[i]]->data);
+ rmesa->state.aos[i].start = 0;
+ rmesa->state.aos[i].aos_offset = r300GartOffsetFromVirtual(rmesa, vb->AttribPtr[tab[i]]->data);
+ rmesa->state.aos[i].aos_stride = vb->AttribPtr[tab[i]]->stride / 4;
+ rmesa->state.aos[i].aos_size = vb->AttribPtr[tab[i]]->size;
+ } else {
+ r300EmitVec(ctx, &rmesa->state.aos[i],
+ vb->AttribPtr[tab[i]]->data,
+ vb->AttribPtr[tab[i]]->size,
+ vb->AttribPtr[tab[i]]->stride, count);
+ }
+
+ rmesa->state.aos[i].aos_size = vb->AttribPtr[tab[i]]->size;
+
+ for (fix = 0; fix <= 4 - vb->AttribPtr[tab[i]]->size; fix++) {
+ if ((rmesa->state.aos[i].aos_offset - _mesa_sizeof_type(GL_FLOAT) * fix) % 4) {
+ continue;
+ }
+ found = 1;
+ break;
+ }
+
+ if (found) {
+ if (fix > 0) {
+ WARN_ONCE("Feeling lucky?\n");
+ }
+ rmesa->state.aos[i].aos_offset -= _mesa_sizeof_type(GL_FLOAT) * fix;
+ for (ci = 0; ci < vb->AttribPtr[tab[i]]->size; ci++) {
+ swizzle[i][ci] += fix;
+ }
+ } else {
+ WARN_ONCE
+ ("Cannot handle offset %x with stride %d, comp %d\n",
+ rmesa->state.aos[i].aos_offset,
+ rmesa->state.aos[i].aos_stride,
+ vb->AttribPtr[tab[i]]->size);
+ return R300_FALLBACK_TCL;
+ }
+ }
+
+ /* Setup INPUT_ROUTE. */
+ R300_STATECHANGE(rmesa, vir[0]);
+ ((drm_r300_cmd_header_t *) rmesa->hw.vir[0].cmd)->packet0.count =
+ r300VAPInputRoute0(&rmesa->hw.vir[0].cmd[R300_VIR_CNTL_0],
+ vb->AttribPtr, inputs, tab, nr);
+ R300_STATECHANGE(rmesa, vir[1]);
+ ((drm_r300_cmd_header_t *) rmesa->hw.vir[1].cmd)->packet0.count =
+ r300VAPInputRoute1(&rmesa->hw.vir[1].cmd[R300_VIR_CNTL_0], swizzle,
+ nr);
+
+ /* Setup INPUT_CNTL. */
+ R300_STATECHANGE(rmesa, vic);
+ rmesa->hw.vic.cmd[R300_VIC_CNTL_0] = r300VAPInputCntl0(ctx, InputsRead);
+ rmesa->hw.vic.cmd[R300_VIC_CNTL_1] = r300VAPInputCntl1(ctx, InputsRead);
+
+ /* Setup OUTPUT_VTX_FMT. */
+ R300_STATECHANGE(rmesa, vof);
+ rmesa->hw.vof.cmd[R300_VOF_CNTL_0] =
+ r300VAPOutputCntl0(ctx, OutputsWritten);
+ rmesa->hw.vof.cmd[R300_VOF_CNTL_1] =
+ r300VAPOutputCntl1(ctx, OutputsWritten);
+
+ rmesa->state.aos_count = nr;
+
+ return R300_FALLBACK_NONE;
+}
+
+#ifdef USER_BUFFERS
+void r300UseArrays(GLcontext * ctx)
+{
+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
+ int i;
+
+ if (rmesa->state.elt_dma.buf)
+ r300_mem_use(rmesa, rmesa->state.elt_dma.buf->id);
+
+ for (i = 0; i < rmesa->state.aos_count; i++) {
+ if (rmesa->state.aos[i].buf)
+ r300_mem_use(rmesa, rmesa->state.aos[i].buf->id);
+ }
+}
+#endif
+
+void r300ReleaseArrays(GLcontext * ctx)
+{
+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
+ int i;
+
+ r300ReleaseDmaRegion(rmesa, &rmesa->state.elt_dma, __FUNCTION__);
+ for (i = 0; i < rmesa->state.aos_count; i++) {
+ r300ReleaseDmaRegion(rmesa, &rmesa->state.aos[i], __FUNCTION__);
+ }
+}
diff --git a/src/mesa/drivers/dri/r300/r300_emit.h b/src/mesa/drivers/dri/r300/r300_emit.h
index bccb84933ad..2f79ee3a23a 100644
--- a/src/mesa/drivers/dri/r300/r300_emit.h
+++ b/src/mesa/drivers/dri/r300/r300_emit.h
@@ -44,22 +44,13 @@
#include "r300_cmdbuf.h"
#include "radeon_reg.h"
-/*
- * CP type-3 packets
- */
-#define RADEON_CP_PACKET3_UNK1B 0xC0001B00
-#define RADEON_CP_PACKET3_INDX_BUFFER 0xC0003300
-#define RADEON_CP_PACKET3_3D_DRAW_VBUF_2 0xC0003400
-#define RADEON_CP_PACKET3_3D_DRAW_IMMD_2 0xC0003500
-#define RADEON_CP_PACKET3_3D_DRAW_INDX_2 0xC0003600
-#define RADEON_CP_PACKET3_3D_LOAD_VBPNTR 0xC0002F00
-#define RADEON_CP_PACKET3_3D_CLEAR_ZMASK 0xC0003202
-#define RADEON_CP_PACKET3_3D_CLEAR_CMASK 0xC0003802
-#define RADEON_CP_PACKET3_3D_CLEAR_HIZ 0xC0003702
-
+/* TODO: move these defines (and the ones from DRM) into r300_reg.h and sync up
+ * with DRM */
#define CP_PACKET0(reg, n) (RADEON_CP_PACKET0 | ((n)<<16) | ((reg)>>2))
+#define CP_PACKET3( pkt, n ) \
+ (RADEON_CP_PACKET3 | (pkt) | ((n) << 16))
-static __inline__ uint32_t cmdpacket0(int reg, int count)
+static inline uint32_t cmdpacket0(int reg, int count)
{
drm_r300_cmd_header_t cmd;
@@ -71,7 +62,7 @@ static __inline__ uint32_t cmdpacket0(int reg, int count)
return cmd.u;
}
-static __inline__ uint32_t cmdvpu(int addr, int count)
+static inline uint32_t cmdvpu(int addr, int count)
{
drm_r300_cmd_header_t cmd;
@@ -83,7 +74,7 @@ static __inline__ uint32_t cmdvpu(int addr, int count)
return cmd.u;
}
-static __inline__ uint32_t cmdpacket3(int packet)
+static inline uint32_t cmdpacket3(int packet)
{
drm_r300_cmd_header_t cmd;
@@ -93,7 +84,7 @@ static __inline__ uint32_t cmdpacket3(int packet)
return cmd.u;
}
-static __inline__ uint32_t cmdcpdelay(unsigned short count)
+static inline uint32_t cmdcpdelay(unsigned short count)
{
drm_r300_cmd_header_t cmd;
@@ -103,7 +94,7 @@ static __inline__ uint32_t cmdcpdelay(unsigned short count)
return cmd.u;
}
-static __inline__ uint32_t cmdwait(unsigned char flags)
+static inline uint32_t cmdwait(unsigned char flags)
{
drm_r300_cmd_header_t cmd;
@@ -113,7 +104,7 @@ static __inline__ uint32_t cmdwait(unsigned char flags)
return cmd.u;
}
-static __inline__ uint32_t cmdpacify(void)
+static inline uint32_t cmdpacify(void)
{
drm_r300_cmd_header_t cmd;
@@ -134,7 +125,7 @@ static __inline__ uint32_t cmdpacify(void)
cmd = (drm_radeon_cmd_header_t*) \
r300AllocCmdBuf(rmesa, \
(_n+2), \
- __func__); \
+ __FUNCTION__); \
cmd_reserved=_n+2; \
cmd_written=1; \
cmd[0].i=cmdpacket0((reg), _n+1); \
@@ -169,7 +160,7 @@ static __inline__ uint32_t cmdpacify(void)
cmd = (drm_radeon_cmd_header_t*) \
r300AllocCmdBuf(rmesa, \
(_n+1), \
- __func__); \
+ __FUNCTION__); \
cmd_reserved = _n+2; \
cmd_written =1; \
cmd[0].i = cmdvpu((dest), _n/4); \
@@ -184,7 +175,7 @@ static __inline__ uint32_t cmdpacify(void)
cmd = (drm_radeon_cmd_header_t*) \
r300AllocCmdBuf(rmesa, \
(_n+3), \
- __func__); \
+ __FUNCTION__); \
cmd_reserved = _n+3; \
cmd_written = 2; \
if(_n > 0x3fff) { \
@@ -227,40 +218,12 @@ void static inline cp_wait(r300ContextPtr rmesa, unsigned char flags)
cmd[0].i = cmdwait(flags);
}
-/**
- * fire vertex buffer
- */
-static void inline fire_AOS(r300ContextPtr rmesa, int vertex_count, int type)
-{
- int cmd_reserved = 0;
- int cmd_written = 0;
- drm_radeon_cmd_header_t *cmd = NULL;
-
- start_packet3(RADEON_CP_PACKET3_3D_DRAW_VBUF_2, 0);
- e32(R300_VAP_VF_CNTL__PRIM_WALK_VERTEX_LIST | (vertex_count << 16)
- | type);
-}
+extern int r300EmitArrays(GLcontext * ctx);
-/**
- * These are followed by the corresponding data
- */
-#define start_index32_packet(vertex_count, type) \
- do { \
- int _vc; \
- _vc = (vertex_count); \
- start_packet3(RADEON_CP_PACKET3_3D_DRAW_INDX_2, _vc); \
- e32(R300_VAP_VF_CNTL__PRIM_WALK_INDICES | (_vc<<16) | \
- type | R300_VAP_VF_CNTL__INDEX_SIZE_32bit); \
- } while (0);
+#ifdef USER_BUFFERS
+void r300UseArrays(GLcontext * ctx);
+#endif
-#define start_index16_packet(vertex_count, type) \
- do { \
- int _vc, _n; \
- _vc = (vertex_count); \
- _n = (vertex_count+1)>>1; \
- start_packet3(RADEON_CP_PACKET3_3D_DRAW_INDX_2, _n); \
- e32(R300_VAP_VF_CNTL__PRIM_WALK_INDICES | (_vc<<16) | \
- type); \
- } while (0);
+extern void r300ReleaseArrays(GLcontext * ctx);
#endif
diff --git a/src/mesa/drivers/dri/r300/r300_fragprog.c b/src/mesa/drivers/dri/r300/r300_fragprog.c
index c6fbe3f9aae..cce8e685865 100644
--- a/src/mesa/drivers/dri/r300/r300_fragprog.c
+++ b/src/mesa/drivers/dri/r300/r300_fragprog.c
@@ -57,7 +57,7 @@
*/
#define ERROR(fmt, args...) do { \
fprintf(stderr, "%s::%s(): " fmt "\n", \
- __FILE__, __func__, ##args); \
+ __FILE__, __FUNCTION__, ##args); \
fp->error = GL_TRUE; \
} while(0)
diff --git a/src/mesa/drivers/dri/r300/r300_ioctl.c b/src/mesa/drivers/dri/r300/r300_ioctl.c
index d2cc97d213e..15c2cf3ad7b 100644
--- a/src/mesa/drivers/dri/r300/r300_ioctl.c
+++ b/src/mesa/drivers/dri/r300/r300_ioctl.c
@@ -114,7 +114,7 @@ static void r300ClearBuffer(r300ContextPtr r300, int flags, int buffer)
(ctx->Color.ColorMask[RCOMP] ? R300_COLORMASK0_R : 0) |
(ctx->Color.ColorMask[ACOMP] ? R300_COLORMASK0_A : 0));
} else {
- e32(0);
+ e32(0x0);
}
R300_STATECHANGE(r300, zs);
@@ -194,6 +194,14 @@ static void r300EmitClearState(GLcontext * ctx)
if (!(r300->radeon.radeonScreen->chip_flags & RADEON_CHIPSET_TCL))
has_tcl = 0;
+ /* FIXME: the values written to R300_VAP_INPUT_ROUTE_0_0 and
+ * R300_VAP_INPUT_ROUTE_0_1 are in fact known, however, the values are
+ * quite complex; see the functions in r300_emit.c.
+ *
+ * I believe it would be a good idea to extend the functions in
+ * r300_emit.c so that they can be used to setup the default values for
+ * these registers, as well as the actual values used for rendering.
+ */
R300_STATECHANGE(r300, vir[0]);
reg_start(R300_VAP_INPUT_ROUTE_0_0, 0);
if (!has_tcl)
@@ -210,31 +218,33 @@ static void r300EmitClearState(GLcontext * ctx)
reg_start(R300_VAP_INPUT_ROUTE_1_0, 0);
e32(0xF688F688);
+ /* R300_VAP_INPUT_CNTL_0, R300_VAP_INPUT_CNTL_1 */
R300_STATECHANGE(r300, vic);
reg_start(R300_VAP_INPUT_CNTL_0, 1);
- e32(0x00000001);
- e32(0x00000405);
-
- if (!has_tcl) {
- R300_STATECHANGE(r300, vte);
- /* comes from fglrx startup of clear */
- reg_start(R300_SE_VTE_CNTL, 1);
- e32(0x043f);
- e32(0x8);
-
- reg_start(0x21dc, 0);
- e32(0xaaaaaaaa);
- }
+ e32(R300_INPUT_CNTL_0_COLOR);
+ e32(R300_INPUT_CNTL_POS | R300_INPUT_CNTL_COLOR | R300_INPUT_CNTL_TC0);
+
+ R300_STATECHANGE(r300, vte);
+ /* comes from fglrx startup of clear */
+ reg_start(R300_SE_VTE_CNTL, 1);
+ e32(R300_VTX_W0_FMT | R300_VPORT_X_SCALE_ENA |
+ R300_VPORT_X_OFFSET_ENA | R300_VPORT_Y_SCALE_ENA |
+ R300_VPORT_Y_OFFSET_ENA | R300_VPORT_Z_SCALE_ENA |
+ R300_VPORT_Z_OFFSET_ENA);
+ e32(0x8);
+
+ reg_start(0x21dc, 0);
+ e32(0xaaaaaaaa);
R300_STATECHANGE(r300, vof);
reg_start(R300_VAP_OUTPUT_VTX_FMT_0, 1);
e32(R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT |
R300_VAP_OUTPUT_VTX_FMT_0__COLOR_PRESENT);
- e32(0); /* no textures */
+ e32(0x0); /* no textures */
R300_STATECHANGE(r300, txe);
reg_start(R300_TX_ENABLE, 0);
- e32(0);
+ e32(0x0);
R300_STATECHANGE(r300, vpt);
reg_start(R300_SE_VPORT_XSCALE, 5);
@@ -247,12 +257,12 @@ static void r300EmitClearState(GLcontext * ctx)
R300_STATECHANGE(r300, at);
reg_start(R300_PP_ALPHA_TEST, 0);
- e32(0);
+ e32(0x0);
R300_STATECHANGE(r300, bld);
reg_start(R300_RB3D_CBLEND, 1);
- e32(0);
- e32(0);
+ e32(0x0);
+ e32(0x0);
R300_STATECHANGE(r300, unk221C);
reg_start(R300_VAP_UNKNOWN_221C, 0);
@@ -273,21 +283,21 @@ static void r300EmitClearState(GLcontext * ctx)
/* The second constant is needed to get glxgears display anything .. */
reg_start(R300_RS_CNTL_0, 1);
e32((1 << R300_RS_CNTL_CI_CNT_SHIFT) | R300_RS_CNTL_0_UNKNOWN_18);
- e32(0);
+ e32(0x0);
R300_STATECHANGE(r300, rr);
reg_start(R300_RS_ROUTE_0, 0);
- e32(0x00004000);
+ e32(R300_RS_ROUTE_0_COLOR);
R300_STATECHANGE(r300, fp);
reg_start(R300_PFS_CNTL_0, 2);
- e32(0);
- e32(0);
- e32(0);
+ e32(0x0);
+ e32(0x0);
+ e32(0x0);
reg_start(R300_PFS_NODE_0, 3);
- e32(0);
- e32(0);
- e32(0);
+ e32(0x0);
+ e32(0x0);
+ e32(0x0);
e32(R300_PFS_NODE_OUTPUT_COLOR);
R300_STATECHANGE(r300, fpi[0]);
@@ -313,7 +323,7 @@ static void r300EmitClearState(GLcontext * ctx)
e32((0 << R300_PVS_CNTL_1_PROGRAM_START_SHIFT) |
(0 << R300_PVS_CNTL_1_POS_END_SHIFT) |
(1 << R300_PVS_CNTL_1_PROGRAM_END_SHIFT));
- e32(0);
+ e32(0x0);
e32(1 << R300_PVS_CNTL_3_PROGRAM_UNKNOWN_SHIFT);
R300_STATECHANGE(r300, vpi);
@@ -321,12 +331,12 @@ static void r300EmitClearState(GLcontext * ctx)
e32(VP_OUT(ADD, OUT, 0, XYZW));
e32(VP_IN(IN, 0));
e32(VP_ZERO());
- e32(0);
+ e32(0x0);
e32(VP_OUT(ADD, OUT, 1, XYZW));
e32(VP_IN(IN, 1));
e32(VP_ZERO());
- e32(0);
+ e32(0x0);
}
}
@@ -667,27 +677,6 @@ void r300AllocDmaRegion(r300ContextPtr rmesa,
#endif
-/* Called via glXGetMemoryOffsetMESA() */
-GLuint r300GetMemoryOffsetMESA(__DRInativeDisplay * dpy, int scrn,
- const GLvoid * pointer)
-{
- GET_CURRENT_CONTEXT(ctx);
- r300ContextPtr rmesa;
- GLuint card_offset;
-
- if (!ctx || !(rmesa = R300_CONTEXT(ctx))) {
- fprintf(stderr, "%s: no context\n", __FUNCTION__);
- return ~0;
- }
-
- if (!r300IsGartMemory(rmesa, pointer, 0))
- return ~0;
-
- card_offset = r300GartOffsetFromVirtual(rmesa, pointer);
-
- return card_offset - rmesa->radeon.radeonScreen->gart_base;
-}
-
GLboolean r300IsGartMemory(r300ContextPtr rmesa, const GLvoid * pointer,
GLint size)
{
diff --git a/src/mesa/drivers/dri/r300/r300_ioctl.h b/src/mesa/drivers/dri/r300/r300_ioctl.h
index cebd22fabed..7a19a2cf3f9 100644
--- a/src/mesa/drivers/dri/r300/r300_ioctl.h
+++ b/src/mesa/drivers/dri/r300/r300_ioctl.h
@@ -39,9 +39,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "r300_context.h"
#include "radeon_drm.h"
-extern GLuint r300GetMemoryOffsetMESA(__DRInativeDisplay * dpy, int scrn,
- const GLvoid * pointer);
-
extern GLboolean r300IsGartMemory(r300ContextPtr rmesa,
const GLvoid * pointer, GLint size);
diff --git a/src/mesa/drivers/dri/r300/r300_maos.c b/src/mesa/drivers/dri/r300/r300_maos.c
deleted file mode 100644
index ec174441e99..00000000000
--- a/src/mesa/drivers/dri/r300/r300_maos.c
+++ /dev/null
@@ -1,665 +0,0 @@
-/*
-Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
-
-The Weather Channel (TM) funded Tungsten Graphics to develop the
-initial release of the Radeon 8500 driver under the XFree86 license.
-This notice must be preserved.
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice (including the
-next paragraph) shall be included in all copies or substantial
-portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-/**
- * \file
- *
- * \author Keith Whitwell <[email protected]>
- */
-
-#include "glheader.h"
-#include "mtypes.h"
-#include "colormac.h"
-#include "imports.h"
-#include "macros.h"
-#include "image.h"
-
-#include "swrast_setup/swrast_setup.h"
-#include "math/m_translate.h"
-#include "tnl/tnl.h"
-#include "tnl/t_context.h"
-
-#include "r300_context.h"
-#include "radeon_ioctl.h"
-#include "r300_state.h"
-#include "r300_maos.h"
-#include "r300_ioctl.h"
-
-#ifdef USER_BUFFERS
-#include "r300_mem.h"
-#endif
-
-#if SWIZZLE_X != R300_INPUT_ROUTE_SELECT_X || \
- SWIZZLE_Y != R300_INPUT_ROUTE_SELECT_Y || \
- SWIZZLE_Z != R300_INPUT_ROUTE_SELECT_Z || \
- SWIZZLE_W != R300_INPUT_ROUTE_SELECT_W || \
- SWIZZLE_ZERO != R300_INPUT_ROUTE_SELECT_ZERO || \
- SWIZZLE_ONE != R300_INPUT_ROUTE_SELECT_ONE
-#error Cannot change these!
-#endif
-
-#define DEBUG_ALL DEBUG_VERTS
-
-#if defined(USE_X86_ASM)
-#define COPY_DWORDS( dst, src, nr ) \
-do { \
- int __tmp; \
- __asm__ __volatile__( "rep ; movsl" \
- : "=%c" (__tmp), "=D" (dst), "=S" (__tmp) \
- : "0" (nr), \
- "D" ((long)dst), \
- "S" ((long)src) ); \
-} while (0)
-#else
-#define COPY_DWORDS( dst, src, nr ) \
-do { \
- int j; \
- for ( j = 0 ; j < nr ; j++ ) \
- dst[j] = ((int *)src)[j]; \
- dst += nr; \
-} while (0)
-#endif
-
-static void emit_vec4(GLcontext * ctx,
- struct r300_dma_region *rvb,
- GLvoid * data, int stride, int count)
-{
- int i;
- int *out = (int *)(rvb->address + rvb->start);
-
- if (RADEON_DEBUG & DEBUG_VERTS)
- fprintf(stderr, "%s count %d stride %d\n",
- __FUNCTION__, count, stride);
-
- if (stride == 4)
- COPY_DWORDS(out, data, count);
- else
- for (i = 0; i < count; i++) {
- out[0] = *(int *)data;
- out++;
- data += stride;
- }
-}
-
-static void emit_vec8(GLcontext * ctx,
- struct r300_dma_region *rvb,
- GLvoid * data, int stride, int count)
-{
- int i;
- int *out = (int *)(rvb->address + rvb->start);
-
- if (RADEON_DEBUG & DEBUG_VERTS)
- fprintf(stderr, "%s count %d stride %d\n",
- __FUNCTION__, count, stride);
-
- if (stride == 8)
- COPY_DWORDS(out, data, count * 2);
- else
- for (i = 0; i < count; i++) {
- out[0] = *(int *)data;
- out[1] = *(int *)(data + 4);
- out += 2;
- data += stride;
- }
-}
-
-static void emit_vec12(GLcontext * ctx,
- struct r300_dma_region *rvb,
- GLvoid * data, int stride, int count)
-{
- int i;
- int *out = (int *)(rvb->address + rvb->start);
-
- if (RADEON_DEBUG & DEBUG_VERTS)
- fprintf(stderr, "%s count %d stride %d out %p data %p\n",
- __FUNCTION__, count, stride, (void *)out, (void *)data);
-
- if (stride == 12)
- COPY_DWORDS(out, data, count * 3);
- else
- for (i = 0; i < count; i++) {
- out[0] = *(int *)data;
- out[1] = *(int *)(data + 4);
- out[2] = *(int *)(data + 8);
- out += 3;
- data += stride;
- }
-}
-
-static void emit_vec16(GLcontext * ctx,
- struct r300_dma_region *rvb,
- GLvoid * data, int stride, int count)
-{
- int i;
- int *out = (int *)(rvb->address + rvb->start);
-
- if (RADEON_DEBUG & DEBUG_VERTS)
- fprintf(stderr, "%s count %d stride %d\n",
- __FUNCTION__, count, stride);
-
- if (stride == 16)
- COPY_DWORDS(out, data, count * 4);
- else
- for (i = 0; i < count; i++) {
- out[0] = *(int *)data;
- out[1] = *(int *)(data + 4);
- out[2] = *(int *)(data + 8);
- out[3] = *(int *)(data + 12);
- out += 4;
- data += stride;
- }
-}
-
-static void emit_vector(GLcontext * ctx,
- struct r300_dma_region *rvb,
- GLvoid * data, int size, int stride, int count)
-{
- r300ContextPtr rmesa = R300_CONTEXT(ctx);
-
- if (RADEON_DEBUG & DEBUG_VERTS)
- fprintf(stderr, "%s count %d size %d stride %d\n",
- __FUNCTION__, count, size, stride);
-
- /* Gets triggered when playing with future_hw_tcl_on ... */
- //assert(!rvb->buf);
-
- if (stride == 0) {
- r300AllocDmaRegion(rmesa, rvb, size * 4, 4);
- count = 1;
- rvb->aos_offset = GET_START(rvb);
- rvb->aos_stride = 0;
- } else {
- r300AllocDmaRegion(rmesa, rvb, size * count * 4, 4); /* alignment? */
- rvb->aos_offset = GET_START(rvb);
- rvb->aos_stride = size;
- }
-
- /* Emit the data
- */
- switch (size) {
- case 1:
- emit_vec4(ctx, rvb, data, stride, count);
- break;
- case 2:
- emit_vec8(ctx, rvb, data, stride, count);
- break;
- case 3:
- emit_vec12(ctx, rvb, data, stride, count);
- break;
- case 4:
- emit_vec16(ctx, rvb, data, stride, count);
- break;
- default:
- assert(0);
- _mesa_exit(-1);
- break;
- }
-
-}
-
-void r300EmitElts(GLcontext * ctx, void *elts, unsigned long n_elts,
- int elt_size)
-{
- r300ContextPtr rmesa = R300_CONTEXT(ctx);
- struct r300_dma_region *rvb = &rmesa->state.elt_dma;
- void *out;
-
- assert(elt_size == 2 || elt_size == 4);
-
- if (r300IsGartMemory(rmesa, elts, n_elts * elt_size)) {
- rvb->address = rmesa->radeon.radeonScreen->gartTextures.map;
- rvb->start = ((char *)elts) - rvb->address;
- rvb->aos_offset =
- rmesa->radeon.radeonScreen->gart_texture_offset +
- rvb->start;
-
- return;
- } else if (r300IsGartMemory(rmesa, elts, 1)) {
- WARN_ONCE("Pointer not within GART memory!\n");
- _mesa_exit(-1);
- }
-
- r300AllocDmaRegion(rmesa, rvb, n_elts * elt_size, elt_size);
- rvb->aos_offset = GET_START(rvb);
-
- out = rvb->address + rvb->start;
- memcpy(out, elts, n_elts * elt_size);
-}
-
-static GLuint t_type(struct dt *dt)
-{
- switch (dt->type) {
- case GL_UNSIGNED_BYTE:
- return AOS_FORMAT_UBYTE;
-
- case GL_SHORT:
- return AOS_FORMAT_USHORT;
-
- case GL_FLOAT:
- return AOS_FORMAT_FLOAT;
-
- default:
- assert(0);
- break;
- }
-
- return AOS_FORMAT_FLOAT;
-}
-
-static GLuint t_vir0_size(struct dt *dt)
-{
- switch (dt->type) {
- case GL_UNSIGNED_BYTE:
- return 4;
-
- case GL_SHORT:
- return 7;
-
- case GL_FLOAT:
- return dt->size - 1;
-
- default:
- assert(0);
- break;
- }
-
- return 0;
-}
-
-static GLuint t_aos_size(struct dt *dt)
-{
- switch (dt->type) {
- case GL_UNSIGNED_BYTE:
- return 1;
-
- case GL_SHORT:
- return 2;
-
- case GL_FLOAT:
- return dt->size;
-
- default:
- assert(0);
- break;
- }
-
- return 0;
-}
-
-static GLuint t_vir0(uint32_t * dst, struct dt *dt, int *inputs,
- GLint * tab, GLuint nr)
-{
- GLuint i, dw;
-
- for (i = 0; i + 1 < nr; i += 2) {
- dw = t_vir0_size(&dt[tab[i]]) | (inputs[tab[i]] << 8) |
- (t_type(&dt[tab[i]]) << 14);
- dw |=
- (t_vir0_size(&dt[tab[i + 1]]) |
- (inputs[tab[i + 1]] << 8) | (t_type(&dt[tab[i + 1]])
- << 14)) << 16;
-
- if (i + 2 == nr) {
- dw |= (1 << (13 + 16));
- }
- dst[i >> 1] = dw;
- }
-
- if (nr & 1) {
- dw = t_vir0_size(&dt[tab[nr - 1]]) | (inputs[tab[nr - 1]]
- << 8) |
- (t_type(&dt[tab[nr - 1]]) << 14);
- dw |= 1 << 13;
-
- dst[nr >> 1] = dw;
- }
-
- return (nr + 1) >> 1;
-}
-
-static GLuint t_swizzle(int swizzle[4])
-{
- return (swizzle[0] << R300_INPUT_ROUTE_X_SHIFT) |
- (swizzle[1] << R300_INPUT_ROUTE_Y_SHIFT) |
- (swizzle[2] << R300_INPUT_ROUTE_Z_SHIFT) |
- (swizzle[3] << R300_INPUT_ROUTE_W_SHIFT);
-}
-
-static GLuint t_vir1(uint32_t * dst, int swizzle[][4], GLuint nr)
-{
- GLuint i;
-
- for (i = 0; i + 1 < nr; i += 2) {
- dst[i >> 1] = t_swizzle(swizzle[i]) | R300_INPUT_ROUTE_ENABLE;
- dst[i >> 1] |=
- (t_swizzle(swizzle[i + 1]) | R300_INPUT_ROUTE_ENABLE)
- << 16;
- }
-
- if (nr & 1)
- dst[nr >> 1] =
- t_swizzle(swizzle[nr - 1]) | R300_INPUT_ROUTE_ENABLE;
-
- return (nr + 1) >> 1;
-}
-
-static GLuint t_emit_size(struct dt *dt)
-{
- return dt->size;
-}
-
-static GLuint t_vic(GLcontext * ctx, GLuint InputsRead)
-{
- r300ContextPtr r300 = R300_CONTEXT(ctx);
- GLuint i, vic_1 = 0;
-
- if (InputsRead & (1 << VERT_ATTRIB_POS))
- vic_1 |= R300_INPUT_CNTL_POS;
-
- if (InputsRead & (1 << VERT_ATTRIB_NORMAL))
- vic_1 |= R300_INPUT_CNTL_NORMAL;
-
- if (InputsRead & (1 << VERT_ATTRIB_COLOR0))
- vic_1 |= R300_INPUT_CNTL_COLOR;
-
- r300->state.texture.tc_count = 0;
- for (i = 0; i < ctx->Const.MaxTextureUnits; i++)
- if (InputsRead & (1 << (VERT_ATTRIB_TEX0 + i))) {
- r300->state.texture.tc_count++;
- vic_1 |= R300_INPUT_CNTL_TC0 << i;
- }
-
- return vic_1;
-}
-
-/* Emit vertex data to GART memory
- * Route inputs to the vertex processor
- * This function should never return R300_FALLBACK_TCL when using software tcl.
- */
-
-int r300EmitArrays(GLcontext * ctx)
-{
- r300ContextPtr rmesa = R300_CONTEXT(ctx);
- r300ContextPtr r300 = rmesa;
- struct radeon_vertex_buffer *VB = &rmesa->state.VB;
- GLuint nr;
- GLuint count = VB->Count;
- GLuint i;
- GLuint InputsRead = 0, OutputsWritten = 0;
- int *inputs = NULL;
- int vir_inputs[VERT_ATTRIB_MAX];
- GLint tab[VERT_ATTRIB_MAX];
- int swizzle[VERT_ATTRIB_MAX][4];
-
- if (hw_tcl_on) {
- struct r300_vertex_program *prog =
- (struct r300_vertex_program *)
- CURRENT_VERTEX_SHADER(ctx);
- inputs = prog->inputs;
- InputsRead = CURRENT_VERTEX_SHADER(ctx)->key.InputsRead;
- OutputsWritten = CURRENT_VERTEX_SHADER(ctx)->key.OutputsWritten;
- } else {
- DECLARE_RENDERINPUTS(inputs_bitset);
- inputs = r300->state.sw_tcl_inputs;
-
- RENDERINPUTS_COPY(inputs_bitset,
- TNL_CONTEXT(ctx)->render_inputs_bitset);
-
- assert(RENDERINPUTS_TEST(inputs_bitset, _TNL_ATTRIB_POS));
- InputsRead |= 1 << VERT_ATTRIB_POS;
- OutputsWritten |= 1 << VERT_RESULT_HPOS;
-
- assert(RENDERINPUTS_TEST(inputs_bitset, _TNL_ATTRIB_NORMAL)
- == 0);
-
- assert(RENDERINPUTS_TEST(inputs_bitset, _TNL_ATTRIB_COLOR0));
- InputsRead |= 1 << VERT_ATTRIB_COLOR0;
- OutputsWritten |= 1 << VERT_RESULT_COL0;
-
- if (RENDERINPUTS_TEST(inputs_bitset, _TNL_ATTRIB_COLOR1)) {
- InputsRead |= 1 << VERT_ATTRIB_COLOR1;
- OutputsWritten |= 1 << VERT_RESULT_COL1;
- }
-
- for (i = 0; i < ctx->Const.MaxTextureUnits; i++)
- if (RENDERINPUTS_TEST
- (inputs_bitset, _TNL_ATTRIB_TEX(i))) {
- InputsRead |= 1 << (VERT_ATTRIB_TEX0 + i);
- OutputsWritten |= 1 << (VERT_RESULT_TEX0 + i);
- }
-
- for (i = 0, nr = 0; i < VERT_ATTRIB_MAX; i++)
- if (InputsRead & (1 << i))
- inputs[i] = nr++;
- else
- inputs[i] = -1;
-
- if (!
- (r300->radeon.radeonScreen->
- chip_flags & RADEON_CHIPSET_TCL)) {
- /* Fixed, apply to vir0 only */
- memcpy(vir_inputs, inputs,
- VERT_ATTRIB_MAX * sizeof(int));
- inputs = vir_inputs;
-
- if (InputsRead & VERT_ATTRIB_POS)
- inputs[VERT_ATTRIB_POS] = 0;
-
- if (InputsRead & (1 << VERT_ATTRIB_COLOR0))
- inputs[VERT_ATTRIB_COLOR0] = 2;
-
- if (InputsRead & (1 << VERT_ATTRIB_COLOR1))
- inputs[VERT_ATTRIB_COLOR1] = 3;
-
- for (i = VERT_ATTRIB_TEX0; i <= VERT_ATTRIB_TEX7; i++)
- if (InputsRead & (1 << i))
- inputs[i] = 6 + (i - VERT_ATTRIB_TEX0);
- }
-
- RENDERINPUTS_COPY(rmesa->state.render_inputs_bitset,
- inputs_bitset);
- }
- assert(InputsRead);
- assert(OutputsWritten);
-
- for (i = 0, nr = 0; i < VERT_ATTRIB_MAX; i++)
- if (InputsRead & (1 << i))
- tab[nr++] = i;
-
- if (nr > R300_MAX_AOS_ARRAYS)
- return R300_FALLBACK_TCL;
-
- for (i = 0; i < nr; i++) {
- int ci;
- int comp_size, fix, found = 0;
-
- swizzle[i][0] = SWIZZLE_ZERO;
- swizzle[i][1] = SWIZZLE_ZERO;
- swizzle[i][2] = SWIZZLE_ZERO;
- swizzle[i][3] = SWIZZLE_ONE;
-
- for (ci = 0; ci < VB->AttribPtr[tab[i]].size; ci++)
- swizzle[i][ci] = ci;
-
-#if MESA_BIG_ENDIAN
-#define SWAP_INT(a, b) do { \
- int __temp; \
- __temp = a;\
- a = b; \
- b = __temp; \
-} while (0)
-
- if (VB->AttribPtr[tab[i]].type == GL_UNSIGNED_BYTE) {
- SWAP_INT(swizzle[i][0], swizzle[i][3]);
- SWAP_INT(swizzle[i][1], swizzle[i][2]);
- }
-#endif /* MESA_BIG_ENDIAN */
-
- if (r300IsGartMemory(rmesa, VB->AttribPtr[tab[i]].data,
- /*(count-1)*stride */ 4)) {
- if (VB->AttribPtr[tab[i]].stride % 4)
- return R300_FALLBACK_TCL;
-
- rmesa->state.aos[i].address =
- VB->AttribPtr[tab[i]].data;
- rmesa->state.aos[i].start = 0;
- rmesa->state.aos[i].aos_offset =
- r300GartOffsetFromVirtual(rmesa,
- VB->
- AttribPtr[tab[i]].data);
- rmesa->state.aos[i].aos_stride =
- VB->AttribPtr[tab[i]].stride / 4;
-
- rmesa->state.aos[i].aos_size =
- t_emit_size(&VB->AttribPtr[tab[i]]);
- } else {
- /* TODO: emit_vector can only handle 4 byte vectors */
- if (VB->AttribPtr[tab[i]].type != GL_FLOAT)
- return R300_FALLBACK_TCL;
-
- emit_vector(ctx, &rmesa->state.aos[i],
- VB->AttribPtr[tab[i]].data,
- t_emit_size(&VB->AttribPtr[tab[i]]),
- VB->AttribPtr[tab[i]].stride, count);
- }
-
- rmesa->state.aos[i].aos_size =
- t_aos_size(&VB->AttribPtr[tab[i]]);
-
- comp_size = _mesa_sizeof_type(VB->AttribPtr[tab[i]].type);
-
- for (fix = 0; fix <= 4 - VB->AttribPtr[tab[i]].size; fix++) {
- if ((rmesa->state.aos[i].aos_offset -
- comp_size * fix) % 4)
- continue;
-
- found = 1;
- break;
- }
-
- if (found) {
- if (fix > 0) {
- WARN_ONCE("Feeling lucky?\n");
- }
-
- rmesa->state.aos[i].aos_offset -= comp_size * fix;
-
- for (ci = 0; ci < VB->AttribPtr[tab[i]].size; ci++)
- swizzle[i][ci] += fix;
- } else {
- WARN_ONCE
- ("Cannot handle offset %x with stride %d, comp %d\n",
- rmesa->state.aos[i].aos_offset,
- rmesa->state.aos[i].aos_stride,
- VB->AttribPtr[tab[i]].size);
- return R300_FALLBACK_TCL;
- }
- }
-
- /* setup INPUT_ROUTE */
- R300_STATECHANGE(r300, vir[0]);
- ((drm_r300_cmd_header_t *) r300->hw.vir[0].cmd)->packet0.count =
- t_vir0(&r300->hw.vir[0].cmd[R300_VIR_CNTL_0], VB->AttribPtr,
- inputs, tab, nr);
-
- R300_STATECHANGE(r300, vir[1]);
- ((drm_r300_cmd_header_t *) r300->hw.vir[1].cmd)->packet0.count =
- t_vir1(&r300->hw.vir[1].cmd[R300_VIR_CNTL_0], swizzle, nr);
-
- /* Set up input_cntl */
- /* I don't think this is needed for vertex buffers, but it doesn't hurt anything */
- R300_STATECHANGE(r300, vic);
- r300->hw.vic.cmd[R300_VIC_CNTL_0] = 0x5555; /* Hard coded value, no idea what it means */
- r300->hw.vic.cmd[R300_VIC_CNTL_1] = t_vic(ctx, InputsRead);
-
- /* Stage 3: VAP output */
-
- R300_STATECHANGE(r300, vof);
-
- r300->hw.vof.cmd[R300_VOF_CNTL_0] = 0;
- r300->hw.vof.cmd[R300_VOF_CNTL_1] = 0;
-
- if (OutputsWritten & (1 << VERT_RESULT_HPOS))
- r300->hw.vof.cmd[R300_VOF_CNTL_0] |=
- R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT;
-
- if (OutputsWritten & (1 << VERT_RESULT_COL0))
- r300->hw.vof.cmd[R300_VOF_CNTL_0] |=
- R300_VAP_OUTPUT_VTX_FMT_0__COLOR_PRESENT;
-
- if (OutputsWritten & (1 << VERT_RESULT_COL1))
- r300->hw.vof.cmd[R300_VOF_CNTL_0] |=
- R300_VAP_OUTPUT_VTX_FMT_0__COLOR_1_PRESENT;
-
- /*if(OutputsWritten & (1 << VERT_RESULT_BFC0))
- r300->hw.vof.cmd[R300_VOF_CNTL_0] |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_2_PRESENT;
-
- if(OutputsWritten & (1 << VERT_RESULT_BFC1))
- r300->hw.vof.cmd[R300_VOF_CNTL_0] |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_3_PRESENT; */
- //if(OutputsWritten & (1 << VERT_RESULT_FOGC))
-
- if (OutputsWritten & (1 << VERT_RESULT_PSIZ))
- r300->hw.vof.cmd[R300_VOF_CNTL_0] |=
- R300_VAP_OUTPUT_VTX_FMT_0__PT_SIZE_PRESENT;
-
- for (i = 0; i < ctx->Const.MaxTextureUnits; i++)
- if (OutputsWritten & (1 << (VERT_RESULT_TEX0 + i)))
- r300->hw.vof.cmd[R300_VOF_CNTL_1] |= (4 << (3 * i));
-
- rmesa->state.aos_count = nr;
-
- return R300_FALLBACK_NONE;
-}
-
-#ifdef USER_BUFFERS
-void r300UseArrays(GLcontext * ctx)
-{
- r300ContextPtr rmesa = R300_CONTEXT(ctx);
- int i;
-
- if (rmesa->state.elt_dma.buf)
- r300_mem_use(rmesa, rmesa->state.elt_dma.buf->id);
-
- for (i = 0; i < rmesa->state.aos_count; i++) {
- if (rmesa->state.aos[i].buf)
- r300_mem_use(rmesa, rmesa->state.aos[i].buf->id);
- }
-}
-#endif
-
-void r300ReleaseArrays(GLcontext * ctx)
-{
- r300ContextPtr rmesa = R300_CONTEXT(ctx);
- int i;
-
- r300ReleaseDmaRegion(rmesa, &rmesa->state.elt_dma, __FUNCTION__);
- for (i = 0; i < rmesa->state.aos_count; i++) {
- r300ReleaseDmaRegion(rmesa, &rmesa->state.aos[i], __FUNCTION__);
- }
-}
diff --git a/src/mesa/drivers/dri/r300/r300_maos.h b/src/mesa/drivers/dri/r300/r300_maos.h
deleted file mode 100644
index 055e8c58eaf..00000000000
--- a/src/mesa/drivers/dri/r300/r300_maos.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
-Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
-
-The Weather Channel (TM) funded Tungsten Graphics to develop the
-initial release of the Radeon 8500 driver under the XFree86 license.
-This notice must be preserved.
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice (including the
-next paragraph) shall be included in all copies or substantial
-portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-/*
- * Authors:
- * Keith Whitwell <[email protected]>
- */
-
-#ifndef __R300_MAOS_H__
-#define __R300_MAOS_H__
-
-#include "r300_context.h"
-
-extern void r300EmitElts(GLcontext * ctx, void *elts, unsigned long n_elts,
- int elt_size);
-extern int r300EmitArrays(GLcontext * ctx);
-
-#ifdef USER_BUFFERS
-void r300UseArrays(GLcontext * ctx);
-#endif
-
-extern void r300ReleaseArrays(GLcontext * ctx);
-
-#endif
diff --git a/src/mesa/drivers/dri/r300/r300_mem.c b/src/mesa/drivers/dri/r300/r300_mem.c
index c08e8367a39..f8f9d4fcdf1 100644
--- a/src/mesa/drivers/dri/r300/r300_mem.c
+++ b/src/mesa/drivers/dri/r300/r300_mem.c
@@ -45,20 +45,22 @@ static void resize_u_list(r300ContextPtr rmesa)
{
void *temp;
int nsize;
-
+
temp = rmesa->rmm->u_list;
nsize = rmesa->rmm->u_size * 2;
-
+
rmesa->rmm->u_list = _mesa_malloc(nsize * sizeof(*rmesa->rmm->u_list));
- _mesa_memset(rmesa->rmm->u_list, 0, nsize * sizeof(*rmesa->rmm->u_list));
-
+ _mesa_memset(rmesa->rmm->u_list, 0,
+ nsize * sizeof(*rmesa->rmm->u_list));
+
if (temp) {
r300FlushCmdBuf(rmesa, __FUNCTION__);
-
- _mesa_memcpy(rmesa->rmm->u_list, temp, rmesa->rmm->u_size * sizeof(*rmesa->rmm->u_list));
+
+ _mesa_memcpy(rmesa->rmm->u_list, temp,
+ rmesa->rmm->u_size * sizeof(*rmesa->rmm->u_list));
_mesa_free(temp);
}
-
+
rmesa->rmm->u_size = nsize;
}
@@ -66,7 +68,7 @@ void r300_mem_init(r300ContextPtr rmesa)
{
rmesa->rmm = malloc(sizeof(struct r300_memory_manager));
memset(rmesa->rmm, 0, sizeof(struct r300_memory_manager));
-
+
rmesa->rmm->u_size = 128;
resize_u_list(rmesa);
}
@@ -89,16 +91,17 @@ void *r300_mem_ptr(r300ContextPtr rmesa, int id)
int r300_mem_find(r300ContextPtr rmesa, void *ptr)
{
int i;
-
- for (i=1; i < rmesa->rmm->u_size+1; i++)
- if(rmesa->rmm->u_list[i].ptr &&
- ptr >= rmesa->rmm->u_list[i].ptr &&
- ptr < rmesa->rmm->u_list[i].ptr + rmesa->rmm->u_list[i].size)
+
+ for (i = 1; i < rmesa->rmm->u_size + 1; i++)
+ if (rmesa->rmm->u_list[i].ptr &&
+ ptr >= rmesa->rmm->u_list[i].ptr &&
+ ptr <
+ rmesa->rmm->u_list[i].ptr + rmesa->rmm->u_list[i].size)
break;
-
+
if (i < rmesa->rmm->u_size + 1)
return i;
-
+
fprintf(stderr, "%p failed\n", ptr);
return 0;
}
@@ -108,387 +111,275 @@ int r300_mem_alloc(r300ContextPtr rmesa, int alignment, int size)
{
drm_radeon_mem_alloc_t alloc;
int offset = 0, ret;
- int i, free=-1;
+ int i, free = -1;
int done_age;
drm_radeon_mem_free_t memfree;
- int tries=0;
- static int bytes_wasted=0, allocated=0;
-
- if(size < 4096)
+ int tries = 0;
+ static int bytes_wasted = 0, allocated = 0;
+
+ if (size < 4096)
bytes_wasted += 4096 - size;
-
+
allocated += size;
-
+
#if 0
- static int t=0;
+ static int t = 0;
if (t != time(NULL)) {
t = time(NULL);
- fprintf(stderr, "slots used %d, wasted %d kb, allocated %d\n", rmesa->rmm->u_last, bytes_wasted/1024, allocated/1024);
+ fprintf(stderr, "slots used %d, wasted %d kb, allocated %d\n",
+ rmesa->rmm->u_last, bytes_wasted / 1024,
+ allocated / 1024);
}
#endif
-
+
memfree.region = RADEON_MEM_REGION_GART;
-
- again:
-
- done_age = radeonGetAge((radeonContextPtr)rmesa);
-
+
+ again:
+
+ done_age = radeonGetAge((radeonContextPtr) rmesa);
+
if (rmesa->rmm->u_last + 1 >= rmesa->rmm->u_size)
resize_u_list(rmesa);
-
- for (i = rmesa->rmm->u_last + 1; i > 0; i --) {
+
+ for (i = rmesa->rmm->u_last + 1; i > 0; i--) {
if (rmesa->rmm->u_list[i].ptr == NULL) {
free = i;
continue;
}
-
+
if (rmesa->rmm->u_list[i].h_pending == 0 &&
- rmesa->rmm->u_list[i].pending && rmesa->rmm->u_list[i].age <= done_age) {
- memfree.region_offset = (char *)rmesa->rmm->u_list[i].ptr -
- (char *)rmesa->radeon.radeonScreen->gartTextures.map;
+ rmesa->rmm->u_list[i].pending
+ && rmesa->rmm->u_list[i].age <= done_age) {
+ memfree.region_offset =
+ (char *)rmesa->rmm->u_list[i].ptr -
+ (char *)rmesa->radeon.radeonScreen->gartTextures.
+ map;
- ret = drmCommandWrite(rmesa->radeon.radeonScreen->driScreen->fd,
- DRM_RADEON_FREE, &memfree, sizeof(memfree));
+ ret =
+ drmCommandWrite(rmesa->radeon.radeonScreen->
+ driScreen->fd, DRM_RADEON_FREE,
+ &memfree, sizeof(memfree));
if (ret) {
- fprintf(stderr, "Failed to free at %p\n", rmesa->rmm->u_list[i].ptr);
+ fprintf(stderr, "Failed to free at %p\n",
+ rmesa->rmm->u_list[i].ptr);
fprintf(stderr, "ret = %s\n", strerror(-ret));
exit(1);
} else {
#ifdef MM_DEBUG
- fprintf(stderr, "really freed %d at age %x\n", i, radeonGetAge((radeonContextPtr)rmesa));
+ fprintf(stderr, "really freed %d at age %x\n",
+ i,
+ radeonGetAge((radeonContextPtr) rmesa));
#endif
if (i == rmesa->rmm->u_last)
- rmesa->rmm->u_last --;
-
- if(rmesa->rmm->u_list[i].size < 4096)
- bytes_wasted -= 4096 - rmesa->rmm->u_list[i].size;
+ rmesa->rmm->u_last--;
+
+ if (rmesa->rmm->u_list[i].size < 4096)
+ bytes_wasted -=
+ 4096 - rmesa->rmm->u_list[i].size;
allocated -= rmesa->rmm->u_list[i].size;
rmesa->rmm->u_list[i].pending = 0;
rmesa->rmm->u_list[i].ptr = NULL;
-
- if (rmesa->rmm->u_list[i].fb) {
- LOCK_HARDWARE(&(rmesa->radeon));
- ret = mmFreeMem(rmesa->rmm->u_list[i].fb);
- UNLOCK_HARDWARE(&(rmesa->radeon));
-
- if (ret != 0)
- fprintf(stderr, "failed to free!\n");
- rmesa->rmm->u_list[i].fb = NULL;
- }
- rmesa->rmm->u_list[i].ref_count = 0;
free = i;
}
}
}
rmesa->rmm->u_head = i;
-
+
if (free == -1) {
WARN_ONCE("Ran out of slots!\n");
//usleep(100);
r300FlushCmdBuf(rmesa, __FUNCTION__);
tries++;
- if(tries>100){
+ if (tries > 100) {
WARN_ONCE("Ran out of slots!\n");
exit(1);
}
goto again;
}
-
+
alloc.region = RADEON_MEM_REGION_GART;
alloc.alignment = alignment;
alloc.size = size;
alloc.region_offset = &offset;
- ret = drmCommandWriteRead( rmesa->radeon.dri.fd, DRM_RADEON_ALLOC, &alloc, sizeof(alloc));
- if (ret) {
+ ret =
+ drmCommandWriteRead(rmesa->radeon.dri.fd, DRM_RADEON_ALLOC, &alloc,
+ sizeof(alloc));
+ if (ret) {
#if 0
WARN_ONCE("Ran out of mem!\n");
r300FlushCmdBuf(rmesa, __FUNCTION__);
//usleep(100);
tries2++;
tries = 0;
- if(tries2>100){
+ if (tries2 > 100) {
WARN_ONCE("Ran out of GART memory!\n");
exit(1);
}
goto again;
#else
- WARN_ONCE("Ran out of GART memory (for %d)!\nPlease consider adjusting GARTSize option.\n", size);
+ WARN_ONCE
+ ("Ran out of GART memory (for %d)!\nPlease consider adjusting GARTSize option.\n",
+ size);
return 0;
#endif
}
-
+
i = free;
-
+
if (i > rmesa->rmm->u_last)
rmesa->rmm->u_last = i;
-
- rmesa->rmm->u_list[i].ptr = ((GLubyte *)rmesa->radeon.radeonScreen->gartTextures.map) + offset;
+
+ rmesa->rmm->u_list[i].ptr =
+ ((GLubyte *) rmesa->radeon.radeonScreen->gartTextures.map) + offset;
rmesa->rmm->u_list[i].size = size;
rmesa->rmm->u_list[i].age = 0;
- rmesa->rmm->u_list[i].fb = NULL;
//fprintf(stderr, "alloc %p at id %d\n", rmesa->rmm->u_list[i].ptr, i);
-
+
#ifdef MM_DEBUG
- fprintf(stderr, "allocated %d at age %x\n", i, radeonGetAge((radeonContextPtr)rmesa));
+ fprintf(stderr, "allocated %d at age %x\n", i,
+ radeonGetAge((radeonContextPtr) rmesa));
#endif
-
- return i;
-}
-#include "r300_emit.h"
-static void emit_lin_cp(r300ContextPtr rmesa, unsigned long dst, unsigned long src, unsigned long size)
-{
- int cmd_reserved = 0;
- int cmd_written = 0;
- drm_radeon_cmd_header_t *cmd = NULL;
- int cp_size;
-
-
- while (size > 0){
- cp_size = size;
- if(cp_size > /*8190*/4096)
- cp_size = /*8190*/4096;
-
- reg_start(0x146c,1);
- e32(0x52cc32fb);
-
- reg_start(0x15ac,1);
- e32(src);
- e32(cp_size);
-
- reg_start(0x1704,0);
- e32(0x0);
-
- reg_start(0x1404,1);
- e32(dst);
- e32(cp_size);
-
- reg_start(0x1700,0);
- e32(0x0);
-
- reg_start(0x1640,3);
- e32(0x00000000);
- e32(0x00001fff);
- e32(0x00000000);
- e32(0x00001fff);
-
- start_packet3(RADEON_CP_PACKET3_UNK1B, 2);
- e32(0 << 16 | 0);
- e32(0 << 16 | 0);
- e32(cp_size << 16 | 0x1);
-
- dst += cp_size;
- src += cp_size;
- size -= cp_size;
- }
-
- reg_start(R300_RB3D_DSTCACHE_CTLSTAT,0);
- e32(R300_RB3D_DSTCACHE_UNKNOWN_0A);
-
- reg_start(0x342c,0);
- e32(0x00000005);
-
- reg_start(0x1720,0);
- e32(0x00010000);
+ return i;
}
void r300_mem_use(r300ContextPtr rmesa, int id)
{
uint64_t ull;
#ifdef MM_DEBUG
- fprintf(stderr, "%s: %d at age %x\n", __FUNCTION__, id, radeonGetAge((radeonContextPtr)rmesa));
-#endif
+ fprintf(stderr, "%s: %d at age %x\n", __FUNCTION__, id,
+ radeonGetAge((radeonContextPtr) rmesa));
+#endif
drm_r300_cmd_header_t *cmd;
-
+
assert(id <= rmesa->rmm->u_last);
-
- if(id == 0)
+
+ if (id == 0)
return;
-
-#if 0 /* FB VBOs. Needs further changes... */
- rmesa->rmm->u_list[id].ref_count ++;
- if (rmesa->rmm->u_list[id].ref_count > 100 && rmesa->rmm->u_list[id].fb == NULL &&
- rmesa->rmm->u_list[id].size != RADEON_BUFFER_SIZE*16 /*&& rmesa->rmm->u_list[id].size > 40*/) {
- driTexHeap *heap;
- struct mem_block *mb;
-
- LOCK_HARDWARE(&(rmesa->radeon));
-
- heap = rmesa->texture_heaps[0];
-
- mb = mmAllocMem(heap->memory_heap, rmesa->rmm->u_list[id].size, heap->alignmentShift, 0);
-
- UNLOCK_HARDWARE(&(rmesa->radeon));
-
- if (mb) {
- rmesa->rmm->u_list[id].fb = mb;
-
- emit_lin_cp(rmesa, rmesa->radeon.radeonScreen->texOffset[0] + rmesa->rmm->u_list[id].fb->ofs,
- r300GartOffsetFromVirtual(rmesa, rmesa->rmm->u_list[id].ptr),
- rmesa->rmm->u_list[id].size);
- } else {
- WARN_ONCE("Upload to fb failed, %d, %d\n", rmesa->rmm->u_list[id].size, id);
- }
- //fprintf(stderr, "Upload to fb! %d, %d\n", rmesa->rmm->u_list[id].ref_count, id);
- }
- /*if (rmesa->rmm->u_list[id].fb) {
- emit_lin_cp(rmesa, rmesa->radeon.radeonScreen->texOffset[0] + rmesa->rmm->u_list[id].fb->ofs,
- r300GartOffsetFromVirtual(rmesa, rmesa->rmm->u_list[id].ptr),
- rmesa->rmm->u_list[id].size);
- }*/
-#endif
-
- cmd = (drm_r300_cmd_header_t *)r300AllocCmdBuf(rmesa, 2 + sizeof(ull) / 4, __FUNCTION__);
+
+ cmd =
+ (drm_r300_cmd_header_t *) r300AllocCmdBuf(rmesa,
+ 2 + sizeof(ull) / 4,
+ __FUNCTION__);
cmd[0].scratch.cmd_type = R300_CMD_SCRATCH;
cmd[0].scratch.reg = R300_MEM_SCRATCH;
cmd[0].scratch.n_bufs = 1;
cmd[0].scratch.flags = 0;
- cmd ++;
-
- ull = (uint64_t)(intptr_t)&rmesa->rmm->u_list[id].age;
+ cmd++;
+
+ ull = (uint64_t) (intptr_t) & rmesa->rmm->u_list[id].age;
_mesa_memcpy(cmd, &ull, sizeof(ull));
cmd += sizeof(ull) / 4;
-
- cmd[0].u = /*id*/0;
-
- LOCK_HARDWARE(&rmesa->radeon); /* Protect from DRM. */
- rmesa->rmm->u_list[id].h_pending ++;
+
+ cmd[0].u = /*id */ 0;
+
+ LOCK_HARDWARE(&rmesa->radeon); /* Protect from DRM. */
+ rmesa->rmm->u_list[id].h_pending++;
UNLOCK_HARDWARE(&rmesa->radeon);
}
unsigned long r300_mem_offset(r300ContextPtr rmesa, int id)
{
unsigned long offset;
-
+
assert(id <= rmesa->rmm->u_last);
-
- if (rmesa->rmm->u_list[id].fb) {
- offset = rmesa->radeon.radeonScreen->texOffset[0] + rmesa->rmm->u_list[id].fb->ofs;
- } else {
- offset = (char *)rmesa->rmm->u_list[id].ptr -
- (char *)rmesa->radeon.radeonScreen->gartTextures.map;
- offset += rmesa->radeon.radeonScreen->gart_texture_offset;
- }
-
+
+ offset = (char *)rmesa->rmm->u_list[id].ptr -
+ (char *)rmesa->radeon.radeonScreen->gartTextures.map;
+ offset += rmesa->radeon.radeonScreen->gart_texture_offset;
+
return offset;
}
-int r300_mem_on_card(r300ContextPtr rmesa, int id)
-{
- assert(id <= rmesa->rmm->u_last);
-
- if (rmesa->rmm->u_list[id].fb)
- return GL_TRUE;
-
- return GL_FALSE;
-}
-
void *r300_mem_map(r300ContextPtr rmesa, int id, int access)
{
#ifdef MM_DEBUG
- fprintf(stderr, "%s: %d at age %x\n", __FUNCTION__, id, radeonGetAge((radeonContextPtr)rmesa));
-#endif
+ fprintf(stderr, "%s: %d at age %x\n", __FUNCTION__, id,
+ radeonGetAge((radeonContextPtr) rmesa));
+#endif
void *ptr;
int tries = 0;
-
+
assert(id <= rmesa->rmm->u_last);
-
- rmesa->rmm->u_list[id].ref_count = 0;
- if (rmesa->rmm->u_list[id].fb) {
- WARN_ONCE("Mapping fb!\n");
- /* Idle gart only and do upload on unmap */
- //rmesa->rmm->u_list[id].fb = NULL;
-
-
- if(rmesa->rmm->u_list[id].mapped == 1)
- WARN_ONCE("buffer %d already mapped\n", id);
-
- rmesa->rmm->u_list[id].mapped = 1;
- ptr = r300_mem_ptr(rmesa, id);
-
- return ptr;
- }
-
+
if (access == R300_MEM_R) {
-
- if(rmesa->rmm->u_list[id].mapped == 1)
+
+ if (rmesa->rmm->u_list[id].mapped == 1)
WARN_ONCE("buffer %d already mapped\n", id);
-
+
rmesa->rmm->u_list[id].mapped = 1;
ptr = r300_mem_ptr(rmesa, id);
-
+
return ptr;
}
-
-
+
if (rmesa->rmm->u_list[id].h_pending)
r300FlushCmdBuf(rmesa, __FUNCTION__);
-
+
if (rmesa->rmm->u_list[id].h_pending) {
return NULL;
}
-
- while(rmesa->rmm->u_list[id].age > radeonGetAge((radeonContextPtr)rmesa) && tries++ < 1000)
+
+ while (rmesa->rmm->u_list[id].age >
+ radeonGetAge((radeonContextPtr) rmesa) && tries++ < 1000)
usleep(10);
-
+
if (tries >= 1000) {
fprintf(stderr, "Idling failed (%x vs %x)\n",
- rmesa->rmm->u_list[id].age, radeonGetAge((radeonContextPtr)rmesa));
+ rmesa->rmm->u_list[id].age,
+ radeonGetAge((radeonContextPtr) rmesa));
return NULL;
}
-
- if(rmesa->rmm->u_list[id].mapped == 1)
+
+ if (rmesa->rmm->u_list[id].mapped == 1)
WARN_ONCE("buffer %d already mapped\n", id);
-
+
rmesa->rmm->u_list[id].mapped = 1;
ptr = r300_mem_ptr(rmesa, id);
-
+
return ptr;
}
void r300_mem_unmap(r300ContextPtr rmesa, int id)
{
#ifdef MM_DEBUG
- fprintf(stderr, "%s: %d at age %x\n", __FUNCTION__, id, radeonGetAge((radeonContextPtr)rmesa));
-#endif
-
+ fprintf(stderr, "%s: %d at age %x\n", __FUNCTION__, id,
+ radeonGetAge((radeonContextPtr) rmesa));
+#endif
+
assert(id <= rmesa->rmm->u_last);
-
- if(rmesa->rmm->u_list[id].mapped == 0)
+
+ if (rmesa->rmm->u_list[id].mapped == 0)
WARN_ONCE("buffer %d not mapped\n", id);
-
+
rmesa->rmm->u_list[id].mapped = 0;
-
- if (rmesa->rmm->u_list[id].fb)
- emit_lin_cp(rmesa, rmesa->radeon.radeonScreen->texOffset[0] + rmesa->rmm->u_list[id].fb->ofs,
- r300GartOffsetFromVirtual(rmesa, rmesa->rmm->u_list[id].ptr),
- rmesa->rmm->u_list[id].size);
}
void r300_mem_free(r300ContextPtr rmesa, int id)
{
#ifdef MM_DEBUG
- fprintf(stderr, "%s: %d at age %x\n", __FUNCTION__, id, radeonGetAge((radeonContextPtr)rmesa));
-#endif
-
+ fprintf(stderr, "%s: %d at age %x\n", __FUNCTION__, id,
+ radeonGetAge((radeonContextPtr) rmesa));
+#endif
+
assert(id <= rmesa->rmm->u_last);
-
- if(id == 0)
+
+ if (id == 0)
return;
-
- if(rmesa->rmm->u_list[id].ptr == NULL){
+
+ if (rmesa->rmm->u_list[id].ptr == NULL) {
WARN_ONCE("Not allocated!\n");
- return ;
+ return;
}
-
- if(rmesa->rmm->u_list[id].pending){
+
+ if (rmesa->rmm->u_list[id].pending) {
WARN_ONCE("%p already pended!\n", rmesa->rmm->u_list[id].ptr);
- return ;
+ return;
}
-
+
rmesa->rmm->u_list[id].pending = 1;
}
#endif
diff --git a/src/mesa/drivers/dri/r300/r300_mem.h b/src/mesa/drivers/dri/r300/r300_mem.h
index 1e99b176383..625a7f6d8d5 100644
--- a/src/mesa/drivers/dri/r300/r300_mem.h
+++ b/src/mesa/drivers/dri/r300/r300_mem.h
@@ -18,11 +18,9 @@ struct r300_memory_manager {
uint32_t h_pending;
int pending;
int mapped;
- int ref_count;
- struct mem_block *fb;
} *u_list;
- int u_head, u_tail, u_size, u_last;
-
+ int u_head, u_size, u_last;
+
};
extern void r300_mem_init(r300ContextPtr rmesa);
@@ -32,7 +30,6 @@ extern int r300_mem_find(r300ContextPtr rmesa, void *ptr);
extern int r300_mem_alloc(r300ContextPtr rmesa, int alignment, int size);
extern void r300_mem_use(r300ContextPtr rmesa, int id);
extern unsigned long r300_mem_offset(r300ContextPtr rmesa, int id);
-extern int r300_mem_on_card(r300ContextPtr rmesa, int id);
extern void *r300_mem_map(r300ContextPtr rmesa, int id, int access);
extern void r300_mem_unmap(r300ContextPtr rmesa, int id);
extern void r300_mem_free(r300ContextPtr rmesa, int id);
diff --git a/src/mesa/drivers/dri/r300/r300_reg.h b/src/mesa/drivers/dri/r300/r300_reg.h
index e309a48c423..3ce09c16d3f 100644
--- a/src/mesa/drivers/dri/r300/r300_reg.h
+++ b/src/mesa/drivers/dri/r300/r300_reg.h
@@ -23,11 +23,11 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
**************************************************************************/
+/* *INDENT-OFF* */
+
#ifndef _R300_REG_H
#define _R300_REG_H
-/* *INDENT-OFF* */
-
#define R300_MC_INIT_MISC_LAT_TIMER 0x180
# define R300_MC_MISC__MC_CPR_INIT_LAT_SHIFT 0
# define R300_MC_MISC__MC_VF_INIT_LAT_SHIFT 4
@@ -116,6 +116,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
# define R300_VAP_OUTPUT_VTX_FMT_0__PT_SIZE_PRESENT (1<<16) /* GUESS */
#define R300_VAP_OUTPUT_VTX_FMT_1 0x2094
+ /* each of the following is 3 bits wide, specifies number
+ of components */
# define R300_VAP_OUTPUT_VTX_FMT_1__TEX_0_COMP_CNT_SHIFT 0
# define R300_VAP_OUTPUT_VTX_FMT_1__TEX_1_COMP_CNT_SHIFT 3
# define R300_VAP_OUTPUT_VTX_FMT_1__TEX_2_COMP_CNT_SHIFT 6
@@ -299,6 +301,18 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
# define R300_221C_NORMAL 0x00000000
# define R300_221C_CLEAR 0x0001C000
+/* These seem to be per-pixel and per-vertex X and Y clipping planes. The first
+ * plane is per-pixel and the second plane is per-vertex.
+ *
+ * This was determined by experimentation alone but I believe it is correct.
+ *
+ * These registers are called X_QUAD0_1_FL to X_QUAD0_4_FL by glxtest.
+ */
+#define R300_VAP_CLIP_X_0 0x2220
+#define R300_VAP_CLIP_X_1 0x2224
+#define R300_VAP_CLIP_Y_0 0x2228
+#define R300_VAP_CLIP_Y_1 0x2230
+
/* gap */
/* Sometimes, END_OF_PKT and 0x2284=0 are the only commands sent between
@@ -673,6 +687,11 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
/* Special handling for color: When the fragment program uses color,
* the ROUTE_0_COLOR bit is set and ROUTE_0_COLOR_DEST contains the
* color register index.
+ *
+ * Apperently you may set the R300_RS_ROUTE_0_COLOR bit, but not provide any
+ * R300_RS_ROUTE_0_COLOR_DEST value; this setup is used for clearing the state.
+ * See r300_ioctl.c:r300EmitClearState. I'm not sure if this setup is strictly
+ * correct or not. - Oliver.
*/
# define R300_RS_ROUTE_0_COLOR (1 << 14)
# define R300_RS_ROUTE_0_COLOR_DEST_SHIFT 17
@@ -962,7 +981,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
* first node is stored in NODE_2, the second node is stored in NODE_3.
*
* Offsets are relative to the master offset from PFS_CNTL_2.
- * LAST_NODE is set for the last node, and only for the last node.
*/
#define R300_PFS_NODE_0 0x4610
#define R300_PFS_NODE_1 0x4614
@@ -976,7 +994,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
# define R300_PFS_NODE_TEX_OFFSET_MASK (31 << 12)
# define R300_PFS_NODE_TEX_END_SHIFT 17
# define R300_PFS_NODE_TEX_END_MASK (31 << 17)
-/*# define R300_PFS_NODE_LAST_NODE (1 << 22) */
# define R300_PFS_NODE_OUTPUT_COLOR (1 << 22)
# define R300_PFS_NODE_OUTPUT_DEPTH (1 << 23)
@@ -1586,6 +1603,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
# define R300_EB_UNK1_SHIFT 24
# define R300_EB_UNK1 (0x80<<24)
# define R300_EB_UNK2 0x0810
+#define R300_PACKET3_3D_DRAW_VBUF_2 0x00003400
#define R300_PACKET3_3D_DRAW_INDX_2 0x00003600
/* END: Packet 3 commands */
@@ -1606,6 +1624,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#define R300_CP_CMD_BITBLT_MULTI 0xC0009B00
-/* *INDENT-ON* */
-
#endif /* _R300_REG_H */
+
+/* *INDENT-ON* */
diff --git a/src/mesa/drivers/dri/r300/r300_render.c b/src/mesa/drivers/dri/r300/r300_render.c
index a118dab7401..1aaf43bfafc 100644
--- a/src/mesa/drivers/dri/r300/r300_render.c
+++ b/src/mesa/drivers/dri/r300/r300_render.c
@@ -45,6 +45,9 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
* obviously this does work... Further investigation is needed.
*
* \author Nicolai Haehnle <[email protected]>
+ *
+ * \todo Add immediate implementation back? Perhaps this is useful if there are
+ * no bugs...
*/
#include "glheader.h"
@@ -70,7 +73,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "r300_state.h"
#include "r300_reg.h"
#include "r300_tex.h"
-#include "r300_maos.h"
#include "r300_emit.h"
extern int future_hw_tcl_on;
@@ -79,47 +81,42 @@ extern int future_hw_tcl_on;
*/
static int r300PrimitiveType(r300ContextPtr rmesa, GLcontext * ctx, int prim)
{
- int type = -1;
-
switch (prim & PRIM_MODE_MASK) {
case GL_POINTS:
- type = R300_VAP_VF_CNTL__PRIM_POINTS;
+ return R300_VAP_VF_CNTL__PRIM_POINTS;
break;
case GL_LINES:
- type = R300_VAP_VF_CNTL__PRIM_LINES;
+ return R300_VAP_VF_CNTL__PRIM_LINES;
break;
case GL_LINE_STRIP:
- type = R300_VAP_VF_CNTL__PRIM_LINE_STRIP;
+ return R300_VAP_VF_CNTL__PRIM_LINE_STRIP;
break;
case GL_LINE_LOOP:
- type = R300_VAP_VF_CNTL__PRIM_LINE_LOOP;
+ return R300_VAP_VF_CNTL__PRIM_LINE_LOOP;
break;
case GL_TRIANGLES:
- type = R300_VAP_VF_CNTL__PRIM_TRIANGLES;
+ return R300_VAP_VF_CNTL__PRIM_TRIANGLES;
break;
case GL_TRIANGLE_STRIP:
- type = R300_VAP_VF_CNTL__PRIM_TRIANGLE_STRIP;
+ return R300_VAP_VF_CNTL__PRIM_TRIANGLE_STRIP;
break;
case GL_TRIANGLE_FAN:
- type = R300_VAP_VF_CNTL__PRIM_TRIANGLE_FAN;
+ return R300_VAP_VF_CNTL__PRIM_TRIANGLE_FAN;
break;
case GL_QUADS:
- type = R300_VAP_VF_CNTL__PRIM_QUADS;
+ return R300_VAP_VF_CNTL__PRIM_QUADS;
break;
case GL_QUAD_STRIP:
- type = R300_VAP_VF_CNTL__PRIM_QUAD_STRIP;
+ return R300_VAP_VF_CNTL__PRIM_QUAD_STRIP;
break;
case GL_POLYGON:
- type = R300_VAP_VF_CNTL__PRIM_POLYGON;
+ return R300_VAP_VF_CNTL__PRIM_POLYGON;
break;
default:
- fprintf(stderr,
- "%s:%s Do not know how to handle primitive 0x%04x - help me !\n",
- __FILE__, __FUNCTION__, prim & PRIM_MODE_MASK);
+ assert(0);
return -1;
break;
}
- return type;
}
static int r300NumVerts(r300ContextPtr rmesa, int num_verts, int prim)
@@ -166,89 +163,103 @@ static int r300NumVerts(r300ContextPtr rmesa, int num_verts, int prim)
verts_off = num_verts;
break;
default:
- fprintf(stderr,
- "%s:%s Do not know how to handle primitive 0x%04x - help me !\n",
- __FILE__, __FUNCTION__, prim & PRIM_MODE_MASK);
+ assert(0);
return -1;
break;
}
- if (num_verts - verts_off == 0) {
- WARN_ONCE
- ("user error: Need more than %d vertices to draw primitive 0x%04x !\n",
- num_verts, prim & PRIM_MODE_MASK);
- return -1;
- }
+ return num_verts - verts_off;
+}
- if (verts_off > 0) {
- WARN_ONCE
- ("user error: %d is not a valid number of vertices for primitive 0x%04x !\n",
- num_verts, prim & PRIM_MODE_MASK);
- return -1;
+static void r300EmitElts(GLcontext * ctx, void *elts, unsigned long n_elts)
+{
+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
+ struct r300_dma_region *rvb = &rmesa->state.elt_dma;
+ void *out;
+
+ if (r300IsGartMemory(rmesa, elts, n_elts * 4)) {
+ rvb->address = rmesa->radeon.radeonScreen->gartTextures.map;
+ rvb->start = ((char *)elts) - rvb->address;
+ rvb->aos_offset =
+ rmesa->radeon.radeonScreen->gart_texture_offset +
+ rvb->start;
+ return;
+ } else if (r300IsGartMemory(rmesa, elts, 1)) {
+ WARN_ONCE("Pointer not within GART memory!\n");
+ _mesa_exit(-1);
}
- return num_verts - verts_off;
+ r300AllocDmaRegion(rmesa, rvb, n_elts * 4, 4);
+ rvb->aos_offset = GET_START(rvb);
+
+ out = rvb->address + rvb->start;
+ memcpy(out, elts, n_elts * 4);
}
-static void inline r300FireEB(r300ContextPtr rmesa, unsigned long addr,
- int vertex_count, int type, int elt_size)
+static void r300FireEB(r300ContextPtr rmesa, unsigned long addr,
+ int vertex_count, int type)
{
int cmd_reserved = 0;
int cmd_written = 0;
drm_radeon_cmd_header_t *cmd = NULL;
- unsigned long t_addr;
- unsigned long magic_1, magic_2;
- assert(elt_size == 2 || elt_size == 4);
+ start_packet3(CP_PACKET3(R300_PACKET3_3D_DRAW_INDX_2, 0), 0);
+ e32(R300_VAP_VF_CNTL__PRIM_WALK_INDICES | (vertex_count << 16) | type | R300_VAP_VF_CNTL__INDEX_SIZE_32bit);
- if (addr & (elt_size - 1)) {
- WARN_ONCE("Badly aligned buffer\n");
- return;
- }
+ start_packet3(CP_PACKET3(R300_PACKET3_INDX_BUFFER, 2), 2);
+ e32(R300_EB_UNK1 | (0 << 16) | R300_EB_UNK2);
+ e32(addr);
+ e32(vertex_count);
+}
+
+static void r300EmitAOS(r300ContextPtr rmesa, GLuint nr, GLuint offset)
+{
+ int sz = 1 + (nr >> 1) * 3 + (nr & 1) * 2;
+ int i;
+ int cmd_reserved = 0;
+ int cmd_written = 0;
+ drm_radeon_cmd_header_t *cmd = NULL;
- magic_1 = (addr % 32) / 4;
- t_addr = addr & ~0x1d;
- magic_2 = (vertex_count + 1 + (t_addr & 0x2)) / 2 + magic_1;
+ if (RADEON_DEBUG & DEBUG_VERTS)
+ fprintf(stderr, "%s: nr=%d, ofs=0x%08x\n", __FUNCTION__, nr,
+ offset);
- start_packet3(RADEON_CP_PACKET3_3D_DRAW_INDX_2, 0);
- if (elt_size == 4) {
- e32(R300_VAP_VF_CNTL__PRIM_WALK_INDICES |
- (vertex_count << 16) | type |
- R300_VAP_VF_CNTL__INDEX_SIZE_32bit);
- } else {
- e32(R300_VAP_VF_CNTL__PRIM_WALK_INDICES |
- (vertex_count << 16) | type);
- }
+ start_packet3(CP_PACKET3(R300_PACKET3_3D_LOAD_VBPNTR, sz - 1), sz - 1);
+ e32(nr);
- start_packet3(RADEON_CP_PACKET3_INDX_BUFFER, 2);
-#ifdef OPTIMIZE_ELTS
- if (elt_size == 4) {
- e32(R300_EB_UNK1 | (0 << 16) | R300_EB_UNK2);
- e32(addr);
- } else {
- e32(R300_EB_UNK1 | (magic_1 << 16) | R300_EB_UNK2);
- e32(t_addr);
+ for (i = 0; i + 1 < nr; i += 2) {
+ e32((rmesa->state.aos[i].aos_size << 0) |
+ (rmesa->state.aos[i].aos_stride << 8) |
+ (rmesa->state.aos[i + 1].aos_size << 16) |
+ (rmesa->state.aos[i + 1].aos_stride << 24));
+
+ e32(rmesa->state.aos[i].aos_offset + offset * 4 * rmesa->state.aos[i].aos_stride);
+ e32(rmesa->state.aos[i + 1].aos_offset + offset * 4 * rmesa->state.aos[i + 1].aos_stride);
}
-#else
- e32(R300_EB_UNK1 | (0 << 16) | R300_EB_UNK2);
- e32(addr);
-#endif
- if (elt_size == 4) {
- e32(vertex_count);
- } else {
-#ifdef OPTIMIZE_ELTS
- e32(magic_2);
-#else
- e32((vertex_count + 1) / 2);
-#endif
+ if (nr & 1) {
+ e32((rmesa->state.aos[nr - 1].aos_size << 0) |
+ (rmesa->state.aos[nr - 1].aos_stride << 8));
+ e32(rmesa->state.aos[nr - 1].aos_offset + offset * 4 * rmesa->state.aos[nr - 1].aos_stride);
}
}
+static void r300FireAOS(r300ContextPtr rmesa, int vertex_count, int type)
+{
+ int cmd_reserved = 0;
+ int cmd_written = 0;
+ drm_radeon_cmd_header_t *cmd = NULL;
+
+ start_packet3(CP_PACKET3(R300_PACKET3_3D_DRAW_VBUF_2, 0), 0);
+ e32(R300_VAP_VF_CNTL__PRIM_WALK_VERTEX_LIST | (vertex_count << 16) | type);
+}
+
static void r300RunRenderPrimitive(r300ContextPtr rmesa, GLcontext * ctx,
int start, int end, int prim)
{
int type, num_verts;
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *vb = &tnl->vb;
type = r300PrimitiveType(rmesa, ctx, prim);
num_verts = r300NumVerts(rmesa, end - start, prim);
@@ -256,88 +267,37 @@ static void r300RunRenderPrimitive(r300ContextPtr rmesa, GLcontext * ctx,
if (type < 0 || num_verts <= 0)
return;
- if (rmesa->state.VB.Elts) {
+ if (vb->Elts) {
r300EmitAOS(rmesa, rmesa->state.aos_count, start);
if (num_verts > 65535) {
/* not implemented yet */
WARN_ONCE("Too many elts\n");
return;
}
- r300EmitElts(ctx, rmesa->state.VB.Elts, num_verts,
- rmesa->state.VB.elt_size);
- r300FireEB(rmesa, rmesa->state.elt_dma.aos_offset,
- num_verts, type, rmesa->state.VB.elt_size);
+ r300EmitElts(ctx, vb->Elts, num_verts);
+ r300FireEB(rmesa, rmesa->state.elt_dma.aos_offset, num_verts, type);
} else {
r300EmitAOS(rmesa, rmesa->state.aos_count, start);
- fire_AOS(rmesa, num_verts, type);
- }
-}
-
-#define CONV_VB(a, b) rvb->AttribPtr[(a)].size = vb->b->size, \
- rvb->AttribPtr[(a)].type = GL_FLOAT, \
- rvb->AttribPtr[(a)].stride = vb->b->stride, \
- rvb->AttribPtr[(a)].data = vb->b->data
-
-static void radeon_vb_to_rvb(r300ContextPtr rmesa,
- struct radeon_vertex_buffer *rvb,
- struct vertex_buffer *vb)
-{
- int i;
- GLcontext *ctx;
- ctx = rmesa->radeon.glCtx;
-
- memset(rvb, 0, sizeof(*rvb));
-
- rvb->Elts = vb->Elts;
- rvb->elt_size = 4;
- rvb->elt_min = 0;
- rvb->elt_max = vb->Count;
-
- rvb->Count = vb->Count;
-
- if (hw_tcl_on) {
- CONV_VB(VERT_ATTRIB_POS, ObjPtr);
- } else {
- assert(vb->ClipPtr);
- CONV_VB(VERT_ATTRIB_POS, ClipPtr);
+ r300FireAOS(rmesa, num_verts, type);
}
-
- CONV_VB(VERT_ATTRIB_NORMAL, NormalPtr);
- CONV_VB(VERT_ATTRIB_COLOR0, ColorPtr[0]);
- CONV_VB(VERT_ATTRIB_COLOR1, SecondaryColorPtr[0]);
- CONV_VB(VERT_ATTRIB_FOG, FogCoordPtr);
-
- for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++)
- CONV_VB(VERT_ATTRIB_TEX0 + i, TexCoordPtr[i]);
-
- for (i = 0; i < MAX_VERTEX_PROGRAM_ATTRIBS; i++)
- CONV_VB(VERT_ATTRIB_GENERIC0 + i,
- AttribPtr[VERT_ATTRIB_GENERIC0 + i]);
-
- rvb->Primitive = vb->Primitive;
- rvb->PrimitiveCount = vb->PrimitiveCount;
- rvb->LockFirst = rvb->LockCount = 0;
- rvb->lock_uptodate = GL_FALSE;
}
static GLboolean r300RunRender(GLcontext * ctx,
struct tnl_pipeline_stage *stage)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
- struct radeon_vertex_buffer *VB = &rmesa->state.VB;
int i;
int cmd_reserved = 0;
int cmd_written = 0;
drm_radeon_cmd_header_t *cmd = NULL;
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *vb = &tnl->vb;
if (RADEON_DEBUG & DEBUG_PRIMS)
fprintf(stderr, "%s\n", __FUNCTION__);
- if (stage) {
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- radeon_vb_to_rvb(rmesa, VB, &tnl->vb);
- }
-
+ if (hw_tcl_on == GL_FALSE)
+ vb->AttribPtr[VERT_ATTRIB_POS] = vb->ClipPtr;
r300UpdateShaders(rmesa);
if (r300EmitArrays(ctx))
return GL_TRUE;
@@ -352,11 +312,10 @@ static GLboolean r300RunRender(GLcontext * ctx,
r300EmitState(rmesa);
- for (i = 0; i < VB->PrimitiveCount; i++) {
- GLuint prim = _tnl_translate_prim(&VB->Primitive[i]);
- GLuint start = VB->Primitive[i].start;
- GLuint length = VB->Primitive[i].count;
- GLuint end = VB->Primitive[i].start + VB->Primitive[i].count;
+ for (i = 0; i < vb->PrimitiveCount; i++) {
+ GLuint prim = _tnl_translate_prim(&vb->Primitive[i]);
+ GLuint start = vb->Primitive[i].start;
+ GLuint end = vb->Primitive[i].start + vb->Primitive[i].count;
r300RunRenderPrimitive(rmesa, ctx, start, end, prim);
}
diff --git a/src/mesa/drivers/dri/r300/r300_shader.c b/src/mesa/drivers/dri/r300/r300_shader.c
index f54a4f9f474..5f5ac7c4c71 100644
--- a/src/mesa/drivers/dri/r300/r300_shader.c
+++ b/src/mesa/drivers/dri/r300/r300_shader.c
@@ -7,19 +7,6 @@
#include "r300_context.h"
#include "r300_fragprog.h"
-static void
-r300BindProgram(GLcontext * ctx, GLenum target, struct gl_program *prog)
-{
- switch (target) {
- case GL_VERTEX_PROGRAM_ARB:
- case GL_FRAGMENT_PROGRAM_ARB:
- break;
- default:
- WARN_ONCE("Target not supported yet!\n");
- break;
- }
-}
-
static struct gl_program *r300NewProgram(GLcontext * ctx, GLenum target,
GLuint id)
{
@@ -62,14 +49,12 @@ r300ProgramStringNotify(GLcontext * ctx, GLenum target, struct gl_program *prog)
switch (target) {
case GL_VERTEX_PROGRAM_ARB:
vp->progs = NULL;
- /*vp->translated = GL_FALSE;
- memset(&vp->translated, 0, sizeof(struct r300_vertex_program) - sizeof(struct gl_vertex_program)); */
- /*r300TranslateVertexShader(vp); */
break;
case GL_FRAGMENT_PROGRAM_ARB:
fp->translated = GL_FALSE;
break;
}
+
/* need this for tcl fallbacks */
_tnl_program_string(ctx, target, prog);
}
@@ -77,13 +62,12 @@ r300ProgramStringNotify(GLcontext * ctx, GLenum target, struct gl_program *prog)
static GLboolean
r300IsProgramNative(GLcontext * ctx, GLenum target, struct gl_program *prog)
{
- return 1;
+ return GL_TRUE;
}
void r300InitShaderFuncs(struct dd_function_table *functions)
{
functions->NewProgram = r300NewProgram;
- functions->BindProgram = r300BindProgram;
functions->DeleteProgram = r300DeleteProgram;
functions->ProgramStringNotify = r300ProgramStringNotify;
functions->IsProgramNative = r300IsProgramNative;
diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c
index bbe3a4caead..e6163262743 100644
--- a/src/mesa/drivers/dri/r300/r300_state.c
+++ b/src/mesa/drivers/dri/r300/r300_state.c
@@ -62,10 +62,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "r300_emit.h"
#include "r300_fragprog.h"
#include "r300_tex.h"
-#include "r300_maos.h"
#include "drirenderbuffer.h"
+extern int future_hw_tcl_on;
+extern void _tnl_UpdateFixedFunctionProgram(GLcontext * ctx);
+
static void r300BlendColor(GLcontext * ctx, const GLfloat cf[4])
{
GLubyte color[4];
@@ -79,7 +81,7 @@ static void r300BlendColor(GLcontext * ctx, const GLfloat cf[4])
CLAMPED_FLOAT_TO_UBYTE(color[3], cf[3]);
rmesa->hw.blend_color.cmd[1] = PACK_COLOR_8888(color[3], color[0],
- color[1], color[2]);
+ color[1], color[2]);
}
/**
@@ -98,60 +100,58 @@ static void r300BlendColor(GLcontext * ctx, const GLfloat cf[4])
*/
static int blend_factor(GLenum factor, GLboolean is_src)
{
- int func;
-
switch (factor) {
case GL_ZERO:
- func = R300_BLEND_GL_ZERO;
+ return R300_BLEND_GL_ZERO;
break;
case GL_ONE:
- func = R300_BLEND_GL_ONE;
+ return R300_BLEND_GL_ONE;
break;
case GL_DST_COLOR:
- func = R300_BLEND_GL_DST_COLOR;
+ return R300_BLEND_GL_DST_COLOR;
break;
case GL_ONE_MINUS_DST_COLOR:
- func = R300_BLEND_GL_ONE_MINUS_DST_COLOR;
+ return R300_BLEND_GL_ONE_MINUS_DST_COLOR;
break;
case GL_SRC_COLOR:
- func = R300_BLEND_GL_SRC_COLOR;
+ return R300_BLEND_GL_SRC_COLOR;
break;
case GL_ONE_MINUS_SRC_COLOR:
- func = R300_BLEND_GL_ONE_MINUS_SRC_COLOR;
+ return R300_BLEND_GL_ONE_MINUS_SRC_COLOR;
break;
case GL_SRC_ALPHA:
- func = R300_BLEND_GL_SRC_ALPHA;
+ return R300_BLEND_GL_SRC_ALPHA;
break;
case GL_ONE_MINUS_SRC_ALPHA:
- func = R300_BLEND_GL_ONE_MINUS_SRC_ALPHA;
+ return R300_BLEND_GL_ONE_MINUS_SRC_ALPHA;
break;
case GL_DST_ALPHA:
- func = R300_BLEND_GL_DST_ALPHA;
+ return R300_BLEND_GL_DST_ALPHA;
break;
case GL_ONE_MINUS_DST_ALPHA:
- func = R300_BLEND_GL_ONE_MINUS_DST_ALPHA;
+ return R300_BLEND_GL_ONE_MINUS_DST_ALPHA;
break;
case GL_SRC_ALPHA_SATURATE:
- func = (is_src) ? R300_BLEND_GL_SRC_ALPHA_SATURATE :
+ return (is_src) ? R300_BLEND_GL_SRC_ALPHA_SATURATE :
R300_BLEND_GL_ZERO;
break;
case GL_CONSTANT_COLOR:
- func = R300_BLEND_GL_CONST_COLOR;
+ return R300_BLEND_GL_CONST_COLOR;
break;
case GL_ONE_MINUS_CONSTANT_COLOR:
- func = R300_BLEND_GL_ONE_MINUS_CONST_COLOR;
+ return R300_BLEND_GL_ONE_MINUS_CONST_COLOR;
break;
case GL_CONSTANT_ALPHA:
- func = R300_BLEND_GL_CONST_ALPHA;
+ return R300_BLEND_GL_CONST_ALPHA;
break;
case GL_ONE_MINUS_CONSTANT_ALPHA:
- func = R300_BLEND_GL_ONE_MINUS_CONST_ALPHA;
+ return R300_BLEND_GL_ONE_MINUS_CONST_ALPHA;
break;
default:
fprintf(stderr, "unknown blend factor %x\n", factor);
- func = (is_src) ? R300_BLEND_GL_ONE : R300_BLEND_GL_ZERO;
+ return (is_src) ? R300_BLEND_GL_ONE : R300_BLEND_GL_ZERO;
+ break;
}
- return func;
}
/**
@@ -249,7 +249,7 @@ static void r300SetBlendState(GLcontext * ctx)
default:
fprintf(stderr,
"[%s:%u] Invalid RGB blend equation (0x%04x).\n",
- __func__, __LINE__, ctx->Color.BlendEquationRGB);
+ __FUNCTION__, __LINE__, ctx->Color.BlendEquationRGB);
return;
}
@@ -287,7 +287,7 @@ static void r300SetBlendState(GLcontext * ctx)
default:
fprintf(stderr,
"[%s:%u] Invalid A blend equation (0x%04x).\n",
- __func__, __LINE__, ctx->Color.BlendEquationA);
+ __FUNCTION__, __LINE__, ctx->Color.BlendEquationA);
return;
}
@@ -334,7 +334,7 @@ static void r300UpdateCulling(GLcontext * ctx)
r300->hw.cul.cmd[R300_CUL_CULL] = val;
}
-static void update_early_z(GLcontext * ctx)
+static void r300SetEarlyZState(GLcontext * ctx)
{
/* updates register R300_RB3D_EARLY_Z (0x4F14)
if depth test is not enabled it should be R300_EARLY_Z_DISABLE
@@ -357,7 +357,7 @@ static void update_early_z(GLcontext * ctx)
}
}
-static void update_alpha(GLcontext * ctx)
+static void r300SetAlphaState(GLcontext * ctx)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
GLubyte refByte;
@@ -403,14 +403,15 @@ static void update_alpha(GLcontext * ctx)
R300_STATECHANGE(r300, at);
r300->hw.at.cmd[R300_AT_ALPHA_TEST] = pp_misc;
- update_early_z(ctx);
+
+ r300SetEarlyZState(ctx);
}
static void r300AlphaFunc(GLcontext * ctx, GLenum func, GLfloat ref)
{
(void)func;
(void)ref;
- update_alpha(ctx);
+ r300SetAlphaState(ctx);
}
static int translate_func(int func)
@@ -436,7 +437,7 @@ static int translate_func(int func)
return 0;
}
-static void update_depth(GLcontext * ctx)
+static void r300SetDepthState(GLcontext * ctx)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
@@ -461,98 +462,7 @@ static void update_depth(GLcontext * ctx)
translate_func(GL_NEVER) << R300_RB3D_ZS1_DEPTH_FUNC_SHIFT;
}
- update_early_z(ctx);
-}
-
-/**
- * Handle glEnable()/glDisable().
- *
- * \note Mesa already filters redundant calls to glEnable/glDisable.
- */
-static void r300Enable(GLcontext * ctx, GLenum cap, GLboolean state)
-{
- r300ContextPtr r300 = R300_CONTEXT(ctx);
-
- if (RADEON_DEBUG & DEBUG_STATE)
- fprintf(stderr, "%s( %s = %s )\n", __FUNCTION__,
- _mesa_lookup_enum_by_nr(cap),
- state ? "GL_TRUE" : "GL_FALSE");
-
- switch (cap) {
- /* Fast track this one...
- */
- case GL_TEXTURE_1D:
- case GL_TEXTURE_2D:
- case GL_TEXTURE_3D:
- break;
-
- case GL_FOG:
- R300_STATECHANGE(r300, fogs);
- if (state) {
- r300->hw.fogs.cmd[R300_FOGS_STATE] |= R300_FOG_ENABLE;
-
- ctx->Driver.Fogfv(ctx, GL_FOG_MODE, NULL);
- ctx->Driver.Fogfv(ctx, GL_FOG_DENSITY,
- &ctx->Fog.Density);
- ctx->Driver.Fogfv(ctx, GL_FOG_START, &ctx->Fog.Start);
- ctx->Driver.Fogfv(ctx, GL_FOG_END, &ctx->Fog.End);
- ctx->Driver.Fogfv(ctx, GL_FOG_COLOR, ctx->Fog.Color);
- } else {
- r300->hw.fogs.cmd[R300_FOGS_STATE] &= ~R300_FOG_ENABLE;
- }
-
- break;
-
- case GL_ALPHA_TEST:
- update_alpha(ctx);
- break;
-
- case GL_BLEND:
- case GL_COLOR_LOGIC_OP:
- r300SetBlendState(ctx);
- break;
-
- case GL_DEPTH_TEST:
- update_depth(ctx);
- break;
-
- case GL_STENCIL_TEST:
- if (r300->state.stencil.hw_stencil) {
- R300_STATECHANGE(r300, zs);
- if (state) {
- r300->hw.zs.cmd[R300_ZS_CNTL_0] |=
- R300_RB3D_STENCIL_ENABLE;
- } else {
- r300->hw.zs.cmd[R300_ZS_CNTL_0] &=
- ~R300_RB3D_STENCIL_ENABLE;
- }
- } else {
-#if R200_MERGED
- FALLBACK(&r300->radeon, RADEON_FALLBACK_STENCIL, state);
-#endif
- }
- break;
-
- case GL_CULL_FACE:
- r300UpdateCulling(ctx);
- break;
-
- case GL_POLYGON_OFFSET_POINT:
- case GL_POLYGON_OFFSET_LINE:
- break;
-
- case GL_POLYGON_OFFSET_FILL:
- R300_STATECHANGE(r300, occlusion_cntl);
- if (state) {
- r300->hw.occlusion_cntl.cmd[1] |= (3 << 0);
- } else {
- r300->hw.occlusion_cntl.cmd[1] &= ~(3 << 0);
- }
- break;
- default:
- radeonEnable(ctx, cap, state);
- return;
- }
+ r300SetEarlyZState(ctx);
}
static void r300UpdatePolygonMode(GLcontext * ctx)
@@ -638,7 +548,7 @@ static void r300FrontFace(GLcontext * ctx, GLenum mode)
static void r300DepthFunc(GLcontext * ctx, GLenum func)
{
(void)func;
- update_depth(ctx);
+ r300SetDepthState(ctx);
}
/**
@@ -649,7 +559,7 @@ static void r300DepthFunc(GLcontext * ctx, GLenum func)
static void r300DepthMask(GLcontext * ctx, GLboolean mask)
{
(void)mask;
- update_depth(ctx);
+ r300SetDepthState(ctx);
}
/**
@@ -805,8 +715,8 @@ static void r300LineWidth(GLcontext * ctx, GLfloat widthf)
widthf = ctx->Line._Width;
R300_STATECHANGE(r300, lcntl);
- r300->hw.lcntl.cmd[1] = (int)(widthf * 6.0);
- r300->hw.lcntl.cmd[1] |= R300_LINE_CNT_VE;
+ r300->hw.lcntl.cmd[1] |=
+ R300_LINE_CNT_HO | R300_LINE_CNT_VE | (int)(widthf * 6.0);
}
static void r300PolygonMode(GLcontext * ctx, GLenum face, GLenum mode)
@@ -978,7 +888,7 @@ static void r300ClearStencil(GLcontext * ctx, GLint s)
#define SUBPIXEL_X 0.125
#define SUBPIXEL_Y 0.125
-void r300UpdateWindow(GLcontext * ctx)
+static void r300UpdateWindow(GLcontext * ctx)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
__DRIdrawablePrivate *dPriv = rmesa->radeon.dri.drawable;
@@ -1441,15 +1351,15 @@ union r300_outputs_written {
((hw_tcl_on) ? (ow).vp_outputs & (1 << (vp_result)) : \
RENDERINPUTS_TEST( (ow.index_bitset), (tnl_attrib) ))
-void r300SetupRSUnit(GLcontext * ctx)
+static void r300SetupRSUnit(GLcontext * ctx)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
/* I'm still unsure if these are needed */
GLuint interp_magic[8] = {
0x00,
- 0x40,
- 0x80,
- 0xC0,
+ R300_RS_INTERP_1_UNKNOWN,
+ R300_RS_INTERP_2_UNKNOWN,
+ R300_RS_INTERP_3_UNKNOWN,
0x00,
0x00,
0x00,
@@ -1462,11 +1372,9 @@ void r300SetupRSUnit(GLcontext * ctx)
int i;
if (hw_tcl_on)
- OutputsWritten.vp_outputs =
- CURRENT_VERTEX_SHADER(ctx)->key.OutputsWritten;
+ OutputsWritten.vp_outputs = CURRENT_VERTEX_SHADER(ctx)->key.OutputsWritten;
else
- RENDERINPUTS_COPY(OutputsWritten.index_bitset,
- r300->state.render_inputs_bitset);
+ RENDERINPUTS_COPY(OutputsWritten.index_bitset, r300->state.render_inputs_bitset);
if (ctx->FragmentProgram._Current)
InputsRead = ctx->FragmentProgram._Current->Base.InputsRead;
@@ -1498,9 +1406,7 @@ void r300SetupRSUnit(GLcontext * ctx)
}
for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
- r300->hw.ri.cmd[R300_RI_INTERP_0 + i] = 0
- | R300_RS_INTERP_USED
- | (in_texcoords << R300_RS_INTERP_SRC_SHIFT)
+ r300->hw.ri.cmd[R300_RI_INTERP_0 + i] = 0 | R300_RS_INTERP_USED | (in_texcoords << R300_RS_INTERP_SRC_SHIFT)
| interp_magic[i];
r300->hw.rr.cmd[R300_RR_ROUTE_0 + fp_reg] = 0;
@@ -1510,65 +1416,45 @@ void r300SetupRSUnit(GLcontext * ctx)
| (fp_reg << R300_RS_ROUTE_DEST_SHIFT);
high_rr = fp_reg;
- if (!R300_OUTPUTS_WRITTEN_TEST
- (OutputsWritten, VERT_RESULT_TEX0 + i,
- _TNL_ATTRIB_TEX(i))) {
- /* Passing invalid data here can lock the GPU. */
- WARN_ONCE
- ("fragprog wants coords for tex%d, vp doesn't provide them!\n",
- i);
- //_mesa_print_program(&CURRENT_VERTEX_SHADER(ctx)->Base);
- //_mesa_exit(-1);
+ /* Passing invalid data here can lock the GPU. */
+ if (R300_OUTPUTS_WRITTEN_TEST(OutputsWritten, VERT_RESULT_TEX0 + i, _TNL_ATTRIB_TEX(i))) {
+ InputsRead &= ~(FRAG_BIT_TEX0 << i);
+ fp_reg++;
+ } else {
+ WARN_ONCE("fragprog wants coords for tex%d, vp doesn't provide them!\n", i);
}
- InputsRead &= ~(FRAG_BIT_TEX0 << i);
- fp_reg++;
}
/* Need to count all coords enabled at vof */
- if (R300_OUTPUTS_WRITTEN_TEST
- (OutputsWritten, VERT_RESULT_TEX0 + i, _TNL_ATTRIB_TEX(i)))
+ if (R300_OUTPUTS_WRITTEN_TEST(OutputsWritten, VERT_RESULT_TEX0 + i, _TNL_ATTRIB_TEX(i))) {
in_texcoords++;
+ }
}
if (InputsRead & FRAG_BIT_COL0) {
- if (!R300_OUTPUTS_WRITTEN_TEST
- (OutputsWritten, VERT_RESULT_COL0, _TNL_ATTRIB_COLOR0)) {
- WARN_ONCE
- ("fragprog wants col0, vp doesn't provide it\n");
- goto out; /* FIXME */
- //_mesa_print_program(&CURRENT_VERTEX_SHADER(ctx)->Base);
- //_mesa_exit(-1);
+ if (R300_OUTPUTS_WRITTEN_TEST(OutputsWritten, VERT_RESULT_COL0, _TNL_ATTRIB_COLOR0)) {
+ r300->hw.rr.cmd[R300_RR_ROUTE_0] |= 0 | R300_RS_ROUTE_0_COLOR | (fp_reg++ << R300_RS_ROUTE_0_COLOR_DEST_SHIFT);
+ InputsRead &= ~FRAG_BIT_COL0;
+ col_interp_nr++;
+ } else {
+ WARN_ONCE("fragprog wants col0, vp doesn't provide it\n");
}
-
- r300->hw.rr.cmd[R300_RR_ROUTE_0] |= 0
- | R300_RS_ROUTE_0_COLOR
- | (fp_reg++ << R300_RS_ROUTE_0_COLOR_DEST_SHIFT);
- InputsRead &= ~FRAG_BIT_COL0;
- col_interp_nr++;
}
- out:
if (InputsRead & FRAG_BIT_COL1) {
- if (!R300_OUTPUTS_WRITTEN_TEST
- (OutputsWritten, VERT_RESULT_COL1, _TNL_ATTRIB_COLOR1)) {
- WARN_ONCE
- ("fragprog wants col1, vp doesn't provide it\n");
- //_mesa_exit(-1);
+ if (R300_OUTPUTS_WRITTEN_TEST(OutputsWritten, VERT_RESULT_COL1, _TNL_ATTRIB_COLOR1)) {
+ r300->hw.rr.cmd[R300_RR_ROUTE_1] |= R300_RS_ROUTE_1_UNKNOWN11 | R300_RS_ROUTE_1_COLOR1 | (fp_reg++ << R300_RS_ROUTE_1_COLOR1_DEST_SHIFT);
+ InputsRead &= ~FRAG_BIT_COL1;
+ if (high_rr < 1)
+ high_rr = 1;
+ col_interp_nr++;
+ } else {
+ WARN_ONCE("fragprog wants col1, vp doesn't provide it\n");
}
-
- r300->hw.rr.cmd[R300_RR_ROUTE_1] |=
- R300_RS_ROUTE_1_UNKNOWN11 | R300_RS_ROUTE_1_COLOR1 |
- (fp_reg++ << R300_RS_ROUTE_1_COLOR1_DEST_SHIFT);
- InputsRead &= ~FRAG_BIT_COL1;
- if (high_rr < 1)
- high_rr = 1;
- col_interp_nr++;
}
/* Need at least one. This might still lock as the values are undefined... */
if (in_texcoords == 0 && col_interp_nr == 0) {
- r300->hw.rr.cmd[R300_RR_ROUTE_0] |= 0
- | R300_RS_ROUTE_0_COLOR
- | (fp_reg++ << R300_RS_ROUTE_0_COLOR_DEST_SHIFT);
+ r300->hw.rr.cmd[R300_RR_ROUTE_0] |= 0 | R300_RS_ROUTE_0_COLOR | (fp_reg++ << R300_RS_ROUTE_0_COLOR_DEST_SHIFT);
col_interp_nr++;
}
@@ -1577,17 +1463,13 @@ void r300SetupRSUnit(GLcontext * ctx)
| R300_RS_CNTL_0_UNKNOWN_18;
assert(high_rr >= 0);
- r300->hw.rr.cmd[R300_RR_CMD_0] =
- cmdpacket0(R300_RS_ROUTE_0, high_rr + 1);
+ r300->hw.rr.cmd[R300_RR_CMD_0] = cmdpacket0(R300_RS_ROUTE_0, high_rr + 1);
r300->hw.rc.cmd[2] = 0xC0 | high_rr;
if (InputsRead)
- WARN_ONCE("Don't know how to satisfy InputsRead=0x%08x\n",
- InputsRead);
+ WARN_ONCE("Don't know how to satisfy InputsRead=0x%08x\n", InputsRead);
}
-#define vpucount(ptr) (((drm_r300_cmd_header_t*)(ptr))->vpu.count)
-
#define bump_vpu_count(ptr, new_count) do{\
drm_r300_cmd_header_t* _p=((drm_r300_cmd_header_t*)(ptr));\
int _nc=(new_count)/4; \
@@ -1644,8 +1526,6 @@ void static inline setup_vertex_shader_fragment(r300ContextPtr r300, int dest, s
}
}
-void r300SetupVertexProgram(r300ContextPtr rmesa);
-
/* just a skeleton for now.. */
/* Generate a vertex shader that simply transforms vertex and texture coordinates,
@@ -1701,66 +1581,7 @@ static void r300GenerateSimpleVertexShader(r300ContextPtr r300)
}
-void r300SetupVertexShader(r300ContextPtr rmesa)
-{
- GLcontext *ctx = rmesa->radeon.glCtx;
-
- /* Reset state, in case we don't use something */
- ((drm_r300_cmd_header_t *) rmesa->hw.vpp.cmd)->vpu.count = 0;
- ((drm_r300_cmd_header_t *) rmesa->hw.vpi.cmd)->vpu.count = 0;
- ((drm_r300_cmd_header_t *) rmesa->hw.vps.cmd)->vpu.count = 0;
-
- /* Not sure why this doesnt work...
- 0x400 area might have something to do with pixel shaders as it appears right after pfs programming.
- 0x406 is set to { 0.0, 0.0, 1.0, 0.0 } most of the time but should change with smooth points and in other rare cases. */
- //setup_vertex_shader_fragment(rmesa, 0x406, &unk4);
- if (hw_tcl_on
- && ((struct r300_vertex_program *)CURRENT_VERTEX_SHADER(ctx))->
- translated) {
- r300SetupVertexProgram(rmesa);
- return;
- }
-
- /* This needs to be replaced by vertex shader generation code */
- r300GenerateSimpleVertexShader(rmesa);
-
- setup_vertex_shader_fragment(rmesa, VSF_DEST_PROGRAM,
- &(rmesa->state.vertex_shader.program));
-
-#if 0
- setup_vertex_shader_fragment(rmesa, VSF_DEST_UNKNOWN1,
- &(rmesa->state.vertex_shader.unknown1));
- setup_vertex_shader_fragment(rmesa, VSF_DEST_UNKNOWN2,
- &(rmesa->state.vertex_shader.unknown2));
-#endif
-
- R300_STATECHANGE(rmesa, pvs);
- rmesa->hw.pvs.cmd[R300_PVS_CNTL_1] =
- (rmesa->state.vertex_shader.
- program_start << R300_PVS_CNTL_1_PROGRAM_START_SHIFT)
- | (rmesa->state.vertex_shader.
- unknown_ptr1 << R300_PVS_CNTL_1_POS_END_SHIFT)
- | (rmesa->state.vertex_shader.
- program_end << R300_PVS_CNTL_1_PROGRAM_END_SHIFT);
- rmesa->hw.pvs.cmd[R300_PVS_CNTL_2] =
- (rmesa->state.vertex_shader.
- param_offset << R300_PVS_CNTL_2_PARAM_OFFSET_SHIFT)
- | (rmesa->state.vertex_shader.
- param_count << R300_PVS_CNTL_2_PARAM_COUNT_SHIFT);
- rmesa->hw.pvs.cmd[R300_PVS_CNTL_3] =
- (rmesa->state.vertex_shader.
- unknown_ptr2 << R300_PVS_CNTL_3_PROGRAM_UNKNOWN_SHIFT)
- | (rmesa->state.vertex_shader.unknown_ptr3 << 0);
-
- /* This is done for vertex shader fragments, but also needs to be done for vap_pvs,
- so I leave it as a reminder */
-#if 0
- reg_start(R300_VAP_PVS_WAITIDLE, 0);
- e32(0x00000000);
-#endif
-}
-
-void r300SetupVertexProgram(r300ContextPtr rmesa)
+static void r300SetupVertexProgram(r300ContextPtr rmesa)
{
GLcontext *ctx = rmesa->radeon.glCtx;
int inst_count;
@@ -1815,197 +1636,159 @@ void r300SetupVertexProgram(r300ContextPtr rmesa)
#endif
}
-extern void _tnl_UpdateFixedFunctionProgram(GLcontext * ctx);
-
-extern int future_hw_tcl_on;
-void r300UpdateShaders(r300ContextPtr rmesa)
+static void r300SetupVertexShader(r300ContextPtr rmesa)
{
- GLcontext *ctx;
- struct r300_vertex_program *vp;
- int i;
-
- ctx = rmesa->radeon.glCtx;
-
- if (rmesa->NewGLState && hw_tcl_on) {
- rmesa->NewGLState = 0;
-
- for (i = _TNL_FIRST_MAT; i <= _TNL_LAST_MAT; i++) {
- rmesa->temp_attrib[i] =
- TNL_CONTEXT(ctx)->vb.AttribPtr[i];
- TNL_CONTEXT(ctx)->vb.AttribPtr[i] =
- &rmesa->dummy_attrib[i];
- }
-
- _tnl_UpdateFixedFunctionProgram(ctx);
-
- for (i = _TNL_FIRST_MAT; i <= _TNL_LAST_MAT; i++) {
- TNL_CONTEXT(ctx)->vb.AttribPtr[i] =
- rmesa->temp_attrib[i];
- }
+ GLcontext *ctx = rmesa->radeon.glCtx;
- r300SelectVertexShader(rmesa);
- vp = (struct r300_vertex_program *)
- CURRENT_VERTEX_SHADER(ctx);
- /*if (vp->translated == GL_FALSE)
- r300TranslateVertexShader(vp); */
- if (vp->translated == GL_FALSE) {
- fprintf(stderr, "Failing back to sw-tcl\n");
- hw_tcl_on = future_hw_tcl_on = 0;
- r300ResetHwState(rmesa);
+ /* Reset state, in case we don't use something */
+ ((drm_r300_cmd_header_t *) rmesa->hw.vpp.cmd)->vpu.count = 0;
+ ((drm_r300_cmd_header_t *) rmesa->hw.vpi.cmd)->vpu.count = 0;
+ ((drm_r300_cmd_header_t *) rmesa->hw.vps.cmd)->vpu.count = 0;
- return;
- }
- r300UpdateStateParameters(ctx, _NEW_PROGRAM);
+ /* Not sure why this doesnt work...
+ 0x400 area might have something to do with pixel shaders as it appears right after pfs programming.
+ 0x406 is set to { 0.0, 0.0, 1.0, 0.0 } most of the time but should change with smooth points and in other rare cases. */
+ //setup_vertex_shader_fragment(rmesa, 0x406, &unk4);
+ if (hw_tcl_on
+ && ((struct r300_vertex_program *)CURRENT_VERTEX_SHADER(ctx))->
+ translated) {
+ r300SetupVertexProgram(rmesa);
+ return;
}
-}
+ /* This needs to be replaced by vertex shader generation code */
+ r300GenerateSimpleVertexShader(rmesa);
-void r300UpdateShaderStates(r300ContextPtr rmesa)
-{
- GLcontext *ctx;
- ctx = rmesa->radeon.glCtx;
+ setup_vertex_shader_fragment(rmesa, VSF_DEST_PROGRAM,
+ &(rmesa->state.vertex_shader.program));
- r300UpdateTextureState(ctx);
+#if 0
+ setup_vertex_shader_fragment(rmesa, VSF_DEST_UNKNOWN1,
+ &(rmesa->state.vertex_shader.unknown1));
+ setup_vertex_shader_fragment(rmesa, VSF_DEST_UNKNOWN2,
+ &(rmesa->state.vertex_shader.unknown2));
+#endif
- r300SetupPixelShader(rmesa);
- r300SetupTextures(ctx);
+ R300_STATECHANGE(rmesa, pvs);
+ rmesa->hw.pvs.cmd[R300_PVS_CNTL_1] =
+ (rmesa->state.vertex_shader.
+ program_start << R300_PVS_CNTL_1_PROGRAM_START_SHIFT)
+ | (rmesa->state.vertex_shader.
+ unknown_ptr1 << R300_PVS_CNTL_1_POS_END_SHIFT)
+ | (rmesa->state.vertex_shader.
+ program_end << R300_PVS_CNTL_1_PROGRAM_END_SHIFT);
+ rmesa->hw.pvs.cmd[R300_PVS_CNTL_2] =
+ (rmesa->state.vertex_shader.
+ param_offset << R300_PVS_CNTL_2_PARAM_OFFSET_SHIFT)
+ | (rmesa->state.vertex_shader.
+ param_count << R300_PVS_CNTL_2_PARAM_COUNT_SHIFT);
+ rmesa->hw.pvs.cmd[R300_PVS_CNTL_3] =
+ (rmesa->state.vertex_shader.
+ unknown_ptr2 << R300_PVS_CNTL_3_PROGRAM_UNKNOWN_SHIFT)
+ | (rmesa->state.vertex_shader.unknown_ptr3 << 0);
- if ((rmesa->radeon.radeonScreen->chip_flags & RADEON_CHIPSET_TCL))
- r300SetupVertexShader(rmesa);
- r300SetupRSUnit(ctx);
+ /* This is done for vertex shader fragments, but also needs to be done for vap_pvs,
+ so I leave it as a reminder */
+#if 0
+ reg_start(R300_VAP_PVS_WAITIDLE, 0);
+ e32(0x00000000);
+#endif
}
-/* This is probably wrong for some values, I need to test this
- * some more. Range checking would be a good idea also..
+/**
+ * Enable/Disable states.
*
- * But it works for most things. I'll fix it later if someone
- * else with a better clue doesn't
+ * \note Mesa already filters redundant calls to this function.
*/
-static unsigned int r300PackFloat24(float f)
+static void r300Enable(GLcontext * ctx, GLenum cap, GLboolean state)
{
- float mantissa;
- int exponent;
- unsigned int float24 = 0;
+ r300ContextPtr r300 = R300_CONTEXT(ctx);
- if (f == 0.0)
- return 0;
+ if (RADEON_DEBUG & DEBUG_STATE)
+ fprintf(stderr, "%s( %s = %s )\n", __FUNCTION__,
+ _mesa_lookup_enum_by_nr(cap),
+ state ? "GL_TRUE" : "GL_FALSE");
- mantissa = frexpf(f, &exponent);
+ switch (cap) {
+ /* Fast track this one...
+ */
+ case GL_TEXTURE_1D:
+ case GL_TEXTURE_2D:
+ case GL_TEXTURE_3D:
+ break;
- /* Handle -ve */
- if (mantissa < 0) {
- float24 |= (1 << 23);
- mantissa = mantissa * -1.0;
- }
- /* Handle exponent, bias of 63 */
- exponent += 62;
- float24 |= (exponent << 16);
- /* Kill 7 LSB of mantissa */
- float24 |= (r300PackFloat32(mantissa) & 0x7FFFFF) >> 7;
+ case GL_FOG:
+ R300_STATECHANGE(r300, fogs);
+ if (state) {
+ r300->hw.fogs.cmd[R300_FOGS_STATE] |= R300_FOG_ENABLE;
- return float24;
-}
+ r300Fogfv(ctx, GL_FOG_MODE, NULL);
+ r300Fogfv(ctx, GL_FOG_DENSITY, &ctx->Fog.Density);
+ r300Fogfv(ctx, GL_FOG_START, &ctx->Fog.Start);
+ r300Fogfv(ctx, GL_FOG_END, &ctx->Fog.End);
+ r300Fogfv(ctx, GL_FOG_COLOR, ctx->Fog.Color);
+ } else {
+ r300->hw.fogs.cmd[R300_FOGS_STATE] &= ~R300_FOG_ENABLE;
+ }
-void r300SetupPixelShader(r300ContextPtr rmesa)
-{
- GLcontext *ctx = rmesa->radeon.glCtx;
- struct r300_fragment_program *fp = (struct r300_fragment_program *)
- (char *)ctx->FragmentProgram._Current;
- int i, k;
+ break;
- if (!fp) /* should only happenen once, just after context is created */
- return;
+ case GL_ALPHA_TEST:
+ r300SetAlphaState(ctx);
+ break;
- r300TranslateFragmentShader(rmesa, fp);
- if (!fp->translated) {
- fprintf(stderr, "%s: No valid fragment shader, exiting\n",
- __func__);
- return;
- }
-#define OUTPUT_FIELD(st, reg, field) \
- R300_STATECHANGE(rmesa, st); \
- for(i=0;i<=fp->alu_end;i++) \
- rmesa->hw.st.cmd[R300_FPI_INSTR_0+i]=fp->alu.inst[i].field;\
- rmesa->hw.st.cmd[R300_FPI_CMD_0]=cmdpacket0(reg, fp->alu_end+1);
+ case GL_BLEND:
+ case GL_COLOR_LOGIC_OP:
+ r300SetBlendState(ctx);
+ break;
- OUTPUT_FIELD(fpi[0], R300_PFS_INSTR0_0, inst0);
- OUTPUT_FIELD(fpi[1], R300_PFS_INSTR1_0, inst1);
- OUTPUT_FIELD(fpi[2], R300_PFS_INSTR2_0, inst2);
- OUTPUT_FIELD(fpi[3], R300_PFS_INSTR3_0, inst3);
-#undef OUTPUT_FIELD
+ case GL_DEPTH_TEST:
+ r300SetDepthState(ctx);
+ break;
- R300_STATECHANGE(rmesa, fp);
- /* I just want to say, the way these nodes are stored.. weird.. */
- for (i = 0, k = (4 - (fp->cur_node + 1)); i < 4; i++, k++) {
- if (i < (fp->cur_node + 1)) {
- rmesa->hw.fp.cmd[R300_FP_NODE0 + k] =
- (fp->node[i].
- alu_offset << R300_PFS_NODE_ALU_OFFSET_SHIFT)
- | (fp->node[i].
- alu_end << R300_PFS_NODE_ALU_END_SHIFT)
- | (fp->node[i].
- tex_offset << R300_PFS_NODE_TEX_OFFSET_SHIFT)
- | (fp->node[i].
- tex_end << R300_PFS_NODE_TEX_END_SHIFT)
- | fp->node[i].flags; /* ( (k==3) ? R300_PFS_NODE_LAST_NODE : 0); */
+ case GL_STENCIL_TEST:
+ if (r300->state.stencil.hw_stencil) {
+ R300_STATECHANGE(r300, zs);
+ if (state) {
+ r300->hw.zs.cmd[R300_ZS_CNTL_0] |=
+ R300_RB3D_STENCIL_ENABLE;
+ } else {
+ r300->hw.zs.cmd[R300_ZS_CNTL_0] &=
+ ~R300_RB3D_STENCIL_ENABLE;
+ }
} else {
- rmesa->hw.fp.cmd[R300_FP_NODE0 + (3 - i)] = 0;
+#if R200_MERGED
+ FALLBACK(&r300->radeon, RADEON_FALLBACK_STENCIL, state);
+#endif
}
- }
-
- /* PFS_CNTL_0 */
- rmesa->hw.fp.cmd[R300_FP_CNTL0] =
- fp->cur_node | (fp->first_node_has_tex << 3);
- /* PFS_CNTL_1 */
- rmesa->hw.fp.cmd[R300_FP_CNTL1] = fp->max_temp_idx;
- /* PFS_CNTL_2 */
- rmesa->hw.fp.cmd[R300_FP_CNTL2] =
- (fp->alu_offset << R300_PFS_CNTL_ALU_OFFSET_SHIFT)
- | (fp->alu_end << R300_PFS_CNTL_ALU_END_SHIFT)
- | (fp->tex_offset << R300_PFS_CNTL_TEX_OFFSET_SHIFT)
- | (fp->tex_end << R300_PFS_CNTL_TEX_END_SHIFT);
-
- R300_STATECHANGE(rmesa, fpp);
- for (i = 0; i < fp->const_nr; i++) {
- rmesa->hw.fpp.cmd[R300_FPP_PARAM_0 + 4 * i + 0] =
- r300PackFloat24(fp->constant[i][0]);
- rmesa->hw.fpp.cmd[R300_FPP_PARAM_0 + 4 * i + 1] =
- r300PackFloat24(fp->constant[i][1]);
- rmesa->hw.fpp.cmd[R300_FPP_PARAM_0 + 4 * i + 2] =
- r300PackFloat24(fp->constant[i][2]);
- rmesa->hw.fpp.cmd[R300_FPP_PARAM_0 + 4 * i + 3] =
- r300PackFloat24(fp->constant[i][3]);
- }
- rmesa->hw.fpp.cmd[R300_FPP_CMD_0] =
- cmdpacket0(R300_PFS_PARAM_0_X, fp->const_nr * 4);
-}
+ break;
-/**
- * Called by Mesa after an internal state update.
- */
-static void r300InvalidateState(GLcontext * ctx, GLuint new_state)
-{
- r300ContextPtr r300 = R300_CONTEXT(ctx);
+ case GL_CULL_FACE:
+ r300UpdateCulling(ctx);
+ break;
- _swrast_InvalidateState(ctx, new_state);
- _swsetup_InvalidateState(ctx, new_state);
- _vbo_InvalidateState(ctx, new_state);
- _tnl_InvalidateState(ctx, new_state);
- _ae_invalidate_state(ctx, new_state);
+ case GL_POLYGON_OFFSET_POINT:
+ case GL_POLYGON_OFFSET_LINE:
+ break;
- if (new_state & (_NEW_BUFFERS | _NEW_COLOR | _NEW_PIXEL)) {
- r300UpdateDrawBuffer(ctx);
+ case GL_POLYGON_OFFSET_FILL:
+ R300_STATECHANGE(r300, occlusion_cntl);
+ if (state) {
+ r300->hw.occlusion_cntl.cmd[1] |= (3 << 0);
+ } else {
+ r300->hw.occlusion_cntl.cmd[1] &= ~(3 << 0);
+ }
+ break;
+ default:
+ radeonEnable(ctx, cap, state);
+ return;
}
-
- r300UpdateStateParameters(ctx, new_state);
-
- r300->NewGLState |= new_state;
}
/**
* Completely recalculates hardware state based on the Mesa state.
*/
-void r300ResetHwState(r300ContextPtr r300)
+static void r300ResetHwState(r300ContextPtr r300)
{
GLcontext *ctx = r300->radeon.glCtx;
int has_tcl = 1;
@@ -2016,12 +1799,6 @@ void r300ResetHwState(r300ContextPtr r300)
if (RADEON_DEBUG & DEBUG_STATE)
fprintf(stderr, "%s\n", __FUNCTION__);
- /* This is a place to initialize registers which
- have bitfields accessed by different functions
- and not all bits are used */
-
- /* go and compute register values from GL state */
-
r300UpdateWindow(ctx);
r300ColorMask(ctx,
@@ -2051,13 +1828,11 @@ void r300ResetHwState(r300ContextPtr r300)
r300AlphaFunc(ctx, ctx->Color.AlphaFunc, ctx->Color.AlphaRef);
r300Enable(ctx, GL_ALPHA_TEST, ctx->Color.AlphaEnabled);
- /* Initialize magic registers
- TODO : learn what they really do, or get rid of
- those we don't have to touch */
if (!has_tcl)
r300->hw.vap_cntl.cmd[1] = 0x0014045a;
else
r300->hw.vap_cntl.cmd[1] = 0x0030045A; //0x0030065a /* Dangerous */
+
r300->hw.vte.cmd[1] = R300_VPORT_X_SCALE_ENA
| R300_VPORT_X_OFFSET_ENA
| R300_VPORT_Y_SCALE_ENA
@@ -2068,10 +1843,12 @@ void r300ResetHwState(r300ContextPtr r300)
r300->hw.unk2134.cmd[1] = 0x00FFFFFF;
r300->hw.unk2134.cmd[2] = 0x00000000;
- if (_mesa_little_endian())
- r300->hw.vap_cntl_status.cmd[1] = R300_VC_NO_SWAP;
- else
- r300->hw.vap_cntl_status.cmd[1] = R300_VC_32BIT_SWAP;
+
+#ifdef MESA_LITTLE_ENDIAN
+ r300->hw.vap_cntl_status.cmd[1] = R300_VC_NO_SWAP;
+#else
+ r300->hw.vap_cntl_status.cmd[1] = R300_VC_32BIT_SWAP;
+#endif
/* disable VAP/TCL on non-TCL capable chips */
if (!has_tcl)
@@ -2081,16 +1858,20 @@ void r300ResetHwState(r300ContextPtr r300)
r300->hw.unk221C.cmd[1] = R300_221C_NORMAL;
- r300->hw.unk2220.cmd[1] = r300PackFloat32(1.0);
- r300->hw.unk2220.cmd[2] = r300PackFloat32(1.0);
- r300->hw.unk2220.cmd[3] = r300PackFloat32(1.0);
- r300->hw.unk2220.cmd[4] = r300PackFloat32(1.0);
+ r300->hw.vap_clip.cmd[1] = r300PackFloat32(1.0); /* X */
+ r300->hw.vap_clip.cmd[2] = r300PackFloat32(1.0); /* X */
+ r300->hw.vap_clip.cmd[3] = r300PackFloat32(1.0); /* Y */
+ r300->hw.vap_clip.cmd[4] = r300PackFloat32(1.0); /* Y */
- /* what about other chips than r300 or rv350??? */
- if (r300->radeon.radeonScreen->chip_family == CHIP_FAMILY_R300)
+ /* XXX: Other families? */
+ switch (r300->radeon.radeonScreen->chip_family) {
+ case CHIP_FAMILY_R300:
r300->hw.unk2288.cmd[1] = R300_2288_R300;
- else
+ break;
+ default:
r300->hw.unk2288.cmd[1] = R300_2288_RV350;
+ break;
+ }
r300->hw.gb_enable.cmd[1] = R300_GB_POINT_STUFF_ENABLE
| R300_GB_LINE_STUFF_ENABLE
@@ -2098,26 +1879,35 @@ void r300ResetHwState(r300ContextPtr r300)
r300->hw.gb_misc.cmd[R300_GB_MISC_MSPOS_0] = 0x66666666;
r300->hw.gb_misc.cmd[R300_GB_MISC_MSPOS_1] = 0x06666666;
- if ((r300->radeon.radeonScreen->chip_family == CHIP_FAMILY_R300) ||
- (r300->radeon.radeonScreen->chip_family == CHIP_FAMILY_R350))
- r300->hw.gb_misc.cmd[R300_GB_MISC_TILE_CONFIG] =
- R300_GB_TILE_ENABLE | R300_GB_TILE_PIPE_COUNT_R300 |
- R300_GB_TILE_SIZE_16;
- else if (r300->radeon.radeonScreen->chip_family == CHIP_FAMILY_RV410)
- r300->hw.gb_misc.cmd[R300_GB_MISC_TILE_CONFIG] =
- R300_GB_TILE_ENABLE | R300_GB_TILE_PIPE_COUNT_RV410 |
- R300_GB_TILE_SIZE_16;
- else if (r300->radeon.radeonScreen->chip_family == CHIP_FAMILY_R420)
- r300->hw.gb_misc.cmd[R300_GB_MISC_TILE_CONFIG] =
- R300_GB_TILE_ENABLE | R300_GB_TILE_PIPE_COUNT_R420 |
- R300_GB_TILE_SIZE_16;
- else
- r300->hw.gb_misc.cmd[R300_GB_MISC_TILE_CONFIG] =
- R300_GB_TILE_ENABLE | R300_GB_TILE_PIPE_COUNT_RV300 |
- R300_GB_TILE_SIZE_16;
- /* set to 0 when fog is disabled? */
+
+ /* XXX: Other families? */
+ r300->hw.gb_misc.cmd[R300_GB_MISC_TILE_CONFIG] =
+ R300_GB_TILE_ENABLE | R300_GB_TILE_SIZE_16;
+ switch (r300->radeon.radeonScreen->chip_family) {
+ case CHIP_FAMILY_R300:
+ case CHIP_FAMILY_R350:
+ r300->hw.gb_misc.cmd[R300_GB_MISC_TILE_CONFIG] |=
+ R300_GB_TILE_PIPE_COUNT_R300;
+ break;
+ case CHIP_FAMILY_RV410:
+ r300->hw.gb_misc.cmd[R300_GB_MISC_TILE_CONFIG] |=
+ R300_GB_TILE_PIPE_COUNT_RV410;
+ break;
+ case CHIP_FAMILY_R420:
+ r300->hw.gb_misc.cmd[R300_GB_MISC_TILE_CONFIG] |=
+ R300_GB_TILE_PIPE_COUNT_R420;
+ break;
+ default:
+ r300->hw.gb_misc.cmd[R300_GB_MISC_TILE_CONFIG] |=
+ R300_GB_TILE_PIPE_COUNT_RV300;
+ break;
+ }
+
+ /* XXX: set to 0 when fog is disabled? */
r300->hw.gb_misc.cmd[R300_GB_MISC_SELECT] = R300_GB_FOG_SELECT_1_1_W;
- r300->hw.gb_misc.cmd[R300_GB_MISC_AA_CONFIG] = R300_AA_DISABLE; /* No antialiasing */
+
+ /* XXX: Enable anti-aliasing? */
+ r300->hw.gb_misc.cmd[R300_GB_MISC_AA_CONFIG] = R300_AA_DISABLE;
r300->hw.unk4200.cmd[1] = r300PackFloat32(0.0);
r300->hw.unk4200.cmd[2] = r300PackFloat32(0.0);
@@ -2126,13 +1916,13 @@ void r300ResetHwState(r300ContextPtr r300)
r300->hw.unk4214.cmd[1] = 0x00050005;
- r300PointSize(ctx, 0.0);
+ r300PointSize(ctx, 1.0);
r300->hw.unk4230.cmd[1] = 0x18000006;
r300->hw.unk4230.cmd[2] = 0x00020006;
r300->hw.unk4230.cmd[3] = r300PackFloat32(1.0 / 192.0);
- r300LineWidth(ctx, 0.0);
+ r300LineWidth(ctx, 1.0);
r300->hw.unk4260.cmd[1] = 0;
r300->hw.unk4260.cmd[2] = r300PackFloat32(0.0);
@@ -2168,12 +1958,12 @@ void r300ResetHwState(r300ContextPtr r300)
r300->hw.unk46A4.cmd[5] = 0x00000001;
r300Enable(ctx, GL_FOG, ctx->Fog.Enabled);
- ctx->Driver.Fogfv(ctx, GL_FOG_MODE, NULL);
- ctx->Driver.Fogfv(ctx, GL_FOG_DENSITY, &ctx->Fog.Density);
- ctx->Driver.Fogfv(ctx, GL_FOG_START, &ctx->Fog.Start);
- ctx->Driver.Fogfv(ctx, GL_FOG_END, &ctx->Fog.End);
- ctx->Driver.Fogfv(ctx, GL_FOG_COLOR, ctx->Fog.Color);
- ctx->Driver.Fogfv(ctx, GL_FOG_COORDINATE_SOURCE_EXT, NULL);
+ r300Fogfv(ctx, GL_FOG_MODE, NULL);
+ r300Fogfv(ctx, GL_FOG_DENSITY, &ctx->Fog.Density);
+ r300Fogfv(ctx, GL_FOG_START, &ctx->Fog.Start);
+ r300Fogfv(ctx, GL_FOG_END, &ctx->Fog.End);
+ r300Fogfv(ctx, GL_FOG_COLOR, ctx->Fog.Color);
+ r300Fogfv(ctx, GL_FOG_COORDINATE_SOURCE_EXT, NULL);
r300->hw.at.cmd[R300_AT_UNKNOWN] = 0;
r300->hw.unk4BD8.cmd[1] = 0;
@@ -2238,7 +2028,7 @@ void r300ResetHwState(r300ContextPtr r300)
r300->hw.zb.cmd[R300_ZB_PITCH] = r300->radeon.radeonScreen->depthPitch;
if (r300->radeon.sarea->tiling_enabled) {
- /* Turn off when clearing buffers ? */
+ /* XXX: Turn off when clearing buffers ? */
r300->hw.zb.cmd[R300_ZB_PITCH] |= R300_DEPTH_TILE_ENABLE;
if (ctx->Visual.depthBits == 24)
@@ -2261,10 +2051,163 @@ void r300ResetHwState(r300ContextPtr r300)
r300->hw.vps.cmd[R300_VPS_POINTSIZE] = r300PackFloat32(1.0);
r300->hw.vps.cmd[R300_VPS_ZERO_3] = 0;
}
-//END: TODO
+
r300->hw.all_dirty = GL_TRUE;
}
+void r300UpdateShaders(r300ContextPtr rmesa)
+{
+ GLcontext *ctx;
+ struct r300_vertex_program *vp;
+ int i;
+
+ ctx = rmesa->radeon.glCtx;
+
+ if (rmesa->NewGLState && hw_tcl_on) {
+ rmesa->NewGLState = 0;
+
+ for (i = _TNL_FIRST_MAT; i <= _TNL_LAST_MAT; i++) {
+ rmesa->temp_attrib[i] =
+ TNL_CONTEXT(ctx)->vb.AttribPtr[i];
+ TNL_CONTEXT(ctx)->vb.AttribPtr[i] =
+ &rmesa->dummy_attrib[i];
+ }
+
+ _tnl_UpdateFixedFunctionProgram(ctx);
+
+ for (i = _TNL_FIRST_MAT; i <= _TNL_LAST_MAT; i++) {
+ TNL_CONTEXT(ctx)->vb.AttribPtr[i] =
+ rmesa->temp_attrib[i];
+ }
+
+ r300SelectVertexShader(rmesa);
+ vp = (struct r300_vertex_program *)
+ CURRENT_VERTEX_SHADER(ctx);
+ /*if (vp->translated == GL_FALSE)
+ r300TranslateVertexShader(vp); */
+ if (vp->translated == GL_FALSE) {
+ fprintf(stderr, "Failing back to sw-tcl\n");
+ hw_tcl_on = future_hw_tcl_on = 0;
+ r300ResetHwState(rmesa);
+
+ return;
+ }
+ r300UpdateStateParameters(ctx, _NEW_PROGRAM);
+ }
+
+}
+
+static void r300SetupPixelShader(r300ContextPtr rmesa)
+{
+ GLcontext *ctx = rmesa->radeon.glCtx;
+ struct r300_fragment_program *fp = (struct r300_fragment_program *)
+ (char *)ctx->FragmentProgram._Current;
+ int i, k;
+
+ if (!fp) /* should only happenen once, just after context is created */
+ return;
+
+ r300TranslateFragmentShader(rmesa, fp);
+ if (!fp->translated) {
+ fprintf(stderr, "%s: No valid fragment shader, exiting\n",
+ __FUNCTION__);
+ return;
+ }
+#define OUTPUT_FIELD(st, reg, field) \
+ R300_STATECHANGE(rmesa, st); \
+ for(i=0;i<=fp->alu_end;i++) \
+ rmesa->hw.st.cmd[R300_FPI_INSTR_0+i]=fp->alu.inst[i].field;\
+ rmesa->hw.st.cmd[R300_FPI_CMD_0]=cmdpacket0(reg, fp->alu_end+1);
+
+ OUTPUT_FIELD(fpi[0], R300_PFS_INSTR0_0, inst0);
+ OUTPUT_FIELD(fpi[1], R300_PFS_INSTR1_0, inst1);
+ OUTPUT_FIELD(fpi[2], R300_PFS_INSTR2_0, inst2);
+ OUTPUT_FIELD(fpi[3], R300_PFS_INSTR3_0, inst3);
+#undef OUTPUT_FIELD
+
+ R300_STATECHANGE(rmesa, fp);
+ /* I just want to say, the way these nodes are stored.. weird.. */
+ for (i = 0, k = (4 - (fp->cur_node + 1)); i < 4; i++, k++) {
+ if (i < (fp->cur_node + 1)) {
+ rmesa->hw.fp.cmd[R300_FP_NODE0 + k] =
+ (fp->node[i].
+ alu_offset << R300_PFS_NODE_ALU_OFFSET_SHIFT)
+ | (fp->node[i].
+ alu_end << R300_PFS_NODE_ALU_END_SHIFT)
+ | (fp->node[i].
+ tex_offset << R300_PFS_NODE_TEX_OFFSET_SHIFT)
+ | (fp->node[i].
+ tex_end << R300_PFS_NODE_TEX_END_SHIFT)
+ | fp->node[i].flags;
+ } else {
+ rmesa->hw.fp.cmd[R300_FP_NODE0 + (3 - i)] = 0;
+ }
+ }
+
+ /* PFS_CNTL_0 */
+ rmesa->hw.fp.cmd[R300_FP_CNTL0] =
+ fp->cur_node | (fp->first_node_has_tex << 3);
+ /* PFS_CNTL_1 */
+ rmesa->hw.fp.cmd[R300_FP_CNTL1] = fp->max_temp_idx;
+ /* PFS_CNTL_2 */
+ rmesa->hw.fp.cmd[R300_FP_CNTL2] =
+ (fp->alu_offset << R300_PFS_CNTL_ALU_OFFSET_SHIFT)
+ | (fp->alu_end << R300_PFS_CNTL_ALU_END_SHIFT)
+ | (fp->tex_offset << R300_PFS_CNTL_TEX_OFFSET_SHIFT)
+ | (fp->tex_end << R300_PFS_CNTL_TEX_END_SHIFT);
+
+ R300_STATECHANGE(rmesa, fpp);
+ for (i = 0; i < fp->const_nr; i++) {
+ rmesa->hw.fpp.cmd[R300_FPP_PARAM_0 + 4 * i + 0] =
+ r300PackFloat24(fp->constant[i][0]);
+ rmesa->hw.fpp.cmd[R300_FPP_PARAM_0 + 4 * i + 1] =
+ r300PackFloat24(fp->constant[i][1]);
+ rmesa->hw.fpp.cmd[R300_FPP_PARAM_0 + 4 * i + 2] =
+ r300PackFloat24(fp->constant[i][2]);
+ rmesa->hw.fpp.cmd[R300_FPP_PARAM_0 + 4 * i + 3] =
+ r300PackFloat24(fp->constant[i][3]);
+ }
+ rmesa->hw.fpp.cmd[R300_FPP_CMD_0] =
+ cmdpacket0(R300_PFS_PARAM_0_X, fp->const_nr * 4);
+}
+
+void r300UpdateShaderStates(r300ContextPtr rmesa)
+{
+ GLcontext *ctx;
+ ctx = rmesa->radeon.glCtx;
+
+ r300UpdateTextureState(ctx);
+
+ r300SetupPixelShader(rmesa);
+ r300SetupTextures(ctx);
+
+ if ((rmesa->radeon.radeonScreen->chip_flags & RADEON_CHIPSET_TCL))
+ r300SetupVertexShader(rmesa);
+ r300SetupRSUnit(ctx);
+}
+
+/**
+ * Called by Mesa after an internal state update.
+ */
+static void r300InvalidateState(GLcontext * ctx, GLuint new_state)
+{
+ r300ContextPtr r300 = R300_CONTEXT(ctx);
+
+ _swrast_InvalidateState(ctx, new_state);
+ _swsetup_InvalidateState(ctx, new_state);
+ _vbo_InvalidateState(ctx, new_state);
+ _tnl_InvalidateState(ctx, new_state);
+ _ae_invalidate_state(ctx, new_state);
+
+ if (new_state & (_NEW_BUFFERS | _NEW_COLOR | _NEW_PIXEL)) {
+ r300UpdateDrawBuffer(ctx);
+ }
+
+ r300UpdateStateParameters(ctx, new_state);
+
+ r300->NewGLState |= new_state;
+}
+
/**
* Calculate initial hardware state and register state functions.
* Assumes that the command buffer and state atoms have been
diff --git a/src/mesa/drivers/dri/r300/r300_state.h b/src/mesa/drivers/dri/r300/r300_state.h
index 3b9d8e74041..21a49b7f361 100644
--- a/src/mesa/drivers/dri/r300/r300_state.h
+++ b/src/mesa/drivers/dri/r300/r300_state.h
@@ -58,21 +58,13 @@ do { \
\
} while (0)
-extern void r300ResetHwState(r300ContextPtr r300);
-
extern void r300UpdateStateParameters(GLcontext * ctx, GLuint new_state);
extern void r300InitState(r300ContextPtr r300);
extern void r300InitStateFuncs(struct dd_function_table *functions);
extern void r300UpdateViewportOffset(GLcontext * ctx);
-extern void r300UpdateWindow(GLcontext * ctx);
extern void r300UpdateDrawBuffer(GLcontext * ctx);
-extern void r300SetupVertexShader(r300ContextPtr rmesa);
-extern void r300SetupPixelShader(r300ContextPtr rmesa);
extern void r300UpdateShaders(r300ContextPtr rmesa);
extern void r300UpdateShaderStates(r300ContextPtr rmesa);
-extern void r300PrintStateAtom(r300ContextPtr r300,
- struct r300_state_atom *state);
-
#endif /* __R300_STATE_H__ */
diff --git a/src/mesa/drivers/dri/r300/r300_tex.c b/src/mesa/drivers/dri/r300/r300_tex.c
index d78e3dfb23e..1805cecd0af 100644
--- a/src/mesa/drivers/dri/r300/r300_tex.c
+++ b/src/mesa/drivers/dri/r300/r300_tex.c
@@ -48,7 +48,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "r300_context.h"
#include "r300_state.h"
#include "r300_ioctl.h"
-//#include "r300_swtcl.h"
#include "r300_tex.h"
#include "xmlpool.h"
@@ -295,27 +294,20 @@ static const struct gl_texture_format *r300Choose8888TexFormat(GLenum srcFormat,
const GLubyte littleEndian = *((const GLubyte *)&ui);
if ((srcFormat == GL_RGBA && srcType == GL_UNSIGNED_INT_8_8_8_8) ||
- (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE
- && !littleEndian) || (srcFormat == GL_ABGR_EXT
- && srcType == GL_UNSIGNED_INT_8_8_8_8_REV)
- || (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_BYTE
- && littleEndian)) {
+ (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE && !littleEndian) ||
+ (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_INT_8_8_8_8_REV) ||
+ (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_BYTE && littleEndian)) {
return &_mesa_texformat_rgba8888;
- } else
- if ((srcFormat == GL_RGBA && srcType == GL_UNSIGNED_INT_8_8_8_8_REV)
- || (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE
- && littleEndian) || (srcFormat == GL_ABGR_EXT
- && srcType == GL_UNSIGNED_INT_8_8_8_8)
- || (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_BYTE
- && !littleEndian)) {
+ } else if ((srcFormat == GL_RGBA && srcType == GL_UNSIGNED_INT_8_8_8_8_REV) ||
+ (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE && littleEndian) ||
+ (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_INT_8_8_8_8) ||
+ (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_BYTE && !littleEndian)) {
return &_mesa_texformat_rgba8888_rev;
- } else if (srcFormat == GL_BGRA &&
- ((srcType == GL_UNSIGNED_BYTE && !littleEndian) ||
- srcType == GL_UNSIGNED_INT_8_8_8_8)) {
+ } else if (srcFormat == GL_BGRA && ((srcType == GL_UNSIGNED_BYTE && !littleEndian) ||
+ srcType == GL_UNSIGNED_INT_8_8_8_8)) {
return &_mesa_texformat_argb8888_rev;
- } else if (srcFormat == GL_BGRA &&
- ((srcType == GL_UNSIGNED_BYTE && littleEndian) ||
- srcType == GL_UNSIGNED_INT_8_8_8_8_REV)) {
+ } else if (srcFormat == GL_BGRA && ((srcType == GL_UNSIGNED_BYTE && littleEndian) ||
+ srcType == GL_UNSIGNED_INT_8_8_8_8_REV)) {
return &_mesa_texformat_argb8888;
} else
return _dri_texformat_argb8888;
@@ -564,34 +556,31 @@ r300ValidateClientStorage(GLcontext * ctx, GLenum target,
return 0;
}
- {
- GLint srcRowStride = _mesa_image_row_stride(packing, srcWidth,
- format, type);
+ GLint srcRowStride = _mesa_image_row_stride(packing, srcWidth,
+ format, type);
- if (RADEON_DEBUG & DEBUG_TEXTURE)
- fprintf(stderr, "%s: srcRowStride %d/%x\n",
- __FUNCTION__, srcRowStride, srcRowStride);
+ if (RADEON_DEBUG & DEBUG_TEXTURE)
+ fprintf(stderr, "%s: srcRowStride %d/%x\n",
+ __FUNCTION__, srcRowStride, srcRowStride);
- /* Could check this later in upload, pitch restrictions could be
- * relaxed, but would need to store the image pitch somewhere,
- * as packing details might change before image is uploaded:
- */
- if (!r300IsGartMemory(rmesa, pixels, srcHeight * srcRowStride)
- || (srcRowStride & 63))
- return 0;
+ /* Could check this later in upload, pitch restrictions could be
+ * relaxed, but would need to store the image pitch somewhere,
+ * as packing details might change before image is uploaded:
+ */
+ if (!r300IsGartMemory(rmesa, pixels, srcHeight * srcRowStride)
+ || (srcRowStride & 63))
+ return 0;
- /* Have validated that _mesa_transfer_teximage would be a straight
- * memcpy at this point. NOTE: future calls to TexSubImage will
- * overwrite the client data. This is explicitly mentioned in the
- * extension spec.
- */
- texImage->Data = (void *)pixels;
- texImage->IsClientData = GL_TRUE;
- texImage->RowStride =
- srcRowStride / texImage->TexFormat->TexelBytes;
+ /* Have validated that _mesa_transfer_teximage would be a straight
+ * memcpy at this point. NOTE: future calls to TexSubImage will
+ * overwrite the client data. This is explicitly mentioned in the
+ * extension spec.
+ */
+ texImage->Data = (void *)pixels;
+ texImage->IsClientData = GL_TRUE;
+ texImage->RowStride = srcRowStride / texImage->TexFormat->TexelBytes;
- return 1;
- }
+ return 1;
}
static void r300TexImage1D(GLcontext * ctx, GLenum target, GLint level,
@@ -801,16 +790,20 @@ static void r300CompressedTexImage2D(GLcontext * ctx, GLenum target,
}
texImage->IsClientData = GL_FALSE;
-/* can't call this, different parameters. Would never evaluate to true anyway currently
- if (r300ValidateClientStorage( ctx, target,
- internalFormat,
- width, height,
- format, type, pixels,
- packing, texObj, texImage)) {
- if (RADEON_DEBUG & DEBUG_TEXTURE)
- fprintf(stderr, "%s: Using client storage\n", __FUNCTION__);
- }
- else */ {
+
+ /* can't call this, different parameters. Would never evaluate to true anyway currently */
+#if 0
+ if (r300ValidateClientStorage(ctx, target,
+ internalFormat,
+ width, height,
+ format, type, pixels,
+ packing, texObj, texImage)) {
+ if (RADEON_DEBUG & DEBUG_TEXTURE)
+ fprintf(stderr, "%s: Using client storage\n",
+ __FUNCTION__);
+ } else
+#endif
+ {
if (RADEON_DEBUG & DEBUG_TEXTURE)
fprintf(stderr, "%s: Using normal storage\n",
__FUNCTION__);
@@ -876,7 +869,6 @@ static void r300CompressedTexSubImage2D(GLcontext * ctx, GLenum target,
t->dirty_images[face] |= (1 << level);
}
-#if ENABLE_HW_3D_TEXTURE
static void r300TexImage3D(GLcontext * ctx, GLenum target, GLint level,
GLint internalFormat,
GLint width, GLint height, GLint depth,
@@ -930,9 +922,7 @@ static void r300TexImage3D(GLcontext * ctx, GLenum target, GLint level,
t->dirty_images[0] |= (1 << level);
}
}
-#endif
-#if ENABLE_HW_3D_TEXTURE
static void
r300TexSubImage3D(GLcontext * ctx, GLenum target, GLint level,
GLint xoffset, GLint yoffset, GLint zoffset,
@@ -966,7 +956,6 @@ r300TexSubImage3D(GLcontext * ctx, GLenum target, GLint level,
t->dirty_images[0] |= (1 << level);
}
-#endif
static void r300TexEnv(GLcontext * ctx, GLenum target,
GLenum pname, const GLfloat * param)
@@ -1087,9 +1076,7 @@ static void r300BindTexture(GLcontext * ctx, GLenum target,
if ((target == GL_TEXTURE_1D)
|| (target == GL_TEXTURE_2D)
-#if ENABLE_HW_3D_TEXTURE
|| (target == GL_TEXTURE_3D)
-#endif
|| (target == GL_TEXTURE_CUBE_MAP)
|| (target == GL_TEXTURE_RECTANGLE_NV)) {
assert(texObj->DriverData != NULL);
@@ -1150,18 +1137,10 @@ void r300InitTextureFuncs(struct dd_function_table *functions)
functions->ChooseTextureFormat = r300ChooseTextureFormat;
functions->TexImage1D = r300TexImage1D;
functions->TexImage2D = r300TexImage2D;
-#if ENABLE_HW_3D_TEXTURE
functions->TexImage3D = r300TexImage3D;
-#else
- functions->TexImage3D = _mesa_store_teximage3d;
-#endif
functions->TexSubImage1D = r300TexSubImage1D;
functions->TexSubImage2D = r300TexSubImage2D;
-#if ENABLE_HW_3D_TEXTURE
functions->TexSubImage3D = r300TexSubImage3D;
-#else
- functions->TexSubImage3D = _mesa_store_texsubimage3d;
-#endif
functions->NewTextureObject = r300NewTextureObject;
functions->BindTexture = r300BindTexture;
functions->DeleteTexture = r300DeleteTexture;
diff --git a/src/mesa/drivers/dri/r300/r300_tex.h b/src/mesa/drivers/dri/r300/r300_tex.h
index 74fa08e97d9..f67a8e6ba65 100644
--- a/src/mesa/drivers/dri/r300/r300_tex.h
+++ b/src/mesa/drivers/dri/r300/r300_tex.h
@@ -35,6 +35,10 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#ifndef __r300_TEX_H__
#define __r300_TEX_H__
+extern void r300SetTexOffset(__DRIcontext *pDRICtx, GLint texname,
+ unsigned long long offset, GLint depth,
+ GLuint pitch);
+
extern void r300UpdateTextureState(GLcontext * ctx);
extern int r300UploadTexImages(r300ContextPtr rmesa, r300TexObjPtr t,
diff --git a/src/mesa/drivers/dri/r300/r300_texmem.c b/src/mesa/drivers/dri/r300/r300_texmem.c
index db80325309a..38f0da8b7c0 100644
--- a/src/mesa/drivers/dri/r300/r300_texmem.c
+++ b/src/mesa/drivers/dri/r300/r300_texmem.c
@@ -49,9 +49,6 @@ SOFTWARE.
#include "r300_state.h"
#include "r300_cmdbuf.h"
#include "radeon_ioctl.h"
-/*
-#include "r300_swtcl.h"
-*/
#include "r300_tex.h"
#include "r300_ioctl.h"
#include <unistd.h> /* for usleep() */
@@ -66,29 +63,16 @@ SOFTWARE.
*/
void r300DestroyTexObj(r300ContextPtr rmesa, r300TexObjPtr t)
{
+ int i;
+
if (RADEON_DEBUG & DEBUG_TEXTURE) {
fprintf(stderr, "%s( %p, %p )\n", __FUNCTION__,
(void *)t, (void *)t->base.tObj);
}
- if (rmesa != NULL) {
- unsigned i;
-
- for (i = 0; i < rmesa->radeon.glCtx->Const.MaxTextureUnits; i++) {
- if (t == rmesa->state.texture.unit[i].texobj) {
- rmesa->state.texture.unit[i].texobj = NULL;
- /* This code below is meant to shorten state
- pushed to the hardware by not programming
- unneeded units.
-
- This does not appear to be worthwhile on R300 */
-#if 0
- remove_from_list(&rmesa->hw.tex[i]);
- make_empty_list(&rmesa->hw.tex[i]);
- remove_from_list(&rmesa->hw.cube[i]);
- make_empty_list(&rmesa->hw.cube[i]);
-#endif
- }
+ for (i = 0; i < rmesa->radeon.glCtx->Const.MaxTextureUnits; i++) {
+ if (rmesa->state.texture.unit[i].texobj == t) {
+ rmesa->state.texture.unit[i].texobj = NULL;
}
}
}
@@ -299,10 +283,10 @@ static void r300UploadRectSubImage(r300ContextPtr rmesa,
* Upload the texture image associated with texture \a t at the specified
* level at the address relative to \a start.
*/
-static void uploadSubImage(r300ContextPtr rmesa, r300TexObjPtr t,
- GLint hwlevel,
- GLint x, GLint y, GLint width, GLint height,
- GLuint face)
+static void r300UploadSubImage(r300ContextPtr rmesa, r300TexObjPtr t,
+ GLint hwlevel,
+ GLint x, GLint y, GLint width, GLint height,
+ GLuint face)
{
struct gl_texture_image *texImage = NULL;
GLuint offset;
@@ -511,6 +495,9 @@ int r300UploadTexImages(r300ContextPtr rmesa, r300TexObjPtr t, GLuint face)
{
const int numLevels = t->base.lastLevel - t->base.firstLevel + 1;
+ if (t->image_override)
+ return 0;
+
if (RADEON_DEBUG & (DEBUG_TEXTURE | DEBUG_IOCTL)) {
fprintf(stderr, "%s( %p, %p ) sz=%d lvls=%d-%d\n", __FUNCTION__,
(void *)rmesa->radeon.glCtx, (void *)t->base.tObj,
@@ -566,9 +553,10 @@ int r300UploadTexImages(r300ContextPtr rmesa, r300TexObjPtr t, GLuint face)
dirty_images[face] & (1 <<
(i + t->base.firstLevel))) !=
0) {
- uploadSubImage(rmesa, t, i, 0, 0,
- t->image[face][i].width,
- t->image[face][i].height, face);
+ r300UploadSubImage(rmesa, t, i, 0, 0,
+ t->image[face][i].width,
+ t->image[face][i].height,
+ face);
}
}
t->base.dirty_images[face] = 0;
diff --git a/src/mesa/drivers/dri/r300/r300_texstate.c b/src/mesa/drivers/dri/r300/r300_texstate.c
index 35f96ce8d6f..1d2909fd214 100644
--- a/src/mesa/drivers/dri/r300/r300_texstate.c
+++ b/src/mesa/drivers/dri/r300/r300_texstate.c
@@ -31,6 +31,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* \file
*
* \author Keith Whitwell <[email protected]>
+ *
+ * \todo Enable R300 texture tiling code?
*/
#include "glheader.h"
@@ -38,6 +40,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "context.h"
#include "macros.h"
#include "texformat.h"
+#include "teximage.h"
+#include "texobj.h"
#include "enums.h"
#include "r300_context.h"
@@ -50,7 +54,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define VALID_FORMAT(f) ( ((f) <= MESA_FORMAT_RGBA_DXT5 \
|| ((f) >= MESA_FORMAT_RGBA_FLOAT32 && \
(f) <= MESA_FORMAT_INTENSITY_FLOAT16)) \
- && tx_table_le[f].flag )
+ && tx_table[f].flag )
#define _ASSIGN(entry, format) \
[ MESA_FORMAT_ ## entry ] = { format, 0, 1}
@@ -64,58 +68,22 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* identically. -- paulus
*/
-static const struct {
+static const struct tx_table {
GLuint format, filter, flag;
-} tx_table_be[] = {
- /* *INDENT-OFF* */
- _ASSIGN(RGBA8888, R300_EASY_TX_FORMAT(Z, Y, X, W, W8Z8Y8X8)),
- _ASSIGN(RGBA8888_REV, R300_EASY_TX_FORMAT(Y, Z, W, X, W8Z8Y8X8)),
- _ASSIGN(ARGB8888, R300_EASY_TX_FORMAT(W, Z, Y, X, W8Z8Y8X8)),
- _ASSIGN(ARGB8888_REV, R300_EASY_TX_FORMAT(X, Y, Z, W, W8Z8Y8X8)),
- _ASSIGN(RGB888, 0xffffffff),
- _ASSIGN(RGB565, R300_EASY_TX_FORMAT(X, Y, Z, ONE, Z5Y6X5)),
- _ASSIGN(RGB565_REV, R300_EASY_TX_FORMAT(X, Y, Z, ONE, Z5Y6X5)),
- _ASSIGN(ARGB4444, R300_EASY_TX_FORMAT(X, Y, Z, W, W4Z4Y4X4)),
- _ASSIGN(ARGB4444_REV, R300_EASY_TX_FORMAT(X, Y, Z, W, W4Z4Y4X4)),
- _ASSIGN(ARGB1555, R300_EASY_TX_FORMAT(X, Y, Z, W, W1Z5Y5X5)),
- _ASSIGN(ARGB1555_REV, R300_EASY_TX_FORMAT(X, Y, Z, W, W1Z5Y5X5)),
- _ASSIGN(AL88, R300_EASY_TX_FORMAT(X, X, X, Y, Y8X8)),
- _ASSIGN(AL88_REV, R300_EASY_TX_FORMAT(X, X, X, Y, Y8X8)),
- _ASSIGN(RGB332, R300_EASY_TX_FORMAT(X, Y, Z, ONE, Z3Y3X2)),
- _ASSIGN(A8, R300_EASY_TX_FORMAT(ZERO, ZERO, ZERO, X, X8)),
- _ASSIGN(L8, R300_EASY_TX_FORMAT(X, X, X, ONE, X8)),
- _ASSIGN(I8, R300_EASY_TX_FORMAT(X, X, X, X, X8)),
- _ASSIGN(CI8, R300_EASY_TX_FORMAT(X, X, X, X, X8)),
- _ASSIGN(YCBCR, R300_EASY_TX_FORMAT(X, Y, Z, ONE, G8R8_G8B8)|R300_TX_FORMAT_YUV_MODE ),
- _ASSIGN(YCBCR_REV, R300_EASY_TX_FORMAT(X, Y, Z, ONE, G8R8_G8B8)|R300_TX_FORMAT_YUV_MODE),
- _ASSIGN(RGB_DXT1, R300_EASY_TX_FORMAT(X, Y, Z, ONE, DXT1)),
- _ASSIGN(RGBA_DXT1, R300_EASY_TX_FORMAT(X, Y, Z, W, DXT1)),
- _ASSIGN(RGBA_DXT3, R300_EASY_TX_FORMAT(X, Y, Z, W, DXT3)),
- _ASSIGN(RGBA_DXT5, R300_EASY_TX_FORMAT(Y, Z, W, X, DXT5)),
- _ASSIGN(RGBA_FLOAT32, R300_EASY_TX_FORMAT(Z, Y, X, W, FL_R32G32B32A32)),
- _ASSIGN(RGBA_FLOAT16, R300_EASY_TX_FORMAT(Z, Y, X, W, FL_R16G16B16A16)),
- _ASSIGN(RGB_FLOAT32, 0xffffffff),
- _ASSIGN(RGB_FLOAT16, 0xffffffff),
- _ASSIGN(ALPHA_FLOAT32, R300_EASY_TX_FORMAT(ZERO, ZERO, ZERO, X, FL_I32)),
- _ASSIGN(ALPHA_FLOAT16, R300_EASY_TX_FORMAT(ZERO, ZERO, ZERO, X, FL_I16)),
- _ASSIGN(LUMINANCE_FLOAT32, R300_EASY_TX_FORMAT(X, X, X, ONE, FL_I32)),
- _ASSIGN(LUMINANCE_FLOAT16, R300_EASY_TX_FORMAT(X, X, X, ONE, FL_I16)),
- _ASSIGN(LUMINANCE_ALPHA_FLOAT32, R300_EASY_TX_FORMAT(X, X, X, Y, FL_I32A32)),
- _ASSIGN(LUMINANCE_ALPHA_FLOAT16, R300_EASY_TX_FORMAT(X, X, X, Y, FL_I16A16)),
- _ASSIGN(INTENSITY_FLOAT32, R300_EASY_TX_FORMAT(X, X, X, X, FL_I32)),
- _ASSIGN(INTENSITY_FLOAT16, R300_EASY_TX_FORMAT(X, X, X, X, FL_I16)),
- /* *INDENT-ON* */
-};
-
-static const struct {
- GLuint format, filter, flag;
-} tx_table_le[] = {
+} tx_table[] = {
/* *INDENT-OFF* */
+#ifdef MESA_LITTLE_ENDIAN
_ASSIGN(RGBA8888, R300_EASY_TX_FORMAT(Y, Z, W, X, W8Z8Y8X8)),
_ASSIGN(RGBA8888_REV, R300_EASY_TX_FORMAT(Z, Y, X, W, W8Z8Y8X8)),
_ASSIGN(ARGB8888, R300_EASY_TX_FORMAT(X, Y, Z, W, W8Z8Y8X8)),
_ASSIGN(ARGB8888_REV, R300_EASY_TX_FORMAT(W, Z, Y, X, W8Z8Y8X8)),
- _ASSIGN(RGB888, 0xffffffff),
+#else
+ _ASSIGN(RGBA8888, R300_EASY_TX_FORMAT(Z, Y, X, W, W8Z8Y8X8)),
+ _ASSIGN(RGBA8888_REV, R300_EASY_TX_FORMAT(Y, Z, W, X, W8Z8Y8X8)),
+ _ASSIGN(ARGB8888, R300_EASY_TX_FORMAT(W, Z, Y, X, W8Z8Y8X8)),
+ _ASSIGN(ARGB8888_REV, R300_EASY_TX_FORMAT(X, Y, Z, W, W8Z8Y8X8)),
+#endif
+ _ASSIGN(RGB888, R300_EASY_TX_FORMAT(X, Y, Z, ONE, W8Z8Y8X8)),
_ASSIGN(RGB565, R300_EASY_TX_FORMAT(X, Y, Z, ONE, Z5Y6X5)),
_ASSIGN(RGB565_REV, R300_EASY_TX_FORMAT(X, Y, Z, ONE, Z5Y6X5)),
_ASSIGN(ARGB4444, R300_EASY_TX_FORMAT(X, Y, Z, W, W4Z4Y4X4)),
@@ -129,8 +97,8 @@ static const struct {
_ASSIGN(L8, R300_EASY_TX_FORMAT(X, X, X, ONE, X8)),
_ASSIGN(I8, R300_EASY_TX_FORMAT(X, X, X, X, X8)),
_ASSIGN(CI8, R300_EASY_TX_FORMAT(X, X, X, X, X8)),
- _ASSIGN(YCBCR, R300_EASY_TX_FORMAT(X, Y, Z, ONE, G8R8_G8B8)|R300_TX_FORMAT_YUV_MODE ),
- _ASSIGN(YCBCR_REV, R300_EASY_TX_FORMAT(X, Y, Z, ONE, G8R8_G8B8)|R300_TX_FORMAT_YUV_MODE),
+ _ASSIGN(YCBCR, R300_EASY_TX_FORMAT(X, Y, Z, ONE, G8R8_G8B8) | R300_TX_FORMAT_YUV_MODE),
+ _ASSIGN(YCBCR_REV, R300_EASY_TX_FORMAT(X, Y, Z, ONE, G8R8_G8B8) | R300_TX_FORMAT_YUV_MODE),
_ASSIGN(RGB_DXT1, R300_EASY_TX_FORMAT(X, Y, Z, ONE, DXT1)),
_ASSIGN(RGBA_DXT1, R300_EASY_TX_FORMAT(X, Y, Z, W, DXT1)),
_ASSIGN(RGBA_DXT3, R300_EASY_TX_FORMAT(X, Y, Z, W, DXT3)),
@@ -176,23 +144,11 @@ static void r300SetTexImages(r300ContextPtr rmesa,
/* Set the hardware texture format
*/
- if (VALID_FORMAT(baseImage->TexFormat->MesaFormat)) {
- if (_mesa_little_endian()) {
- t->format =
- tx_table_le[baseImage->TexFormat->MesaFormat].
- format;
- t->filter |=
- tx_table_le[baseImage->TexFormat->MesaFormat].
- filter;
- } else {
- t->format =
- tx_table_be[baseImage->TexFormat->MesaFormat].
- format;
- t->filter |=
- tx_table_be[baseImage->TexFormat->MesaFormat].
- filter;
- }
- } else {
+ if (!t->image_override
+ && VALID_FORMAT(baseImage->TexFormat->MesaFormat)) {
+ t->format = tx_table[baseImage->TexFormat->MesaFormat].format;
+ t->filter |= tx_table[baseImage->TexFormat->MesaFormat].filter;
+ } else if (!t->image_override) {
_mesa_problem(NULL, "unexpected texture format in %s",
__FUNCTION__);
return;
@@ -380,9 +336,10 @@ static void r300SetTexImages(r300ContextPtr rmesa,
t->pitch = ((tObj->Image[0][t->base.firstLevel]->Width *
texelBytes) + 63) & ~(63);
t->size |= R300_TX_SIZE_TXPITCH_EN;
- t->pitch_reg =
- (((tObj->Image[0][t->base.firstLevel]->Width) +
- align) & ~align) - 1;
+ if (!t->image_override)
+ t->pitch_reg =
+ (((tObj->Image[0][t->base.firstLevel]->Width) +
+ align) & ~align) - 1;
} else {
t->pitch =
((tObj->Image[0][t->base.firstLevel]->Width *
@@ -398,7 +355,7 @@ static void r300SetTexImages(r300ContextPtr rmesa,
* Texture unit state management
*/
-static GLboolean enable_tex_2d(GLcontext * ctx, int unit)
+static GLboolean r300EnableTexture2D(GLcontext * ctx, int unit)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
@@ -409,17 +366,17 @@ static GLboolean enable_tex_2d(GLcontext * ctx, int unit)
if (t->base.dirty_images[0]) {
R300_FIREVERTICES(rmesa);
+
r300SetTexImages(rmesa, tObj);
r300UploadTexImages(rmesa, (r300TexObjPtr) tObj->DriverData, 0);
- if (!t->base.memBlock)
+ if (!t->base.memBlock && !t->image_override)
return GL_FALSE;
}
return GL_TRUE;
}
-#if ENABLE_HW_3D_TEXTURE
-static GLboolean enable_tex_3d(GLcontext * ctx, int unit)
+static GLboolean r300EnableTexture3D(GLcontext * ctx, int unit)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
@@ -443,9 +400,8 @@ static GLboolean enable_tex_3d(GLcontext * ctx, int unit)
return GL_TRUE;
}
-#endif
-static GLboolean enable_tex_cube(GLcontext * ctx, int unit)
+static GLboolean r300EnableTextureCube(GLcontext * ctx, int unit)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
@@ -481,7 +437,7 @@ static GLboolean enable_tex_cube(GLcontext * ctx, int unit)
return GL_TRUE;
}
-static GLboolean enable_tex_rect(GLcontext * ctx, int unit)
+static GLboolean r300EnableTextureRect(GLcontext * ctx, int unit)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
@@ -492,16 +448,18 @@ static GLboolean enable_tex_rect(GLcontext * ctx, int unit)
if (t->base.dirty_images[0]) {
R300_FIREVERTICES(rmesa);
+
r300SetTexImages(rmesa, tObj);
r300UploadTexImages(rmesa, (r300TexObjPtr) tObj->DriverData, 0);
- if (!t->base.memBlock && !rmesa->prefer_gart_client_texturing)
+ if (!t->base.memBlock && !t->image_override &&
+ !rmesa->prefer_gart_client_texturing)
return GL_FALSE;
}
return GL_TRUE;
}
-static GLboolean update_tex_common(GLcontext * ctx, int unit)
+static GLboolean r300UpdateTexture(GLcontext * ctx, int unit)
{
r300ContextPtr rmesa = R300_CONTEXT(ctx);
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
@@ -522,11 +480,11 @@ static GLboolean update_tex_common(GLcontext * ctx, int unit)
*/
rmesa->state.texture.unit[unit].texobj->base.bound &=
- ~(1UL << unit);
+ ~(1 << unit);
}
rmesa->state.texture.unit[unit].texobj = t;
- t->base.bound |= (1UL << unit);
+ t->base.bound |= (1 << unit);
t->dirty_state |= 1 << unit;
driUpdateTextureLRU((driTextureObject *) t); /* XXX: should be locked! */
}
@@ -534,26 +492,67 @@ static GLboolean update_tex_common(GLcontext * ctx, int unit)
return !t->border_fallback;
}
+void r300SetTexOffset(__DRIcontext * pDRICtx, GLint texname,
+ unsigned long long offset, GLint depth, GLuint pitch)
+{
+ r300ContextPtr rmesa =
+ (r300ContextPtr) ((__DRIcontextPrivate *) pDRICtx->private)->
+ driverPrivate;
+ struct gl_texture_object *tObj =
+ _mesa_lookup_texture(rmesa->radeon.glCtx, texname);
+ r300TexObjPtr t;
+
+ if (!tObj)
+ return;
+
+ t = (r300TexObjPtr) tObj->DriverData;
+
+ t->image_override = GL_TRUE;
+
+ if (!offset)
+ return;
+
+ t->offset = offset;
+ t->pitch_reg = pitch;
+
+ switch (depth) {
+ case 32:
+ t->format = R300_EASY_TX_FORMAT(X, Y, Z, W, W8Z8Y8X8);
+ t->filter |= tx_table[2].filter;
+ t->pitch_reg /= 4;
+ break;
+ case 24:
+ default:
+ t->format = R300_EASY_TX_FORMAT(X, Y, Z, ONE, W8Z8Y8X8);
+ t->filter |= tx_table[4].filter;
+ t->pitch_reg /= 4;
+ break;
+ case 16:
+ t->format = R300_EASY_TX_FORMAT(X, Y, Z, ONE, Z5Y6X5);
+ t->filter |= tx_table[5].filter;
+ t->pitch_reg /= 2;
+ break;
+ }
+
+ t->pitch_reg--;
+}
+
static GLboolean r300UpdateTextureUnit(GLcontext * ctx, int unit)
{
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
if (texUnit->_ReallyEnabled & (TEXTURE_RECT_BIT)) {
- return (enable_tex_rect(ctx, unit) &&
- update_tex_common(ctx, unit));
+ return (r300EnableTextureRect(ctx, unit) &&
+ r300UpdateTexture(ctx, unit));
} else if (texUnit->_ReallyEnabled & (TEXTURE_1D_BIT | TEXTURE_2D_BIT)) {
- return (enable_tex_2d(ctx, unit) &&
- update_tex_common(ctx, unit));
- }
-#if ENABLE_HW_3D_TEXTURE
- else if (texUnit->_ReallyEnabled & (TEXTURE_3D_BIT)) {
- return (enable_tex_3d(ctx, unit) &&
- update_tex_common(ctx, unit));
- }
-#endif
- else if (texUnit->_ReallyEnabled & (TEXTURE_CUBE_BIT)) {
- return (enable_tex_cube(ctx, unit) &&
- update_tex_common(ctx, unit));
+ return (r300EnableTexture2D(ctx, unit) &&
+ r300UpdateTexture(ctx, unit));
+ } else if (texUnit->_ReallyEnabled & (TEXTURE_3D_BIT)) {
+ return (r300EnableTexture3D(ctx, unit) &&
+ r300UpdateTexture(ctx, unit));
+ } else if (texUnit->_ReallyEnabled & (TEXTURE_CUBE_BIT)) {
+ return (r300EnableTextureCube(ctx, unit) &&
+ r300UpdateTexture(ctx, unit));
} else if (texUnit->_ReallyEnabled) {
return GL_FALSE;
} else {
diff --git a/src/mesa/drivers/dri/r300/r300_vertprog.c b/src/mesa/drivers/dri/r300/r300_vertprog.c
index 1d90ade2ed1..16dddf6557d 100644
--- a/src/mesa/drivers/dri/r300/r300_vertprog.c
+++ b/src/mesa/drivers/dri/r300/r300_vertprog.c
@@ -222,7 +222,7 @@ static unsigned long t_src_class(enum register_file file)
}
}
-static __inline unsigned long t_swizzle(GLubyte swizzle)
+static inline unsigned long t_swizzle(GLubyte swizzle)
{
/* this is in fact a NOP as the Mesa SWIZZLE_* are all identical to VSF_IN_COMPONENT_* */
return swizzle;
diff --git a/src/mesa/drivers/dri/r300/radeon_lock.c b/src/mesa/drivers/dri/r300/radeon_lock.c
index 0d0d9ab7f06..bc3c2d6c6b3 100644
--- a/src/mesa/drivers/dri/r300/radeon_lock.c
+++ b/src/mesa/drivers/dri/r300/radeon_lock.c
@@ -1,10 +1,15 @@
-/*
+/**************************************************************************
+
+Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
+ VA Linux Systems Inc., Fremont, California.
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
The Weather Channel (TM) funded Tungsten Graphics to develop the
initial release of the Radeon 8500 driver under the XFree86 license.
This notice must be preserved.
+All Rights Reserved.
+
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
@@ -29,9 +34,10 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/*
* Authors:
+ * Gareth Hughes <[email protected]>
* Keith Whitwell <[email protected]>
+ * Kevin E. Martin <[email protected]>
*/
-#include <string.h>
#include "radeon_lock.h"
#include "radeon_ioctl.h"
@@ -50,57 +56,31 @@ int prevLockLine = 0;
/* Turn on/off page flipping according to the flags in the sarea:
*/
-void radeonUpdatePageFlipping(radeonContextPtr radeon)
+void radeonUpdatePageFlipping(radeonContextPtr rmesa)
{
int use_back;
- radeon->doPageFlip = radeon->sarea->pfState;
- if (radeon->glCtx->WinSysDrawBuffer) {
- driFlipRenderbuffers(radeon->glCtx->WinSysDrawBuffer, radeon->sarea->pfCurrentPage);
- r300UpdateDrawBuffer(radeon->glCtx);
- }
+ rmesa->doPageFlip = rmesa->sarea->pfState;
+ if (rmesa->glCtx->WinSysDrawBuffer) {
+ driFlipRenderbuffers(rmesa->glCtx->WinSysDrawBuffer,
+ rmesa->sarea->pfCurrentPage);
+ r300UpdateDrawBuffer(rmesa->glCtx);
+ }
- use_back = radeon->glCtx->DrawBuffer ?
- (radeon->glCtx->DrawBuffer->_ColorDrawBufferMask[0] ==
- BUFFER_BIT_BACK_LEFT) : 1;
- use_back ^= (radeon->sarea->pfCurrentPage == 1);
+ use_back = rmesa->glCtx->DrawBuffer ?
+ (rmesa->glCtx->DrawBuffer->_ColorDrawBufferMask[0] ==
+ BUFFER_BIT_BACK_LEFT) : 1;
+ use_back ^= (rmesa->sarea->pfCurrentPage == 1);
if (use_back) {
- radeon->state.color.drawOffset = radeon->radeonScreen->backOffset;
- radeon->state.color.drawPitch = radeon->radeonScreen->backPitch;
+ rmesa->state.color.drawOffset =
+ rmesa->radeonScreen->backOffset;
+ rmesa->state.color.drawPitch = rmesa->radeonScreen->backPitch;
} else {
- radeon->state.color.drawOffset = radeon->radeonScreen->frontOffset;
- radeon->state.color.drawPitch = radeon->radeonScreen->frontPitch;
- }
-}
-
-/**
- * Called by radeonGetLock() after the lock has been obtained.
- */
-static void r300RegainedLock(radeonContextPtr radeon)
-{
- int i;
- __DRIdrawablePrivate *const drawable = radeon->dri.drawable;
- r300ContextPtr r300 = (r300ContextPtr)radeon;
- drm_radeon_sarea_t *sarea = radeon->sarea;
-
- if ( radeon->lastStamp != drawable->lastStamp ) {
- radeonUpdatePageFlipping(radeon);
- radeonSetCliprects(radeon);
-#if 1
- r300UpdateViewportOffset( radeon->glCtx );
- driUpdateFramebufferSize(radeon->glCtx, drawable);
-#else
- radeonUpdateScissor(radeon->glCtx);
-#endif
- }
-
- if (sarea->ctx_owner != radeon->dri.hwContext) {
- sarea->ctx_owner = radeon->dri.hwContext;
-
- for (i = 0; i < r300->nr_heaps; i++) {
- DRI_AGE_TEXTURES(r300->texture_heaps[i]);
- }
+ rmesa->state.color.drawOffset =
+ rmesa->radeonScreen->frontOffset;
+ rmesa->state.color.drawPitch =
+ rmesa->radeonScreen->frontPitch;
}
}
@@ -112,15 +92,17 @@ static void r300RegainedLock(radeonContextPtr radeon)
* the hardware lock when it changes the window state, this routine will
* automatically be called after such a change.
*/
-void radeonGetLock(radeonContextPtr radeon, GLuint flags)
+void radeonGetLock(radeonContextPtr rmesa, GLuint flags)
{
- __DRIdrawablePrivate *const drawable = radeon->dri.drawable;
- __DRIdrawablePrivate *const readable = radeon->dri.readable;
- __DRIscreenPrivate *sPriv = radeon->dri.screen;
-
- assert (drawable != NULL);
+ __DRIdrawablePrivate *const drawable = rmesa->dri.drawable;
+ __DRIdrawablePrivate *const readable = rmesa->dri.readable;
+ __DRIscreenPrivate *sPriv = rmesa->dri.screen;
+ drm_radeon_sarea_t *sarea = rmesa->sarea;
+ r300ContextPtr r300 = (r300ContextPtr) rmesa;
- drmGetLock(radeon->dri.fd, radeon->dri.hwContext, flags);
+ assert(drawable != NULL);
+
+ drmGetLock(rmesa->dri.fd, rmesa->dri.hwContext, flags);
/* The window might have moved, so we might need to get new clip
* rects.
@@ -130,13 +112,26 @@ void radeonGetLock(radeonContextPtr radeon, GLuint flags)
* Since the hardware state depends on having the latest drawable
* clip rects, all state checking must be done _after_ this call.
*/
- DRI_VALIDATE_DRAWABLE_INFO( sPriv, drawable );
+ DRI_VALIDATE_DRAWABLE_INFO(sPriv, drawable);
if (drawable != readable) {
- DRI_VALIDATE_DRAWABLE_INFO( sPriv, readable );
+ DRI_VALIDATE_DRAWABLE_INFO(sPriv, readable);
+ }
+
+ if (rmesa->lastStamp != drawable->lastStamp) {
+ radeonUpdatePageFlipping(rmesa);
+ radeonSetCliprects(rmesa);
+ r300UpdateViewportOffset(rmesa->glCtx);
+ driUpdateFramebufferSize(rmesa->glCtx, drawable);
+ }
+
+ if (sarea->ctx_owner != rmesa->dri.hwContext) {
+ int i;
+
+ sarea->ctx_owner = rmesa->dri.hwContext;
+ for (i = 0; i < r300->nr_heaps; i++) {
+ DRI_AGE_TEXTURES(r300->texture_heaps[i]);
+ }
}
- if (IS_R300_CLASS(radeon->radeonScreen))
- r300RegainedLock(radeon);
-
- radeon->lost_context = GL_TRUE;
+ rmesa->lost_context = GL_TRUE;
}
diff --git a/src/mesa/drivers/dri/r300/radeon_lock.h b/src/mesa/drivers/dri/r300/radeon_lock.h
index b11ddf0895e..c47adc9575b 100644
--- a/src/mesa/drivers/dri/r300/radeon_lock.h
+++ b/src/mesa/drivers/dri/r300/radeon_lock.h
@@ -1,10 +1,15 @@
-/*
+/**************************************************************************
+
+Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
+ VA Linux Systems Inc., Fremont, California.
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
The Weather Channel (TM) funded Tungsten Graphics to develop the
initial release of the Radeon 8500 driver under the XFree86 license.
This notice must be preserved.
+All Rights Reserved.
+
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
@@ -29,7 +34,9 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/*
* Authors:
+ * Gareth Hughes <[email protected]>
* Keith Whitwell <[email protected]>
+ * Kevin E. Martin <[email protected]>
*/
#ifndef __RADEON_LOCK_H__
@@ -40,8 +47,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#endif
#include "radeon_context.h"
-extern void radeonGetLock(radeonContextPtr radeon, GLuint flags);
-extern void radeonUpdatePageFlipping(radeonContextPtr radeon);
+extern void radeonGetLock(radeonContextPtr rmesa, GLuint flags);
+extern void radeonUpdatePageFlipping(radeonContextPtr rmesa);
/* Turn DEBUG_LOCKING on to find locking conflicts.
*/
@@ -65,11 +72,11 @@ extern int prevLockLine;
#define DEBUG_CHECK_LOCK() \
do { \
- if ( prevLockFile ) { \
- fprintf( stderr, \
+ if (prevLockFile) { \
+ fprintf(stderr, \
"LOCK SET!\n\tPrevious %s:%d\n\tCurrent: %s:%d\n", \
- prevLockFile, prevLockLine, __FILE__, __LINE__ ); \
- exit( 1 ); \
+ prevLockFile, prevLockLine, __FILE__, __LINE__); \
+ exit(1); \
} \
} while (0)
@@ -89,38 +96,23 @@ extern int prevLockLine;
/* Lock the hardware and validate our state.
*/
-#define LOCK_HARDWARE( radeon ) \
+#define LOCK_HARDWARE( rmesa ) \
do { \
char __ret = 0; \
DEBUG_CHECK_LOCK(); \
- DRM_CAS( (radeon)->dri.hwLock, (radeon)->dri.hwContext, \
- (DRM_LOCK_HELD | (radeon)->dri.hwContext), __ret ); \
- if ( __ret ) \
- radeonGetLock( (radeon), 0 ); \
+ DRM_CAS((rmesa)->dri.hwLock, (rmesa)->dri.hwContext, \
+ (DRM_LOCK_HELD | (rmesa)->dri.hwContext), __ret); \
+ if (__ret) \
+ radeonGetLock((rmesa), 0); \
DEBUG_LOCK(); \
} while (0)
-#if R200_MERGED
-#define UNLOCK_HARDWARE( radeon ) \
+#define UNLOCK_HARDWARE( rmesa ) \
do { \
- DRM_UNLOCK( (radeon)->dri.fd, \
- (radeon)->dri.hwLock, \
- (radeon)->dri.hwContext ); \
+ DRM_UNLOCK((rmesa)->dri.fd, \
+ (rmesa)->dri.hwLock, \
+ (rmesa)->dri.hwContext); \
DEBUG_RESET(); \
- if (IS_R200_CLASS(radeon->radeonScreen)) { \
- r200ContextPtr __r200 = (r200ContextPtr)(radeon); \
- if (__r200->save_on_next_unlock) \
- r200SaveHwState( __r200 ); \
- __r200->save_on_next_unlock = GL_FALSE; \
- } \
} while (0)
-#else
-#define UNLOCK_HARDWARE( radeon ) \
- do { \
- DRM_UNLOCK( (radeon)->dri.fd, \
- (radeon)->dri.hwLock, \
- (radeon)->dri.hwContext ); \
- DEBUG_RESET(); \
- } while (0)
-#endif
+
#endif /* __RADEON_LOCK_H__ */
diff --git a/src/mesa/drivers/dri/radeon/radeon_context.c b/src/mesa/drivers/dri/radeon/radeon_context.c
index d7c2d1407d6..9451ec4aa5b 100644
--- a/src/mesa/drivers/dri/radeon/radeon_context.c
+++ b/src/mesa/drivers/dri/radeon/radeon_context.c
@@ -604,7 +604,6 @@ radeonMakeCurrent( __DRIcontextPrivate *driContextPriv,
newCtx->dri.drawable = driDrawPriv;
radeonSetCliprects(newCtx);
- radeonUpdateWindow( newCtx->glCtx );
radeonUpdateViewportOffset( newCtx->glCtx );
}
@@ -612,6 +611,7 @@ radeonMakeCurrent( __DRIcontextPrivate *driContextPriv,
(GLframebuffer *) driDrawPriv->driverPrivate,
(GLframebuffer *) driReadPriv->driverPrivate );
+ _mesa_update_state( newCtx->glCtx );
} else {
if (RADEON_DEBUG & DEBUG_DRI)
fprintf(stderr, "%s ctx is null\n", __FUNCTION__);
diff --git a/src/mesa/drivers/dri/radeon/radeon_lock.c b/src/mesa/drivers/dri/radeon/radeon_lock.c
index 312041e0351..30a0c3863c2 100644
--- a/src/mesa/drivers/dri/radeon/radeon_lock.c
+++ b/src/mesa/drivers/dri/radeon/radeon_lock.c
@@ -1,8 +1,12 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_lock.c,v 1.5 2002/10/30 12:51:55 alanh Exp $ */
/**************************************************************************
Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
VA Linux Systems Inc., Fremont, California.
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
All Rights Reserved.
@@ -30,8 +34,9 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/*
* Authors:
- * Kevin E. Martin <[email protected]>
* Gareth Hughes <[email protected]>
+ * Keith Whitwell <[email protected]>
+ * Kevin E. Martin <[email protected]>
*/
#include "glheader.h"
@@ -44,7 +49,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "drirenderbuffer.h"
-
#if DEBUG_LOCKING
char *prevLockFile = NULL;
int prevLockLine = 0;
@@ -52,17 +56,15 @@ int prevLockLine = 0;
/* Turn on/off page flipping according to the flags in the sarea:
*/
-static void
-radeonUpdatePageFlipping( radeonContextPtr rmesa )
+static void radeonUpdatePageFlipping(radeonContextPtr rmesa)
{
- rmesa->doPageFlip = rmesa->sarea->pfState;
- if (rmesa->glCtx->WinSysDrawBuffer) {
- driFlipRenderbuffers(rmesa->glCtx->WinSysDrawBuffer,
- rmesa->sarea->pfCurrentPage);
- }
+ rmesa->doPageFlip = rmesa->sarea->pfState;
+ if (rmesa->glCtx->WinSysDrawBuffer) {
+ driFlipRenderbuffers(rmesa->glCtx->WinSysDrawBuffer,
+ rmesa->sarea->pfCurrentPage);
+ }
}
-
/* Update the hardware state. This is called if another context has
* grabbed the hardware lock, which includes the X server. This
* function also updates the driver's window state after the X server
@@ -71,51 +73,52 @@ radeonUpdatePageFlipping( radeonContextPtr rmesa )
* the hardware lock when it changes the window state, this routine will
* automatically be called after such a change.
*/
-void radeonGetLock( radeonContextPtr rmesa, GLuint flags )
+void radeonGetLock(radeonContextPtr rmesa, GLuint flags)
{
- __DRIdrawablePrivate *const drawable = rmesa->dri.drawable;
- __DRIdrawablePrivate *const readable = rmesa->dri.readable;
- __DRIscreenPrivate *sPriv = rmesa->dri.screen;
- drm_radeon_sarea_t *sarea = rmesa->sarea;
-
- drmGetLock( rmesa->dri.fd, rmesa->dri.hwContext, flags );
-
- /* The window might have moved, so we might need to get new clip
- * rects.
- *
- * NOTE: This releases and regrabs the hw lock to allow the X server
- * to respond to the DRI protocol request for new drawable info.
- * Since the hardware state depends on having the latest drawable
- * clip rects, all state checking must be done _after_ this call.
- */
- DRI_VALIDATE_DRAWABLE_INFO( sPriv, drawable );
- if (drawable != readable) {
- DRI_VALIDATE_DRAWABLE_INFO( sPriv, readable );
- }
-
- if ( rmesa->lastStamp != drawable->lastStamp ) {
- radeonUpdatePageFlipping( rmesa );
- radeonSetCliprects( rmesa );
- radeonUpdateViewportOffset( rmesa->glCtx );
- driUpdateFramebufferSize(rmesa->glCtx, drawable);
- }
-
- RADEON_STATECHANGE( rmesa, ctx );
- if (rmesa->sarea->tiling_enabled) {
- rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] |= RADEON_COLOR_TILE_ENABLE;
- }
- else {
- rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] &= ~RADEON_COLOR_TILE_ENABLE;
- }
-
- if ( sarea->ctx_owner != rmesa->dri.hwContext ) {
- int i;
- sarea->ctx_owner = rmesa->dri.hwContext;
-
- for ( i = 0 ; i < rmesa->nr_heaps ; i++ ) {
- DRI_AGE_TEXTURES( rmesa->texture_heaps[ i ] );
- }
- }
-
- rmesa->lost_context = GL_TRUE;
+ __DRIdrawablePrivate *const drawable = rmesa->dri.drawable;
+ __DRIdrawablePrivate *const readable = rmesa->dri.readable;
+ __DRIscreenPrivate *sPriv = rmesa->dri.screen;
+ drm_radeon_sarea_t *sarea = rmesa->sarea;
+
+ drmGetLock(rmesa->dri.fd, rmesa->dri.hwContext, flags);
+
+ /* The window might have moved, so we might need to get new clip
+ * rects.
+ *
+ * NOTE: This releases and regrabs the hw lock to allow the X server
+ * to respond to the DRI protocol request for new drawable info.
+ * Since the hardware state depends on having the latest drawable
+ * clip rects, all state checking must be done _after_ this call.
+ */
+ DRI_VALIDATE_DRAWABLE_INFO(sPriv, drawable);
+ if (drawable != readable) {
+ DRI_VALIDATE_DRAWABLE_INFO(sPriv, readable);
+ }
+
+ if (rmesa->lastStamp != drawable->lastStamp) {
+ radeonUpdatePageFlipping(rmesa);
+ radeonSetCliprects(rmesa);
+ radeonUpdateViewportOffset(rmesa->glCtx);
+ driUpdateFramebufferSize(rmesa->glCtx, drawable);
+ }
+
+ RADEON_STATECHANGE(rmesa, ctx);
+ if (rmesa->sarea->tiling_enabled) {
+ rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] |=
+ RADEON_COLOR_TILE_ENABLE;
+ } else {
+ rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] &=
+ ~RADEON_COLOR_TILE_ENABLE;
+ }
+
+ if (sarea->ctx_owner != rmesa->dri.hwContext) {
+ int i;
+ sarea->ctx_owner = rmesa->dri.hwContext;
+
+ for (i = 0; i < rmesa->nr_heaps; i++) {
+ DRI_AGE_TEXTURES(rmesa->texture_heaps[i]);
+ }
+ }
+
+ rmesa->lost_context = GL_TRUE;
}
diff --git a/src/mesa/drivers/dri/radeon/radeon_lock.h b/src/mesa/drivers/dri/radeon/radeon_lock.h
index 4e8617eb8f1..86e96aa7d2c 100644
--- a/src/mesa/drivers/dri/radeon/radeon_lock.h
+++ b/src/mesa/drivers/dri/radeon/radeon_lock.h
@@ -1,8 +1,12 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_lock.h,v 1.3 2002/10/30 12:51:55 alanh Exp $ */
/**************************************************************************
Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
VA Linux Systems Inc., Fremont, California.
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
All Rights Reserved.
@@ -30,14 +34,15 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/*
* Authors:
- * Kevin E. Martin <[email protected]>
* Gareth Hughes <[email protected]>
+ * Keith Whitwell <[email protected]>
+ * Kevin E. Martin <[email protected]>
*/
#ifndef __RADEON_LOCK_H__
#define __RADEON_LOCK_H__
-extern void radeonGetLock( radeonContextPtr rmesa, GLuint flags );
+extern void radeonGetLock(radeonContextPtr rmesa, GLuint flags);
/* Turn DEBUG_LOCKING on to find locking conflicts.
*/
@@ -83,26 +88,25 @@ extern int prevLockLine;
* do not do any drawing !!!
*/
-
/* Lock the hardware and validate our state.
*/
#define LOCK_HARDWARE( rmesa ) \
do { \
char __ret = 0; \
DEBUG_CHECK_LOCK(); \
- DRM_CAS( rmesa->dri.hwLock, rmesa->dri.hwContext, \
- (DRM_LOCK_HELD | rmesa->dri.hwContext), __ret ); \
+ DRM_CAS( (rmesa)->dri.hwLock, (rmesa)->dri.hwContext, \
+ (DRM_LOCK_HELD | (rmesa)->dri.hwContext), __ret ); \
if ( __ret ) \
- radeonGetLock( rmesa, 0 ); \
+ radeonGetLock( (rmesa), 0 ); \
DEBUG_LOCK(); \
} while (0)
#define UNLOCK_HARDWARE( rmesa ) \
do { \
- DRM_UNLOCK( rmesa->dri.fd, \
- rmesa->dri.hwLock, \
- rmesa->dri.hwContext ); \
+ DRM_UNLOCK( (rmesa)->dri.fd, \
+ (rmesa)->dri.hwLock, \
+ (rmesa)->dri.hwContext ); \
DEBUG_RESET(); \
} while (0)
-#endif /* __RADEON_LOCK_H__ */
+#endif /* __RADEON_LOCK_H__ */
diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.c b/src/mesa/drivers/dri/radeon/radeon_screen.c
index b476864d035..aa7fb633dd1 100644
--- a/src/mesa/drivers/dri/radeon/radeon_screen.c
+++ b/src/mesa/drivers/dri/radeon/radeon_screen.c
@@ -56,6 +56,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#elif RADEON_COMMON && defined(RADEON_COMMON_FOR_R300)
#include "r300_context.h"
#include "r300_fragprog.h"
+#include "r300_tex.h"
#include "radeon_span.h"
#endif
@@ -952,6 +953,9 @@ static struct __DriverAPIRec radeonAPI = {
.WaitForSBC = NULL,
.SwapBuffersMSC = NULL,
.CopySubBuffer = radeonCopySubBuffer,
+#if RADEON_COMMON && defined(RADEON_COMMON_FOR_R300)
+ .setTexOffset = r300SetTexOffset,
+#endif
};
#else
static const struct __DriverAPIRec r200API = {
diff --git a/src/mesa/drivers/dri/s3v/s3v_tritmp.h b/src/mesa/drivers/dri/s3v/s3v_tritmp.h
index 696fc02250f..2321bd414ff 100644
--- a/src/mesa/drivers/dri/s3v/s3v_tritmp.h
+++ b/src/mesa/drivers/dri/s3v/s3v_tritmp.h
@@ -43,12 +43,12 @@
#define SORT_LINE_VERT() \
do { \
- if(v[0].win[1] <= v[1].win[1]) { \
+ if(v[0].attrib[FRAG_ATTRIB_WPOS][1] <= v[1].attrib[FRAG_ATTRIB_WPOS][1]) { \
\
idx[0] = 0; \
idx[1] = 1; \
\
- } else if (v[0].win[1] > v[1].win[1]) { \
+ } else if (v[0].attrib[FRAG_ATTRIB_WPOS][1] > v[1].attrib[FRAG_ATTRIB_WPOS][1]) { \
\
idx[0] = 1; \
idx[1] = 0; \
@@ -58,19 +58,19 @@ do { \
#define SET_LINE_VERT() \
do { \
- x[0] = (v[idx[0]].win[0] * 1024.0f * 1024.0f); /* 0x100000 */ \
- y[0] = fy[0] = dPriv->h - v[idx[0]].win[1]; \
- z[0] = (v[idx[0]].win[2]) * 1024.0f * 32.0f; /* 0x8000; */ \
+ x[0] = (v[idx[0]].attrib[FRAG_ATTRIB_WPOS][0] * 1024.0f * 1024.0f); /* 0x100000 */ \
+ y[0] = fy[0] = dPriv->h - v[idx[0]].attrib[FRAG_ATTRIB_WPOS][1]; \
+ z[0] = (v[idx[0]].attrib[FRAG_ATTRIB_WPOS][2]) * 1024.0f * 32.0f; /* 0x8000; */ \
\
- x[1] = (v[idx[1]].win[0] * 1024.0f * 1024.0f); /* 0x100000 */ \
- y[1] = dPriv->h - v[idx[1]].win[1]; \
- z[1] = (v[idx[1]].win[2]) * 1024.0f * 32.0f; /* 0x8000 */ \
+ x[1] = (v[idx[1]].attrib[FRAG_ATTRIB_WPOS][0] * 1024.0f * 1024.0f); /* 0x100000 */ \
+ y[1] = dPriv->h - v[idx[1]].attrib[FRAG_ATTRIB_WPOS][1]; \
+ z[1] = (v[idx[1]].attrib[FRAG_ATTRIB_WPOS][2]) * 1024.0f * 32.0f; /* 0x8000 */ \
} while(0)
#define SET_LINE_XY() \
do { \
- tmp = v[idx[0]].win[0]; \
- tmp2 = v[idx[1]].win[0]; \
+ tmp = v[idx[0]].attrib[FRAG_ATTRIB_WPOS][0]; \
+ tmp2 = v[idx[1]].attrib[FRAG_ATTRIB_WPOS][0]; \
\
dx01 = x[0] - x[1]; \
dy01 = y[0] - y[1]; \
@@ -265,7 +265,7 @@ do { \
#define SORT_VERT() \
do { \
for (i=0; i<3; i++) \
- fy[i] = v[i].win[1]; \
+ fy[i] = v[i].attrib[FRAG_ATTRIB_WPOS][1]; \
\
if (fy[1] > fy[0]) { /* (fy[1] > fy[0]) */ \
\
@@ -305,9 +305,9 @@ do { \
do { \
for (i=0; i<3; i++) \
{ \
- x[i] = ((v[idx[i]].win[0]) * /* 0x100000*/ 1024.0 * 1024.0); \
- y[i] = fy[i] = (dPriv->h - v[idx[i]].win[1]); \
- z[i] = ((v[idx[i]].win[2]) * /* 0x8000 */ 1024.0 * 32.0); \
+ x[i] = ((v[idx[i]].attrib[FRAG_ATTRIB_WPOS][0]) * /* 0x100000*/ 1024.0 * 1024.0); \
+ y[i] = fy[i] = (dPriv->h - v[idx[i]].attrib[FRAG_ATTRIB_WPOS][1]); \
+ z[i] = ((v[idx[i]].attrib[FRAG_ATTRIB_WPOS][2]) * /* 0x8000 */ 1024.0 * 32.0); \
} \
\
ydiff = fy[0] - (float)y[0]; \
@@ -420,9 +420,9 @@ do { \
v2 = (v[idx[2]].attrib[FRAG_ATTRIB_TEX0][1] \
* (GLfloat)(t->globj->Image[0][0]->Height) * 256.0); \
\
- w0 = (v[idx[0]].win[3]); \
- w1 = (v[idx[1]].win[3]); \
- w2 = (v[idx[2]].win[3]); \
+ w0 = (v[idx[0]].attrib[FRAG_ATTRIB_WPOS][3]); \
+ w1 = (v[idx[1]].attrib[FRAG_ATTRIB_WPOS][3]); \
+ w2 = (v[idx[2]].attrib[FRAG_ATTRIB_WPOS][3]); \
} while (0)
#define SET_BASEUV() \
@@ -732,8 +732,8 @@ DEBUG(("***\n"));
#if (IND & S3V_RAST_CULL_BIT)
cull = vmesa->backface_sign *
- ((v[1].win[0] - v[0].win[0]) * (v[0].win[1] - v[2].win[1]) +
- (v[1].win[1] - v[0].win[1]) * (v[2].win[0] - v[0].win[0]));
+ ((v[1].attrib[FRAG_ATTRIB_WPOS][0] - v[0].attrib[FRAG_ATTRIB_WPOS][0]) * (v[0].attrib[FRAG_ATTRIB_WPOS][1] - v[2].attrib[FRAG_ATTRIB_WPOS][1]) +
+ (v[1].attrib[FRAG_ATTRIB_WPOS][1] - v[0].attrib[FRAG_ATTRIB_WPOS][1]) * (v[2].attrib[FRAG_ATTRIB_WPOS][0] - v[0].attrib[FRAG_ATTRIB_WPOS][0]));
if (cull < vmesa->cull_zero /* -0.02f */) return;
#endif
@@ -842,8 +842,8 @@ static void TAG(s3v_quad)( s3vContextPtr vmesa,
#if (IND & S3V_RAST_CULL_BIT)
cull = vmesa->backface_sign *
- ((v[1].win[0] - v[0].win[0]) * (v[0].win[1] - v[2].win[1]) +
- (v[1].win[1] - v[0].win[1]) * (v[2].win[0] - v[0].win[0]));
+ ((v[1].attrib[FRAG_ATTRIB_WPOS][0] - v[0].attrib[FRAG_ATTRIB_WPOS][0]) * (v[0].attrib[FRAG_ATTRIB_WPOS][1] - v[2].attrib[FRAG_ATTRIB_WPOS][1]) +
+ (v[1].attrib[FRAG_ATTRIB_WPOS][1] - v[0].attrib[FRAG_ATTRIB_WPOS][1]) * (v[2].attrib[FRAG_ATTRIB_WPOS][0] - v[0].attrib[FRAG_ATTRIB_WPOS][0]));
if (cull < vmesa->cull_zero /* -0.02f */) goto second; /* return; */ /* (a) */
#endif
@@ -897,8 +897,8 @@ second:
#if (IND & S3V_RAST_CULL_BIT)
cull = vmesa->backface_sign *
- ((v[1].win[0] - v[0].win[0]) * (v[0].win[1] - v[2].win[1]) +
- (v[1].win[1] - v[0].win[1]) * (v[2].win[0] - v[0].win[0]));
+ ((v[1].attrib[FRAG_ATTRIB_WPOS][0] - v[0].attrib[FRAG_ATTRIB_WPOS][0]) * (v[0].attrib[FRAG_ATTRIB_WPOS][1] - v[2].attrib[FRAG_ATTRIB_WPOS][1]) +
+ (v[1].attrib[FRAG_ATTRIB_WPOS][1] - v[0].attrib[FRAG_ATTRIB_WPOS][1]) * (v[2].attrib[FRAG_ATTRIB_WPOS][0] - v[0].attrib[FRAG_ATTRIB_WPOS][0]));
if (cull < /* -0.02f */ vmesa->cull_zero) return;
#endif
diff --git a/src/mesa/drivers/dri/tdfx/tdfx_tris.c b/src/mesa/drivers/dri/tdfx/tdfx_tris.c
index 4ba2f40b9e8..96f9ae27fc1 100644
--- a/src/mesa/drivers/dri/tdfx/tdfx_tris.c
+++ b/src/mesa/drivers/dri/tdfx/tdfx_tris.c
@@ -142,10 +142,10 @@ tdfx_translate_vertex( GLcontext *ctx, const tdfxVertex *src, SWvertex *dst)
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
if (fxMesa->vertexFormat == TDFX_LAYOUT_TINY) {
- dst->win[0] = src->x - fxMesa->x_offset;
- dst->win[1] = src->y - (fxMesa->screen_height - fxMesa->height - fxMesa->y_offset);
- dst->win[2] = src->z;
- dst->win[3] = 1.0;
+ dst->attrib[FRAG_ATTRIB_WPOS][0] = src->x - fxMesa->x_offset;
+ dst->attrib[FRAG_ATTRIB_WPOS][1] = src->y - (fxMesa->screen_height - fxMesa->height - fxMesa->y_offset);
+ dst->attrib[FRAG_ATTRIB_WPOS][2] = src->z;
+ dst->attrib[FRAG_ATTRIB_WPOS][3] = 1.0;
dst->color[0] = src->color[2];
dst->color[1] = src->color[1];
@@ -155,10 +155,10 @@ tdfx_translate_vertex( GLcontext *ctx, const tdfxVertex *src, SWvertex *dst)
else {
GLfloat w = 1.0 / src->rhw;
- dst->win[0] = src->x - fxMesa->x_offset;
- dst->win[1] = src->y - (fxMesa->screen_height - fxMesa->height - fxMesa->y_offset);
- dst->win[2] = src->z;
- dst->win[3] = src->rhw;
+ dst->attrib[FRAG_ATTRIB_WPOS][0] = src->x - fxMesa->x_offset;
+ dst->attrib[FRAG_ATTRIB_WPOS][1] = src->y - (fxMesa->screen_height - fxMesa->height - fxMesa->y_offset);
+ dst->attrib[FRAG_ATTRIB_WPOS][2] = src->z;
+ dst->attrib[FRAG_ATTRIB_WPOS][3] = src->rhw;
dst->color[0] = src->color[2];
dst->color[1] = src->color[1];