summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAapo Tahkola <aet@rasterburn.org>2005-03-12 10:14:09 +0000
committerAapo Tahkola <aet@rasterburn.org>2005-03-12 10:14:09 +0000
commit203bd3e8ecf923bba3733b5ebe861c5700ffcb79 (patch)
tree2b68dba3fb7933f016a344860afd8743ebbc17d0 /src
parent91c219d9063bf7d3a181ee0b289c68b4a68f3db6 (diff)
Unlike radeon and r200 drivers r300AllocCmdBuf allocs dwords not bytes.
Diffstat (limited to 'src')
-rw-r--r--src/mesa/drivers/dri/r300/r300_cmdbuf.c4
-rw-r--r--src/mesa/drivers/dri/r300/r300_context.c12
-rw-r--r--src/mesa/drivers/dri/r300/r300_context.h7
-rw-r--r--src/mesa/drivers/dri/r300/r300_emit.h6
-rw-r--r--src/mesa/drivers/dri/r300/r300_state.c22
-rw-r--r--src/mesa/drivers/dri/r300/r300_vertexprog.c42
6 files changed, 70 insertions, 23 deletions
diff --git a/src/mesa/drivers/dri/r300/r300_cmdbuf.c b/src/mesa/drivers/dri/r300/r300_cmdbuf.c
index 3fe69c3b2e..df825ba3b4 100644
--- a/src/mesa/drivers/dri/r300/r300_cmdbuf.c
+++ b/src/mesa/drivers/dri/r300/r300_cmdbuf.c
@@ -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;
diff --git a/src/mesa/drivers/dri/r300/r300_context.c b/src/mesa/drivers/dri/r300/r300_context.c
index cd7b536592..da8497c4ee 100644
--- a/src/mesa/drivers/dri/r300/r300_context.c
+++ b/src/mesa/drivers/dri/r300/r300_context.c
@@ -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);
diff --git a/src/mesa/drivers/dri/r300/r300_context.h b/src/mesa/drivers/dri/r300/r300_context.h
index 7879de1b88..d956848dd1 100644
--- a/src/mesa/drivers/dri/r300/r300_context.h
+++ b/src/mesa/drivers/dri/r300/r300_context.h
@@ -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 {
diff --git a/src/mesa/drivers/dri/r300/r300_emit.h b/src/mesa/drivers/dri/r300/r300_emit.h
index eb2a913f1c..6085ccf000 100644
--- a/src/mesa/drivers/dri/r300/r300_emit.h
+++ b/src/mesa/drivers/dri/r300/r300_emit.h
@@ -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)
diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c
index ad2cdf585a..874bd856dd 100644
--- a/src/mesa/drivers/dri/r300/r300_state.c
+++ b/src/mesa/drivers/dri/r300/r300_state.c
@@ -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 */
diff --git a/src/mesa/drivers/dri/r300/r300_vertexprog.c b/src/mesa/drivers/dri/r300/r300_vertexprog.c
index 02e0b5b739..811f9ccb55 100644
--- a/src/mesa/drivers/dri/r300/r300_vertexprog.c
+++ b/src/mesa/drivers/dri/r300/r300_vertexprog.c
@@ -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*/