2 * Copyright 2009 Henri Verbeet for CodeWeavers
3 * Copyright 2010 Rico Schüller
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "wine/port.h"
24 #include "d3dcompiler_private.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(d3dcompiler);
28 enum D3DCOMPILER_SIGNATURE_ELEMENT_SIZE
30 D3DCOMPILER_SIGNATURE_ELEMENT_SIZE6 = 6,
31 D3DCOMPILER_SIGNATURE_ELEMENT_SIZE7 = 7,
34 const struct ID3D11ShaderReflectionConstantBufferVtbl d3dcompiler_shader_reflection_constant_buffer_vtbl;
35 const struct ID3D11ShaderReflectionVariableVtbl d3dcompiler_shader_reflection_variable_vtbl;
36 const struct ID3D11ShaderReflectionTypeVtbl d3dcompiler_shader_reflection_type_vtbl;
38 /* null objects - needed for invalid calls */
39 static struct d3dcompiler_shader_reflection_constant_buffer null_constant_buffer = {{&d3dcompiler_shader_reflection_constant_buffer_vtbl}};
40 static struct d3dcompiler_shader_reflection_type null_type = {{&d3dcompiler_shader_reflection_type_vtbl}};
41 static struct d3dcompiler_shader_reflection_variable null_variable = {{&d3dcompiler_shader_reflection_variable_vtbl},
42 &null_constant_buffer, &null_type};
44 static BOOL copy_name(const char *ptr, char **name)
48 if (!ptr) return TRUE;
50 name_len = strlen(ptr) + 1;
56 *name = HeapAlloc(GetProcessHeap(), 0, name_len);
59 ERR("Failed to allocate name memory.\n");
63 memcpy(*name, ptr, name_len);
68 static BOOL copy_value(const char *ptr, void **value, DWORD size)
70 if (!ptr || !size) return TRUE;
72 *value = HeapAlloc(GetProcessHeap(), 0, size);
75 ERR("Failed to allocate vlaue memory.\n");
79 memcpy(*value, ptr, size);
84 void *d3dcompiler_rb_alloc(size_t size)
86 return HeapAlloc(GetProcessHeap(), 0, size);
89 void *d3dcompiler_rb_realloc(void *ptr, size_t size)
91 return HeapReAlloc(GetProcessHeap(), 0, ptr, size);
94 void d3dcompiler_rb_free(void *ptr)
96 HeapFree(GetProcessHeap(), 0, ptr);
99 static int d3dcompiler_shader_reflection_type_compare(const void *key, const struct wine_rb_entry *entry)
101 const struct d3dcompiler_shader_reflection_type *t = WINE_RB_ENTRY_VALUE(entry, const struct d3dcompiler_shader_reflection_type, entry);
102 const DWORD *id = key;
107 static void d3dcompiler_shader_reflection_type_destroy(struct wine_rb_entry *entry, void *context)
109 struct d3dcompiler_shader_reflection_type *t = WINE_RB_ENTRY_VALUE(entry, struct d3dcompiler_shader_reflection_type, entry);
111 TRACE("reflection type %p.\n", t);
113 HeapFree(GetProcessHeap(), 0, t);
116 static const struct wine_rb_functions d3dcompiler_shader_reflection_type_rb_functions =
118 d3dcompiler_rb_alloc,
119 d3dcompiler_rb_realloc,
121 d3dcompiler_shader_reflection_type_compare,
124 static void free_signature(struct d3dcompiler_shader_signature *sig)
126 TRACE("Free signature %p\n", sig);
128 HeapFree(GetProcessHeap(), 0, sig->elements);
129 HeapFree(GetProcessHeap(), 0, sig->string_data);
132 static void free_variable(struct d3dcompiler_shader_reflection_variable *var)
136 HeapFree(GetProcessHeap(), 0, var->name);
137 HeapFree(GetProcessHeap(), 0, var->default_value);
141 static void free_constant_buffer(struct d3dcompiler_shader_reflection_constant_buffer *cb)
147 for (i = 0; i < cb->variable_count; ++i)
149 free_variable(&cb->variables[i]);
151 HeapFree(GetProcessHeap(), 0, cb->variables);
154 HeapFree(GetProcessHeap(), 0, cb->name);
157 static void reflection_cleanup(struct d3dcompiler_shader_reflection *ref)
159 TRACE("Cleanup %p\n", ref);
163 free_signature(ref->isgn);
164 HeapFree(GetProcessHeap(), 0, ref->isgn);
169 free_signature(ref->osgn);
170 HeapFree(GetProcessHeap(), 0, ref->osgn);
175 free_signature(ref->pcsg);
176 HeapFree(GetProcessHeap(), 0, ref->pcsg);
179 if (ref->constant_buffers)
183 for (i = 0; i < ref->constant_buffer_count; ++i)
185 free_constant_buffer(&ref->constant_buffers[i]);
189 wine_rb_destroy(&ref->types, d3dcompiler_shader_reflection_type_destroy, NULL);
190 HeapFree(GetProcessHeap(), 0, ref->constant_buffers);
191 HeapFree(GetProcessHeap(), 0, ref->bound_resources);
192 HeapFree(GetProcessHeap(), 0, ref->resource_string);
193 HeapFree(GetProcessHeap(), 0, ref->creator);
196 /* IUnknown methods */
198 static inline struct d3dcompiler_shader_reflection *impl_from_ID3D11ShaderReflection(ID3D11ShaderReflection *iface)
200 return CONTAINING_RECORD(iface, struct d3dcompiler_shader_reflection, ID3D11ShaderReflection_iface);
203 static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_QueryInterface(ID3D11ShaderReflection *iface, REFIID riid, void **object)
205 TRACE("iface %p, riid %s, object %p\n", iface, debugstr_guid(riid), object);
207 if (IsEqualGUID(riid, &IID_ID3D11ShaderReflection)
208 || IsEqualGUID(riid, &IID_IUnknown))
210 IUnknown_AddRef(iface);
215 WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid));
218 return E_NOINTERFACE;
221 static ULONG STDMETHODCALLTYPE d3dcompiler_shader_reflection_AddRef(ID3D11ShaderReflection *iface)
223 struct d3dcompiler_shader_reflection *This = impl_from_ID3D11ShaderReflection(iface);
224 ULONG refcount = InterlockedIncrement(&This->refcount);
226 TRACE("%p increasing refcount to %u\n", This, refcount);
231 static ULONG STDMETHODCALLTYPE d3dcompiler_shader_reflection_Release(ID3D11ShaderReflection *iface)
233 struct d3dcompiler_shader_reflection *This = impl_from_ID3D11ShaderReflection(iface);
234 ULONG refcount = InterlockedDecrement(&This->refcount);
236 TRACE("%p decreasing refcount to %u\n", This, refcount);
240 reflection_cleanup(This);
241 HeapFree(GetProcessHeap(), 0, This);
247 /* ID3D11ShaderReflection methods */
249 static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetDesc(ID3D11ShaderReflection *iface, D3D11_SHADER_DESC *desc)
251 struct d3dcompiler_shader_reflection *This = impl_from_ID3D11ShaderReflection(iface);
253 FIXME("iface %p, desc %p partial stub!\n", iface, desc);
257 WARN("Invalid argument specified\n");
261 desc->Version = This->version;
262 desc->Creator = This->creator;
263 desc->Flags = This->flags;
264 desc->ConstantBuffers = This->constant_buffer_count;
265 desc->BoundResources = This->bound_resource_count;
266 desc->InputParameters = This->isgn ? This->isgn->element_count : 0;
267 desc->OutputParameters = This->osgn ? This->osgn->element_count : 0;
268 desc->InstructionCount = This->instruction_count;
269 desc->TempRegisterCount = This->temp_register_count;
270 desc->TempArrayCount = This->temp_array_count;
272 desc->DclCount = This->dcl_count;
273 desc->TextureNormalInstructions = This->texture_normal_instructions;
274 desc->TextureLoadInstructions = This->texture_load_instructions;
275 desc->TextureCompInstructions = This->texture_comp_instructions;
276 desc->TextureBiasInstructions = This->texture_bias_instructions;
277 desc->TextureGradientInstructions = This->texture_gradient_instructions;
278 desc->FloatInstructionCount = This->float_instruction_count;
279 desc->IntInstructionCount = This->int_instruction_count;
280 desc->UintInstructionCount = This->uint_instruction_count;
281 desc->StaticFlowControlCount = This->static_flow_control_count;
282 desc->DynamicFlowControlCount = This->dynamic_flow_control_count;
283 desc->MacroInstructionCount = 0;
284 desc->ArrayInstructionCount = This->array_instruction_count;
285 desc->CutInstructionCount = This->cut_instruction_count;
286 desc->EmitInstructionCount = This->emit_instruction_count;
287 desc->GSOutputTopology = This->gs_output_topology;
288 desc->GSMaxOutputVertexCount = This->gs_max_output_vertex_count;
289 desc->InputPrimitive = This->input_primitive;
290 desc->PatchConstantParameters = This->pcsg ? This->pcsg->element_count : 0;
291 desc->cGSInstanceCount = 0;
292 desc->cControlPoints = This->c_control_points;
293 desc->HSOutputPrimitive = This->hs_output_primitive;
294 desc->HSPartitioning = This->hs_prtitioning;
295 desc->TessellatorDomain = This->tessellator_domain;
296 desc->cBarrierInstructions = 0;
297 desc->cInterlockedInstructions = 0;
298 desc->cTextureStoreInstructions = 0;
303 static struct ID3D11ShaderReflectionConstantBuffer * STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetConstantBufferByIndex(
304 ID3D11ShaderReflection *iface, UINT index)
306 struct d3dcompiler_shader_reflection *This = impl_from_ID3D11ShaderReflection(iface);
308 TRACE("iface %p, index %u\n", iface, index);
310 if (index >= This->constant_buffer_count)
312 WARN("Invalid argument specified\n");
313 return &null_constant_buffer.ID3D11ShaderReflectionConstantBuffer_iface;
316 return &This->constant_buffers[index].ID3D11ShaderReflectionConstantBuffer_iface;
319 static struct ID3D11ShaderReflectionConstantBuffer * STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetConstantBufferByName(
320 ID3D11ShaderReflection *iface, LPCSTR name)
322 struct d3dcompiler_shader_reflection *This = impl_from_ID3D11ShaderReflection(iface);
325 TRACE("iface %p, name %s\n", iface, debugstr_a(name));
329 WARN("Invalid argument specified\n");
330 return &null_constant_buffer.ID3D11ShaderReflectionConstantBuffer_iface;
333 for (i = 0; i < This->constant_buffer_count; ++i)
335 struct d3dcompiler_shader_reflection_constant_buffer *d = &This->constant_buffers[i];
337 if (!strcmp(d->name, name))
339 TRACE("Returning ID3D11ShaderReflectionConstantBuffer %p.\n", d);
340 return &d->ID3D11ShaderReflectionConstantBuffer_iface;
344 WARN("Invalid name specified\n");
346 return &null_constant_buffer.ID3D11ShaderReflectionConstantBuffer_iface;
349 static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetResourceBindingDesc(
350 ID3D11ShaderReflection *iface, UINT index, D3D11_SHADER_INPUT_BIND_DESC *desc)
352 struct d3dcompiler_shader_reflection *This = impl_from_ID3D11ShaderReflection(iface);
354 TRACE("iface %p, index %u, desc %p\n", iface, index, desc);
356 if (!desc || index >= This->bound_resource_count)
358 WARN("Invalid argument specified\n");
362 *desc = This->bound_resources[index];
367 static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetInputParameterDesc(
368 ID3D11ShaderReflection *iface, UINT index, D3D11_SIGNATURE_PARAMETER_DESC *desc)
370 struct d3dcompiler_shader_reflection *This = impl_from_ID3D11ShaderReflection(iface);
372 TRACE("iface %p, index %u, desc %p\n", iface, index, desc);
374 if (!desc || !This->isgn || index >= This->isgn->element_count)
376 WARN("Invalid argument specified\n");
380 *desc = This->isgn->elements[index];
385 static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetOutputParameterDesc(
386 ID3D11ShaderReflection *iface, UINT index, D3D11_SIGNATURE_PARAMETER_DESC *desc)
388 struct d3dcompiler_shader_reflection *This = impl_from_ID3D11ShaderReflection(iface);
390 TRACE("iface %p, index %u, desc %p\n", iface, index, desc);
392 if (!desc || !This->osgn || index >= This->osgn->element_count)
394 WARN("Invalid argument specified\n");
398 *desc = This->osgn->elements[index];
403 static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetPatchConstantParameterDesc(
404 ID3D11ShaderReflection *iface, UINT index, D3D11_SIGNATURE_PARAMETER_DESC *desc)
406 struct d3dcompiler_shader_reflection *This = impl_from_ID3D11ShaderReflection(iface);
408 TRACE("iface %p, index %u, desc %p\n", iface, index, desc);
410 if (!desc || !This->pcsg || index >= This->pcsg->element_count)
412 WARN("Invalid argument specified\n");
416 *desc = This->pcsg->elements[index];
421 static struct ID3D11ShaderReflectionVariable * STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetVariableByName(
422 ID3D11ShaderReflection *iface, LPCSTR name)
424 struct d3dcompiler_shader_reflection *This = impl_from_ID3D11ShaderReflection(iface);
427 TRACE("iface %p, name %s\n", iface, debugstr_a(name));
431 WARN("Invalid name specified\n");
432 return &null_variable.ID3D11ShaderReflectionVariable_iface;
435 for (i = 0; i < This->constant_buffer_count; ++i)
437 struct d3dcompiler_shader_reflection_constant_buffer *cb = &This->constant_buffers[i];
439 for (k = 0; k < cb->variable_count; ++k)
441 struct d3dcompiler_shader_reflection_variable *v = &cb->variables[k];
443 if (!strcmp(v->name, name))
445 TRACE("Returning ID3D11ShaderReflectionVariable %p.\n", v);
446 return &v->ID3D11ShaderReflectionVariable_iface;
451 WARN("Invalid name specified\n");
453 return &null_variable.ID3D11ShaderReflectionVariable_iface;
456 static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetResourceBindingDescByName(
457 ID3D11ShaderReflection *iface, LPCSTR name, D3D11_SHADER_INPUT_BIND_DESC *desc)
459 struct d3dcompiler_shader_reflection *This = impl_from_ID3D11ShaderReflection(iface);
462 TRACE("iface %p, name %s, desc %p\n", iface, debugstr_a(name), desc);
466 WARN("Invalid argument specified\n");
470 for (i = 0; i < This->bound_resource_count; ++i)
472 D3D11_SHADER_INPUT_BIND_DESC *d = &This->bound_resources[i];
474 if (!strcmp(d->Name, name))
476 TRACE("Returning D3D11_SHADER_INPUT_BIND_DESC %p.\n", d);
482 WARN("Invalid name specified\n");
487 static UINT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetMovInstructionCount(
488 ID3D11ShaderReflection *iface)
490 struct d3dcompiler_shader_reflection *This = impl_from_ID3D11ShaderReflection(iface);
492 TRACE("iface %p\n", iface);
494 return This->mov_instruction_count;
497 static UINT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetMovcInstructionCount(
498 ID3D11ShaderReflection *iface)
500 FIXME("iface %p stub!\n", iface);
505 static UINT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetConversionInstructionCount(
506 ID3D11ShaderReflection *iface)
508 struct d3dcompiler_shader_reflection *This = impl_from_ID3D11ShaderReflection(iface);
510 TRACE("iface %p\n", iface);
512 return This->conversion_instruction_count;
515 static UINT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetBitwiseInstructionCount(
516 ID3D11ShaderReflection *iface)
518 FIXME("iface %p stub!\n", iface);
523 static D3D_PRIMITIVE STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetGSInputPrimitive(
524 ID3D11ShaderReflection *iface)
526 FIXME("iface %p stub!\n", iface);
531 static BOOL STDMETHODCALLTYPE d3dcompiler_shader_reflection_IsSampleFrequencyShader(
532 ID3D11ShaderReflection *iface)
534 FIXME("iface %p stub!\n", iface);
539 static UINT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetNumInterfaceSlots(
540 ID3D11ShaderReflection *iface)
542 FIXME("iface %p stub!\n", iface);
547 static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetMinFeatureLevel(
548 ID3D11ShaderReflection *iface, D3D_FEATURE_LEVEL *level)
550 FIXME("iface %p, level %p stub!\n", iface, level);
555 static UINT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetThreadGroupSize(
556 ID3D11ShaderReflection *iface, UINT *sizex, UINT *sizey, UINT *sizez)
558 FIXME("iface %p, sizex %p, sizey %p, sizez %p stub!\n", iface, sizex, sizey, sizez);
563 const struct ID3D11ShaderReflectionVtbl d3dcompiler_shader_reflection_vtbl =
565 /* IUnknown methods */
566 d3dcompiler_shader_reflection_QueryInterface,
567 d3dcompiler_shader_reflection_AddRef,
568 d3dcompiler_shader_reflection_Release,
569 /* ID3D11ShaderReflection methods */
570 d3dcompiler_shader_reflection_GetDesc,
571 d3dcompiler_shader_reflection_GetConstantBufferByIndex,
572 d3dcompiler_shader_reflection_GetConstantBufferByName,
573 d3dcompiler_shader_reflection_GetResourceBindingDesc,
574 d3dcompiler_shader_reflection_GetInputParameterDesc,
575 d3dcompiler_shader_reflection_GetOutputParameterDesc,
576 d3dcompiler_shader_reflection_GetPatchConstantParameterDesc,
577 d3dcompiler_shader_reflection_GetVariableByName,
578 d3dcompiler_shader_reflection_GetResourceBindingDescByName,
579 d3dcompiler_shader_reflection_GetMovInstructionCount,
580 d3dcompiler_shader_reflection_GetMovcInstructionCount,
581 d3dcompiler_shader_reflection_GetConversionInstructionCount,
582 d3dcompiler_shader_reflection_GetBitwiseInstructionCount,
583 d3dcompiler_shader_reflection_GetGSInputPrimitive,
584 d3dcompiler_shader_reflection_IsSampleFrequencyShader,
585 d3dcompiler_shader_reflection_GetNumInterfaceSlots,
586 d3dcompiler_shader_reflection_GetMinFeatureLevel,
587 d3dcompiler_shader_reflection_GetThreadGroupSize,
590 /* ID3D11ShaderReflectionConstantBuffer methods */
592 static inline struct d3dcompiler_shader_reflection_constant_buffer *impl_from_ID3D11ShaderReflectionConstantBuffer(ID3D11ShaderReflectionConstantBuffer *iface)
594 return CONTAINING_RECORD(iface, struct d3dcompiler_shader_reflection_constant_buffer, ID3D11ShaderReflectionConstantBuffer_iface);
597 static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_constant_buffer_GetDesc(
598 ID3D11ShaderReflectionConstantBuffer *iface, D3D11_SHADER_BUFFER_DESC *desc)
600 struct d3dcompiler_shader_reflection_constant_buffer *This = impl_from_ID3D11ShaderReflectionConstantBuffer(iface);
602 TRACE("iface %p, desc %p\n", iface, desc);
604 if (This == &null_constant_buffer)
606 WARN("Null constant buffer specified\n");
612 WARN("Invalid argument specified\n");
616 desc->Name = This->name;
617 desc->Type = This->type;
618 desc->Variables = This->variable_count;
619 desc->Size = This->size;
620 desc->uFlags = This->flags;
625 static ID3D11ShaderReflectionVariable * STDMETHODCALLTYPE d3dcompiler_shader_reflection_constant_buffer_GetVariableByIndex(
626 ID3D11ShaderReflectionConstantBuffer *iface, UINT index)
628 struct d3dcompiler_shader_reflection_constant_buffer *This = impl_from_ID3D11ShaderReflectionConstantBuffer(iface);
630 TRACE("iface %p, index %u\n", iface, index);
632 if (index >= This->variable_count)
634 WARN("Invalid index specified\n");
635 return &null_variable.ID3D11ShaderReflectionVariable_iface;
638 return &This->variables[index].ID3D11ShaderReflectionVariable_iface;
641 static ID3D11ShaderReflectionVariable * STDMETHODCALLTYPE d3dcompiler_shader_reflection_constant_buffer_GetVariableByName(
642 ID3D11ShaderReflectionConstantBuffer *iface, LPCSTR name)
644 struct d3dcompiler_shader_reflection_constant_buffer *This = impl_from_ID3D11ShaderReflectionConstantBuffer(iface);
647 TRACE("iface %p, name %s\n", iface, debugstr_a(name));
651 WARN("Invalid argument specified\n");
652 return &null_variable.ID3D11ShaderReflectionVariable_iface;
655 for (i = 0; i < This->variable_count; ++i)
657 struct d3dcompiler_shader_reflection_variable *v = &This->variables[i];
659 if (!strcmp(v->name, name))
661 TRACE("Returning ID3D11ShaderReflectionVariable %p.\n", v);
662 return &v->ID3D11ShaderReflectionVariable_iface;
666 WARN("Invalid name specified\n");
668 return &null_variable.ID3D11ShaderReflectionVariable_iface;
671 const struct ID3D11ShaderReflectionConstantBufferVtbl d3dcompiler_shader_reflection_constant_buffer_vtbl =
673 /* ID3D11ShaderReflectionConstantBuffer methods */
674 d3dcompiler_shader_reflection_constant_buffer_GetDesc,
675 d3dcompiler_shader_reflection_constant_buffer_GetVariableByIndex,
676 d3dcompiler_shader_reflection_constant_buffer_GetVariableByName,
679 /* ID3D11ShaderReflectionVariable methods */
681 static inline struct d3dcompiler_shader_reflection_variable *impl_from_ID3D11ShaderReflectionVariable(ID3D11ShaderReflectionVariable *iface)
683 return CONTAINING_RECORD(iface, struct d3dcompiler_shader_reflection_variable, ID3D11ShaderReflectionVariable_iface);
686 static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_variable_GetDesc(
687 ID3D11ShaderReflectionVariable *iface, D3D11_SHADER_VARIABLE_DESC *desc)
689 struct d3dcompiler_shader_reflection_variable *This = impl_from_ID3D11ShaderReflectionVariable(iface);
691 TRACE("iface %p, desc %p\n", iface, desc);
693 if (This == &null_variable)
695 WARN("Null variable specified\n");
701 WARN("Invalid argument specified\n");
705 desc->Name = This->name;
706 desc->StartOffset = This->start_offset;
707 desc->Size = This->size;
708 desc->uFlags = This->flags;
709 desc->DefaultValue = This->default_value;
714 static ID3D11ShaderReflectionType * STDMETHODCALLTYPE d3dcompiler_shader_reflection_variable_GetType(
715 ID3D11ShaderReflectionVariable *iface)
717 struct d3dcompiler_shader_reflection_variable *This = impl_from_ID3D11ShaderReflectionVariable(iface);
719 TRACE("iface %p\n", iface);
721 return &This->type->ID3D11ShaderReflectionType_iface;
724 static ID3D11ShaderReflectionConstantBuffer * STDMETHODCALLTYPE d3dcompiler_shader_reflection_variable_GetBuffer(
725 ID3D11ShaderReflectionVariable *iface)
727 struct d3dcompiler_shader_reflection_variable *This = impl_from_ID3D11ShaderReflectionVariable(iface);
729 TRACE("iface %p\n", iface);
731 return &This->constant_buffer->ID3D11ShaderReflectionConstantBuffer_iface;
734 static UINT STDMETHODCALLTYPE d3dcompiler_shader_reflection_variable_GetInterfaceSlot(
735 ID3D11ShaderReflectionVariable *iface, UINT index)
737 FIXME("iface %p, index %u stub!\n", iface, index);
742 const struct ID3D11ShaderReflectionVariableVtbl d3dcompiler_shader_reflection_variable_vtbl =
744 /* ID3D11ShaderReflectionVariable methods */
745 d3dcompiler_shader_reflection_variable_GetDesc,
746 d3dcompiler_shader_reflection_variable_GetType,
747 d3dcompiler_shader_reflection_variable_GetBuffer,
748 d3dcompiler_shader_reflection_variable_GetInterfaceSlot,
751 /* ID3D11ShaderReflectionType methods */
753 static inline struct d3dcompiler_shader_reflection_type *impl_from_ID3D11ShaderReflectionType(ID3D11ShaderReflectionType *iface)
755 return CONTAINING_RECORD(iface, struct d3dcompiler_shader_reflection_type, ID3D11ShaderReflectionType_iface);
758 static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_type_GetDesc(
759 ID3D11ShaderReflectionType *iface, D3D11_SHADER_TYPE_DESC *desc)
761 struct d3dcompiler_shader_reflection_type *This = impl_from_ID3D11ShaderReflectionType(iface);
763 TRACE("iface %p, desc %p\n", iface, desc);
765 if (This == &null_type)
767 WARN("Null type specified\n");
773 WARN("Invalid argument specified\n");
782 static ID3D11ShaderReflectionType * STDMETHODCALLTYPE d3dcompiler_shader_reflection_type_GetMemberTypeByIndex(
783 ID3D11ShaderReflectionType *iface, UINT index)
785 FIXME("iface %p, index %u stub!\n", iface, index);
790 static ID3D11ShaderReflectionType * STDMETHODCALLTYPE d3dcompiler_shader_reflection_type_GetMemberTypeByName(
791 ID3D11ShaderReflectionType *iface, LPCSTR name)
793 FIXME("iface %p, name %s stub!\n", iface, name);
798 static LPCSTR STDMETHODCALLTYPE d3dcompiler_shader_reflection_type_GetMemberTypeName(
799 ID3D11ShaderReflectionType *iface, UINT index)
801 FIXME("iface %p, index %u stub!\n", iface, index);
806 static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_type_IsEqual(
807 ID3D11ShaderReflectionType *iface, ID3D11ShaderReflectionType *type)
809 FIXME("iface %p, type %p stub!\n", iface, type);
814 static ID3D11ShaderReflectionType * STDMETHODCALLTYPE d3dcompiler_shader_reflection_type_GetSubType(
815 ID3D11ShaderReflectionType *iface)
817 FIXME("iface %p stub!\n", iface);
822 static ID3D11ShaderReflectionType * STDMETHODCALLTYPE d3dcompiler_shader_reflection_type_GetBaseClass(
823 ID3D11ShaderReflectionType *iface)
825 FIXME("iface %p stub!\n", iface);
830 static UINT STDMETHODCALLTYPE d3dcompiler_shader_reflection_type_GetNumInterfaces(
831 ID3D11ShaderReflectionType *iface)
833 FIXME("iface %p stub!\n", iface);
838 static ID3D11ShaderReflectionType * STDMETHODCALLTYPE d3dcompiler_shader_reflection_type_GetInterfaceByIndex(
839 ID3D11ShaderReflectionType *iface, UINT index)
841 FIXME("iface %p, index %u stub!\n", iface, index);
846 static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_type_IsOfType(
847 ID3D11ShaderReflectionType *iface, ID3D11ShaderReflectionType *type)
849 FIXME("iface %p, type %p stub!\n", iface, type);
854 static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_type_ImplementsInterface(
855 ID3D11ShaderReflectionType *iface, ID3D11ShaderReflectionType *base)
857 FIXME("iface %p, base %p stub!\n", iface, base);
862 const struct ID3D11ShaderReflectionTypeVtbl d3dcompiler_shader_reflection_type_vtbl =
864 /* ID3D11ShaderReflectionType methods */
865 d3dcompiler_shader_reflection_type_GetDesc,
866 d3dcompiler_shader_reflection_type_GetMemberTypeByIndex,
867 d3dcompiler_shader_reflection_type_GetMemberTypeByName,
868 d3dcompiler_shader_reflection_type_GetMemberTypeName,
869 d3dcompiler_shader_reflection_type_IsEqual,
870 d3dcompiler_shader_reflection_type_GetSubType,
871 d3dcompiler_shader_reflection_type_GetBaseClass,
872 d3dcompiler_shader_reflection_type_GetNumInterfaces,
873 d3dcompiler_shader_reflection_type_GetInterfaceByIndex,
874 d3dcompiler_shader_reflection_type_IsOfType,
875 d3dcompiler_shader_reflection_type_ImplementsInterface,
878 static HRESULT d3dcompiler_parse_stat(struct d3dcompiler_shader_reflection *r, const char *data, DWORD data_size)
880 const char *ptr = data;
881 DWORD size = data_size >> 2;
883 TRACE("Size %u\n", size);
885 read_dword(&ptr, &r->instruction_count);
886 TRACE("InstructionCount: %u\n", r->instruction_count);
888 read_dword(&ptr, &r->temp_register_count);
889 TRACE("TempRegisterCount: %u\n", r->temp_register_count);
891 skip_dword_unknown(&ptr, 1);
893 read_dword(&ptr, &r->dcl_count);
894 TRACE("DclCount: %u\n", r->dcl_count);
896 read_dword(&ptr, &r->float_instruction_count);
897 TRACE("FloatInstructionCount: %u\n", r->float_instruction_count);
899 read_dword(&ptr, &r->int_instruction_count);
900 TRACE("IntInstructionCount: %u\n", r->int_instruction_count);
902 read_dword(&ptr, &r->uint_instruction_count);
903 TRACE("UintInstructionCount: %u\n", r->uint_instruction_count);
905 read_dword(&ptr, &r->static_flow_control_count);
906 TRACE("StaticFlowControlCount: %u\n", r->static_flow_control_count);
908 read_dword(&ptr, &r->dynamic_flow_control_count);
909 TRACE("DynamicFlowControlCount: %u\n", r->dynamic_flow_control_count);
911 skip_dword_unknown(&ptr, 1);
913 read_dword(&ptr, &r->temp_array_count);
914 TRACE("TempArrayCount: %u\n", r->temp_array_count);
916 read_dword(&ptr, &r->array_instruction_count);
917 TRACE("ArrayInstructionCount: %u\n", r->array_instruction_count);
919 read_dword(&ptr, &r->cut_instruction_count);
920 TRACE("CutInstructionCount: %u\n", r->cut_instruction_count);
922 read_dword(&ptr, &r->emit_instruction_count);
923 TRACE("EmitInstructionCount: %u\n", r->emit_instruction_count);
925 read_dword(&ptr, &r->texture_normal_instructions);
926 TRACE("TextureNormalInstructions: %u\n", r->texture_normal_instructions);
928 read_dword(&ptr, &r->texture_load_instructions);
929 TRACE("TextureLoadInstructions: %u\n", r->texture_load_instructions);
931 read_dword(&ptr, &r->texture_comp_instructions);
932 TRACE("TextureCompInstructions: %u\n", r->texture_comp_instructions);
934 read_dword(&ptr, &r->texture_bias_instructions);
935 TRACE("TextureBiasInstructions: %u\n", r->texture_bias_instructions);
937 read_dword(&ptr, &r->texture_gradient_instructions);
938 TRACE("TextureGradientInstructions: %u\n", r->texture_gradient_instructions);
940 read_dword(&ptr, &r->mov_instruction_count);
941 TRACE("MovInstructionCount: %u\n", r->mov_instruction_count);
943 skip_dword_unknown(&ptr, 1);
945 read_dword(&ptr, &r->conversion_instruction_count);
946 TRACE("ConversionInstructionCount: %u\n", r->conversion_instruction_count);
948 skip_dword_unknown(&ptr, 1);
950 read_dword(&ptr, &r->input_primitive);
951 TRACE("InputPrimitive: %x\n", r->input_primitive);
953 read_dword(&ptr, &r->gs_output_topology);
954 TRACE("GSOutputTopology: %x\n", r->gs_output_topology);
956 read_dword(&ptr, &r->gs_max_output_vertex_count);
957 TRACE("GSMaxOutputVertexCount: %u\n", r->gs_max_output_vertex_count);
959 skip_dword_unknown(&ptr, 3);
962 if (size == 29) return S_OK;
964 skip_dword_unknown(&ptr, 1);
966 read_dword(&ptr, &r->c_control_points);
967 TRACE("cControlPoints: %u\n", r->c_control_points);
969 read_dword(&ptr, &r->hs_output_primitive);
970 TRACE("HSOutputPrimitive: %x\n", r->hs_output_primitive);
972 read_dword(&ptr, &r->hs_prtitioning);
973 TRACE("HSPartitioning: %x\n", r->hs_prtitioning);
975 read_dword(&ptr, &r->tessellator_domain);
976 TRACE("TessellatorDomain: %x\n", r->tessellator_domain);
978 skip_dword_unknown(&ptr, 3);
981 if (size == 37) return S_OK;
983 FIXME("Unhandled size %u\n", size);
988 static HRESULT d3dcompiler_parse_type(struct d3dcompiler_shader_reflection_type *type, const char *data, DWORD offset)
990 const char *ptr = data + offset;
992 D3D11_SHADER_TYPE_DESC *desc;
997 read_dword(&ptr, &temp);
998 desc->Class = temp & 0xffff;
999 desc->Type = temp >> 16;
1000 TRACE("Class %x, Type %x\n", desc->Class, desc->Type);
1002 read_dword(&ptr, &temp);
1003 desc->Rows = temp & 0xffff;
1004 desc->Columns = temp >> 16;
1005 TRACE("Rows %u, Columns %u\n", desc->Rows, desc->Columns);
1007 read_dword(&ptr, &temp);
1008 desc->Elements = temp & 0xffff;
1009 desc->Members = temp >> 16;
1010 TRACE("Elements %u, Members %u\n", desc->Elements, desc->Members);
1012 read_dword(&ptr, &temp);
1013 TRACE("Member Offset %u\n", temp);
1015 if ((type->reflection->target & 0xffff) >= 0x500)
1016 skip_dword_unknown(&ptr, 4);
1018 /* todo: Parse type members */
1019 for (i = 0; i < desc->Members; ++i)
1021 skip_dword_unknown(&ptr, 3);
1027 static struct d3dcompiler_shader_reflection_type *get_reflection_type(struct d3dcompiler_shader_reflection *reflection, const char *data, DWORD offset)
1029 struct d3dcompiler_shader_reflection_type *type;
1030 struct wine_rb_entry *entry;
1033 entry = wine_rb_get(&reflection->types, &offset);
1036 TRACE("Returning existing type.\n");
1037 return WINE_RB_ENTRY_VALUE(entry, struct d3dcompiler_shader_reflection_type, entry);
1040 type = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*type));
1043 ERR("Failed to allocate type memory.\n");
1047 type->ID3D11ShaderReflectionType_iface.lpVtbl = &d3dcompiler_shader_reflection_type_vtbl;
1049 type->reflection = reflection;
1051 hr = d3dcompiler_parse_type(type, data, offset);
1054 ERR("Failed to parse type info, hr %#x.\n", hr);
1055 HeapFree(GetProcessHeap(), 0, type);
1059 if (wine_rb_put(&reflection->types, &offset, &type->entry) == -1)
1061 ERR("Failed to insert type entry.\n");
1062 HeapFree(GetProcessHeap(), 0, type);
1069 static HRESULT d3dcompiler_parse_variables(struct d3dcompiler_shader_reflection_constant_buffer *cb,
1070 const char *data, DWORD data_size, const char *ptr)
1072 struct d3dcompiler_shader_reflection_variable *variables;
1076 variables = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, cb->variable_count * sizeof(*variables));
1079 ERR("Failed to allocate variables memory.\n");
1080 return E_OUTOFMEMORY;
1083 for (i = 0; i < cb->variable_count; i++)
1085 struct d3dcompiler_shader_reflection_variable *v = &variables[i];
1088 v->ID3D11ShaderReflectionVariable_iface.lpVtbl = &d3dcompiler_shader_reflection_variable_vtbl;
1089 v->constant_buffer = cb;
1091 read_dword(&ptr, &offset);
1092 if (!copy_name(data + offset, &v->name))
1094 ERR("Failed to copy name.\n");
1098 TRACE("Variable name: %s.\n", debugstr_a(v->name));
1100 read_dword(&ptr, &v->start_offset);
1101 TRACE("Variable offset: %u\n", v->start_offset);
1103 read_dword(&ptr, &v->size);
1104 TRACE("Variable size: %u\n", v->size);
1106 read_dword(&ptr, &v->flags);
1107 TRACE("Variable flags: %u\n", v->flags);
1109 read_dword(&ptr, &offset);
1110 TRACE("Variable type offset: %x\n", offset);
1111 v->type = get_reflection_type(cb->reflection, data, offset);
1114 ERR("Failed to get type.\n");
1119 read_dword(&ptr, &offset);
1120 TRACE("Variable default value offset: %x\n", offset);
1121 if (!copy_value(data + offset, &v->default_value, offset ? v->size : 0))
1123 ERR("Failed to copy name.\n");
1128 if ((cb->reflection->target & 0xffff) >= 0x500)
1129 skip_dword_unknown(&ptr, 4);
1132 cb->variables = variables;
1137 for (i = 0; i < cb->variable_count; i++)
1139 free_variable(&variables[i]);
1141 HeapFree(GetProcessHeap(), 0, variables);
1145 static HRESULT d3dcompiler_parse_rdef(struct d3dcompiler_shader_reflection *r, const char *data, DWORD data_size)
1147 const char *ptr = data;
1148 DWORD size = data_size >> 2;
1149 DWORD offset, cbuffer_offset, resource_offset, creator_offset;
1150 unsigned int i, string_data_offset, string_data_size;
1151 char *string_data = NULL, *creator = NULL;
1152 D3D11_SHADER_INPUT_BIND_DESC *bound_resources = NULL;
1153 struct d3dcompiler_shader_reflection_constant_buffer *constant_buffers = NULL;
1156 TRACE("Size %u\n", size);
1158 read_dword(&ptr, &r->constant_buffer_count);
1159 TRACE("Constant buffer count: %u\n", r->constant_buffer_count);
1161 read_dword(&ptr, &cbuffer_offset);
1162 TRACE("Constant buffer offset: %#x\n", cbuffer_offset);
1164 read_dword(&ptr, &r->bound_resource_count);
1165 TRACE("Bound resource count: %u\n", r->bound_resource_count);
1167 read_dword(&ptr, &resource_offset);
1168 TRACE("Bound resource offset: %#x\n", resource_offset);
1170 read_dword(&ptr, &r->target);
1171 TRACE("Target: %#x\n", r->target);
1173 read_dword(&ptr, &r->flags);
1174 TRACE("Flags: %u\n", r->flags);
1176 read_dword(&ptr, &creator_offset);
1177 TRACE("Creator at offset %#x.\n", creator_offset);
1179 if (!copy_name(data + creator_offset, &creator))
1181 ERR("Failed to copy name.\n");
1182 return E_OUTOFMEMORY;
1184 TRACE("Creator: %s.\n", debugstr_a(creator));
1186 /* todo: Parse RD11 */
1187 if ((r->target & 0x0000ffff) >= 0x500)
1189 skip_dword_unknown(&ptr, 8);
1192 if (r->bound_resource_count)
1194 /* 8 for each bind desc */
1195 string_data_offset = resource_offset + r->bound_resource_count * 8 * sizeof(DWORD);
1196 string_data_size = (cbuffer_offset ? cbuffer_offset : creator_offset) - string_data_offset;
1198 string_data = HeapAlloc(GetProcessHeap(), 0, string_data_size);
1201 ERR("Failed to allocate string data memory.\n");
1205 memcpy(string_data, data + string_data_offset, string_data_size);
1207 bound_resources = HeapAlloc(GetProcessHeap(), 0, r->bound_resource_count * sizeof(*bound_resources));
1208 if (!bound_resources)
1210 ERR("Failed to allocate resources memory.\n");
1215 ptr = data + resource_offset;
1216 for (i = 0; i < r->bound_resource_count; i++)
1218 D3D11_SHADER_INPUT_BIND_DESC *desc = &bound_resources[i];
1220 read_dword(&ptr, &offset);
1221 desc->Name = string_data + (offset - string_data_offset);
1222 TRACE("Input bind Name: %s\n", debugstr_a(desc->Name));
1224 read_dword(&ptr, &desc->Type);
1225 TRACE("Input bind Type: %#x\n", desc->Type);
1227 read_dword(&ptr, &desc->ReturnType);
1228 TRACE("Input bind ReturnType: %#x\n", desc->ReturnType);
1230 read_dword(&ptr, &desc->Dimension);
1231 TRACE("Input bind Dimension: %#x\n", desc->Dimension);
1233 read_dword(&ptr, &desc->NumSamples);
1234 TRACE("Input bind NumSamples: %u\n", desc->NumSamples);
1236 read_dword(&ptr, &desc->BindPoint);
1237 TRACE("Input bind BindPoint: %u\n", desc->BindPoint);
1239 read_dword(&ptr, &desc->BindCount);
1240 TRACE("Input bind BindCount: %u\n", desc->BindCount);
1242 read_dword(&ptr, &desc->uFlags);
1243 TRACE("Input bind uFlags: %u\n", desc->uFlags);
1247 if (r->constant_buffer_count)
1249 constant_buffers = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, r->constant_buffer_count * sizeof(*constant_buffers));
1250 if (!constant_buffers)
1252 ERR("Failed to allocate constant buffer memory.\n");
1257 ptr = data + cbuffer_offset;
1258 for (i = 0; i < r->constant_buffer_count; i++)
1260 struct d3dcompiler_shader_reflection_constant_buffer *cb = &constant_buffers[i];
1262 cb->ID3D11ShaderReflectionConstantBuffer_iface.lpVtbl = &d3dcompiler_shader_reflection_constant_buffer_vtbl;
1265 read_dword(&ptr, &offset);
1266 if (!copy_name(data + offset, &cb->name))
1268 ERR("Failed to copy name.\n");
1272 TRACE("Name: %s.\n", debugstr_a(cb->name));
1274 read_dword(&ptr, &cb->variable_count);
1275 TRACE("Variable count: %u\n", cb->variable_count);
1277 read_dword(&ptr, &offset);
1278 TRACE("Variable offset: %x\n", offset);
1280 hr = d3dcompiler_parse_variables(cb, data, data_size, data + offset);
1283 FIXME("Failed to parse variables.");
1287 read_dword(&ptr, &cb->size);
1288 TRACE("Cbuffer size: %u\n", cb->size);
1290 read_dword(&ptr, &cb->flags);
1291 TRACE("Cbuffer flags: %u\n", cb->flags);
1293 read_dword(&ptr, &cb->type);
1294 TRACE("Cbuffer type: %#x\n", cb->type);
1298 r->creator = creator;
1299 r->resource_string = string_data;
1300 r->bound_resources = bound_resources;
1301 r->constant_buffers = constant_buffers;
1306 for (i = 0; i < r->constant_buffer_count; ++i)
1308 free_constant_buffer(&constant_buffers[i]);
1310 HeapFree(GetProcessHeap(), 0, constant_buffers);
1311 HeapFree(GetProcessHeap(), 0, bound_resources);
1312 HeapFree(GetProcessHeap(), 0, string_data);
1313 HeapFree(GetProcessHeap(), 0, creator);
1318 HRESULT d3dcompiler_parse_signature(struct d3dcompiler_shader_signature *s, struct dxbc_section *section)
1320 D3D11_SIGNATURE_PARAMETER_DESC *d;
1321 unsigned int string_data_offset;
1322 unsigned int string_data_size;
1323 const char *ptr = section->data;
1327 enum D3DCOMPILER_SIGNATURE_ELEMENT_SIZE element_size;
1329 switch (section->tag)
1332 element_size = D3DCOMPILER_SIGNATURE_ELEMENT_SIZE7;
1338 element_size = D3DCOMPILER_SIGNATURE_ELEMENT_SIZE6;
1342 FIXME("Unhandled section %s!\n", debugstr_an((const char *)§ion->tag, 4));
1343 element_size = D3DCOMPILER_SIGNATURE_ELEMENT_SIZE6;
1347 read_dword(&ptr, &count);
1348 TRACE("%u elements\n", count);
1350 skip_dword_unknown(&ptr, 1);
1352 d = HeapAlloc(GetProcessHeap(), 0, count * sizeof(*d));
1355 ERR("Failed to allocate signature memory.\n");
1356 return E_OUTOFMEMORY;
1359 /* 2 DWORDs for the header, element_size for each element. */
1360 string_data_offset = 2 * sizeof(DWORD) + count * element_size * sizeof(DWORD);
1361 string_data_size = section->data_size - string_data_offset;
1363 string_data = HeapAlloc(GetProcessHeap(), 0, string_data_size);
1366 ERR("Failed to allocate string data memory.\n");
1367 HeapFree(GetProcessHeap(), 0, d);
1368 return E_OUTOFMEMORY;
1370 memcpy(string_data, section->data + string_data_offset, string_data_size);
1372 for (i = 0; i < count; ++i)
1377 if (element_size == D3DCOMPILER_SIGNATURE_ELEMENT_SIZE7)
1379 read_dword(&ptr, &d[i].Stream);
1386 read_dword(&ptr, &name_offset);
1387 d[i].SemanticName = string_data + (name_offset - string_data_offset);
1388 read_dword(&ptr, &d[i].SemanticIndex);
1389 read_dword(&ptr, &d[i].SystemValueType);
1390 read_dword(&ptr, &d[i].ComponentType);
1391 read_dword(&ptr, &d[i].Register);
1392 read_dword(&ptr, &mask);
1393 d[i].ReadWriteMask = (mask >> 8) & 0xff;
1394 d[i].Mask = mask & 0xff;
1396 TRACE("semantic: %s, semantic idx: %u, sysval_semantic %#x, "
1397 "type %u, register idx: %u, use_mask %#x, input_mask %#x, stream %u\n",
1398 debugstr_a(d[i].SemanticName), d[i].SemanticIndex, d[i].SystemValueType,
1399 d[i].ComponentType, d[i].Register, d[i].Mask, d[i].ReadWriteMask, d[i].Stream);
1403 s->element_count = count;
1404 s->string_data = string_data;
1409 static HRESULT d3dcompiler_parse_shdr(struct d3dcompiler_shader_reflection *r, const char *data, DWORD data_size)
1411 const char *ptr = data;
1413 read_dword(&ptr, &r->version);
1414 TRACE("Shader version: %u\n", r->version);
1416 /* todo: Check if anything else is needed from the shdr or shex blob. */
1421 HRESULT d3dcompiler_shader_reflection_init(struct d3dcompiler_shader_reflection *reflection,
1422 const void *data, SIZE_T data_size)
1424 struct dxbc src_dxbc;
1428 reflection->ID3D11ShaderReflection_iface.lpVtbl = &d3dcompiler_shader_reflection_vtbl;
1429 reflection->refcount = 1;
1431 if (wine_rb_init(&reflection->types, &d3dcompiler_shader_reflection_type_rb_functions) == -1)
1433 ERR("Failed to initialize type rbtree.\n");
1437 hr = dxbc_parse(data, data_size, &src_dxbc);
1440 WARN("Failed to parse reflection\n");
1444 for (i = 0; i < src_dxbc.count; ++i)
1446 struct dxbc_section *section = &src_dxbc.sections[i];
1448 switch (section->tag)
1451 hr = d3dcompiler_parse_stat(reflection, section->data, section->data_size);
1454 WARN("Failed to parse section STAT.\n");
1461 hr = d3dcompiler_parse_shdr(reflection, section->data, section->data_size);
1464 WARN("Failed to parse SHDR section.\n");
1470 hr = d3dcompiler_parse_rdef(reflection, section->data, section->data_size);
1473 WARN("Failed to parse RDEF section.\n");
1479 reflection->isgn = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*reflection->isgn));
1480 if (!reflection->isgn)
1482 ERR("Failed to allocate ISGN memory.\n");
1487 hr = d3dcompiler_parse_signature(reflection->isgn, section);
1490 WARN("Failed to parse section ISGN.\n");
1497 reflection->osgn = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*reflection->osgn));
1498 if (!reflection->osgn)
1500 ERR("Failed to allocate OSGN memory.\n");
1505 hr = d3dcompiler_parse_signature(reflection->osgn, section);
1508 WARN("Failed to parse section OSGN.\n");
1514 reflection->pcsg = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*reflection->pcsg));
1515 if (!reflection->pcsg)
1517 ERR("Failed to allocate PCSG memory.\n");
1522 hr = d3dcompiler_parse_signature(reflection->pcsg, section);
1525 WARN("Failed to parse section PCSG.\n");
1531 FIXME("Unhandled section %s!\n", debugstr_an((const char *)§ion->tag, 4));
1536 dxbc_destroy(&src_dxbc);
1541 reflection_cleanup(reflection);
1542 dxbc_destroy(&src_dxbc);