wined3d: Move shader input/output signatures to IWineD3DBaseShaderClass.
This commit is contained in:
parent
736aaf7d09
commit
b548e387ae
|
@ -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]"
|
||||
};
|
||||
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;
|
||||
DWORD semantic_idx;
|
||||
|
||||
|
@ -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]"
|
||||
};
|
||||
IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *) shader->baseShader.device;
|
||||
IWineD3DBaseShaderClass *baseshader = &shader->baseShader;
|
||||
const struct wined3d_shader_signature_element *sig;
|
||||
const char *semantic_name;
|
||||
DWORD semantic_idx, reg_idx;
|
||||
|
@ -3697,40 +3698,42 @@ static void init_output_registers(IWineD3DVertexShaderImpl *shader, DWORD sig_nu
|
|||
priv_ctx->fog_output = "result.fogcoord";
|
||||
|
||||
/* 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(shader_match_semantic(semantic_name, WINED3DDECLUSAGE_POSITION))
|
||||
{
|
||||
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 if(shader_match_semantic(semantic_name, WINED3DDECLUSAGE_PSIZE))
|
||||
{
|
||||
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 if(shader_match_semantic(semantic_name, WINED3DDECLUSAGE_COLOR))
|
||||
{
|
||||
TRACE("o%u is result.color.?, idx %u\n", i, shader->output_signature[i].semantic_idx);
|
||||
if(shader->output_signature[i].semantic_idx == 0) priv_ctx->vs_output[i] = "result.color.primary";
|
||||
else if(shader->output_signature[i].semantic_idx == 1) priv_ctx->vs_output[i] = "result.color.secondary";
|
||||
TRACE("o%u is result.color.?, idx %u\n", i, baseshader->output_signature[i].semantic_idx);
|
||||
if (baseshader->output_signature[i].semantic_idx == 0)
|
||||
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 if(shader_match_semantic(semantic_name, WINED3DDECLUSAGE_TEXCOORD))
|
||||
{
|
||||
TRACE("o%u is %s\n", i, texcoords[shader->output_signature[i].semantic_idx]);
|
||||
if(shader->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];
|
||||
TRACE("o%u is %s\n", i, texcoords[baseshader->output_signature[i].semantic_idx]);
|
||||
if (baseshader->output_signature[i].semantic_idx >= 8) priv_ctx->vs_output[i] = "TA";
|
||||
else priv_ctx->vs_output[i] = texcoords[baseshader->output_signature[i].semantic_idx];
|
||||
}
|
||||
else if(shader_match_semantic(semantic_name, WINED3DDECLUSAGE_FOG))
|
||||
{
|
||||
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
|
||||
|
@ -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.
|
||||
* 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");
|
||||
|
||||
/* 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
|
|||
}
|
||||
|
||||
/* 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 */
|
||||
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)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if(shader_match_semantic(semantic_name, WINED3DDECLUSAGE_POSITION) &&
|
||||
shader->output_signature[i].semantic_idx == 0)
|
||||
if (shader_match_semantic(semantic_name, WINED3DDECLUSAGE_POSITION)
|
||||
&& baseshader->output_signature[i].semantic_idx == 0)
|
||||
{
|
||||
priv_ctx->vs_output[i] = "TMP_OUT";
|
||||
continue;
|
||||
}
|
||||
else if(shader_match_semantic(semantic_name, WINED3DDECLUSAGE_PSIZE) &&
|
||||
shader->output_signature[i].semantic_idx == 0)
|
||||
else if (shader_match_semantic(semantic_name, WINED3DDECLUSAGE_PSIZE)
|
||||
&& baseshader->output_signature[i].semantic_idx == 0)
|
||||
{
|
||||
priv_ctx->vs_output[i] = "result.pointsize";
|
||||
continue;
|
||||
|
@ -3824,8 +3827,8 @@ static void init_output_registers(IWineD3DVertexShaderImpl *shader, DWORD sig_nu
|
|||
continue;
|
||||
}
|
||||
|
||||
if(strcmp(sig[j].semantic_name, semantic_name) == 0 &&
|
||||
sig[j].semantic_idx == shader->output_signature[i].semantic_idx)
|
||||
if (strcmp(sig[j].semantic_name, semantic_name) == 0
|
||||
&& sig[j].semantic_idx == baseshader->output_signature[i].semantic_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 *
|
|||
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;
|
||||
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;
|
||||
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
|
|||
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 */
|
||||
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);
|
||||
for (i = 0; map; map >>= 1, ++i)
|
||||
|
@ -3658,7 +3658,7 @@ static GLhandleARB generate_param_reorder_function(struct wined3d_shader_buffer
|
|||
} else if(ps_major >= 3 && vs_major >= 3) {
|
||||
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 */
|
||||
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
|
|||
}
|
||||
|
||||
/* 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);
|
||||
|
||||
shader_addline(buffer, "}\n");
|
||||
|
@ -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
|
||||
* 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);
|
||||
shader_addline(buffer, "}\n");
|
||||
} else {
|
||||
|
@ -3766,7 +3766,8 @@ static GLuint shader_glsl_generate_pshader(const struct wined3d_context *context
|
|||
/* Pack 3.0 inputs */
|
||||
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 */
|
||||
|
|
|
@ -318,7 +318,7 @@ static HRESULT vertexshader_set_function(IWineD3DVertexShaderImpl *shader,
|
|||
shader->min_rel_offset = device->d3d_vshader_constantF;
|
||||
shader->max_rel_offset = 0;
|
||||
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);
|
||||
if (FAILED(hr)) return hr;
|
||||
|
||||
|
@ -328,8 +328,9 @@ static HRESULT vertexshader_set_function(IWineD3DVertexShaderImpl *shader,
|
|||
{
|
||||
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_idx = shader->input_signature[i].semantic_idx;
|
||||
shader->attributes[i].usage =
|
||||
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)
|
||||
|
@ -338,7 +339,7 @@ static HRESULT vertexshader_set_function(IWineD3DVertexShaderImpl *shader,
|
|||
{
|
||||
struct wined3d_shader_signature_element *e = &output_signature->elements[i];
|
||||
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,
|
|||
|
||||
/* Second pass: figure out which registers are used, what the semantics are, etc.. */
|
||||
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);
|
||||
if (FAILED(hr)) return hr;
|
||||
|
||||
|
|
|
@ -2621,6 +2621,9 @@ typedef struct IWineD3DBaseShaderClass
|
|||
struct list constantsI;
|
||||
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 */
|
||||
IWineD3DDevice *device;
|
||||
struct list shader_list_entry;
|
||||
|
@ -2729,10 +2732,8 @@ typedef struct IWineD3DVertexShaderImpl {
|
|||
/* IWineD3DBaseShader */
|
||||
IWineD3DBaseShaderClass baseShader;
|
||||
|
||||
/* Vertex shader input and output semantics */
|
||||
/* Vertex shader attributes. */
|
||||
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 rel_offset;
|
||||
|
@ -2773,7 +2774,6 @@ typedef struct IWineD3DPixelShaderImpl {
|
|||
IWineD3DBaseShaderClass baseShader;
|
||||
|
||||
/* Pixel shader input semantics */
|
||||
struct wined3d_shader_signature_element input_signature[MAX_REG_INPUT];
|
||||
DWORD input_reg_map[MAX_REG_INPUT];
|
||||
BOOL input_reg_used[MAX_REG_INPUT];
|
||||
unsigned int declared_in_count;
|
||||
|
|
Loading…
Reference in New Issue