From 1cb181668ee991c0e17c116b5c16880ea18393b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zef=20Kucia?= Date: Tue, 15 Sep 2015 01:37:44 +0200 Subject: [PATCH] d3d11: Implement d3d11_device_CreateInputLayout(). --- dlls/d3d11/d3d11_private.h | 7 ++++--- dlls/d3d11/device.c | 32 ++++++++++++++++---------------- dlls/d3d11/inputlayout.c | 36 +++++++++++++++++++++++++++++++----- 3 files changed, 51 insertions(+), 24 deletions(-) diff --git a/dlls/d3d11/d3d11_private.h b/dlls/d3d11/d3d11_private.h index 5dfdc296d63..303fa6d5ed0 100644 --- a/dlls/d3d11/d3d11_private.h +++ b/dlls/d3d11/d3d11_private.h @@ -218,9 +218,10 @@ struct d3d_input_layout struct wined3d_vertex_declaration *wined3d_decl; }; -HRESULT d3d_input_layout_init(struct d3d_input_layout *layout, struct d3d_device *device, - const D3D10_INPUT_ELEMENT_DESC *element_descs, UINT element_count, - const void *shader_byte_code, SIZE_T shader_byte_code_length) DECLSPEC_HIDDEN; +HRESULT d3d_input_layout_create(struct d3d_device *device, + const D3D11_INPUT_ELEMENT_DESC *element_descs, UINT element_count, + const void *shader_byte_code, SIZE_T shader_byte_code_length, + struct d3d_input_layout **layout) DECLSPEC_HIDDEN; struct d3d_input_layout *unsafe_impl_from_ID3D10InputLayout(ID3D10InputLayout *iface) DECLSPEC_HIDDEN; /* ID3D10VertexShader */ diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c index d0468e2312f..65524d30f52 100644 --- a/dlls/d3d11/device.c +++ b/dlls/d3d11/device.c @@ -179,11 +179,21 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_CreateInputLayout(ID3D11Device *if const D3D11_INPUT_ELEMENT_DESC *element_descs, UINT element_count, const void *shader_byte_code, SIZE_T shader_byte_code_length, ID3D11InputLayout **input_layout) { - FIXME("iface %p, element_descs %p, element_count %u, shader_byte_code %p, shader_byte_code_length %lu, " - "input_layout %p stub!\n", iface, element_descs, element_count, shader_byte_code, + struct d3d_device *device = impl_from_ID3D11Device(iface); + struct d3d_input_layout *object; + HRESULT hr; + + TRACE("iface %p, element_descs %p, element_count %u, shader_byte_code %p, shader_byte_code_length %lu, " + "input_layout %p.\n", iface, element_descs, element_count, shader_byte_code, shader_byte_code_length, input_layout); - return E_NOTIMPL; + if (FAILED(hr = d3d_input_layout_create(device, element_descs, element_count, + shader_byte_code, shader_byte_code_length, &object))) + return hr; + + *input_layout = &object->ID3D11InputLayout_iface; + + return S_OK; } static HRESULT STDMETHODCALLTYPE d3d11_device_CreateVertexShader(ID3D11Device *iface, const void *byte_code, @@ -2206,7 +2216,7 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateInputLayout(ID3D10Device1 *i const void *shader_byte_code, SIZE_T shader_byte_code_length, ID3D10InputLayout **input_layout) { - struct d3d_device *This = impl_from_ID3D10Device(iface); + struct d3d_device *device = impl_from_ID3D10Device(iface); struct d3d_input_layout *object; HRESULT hr; @@ -2215,20 +2225,10 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateInputLayout(ID3D10Device1 *i iface, element_descs, element_count, shader_byte_code, shader_byte_code_length, input_layout); - object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); - if (!object) - return E_OUTOFMEMORY; - - hr = d3d_input_layout_init(object, This, element_descs, element_count, - shader_byte_code, shader_byte_code_length); - if (FAILED(hr)) - { - WARN("Failed to initialize input layout, hr %#x.\n", hr); - HeapFree(GetProcessHeap(), 0, object); + if (FAILED(hr = d3d_input_layout_create(device, (const D3D11_INPUT_ELEMENT_DESC *)element_descs, element_count, + shader_byte_code, shader_byte_code_length, &object))) return hr; - } - TRACE("Created input layout %p.\n", object); *input_layout = &object->ID3D10InputLayout_iface; return S_OK; diff --git a/dlls/d3d11/inputlayout.c b/dlls/d3d11/inputlayout.c index 68b8b6fbb7e..bb98d300378 100644 --- a/dlls/d3d11/inputlayout.c +++ b/dlls/d3d11/inputlayout.c @@ -39,7 +39,7 @@ static HRESULT isgn_handler(const char *data, DWORD data_size, DWORD tag, void * } } -static HRESULT d3d10_input_layout_to_wined3d_declaration(const D3D10_INPUT_ELEMENT_DESC *element_descs, +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) { @@ -65,7 +65,7 @@ static HRESULT d3d10_input_layout_to_wined3d_declaration(const D3D10_INPUT_ELEME for (i = 0; i < element_count; ++i) { struct wined3d_vertex_element *e = &(*wined3d_elements)[i]; - const D3D10_INPUT_ELEMENT_DESC *f = &element_descs[i]; + const D3D11_INPUT_ELEMENT_DESC *f = &element_descs[i]; UINT j; e->format = wined3dformat_from_dxgi_format(f->Format); @@ -316,8 +316,8 @@ static const struct wined3d_parent_ops d3d_input_layout_wined3d_parent_ops = d3d_input_layout_wined3d_object_destroyed, }; -HRESULT d3d_input_layout_init(struct d3d_input_layout *layout, struct d3d_device *device, - const D3D10_INPUT_ELEMENT_DESC *element_descs, UINT element_count, +static HRESULT d3d_input_layout_init(struct d3d_input_layout *layout, struct d3d_device *device, + 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; @@ -329,7 +329,7 @@ HRESULT d3d_input_layout_init(struct d3d_input_layout *layout, struct d3d_device wined3d_mutex_lock(); wined3d_private_store_init(&layout->private_store); - if (FAILED(hr = d3d10_input_layout_to_wined3d_declaration(element_descs, element_count, + if (FAILED(hr = d3d11_input_layout_to_wined3d_declaration(element_descs, element_count, shader_byte_code, shader_byte_code_length, &wined3d_elements))) { WARN("Failed to create wined3d vertex declaration elements, hr %#x.\n", hr); @@ -353,6 +353,32 @@ HRESULT d3d_input_layout_init(struct d3d_input_layout *layout, struct d3d_device return S_OK; } +HRESULT d3d_input_layout_create(struct d3d_device *device, + const D3D11_INPUT_ELEMENT_DESC *element_descs, UINT element_count, + const void *shader_byte_code, SIZE_T shader_byte_code_length, + struct d3d_input_layout **layout) +{ + struct d3d_input_layout *object; + HRESULT hr; + + object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); + if (!object) + return E_OUTOFMEMORY; + + if (FAILED(hr = d3d_input_layout_init(object, device, element_descs, element_count, + shader_byte_code, shader_byte_code_length))) + { + WARN("Failed to initialize input layout, hr %#x.\n", hr); + HeapFree(GetProcessHeap(), 0, object); + return hr; + } + + TRACE("Created input layout %p.\n", object); + *layout = object; + + return S_OK; +} + struct d3d_input_layout *unsafe_impl_from_ID3D10InputLayout(ID3D10InputLayout *iface) { if (!iface)