Commit 76b571cb authored by Ivan Gyurdiev's avatar Ivan Gyurdiev Committed by Alexandre Julliard

wined3d: Move D3DSP source modifier-related items into the WINED3D namespace.

parent 17c9d958
......@@ -231,7 +231,7 @@ static void vshader_program_add_output_param_swizzle(const DWORD param, int is_c
static void pshader_get_input_register_swizzle(const DWORD instr, char *swzstring) {
static const char swizzle_reg_chars[] = "rgba";
DWORD swizzle = (instr & D3DSP_SWIZZLE_MASK) >> D3DSP_SWIZZLE_SHIFT;
DWORD swizzle = (instr & WINED3DSP_SWIZZLE_MASK) >> WINED3DSP_SWIZZLE_SHIFT;
DWORD swizzle_x = swizzle & 0x03;
DWORD swizzle_y = (swizzle >> 2) & 0x03;
DWORD swizzle_z = (swizzle >> 4) & 0x03;
......@@ -241,7 +241,7 @@ static void pshader_get_input_register_swizzle(const DWORD instr, char *swzstrin
* WWZZYYXX
*/
*swzstring = 0;
if ((D3DSP_NOSWIZZLE >> D3DSP_SWIZZLE_SHIFT) != swizzle) { /* ! D3DVS_NOSWIZZLE == 0xE4 << D3DVS_SWIZZLE_SHIFT */
if ((WINED3DSP_NOSWIZZLE >> WINED3DSP_SWIZZLE_SHIFT) != swizzle) {
if (swizzle_x == swizzle_y &&
swizzle_x == swizzle_z &&
swizzle_x == swizzle_w) {
......@@ -264,7 +264,7 @@ static void vshader_program_add_input_param_swizzle(const DWORD param, int is_co
char tmpReg[255];
/** operand input */
DWORD swizzle = (param & D3DVS_SWIZZLE_MASK) >> D3DVS_SWIZZLE_SHIFT;
DWORD swizzle = (param & WINED3DVS_SWIZZLE_MASK) >> WINED3DVS_SWIZZLE_SHIFT;
DWORD swizzle_x = swizzle & 0x03;
DWORD swizzle_y = (swizzle >> 2) & 0x03;
DWORD swizzle_z = (swizzle >> 4) & 0x03;
......@@ -280,7 +280,7 @@ static void vshader_program_add_input_param_swizzle(const DWORD param, int is_co
* swizzle bits fields:
* WWZZYYXX
*/
if ((D3DVS_NOSWIZZLE >> D3DVS_SWIZZLE_SHIFT) == swizzle) { /* D3DVS_NOSWIZZLE == 0xE4 << D3DVS_SWIZZLE_SHIFT */
if ((WINED3DVS_NOSWIZZLE >> WINED3DVS_SWIZZLE_SHIFT) == swizzle) {
if (is_color) {
sprintf(tmpReg, ".%c%c%c%c",
swizzle_regs[swizzle_x],
......@@ -368,7 +368,7 @@ static void vshader_program_add_param(SHADER_OPCODE_ARG *arg, const DWORD param,
char tmpReg[255];
BOOL is_color = FALSE;
if ((param & D3DSP_SRCMOD_MASK) == D3DSPSM_NEG) {
if ((param & WINED3DSP_SRCMOD_MASK) == WINED3DSPSM_NEG) {
strcat(hwLine, " -");
} else {
strcat(hwLine, " ");
......@@ -441,41 +441,41 @@ static void pshader_gen_input_modifier_line (
pshader_get_register_name(instr, regstr);
pshader_get_input_register_swizzle(instr, swzstr);
switch (instr & D3DSP_SRCMOD_MASK) {
case D3DSPSM_NONE:
switch (instr & WINED3DSP_SRCMOD_MASK) {
case WINED3DSPSM_NONE:
sprintf(outregstr, "%s%s", regstr, swzstr);
insert_line = 0;
break;
case D3DSPSM_NEG:
case WINED3DSPSM_NEG:
sprintf(outregstr, "-%s%s", regstr, swzstr);
insert_line = 0;
break;
case D3DSPSM_BIAS:
case WINED3DSPSM_BIAS:
shader_addline(buffer, "ADD T%c, %s, -coefdiv.x;\n", 'A' + tmpreg, regstr);
break;
case D3DSPSM_BIASNEG:
case WINED3DSPSM_BIASNEG:
shader_addline(buffer, "ADD T%c, -%s, coefdiv.x;\n", 'A' + tmpreg, regstr);
break;
case D3DSPSM_SIGN:
case WINED3DSPSM_SIGN:
shader_addline(buffer, "MAD T%c, %s, coefmul.x, -one.x;\n", 'A' + tmpreg, regstr);
break;
case D3DSPSM_SIGNNEG:
case WINED3DSPSM_SIGNNEG:
shader_addline(buffer, "MAD T%c, %s, -coefmul.x, one.x;\n", 'A' + tmpreg, regstr);
break;
case D3DSPSM_COMP:
case WINED3DSPSM_COMP:
shader_addline(buffer, "SUB T%c, one.x, %s;\n", 'A' + tmpreg, regstr);
break;
case D3DSPSM_X2:
case WINED3DSPSM_X2:
shader_addline(buffer, "ADD T%c, %s, %s;\n", 'A' + tmpreg, regstr, regstr);
break;
case D3DSPSM_X2NEG:
case WINED3DSPSM_X2NEG:
shader_addline(buffer, "ADD T%c, -%s, -%s;\n", 'A' + tmpreg, regstr, regstr);
break;
case D3DSPSM_DZ:
case WINED3DSPSM_DZ:
shader_addline(buffer, "RCP T%c, %s.z;\n", 'A' + tmpreg, regstr);
shader_addline(buffer, "MUL T%c, %s, T%c;\n", 'A' + tmpreg, regstr, 'A' + tmpreg);
break;
case D3DSPSM_DW:
case WINED3DSPSM_DW:
shader_addline(buffer, "RCP T%c, %s.w;\n", 'A' + tmpreg, regstr);
shader_addline(buffer, "MUL T%c, %s, T%c;\n", 'A' + tmpreg, regstr, 'A' + tmpreg);
break;
......
......@@ -507,7 +507,7 @@ void shader_dump_param(
DWORD reg = param & WINED3DSP_REGNUM_MASK;
DWORD regtype = shader_get_regtype(param);
DWORD modifier = param & D3DSP_SRCMOD_MASK;
DWORD modifier = param & WINED3DSP_SRCMOD_MASK;
/* There are some minor differences between pixel and vertex shaders */
char pshader = shader_is_pshader_version(This->baseShader.hex_version);
......@@ -521,18 +521,18 @@ void shader_dump_param(
swizzle_reg_chars[3] = pshader? 'a': 'w';
if (input) {
if ( (modifier == D3DSPSM_NEG) ||
(modifier == D3DSPSM_BIASNEG) ||
(modifier == D3DSPSM_SIGNNEG) ||
(modifier == D3DSPSM_X2NEG) ||
(modifier == D3DSPSM_ABSNEG) )
if ( (modifier == WINED3DSPSM_NEG) ||
(modifier == WINED3DSPSM_BIASNEG) ||
(modifier == WINED3DSPSM_SIGNNEG) ||
(modifier == WINED3DSPSM_X2NEG) ||
(modifier == WINED3DSPSM_ABSNEG) )
TRACE("-");
else if (modifier == D3DSPSM_COMP)
else if (modifier == WINED3DSPSM_COMP)
TRACE("1-");
else if (modifier == D3DSPSM_NOT)
else if (modifier == WINED3DSPSM_NOT)
TRACE("!");
if (modifier == D3DSPSM_ABS || modifier == D3DSPSM_ABSNEG)
if (modifier == WINED3DSPSM_ABS || modifier == WINED3DSPSM_ABSNEG)
TRACE("abs(");
}
......@@ -616,7 +616,7 @@ void shader_dump_param(
} else {
/** operand input */
DWORD swizzle = (param & D3DSP_SWIZZLE_MASK) >> D3DSP_SWIZZLE_SHIFT;
DWORD swizzle = (param & WINED3DSP_SWIZZLE_MASK) >> WINED3DSP_SWIZZLE_SHIFT;
DWORD swizzle_r = swizzle & 0x03;
DWORD swizzle_g = (swizzle >> 2) & 0x03;
DWORD swizzle_b = (swizzle >> 4) & 0x03;
......@@ -624,22 +624,22 @@ void shader_dump_param(
if (0 != modifier) {
switch (modifier) {
case D3DSPSM_NONE: break;
case D3DSPSM_NEG: break;
case D3DSPSM_NOT: break;
case D3DSPSM_BIAS: TRACE("_bias"); break;
case D3DSPSM_BIASNEG: TRACE("_bias"); break;
case D3DSPSM_SIGN: TRACE("_bx2"); break;
case D3DSPSM_SIGNNEG: TRACE("_bx2"); break;
case D3DSPSM_COMP: break;
case D3DSPSM_X2: TRACE("_x2"); break;
case D3DSPSM_X2NEG: TRACE("_x2"); break;
case D3DSPSM_DZ: TRACE("_dz"); break;
case D3DSPSM_DW: TRACE("_dw"); break;
case D3DSPSM_ABSNEG: TRACE(")"); break;
case D3DSPSM_ABS: TRACE(")"); break;
case WINED3DSPSM_NONE: break;
case WINED3DSPSM_NEG: break;
case WINED3DSPSM_NOT: break;
case WINED3DSPSM_BIAS: TRACE("_bias"); break;
case WINED3DSPSM_BIASNEG: TRACE("_bias"); break;
case WINED3DSPSM_SIGN: TRACE("_bx2"); break;
case WINED3DSPSM_SIGNNEG: TRACE("_bx2"); break;
case WINED3DSPSM_COMP: break;
case WINED3DSPSM_X2: TRACE("_x2"); break;
case WINED3DSPSM_X2NEG: TRACE("_x2"); break;
case WINED3DSPSM_DZ: TRACE("_dz"); break;
case WINED3DSPSM_DW: TRACE("_dw"); break;
case WINED3DSPSM_ABSNEG: TRACE(")"); break;
case WINED3DSPSM_ABS: TRACE(")"); break;
default:
TRACE("_unknown_modifier(%#x)", modifier >> D3DSP_SRCMOD_SHIFT);
TRACE("_unknown_modifier(%#x)", modifier >> WINED3DSP_SRCMOD_SHIFT);
}
}
......@@ -647,7 +647,7 @@ void shader_dump_param(
* swizzle bits fields:
* RRGGBBAA
*/
if ((D3DVS_NOSWIZZLE >> D3DVS_SWIZZLE_SHIFT) != swizzle) { /* ! D3DVS_NOSWIZZLE == 0xE4 << D3DVS_SWIZZLE_SHIFT */
if ((WINED3DVS_NOSWIZZLE >> WINED3DVS_SWIZZLE_SHIFT) != swizzle) {
if (swizzle_r == swizzle_g &&
swizzle_r == swizzle_b &&
swizzle_r == swizzle_a) {
......
......@@ -537,51 +537,51 @@ static void shader_glsl_gen_modifier (
if (instr == WINED3DSIO_TEXKILL)
return;
switch (instr & D3DSP_SRCMOD_MASK) {
case D3DSPSM_NONE:
switch (instr & WINED3DSP_SRCMOD_MASK) {
case WINED3DSPSM_NONE:
sprintf(out_str, "%s%s", in_reg, in_regswizzle);
break;
case D3DSPSM_NEG:
case WINED3DSPSM_NEG:
sprintf(out_str, "-%s%s", in_reg, in_regswizzle);
break;
case D3DSPSM_NOT:
case WINED3DSPSM_NOT:
sprintf(out_str, "!%s%s", in_reg, in_regswizzle);
break;
case D3DSPSM_BIAS:
case WINED3DSPSM_BIAS:
sprintf(out_str, "(%s%s - vec4(0.5)%s)", in_reg, in_regswizzle, in_regswizzle);
break;
case D3DSPSM_BIASNEG:
case WINED3DSPSM_BIASNEG:
sprintf(out_str, "-(%s%s - vec4(0.5)%s)", in_reg, in_regswizzle, in_regswizzle);
break;
case D3DSPSM_SIGN:
case WINED3DSPSM_SIGN:
sprintf(out_str, "(2.0 * (%s%s - 0.5))", in_reg, in_regswizzle);
break;
case D3DSPSM_SIGNNEG:
case WINED3DSPSM_SIGNNEG:
sprintf(out_str, "-(2.0 * (%s%s - 0.5))", in_reg, in_regswizzle);
break;
case D3DSPSM_COMP:
case WINED3DSPSM_COMP:
sprintf(out_str, "(1.0 - %s%s)", in_reg, in_regswizzle);
break;
case D3DSPSM_X2:
case WINED3DSPSM_X2:
sprintf(out_str, "(2.0 * %s%s)", in_reg, in_regswizzle);
break;
case D3DSPSM_X2NEG:
case WINED3DSPSM_X2NEG:
sprintf(out_str, "-(2.0 * %s%s)", in_reg, in_regswizzle);
break;
case D3DSPSM_DZ: /* reg1_db = { reg1.r/b, reg1.g/b, ...} The g & a components are undefined, so we'll leave them alone */
case WINED3DSPSM_DZ: /* reg1_db = { reg1.r/b, reg1.g/b, ...} The g & a components are undefined, so we'll leave them alone */
sprintf(out_str, "vec4(%s.r / %s.b, %s.g / %s.b, %s.b, %s.a)", in_reg, in_reg, in_reg, in_reg, in_reg, in_reg);
break;
case D3DSPSM_DW:
case WINED3DSPSM_DW:
sprintf(out_str, "vec4(%s.r / %s.a, %s.g / %s.a, %s.b, %s.a)", in_reg, in_reg, in_reg, in_reg, in_reg, in_reg);
break;
case D3DSPSM_ABS:
case WINED3DSPSM_ABS:
sprintf(out_str, "abs(%s%s)", in_reg, in_regswizzle);
break;
case D3DSPSM_ABSNEG:
case WINED3DSPSM_ABSNEG:
sprintf(out_str, "-abs(%s%s)", in_reg, in_regswizzle);
break;
default:
FIXME("Unhandled modifier %u\n", (instr & D3DSP_SRCMOD_MASK));
FIXME("Unhandled modifier %u\n", (instr & WINED3DSP_SRCMOD_MASK));
sprintf(out_str, "%s%s", in_reg, in_regswizzle);
}
}
......@@ -747,7 +747,7 @@ static void shader_glsl_get_input_register_swizzle(
const char* swizzle_regs = NULL;
/** operand input */
DWORD swizzle = (param & D3DVS_SWIZZLE_MASK) >> D3DVS_SWIZZLE_SHIFT;
DWORD swizzle = (param & WINED3DVS_SWIZZLE_MASK) >> WINED3DVS_SWIZZLE_SHIFT;
DWORD swizzle_x = swizzle & 0x03;
DWORD swizzle_y = (swizzle >> 2) & 0x03;
DWORD swizzle_z = (swizzle >> 4) & 0x03;
......@@ -763,7 +763,7 @@ static void shader_glsl_get_input_register_swizzle(
* swizzle bits fields:
* WWZZYYXX
*/
if ((D3DVS_NOSWIZZLE >> D3DVS_SWIZZLE_SHIFT) == swizzle) { /* D3DVS_NOSWIZZLE == 0xE4 << D3DVS_SWIZZLE_SHIFT */
if ((WINED3DVS_NOSWIZZLE >> WINED3DVS_SWIZZLE_SHIFT) == swizzle) {
if (is_color) {
sprintf(reg_mask, ".%c%c%c%c",
swizzle_regs[swizzle_x],
......
......@@ -971,10 +971,10 @@ HRESULT WINAPI IWineD3DVertexShaderImpl_ExecuteSW(IWineD3DVertexShader* iface, W
}
if (i > 0) { /* input reg */
DWORD swizzle = (pToken[i] & D3DVS_SWIZZLE_MASK) >> D3DVS_SWIZZLE_SHIFT;
UINT isNegative = ((pToken[i] & D3DSP_SRCMOD_MASK) == D3DSPSM_NEG);
DWORD swizzle = (pToken[i] & WINED3DVS_SWIZZLE_MASK) >> WINED3DVS_SWIZZLE_SHIFT;
UINT isNegative = ((pToken[i] & WINED3DSP_SRCMOD_MASK) == WINED3DSPSM_NEG);
if (!isNegative && (D3DVS_NOSWIZZLE >> D3DVS_SWIZZLE_SHIFT) == swizzle) {
if (!isNegative && (WINED3DVS_NOSWIZZLE >> WINED3DVS_SWIZZLE_SHIFT) == swizzle) {
/* TRACE("p[%d] not swizzled\n", i); */
p_send[i] = p[i];
} else {
......
......@@ -80,6 +80,60 @@ typedef enum _WINED3DSHADER_PARAM_REGISTER_TYPE {
WINED3DSPR_FORCE_DWORD = 0x7FFFFFFF
} WINED3DSHADER_PARAM_REGISTER_TYPE;
/** Source register modifiers **/
#define WINED3DVS_SWIZZLE_SHIFT 16
#define WINED3DVS_SWIZZLE_MASK (0xFF << WINED3DVS_SWIZZLE_SHIFT)
#define WINED3DSP_SWIZZLE_SHIFT 16
#define WINED3DSP_SWIZZLE_MASK (0xFF << WINED3DSP_SWIZZLE_SHIFT)
#define WINED3DVS_X_X (0 << WINED3DVS_SWIZZLE_SHIFT)
#define WINED3DVS_X_Y (1 << WINED3DVS_SWIZZLE_SHIFT)
#define WINED3DVS_X_Z (2 << WINED3DVS_SWIZZLE_SHIFT)
#define WINED3DVS_X_W (3 << WINED3DVS_SWIZZLE_SHIFT)
#define WINED3DVS_Y_X (0 << (WINED3DVS_SWIZZLE_SHIFT + 2))
#define WINED3DVS_Y_Y (1 << (WINED3DVS_SWIZZLE_SHIFT + 2))
#define WINED3DVS_Y_Z (2 << (WINED3DVS_SWIZZLE_SHIFT + 2))
#define WINED3DVS_Y_W (3 << (WINED3DVS_SWIZZLE_SHIFT + 2))
#define WINED3DVS_Z_X (0 << (WINED3DVS_SWIZZLE_SHIFT + 4))
#define WINED3DVS_Z_Y (1 << (WINED3DVS_SWIZZLE_SHIFT + 4))
#define WINED3DVS_Z_Z (2 << (WINED3DVS_SWIZZLE_SHIFT + 4))
#define WINED3DVS_Z_W (3 << (WINED3DVS_SWIZZLE_SHIFT + 4))
#define WINED3DVS_W_X (0 << (WINED3DVS_SWIZZLE_SHIFT + 6))
#define WINED3DVS_W_Y (1 << (WINED3DVS_SWIZZLE_SHIFT + 6))
#define WINED3DVS_W_Z (2 << (WINED3DVS_SWIZZLE_SHIFT + 6))
#define WINED3DVS_W_W (3 << (WINED3DVS_SWIZZLE_SHIFT + 6))
#define WINED3DVS_NOSWIZZLE (WINED3DVS_X_X | WINED3DVS_Y_Y | WINED3DVS_Z_Z | WINED3DVS_W_W)
#define WINED3DSP_NOSWIZZLE \
((0 << (WINED3DSP_SWIZZLE_SHIFT + 0)) | (1 << (WINED3DSP_SWIZZLE_SHIFT + 2)) | \
(2 << (WINED3DSP_SWIZZLE_SHIFT + 4)) | (3 << (WINED3DSP_SWIZZLE_SHIFT + 6)))
#define WINED3DSP_SRCMOD_SHIFT 24
#define WINED3DSP_SRCMOD_MASK (0xF << WINED3DSP_SRCMOD_SHIFT)
typedef enum _WINED3DSHADER_PARAM_SRCMOD_TYPE {
WINED3DSPSM_NONE = 0 << WINED3DSP_SRCMOD_SHIFT,
WINED3DSPSM_NEG = 1 << WINED3DSP_SRCMOD_SHIFT,
WINED3DSPSM_BIAS = 2 << WINED3DSP_SRCMOD_SHIFT,
WINED3DSPSM_BIASNEG = 3 << WINED3DSP_SRCMOD_SHIFT,
WINED3DSPSM_SIGN = 4 << WINED3DSP_SRCMOD_SHIFT,
WINED3DSPSM_SIGNNEG = 5 << WINED3DSP_SRCMOD_SHIFT,
WINED3DSPSM_COMP = 6 << WINED3DSP_SRCMOD_SHIFT,
WINED3DSPSM_X2 = 7 << WINED3DSP_SRCMOD_SHIFT,
WINED3DSPSM_X2NEG = 8 << WINED3DSP_SRCMOD_SHIFT,
WINED3DSPSM_DZ = 9 << WINED3DSP_SRCMOD_SHIFT,
WINED3DSPSM_DW = 10 << WINED3DSP_SRCMOD_SHIFT,
WINED3DSPSM_ABS = 11 << WINED3DSP_SRCMOD_SHIFT,
WINED3DSPSM_ABSNEG = 12 << WINED3DSP_SRCMOD_SHIFT,
WINED3DSPSM_NOT = 13 << WINED3DSP_SRCMOD_SHIFT,
WINED3DSPSM_FORCE_DWORD = 0x7FFFFFFF
} WINED3DSHADER_PARAM_SRCMOD_TYPE;
/** opcodes types for PS and VS */
typedef enum _WINED3DSHADER_INSTRUCTION_OPCODE_TYPE {
WINED3DSIO_NOP = 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