return GL_TRUE;
}
-static void nouveauDoSwapBuffers(nouveauContextPtr nmesa,
- __DRIdrawablePrivate *dPriv)
+void
+nouveauDoSwapBuffers(nouveauContextPtr nmesa, __DRIdrawablePrivate *dPriv)
{
struct gl_framebuffer *fb;
- nouveau_renderbuffer *src, *dst;
+ nouveauScreenPtr screen = dPriv->driScreenPriv->private;
+ nouveau_renderbuffer_t *src;
drm_clip_rect_t *box;
int nbox, i;
fb = (struct gl_framebuffer *)dPriv->driverPrivate;
- dst = (nouveau_renderbuffer*)
- fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer;
- src = (nouveau_renderbuffer*)
- fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer;
+ if (fb->_ColorDrawBufferMask[0] == BUFFER_BIT_FRONT_LEFT) {
+ src = (nouveau_renderbuffer_t *)
+ fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer;
+ } else {
+ src = (nouveau_renderbuffer_t *)
+ fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer;
+ }
#ifdef ALLOW_MULTI_SUBCHANNEL
LOCK_HARDWARE(nmesa);
OUT_RING (6); /* X8R8G8B8 */
else
OUT_RING (4); /* R5G6B5 */
- OUT_RING ((dst->pitch << 16) | src->pitch);
- OUT_RING (src->offset);
- OUT_RING (dst->offset);
+ OUT_RING(((screen->frontPitch * screen->fbFormat) << 16) |
+ src->pitch);
+ OUT_RING(src->offset);
+ OUT_RING(screen->frontOffset);
}
for (i=0; i<nbox; i++, box++) {
GLboolean (*InitCard)(struct nouveau_context *);
/* Update buffer offset/pitch/format */
GLboolean (*BindBuffers)(struct nouveau_context *, int num_color,
- nouveau_renderbuffer **color,
- nouveau_renderbuffer *depth);
+ nouveau_renderbuffer_t **color,
+ nouveau_renderbuffer_t *depth);
/* Update anything that depends on the window position/size */
void (*WindowMoved)(struct nouveau_context *);
} nouveau_hw_func;
extern GLboolean nouveauUnbindContext( __DRIcontextPrivate *driContextPriv );
+extern void nouveauDoSwapBuffers(nouveauContextPtr nmesa,
+ __DRIdrawablePrivate *dPriv);
+
extern void nouveauSwapBuffers(__DRIdrawablePrivate *dPriv);
extern void nouveauCopySubBuffer(__DRIdrawablePrivate *dPriv,
static void nouveauFlush( GLcontext *ctx )
{
nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
+
+ if (ctx->DrawBuffer->_ColorDrawBufferMask[0] == BUFFER_BIT_FRONT_LEFT)
+ nouveauDoSwapBuffers(nmesa, nmesa->driDrawable);
FIRE_RING();
}
static void nouveauFinish( GLcontext *ctx )
{
nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
+
nouveauFlush( ctx );
nouveauWaitForIdle( nmesa );
}
#include "nouveau_reg.h"
static GLboolean
-nouveau_renderbuffer_pixelformat(nouveau_renderbuffer * nrb,
+nouveau_renderbuffer_pixelformat(nouveau_renderbuffer_t * nrb,
GLenum internalFormat)
{
nrb->mesa.InternalFormat = internalFormat;
GLenum internalFormat,
GLuint width, GLuint height)
{
- nouveau_renderbuffer *nrb = (nouveau_renderbuffer *) rb;
+ nouveau_renderbuffer_t *nrb = (nouveau_renderbuffer_t *) rb;
if (!nouveau_renderbuffer_pixelformat(nrb, internalFormat)) {
fprintf(stderr, "%s: unknown internalFormat\n", __func__);
/* If this buffer isn't statically alloc'd, we may need to ask the
* drm for more memory */
- if (!nrb->dPriv && (rb->Width != width || rb->Height != height)) {
+ if (rb->Width != width || rb->Height != height) {
GLuint pitch;
/* align pitches to 64 bytes */
rb->Width = width;
rb->Height = height;
rb->InternalFormat = internalFormat;
+
+ nouveauSpanSetFunctions(nrb);
+
return GL_TRUE;
}
-static void nouveau_renderbuffer_delete(struct gl_renderbuffer *rb)
+static void
+nouveau_renderbuffer_delete(struct gl_renderbuffer *rb)
{
GET_CURRENT_CONTEXT(ctx);
- nouveau_renderbuffer *nrb = (nouveau_renderbuffer *) rb;
+ nouveau_renderbuffer_t *nrb = (nouveau_renderbuffer_t *) rb;
if (nrb->mem)
nouveau_mem_free(ctx, nrb->mem);
FREE(nrb);
}
-nouveau_renderbuffer *nouveau_renderbuffer_new(GLenum internalFormat,
- GLvoid * map, GLuint offset,
- GLuint pitch,
- __DRIdrawablePrivate *
- dPriv)
+nouveau_renderbuffer_t *
+nouveau_renderbuffer_new(GLenum internalFormat)
{
- nouveau_renderbuffer *nrb;
+ nouveau_renderbuffer_t *nrb;
- nrb = CALLOC_STRUCT(nouveau_renderbuffer_t);
- if (nrb) {
- _mesa_init_renderbuffer(&nrb->mesa, 0);
-
- nouveau_renderbuffer_pixelformat(nrb, internalFormat);
+ nrb = CALLOC_STRUCT(nouveau_renderbuffer);
+ if (!nrb)
+ return NULL;
- nrb->mesa.AllocStorage = nouveau_renderbuffer_storage;
- nrb->mesa.Delete = nouveau_renderbuffer_delete;
+ _mesa_init_renderbuffer(&nrb->mesa, 0);
- nrb->dPriv = dPriv;
- nrb->offset = offset;
- nrb->pitch = pitch;
- nrb->map = map;
+ if (!nouveau_renderbuffer_pixelformat(nrb, internalFormat)) {
+ fprintf(stderr, "%s: unknown internalFormat\n", __func__);
+ return GL_FALSE;
}
- return nrb;
-}
+ nrb->mesa.AllocStorage = nouveau_renderbuffer_storage;
+ nrb->mesa.Delete = nouveau_renderbuffer_delete;
-static void
-nouveau_cliprects_drawable_set(nouveauContextPtr nmesa,
- nouveau_renderbuffer * nrb)
-{
- __DRIdrawablePrivate *dPriv = nrb->dPriv;
-
- nmesa->numClipRects = dPriv->numClipRects;
- nmesa->pClipRects = dPriv->pClipRects;
- nmesa->drawX = dPriv->x;
- nmesa->drawY = dPriv->y;
- nmesa->drawW = dPriv->w;
- nmesa->drawH = dPriv->h;
+ return nrb;
}
static void
nouveau_cliprects_renderbuffer_set(nouveauContextPtr nmesa,
- nouveau_renderbuffer * nrb)
+ nouveau_renderbuffer_t * nrb)
{
nmesa->numClipRects = 1;
nmesa->pClipRects = &nmesa->osClipRect;
nmesa->drawH = nrb->mesa.Height;
}
-void nouveau_window_moved(GLcontext * ctx)
+void
+nouveau_window_moved(GLcontext * ctx)
{
nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
- nouveau_renderbuffer *nrb;
+ nouveau_renderbuffer_t *nrb;
- nrb = (nouveau_renderbuffer *)ctx->DrawBuffer->_ColorDrawBuffers[0][0];
+ nrb = (nouveau_renderbuffer_t *)
+ ctx->DrawBuffer->_ColorDrawBuffers[0][0];
if (!nrb)
return;
- if (!nrb->dPriv)
- nouveau_cliprects_renderbuffer_set(nmesa, nrb);
- else
- nouveau_cliprects_drawable_set(nmesa, nrb);
+ nouveau_cliprects_renderbuffer_set(nmesa, nrb);
/* Viewport depends on window size/position, nouveauCalcViewport
* will take care of calling the hw-specific WindowMoved
}
GLboolean
-nouveau_build_framebuffer(GLcontext * ctx, struct gl_framebuffer *fb)
+nouveau_build_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb)
{
nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
- nouveau_renderbuffer *color[MAX_DRAW_BUFFERS];
- nouveau_renderbuffer *depth;
+ nouveau_renderbuffer_t *color[MAX_DRAW_BUFFERS];
+ nouveau_renderbuffer_t *depth;
_mesa_update_framebuffer(ctx);
_mesa_update_draw_buffer_bounds(ctx);
- color[0] = (nouveau_renderbuffer *) fb->_ColorDrawBuffers[0][0];
+ color[0] = (nouveau_renderbuffer_t *) fb->_ColorDrawBuffers[0][0];
if (fb->_DepthBuffer && fb->_DepthBuffer->Wrapped)
- depth = (nouveau_renderbuffer *) fb->_DepthBuffer->Wrapped;
+ depth = (nouveau_renderbuffer_t *) fb->_DepthBuffer->Wrapped;
else
- depth = (nouveau_renderbuffer *) fb->_DepthBuffer;
+ depth = (nouveau_renderbuffer_t *) fb->_DepthBuffer;
if (!nmesa->hw_func.BindBuffers(nmesa, 1, color, depth))
return GL_FALSE;
return GL_TRUE;
}
-static void nouveauDrawBuffer(GLcontext * ctx, GLenum buffer)
+static void
+nouveauDrawBuffer(GLcontext *ctx, GLenum buffer)
{
nouveau_build_framebuffer(ctx, ctx->DrawBuffer);
}
-static struct gl_framebuffer *nouveauNewFramebuffer(GLcontext * ctx,
- GLuint name)
+static struct gl_framebuffer *
+nouveauNewFramebuffer(GLcontext *ctx, GLuint name)
{
return _mesa_new_framebuffer(ctx, name);
}
-static struct gl_renderbuffer *nouveauNewRenderbuffer(GLcontext * ctx,
- GLuint name)
+static struct gl_renderbuffer *
+nouveauNewRenderbuffer(GLcontext *ctx, GLuint name)
{
- nouveau_renderbuffer *nrb;
+ nouveau_renderbuffer_t *nrb;
- nrb = CALLOC_STRUCT(nouveau_renderbuffer_t);
- if (nrb) {
- _mesa_init_renderbuffer(&nrb->mesa, name);
+ nrb = CALLOC_STRUCT(nouveau_renderbuffer);
+ if (!nrb)
+ return NULL;
- nrb->mesa.AllocStorage = nouveau_renderbuffer_storage;
- nrb->mesa.Delete = nouveau_renderbuffer_delete;
- }
+ _mesa_init_renderbuffer(&nrb->mesa, name);
+
+ nrb->mesa.AllocStorage = nouveau_renderbuffer_storage;
+ nrb->mesa.Delete = nouveau_renderbuffer_delete;
return &nrb->mesa;
}
static void
-nouveauBindFramebuffer(GLcontext * ctx, GLenum target,
+nouveauBindFramebuffer(GLcontext *ctx, GLenum target,
struct gl_framebuffer *fb,
struct gl_framebuffer *fbread)
{
}
static void
-nouveauFramebufferRenderbuffer(GLcontext * ctx,
- struct gl_framebuffer *fb,
- GLenum attachment,
- struct gl_renderbuffer *rb)
+nouveauFramebufferRenderbuffer(GLcontext *ctx, struct gl_framebuffer *fb,
+ GLenum attachment, struct gl_renderbuffer *rb)
{
_mesa_framebuffer_renderbuffer(ctx, fb, attachment, rb);
nouveau_build_framebuffer(ctx, fb);
}
static void
-nouveauRenderTexture(GLcontext * ctx,
- struct gl_framebuffer *fb,
+nouveauRenderTexture(GLcontext * ctx, struct gl_framebuffer *fb,
struct gl_renderbuffer_attachment *att)
{
}
{
}
-void nouveauInitBufferFuncs(struct dd_function_table *func)
+void
+nouveauInitBufferFuncs(struct dd_function_table *func)
{
func->DrawBuffer = nouveauDrawBuffer;
func->RenderTexture = nouveauRenderTexture;
func->FinishRenderTexture = nouveauFinishRenderTexture;
}
+
#include "nouveau_mem.h"
-typedef struct nouveau_renderbuffer_t {
+typedef struct nouveau_renderbuffer {
struct gl_renderbuffer mesa; /* must be first! */
- __DRIdrawablePrivate *dPriv;
nouveau_mem *mem;
void *map;
int cpp;
uint32_t offset;
uint32_t pitch;
-} nouveau_renderbuffer;
+} nouveau_renderbuffer_t;
-extern nouveau_renderbuffer *nouveau_renderbuffer_new(GLenum internalFormat,
- GLvoid *map,
- GLuint offset,
- GLuint pitch,
- __DRIdrawablePrivate *);
+extern nouveau_renderbuffer_t *nouveau_renderbuffer_new(GLenum internalFormat);
extern void nouveau_window_moved(GLcontext *);
extern GLboolean nouveau_build_framebuffer(GLcontext *,
struct gl_framebuffer *);
-extern nouveau_renderbuffer *nouveau_current_draw_buffer(GLcontext *);
+extern nouveau_renderbuffer_t *nouveau_current_draw_buffer(GLcontext *);
extern void nouveauInitBufferFuncs(struct dd_function_table *);
GLboolean isPixmap)
{
nouveauScreenPtr screen = (nouveauScreenPtr) driScrnPriv->private;
- nouveau_renderbuffer *nrb;
+ nouveau_renderbuffer_t *nrb;
struct gl_framebuffer *fb;
const GLboolean swAccum = mesaVis->accumRedBits > 0;
- const GLboolean swStencil = mesaVis->stencilBits > 0 && mesaVis->depthBits != 24;
+ const GLboolean swStencil = (mesaVis->stencilBits > 0 &&
+ mesaVis->depthBits != 24);
GLenum color_format = screen->fbFormat == 4 ? GL_RGBA8 : GL_RGB5;
if (isPixmap)
return GL_FALSE;
/* Front buffer */
- nrb = nouveau_renderbuffer_new(color_format,
- driScrnPriv->pFB + screen->frontOffset,
- screen->frontOffset,
- screen->frontPitch * screen->fbFormat,
- driDrawPriv);
- nouveauSpanSetFunctions(nrb, mesaVis);
+ nrb = nouveau_renderbuffer_new(color_format);
_mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &nrb->mesa);
if (mesaVis->doubleBufferMode) {
- nrb = nouveau_renderbuffer_new(color_format, NULL, 0, 0, NULL);
- nouveauSpanSetFunctions(nrb, mesaVis);
+ nrb = nouveau_renderbuffer_new(color_format);
_mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &nrb->mesa);
}
if (mesaVis->depthBits == 24 && mesaVis->stencilBits == 8) {
- nrb = nouveau_renderbuffer_new(GL_DEPTH24_STENCIL8_EXT, NULL,
- 0, 0, NULL);
- nouveauSpanSetFunctions(nrb, mesaVis);
+ nrb = nouveau_renderbuffer_new(GL_DEPTH24_STENCIL8_EXT);
_mesa_add_renderbuffer(fb, BUFFER_DEPTH, &nrb->mesa);
_mesa_add_renderbuffer(fb, BUFFER_STENCIL, &nrb->mesa);
} else
if (mesaVis->depthBits == 24) {
- nrb = nouveau_renderbuffer_new(GL_DEPTH_COMPONENT24, NULL,
- 0, 0, NULL);
- nouveauSpanSetFunctions(nrb, mesaVis);
+ nrb = nouveau_renderbuffer_new(GL_DEPTH_COMPONENT24);
_mesa_add_renderbuffer(fb, BUFFER_DEPTH, &nrb->mesa);
} else
if (mesaVis->depthBits == 16) {
- nrb = nouveau_renderbuffer_new(GL_DEPTH_COMPONENT16, NULL,
- 0, 0, NULL);
- nouveauSpanSetFunctions(nrb, mesaVis);
+ nrb = nouveau_renderbuffer_new(GL_DEPTH_COMPONENT16);
_mesa_add_renderbuffer(fb, BUFFER_DEPTH, &nrb->mesa);
}
#define HAVE_HW_STENCIL_SPANS 0
#define HAVE_HW_STENCIL_PIXELS 0
-static char *fake_span[1280*1024*4];
-
#define HW_CLIPLOOP() \
do { \
int _nc = nmesa->numClipRects; \
#define LOCAL_VARS \
nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); \
- nouveau_renderbuffer *nrb = (nouveau_renderbuffer *)rb; \
+ nouveau_renderbuffer_t *nrb = (nouveau_renderbuffer_t *)rb; \
GLuint height = nrb->mesa.Height; \
GLubyte *map = (GLubyte *)(nrb->map ? nrb->map : nrb->mem->map) + \
(nmesa->drawY * nrb->pitch) + (nmesa->drawX * nrb->cpp); \
- map = fake_span; \
GLuint p; \
(void) p;
* Plug in the Get/Put routines for the given driRenderbuffer.
*/
void
-nouveauSpanSetFunctions(nouveau_renderbuffer *nrb, const GLvisual *vis)
+nouveauSpanSetFunctions(nouveau_renderbuffer_t *nrb)
{
if (nrb->mesa._ActualFormat == GL_RGBA8)
nouveauInitPointers_ARGB8888(&nrb->mesa);
else // if (nrb->mesa._ActualFormat == GL_RGB5)
nouveauInitPointers_RGB565(&nrb->mesa);
}
+
#include "drirenderbuffer.h"
#include "nouveau_fbo.h"
-extern void nouveauSpanInitFunctions( GLcontext *ctx );
-extern void nouveauSpanSetFunctions(nouveau_renderbuffer *nrb, const GLvisual *vis);
+extern void nouveauSpanInitFunctions(GLcontext *ctx);
+extern void nouveauSpanSetFunctions(nouveau_renderbuffer_t *nrb);
#endif /* __NOUVEAU_SPAN_H__ */
/* Update buffer offset/pitch/format */
static GLboolean nv04BindBuffers(nouveauContextPtr nmesa, int num_color,
- nouveau_renderbuffer **color,
- nouveau_renderbuffer *depth)
+ nouveau_renderbuffer_t **color,
+ nouveau_renderbuffer_t *depth)
{
GLuint x, y, w, h;
uint32_t depth_pitch=(depth?depth->pitch:0+15)&~15+16;
/* Update buffer offset/pitch/format */
static GLboolean nv10BindBuffers(nouveauContextPtr nmesa, int num_color,
- nouveau_renderbuffer **color,
- nouveau_renderbuffer *depth)
+ nouveau_renderbuffer_t **color,
+ nouveau_renderbuffer_t *depth)
{
GLuint x, y, w, h;
GLuint pitch, format, depth_pitch;
/* Update buffer offset/pitch/format */
static GLboolean nv20BindBuffers(nouveauContextPtr nmesa, int num_color,
- nouveau_renderbuffer **color,
- nouveau_renderbuffer *depth)
+ nouveau_renderbuffer_t **color,
+ nouveau_renderbuffer_t *depth)
{
GLuint x, y, w, h;
GLuint pitch, format, depth_pitch;
return GL_TRUE;
}
-static GLboolean nv30BindBuffers(nouveauContextPtr nmesa, int num_color,
- nouveau_renderbuffer **color,
- nouveau_renderbuffer *depth)
+static GLboolean
+nv30BindBuffers(nouveauContextPtr nmesa, int num_color,
+ nouveau_renderbuffer_t **color, nouveau_renderbuffer_t *depth)
{
GLuint x, y, w, h;
return GL_FALSE;
}
-static GLboolean nv50BindBuffers(nouveauContextPtr nmesa, int num_color,
- nouveau_renderbuffer **color,
- nouveau_renderbuffer *depth)
+static GLboolean
+nv50BindBuffers(nouveauContextPtr nmesa, int num_color,
+ nouveau_renderbuffer_t **color, nouveau_renderbuffer_t *depth)
{
return GL_FALSE;
}