summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri/savage
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2005-05-04 20:11:35 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2005-05-04 20:11:35 +0000
commite4b2356c07d31fbeeabb13b2fb47db703b473080 (patch)
treed8b7f1c7c9e7c84d84349485f942dd205dd4c16d /src/mesa/drivers/dri/savage
parentebef61f5c0950572f9c6a81b08f447957461675c (diff)
Major check-in of changes for GL_EXT_framebuffer_object extension.
Main driver impacts: - new code for creating the Mesa GLframebuffer - new span/pixel read/write code Some drivers not yet updated/tested.
Diffstat (limited to 'src/mesa/drivers/dri/savage')
-rw-r--r--src/mesa/drivers/dri/savage/savage_init.h10
-rw-r--r--src/mesa/drivers/dri/savage/savage_xmesa.c81
-rw-r--r--src/mesa/drivers/dri/savage/savagedd.c3
-rw-r--r--src/mesa/drivers/dri/savage/savageioctl.c16
-rw-r--r--src/mesa/drivers/dri/savage/savagespan.c74
-rw-r--r--src/mesa/drivers/dri/savage/savagespan.h9
-rw-r--r--src/mesa/drivers/dri/savage/savagestate.c6
7 files changed, 173 insertions, 26 deletions
diff --git a/src/mesa/drivers/dri/savage/savage_init.h b/src/mesa/drivers/dri/savage/savage_init.h
index 9cf8e66b7c..0dec397b7b 100644
--- a/src/mesa/drivers/dri/savage/savage_init.h
+++ b/src/mesa/drivers/dri/savage/savage_init.h
@@ -80,6 +80,16 @@ typedef struct {
} savageScreenPrivate;
+/**
+ * savageRenderbuffer, derived from Mesa's gl_renderbuffer
+ */
+typedef struct {
+ struct gl_renderbuffer Base;
+ /* XXX per-window info should go here */
+ int foo, bar;
+} savageRenderbuffer;
+
+
#include "savagecontext.h"
extern void savageGetLock( savageContextPtr imesa, GLuint flags );
diff --git a/src/mesa/drivers/dri/savage/savage_xmesa.c b/src/mesa/drivers/dri/savage/savage_xmesa.c
index 485bc77458..aeb314681e 100644
--- a/src/mesa/drivers/dri/savage/savage_xmesa.c
+++ b/src/mesa/drivers/dri/savage/savage_xmesa.c
@@ -29,7 +29,8 @@
#include "savagecontext.h"
#include "context.h"
#include "matrix.h"
-
+#include "framebuffer.h"
+#include "renderbuffer.h"
#include "simple_list.h"
#include "utils.h"
@@ -588,25 +589,85 @@ savageDestroyContext(__DRIcontextPrivate *driContextPriv)
}
}
+
static GLboolean
savageCreateBuffer( __DRIscreenPrivate *driScrnPriv,
__DRIdrawablePrivate *driDrawPriv,
const __GLcontextModes *mesaVis,
GLboolean isPixmap)
{
+ savageScreenPrivate *screen = (savageScreenPrivate *) driScrnPriv->private;
+
if (isPixmap) {
return GL_FALSE; /* not implemented */
}
else {
GLboolean swStencil = mesaVis->stencilBits > 0 && mesaVis->depthBits != 24;
- driDrawPriv->driverPrivate = (void *)
+#if 0
+ driDrawPriv->driverPrivate = (void *)
_mesa_create_framebuffer(mesaVis,
GL_FALSE, /* software depth buffer? */
swStencil,
mesaVis->accumRedBits > 0,
mesaVis->alphaBits > 0 );
+#else
+ struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis);
+ /*
+ * XXX: this value needs to be set according to the config file
+ * setting. But we don't get that until we create a rendering
+ * context!!!!
+ */
+ GLboolean float_depth = GL_FALSE;
+
+ {
+ driRenderbuffer *frontRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ screen->frontOffset, screen->aperturePitch);
+ savageSetSpanFunctions(frontRb, mesaVis, float_depth);
+ _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base);
+ }
+
+ if (mesaVis->doubleBufferMode) {
+ driRenderbuffer *backRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ screen->backOffset, screen->aperturePitch);
+ savageSetSpanFunctions(backRb, mesaVis, float_depth);
+ _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base);
+ }
- return (driDrawPriv->driverPrivate != NULL);
+ if (mesaVis->depthBits == 16) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT16, screen->cpp,
+ screen->depthOffset, screen->aperturePitch);
+ savageSetSpanFunctions(depthRb, mesaVis, float_depth);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+ else if (mesaVis->depthBits == 24) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT24, screen->cpp,
+ screen->depthOffset, screen->aperturePitch);
+ savageSetSpanFunctions(depthRb, mesaVis, float_depth);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+
+ if (mesaVis->stencilBits > 0 && !swStencil) {
+ driRenderbuffer *stencilRb
+ = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT, screen->cpp,
+ screen->depthOffset, screen->aperturePitch);
+ savageSetSpanFunctions(stencilRb, mesaVis, float_depth);
+ _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &stencilRb->Base);
+ }
+
+ _mesa_add_soft_renderbuffers(fb,
+ GL_FALSE, /* color */
+ GL_FALSE, /* depth */
+ swStencil,
+ mesaVis->accumRedBits > 0,
+ GL_FALSE, /* alpha */
+ GL_FALSE /* aux */);
+ driDrawPriv->driverPrivate = (void *) fb;
+#endif
+ return (driDrawPriv->driverPrivate != NULL);
}
}
@@ -670,11 +731,11 @@ static void savageXMesaWindowMoved( savageContextPtr imesa )
if (0)
fprintf(stderr, "savageXMesaWindowMoved\n\n");
- switch (imesa->glCtx->Color._DrawDestMask[0]) {
- case DD_FRONT_LEFT_BIT:
+ switch (imesa->glCtx->DrawBuffer->_ColorDrawBufferMask[0]) {
+ case BUFFER_BIT_FRONT_LEFT:
savageXMesaSetFrontClipRects( imesa );
break;
- case DD_BACK_LEFT_BIT:
+ case BUFFER_BIT_BACK_LEFT:
savageXMesaSetBackClipRects( imesa );
break;
default:
@@ -742,15 +803,15 @@ savageMakeCurrent(__DRIcontextPrivate *driContextPriv,
imesa->mesa_drawable = driDrawPriv;
imesa->dirty = ~0;
- _mesa_make_current2(imesa->glCtx,
- (GLframebuffer *) driDrawPriv->driverPrivate,
- (GLframebuffer *) driReadPriv->driverPrivate);
+ _mesa_make_current(imesa->glCtx,
+ (GLframebuffer *) driDrawPriv->driverPrivate,
+ (GLframebuffer *) driReadPriv->driverPrivate);
savageXMesaWindowMoved( imesa );
}
else
{
- _mesa_make_current(NULL, NULL);
+ _mesa_make_current(NULL, NULL, NULL);
}
return GL_TRUE;
}
diff --git a/src/mesa/drivers/dri/savage/savagedd.c b/src/mesa/drivers/dri/savage/savagedd.c
index 639b335be7..72d7d33ce3 100644
--- a/src/mesa/drivers/dri/savage/savagedd.c
+++ b/src/mesa/drivers/dri/savage/savagedd.c
@@ -24,6 +24,7 @@
#include "mtypes.h"
+#include "framebuffer.h"
#include <stdio.h>
@@ -113,6 +114,6 @@ static void savageBufferSize(GLframebuffer *buffer, GLuint *width, GLuint *heigh
void savageDDInitDriverFuncs( GLcontext *ctx )
{
ctx->Driver.GetBufferSize = savageBufferSize;
- ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
+ ctx->Driver.ResizeBuffers = _mesa_resize_framebuffer;
ctx->Driver.GetString = savageDDGetString;
}
diff --git a/src/mesa/drivers/dri/savage/savageioctl.c b/src/mesa/drivers/dri/savage/savageioctl.c
index e68f58cccf..30d008e1be 100644
--- a/src/mesa/drivers/dri/savage/savageioctl.c
+++ b/src/mesa/drivers/dri/savage/savageioctl.c
@@ -367,28 +367,28 @@ static void savageDDClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
flags = 0;
- if (mask & DD_FRONT_LEFT_BIT) {
+ if (mask & BUFFER_BIT_FRONT_LEFT) {
flags |= SAVAGE_FRONT;
- mask &= ~DD_FRONT_LEFT_BIT;
+ mask &= ~BUFFER_BIT_FRONT_LEFT;
}
- if (mask & DD_BACK_LEFT_BIT) {
+ if (mask & BUFFER_BIT_BACK_LEFT) {
flags |= SAVAGE_BACK;
- mask &= ~DD_BACK_LEFT_BIT;
+ mask &= ~BUFFER_BIT_BACK_LEFT;
}
- if ((mask & DD_DEPTH_BIT) && ctx->Depth.Mask) {
+ if ((mask & BUFFER_BIT_DEPTH) && ctx->Depth.Mask) {
flags |= SAVAGE_DEPTH;
depthMask |=
(imesa->savageScreen->zpp == 2) ? 0xffffffff : 0x00ffffff;
- mask &= ~DD_DEPTH_BIT;
+ mask &= ~BUFFER_BIT_DEPTH;
}
- if((mask & DD_STENCIL_BIT) && imesa->hw_stencil)
+ if((mask & BUFFER_BIT_STENCIL) && imesa->hw_stencil)
{
flags |= SAVAGE_DEPTH;
depthMask |= 0xff000000;
- mask &= ~DD_STENCIL_BIT;
+ mask &= ~BUFFER_BIT_STENCIL;
}
savageFlushVertices(imesa);
diff --git a/src/mesa/drivers/dri/savage/savagespan.c b/src/mesa/drivers/dri/savage/savagespan.c
index 4fad537ba6..acdfde097b 100644
--- a/src/mesa/drivers/dri/savage/savagespan.c
+++ b/src/mesa/drivers/dri/savage/savagespan.c
@@ -230,9 +230,9 @@ static void savageDDSetBuffer(GLcontext *ctx, GLframebuffer *buffer,
savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
char *map;
- assert((bufferBit == DD_FRONT_LEFT_BIT) || (bufferBit == DD_BACK_LEFT_BIT));
+ assert((bufferBit == BUFFER_BIT_FRONT_LEFT) || (bufferBit == BUFFER_BIT_BACK_LEFT));
- map = (bufferBit == DD_FRONT_LEFT_BIT)
+ map = (bufferBit == BUFFER_BIT_FRONT_LEFT)
? imesa->apertureBase[TARGET_FRONT]
: imesa->apertureBase[TARGET_BACK];
@@ -306,15 +306,18 @@ void savageDDInitSpanFuncs( GLcontext *ctx )
swdd->SetBuffer = savageDDSetBuffer;
+#if 0
switch (imesa->savageScreen->cpp)
{
case 2: savageInitPointers_565( swdd ); break;
case 4: savageInitPointers_8888( swdd );
}
+#endif
switch (imesa->savageScreen->zpp)
{
case 2:
+#if 0
if (imesa->float_depth) {
swdd->ReadDepthSpan = savageReadDepthSpan_16f;
swdd->WriteDepthSpan = savageWriteDepthSpan_16f;
@@ -328,9 +331,10 @@ void savageDDInitSpanFuncs( GLcontext *ctx )
swdd->ReadDepthPixels = savageReadDepthPixels_16;
swdd->WriteDepthPixels = savageWriteDepthPixels_16;
}
-
+#endif
break;
- case 4:
+ case 4:
+#if 0
if (imesa->float_depth) {
swdd->ReadDepthSpan = savageReadDepthSpan_8_24f;
swdd->WriteDepthSpan = savageWriteDepthSpan_8_24f;
@@ -348,6 +352,7 @@ void savageDDInitSpanFuncs( GLcontext *ctx )
swdd->WriteStencilSpan = savageWriteStencilSpan_8_24;
swdd->ReadStencilPixels = savageReadStencilPixels_8_24;
swdd->WriteStencilPixels = savageWriteStencilPixels_8_24;
+#endif
break;
}
@@ -369,3 +374,64 @@ void savageDDInitSpanFuncs( GLcontext *ctx )
ctx->Driver.DrawPixels = savageDrawPixels;
ctx->Driver.ReadPixels = savageReadPixels;
}
+
+
+
+/**
+ * Plug in the Get/Put routines for the given driRenderbuffer.
+ */
+void
+savageSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis,
+ GLboolean float_depth)
+{
+ if (drb->Base.InternalFormat == GL_RGBA) {
+ if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) {
+ savageInitPointers_565(&drb->Base);
+ }
+ else {
+ savageInitPointers_8888(&drb->Base);
+ }
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
+ if (float_depth) {
+ drb->Base.GetRow = savageReadDepthSpan_16f;
+ drb->Base.GetValues = savageReadDepthPixels_16f;
+ drb->Base.PutRow = savageWriteDepthSpan_16f;
+ drb->Base.PutMonoRow = savageWriteMonoDepthSpan_16f;
+ drb->Base.PutValues = savageWriteDepthPixels_16f;
+ }
+ else {
+ drb->Base.GetRow = savageReadDepthSpan_16;
+ drb->Base.GetValues = savageReadDepthPixels_16;
+ drb->Base.PutRow = savageWriteDepthSpan_16;
+ drb->Base.PutMonoRow = savageWriteMonoDepthSpan_16;
+ drb->Base.PutValues = savageWriteDepthPixels_16;
+ }
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
+ if (float_depth) {
+ drb->Base.GetRow = savageReadDepthSpan_8_24f;
+ drb->Base.GetValues = savageReadDepthPixels_8_24f;
+ drb->Base.PutRow = savageWriteDepthSpan_8_24f;
+ drb->Base.PutMonoRow = savageWriteMonoDepthSpan_8_24f;
+ drb->Base.PutValues = savageWriteDepthPixels_8_24f;
+ }
+ else {
+ drb->Base.GetRow = savageReadDepthSpan_8_24;
+ drb->Base.GetValues = savageReadDepthPixels_8_24;
+ drb->Base.PutRow = savageWriteDepthSpan_8_24;
+ drb->Base.PutMonoRow = savageWriteMonoDepthSpan_8_24;
+ drb->Base.PutValues = savageWriteDepthPixels_8_24;
+ }
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
+ drb->Base.GetRow = savageReadStencilSpan_8_24;
+ drb->Base.GetValues = savageReadStencilPixels_8_24;
+ drb->Base.PutRow = savageWriteStencilSpan_8_24;
+ drb->Base.PutMonoRow = savageWriteMonoStencilSpan_8_24;
+ drb->Base.PutValues = savageWriteStencilPixels_8_24;
+ drb->Base.PutMonoValues = NULL;
+ }
+}
diff --git a/src/mesa/drivers/dri/savage/savagespan.h b/src/mesa/drivers/dri/savage/savagespan.h
index cb3a1b52fd..f6a312e820 100644
--- a/src/mesa/drivers/dri/savage/savagespan.h
+++ b/src/mesa/drivers/dri/savage/savagespan.h
@@ -25,8 +25,16 @@
#ifndef _SAVAGE_SPAN_H
#define _SAVAGE_SPAN_H
+#include "drirenderbuffer.h"
+
+
extern void savageDDInitSpanFuncs( GLcontext *ctx );
+extern void
+savageSetSpanFunctions(driRenderbuffer *rb, const GLvisual *vis,
+ GLboolean float_depth);
+
+
/*
* Savage 16-bit float depth format with zExpOffset=16:
* 4 bit unsigned exponent, 12 bit mantissa
@@ -125,4 +133,5 @@ static __inline GLdouble savageDecodeFloat24( GLuint x )
}
#undef _1
+
#endif
diff --git a/src/mesa/drivers/dri/savage/savagestate.c b/src/mesa/drivers/dri/savage/savagestate.c
index 7b58c817a2..567b979733 100644
--- a/src/mesa/drivers/dri/savage/savagestate.c
+++ b/src/mesa/drivers/dri/savage/savagestate.c
@@ -644,8 +644,8 @@ static void savageDDDrawBuffer(GLcontext *ctx, GLenum mode )
/*
* _DrawDestMask is easier to cope with than <mode>.
*/
- switch ( ctx->Color._DrawDestMask[0] ) {
- case DD_FRONT_LEFT_BIT:
+ switch ( ctx->DrawBuffer->_ColorDrawBufferMask[0] ) {
+ case BUFFER_BIT_FRONT_LEFT:
imesa->IsDouble = GL_FALSE;
imesa->regs.s4.destCtrl.ni.offset = imesa->savageScreen->frontOffset>>11;
@@ -653,7 +653,7 @@ static void savageDDDrawBuffer(GLcontext *ctx, GLenum mode )
savageXMesaSetFrontClipRects( imesa );
FALLBACK( ctx, SAVAGE_FALLBACK_DRAW_BUFFER, GL_FALSE );
break;
- case DD_BACK_LEFT_BIT:
+ case BUFFER_BIT_BACK_LEFT:
imesa->IsDouble = GL_TRUE;
imesa->regs.s4.destCtrl.ni.offset = imesa->savageScreen->backOffset>>11;
imesa->NotFirstFrame = GL_FALSE;