r300: Indented the vertex program code...
This commit is contained in:
parent
82770b8c83
commit
e49ec6e2a4
|
@ -69,7 +69,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
u_temp_i=VSF_MAX_FRAGMENT_TEMPS-1; \
|
||||
} while (0)
|
||||
|
||||
int r300VertexProgUpdateParams(GLcontext * ctx, struct r300_vertex_program_cont *vp, float *dst)
|
||||
int r300VertexProgUpdateParams(GLcontext * ctx,
|
||||
struct r300_vertex_program_cont *vp, float *dst)
|
||||
{
|
||||
int pi;
|
||||
struct gl_vertex_program *mesa_vp = &vp->mesa_program;
|
||||
|
@ -91,7 +92,8 @@ int r300VertexProgUpdateParams(GLcontext * ctx, struct r300_vertex_program_cont
|
|||
assert(mesa_vp->Base.Parameters);
|
||||
_mesa_load_state_parameters(ctx, mesa_vp->Base.Parameters);
|
||||
|
||||
if (mesa_vp->Base.Parameters->NumParameters * 4 > VSF_MAX_FRAGMENT_LENGTH) {
|
||||
if (mesa_vp->Base.Parameters->NumParameters * 4 >
|
||||
VSF_MAX_FRAGMENT_LENGTH) {
|
||||
fprintf(stderr, "%s:Params exhausted\n", __FUNCTION__);
|
||||
_mesa_exit(-1);
|
||||
}
|
||||
|
@ -109,7 +111,8 @@ int r300VertexProgUpdateParams(GLcontext * ctx, struct r300_vertex_program_cont
|
|||
*dst++ = paramList->ParameterValues[pi][3];
|
||||
break;
|
||||
default:
|
||||
_mesa_problem(NULL, "Bad param type in %s", __FUNCTION__);
|
||||
_mesa_problem(NULL, "Bad param type in %s",
|
||||
__FUNCTION__);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -149,7 +152,8 @@ static unsigned long t_dst_class(enum register_file file)
|
|||
}
|
||||
}
|
||||
|
||||
static unsigned long t_dst_index(struct r300_vertex_program *vp, struct prog_dst_register *dst)
|
||||
static unsigned long t_dst_index(struct r300_vertex_program *vp,
|
||||
struct prog_dst_register *dst)
|
||||
{
|
||||
if (dst->File == PROGRAM_OUTPUT)
|
||||
return vp->outputs[dst->Index];
|
||||
|
@ -193,7 +197,8 @@ static void vp_dump_inputs(struct r300_vertex_program *vp, char *caller)
|
|||
int i;
|
||||
|
||||
if (vp == NULL) {
|
||||
fprintf(stderr, "vp null in call to %s from %s\n", __FUNCTION__, caller);
|
||||
fprintf(stderr, "vp null in call to %s from %s\n", __FUNCTION__,
|
||||
caller);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -205,7 +210,8 @@ static void vp_dump_inputs(struct r300_vertex_program *vp, char *caller)
|
|||
}
|
||||
#endif
|
||||
|
||||
static unsigned long t_src_index(struct r300_vertex_program *vp, struct prog_src_register *src)
|
||||
static unsigned long t_src_index(struct r300_vertex_program *vp,
|
||||
struct prog_src_register *src)
|
||||
{
|
||||
int i;
|
||||
int max_reg = -1;
|
||||
|
@ -225,7 +231,8 @@ static unsigned long t_src_index(struct r300_vertex_program *vp, struct prog_src
|
|||
return vp->inputs[src->Index];
|
||||
} else {
|
||||
if (src->Index < 0) {
|
||||
fprintf(stderr, "negative offsets for indirect addressing do not work.\n");
|
||||
fprintf(stderr,
|
||||
"negative offsets for indirect addressing do not work.\n");
|
||||
return 0;
|
||||
}
|
||||
return src->Index;
|
||||
|
@ -234,7 +241,8 @@ static unsigned long t_src_index(struct r300_vertex_program *vp, struct prog_src
|
|||
|
||||
/* these two functions should probably be merged... */
|
||||
|
||||
static unsigned long t_src(struct r300_vertex_program *vp, struct prog_src_register *src)
|
||||
static unsigned long t_src(struct r300_vertex_program *vp,
|
||||
struct prog_src_register *src)
|
||||
{
|
||||
/* src->NegateBase uses the NEGATE_ flags from program_instruction.h,
|
||||
* which equal our VSF_FLAGS_ values, so it's safe to just pass it here.
|
||||
|
@ -248,7 +256,8 @@ static unsigned long t_src(struct r300_vertex_program *vp, struct prog_src_regis
|
|||
src->NegateBase) | (src->RelAddr << 4);
|
||||
}
|
||||
|
||||
static unsigned long t_src_scalar(struct r300_vertex_program *vp, struct prog_src_register *src)
|
||||
static unsigned long t_src_scalar(struct r300_vertex_program *vp,
|
||||
struct prog_src_register *src)
|
||||
{
|
||||
/* src->NegateBase uses the NEGATE_ flags from program_instruction.h,
|
||||
* which equal our VSF_FLAGS_ values, so it's safe to just pass it here.
|
||||
|
@ -259,10 +268,13 @@ static unsigned long t_src_scalar(struct r300_vertex_program *vp, struct prog_sr
|
|||
t_swizzle(GET_SWZ(src->Swizzle, 0)),
|
||||
t_swizzle(GET_SWZ(src->Swizzle, 0)),
|
||||
t_src_class(src->File),
|
||||
src->NegateBase ? VSF_FLAG_ALL : VSF_FLAG_NONE) | (src->RelAddr << 4);
|
||||
src->
|
||||
NegateBase ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
|
||||
(src->RelAddr << 4);
|
||||
}
|
||||
|
||||
static GLboolean valid_dst(struct r300_vertex_program *vp, struct prog_dst_register *dst)
|
||||
static GLboolean valid_dst(struct r300_vertex_program *vp,
|
||||
struct prog_dst_register *dst)
|
||||
{
|
||||
if (dst->File == PROGRAM_OUTPUT && vp->outputs[dst->Index] == -1) {
|
||||
return GL_FALSE;
|
||||
|
@ -273,7 +285,10 @@ static GLboolean valid_dst(struct r300_vertex_program *vp, struct prog_dst_regis
|
|||
return GL_TRUE;
|
||||
}
|
||||
|
||||
static GLuint *r300TranslateOpcodeABS(struct r300_vertex_program *vp, struct prog_instruction *vpi, GLuint * inst, struct prog_src_register src[3])
|
||||
static GLuint *r300TranslateOpcodeABS(struct r300_vertex_program *vp,
|
||||
struct prog_instruction *vpi,
|
||||
GLuint * inst,
|
||||
struct prog_src_register src[3])
|
||||
{
|
||||
//MAX RESULT 1.X Y Z W PARAM 0{} {X Y Z W} PARAM 0{X Y Z W } {X Y Z W} neg Xneg Yneg Zneg W
|
||||
|
||||
|
@ -290,13 +305,18 @@ static GLuint *r300TranslateOpcodeABS(struct r300_vertex_program *vp, struct pro
|
|||
t_swizzle(GET_SWZ(src[0].Swizzle, 2)),
|
||||
t_swizzle(GET_SWZ(src[0].Swizzle, 3)),
|
||||
t_src_class(src[0].File),
|
||||
(!src[0].NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE) | (src[0].RelAddr << 4);
|
||||
(!src[0].
|
||||
NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
|
||||
(src[0].RelAddr << 4);
|
||||
inst[3] = 0;
|
||||
|
||||
return inst;
|
||||
}
|
||||
|
||||
static GLuint *r300TranslateOpcodeADD(struct r300_vertex_program *vp, struct prog_instruction *vpi, GLuint * inst, struct prog_src_register src[3])
|
||||
static GLuint *r300TranslateOpcodeADD(struct r300_vertex_program *vp,
|
||||
struct prog_instruction *vpi,
|
||||
GLuint * inst,
|
||||
struct prog_src_register src[3])
|
||||
{
|
||||
inst[0] = PVS_OP_DST_OPERAND(VE_ADD,
|
||||
GL_FALSE,
|
||||
|
@ -311,7 +331,10 @@ static GLuint *r300TranslateOpcodeADD(struct r300_vertex_program *vp, struct pro
|
|||
return inst;
|
||||
}
|
||||
|
||||
static GLuint *r300TranslateOpcodeARL(struct r300_vertex_program *vp, struct prog_instruction *vpi, GLuint * inst, struct prog_src_register src[3])
|
||||
static GLuint *r300TranslateOpcodeARL(struct r300_vertex_program *vp,
|
||||
struct prog_instruction *vpi,
|
||||
GLuint * inst,
|
||||
struct prog_src_register src[3])
|
||||
{
|
||||
inst[0] = PVS_OP_DST_OPERAND(VE_FLT2FIX_DX,
|
||||
GL_FALSE,
|
||||
|
@ -326,7 +349,10 @@ static GLuint *r300TranslateOpcodeARL(struct r300_vertex_program *vp, struct pro
|
|||
return inst;
|
||||
}
|
||||
|
||||
static GLuint *r300TranslateOpcodeDP3(struct r300_vertex_program *vp, struct prog_instruction *vpi, GLuint * inst, struct prog_src_register src[3])
|
||||
static GLuint *r300TranslateOpcodeDP3(struct r300_vertex_program *vp,
|
||||
struct prog_instruction *vpi,
|
||||
GLuint * inst,
|
||||
struct prog_src_register src[3])
|
||||
{
|
||||
//DOT RESULT 1.X Y Z W PARAM 0{} {X Y Z ZERO} PARAM 0{} {X Y Z ZERO}
|
||||
|
||||
|
@ -342,20 +368,27 @@ static GLuint *r300TranslateOpcodeDP3(struct r300_vertex_program *vp, struct pro
|
|||
t_swizzle(GET_SWZ(src[0].Swizzle, 2)),
|
||||
SWIZZLE_ZERO,
|
||||
t_src_class(src[0].File),
|
||||
src[0].NegateBase ? VSF_FLAG_XYZ : VSF_FLAG_NONE) | (src[0].RelAddr << 4);
|
||||
inst[2] = PVS_SRC_OPERAND(t_src_index(vp, &src[1]),
|
||||
src[0].
|
||||
NegateBase ? VSF_FLAG_XYZ : VSF_FLAG_NONE) |
|
||||
(src[0].RelAddr << 4);
|
||||
inst[2] =
|
||||
PVS_SRC_OPERAND(t_src_index(vp, &src[1]),
|
||||
t_swizzle(GET_SWZ(src[1].Swizzle, 0)),
|
||||
t_swizzle(GET_SWZ(src[1].Swizzle, 1)),
|
||||
t_swizzle(GET_SWZ(src[1].Swizzle, 2)),
|
||||
SWIZZLE_ZERO,
|
||||
t_swizzle(GET_SWZ(src[1].Swizzle, 2)), SWIZZLE_ZERO,
|
||||
t_src_class(src[1].File),
|
||||
src[1].NegateBase ? VSF_FLAG_XYZ : VSF_FLAG_NONE) | (src[1].RelAddr << 4);
|
||||
src[1].
|
||||
NegateBase ? VSF_FLAG_XYZ : VSF_FLAG_NONE) |
|
||||
(src[1].RelAddr << 4);
|
||||
inst[3] = __CONST(1, SWIZZLE_ZERO);
|
||||
|
||||
return inst;
|
||||
}
|
||||
|
||||
static GLuint *r300TranslateOpcodeDP4(struct r300_vertex_program *vp, struct prog_instruction *vpi, GLuint * inst, struct prog_src_register src[3])
|
||||
static GLuint *r300TranslateOpcodeDP4(struct r300_vertex_program *vp,
|
||||
struct prog_instruction *vpi,
|
||||
GLuint * inst,
|
||||
struct prog_src_register src[3])
|
||||
{
|
||||
inst[0] = PVS_OP_DST_OPERAND(VE_DOT_PRODUCT,
|
||||
GL_FALSE,
|
||||
|
@ -370,7 +403,10 @@ static GLuint *r300TranslateOpcodeDP4(struct r300_vertex_program *vp, struct pro
|
|||
return inst;
|
||||
}
|
||||
|
||||
static GLuint *r300TranslateOpcodeDPH(struct r300_vertex_program *vp, struct prog_instruction *vpi, GLuint * inst, struct prog_src_register src[3])
|
||||
static GLuint *r300TranslateOpcodeDPH(struct r300_vertex_program *vp,
|
||||
struct prog_instruction *vpi,
|
||||
GLuint * inst,
|
||||
struct prog_src_register src[3])
|
||||
{
|
||||
//DOT RESULT 1.X Y Z W PARAM 0{} {X Y Z ONE} PARAM 0{} {X Y Z W}
|
||||
inst[0] = PVS_OP_DST_OPERAND(VE_DOT_PRODUCT,
|
||||
|
@ -385,14 +421,19 @@ static GLuint *r300TranslateOpcodeDPH(struct r300_vertex_program *vp, struct pro
|
|||
t_swizzle(GET_SWZ(src[0].Swizzle, 2)),
|
||||
PVS_SRC_SELECT_FORCE_1,
|
||||
t_src_class(src[0].File),
|
||||
src[0].NegateBase ? VSF_FLAG_XYZ : VSF_FLAG_NONE) | (src[0].RelAddr << 4);
|
||||
src[0].
|
||||
NegateBase ? VSF_FLAG_XYZ : VSF_FLAG_NONE) |
|
||||
(src[0].RelAddr << 4);
|
||||
inst[2] = t_src(vp, &src[1]);
|
||||
inst[3] = __CONST(1, SWIZZLE_ZERO);
|
||||
|
||||
return inst;
|
||||
}
|
||||
|
||||
static GLuint *r300TranslateOpcodeDST(struct r300_vertex_program *vp, struct prog_instruction *vpi, GLuint * inst, struct prog_src_register src[3])
|
||||
static GLuint *r300TranslateOpcodeDST(struct r300_vertex_program *vp,
|
||||
struct prog_instruction *vpi,
|
||||
GLuint * inst,
|
||||
struct prog_src_register src[3])
|
||||
{
|
||||
inst[0] = PVS_OP_DST_OPERAND(VE_DISTANCE_VECTOR,
|
||||
GL_FALSE,
|
||||
|
@ -407,7 +448,10 @@ static GLuint *r300TranslateOpcodeDST(struct r300_vertex_program *vp, struct pro
|
|||
return inst;
|
||||
}
|
||||
|
||||
static GLuint *r300TranslateOpcodeEX2(struct r300_vertex_program *vp, struct prog_instruction *vpi, GLuint * inst, struct prog_src_register src[3])
|
||||
static GLuint *r300TranslateOpcodeEX2(struct r300_vertex_program *vp,
|
||||
struct prog_instruction *vpi,
|
||||
GLuint * inst,
|
||||
struct prog_src_register src[3])
|
||||
{
|
||||
inst[0] = PVS_OP_DST_OPERAND(ME_EXP_BASE2_FULL_DX,
|
||||
GL_TRUE,
|
||||
|
@ -422,7 +466,10 @@ static GLuint *r300TranslateOpcodeEX2(struct r300_vertex_program *vp, struct pro
|
|||
return inst;
|
||||
}
|
||||
|
||||
static GLuint *r300TranslateOpcodeEXP(struct r300_vertex_program *vp, struct prog_instruction *vpi, GLuint * inst, struct prog_src_register src[3])
|
||||
static GLuint *r300TranslateOpcodeEXP(struct r300_vertex_program *vp,
|
||||
struct prog_instruction *vpi,
|
||||
GLuint * inst,
|
||||
struct prog_src_register src[3])
|
||||
{
|
||||
inst[0] = PVS_OP_DST_OPERAND(ME_EXP_BASE2_DX,
|
||||
GL_TRUE,
|
||||
|
@ -437,7 +484,11 @@ static GLuint *r300TranslateOpcodeEXP(struct r300_vertex_program *vp, struct pro
|
|||
return inst;
|
||||
}
|
||||
|
||||
static GLuint *r300TranslateOpcodeFLR(struct r300_vertex_program *vp, struct prog_instruction *vpi, GLuint * inst, struct prog_src_register src[3], int *u_temp_i)
|
||||
static GLuint *r300TranslateOpcodeFLR(struct r300_vertex_program *vp,
|
||||
struct prog_instruction *vpi,
|
||||
GLuint * inst,
|
||||
struct prog_src_register src[3],
|
||||
int *u_temp_i)
|
||||
{
|
||||
/* FRC TMP 0.X Y Z W PARAM 0{} {X Y Z W}
|
||||
ADD RESULT 1.X Y Z W PARAM 0{} {X Y Z W} TMP 0{X Y Z W } {X Y Z W} neg Xneg Yneg Zneg W */
|
||||
|
@ -475,7 +526,10 @@ static GLuint *r300TranslateOpcodeFLR(struct r300_vertex_program *vp, struct pro
|
|||
return inst;
|
||||
}
|
||||
|
||||
static GLuint *r300TranslateOpcodeFRC(struct r300_vertex_program *vp, struct prog_instruction *vpi, GLuint * inst, struct prog_src_register src[3])
|
||||
static GLuint *r300TranslateOpcodeFRC(struct r300_vertex_program *vp,
|
||||
struct prog_instruction *vpi,
|
||||
GLuint * inst,
|
||||
struct prog_src_register src[3])
|
||||
{
|
||||
inst[0] = PVS_OP_DST_OPERAND(VE_FRACTION,
|
||||
GL_FALSE,
|
||||
|
@ -490,7 +544,10 @@ static GLuint *r300TranslateOpcodeFRC(struct r300_vertex_program *vp, struct pro
|
|||
return inst;
|
||||
}
|
||||
|
||||
static GLuint *r300TranslateOpcodeLG2(struct r300_vertex_program *vp, struct prog_instruction *vpi, GLuint * inst, struct prog_src_register src[3])
|
||||
static GLuint *r300TranslateOpcodeLG2(struct r300_vertex_program *vp,
|
||||
struct prog_instruction *vpi,
|
||||
GLuint * inst,
|
||||
struct prog_src_register src[3])
|
||||
{
|
||||
// LG2 RESULT 1.X Y Z W PARAM 0{} {X X X X}
|
||||
|
||||
|
@ -506,14 +563,19 @@ static GLuint *r300TranslateOpcodeLG2(struct r300_vertex_program *vp, struct pro
|
|||
t_swizzle(GET_SWZ(src[0].Swizzle, 0)),
|
||||
t_swizzle(GET_SWZ(src[0].Swizzle, 0)),
|
||||
t_src_class(src[0].File),
|
||||
src[0].NegateBase ? VSF_FLAG_ALL : VSF_FLAG_NONE) | (src[0].RelAddr << 4);
|
||||
src[0].
|
||||
NegateBase ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
|
||||
(src[0].RelAddr << 4);
|
||||
inst[2] = __CONST(0, SWIZZLE_ZERO);
|
||||
inst[3] = __CONST(0, SWIZZLE_ZERO);
|
||||
|
||||
return inst;
|
||||
}
|
||||
|
||||
static GLuint *r300TranslateOpcodeLIT(struct r300_vertex_program *vp, struct prog_instruction *vpi, GLuint * inst, struct prog_src_register src[3])
|
||||
static GLuint *r300TranslateOpcodeLIT(struct r300_vertex_program *vp,
|
||||
struct prog_instruction *vpi,
|
||||
GLuint * inst,
|
||||
struct prog_src_register src[3])
|
||||
{
|
||||
//LIT TMP 1.Y Z TMP 1{} {X W Z Y} TMP 1{} {Y W Z X} TMP 1{} {Y X Z W}
|
||||
|
||||
|
@ -524,32 +586,38 @@ static GLuint *r300TranslateOpcodeLIT(struct r300_vertex_program *vp, struct pro
|
|||
t_dst_mask(vpi->DstReg.WriteMask),
|
||||
t_dst_class(vpi->DstReg.File));
|
||||
/* NOTE: Users swizzling might not work. */
|
||||
inst[1] = PVS_SRC_OPERAND(t_src_index(vp, &src[0]),
|
||||
t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // X
|
||||
inst[1] = PVS_SRC_OPERAND(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // X
|
||||
t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // W
|
||||
PVS_SRC_SELECT_FORCE_0, // Z
|
||||
t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // Y
|
||||
t_src_class(src[0].File),
|
||||
src[0].NegateBase ? VSF_FLAG_ALL : VSF_FLAG_NONE) | (src[0].RelAddr << 4);
|
||||
inst[2] = PVS_SRC_OPERAND(t_src_index(vp, &src[0]),
|
||||
t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // Y
|
||||
src[0].
|
||||
NegateBase ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
|
||||
(src[0].RelAddr << 4);
|
||||
inst[2] = PVS_SRC_OPERAND(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // Y
|
||||
t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // W
|
||||
PVS_SRC_SELECT_FORCE_0, // Z
|
||||
t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // X
|
||||
t_src_class(src[0].File),
|
||||
src[0].NegateBase ? VSF_FLAG_ALL : VSF_FLAG_NONE) | (src[0].RelAddr << 4);
|
||||
inst[3] = PVS_SRC_OPERAND(t_src_index(vp, &src[0]),
|
||||
t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // Y
|
||||
src[0].
|
||||
NegateBase ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
|
||||
(src[0].RelAddr << 4);
|
||||
inst[3] = PVS_SRC_OPERAND(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // Y
|
||||
t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // X
|
||||
PVS_SRC_SELECT_FORCE_0, // Z
|
||||
t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // W
|
||||
t_src_class(src[0].File),
|
||||
src[0].NegateBase ? VSF_FLAG_ALL : VSF_FLAG_NONE) | (src[0].RelAddr << 4);
|
||||
src[0].
|
||||
NegateBase ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
|
||||
(src[0].RelAddr << 4);
|
||||
|
||||
return inst;
|
||||
}
|
||||
|
||||
static GLuint *r300TranslateOpcodeLOG(struct r300_vertex_program *vp, struct prog_instruction *vpi, GLuint * inst, struct prog_src_register src[3])
|
||||
static GLuint *r300TranslateOpcodeLOG(struct r300_vertex_program *vp,
|
||||
struct prog_instruction *vpi,
|
||||
GLuint * inst,
|
||||
struct prog_src_register src[3])
|
||||
{
|
||||
inst[0] = PVS_OP_DST_OPERAND(ME_LOG_BASE2_DX,
|
||||
GL_TRUE,
|
||||
|
@ -564,7 +632,10 @@ static GLuint *r300TranslateOpcodeLOG(struct r300_vertex_program *vp, struct pro
|
|||
return inst;
|
||||
}
|
||||
|
||||
static GLuint *r300TranslateOpcodeMAD(struct r300_vertex_program *vp, struct prog_instruction *vpi, GLuint * inst, struct prog_src_register src[3])
|
||||
static GLuint *r300TranslateOpcodeMAD(struct r300_vertex_program *vp,
|
||||
struct prog_instruction *vpi,
|
||||
GLuint * inst,
|
||||
struct prog_src_register src[3])
|
||||
{
|
||||
inst[0] = PVS_OP_DST_OPERAND(PVS_MACRO_OP_2CLK_MADD,
|
||||
GL_FALSE,
|
||||
|
@ -579,7 +650,10 @@ static GLuint *r300TranslateOpcodeMAD(struct r300_vertex_program *vp, struct pro
|
|||
return inst;
|
||||
}
|
||||
|
||||
static GLuint *r300TranslateOpcodeMAX(struct r300_vertex_program *vp, struct prog_instruction *vpi, GLuint * inst, struct prog_src_register src[3])
|
||||
static GLuint *r300TranslateOpcodeMAX(struct r300_vertex_program *vp,
|
||||
struct prog_instruction *vpi,
|
||||
GLuint * inst,
|
||||
struct prog_src_register src[3])
|
||||
{
|
||||
inst[0] = PVS_OP_DST_OPERAND(VE_MAXIMUM,
|
||||
GL_FALSE,
|
||||
|
@ -594,7 +668,10 @@ static GLuint *r300TranslateOpcodeMAX(struct r300_vertex_program *vp, struct pro
|
|||
return inst;
|
||||
}
|
||||
|
||||
static GLuint *r300TranslateOpcodeMIN(struct r300_vertex_program *vp, struct prog_instruction *vpi, GLuint * inst, struct prog_src_register src[3])
|
||||
static GLuint *r300TranslateOpcodeMIN(struct r300_vertex_program *vp,
|
||||
struct prog_instruction *vpi,
|
||||
GLuint * inst,
|
||||
struct prog_src_register src[3])
|
||||
{
|
||||
inst[0] = PVS_OP_DST_OPERAND(VE_MINIMUM,
|
||||
GL_FALSE,
|
||||
|
@ -609,7 +686,10 @@ static GLuint *r300TranslateOpcodeMIN(struct r300_vertex_program *vp, struct pro
|
|||
return inst;
|
||||
}
|
||||
|
||||
static GLuint *r300TranslateOpcodeMOV(struct r300_vertex_program *vp, struct prog_instruction *vpi, GLuint * inst, struct prog_src_register src[3])
|
||||
static GLuint *r300TranslateOpcodeMOV(struct r300_vertex_program *vp,
|
||||
struct prog_instruction *vpi,
|
||||
GLuint * inst,
|
||||
struct prog_src_register src[3])
|
||||
{
|
||||
//ADD RESULT 1.X Y Z W PARAM 0{} {X Y Z W} PARAM 0{} {ZERO ZERO ZERO ZERO}
|
||||
|
||||
|
@ -626,7 +706,10 @@ static GLuint *r300TranslateOpcodeMOV(struct r300_vertex_program *vp, struct pro
|
|||
return inst;
|
||||
}
|
||||
|
||||
static GLuint *r300TranslateOpcodeMUL(struct r300_vertex_program *vp, struct prog_instruction *vpi, GLuint * inst, struct prog_src_register src[3])
|
||||
static GLuint *r300TranslateOpcodeMUL(struct r300_vertex_program *vp,
|
||||
struct prog_instruction *vpi,
|
||||
GLuint * inst,
|
||||
struct prog_src_register src[3])
|
||||
{
|
||||
inst[0] = PVS_OP_DST_OPERAND(VE_MULTIPLY,
|
||||
GL_FALSE,
|
||||
|
@ -641,7 +724,10 @@ static GLuint *r300TranslateOpcodeMUL(struct r300_vertex_program *vp, struct pro
|
|||
return inst;
|
||||
}
|
||||
|
||||
static GLuint *r300TranslateOpcodePOW(struct r300_vertex_program *vp, struct prog_instruction *vpi, GLuint * inst, struct prog_src_register src[3])
|
||||
static GLuint *r300TranslateOpcodePOW(struct r300_vertex_program *vp,
|
||||
struct prog_instruction *vpi,
|
||||
GLuint * inst,
|
||||
struct prog_src_register src[3])
|
||||
{
|
||||
inst[0] = PVS_OP_DST_OPERAND(ME_POWER_FUNC_FF,
|
||||
GL_TRUE,
|
||||
|
@ -656,7 +742,10 @@ static GLuint *r300TranslateOpcodePOW(struct r300_vertex_program *vp, struct pro
|
|||
return inst;
|
||||
}
|
||||
|
||||
static GLuint *r300TranslateOpcodeRCP(struct r300_vertex_program *vp, struct prog_instruction *vpi, GLuint * inst, struct prog_src_register src[3])
|
||||
static GLuint *r300TranslateOpcodeRCP(struct r300_vertex_program *vp,
|
||||
struct prog_instruction *vpi,
|
||||
GLuint * inst,
|
||||
struct prog_src_register src[3])
|
||||
{
|
||||
inst[0] = PVS_OP_DST_OPERAND(ME_RECIP_DX,
|
||||
GL_TRUE,
|
||||
|
@ -671,7 +760,10 @@ static GLuint *r300TranslateOpcodeRCP(struct r300_vertex_program *vp, struct pro
|
|||
return inst;
|
||||
}
|
||||
|
||||
static GLuint *r300TranslateOpcodeRSQ(struct r300_vertex_program *vp, struct prog_instruction *vpi, GLuint * inst, struct prog_src_register src[3])
|
||||
static GLuint *r300TranslateOpcodeRSQ(struct r300_vertex_program *vp,
|
||||
struct prog_instruction *vpi,
|
||||
GLuint * inst,
|
||||
struct prog_src_register src[3])
|
||||
{
|
||||
inst[0] = PVS_OP_DST_OPERAND(ME_RECIP_SQRT_DX,
|
||||
GL_TRUE,
|
||||
|
@ -686,7 +778,10 @@ static GLuint *r300TranslateOpcodeRSQ(struct r300_vertex_program *vp, struct pro
|
|||
return inst;
|
||||
}
|
||||
|
||||
static GLuint *r300TranslateOpcodeSGE(struct r300_vertex_program *vp, struct prog_instruction *vpi, GLuint * inst, struct prog_src_register src[3])
|
||||
static GLuint *r300TranslateOpcodeSGE(struct r300_vertex_program *vp,
|
||||
struct prog_instruction *vpi,
|
||||
GLuint * inst,
|
||||
struct prog_src_register src[3])
|
||||
{
|
||||
inst[0] = PVS_OP_DST_OPERAND(VE_SET_GREATER_THAN_EQUAL,
|
||||
GL_FALSE,
|
||||
|
@ -701,7 +796,10 @@ static GLuint *r300TranslateOpcodeSGE(struct r300_vertex_program *vp, struct pro
|
|||
return inst;
|
||||
}
|
||||
|
||||
static GLuint *r300TranslateOpcodeSLT(struct r300_vertex_program *vp, struct prog_instruction *vpi, GLuint * inst, struct prog_src_register src[3])
|
||||
static GLuint *r300TranslateOpcodeSLT(struct r300_vertex_program *vp,
|
||||
struct prog_instruction *vpi,
|
||||
GLuint * inst,
|
||||
struct prog_src_register src[3])
|
||||
{
|
||||
inst[0] = PVS_OP_DST_OPERAND(VE_SET_LESS_THAN,
|
||||
GL_FALSE,
|
||||
|
@ -716,7 +814,10 @@ static GLuint *r300TranslateOpcodeSLT(struct r300_vertex_program *vp, struct pro
|
|||
return inst;
|
||||
}
|
||||
|
||||
static GLuint *r300TranslateOpcodeSUB(struct r300_vertex_program *vp, struct prog_instruction *vpi, GLuint * inst, struct prog_src_register src[3])
|
||||
static GLuint *r300TranslateOpcodeSUB(struct r300_vertex_program *vp,
|
||||
struct prog_instruction *vpi,
|
||||
GLuint * inst,
|
||||
struct prog_src_register src[3])
|
||||
{
|
||||
//ADD RESULT 1.X Y Z W TMP 0{} {X Y Z W} PARAM 1{X Y Z W } {X Y Z W} neg Xneg Yneg Zneg W
|
||||
|
||||
|
@ -734,7 +835,9 @@ static GLuint *r300TranslateOpcodeSUB(struct r300_vertex_program *vp, struct pro
|
|||
t_swizzle(GET_SWZ(src[1].Swizzle, 2)),
|
||||
t_swizzle(GET_SWZ(src[1].Swizzle, 3)),
|
||||
t_src_class(src[1].File),
|
||||
(!src[1].NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE) | (src[1].RelAddr << 4);
|
||||
(!src[1].
|
||||
NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
|
||||
(src[1].RelAddr << 4);
|
||||
inst[3] = 0;
|
||||
#else
|
||||
inst[0] =
|
||||
|
@ -751,13 +854,18 @@ static GLuint *r300TranslateOpcodeSUB(struct r300_vertex_program *vp, struct pro
|
|||
t_swizzle(GET_SWZ(src[1].Swizzle, 2)),
|
||||
t_swizzle(GET_SWZ(src[1].Swizzle, 3)),
|
||||
t_src_class(src[1].File),
|
||||
(!src[1].NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE) | (src[1].RelAddr << 4);
|
||||
(!src[1].
|
||||
NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
|
||||
(src[1].RelAddr << 4);
|
||||
#endif
|
||||
|
||||
return inst;
|
||||
}
|
||||
|
||||
static GLuint *r300TranslateOpcodeSWZ(struct r300_vertex_program *vp, struct prog_instruction *vpi, GLuint * inst, struct prog_src_register src[3])
|
||||
static GLuint *r300TranslateOpcodeSWZ(struct r300_vertex_program *vp,
|
||||
struct prog_instruction *vpi,
|
||||
GLuint * inst,
|
||||
struct prog_src_register src[3])
|
||||
{
|
||||
//ADD RESULT 1.X Y Z W PARAM 0{} {X Y Z W} PARAM 0{} {ZERO ZERO ZERO ZERO}
|
||||
|
||||
|
@ -774,7 +882,11 @@ static GLuint *r300TranslateOpcodeSWZ(struct r300_vertex_program *vp, struct pro
|
|||
return inst;
|
||||
}
|
||||
|
||||
static GLuint *r300TranslateOpcodeXPD(struct r300_vertex_program *vp, struct prog_instruction *vpi, GLuint * inst, struct prog_src_register src[3], int *u_temp_i)
|
||||
static GLuint *r300TranslateOpcodeXPD(struct r300_vertex_program *vp,
|
||||
struct prog_instruction *vpi,
|
||||
GLuint * inst,
|
||||
struct prog_src_register src[3],
|
||||
int *u_temp_i)
|
||||
{
|
||||
/* mul r0, r1.yzxw, r2.zxyw
|
||||
mad r0, -r2.yzxw, r1.zxyw, r0
|
||||
|
@ -786,20 +898,22 @@ static GLuint *r300TranslateOpcodeXPD(struct r300_vertex_program *vp, struct pro
|
|||
*u_temp_i,
|
||||
t_dst_mask(vpi->DstReg.WriteMask),
|
||||
PVS_DST_REG_TEMPORARY);
|
||||
inst[1] = PVS_SRC_OPERAND(t_src_index(vp, &src[0]),
|
||||
t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // Y
|
||||
inst[1] = PVS_SRC_OPERAND(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // Y
|
||||
t_swizzle(GET_SWZ(src[0].Swizzle, 2)), // Z
|
||||
t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // X
|
||||
t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // W
|
||||
t_src_class(src[0].File),
|
||||
src[0].NegateBase ? VSF_FLAG_ALL : VSF_FLAG_NONE) | (src[0].RelAddr << 4);
|
||||
inst[2] = PVS_SRC_OPERAND(t_src_index(vp, &src[1]),
|
||||
t_swizzle(GET_SWZ(src[1].Swizzle, 2)), // Z
|
||||
src[0].
|
||||
NegateBase ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
|
||||
(src[0].RelAddr << 4);
|
||||
inst[2] = PVS_SRC_OPERAND(t_src_index(vp, &src[1]), t_swizzle(GET_SWZ(src[1].Swizzle, 2)), // Z
|
||||
t_swizzle(GET_SWZ(src[1].Swizzle, 0)), // X
|
||||
t_swizzle(GET_SWZ(src[1].Swizzle, 1)), // Y
|
||||
t_swizzle(GET_SWZ(src[1].Swizzle, 3)), // W
|
||||
t_src_class(src[1].File),
|
||||
src[1].NegateBase ? VSF_FLAG_ALL : VSF_FLAG_NONE) | (src[1].RelAddr << 4);
|
||||
src[1].
|
||||
NegateBase ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
|
||||
(src[1].RelAddr << 4);
|
||||
inst[3] = __CONST(1, SWIZZLE_ZERO);
|
||||
inst += 4;
|
||||
|
||||
|
@ -809,27 +923,26 @@ static GLuint *r300TranslateOpcodeXPD(struct r300_vertex_program *vp, struct pro
|
|||
t_dst_index(vp, &vpi->DstReg),
|
||||
t_dst_mask(vpi->DstReg.WriteMask),
|
||||
t_dst_class(vpi->DstReg.File));
|
||||
inst[1] = PVS_SRC_OPERAND(t_src_index(vp, &src[1]),
|
||||
t_swizzle(GET_SWZ(src[1].Swizzle, 1)), // Y
|
||||
inst[1] = PVS_SRC_OPERAND(t_src_index(vp, &src[1]), t_swizzle(GET_SWZ(src[1].Swizzle, 1)), // Y
|
||||
t_swizzle(GET_SWZ(src[1].Swizzle, 2)), // Z
|
||||
t_swizzle(GET_SWZ(src[1].Swizzle, 0)), // X
|
||||
t_swizzle(GET_SWZ(src[1].Swizzle, 3)), // W
|
||||
t_src_class(src[1].File),
|
||||
(!src[1].NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE) | (src[1].RelAddr << 4);
|
||||
inst[2] = PVS_SRC_OPERAND(t_src_index(vp, &src[0]),
|
||||
t_swizzle(GET_SWZ(src[0].Swizzle, 2)), // Z
|
||||
(!src[1].
|
||||
NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
|
||||
(src[1].RelAddr << 4);
|
||||
inst[2] = PVS_SRC_OPERAND(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 2)), // Z
|
||||
t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // X
|
||||
t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // Y
|
||||
t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // W
|
||||
t_src_class(src[0].File),
|
||||
src[0].NegateBase ? VSF_FLAG_ALL : VSF_FLAG_NONE) | (src[0].RelAddr << 4);
|
||||
inst[3] = PVS_SRC_OPERAND(*u_temp_i,
|
||||
PVS_SRC_SELECT_X,
|
||||
PVS_SRC_SELECT_Y,
|
||||
PVS_SRC_SELECT_Z,
|
||||
PVS_SRC_SELECT_W,
|
||||
PVS_SRC_REG_TEMPORARY,
|
||||
VSF_FLAG_NONE);
|
||||
src[0].
|
||||
NegateBase ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
|
||||
(src[0].RelAddr << 4);
|
||||
inst[3] =
|
||||
PVS_SRC_OPERAND(*u_temp_i, PVS_SRC_SELECT_X, PVS_SRC_SELECT_Y,
|
||||
PVS_SRC_SELECT_Z, PVS_SRC_SELECT_W,
|
||||
PVS_SRC_REG_TEMPORARY, VSF_FLAG_NONE);
|
||||
|
||||
(*u_temp_i)--;
|
||||
|
||||
|
@ -862,17 +975,20 @@ static void t_inputs_outputs(struct r300_vertex_program *vp)
|
|||
}
|
||||
|
||||
if (vp->key.OutputsWritten & (1 << VERT_RESULT_COL1)) {
|
||||
vp->outputs[VERT_RESULT_COL1] = vp->outputs[VERT_RESULT_COL0] + 1;
|
||||
vp->outputs[VERT_RESULT_COL1] =
|
||||
vp->outputs[VERT_RESULT_COL0] + 1;
|
||||
cur_reg = vp->outputs[VERT_RESULT_COL1] + 1;
|
||||
}
|
||||
|
||||
if (vp->key.OutputsWritten & (1 << VERT_RESULT_BFC0)) {
|
||||
vp->outputs[VERT_RESULT_BFC0] = vp->outputs[VERT_RESULT_COL0] + 2;
|
||||
vp->outputs[VERT_RESULT_BFC0] =
|
||||
vp->outputs[VERT_RESULT_COL0] + 2;
|
||||
cur_reg = vp->outputs[VERT_RESULT_BFC0] + 2;
|
||||
}
|
||||
|
||||
if (vp->key.OutputsWritten & (1 << VERT_RESULT_BFC1)) {
|
||||
vp->outputs[VERT_RESULT_BFC1] = vp->outputs[VERT_RESULT_COL0] + 3;
|
||||
vp->outputs[VERT_RESULT_BFC1] =
|
||||
vp->outputs[VERT_RESULT_COL0] + 3;
|
||||
cur_reg = vp->outputs[VERT_RESULT_BFC1] + 1;
|
||||
}
|
||||
#if 0
|
||||
|
@ -888,7 +1004,8 @@ static void t_inputs_outputs(struct r300_vertex_program *vp)
|
|||
}
|
||||
}
|
||||
|
||||
static void r300TranslateVertexShader(struct r300_vertex_program *vp, struct prog_instruction *vpi)
|
||||
static void r300TranslateVertexShader(struct r300_vertex_program *vp,
|
||||
struct prog_instruction *vpi)
|
||||
{
|
||||
int i;
|
||||
GLuint *inst;
|
||||
|
@ -907,7 +1024,8 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp, struct pro
|
|||
|
||||
t_inputs_outputs(vp);
|
||||
|
||||
for (inst = vp->program.body.i; vpi->Opcode != OPCODE_END; vpi++, inst += 4) {
|
||||
for (inst = vp->program.body.i; vpi->Opcode != OPCODE_END;
|
||||
vpi++, inst += 4) {
|
||||
|
||||
FREE_TEMPS();
|
||||
|
||||
|
@ -940,7 +1058,9 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp, struct pro
|
|||
SWIZZLE_Z,
|
||||
SWIZZLE_W,
|
||||
t_src_class(src[2].File),
|
||||
VSF_FLAG_NONE) | (src[2].RelAddr << 4);
|
||||
VSF_FLAG_NONE) | (src[2].
|
||||
RelAddr <<
|
||||
4);
|
||||
inst[2] = __CONST(2, SWIZZLE_ZERO);
|
||||
inst[3] = __CONST(2, SWIZZLE_ZERO);
|
||||
inst += 4;
|
||||
|
@ -967,7 +1087,9 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp, struct pro
|
|||
SWIZZLE_Z,
|
||||
SWIZZLE_W,
|
||||
t_src_class(src[0].File),
|
||||
VSF_FLAG_NONE) | (src[0].RelAddr << 4);
|
||||
VSF_FLAG_NONE) | (src[0].
|
||||
RelAddr <<
|
||||
4);
|
||||
inst[2] = __CONST(0, SWIZZLE_ZERO);
|
||||
inst[3] = __CONST(0, SWIZZLE_ZERO);
|
||||
inst += 4;
|
||||
|
@ -1077,7 +1199,8 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp, struct pro
|
|||
GL_FALSE,
|
||||
GL_FALSE,
|
||||
vp->outputs[i],
|
||||
VSF_FLAG_ALL, PVS_DST_REG_OUT);
|
||||
VSF_FLAG_ALL,
|
||||
PVS_DST_REG_OUT);
|
||||
inst[1] = __CONST(0, SWIZZLE_ZERO);
|
||||
inst[2] = __CONST(0, SWIZZLE_ZERO);
|
||||
inst[3] = __CONST(0, SWIZZLE_ZERO);
|
||||
|
@ -1173,7 +1296,8 @@ static void position_invariant(struct gl_program *prog)
|
|||
#endif
|
||||
}
|
||||
|
||||
_mesa_copy_instructions(&vpi[i], prog->Instructions, prog->NumInstructions);
|
||||
_mesa_copy_instructions(&vpi[i], prog->Instructions,
|
||||
prog->NumInstructions);
|
||||
|
||||
free(prog->Instructions);
|
||||
|
||||
|
@ -1185,7 +1309,8 @@ static void position_invariant(struct gl_program *prog)
|
|||
assert(vpi->Opcode == OPCODE_END);
|
||||
}
|
||||
|
||||
static void insert_wpos(struct r300_vertex_program *vp, struct gl_program *prog, GLuint temp_index)
|
||||
static void insert_wpos(struct r300_vertex_program *vp, struct gl_program *prog,
|
||||
GLuint temp_index)
|
||||
{
|
||||
struct prog_instruction *vpi;
|
||||
struct prog_instruction *vpi_insert;
|
||||
|
@ -1194,9 +1319,12 @@ static void insert_wpos(struct r300_vertex_program *vp, struct gl_program *prog,
|
|||
vpi = _mesa_alloc_instructions(prog->NumInstructions + 2);
|
||||
_mesa_init_instructions(vpi, prog->NumInstructions + 2);
|
||||
/* all but END */
|
||||
_mesa_copy_instructions(vpi, prog->Instructions, prog->NumInstructions - 1);
|
||||
_mesa_copy_instructions(vpi, prog->Instructions,
|
||||
prog->NumInstructions - 1);
|
||||
/* END */
|
||||
_mesa_copy_instructions(&vpi[prog->NumInstructions + 1], &prog->Instructions[prog->NumInstructions - 1], 1);
|
||||
_mesa_copy_instructions(&vpi[prog->NumInstructions + 1],
|
||||
&prog->Instructions[prog->NumInstructions - 1],
|
||||
1);
|
||||
vpi_insert = &vpi[prog->NumInstructions - 1];
|
||||
|
||||
vpi_insert[i].Opcode = OPCODE_MOV;
|
||||
|
@ -1233,7 +1361,8 @@ static void insert_wpos(struct r300_vertex_program *vp, struct gl_program *prog,
|
|||
assert(vpi->Opcode == OPCODE_END);
|
||||
}
|
||||
|
||||
static void pos_as_texcoord(struct r300_vertex_program *vp, struct gl_program *prog)
|
||||
static void pos_as_texcoord(struct r300_vertex_program *vp,
|
||||
struct gl_program *prog)
|
||||
{
|
||||
struct prog_instruction *vpi;
|
||||
GLuint tempregi = prog->NumTemporaries;
|
||||
|
@ -1241,7 +1370,8 @@ static void pos_as_texcoord(struct r300_vertex_program *vp, struct gl_program *p
|
|||
prog->NumTemporaries++;
|
||||
|
||||
for (vpi = prog->Instructions; vpi->Opcode != OPCODE_END; vpi++) {
|
||||
if (vpi->DstReg.File == PROGRAM_OUTPUT && vpi->DstReg.Index == VERT_RESULT_HPOS) {
|
||||
if (vpi->DstReg.File == PROGRAM_OUTPUT
|
||||
&& vpi->DstReg.Index == VERT_RESULT_HPOS) {
|
||||
vpi->DstReg.File = PROGRAM_TEMPORARY;
|
||||
vpi->DstReg.Index = tempregi;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue