#include "context.h"
#include "state.h"
#include "matrix.h"
+#include "framebuffer.h"
#include "drivers/common/driverfuncs.h"
#include "swrast/swrast.h"
#include "radeon_screen.h"
-#include "r200_context.h"
#include "radeon_ioctl.h"
#include "radeon_macros.h"
#include "radeon_reg.h"
-#include "r200_state.h"
+
+#include "radeon_state.h"
+#include "r300_state.h"
#include "utils.h"
#include "vblank.h"
#include "xmlpool.h" /* for symbolic values of enum-type options */
-#define DRIVER_DATE "20040924"
+#define DRIVER_DATE "20060815"
/* Return various strings for glGetString().
switch (name) {
case GL_VENDOR:
- return (GLubyte *) "Tungsten Graphics, Inc.";
+ if (IS_R300_CLASS(radeon->radeonScreen))
+ return (GLubyte *) "DRI R300 Project";
+ else
+ return (GLubyte *) "Tungsten Graphics, Inc.";
case GL_RENDERER:
{
unsigned offset;
- GLuint agp_mode = radeon->radeonScreen->IsPCI ? 0 :
+ GLuint agp_mode = (radeon->radeonScreen->card_type==RADEON_CARD_PCI) ? 0 :
radeon->radeonScreen->AGPMode;
const char* chipname;
- if (IS_FAMILY_R300(radeon))
+ if (IS_R300_CLASS(radeon->radeonScreen))
chipname = "R300";
else
chipname = "R200";
offset = driGetRendererString(buffer, chipname, DRIVER_DATE,
agp_mode);
+ if (IS_R300_CLASS(radeon->radeonScreen)) {
sprintf(&buffer[offset], " %sTCL",
+ (radeon->radeonScreen->chip_flags & RADEON_CHIPSET_TCL)
+ ? "" : "NO-");
+ } else {
+ sprintf(&buffer[offset], " %sTCL",
!(radeon->TclFallback & RADEON_TCL_FALLBACK_TCL_DISABLE)
? "" : "NO-");
+ }
return (GLubyte *) buffer;
}
}
}
-
-/* Return the width and height of the given buffer.
- */
-static void radeonGetBufferSize(GLframebuffer * buffer,
- GLuint * width, GLuint * height)
-{
- GET_CURRENT_CONTEXT(ctx);
- radeonContextPtr radeon = RADEON_CONTEXT(ctx);
-
- LOCK_HARDWARE(radeon);
- *width = radeon->dri.drawable->w;
- *height = radeon->dri.drawable->h;
- UNLOCK_HARDWARE(radeon);
-}
-
-
/* Initialize the driver's misc functions.
*/
static void radeonInitDriverFuncs(struct dd_function_table *functions)
{
- functions->GetBufferSize = radeonGetBufferSize;
- functions->ResizeBuffers = _swrast_alloc_buffers;
functions->GetString = radeonGetString;
}
-static int get_ust_nop(int64_t * ust)
-{
- *ust = 1;
- return 0;
-}
-
/**
* Create and initialize all common fields of the context,
* including the Mesa context itself.
/* DRI fields */
radeon->dri.context = driContextPriv;
radeon->dri.screen = sPriv;
- radeon->dri.drawable = NULL; /* Set by XMesaMakeCurrent */
+ radeon->dri.drawable = NULL;
+ radeon->dri.readable = NULL;
radeon->dri.hwContext = driContextPriv->hHWContext;
radeon->dri.hwLock = &sPriv->pSAREA->lock;
radeon->dri.fd = sPriv->fd;
- radeon->dri.drmMinor = sPriv->drmMinor;
+ radeon->dri.drmMinor = sPriv->drm_version.minor;
radeon->radeonScreen = screen;
radeon->sarea = (drm_radeon_sarea_t *) ((GLubyte *) sPriv->pSAREA +
fthrottle_mode = driQueryOptioni(&radeon->optionCache, "fthrottle_mode");
radeon->iw.irq_seq = -1;
radeon->irqsEmitted = 0;
- radeon->do_irqs = (radeon->dri.drmMinor >= 6 &&
- fthrottle_mode == DRI_CONF_FTHROTTLE_IRQS &&
+ radeon->do_irqs = (fthrottle_mode == DRI_CONF_FTHROTTLE_IRQS &&
radeon->radeonScreen->irq);
radeon->do_usleeps = (fthrottle_mode == DRI_CONF_FTHROTTLE_USLEEPS);
if (!radeon->do_irqs)
fprintf(stderr,
- "IRQ's not enabled, falling back to %s: %d %d %d\n",
+ "IRQ's not enabled, falling back to %s: %d %d\n",
radeon->do_usleeps ? "usleeps" : "busy waits",
- radeon->dri.drmMinor,
fthrottle_mode, radeon->radeonScreen->irq);
- radeon->vblank_flags = (radeon->radeonScreen->irq != 0)
- ? driGetDefaultVBlankFlags(&radeon->optionCache) : VBLANK_FLAG_NO_IRQ;
-
- radeon->get_ust =
- (PFNGLXGETUSTPROC) glXGetProcAddress((const GLubyte *)
- "__glXGetUST");
- if (radeon->get_ust == NULL) {
- radeon->get_ust = get_ust_nop;
- }
- (*radeon->get_ust) (&radeon->swap_ust);
+ (*dri_interface->getUST) (&radeon->swap_ust);
return GL_TRUE;
}
*/
void radeonCleanupContext(radeonContextPtr radeon)
{
+ /* _mesa_destroy_context() might result in calls to functions that
+ * depend on the DriverCtx, so don't set it to NULL before.
+ *
+ * radeon->glCtx->DriverCtx = NULL;
+ */
+
/* free the Mesa context */
- radeon->glCtx->DriverCtx = NULL;
_mesa_destroy_context(radeon->glCtx);
if (radeon->state.scissor.pClipRects) {
if (radeon->doPageFlip) {
radeonPageFlip(dPriv);
} else {
- radeonCopyBuffer(dPriv);
+ radeonCopyBuffer(dPriv, NULL);
}
}
} else {
}
}
+void radeonCopySubBuffer(__DRIdrawablePrivate * dPriv,
+ int x, int y, int w, int h )
+{
+ if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
+ radeonContextPtr radeon;
+ GLcontext *ctx;
+
+ radeon = (radeonContextPtr) dPriv->driContextPriv->driverPrivate;
+ ctx = radeon->glCtx;
+
+ if (ctx->Visual.doubleBufferMode) {
+ drm_clip_rect_t rect;
+ rect.x1 = x + dPriv->x;
+ rect.y1 = (dPriv->h - y - h) + dPriv->y;
+ rect.x2 = rect.x1 + w;
+ rect.y2 = rect.y1 + h;
+ _mesa_notifySwapBuffers(ctx); /* flush pending rendering comands */
+ radeonCopyBuffer(dPriv, &rect);
+ }
+ } else {
+ /* XXX this shouldn't be an error but we can't handle it for now */
+ _mesa_problem(NULL, "%s: drawable has no context!",
+ __FUNCTION__);
+ }
+}
/* Force the context `c' to be the current context and associate with it
* buffer `b'.
radeon->glCtx);
if (radeon->dri.drawable != driDrawPriv) {
- driDrawableInitVBlank(driDrawPriv,
- radeon->vblank_flags);
- radeon->dri.drawable = driDrawPriv;
-
-#if R200_MERGED
- if (IS_FAMILY_R200(radeon)) {
- r200UpdateWindow(radeon->glCtx);
- r200UpdateViewportOffset(radeon->glCtx);
+ if (driDrawPriv->swap_interval == (unsigned)-1) {
+ driDrawPriv->vblFlags =
+ (radeon->radeonScreen->irq != 0)
+ ? driGetDefaultVBlankFlags(&radeon->
+ optionCache)
+ : VBLANK_FLAG_NO_IRQ;
+
+ driDrawableInitVBlank(driDrawPriv);
}
-#endif
}
- _mesa_make_current2(radeon->glCtx,
+ radeon->dri.readable = driReadPriv;
+
+ if (radeon->dri.drawable != driDrawPriv ||
+ radeon->lastStamp != driDrawPriv->lastStamp) {
+ radeon->dri.drawable = driDrawPriv;
+
+ radeonSetCliprects(radeon);
+ r300UpdateViewportOffset(radeon->glCtx);
+ }
+
+ _mesa_make_current(radeon->glCtx,
(GLframebuffer *) driDrawPriv->
driverPrivate,
(GLframebuffer *) driReadPriv->
driverPrivate);
- if (!radeon->glCtx->Viewport.Width) {
- _mesa_set_viewport(radeon->glCtx, 0, 0,
- driDrawPriv->w, driDrawPriv->h);
- }
-
- _mesa_update_state(radeon->glCtx);
+ _mesa_update_state(radeon->glCtx);
-#if R200_MERGED
- if (IS_FAMILY_R200(radeon))
- r200ValidateState(radeon->glCtx);
-#endif
-
+ radeonUpdatePageFlipping(radeon);
} else {
if (RADEON_DEBUG & DEBUG_DRI)
fprintf(stderr, "%s ctx is null\n", __FUNCTION__);
- _mesa_make_current(0, 0);
+ _mesa_make_current(0, 0, 0);
}
if (RADEON_DEBUG & DEBUG_DRI)