cmd[0].i=cmdcpdelay(count);
}
+/* fire vertex buffer */
+static void inline fire_AOS(PREFIX int vertex_count, int type)
+{
+LOCAL_VARS
+check_space(9);
+
+start_packet3(RADEON_CP_PACKET3_3D_DRAW_VBUF_2, 0);
+/* e32(0x840c0024); */
+ e32(R300_VAP_VF_CNTL__PRIM_WALK_VERTEX_LIST | (vertex_count<<16) | type);
+}
+
+/* these are followed by the corresponding data */
+#define start_index32_packet(vertex_count, type) \
+ {\
+ int _vc;\
+ _vc=(vertex_count); \
+ start_packet3(RADEON_CP_PACKET3_3D_DRAW_INDX_2, _vc); \
+ e32(R300_VAP_VF_CNTL__PRIM_WALK_INDICES | (_vc<<16) | type \
+ | R300_VAP_VF_CNTL__INDEX_SIZE_32bit); \
+ }
+
+#define start_index16_packet(vertex_count, type) \
+ {\
+ int _vc, _n;\
+ _vc=(vertex_count); \
+ _n=(vertex_count+1)>>1; \
+ start_packet3(RADEON_CP_PACKET3_3D_DRAW_INDX_2, _n); \
+ e32(R300_VAP_VF_CNTL__PRIM_WALK_INDICES | (_vc<<16) | type); \
+ }
+
+/* Interestingly enough this ones needs the call to setup_AOS, even thought
+ some of the data so setup is not needed and some is not as arbitrary
+ as when used by DRAW_VBUF_2 or DRAW_INDX_2 */
+#define start_immediate_packet(vertex_count, type, vertex_size) \
+ {\
+ int _vc; \
+ _vc=(vertex_count); \
+ start_packet3(RADEON_CP_PACKET3_3D_DRAW_IMMD_2, _vc*(vertex_size)); \
+ e32(R300_VAP_VF_CNTL__PRIM_WALK_VERTEX_EMBEDDED | (_vc<<16) | type); \
+ }
+
#endif
#include "r300_program.h"
#include "r300_tex.h"
-#include "r300_lib.h"
-
+#include "r300_emit.h"
/**********************************************************************
* Hardware rasterization
/* We use the start part of GART texture buffer for vertices */
-static void upload_vertex_buffer(r300ContextPtr rmesa,
- GLcontext *ctx, AOS_DATA *array, int *n_arrays)
+static void upload_vertex_buffer(r300ContextPtr rmesa, GLcontext *ctx)
{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- struct vertex_buffer *VB = &tnl->vb;
- int idx=0;
- int i,j,k;
- radeonScreenPtr rsp=rmesa->radeon.radeonScreen;
-
- /* A hack - we don't want to overwrite vertex buffers, so we
- just use AGP space for them.. Fix me ! */
- static int offset=0;
- if(offset>2*1024*1024){
- //fprintf(stderr, "Wrapping agp vertex buffer offset\n");
- offset=0;
- }
- /* Not the most efficient implementation, but, for now, I just want something that
- works */
- /* to do - make single memcpy per column (is it possible ?) */
- /* to do - use dirty flags to avoid redundant copies */
-#define UPLOAD_VECTOR(v, r, f)\
- { \
- /* Is the data dirty ? */ \
- if (v->flags & ((1<<v->size)-1)) { \
- /* fprintf(stderr, "size=%d vs stride=%d\n", v->size, v->stride); */ \
- if(v->size*4==v->stride){\
- /* fast path */ \
- memcpy(rsp->gartTextures.map+offset, v->data, v->stride*VB->Count); \
- } else { \
- for(i=0;i<VB->Count;i++){ \
- /* copy one vertex at a time*/ \
- memcpy(rsp->gartTextures.map+offset+i*v->size*4, VEC_ELT(v, GLfloat, i), v->size*4); \
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ int idx=0;
+ int i,j,k;
+ radeonScreenPtr rsp=rmesa->radeon.radeonScreen;
+
+ /* A hack - we don't want to overwrite vertex buffers, so we
+ just use AGP space for them.. Fix me ! */
+ static int offset=0;
+ if(offset>2*1024*1024){
+ //fprintf(stderr, "Wrapping agp vertex buffer offset\n");
+ offset=0;
+ }
+ /* Not the most efficient implementation, but, for now, I just want something that
+ works */
+ /* to do - make single memcpy per column (is it possible ?) */
+ /* to do - use dirty flags to avoid redundant copies */
+ #define UPLOAD_VECTOR(v)\
+ { \
+ /* Is the data dirty ? */ \
+ if (v->flags & ((1<<v->size)-1)) { \
+ /* fprintf(stderr, "size=%d vs stride=%d\n", v->size, v->stride); */ \
+ if(v->size*4==v->stride){\
+ /* fast path */ \
+ memcpy(rsp->gartTextures.map+offset, v->data, v->stride*VB->Count); \
+ } else { \
+ for(i=0;i<VB->Count;i++){ \
+ /* copy one vertex at a time*/ \
+ memcpy(rsp->gartTextures.map+offset+i*v->size*4, VEC_ELT(v, GLfloat, i), v->size*4); \
+ } \
} \
+ /* v->flags &= ~((1<<v->size)-1);*/ \
} \
- /* v->flags &= ~((1<<v->size)-1);*/ \
- } \
- array[idx].element_size=v->size; \
- array[idx].stride=v->size; \
- array[idx].format=(f); \
- array[idx].ncomponents=v->size; \
- array[idx].offset=rsp->gartTextures.handle+offset; \
- array[idx].reg=r; \
- offset+=v->size*4*VB->Count; \
- idx++; \
- }
-
-UPLOAD_VECTOR(VB->ObjPtr, REG_COORDS, AOS_FORMAT_FLOAT);
-UPLOAD_VECTOR(VB->ColorPtr[0], REG_COLOR0, AOS_FORMAT_FLOAT_COLOR);
+ rmesa->state.aos[idx].offset=rsp->gartTextures.handle+offset; \
+ offset+=v->size*4*VB->Count; \
+ idx++; \
+ }
+
+ UPLOAD_VECTOR(VB->ObjPtr);
+ UPLOAD_VECTOR(VB->ColorPtr[0]);
/* texture coordinates */
for(k=0;k < ctx->Const.MaxTextureUnits;k++)
if(ctx->Texture.Unit[k].Enabled)
- UPLOAD_VECTOR(VB->TexCoordPtr[k], REG_TEX0+i, AOS_FORMAT_FLOAT);
+ UPLOAD_VECTOR(VB->TexCoordPtr[k]);
-*n_arrays=idx;
-if(idx>=R300_MAX_AOS_ARRAYS){
- fprintf(stderr, "Aieee ! Maximum AOS arrays count exceeded.. \n");
- exit(-1);
- }
+ if(idx>=R300_MAX_AOS_ARRAYS){
+ fprintf(stderr, "Aieee ! Maximum AOS arrays count exceeded.. \n");
+ exit(-1);
+ }
}
static void r300_render_vb_primitive(r300ContextPtr rmesa,
r300ContextPtr rmesa = R300_CONTEXT(ctx);
TNLcontext *tnl = TNL_CONTEXT(ctx);
struct vertex_buffer *VB = &tnl->vb;
- int i, j, n_arrays;
- AOS_DATA vb_arrays[R300_MAX_AOS_ARRAYS];
+ int i, j;
LOCAL_VARS
if (RADEON_DEBUG == DEBUG_PRIMS)
/* setup array of structures data */
LOCK_HARDWARE(&(rmesa->radeon));
- upload_vertex_buffer(rmesa, ctx, vb_arrays, &n_arrays);
+ upload_vertex_buffer(rmesa, ctx);
//fprintf(stderr, "Using %d AOS arrays\n", n_arrays);
- for(i=0;i<n_arrays;i++)
- rmesa->state.aos[i].offset=vb_arrays[i].offset;
for(i=0; i < VB->PrimitiveCount; i++){
GLuint prim = VB->Primitive[i].mode;