d3d10core: Add a separate function for d3d10_input_layout initialization.

This commit is contained in:
Henri Verbeet 2009-09-23 10:05:48 +02:00 committed by Alexandre Julliard
parent 4a5ecb3236
commit cc68900d86
3 changed files with 40 additions and 18 deletions

View File

@ -119,7 +119,6 @@ struct d3d10_rendertarget_view
};
/* ID3D10InputLayout */
extern const struct ID3D10InputLayoutVtbl d3d10_input_layout_vtbl DECLSPEC_HIDDEN;
struct d3d10_input_layout
{
const struct ID3D10InputLayoutVtbl *vtbl;
@ -128,9 +127,9 @@ struct d3d10_input_layout
IWineD3DVertexDeclaration *wined3d_decl;
};
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) DECLSPEC_HIDDEN;
HRESULT d3d10_input_layout_init(struct d3d10_input_layout *layout, struct d3d10_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;
/* ID3D10VertexShader */
extern const struct ID3D10VertexShaderVtbl d3d10_vertex_shader_vtbl DECLSPEC_HIDDEN;

View File

@ -901,8 +901,6 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateInputLayout(ID3D10Device *if
{
struct d3d10_device *This = (struct d3d10_device *)iface;
struct d3d10_input_layout *object;
WINED3DVERTEXELEMENT *wined3d_elements;
UINT wined3d_element_count;
HRESULT hr;
TRACE("iface %p, element_descs %p, element_count %u, shader_byte_code %p,"
@ -917,22 +915,16 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateInputLayout(ID3D10Device *if
return E_OUTOFMEMORY;
}
object->vtbl = &d3d10_input_layout_vtbl;
object->refcount = 1;
hr = d3d10_input_layout_to_wined3d_declaration(element_descs, element_count,
shader_byte_code, shader_byte_code_length, &wined3d_elements, &wined3d_element_count);
hr = d3d10_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);
return hr;
}
IWineD3DDevice_CreateVertexDeclaration(This->wined3d_device, &object->wined3d_decl,
(IUnknown *)object, wined3d_elements, wined3d_element_count);
HeapFree(GetProcessHeap(), 0, wined3d_elements);
TRACE("Created input layout %p.\n", object);
*input_layout = (ID3D10InputLayout *)object;
return S_OK;

View File

@ -39,7 +39,7 @@ static HRESULT isgn_handler(const char *data, DWORD data_size, DWORD tag, void *
}
}
HRESULT d3d10_input_layout_to_wined3d_declaration(const D3D10_INPUT_ELEMENT_DESC *element_descs,
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)
{
@ -181,7 +181,7 @@ static HRESULT STDMETHODCALLTYPE d3d10_input_layout_SetPrivateDataInterface(ID3D
return E_NOTIMPL;
}
const struct ID3D10InputLayoutVtbl d3d10_input_layout_vtbl =
static const struct ID3D10InputLayoutVtbl d3d10_input_layout_vtbl =
{
/* IUnknown methods */
d3d10_input_layout_QueryInterface,
@ -193,3 +193,34 @@ const struct ID3D10InputLayoutVtbl d3d10_input_layout_vtbl =
d3d10_input_layout_SetPrivateData,
d3d10_input_layout_SetPrivateDataInterface,
};
HRESULT d3d10_input_layout_init(struct d3d10_input_layout *layout, struct d3d10_device *device,
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;
HRESULT hr;
layout->vtbl = &d3d10_input_layout_vtbl;
layout->refcount = 1;
hr = d3d10_input_layout_to_wined3d_declaration(element_descs, element_count,
shader_byte_code, shader_byte_code_length, &wined3d_elements, &wined3d_element_count);
if (FAILED(hr))
{
WARN("Failed to create wined3d vertex declaration elements, hr %#x.\n", hr);
return hr;
}
hr = IWineD3DDevice_CreateVertexDeclaration(device->wined3d_device, &layout->wined3d_decl,
(IUnknown *)layout, wined3d_elements, wined3d_element_count);
HeapFree(GetProcessHeap(), 0, wined3d_elements);
if (FAILED(hr))
{
WARN("Failed to create wined3d vertex declaration, hr %#x.\n", hr);
return hr;
}
return S_OK;
}