Commit d6ee7d59 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Create a relative addressing token for 1.x shaders in the frontend.

Rather than handling this in the backends. Note that the ARB backend always assumes 1.x shaders.
parent 59cc56b1
......@@ -7,6 +7,7 @@
* Copyright 2005 Oliver Stieber
* Copyright 2006 Ivan Gyurdiev
* Copyright 2007-2008 Stefan Dösinger for CodeWeavers
* Copyright 2009 Henri Verbeet for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -131,17 +132,31 @@ const SHADER_OPCODE *shader_get_opcode(const SHADER_OPCODE *opcode_table, DWORD
* Return the number of tokens read */
static int shader_get_param(const DWORD *pToken, DWORD shader_version, DWORD *param, DWORD *addr_token)
{
UINT count = 1;
*param = *pToken;
/* PS >= 3.0 have relative addressing (with token)
* VS >= 2.0 have relative addressing (with token)
* VS >= 1.0 < 2.0 have relative addressing (without token)
* The version check below should work in general */
if (*pToken & WINED3DSHADER_ADDRMODE_RELATIVE)
{
if (WINED3DSHADER_VERSION_MAJOR(shader_version) < 2)
{
*addr_token = (1 << 31)
| ((WINED3DSPR_ADDR << WINED3DSP_REGTYPE_SHIFT2) & WINED3DSP_REGTYPE_MASK2)
| ((WINED3DSPR_ADDR << WINED3DSP_REGTYPE_SHIFT) & WINED3DSP_REGTYPE_MASK)
| WINED3DSP_NOSWIZZLE;
}
else
{
*addr_token = *(pToken + 1);
++count;
}
}
char rel_token = WINED3DSHADER_VERSION_MAJOR(shader_version) >= 2 &&
((*pToken & WINED3DSHADER_ADDRESSMODE_MASK) == WINED3DSHADER_ADDRMODE_RELATIVE);
*param = *pToken;
*addr_token = rel_token? *(pToken + 1): 0;
return rel_token? 2:1;
return count;
}
/* Return the number of parameters to skip for an opcode */
......@@ -167,7 +182,7 @@ static int shader_skip_unrecognized(const DWORD *pToken, DWORD shader_version)
/* TODO: Think of a good name for 0x80000000 and replace it with a constant */
while (*pToken & 0x80000000) {
DWORD param, addr_token;
DWORD param, addr_token = 0;
tokens_read += shader_get_param(pToken, shader_version, &param, &addr_token);
pToken += tokens_read;
......@@ -1014,7 +1029,7 @@ void shader_trace_init(const DWORD *pFunction, const SHADER_OPCODE *opcode_table
}
else
{
DWORD param, addr_token;
DWORD param, addr_token = 0;
int tokens_read;
/* Print out predication source token first - it follows
......
......@@ -1105,27 +1105,12 @@ static void shader_glsl_get_register_name(WINED3DSHADER_PARAM_REGISTER_TYPE regi
/* Relative addressing */
if (rel_addr)
{
/* Relative addressing on shaders 2.0+ have a relative address token,
* prior to that, it was hard-coded as "A0.x" because there's only 1 register */
if (WINED3DSHADER_VERSION_MAJOR(shader_version) >= 2)
{
glsl_src_param_t rel_param;
shader_glsl_add_src_param(ins, addr_token, 0, WINED3DSP_WRITEMASK_0, &rel_param);
if (register_idx)
{
sprintf(register_name, "%cC[%s + %u]", prefix, rel_param.param_str, register_idx);
} else {
sprintf(register_name, "%cC[%s]", prefix, rel_param.param_str);
}
} else {
if (register_idx)
{
sprintf(register_name, "%cC[A0.x + %u]", prefix, register_idx);
} else {
sprintf(register_name, "%cC[A0.x]", prefix);
}
}
glsl_src_param_t rel_param;
shader_glsl_add_src_param(ins, addr_token, 0, WINED3DSP_WRITEMASK_0, &rel_param);
if (register_idx)
sprintf(register_name, "%cC[%s + %u]", prefix, rel_param.param_str, register_idx);
else
sprintf(register_name, "%cC[%s]", prefix, rel_param.param_str);
} else {
if (shader_constant_is_local(This, register_idx))
{
......
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