Unlike radeon and r200 drivers r300AllocCmdBuf allocs dwords not bytes.
authorAapo Tahkola <aet@rasterburn.org>
Sat, 12 Mar 2005 10:14:09 +0000 (10:14 +0000)
committerAapo Tahkola <aet@rasterburn.org>
Sat, 12 Mar 2005 10:14:09 +0000 (10:14 +0000)
src/mesa/drivers/dri/r300/r300_cmdbuf.c
src/mesa/drivers/dri/r300/r300_context.c
src/mesa/drivers/dri/r300/r300_context.h
src/mesa/drivers/dri/r300/r300_emit.h
src/mesa/drivers/dri/r300/r300_state.c
src/mesa/drivers/dri/r300/r300_vertexprog.c

index 3fe69c3b2eb3ec9a6602ca5a0c2a0f04ffee1176..df825ba3b435cf8107719a5ddee5b57bcd29d0e6 100644 (file)
@@ -601,7 +601,7 @@ void r300EmitBlit(r300ContextPtr rmesa,
        assert(h < (1 << 16));
 
        cmd =
-           (drm_radeon_cmd_header_t *) r300AllocCmdBuf(rmesa, 8 * sizeof(int),
+           (drm_radeon_cmd_header_t *) r300AllocCmdBuf(rmesa, 8,
                                                        __FUNCTION__);
 
        cmd[0].header.cmd_type = R300_CMD_PACKET3;
@@ -631,7 +631,7 @@ void r300EmitWait(r300ContextPtr rmesa, GLuint flags)
 
                cmd =
                    (drm_radeon_cmd_header_t *) r300AllocCmdBuf(rmesa,
-                                                               1 * sizeof(int),
+                                                               1,
                                                                __FUNCTION__);
                cmd[0].i = 0;
                cmd[0].wait.cmd_type = R300_CMD_WAIT;
index cd7b53659208a13cd49dc33cc2ddb336f7cf9b62..da8497c4ee945a4195cf7a63cd8aeb6a6ae24357 100644 (file)
@@ -267,12 +267,12 @@ GLboolean r300CreateContext(const __GLcontextModes * glVisual,
                _mesa_enable_extension( ctx, "GL_NV_vertex_program");
 #endif
        /* currently bogus data */
-       ctx->Const.MaxVertexProgramInstructions=128;
-       ctx->Const.MaxVertexProgramAttribs=64;
-       ctx->Const.MaxVertexProgramTemps=64;
-       ctx->Const.MaxVertexProgramLocalParams=64;
-       ctx->Const.MaxVertexProgramEnvParams=64;
-       ctx->Const.MaxVertexProgramAddressRegs=8;
+       ctx->Const.MaxVertexProgramInstructions=VSF_MAX_FRAGMENT_LENGTH;
+       ctx->Const.MaxVertexProgramAttribs=16; // r420
+       ctx->Const.MaxVertexProgramTemps=VSF_MAX_FRAGMENT_TEMPS;
+       ctx->Const.MaxVertexProgramLocalParams=256; // r420
+       ctx->Const.MaxVertexProgramEnvParams=256; // r420
+       ctx->Const.MaxVertexProgramAddressRegs=1;
                
        driInitExtensions(ctx, card_extensions, GL_TRUE);
        
index 7879de1b88c3b9a77e44a284ef7ff974ae075243..d956848dd11d49adf3d41ce577efd97d35d6bc67 100644 (file)
@@ -513,8 +513,11 @@ struct r300_vap_reg_state {
 
 /* Vertex shader state */
 
-/* 64 appears to be the maximum */
-#define VSF_MAX_FRAGMENT_LENGTH (64*4)
+/* Tested with rv350 and verified from misc web pages. */
+#define VSF_MAX_FRAGMENT_LENGTH (256*4)
+       
+/* Tested with rv350 and verified from misc web pages. */
+#define VSF_MAX_FRAGMENT_TEMPS (32)
 
 
 struct r300_vertex_shader_fragment {
index eb2a913f1cd1ec707fad8d89e19d706424c8d919..6085ccf00048b3a069c5b7a01e1614d62655df42 100644 (file)
@@ -200,13 +200,14 @@ static __inline__ uint32_t cmdpacify(void)
        }
 
        /* must be sent to switch to 2d commands */
+/*
 void static inline end_3d(PREFIX_VOID)
 {
 LOCAL_VARS
 (void)cmd_reserved; (void)cmd_written;
 
 cmd=(drm_radeon_cmd_header_t *) r300AllocCmdBuf(rmesa, \
-                                       0, \
+                                       0, \ // ??!
                                        __FUNCTION__); \
 
 cmd[0].header.cmd_type=R300_CMD_END3D;
@@ -218,11 +219,12 @@ LOCAL_VARS
 (void)cmd_reserved; (void)cmd_written;
 
 cmd=(drm_radeon_cmd_header_t *) r300AllocCmdBuf(rmesa, \
-                                       0, \
+                                       0, \ // ??!
                                        __FUNCTION__); \
 
 cmd[0].i=cmdcpdelay(count);
 }
+*/
 
 /* fire vertex buffer */
 static void inline fire_AOS(PREFIX int vertex_count, int type)
index ad2cdf585a5c8aad55cc8ccf54a533412cf7bf2c..874bd856dd997caee52cec70f7be7a780451ca9e 100644 (file)
@@ -1607,18 +1607,30 @@ void r300GenerateSimpleVertexShader(r300ContextPtr r300)
 void r300SetupVertexShader(r300ContextPtr rmesa)
 {
        GLcontext* ctx = rmesa->radeon.glCtx;
+       struct r300_vertex_shader_fragment unk4={
+                       length: 4,
+                       body: { f: {
+                               /*0.0*/(rand()%100)/10.0,
+                               /*0.0*/(rand()%100)/10.0,
+                               /*1.0*/(rand()%100)/10.0,
+                               /*0.0*/(rand()%100)/10.0
+                               } }
+                       };
        LOCAL_VARS
 
-       if(rmesa->current_vp != NULL){
-               r300SetupVertexProgram(rmesa);
-               return ;
-       }
-
        /* Reset state, in case we don't use something */
        ((drm_r300_cmd_header_t*)rmesa->hw.vpp.cmd)->vpu.count = 0;
        ((drm_r300_cmd_header_t*)rmesa->hw.vpi.cmd)->vpu.count = 0;
        ((drm_r300_cmd_header_t*)rmesa->hw.vps.cmd)->vpu.count = 0;
 
+       /* Not sure why this doesnt work...
+          0x400 area might have something to do with pixel shaders as it appears right after pfs programming.
+          0x406 is set to { 0.0, 0.0, 1.0, 0.0 } most of the time but should change with smooth points and in other rare cases. */
+       //setup_vertex_shader_fragment(rmesa, 0x406, &unk4);
+       if(rmesa->current_vp != NULL){
+               r300SetupVertexProgram(rmesa);
+               return ;
+       }
 
 /* This needs to be replaced by vertex shader generation code */
 
index 02e0b5b7391cf7987c20d10a6c67a1dc578de6cd..811f9ccb55fd7a936450950066ef53d117be1d67 100644 (file)
@@ -422,7 +422,6 @@ static unsigned long t_opcode(enum vp_opcode opcode)
                case VP_OPCODE_EXP: return R300_VPI_OUT_OP_EXP;
                case VP_OPCODE_FRC: return R300_VPI_OUT_OP_FRC;
                case VP_OPCODE_LG2: return R300_VPI_OUT_OP_LG2;
-               case VP_OPCODE_LIT: return R300_VPI_OUT_OP_LIT;
                case VP_OPCODE_LOG: return R300_VPI_OUT_OP_LOG;
                case VP_OPCODE_MAD: return R300_VPI_OUT_OP_MAD;
                case VP_OPCODE_MAX: return R300_VPI_OUT_OP_MAX;
@@ -472,7 +471,10 @@ static void translate_program(struct r300_vertex_program *vp)
        VERTEX_SHADER_INSTRUCTION t2rs[1024];
        VERTEX_SHADER_INSTRUCTION *o_inst;
        unsigned long operands;
-       int u_temp_i=63; /* Initial value should be last tmp reg that hw supports */
+       /* Initial value should be last tmp reg that hw supports.
+          Strangely enough r300 doesnt mind even though these would be out of range.
+          Smart enough to realize that it doesnt need it? */
+       int u_temp_i=VSF_MAX_FRAGMENT_TEMPS-1;
 #ifdef SRCS_WRITABLE
        struct vp_src_register src[3];
 #else  
@@ -501,12 +503,12 @@ static void translate_program(struct r300_vertex_program *vp)
                                o_inst->src1=MAKE_VSF_SOURCE(t_src_index(vp, &src[2]),
                                                SWIZZLE_X, SWIZZLE_Y,
                                                SWIZZLE_Z, SWIZZLE_W,
-                                               t_src_class(src[0].File), VSF_FLAG_NONE);
+                                               t_src_class(src[2].File), VSF_FLAG_NONE);
 
                                o_inst->src2=MAKE_VSF_SOURCE(t_src_index(vp, &src[2]),
                                                SWIZZLE_ZERO, SWIZZLE_ZERO,
                                                SWIZZLE_ZERO, SWIZZLE_ZERO,
-                                               t_src_class(src[0].File), VSF_FLAG_NONE);
+                                               t_src_class(src[2].File), VSF_FLAG_NONE);
                                o_inst->src3=0;
                                o_inst++;
                                                
@@ -601,7 +603,8 @@ static void translate_program(struct r300_vertex_program *vp)
 #ifdef SRCS_WRITABLE
                        vpi->Opcode=VP_OPCODE_MAX;
                        src[1]=src[0];
-                       src[1].Negate=GL_TRUE;
+                       src[1].Negate=!src[0].Negate;
+                       operands=op_operands(vpi->Opcode);
                        break;
 #else
                        o_inst->op=MAKE_VSF_OP(R300_VPI_OUT_OP_MAX, vpi->DstReg.Index,
@@ -647,6 +650,33 @@ static void translate_program(struct r300_vertex_program *vp)
                        u_temp_i--;
                        goto next;
                        
+               case VP_OPCODE_LIT://LIT TMP 1.Y Z TMP 1{} {X W Z Y} TMP 1{} {Y W Z X} TMP 1{} {Y X Z W} 
+                       o_inst->op=MAKE_VSF_OP(R300_VPI_OUT_OP_LIT, vpi->DstReg.Index,
+                                       t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File));
+                       /* NOTE: Users swizzling might not work. */
+                       o_inst->src1=MAKE_VSF_SOURCE(t_src_index(vp, &src[0]),
+                                       t_swizzle(src[0].Swizzle[0]), // x
+                                       t_swizzle(src[0].Swizzle[3]), // w
+                                       t_swizzle(src[0].Swizzle[2]), // z
+                                       t_swizzle(src[0].Swizzle[1]), // y
+                                       t_src_class(src[0].File),
+                                       src[0].Negate ? VSF_FLAG_ALL : VSF_FLAG_NONE);
+                       o_inst->src2=MAKE_VSF_SOURCE(t_src_index(vp, &src[0]),
+                                       t_swizzle(src[0].Swizzle[1]), // y
+                                       t_swizzle(src[0].Swizzle[3]), // w
+                                       t_swizzle(src[0].Swizzle[2]), // z
+                                       t_swizzle(src[0].Swizzle[0]), // x
+                                       t_src_class(src[0].File),
+                                       src[0].Negate ? VSF_FLAG_ALL : VSF_FLAG_NONE);
+                       o_inst->src3=MAKE_VSF_SOURCE(t_src_index(vp, &src[0]),
+                                       t_swizzle(src[0].Swizzle[1]), // y
+                                       t_swizzle(src[0].Swizzle[0]), // x
+                                       t_swizzle(src[0].Swizzle[2]), // z
+                                       t_swizzle(src[0].Swizzle[3]), // w
+                                       t_src_class(src[0].File),
+                                       src[0].Negate ? VSF_FLAG_ALL : VSF_FLAG_NONE);
+                       goto next;
+                       
                case VP_OPCODE_DPH://DOT RESULT 1.X Y Z W PARAM 0{} {X Y Z ONE} PARAM 0{} {X Y Z W} 
                        o_inst->op=MAKE_VSF_OP(R300_VPI_OUT_OP_DOT, vpi->DstReg.Index,
                                        t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File));
@@ -662,7 +692,7 @@ static void translate_program(struct r300_vertex_program *vp)
                        o_inst->src3=0;
                        goto next;
                        
-               case VP_OPCODE_XPD:
+               case VP_OPCODE_XPD: /* Broken due to swizzling */
                /* ADD TMP 0.X Y Z PARAM 0{} {X Y Z W} PARAM 0{} {ZERO ZERO ZERO ZERO} 
                   MUL TMP 1.X Y Z W TMP 0{} {Z X Y ZERO} PARAM 1{} {Y Z X ZERO} 
                   MAD RESULT 1.X Y Z W TMP 0{} {Y Z X ONE} PARAM 1{} {Z X Y ONE} TMP 1{X Y Z W } {X Y Z W} neg Xneg Yneg Zneg W*/