wined3d: Implement more GLSL instructions and a little cleanup.

- Implement D3DSIO_DP2ADD, D3DSIO_TEXKILL, D3DSIO_TEXM3X3PAD
- Partially implement D3DSIO_TEXBEM, D3DSIO_TEXM3X3VSPEC (as much as
  they are implemented in ARB_fragment_program at least).
- Stop copying the SHADER_PARSE_STATE struct in each ARB shader
  routine - use a pointer instead.
This commit is contained in:
Jason Green 2006-06-27 02:00:02 -04:00 committed by Alexandre Julliard
parent 3489f1b9b1
commit baf38b3007
4 changed files with 121 additions and 19 deletions

View File

@ -375,6 +375,7 @@ void shader_get_registers_used(
/* Declare 1.X samplers implicitly, based on the destination reg. number */ /* Declare 1.X samplers implicitly, based on the destination reg. number */
if (D3DSHADER_VERSION_MAJOR(This->baseShader.hex_version) == 1 && if (D3DSHADER_VERSION_MAJOR(This->baseShader.hex_version) == 1 &&
(D3DSIO_TEX == curOpcode->opcode || (D3DSIO_TEX == curOpcode->opcode ||
D3DSIO_TEXBEM == curOpcode->opcode ||
D3DSIO_TEXM3x2TEX == curOpcode->opcode || D3DSIO_TEXM3x2TEX == curOpcode->opcode ||
D3DSIO_TEXM3x3TEX == curOpcode->opcode || D3DSIO_TEXM3x3TEX == curOpcode->opcode ||
D3DSIO_TEXM3x3SPEC == curOpcode->opcode || D3DSIO_TEXM3x3SPEC == curOpcode->opcode ||

View File

@ -416,6 +416,9 @@ static void shader_glsl_gen_modifier (
out_str[0] = 0; out_str[0] = 0;
if (instr == D3DSIO_TEXKILL)
return;
switch (instr & D3DSP_SRCMOD_MASK) { switch (instr & D3DSP_SRCMOD_MASK) {
case D3DSPSM_NONE: case D3DSPSM_NONE:
sprintf(out_str, "%s%s", in_reg, in_regswizzle); sprintf(out_str, "%s%s", in_reg, in_regswizzle);
@ -1266,8 +1269,6 @@ void pshader_glsl_texcoord(SHADER_OPCODE_ARG* arg) {
void pshader_glsl_texm3x2pad(SHADER_OPCODE_ARG* arg) { void pshader_glsl_texm3x2pad(SHADER_OPCODE_ARG* arg) {
/* FIXME: Make this work for more than just 2D textures */
DWORD reg = arg->dst & D3DSP_REGNUM_MASK; DWORD reg = arg->dst & D3DSP_REGNUM_MASK;
SHADER_BUFFER* buffer = arg->buffer; SHADER_BUFFER* buffer = arg->buffer;
char src0_str[100]; char src0_str[100];
@ -1275,7 +1276,24 @@ void pshader_glsl_texm3x2pad(SHADER_OPCODE_ARG* arg) {
char src0_mask[6]; char src0_mask[6];
shader_glsl_add_param(arg, arg->src[0], arg->src_addr[0], TRUE, src0_name, src0_mask, src0_str); shader_glsl_add_param(arg, arg->src[0], arg->src_addr[0], TRUE, src0_name, src0_mask, src0_str);
shader_addline(buffer, "tmp0.x = dot(vec3(T%lu), vec3(%s));\n", reg, src0_name, src0_mask, src0_str); shader_addline(buffer, "tmp0.x = dot(vec3(T%lu), vec3(%s));\n", reg, src0_name, src0_str);
}
/** Process the D3DSIO_TEXM3X3PAD instruction in GLSL
* Calculate the 1st or 2nd row of a 3-row matrix multiplication. */
void pshader_glsl_texm3x3pad(SHADER_OPCODE_ARG* arg) {
IWineD3DPixelShaderImpl* shader = (IWineD3DPixelShaderImpl*) arg->shader;
DWORD reg = arg->dst & D3DSP_REGNUM_MASK;
SHADER_BUFFER* buffer = arg->buffer;
SHADER_PARSE_STATE* current_state = &shader->baseShader.parse_state;
char src0_str[100];
char src0_name[50];
char src0_mask[6];
shader_glsl_add_param(arg, arg->src[0], arg->src_addr[0], TRUE, src0_name, src0_mask, src0_str);
shader_addline(buffer, "tmp%i.x = dot(vec3(T%lu), vec3(%s));\n", current_state->current_row, reg, src0_str);
current_state->texcoord_w[current_state->current_row++] = reg;
} }
void pshader_glsl_texm3x2tex(SHADER_OPCODE_ARG* arg) { void pshader_glsl_texm3x2tex(SHADER_OPCODE_ARG* arg) {
@ -1293,6 +1311,84 @@ void pshader_glsl_texm3x2tex(SHADER_OPCODE_ARG* arg) {
shader_addline(buffer, "T%lu = texture2D(Psampler%lu, tmp0.st);\n", reg, reg); shader_addline(buffer, "T%lu = texture2D(Psampler%lu, tmp0.st);\n", reg, reg);
} }
/** Process the D3DSIO_TEXM3X3VSPEC instruction in GLSL
* Peform the final texture lookup based on the previous 2 3x3 matrix multiplies */
void pshader_glsl_texm3x3vspec(SHADER_OPCODE_ARG* arg) {
IWineD3DPixelShaderImpl* shader = (IWineD3DPixelShaderImpl*) arg->shader;
DWORD reg = arg->dst & D3DSP_REGNUM_MASK;
SHADER_BUFFER* buffer = arg->buffer;
SHADER_PARSE_STATE* current_state = &shader->baseShader.parse_state;
char src0_str[100], src0_name[50], src0_mask[6];
shader_glsl_add_param(arg, arg->src[0], arg->src_addr[0], TRUE, src0_name, src0_mask, src0_str);
/* Perform the last matrix multiply operation */
shader_addline(buffer, "tmp0.z = dot(vec3(T%lu), vec3(%s));\n", reg, src0_str);
/* Construct the eye-ray vector from w coordinates */
shader_addline(buffer, "tmp1.x = gl_TexCoord[%lu].w;\n", current_state->texcoord_w[0]);
shader_addline(buffer, "tmp1.x = gl_TexCoord[%lu].w;\n", current_state->texcoord_w[1]);
shader_addline(buffer, "tmp1.z = gl_TexCoord[%lu].w;\n", reg);
/* Calculate reflection vector (Assume normal is normalized): RF = 2*(N.E)*N -E */
shader_addline(buffer, "tmp0.x = dot(vec3(tmp0), vec3(tmp1));\n");
shader_addline(buffer, "tmp0 = tmp0.w * tmp0;\n");
shader_addline(buffer, "tmp0 = (2.0 * tmp0) - tmp1;\n");
/* FIXME:
* The ARB_fragment_program implementation uses Cube texture lookups here, but that is just a guess.
* We probably need to push back the pixel shader generation code until drawPrimitive() for
* shader versions < 2.0, since that's the only time we can guarantee that we're sampling
* the correct type of texture because we can lookup what textures are bound at that point.
* For now, just sample the texture as if it's 2D.
*/
FIXME("Incorrect dimensionality for pixel shader texm3x3vspec instruction.\n");
shader_addline(buffer, "T%lu = texture2D(Psampler%lu, tmp0.xy);\n", reg, reg);
current_state->current_row = 0;
}
/** Process the D3DSIO_TEXBEM instruction in GLSL.
* Apply a fake bump map transform.
* FIXME: Should apply the BUMPMAPENV matrix. For now, just sample the texture */
void pshader_glsl_texbem(SHADER_OPCODE_ARG* arg) {
DWORD reg1 = arg->dst & D3DSP_REGNUM_MASK;
DWORD reg2 = arg->src[0] & D3DSP_REGNUM_MASK;
FIXME("Not applying the BUMPMAPENV matrix for pixel shader instruction texbem.\n");
shader_addline(arg->buffer, "T%lu = texture2D(Psampler%lu, gl_TexCoord[%lu].xy + T%lu.xy);\n",
reg1, reg1, reg1, reg2);
}
/** Process the D3DSIO_TEXKILL instruction in GLSL.
* If any of the first 3 components are < 0, discard this pixel */
void pshader_glsl_texkill(SHADER_OPCODE_ARG* arg) {
char src0_str[100], src0_name[50], src0_mask[6];
shader_glsl_add_param(arg, arg->src[0], arg->src_addr[0], TRUE, src0_name, src0_mask, src0_str);
shader_addline(arg->buffer, "if (%s.x < 0.0 || %s.y < 0.0 || %s.z < 0.0) discard;\n", src0_name, src0_name, src0_name);
}
/** Process the D3DSIO_DP2ADD instruction in GLSL.
* dst = dot2(src0, src1) + src2 */
void pshader_glsl_dp2add(SHADER_OPCODE_ARG* arg) {
char tmpLine[256];
char dst_str[100], src0_str[100], src1_str[100], src2_str[100];
char dst_reg[50], src0_reg[50], src1_reg[50], src2_reg[50];
char dst_mask[6], src0_mask[6], src1_mask[6], src2_mask[6];
shader_glsl_add_param(arg, arg->dst, 0, FALSE, dst_reg, dst_mask, dst_str);
shader_glsl_add_param(arg, arg->src[0], arg->src_addr[0], TRUE, src0_reg, src0_mask, src0_str);
shader_glsl_add_param(arg, arg->src[1], arg->src_addr[1], TRUE, src1_reg, src1_mask, src1_str);
shader_glsl_add_param(arg, arg->src[2], arg->src_addr[2], TRUE, src2_reg, src2_mask, src2_str);
shader_glsl_add_dst(arg->dst, dst_reg, dst_mask, tmpLine);
shader_addline(arg->buffer, "%sdot(vec2(%s), vec2(%s)) + %s)%s;\n",
tmpLine, src0_str, src1_str, src2_str, dst_mask);
}
void pshader_glsl_input_pack( void pshader_glsl_input_pack(
SHADER_BUFFER* buffer, SHADER_BUFFER* buffer,
DWORD* semantics_in) { DWORD* semantics_in) {

View File

@ -676,7 +676,7 @@ CONST SHADER_OPCODE IWineD3DPixelShaderImpl_shader_ins[] = {
{D3DSIO_SINCOS, "sincos", NULL, 1, 4, pshader_sincos2, NULL, shader_glsl_sincos, D3DPS_VERSION(2,0), D3DPS_VERSION(2,0)}, {D3DSIO_SINCOS, "sincos", NULL, 1, 4, pshader_sincos2, NULL, shader_glsl_sincos, D3DPS_VERSION(2,0), D3DPS_VERSION(2,0)},
{D3DSIO_SINCOS, "sincos", NULL, 1, 2, pshader_sincos3, NULL, shader_glsl_sincos, D3DPS_VERSION(3,0), -1}, {D3DSIO_SINCOS, "sincos", NULL, 1, 2, pshader_sincos3, NULL, shader_glsl_sincos, D3DPS_VERSION(3,0), -1},
/* TODO: dp2add can be made out of multiple instuctions */ /* TODO: dp2add can be made out of multiple instuctions */
{D3DSIO_DP2ADD, "dp2add", GLNAME_REQUIRE_GLSL, 1, 4, pshader_dp2add, NULL, NULL, D3DPS_VERSION(2,0), -1}, {D3DSIO_DP2ADD, "dp2add", GLNAME_REQUIRE_GLSL, 1, 4, pshader_dp2add, NULL, pshader_glsl_dp2add, D3DPS_VERSION(2,0), -1},
/* Matrix */ /* Matrix */
{D3DSIO_M4x4, "m4x4", "undefined", 1, 3, pshader_m4x4, NULL, shader_glsl_mnxn, 0, 0}, {D3DSIO_M4x4, "m4x4", "undefined", 1, 3, pshader_m4x4, NULL, shader_glsl_mnxn, 0, 0},
@ -713,21 +713,21 @@ CONST SHADER_OPCODE IWineD3DPixelShaderImpl_shader_ins[] = {
/* Texture */ /* Texture */
{D3DSIO_TEXCOORD, "texcoord", "undefined", 1, 1, pshader_texcoord, pshader_hw_texcoord, pshader_glsl_texcoord, 0, D3DPS_VERSION(1,3)}, {D3DSIO_TEXCOORD, "texcoord", "undefined", 1, 1, pshader_texcoord, pshader_hw_texcoord, pshader_glsl_texcoord, 0, D3DPS_VERSION(1,3)},
{D3DSIO_TEXCOORD, "texcrd", "undefined", 1, 2, pshader_texcoord, pshader_hw_texcoord, pshader_glsl_texcoord, D3DPS_VERSION(1,4), D3DPS_VERSION(1,4)}, {D3DSIO_TEXCOORD, "texcrd", "undefined", 1, 2, pshader_texcoord, pshader_hw_texcoord, pshader_glsl_texcoord, D3DPS_VERSION(1,4), D3DPS_VERSION(1,4)},
{D3DSIO_TEXKILL, "texkill", "KIL", 1, 1, pshader_texkill, pshader_hw_map2gl, NULL, D3DPS_VERSION(1,0), D3DPS_VERSION(3,0)}, {D3DSIO_TEXKILL, "texkill", "KIL", 1, 1, pshader_texkill, pshader_hw_map2gl, pshader_glsl_texkill, D3DPS_VERSION(1,0), D3DPS_VERSION(3,0)},
{D3DSIO_TEX, "tex", "undefined", 1, 1, pshader_tex, pshader_hw_tex, pshader_glsl_tex, 0, D3DPS_VERSION(1,3)}, {D3DSIO_TEX, "tex", "undefined", 1, 1, pshader_tex, pshader_hw_tex, pshader_glsl_tex, 0, D3DPS_VERSION(1,3)},
{D3DSIO_TEX, "texld", "undefined", 1, 2, pshader_texld, pshader_hw_tex, pshader_glsl_tex, D3DPS_VERSION(1,4), D3DPS_VERSION(1,4)}, {D3DSIO_TEX, "texld", "undefined", 1, 2, pshader_texld, pshader_hw_tex, pshader_glsl_tex, D3DPS_VERSION(1,4), D3DPS_VERSION(1,4)},
{D3DSIO_TEX, "texld", "undefined", 1, 3, pshader_texld, pshader_hw_tex, pshader_glsl_tex, D3DPS_VERSION(2,0), -1}, {D3DSIO_TEX, "texld", "undefined", 1, 3, pshader_texld, pshader_hw_tex, pshader_glsl_tex, D3DPS_VERSION(2,0), -1},
{D3DSIO_TEXBEM, "texbem", "undefined", 1, 2, pshader_texbem, pshader_hw_texbem, NULL, 0, D3DPS_VERSION(1,3)}, {D3DSIO_TEXBEM, "texbem", "undefined", 1, 2, pshader_texbem, pshader_hw_texbem, pshader_glsl_texbem, 0, D3DPS_VERSION(1,3)},
{D3DSIO_TEXBEML, "texbeml", GLNAME_REQUIRE_GLSL, 1, 2, pshader_texbeml, NULL, NULL, D3DPS_VERSION(1,0), D3DPS_VERSION(1,3)}, {D3DSIO_TEXBEML, "texbeml", GLNAME_REQUIRE_GLSL, 1, 2, pshader_texbeml, NULL, NULL, D3DPS_VERSION(1,0), D3DPS_VERSION(1,3)},
{D3DSIO_TEXREG2AR,"texreg2ar","undefined", 1, 2, pshader_texreg2ar, pshader_hw_texreg2ar, NULL, D3DPS_VERSION(1,1), D3DPS_VERSION(1,3)}, {D3DSIO_TEXREG2AR,"texreg2ar","undefined", 1, 2, pshader_texreg2ar, pshader_hw_texreg2ar, NULL, D3DPS_VERSION(1,1), D3DPS_VERSION(1,3)},
{D3DSIO_TEXREG2GB,"texreg2gb","undefined", 1, 2, pshader_texreg2gb, pshader_hw_texreg2gb, NULL, D3DPS_VERSION(1,1), D3DPS_VERSION(1,3)}, {D3DSIO_TEXREG2GB,"texreg2gb","undefined", 1, 2, pshader_texreg2gb, pshader_hw_texreg2gb, NULL, D3DPS_VERSION(1,1), D3DPS_VERSION(1,3)},
{D3DSIO_TEXREG2RGB, "texreg2rgb", GLNAME_REQUIRE_GLSL, 1, 2, pshader_texreg2rgb, NULL, NULL, D3DPS_VERSION(1,2), D3DPS_VERSION(1,3)}, {D3DSIO_TEXREG2RGB, "texreg2rgb", GLNAME_REQUIRE_GLSL, 1, 2, pshader_texreg2rgb, NULL, NULL, D3DPS_VERSION(1,2), D3DPS_VERSION(1,3)},
{D3DSIO_TEXM3x2PAD, "texm3x2pad", "undefined", 1, 2, pshader_texm3x2pad, pshader_hw_texm3x2pad, pshader_glsl_texm3x2pad, D3DPS_VERSION(1,0), D3DPS_VERSION(1,3)}, {D3DSIO_TEXM3x2PAD, "texm3x2pad", "undefined", 1, 2, pshader_texm3x2pad, pshader_hw_texm3x2pad, pshader_glsl_texm3x2pad, D3DPS_VERSION(1,0), D3DPS_VERSION(1,3)},
{D3DSIO_TEXM3x2TEX, "texm3x2tex", "undefined", 1, 2, pshader_texm3x2tex, pshader_hw_texm3x2tex, pshader_glsl_texm3x2tex, D3DPS_VERSION(1,0), D3DPS_VERSION(1,3)}, {D3DSIO_TEXM3x2TEX, "texm3x2tex", "undefined", 1, 2, pshader_texm3x2tex, pshader_hw_texm3x2tex, pshader_glsl_texm3x2tex, D3DPS_VERSION(1,0), D3DPS_VERSION(1,3)},
{D3DSIO_TEXM3x3PAD, "texm3x3pad", "undefined", 1, 2, pshader_texm3x3pad, pshader_hw_texm3x3pad, NULL, D3DPS_VERSION(1,0), D3DPS_VERSION(1,3)}, {D3DSIO_TEXM3x3PAD, "texm3x3pad", "undefined", 1, 2, pshader_texm3x3pad, pshader_hw_texm3x3pad, pshader_glsl_texm3x3pad, D3DPS_VERSION(1,0), D3DPS_VERSION(1,3)},
{D3DSIO_TEXM3x3DIFF, "texm3x3diff", GLNAME_REQUIRE_GLSL, 1, 2, pshader_texm3x3diff, NULL, NULL, D3DPS_VERSION(0,0), D3DPS_VERSION(0,0)}, {D3DSIO_TEXM3x3DIFF, "texm3x3diff", GLNAME_REQUIRE_GLSL, 1, 2, pshader_texm3x3diff, NULL, NULL, D3DPS_VERSION(0,0), D3DPS_VERSION(0,0)},
{D3DSIO_TEXM3x3SPEC, "texm3x3spec", "undefined", 1, 3, pshader_texm3x3spec, pshader_hw_texm3x3spec, NULL, D3DPS_VERSION(1,0), D3DPS_VERSION(1,3)}, {D3DSIO_TEXM3x3SPEC, "texm3x3spec", "undefined", 1, 3, pshader_texm3x3spec, pshader_hw_texm3x3spec, NULL, D3DPS_VERSION(1,0), D3DPS_VERSION(1,3)},
{D3DSIO_TEXM3x3VSPEC, "texm3x3vspe", "undefined", 1, 2, pshader_texm3x3vspec, pshader_hw_texm3x3vspec, NULL, D3DPS_VERSION(1,0), D3DPS_VERSION(1,3)}, {D3DSIO_TEXM3x3VSPEC, "texm3x3vspec", "undefined", 1, 2, pshader_texm3x3vspec, pshader_hw_texm3x3vspec, pshader_glsl_texm3x3vspec, D3DPS_VERSION(1,0), D3DPS_VERSION(1,3)},
{D3DSIO_TEXM3x3TEX, "texm3x3tex", "undefined", 1, 2, pshader_texm3x3tex, pshader_hw_texm3x3tex, NULL, D3DPS_VERSION(1,0), D3DPS_VERSION(1,3)}, {D3DSIO_TEXM3x3TEX, "texm3x3tex", "undefined", 1, 2, pshader_texm3x3tex, pshader_hw_texm3x3tex, NULL, D3DPS_VERSION(1,0), D3DPS_VERSION(1,3)},
{D3DSIO_TEXDP3TEX, "texdp3tex", GLNAME_REQUIRE_GLSL, 1, 2, pshader_texdp3tex, NULL, NULL, D3DPS_VERSION(1,2), D3DPS_VERSION(1,3)}, {D3DSIO_TEXDP3TEX, "texdp3tex", GLNAME_REQUIRE_GLSL, 1, 2, pshader_texdp3tex, NULL, NULL, D3DPS_VERSION(1,2), D3DPS_VERSION(1,3)},
{D3DSIO_TEXM3x2DEPTH, "texm3x2depth", GLNAME_REQUIRE_GLSL, 1, 2, pshader_texm3x2depth, NULL, NULL, D3DPS_VERSION(1,3), D3DPS_VERSION(1,3)}, {D3DSIO_TEXM3x2DEPTH, "texm3x2depth", GLNAME_REQUIRE_GLSL, 1, 2, pshader_texm3x2depth, NULL, NULL, D3DPS_VERSION(1,3), D3DPS_VERSION(1,3)},
@ -1226,12 +1226,12 @@ static void pshader_hw_texm3x3pad(SHADER_OPCODE_ARG* arg) {
IWineD3DPixelShaderImpl* shader = (IWineD3DPixelShaderImpl*) arg->shader; IWineD3DPixelShaderImpl* shader = (IWineD3DPixelShaderImpl*) arg->shader;
DWORD reg = arg->dst & D3DSP_REGNUM_MASK; DWORD reg = arg->dst & D3DSP_REGNUM_MASK;
SHADER_BUFFER* buffer = arg->buffer; SHADER_BUFFER* buffer = arg->buffer;
SHADER_PARSE_STATE current_state = shader->baseShader.parse_state; SHADER_PARSE_STATE* current_state = &shader->baseShader.parse_state;
char src0_name[50]; char src0_name[50];
pshader_gen_input_modifier_line(buffer, arg->src[0], 0, src0_name, arg->reg_maps->constantsF); pshader_gen_input_modifier_line(buffer, arg->src[0], 0, src0_name, arg->reg_maps->constantsF);
shader_addline(buffer, "DP3 TMP.%c, T%lu, %s;\n", 'x' + current_state.current_row, reg, src0_name); shader_addline(buffer, "DP3 TMP.%c, T%lu, %s;\n", 'x' + current_state->current_row, reg, src0_name);
current_state.texcoord_w[current_state.current_row++] = reg; current_state->texcoord_w[current_state->current_row++] = reg;
} }
static void pshader_hw_texm3x3tex(SHADER_OPCODE_ARG* arg) { static void pshader_hw_texm3x3tex(SHADER_OPCODE_ARG* arg) {
@ -1239,7 +1239,7 @@ static void pshader_hw_texm3x3tex(SHADER_OPCODE_ARG* arg) {
IWineD3DPixelShaderImpl* shader = (IWineD3DPixelShaderImpl*) arg->shader; IWineD3DPixelShaderImpl* shader = (IWineD3DPixelShaderImpl*) arg->shader;
DWORD reg = arg->dst & D3DSP_REGNUM_MASK; DWORD reg = arg->dst & D3DSP_REGNUM_MASK;
SHADER_BUFFER* buffer = arg->buffer; SHADER_BUFFER* buffer = arg->buffer;
SHADER_PARSE_STATE current_state = shader->baseShader.parse_state; SHADER_PARSE_STATE* current_state = &shader->baseShader.parse_state;
char src0_name[50]; char src0_name[50];
pshader_gen_input_modifier_line(buffer, arg->src[0], 0, src0_name, arg->reg_maps->constantsF); pshader_gen_input_modifier_line(buffer, arg->src[0], 0, src0_name, arg->reg_maps->constantsF);
@ -1247,7 +1247,7 @@ static void pshader_hw_texm3x3tex(SHADER_OPCODE_ARG* arg) {
/* Cubemap textures will be more used than 3D ones. */ /* Cubemap textures will be more used than 3D ones. */
shader_addline(buffer, "TEX T%lu, TMP, texture[%lu], CUBE;\n", reg, reg); shader_addline(buffer, "TEX T%lu, TMP, texture[%lu], CUBE;\n", reg, reg);
current_state.current_row = 0; current_state->current_row = 0;
} }
static void pshader_hw_texm3x3vspec(SHADER_OPCODE_ARG* arg) { static void pshader_hw_texm3x3vspec(SHADER_OPCODE_ARG* arg) {
@ -1255,15 +1255,15 @@ static void pshader_hw_texm3x3vspec(SHADER_OPCODE_ARG* arg) {
IWineD3DPixelShaderImpl* shader = (IWineD3DPixelShaderImpl*) arg->shader; IWineD3DPixelShaderImpl* shader = (IWineD3DPixelShaderImpl*) arg->shader;
DWORD reg = arg->dst & D3DSP_REGNUM_MASK; DWORD reg = arg->dst & D3DSP_REGNUM_MASK;
SHADER_BUFFER* buffer = arg->buffer; SHADER_BUFFER* buffer = arg->buffer;
SHADER_PARSE_STATE current_state = shader->baseShader.parse_state; SHADER_PARSE_STATE* current_state = &shader->baseShader.parse_state;
char src0_name[50]; char src0_name[50];
pshader_gen_input_modifier_line(buffer, arg->src[0], 0, src0_name, arg->reg_maps->constantsF); pshader_gen_input_modifier_line(buffer, arg->src[0], 0, src0_name, arg->reg_maps->constantsF);
shader_addline(buffer, "DP3 TMP.z, T%lu, %s;\n", reg, src0_name); shader_addline(buffer, "DP3 TMP.z, T%lu, %s;\n", reg, src0_name);
/* Construct the eye-ray vector from w coordinates */ /* Construct the eye-ray vector from w coordinates */
shader_addline(buffer, "MOV TMP2.x, fragment.texcoord[%lu].w;\n", current_state.texcoord_w[0]); shader_addline(buffer, "MOV TMP2.x, fragment.texcoord[%lu].w;\n", current_state->texcoord_w[0]);
shader_addline(buffer, "MOV TMP2.y, fragment.texcoord[%lu].w;\n", current_state.texcoord_w[1]); shader_addline(buffer, "MOV TMP2.y, fragment.texcoord[%lu].w;\n", current_state->texcoord_w[1]);
shader_addline(buffer, "MOV TMP2.z, fragment.texcoord[%lu].w;\n", reg); shader_addline(buffer, "MOV TMP2.z, fragment.texcoord[%lu].w;\n", reg);
/* Calculate reflection vector (Assume normal is normalized): RF = 2*(N.E)*N -E */ /* Calculate reflection vector (Assume normal is normalized): RF = 2*(N.E)*N -E */
@ -1273,7 +1273,7 @@ static void pshader_hw_texm3x3vspec(SHADER_OPCODE_ARG* arg) {
/* Cubemap textures will be more used than 3D ones. */ /* Cubemap textures will be more used than 3D ones. */
shader_addline(buffer, "TEX T%lu, TMP, texture[%lu], CUBE;\n", reg, reg); shader_addline(buffer, "TEX T%lu, TMP, texture[%lu], CUBE;\n", reg, reg);
current_state.current_row = 0; current_state->current_row = 0;
} }
static void pshader_hw_texm3x3spec(SHADER_OPCODE_ARG* arg) { static void pshader_hw_texm3x3spec(SHADER_OPCODE_ARG* arg) {
@ -1281,7 +1281,7 @@ static void pshader_hw_texm3x3spec(SHADER_OPCODE_ARG* arg) {
IWineD3DPixelShaderImpl* shader = (IWineD3DPixelShaderImpl*) arg->shader; IWineD3DPixelShaderImpl* shader = (IWineD3DPixelShaderImpl*) arg->shader;
DWORD reg = arg->dst & D3DSP_REGNUM_MASK; DWORD reg = arg->dst & D3DSP_REGNUM_MASK;
DWORD reg3 = arg->src[1] & D3DSP_REGNUM_MASK; DWORD reg3 = arg->src[1] & D3DSP_REGNUM_MASK;
SHADER_PARSE_STATE current_state = shader->baseShader.parse_state; SHADER_PARSE_STATE* current_state = &shader->baseShader.parse_state;
SHADER_BUFFER* buffer = arg->buffer; SHADER_BUFFER* buffer = arg->buffer;
char src0_name[50]; char src0_name[50];
@ -1295,7 +1295,7 @@ static void pshader_hw_texm3x3spec(SHADER_OPCODE_ARG* arg) {
/* Cubemap textures will be more used than 3D ones. */ /* Cubemap textures will be more used than 3D ones. */
shader_addline(buffer, "TEX T%lu, TMP, texture[%lu], CUBE;\n", reg, reg); shader_addline(buffer, "TEX T%lu, TMP, texture[%lu], CUBE;\n", reg, reg);
current_state.current_row = 0; current_state->current_row = 0;
} }
/** Generate a pixel shader string using either GL_FRAGMENT_PROGRAM_ARB /** Generate a pixel shader string using either GL_FRAGMENT_PROGRAM_ARB

View File

@ -1411,6 +1411,11 @@ extern void pshader_glsl_tex(SHADER_OPCODE_ARG* arg);
extern void pshader_glsl_texcoord(SHADER_OPCODE_ARG* arg); extern void pshader_glsl_texcoord(SHADER_OPCODE_ARG* arg);
extern void pshader_glsl_texm3x2pad(SHADER_OPCODE_ARG* arg); extern void pshader_glsl_texm3x2pad(SHADER_OPCODE_ARG* arg);
extern void pshader_glsl_texm3x2tex(SHADER_OPCODE_ARG* arg); extern void pshader_glsl_texm3x2tex(SHADER_OPCODE_ARG* arg);
extern void pshader_glsl_texm3x3pad(SHADER_OPCODE_ARG* arg);
extern void pshader_glsl_texm3x3vspec(SHADER_OPCODE_ARG* arg);
extern void pshader_glsl_texkill(SHADER_OPCODE_ARG* arg);
extern void pshader_glsl_texbem(SHADER_OPCODE_ARG* arg);
extern void pshader_glsl_dp2add(SHADER_OPCODE_ARG* arg);
extern void pshader_glsl_input_pack( extern void pshader_glsl_input_pack(
SHADER_BUFFER* buffer, SHADER_BUFFER* buffer,
DWORD* semantics_out); DWORD* semantics_out);