6/10: WineD3D: rsq and rcp instructions may need a default swizzle in arb.

ARB shaders need a swizzle for the RSQ and RCP instructions, while d3d
shaders do not. The DirectX sdk says that the x component is used if
no swizzle is given.
This commit is contained in:
Stefan Dösinger 2007-02-15 13:50:59 +01:00 committed by Alexandre Julliard
parent 8e84127aed
commit 2f96220b3e
3 changed files with 24 additions and 2 deletions

View File

@ -881,6 +881,27 @@ void vshader_hw_mnxn(SHADER_OPCODE_ARG* arg) {
}
}
void vshader_hw_rsq_rcp(SHADER_OPCODE_ARG* arg) {
CONST SHADER_OPCODE* curOpcode = arg->opcode;
SHADER_BUFFER* buffer = arg->buffer;
DWORD dst = arg->dst;
DWORD src = arg->src[0];
DWORD swizzle = (src & WINED3DSP_SWIZZLE_MASK) >> WINED3DSP_SWIZZLE_SHIFT;
char tmpLine[256];
strcpy(tmpLine, curOpcode->glname); /* Opcode */
vshader_program_add_param(arg, dst, FALSE, tmpLine); /* Destination */
strcat(tmpLine, ",");
vshader_program_add_param(arg, src, TRUE, tmpLine);
if ((WINED3DSP_NOSWIZZLE >> WINED3DSP_SWIZZLE_SHIFT) == swizzle) {
/* Dx sdk says .x is used if no swizzle is given */
strcat(tmpLine, ".x");
}
shader_addline(buffer, "%s;\n", tmpLine);
}
/* TODO: merge with pixel shader */
/* Map the opcode 1-to-1 to the GL code */
void vshader_hw_map2gl(SHADER_OPCODE_ARG* arg) {

View File

@ -483,8 +483,8 @@ CONST SHADER_OPCODE IWineD3DVertexShaderImpl_shader_ins[] = {
{WINED3DSIO_SUB, "sub", "SUB", 1, 3, vshader_sub, vshader_hw_map2gl, shader_glsl_arith, 0, 0},
{WINED3DSIO_MAD, "mad", "MAD", 1, 4, vshader_mad, vshader_hw_map2gl, shader_glsl_mad, 0, 0},
{WINED3DSIO_MUL, "mul", "MUL", 1, 3, vshader_mul, vshader_hw_map2gl, shader_glsl_arith, 0, 0},
{WINED3DSIO_RCP, "rcp", "RCP", 1, 2, vshader_rcp, vshader_hw_map2gl, shader_glsl_rcp, 0, 0},
{WINED3DSIO_RSQ, "rsq", "RSQ", 1, 2, vshader_rsq, vshader_hw_map2gl, shader_glsl_map2gl, 0, 0},
{WINED3DSIO_RCP, "rcp", "RCP", 1, 2, vshader_rcp, vshader_hw_rsq_rcp,shader_glsl_rcp, 0, 0},
{WINED3DSIO_RSQ, "rsq", "RSQ", 1, 2, vshader_rsq, vshader_hw_rsq_rcp,shader_glsl_map2gl, 0, 0},
{WINED3DSIO_DP3, "dp3", "DP3", 1, 3, vshader_dp3, vshader_hw_map2gl, shader_glsl_dot, 0, 0},
{WINED3DSIO_DP4, "dp4", "DP4", 1, 3, vshader_dp4, vshader_hw_map2gl, shader_glsl_dot, 0, 0},
{WINED3DSIO_MIN, "min", "MIN", 1, 3, vshader_min, vshader_hw_map2gl, shader_glsl_map2gl, 0, 0},

View File

@ -1601,6 +1601,7 @@ extern void pshader_hw_texm3x3vspec(SHADER_OPCODE_ARG* arg);
/* ARB vertex shader prototypes */
extern void vshader_hw_map2gl(SHADER_OPCODE_ARG* arg);
extern void vshader_hw_mnxn(SHADER_OPCODE_ARG* arg);
extern void vshader_hw_rsq_rcp(SHADER_OPCODE_ARG* arg);
/* GLSL helper functions */
extern void shader_glsl_add_instruction_modifiers(SHADER_OPCODE_ARG *arg);