Use SecondaryColorPtr, not ColorPtr[1] (the latter is NULL).
[mesa.git] / src / mesa / drivers / dri / sis / sis_span.c
index 202454a06afaba7e65df57e37c8a844b9e352a19..8f4b3af62ed2ccbd0bedd00fb8ffa3ab1a1ecb38 100644 (file)
@@ -18,7 +18,7 @@ Software.
 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
-ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ERIC ANHOLT OR SILICON INTEGRATED SYSTEMS CORP BE LIABLE FOR ANY CLAIM,
 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
 OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
 USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -34,6 +34,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #include "sis_context.h"
 #include "sis_span.h"
+#include "sis_lock.h"
+#include "sis_tris.h"
 
 #include "swrast/swrast.h"
 
@@ -141,10 +143,10 @@ do {                                                      \
 /* 16 bit depthbuffer functions.
  */
 #define WRITE_DEPTH( _x, _y, d )       \
-   *(GLushort *)(buf + _x*2 + _y*smesa->depthPitch) = d;
+   *(GLushort *)(buf + (_x)*2 + (_y)*smesa->depthPitch) = d;
 
 #define READ_DEPTH( d, _x, _y )                \
-   d = *(GLushort *)(buf + _x*2 + _y*smesa->depthPitch);
+   d = *(GLushort *)(buf + (_x)*2 + (_y)*smesa->depthPitch);
 
 #define TAG(x) sis##x##_16
 #include "depthtmp.h"
@@ -153,10 +155,10 @@ do {                                                      \
 /* 32 bit depthbuffer functions.
  */
 #define WRITE_DEPTH( _x, _y, d )       \
-   *(GLuint *)(buf + _x*4 + _y*smesa->depthPitch) = d;
+   *(GLuint *)(buf + (_x)*4 + (_y)*smesa->depthPitch) = d;
 
 #define READ_DEPTH( d, _x, _y )                \
-   d = *(GLuint *)(buf + _x*4 + _y*smesa->depthPitch);
+   d = *(GLuint *)(buf + (_x)*4 + (_y)*smesa->depthPitch);
 
 #define TAG(x) sis##x##_32
 #include "depthtmp.h"
@@ -165,28 +167,28 @@ do {                                                      \
 /* 8/24 bit interleaved depth/stencil functions
  */
 #define WRITE_DEPTH( _x, _y, d ) {                             \
-   GLuint tmp = *(GLuint *)(buf + _x*4 + _y*smesa->depthPitch); \
+   GLuint tmp = *(GLuint *)(buf + (_x)*4 + (_y)*smesa->depthPitch); \
    tmp &= 0xff000000;                                          \
    tmp |= (d & 0x00ffffff);                                    \
-   *(GLuint *)(buf + _x*4 + _y*smesa->depthPitch) = tmp;       \
+   *(GLuint *)(buf + (_x)*4 + (_y)*smesa->depthPitch) = tmp;   \
 }
 
 #define READ_DEPTH( d, _x, _y )        {                       \
-   d = *(GLuint *)(buf + _x*4 + _y*smesa->depthPitch) & 0x00ffffff; \
+   d = *(GLuint *)(buf + (_x)*4 + (_y)*smesa->depthPitch) & 0x00ffffff; \
 }
 
 #define TAG(x) sis##x##_24_8
 #include "depthtmp.h"
 
 #define WRITE_STENCIL( _x, _y, d ) {                           \
-   GLuint tmp = *(GLuint *)(buf + _x*4 + _y*smesa->depthPitch); \
+   GLuint tmp = *(GLuint *)(buf + (_x)*4 + (_y)*smesa->depthPitch); \
    tmp &= 0x00ffffff;                                          \
    tmp |= (d << 24);                                           \
-   *(GLuint *)(buf + _x*4 + _y*smesa->depthPitch) = tmp;       \
+   *(GLuint *)(buf + (_x)*4 + (_y)*smesa->depthPitch) = tmp;   \
 }
 
 #define READ_STENCIL( d, _x, _y )                      \
-   d = (*(GLuint *)(buf + _x*4 + _y*smesa->depthPitch) & 0xff000000) >> 24;
+   d = (*(GLuint *)(buf + (_x)*4 + (_y)*smesa->depthPitch) & 0xff000000) >> 24;
 
 #define TAG(x) sis##x##_24_8
 #include "stenciltmp.h"
@@ -203,11 +205,11 @@ static void sisDDSetBuffer( GLcontext *ctx,
    sisContextPtr smesa = SIS_CONTEXT(ctx);
 
    switch ( bufferBit ) {
-   case FRONT_LEFT_BIT:
+   case DD_FRONT_LEFT_BIT:
       smesa->drawOffset = smesa->readOffset = smesa->frontOffset;
       smesa->drawPitch  = smesa->readPitch  = smesa->frontPitch;
       break;
-   case BACK_LEFT_BIT:
+   case DD_BACK_LEFT_BIT:
       smesa->drawOffset = smesa->readOffset = smesa->backOffset;
       smesa->drawPitch  = smesa->readPitch  = smesa->backPitch;
       break;
@@ -216,16 +218,21 @@ static void sisDDSetBuffer( GLcontext *ctx,
    }
 }
 
-static void sisSpanRenderStart( GLcontext *ctx )
+void sisSpanRenderStart( GLcontext *ctx )
 {
    sisContextPtr smesa = SIS_CONTEXT(ctx);
 
+   SIS_FIREVERTICES(smesa);
+   LOCK_HARDWARE();
    WaitEngIdle( smesa );
 }
 
-static void sisSpanRenderFinish( GLcontext *ctx )
+void sisSpanRenderFinish( GLcontext *ctx )
 {
+   sisContextPtr smesa = SIS_CONTEXT(ctx);
+
    _swrast_flush( ctx );
+   UNLOCK_HARDWARE();
 }
 
 void
@@ -294,7 +301,7 @@ sisDDInitSpanFuncs( GLcontext *ctx )
       swdd->ReadRGBAPixels = sisReadRGBAPixels_8888;
       break;
     default:
-      assert(0);
+      sis_fatal_error("Bad bytesPerPixel.\n");
       break;
    }