mesa/r300classic: Fix dri2Invalidate/radeon_prepare_render for page flipping.
[mesa.git] / src / mesa / drivers / dri / r300 / r300_draw.c
index 4ae0d6fe48f38f030fd43e354b07575fca18654a..0c4d8537c61a53627edd1fb73def61c37fae5849 100644 (file)
@@ -75,7 +75,7 @@ static int getTypeSize(GLenum type)
        }
 }
 
-static void r300FixupIndexBuffer(GLcontext *ctx, const struct _mesa_index_buffer *mesa_ind_buf)
+static void r300FixupIndexBuffer(struct gl_context *ctx, const struct _mesa_index_buffer *mesa_ind_buf)
 {
        r300ContextPtr r300 = R300_CONTEXT(ctx);
        GLvoid *src_ptr;
@@ -143,7 +143,7 @@ static void r300FixupIndexBuffer(GLcontext *ctx, const struct _mesa_index_buffer
 }
 
 
-static void r300SetupIndexBuffer(GLcontext *ctx, const struct _mesa_index_buffer *mesa_ind_buf)
+static void r300SetupIndexBuffer(struct gl_context *ctx, const struct _mesa_index_buffer *mesa_ind_buf)
 {
        r300ContextPtr r300 = R300_CONTEXT(ctx);
 
@@ -177,7 +177,7 @@ static void r300SetupIndexBuffer(GLcontext *ctx, const struct _mesa_index_buffer
                radeon_bo_map(r300->ind_buf.bo, 1);
                assert(r300->ind_buf.bo->ptr != NULL);
                dst_ptr = ADD_POINTERS(r300->ind_buf.bo->ptr, r300->ind_buf.bo_offset);
-               _mesa_memcpy(dst_ptr, src_ptr, size);
+               memcpy(dst_ptr, src_ptr, size);
 
                radeon_bo_unmap(r300->ind_buf.bo);
                r300->ind_buf.is_32bit = (mesa_ind_buf->type == GL_UNSIGNED_INT);
@@ -219,7 +219,7 @@ static void r300SetupIndexBuffer(GLcontext *ctx, const struct _mesa_index_buffer
  * Convert attribute data type to float
  * If the attribute uses named buffer object replace the bo with newly allocated bo
  */
-static void r300ConvertAttrib(GLcontext *ctx, int count, const struct gl_client_array *input, struct vertex_attribute *attr)
+static void r300ConvertAttrib(struct gl_context *ctx, int count, const struct gl_client_array *input, struct vertex_attribute *attr)
 {
        r300ContextPtr r300 = R300_CONTEXT(ctx);
        const GLvoid *src_ptr;
@@ -290,7 +290,7 @@ static void r300ConvertAttrib(GLcontext *ctx, int count, const struct gl_client_
        }
 }
 
-static void r300AlignDataToDword(GLcontext *ctx, const struct gl_client_array *input, int count, struct vertex_attribute *attr)
+static void r300AlignDataToDword(struct gl_context *ctx, const struct gl_client_array *input, int count, struct vertex_attribute *attr)
 {
        r300ContextPtr r300 = R300_CONTEXT(ctx);
        const int dst_stride = (input->StrideB + 3) & ~3;
@@ -314,7 +314,7 @@ static void r300AlignDataToDword(GLcontext *ctx, const struct gl_client_array *i
                int i;
 
                for (i = 0; i < count; ++i) {
-                       _mesa_memcpy(dst_ptr, src_ptr, input->StrideB);
+                       memcpy(dst_ptr, src_ptr, input->StrideB);
                        src_ptr += input->StrideB;
                        dst_ptr += dst_stride;
                }
@@ -328,11 +328,11 @@ static void r300AlignDataToDword(GLcontext *ctx, const struct gl_client_array *i
        attr->stride = dst_stride;
 }
 
-static void r300TranslateAttrib(GLcontext *ctx, GLuint attr, int count, const struct gl_client_array *input)
+static void r300TranslateAttrib(struct gl_context *ctx, GLuint attr, int count, const struct gl_client_array *input)
 {
        r300ContextPtr r300 = R300_CONTEXT(ctx);
        struct r300_vertex_buffer *vbuf = &r300->vbuf;
-       struct vertex_attribute r300_attr;
+       struct vertex_attribute r300_attr = { 0 };
        GLenum type;
        GLuint stride;
 
@@ -467,7 +467,7 @@ static void r300TranslateAttrib(GLcontext *ctx, GLuint attr, int count, const st
        ++vbuf->num_attribs;
 }
 
-static void r300SetVertexFormat(GLcontext *ctx, const struct gl_client_array *arrays[], int count)
+static void r300SetVertexFormat(struct gl_context *ctx, const struct gl_client_array *arrays[], int count)
 {
        r300ContextPtr r300 = R300_CONTEXT(ctx);
        struct r300_vertex_buffer *vbuf = &r300->vbuf;
@@ -497,7 +497,7 @@ static void r300SetVertexFormat(GLcontext *ctx, const struct gl_client_array *ar
                return;
 }
 
-static void r300AllocDmaRegions(GLcontext *ctx, const struct gl_client_array *input[], int count)
+static void r300AllocDmaRegions(struct gl_context *ctx, const struct gl_client_array *input[], int count)
 {
        r300ContextPtr r300 = R300_CONTEXT(ctx);
        struct r300_vertex_buffer *vbuf = &r300->vbuf;
@@ -523,8 +523,7 @@ static void r300AllocDmaRegions(GLcontext *ctx, const struct gl_client_array *in
                        r300ConvertAttrib(ctx, count, input[i], &vbuf->attribs[index]);
                } else {
                        if (input[i]->BufferObj->Name) {
-                               if (stride % 4 != 0) {
-                                       assert(((intptr_t) input[i]->Ptr) % input[i]->StrideB == 0);
+                               if (stride % 4 != 0 || (intptr_t)input[i]->Ptr % 4 != 0) {
                                        r300AlignDataToDword(ctx, input[i], count, &vbuf->attribs[index]);
                                        vbuf->attribs[index].is_named_bo = GL_FALSE;
                                } else {
@@ -579,7 +578,7 @@ static void r300AllocDmaRegions(GLcontext *ctx, const struct gl_client_array *in
 
 }
 
-static void r300FreeData(GLcontext *ctx)
+static void r300FreeData(struct gl_context *ctx)
 {
        /* Need to zero tcl.aos[n].bo and tcl.elt_dma_bo
         * to prevent double unref in radeonReleaseArrays
@@ -605,7 +604,7 @@ static void r300FreeData(GLcontext *ctx)
        }
 }
 
-static GLuint r300PredictTryDrawPrimsSize(GLcontext *ctx,
+static GLuint r300PredictTryDrawPrimsSize(struct gl_context *ctx,
                GLuint nr_prims, const struct _mesa_prim *prim)
 {
        struct r300_context *r300 = R300_CONTEXT(ctx);
@@ -642,7 +641,7 @@ static GLuint r300PredictTryDrawPrimsSize(GLcontext *ctx,
        return dwords;
 }
 
-static GLboolean r300TryDrawPrims(GLcontext *ctx,
+static GLboolean r300TryDrawPrims(struct gl_context *ctx,
                                         const struct gl_client_array *arrays[],
                                         const struct _mesa_prim *prim,
                                         GLuint nr_prims,
@@ -708,7 +707,7 @@ static GLboolean r300TryDrawPrims(GLcontext *ctx,
        return GL_TRUE;
 }
 
-static void r300DrawPrims(GLcontext *ctx,
+static void r300DrawPrims(struct gl_context *ctx,
                         const struct gl_client_array *arrays[],
                         const struct _mesa_prim *prim,
                         GLuint nr_prims,
@@ -718,6 +717,10 @@ static void r300DrawPrims(GLcontext *ctx,
                         GLuint max_index)
 {
        GLboolean retval;
+       struct r300_context *r300 = R300_CONTEXT(ctx);
+       radeonContextPtr radeon = &r300->radeon;
+
+       radeon_prepare_render(radeon);
 
        /* This check should get folded into just the places that
         * min/max index are really needed.
@@ -742,7 +745,7 @@ static void r300DrawPrims(GLcontext *ctx,
                _tnl_draw_prims(ctx, arrays, prim, nr_prims, ib, min_index, max_index);
 }
 
-void r300InitDraw(GLcontext *ctx)
+void r300InitDraw(struct gl_context *ctx)
 {
        struct vbo_context *vbo = vbo_context(ctx);