wined3d: Store the source relative addressing token as a struct wined3d_shader_src_param.

This commit is contained in:
Henri Verbeet 2009-04-17 09:46:56 +02:00 committed by Alexandre Julliard
parent d6ee7d59a8
commit 0663eb9323
3 changed files with 100 additions and 90 deletions

View File

@ -239,14 +239,15 @@ static void shader_parse_dst_param(DWORD param, DWORD addr_param, struct wined3d
dst->addr_token = addr_param;
}
static void shader_parse_src_param(DWORD param, DWORD addr_param, struct wined3d_shader_src_param *src)
static void shader_parse_src_param(DWORD param, const struct wined3d_shader_src_param *rel_addr,
struct wined3d_shader_src_param *src)
{
src->register_type = ((param & WINED3DSP_REGTYPE_MASK) >> WINED3DSP_REGTYPE_SHIFT)
| ((param & WINED3DSP_REGTYPE_MASK2) >> WINED3DSP_REGTYPE_SHIFT2);
src->register_idx = param & WINED3DSP_REGNUM_MASK;
src->modifiers = param & WINED3DSP_SRCMOD_MASK;
src->rel_addr = rel_addr;
src->token = param;
src->addr_token = addr_param;
}
/* Note that this does not count the loop register
@ -814,6 +815,7 @@ 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_src_param src_rel_addr[4];
struct wined3d_shader_src_param src_param[4];
struct wined3d_shader_dst_param dst_param;
struct wined3d_shader_instruction ins;
@ -908,9 +910,17 @@ void shader_generate_main(IWineD3DBaseShader *iface, SHADER_BUFFER* buffer,
ins.src_count = curOpcode->num_params - curOpcode->dst_token;
for (i = 0; i < ins.src_count; ++i)
{
DWORD param, addr_token = 0;
pToken += shader_get_param(pToken, shader_version, &param, &addr_token);
shader_parse_src_param(param, addr_token, &src_param[i]);
DWORD param, addr_param;
pToken += shader_get_param(pToken, shader_version, &param, &addr_param);
if (param & WINED3DSHADER_ADDRMODE_RELATIVE)
{
shader_parse_src_param(addr_param, NULL, &src_rel_addr[i]);
shader_parse_src_param(param, &src_rel_addr[i], &src_param[i]);
}
else
{
shader_parse_src_param(param, NULL, &src_param[i]);
}
}
/* Call appropriate function for output target */

View File

@ -942,8 +942,8 @@ static void shader_generate_glsl_declarations(IWineD3DBaseShader *iface, const s
****************************************************************************/
/* Prototypes */
static void shader_glsl_add_src_param(const struct wined3d_shader_instruction *ins, const DWORD param,
const DWORD addr_token, DWORD mask, glsl_src_param_t *src_param);
static void shader_glsl_add_src_param(const struct wined3d_shader_instruction *ins,
const DWORD param, const struct wined3d_shader_src_param *addr_param, DWORD mask, glsl_src_param_t *src_param);
/** Used for opcode modifiers - They multiply the result by the specified amount */
static const char * const shift_glsl_tab[] = {
@ -1051,7 +1051,7 @@ static void shader_glsl_get_register_name(WINED3DSHADER_PARAM_REGISTER_TYPE regi
if (rel_addr)
{
glsl_src_param_t rel_param;
shader_glsl_add_src_param(ins, addr_token, 0, WINED3DSP_WRITEMASK_0, &rel_param);
shader_glsl_add_src_param(ins, addr_token, NULL, WINED3DSP_WRITEMASK_0, &rel_param);
/* Removing a + 0 would be an obvious optimization, but macos doesn't see the NOP
* operation there
@ -1106,7 +1106,7 @@ static void shader_glsl_get_register_name(WINED3DSHADER_PARAM_REGISTER_TYPE regi
if (rel_addr)
{
glsl_src_param_t rel_param;
shader_glsl_add_src_param(ins, addr_token, 0, WINED3DSP_WRITEMASK_0, &rel_param);
shader_glsl_add_src_param(ins, addr_token, NULL, WINED3DSP_WRITEMASK_0, &rel_param);
if (register_idx)
sprintf(register_name, "%cC[%s + %u]", prefix, rel_param.param_str, register_idx);
else
@ -1267,7 +1267,7 @@ static void shader_glsl_get_swizzle(const DWORD param, BOOL fixup, DWORD mask, c
* Also, return the actual register name and swizzle in case the
* caller needs this information as well. */
static void shader_glsl_add_src_param(const struct wined3d_shader_instruction *ins,
const DWORD param, const DWORD addr_token, DWORD mask, glsl_src_param_t *src_param)
const DWORD param, const struct wined3d_shader_src_param *addr_param, DWORD mask, glsl_src_param_t *src_param)
{
BOOL is_color = FALSE;
char swizzle_str[6];
@ -1277,7 +1277,7 @@ static void shader_glsl_add_src_param(const struct wined3d_shader_instruction *i
swizzle_str[0] = '\0';
shader_glsl_get_register_name(shader_get_regtype(param), param & WINED3DSP_REGNUM_MASK,
param & WINED3DSHADER_ADDRMODE_RELATIVE, addr_token, src_param->reg_name, &is_color, ins);
!!addr_param, addr_param ? addr_param->token : 0, src_param->reg_name, &is_color, ins);
shader_glsl_get_swizzle(param, is_color, mask, swizzle_str);
shader_glsl_gen_modifier(param, src_param->reg_name, swizzle_str, src_param->param_str);
@ -1608,8 +1608,8 @@ static void shader_glsl_arith(const struct wined3d_shader_instruction *ins)
}
write_mask = shader_glsl_append_dst(buffer, ins);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].addr_token, write_mask, &src0_param);
shader_glsl_add_src_param(ins, ins->src[1].token, ins->src[1].addr_token, write_mask, &src1_param);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].rel_addr, write_mask, &src0_param);
shader_glsl_add_src_param(ins, ins->src[1].token, ins->src[1].rel_addr, write_mask, &src1_param);
shader_addline(buffer, "%s %c %s);\n", src0_param.param_str, op, src1_param.param_str);
}
@ -1621,7 +1621,7 @@ static void shader_glsl_mov(const struct wined3d_shader_instruction *ins)
DWORD write_mask;
write_mask = shader_glsl_append_dst(buffer, ins);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].addr_token, write_mask, &src0_param);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].rel_addr, write_mask, &src0_param);
/* In vs_1_1 WINED3DSIO_MOV can write to the address register. In later
* shader versions WINED3DSIO_MOVA is used for this. */
@ -1671,8 +1671,8 @@ static void shader_glsl_dot(const struct wined3d_shader_instruction *ins)
src_write_mask = WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1 | WINED3DSP_WRITEMASK_2;
}
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].addr_token, src_write_mask, &src0_param);
shader_glsl_add_src_param(ins, ins->src[1].token, ins->src[1].addr_token, src_write_mask, &src1_param);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].rel_addr, src_write_mask, &src0_param);
shader_glsl_add_src_param(ins, ins->src[1].token, ins->src[1].rel_addr, src_write_mask, &src1_param);
if (dst_size > 1) {
shader_addline(buffer, "vec%d(dot(%s, %s)));\n", dst_size, src0_param.param_str, src1_param.param_str);
@ -1692,8 +1692,8 @@ static void shader_glsl_cross(const struct wined3d_shader_instruction *ins)
shader_glsl_get_write_mask(&ins->dst[0], dst_mask);
shader_glsl_append_dst(ins->ctx->buffer, ins);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].addr_token, src_mask, &src0_param);
shader_glsl_add_src_param(ins, ins->src[1].token, ins->src[1].addr_token, src_mask, &src1_param);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].rel_addr, src_mask, &src0_param);
shader_glsl_add_src_param(ins, ins->src[1].token, ins->src[1].rel_addr, src_mask, &src1_param);
shader_addline(ins->ctx->buffer, "cross(%s, %s)%s);\n", src0_param.param_str, src1_param.param_str, dst_mask);
}
@ -1711,8 +1711,8 @@ static void shader_glsl_pow(const struct wined3d_shader_instruction *ins)
dst_write_mask = shader_glsl_append_dst(buffer, ins);
dst_size = shader_glsl_get_write_mask_size(dst_write_mask);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].addr_token, WINED3DSP_WRITEMASK_0, &src0_param);
shader_glsl_add_src_param(ins, ins->src[1].token, ins->src[1].addr_token, WINED3DSP_WRITEMASK_0, &src1_param);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].rel_addr, WINED3DSP_WRITEMASK_0, &src0_param);
shader_glsl_add_src_param(ins, ins->src[1].token, ins->src[1].rel_addr, WINED3DSP_WRITEMASK_0, &src1_param);
if (dst_size > 1) {
shader_addline(buffer, "vec%d(pow(abs(%s), %s)));\n", dst_size, src0_param.param_str, src1_param.param_str);
@ -1734,7 +1734,7 @@ static void shader_glsl_log(const struct wined3d_shader_instruction *ins)
dst_write_mask = shader_glsl_append_dst(buffer, ins);
dst_size = shader_glsl_get_write_mask_size(dst_write_mask);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].addr_token, WINED3DSP_WRITEMASK_0, &src0_param);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].rel_addr, WINED3DSP_WRITEMASK_0, &src0_param);
if (dst_size > 1) {
shader_addline(buffer, "vec%d(log2(abs(%s))));\n", dst_size, src0_param.param_str);
@ -1776,11 +1776,11 @@ static void shader_glsl_map2gl(const struct wined3d_shader_instruction *ins)
if (ins->src_count)
{
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].addr_token, write_mask, &src_param);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].rel_addr, write_mask, &src_param);
shader_addline(buffer, "%s", src_param.param_str);
for (i = 1; i < ins->src_count; ++i)
{
shader_glsl_add_src_param(ins, ins->src[i].token, ins->src[i].addr_token, write_mask, &src_param);
shader_glsl_add_src_param(ins, ins->src[i].token, ins->src[i].rel_addr, write_mask, &src_param);
shader_addline(buffer, ", %s", src_param.param_str);
}
}
@ -1801,7 +1801,7 @@ static void shader_glsl_expp(const struct wined3d_shader_instruction *ins)
{
glsl_src_param_t src_param;
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].addr_token, WINED3DSP_WRITEMASK_0, &src_param);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].rel_addr, WINED3DSP_WRITEMASK_0, &src_param);
if (ins->ctx->reg_maps->shader_version < WINED3DPS_VERSION(2,0))
{
@ -1839,7 +1839,7 @@ static void shader_glsl_rcp(const struct wined3d_shader_instruction *ins)
write_mask = shader_glsl_append_dst(ins->ctx->buffer, ins);
mask_size = shader_glsl_get_write_mask_size(write_mask);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].addr_token, WINED3DSP_WRITEMASK_3, &src_param);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].rel_addr, WINED3DSP_WRITEMASK_3, &src_param);
if (mask_size > 1) {
shader_addline(ins->ctx->buffer, "vec%d(1.0 / %s));\n", mask_size, src_param.param_str);
@ -1858,7 +1858,7 @@ static void shader_glsl_rsq(const struct wined3d_shader_instruction *ins)
write_mask = shader_glsl_append_dst(buffer, ins);
mask_size = shader_glsl_get_write_mask_size(write_mask);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].addr_token, WINED3DSP_WRITEMASK_3, &src_param);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].rel_addr, WINED3DSP_WRITEMASK_3, &src_param);
if (mask_size > 1) {
shader_addline(buffer, "vec%d(inversesqrt(%s)));\n", mask_size, src_param.param_str);
@ -1877,8 +1877,8 @@ static void shader_glsl_compare(const struct wined3d_shader_instruction *ins)
write_mask = shader_glsl_append_dst(ins->ctx->buffer, ins);
mask_size = shader_glsl_get_write_mask_size(write_mask);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].addr_token, write_mask, &src0_param);
shader_glsl_add_src_param(ins, ins->src[1].token, ins->src[1].addr_token, write_mask, &src1_param);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].rel_addr, write_mask, &src0_param);
shader_glsl_add_src_param(ins, ins->src[1].token, ins->src[1].rel_addr, write_mask, &src1_param);
if (mask_size > 1) {
const char *compare;
@ -1933,9 +1933,9 @@ static void shader_glsl_cmp(const struct wined3d_shader_instruction *ins)
{
write_mask = shader_glsl_append_dst(ins->ctx->buffer, ins);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].addr_token, WINED3DSP_WRITEMASK_ALL, &src0_param);
shader_glsl_add_src_param(ins, ins->src[1].token, ins->src[1].addr_token, write_mask, &src1_param);
shader_glsl_add_src_param(ins, ins->src[2].token, ins->src[2].addr_token, write_mask, &src2_param);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].rel_addr, WINED3DSP_WRITEMASK_ALL, &src0_param);
shader_glsl_add_src_param(ins, ins->src[1].token, ins->src[1].rel_addr, write_mask, &src1_param);
shader_glsl_add_src_param(ins, ins->src[2].token, ins->src[2].rel_addr, write_mask, &src2_param);
shader_addline(ins->ctx->buffer, "%s >= 0.0 ? %s : %s);\n",
src0_param.param_str, src1_param.param_str, src2_param.param_str);
@ -1976,9 +1976,9 @@ static void shader_glsl_cmp(const struct wined3d_shader_instruction *ins)
if (!write_mask) continue;
}
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].addr_token, cmp_channel, &src0_param);
shader_glsl_add_src_param(ins, ins->src[1].token, ins->src[1].addr_token, write_mask, &src1_param);
shader_glsl_add_src_param(ins, ins->src[2].token, ins->src[2].addr_token, write_mask, &src2_param);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].rel_addr, cmp_channel, &src0_param);
shader_glsl_add_src_param(ins, ins->src[1].token, ins->src[1].rel_addr, write_mask, &src1_param);
shader_glsl_add_src_param(ins, ins->src[2].token, ins->src[2].rel_addr, write_mask, &src2_param);
shader_addline(ins->ctx->buffer, "%s >= 0.0 ? %s : %s);\n",
src0_param.param_str, src1_param.param_str, src2_param.param_str);
@ -2009,9 +2009,9 @@ static void shader_glsl_cnd(const struct wined3d_shader_instruction *ins)
if (ins->ctx->reg_maps->shader_version < WINED3DPS_VERSION(1, 4))
{
write_mask = shader_glsl_append_dst(ins->ctx->buffer, ins);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].addr_token, WINED3DSP_WRITEMASK_0, &src0_param);
shader_glsl_add_src_param(ins, ins->src[1].token, ins->src[1].addr_token, write_mask, &src1_param);
shader_glsl_add_src_param(ins, ins->src[2].token, ins->src[2].addr_token, write_mask, &src2_param);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].rel_addr, WINED3DSP_WRITEMASK_0, &src0_param);
shader_glsl_add_src_param(ins, ins->src[1].token, ins->src[1].rel_addr, write_mask, &src1_param);
shader_glsl_add_src_param(ins, ins->src[2].token, ins->src[2].rel_addr, write_mask, &src2_param);
/* Fun: The D3DSI_COISSUE flag changes the semantic of the cnd instruction for < 1.4 shaders */
if (ins->coissue)
@ -2041,9 +2041,9 @@ static void shader_glsl_cnd(const struct wined3d_shader_instruction *ins)
write_mask = shader_glsl_append_dst_ext(ins->ctx->buffer, ins, &dst);
if (!write_mask) continue;
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].addr_token, cmp_channel, &src0_param);
shader_glsl_add_src_param(ins, ins->src[1].token, ins->src[1].addr_token, write_mask, &src1_param);
shader_glsl_add_src_param(ins, ins->src[2].token, ins->src[2].addr_token, write_mask, &src2_param);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].rel_addr, cmp_channel, &src0_param);
shader_glsl_add_src_param(ins, ins->src[1].token, ins->src[1].rel_addr, write_mask, &src1_param);
shader_glsl_add_src_param(ins, ins->src[2].token, ins->src[2].rel_addr, write_mask, &src2_param);
shader_addline(ins->ctx->buffer, "%s > 0.5 ? %s : %s);\n",
src0_param.param_str, src1_param.param_str, src2_param.param_str);
@ -2059,9 +2059,9 @@ static void shader_glsl_mad(const struct wined3d_shader_instruction *ins)
DWORD write_mask;
write_mask = shader_glsl_append_dst(ins->ctx->buffer, ins);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].addr_token, write_mask, &src0_param);
shader_glsl_add_src_param(ins, ins->src[1].token, ins->src[1].addr_token, write_mask, &src1_param);
shader_glsl_add_src_param(ins, ins->src[2].token, ins->src[2].addr_token, write_mask, &src2_param);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].rel_addr, write_mask, &src0_param);
shader_glsl_add_src_param(ins, ins->src[1].token, ins->src[1].rel_addr, write_mask, &src1_param);
shader_glsl_add_src_param(ins, ins->src[2].token, ins->src[2].rel_addr, write_mask, &src2_param);
shader_addline(ins->ctx->buffer, "(%s * %s) + %s);\n",
src0_param.param_str, src1_param.param_str, src2_param.param_str);
}
@ -2138,9 +2138,9 @@ static void shader_glsl_lrp(const struct wined3d_shader_instruction *ins)
write_mask = shader_glsl_append_dst(ins->ctx->buffer, ins);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].addr_token, write_mask, &src0_param);
shader_glsl_add_src_param(ins, ins->src[1].token, ins->src[1].addr_token, write_mask, &src1_param);
shader_glsl_add_src_param(ins, ins->src[2].token, ins->src[2].addr_token, write_mask, &src2_param);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].rel_addr, write_mask, &src0_param);
shader_glsl_add_src_param(ins, ins->src[1].token, ins->src[1].rel_addr, write_mask, &src1_param);
shader_glsl_add_src_param(ins, ins->src[2].token, ins->src[2].rel_addr, write_mask, &src2_param);
shader_addline(ins->ctx->buffer, "mix(%s, %s, %s));\n",
src2_param.param_str, src1_param.param_str, src0_param.param_str);
@ -2162,9 +2162,9 @@ static void shader_glsl_lit(const struct wined3d_shader_instruction *ins)
shader_glsl_append_dst(ins->ctx->buffer, ins);
shader_glsl_get_write_mask(&ins->dst[0], dst_mask);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].addr_token, WINED3DSP_WRITEMASK_0, &src0_param);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].addr_token, WINED3DSP_WRITEMASK_1, &src1_param);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].addr_token, WINED3DSP_WRITEMASK_3, &src3_param);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].rel_addr, WINED3DSP_WRITEMASK_0, &src0_param);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].rel_addr, WINED3DSP_WRITEMASK_1, &src1_param);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].rel_addr, WINED3DSP_WRITEMASK_3, &src3_param);
/* The sdk specifies the instruction like this
* dst.x = 1.0;
@ -2209,10 +2209,10 @@ static void shader_glsl_dst(const struct wined3d_shader_instruction *ins)
shader_glsl_append_dst(ins->ctx->buffer, ins);
shader_glsl_get_write_mask(&ins->dst[0], dst_mask);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].addr_token, WINED3DSP_WRITEMASK_1, &src0y_param);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].addr_token, WINED3DSP_WRITEMASK_2, &src0z_param);
shader_glsl_add_src_param(ins, ins->src[1].token, ins->src[1].addr_token, WINED3DSP_WRITEMASK_1, &src1y_param);
shader_glsl_add_src_param(ins, ins->src[1].token, ins->src[1].addr_token, WINED3DSP_WRITEMASK_3, &src1w_param);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].rel_addr, WINED3DSP_WRITEMASK_1, &src0y_param);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].rel_addr, WINED3DSP_WRITEMASK_2, &src0z_param);
shader_glsl_add_src_param(ins, ins->src[1].token, ins->src[1].rel_addr, WINED3DSP_WRITEMASK_1, &src1y_param);
shader_glsl_add_src_param(ins, ins->src[1].token, ins->src[1].rel_addr, WINED3DSP_WRITEMASK_3, &src1w_param);
shader_addline(ins->ctx->buffer, "vec4(1.0, %s * %s, %s, %s))%s;\n",
src0y_param.param_str, src1y_param.param_str, src0z_param.param_str, src1w_param.param_str, dst_mask);
@ -2233,7 +2233,7 @@ static void shader_glsl_sincos(const struct wined3d_shader_instruction *ins)
DWORD write_mask;
write_mask = shader_glsl_append_dst(ins->ctx->buffer, ins);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].addr_token, WINED3DSP_WRITEMASK_0, &src0_param);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].rel_addr, WINED3DSP_WRITEMASK_0, &src0_param);
switch (write_mask) {
case WINED3DSP_WRITEMASK_0:
@ -2267,7 +2267,7 @@ static void shader_glsl_loop(const struct wined3d_shader_instruction *ins)
const DWORD *control_values = NULL;
const local_constant *constant;
shader_glsl_add_src_param(ins, ins->src[1].token, ins->src[1].addr_token, WINED3DSP_WRITEMASK_ALL, &src1_param);
shader_glsl_add_src_param(ins, ins->src[1].token, ins->src[1].rel_addr, WINED3DSP_WRITEMASK_ALL, &src1_param);
/* Try to hardcode the loop control parameters if possible. Direct3D 9 class hardware doesn't support real
* varying indexing, but Microsoft designed this feature for Shader model 2.x+. If the loop control is
@ -2337,7 +2337,7 @@ static void shader_glsl_rep(const struct wined3d_shader_instruction *ins)
IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader;
glsl_src_param_t src0_param;
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].addr_token, WINED3DSP_WRITEMASK_0, &src0_param);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].rel_addr, WINED3DSP_WRITEMASK_0, &src0_param);
shader_addline(ins->ctx->buffer, "for (tmpInt%d = 0; tmpInt%d < %s; tmpInt%d++) {\n",
shader->baseShader.cur_loop_depth, shader->baseShader.cur_loop_depth,
src0_param.param_str, shader->baseShader.cur_loop_depth);
@ -2348,7 +2348,7 @@ static void shader_glsl_if(const struct wined3d_shader_instruction *ins)
{
glsl_src_param_t src0_param;
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].addr_token, WINED3DSP_WRITEMASK_0, &src0_param);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].rel_addr, WINED3DSP_WRITEMASK_0, &src0_param);
shader_addline(ins->ctx->buffer, "if (%s) {\n", src0_param.param_str);
}
@ -2357,8 +2357,8 @@ static void shader_glsl_ifc(const struct wined3d_shader_instruction *ins)
glsl_src_param_t src0_param;
glsl_src_param_t src1_param;
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].addr_token, WINED3DSP_WRITEMASK_0, &src0_param);
shader_glsl_add_src_param(ins, ins->src[1].token, ins->src[1].addr_token, WINED3DSP_WRITEMASK_0, &src1_param);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].rel_addr, WINED3DSP_WRITEMASK_0, &src0_param);
shader_glsl_add_src_param(ins, ins->src[1].token, ins->src[1].rel_addr, WINED3DSP_WRITEMASK_0, &src1_param);
shader_addline(ins->ctx->buffer, "if (%s %s %s) {\n",
src0_param.param_str, shader_get_comp_op(ins->flags), src1_param.param_str);
@ -2380,8 +2380,8 @@ static void shader_glsl_breakc(const struct wined3d_shader_instruction *ins)
glsl_src_param_t src0_param;
glsl_src_param_t src1_param;
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].addr_token, WINED3DSP_WRITEMASK_0, &src0_param);
shader_glsl_add_src_param(ins, ins->src[1].token, ins->src[1].addr_token, WINED3DSP_WRITEMASK_0, &src1_param);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].rel_addr, WINED3DSP_WRITEMASK_0, &src0_param);
shader_glsl_add_src_param(ins, ins->src[1].token, ins->src[1].rel_addr, WINED3DSP_WRITEMASK_0, &src1_param);
shader_addline(ins->ctx->buffer, "if (%s %s %s) break;\n",
src0_param.param_str, shader_get_comp_op(ins->flags), src1_param.param_str);
@ -2402,7 +2402,7 @@ static void shader_glsl_callnz(const struct wined3d_shader_instruction *ins)
{
glsl_src_param_t src1_param;
shader_glsl_add_src_param(ins, ins->src[1].token, ins->src[1].addr_token, WINED3DSP_WRITEMASK_0, &src1_param);
shader_glsl_add_src_param(ins, ins->src[1].token, ins->src[1].rel_addr, WINED3DSP_WRITEMASK_0, &src1_param);
shader_addline(ins->ctx->buffer, "if (%s) subroutine%u();\n", src1_param.param_str, ins->src[0].register_idx);
}
@ -2483,11 +2483,11 @@ static void pshader_glsl_tex(const struct wined3d_shader_instruction *ins)
"T%u%s", sampler_idx, coord_mask);
} else {
glsl_src_param_t coord_param;
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].addr_token, mask, &coord_param);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].rel_addr, mask, &coord_param);
if (ins->flags & WINED3DSI_TEXLD_BIAS)
{
glsl_src_param_t bias;
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].addr_token, WINED3DSP_WRITEMASK_3, &bias);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].rel_addr, WINED3DSP_WRITEMASK_3, &bias);
shader_glsl_gen_sample_code(ins, sampler_idx, &sample_function, swizzle, bias.param_str,
"%s", coord_param.param_str);
} else {
@ -2515,9 +2515,9 @@ static void shader_glsl_texldl(const struct wined3d_shader_instruction *ins)
sample_flags |= WINED3D_GLSL_SAMPLE_RECT;
}
shader_glsl_get_sample_function(sampler_type, sample_flags, &sample_function);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].addr_token, sample_function.coord_mask, &coord_param);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].rel_addr, sample_function.coord_mask, &coord_param);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].addr_token, WINED3DSP_WRITEMASK_3, &lod_param);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].rel_addr, WINED3DSP_WRITEMASK_3, &lod_param);
if (shader_is_pshader_version(ins->ctx->reg_maps->shader_version))
{
@ -2552,7 +2552,7 @@ static void pshader_glsl_texcoord(const struct wined3d_shader_instruction *ins)
if (src_mod == WINED3DSPSM_DZ) {
glsl_src_param_t div_param;
unsigned int mask_size = shader_glsl_get_write_mask_size(write_mask);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].addr_token, WINED3DSP_WRITEMASK_2, &div_param);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].rel_addr, WINED3DSP_WRITEMASK_2, &div_param);
if (mask_size > 1) {
shader_addline(buffer, "gl_TexCoord[%u]%s / vec%d(%s));\n", reg, dst_swizzle, mask_size, div_param.param_str);
@ -2562,7 +2562,7 @@ static void pshader_glsl_texcoord(const struct wined3d_shader_instruction *ins)
} else if (src_mod == WINED3DSPSM_DW) {
glsl_src_param_t div_param;
unsigned int mask_size = shader_glsl_get_write_mask_size(write_mask);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].addr_token, WINED3DSP_WRITEMASK_3, &div_param);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].rel_addr, WINED3DSP_WRITEMASK_3, &div_param);
if (mask_size > 1) {
shader_addline(buffer, "gl_TexCoord[%u]%s / vec%d(%s));\n", reg, dst_swizzle, mask_size, div_param.param_str);
@ -2587,7 +2587,7 @@ static void pshader_glsl_texdp3tex(const struct wined3d_shader_instruction *ins)
DWORD sampler_type = ins->ctx->reg_maps->samplers[sampler_idx] & WINED3DSP_TEXTURETYPE_MASK;
UINT mask_size;
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].addr_token, src_mask, &src0_param);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].rel_addr, src_mask, &src0_param);
/* Do I have to take care about the projected bit? I don't think so, since the dp3 returns only one
* scalar, and projected sampling would require 4.
@ -2632,7 +2632,7 @@ static void pshader_glsl_texdp3(const struct wined3d_shader_instruction *ins)
dst_mask = shader_glsl_append_dst(ins->ctx->buffer, ins);
mask_size = shader_glsl_get_write_mask_size(dst_mask);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].addr_token, src_mask, &src0_param);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].rel_addr, src_mask, &src0_param);
if (mask_size > 1) {
shader_addline(ins->ctx->buffer, "vec%d(dot(T%u.xyz, %s)));\n", mask_size, dstreg, src0_param.param_str);
@ -2670,7 +2670,7 @@ static void pshader_glsl_texm3x2depth(const struct wined3d_shader_instruction *i
DWORD dstreg = ins->dst[0].register_idx;
glsl_src_param_t src0_param;
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].addr_token, src_mask, &src0_param);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].rel_addr, src_mask, &src0_param);
shader_addline(ins->ctx->buffer, "tmp0.y = dot(T%u.xyz, %s);\n", dstreg, src0_param.param_str);
shader_addline(ins->ctx->buffer, "gl_FragDepth = (tmp0.y == 0.0) ? 1.0 : clamp(tmp0.x / tmp0.y, 0.0, 1.0);\n");
@ -2685,7 +2685,7 @@ static void pshader_glsl_texm3x2pad(const struct wined3d_shader_instruction *ins
SHADER_BUFFER *buffer = ins->ctx->buffer;
glsl_src_param_t src0_param;
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].addr_token, src_mask, &src0_param);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].rel_addr, src_mask, &src0_param);
shader_addline(buffer, "tmp0.x = dot(T%u.xyz, %s);\n", reg, src0_param.param_str);
}
@ -2700,7 +2700,7 @@ static void pshader_glsl_texm3x3pad(const struct wined3d_shader_instruction *ins
SHADER_PARSE_STATE* current_state = &shader->baseShader.parse_state;
glsl_src_param_t src0_param;
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].addr_token, src_mask, &src0_param);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].rel_addr, src_mask, &src0_param);
shader_addline(buffer, "tmp0.%c = dot(T%u.xyz, %s);\n", 'x' + current_state->current_row, reg, src0_param.param_str);
current_state->texcoord_w[current_state->current_row++] = reg;
}
@ -2714,7 +2714,7 @@ static void pshader_glsl_texm3x2tex(const struct wined3d_shader_instruction *ins
DWORD sampler_type = ins->ctx->reg_maps->samplers[reg] & WINED3DSP_TEXTURETYPE_MASK;
glsl_sample_function_t sample_function;
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].addr_token, src_mask, &src0_param);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].rel_addr, src_mask, &src0_param);
shader_addline(buffer, "tmp0.y = dot(T%u.xyz, %s);\n", reg, src0_param.param_str);
shader_glsl_get_sample_function(sampler_type, 0, &sample_function);
@ -2735,7 +2735,7 @@ static void pshader_glsl_texm3x3tex(const struct wined3d_shader_instruction *ins
DWORD sampler_type = ins->ctx->reg_maps->samplers[reg] & WINED3DSP_TEXTURETYPE_MASK;
glsl_sample_function_t sample_function;
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].addr_token, src_mask, &src0_param);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].rel_addr, src_mask, &src0_param);
shader_addline(ins->ctx->buffer, "tmp0.z = dot(T%u.xyz, %s);\n", reg, src0_param.param_str);
/* Dependent read, not valid with conditional NP2 */
@ -2758,7 +2758,7 @@ static void pshader_glsl_texm3x3(const struct wined3d_shader_instruction *ins)
IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->ctx->shader;
SHADER_PARSE_STATE* current_state = &This->baseShader.parse_state;
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].addr_token, src_mask, &src0_param);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].rel_addr, src_mask, &src0_param);
shader_glsl_append_dst(ins->ctx->buffer, ins);
shader_glsl_get_write_mask(&ins->dst[0], dst_mask);
@ -2781,8 +2781,8 @@ static void pshader_glsl_texm3x3spec(const struct wined3d_shader_instruction *in
DWORD src_mask = WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1 | WINED3DSP_WRITEMASK_2;
glsl_sample_function_t sample_function;
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].addr_token, src_mask, &src0_param);
shader_glsl_add_src_param(ins, ins->src[1].token, ins->src[1].addr_token, src_mask, &src1_param);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].rel_addr, src_mask, &src0_param);
shader_glsl_add_src_param(ins, ins->src[1].token, ins->src[1].rel_addr, src_mask, &src1_param);
/* Perform the last matrix multiply operation */
shader_addline(buffer, "tmp0.z = dot(T%u.xyz, %s);\n", reg, src0_param.param_str);
@ -2811,7 +2811,7 @@ static void pshader_glsl_texm3x3vspec(const struct wined3d_shader_instruction *i
DWORD sampler_type = ins->ctx->reg_maps->samplers[reg] & WINED3DSP_TEXTURETYPE_MASK;
glsl_sample_function_t sample_function;
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].addr_token, src_mask, &src0_param);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].rel_addr, src_mask, &src0_param);
/* Perform the last matrix multiply operation */
shader_addline(buffer, "tmp0.z = dot(vec3(T%u), vec3(%s));\n", reg, src0_param.param_str);
@ -2873,7 +2873,7 @@ static void pshader_glsl_texbem(const struct wined3d_shader_instruction *ins)
shader_addline(ins->ctx->buffer, "T%u%s /= T%u%s;\n", sampler_idx, coord_mask, sampler_idx, coord_div_mask);
}
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].addr_token,
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].rel_addr,
WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1, &coord_param);
shader_glsl_gen_sample_code(ins, sampler_idx, &sample_function, WINED3DVS_NOSWIZZLE, NULL,
@ -2885,7 +2885,7 @@ static void pshader_glsl_texbem(const struct wined3d_shader_instruction *ins)
glsl_src_param_t luminance_param;
glsl_dst_param_t dst_param;
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].addr_token, WINED3DSP_WRITEMASK_2, &luminance_param);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].rel_addr, WINED3DSP_WRITEMASK_2, &luminance_param);
shader_glsl_add_dst_param(ins, &ins->dst[0], &dst_param);
shader_addline(ins->ctx->buffer, "%s%s *= (%s * luminancescale%d + luminanceoffset%d);\n",
@ -2899,9 +2899,9 @@ static void pshader_glsl_bem(const struct wined3d_shader_instruction *ins)
glsl_src_param_t src0_param, src1_param;
DWORD sampler_idx = ins->dst[0].register_idx;
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].addr_token,
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].rel_addr,
WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1, &src0_param);
shader_glsl_add_src_param(ins, ins->src[1].token, ins->src[1].addr_token,
shader_glsl_add_src_param(ins, ins->src[1].token, ins->src[1].rel_addr,
WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1, &src1_param);
shader_glsl_append_dst(ins->ctx->buffer, ins);
@ -2918,7 +2918,7 @@ static void pshader_glsl_texreg2ar(const struct wined3d_shader_instruction *ins)
DWORD sampler_type = ins->ctx->reg_maps->samplers[sampler_idx] & WINED3DSP_TEXTURETYPE_MASK;
glsl_sample_function_t sample_function;
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].addr_token, WINED3DSP_WRITEMASK_ALL, &src0_param);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].rel_addr, WINED3DSP_WRITEMASK_ALL, &src0_param);
shader_glsl_get_sample_function(sampler_type, 0, &sample_function);
shader_glsl_gen_sample_code(ins, sampler_idx, &sample_function, WINED3DVS_NOSWIZZLE, NULL,
@ -2934,7 +2934,7 @@ static void pshader_glsl_texreg2gb(const struct wined3d_shader_instruction *ins)
DWORD sampler_type = ins->ctx->reg_maps->samplers[sampler_idx] & WINED3DSP_TEXTURETYPE_MASK;
glsl_sample_function_t sample_function;
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].addr_token, WINED3DSP_WRITEMASK_ALL, &src0_param);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].rel_addr, WINED3DSP_WRITEMASK_ALL, &src0_param);
shader_glsl_get_sample_function(sampler_type, 0, &sample_function);
shader_glsl_gen_sample_code(ins, sampler_idx, &sample_function, WINED3DVS_NOSWIZZLE, NULL,
@ -2952,7 +2952,7 @@ static void pshader_glsl_texreg2rgb(const struct wined3d_shader_instruction *ins
/* Dependent read, not valid with conditional NP2 */
shader_glsl_get_sample_function(sampler_type, 0, &sample_function);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].addr_token, sample_function.coord_mask, &src0_param);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].rel_addr, sample_function.coord_mask, &src0_param);
shader_glsl_gen_sample_code(ins, sampler_idx, &sample_function, WINED3DVS_NOSWIZZLE, NULL,
"%s", src0_param.param_str);
@ -2992,11 +2992,11 @@ static void pshader_glsl_dp2add(const struct wined3d_shader_instruction *ins)
write_mask = shader_glsl_append_dst(ins->ctx->buffer, ins);
mask_size = shader_glsl_get_write_mask_size(write_mask);
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].addr_token,
shader_glsl_add_src_param(ins, ins->src[0].token, ins->src[0].rel_addr,
WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1, &src0_param);
shader_glsl_add_src_param(ins, ins->src[1].token, ins->src[1].addr_token,
shader_glsl_add_src_param(ins, ins->src[1].token, ins->src[1].rel_addr,
WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1, &src1_param);
shader_glsl_add_src_param(ins, ins->src[2].token, ins->src[2].addr_token,
shader_glsl_add_src_param(ins, ins->src[2].token, ins->src[2].rel_addr,
WINED3DSP_WRITEMASK_0, &src2_param);
if (mask_size > 1) {

View File

@ -467,8 +467,8 @@ struct wined3d_shader_src_param
WINED3DSHADER_PARAM_REGISTER_TYPE register_type;
UINT register_idx;
DWORD modifiers;
const struct wined3d_shader_src_param *rel_addr;
DWORD token;
DWORD addr_token;
};
struct wined3d_shader_instruction