wined3d: Give WINED3DSIO_CRS its own function, properly take the write mask into account.

This commit is contained in:
H. Verbeet 2007-01-15 19:31:56 +01:00 committed by Alexandre Julliard
parent b557a8021a
commit 7252b4d340
4 changed files with 18 additions and 3 deletions

View File

@ -1003,6 +1003,21 @@ void shader_glsl_dot(SHADER_OPCODE_ARG* arg) {
tmpDest, cast, src0_str, cast, src1_str, dst_mask);
}
/* Note that this instruction has some restrictions. The destination write mask
* can't contain the w component, and the source swizzles have to be .xyzw */
void shader_glsl_cross(SHADER_OPCODE_ARG *arg) {
char src0_reg[50], src0_mask[6], src0_str[100];
char src1_reg[50], src1_mask[6], src1_str[100];
DWORD src_mask = WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1 | WINED3DSP_WRITEMASK_2;
char dst_mask[6];
shader_glsl_get_write_mask(arg->dst, dst_mask);
shader_glsl_append_dst(arg->buffer, arg);
shader_glsl_add_src_param(arg, arg->src[0], arg->src_addr[0], src_mask, src0_reg, src0_mask, src0_str);
shader_glsl_add_src_param(arg, arg->src[1], arg->src_addr[1], src_mask, src1_reg, src1_mask, src1_str);
shader_addline(arg->buffer, "cross(%s, %s).%s);\n", src0_str, src1_str, dst_mask);
}
/* Map the opcode 1-to-1 to the GL code (arg->dst = instruction(src0, src1, ...) */
void shader_glsl_map2gl(SHADER_OPCODE_ARG* arg) {
@ -1027,7 +1042,6 @@ void shader_glsl_map2gl(SHADER_OPCODE_ARG* arg) {
case WINED3DSIO_ABS: strcat(tmpLine, "abs"); break;
case WINED3DSIO_FRC: strcat(tmpLine, "fract"); break;
case WINED3DSIO_POW: strcat(tmpLine, "pow"); break;
case WINED3DSIO_CRS: strcat(tmpLine, "cross"); break;
case WINED3DSIO_NRM: strcat(tmpLine, "normalize"); break;
case WINED3DSIO_LOGP:
case WINED3DSIO_LOG: strcat(tmpLine, "log2"); break;

View File

@ -646,7 +646,7 @@ CONST SHADER_OPCODE IWineD3DPixelShaderImpl_shader_ins[] = {
{WINED3DSIO_CND, "cnd", NULL, 1, 4, pshader_cnd, pshader_hw_cnd, shader_glsl_cnd, WINED3DPS_VERSION(1,1), WINED3DPS_VERSION(1,4)},
{WINED3DSIO_CMP, "cmp", NULL, 1, 4, pshader_cmp, pshader_hw_cmp, shader_glsl_cmp, WINED3DPS_VERSION(1,2), WINED3DPS_VERSION(3,0)},
{WINED3DSIO_POW, "pow", "POW", 1, 3, pshader_pow, NULL, shader_glsl_map2gl, 0, 0},
{WINED3DSIO_CRS, "crs", "XPS", 1, 3, pshader_crs, NULL, shader_glsl_map2gl, 0, 0},
{WINED3DSIO_CRS, "crs", "XPS", 1, 3, pshader_crs, NULL, shader_glsl_cross, 0, 0},
/* TODO: xyz normalise can be performed as VS_ARB using one temporary register,
DP3 tmp , vec, vec;
RSQ tmp, tmp.x;

View File

@ -501,7 +501,7 @@ CONST SHADER_OPCODE IWineD3DVertexShaderImpl_shader_ins[] = {
{WINED3DSIO_LRP, "lrp", "LRP", 1, 4, vshader_lrp, NULL, shader_glsl_lrp, 0, 0},
{WINED3DSIO_FRC, "frc", "FRC", 1, 2, vshader_frc, vshader_hw_map2gl, shader_glsl_map2gl, 0, 0},
{WINED3DSIO_POW, "pow", "POW", 1, 3, vshader_pow, NULL, shader_glsl_map2gl, 0, 0},
{WINED3DSIO_CRS, "crs", "XPS", 1, 3, vshader_crs, NULL, shader_glsl_map2gl, 0, 0},
{WINED3DSIO_CRS, "crs", "XPS", 1, 3, vshader_crs, NULL, shader_glsl_cross, 0, 0},
/* TODO: sng can possibly be performed a s
RCP tmp, vec
MUL out, tmp, vec*/

View File

@ -1616,6 +1616,7 @@ extern void shader_glsl_load_constants(
char useVertexShader);
/** The following translate DirectX pixel/vertex shader opcodes to GLSL lines */
extern void shader_glsl_cross(SHADER_OPCODE_ARG* arg);
extern void shader_glsl_map2gl(SHADER_OPCODE_ARG* arg);
extern void shader_glsl_arith(SHADER_OPCODE_ARG* arg);
extern void shader_glsl_mov(SHADER_OPCODE_ARG* arg);