d3d11: Factor out shader_find_signature_element() function.

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Józef Kucia 2017-03-23 12:15:49 +01:00 committed by Alexandre Julliard
parent 5bf5655bfd
commit 7583bcfc22
3 changed files with 21 additions and 12 deletions

View File

@ -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 */

View File

@ -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);
}

View File

@ -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);