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

wined3d: Move shader input/output signatures to IWineD3DBaseShaderClass.

parent 736aaf7d
...@@ -3190,7 +3190,7 @@ static void init_ps_input(const IWineD3DPixelShaderImpl *This, const struct arb_ ...@@ -3190,7 +3190,7 @@ static void init_ps_input(const IWineD3DPixelShaderImpl *This, const struct arb_
"fragment.texcoord[4]", "fragment.texcoord[5]", "fragment.texcoord[6]", "fragment.texcoord[7]" "fragment.texcoord[4]", "fragment.texcoord[5]", "fragment.texcoord[6]", "fragment.texcoord[7]"
}; };
unsigned int i; unsigned int i;
const struct wined3d_shader_signature_element *sig = This->input_signature; const struct wined3d_shader_signature_element *sig = This->baseShader.input_signature;
const char *semantic_name; const char *semantic_name;
DWORD semantic_idx; DWORD semantic_idx;
...@@ -3670,6 +3670,7 @@ static void init_output_registers(IWineD3DVertexShaderImpl *shader, DWORD sig_nu ...@@ -3670,6 +3670,7 @@ static void init_output_registers(IWineD3DVertexShaderImpl *shader, DWORD sig_nu
"result.texcoord[4]", "result.texcoord[5]", "result.texcoord[6]", "result.texcoord[7]" "result.texcoord[4]", "result.texcoord[5]", "result.texcoord[6]", "result.texcoord[7]"
}; };
IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *) shader->baseShader.device; IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *) shader->baseShader.device;
IWineD3DBaseShaderClass *baseshader = &shader->baseShader;
const struct wined3d_shader_signature_element *sig; const struct wined3d_shader_signature_element *sig;
const char *semantic_name; const char *semantic_name;
DWORD semantic_idx, reg_idx; DWORD semantic_idx, reg_idx;
...@@ -3697,40 +3698,42 @@ static void init_output_registers(IWineD3DVertexShaderImpl *shader, DWORD sig_nu ...@@ -3697,40 +3698,42 @@ static void init_output_registers(IWineD3DVertexShaderImpl *shader, DWORD sig_nu
priv_ctx->fog_output = "result.fogcoord"; priv_ctx->fog_output = "result.fogcoord";
/* Map declared regs to builtins. Use "TA" to /dev/null unread output */ /* Map declared regs to builtins. Use "TA" to /dev/null unread output */
for(i = 0; i < (sizeof(shader->output_signature) / sizeof(*shader->output_signature)); i++) for (i = 0; i < (sizeof(baseshader->output_signature) / sizeof(*baseshader->output_signature)); ++i)
{ {
semantic_name = shader->output_signature[i].semantic_name; semantic_name = baseshader->output_signature[i].semantic_name;
if(semantic_name == NULL) continue; if(semantic_name == NULL) continue;
if(shader_match_semantic(semantic_name, WINED3DDECLUSAGE_POSITION)) if(shader_match_semantic(semantic_name, WINED3DDECLUSAGE_POSITION))
{ {
TRACE("o%u is TMP_OUT\n", i); TRACE("o%u is TMP_OUT\n", i);
if(shader->output_signature[i].semantic_idx == 0) priv_ctx->vs_output[i] = "TMP_OUT"; if (baseshader->output_signature[i].semantic_idx == 0) priv_ctx->vs_output[i] = "TMP_OUT";
else priv_ctx->vs_output[i] = "TA"; else priv_ctx->vs_output[i] = "TA";
} }
else if(shader_match_semantic(semantic_name, WINED3DDECLUSAGE_PSIZE)) else if(shader_match_semantic(semantic_name, WINED3DDECLUSAGE_PSIZE))
{ {
TRACE("o%u is result.pointsize\n", i); TRACE("o%u is result.pointsize\n", i);
if(shader->output_signature[i].semantic_idx == 0) priv_ctx->vs_output[i] = "result.pointsize"; if (baseshader->output_signature[i].semantic_idx == 0) priv_ctx->vs_output[i] = "result.pointsize";
else priv_ctx->vs_output[i] = "TA"; else priv_ctx->vs_output[i] = "TA";
} }
else if(shader_match_semantic(semantic_name, WINED3DDECLUSAGE_COLOR)) else if(shader_match_semantic(semantic_name, WINED3DDECLUSAGE_COLOR))
{ {
TRACE("o%u is result.color.?, idx %u\n", i, shader->output_signature[i].semantic_idx); TRACE("o%u is result.color.?, idx %u\n", i, baseshader->output_signature[i].semantic_idx);
if(shader->output_signature[i].semantic_idx == 0) priv_ctx->vs_output[i] = "result.color.primary"; if (baseshader->output_signature[i].semantic_idx == 0)
else if(shader->output_signature[i].semantic_idx == 1) priv_ctx->vs_output[i] = "result.color.secondary"; priv_ctx->vs_output[i] = "result.color.primary";
else if (baseshader->output_signature[i].semantic_idx == 1)
priv_ctx->vs_output[i] = "result.color.secondary";
else priv_ctx->vs_output[i] = "TA"; else priv_ctx->vs_output[i] = "TA";
} }
else if(shader_match_semantic(semantic_name, WINED3DDECLUSAGE_TEXCOORD)) else if(shader_match_semantic(semantic_name, WINED3DDECLUSAGE_TEXCOORD))
{ {
TRACE("o%u is %s\n", i, texcoords[shader->output_signature[i].semantic_idx]); TRACE("o%u is %s\n", i, texcoords[baseshader->output_signature[i].semantic_idx]);
if(shader->output_signature[i].semantic_idx >= 8) priv_ctx->vs_output[i] = "TA"; if (baseshader->output_signature[i].semantic_idx >= 8) priv_ctx->vs_output[i] = "TA";
else priv_ctx->vs_output[i] = texcoords[shader->output_signature[i].semantic_idx]; else priv_ctx->vs_output[i] = texcoords[baseshader->output_signature[i].semantic_idx];
} }
else if(shader_match_semantic(semantic_name, WINED3DDECLUSAGE_FOG)) else if(shader_match_semantic(semantic_name, WINED3DDECLUSAGE_FOG))
{ {
TRACE("o%u is result.fogcoord\n", i); TRACE("o%u is result.fogcoord\n", i);
if(shader->output_signature[i].semantic_idx > 0) priv_ctx->vs_output[i] = "TA"; if (baseshader->output_signature[i].semantic_idx > 0) priv_ctx->vs_output[i] = "TA";
else priv_ctx->vs_output[i] = "result.fogcoord"; else priv_ctx->vs_output[i] = "result.fogcoord";
} }
else else
...@@ -3744,7 +3747,7 @@ static void init_output_registers(IWineD3DVertexShaderImpl *shader, DWORD sig_nu ...@@ -3744,7 +3747,7 @@ static void init_output_registers(IWineD3DVertexShaderImpl *shader, DWORD sig_nu
/* Instead of searching for the signature in the signature list, read the one from the current pixel shader. /* Instead of searching for the signature in the signature list, read the one from the current pixel shader.
* Its maybe not the shader where the signature came from, but it is the same signature and faster to find * Its maybe not the shader where the signature came from, but it is the same signature and faster to find
*/ */
sig = ((IWineD3DPixelShaderImpl *)device->stateBlock->pixelShader)->input_signature; sig = ((IWineD3DPixelShaderImpl *)device->stateBlock->pixelShader)->baseShader.input_signature;
TRACE("Pixel shader uses declared varyings\n"); TRACE("Pixel shader uses declared varyings\n");
/* Map builtin to declared. /dev/null the results by default to the TA temp reg */ /* Map builtin to declared. /dev/null the results by default to the TA temp reg */
...@@ -3794,24 +3797,24 @@ static void init_output_registers(IWineD3DVertexShaderImpl *shader, DWORD sig_nu ...@@ -3794,24 +3797,24 @@ static void init_output_registers(IWineD3DVertexShaderImpl *shader, DWORD sig_nu
} }
/* Map declared to declared */ /* Map declared to declared */
for(i = 0; i < (sizeof(shader->output_signature) / sizeof(*shader->output_signature)); i++) for (i = 0; i < (sizeof(baseshader->output_signature) / sizeof(*baseshader->output_signature)); ++i)
{ {
/* Write unread output to TA to throw them away */ /* Write unread output to TA to throw them away */
priv_ctx->vs_output[i] = "TA"; priv_ctx->vs_output[i] = "TA";
semantic_name = shader->output_signature[i].semantic_name; semantic_name = baseshader->output_signature[i].semantic_name;
if(semantic_name == NULL) if(semantic_name == NULL)
{ {
continue; continue;
} }
if(shader_match_semantic(semantic_name, WINED3DDECLUSAGE_POSITION) && if (shader_match_semantic(semantic_name, WINED3DDECLUSAGE_POSITION)
shader->output_signature[i].semantic_idx == 0) && baseshader->output_signature[i].semantic_idx == 0)
{ {
priv_ctx->vs_output[i] = "TMP_OUT"; priv_ctx->vs_output[i] = "TMP_OUT";
continue; continue;
} }
else if(shader_match_semantic(semantic_name, WINED3DDECLUSAGE_PSIZE) && else if (shader_match_semantic(semantic_name, WINED3DDECLUSAGE_PSIZE)
shader->output_signature[i].semantic_idx == 0) && baseshader->output_signature[i].semantic_idx == 0)
{ {
priv_ctx->vs_output[i] = "result.pointsize"; priv_ctx->vs_output[i] = "result.pointsize";
continue; continue;
...@@ -3824,8 +3827,8 @@ static void init_output_registers(IWineD3DVertexShaderImpl *shader, DWORD sig_nu ...@@ -3824,8 +3827,8 @@ static void init_output_registers(IWineD3DVertexShaderImpl *shader, DWORD sig_nu
continue; continue;
} }
if(strcmp(sig[j].semantic_name, semantic_name) == 0 && if (strcmp(sig[j].semantic_name, semantic_name) == 0
sig[j].semantic_idx == shader->output_signature[i].semantic_idx) && sig[j].semantic_idx == baseshader->output_signature[i].semantic_idx)
{ {
priv_ctx->vs_output[i] = decl_idx_to_string[sig[j].register_idx]; priv_ctx->vs_output[i] = decl_idx_to_string[sig[j].register_idx];
...@@ -4017,7 +4020,7 @@ static struct arb_ps_compiled_shader *find_arb_pshader(IWineD3DPixelShaderImpl * ...@@ -4017,7 +4020,7 @@ static struct arb_ps_compiled_shader *find_arb_pshader(IWineD3DPixelShaderImpl *
shader_data->clamp_consts = shader->baseShader.reg_maps.shader_version.major == 1; shader_data->clamp_consts = shader->baseShader.reg_maps.shader_version.major == 1;
if(shader->baseShader.reg_maps.shader_version.major < 3) shader_data->input_signature_idx = ~0; if(shader->baseShader.reg_maps.shader_version.major < 3) shader_data->input_signature_idx = ~0;
else shader_data->input_signature_idx = find_input_signature(priv, shader->input_signature); else shader_data->input_signature_idx = find_input_signature(priv, shader->baseShader.input_signature);
shader_data->has_signature_idx = TRUE; shader_data->has_signature_idx = TRUE;
TRACE("Shader got assigned input signature index %u\n", shader_data->input_signature_idx); TRACE("Shader got assigned input signature index %u\n", shader_data->input_signature_idx);
......
...@@ -3606,7 +3606,7 @@ static GLhandleARB generate_param_reorder_function(struct wined3d_shader_buffer ...@@ -3606,7 +3606,7 @@ static GLhandleARB generate_param_reorder_function(struct wined3d_shader_buffer
WORD map = vs->baseShader.reg_maps.output_registers; WORD map = vs->baseShader.reg_maps.output_registers;
/* The vertex shader writes to its own varyings, the pixel shader needs them in the builtin ones */ /* The vertex shader writes to its own varyings, the pixel shader needs them in the builtin ones */
output_signature = vs->output_signature; output_signature = vs->baseShader.output_signature;
shader_addline(buffer, "void order_ps_input(in vec4 OUT[%u]) {\n", MAX_REG_OUTPUT); shader_addline(buffer, "void order_ps_input(in vec4 OUT[%u]) {\n", MAX_REG_OUTPUT);
for (i = 0; map; map >>= 1, ++i) for (i = 0; map; map >>= 1, ++i)
...@@ -3658,7 +3658,7 @@ static GLhandleARB generate_param_reorder_function(struct wined3d_shader_buffer ...@@ -3658,7 +3658,7 @@ static GLhandleARB generate_param_reorder_function(struct wined3d_shader_buffer
} else if(ps_major >= 3 && vs_major >= 3) { } else if(ps_major >= 3 && vs_major >= 3) {
WORD map = vs->baseShader.reg_maps.output_registers; WORD map = vs->baseShader.reg_maps.output_registers;
output_signature = vs->output_signature; output_signature = vs->baseShader.output_signature;
/* This one is tricky: a 3.0 pixel shader reads from a 3.0 vertex shader */ /* This one is tricky: a 3.0 pixel shader reads from a 3.0 vertex shader */
shader_addline(buffer, "varying vec4 IN[%u];\n", vec4_varyings(3, gl_info)); shader_addline(buffer, "varying vec4 IN[%u];\n", vec4_varyings(3, gl_info));
...@@ -3683,7 +3683,7 @@ static GLhandleARB generate_param_reorder_function(struct wined3d_shader_buffer ...@@ -3683,7 +3683,7 @@ static GLhandleARB generate_param_reorder_function(struct wined3d_shader_buffer
} }
/* Then, fix the pixel shader input */ /* Then, fix the pixel shader input */
handle_ps3_input(buffer, gl_info, ps->input_reg_map, ps->input_signature, handle_ps3_input(buffer, gl_info, ps->input_reg_map, ps->baseShader.input_signature,
&ps->baseShader.reg_maps, output_signature, &vs->baseShader.reg_maps); &ps->baseShader.reg_maps, output_signature, &vs->baseShader.reg_maps);
shader_addline(buffer, "}\n"); shader_addline(buffer, "}\n");
...@@ -3694,7 +3694,7 @@ static GLhandleARB generate_param_reorder_function(struct wined3d_shader_buffer ...@@ -3694,7 +3694,7 @@ static GLhandleARB generate_param_reorder_function(struct wined3d_shader_buffer
* point size, but we depend on the optimizers kindness to find out that the pixel shader doesn't * point size, but we depend on the optimizers kindness to find out that the pixel shader doesn't
* read gl_TexCoord and gl_ColorX, otherwise we'll run out of varyings * read gl_TexCoord and gl_ColorX, otherwise we'll run out of varyings
*/ */
handle_ps3_input(buffer, gl_info, ps->input_reg_map, ps->input_signature, handle_ps3_input(buffer, gl_info, ps->input_reg_map, ps->baseShader.input_signature,
&ps->baseShader.reg_maps, NULL, NULL); &ps->baseShader.reg_maps, NULL, NULL);
shader_addline(buffer, "}\n"); shader_addline(buffer, "}\n");
} else { } else {
...@@ -3766,7 +3766,8 @@ static GLuint shader_glsl_generate_pshader(const struct wined3d_context *context ...@@ -3766,7 +3766,8 @@ static GLuint shader_glsl_generate_pshader(const struct wined3d_context *context
/* Pack 3.0 inputs */ /* Pack 3.0 inputs */
if (reg_maps->shader_version.major >= 3 && args->vp_mode != vertexshader) if (reg_maps->shader_version.major >= 3 && args->vp_mode != vertexshader)
{ {
shader_glsl_input_pack((IWineD3DPixelShader *) This, buffer, This->input_signature, reg_maps, args->vp_mode); shader_glsl_input_pack((IWineD3DPixelShader *) This, buffer,
This->baseShader.input_signature, reg_maps, args->vp_mode);
} }
/* Base Shader Body */ /* Base Shader Body */
......
...@@ -318,7 +318,7 @@ static HRESULT vertexshader_set_function(IWineD3DVertexShaderImpl *shader, ...@@ -318,7 +318,7 @@ static HRESULT vertexshader_set_function(IWineD3DVertexShaderImpl *shader,
shader->min_rel_offset = device->d3d_vshader_constantF; shader->min_rel_offset = device->d3d_vshader_constantF;
shader->max_rel_offset = 0; shader->max_rel_offset = 0;
hr = shader_get_registers_used((IWineD3DBaseShader *)shader, fe, hr = shader_get_registers_used((IWineD3DBaseShader *)shader, fe,
reg_maps, shader->input_signature, shader->output_signature, reg_maps, shader->baseShader.input_signature, shader->baseShader.output_signature,
byte_code, device->d3d_vshader_constantF); byte_code, device->d3d_vshader_constantF);
if (FAILED(hr)) return hr; if (FAILED(hr)) return hr;
...@@ -328,8 +328,9 @@ static HRESULT vertexshader_set_function(IWineD3DVertexShaderImpl *shader, ...@@ -328,8 +328,9 @@ static HRESULT vertexshader_set_function(IWineD3DVertexShaderImpl *shader,
{ {
if (!(map & 1) || !shader->baseShader.input_signature[i].semantic_name) continue; if (!(map & 1) || !shader->baseShader.input_signature[i].semantic_name) continue;
shader->attributes[i].usage = shader_usage_from_semantic_name(shader->input_signature[i].semantic_name); shader->attributes[i].usage =
shader->attributes[i].usage_idx = shader->input_signature[i].semantic_idx; shader_usage_from_semantic_name(shader->baseShader.input_signature[i].semantic_name);
shader->attributes[i].usage_idx = shader->baseShader.input_signature[i].semantic_idx;
} }
if (output_signature) if (output_signature)
...@@ -338,7 +339,7 @@ static HRESULT vertexshader_set_function(IWineD3DVertexShaderImpl *shader, ...@@ -338,7 +339,7 @@ static HRESULT vertexshader_set_function(IWineD3DVertexShaderImpl *shader,
{ {
struct wined3d_shader_signature_element *e = &output_signature->elements[i]; struct wined3d_shader_signature_element *e = &output_signature->elements[i];
reg_maps->output_registers |= 1 << e->register_idx; reg_maps->output_registers |= 1 << e->register_idx;
shader->output_signature[e->register_idx] = *e; shader->baseShader.output_signature[e->register_idx] = *e;
} }
} }
...@@ -677,7 +678,7 @@ static HRESULT pixelshader_set_function(IWineD3DPixelShaderImpl *shader, ...@@ -677,7 +678,7 @@ static HRESULT pixelshader_set_function(IWineD3DPixelShaderImpl *shader,
/* Second pass: figure out which registers are used, what the semantics are, etc.. */ /* Second pass: figure out which registers are used, what the semantics are, etc.. */
hr = shader_get_registers_used((IWineD3DBaseShader *)shader, fe, hr = shader_get_registers_used((IWineD3DBaseShader *)shader, fe,
reg_maps, shader->input_signature, NULL, reg_maps, shader->baseShader.input_signature, NULL,
byte_code, device->d3d_pshader_constantF); byte_code, device->d3d_pshader_constantF);
if (FAILED(hr)) return hr; if (FAILED(hr)) return hr;
......
...@@ -2621,6 +2621,9 @@ typedef struct IWineD3DBaseShaderClass ...@@ -2621,6 +2621,9 @@ typedef struct IWineD3DBaseShaderClass
struct list constantsI; struct list constantsI;
shader_reg_maps reg_maps; shader_reg_maps reg_maps;
struct wined3d_shader_signature_element input_signature[max(MAX_ATTRIBS, MAX_REG_INPUT)];
struct wined3d_shader_signature_element output_signature[MAX_REG_OUTPUT];
/* Pointer to the parent device */ /* Pointer to the parent device */
IWineD3DDevice *device; IWineD3DDevice *device;
struct list shader_list_entry; struct list shader_list_entry;
...@@ -2729,10 +2732,8 @@ typedef struct IWineD3DVertexShaderImpl { ...@@ -2729,10 +2732,8 @@ typedef struct IWineD3DVertexShaderImpl {
/* IWineD3DBaseShader */ /* IWineD3DBaseShader */
IWineD3DBaseShaderClass baseShader; IWineD3DBaseShaderClass baseShader;
/* Vertex shader input and output semantics */ /* Vertex shader attributes. */
struct wined3d_shader_attribute attributes[MAX_ATTRIBS]; struct wined3d_shader_attribute attributes[MAX_ATTRIBS];
struct wined3d_shader_signature_element input_signature[max(MAX_ATTRIBS, MAX_REG_INPUT)];
struct wined3d_shader_signature_element output_signature[MAX_REG_OUTPUT];
UINT min_rel_offset, max_rel_offset; UINT min_rel_offset, max_rel_offset;
UINT rel_offset; UINT rel_offset;
...@@ -2773,7 +2774,6 @@ typedef struct IWineD3DPixelShaderImpl { ...@@ -2773,7 +2774,6 @@ typedef struct IWineD3DPixelShaderImpl {
IWineD3DBaseShaderClass baseShader; IWineD3DBaseShaderClass baseShader;
/* Pixel shader input semantics */ /* Pixel shader input semantics */
struct wined3d_shader_signature_element input_signature[MAX_REG_INPUT];
DWORD input_reg_map[MAX_REG_INPUT]; DWORD input_reg_map[MAX_REG_INPUT];
BOOL input_reg_used[MAX_REG_INPUT]; BOOL input_reg_used[MAX_REG_INPUT];
unsigned int declared_in_count; unsigned int declared_in_count;
......
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