#include "r200_context.h"
#include "r200_ioctl.h"
#include "r200_state.h"
-#include "r200_span.h"
#include "r200_pixel.h"
#include "r200_tex.h"
#include "r200_swtcl.h"
#include "r200_maos.h"
#include "r200_vertprog.h"
+#include "radeon_span.h"
+
#define need_GL_ARB_multisample
#define need_GL_ARB_texture_compression
#define need_GL_ARB_vertex_buffer_object
#include "vblank.h"
#include "utils.h"
#include "xmlpool.h" /* for symbolic values of enum-type options */
-#ifndef R200_DEBUG
-int R200_DEBUG = (0);
-#endif
/* Return various strings for glGetString().
*/
}
}
-
-static void r200_vtbl_flush(GLcontext *ctx)
+static void r200_vtbl_emit_cs_header(struct radeon_cs *cs, radeonContextPtr rmesa)
{
- R200_FIREVERTICES(R200_CONTEXT(ctx));
}
-static void r200_vtbl_set_all_dirty(GLcontext *ctx)
-{
- r200ContextPtr rmesa = R200_CONTEXT(ctx);
- rmesa->hw.all_dirty = GL_TRUE;
-}
static void r200_init_vtbl(radeonContextPtr radeon)
{
radeon->vtbl.get_lock = r200_get_lock;
radeon->vtbl.update_viewport_offset = r200UpdateViewportOffset;
- radeon->vtbl.flush = r200_vtbl_flush;
- radeon->vtbl.set_all_dirty = r200_vtbl_set_all_dirty;
radeon->vtbl.update_draw_buffer = r200UpdateDrawBuffer;
+ radeon->vtbl.emit_cs_header = r200_vtbl_emit_cs_header;
+ radeon->vtbl.swtcl_flush = r200_swtcl_flush;
}
+
/* Create the device specific rendering context.
*/
GLboolean r200CreateContext( const __GLcontextModes *glVisual,
radeonScreenPtr screen = (radeonScreenPtr)(sPriv->private);
struct dd_function_table functions;
r200ContextPtr rmesa;
- GLcontext *ctx, *shareCtx;
+ GLcontext *ctx;
int i;
- int tcl_mode, fthrottle_mode;
+ int tcl_mode;
assert(glVisual);
assert(driContextPriv);
r200InitTextureFuncs(&functions);
r200InitShaderFuncs(&functions);
- /* Allocate and initialize the Mesa context */
- if (sharedContextPrivate)
- shareCtx = ((r200ContextPtr) sharedContextPrivate)->radeon.glCtx;
- else
- shareCtx = NULL;
- rmesa->radeon.glCtx = _mesa_create_context(glVisual, shareCtx,
- &functions, (void *) rmesa);
- if (!rmesa->radeon.glCtx) {
- FREE(rmesa);
- return GL_FALSE;
+ if (!radeonInitContext(&rmesa->radeon, &functions,
+ glVisual, driContextPriv,
+ sharedContextPrivate)) {
+ FREE(rmesa);
+ return GL_FALSE;
}
- driContextPriv->driverPrivate = rmesa;
-
- /* Init r200 context data */
- rmesa->radeon.dri.context = driContextPriv;
- rmesa->radeon.dri.screen = sPriv;
- rmesa->radeon.dri.drawable = NULL; /* Set by XMesaMakeCurrent */
- rmesa->radeon.dri.hwContext = driContextPriv->hHWContext;
- rmesa->radeon.dri.hwLock = &sPriv->pSAREA->lock;
- rmesa->radeon.dri.fd = sPriv->fd;
- rmesa->radeon.dri.drmMinor = sPriv->drm_version.minor;
- rmesa->radeon.radeonScreen = screen;
- rmesa->radeon.sarea = (drm_radeon_sarea_t *)((GLubyte *)sPriv->pSAREA +
- screen->sarea_priv_offset);
-
-
- rmesa->dma.buf0_address = rmesa->radeon.radeonScreen->buffers->list[0].address;
(void) memset( rmesa->radeon.texture_heaps, 0, sizeof( rmesa->radeon.texture_heaps ) );
make_empty_list( & rmesa->radeon.swapped );
rmesa->radeon.nr_heaps = 1 /* screen->numTexHeaps */ ;
assert(rmesa->radeon.nr_heaps < RADEON_NR_TEX_HEAPS);
+#if 0
for ( i = 0 ; i < rmesa->radeon.nr_heaps ; i++ ) {
rmesa->radeon.texture_heaps[i] = driCreateTextureHeap( i, rmesa,
screen->texSize[i],
sizeof( radeonTexObj ),
(destroy_texture_object_t *) r200DestroyTexObj );
}
+#endif
rmesa->radeon.texture_depth = driQueryOptioni (&rmesa->radeon.optionCache,
"texture_depth");
if (rmesa->radeon.texture_depth == DRI_CONF_TEXTURE_DEPTH_FB)
rmesa->radeon.texture_depth = ( screen->cpp == 4 ) ?
DRI_CONF_TEXTURE_DEPTH_32 : DRI_CONF_TEXTURE_DEPTH_16;
- rmesa->swtcl.RenderIndex = ~0;
- rmesa->hw.all_dirty = 1;
+ rmesa->radeon.swtcl.RenderIndex = ~0;
+ rmesa->radeon.hw.all_dirty = 1;
/* Set the maximum texture size small enough that we can guarentee that
* all texture units can bind a maximal texture and have all of them in
#endif
/* plug in a few more device driver functions */
/* XXX these should really go right after _mesa_init_driver_functions() */
+ radeonInitSpanFuncs( ctx );
r200InitPixelFuncs( ctx );
- r200InitSpanFuncs( ctx );
r200InitTnlFuncs( ctx );
r200InitState( rmesa );
r200InitSwtcl( ctx );
- fthrottle_mode = driQueryOptioni(&rmesa->radeon.optionCache, "fthrottle_mode");
- rmesa->radeon.iw.irq_seq = -1;
- rmesa->radeon.irqsEmitted = 0;
- rmesa->radeon.do_irqs = (fthrottle_mode == DRI_CONF_FTHROTTLE_IRQS &&
- rmesa->radeon.radeonScreen->irq);
-
- rmesa->radeon.do_usleeps = (fthrottle_mode == DRI_CONF_FTHROTTLE_USLEEPS);
-
- if (!rmesa->radeon.do_irqs)
- fprintf(stderr,
- "IRQ's not enabled, falling back to %s: %d %d\n",
- rmesa->radeon.do_usleeps ? "usleeps" : "busy waits",
- fthrottle_mode,
- rmesa->radeon.radeonScreen->irq);
-
rmesa->prefer_gart_client_texturing =
(getenv("R200_GART_CLIENT_TEXTURES") != 0);
- (*sPriv->systemTime->getUST)( & rmesa->radeon.swap_ust );
-
-
#if DO_DEBUG
R200_DEBUG = driParseDebugString( getenv( "R200_DEBUG" ),
debug_control );
/* check if we're deleting the currently bound context */
if (rmesa == current) {
- R200_FIREVERTICES( rmesa );
+ radeon_firevertices(&rmesa->radeon);
_mesa_make_current(NULL, NULL, NULL);
}
r200DestroySwtcl( rmesa->radeon.glCtx );
r200ReleaseArrays( rmesa->radeon.glCtx, ~0 );
- if (rmesa->dma.current.buf) {
- r200ReleaseDmaRegion( rmesa, &rmesa->dma.current, __FUNCTION__ );
- r200FlushCmdBuf( rmesa, __FUNCTION__ );
+ if (rmesa->radeon.dma.current) {
+ rcommonFlushCmdBuf( &rmesa->radeon, __FUNCTION__ );
}
if (rmesa->radeon.state.scissor.pClipRects) {
rmesa->radeon.state.scissor.pClipRects = NULL;
}
+
if ( release_texture_heaps ) {
/* This share group is about to go away, free our private
* texture object data.
assert( is_empty_list( & rmesa->radeon.swapped ) );
}
- /* free the Mesa context */
- rmesa->radeon.glCtx->DriverCtx = NULL;
- _mesa_destroy_context( rmesa->radeon.glCtx );
-
- /* free the option cache */
- driDestroyOptionCache (&rmesa->radeon.optionCache);
+ radeonCleanupContext(&rmesa->radeon);
FREE( rmesa );
}
}
-/* Force the context `c' to be the current context and associate with it
- * buffer `b'.
- */
-GLboolean
-r200MakeCurrent( __DRIcontextPrivate *driContextPriv,
- __DRIdrawablePrivate *driDrawPriv,
- __DRIdrawablePrivate *driReadPriv )
-{
- if ( driContextPriv ) {
- r200ContextPtr newCtx =
- (r200ContextPtr) driContextPriv->driverPrivate;
-
- if (R200_DEBUG & DEBUG_DRI)
- fprintf(stderr, "%s ctx %p\n", __FUNCTION__, (void *)newCtx->radeon.glCtx);
-
- newCtx->radeon.dri.readable = driReadPriv;
-
- if ( newCtx->radeon.dri.drawable != driDrawPriv ||
- newCtx->radeon.lastStamp != driDrawPriv->lastStamp ) {
- if (driDrawPriv->swap_interval == (unsigned)-1) {
- driDrawPriv->vblFlags = (newCtx->radeon.radeonScreen->irq != 0)
- ? driGetDefaultVBlankFlags(&newCtx->radeon.optionCache)
- : VBLANK_FLAG_NO_IRQ;
-
- driDrawableInitVBlank( driDrawPriv );
- }
-
- newCtx->radeon.dri.drawable = driDrawPriv;
- r200SetCliprects(newCtx);
- r200UpdateViewportOffset( newCtx->radeon.glCtx );
- }
-
- _mesa_make_current( newCtx->radeon.glCtx,
- (GLframebuffer *) driDrawPriv->driverPrivate,
- (GLframebuffer *) driReadPriv->driverPrivate );
-
- _mesa_update_state( newCtx->radeon.glCtx );
- r200ValidateState( newCtx->radeon.glCtx );
-
- } else {
- if (R200_DEBUG & DEBUG_DRI)
- fprintf(stderr, "%s ctx is null\n", __FUNCTION__);
- _mesa_make_current( NULL, NULL, NULL );
- }
-
- if (R200_DEBUG & DEBUG_DRI)
- fprintf(stderr, "End %s\n", __FUNCTION__);
- return GL_TRUE;
-}
/* Force the context `c' to be unbound from its buffer.
*/