nouveau: Always render offscreen, emulate front buffer rendering.
[mesa.git] / src / mesa / drivers / dri / nouveau / nouveau_span.c
index f990a8907eab929a3d1646ec9a3e179e7b965233..453bc5f6c49f7d384cefdc5a4fc055c33d5bc930 100644 (file)
@@ -28,6 +28,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "nouveau_context.h"
 #include "nouveau_span.h"
 #include "nouveau_fifo.h"
+#include "nouveau_lock.h"
 
 #include "swrast/swrast.h"
 
@@ -36,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_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);       \
    GLuint p;                                                           \
    (void) p;
 
@@ -63,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"
 
 
@@ -74,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
@@ -108,14 +116,11 @@ void nouveauSpanInitFunctions( GLcontext *ctx )
  * Plug in the Get/Put routines for the given driRenderbuffer.
  */
 void
-nouveauSpanSetFunctions(driRenderbuffer *drb, const GLvisual *vis)
+nouveauSpanSetFunctions(nouveau_renderbuffer_t *nrb)
 {
-   if (drb->Base.InternalFormat == GL_RGBA) {
-      if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) {
-         nouveauInitPointers_RGB565(&drb->Base);
-      }
-      else {
-         nouveauInitPointers_ARGB8888(&drb->Base);
-      }
-   }
+   if (nrb->mesa._ActualFormat == GL_RGBA8)
+      nouveauInitPointers_ARGB8888(&nrb->mesa);
+   else // if (nrb->mesa._ActualFormat == GL_RGB5)
+      nouveauInitPointers_RGB565(&nrb->mesa);
 }
+