wined3d: Simplify shader_generate_main() a bit.
This commit is contained in:
parent
8553665cb1
commit
9011452243
|
@ -822,10 +822,8 @@ static void shader_color_correction(IWineD3DBaseShaderImpl *shader,
|
||||||
device->shader_backend->shader_color_correction(arg, fixup);
|
device->shader_backend->shader_color_correction(arg, fixup);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Shared code in order to generate the bulk of the shader string.
|
/* Shared code in order to generate the bulk of the shader string.
|
||||||
Use the shader_header_fct & shader_footer_fct to add strings
|
* NOTE: A description of how to parse tokens can be found on msdn */
|
||||||
that are specific to pixel or vertex functions
|
|
||||||
NOTE: A description of how to parse tokens can be found on msdn */
|
|
||||||
void shader_generate_main(IWineD3DBaseShader *iface, SHADER_BUFFER* buffer,
|
void shader_generate_main(IWineD3DBaseShader *iface, SHADER_BUFFER* buffer,
|
||||||
const shader_reg_maps* reg_maps, CONST DWORD* pFunction)
|
const shader_reg_maps* reg_maps, CONST DWORD* pFunction)
|
||||||
{
|
{
|
||||||
|
@ -835,8 +833,8 @@ void shader_generate_main(IWineD3DBaseShader *iface, SHADER_BUFFER* buffer,
|
||||||
const SHADER_HANDLER *handler_table = device->shader_backend->shader_instruction_handler_table;
|
const SHADER_HANDLER *handler_table = device->shader_backend->shader_instruction_handler_table;
|
||||||
DWORD shader_version = reg_maps->shader_version;
|
DWORD shader_version = reg_maps->shader_version;
|
||||||
const DWORD *pToken = pFunction;
|
const DWORD *pToken = pFunction;
|
||||||
const SHADER_OPCODE *curOpcode = NULL;
|
const SHADER_OPCODE *curOpcode;
|
||||||
SHADER_HANDLER hw_fct = NULL;
|
SHADER_HANDLER hw_fct;
|
||||||
DWORD i;
|
DWORD i;
|
||||||
SHADER_OPCODE_ARG hw_arg;
|
SHADER_OPCODE_ARG hw_arg;
|
||||||
|
|
||||||
|
@ -846,22 +844,22 @@ void shader_generate_main(IWineD3DBaseShader *iface, SHADER_BUFFER* buffer,
|
||||||
hw_arg.reg_maps = reg_maps;
|
hw_arg.reg_maps = reg_maps;
|
||||||
This->baseShader.parse_state.current_row = 0;
|
This->baseShader.parse_state.current_row = 0;
|
||||||
|
|
||||||
/* Second pass, process opcodes */
|
if (!pToken) return;
|
||||||
if (NULL != pToken) {
|
|
||||||
while (WINED3DPS_END() != *pToken) {
|
|
||||||
|
|
||||||
|
while (WINED3DPS_END() != *pToken)
|
||||||
|
{
|
||||||
/* Skip version token */
|
/* Skip version token */
|
||||||
if (shader_is_version_token(*pToken)) {
|
if (shader_is_version_token(*pToken))
|
||||||
|
{
|
||||||
++pToken;
|
++pToken;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Skip comment tokens */
|
/* Skip comment tokens */
|
||||||
if (shader_is_comment(*pToken)) {
|
if (shader_is_comment(*pToken))
|
||||||
DWORD comment_len = (*pToken & WINED3DSI_COMMENTSIZE_MASK) >> WINED3DSI_COMMENTSIZE_SHIFT;
|
{
|
||||||
|
pToken += (*pToken & WINED3DSI_COMMENTSIZE_MASK) >> WINED3DSI_COMMENTSIZE_SHIFT;
|
||||||
++pToken;
|
++pToken;
|
||||||
TRACE("#%s\n", (const char*)pToken);
|
|
||||||
pToken += comment_len;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -869,36 +867,43 @@ void shader_generate_main(IWineD3DBaseShader *iface, SHADER_BUFFER* buffer,
|
||||||
hw_arg.opcode_token = *pToken++;
|
hw_arg.opcode_token = *pToken++;
|
||||||
curOpcode = shader_get_opcode(opcode_table, shader_version, hw_arg.opcode_token);
|
curOpcode = shader_get_opcode(opcode_table, shader_version, hw_arg.opcode_token);
|
||||||
|
|
||||||
/* Select handler */
|
|
||||||
if (curOpcode == NULL)
|
|
||||||
hw_fct = NULL;
|
|
||||||
else
|
|
||||||
hw_fct = handler_table[curOpcode->handler_idx];
|
|
||||||
|
|
||||||
/* Unknown opcode and its parameters */
|
/* Unknown opcode and its parameters */
|
||||||
if (NULL == curOpcode) {
|
if (!curOpcode)
|
||||||
|
{
|
||||||
FIXME("Unrecognized opcode: token=0x%08x\n", hw_arg.opcode_token);
|
FIXME("Unrecognized opcode: token=0x%08x\n", hw_arg.opcode_token);
|
||||||
pToken += shader_skip_unrecognized(pToken, shader_version);
|
pToken += shader_skip_unrecognized(pToken, shader_version);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
/* Nothing to do */
|
/* Nothing to do */
|
||||||
} else if (WINED3DSIO_DCL == curOpcode->opcode ||
|
if (WINED3DSIO_DCL == curOpcode->opcode
|
||||||
WINED3DSIO_NOP == curOpcode->opcode ||
|
|| WINED3DSIO_NOP == curOpcode->opcode
|
||||||
WINED3DSIO_DEF == curOpcode->opcode ||
|
|| WINED3DSIO_DEF == curOpcode->opcode
|
||||||
WINED3DSIO_DEFI == curOpcode->opcode ||
|
|| WINED3DSIO_DEFI == curOpcode->opcode
|
||||||
WINED3DSIO_DEFB == curOpcode->opcode ||
|
|| WINED3DSIO_DEFB == curOpcode->opcode
|
||||||
WINED3DSIO_PHASE == curOpcode->opcode ||
|
|| WINED3DSIO_PHASE == curOpcode->opcode
|
||||||
WINED3DSIO_RET == curOpcode->opcode) {
|
|| WINED3DSIO_RET == curOpcode->opcode)
|
||||||
|
{
|
||||||
pToken += shader_skip_opcode(curOpcode, hw_arg.opcode_token, shader_version);
|
pToken += shader_skip_opcode(curOpcode, hw_arg.opcode_token, shader_version);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
/* If a generator function is set for current shader target, use it */
|
/* Select handler */
|
||||||
} else if (hw_fct != NULL) {
|
hw_fct = handler_table[curOpcode->handler_idx];
|
||||||
|
|
||||||
|
/* Unhandled opcode */
|
||||||
|
if (!hw_fct)
|
||||||
|
{
|
||||||
|
FIXME("Can't handle opcode %s in hwShader\n", curOpcode->name);
|
||||||
|
pToken += shader_skip_opcode(curOpcode, hw_arg.opcode_token, shader_version);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
hw_arg.opcode = curOpcode;
|
hw_arg.opcode = curOpcode;
|
||||||
|
|
||||||
/* Destination token */
|
/* Destination token */
|
||||||
if (curOpcode->dst_token) {
|
if (curOpcode->dst_token)
|
||||||
|
{
|
||||||
DWORD param, addr_token = 0;
|
DWORD param, addr_token = 0;
|
||||||
pToken += shader_get_param(pToken, shader_version, ¶m, &addr_token);
|
pToken += shader_get_param(pToken, shader_version, ¶m, &addr_token);
|
||||||
hw_arg.dst = param;
|
hw_arg.dst = param;
|
||||||
|
@ -906,12 +911,11 @@ void shader_generate_main(IWineD3DBaseShader *iface, SHADER_BUFFER* buffer,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Predication token */
|
/* Predication token */
|
||||||
if (hw_arg.opcode_token & WINED3DSHADER_INSTRUCTION_PREDICATED)
|
if (hw_arg.opcode_token & WINED3DSHADER_INSTRUCTION_PREDICATED) hw_arg.predicate = *pToken++;
|
||||||
hw_arg.predicate = *pToken++;
|
|
||||||
|
|
||||||
/* Other source tokens */
|
/* Other source tokens */
|
||||||
for (i = 0; i < (curOpcode->num_params - curOpcode->dst_token); i++) {
|
for (i = 0; i < (curOpcode->num_params - curOpcode->dst_token); ++i)
|
||||||
|
{
|
||||||
DWORD param, addr_token = 0;
|
DWORD param, addr_token = 0;
|
||||||
pToken += shader_get_param(pToken, shader_version, ¶m, &addr_token);
|
pToken += shader_get_param(pToken, shader_version, ¶m, &addr_token);
|
||||||
hw_arg.src[i] = param;
|
hw_arg.src[i] = param;
|
||||||
|
@ -927,18 +931,7 @@ void shader_generate_main(IWineD3DBaseShader *iface, SHADER_BUFFER* buffer,
|
||||||
/* Process instruction modifiers for GLSL apps ( _sat, etc. ) */
|
/* Process instruction modifiers for GLSL apps ( _sat, etc. ) */
|
||||||
/* FIXME: This should be internal to the shader backend.
|
/* FIXME: This should be internal to the shader backend.
|
||||||
* Also, right now this is the only reason "shader_mode" exists. */
|
* Also, right now this is the only reason "shader_mode" exists. */
|
||||||
if (This->baseShader.shader_mode == SHADER_GLSL)
|
if (This->baseShader.shader_mode == SHADER_GLSL) shader_glsl_add_instruction_modifiers(&hw_arg);
|
||||||
shader_glsl_add_instruction_modifiers(&hw_arg);
|
|
||||||
|
|
||||||
/* Unhandled opcode */
|
|
||||||
} else {
|
|
||||||
|
|
||||||
FIXME("Can't handle opcode %s in hwShader\n", curOpcode->name);
|
|
||||||
pToken += shader_skip_opcode(curOpcode, hw_arg.opcode_token, shader_version);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* TODO: What about result.depth? */
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue