#include "drivers/common/meta.h"
#include "main/context.h"
#include "main/framebuffer.h"
+#include "main/fbobject.h"
#include "main/renderbuffer.h"
#include "main/state.h"
-#include "main/simple_list.h"
+#include "util/simple_list.h"
#include "swrast/swrast.h"
#include "swrast_setup/swrast_setup.h"
#include "tnl/tnl.h"
}
}
+const char const *radeonVendorString = "Mesa Project";
-/* Return various strings for glGetString().
+/* Return complete renderer string.
*/
-static const GLubyte *radeonGetString(struct gl_context * ctx, GLenum name)
+const char *radeonGetRendererString(radeonScreenPtr radeonScreen)
{
- radeonContextPtr radeon = RADEON_CONTEXT(ctx);
static char buffer[128];
+ char hardwarename[32];
- switch (name) {
- case GL_VENDOR:
- return (GLubyte *) "Tungsten Graphics, Inc.";
-
- case GL_RENDERER:
- {
- unsigned offset;
- GLuint agp_mode = (radeon->radeonScreen->card_type==RADEON_CARD_PCI) ? 0 :
- radeon->radeonScreen->AGPMode;
- char hardwarename[32];
+ GLuint agp_mode = (radeonScreen->card_type==RADEON_CARD_PCI) ? 0 :
+ radeonScreen->AGPMode;
- sprintf(hardwarename, "%s (%s %04X)",
+ snprintf(hardwarename, sizeof(hardwarename), "%s (%s %04X)",
#if defined(RADEON_R100)
- "R100",
+ "R100",
#elif defined(RADEON_R200)
- "R200",
+ "R200",
#endif
- get_chip_family_name(radeon->radeonScreen->chip_family),
- radeon->radeonScreen->device_id);
+ get_chip_family_name(radeonScreen->chip_family),
+ radeonScreen->device_id);
- offset = driGetRendererString(buffer, hardwarename, agp_mode);
+ driGetRendererString(buffer, hardwarename, agp_mode);
- sprintf(&buffer[offset], " %sTCL",
- !(radeon->TclFallback & RADEON_TCL_FALLBACK_TCL_DISABLE)
- ? "" : "NO-");
+ strcat(buffer, " DRI2");
- strcat(buffer, " DRI2");
+ return buffer;
+}
- return (GLubyte *) buffer;
- }
+
+/* Return various strings for glGetString().
+ */
+static const GLubyte *radeonGetString(struct gl_context * ctx, GLenum name)
+{
+ radeonContextPtr radeon = RADEON_CONTEXT(ctx);
+
+ switch (name) {
+ case GL_VENDOR:
+ return (GLubyte *) radeonVendorString;
+
+ case GL_RENDERER:
+ return (GLubyte *) radeonGetRendererString(radeon->radeonScreen);
default:
return NULL;
* including the Mesa context itself.
*/
GLboolean radeonInitContext(radeonContextPtr radeon,
+ gl_api api,
struct dd_function_table* functions,
const struct gl_config * glVisual,
__DRIcontext * driContextPriv,
radeon->radeonScreen = screen;
/* Allocate and initialize the Mesa context */
if (sharedContextPrivate)
- shareCtx = ((radeonContextPtr)sharedContextPrivate)->glCtx;
+ shareCtx = &((radeonContextPtr)sharedContextPrivate)->glCtx;
else
shareCtx = NULL;
- radeon->glCtx = _mesa_create_context(API_OPENGL, glVisual, shareCtx,
- functions, (void *)radeon);
- if (!radeon->glCtx)
+
+ if (!_mesa_initialize_context(&radeon->glCtx, api,
+ glVisual, shareCtx,
+ functions))
return GL_FALSE;
- ctx = radeon->glCtx;
+ ctx = &radeon->glCtx;
driContextPriv->driverPrivate = radeon;
_mesa_meta_init(ctx);
/* DRI fields */
- radeon->dri.context = driContextPriv;
- radeon->dri.screen = sPriv;
- radeon->dri.fd = sPriv->fd;
- radeon->dri.drmMinor = sPriv->drm_version.minor;
+ radeon->driContext = driContextPriv;
/* Setup IRQs */
fthrottle_mode = driQueryOptioni(&radeon->optionCache, "fthrottle_mode");
radeon_init_dma(radeon);
+ /* _mesa_initialize_context calls _mesa_init_queryobj which
+ * initializes all of the counter sizes to 64. The counters on r100
+ * and r200 are only 32-bits for occlusion queries. Those are the
+ * only counters, so set the other sizes to zero.
+ */
+ radeon->glCtx.Const.QueryCounterBits.SamplesPassed = 32;
+
+ radeon->glCtx.Const.QueryCounterBits.TimeElapsed = 0;
+ radeon->glCtx.Const.QueryCounterBits.Timestamp = 0;
+ radeon->glCtx.Const.QueryCounterBits.PrimitivesGenerated = 0;
+ radeon->glCtx.Const.QueryCounterBits.PrimitivesWritten = 0;
+ radeon->glCtx.Const.QueryCounterBits.VerticesSubmitted = 0;
+ radeon->glCtx.Const.QueryCounterBits.PrimitivesSubmitted = 0;
+ radeon->glCtx.Const.QueryCounterBits.VsInvocations = 0;
+ radeon->glCtx.Const.QueryCounterBits.TessPatches = 0;
+ radeon->glCtx.Const.QueryCounterBits.TessInvocations = 0;
+ radeon->glCtx.Const.QueryCounterBits.GsInvocations = 0;
+ radeon->glCtx.Const.QueryCounterBits.GsPrimitives = 0;
+ radeon->glCtx.Const.QueryCounterBits.FsInvocations = 0;
+ radeon->glCtx.Const.QueryCounterBits.ComputeInvocations = 0;
+ radeon->glCtx.Const.QueryCounterBits.ClInPrimitives = 0;
+ radeon->glCtx.Const.QueryCounterBits.ClOutPrimitives = 0;
+
return GL_TRUE;
}
struct radeon_state_atom *atom;
foreach(atom, &radeon->hw.atomlist) {
- FREE(atom->cmd);
- if (atom->lastcmd)
- FREE(atom->lastcmd);
+ free(atom->cmd);
+ free(atom->lastcmd);
}
}
assert(radeon);
- _mesa_meta_free(radeon->glCtx);
+ _mesa_meta_free(&radeon->glCtx);
if (radeon == current) {
_mesa_make_current(NULL, NULL, NULL);
radeon_firevertices(radeon);
if (!is_empty_list(&radeon->dma.reserved)) {
- rcommonFlushCmdBuf( radeon, __FUNCTION__ );
+ rcommonFlushCmdBuf( radeon, __func__ );
}
radeonFreeDmaRegions(radeon);
- radeonReleaseArrays(radeon->glCtx, ~0);
+ radeonReleaseArrays(&radeon->glCtx, ~0);
if (radeon->vtbl.free_context)
- radeon->vtbl.free_context(radeon->glCtx);
- _swsetup_DestroyContext( radeon->glCtx );
- _tnl_DestroyContext( radeon->glCtx );
- _vbo_DestroyContext( radeon->glCtx );
- _swrast_DestroyContext( radeon->glCtx );
+ radeon->vtbl.free_context(&radeon->glCtx);
+ _swsetup_DestroyContext( &radeon->glCtx );
+ _tnl_DestroyContext( &radeon->glCtx );
+ _vbo_DestroyContext( &radeon->glCtx );
+ _swrast_DestroyContext( &radeon->glCtx );
/* free atom list */
- /* free the Mesa context */
- _mesa_destroy_context(radeon->glCtx);
+ /* free the Mesa context data */
+ _mesa_free_context_data(&radeon->glCtx);
- /* _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 option cache */
driDestroyOptionCache(&radeon->optionCache);
radeon_destroy_atom_list(radeon);
- if (radeon->state.scissor.pClipRects) {
- FREE(radeon->state.scissor.pClipRects);
- radeon->state.scissor.pClipRects = 0;
- }
#ifdef RADEON_BO_TRACK
track = fopen("/tmp/tracklog", "w");
if (track) {
fclose(track);
}
#endif
- FREE(radeon);
+ free(radeon);
}
/* Force the context `c' to be unbound from its buffer.
radeonContextPtr radeon = (radeonContextPtr) driContextPriv->driverPrivate;
if (RADEON_DEBUG & RADEON_DRI)
- fprintf(stderr, "%s ctx %p\n", __FUNCTION__,
- radeon->glCtx);
+ fprintf(stderr, "%s ctx %p\n", __func__,
+ &radeon->glCtx);
/* Unset current context and dispath table */
_mesa_make_current(NULL, NULL, NULL);
static unsigned
radeon_bits_per_pixel(const struct radeon_renderbuffer *rb)
{
- return _mesa_get_format_bytes(rb->base.Format) * 8;
+ return _mesa_get_format_bytes(rb->base.Base.Format) * 8;
}
/*
*/
void radeon_prepare_render(radeonContextPtr radeon)
{
- __DRIcontext *driContext = radeon->dri.context;
+ __DRIcontext *driContext = radeon->driContext;
__DRIdrawable *drawable;
__DRIscreen *screen;
radeon_update_renderbuffers(driContext, drawable, GL_FALSE);
/* Intel driver does the equivalent of this, no clue if it is needed:*/
- radeon_draw_buffer(radeon->glCtx, radeon->glCtx->DrawBuffer);
+ radeon_draw_buffer(&radeon->glCtx, radeon->glCtx.DrawBuffer);
driContext->dri2.draw_stamp = drawable->dri2.stamp;
}
rb->cpp = buffers[i].cpp;
rb->pitch = buffers[i].pitch;
- rb->base.Width = drawable->w;
- rb->base.Height = drawable->h;
+ rb->base.Base.Width = drawable->w;
+ rb->base.Base.Height = drawable->h;
rb->has_surface = 0;
if (buffers[i].attachment == __DRI_BUFFER_STENCIL && depth_bo) {
}
}
- driUpdateFramebufferSize(radeon->glCtx, drawable);
+ driUpdateFramebufferSize(&radeon->glCtx, drawable);
}
/* Force the context `c' to be the current context and associate with it
__DRIdrawable * driReadPriv)
{
radeonContextPtr radeon;
+ GET_CURRENT_CONTEXT(curCtx);
struct gl_framebuffer *drfb, *readfb;
+ if (driContextPriv)
+ radeon = (radeonContextPtr)driContextPriv->driverPrivate;
+ else
+ radeon = NULL;
+ /* According to the glXMakeCurrent() man page: "Pending commands to
+ * the previous context, if any, are flushed before it is released."
+ * But only flush if we're actually changing contexts.
+ */
+
+ if ((radeonContextPtr)curCtx && (radeonContextPtr)curCtx != radeon) {
+ _mesa_flush(curCtx);
+ }
+
if (!driContextPriv) {
if (RADEON_DEBUG & RADEON_DRI)
- fprintf(stderr, "%s ctx is null\n", __FUNCTION__);
+ fprintf(stderr, "%s ctx is null\n", __func__);
_mesa_make_current(NULL, NULL, NULL);
return GL_TRUE;
}
- radeon = (radeonContextPtr) driContextPriv->driverPrivate;
-
if(driDrawPriv == NULL && driReadPriv == NULL) {
- drfb = _mesa_create_framebuffer(&radeon->glCtx->Visual);
+ drfb = _mesa_create_framebuffer(&radeon->glCtx.Visual);
readfb = drfb;
}
else {
if (driDrawPriv != driReadPriv)
radeon_update_renderbuffers(driContextPriv, driReadPriv, GL_FALSE);
_mesa_reference_renderbuffer(&radeon->state.color.rb,
- &(radeon_get_renderbuffer(drfb, BUFFER_BACK_LEFT)->base));
+ &(radeon_get_renderbuffer(drfb, BUFFER_BACK_LEFT)->base.Base));
_mesa_reference_renderbuffer(&radeon->state.depth.rb,
- &(radeon_get_renderbuffer(drfb, BUFFER_DEPTH)->base));
+ &(radeon_get_renderbuffer(drfb, BUFFER_DEPTH)->base.Base));
if (RADEON_DEBUG & RADEON_DRI)
- fprintf(stderr, "%s ctx %p dfb %p rfb %p\n", __FUNCTION__, radeon->glCtx, drfb, readfb);
+ fprintf(stderr, "%s ctx %p dfb %p rfb %p\n", __func__, &radeon->glCtx, drfb, readfb);
if(driDrawPriv)
- driUpdateFramebufferSize(radeon->glCtx, driDrawPriv);
+ driUpdateFramebufferSize(&radeon->glCtx, driDrawPriv);
if (driReadPriv != driDrawPriv)
- driUpdateFramebufferSize(radeon->glCtx, driReadPriv);
+ driUpdateFramebufferSize(&radeon->glCtx, driReadPriv);
- _mesa_make_current(radeon->glCtx, drfb, readfb);
+ _mesa_make_current(&radeon->glCtx, drfb, readfb);
if (driDrawPriv == NULL && driReadPriv == NULL)
_mesa_reference_framebuffer(&drfb, NULL);
- _mesa_update_state(radeon->glCtx);
+ _mesa_update_state(&radeon->glCtx);
- if (radeon->glCtx->DrawBuffer == drfb) {
+ if (radeon->glCtx.DrawBuffer == drfb) {
if(driDrawPriv != NULL) {
radeon_window_moved(radeon);
}
- radeon_draw_buffer(radeon->glCtx, drfb);
+ radeon_draw_buffer(&radeon->glCtx, drfb);
}
if (RADEON_DEBUG & RADEON_DRI)
- fprintf(stderr, "End %s\n", __FUNCTION__);
+ fprintf(stderr, "End %s\n", __func__);
return GL_TRUE;
}