Compiled arrays for vtxfmt_a path.
authorAapo Tahkola <aet@rasterburn.org>
Fri, 28 Oct 2005 09:28:32 +0000 (09:28 +0000)
committerAapo Tahkola <aet@rasterburn.org>
Fri, 28 Oct 2005 09:28:32 +0000 (09:28 +0000)
src/mesa/drivers/dri/r300/r300_context.h
src/mesa/drivers/dri/r300/r300_ioctl.c
src/mesa/drivers/dri/r300/r300_shader.c
src/mesa/drivers/dri/r300/r300_state.c
src/mesa/drivers/dri/r300/radeon_vtxfmt_a.c

index 96f4ff6afa74e385186de7cc06b4c731152b222e..0ece8f8d1f4e8d9e484300282fef7e2ed83b1f5d 100644 (file)
@@ -52,6 +52,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //#define RADEON_VTXFMT_A
 //#define HW_VBOS
 //#define OPTIMIZE_ELTS
+//#define CB_DPATH
 
 struct r300_context;
 typedef struct r300_context r300ContextRec;
index 56a5ec9473aa2ea3a1df238fb9df750f5aac3e68..79411e1dba7b60be745b8f794f8f89fcc279c807 100644 (file)
@@ -55,8 +55,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #include "vblank.h"
 
-//#define CB_DPATH
-
 #define CLEARBUFFER_COLOR      0x1
 #define CLEARBUFFER_DEPTH      0x2
 #define CLEARBUFFER_STENCIL    0x4
index aa9645e163e40d94c8e40b10e2891ef19aaca860..b8e951d17125759888c1e0f0bbe2aac1ec6ff50d 100644 (file)
@@ -40,6 +40,7 @@ static struct program *r300NewProgram(GLcontext *ctx, GLenum target, GLuint id)
        struct ati_fragment_shader *afs;
        
        switch(target){
+               case GL_VERTEX_STATE_PROGRAM_NV:
                case GL_VERTEX_PROGRAM_ARB:
                        vp=CALLOC_STRUCT(r300_vertex_program);
                        return _mesa_init_vertex_program(ctx, &vp->mesa_program, target, id);
index 6ab7d97faf67959bdb5efec0827cc1285a6a6b11..e3aa74b1023f487c78a4a048fdf14a8c9a07408e 100644 (file)
@@ -1257,7 +1257,7 @@ void r300_setup_rs_unit(GLcontext *ctx)
 
        r300->hw.rc.cmd[1] = 0
                        | (cur_reg /* count */ << R300_RS_CNTL_TC_CNT_SHIFT)
-                       | R300_RS_CNTL_0_UNKNOWN_7
+                       | (1 << R300_RS_CNTL_CI_CNT_SHIFT)
                        | R300_RS_CNTL_0_UNKNOWN_18;
 
        if (r300->state.texture.tc_count > 0) {
@@ -1867,6 +1867,10 @@ static void r300InvalidateState(GLcontext * ctx, GLuint new_state)
 
        /* Go inefficiency! */
        r300ResetHwState(r300);
+#ifdef HW_VBOS
+       if(new_state & _NEW_ARRAY)
+               r300->state.VB.lock_uptodate = GL_FALSE;
+#endif
 }
 
 /**
index d1f90abfb249a1a585837d320b496206d25a40fd..b6292bb00e1c28b3aebfd2dcc551285db9bf1416 100644 (file)
@@ -249,7 +249,7 @@ void radeonDrawElements( GLenum mode, GLsizei count, GLenum type, const GLvoid *
                radeon_mm_use(rmesa, rvb.buf->id);
 }
 
-void radeonDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices)
+void radeonDrawRangeElements(GLenum mode, GLuint min, GLuint max, GLsizei count, GLenum type, const GLvoid *indices)
 {
        GET_CURRENT_CONTEXT(ctx);
        r300ContextPtr rmesa = R300_CONTEXT(ctx);
@@ -270,7 +270,7 @@ void radeonDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei coun
                ADD_POINTERS(ctx->Array.ElementArrayBufferObj->Data, (const GLubyte *) indices);
        }
        
-       if (!_mesa_validate_DrawRangeElements( ctx, mode, start, end, count, type, indices ))
+       if (!_mesa_validate_DrawRangeElements( ctx, mode, min, max, count, type, indices ))
                return;
        
        FLUSH_CURRENT( ctx, 0 );
@@ -288,7 +288,7 @@ void radeonDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei coun
                ptr = rvb.address + rvb.start;
                
                for(i=0; i < count; i++)
-                       ((unsigned short int *)ptr)[i] = ((unsigned char *)indices)[i] - start;
+                       ((unsigned short int *)ptr)[i] = ((unsigned char *)indices)[i] - min;
        break;
        
        case GL_UNSIGNED_SHORT:
@@ -305,7 +305,7 @@ void radeonDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei coun
                ptr = rvb.address + rvb.start;
 
                for(i=0; i < count; i++)
-                       ((unsigned short int *)ptr)[i] = ((unsigned short int *)indices)[i] - start;
+                       ((unsigned short int *)ptr)[i] = ((unsigned short int *)indices)[i] - min;
        break;
        
        case GL_UNSIGNED_INT:
@@ -316,7 +316,7 @@ void radeonDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei coun
                ptr = rvb.address + rvb.start;
                
                for(i=0; i < count; i++)
-                       ((unsigned int *)ptr)[i] = ((unsigned int *)indices)[i] - start;
+                       ((unsigned int *)ptr)[i] = ((unsigned int *)indices)[i] - min;
        break;
        
        default:
@@ -325,26 +325,56 @@ void radeonDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei coun
        
        }
        
-       if(setup_arrays(rmesa, start))
-               return;
+       /* XXX: setup_arrays before state update? */
        
        if (ctx->NewState) 
                _mesa_update_state( ctx );
        
        r300UpdateShaderStates(rmesa);
 
-       rmesa->state.VB.Count = (end - start) + 1;
+       if (rmesa->state.VB.LockCount) {
+               if (rmesa->state.VB.lock_uptodate == GL_FALSE) {
+                       if (setup_arrays(rmesa, rmesa->state.VB.LockFirst))
+                               return;
+                       
+                       rmesa->state.VB.Count = rmesa->state.VB.LockCount;
+                       
+                       r300ReleaseArrays(ctx);
+                       r300EmitArraysVtx(ctx, GL_FALSE);
+                       
+                       rmesa->state.VB.lock_uptodate = GL_TRUE;
+               }
+               
+               if (min < rmesa->state.VB.LockFirst) {
+                       WARN_ONCE("Out of range min %d vs %d!\n", min, rmesa->state.VB.LockFirst);
+                       return;
+               }
+               
+               /*if (max >= rmesa->state.VB.LockFirst + rmesa->state.VB.LockCount) {
+                       WARN_ONCE("Out of range max %d vs %d!\n", max, rmesa->state.VB.LockFirst +
+                                       rmesa->state.VB.LockCount);
+                       return;
+               }*/
+       } else {
+               if (setup_arrays(rmesa, min))
+                       return;
+               rmesa->state.VB.Count = max - min + 1;
+       }
+       
        rmesa->state.VB.Primitive = &prim;
        rmesa->state.VB.PrimitiveCount = 1;
        
        prim.mode = mode | PRIM_BEGIN | PRIM_END;
-       prim.start = 0;
+       if (rmesa->state.VB.LockCount)
+               prim.start = min - rmesa->state.VB.LockFirst;
+       else
+               prim.start = 0;
        prim.count = count;
        
        rmesa->state.VB.Elts = ptr;
        rmesa->state.VB.elt_size = elt_size;
-       rmesa->state.VB.elt_min = start;
-       rmesa->state.VB.elt_max = end;
+       rmesa->state.VB.elt_min = min;
+       rmesa->state.VB.elt_max = max;
        
        r300_run_vb_render_vtxfmt_a(ctx, NULL);
        
@@ -366,31 +396,47 @@ void radeonDrawArrays( GLenum mode, GLint start, GLsizei count )
        if (ctx->NewState) 
                _mesa_update_state( ctx );
        
-       if (rmesa->state.VB.LockCount == 0)
-               if (setup_arrays(rmesa, start))
-                       return;
+       /* XXX: setup_arrays before state update? */
        
        r300UpdateShaderStates(rmesa);
-       
+
        if (rmesa->state.VB.LockCount) {
-               start -= rmesa->state.VB.LockFirst;
-               if (start < 0) { /* Generate error */
-                       WARN_ONCE("Out of range!\n");
+               if (rmesa->state.VB.lock_uptodate == GL_FALSE) {
+                       if (setup_arrays(rmesa, rmesa->state.VB.LockFirst))
+                               return;
+                       
+                       rmesa->state.VB.Count = rmesa->state.VB.LockCount;
+                       
+                       r300ReleaseArrays(ctx);
+                       r300EmitArraysVtx(ctx, GL_FALSE);
+                       
+                       rmesa->state.VB.lock_uptodate = GL_TRUE;
+               }
+               
+               if (start < rmesa->state.VB.LockFirst) {
+                       WARN_ONCE("Out of range min %d vs %d!\n", start, rmesa->state.VB.LockFirst);
                        return;
                }
-       }
                
-       if (rmesa->state.VB.LockCount == 0)
+               if (start + count - 1 >= rmesa->state.VB.LockFirst + rmesa->state.VB.LockCount) { /* XXX */
+                       WARN_ONCE("Out of range max %d vs %d!\n", start + count - 1, rmesa->state.VB.LockFirst +
+                                       rmesa->state.VB.LockCount);
+                       return;
+               }
+       } else {
+               if (setup_arrays(rmesa, start))
+                       return;
                rmesa->state.VB.Count = count;
+       }
+
        rmesa->state.VB.Primitive = &prim;
        rmesa->state.VB.PrimitiveCount = 1;
        
        prim.mode = mode | PRIM_BEGIN | PRIM_END;
-       if (ctx->Array.LockCount == 0)
-               prim.start = 0;
+       if (rmesa->state.VB.LockCount)
+               prim.start = start - rmesa->state.VB.LockFirst;
        else
-               prim.start = start;
-       
+               prim.start = 0;
        prim.count = count;
        
        rmesa->state.VB.Elts = NULL;
@@ -423,12 +469,18 @@ void radeonLockArraysEXT(GLcontext *ctx, GLint first, GLsizei count)
        r300ContextPtr rmesa = R300_CONTEXT(ctx);
        int i;
        
-       /* Disabled as array changes arent properly handled yet. */
+       /* Only when CB_DPATH is defined.
+          r300Clear tampers over the aos setup without it.
+          (r300ResetHwState cannot call r300EmitArrays)
+        */
+#ifndef CB_DPATH
        first = 0; count = 0;
+#endif
        
        if (first < 0 || count <= 0) {
                rmesa->state.VB.LockFirst = 0;
                rmesa->state.VB.LockCount = 0;
+               rmesa->state.VB.lock_uptodate = GL_FALSE;
                return ;
        }
        
@@ -443,6 +495,7 @@ void radeonUnlockArraysEXT(GLcontext *ctx)
        
        rmesa->state.VB.LockFirst = 0;
        rmesa->state.VB.LockCount = 0;
+       rmesa->state.VB.lock_uptodate = GL_FALSE;
 }
 
 struct gl_buffer_object *