Commit fb3ee6e0 authored by Matteo Bruni's avatar Matteo Bruni Committed by Alexandre Julliard

d3dx9: Support some more vs_3_0 instructions in the shader assembler.

parent 399bde57
......@@ -85,7 +85,44 @@ ANY (.)
%%
/* Common instructions(vertex and pixel shaders) */
add {return INSTR_ADD; }
nop {return INSTR_NOP; }
mov {return INSTR_MOV; }
sub {return INSTR_SUB; }
mad {return INSTR_MAD; }
mul {return INSTR_MUL; }
rcp {return INSTR_RCP; }
rsq {return INSTR_RSQ; }
dp3 {return INSTR_DP3; }
dp4 {return INSTR_DP4; }
min {return INSTR_MIN; }
max {return INSTR_MAX; }
slt {return INSTR_SLT; }
sge {return INSTR_SGE; }
abs {return INSTR_ABS; }
exp {return INSTR_EXP; }
log {return INSTR_LOG; }
expp {return INSTR_EXPP; }
logp {return INSTR_LOGP; }
dst {return INSTR_DST; }
lrp {return INSTR_LRP; }
frc {return INSTR_FRC; }
pow {return INSTR_POW; }
crs {return INSTR_CRS; }
sgn {return INSTR_SGN; }
nrm {return INSTR_NRM; }
sincos {return INSTR_SINCOS; }
m4x4 {return INSTR_M4x4; }
m4x3 {return INSTR_M4x3; }
m3x4 {return INSTR_M3x4; }
m3x3 {return INSTR_M3x3; }
m3x2 {return INSTR_M3x2; }
texldl {return INSTR_TEXLDL; }
/* Vertex shader only instructions */
lit {return INSTR_LIT; }
mova {return INSTR_MOVA; }
{REG_TEMP} {
asmshader_lval.regnum = atoi(yytext + 1);
......
......@@ -116,7 +116,41 @@ DWORD d3d9_register(DWORD bwriter_register) {
DWORD d3d9_opcode(DWORD bwriter_opcode) {
switch(bwriter_opcode) {
case BWRITERSIO_NOP: return D3DSIO_NOP;
case BWRITERSIO_MOV: return D3DSIO_MOV;
case BWRITERSIO_ADD: return D3DSIO_ADD;
case BWRITERSIO_SUB: return D3DSIO_SUB;
case BWRITERSIO_MAD: return D3DSIO_MAD;
case BWRITERSIO_MUL: return D3DSIO_MUL;
case BWRITERSIO_RCP: return D3DSIO_RCP;
case BWRITERSIO_RSQ: return D3DSIO_RSQ;
case BWRITERSIO_DP3: return D3DSIO_DP3;
case BWRITERSIO_DP4: return D3DSIO_DP4;
case BWRITERSIO_MIN: return D3DSIO_MIN;
case BWRITERSIO_MAX: return D3DSIO_MAX;
case BWRITERSIO_SLT: return D3DSIO_SLT;
case BWRITERSIO_SGE: return D3DSIO_SGE;
case BWRITERSIO_EXP: return D3DSIO_EXP;
case BWRITERSIO_LOG: return D3DSIO_LOG;
case BWRITERSIO_LIT: return D3DSIO_LIT;
case BWRITERSIO_DST: return D3DSIO_DST;
case BWRITERSIO_LRP: return D3DSIO_LRP;
case BWRITERSIO_FRC: return D3DSIO_FRC;
case BWRITERSIO_M4x4: return D3DSIO_M4x4;
case BWRITERSIO_M4x3: return D3DSIO_M4x3;
case BWRITERSIO_M3x4: return D3DSIO_M3x4;
case BWRITERSIO_M3x3: return D3DSIO_M3x3;
case BWRITERSIO_M3x2: return D3DSIO_M3x2;
case BWRITERSIO_POW: return D3DSIO_POW;
case BWRITERSIO_CRS: return D3DSIO_CRS;
case BWRITERSIO_SGN: return D3DSIO_SGN;
case BWRITERSIO_ABS: return D3DSIO_ABS;
case BWRITERSIO_NRM: return D3DSIO_NRM;
case BWRITERSIO_SINCOS: return D3DSIO_SINCOS;
case BWRITERSIO_MOVA: return D3DSIO_MOVA;
case BWRITERSIO_EXPP: return D3DSIO_EXPP;
case BWRITERSIO_LOGP: return D3DSIO_LOGP;
case BWRITERSIO_TEXLDL: return D3DSIO_TEXLDL;
case BWRITERSIO_COMMENT: return D3DSIO_COMMENT;
case BWRITERSIO_END: return D3DSIO_END;
......@@ -312,7 +346,41 @@ const char *debug_print_srcreg(const struct shader_reg *reg, shader_type st) {
const char *debug_print_opcode(DWORD opcode) {
switch(opcode){
case BWRITERSIO_NOP: return "nop";
case BWRITERSIO_MOV: return "mov";
case BWRITERSIO_ADD: return "add";
case BWRITERSIO_SUB: return "sub";
case BWRITERSIO_MAD: return "mad";
case BWRITERSIO_MUL: return "mul";
case BWRITERSIO_RCP: return "rcp";
case BWRITERSIO_RSQ: return "rsq";
case BWRITERSIO_DP3: return "dp3";
case BWRITERSIO_DP4: return "dp4";
case BWRITERSIO_MIN: return "min";
case BWRITERSIO_MAX: return "max";
case BWRITERSIO_SLT: return "slt";
case BWRITERSIO_SGE: return "sge";
case BWRITERSIO_EXP: return "exp";
case BWRITERSIO_LOG: return "log";
case BWRITERSIO_LIT: return "lit";
case BWRITERSIO_DST: return "dst";
case BWRITERSIO_LRP: return "lrp";
case BWRITERSIO_FRC: return "frc";
case BWRITERSIO_M4x4: return "m4x4";
case BWRITERSIO_M4x3: return "m4x3";
case BWRITERSIO_M3x4: return "m3x4";
case BWRITERSIO_M3x3: return "m3x3";
case BWRITERSIO_M3x2: return "m3x2";
case BWRITERSIO_POW: return "pow";
case BWRITERSIO_CRS: return "crs";
case BWRITERSIO_SGN: return "sgn";
case BWRITERSIO_ABS: return "abs";
case BWRITERSIO_NRM: return "nrm";
case BWRITERSIO_SINCOS: return "sincos";
case BWRITERSIO_MOVA: return "mova";
case BWRITERSIO_EXPP: return "expp";
case BWRITERSIO_LOGP: return "logp";
case BWRITERSIO_TEXLDL: return "texldl";
default: return "unknown";
}
......
......@@ -283,7 +283,43 @@ static void sm_3_dstreg(struct bc_writer *This,
}
static const struct instr_handler_table vs_3_handlers[] = {
{BWRITERSIO_ADD, instr_handler},
{BWRITERSIO_NOP, instr_handler},
{BWRITERSIO_MOV, instr_handler},
{BWRITERSIO_SUB, instr_handler},
{BWRITERSIO_MAD, instr_handler},
{BWRITERSIO_MUL, instr_handler},
{BWRITERSIO_RCP, instr_handler},
{BWRITERSIO_RSQ, instr_handler},
{BWRITERSIO_DP3, instr_handler},
{BWRITERSIO_DP4, instr_handler},
{BWRITERSIO_MIN, instr_handler},
{BWRITERSIO_MAX, instr_handler},
{BWRITERSIO_SLT, instr_handler},
{BWRITERSIO_SGE, instr_handler},
{BWRITERSIO_ABS, instr_handler},
{BWRITERSIO_EXP, instr_handler},
{BWRITERSIO_LOG, instr_handler},
{BWRITERSIO_EXPP, instr_handler},
{BWRITERSIO_LOGP, instr_handler},
{BWRITERSIO_DST, instr_handler},
{BWRITERSIO_LRP, instr_handler},
{BWRITERSIO_FRC, instr_handler},
{BWRITERSIO_CRS, instr_handler},
{BWRITERSIO_SGN, instr_handler},
{BWRITERSIO_NRM, instr_handler},
{BWRITERSIO_SINCOS, instr_handler},
{BWRITERSIO_M4x4, instr_handler},
{BWRITERSIO_M4x3, instr_handler},
{BWRITERSIO_M3x4, instr_handler},
{BWRITERSIO_M3x3, instr_handler},
{BWRITERSIO_M3x2, instr_handler},
{BWRITERSIO_LIT, instr_handler},
{BWRITERSIO_POW, instr_handler},
{BWRITERSIO_MOVA, instr_handler},
{BWRITERSIO_TEXLDL, instr_handler},
{BWRITERSIO_END, NULL},
};
......
......@@ -363,10 +363,45 @@ DWORD d3d9_opcode(DWORD bwriter_opcode);
intermediate representation
*/
typedef enum _BWRITERSHADER_INSTRUCTION_OPCODE_TYPE {
BWRITERSIO_MOV = 1,
BWRITERSIO_COMMENT = 0xfffe,
BWRITERSIO_END = 0Xffff,
BWRITERSIO_NOP,
BWRITERSIO_MOV,
BWRITERSIO_ADD,
BWRITERSIO_SUB,
BWRITERSIO_MAD,
BWRITERSIO_MUL,
BWRITERSIO_RCP,
BWRITERSIO_RSQ,
BWRITERSIO_DP3,
BWRITERSIO_DP4,
BWRITERSIO_MIN,
BWRITERSIO_MAX,
BWRITERSIO_SLT,
BWRITERSIO_SGE,
BWRITERSIO_EXP,
BWRITERSIO_LOG,
BWRITERSIO_LIT,
BWRITERSIO_DST,
BWRITERSIO_LRP,
BWRITERSIO_FRC,
BWRITERSIO_M4x4,
BWRITERSIO_M4x3,
BWRITERSIO_M3x4,
BWRITERSIO_M3x3,
BWRITERSIO_M3x2,
BWRITERSIO_POW,
BWRITERSIO_CRS,
BWRITERSIO_SGN,
BWRITERSIO_ABS,
BWRITERSIO_NRM,
BWRITERSIO_SINCOS,
BWRITERSIO_MOVA,
BWRITERSIO_EXPP,
BWRITERSIO_LOGP,
BWRITERSIO_TEXLDL,
BWRITERSIO_COMMENT,
BWRITERSIO_END,
} BWRITERSHADER_INSTRUCTION_OPCODE_TYPE;
typedef enum _BWRITERSHADER_PARAM_REGISTER_TYPE {
......
......@@ -1033,11 +1033,11 @@ static void vs_3_0_test(void) {
"dcl_texcoord12 o11\n",
{0xfffe0300, 0x0200001f, 0x800c0005, 0xe00f000b, 0x0000ffff}
},*/
/* {*/ /* shader 4 */
/* "vs_3_0\n"
{ /* shader 4 */
"vs_3_0\n"
"texldl r0, v0, s0\n",
{0xfffe0300, 0x0300005f, 0x800f0000, 0x90e40000, 0xa0e40800, 0x0000ffff}
},*/
},
{ /* shader 5 */
"vs_3_0\n"
"mov r0, c0[aL]\n",
......@@ -1048,11 +1048,11 @@ static void vs_3_0_test(void) {
"mov o[ a0.x + 12 ], r0\n",
{0xfffe0300, 0x03000001, 0xe00f200c, 0xb0000000, 0x80e40000, 0x0000ffff}
},
/* {*/ /* shader 7 */
/* "vs_3_0\n"
{ /* shader 7 */
"vs_3_0\n"
"add_sat r0, r0, r1\n",
{0xfffe0300, 0x03000002, 0x801f0000, 0x80e40000, 0x80e40001, 0x0000ffff}
},*/
},
{ /* shader 8 */
"vs_3_0\n"
"mov r2, r1_abs\n",
......@@ -1068,7 +1068,16 @@ static void vs_3_0_test(void) {
"mov r2.xyb, r1\n",
{0xfffe0300, 0x02000001, 0x80070002, 0x80e40001, 0x0000ffff}
},
{ /* shader 11 */
"vs_3_0\n"
"mova_sat a0.x, r1\n",
{0xfffe0300, 0x0200002e, 0xb0110000, 0x80e40001, 0x0000ffff}
},
{ /* shader 12 */
"vs_3_0\n"
"sincos r0, r1\n",
{0xfffe0300, 0x02000025, 0x800f0000, 0x80e40001, 0x0000ffff}
},
};
exec_tests("vs_3_0", tests, sizeof(tests) / sizeof(tests[0]));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment