static HRESULT d3d10_input_layout_to_wined3d_declaration(const D3D10_INPUT_ELEMENT_DESC *element_descs, UINT element_count, const void *shader_byte_code, SIZE_T shader_byte_code_length, WINED3DVERTEXELEMENT **wined3d_elements, UINT *wined3d_element_count) { struct wined3d_shader_signature is; HRESULT hr; UINT i; hr = parse_dxbc(shader_byte_code, shader_byte_code_length, isgn_handler, &is); if (FAILED(hr)) { ERR("Failed to parse input signature.\n"); return E_FAIL; } *wined3d_elements = HeapAlloc(GetProcessHeap(), 0, element_count * sizeof(**wined3d_elements)); if (!*wined3d_elements) { ERR("Failed to allocate wined3d vertex element array memory.\n"); HeapFree(GetProcessHeap(), 0, is.elements); return E_OUTOFMEMORY; } *wined3d_element_count = 0; for (i = 0; i < element_count; ++i) { UINT j; for (j = 0; j < is.element_count; ++j) { if (!strcmp(element_descs[i].SemanticName, is.elements[j].semantic_name) && element_descs[i].SemanticIndex == is.elements[j].semantic_idx) { WINED3DVERTEXELEMENT *e = &(*wined3d_elements)[(*wined3d_element_count)++]; const D3D10_INPUT_ELEMENT_DESC *f = &element_descs[i]; e->format = wined3dformat_from_dxgi_format(f->Format); e->input_slot = f->InputSlot; e->offset = f->AlignedByteOffset; e->output_slot = is.elements[j].register_idx; e->method = WINED3DDECLMETHOD_DEFAULT; e->usage = 0; e->usage_idx = 0; if (f->AlignedByteOffset == D3D10_APPEND_ALIGNED_ELEMENT) FIXME("D3D10_APPEND_ALIGNED_ELEMENT not supported\n"); if (f->InputSlotClass != D3D10_INPUT_PER_VERTEX_DATA) FIXME("Ignoring input slot class (%#x)\n", f->InputSlotClass); if (f->InstanceDataStepRate) FIXME("Ignoring instace data step rate (%#x)\n", f->InstanceDataStepRate); break; } } } shader_free_signature(&is); return S_OK; }
static HRESULT d3d11_input_layout_to_wined3d_declaration(const D3D11_INPUT_ELEMENT_DESC *element_descs, UINT element_count, const void *shader_byte_code, SIZE_T shader_byte_code_length, struct wined3d_vertex_element **wined3d_elements) { struct wined3d_shader_signature is; unsigned int i; HRESULT hr; if (FAILED(hr = parse_dxbc(shader_byte_code, shader_byte_code_length, isgn_handler, &is))) { ERR("Failed to parse input signature.\n"); return E_FAIL; } if (!(*wined3d_elements = d3d11_calloc(element_count, sizeof(**wined3d_elements)))) { ERR("Failed to allocate wined3d vertex element array memory.\n"); HeapFree(GetProcessHeap(), 0, is.elements); return E_OUTOFMEMORY; } for (i = 0; i < element_count; ++i) { struct wined3d_vertex_element *e = &(*wined3d_elements)[i]; const D3D11_INPUT_ELEMENT_DESC *f = &element_descs[i]; unsigned int j; e->format = wined3dformat_from_dxgi_format(f->Format); e->input_slot = f->InputSlot; e->offset = f->AlignedByteOffset; e->output_slot = WINED3D_OUTPUT_SLOT_UNUSED; e->input_slot_class = f->InputSlotClass; e->instance_data_step_rate = f->InstanceDataStepRate; e->method = WINED3D_DECL_METHOD_DEFAULT; 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) WARN("Unused input element %u.\n", i); } shader_free_signature(&is); return S_OK; }
static HRESULT shader_extract_from_dxbc(const void *dxbc, SIZE_T dxbc_length, struct d3d10_shader_info *shader_info) { HRESULT hr; shader_info->shader_code = NULL; memset(shader_info->output_signature, 0, sizeof(*shader_info->output_signature)); hr = parse_dxbc(dxbc, dxbc_length, shdr_handler, shader_info); if (!shader_info->shader_code) hr = E_INVALIDARG; if (FAILED(hr)) { ERR("Failed to parse shader, hr %#x\n", hr); shader_free_signature(shader_info->output_signature); } return hr; }