wined3d: Merge pshader_get_register_name() and part of vshader_program_add_param().

This commit is contained in:
Henri Verbeet 2009-04-10 09:15:07 +02:00 committed by Alexandre Julliard
parent 9a28d273bc
commit e6031afdfa
1 changed files with 180 additions and 161 deletions

View File

@ -433,56 +433,95 @@ static void shader_arb_get_swizzle(const DWORD param, BOOL fixup, char *swizzle_
*ptr = '\0'; *ptr = '\0';
} }
static void pshader_get_register_name(IWineD3DBaseShader *iface, static void shader_arb_get_register_name(IWineD3DBaseShader *iface, WINED3DSHADER_PARAM_REGISTER_TYPE register_type,
WINED3DSHADER_PARAM_REGISTER_TYPE register_type, UINT register_idx, char *regstr) UINT register_idx, BOOL rel_addr, char *register_name, BOOL *is_color)
{ {
IWineD3DBaseShaderImpl *This = (IWineD3DBaseShaderImpl *) iface; /* oPos, oFog and oPts in D3D */
static const char * const rastout_reg_names[] = {"TMP_OUT", "result.fogcoord", "result.pointsize"};
IWineD3DBaseShaderImpl *This = (IWineD3DBaseShaderImpl *)iface;
DWORD shader_version = This->baseShader.reg_maps.shader_version;
BOOL pshader = shader_is_pshader_version(shader_version);
*is_color = FALSE;
switch (register_type) switch (register_type)
{ {
case WINED3DSPR_TEMP: case WINED3DSPR_TEMP:
sprintf(regstr, "R%u", register_idx); sprintf(register_name, "R%u", register_idx);
break; break;
case WINED3DSPR_INPUT:
if (register_idx == 0) case WINED3DSPR_INPUT:
{ if (pshader)
strcpy(regstr, "fragment.color.primary"); {
} else { if (register_idx == 0) strcpy(register_name, "fragment.color.primary");
strcpy(regstr, "fragment.color.secondary"); else strcpy(register_name, "fragment.color.secondary");
} }
break; else
case WINED3DSPR_CONST: {
if(This->baseShader.load_local_constsF || list_empty(&This->baseShader.constantsF)) { if (((IWineD3DVertexShaderImpl *)This)->cur_args->swizzle_map & (1 << register_idx)) *is_color = TRUE;
sprintf(regstr, "C[%u]", register_idx); sprintf(register_name, "vertex.attrib[%u]", register_idx);
} else { }
sprintf(regstr, "C%u", register_idx); break;
}
break; case WINED3DSPR_CONST:
case WINED3DSPR_TEXTURE: /* case WINED3DSPR_ADDR: */ if (!pshader && rel_addr)
sprintf(regstr, "T%u", register_idx); {
break; UINT rel_offset = ((IWineD3DVertexShaderImpl *)This)->rel_offset;
case WINED3DSPR_COLOROUT: if (register_idx >= rel_offset)
if (register_idx == 0) sprintf(register_name, "C[A0.x + %u]", register_idx - rel_offset);
sprintf(regstr, "TMP_COLOR"); else
else { sprintf(register_name, "C[A0.x - %u]", -register_idx + rel_offset);
/* TODO: See GL_ARB_draw_buffers */ }
FIXME("Unsupported write to render target %u\n", register_idx); else
sprintf(regstr, "unsupported_register"); {
} if (This->baseShader.load_local_constsF || list_empty(&This->baseShader.constantsF))
break; sprintf(register_name, "C[%u]", register_idx);
case WINED3DSPR_DEPTHOUT: else
sprintf(regstr, "result.depth"); sprintf(register_name, "C%u", register_idx);
break; }
case WINED3DSPR_ATTROUT: break;
sprintf(regstr, "oD[%u]", register_idx);
break; case WINED3DSPR_TEXTURE: /* case WINED3DSPR_ADDR: */
case WINED3DSPR_TEXCRDOUT: if (pshader) sprintf(register_name, "T%u", register_idx);
sprintf(regstr, "oT[%u]", register_idx); else sprintf(register_name, "A%u", register_idx);
break; break;
default:
FIXME("Unhandled register name Type(%d)\n", register_type); case WINED3DSPR_COLOROUT:
sprintf(regstr, "unrecognized_register"); if (register_idx == 0)
break; {
strcpy(register_name, "TMP_COLOR");
}
else
{
/* TODO: See GL_ARB_draw_buffers */
FIXME("Unsupported write to render target %u\n", register_idx);
sprintf(register_name, "unsupported_register");
}
break;
case WINED3DSPR_RASTOUT:
sprintf(register_name, "%s", rastout_reg_names[register_idx]);
break;
case WINED3DSPR_DEPTHOUT:
strcpy(register_name, "result.depth");
break;
case WINED3DSPR_ATTROUT:
if (pshader) sprintf(register_name, "oD[%u]", register_idx);
else if (register_idx == 0) strcpy(register_name, "result.color.primary");
else strcpy(register_name, "result.color.secondary");
break;
case WINED3DSPR_TEXCRDOUT:
if (pshader) sprintf(register_name, "oT[%u]", register_idx);
else sprintf(register_name, "result.texcoord[%u]", register_idx);
break;
default:
FIXME("Unhandled register type %#x[%u]\n", register_type, register_idx);
sprintf(register_name, "unrecognized_register[%u]", register_idx);
break;
} }
} }
@ -490,84 +529,28 @@ static void pshader_get_register_name(IWineD3DBaseShader *iface,
static void vshader_program_add_param(const struct wined3d_shader_instruction *ins, static void vshader_program_add_param(const struct wined3d_shader_instruction *ins,
const DWORD param, BOOL is_input, char *hwLine) const DWORD param, BOOL is_input, char *hwLine)
{ {
IWineD3DVertexShaderImpl *This = (IWineD3DVertexShaderImpl *)ins->shader; char tmpReg[255];
BOOL is_color;
/* oPos, oFog and oPts in D3D */ if ((param & WINED3DSP_SRCMOD_MASK) == WINED3DSPSM_NEG) strcat(hwLine, " -");
static const char * const hwrastout_reg_names[] = { "TMP_OUT", "result.fogcoord", "result.pointsize" }; else strcat(hwLine, " ");
DWORD reg = param & WINED3DSP_REGNUM_MASK; shader_arb_get_register_name(ins->shader, shader_get_regtype(param), param & WINED3DSP_REGNUM_MASK,
DWORD regtype = shader_get_regtype(param); param & WINED3DSHADER_ADDRMODE_RELATIVE, tmpReg, &is_color);
char tmpReg[255];
BOOL is_color = FALSE;
if ((param & WINED3DSP_SRCMOD_MASK) == WINED3DSPSM_NEG) {
strcat(hwLine, " -");
} else {
strcat(hwLine, " ");
}
switch (regtype) {
case WINED3DSPR_TEMP:
sprintf(tmpReg, "R%u", reg);
strcat(hwLine, tmpReg); strcat(hwLine, tmpReg);
break;
case WINED3DSPR_INPUT:
if (This->cur_args->swizzle_map & (1 << reg)) is_color = TRUE; if (!is_input)
{
sprintf(tmpReg, "vertex.attrib[%u]", reg); char write_mask[6];
strcat(hwLine, tmpReg); shader_arb_get_write_mask(ins, param, write_mask);
break; strcat(hwLine, write_mask);
case WINED3DSPR_CONST: }
if(param & WINED3DSHADER_ADDRMODE_RELATIVE) { else
if(reg >= This->rel_offset) { {
sprintf(tmpReg, "C[A0.x + %u]", reg - This->rel_offset); char swizzle[6];
} else { shader_arb_get_swizzle(param, is_color, swizzle);
sprintf(tmpReg, "C[A0.x - %u]", -reg + This->rel_offset); strcat(hwLine, swizzle);
}
} else {
if(This->baseShader.load_local_constsF || list_empty(&This->baseShader.constantsF)) {
sprintf(tmpReg, "C[%u]", reg);
} else {
sprintf(tmpReg, "C%u", reg);
}
}
strcat(hwLine, tmpReg);
break;
case WINED3DSPR_ADDR: /*case D3DSPR_TEXTURE:*/
sprintf(tmpReg, "A%u", reg);
strcat(hwLine, tmpReg);
break;
case WINED3DSPR_RASTOUT:
sprintf(tmpReg, "%s", hwrastout_reg_names[reg]);
strcat(hwLine, tmpReg);
break;
case WINED3DSPR_ATTROUT:
if (reg==0) {
strcat(hwLine, "result.color.primary");
} else {
strcat(hwLine, "result.color.secondary");
} }
break;
case WINED3DSPR_TEXCRDOUT:
sprintf(tmpReg, "result.texcoord[%u]", reg);
strcat(hwLine, tmpReg);
break;
default:
FIXME("Unknown reg type %d %d\n", regtype, reg);
strcat(hwLine, "unrecognized_register");
break;
}
if (!is_input) {
char write_mask[6];
shader_arb_get_write_mask(ins, param, write_mask);
strcat(hwLine, write_mask);
} else {
char swizzle[6];
shader_arb_get_swizzle(param, is_color, swizzle);
strcat(hwLine, swizzle);
}
} }
static const char *shader_arb_get_fixup_swizzle(enum fixup_channel_source channel_source) static const char *shader_arb_get_fixup_swizzle(enum fixup_channel_source channel_source)
@ -701,6 +684,7 @@ static void pshader_gen_input_modifier_line (
char *outregstr) { char *outregstr) {
/* Generate a line that does the input modifier computation and return the input register to use */ /* Generate a line that does the input modifier computation and return the input register to use */
BOOL is_color = FALSE;
char regstr[256]; char regstr[256];
char swzstr[20]; char swzstr[20];
int insert_line; int insert_line;
@ -709,8 +693,9 @@ static void pshader_gen_input_modifier_line (
insert_line = 1; insert_line = 1;
/* Get register name */ /* Get register name */
pshader_get_register_name(iface, shader_get_regtype(instr), instr & WINED3DSP_REGNUM_MASK, regstr); shader_arb_get_register_name(iface, shader_get_regtype(instr), instr & WINED3DSP_REGNUM_MASK,
shader_arb_get_swizzle(instr, FALSE, swzstr); instr & WINED3DSHADER_ADDRMODE_RELATIVE, regstr, &is_color);
shader_arb_get_swizzle(instr, is_color, swzstr);
switch (instr & WINED3DSP_SRCMOD_MASK) { switch (instr & WINED3DSP_SRCMOD_MASK) {
case WINED3DSPSM_NONE: case WINED3DSPSM_NONE:
@ -771,12 +756,14 @@ static inline void pshader_gen_output_modifier_line(SHADER_BUFFER *buffer, int s
static void pshader_hw_bem(const struct wined3d_shader_instruction *ins) static void pshader_hw_bem(const struct wined3d_shader_instruction *ins)
{ {
IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->shader; IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->shader;
const struct wined3d_shader_dst_param *dst = &ins->dst[0];
SHADER_BUFFER *buffer = ins->buffer; SHADER_BUFFER *buffer = ins->buffer;
char dst_name[50]; char dst_name[50];
char src_name[2][50]; char src_name[2][50];
char dst_wmask[20]; char dst_wmask[20];
DWORD sampler_code = ins->dst[0].register_idx; DWORD sampler_code = dst->register_idx;
BOOL has_bumpmat = FALSE; BOOL has_bumpmat = FALSE;
BOOL is_color;
int i; int i;
for(i = 0; i < This->numbumpenvmatconsts; i++) { for(i = 0; i < This->numbumpenvmatconsts; i++) {
@ -788,8 +775,9 @@ static void pshader_hw_bem(const struct wined3d_shader_instruction *ins)
} }
} }
pshader_get_register_name(ins->shader, ins->dst[0].register_type, ins->dst[0].register_idx, dst_name); shader_arb_get_register_name(ins->shader, dst->register_type,
shader_arb_get_write_mask(ins, ins->dst[0].token, dst_wmask); dst->register_idx, dst->has_rel_addr, dst_name, &is_color);
shader_arb_get_write_mask(ins, dst->token, dst_wmask);
strcat(dst_name, dst_wmask); strcat(dst_name, dst_wmask);
pshader_gen_input_modifier_line(ins->shader, buffer, ins->src[0], 0, src_name[0]); pshader_gen_input_modifier_line(ins->shader, buffer, ins->src[0], 0, src_name[0]);
@ -810,18 +798,21 @@ static void pshader_hw_bem(const struct wined3d_shader_instruction *ins)
static void pshader_hw_cnd(const struct wined3d_shader_instruction *ins) static void pshader_hw_cnd(const struct wined3d_shader_instruction *ins)
{ {
const struct wined3d_shader_dst_param *dst = &ins->dst[0];
SHADER_BUFFER *buffer = ins->buffer; SHADER_BUFFER *buffer = ins->buffer;
char dst_wmask[20]; char dst_wmask[20];
char dst_name[50]; char dst_name[50];
char src_name[3][50]; char src_name[3][50];
BOOL sat = ins->dst[0].modifiers & WINED3DSPDM_SATURATE; BOOL sat = dst->modifiers & WINED3DSPDM_SATURATE;
DWORD shift = ins->dst[0].shift; DWORD shift = dst->shift;
BOOL is_color;
/* FIXME: support output modifiers */ /* FIXME: support output modifiers */
/* Handle output register */ /* Handle output register */
pshader_get_register_name(ins->shader, ins->dst[0].register_type, ins->dst[0].register_idx, dst_name); shader_arb_get_register_name(ins->shader, dst->register_type,
shader_arb_get_write_mask(ins, ins->dst[0].token, dst_wmask); dst->register_idx, dst->has_rel_addr, dst_name, &is_color);
shader_arb_get_write_mask(ins, dst->token, dst_wmask);
/* Generate input register names (with modifiers) */ /* Generate input register names (with modifiers) */
pshader_gen_input_modifier_line(ins->shader, buffer, ins->src[0], 0, src_name[0]); pshader_gen_input_modifier_line(ins->shader, buffer, ins->src[0], 0, src_name[0]);
@ -843,18 +834,21 @@ static void pshader_hw_cnd(const struct wined3d_shader_instruction *ins)
static void pshader_hw_cmp(const struct wined3d_shader_instruction *ins) static void pshader_hw_cmp(const struct wined3d_shader_instruction *ins)
{ {
const struct wined3d_shader_dst_param *dst = &ins->dst[0];
SHADER_BUFFER *buffer = ins->buffer; SHADER_BUFFER *buffer = ins->buffer;
char dst_wmask[20]; char dst_wmask[20];
char dst_name[50]; char dst_name[50];
char src_name[3][50]; char src_name[3][50];
DWORD shift = ins->dst[0].shift; DWORD shift = dst->shift;
BOOL sat = ins->dst[0].modifiers & WINED3DSPDM_SATURATE; BOOL sat = dst->modifiers & WINED3DSPDM_SATURATE;
BOOL is_color;
/* FIXME: support output modifiers */ /* FIXME: support output modifiers */
/* Handle output register */ /* Handle output register */
pshader_get_register_name(ins->shader, ins->dst[0].register_type, ins->dst[0].register_idx, dst_name); shader_arb_get_register_name(ins->shader, dst->register_type,
shader_arb_get_write_mask(ins, ins->dst[0].token, dst_wmask); dst->register_idx, dst->has_rel_addr, dst_name, &is_color);
shader_arb_get_write_mask(ins, dst->token, dst_wmask);
/* Generate input register names (with modifiers) */ /* Generate input register names (with modifiers) */
pshader_gen_input_modifier_line(ins->shader, buffer, ins->src[0], 0, src_name[0]); pshader_gen_input_modifier_line(ins->shader, buffer, ins->src[0], 0, src_name[0]);
@ -872,15 +866,18 @@ static void pshader_hw_cmp(const struct wined3d_shader_instruction *ins)
* dst = dot2(src0, src1) + src2 */ * dst = dot2(src0, src1) + src2 */
static void pshader_hw_dp2add(const struct wined3d_shader_instruction *ins) static void pshader_hw_dp2add(const struct wined3d_shader_instruction *ins)
{ {
const struct wined3d_shader_dst_param *dst = &ins->dst[0];
SHADER_BUFFER *buffer = ins->buffer; SHADER_BUFFER *buffer = ins->buffer;
char dst_wmask[20]; char dst_wmask[20];
char dst_name[50]; char dst_name[50];
char src_name[3][50]; char src_name[3][50];
DWORD shift = ins->dst[0].shift; DWORD shift = dst->shift;
BOOL sat = ins->dst[0].modifiers & WINED3DSPDM_SATURATE; BOOL sat = dst->modifiers & WINED3DSPDM_SATURATE;
BOOL is_color;
pshader_get_register_name(ins->shader, ins->dst[0].register_type, ins->dst[0].register_idx, dst_name); shader_arb_get_register_name(ins->shader, dst->register_type,
shader_arb_get_write_mask(ins, ins->dst[0].token, dst_wmask); dst->register_idx, dst->has_rel_addr, dst_name, &is_color);
shader_arb_get_write_mask(ins, dst->token, dst_wmask);
pshader_gen_input_modifier_line(ins->shader, buffer, ins->src[0], 0, src_name[0]); pshader_gen_input_modifier_line(ins->shader, buffer, ins->src[0], 0, src_name[0]);
pshader_gen_input_modifier_line(ins->shader, buffer, ins->src[1], 1, src_name[1]); pshader_gen_input_modifier_line(ins->shader, buffer, ins->src[1], 1, src_name[1]);
@ -946,6 +943,7 @@ static void shader_hw_map2gl(const struct wined3d_shader_instruction *ins)
BOOL centroid = FALSE; BOOL centroid = FALSE;
BOOL partialprecision = FALSE; BOOL partialprecision = FALSE;
const char *modifier; const char *modifier;
BOOL is_color;
DWORD shift; DWORD shift;
if (!(ins->dst_count + ins->src_count)) if (!(ins->dst_count + ins->src_count))
@ -980,7 +978,8 @@ static void shader_hw_map2gl(const struct wined3d_shader_instruction *ins)
} }
/* Handle output register */ /* Handle output register */
pshader_get_register_name(ins->shader, ins->dst[0].register_type, ins->dst[0].register_idx, output_rname); shader_arb_get_register_name(ins->shader, dst->register_type,
dst->register_idx, dst->has_rel_addr, output_rname, &is_color);
strcpy(operands[0], output_rname); strcpy(operands[0], output_rname);
shader_arb_get_write_mask(ins, dst->token, output_wmask); shader_arb_get_write_mask(ins, dst->token, output_wmask);
strcat(operands[0], output_wmask); strcat(operands[0], output_wmask);
@ -1062,14 +1061,17 @@ static void shader_hw_mov(const struct wined3d_shader_instruction *ins)
static void pshader_hw_texkill(const struct wined3d_shader_instruction *ins) static void pshader_hw_texkill(const struct wined3d_shader_instruction *ins)
{ {
const struct wined3d_shader_dst_param *dst = &ins->dst[0];
DWORD shader_version = ins->reg_maps->shader_version; DWORD shader_version = ins->reg_maps->shader_version;
SHADER_BUFFER *buffer = ins->buffer; SHADER_BUFFER *buffer = ins->buffer;
char reg_dest[40]; char reg_dest[40];
BOOL is_color;
/* No swizzles are allowed in d3d's texkill. PS 1.x ignores the 4th component as documented, /* No swizzles are allowed in d3d's texkill. PS 1.x ignores the 4th component as documented,
* but >= 2.0 honors it(undocumented, but tested by the d3d9 testsuit) * but >= 2.0 honors it(undocumented, but tested by the d3d9 testsuit)
*/ */
pshader_get_register_name(ins->shader, ins->dst[0].register_type, ins->dst[0].register_idx, reg_dest); shader_arb_get_register_name(ins->shader, dst->register_type,
dst->register_idx, dst->has_rel_addr, reg_dest, &is_color);
if (shader_version >= WINED3DPS_VERSION(2,0)) if (shader_version >= WINED3DPS_VERSION(2,0))
{ {
@ -1089,6 +1091,8 @@ static void pshader_hw_tex(const struct wined3d_shader_instruction *ins)
{ {
IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->shader; IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->shader;
IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device; IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device;
const struct wined3d_shader_dst_param *dst = &ins->dst[0];
BOOL is_color;
const DWORD *src = ins->src; const DWORD *src = ins->src;
SHADER_BUFFER* buffer = ins->buffer; SHADER_BUFFER* buffer = ins->buffer;
@ -1097,12 +1101,11 @@ static void pshader_hw_tex(const struct wined3d_shader_instruction *ins)
char reg_dest[40]; char reg_dest[40];
char reg_coord[40]; char reg_coord[40];
DWORD reg_dest_code;
DWORD reg_sampler_code; DWORD reg_sampler_code;
/* All versions have a destination register */ /* All versions have a destination register */
reg_dest_code = ins->dst[0].register_idx; shader_arb_get_register_name(ins->shader, dst->register_type,
pshader_get_register_name(ins->shader, ins->dst[0].register_type, ins->dst[0].register_idx, reg_dest); dst->register_idx, dst->has_rel_addr, reg_dest, &is_color);
/* 1.0-1.3: Use destination register as coordinate source. /* 1.0-1.3: Use destination register as coordinate source.
1.4+: Use provided coordinate source register. */ 1.4+: Use provided coordinate source register. */
@ -1114,7 +1117,7 @@ static void pshader_hw_tex(const struct wined3d_shader_instruction *ins)
/* 1.0-1.4: Use destination register number as texture code. /* 1.0-1.4: Use destination register number as texture code.
2.0+: Use provided sampler number as texure code. */ 2.0+: Use provided sampler number as texure code. */
if (shader_version < WINED3DPS_VERSION(2,0)) if (shader_version < WINED3DPS_VERSION(2,0))
reg_sampler_code = reg_dest_code; reg_sampler_code = dst->register_idx;
else else
reg_sampler_code = src[1] & WINED3DSP_REGNUM_MASK; reg_sampler_code = src[1] & WINED3DSP_REGNUM_MASK;
@ -1217,8 +1220,10 @@ static void pshader_hw_texreg2rgb(const struct wined3d_shader_instruction *ins)
static void pshader_hw_texbem(const struct wined3d_shader_instruction *ins) static void pshader_hw_texbem(const struct wined3d_shader_instruction *ins)
{ {
IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->shader; IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->shader;
const struct wined3d_shader_dst_param *dst = &ins->dst[0];
BOOL has_bumpmat = FALSE; BOOL has_bumpmat = FALSE;
BOOL has_luminance = FALSE; BOOL has_luminance = FALSE;
BOOL is_color;
int i; int i;
DWORD src = ins->src[0] & WINED3DSP_REGNUM_MASK; DWORD src = ins->src[0] & WINED3DSP_REGNUM_MASK;
@ -1228,9 +1233,10 @@ static void pshader_hw_texbem(const struct wined3d_shader_instruction *ins)
DWORD reg_dest_code; DWORD reg_dest_code;
/* All versions have a destination register */ /* All versions have a destination register */
reg_dest_code = ins->dst[0].register_idx; reg_dest_code = dst->register_idx;
/* Can directly use the name because texbem is only valid for <= 1.3 shaders */ /* Can directly use the name because texbem is only valid for <= 1.3 shaders */
pshader_get_register_name(ins->shader, ins->dst[0].register_type, ins->dst[0].register_idx, reg_coord); shader_arb_get_register_name(ins->shader, dst->register_type,
dst->register_idx, dst->has_rel_addr, reg_coord, &is_color);
for(i = 0; i < This->numbumpenvmatconsts; i++) { for(i = 0; i < This->numbumpenvmatconsts; i++) {
if (This->bumpenvmatconst[i].const_num != WINED3D_CONST_NUM_UNUSED if (This->bumpenvmatconst[i].const_num != WINED3D_CONST_NUM_UNUSED
@ -1426,15 +1432,18 @@ static void pshader_hw_texm3x3spec(const struct wined3d_shader_instruction *ins)
static void pshader_hw_texdepth(const struct wined3d_shader_instruction *ins) static void pshader_hw_texdepth(const struct wined3d_shader_instruction *ins)
{ {
const struct wined3d_shader_dst_param *dst = &ins->dst[0];
SHADER_BUFFER *buffer = ins->buffer; SHADER_BUFFER *buffer = ins->buffer;
char dst_name[50]; char dst_name[50];
BOOL is_color;
/* texdepth has an implicit destination, the fragment depth value. It's only parameter, /* texdepth has an implicit destination, the fragment depth value. It's only parameter,
* which is essentially an input, is the destination register because it is the first * which is essentially an input, is the destination register because it is the first
* parameter. According to the msdn, this must be register r5, but let's keep it more flexible * parameter. According to the msdn, this must be register r5, but let's keep it more flexible
* here * here
*/ */
pshader_get_register_name(ins->shader, ins->dst[0].register_type, ins->dst[0].register_idx, dst_name); shader_arb_get_register_name(ins->shader, dst->register_type,
dst->register_idx, dst->has_rel_addr, dst_name, &is_color);
/* According to the msdn, the source register(must be r5) is unusable after /* According to the msdn, the source register(must be r5) is unusable after
* the texdepth instruction, so we're free to modify it * the texdepth instruction, so we're free to modify it
@ -1473,18 +1482,20 @@ static void pshader_hw_texdp3tex(const struct wined3d_shader_instruction *ins)
* Take a 3-component dot product of the TexCoord[dstreg] and src. */ * Take a 3-component dot product of the TexCoord[dstreg] and src. */
static void pshader_hw_texdp3(const struct wined3d_shader_instruction *ins) static void pshader_hw_texdp3(const struct wined3d_shader_instruction *ins)
{ {
const struct wined3d_shader_dst_param *dst = &ins->dst[0];
char src0[50]; char src0[50];
char dst_str[50]; char dst_str[50];
char dst_mask[6]; char dst_mask[6];
DWORD dstreg = ins->dst[0].register_idx;
SHADER_BUFFER *buffer = ins->buffer; SHADER_BUFFER *buffer = ins->buffer;
BOOL is_color;
/* Handle output register */ /* Handle output register */
pshader_get_register_name(ins->shader, ins->dst[0].register_type, ins->dst[0].register_idx, dst_str); shader_arb_get_register_name(ins->shader, dst->register_type,
shader_arb_get_write_mask(ins, ins->dst[0].token, dst_mask); dst->register_idx, dst->has_rel_addr, dst_str, &is_color);
shader_arb_get_write_mask(ins, dst->token, dst_mask);
pshader_gen_input_modifier_line(ins->shader, buffer, ins->src[0], 0, src0); pshader_gen_input_modifier_line(ins->shader, buffer, ins->src[0], 0, src0);
shader_addline(buffer, "DP3 %s%s, T%u, %s;\n", dst_str, dst_mask, dstreg, src0); shader_addline(buffer, "DP3 %s%s, T%u, %s;\n", dst_str, dst_mask, dst->register_idx, src0);
/* TODO: Handle output modifiers */ /* TODO: Handle output modifiers */
} }
@ -1493,17 +1504,19 @@ static void pshader_hw_texdp3(const struct wined3d_shader_instruction *ins)
* Perform the 3rd row of a 3x3 matrix multiply */ * Perform the 3rd row of a 3x3 matrix multiply */
static void pshader_hw_texm3x3(const struct wined3d_shader_instruction *ins) static void pshader_hw_texm3x3(const struct wined3d_shader_instruction *ins)
{ {
const struct wined3d_shader_dst_param *dst = &ins->dst[0];
SHADER_BUFFER *buffer = ins->buffer; SHADER_BUFFER *buffer = ins->buffer;
char dst_str[50]; char dst_str[50];
char dst_mask[6]; char dst_mask[6];
char src0[50]; char src0[50];
DWORD dst_reg = ins->dst[0].register_idx; BOOL is_color;
pshader_get_register_name(ins->shader, ins->dst[0].register_type, ins->dst[0].register_idx, dst_str); shader_arb_get_register_name(ins->shader, dst->register_type,
shader_arb_get_write_mask(ins, ins->dst[0].token, dst_mask); dst->register_idx, dst->has_rel_addr, dst_str, &is_color);
shader_arb_get_write_mask(ins, dst->token, dst_mask);
pshader_gen_input_modifier_line(ins->shader, buffer, ins->src[0], 0, src0); pshader_gen_input_modifier_line(ins->shader, buffer, ins->src[0], 0, src0);
shader_addline(buffer, "DP3 TMP.z, T%u, %s;\n", dst_reg, src0); shader_addline(buffer, "DP3 TMP.z, T%u, %s;\n", dst->register_idx, src0);
shader_addline(buffer, "MOV %s%s, TMP;\n", dst_str, dst_mask); shader_addline(buffer, "MOV %s%s, TMP;\n", dst_str, dst_mask);
/* TODO: Handle output modifiers */ /* TODO: Handle output modifiers */
@ -1626,15 +1639,18 @@ static void vshader_hw_rsq_rcp(const struct wined3d_shader_instruction *ins)
static void shader_hw_nrm(const struct wined3d_shader_instruction *ins) static void shader_hw_nrm(const struct wined3d_shader_instruction *ins)
{ {
const struct wined3d_shader_dst_param *dst = &ins->dst[0];
SHADER_BUFFER *buffer = ins->buffer; SHADER_BUFFER *buffer = ins->buffer;
char dst_name[50]; char dst_name[50];
char src_name[50]; char src_name[50];
char dst_wmask[20]; char dst_wmask[20];
DWORD shift = ins->dst[0].shift; DWORD shift = dst->shift;
BOOL sat = ins->dst[0].modifiers & WINED3DSPDM_SATURATE; BOOL sat = dst->modifiers & WINED3DSPDM_SATURATE;
BOOL is_color;
pshader_get_register_name(ins->shader, ins->dst[0].register_type, ins->dst[0].register_idx, dst_name); shader_arb_get_register_name(ins->shader, dst->register_type,
shader_arb_get_write_mask(ins, ins->dst[0].token, dst_wmask); dst->register_idx, dst->has_rel_addr, dst_name, &is_color);
shader_arb_get_write_mask(ins, dst->token, dst_wmask);
pshader_gen_input_modifier_line(ins->shader, buffer, ins->src[0], 0, src_name); pshader_gen_input_modifier_line(ins->shader, buffer, ins->src[0], 0, src_name);
shader_addline(buffer, "DP3 TMP, %s, %s;\n", src_name, src_name); shader_addline(buffer, "DP3 TMP, %s, %s;\n", src_name, src_name);
@ -1653,15 +1669,18 @@ static void shader_hw_sincos(const struct wined3d_shader_instruction *ins)
* must contain fixed constants. So we need a separate function to filter those constants and * must contain fixed constants. So we need a separate function to filter those constants and
* can't use map2gl * can't use map2gl
*/ */
const struct wined3d_shader_dst_param *dst = &ins->dst[0];
SHADER_BUFFER *buffer = ins->buffer; SHADER_BUFFER *buffer = ins->buffer;
char dst_name[50]; char dst_name[50];
char src_name[50]; char src_name[50];
char dst_wmask[20]; char dst_wmask[20];
DWORD shift = ins->dst[0].shift; DWORD shift = dst->shift;
BOOL sat = ins->dst[0].modifiers & WINED3DSPDM_SATURATE; BOOL sat = dst->modifiers & WINED3DSPDM_SATURATE;
BOOL is_color;
pshader_get_register_name(ins->shader, ins->dst[0].register_type, ins->dst[0].register_idx, dst_name); shader_arb_get_register_name(ins->shader, dst->register_type,
shader_arb_get_write_mask(ins, ins->dst[0].token, dst_wmask); dst->register_idx, dst->has_rel_addr, dst_name, &is_color);
shader_arb_get_write_mask(ins, dst->token, dst_wmask);
pshader_gen_input_modifier_line(ins->shader, buffer, ins->src[0], 0, src_name); pshader_gen_input_modifier_line(ins->shader, buffer, ins->src[0], 0, src_name);
shader_addline(buffer, "SCS%s %s%s, %s;\n", sat ? "_SAT" : "", dst_name, dst_wmask, shader_addline(buffer, "SCS%s %s%s, %s;\n", sat ? "_SAT" : "", dst_name, dst_wmask,