wined3d: Use a more reasonable name for "SHADER_OPCODE_ARG".
This commit is contained in:
parent
de4e8cf0f9
commit
c3a01b315e
|
@ -382,10 +382,11 @@ static const char * const shift_tab[] = {
|
|||
"coefdiv.x" /* 15 (d2) */
|
||||
};
|
||||
|
||||
static void shader_arb_get_write_mask(const SHADER_OPCODE_ARG *arg, const DWORD param, char *write_mask)
|
||||
static void shader_arb_get_write_mask(const struct wined3d_shader_instruction *ins,
|
||||
const DWORD param, char *write_mask)
|
||||
{
|
||||
char *ptr = write_mask;
|
||||
char vshader = shader_is_vshader_version(arg->reg_maps->shader_version);
|
||||
char vshader = shader_is_vshader_version(ins->reg_maps->shader_version);
|
||||
|
||||
if(vshader && shader_get_regtype(param) == WINED3DSPR_ADDR) {
|
||||
*ptr++ = '.';
|
||||
|
@ -486,9 +487,10 @@ static void pshader_get_register_name(IWineD3DBaseShader* iface,
|
|||
}
|
||||
|
||||
/* TODO: merge with pixel shader */
|
||||
static void vshader_program_add_param(const SHADER_OPCODE_ARG *arg, const DWORD param, BOOL is_input, char *hwLine)
|
||||
static void vshader_program_add_param(const struct wined3d_shader_instruction *ins,
|
||||
const DWORD param, BOOL is_input, char *hwLine)
|
||||
{
|
||||
IWineD3DVertexShaderImpl* This = (IWineD3DVertexShaderImpl*) arg->shader;
|
||||
IWineD3DVertexShaderImpl *This = (IWineD3DVertexShaderImpl *)ins->shader;
|
||||
|
||||
/* oPos, oFog and oPts in D3D */
|
||||
static const char * const hwrastout_reg_names[] = { "TMP_OUT", "result.fogcoord", "result.pointsize" };
|
||||
|
@ -559,7 +561,7 @@ static void vshader_program_add_param(const SHADER_OPCODE_ARG *arg, const DWORD
|
|||
|
||||
if (!is_input) {
|
||||
char write_mask[6];
|
||||
shader_arb_get_write_mask(arg, param, write_mask);
|
||||
shader_arb_get_write_mask(ins, param, write_mask);
|
||||
strcat(hwLine, write_mask);
|
||||
} else {
|
||||
char swizzle[6];
|
||||
|
@ -636,13 +638,13 @@ static void gen_color_correction(SHADER_BUFFER *buffer, const char *reg, DWORD d
|
|||
}
|
||||
}
|
||||
|
||||
static void shader_hw_sample(const SHADER_OPCODE_ARG *arg, DWORD sampler_idx, const char *dst_str,
|
||||
const char *coord_reg, BOOL projected, BOOL bias)
|
||||
static void shader_hw_sample(const struct wined3d_shader_instruction *ins, DWORD sampler_idx,
|
||||
const char *dst_str, const char *coord_reg, BOOL projected, BOOL bias)
|
||||
{
|
||||
SHADER_BUFFER* buffer = arg->buffer;
|
||||
DWORD sampler_type = arg->reg_maps->samplers[sampler_idx] & WINED3DSP_TEXTURETYPE_MASK;
|
||||
SHADER_BUFFER *buffer = ins->buffer;
|
||||
DWORD sampler_type = ins->reg_maps->samplers[sampler_idx] & WINED3DSP_TEXTURETYPE_MASK;
|
||||
const char *tex_type;
|
||||
IWineD3DBaseShaderImpl *This = (IWineD3DBaseShaderImpl *) arg->shader;
|
||||
IWineD3DBaseShaderImpl *This = (IWineD3DBaseShaderImpl *)ins->shader;
|
||||
IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *) This->baseShader.device;
|
||||
|
||||
switch(sampler_type) {
|
||||
|
@ -683,9 +685,10 @@ static void shader_hw_sample(const SHADER_OPCODE_ARG *arg, DWORD sampler_idx, co
|
|||
shader_addline(buffer, "TEX %s, %s, texture[%u], %s;\n", dst_str, coord_reg, sampler_idx, tex_type);
|
||||
}
|
||||
|
||||
if(shader_is_pshader_version(arg->reg_maps->shader_version)) {
|
||||
IWineD3DPixelShaderImpl *ps = (IWineD3DPixelShaderImpl *) arg->shader;
|
||||
gen_color_correction(buffer, dst_str, arg->dst & WINED3DSP_WRITEMASK_ALL, "one", "coefmul.x",
|
||||
if (shader_is_pshader_version(ins->reg_maps->shader_version))
|
||||
{
|
||||
IWineD3DPixelShaderImpl *ps = (IWineD3DPixelShaderImpl *)ins->shader;
|
||||
gen_color_correction(buffer, dst_str, ins->dst & WINED3DSP_WRITEMASK_ALL, "one", "coefmul.x",
|
||||
ps->cur_args->color_fixup[sampler_idx]);
|
||||
}
|
||||
}
|
||||
|
@ -765,15 +768,14 @@ static inline void pshader_gen_output_modifier_line(SHADER_BUFFER *buffer, int s
|
|||
regstr, write_mask, regstr, shift_tab[shift]);
|
||||
}
|
||||
|
||||
static void pshader_hw_bem(const SHADER_OPCODE_ARG *arg)
|
||||
static void pshader_hw_bem(const struct wined3d_shader_instruction *ins)
|
||||
{
|
||||
IWineD3DPixelShaderImpl* This = (IWineD3DPixelShaderImpl*) arg->shader;
|
||||
|
||||
SHADER_BUFFER* buffer = arg->buffer;
|
||||
IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->shader;
|
||||
SHADER_BUFFER *buffer = ins->buffer;
|
||||
char dst_name[50];
|
||||
char src_name[2][50];
|
||||
char dst_wmask[20];
|
||||
DWORD sampler_code = arg->dst & WINED3DSP_REGNUM_MASK;
|
||||
DWORD sampler_code = ins->dst & WINED3DSP_REGNUM_MASK;
|
||||
BOOL has_bumpmat = FALSE;
|
||||
int i;
|
||||
|
||||
|
@ -786,12 +788,12 @@ static void pshader_hw_bem(const SHADER_OPCODE_ARG *arg)
|
|||
}
|
||||
}
|
||||
|
||||
pshader_get_register_name(arg->shader, arg->dst, dst_name);
|
||||
shader_arb_get_write_mask(arg, arg->dst, dst_wmask);
|
||||
pshader_get_register_name(ins->shader, ins->dst, dst_name);
|
||||
shader_arb_get_write_mask(ins, ins->dst, dst_wmask);
|
||||
strcat(dst_name, dst_wmask);
|
||||
|
||||
pshader_gen_input_modifier_line(arg->shader, buffer, arg->src[0], 0, src_name[0]);
|
||||
pshader_gen_input_modifier_line(arg->shader, buffer, arg->src[1], 1, src_name[1]);
|
||||
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]);
|
||||
|
||||
if(has_bumpmat) {
|
||||
/* Sampling the perturbation map in Tsrc was done already, including the signedness correction if needed */
|
||||
|
@ -806,28 +808,28 @@ static void pshader_hw_bem(const SHADER_OPCODE_ARG *arg)
|
|||
}
|
||||
}
|
||||
|
||||
static void pshader_hw_cnd(const SHADER_OPCODE_ARG *arg)
|
||||
static void pshader_hw_cnd(const struct wined3d_shader_instruction *ins)
|
||||
{
|
||||
SHADER_BUFFER* buffer = arg->buffer;
|
||||
SHADER_BUFFER *buffer = ins->buffer;
|
||||
char dst_wmask[20];
|
||||
char dst_name[50];
|
||||
char src_name[3][50];
|
||||
BOOL sat = (arg->dst & WINED3DSP_DSTMOD_MASK) & WINED3DSPDM_SATURATE;
|
||||
DWORD shift = (arg->dst & WINED3DSP_DSTSHIFT_MASK) >> WINED3DSP_DSTSHIFT_SHIFT;
|
||||
BOOL sat = (ins->dst & WINED3DSP_DSTMOD_MASK) & WINED3DSPDM_SATURATE;
|
||||
DWORD shift = (ins->dst & WINED3DSP_DSTSHIFT_MASK) >> WINED3DSP_DSTSHIFT_SHIFT;
|
||||
|
||||
/* FIXME: support output modifiers */
|
||||
|
||||
/* Handle output register */
|
||||
pshader_get_register_name(arg->shader, arg->dst, dst_name);
|
||||
shader_arb_get_write_mask(arg, arg->dst, dst_wmask);
|
||||
pshader_get_register_name(ins->shader, ins->dst, dst_name);
|
||||
shader_arb_get_write_mask(ins, ins->dst, dst_wmask);
|
||||
|
||||
/* Generate input register names (with modifiers) */
|
||||
pshader_gen_input_modifier_line(arg->shader, buffer, arg->src[0], 0, src_name[0]);
|
||||
pshader_gen_input_modifier_line(arg->shader, buffer, arg->src[1], 1, src_name[1]);
|
||||
pshader_gen_input_modifier_line(arg->shader, buffer, arg->src[2], 2, src_name[2]);
|
||||
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[2], 2, src_name[2]);
|
||||
|
||||
/* The coissue flag changes the semantic of the cnd instruction in <= 1.3 shaders */
|
||||
if (arg->reg_maps->shader_version <= WINED3DPS_VERSION(1, 3) && arg->coissue)
|
||||
if (ins->reg_maps->shader_version <= WINED3DPS_VERSION(1, 3) && ins->coissue)
|
||||
{
|
||||
shader_addline(buffer, "MOV%s %s%s, %s;\n", sat ? "_SAT" : "", dst_name, dst_wmask, src_name[1]);
|
||||
} else {
|
||||
|
@ -839,25 +841,25 @@ static void pshader_hw_cnd(const SHADER_OPCODE_ARG *arg)
|
|||
pshader_gen_output_modifier_line(buffer, FALSE, dst_wmask, shift, dst_name);
|
||||
}
|
||||
|
||||
static void pshader_hw_cmp(const SHADER_OPCODE_ARG *arg)
|
||||
static void pshader_hw_cmp(const struct wined3d_shader_instruction *ins)
|
||||
{
|
||||
SHADER_BUFFER* buffer = arg->buffer;
|
||||
SHADER_BUFFER *buffer = ins->buffer;
|
||||
char dst_wmask[20];
|
||||
char dst_name[50];
|
||||
char src_name[3][50];
|
||||
DWORD shift = (arg->dst & WINED3DSP_DSTSHIFT_MASK) >> WINED3DSP_DSTSHIFT_SHIFT;
|
||||
BOOL sat = (arg->dst & WINED3DSP_DSTMOD_MASK) & WINED3DSPDM_SATURATE;
|
||||
DWORD shift = (ins->dst & WINED3DSP_DSTSHIFT_MASK) >> WINED3DSP_DSTSHIFT_SHIFT;
|
||||
BOOL sat = (ins->dst & WINED3DSP_DSTMOD_MASK) & WINED3DSPDM_SATURATE;
|
||||
|
||||
/* FIXME: support output modifiers */
|
||||
|
||||
/* Handle output register */
|
||||
pshader_get_register_name(arg->shader, arg->dst, dst_name);
|
||||
shader_arb_get_write_mask(arg, arg->dst, dst_wmask);
|
||||
pshader_get_register_name(ins->shader, ins->dst, dst_name);
|
||||
shader_arb_get_write_mask(ins, ins->dst, dst_wmask);
|
||||
|
||||
/* Generate input register names (with modifiers) */
|
||||
pshader_gen_input_modifier_line(arg->shader, buffer, arg->src[0], 0, src_name[0]);
|
||||
pshader_gen_input_modifier_line(arg->shader, buffer, arg->src[1], 1, src_name[1]);
|
||||
pshader_gen_input_modifier_line(arg->shader, buffer, arg->src[2], 2, src_name[2]);
|
||||
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[2], 2, src_name[2]);
|
||||
|
||||
shader_addline(buffer, "CMP%s %s%s, %s, %s, %s;\n", sat ? "_SAT" : "", dst_name, dst_wmask,
|
||||
src_name[0], src_name[2], src_name[1]);
|
||||
|
@ -868,21 +870,21 @@ static void pshader_hw_cmp(const SHADER_OPCODE_ARG *arg)
|
|||
|
||||
/** Process the WINED3DSIO_DP2ADD instruction in ARB.
|
||||
* dst = dot2(src0, src1) + src2 */
|
||||
static void pshader_hw_dp2add(const SHADER_OPCODE_ARG *arg)
|
||||
static void pshader_hw_dp2add(const struct wined3d_shader_instruction *ins)
|
||||
{
|
||||
SHADER_BUFFER* buffer = arg->buffer;
|
||||
SHADER_BUFFER *buffer = ins->buffer;
|
||||
char dst_wmask[20];
|
||||
char dst_name[50];
|
||||
char src_name[3][50];
|
||||
DWORD shift = (arg->dst & WINED3DSP_DSTSHIFT_MASK) >> WINED3DSP_DSTSHIFT_SHIFT;
|
||||
BOOL sat = (arg->dst & WINED3DSP_DSTMOD_MASK) & WINED3DSPDM_SATURATE;
|
||||
DWORD shift = (ins->dst & WINED3DSP_DSTSHIFT_MASK) >> WINED3DSP_DSTSHIFT_SHIFT;
|
||||
BOOL sat = (ins->dst & WINED3DSP_DSTMOD_MASK) & WINED3DSPDM_SATURATE;
|
||||
|
||||
pshader_get_register_name(arg->shader, arg->dst, dst_name);
|
||||
shader_arb_get_write_mask(arg, arg->dst, dst_wmask);
|
||||
pshader_get_register_name(ins->shader, ins->dst, dst_name);
|
||||
shader_arb_get_write_mask(ins, ins->dst, dst_wmask);
|
||||
|
||||
pshader_gen_input_modifier_line(arg->shader, buffer, arg->src[0], 0, src_name[0]);
|
||||
pshader_gen_input_modifier_line(arg->shader, buffer, arg->src[1], 1, src_name[1]);
|
||||
pshader_gen_input_modifier_line(arg->shader, buffer, arg->src[2], 2, src_name[2]);
|
||||
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[2], 2, src_name[2]);
|
||||
|
||||
/* Emulate a DP2 with a DP3 and 0.0 */
|
||||
shader_addline(buffer, "MOV TMP, %s;\n", src_name[0]);
|
||||
|
@ -895,12 +897,12 @@ static void pshader_hw_dp2add(const SHADER_OPCODE_ARG *arg)
|
|||
}
|
||||
|
||||
/* Map the opcode 1-to-1 to the GL code */
|
||||
static void shader_hw_map2gl(const SHADER_OPCODE_ARG *arg)
|
||||
static void shader_hw_map2gl(const struct wined3d_shader_instruction *ins)
|
||||
{
|
||||
CONST SHADER_OPCODE* curOpcode = arg->opcode;
|
||||
SHADER_BUFFER* buffer = arg->buffer;
|
||||
DWORD dst = arg->dst;
|
||||
const DWORD *src = arg->src;
|
||||
CONST SHADER_OPCODE *curOpcode = ins->opcode;
|
||||
SHADER_BUFFER *buffer = ins->buffer;
|
||||
DWORD dst = ins->dst;
|
||||
const DWORD *src = ins->src;
|
||||
const char *instruction;
|
||||
char arguments[256];
|
||||
unsigned int i;
|
||||
|
@ -935,7 +937,7 @@ static void shader_hw_map2gl(const SHADER_OPCODE_ARG *arg)
|
|||
break;
|
||||
}
|
||||
|
||||
if (shader_is_pshader_version(arg->reg_maps->shader_version))
|
||||
if (shader_is_pshader_version(ins->reg_maps->shader_version))
|
||||
{
|
||||
/* Output token related */
|
||||
char output_rname[256];
|
||||
|
@ -973,12 +975,12 @@ static void shader_hw_map2gl(const SHADER_OPCODE_ARG *arg)
|
|||
|
||||
/* Generate input register names (with modifiers) */
|
||||
for (i = 1; i < curOpcode->num_params; ++i)
|
||||
pshader_gen_input_modifier_line(arg->shader, buffer, src[i-1], i-1, operands[i]);
|
||||
pshader_gen_input_modifier_line(ins->shader, buffer, src[i-1], i-1, operands[i]);
|
||||
|
||||
/* Handle output register */
|
||||
pshader_get_register_name(arg->shader, dst, output_rname);
|
||||
pshader_get_register_name(ins->shader, dst, output_rname);
|
||||
strcpy(operands[0], output_rname);
|
||||
shader_arb_get_write_mask(arg, dst, output_wmask);
|
||||
shader_arb_get_write_mask(ins, dst, output_wmask);
|
||||
strcat(operands[0], output_wmask);
|
||||
|
||||
arguments[0] = '\0';
|
||||
|
@ -998,36 +1000,36 @@ static void shader_hw_map2gl(const SHADER_OPCODE_ARG *arg)
|
|||
arguments[0] = '\0';
|
||||
if (curOpcode->num_params > 0)
|
||||
{
|
||||
vshader_program_add_param(arg, dst, FALSE, arguments);
|
||||
vshader_program_add_param(ins, dst, FALSE, arguments);
|
||||
for (i = 1; i < curOpcode->num_params; ++i)
|
||||
{
|
||||
strcat(arguments, ",");
|
||||
vshader_program_add_param(arg, src[i-1], TRUE, arguments);
|
||||
vshader_program_add_param(ins, src[i-1], TRUE, arguments);
|
||||
}
|
||||
}
|
||||
shader_addline(buffer, "%s%s;\n", instruction, arguments);
|
||||
}
|
||||
}
|
||||
|
||||
static void shader_hw_mov(const SHADER_OPCODE_ARG *arg)
|
||||
static void shader_hw_mov(const struct wined3d_shader_instruction *ins)
|
||||
{
|
||||
IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl*)arg->shader;
|
||||
IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->shader;
|
||||
|
||||
if ((WINED3DSHADER_VERSION_MAJOR(arg->reg_maps->shader_version) == 1
|
||||
&& !shader_is_pshader_version(arg->reg_maps->shader_version)
|
||||
&& shader_get_regtype(arg->dst) == WINED3DSPR_ADDR)
|
||||
|| arg->opcode->opcode == WINED3DSIO_MOVA)
|
||||
if ((WINED3DSHADER_VERSION_MAJOR(ins->reg_maps->shader_version) == 1
|
||||
&& !shader_is_pshader_version(ins->reg_maps->shader_version)
|
||||
&& shader_get_regtype(ins->dst) == WINED3DSPR_ADDR)
|
||||
|| ins->opcode->opcode == WINED3DSIO_MOVA)
|
||||
{
|
||||
SHADER_BUFFER *buffer = arg->buffer;
|
||||
SHADER_BUFFER *buffer = ins->buffer;
|
||||
char src0_param[256];
|
||||
|
||||
if (arg->opcode->opcode == WINED3DSIO_MOVA)
|
||||
if (ins->opcode->opcode == WINED3DSIO_MOVA)
|
||||
FIXME("mova should round\n");
|
||||
|
||||
src0_param[0] = '\0';
|
||||
if (((IWineD3DVertexShaderImpl *)shader)->rel_offset)
|
||||
{
|
||||
vshader_program_add_param(arg, arg->src[0], TRUE, src0_param);
|
||||
vshader_program_add_param(ins, ins->src[0], TRUE, src0_param);
|
||||
shader_addline(buffer, "ADD TMP.x, %s, helper_const.z;\n", src0_param);
|
||||
shader_addline(buffer, "ARL A0.x, TMP.x;\n");
|
||||
}
|
||||
|
@ -1037,35 +1039,35 @@ static void shader_hw_mov(const SHADER_OPCODE_ARG *arg)
|
|||
* with more than one component. Thus replicate the first source argument over all
|
||||
* 4 components. For example, .xyzw -> .x (or better: .xxxx), .zwxy -> .z, etc)
|
||||
*/
|
||||
DWORD parm = arg->src[0] & ~(WINED3DVS_SWIZZLE_MASK);
|
||||
if((arg->src[0] & WINED3DVS_X_W) == WINED3DVS_X_W)
|
||||
DWORD parm = ins->src[0] & ~(WINED3DVS_SWIZZLE_MASK);
|
||||
if((ins->src[0] & WINED3DVS_X_W) == WINED3DVS_X_W)
|
||||
parm |= WINED3DVS_X_W | WINED3DVS_Y_W | WINED3DVS_Z_W | WINED3DVS_W_W;
|
||||
else if((arg->src[0] & WINED3DVS_X_Z) == WINED3DVS_X_Z)
|
||||
else if((ins->src[0] & WINED3DVS_X_Z) == WINED3DVS_X_Z)
|
||||
parm |= WINED3DVS_X_Z | WINED3DVS_Y_Z | WINED3DVS_Z_Z | WINED3DVS_W_Z;
|
||||
else if((arg->src[0] & WINED3DVS_X_Y) == WINED3DVS_X_Y)
|
||||
else if((ins->src[0] & WINED3DVS_X_Y) == WINED3DVS_X_Y)
|
||||
parm |= WINED3DVS_X_Y | WINED3DVS_Y_Y | WINED3DVS_Z_Y | WINED3DVS_W_Y;
|
||||
else if((arg->src[0] & WINED3DVS_X_X) == WINED3DVS_X_X)
|
||||
else if((ins->src[0] & WINED3DVS_X_X) == WINED3DVS_X_X)
|
||||
parm |= WINED3DVS_X_X | WINED3DVS_Y_X | WINED3DVS_Z_X | WINED3DVS_W_X;
|
||||
vshader_program_add_param(arg, parm, TRUE, src0_param);
|
||||
vshader_program_add_param(ins, parm, TRUE, src0_param);
|
||||
shader_addline(buffer, "ARL A0.x, %s;\n", src0_param);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
shader_hw_map2gl(arg);
|
||||
shader_hw_map2gl(ins);
|
||||
}
|
||||
}
|
||||
|
||||
static void pshader_hw_texkill(const SHADER_OPCODE_ARG *arg)
|
||||
static void pshader_hw_texkill(const struct wined3d_shader_instruction *ins)
|
||||
{
|
||||
DWORD shader_version = arg->reg_maps->shader_version;
|
||||
SHADER_BUFFER* buffer = arg->buffer;
|
||||
DWORD shader_version = ins->reg_maps->shader_version;
|
||||
SHADER_BUFFER *buffer = ins->buffer;
|
||||
char reg_dest[40];
|
||||
|
||||
/* 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)
|
||||
*/
|
||||
pshader_get_register_name(arg->shader, arg->dst, reg_dest);
|
||||
pshader_get_register_name(ins->shader, ins->dst, reg_dest);
|
||||
|
||||
if (shader_version >= WINED3DPS_VERSION(2,0))
|
||||
{
|
||||
|
@ -1081,15 +1083,15 @@ static void pshader_hw_texkill(const SHADER_OPCODE_ARG *arg)
|
|||
}
|
||||
}
|
||||
|
||||
static void pshader_hw_tex(const SHADER_OPCODE_ARG *arg)
|
||||
static void pshader_hw_tex(const struct wined3d_shader_instruction *ins)
|
||||
{
|
||||
IWineD3DPixelShaderImpl* This = (IWineD3DPixelShaderImpl*) arg->shader;
|
||||
IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->shader;
|
||||
IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device;
|
||||
|
||||
DWORD dst = arg->dst;
|
||||
const DWORD *src = arg->src;
|
||||
SHADER_BUFFER* buffer = arg->buffer;
|
||||
DWORD shader_version = arg->reg_maps->shader_version;
|
||||
DWORD dst = ins->dst;
|
||||
const DWORD *src = ins->src;
|
||||
SHADER_BUFFER* buffer = ins->buffer;
|
||||
DWORD shader_version = ins->reg_maps->shader_version;
|
||||
BOOL projected = FALSE, bias = FALSE;
|
||||
|
||||
char reg_dest[40];
|
||||
|
@ -1099,14 +1101,14 @@ static void pshader_hw_tex(const SHADER_OPCODE_ARG *arg)
|
|||
|
||||
/* All versions have a destination register */
|
||||
reg_dest_code = dst & WINED3DSP_REGNUM_MASK;
|
||||
pshader_get_register_name(arg->shader, dst, reg_dest);
|
||||
pshader_get_register_name(ins->shader, dst, reg_dest);
|
||||
|
||||
/* 1.0-1.3: Use destination register as coordinate source.
|
||||
1.4+: Use provided coordinate source register. */
|
||||
if (shader_version < WINED3DPS_VERSION(1,4))
|
||||
strcpy(reg_coord, reg_dest);
|
||||
else
|
||||
pshader_gen_input_modifier_line(arg->shader, buffer, src[0], 0, reg_coord);
|
||||
pshader_gen_input_modifier_line(ins->shader, buffer, src[0], 0, reg_coord);
|
||||
|
||||
/* 1.0-1.4: Use destination register number as texture code.
|
||||
2.0+: Use provided sampler number as texure code. */
|
||||
|
@ -1132,27 +1134,27 @@ static void pshader_hw_tex(const SHADER_OPCODE_ARG *arg)
|
|||
}
|
||||
else if (shader_version < WINED3DPS_VERSION(2,0))
|
||||
{
|
||||
DWORD src_mod = arg->src[0] & WINED3DSP_SRCMOD_MASK;
|
||||
DWORD src_mod = ins->src[0] & WINED3DSP_SRCMOD_MASK;
|
||||
if (src_mod == WINED3DSPSM_DZ) {
|
||||
projected = TRUE;
|
||||
} else if(src_mod == WINED3DSPSM_DW) {
|
||||
projected = TRUE;
|
||||
}
|
||||
} else {
|
||||
if (arg->flags & WINED3DSI_TEXLD_PROJECT) projected = TRUE;
|
||||
if (arg->flags & WINED3DSI_TEXLD_BIAS) bias = TRUE;
|
||||
if (ins->flags & WINED3DSI_TEXLD_PROJECT) projected = TRUE;
|
||||
if (ins->flags & WINED3DSI_TEXLD_BIAS) bias = TRUE;
|
||||
}
|
||||
shader_hw_sample(arg, reg_sampler_code, reg_dest, reg_coord, projected, bias);
|
||||
shader_hw_sample(ins, reg_sampler_code, reg_dest, reg_coord, projected, bias);
|
||||
}
|
||||
|
||||
static void pshader_hw_texcoord(const SHADER_OPCODE_ARG *arg)
|
||||
static void pshader_hw_texcoord(const struct wined3d_shader_instruction *ins)
|
||||
{
|
||||
DWORD dst = arg->dst;
|
||||
SHADER_BUFFER* buffer = arg->buffer;
|
||||
DWORD dst = ins->dst;
|
||||
SHADER_BUFFER *buffer = ins->buffer;
|
||||
|
||||
char tmp[20];
|
||||
shader_arb_get_write_mask(arg, dst, tmp);
|
||||
if (arg->reg_maps->shader_version != WINED3DPS_VERSION(1,4))
|
||||
shader_arb_get_write_mask(ins, dst, tmp);
|
||||
if (ins->reg_maps->shader_version != WINED3DPS_VERSION(1,4))
|
||||
{
|
||||
DWORD reg = dst & WINED3DSP_REGNUM_MASK;
|
||||
shader_addline(buffer, "MOV_SAT T%u%s, fragment.texcoord[%u];\n", reg, tmp, reg);
|
||||
|
@ -1160,67 +1162,67 @@ static void pshader_hw_texcoord(const SHADER_OPCODE_ARG *arg)
|
|||
DWORD reg1 = dst & WINED3DSP_REGNUM_MASK;
|
||||
char reg_src[40];
|
||||
|
||||
pshader_gen_input_modifier_line(arg->shader, buffer, arg->src[0], 0, reg_src);
|
||||
pshader_gen_input_modifier_line(ins->shader, buffer, ins->src[0], 0, reg_src);
|
||||
shader_addline(buffer, "MOV R%u%s, %s;\n", reg1, tmp, reg_src);
|
||||
}
|
||||
}
|
||||
|
||||
static void pshader_hw_texreg2ar(const SHADER_OPCODE_ARG *arg)
|
||||
static void pshader_hw_texreg2ar(const struct wined3d_shader_instruction *ins)
|
||||
{
|
||||
SHADER_BUFFER* buffer = arg->buffer;
|
||||
IWineD3DPixelShaderImpl* This = (IWineD3DPixelShaderImpl*) arg->shader;
|
||||
SHADER_BUFFER *buffer = ins->buffer;
|
||||
IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->shader;
|
||||
IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device;
|
||||
DWORD flags;
|
||||
|
||||
DWORD reg1 = arg->dst & WINED3DSP_REGNUM_MASK;
|
||||
DWORD reg1 = ins->dst & WINED3DSP_REGNUM_MASK;
|
||||
char dst_str[8];
|
||||
char src_str[50];
|
||||
|
||||
sprintf(dst_str, "T%u", reg1);
|
||||
pshader_gen_input_modifier_line(arg->shader, buffer, arg->src[0], 0, src_str);
|
||||
pshader_gen_input_modifier_line(ins->shader, buffer, ins->src[0], 0, src_str);
|
||||
shader_addline(buffer, "MOV TMP.x, %s.w;\n", src_str);
|
||||
shader_addline(buffer, "MOV TMP.y, %s.x;\n", src_str);
|
||||
flags = reg1 < MAX_TEXTURES ? deviceImpl->stateBlock->textureState[reg1][WINED3DTSS_TEXTURETRANSFORMFLAGS] : 0;
|
||||
shader_hw_sample(arg, reg1, dst_str, "TMP", flags & WINED3DTTFF_PROJECTED, FALSE);
|
||||
shader_hw_sample(ins, reg1, dst_str, "TMP", flags & WINED3DTTFF_PROJECTED, FALSE);
|
||||
}
|
||||
|
||||
static void pshader_hw_texreg2gb(const SHADER_OPCODE_ARG *arg)
|
||||
static void pshader_hw_texreg2gb(const struct wined3d_shader_instruction *ins)
|
||||
{
|
||||
SHADER_BUFFER* buffer = arg->buffer;
|
||||
SHADER_BUFFER *buffer = ins->buffer;
|
||||
|
||||
DWORD reg1 = arg->dst & WINED3DSP_REGNUM_MASK;
|
||||
DWORD reg1 = ins->dst & WINED3DSP_REGNUM_MASK;
|
||||
char dst_str[8];
|
||||
char src_str[50];
|
||||
|
||||
sprintf(dst_str, "T%u", reg1);
|
||||
pshader_gen_input_modifier_line(arg->shader, buffer, arg->src[0], 0, src_str);
|
||||
pshader_gen_input_modifier_line(ins->shader, buffer, ins->src[0], 0, src_str);
|
||||
shader_addline(buffer, "MOV TMP.x, %s.y;\n", src_str);
|
||||
shader_addline(buffer, "MOV TMP.y, %s.z;\n", src_str);
|
||||
shader_hw_sample(arg, reg1, dst_str, "TMP", FALSE, FALSE);
|
||||
shader_hw_sample(ins, reg1, dst_str, "TMP", FALSE, FALSE);
|
||||
}
|
||||
|
||||
static void pshader_hw_texreg2rgb(const SHADER_OPCODE_ARG *arg)
|
||||
static void pshader_hw_texreg2rgb(const struct wined3d_shader_instruction *ins)
|
||||
{
|
||||
SHADER_BUFFER* buffer = arg->buffer;
|
||||
DWORD reg1 = arg->dst & WINED3DSP_REGNUM_MASK;
|
||||
SHADER_BUFFER *buffer = ins->buffer;
|
||||
DWORD reg1 = ins->dst & WINED3DSP_REGNUM_MASK;
|
||||
char dst_str[8];
|
||||
char src_str[50];
|
||||
|
||||
sprintf(dst_str, "T%u", reg1);
|
||||
pshader_gen_input_modifier_line(arg->shader, buffer, arg->src[0], 0, src_str);
|
||||
shader_hw_sample(arg, reg1, dst_str, src_str, FALSE, FALSE);
|
||||
pshader_gen_input_modifier_line(ins->shader, buffer, ins->src[0], 0, src_str);
|
||||
shader_hw_sample(ins, reg1, dst_str, src_str, FALSE, FALSE);
|
||||
}
|
||||
|
||||
static void pshader_hw_texbem(const SHADER_OPCODE_ARG *arg)
|
||||
static void pshader_hw_texbem(const struct wined3d_shader_instruction *ins)
|
||||
{
|
||||
IWineD3DPixelShaderImpl* This = (IWineD3DPixelShaderImpl*) arg->shader;
|
||||
IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->shader;
|
||||
BOOL has_bumpmat = FALSE;
|
||||
BOOL has_luminance = FALSE;
|
||||
int i;
|
||||
|
||||
DWORD dst = arg->dst;
|
||||
DWORD src = arg->src[0] & WINED3DSP_REGNUM_MASK;
|
||||
SHADER_BUFFER* buffer = arg->buffer;
|
||||
DWORD dst = ins->dst;
|
||||
DWORD src = ins->src[0] & WINED3DSP_REGNUM_MASK;
|
||||
SHADER_BUFFER* buffer = ins->buffer;
|
||||
|
||||
char reg_coord[40];
|
||||
DWORD reg_dest_code;
|
||||
|
@ -1228,7 +1230,7 @@ static void pshader_hw_texbem(const SHADER_OPCODE_ARG *arg)
|
|||
/* All versions have a destination register */
|
||||
reg_dest_code = dst & WINED3DSP_REGNUM_MASK;
|
||||
/* Can directly use the name because texbem is only valid for <= 1.3 shaders */
|
||||
pshader_get_register_name(arg->shader, dst, reg_coord);
|
||||
pshader_get_register_name(ins->shader, dst, reg_coord);
|
||||
|
||||
for(i = 0; i < This->numbumpenvmatconsts; i++) {
|
||||
if (This->bumpenvmatconst[i].const_num != WINED3D_CONST_NUM_UNUSED
|
||||
|
@ -1267,9 +1269,10 @@ static void pshader_hw_texbem(const SHADER_OPCODE_ARG *arg)
|
|||
shader_addline(buffer, "ADD TMP.xy, TMP, %s;\n", reg_coord);
|
||||
}
|
||||
|
||||
shader_hw_sample(arg, reg_dest_code, reg_coord, "TMP", FALSE, FALSE);
|
||||
shader_hw_sample(ins, reg_dest_code, reg_coord, "TMP", FALSE, FALSE);
|
||||
|
||||
if(arg->opcode->opcode == WINED3DSIO_TEXBEML && has_luminance) {
|
||||
if (ins->opcode->opcode == WINED3DSIO_TEXBEML && has_luminance)
|
||||
{
|
||||
shader_addline(buffer, "MAD TMP, T%u.z, luminance%d.x, luminance%d.y;\n",
|
||||
src, reg_dest_code, reg_dest_code);
|
||||
shader_addline(buffer, "MUL %s, %s, TMP;\n", reg_coord, reg_coord);
|
||||
|
@ -1283,83 +1286,83 @@ static void pshader_hw_texbem(const SHADER_OPCODE_ARG *arg)
|
|||
tf = 0;
|
||||
}
|
||||
/* Without a bump matrix loaded, just sample with the unmodified coordinates */
|
||||
shader_hw_sample(arg, reg_dest_code, reg_coord, reg_coord, tf & WINED3DTTFF_PROJECTED, FALSE);
|
||||
shader_hw_sample(ins, reg_dest_code, reg_coord, reg_coord, tf & WINED3DTTFF_PROJECTED, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
static void pshader_hw_texm3x2pad(const SHADER_OPCODE_ARG *arg)
|
||||
static void pshader_hw_texm3x2pad(const struct wined3d_shader_instruction *ins)
|
||||
{
|
||||
DWORD reg = arg->dst & WINED3DSP_REGNUM_MASK;
|
||||
SHADER_BUFFER* buffer = arg->buffer;
|
||||
DWORD reg = ins->dst & WINED3DSP_REGNUM_MASK;
|
||||
SHADER_BUFFER *buffer = ins->buffer;
|
||||
char src0_name[50];
|
||||
|
||||
pshader_gen_input_modifier_line(arg->shader, buffer, arg->src[0], 0, src0_name);
|
||||
pshader_gen_input_modifier_line(ins->shader, buffer, ins->src[0], 0, src0_name);
|
||||
shader_addline(buffer, "DP3 TMP.x, T%u, %s;\n", reg, src0_name);
|
||||
}
|
||||
|
||||
static void pshader_hw_texm3x2tex(const SHADER_OPCODE_ARG *arg)
|
||||
static void pshader_hw_texm3x2tex(const struct wined3d_shader_instruction *ins)
|
||||
{
|
||||
IWineD3DPixelShaderImpl* This = (IWineD3DPixelShaderImpl*) arg->shader;
|
||||
IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->shader;
|
||||
IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device;
|
||||
DWORD flags;
|
||||
DWORD reg = arg->dst & WINED3DSP_REGNUM_MASK;
|
||||
SHADER_BUFFER* buffer = arg->buffer;
|
||||
DWORD reg = ins->dst & WINED3DSP_REGNUM_MASK;
|
||||
SHADER_BUFFER *buffer = ins->buffer;
|
||||
char dst_str[8];
|
||||
char src0_name[50];
|
||||
|
||||
sprintf(dst_str, "T%u", reg);
|
||||
pshader_gen_input_modifier_line(arg->shader, buffer, arg->src[0], 0, src0_name);
|
||||
pshader_gen_input_modifier_line(ins->shader, buffer, ins->src[0], 0, src0_name);
|
||||
shader_addline(buffer, "DP3 TMP.y, T%u, %s;\n", reg, src0_name);
|
||||
flags = reg < MAX_TEXTURES ? deviceImpl->stateBlock->textureState[reg][WINED3DTSS_TEXTURETRANSFORMFLAGS] : 0;
|
||||
shader_hw_sample(arg, reg, dst_str, "TMP", flags & WINED3DTTFF_PROJECTED, FALSE);
|
||||
shader_hw_sample(ins, reg, dst_str, "TMP", flags & WINED3DTTFF_PROJECTED, FALSE);
|
||||
}
|
||||
|
||||
static void pshader_hw_texm3x3pad(const SHADER_OPCODE_ARG *arg)
|
||||
static void pshader_hw_texm3x3pad(const struct wined3d_shader_instruction *ins)
|
||||
{
|
||||
IWineD3DPixelShaderImpl* This = (IWineD3DPixelShaderImpl*) arg->shader;
|
||||
DWORD reg = arg->dst & WINED3DSP_REGNUM_MASK;
|
||||
SHADER_BUFFER* buffer = arg->buffer;
|
||||
IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->shader;
|
||||
DWORD reg = ins->dst & WINED3DSP_REGNUM_MASK;
|
||||
SHADER_BUFFER *buffer = ins->buffer;
|
||||
SHADER_PARSE_STATE* current_state = &This->baseShader.parse_state;
|
||||
char src0_name[50];
|
||||
|
||||
pshader_gen_input_modifier_line(arg->shader, buffer, arg->src[0], 0, src0_name);
|
||||
pshader_gen_input_modifier_line(ins->shader, buffer, ins->src[0], 0, src0_name);
|
||||
shader_addline(buffer, "DP3 TMP.%c, T%u, %s;\n", 'x' + current_state->current_row, reg, src0_name);
|
||||
current_state->texcoord_w[current_state->current_row++] = reg;
|
||||
}
|
||||
|
||||
static void pshader_hw_texm3x3tex(const SHADER_OPCODE_ARG *arg)
|
||||
static void pshader_hw_texm3x3tex(const struct wined3d_shader_instruction *ins)
|
||||
{
|
||||
IWineD3DPixelShaderImpl* This = (IWineD3DPixelShaderImpl*) arg->shader;
|
||||
IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->shader;
|
||||
IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device;
|
||||
DWORD flags;
|
||||
DWORD reg = arg->dst & WINED3DSP_REGNUM_MASK;
|
||||
SHADER_BUFFER* buffer = arg->buffer;
|
||||
DWORD reg = ins->dst & WINED3DSP_REGNUM_MASK;
|
||||
SHADER_BUFFER *buffer = ins->buffer;
|
||||
SHADER_PARSE_STATE* current_state = &This->baseShader.parse_state;
|
||||
char dst_str[8];
|
||||
char src0_name[50];
|
||||
|
||||
pshader_gen_input_modifier_line(arg->shader, buffer, arg->src[0], 0, src0_name);
|
||||
pshader_gen_input_modifier_line(ins->shader, buffer, ins->src[0], 0, src0_name);
|
||||
shader_addline(buffer, "DP3 TMP.z, T%u, %s;\n", reg, src0_name);
|
||||
|
||||
/* Sample the texture using the calculated coordinates */
|
||||
sprintf(dst_str, "T%u", reg);
|
||||
flags = reg < MAX_TEXTURES ? deviceImpl->stateBlock->textureState[reg][WINED3DTSS_TEXTURETRANSFORMFLAGS] : 0;
|
||||
shader_hw_sample(arg, reg, dst_str, "TMP", flags & WINED3DTTFF_PROJECTED, FALSE);
|
||||
shader_hw_sample(ins, reg, dst_str, "TMP", flags & WINED3DTTFF_PROJECTED, FALSE);
|
||||
current_state->current_row = 0;
|
||||
}
|
||||
|
||||
static void pshader_hw_texm3x3vspec(const SHADER_OPCODE_ARG *arg)
|
||||
static void pshader_hw_texm3x3vspec(const struct wined3d_shader_instruction *ins)
|
||||
{
|
||||
IWineD3DPixelShaderImpl* This = (IWineD3DPixelShaderImpl*) arg->shader;
|
||||
IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->shader;
|
||||
IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device;
|
||||
DWORD flags;
|
||||
DWORD reg = arg->dst & WINED3DSP_REGNUM_MASK;
|
||||
SHADER_BUFFER* buffer = arg->buffer;
|
||||
DWORD reg = ins->dst & WINED3DSP_REGNUM_MASK;
|
||||
SHADER_BUFFER *buffer = ins->buffer;
|
||||
SHADER_PARSE_STATE* current_state = &This->baseShader.parse_state;
|
||||
char dst_str[8];
|
||||
char src0_name[50];
|
||||
|
||||
pshader_gen_input_modifier_line(arg->shader, buffer, arg->src[0], 0, src0_name);
|
||||
pshader_gen_input_modifier_line(ins->shader, buffer, ins->src[0], 0, src0_name);
|
||||
shader_addline(buffer, "DP3 TMP.z, T%u, %s;\n", reg, src0_name);
|
||||
|
||||
/* Construct the eye-ray vector from w coordinates */
|
||||
|
@ -1380,23 +1383,23 @@ static void pshader_hw_texm3x3vspec(const SHADER_OPCODE_ARG *arg)
|
|||
/* Sample the texture using the calculated coordinates */
|
||||
sprintf(dst_str, "T%u", reg);
|
||||
flags = reg < MAX_TEXTURES ? deviceImpl->stateBlock->textureState[reg][WINED3DTSS_TEXTURETRANSFORMFLAGS] : 0;
|
||||
shader_hw_sample(arg, reg, dst_str, "TMP", flags & WINED3DTTFF_PROJECTED, FALSE);
|
||||
shader_hw_sample(ins, reg, dst_str, "TMP", flags & WINED3DTTFF_PROJECTED, FALSE);
|
||||
current_state->current_row = 0;
|
||||
}
|
||||
|
||||
static void pshader_hw_texm3x3spec(const SHADER_OPCODE_ARG *arg)
|
||||
static void pshader_hw_texm3x3spec(const struct wined3d_shader_instruction *ins)
|
||||
{
|
||||
IWineD3DPixelShaderImpl* This = (IWineD3DPixelShaderImpl*) arg->shader;
|
||||
IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->shader;
|
||||
IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device;
|
||||
DWORD flags;
|
||||
DWORD reg = arg->dst & WINED3DSP_REGNUM_MASK;
|
||||
DWORD reg3 = arg->src[1] & WINED3DSP_REGNUM_MASK;
|
||||
DWORD reg = ins->dst & WINED3DSP_REGNUM_MASK;
|
||||
DWORD reg3 = ins->src[1] & WINED3DSP_REGNUM_MASK;
|
||||
SHADER_PARSE_STATE* current_state = &This->baseShader.parse_state;
|
||||
SHADER_BUFFER* buffer = arg->buffer;
|
||||
SHADER_BUFFER *buffer = ins->buffer;
|
||||
char dst_str[8];
|
||||
char src0_name[50];
|
||||
|
||||
pshader_gen_input_modifier_line(arg->shader, buffer, arg->src[0], 0, src0_name);
|
||||
pshader_gen_input_modifier_line(ins->shader, buffer, ins->src[0], 0, src0_name);
|
||||
shader_addline(buffer, "DP3 TMP.z, T%u, %s;\n", reg, src0_name);
|
||||
|
||||
/* Calculate reflection vector.
|
||||
|
@ -1417,13 +1420,13 @@ static void pshader_hw_texm3x3spec(const SHADER_OPCODE_ARG *arg)
|
|||
/* Sample the texture using the calculated coordinates */
|
||||
sprintf(dst_str, "T%u", reg);
|
||||
flags = reg < MAX_TEXTURES ? deviceImpl->stateBlock->textureState[reg][WINED3DTSS_TEXTURETRANSFORMFLAGS] : 0;
|
||||
shader_hw_sample(arg, reg, dst_str, "TMP", flags & WINED3DTTFF_PROJECTED, FALSE);
|
||||
shader_hw_sample(ins, reg, dst_str, "TMP", flags & WINED3DTTFF_PROJECTED, FALSE);
|
||||
current_state->current_row = 0;
|
||||
}
|
||||
|
||||
static void pshader_hw_texdepth(const SHADER_OPCODE_ARG *arg)
|
||||
static void pshader_hw_texdepth(const struct wined3d_shader_instruction *ins)
|
||||
{
|
||||
SHADER_BUFFER* buffer = arg->buffer;
|
||||
SHADER_BUFFER *buffer = ins->buffer;
|
||||
char dst_name[50];
|
||||
|
||||
/* texdepth has an implicit destination, the fragment depth value. It's only parameter,
|
||||
|
@ -1431,7 +1434,7 @@ static void pshader_hw_texdepth(const SHADER_OPCODE_ARG *arg)
|
|||
* parameter. According to the msdn, this must be register r5, but let's keep it more flexible
|
||||
* here
|
||||
*/
|
||||
pshader_get_register_name(arg->shader, arg->dst, dst_name);
|
||||
pshader_get_register_name(ins->shader, ins->dst, dst_name);
|
||||
|
||||
/* According to the msdn, the source register(must be r5) is unusable after
|
||||
* the texdepth instruction, so we're free to modify it
|
||||
|
@ -1451,36 +1454,36 @@ static void pshader_hw_texdepth(const SHADER_OPCODE_ARG *arg)
|
|||
/** Process the WINED3DSIO_TEXDP3TEX instruction in ARB:
|
||||
* Take a 3-component dot product of the TexCoord[dstreg] and src,
|
||||
* then perform a 1D texture lookup from stage dstregnum, place into dst. */
|
||||
static void pshader_hw_texdp3tex(const SHADER_OPCODE_ARG *arg)
|
||||
static void pshader_hw_texdp3tex(const struct wined3d_shader_instruction *ins)
|
||||
{
|
||||
SHADER_BUFFER* buffer = arg->buffer;
|
||||
DWORD sampler_idx = arg->dst & WINED3DSP_REGNUM_MASK;
|
||||
SHADER_BUFFER *buffer = ins->buffer;
|
||||
DWORD sampler_idx = ins->dst & WINED3DSP_REGNUM_MASK;
|
||||
char src0[50];
|
||||
char dst_str[8];
|
||||
|
||||
pshader_gen_input_modifier_line(arg->shader, buffer, arg->src[0], 0, src0);
|
||||
pshader_gen_input_modifier_line(ins->shader, buffer, ins->src[0], 0, src0);
|
||||
shader_addline(buffer, "MOV TMP, 0.0;\n");
|
||||
shader_addline(buffer, "DP3 TMP.x, T%u, %s;\n", sampler_idx, src0);
|
||||
|
||||
sprintf(dst_str, "T%u", sampler_idx);
|
||||
shader_hw_sample(arg, sampler_idx, dst_str, "TMP", FALSE /* Only one coord, can't be projected */, FALSE);
|
||||
shader_hw_sample(ins, sampler_idx, dst_str, "TMP", FALSE /* Only one coord, can't be projected */, FALSE);
|
||||
}
|
||||
|
||||
/** Process the WINED3DSIO_TEXDP3 instruction in ARB:
|
||||
* Take a 3-component dot product of the TexCoord[dstreg] and src. */
|
||||
static void pshader_hw_texdp3(const SHADER_OPCODE_ARG *arg)
|
||||
static void pshader_hw_texdp3(const struct wined3d_shader_instruction *ins)
|
||||
{
|
||||
char src0[50];
|
||||
char dst_str[50];
|
||||
char dst_mask[6];
|
||||
DWORD dstreg = arg->dst & WINED3DSP_REGNUM_MASK;
|
||||
SHADER_BUFFER* buffer = arg->buffer;
|
||||
DWORD dstreg = ins->dst & WINED3DSP_REGNUM_MASK;
|
||||
SHADER_BUFFER *buffer = ins->buffer;
|
||||
|
||||
/* Handle output register */
|
||||
pshader_get_register_name(arg->shader, arg->dst, dst_str);
|
||||
shader_arb_get_write_mask(arg, arg->dst, dst_mask);
|
||||
pshader_get_register_name(ins->shader, ins->dst, dst_str);
|
||||
shader_arb_get_write_mask(ins, ins->dst, dst_mask);
|
||||
|
||||
pshader_gen_input_modifier_line(arg->shader, buffer, arg->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);
|
||||
|
||||
/* TODO: Handle output modifiers */
|
||||
|
@ -1488,18 +1491,18 @@ static void pshader_hw_texdp3(const SHADER_OPCODE_ARG *arg)
|
|||
|
||||
/** Process the WINED3DSIO_TEXM3X3 instruction in ARB
|
||||
* Perform the 3rd row of a 3x3 matrix multiply */
|
||||
static void pshader_hw_texm3x3(const SHADER_OPCODE_ARG *arg)
|
||||
static void pshader_hw_texm3x3(const struct wined3d_shader_instruction *ins)
|
||||
{
|
||||
SHADER_BUFFER* buffer = arg->buffer;
|
||||
SHADER_BUFFER *buffer = ins->buffer;
|
||||
char dst_str[50];
|
||||
char dst_mask[6];
|
||||
char src0[50];
|
||||
DWORD dst_reg = arg->dst & WINED3DSP_REGNUM_MASK;
|
||||
DWORD dst_reg = ins->dst & WINED3DSP_REGNUM_MASK;
|
||||
|
||||
pshader_get_register_name(arg->shader, arg->dst, dst_str);
|
||||
shader_arb_get_write_mask(arg, arg->dst, dst_mask);
|
||||
pshader_get_register_name(ins->shader, ins->dst, dst_str);
|
||||
shader_arb_get_write_mask(ins, ins->dst, dst_mask);
|
||||
|
||||
pshader_gen_input_modifier_line(arg->shader, buffer, arg->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, "MOV %s%s, TMP;\n", dst_str, dst_mask);
|
||||
|
||||
|
@ -1511,13 +1514,13 @@ static void pshader_hw_texm3x3(const SHADER_OPCODE_ARG *arg)
|
|||
* Calculate tmp0.y = TexCoord[dstreg] . src.xyz; (tmp0.x has already been calculated)
|
||||
* depth = (tmp0.y == 0.0) ? 1.0 : tmp0.x / tmp0.y
|
||||
*/
|
||||
static void pshader_hw_texm3x2depth(const SHADER_OPCODE_ARG *arg)
|
||||
static void pshader_hw_texm3x2depth(const struct wined3d_shader_instruction *ins)
|
||||
{
|
||||
SHADER_BUFFER* buffer = arg->buffer;
|
||||
DWORD dst_reg = arg->dst & WINED3DSP_REGNUM_MASK;
|
||||
SHADER_BUFFER *buffer = ins->buffer;
|
||||
DWORD dst_reg = ins->dst & WINED3DSP_REGNUM_MASK;
|
||||
char src0[50];
|
||||
|
||||
pshader_gen_input_modifier_line(arg->shader, buffer, arg->src[0], 0, src0);
|
||||
pshader_gen_input_modifier_line(ins->shader, buffer, ins->src[0], 0, src0);
|
||||
shader_addline(buffer, "DP3 TMP.y, T%u, %s;\n", dst_reg, src0);
|
||||
|
||||
/* How to deal with the special case dst_name.g == 0? if r != 0, then
|
||||
|
@ -1532,63 +1535,64 @@ static void pshader_hw_texm3x2depth(const SHADER_OPCODE_ARG *arg)
|
|||
|
||||
/** Handles transforming all WINED3DSIO_M?x? opcodes for
|
||||
Vertex/Pixel shaders to ARB_vertex_program codes */
|
||||
static void shader_hw_mnxn(const SHADER_OPCODE_ARG *arg)
|
||||
static void shader_hw_mnxn(const struct wined3d_shader_instruction *ins)
|
||||
{
|
||||
int i;
|
||||
int nComponents = 0;
|
||||
SHADER_OPCODE_ARG tmpArg;
|
||||
IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)arg->shader;
|
||||
struct wined3d_shader_instruction tmp_ins;
|
||||
IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->shader;
|
||||
const SHADER_OPCODE *opcode_table = shader->baseShader.shader_ins;
|
||||
DWORD shader_version = arg->reg_maps->shader_version;
|
||||
DWORD shader_version = ins->reg_maps->shader_version;
|
||||
|
||||
memset(&tmpArg, 0, sizeof(SHADER_OPCODE_ARG));
|
||||
memset(&tmp_ins, 0, sizeof(tmp_ins));
|
||||
|
||||
/* Set constants for the temporary argument */
|
||||
tmpArg.shader = arg->shader;
|
||||
tmpArg.buffer = arg->buffer;
|
||||
tmpArg.src[0] = arg->src[0];
|
||||
tmpArg.src_addr[0] = arg->src_addr[0];
|
||||
tmpArg.src_addr[1] = arg->src_addr[1];
|
||||
tmpArg.reg_maps = arg->reg_maps;
|
||||
tmp_ins.shader = ins->shader;
|
||||
tmp_ins.buffer = ins->buffer;
|
||||
tmp_ins.src[0] = ins->src[0];
|
||||
tmp_ins.src_addr[0] = ins->src_addr[0];
|
||||
tmp_ins.src_addr[1] = ins->src_addr[1];
|
||||
tmp_ins.reg_maps = ins->reg_maps;
|
||||
|
||||
switch(arg->opcode->opcode) {
|
||||
switch(ins->opcode->opcode)
|
||||
{
|
||||
case WINED3DSIO_M4x4:
|
||||
nComponents = 4;
|
||||
tmpArg.opcode = shader_get_opcode(opcode_table, shader_version, WINED3DSIO_DP4);
|
||||
tmp_ins.opcode = shader_get_opcode(opcode_table, shader_version, WINED3DSIO_DP4);
|
||||
break;
|
||||
case WINED3DSIO_M4x3:
|
||||
nComponents = 3;
|
||||
tmpArg.opcode = shader_get_opcode(opcode_table, shader_version, WINED3DSIO_DP4);
|
||||
tmp_ins.opcode = shader_get_opcode(opcode_table, shader_version, WINED3DSIO_DP4);
|
||||
break;
|
||||
case WINED3DSIO_M3x4:
|
||||
nComponents = 4;
|
||||
tmpArg.opcode = shader_get_opcode(opcode_table, shader_version, WINED3DSIO_DP3);
|
||||
tmp_ins.opcode = shader_get_opcode(opcode_table, shader_version, WINED3DSIO_DP3);
|
||||
break;
|
||||
case WINED3DSIO_M3x3:
|
||||
nComponents = 3;
|
||||
tmpArg.opcode = shader_get_opcode(opcode_table, shader_version, WINED3DSIO_DP3);
|
||||
tmp_ins.opcode = shader_get_opcode(opcode_table, shader_version, WINED3DSIO_DP3);
|
||||
break;
|
||||
case WINED3DSIO_M3x2:
|
||||
nComponents = 2;
|
||||
tmpArg.opcode = shader_get_opcode(opcode_table, shader_version, WINED3DSIO_DP3);
|
||||
tmp_ins.opcode = shader_get_opcode(opcode_table, shader_version, WINED3DSIO_DP3);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
for (i = 0; i < nComponents; i++) {
|
||||
tmpArg.dst = ((arg->dst) & ~WINED3DSP_WRITEMASK_ALL)|(WINED3DSP_WRITEMASK_0<<i);
|
||||
tmpArg.src[1] = arg->src[1]+i;
|
||||
shader_hw_map2gl(&tmpArg);
|
||||
tmp_ins.dst = ((ins->dst) & ~WINED3DSP_WRITEMASK_ALL)|(WINED3DSP_WRITEMASK_0<<i);
|
||||
tmp_ins.src[1] = ins->src[1]+i;
|
||||
shader_hw_map2gl(&tmp_ins);
|
||||
}
|
||||
}
|
||||
|
||||
static void vshader_hw_rsq_rcp(const SHADER_OPCODE_ARG *arg)
|
||||
static void vshader_hw_rsq_rcp(const struct wined3d_shader_instruction *ins)
|
||||
{
|
||||
CONST SHADER_OPCODE* curOpcode = arg->opcode;
|
||||
SHADER_BUFFER* buffer = arg->buffer;
|
||||
DWORD dst = arg->dst;
|
||||
DWORD src = arg->src[0];
|
||||
CONST SHADER_OPCODE *curOpcode = ins->opcode;
|
||||
SHADER_BUFFER *buffer = ins->buffer;
|
||||
DWORD dst = ins->dst;
|
||||
DWORD src = ins->src[0];
|
||||
DWORD swizzle = (src & WINED3DSP_SWIZZLE_MASK) >> WINED3DSP_SWIZZLE_SHIFT;
|
||||
const char *instruction;
|
||||
|
||||
|
@ -1604,9 +1608,9 @@ static void vshader_hw_rsq_rcp(const SHADER_OPCODE_ARG *arg)
|
|||
}
|
||||
|
||||
strcpy(tmpLine, instruction);
|
||||
vshader_program_add_param(arg, dst, FALSE, tmpLine); /* Destination */
|
||||
vshader_program_add_param(ins, dst, FALSE, tmpLine); /* Destination */
|
||||
strcat(tmpLine, ",");
|
||||
vshader_program_add_param(arg, src, TRUE, tmpLine);
|
||||
vshader_program_add_param(ins, src, TRUE, tmpLine);
|
||||
if ((WINED3DSP_NOSWIZZLE >> WINED3DSP_SWIZZLE_SHIFT) == swizzle) {
|
||||
/* Dx sdk says .x is used if no swizzle is given, but our test shows that
|
||||
* .w is used
|
||||
|
@ -1617,19 +1621,19 @@ static void vshader_hw_rsq_rcp(const SHADER_OPCODE_ARG *arg)
|
|||
shader_addline(buffer, "%s;\n", tmpLine);
|
||||
}
|
||||
|
||||
static void shader_hw_nrm(const SHADER_OPCODE_ARG *arg)
|
||||
static void shader_hw_nrm(const struct wined3d_shader_instruction *ins)
|
||||
{
|
||||
SHADER_BUFFER* buffer = arg->buffer;
|
||||
SHADER_BUFFER *buffer = ins->buffer;
|
||||
char dst_name[50];
|
||||
char src_name[50];
|
||||
char dst_wmask[20];
|
||||
DWORD shift = (arg->dst & WINED3DSP_DSTSHIFT_MASK) >> WINED3DSP_DSTSHIFT_SHIFT;
|
||||
BOOL sat = (arg->dst & WINED3DSP_DSTMOD_MASK) & WINED3DSPDM_SATURATE;
|
||||
DWORD shift = (ins->dst & WINED3DSP_DSTSHIFT_MASK) >> WINED3DSP_DSTSHIFT_SHIFT;
|
||||
BOOL sat = (ins->dst & WINED3DSP_DSTMOD_MASK) & WINED3DSPDM_SATURATE;
|
||||
|
||||
pshader_get_register_name(arg->shader, arg->dst, dst_name);
|
||||
shader_arb_get_write_mask(arg, arg->dst, dst_wmask);
|
||||
pshader_get_register_name(ins->shader, ins->dst, dst_name);
|
||||
shader_arb_get_write_mask(ins, ins->dst, dst_wmask);
|
||||
|
||||
pshader_gen_input_modifier_line(arg->shader, buffer, arg->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, "RSQ TMP, TMP.x;\n");
|
||||
/* dst.w = src[0].w * 1 / (src.x^2 + src.y^2 + src.z^2)^(1/2) according to msdn*/
|
||||
|
@ -1640,23 +1644,23 @@ static void shader_hw_nrm(const SHADER_OPCODE_ARG *arg)
|
|||
pshader_gen_output_modifier_line(buffer, FALSE, dst_wmask, shift, dst_name);
|
||||
}
|
||||
|
||||
static void shader_hw_sincos(const SHADER_OPCODE_ARG *arg)
|
||||
static void shader_hw_sincos(const struct wined3d_shader_instruction *ins)
|
||||
{
|
||||
/* This instruction exists in ARB, but the d3d instruction takes two extra parameters which
|
||||
* must contain fixed constants. So we need a separate function to filter those constants and
|
||||
* can't use map2gl
|
||||
*/
|
||||
SHADER_BUFFER* buffer = arg->buffer;
|
||||
SHADER_BUFFER *buffer = ins->buffer;
|
||||
char dst_name[50];
|
||||
char src_name[50];
|
||||
char dst_wmask[20];
|
||||
DWORD shift = (arg->dst & WINED3DSP_DSTSHIFT_MASK) >> WINED3DSP_DSTSHIFT_SHIFT;
|
||||
BOOL sat = (arg->dst & WINED3DSP_DSTMOD_MASK) & WINED3DSPDM_SATURATE;
|
||||
DWORD shift = (ins->dst & WINED3DSP_DSTSHIFT_MASK) >> WINED3DSP_DSTSHIFT_SHIFT;
|
||||
BOOL sat = (ins->dst & WINED3DSP_DSTMOD_MASK) & WINED3DSPDM_SATURATE;
|
||||
|
||||
pshader_get_register_name(arg->shader, arg->dst, dst_name);
|
||||
shader_arb_get_write_mask(arg, arg->dst, dst_wmask);
|
||||
pshader_get_register_name(ins->shader, ins->dst, dst_name);
|
||||
shader_arb_get_write_mask(ins, ins->dst, dst_wmask);
|
||||
|
||||
pshader_gen_input_modifier_line(arg->shader, buffer, arg->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,
|
||||
src_name);
|
||||
|
||||
|
|
|
@ -771,16 +771,16 @@ void shader_generate_main(IWineD3DBaseShader *iface, SHADER_BUFFER* buffer,
|
|||
const SHADER_OPCODE *opcode_table = This->baseShader.shader_ins;
|
||||
const SHADER_HANDLER *handler_table = device->shader_backend->shader_instruction_handler_table;
|
||||
DWORD shader_version = reg_maps->shader_version;
|
||||
struct wined3d_shader_instruction ins;
|
||||
const DWORD *pToken = pFunction;
|
||||
const SHADER_OPCODE *curOpcode;
|
||||
SHADER_HANDLER hw_fct;
|
||||
DWORD i;
|
||||
SHADER_OPCODE_ARG hw_arg;
|
||||
|
||||
/* Initialize current parsing state */
|
||||
hw_arg.shader = iface;
|
||||
hw_arg.buffer = buffer;
|
||||
hw_arg.reg_maps = reg_maps;
|
||||
ins.shader = iface;
|
||||
ins.buffer = buffer;
|
||||
ins.reg_maps = reg_maps;
|
||||
This->baseShader.parse_state.current_row = 0;
|
||||
|
||||
while (WINED3DPS_END() != *pToken)
|
||||
|
@ -838,39 +838,39 @@ void shader_generate_main(IWineD3DBaseShader *iface, SHADER_BUFFER* buffer,
|
|||
continue;
|
||||
}
|
||||
|
||||
hw_arg.opcode = curOpcode;
|
||||
ins.opcode = curOpcode;
|
||||
|
||||
hw_arg.flags = opcode_token & WINED3D_OPCODESPECIFICCONTROL_MASK;
|
||||
hw_arg.coissue = opcode_token & WINED3DSI_COISSUE;
|
||||
ins.flags = opcode_token & WINED3D_OPCODESPECIFICCONTROL_MASK;
|
||||
ins.coissue = opcode_token & WINED3DSI_COISSUE;
|
||||
|
||||
/* Destination token */
|
||||
if (curOpcode->dst_token)
|
||||
{
|
||||
DWORD param, addr_token = 0;
|
||||
pToken += shader_get_param(pToken, shader_version, ¶m, &addr_token);
|
||||
hw_arg.dst = param;
|
||||
hw_arg.dst_addr = addr_token;
|
||||
ins.dst = param;
|
||||
ins.dst_addr = addr_token;
|
||||
}
|
||||
|
||||
/* Predication token */
|
||||
if (opcode_token & WINED3DSHADER_INSTRUCTION_PREDICATED) hw_arg.predicate = *pToken++;
|
||||
if (opcode_token & WINED3DSHADER_INSTRUCTION_PREDICATED) ins.predicate = *pToken++;
|
||||
|
||||
/* Other source tokens */
|
||||
for (i = 0; i < (curOpcode->num_params - curOpcode->dst_token); ++i)
|
||||
{
|
||||
DWORD param, addr_token = 0;
|
||||
pToken += shader_get_param(pToken, shader_version, ¶m, &addr_token);
|
||||
hw_arg.src[i] = param;
|
||||
hw_arg.src_addr[i] = addr_token;
|
||||
ins.src[i] = param;
|
||||
ins.src_addr[i] = addr_token;
|
||||
}
|
||||
|
||||
/* Call appropriate function for output target */
|
||||
hw_fct(&hw_arg);
|
||||
hw_fct(&ins);
|
||||
|
||||
/* Process instruction modifiers for GLSL apps ( _sat, etc. ) */
|
||||
/* FIXME: This should be internal to the shader backend.
|
||||
* Also, right now this is the only reason "shader_mode" exists. */
|
||||
if (This->baseShader.shader_mode == SHADER_GLSL) shader_glsl_add_instruction_modifiers(&hw_arg);
|
||||
if (This->baseShader.shader_mode == SHADER_GLSL) shader_glsl_add_instruction_modifiers(&ins);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -450,7 +450,7 @@ typedef struct SHADER_OPCODE
|
|||
DWORD max_version;
|
||||
} SHADER_OPCODE;
|
||||
|
||||
typedef struct SHADER_OPCODE_ARG
|
||||
struct wined3d_shader_instruction
|
||||
{
|
||||
IWineD3DBaseShader *shader;
|
||||
const shader_reg_maps *reg_maps;
|
||||
|
@ -463,9 +463,9 @@ typedef struct SHADER_OPCODE_ARG
|
|||
DWORD src[4];
|
||||
DWORD src_addr[4];
|
||||
SHADER_BUFFER *buffer;
|
||||
} SHADER_OPCODE_ARG;
|
||||
};
|
||||
|
||||
typedef void (*SHADER_HANDLER)(const struct SHADER_OPCODE_ARG *);
|
||||
typedef void (*SHADER_HANDLER)(const struct wined3d_shader_instruction *);
|
||||
|
||||
struct shader_caps {
|
||||
DWORD VertexShaderVersion;
|
||||
|
@ -2300,7 +2300,7 @@ extern BOOL vshader_get_input(
|
|||
extern HRESULT allocate_shader_constants(IWineD3DStateBlockImpl* object);
|
||||
|
||||
/* GLSL helper functions */
|
||||
extern void shader_glsl_add_instruction_modifiers(const SHADER_OPCODE_ARG *arg);
|
||||
extern void shader_glsl_add_instruction_modifiers(const struct wined3d_shader_instruction *ins);
|
||||
|
||||
/*****************************************************************************
|
||||
* IDirect3DBaseShader implementation structure
|
||||
|
|
Loading…
Reference in New Issue