Commit 9887d66d authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Return early from shader_trace_init() when a NULL pFunction is passed.

This is mainly to reduce the size and indentation level of the if-block.
parent e18629be
......@@ -981,9 +981,17 @@ void shader_trace_init(
TRACE("(%p) : Parsing program\n", This);
if (NULL != pToken) {
while (WINED3DVS_END() != *pToken) {
if (shader_is_version_token(*pToken)) { /** version */
if (!pFunction)
{
WARN("Got a NULL pFunction, returning.\n");
This->baseShader.functionLength = 1; /* no Function defined use fixed function vertex processing */
return;
}
while (WINED3DVS_END() != *pToken)
{
if (shader_is_version_token(*pToken)) /* version */
{
This->baseShader.hex_version = *pToken;
TRACE("%s_%u_%u\n", shader_is_pshader_version(This->baseShader.hex_version)? "ps": "vs",
WINED3DSHADER_VERSION_MAJOR(This->baseShader.hex_version),
......@@ -992,7 +1000,8 @@ void shader_trace_init(
++len;
continue;
}
if (shader_is_comment(*pToken)) { /** comment */
if (shader_is_comment(*pToken)) /* comment */
{
DWORD comment_len = (*pToken & WINED3DSI_COMMENTSIZE_MASK) >> WINED3DSI_COMMENTSIZE_SHIFT;
++pToken;
TRACE("//%s\n", (const char*)pToken);
......@@ -1004,16 +1013,18 @@ void shader_trace_init(
curOpcode = shader_get_opcode(This->baseShader.shader_ins, This->baseShader.hex_version, opcode_token);
len++;
if (NULL == curOpcode) {
if (!curOpcode)
{
int tokens_read;
FIXME("Unrecognized opcode: token=0x%08x\n", opcode_token);
tokens_read = shader_skip_unrecognized(pToken, This->baseShader.hex_version);
pToken += tokens_read;
len += tokens_read;
} else {
if (curOpcode->opcode == WINED3DSIO_DCL) {
}
else
{
if (curOpcode->opcode == WINED3DSIO_DCL)
{
DWORD usage = *pToken;
DWORD param = *(pToken + 1);
......@@ -1023,9 +1034,9 @@ void shader_trace_init(
shader_dump_param(param, 0, 0, This->baseShader.hex_version);
pToken += 2;
len += 2;
} else if (curOpcode->opcode == WINED3DSIO_DEF) {
}
else if (curOpcode->opcode == WINED3DSIO_DEF)
{
unsigned int offset = shader_get_float_offset(*pToken);
TRACE("def c%u = %f, %f, %f, %f", offset,
......@@ -1033,70 +1044,73 @@ void shader_trace_init(
*(const float *)(pToken + 2),
*(const float *)(pToken + 3),
*(const float *)(pToken + 4));
pToken += 5;
len += 5;
} else if (curOpcode->opcode == WINED3DSIO_DEFI) {
}
else if (curOpcode->opcode == WINED3DSIO_DEFI)
{
TRACE("defi i%u = %d, %d, %d, %d", *pToken & WINED3DSP_REGNUM_MASK,
*(pToken + 1),
*(pToken + 2),
*(pToken + 3),
*(pToken + 4));
pToken += 5;
len += 5;
} else if (curOpcode->opcode == WINED3DSIO_DEFB) {
}
else if (curOpcode->opcode == WINED3DSIO_DEFB)
{
TRACE("defb b%u = %s", *pToken & WINED3DSP_REGNUM_MASK,
*(pToken + 1)? "true": "false");
pToken += 2;
len += 2;
} else {
}
else
{
DWORD param, addr_token;
int tokens_read;
/* Print out predication source token first - it follows
* the destination token. */
if (opcode_token & WINED3DSHADER_INSTRUCTION_PREDICATED) {
if (opcode_token & WINED3DSHADER_INSTRUCTION_PREDICATED)
{
TRACE("(");
shader_dump_param(*(pToken + 2), 0, 1, This->baseShader.hex_version);
TRACE(") ");
}
if (opcode_token & WINED3DSI_COISSUE) {
if (opcode_token & WINED3DSI_COISSUE)
{
/* PixWin marks instructions with the coissue flag with a '+' */
TRACE("+");
}
TRACE("%s", curOpcode->name);
if (curOpcode->opcode == WINED3DSIO_IFC ||
curOpcode->opcode == WINED3DSIO_BREAKC) {
if (curOpcode->opcode == WINED3DSIO_IFC
|| curOpcode->opcode == WINED3DSIO_BREAKC)
{
DWORD op = (opcode_token & INST_CONTROLS_MASK) >> INST_CONTROLS_SHIFT;
switch (op) {
switch (op)
{
case COMPARISON_GT: TRACE("_gt"); break;
case COMPARISON_EQ: TRACE("_eq"); break;
case COMPARISON_GE: TRACE("_ge"); break;
case COMPARISON_LT: TRACE("_lt"); break;
case COMPARISON_NE: TRACE("_ne"); break;
case COMPARISON_LE: TRACE("_le"); break;
default:
TRACE("_(%u)", op);
default: TRACE("_(%u)", op);
}
} else if (curOpcode->opcode == WINED3DSIO_TEX &&
This->baseShader.hex_version >= WINED3DPS_VERSION(2,0)) {
if(opcode_token & WINED3DSI_TEXLD_PROJECT) TRACE("p");
}
else if (curOpcode->opcode == WINED3DSIO_TEX
&& This->baseShader.hex_version >= WINED3DPS_VERSION(2,0)
&& (opcode_token & WINED3DSI_TEXLD_PROJECT))
{
TRACE("p");
}
/* Destination token */
if (curOpcode->dst_token) {
/* Destination token */
if (curOpcode->dst_token)
{
tokens_read = shader_get_param(pToken, This->baseShader.hex_version, &param, &addr_token);
pToken += tokens_read;
len += tokens_read;
......@@ -1107,14 +1121,15 @@ void shader_trace_init(
}
/* Predication token - already printed out, just skip it */
if (opcode_token & WINED3DSHADER_INSTRUCTION_PREDICATED) {
if (opcode_token & WINED3DSHADER_INSTRUCTION_PREDICATED)
{
pToken++;
len++;
}
/* Other source tokens */
for (i = curOpcode->dst_token; i < curOpcode->num_params; ++i) {
for (i = curOpcode->dst_token; i < curOpcode->num_params; ++i)
{
tokens_read = shader_get_param(pToken, This->baseShader.hex_version, &param, &addr_token);
pToken += tokens_read;
len += tokens_read;
......@@ -1127,9 +1142,6 @@ void shader_trace_init(
}
}
This->baseShader.functionLength = (len + 1) * sizeof(DWORD);
} else {
This->baseShader.functionLength = 1; /* no Function defined use fixed function vertex processing */
}
}
static const SHADER_HANDLER shader_none_instruction_handler_table[WINED3DSIH_TABLE_SIZE] = {0};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment