Commit 7583bcfc authored by Józef Kucia's avatar Józef Kucia Committed by Alexandre Julliard

d3d11: Factor out shader_find_signature_element() function.

parent 5bf5655b
......@@ -353,6 +353,8 @@ HRESULT d3d11_compute_shader_create(struct d3d_device *device, const void *byte_
struct d3d11_compute_shader *unsafe_impl_from_ID3D11ComputeShader(ID3D11ComputeShader *iface) DECLSPEC_HIDDEN;
HRESULT shader_parse_signature(const char *data, DWORD data_size, struct wined3d_shader_signature *s) DECLSPEC_HIDDEN;
struct wined3d_shader_signature_element *shader_find_signature_element(const struct wined3d_shader_signature *s,
const char *semantic_name, unsigned int semantic_idx) DECLSPEC_HIDDEN;
void shader_free_signature(struct wined3d_shader_signature *s) DECLSPEC_HIDDEN;
/* ID3D11ClassLinkage */
......
......@@ -65,7 +65,7 @@ static HRESULT d3d11_input_layout_to_wined3d_declaration(const D3D11_INPUT_ELEME
{
struct wined3d_vertex_element *e = &(*wined3d_elements)[i];
const D3D11_INPUT_ELEMENT_DESC *f = &element_descs[i];
unsigned int j;
struct wined3d_shader_signature_element *element;
e->format = wined3dformat_from_dxgi_format(f->Format);
e->input_slot = f->InputSlot;
......@@ -77,17 +77,9 @@ static HRESULT d3d11_input_layout_to_wined3d_declaration(const D3D11_INPUT_ELEME
e->usage = 0;
e->usage_idx = 0;
for (j = 0; j < is.element_count; ++j)
{
if (!strcasecmp(element_descs[i].SemanticName, is.elements[j].semantic_name)
&& element_descs[i].SemanticIndex == is.elements[j].semantic_idx)
{
e->output_slot = is.elements[j].register_idx;
break;
}
}
if (e->output_slot == WINED3D_OUTPUT_SLOT_UNUSED)
if ((element = shader_find_signature_element(&is, f->SemanticName, f->SemanticIndex)))
e->output_slot = element->register_idx;
else
WARN("Unused input element %u.\n", i);
}
......
......@@ -226,6 +226,21 @@ HRESULT shader_parse_signature(const char *data, DWORD data_size, struct wined3d
return S_OK;
}
struct wined3d_shader_signature_element *shader_find_signature_element(const struct wined3d_shader_signature *s,
const char *semantic_name, unsigned int semantic_idx)
{
struct wined3d_shader_signature_element *e = s->elements;
unsigned int i;
for (i = 0; i < s->element_count; ++i)
{
if (!strcasecmp(e[i].semantic_name, semantic_name) && e[i].semantic_idx == semantic_idx)
return &e[i];
}
return NULL;
}
void shader_free_signature(struct wined3d_shader_signature *s)
{
HeapFree(GetProcessHeap(), 0, s->elements);
......
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