mesa: Branch 'master' - 3 commits

Ben Skeggs darktama at kemper.freedesktop.org
Sat Dec 23 13:13:01 UTC 2006


 src/mesa/drivers/dri/nouveau/nouveau_buffers.c |   60 +++++++++++++++++--------
 src/mesa/drivers/dri/nouveau/nouveau_context.h |    2 
 src/mesa/drivers/dri/nouveau/nouveau_fifo.c    |    7 ++
 src/mesa/drivers/dri/nouveau/nouveau_screen.c  |    8 +--
 src/mesa/drivers/dri/nouveau/nouveau_span.c    |   23 ++++++---
 src/mesa/drivers/dri/nouveau/nouveau_state.c   |   13 -----
 src/mesa/drivers/dri/nouveau/nv30_state.c      |   32 ++-----------
 7 files changed, 78 insertions(+), 67 deletions(-)

New commits:
diff-tree f54c725497cac19294e1465413d21a9416d4245f (from cb6a400dcd26089101c8a29a4eee198bd7ad9a58)
Author: Ben Skeggs <darktama at iinet.net.au>
Date:   Sun Dec 24 00:13:34 2006 +1100

    nouveau: Modify span routines to use nouveau_renderbuffer instead of driRenderbuffer

diff --git a/src/mesa/drivers/dri/nouveau/nouveau_buffers.c b/src/mesa/drivers/dri/nouveau/nouveau_buffers.c
index e3e2a80..f6a03ec 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_buffers.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_buffers.c
@@ -288,6 +288,12 @@ nouveau_build_framebuffer(GLcontext *ctx
    return GL_TRUE;
 }
 
+static void
+nouveauDrawBuffer(GLcontext *ctx, GLenum buffer)
+{
+   nouveau_build_framebuffer(ctx, ctx->DrawBuffer);
+}
+
 static struct gl_framebuffer *
 nouveauNewFramebuffer(GLcontext *ctx, GLuint name)
 {
@@ -341,6 +347,8 @@ nouveauFinishRenderTexture(GLcontext *ct
 void
 nouveauInitBufferFuncs(struct dd_function_table *func)
 {
+   func->DrawBuffer		 = nouveauDrawBuffer;
+
    func->NewFramebuffer		 = nouveauNewFramebuffer;
    func->NewRenderbuffer	 = nouveauNewRenderbuffer;
    func->BindFramebuffer	 = nouveauBindFramebuffer;
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_fifo.c b/src/mesa/drivers/dri/nouveau/nouveau_fifo.c
index 0b745e1..fcfc0eb 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_fifo.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_fifo.c
@@ -77,6 +77,12 @@ void nouveauWaitForIdleLocked(nouveauCon
 	FIRE_RING();
 	while(RING_AHEAD()>0);
 
+	/* We can't wait on PGRAPH going idle..
+	 *  1) We don't have the regs mapped
+	 *  2) PGRAPH may not go idle with multiple channels active
+	 * Look into replacing this with a NOTIFY/NOP + wait notifier sequence.
+	 */
+#if 0
 	for(i=0;i<1000000;i++) /* 1 second */
 	{
 		switch(nmesa->screen->card->type)
@@ -100,6 +106,7 @@ void nouveauWaitForIdleLocked(nouveauCon
 			return;
 		DO_USLEEP(1);
 	}
+#endif
 }
 
 void nouveauWaitForIdle(nouveauContextPtr nmesa)
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_span.c b/src/mesa/drivers/dri/nouveau/nouveau_span.c
index 6d99728..74dec66 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_span.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_span.c
@@ -37,12 +37,21 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define HAVE_HW_STENCIL_SPANS	0
 #define HAVE_HW_STENCIL_PIXELS	0
 
+#define HW_CLIPLOOP()							\
+   do {									\
+      int _nc = nmesa->numClipRects;					\
+      while ( _nc-- ) {							\
+	 int minx = nmesa->pClipRects[_nc].x1 - nmesa->drawX;		\
+	 int miny = nmesa->pClipRects[_nc].y1 - nmesa->drawY;		\
+	 int maxx = nmesa->pClipRects[_nc].x2 - nmesa->drawX;		\
+	 int maxy = nmesa->pClipRects[_nc].y2 - nmesa->drawY;
+
 #define LOCAL_VARS							\
    nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);			\
-   __DRIscreenPrivate *sPriv = nmesa->driScreen;			\
-   __DRIdrawablePrivate *dPriv = nmesa->driDrawable;			\
-   driRenderbuffer *drb = (driRenderbuffer *) rb;			\
-   GLuint height = dPriv->h;						\
+   nouveau_renderbuffer *nrb = (nouveau_renderbuffer *)rb;		\
+   GLuint height = nrb->mesa.Height;					\
+   GLubyte *map = (GLubyte *)(nrb->map ? nrb->map : nrb->mem->map) +    \
+	 (nmesa->drawY * nrb->pitch) + (nmesa->drawX * nrb->cpp);       \
    GLuint p;								\
    (void) p;
 
@@ -64,8 +73,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #define TAG(x)    nouveau##x##_RGB565
 #define TAG2(x,y) nouveau##x##_RGB565##y
-#define GET_PTR(X,Y) (sPriv->pFB + drb->flippedOffset		\
-     + ((dPriv->y + (Y)) * drb->flippedPitch + (dPriv->x + (X))) * drb->cpp)
+#define GET_PTR(X,Y) (map + (Y)*nrb->pitch + (X)*nrb->cpp)
 #include "spantmp2.h"
 
 
@@ -75,8 +83,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #define TAG(x)    nouveau##x##_ARGB8888
 #define TAG2(x,y) nouveau##x##_ARGB8888##y
-#define GET_PTR(X,Y) (sPriv->pFB + drb->flippedOffset		\
-     + ((dPriv->y + (Y)) * drb->flippedPitch + (dPriv->x + (X))) * drb->cpp)
+#define GET_PTR(X,Y) (map + (Y)*nrb->pitch + (X)*nrb->cpp)
 #include "spantmp2.h"
 
 static void
diff-tree cb6a400dcd26089101c8a29a4eee198bd7ad9a58 (from ae8d8d132600cc544b7295c9554e6531bdbd8094)
Author: Ben Skeggs <darktama at iinet.net.au>
Date:   Sat Dec 23 23:51:24 2006 +1100

    nouveau: maintain numClipRects/pClipRects in context.

diff --git a/src/mesa/drivers/dri/nouveau/nouveau_buffers.c b/src/mesa/drivers/dri/nouveau/nouveau_buffers.c
index 0a5efa8..e3e2a80 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_buffers.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_buffers.c
@@ -214,10 +214,46 @@ nouveau_renderbuffer_new(GLenum internal
    return nrb;
 }
 
+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;
+}
+
+static void
+nouveau_cliprects_renderbuffer_set(nouveauContextPtr nmesa,
+      				   nouveau_renderbuffer *nrb)
+{
+   nmesa->numClipRects	= 1;
+   nmesa->pClipRects	= &nmesa->osClipRect;
+   nmesa->osClipRect.x1	= 0;
+   nmesa->osClipRect.y1	= 0;
+   nmesa->osClipRect.x2	= nrb->mesa.Width;
+   nmesa->osClipRect.y2	= nrb->mesa.Height;
+   nmesa->drawX		= 0;
+   nmesa->drawY		= 0;
+}
+
 void
 nouveau_window_moved(GLcontext *ctx)
 {
    nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
+   nouveau_renderbuffer *nrb;
+
+   nrb = (nouveau_renderbuffer *)ctx->DrawBuffer->_ColorDrawBuffers[0][0];
+   if (!nrb)
+      return;
+
+   if (!nrb->dPriv)
+      nouveau_cliprects_renderbuffer_set(nmesa, nrb);
+   else
+      nouveau_cliprects_drawable_set(nmesa, nrb);
 
    /* Viewport depends on window size/position, nouveauCalcViewport
     * will take care of calling the hw-specific WindowMoved
@@ -252,26 +288,6 @@ nouveau_build_framebuffer(GLcontext *ctx
    return GL_TRUE;
 }
 
-nouveau_renderbuffer *
-nouveau_current_draw_buffer(GLcontext *ctx)
-{
-   struct gl_framebuffer *fb = ctx->DrawBuffer;
-   nouveau_renderbuffer *nrb;
-
-   if (!fb)
-      return NULL;
-
-   if (fb->_ColorDrawBufferMask[0] == BUFFER_BIT_FRONT_LEFT)
-      nrb = (nouveau_renderbuffer *)
-	 fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer;
-   else if (fb->_ColorDrawBufferMask[0] == BUFFER_BIT_BACK_LEFT)
-      nrb = (nouveau_renderbuffer *)
-	 fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer;
-   else
-      nrb = NULL;
-   return nrb;
-}
-
 static struct gl_framebuffer *
 nouveauNewFramebuffer(GLcontext *ctx, GLuint name)
 {
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.h b/src/mesa/drivers/dri/nouveau/nouveau_context.h
index d7730bd..ea28506 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_context.h
+++ b/src/mesa/drivers/dri/nouveau/nouveau_context.h
@@ -134,6 +134,8 @@ typedef struct nouveau_context {
 	/* Cliprects information */
 	GLuint numClipRects;
 	drm_clip_rect_t *pClipRects;
+	drm_clip_rect_t osClipRect;
+	GLuint drawX, drawY;
 
 	/* The rendering context information */
 	GLenum current_primitive; /* the current primitive enum */
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_state.c b/src/mesa/drivers/dri/nouveau/nouveau_state.c
index d3c233e..8df334d 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_state.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_state.c
@@ -62,22 +62,11 @@ static void nouveauCalcViewport(GLcontex
     nouveau_renderbuffer *nrb;
     const GLfloat *v = ctx->Viewport._WindowMap.m;
     GLfloat *m = nmesa->viewport.m;
-    GLfloat xoffset, yoffset;
+    GLfloat xoffset = nmesa->drawX, yoffset = nmesa->drawY;
     GLint h = 0;
   
-    nrb = nouveau_current_draw_buffer(ctx);
     nmesa->depth_scale = 1.0 / ctx->DrawBuffer->_DepthMaxF;
 
-    if (nrb && nrb->dPriv) {
-       /* Window */
-       xoffset = nrb->dPriv->x;
-       yoffset = nrb->dPriv->y;
-    } else {
-       /* Offscreen or back buffer */
-       xoffset = 0.0;
-       yoffset = 0.0;
-    }
-
     m[MAT_SX] =   v[MAT_SX];
     m[MAT_TX] =   v[MAT_TX] + xoffset + SUBPIXEL_X;
     m[MAT_SY] = - v[MAT_SY];
diff --git a/src/mesa/drivers/dri/nouveau/nv30_state.c b/src/mesa/drivers/dri/nouveau/nv30_state.c
index 35b428b..7ccf5f9 100644
--- a/src/mesa/drivers/dri/nouveau/nv30_state.c
+++ b/src/mesa/drivers/dri/nouveau/nv30_state.c
@@ -575,19 +575,15 @@ static void nv30Scissor(GLcontext *ctx, 
         nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
 	nouveau_renderbuffer *nrb;
 
-	/* Adjust offsets if drawing to a window */
-	nrb = nouveau_current_draw_buffer(ctx);
-	if (nrb && nrb->dPriv) {
-	   x += nrb->dPriv->x;
-	   y += nrb->dPriv->y;
-	}
-
 	/* There's no scissor enable bit, so adjust the scissor to cover the
 	 * maximum draw buffer bounds
 	 */
 	if (!ctx->Scissor.Enabled) {
 	   x = y = 0;
 	   w = h = 4095;
+	} else {
+	   x += nmesa->drawX;
+	   y += nmesa->drawY;
 	}
 
         BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_SCISSOR_WIDTH_XPOS, 2);
@@ -685,15 +681,8 @@ static void nv30WindowMoved(nouveauConte
 	GLfloat *v = nmesa->viewport.m;
 	GLuint w = ctx->Viewport.Width;
 	GLuint h = ctx->Viewport.Height;
-	GLuint x = ctx->Viewport.X;
-	GLuint y = ctx->Viewport.Y;
-
-	/* Adjust offsets if drawing to a window */
-	nrb = nouveau_current_draw_buffer(ctx);
-	if (nrb && nrb->dPriv) {
-	   x += nrb->dPriv->x;
-	   y += nrb->dPriv->y;
-	}
+	GLuint x = ctx->Viewport.X + nmesa->drawX;
+	GLuint y = ctx->Viewport.Y + nmesa->drawY;
 
         BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_VIEWPORT_DIMS_0, 2);
         OUT_RING_CACHE((w << 16) | x);
@@ -773,17 +762,10 @@ static GLboolean nv30BindBuffers(nouveau
    nouveau_renderbuffer *nrb;
    GLuint x, y, w, h;
 
-   /* Adjust offsets if drawing to a window */
-   nrb = nouveau_current_draw_buffer(nmesa->glCtx);
    w = nrb->mesa.Width;
    h = nrb->mesa.Height;
-   if (nrb && nrb->dPriv) {
-      x = nrb->dPriv->x;
-      y = nrb->dPriv->y;
-   } else {
-      x = 0;
-      y = 0;
-   }
+   x = nmesa->drawX;
+   y = nmesa->drawY;
 
    if (num_color != 1)
       return GL_FALSE;
diff-tree ae8d8d132600cc544b7295c9554e6531bdbd8094 (from 1dd6759c059e054a9a2279d2339a5bd8bb83f6b4)
Author: Ben Skeggs <darktama at iinet.net.au>
Date:   Sat Dec 23 23:03:55 2006 +1100

    nouveau: Don't fill nrb->dPriv for private buffers

diff --git a/src/mesa/drivers/dri/nouveau/nouveau_buffers.c b/src/mesa/drivers/dri/nouveau/nouveau_buffers.c
index f30e593..0a5efa8 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_buffers.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_buffers.c
@@ -152,7 +152,7 @@ nouveau_renderbuffer_storage(GLcontext *
 
    /* If this buffer isn't statically alloc'd, we may need to ask the
     * drm for more memory */
-   if (!nrb->map && (rb->Width != width || rb->Height != height)) {
+   if (!nrb->dPriv && (rb->Width != width || rb->Height != height)) {
       GLuint pitch;
 
       /* align pitches to 64 bytes */
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_screen.c b/src/mesa/drivers/dri/nouveau/nouveau_screen.c
index 140db49..99992b8 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_screen.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_screen.c
@@ -152,7 +152,7 @@ nouveauCreateBuffer(__DRIscreenPrivate *
 		if (mesaVis->doubleBufferMode) {
 			nrb = nouveau_renderbuffer_new(color_format, NULL,
 						       0, 0,
-						       driDrawPriv);
+						       NULL);
 			nouveauSpanSetFunctions(nrb, mesaVis);
 			_mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &nrb->mesa);
 		}
@@ -160,20 +160,20 @@ nouveauCreateBuffer(__DRIscreenPrivate *
 		if (mesaVis->depthBits == 24 && mesaVis->stencilBits == 8) {
 			nrb = nouveau_renderbuffer_new(GL_DEPTH24_STENCIL8_EXT, NULL,
 						       0, 0,
-						       driDrawPriv);
+						       NULL);
 			nouveauSpanSetFunctions(nrb, mesaVis);
 			_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,
-						       driDrawPriv);
+						       NULL);
 			nouveauSpanSetFunctions(nrb, mesaVis);
 			_mesa_add_renderbuffer(fb, BUFFER_DEPTH, &nrb->mesa);
 		} else if (mesaVis->depthBits == 16) {
 			nrb = nouveau_renderbuffer_new(GL_DEPTH_COMPONENT16, NULL,
 						       0, 0,
-						       driDrawPriv);
+						       NULL);
 			nouveauSpanSetFunctions(nrb, mesaVis);
 			_mesa_add_renderbuffer(fb, BUFFER_DEPTH, &nrb->mesa);
 		}
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_state.c b/src/mesa/drivers/dri/nouveau/nouveau_state.c
index cec7120..d3c233e 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_state.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_state.c
@@ -68,7 +68,7 @@ static void nouveauCalcViewport(GLcontex
     nrb = nouveau_current_draw_buffer(ctx);
     nmesa->depth_scale = 1.0 / ctx->DrawBuffer->_DepthMaxF;
 
-    if (nrb && nrb->map) {
+    if (nrb && nrb->dPriv) {
        /* Window */
        xoffset = nrb->dPriv->x;
        yoffset = nrb->dPriv->y;
diff --git a/src/mesa/drivers/dri/nouveau/nv30_state.c b/src/mesa/drivers/dri/nouveau/nv30_state.c
index 4169dad..35b428b 100644
--- a/src/mesa/drivers/dri/nouveau/nv30_state.c
+++ b/src/mesa/drivers/dri/nouveau/nv30_state.c
@@ -577,7 +577,7 @@ static void nv30Scissor(GLcontext *ctx, 
 
 	/* Adjust offsets if drawing to a window */
 	nrb = nouveau_current_draw_buffer(ctx);
-	if (nrb && nrb->map) {
+	if (nrb && nrb->dPriv) {
 	   x += nrb->dPriv->x;
 	   y += nrb->dPriv->y;
 	}
@@ -690,7 +690,7 @@ static void nv30WindowMoved(nouveauConte
 
 	/* Adjust offsets if drawing to a window */
 	nrb = nouveau_current_draw_buffer(ctx);
-	if (nrb && nrb->map) {
+	if (nrb && nrb->dPriv) {
 	   x += nrb->dPriv->x;
 	   y += nrb->dPriv->y;
 	}
@@ -777,7 +777,7 @@ static GLboolean nv30BindBuffers(nouveau
    nrb = nouveau_current_draw_buffer(nmesa->glCtx);
    w = nrb->mesa.Width;
    h = nrb->mesa.Height;
-   if (nrb && nrb->map) {
+   if (nrb && nrb->dPriv) {
       x = nrb->dPriv->x;
       y = nrb->dPriv->y;
    } else {



More information about the mesa-commit mailing list