extend some DrawRangeElements cases to support rendering more than 65535 verts in...
authorAapo Tahkola <aet@rasterburn.org>
Tue, 22 Aug 2006 21:54:50 +0000 (21:54 +0000)
committerAapo Tahkola <aet@rasterburn.org>
Tue, 22 Aug 2006 21:54:50 +0000 (21:54 +0000)
src/mesa/drivers/dri/r300/r300_context.h
src/mesa/drivers/dri/r300/r300_render.c
src/mesa/drivers/dri/r300/radeon_vtxfmt_a.c

index 4867790951900bc60fbb5c2810efda23dc49ae0e..1acb6a6c9448b747ed6989a5023244c5525a3f47 100644 (file)
@@ -847,6 +847,8 @@ extern GLboolean r300CreateContext(const __GLcontextModes * glVisual,
                                   __DRIcontextPrivate * driContextPriv,
                                   void *sharedContextPrivate);
 
+extern int r300_get_num_verts(r300ContextPtr rmesa, int num_verts, int prim);
+
 void r300_translate_vertex_shader(struct r300_vertex_program *vp);
 extern void r300InitShaderFuncs(struct dd_function_table *functions);
 extern int r300VertexProgUpdateParams(GLcontext *ctx, struct r300_vertex_program *vp, float *dst);
index 0f1e567a910a39f8b2c82f9c1eb2f19b8ab9e43a..c49567d69e9a66ab5e2897108ea47a62d9489a63 100644 (file)
@@ -113,10 +113,7 @@ static int r300_get_primitive_type(r300ContextPtr rmesa, GLcontext *ctx, int pri
    return type;
 }
 
-static int r300_get_num_verts(r300ContextPtr rmesa,
-       GLcontext *ctx,
-       int num_verts,
-       int prim)
+int r300_get_num_verts(r300ContextPtr rmesa, int num_verts, int prim)
 {
        int verts_off=0;
        char *name="UNKNOWN";
@@ -286,7 +283,7 @@ static void r300_render_vb_primitive(r300ContextPtr rmesa,
    int type, num_verts;
 
    type=r300_get_primitive_type(rmesa, ctx, prim);
-   num_verts=r300_get_num_verts(rmesa, ctx, end-start, prim);
+   num_verts=r300_get_num_verts(rmesa, end-start, prim);
 
    if(type<0 || num_verts <= 0)return;
 
index cbd837fa725cee74495a74ab3c18f3623f10f5b3..7f539b437760256524bf066faebe51ef3ceee63d 100644 (file)
@@ -344,6 +344,22 @@ static void radeonDrawElements( GLenum mode, GLsizei count, GLenum type, const G
        _mesa_install_exec_vtxfmt( ctx, &TNL_CONTEXT(ctx)->exec_vtxfmt );
 }
 
+static int elt_bytes(GLenum type)
+{
+       switch (type) {
+       case GL_UNSIGNED_BYTE:
+               return 1;
+       case GL_UNSIGNED_SHORT:
+               return 2;
+       case GL_UNSIGNED_INT:
+               return 4;
+       default:
+               _mesa_problem(NULL, "bad elt type in %s", __FUNCTION__);
+               return 0;
+       }
+       return 0;
+}
+
 static void radeonDrawRangeElements(GLenum mode, GLuint min, GLuint max, GLsizei count, GLenum type, const GLvoid *c_indices)
 {
        GET_CURRENT_CONTEXT(ctx);
@@ -356,6 +372,25 @@ static void radeonDrawRangeElements(GLenum mode, GLuint min, GLuint max, GLsizei
        const GLvoid *indices = c_indices;
        
        if (count > 65535) {
+               /* TODO */
+               if (mode == GL_POINTS ||
+                   mode == GL_LINES ||
+                   mode == GL_QUADS ||
+                   mode == GL_TRIANGLES) {
+                       
+                       if (!_mesa_validate_DrawRangeElements( ctx, mode, min, max, count, type, indices ))
+                               return;
+                       
+                       while (count) {
+                               i = r300_get_num_verts(rmesa, MIN2(count, 65535), mode);
+                               
+                               radeonDrawRangeElements(mode, min, max, i, type, indices);
+                               
+                               indices += i * elt_bytes(type);
+                               count -= i;
+                       }
+                       return ;
+               }
                WARN_ONCE("Too many verts!\n");
                goto fallback;
        }
@@ -506,7 +541,6 @@ static void radeonDrawArrays( GLenum mode, GLint start, GLsizei count )
        GET_CURRENT_CONTEXT(ctx);
        r300ContextPtr rmesa = R300_CONTEXT(ctx);
        struct tnl_prim prim;
-       int i;
        
        if (count > 65535) {
                WARN_ONCE("Too many verts!\n");