Commit 868f5bfc authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Handle reading the shader header in the frontend.

In SM 1-3 this is just the version, in SM4 this also includes the token count.
parent ef074cdd
...@@ -342,13 +342,8 @@ HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3 ...@@ -342,13 +342,8 @@ HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3
shader_delete_constant_list(&This->baseShader.constantsB); shader_delete_constant_list(&This->baseShader.constantsB);
shader_delete_constant_list(&This->baseShader.constantsI); shader_delete_constant_list(&This->baseShader.constantsI);
/* The version token is supposed to be the first token */ fe->shader_read_header(&pToken, &shader_version);
if (!shader_is_version_token(*pToken)) reg_maps->shader_version = shader_version;
{
FIXME("First token is not a version token, invalid shader.\n");
return WINED3DERR_INVALIDCALL;
}
reg_maps->shader_version = shader_version = *pToken++;
pshader = shader_is_pshader_version(shader_version); pshader = shader_is_pshader_version(shader_version);
while (!fe->shader_is_end(&pToken)) while (!fe->shader_is_end(&pToken))
...@@ -868,7 +863,6 @@ void shader_generate_main(IWineD3DBaseShader *iface, SHADER_BUFFER *buffer, ...@@ -868,7 +863,6 @@ void shader_generate_main(IWineD3DBaseShader *iface, SHADER_BUFFER *buffer,
IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *) This->baseShader.device; /* To access shader backend callbacks */ IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *) This->baseShader.device; /* To access shader backend callbacks */
const SHADER_OPCODE *opcode_table = This->baseShader.shader_ins; const SHADER_OPCODE *opcode_table = This->baseShader.shader_ins;
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;
struct wined3d_shader_src_param src_rel_addr[4]; struct wined3d_shader_src_param src_rel_addr[4];
struct wined3d_shader_src_param src_param[4]; struct wined3d_shader_src_param src_param[4];
struct wined3d_shader_src_param dst_rel_addr; struct wined3d_shader_src_param dst_rel_addr;
...@@ -877,6 +871,7 @@ void shader_generate_main(IWineD3DBaseShader *iface, SHADER_BUFFER *buffer, ...@@ -877,6 +871,7 @@ void shader_generate_main(IWineD3DBaseShader *iface, SHADER_BUFFER *buffer,
struct wined3d_shader_context ctx; struct wined3d_shader_context ctx;
const DWORD *pToken = pFunction; const DWORD *pToken = pFunction;
SHADER_HANDLER hw_fct; SHADER_HANDLER hw_fct;
DWORD shader_version;
DWORD i; DWORD i;
/* Initialize current parsing state */ /* Initialize current parsing state */
...@@ -889,11 +884,7 @@ void shader_generate_main(IWineD3DBaseShader *iface, SHADER_BUFFER *buffer, ...@@ -889,11 +884,7 @@ void shader_generate_main(IWineD3DBaseShader *iface, SHADER_BUFFER *buffer,
ins.src = src_param; ins.src = src_param;
This->baseShader.parse_state.current_row = 0; This->baseShader.parse_state.current_row = 0;
if (!shader_is_version_token(*pToken++)) fe->shader_read_header(&pToken, &shader_version);
{
ERR("First token is not a version token, invalid shader.\n");
return;
}
while (!fe->shader_is_end(&pToken)) while (!fe->shader_is_end(&pToken))
{ {
...@@ -995,13 +986,8 @@ void shader_trace_init(const struct wined3d_shader_frontend *fe, ...@@ -995,13 +986,8 @@ void shader_trace_init(const struct wined3d_shader_frontend *fe,
TRACE("Parsing %p\n", pFunction); TRACE("Parsing %p\n", pFunction);
/* The version token is supposed to be the first token */ fe->shader_read_header(&pToken, &shader_version);
if (!shader_is_version_token(*pToken))
{
FIXME("First token is not a version token, invalid shader.\n");
return;
}
shader_version = *pToken++;
TRACE("%s_%u_%u\n", shader_is_pshader_version(shader_version) ? "ps": "vs", TRACE("%s_%u_%u\n", shader_is_pshader_version(shader_version) ? "ps": "vs",
WINED3DSHADER_VERSION_MAJOR(shader_version), WINED3DSHADER_VERSION_MINOR(shader_version)); WINED3DSHADER_VERSION_MAJOR(shader_version), WINED3DSHADER_VERSION_MINOR(shader_version));
......
...@@ -221,6 +221,12 @@ static int shader_skip_unrecognized(const DWORD *ptr, DWORD shader_version) ...@@ -221,6 +221,12 @@ static int shader_skip_unrecognized(const DWORD *ptr, DWORD shader_version)
return tokens_read; return tokens_read;
} }
static void shader_sm1_read_header(const DWORD **ptr, DWORD *shader_version)
{
TRACE("version: 0x%08x\n", **ptr);
*shader_version = *(*ptr)++;
}
static void shader_sm1_read_opcode(const DWORD **ptr, struct wined3d_shader_instruction *ins, UINT *param_size, static void shader_sm1_read_opcode(const DWORD **ptr, struct wined3d_shader_instruction *ins, UINT *param_size,
const SHADER_OPCODE *opcode_table, DWORD shader_version) const SHADER_OPCODE *opcode_table, DWORD shader_version)
{ {
...@@ -318,6 +324,7 @@ static BOOL shader_sm1_is_end(const DWORD **ptr) ...@@ -318,6 +324,7 @@ static BOOL shader_sm1_is_end(const DWORD **ptr)
const struct wined3d_shader_frontend sm1_shader_frontend = const struct wined3d_shader_frontend sm1_shader_frontend =
{ {
shader_sm1_read_header,
shader_sm1_read_opcode, shader_sm1_read_opcode,
shader_sm1_read_src_param, shader_sm1_read_src_param,
shader_sm1_read_dst_param, shader_sm1_read_dst_param,
......
...@@ -23,6 +23,14 @@ ...@@ -23,6 +23,14 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader); WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader);
static void shader_sm4_read_header(const DWORD **ptr, DWORD *shader_version)
{
TRACE("version: 0x%08x\n", **ptr);
*shader_version = *(*ptr)++;
TRACE("token count: %u\n", **ptr);
++(*ptr);
}
static void shader_sm4_read_opcode(const DWORD **ptr, struct wined3d_shader_instruction *ins, static void shader_sm4_read_opcode(const DWORD **ptr, struct wined3d_shader_instruction *ins,
UINT *param_size, const SHADER_OPCODE *opcode_table, DWORD shader_version) UINT *param_size, const SHADER_OPCODE *opcode_table, DWORD shader_version)
{ {
...@@ -63,6 +71,7 @@ static BOOL shader_sm4_is_end(const DWORD **ptr) ...@@ -63,6 +71,7 @@ static BOOL shader_sm4_is_end(const DWORD **ptr)
const struct wined3d_shader_frontend sm4_shader_frontend = const struct wined3d_shader_frontend sm4_shader_frontend =
{ {
shader_sm4_read_header,
shader_sm4_read_opcode, shader_sm4_read_opcode,
shader_sm4_read_src_param, shader_sm4_read_src_param,
shader_sm4_read_dst_param, shader_sm4_read_dst_param,
......
...@@ -674,6 +674,7 @@ struct wined3d_shader_semantic ...@@ -674,6 +674,7 @@ struct wined3d_shader_semantic
struct wined3d_shader_frontend struct wined3d_shader_frontend
{ {
void (*shader_read_header)(const DWORD **ptr, DWORD *shader_version);
void (*shader_read_opcode)(const DWORD **ptr, struct wined3d_shader_instruction *ins, void (*shader_read_opcode)(const DWORD **ptr, struct wined3d_shader_instruction *ins,
UINT *param_size, const SHADER_OPCODE *opcode_table, DWORD shader_version); UINT *param_size, const SHADER_OPCODE *opcode_table, DWORD shader_version);
void (*shader_read_src_param)(const DWORD **ptr, struct wined3d_shader_src_param *src_param, void (*shader_read_src_param)(const DWORD **ptr, struct wined3d_shader_src_param *src_param,
......
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