dplayx: Adjust GetCaps behaviour to documentation
[wine/gsoc_dplay.git] / dlls / d3d10core / inputlayout.c
blobf6f50bc26a9e5914fecbad115647da22b885fbaa
1 /*
2 * Copyright 2009 Henri Verbeet for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include "config.h"
21 #include "wine/port.h"
23 #include "d3d10core_private.h"
25 WINE_DEFAULT_DEBUG_CHANNEL(d3d10core);
27 static HRESULT isgn_handler(const char *data, DWORD data_size, DWORD tag, void *ctx)
29 struct wined3d_shader_signature *is = ctx;
30 char tag_str[5];
32 switch(tag)
34 case TAG_ISGN:
35 return shader_parse_signature(data, data_size, is);
37 default:
38 memcpy(tag_str, &tag, 4);
39 tag_str[4] = '\0';
40 FIXME("Unhandled chunk %s\n", tag_str);
41 return S_OK;
45 HRESULT d3d10_input_layout_to_wined3d_declaration(const D3D10_INPUT_ELEMENT_DESC *element_descs,
46 UINT element_count, const void *shader_byte_code, SIZE_T shader_byte_code_length,
47 WINED3DVERTEXELEMENT **wined3d_elements, UINT *wined3d_element_count)
49 struct wined3d_shader_signature is;
50 HRESULT hr;
51 UINT i;
53 hr = parse_dxbc(shader_byte_code, shader_byte_code_length, isgn_handler, &is);
54 if (FAILED(hr))
56 ERR("Failed to parse input signature.\n");
57 return E_FAIL;
60 *wined3d_elements = HeapAlloc(GetProcessHeap(), 0, element_count * sizeof(**wined3d_elements));
61 if (!*wined3d_elements)
63 ERR("Failed to allocate wined3d vertex element array memory.\n");
64 HeapFree(GetProcessHeap(), 0, is.elements);
65 return E_OUTOFMEMORY;
67 *wined3d_element_count = 0;
69 for (i = 0; i < element_count; ++i)
71 UINT j;
73 for (j = 0; j < is.element_count; ++j)
75 if (!strcmp(element_descs[i].SemanticName, is.elements[j].semantic_name)
76 && element_descs[i].SemanticIndex == is.elements[j].semantic_idx)
78 WINED3DVERTEXELEMENT *e = &(*wined3d_elements)[(*wined3d_element_count)++];
79 const D3D10_INPUT_ELEMENT_DESC *f = &element_descs[i];
81 e->format = wined3dformat_from_dxgi_format(f->Format);
82 e->input_slot = f->InputSlot;
83 e->offset = f->AlignedByteOffset;
84 e->output_slot = is.elements[j].register_idx;
85 e->method = WINED3DDECLMETHOD_DEFAULT;
86 e->usage = 0;
87 e->usage_idx = 0;
89 if (f->AlignedByteOffset == D3D10_APPEND_ALIGNED_ELEMENT)
90 FIXME("D3D10_APPEND_ALIGNED_ELEMENT not supported\n");
91 if (f->InputSlotClass != D3D10_INPUT_PER_VERTEX_DATA)
92 FIXME("Ignoring input slot class (%#x)\n", f->InputSlotClass);
93 if (f->InstanceDataStepRate)
94 FIXME("Ignoring instace data step rate (%#x)\n", f->InstanceDataStepRate);
96 break;
101 shader_free_signature(&is);
103 return S_OK;
106 /* IUnknown methods */
108 static HRESULT STDMETHODCALLTYPE d3d10_input_layout_QueryInterface(ID3D10InputLayout *iface,
109 REFIID riid, void **object)
111 TRACE("iface %p, riid %s, object %p\n", iface, debugstr_guid(riid), object);
113 if (IsEqualGUID(riid, &IID_ID3D10InputLayout)
114 || IsEqualGUID(riid, &IID_ID3D10DeviceChild)
115 || IsEqualGUID(riid, &IID_IUnknown))
117 IUnknown_AddRef(iface);
118 *object = iface;
119 return S_OK;
122 WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid));
124 *object = NULL;
125 return E_NOINTERFACE;
128 static ULONG STDMETHODCALLTYPE d3d10_input_layout_AddRef(ID3D10InputLayout *iface)
130 struct d3d10_input_layout *This = (struct d3d10_input_layout *)iface;
131 ULONG refcount = InterlockedIncrement(&This->refcount);
133 TRACE("%p increasing refcount to %u\n", This, refcount);
135 return refcount;
138 static ULONG STDMETHODCALLTYPE d3d10_input_layout_Release(ID3D10InputLayout *iface)
140 struct d3d10_input_layout *This = (struct d3d10_input_layout *)iface;
141 ULONG refcount = InterlockedDecrement(&This->refcount);
143 TRACE("%p decreasing refcount to %u\n", This, refcount);
145 if (!refcount)
147 IWineD3DVertexDeclaration_Release(This->wined3d_decl);
148 HeapFree(GetProcessHeap(), 0, This);
151 return refcount;
154 /* ID3D10DeviceChild methods */
156 static void STDMETHODCALLTYPE d3d10_input_layout_GetDevice(ID3D10InputLayout *iface, ID3D10Device **device)
158 FIXME("iface %p, device %p stub!\n", iface, device);
161 static HRESULT STDMETHODCALLTYPE d3d10_input_layout_GetPrivateData(ID3D10InputLayout *iface,
162 REFGUID guid, UINT *data_size, void *data)
164 FIXME("iface %p, guid %s, data_size %p, data %p stub!\n",
165 iface, debugstr_guid(guid), data_size, data);
167 return E_NOTIMPL;
170 static HRESULT STDMETHODCALLTYPE d3d10_input_layout_SetPrivateData(ID3D10InputLayout *iface,
171 REFGUID guid, UINT data_size, const void *data)
173 FIXME("iface %p, guid %s, data_size %u, data %p stub!\n",
174 iface, debugstr_guid(guid), data_size, data);
176 return E_NOTIMPL;
179 static HRESULT STDMETHODCALLTYPE d3d10_input_layout_SetPrivateDataInterface(ID3D10InputLayout *iface,
180 REFGUID guid, const IUnknown *data)
182 FIXME("iface %p, guid %s, data %p stub!\n", iface, debugstr_guid(guid), data);
184 return E_NOTIMPL;
187 const struct ID3D10InputLayoutVtbl d3d10_input_layout_vtbl =
189 /* IUnknown methods */
190 d3d10_input_layout_QueryInterface,
191 d3d10_input_layout_AddRef,
192 d3d10_input_layout_Release,
193 /* ID3D10DeviceChild methods */
194 d3d10_input_layout_GetDevice,
195 d3d10_input_layout_GetPrivateData,
196 d3d10_input_layout_SetPrivateData,
197 d3d10_input_layout_SetPrivateDataInterface,