wined3d: Split shader_dump_param() in shader_dump_src_param() and shader_dump_dst_param().

This commit is contained in:
Henri Verbeet 2009-04-30 11:02:20 +02:00 committed by Alexandre Julliard
parent 54a3054e5a
commit bf4f7bf34a
1 changed files with 113 additions and 103 deletions

View File

@ -94,8 +94,8 @@ typedef enum _WINED3DSHADER_ADDRESSMODE_TYPE
WINED3DSHADER_ADDRMODE_FORCE_DWORD = 0x7fffffff, WINED3DSHADER_ADDRMODE_FORCE_DWORD = 0x7fffffff,
} WINED3DSHADER_ADDRESSMODE_TYPE; } WINED3DSHADER_ADDRESSMODE_TYPE;
static void shader_dump_param(WINED3DSHADER_PARAM_REGISTER_TYPE register_type, UINT register_idx, BOOL is_src, static void shader_dump_src_param(const struct wined3d_shader_src_param *param, DWORD shader_version);
DWORD src_modifier, DWORD mask_swizzle, const struct wined3d_shader_src_param *rel_addr, DWORD shader_version); static void shader_dump_dst_param(const struct wined3d_shader_dst_param *param, DWORD shader_version);
/* Read a parameter opcode from the input stream, /* Read a parameter opcode from the input stream,
* and possibly a relative addressing token. * and possibly a relative addressing token.
@ -211,16 +211,14 @@ static int shader_skip_unrecognized(const DWORD *ptr, DWORD shader_version)
struct wined3d_shader_dst_param dst; struct wined3d_shader_dst_param dst;
shader_parse_dst_param(token, token & WINED3DSHADER_ADDRMODE_RELATIVE ? &rel_addr : NULL, &dst); shader_parse_dst_param(token, token & WINED3DSHADER_ADDRMODE_RELATIVE ? &rel_addr : NULL, &dst);
shader_dump_param(dst.register_type, dst.register_idx, FALSE, 0, shader_dump_dst_param(&dst, shader_version);
dst.write_mask, dst.rel_addr, shader_version);
} }
else else
{ {
struct wined3d_shader_src_param src; struct wined3d_shader_src_param src;
shader_parse_src_param(token, token & WINED3DSHADER_ADDRMODE_RELATIVE ? &rel_addr : NULL, &src); shader_parse_src_param(token, token & WINED3DSHADER_ADDRMODE_RELATIVE ? &rel_addr : NULL, &src);
shader_dump_param(src.register_type, src.register_idx, TRUE, src.modifiers, shader_dump_src_param(&src, shader_version);
src.swizzle, src.rel_addr, shader_version);
} }
FIXME("\n"); FIXME("\n");
++i; ++i;
@ -919,50 +917,30 @@ static void shader_dump_arr_entry(const struct wined3d_shader_src_param *rel_add
if (rel_addr) if (rel_addr)
{ {
TRACE("["); TRACE("[");
shader_dump_param(rel_addr->register_type, rel_addr->register_idx, TRUE, shader_dump_src_param(rel_addr, shader_version);
rel_addr->modifiers, rel_addr->swizzle, NULL, shader_version);
TRACE(" + "); TRACE(" + ");
} }
TRACE("%u", register_idx); TRACE("%u", register_idx);
if (rel_addr) TRACE("]"); if (rel_addr) TRACE("]");
} }
static void shader_dump_param(WINED3DSHADER_PARAM_REGISTER_TYPE register_type, UINT register_idx, BOOL is_src, static void shader_dump_register(WINED3DSHADER_PARAM_REGISTER_TYPE register_type, UINT register_idx,
DWORD src_modifier, DWORD mask_swizzle, const struct wined3d_shader_src_param *rel_addr, DWORD shader_version) const struct wined3d_shader_src_param *rel_addr, DWORD shader_version)
{ {
static const char * const rastout_reg_names[] = { "oPos", "oFog", "oPts" }; static const char * const rastout_reg_names[] = {"oPos", "oFog", "oPts"};
static const char * const misctype_reg_names[] = { "vPos", "vFace"}; static const char * const misctype_reg_names[] = {"vPos", "vFace"};
const char *swizzle_reg_chars = "xyzw";
/* There are some minor differences between pixel and vertex shaders */
char pshader = shader_is_pshader_version(shader_version);
if (is_src)
{
if (src_modifier == WINED3DSPSM_NEG
|| src_modifier == WINED3DSPSM_BIASNEG
|| src_modifier == WINED3DSPSM_SIGNNEG
|| src_modifier == WINED3DSPSM_X2NEG
|| src_modifier == WINED3DSPSM_ABSNEG)
TRACE("-");
else if (src_modifier == WINED3DSPSM_COMP)
TRACE("1-");
else if (src_modifier == WINED3DSPSM_NOT)
TRACE("!");
if (src_modifier == WINED3DSPSM_ABS || src_modifier == WINED3DSPSM_ABSNEG)
TRACE("abs(");
}
switch (register_type) switch (register_type)
{ {
case WINED3DSPR_TEMP: case WINED3DSPR_TEMP:
TRACE("r%u", register_idx); TRACE("r%u", register_idx);
break; break;
case WINED3DSPR_INPUT: case WINED3DSPR_INPUT:
TRACE("v"); TRACE("v");
shader_dump_arr_entry(rel_addr, register_idx, shader_version); shader_dump_arr_entry(rel_addr, register_idx, shader_version);
break; break;
case WINED3DSPR_CONST: case WINED3DSPR_CONST:
case WINED3DSPR_CONST2: case WINED3DSPR_CONST2:
case WINED3DSPR_CONST3: case WINED3DSPR_CONST3:
@ -970,122 +948,158 @@ static void shader_dump_param(WINED3DSHADER_PARAM_REGISTER_TYPE register_type, U
TRACE("c"); TRACE("c");
shader_dump_arr_entry(rel_addr, shader_get_float_offset(register_type, register_idx), shader_version); shader_dump_arr_entry(rel_addr, shader_get_float_offset(register_type, register_idx), shader_version);
break; break;
case WINED3DSPR_TEXTURE: /* vs: case WINED3DSPR_ADDR */ case WINED3DSPR_TEXTURE: /* vs: case WINED3DSPR_ADDR */
TRACE("%c%u", (pshader ? 't' : 'a'), register_idx); TRACE("%c%u", (shader_is_pshader_version(shader_version) ? 't' : 'a'), register_idx);
break; break;
case WINED3DSPR_RASTOUT: case WINED3DSPR_RASTOUT:
TRACE("%s", rastout_reg_names[register_idx]); TRACE("%s", rastout_reg_names[register_idx]);
break; break;
case WINED3DSPR_COLOROUT: case WINED3DSPR_COLOROUT:
TRACE("oC%u", register_idx); TRACE("oC%u", register_idx);
break; break;
case WINED3DSPR_DEPTHOUT: case WINED3DSPR_DEPTHOUT:
TRACE("oDepth"); TRACE("oDepth");
break; break;
case WINED3DSPR_ATTROUT: case WINED3DSPR_ATTROUT:
TRACE("oD%u", register_idx); TRACE("oD%u", register_idx);
break; break;
case WINED3DSPR_TEXCRDOUT:
case WINED3DSPR_TEXCRDOUT:
/* Vertex shaders >= 3.0 use general purpose output registers /* Vertex shaders >= 3.0 use general purpose output registers
* (WINED3DSPR_OUTPUT), which can include an address token */ * (WINED3DSPR_OUTPUT), which can include an address token */
if (WINED3DSHADER_VERSION_MAJOR(shader_version) >= 3)
if (WINED3DSHADER_VERSION_MAJOR(shader_version) >= 3) { {
TRACE("o"); TRACE("o");
shader_dump_arr_entry(rel_addr, register_idx, shader_version); shader_dump_arr_entry(rel_addr, register_idx, shader_version);
} }
else else
TRACE("oT%u", register_idx); {
TRACE("oT%u", register_idx);
}
break; break;
case WINED3DSPR_CONSTINT: case WINED3DSPR_CONSTINT:
TRACE("i"); TRACE("i");
shader_dump_arr_entry(rel_addr, register_idx, shader_version); shader_dump_arr_entry(rel_addr, register_idx, shader_version);
break; break;
case WINED3DSPR_CONSTBOOL: case WINED3DSPR_CONSTBOOL:
TRACE("b"); TRACE("b");
shader_dump_arr_entry(rel_addr, register_idx, shader_version); shader_dump_arr_entry(rel_addr, register_idx, shader_version);
break; break;
case WINED3DSPR_LABEL: case WINED3DSPR_LABEL:
TRACE("l%u", register_idx); TRACE("l%u", register_idx);
break; break;
case WINED3DSPR_LOOP: case WINED3DSPR_LOOP:
TRACE("aL"); TRACE("aL");
break; break;
case WINED3DSPR_SAMPLER: case WINED3DSPR_SAMPLER:
TRACE("s%u", register_idx); TRACE("s%u", register_idx);
break; break;
case WINED3DSPR_MISCTYPE: case WINED3DSPR_MISCTYPE:
if (register_idx > 1) FIXME("Unhandled misctype register %d\n", register_idx); if (register_idx > 1) FIXME("Unhandled misctype register %d\n", register_idx);
else TRACE("%s", misctype_reg_names[register_idx]); else TRACE("%s", misctype_reg_names[register_idx]);
break; break;
case WINED3DSPR_PREDICATE: case WINED3DSPR_PREDICATE:
TRACE("p%u", register_idx); TRACE("p%u", register_idx);
break; break;
default: default:
TRACE("unhandled_rtype(%#x)", register_type); TRACE("unhandled_rtype(%#x)", register_type);
break; break;
} }
}
if (!is_src) static void shader_dump_dst_param(const struct wined3d_shader_dst_param *param, DWORD shader_version)
{ {
/* operand output (for modifiers and shift, see dump_ins_modifiers) */ DWORD write_mask = param->write_mask;
if (mask_swizzle != WINED3DSP_WRITEMASK_ALL)
{ shader_dump_register(param->register_type, param->register_idx, param->rel_addr, shader_version);
TRACE(".");
if (mask_swizzle & WINED3DSP_WRITEMASK_0) TRACE("%c", swizzle_reg_chars[0]); if (write_mask != WINED3DSP_WRITEMASK_ALL)
if (mask_swizzle & WINED3DSP_WRITEMASK_1) TRACE("%c", swizzle_reg_chars[1]); {
if (mask_swizzle & WINED3DSP_WRITEMASK_2) TRACE("%c", swizzle_reg_chars[2]); static const char *write_mask_chars = "xyzw";
if (mask_swizzle & WINED3DSP_WRITEMASK_3) TRACE("%c", swizzle_reg_chars[3]);
} TRACE(".");
} if (write_mask & WINED3DSP_WRITEMASK_0) TRACE("%c", write_mask_chars[0]);
else if (write_mask & WINED3DSP_WRITEMASK_1) TRACE("%c", write_mask_chars[1]);
{ if (write_mask & WINED3DSP_WRITEMASK_2) TRACE("%c", write_mask_chars[2]);
/* operand input */ if (write_mask & WINED3DSP_WRITEMASK_3) TRACE("%c", write_mask_chars[3]);
if (src_modifier) }
}
static void shader_dump_src_param(const struct wined3d_shader_src_param *param, DWORD shader_version)
{
DWORD src_modifier = param->modifiers;
DWORD swizzle = param->swizzle;
if (src_modifier == WINED3DSPSM_NEG
|| src_modifier == WINED3DSPSM_BIASNEG
|| src_modifier == WINED3DSPSM_SIGNNEG
|| src_modifier == WINED3DSPSM_X2NEG
|| src_modifier == WINED3DSPSM_ABSNEG)
TRACE("-");
else if (src_modifier == WINED3DSPSM_COMP)
TRACE("1-");
else if (src_modifier == WINED3DSPSM_NOT)
TRACE("!");
if (src_modifier == WINED3DSPSM_ABS || src_modifier == WINED3DSPSM_ABSNEG)
TRACE("abs(");
shader_dump_register(param->register_type, param->register_idx, param->rel_addr, shader_version);
if (src_modifier)
{
switch (src_modifier)
{ {
switch (src_modifier) case WINED3DSPSM_NONE: break;
{ case WINED3DSPSM_NEG: break;
case WINED3DSPSM_NONE: break; case WINED3DSPSM_NOT: break;
case WINED3DSPSM_NEG: break; case WINED3DSPSM_BIAS: TRACE("_bias"); break;
case WINED3DSPSM_NOT: break; case WINED3DSPSM_BIASNEG: TRACE("_bias"); break;
case WINED3DSPSM_BIAS: TRACE("_bias"); break; case WINED3DSPSM_SIGN: TRACE("_bx2"); break;
case WINED3DSPSM_BIASNEG: TRACE("_bias"); break; case WINED3DSPSM_SIGNNEG: TRACE("_bx2"); break;
case WINED3DSPSM_SIGN: TRACE("_bx2"); break; case WINED3DSPSM_COMP: break;
case WINED3DSPSM_SIGNNEG: TRACE("_bx2"); break; case WINED3DSPSM_X2: TRACE("_x2"); break;
case WINED3DSPSM_COMP: break; case WINED3DSPSM_X2NEG: TRACE("_x2"); break;
case WINED3DSPSM_X2: TRACE("_x2"); break; case WINED3DSPSM_DZ: TRACE("_dz"); break;
case WINED3DSPSM_X2NEG: TRACE("_x2"); break; case WINED3DSPSM_DW: TRACE("_dw"); break;
case WINED3DSPSM_DZ: TRACE("_dz"); break; case WINED3DSPSM_ABSNEG: TRACE(")"); break;
case WINED3DSPSM_DW: TRACE("_dw"); break; case WINED3DSPSM_ABS: TRACE(")"); break;
case WINED3DSPSM_ABSNEG: TRACE(")"); break; default:
case WINED3DSPSM_ABS: TRACE(")"); break; TRACE("_unknown_modifier(%#x)", src_modifier);
default:
TRACE("_unknown_modifier(%#x)", src_modifier);
}
} }
}
/** if (swizzle != WINED3DSP_NOSWIZZLE)
* swizzle bits fields: {
* RRGGBBAA static const char *swizzle_chars = "xyzw";
*/ DWORD swizzle_x = swizzle & 0x03;
if (mask_swizzle != WINED3DSP_NOSWIZZLE) DWORD swizzle_y = (swizzle >> 2) & 0x03;
DWORD swizzle_z = (swizzle >> 4) & 0x03;
DWORD swizzle_w = (swizzle >> 6) & 0x03;
if (swizzle_x == swizzle_y
&& swizzle_x == swizzle_z
&& swizzle_x == swizzle_w)
{ {
DWORD swizzle_x = mask_swizzle & 0x03; TRACE(".%c", swizzle_chars[swizzle_x]);
DWORD swizzle_y = (mask_swizzle >> 2) & 0x03; }
DWORD swizzle_z = (mask_swizzle >> 4) & 0x03; else
DWORD swizzle_w = (mask_swizzle >> 6) & 0x03; {
TRACE(".%c%c%c%c", swizzle_chars[swizzle_x], swizzle_chars[swizzle_y],
if (swizzle_x == swizzle_y && swizzle_chars[swizzle_z], swizzle_chars[swizzle_w]);
swizzle_x == swizzle_z &&
swizzle_x == swizzle_w) {
TRACE(".%c", swizzle_reg_chars[swizzle_x]);
} else {
TRACE(".%c%c%c%c",
swizzle_reg_chars[swizzle_x],
swizzle_reg_chars[swizzle_y],
swizzle_reg_chars[swizzle_z],
swizzle_reg_chars[swizzle_w]);
}
} }
} }
} }
@ -1269,8 +1283,7 @@ void shader_trace_init(const DWORD *pFunction, const SHADER_OPCODE *opcode_table
shader_dump_decl_usage(&semantic, shader_version); shader_dump_decl_usage(&semantic, shader_version);
shader_dump_ins_modifiers(&semantic.reg); shader_dump_ins_modifiers(&semantic.reg);
TRACE(" "); TRACE(" ");
shader_dump_param(semantic.reg.register_type, semantic.reg.register_idx, FALSE, shader_dump_dst_param(&semantic.reg, shader_version);
0, semantic.reg.write_mask, semantic.reg.rel_addr, shader_version);
} }
else if (ins.handler_idx == WINED3DSIH_DEF) else if (ins.handler_idx == WINED3DSIH_DEF)
{ {
@ -1313,8 +1326,7 @@ void shader_trace_init(const DWORD *pFunction, const SHADER_OPCODE *opcode_table
shader_parse_src_param(*(pToken + 2), NULL, &pred); shader_parse_src_param(*(pToken + 2), NULL, &pred);
TRACE("("); TRACE("(");
shader_dump_param(pred.register_type, pred.register_idx, TRUE, shader_dump_src_param(&pred, shader_version);
pred.modifiers, pred.swizzle, pred.rel_addr, shader_version);
TRACE(") "); TRACE(") ");
} }
@ -1354,8 +1366,7 @@ void shader_trace_init(const DWORD *pFunction, const SHADER_OPCODE *opcode_table
shader_dump_ins_modifiers(&dst); shader_dump_ins_modifiers(&dst);
TRACE(" "); TRACE(" ");
shader_dump_param(dst.register_type, dst.register_idx, FALSE, shader_dump_dst_param(&dst, shader_version);
0, dst.write_mask, dst.rel_addr, shader_version);
} }
/* Predication token - already printed out, just skip it */ /* Predication token - already printed out, just skip it */
@ -1380,8 +1391,7 @@ void shader_trace_init(const DWORD *pFunction, const SHADER_OPCODE *opcode_table
} }
TRACE(!i ? " " : ", "); TRACE(!i ? " " : ", ");
shader_dump_param(src.register_type, src.register_idx, TRUE, shader_dump_src_param(&src, shader_version);
src.modifiers, src.swizzle, src.rel_addr, shader_version);
} }
} }
TRACE("\n"); TRACE("\n");