[PATCH v3 3/5] d3dcompiler: Use a single definition for both d3d10 and d3d11 reflection interfaces.

Matteo Bruni mbruni at codeweavers.com
Thu Mar 3 07:24:05 CST 2022


From: Zebediah Figura <zfigura at codeweavers.com>

Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
---
This is a bit ugly but probably better than the alternatives...

 dlls/d3dcompiler_43/reflection.c | 508 +++----------------------------
 1 file changed, 40 insertions(+), 468 deletions(-)

diff --git a/dlls/d3dcompiler_43/reflection.c b/dlls/d3dcompiler_43/reflection.c
index 5708d3d878f..f15cdfa0467 100644
--- a/dlls/d3dcompiler_43/reflection.c
+++ b/dlls/d3dcompiler_43/reflection.c
@@ -22,6 +22,24 @@
 #include "d3dcompiler_private.h"
 #include "d3d10.h"
 
+#if !D3D_COMPILER_VERSION
+#define ID3D11ShaderReflection ID3D10ShaderReflection
+#define ID3D11ShaderReflectionVtbl ID3D10ShaderReflectionVtbl
+#define ID3D11ShaderReflectionConstantBuffer ID3D10ShaderReflectionConstantBuffer
+#define ID3D11ShaderReflectionConstantBufferVtbl ID3D10ShaderReflectionConstantBufferVtbl
+#define ID3D11ShaderReflectionType ID3D10ShaderReflectionType
+#define ID3D11ShaderReflectionTypeVtbl ID3D10ShaderReflectionTypeVtbl
+#define ID3D11ShaderReflectionVariable ID3D10ShaderReflectionVariable
+#define ID3D11ShaderReflectionVariableVtbl ID3D10ShaderReflectionVariableVtbl
+#define IID_ID3D11ShaderReflection IID_ID3D10ShaderReflection
+#define D3D11_SHADER_BUFFER_DESC D3D10_SHADER_BUFFER_DESC
+#define D3D11_SHADER_DESC D3D10_SHADER_DESC
+#define D3D11_SHADER_INPUT_BIND_DESC D3D10_SHADER_INPUT_BIND_DESC
+#define D3D11_SHADER_TYPE_DESC D3D10_SHADER_TYPE_DESC
+#define D3D11_SHADER_VARIABLE_DESC D3D10_SHADER_VARIABLE_DESC
+#define D3D11_SIGNATURE_PARAMETER_DESC D3D10_SIGNATURE_PARAMETER_DESC
+#endif
+
 WINE_DEFAULT_DEBUG_CHANNEL(d3dcompiler);
 
 enum D3DCOMPILER_SIGNATURE_ELEMENT_SIZE
@@ -43,7 +61,6 @@ struct d3dcompiler_shader_signature
 struct d3dcompiler_shader_reflection_type
 {
     ID3D11ShaderReflectionType ID3D11ShaderReflectionType_iface;
-    ID3D10ShaderReflectionType ID3D10ShaderReflectionType_iface;
 
     uint32_t id;
     struct wine_rb_entry entry;
@@ -65,7 +82,6 @@ struct d3dcompiler_shader_reflection_type_member
 struct d3dcompiler_shader_reflection_variable
 {
     ID3D11ShaderReflectionVariable ID3D11ShaderReflectionVariable_iface;
-    ID3D10ShaderReflectionVariable ID3D10ShaderReflectionVariable_iface;
 
     struct d3dcompiler_shader_reflection_constant_buffer *constant_buffer;
     struct d3dcompiler_shader_reflection_type *type;
@@ -80,7 +96,6 @@ struct d3dcompiler_shader_reflection_variable
 struct d3dcompiler_shader_reflection_constant_buffer
 {
     ID3D11ShaderReflectionConstantBuffer ID3D11ShaderReflectionConstantBuffer_iface;
-    ID3D10ShaderReflectionConstantBuffer ID3D10ShaderReflectionConstantBuffer_iface;
 
     struct d3dcompiler_shader_reflection *reflection;
 
@@ -104,7 +119,6 @@ enum D3DCOMPILER_REFLECTION_VERSION
 struct d3dcompiler_shader_reflection
 {
     ID3D11ShaderReflection ID3D11ShaderReflection_iface;
-    ID3D10ShaderReflection ID3D10ShaderReflection_iface;
     LONG refcount;
 
     enum D3DCOMPILER_REFLECTION_VERSION interface_version;
@@ -160,25 +174,18 @@ static const struct ID3D11ShaderReflectionConstantBufferVtbl d3dcompiler_shader_
 static const struct ID3D11ShaderReflectionVariableVtbl d3dcompiler_shader_reflection_variable_vtbl;
 static const struct ID3D11ShaderReflectionTypeVtbl d3dcompiler_shader_reflection_type_vtbl;
 
-static const struct ID3D10ShaderReflectionConstantBufferVtbl d3d10_shader_reflection_constant_buffer_vtbl;
-static const struct ID3D10ShaderReflectionVariableVtbl d3d10_shader_reflection_variable_vtbl;
-static const struct ID3D10ShaderReflectionTypeVtbl d3d10_shader_reflection_type_vtbl;
-
 /* null objects - needed for invalid calls */
 static struct d3dcompiler_shader_reflection_constant_buffer null_constant_buffer =
 {
     {&d3dcompiler_shader_reflection_constant_buffer_vtbl},
-    {&d3d10_shader_reflection_constant_buffer_vtbl}
 };
 static struct d3dcompiler_shader_reflection_type null_type =
 {
     {&d3dcompiler_shader_reflection_type_vtbl},
-    {&d3d10_shader_reflection_type_vtbl}
 };
 static struct d3dcompiler_shader_reflection_variable null_variable =
 {
     {&d3dcompiler_shader_reflection_variable_vtbl},
-    {&d3d10_shader_reflection_variable_vtbl},
     &null_constant_buffer,
     &null_type
 };
@@ -425,6 +432,7 @@ static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetDesc(ID3D11Sha
     desc->EmitInstructionCount = reflection->emit_instruction_count;
     desc->GSOutputTopology = reflection->gs_output_topology;
     desc->GSMaxOutputVertexCount = reflection->gs_max_output_vertex_count;
+#if D3D_COMPILER_VERSION
     desc->InputPrimitive = reflection->input_primitive;
     desc->PatchConstantParameters = reflection->pcsg ? reflection->pcsg->element_count : 0;
     desc->cGSInstanceCount = 0;
@@ -435,6 +443,7 @@ static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetDesc(ID3D11Sha
     desc->cBarrierInstructions = 0;
     desc->cInterlockedInstructions = 0;
     desc->cTextureStoreInstructions = 0;
+#endif
 
     return S_OK;
 }
@@ -541,6 +550,7 @@ static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetOutputParamete
     return S_OK;
 }
 
+#if D3D_COMPILER_VERSION
 static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetPatchConstantParameterDesc(
         ID3D11ShaderReflection *iface, UINT index, D3D11_SIGNATURE_PARAMETER_DESC *desc)
 {
@@ -709,6 +719,7 @@ static UINT64 STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetRequiresFlags(
 
     return 0;
 }
+#endif
 
 static const struct ID3D11ShaderReflectionVtbl d3dcompiler_shader_reflection_vtbl =
 {
@@ -723,6 +734,7 @@ static const struct ID3D11ShaderReflectionVtbl d3dcompiler_shader_reflection_vtb
     d3dcompiler_shader_reflection_GetResourceBindingDesc,
     d3dcompiler_shader_reflection_GetInputParameterDesc,
     d3dcompiler_shader_reflection_GetOutputParameterDesc,
+#if D3D_COMPILER_VERSION
     d3dcompiler_shader_reflection_GetPatchConstantParameterDesc,
     d3dcompiler_shader_reflection_GetVariableByName,
     d3dcompiler_shader_reflection_GetResourceBindingDescByName,
@@ -736,6 +748,7 @@ static const struct ID3D11ShaderReflectionVtbl d3dcompiler_shader_reflection_vtb
     d3dcompiler_shader_reflection_GetMinFeatureLevel,
     d3dcompiler_shader_reflection_GetThreadGroupSize,
     d3dcompiler_shader_reflection_GetRequiresFlags,
+#endif
 };
 
 /* ID3D11ShaderReflectionConstantBuffer methods */
@@ -859,11 +872,13 @@ static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_variable_GetDesc(
     desc->uFlags = This->flags;
     desc->DefaultValue = This->default_value;
 
+#if D3D_COMPILER_VERSION
     /* TODO test and set proper values for texture. */
     desc->StartTexture = 0xffffffff;
     desc->TextureSize = 0;
     desc->StartSampler = 0xffffffff;
     desc->SamplerSize = 0;
+#endif
 
     return S_OK;
 }
@@ -878,6 +893,7 @@ static ID3D11ShaderReflectionType * STDMETHODCALLTYPE d3dcompiler_shader_reflect
     return &This->type->ID3D11ShaderReflectionType_iface;
 }
 
+#if D3D_COMPILER_VERSION
 static ID3D11ShaderReflectionConstantBuffer * STDMETHODCALLTYPE d3dcompiler_shader_reflection_variable_GetBuffer(
         ID3D11ShaderReflectionVariable *iface)
 {
@@ -895,14 +911,17 @@ static UINT STDMETHODCALLTYPE d3dcompiler_shader_reflection_variable_GetInterfac
 
     return 0;
 }
+#endif
 
 static const struct ID3D11ShaderReflectionVariableVtbl d3dcompiler_shader_reflection_variable_vtbl =
 {
     /* ID3D11ShaderReflectionVariable methods */
     d3dcompiler_shader_reflection_variable_GetDesc,
     d3dcompiler_shader_reflection_variable_GetType,
+#if D3D_COMPILER_VERSION
     d3dcompiler_shader_reflection_variable_GetBuffer,
     d3dcompiler_shader_reflection_variable_GetInterfaceSlot,
+#endif
 };
 
 /* ID3D11ShaderReflectionType methods */
@@ -1004,6 +1023,7 @@ static const char * STDMETHODCALLTYPE d3dcompiler_shader_reflection_type_GetMemb
     return This->members[index].name;
 }
 
+#if D3D_COMPILER_VERSION
 static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_type_IsEqual(
         ID3D11ShaderReflectionType *iface, ID3D11ShaderReflectionType *type)
 {
@@ -1070,6 +1090,7 @@ static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_type_ImplementsIn
 
     return E_NOTIMPL;
 }
+#endif
 
 static const struct ID3D11ShaderReflectionTypeVtbl d3dcompiler_shader_reflection_type_vtbl =
 {
@@ -1078,6 +1099,7 @@ static const struct ID3D11ShaderReflectionTypeVtbl d3dcompiler_shader_reflection
     d3dcompiler_shader_reflection_type_GetMemberTypeByIndex,
     d3dcompiler_shader_reflection_type_GetMemberTypeByName,
     d3dcompiler_shader_reflection_type_GetMemberTypeName,
+#if D3D_COMPILER_VERSION
     d3dcompiler_shader_reflection_type_IsEqual,
     d3dcompiler_shader_reflection_type_GetSubType,
     d3dcompiler_shader_reflection_type_GetBaseClass,
@@ -1085,6 +1107,7 @@ static const struct ID3D11ShaderReflectionTypeVtbl d3dcompiler_shader_reflection
     d3dcompiler_shader_reflection_type_GetInterfaceByIndex,
     d3dcompiler_shader_reflection_type_IsOfType,
     d3dcompiler_shader_reflection_type_ImplementsInterface,
+#endif
 };
 
 static HRESULT d3dcompiler_parse_stat(struct d3dcompiler_shader_reflection *r, const char *data, size_t data_size)
@@ -1290,6 +1313,7 @@ static HRESULT d3dcompiler_parse_type(struct d3dcompiler_shader_reflection_type
         }
     }
 
+#if D3D_COMPILER_VERSION
     if ((type->reflection->target & D3DCOMPILER_SHADER_TARGET_VERSION_MASK) >= 0x500)
     {
         offset = read_u32(&ptr);
@@ -1302,6 +1326,7 @@ static HRESULT d3dcompiler_parse_type(struct d3dcompiler_shader_reflection_type
         desc->Name = type->name;
         TRACE("Type name: %s.\n", debugstr_a(type->name));
     }
+#endif
 
     type->members = members;
 
@@ -1334,7 +1359,6 @@ static struct d3dcompiler_shader_reflection_type *get_reflection_type(struct d3d
         return NULL;
 
     type->ID3D11ShaderReflectionType_iface.lpVtbl = &d3dcompiler_shader_reflection_type_vtbl;
-    type->ID3D10ShaderReflectionType_iface.lpVtbl = &d3d10_shader_reflection_type_vtbl;
     type->id = offset;
     type->reflection = reflection;
 
@@ -1376,7 +1400,6 @@ static HRESULT d3dcompiler_parse_variables(struct d3dcompiler_shader_reflection_
         uint32_t offset;
 
         v->ID3D11ShaderReflectionVariable_iface.lpVtbl = &d3dcompiler_shader_reflection_variable_vtbl;
-        v->ID3D10ShaderReflectionVariable_iface.lpVtbl = &d3d10_shader_reflection_variable_vtbl;
         v->constant_buffer = cb;
 
         offset = read_u32(&ptr);
@@ -1575,7 +1598,6 @@ static HRESULT d3dcompiler_parse_rdef(struct d3dcompiler_shader_reflection *r, c
             struct d3dcompiler_shader_reflection_constant_buffer *cb = &constant_buffers[i];
 
             cb->ID3D11ShaderReflectionConstantBuffer_iface.lpVtbl = &d3dcompiler_shader_reflection_constant_buffer_vtbl;
-            cb->ID3D10ShaderReflectionConstantBuffer_iface.lpVtbl = &d3d10_shader_reflection_constant_buffer_vtbl;
             cb->reflection = r;
 
             offset = read_u32(&ptr);
@@ -1692,6 +1714,7 @@ static HRESULT d3dcompiler_parse_signature(struct d3dcompiler_shader_signature *
         /* FIXME */
         d[i].MinPrecision = D3D_MIN_PRECISION_DEFAULT;
 #endif
+#if D3D_COMPILER_VERSION
         if (element_size == D3DCOMPILER_SIGNATURE_ELEMENT_SIZE7)
         {
             d[i].Stream = read_u32(&ptr);
@@ -1700,6 +1723,7 @@ static HRESULT d3dcompiler_parse_signature(struct d3dcompiler_shader_signature *
         {
             d[i].Stream = 0;
         }
+#endif
 
         name_offset = read_u32(&ptr);
         d[i].SemanticName = string_data + (name_offset - string_data_offset);
@@ -1721,11 +1745,6 @@ static HRESULT d3dcompiler_parse_signature(struct d3dcompiler_shader_signature *
             d[i].SystemValueType = D3D_NAME_DEPTH_LESS_EQUAL;
         else if (!stricmp(d[i].SemanticName, "sv_target"))
             d[i].SystemValueType = D3D_NAME_TARGET;
-
-        TRACE("semantic: %s, semantic idx: %u, sysval_semantic %#x, "
-                "type %u, register idx: %u, use_mask %#x, input_mask %#x, stream %u\n",
-                debugstr_a(d[i].SemanticName), d[i].SemanticIndex, d[i].SystemValueType,
-                d[i].ComponentType, d[i].Register, d[i].Mask, d[i].ReadWriteMask, d[i].Stream);
     }
 
     s->elements = d;
@@ -1868,453 +1887,6 @@ err_out:
 
 /* d3d10 reflection methods. */
 #if !D3D_COMPILER_VERSION
-static inline struct d3dcompiler_shader_reflection *impl_from_ID3D10ShaderReflection(ID3D10ShaderReflection *iface)
-{
-    return CONTAINING_RECORD(iface, struct d3dcompiler_shader_reflection, ID3D10ShaderReflection_iface);
-}
-
-static HRESULT STDMETHODCALLTYPE d3d10_shader_reflection_QueryInterface(ID3D10ShaderReflection *iface,
-        REFIID riid, void **object)
-{
-    TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
-
-    if (IsEqualGUID(riid, &IID_ID3D10ShaderReflection) || IsEqualGUID(riid, &IID_IUnknown))
-    {
-        IUnknown_AddRef(iface);
-        *object = iface;
-        return S_OK;
-    }
-
-    WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
-
-    *object = NULL;
-    return E_NOINTERFACE;
-}
-
-static ULONG STDMETHODCALLTYPE d3d10_shader_reflection_AddRef(ID3D10ShaderReflection *iface)
-{
-    struct d3dcompiler_shader_reflection *reflection = impl_from_ID3D10ShaderReflection(iface);
-    ULONG refcount = InterlockedIncrement(&reflection->refcount);
-
-    TRACE("%p increasing refcount to %lu.\n", reflection, refcount);
-
-    return refcount;
-}
-
-static ULONG STDMETHODCALLTYPE d3d10_shader_reflection_Release(ID3D10ShaderReflection *iface)
-{
-    struct d3dcompiler_shader_reflection *reflection = impl_from_ID3D10ShaderReflection(iface);
-    ULONG refcount = InterlockedDecrement(&reflection->refcount);
-
-    TRACE("%p decreasing refcount to %lu.\n", reflection, refcount);
-
-    if (!refcount)
-        heap_free(reflection);
-
-    return refcount;
-}
-
-static HRESULT STDMETHODCALLTYPE d3d10_shader_reflection_GetDesc(ID3D10ShaderReflection *iface,
-        D3D10_SHADER_DESC *desc)
-{
-    struct d3dcompiler_shader_reflection *reflection = impl_from_ID3D10ShaderReflection(iface);
-
-    TRACE("iface %p, desc %p.\n", iface, desc);
-
-    if (!desc)
-    {
-        WARN("Invalid argument specified.\n");
-        return E_FAIL;
-    }
-
-    desc->Version = reflection->version;
-    desc->Creator = reflection->creator;
-    desc->Flags = reflection->flags;
-    desc->ConstantBuffers = reflection->constant_buffer_count;
-    desc->BoundResources = reflection->bound_resource_count;
-    desc->InputParameters = reflection->isgn ? reflection->isgn->element_count : 0;
-    desc->OutputParameters = reflection->osgn ? reflection->osgn->element_count : 0;
-    desc->InstructionCount = reflection->instruction_count;
-    desc->TempRegisterCount = reflection->temp_register_count;
-    desc->TempArrayCount = reflection->temp_array_count;
-    desc->DefCount = reflection->def_count;
-    desc->DclCount = reflection->dcl_count;
-    desc->TextureNormalInstructions = reflection->texture_normal_instructions;
-    desc->TextureLoadInstructions = reflection->texture_load_instructions;
-    desc->TextureCompInstructions = reflection->texture_comp_instructions;
-    desc->TextureBiasInstructions = reflection->texture_bias_instructions;
-    desc->TextureGradientInstructions = reflection->texture_gradient_instructions;
-    desc->FloatInstructionCount = reflection->float_instruction_count;
-    desc->IntInstructionCount = reflection->int_instruction_count;
-    desc->UintInstructionCount = reflection->uint_instruction_count;
-    desc->StaticFlowControlCount = reflection->static_flow_control_count;
-    desc->DynamicFlowControlCount = reflection->dynamic_flow_control_count;
-    desc->MacroInstructionCount = reflection->macro_instruction_count;
-    desc->ArrayInstructionCount = reflection->array_instruction_count;
-    desc->CutInstructionCount = reflection->cut_instruction_count;
-    desc->EmitInstructionCount = reflection->emit_instruction_count;
-    desc->GSOutputTopology = reflection->gs_output_topology;
-    desc->GSMaxOutputVertexCount = reflection->gs_max_output_vertex_count;
-
-    return S_OK;
-}
-
-static struct ID3D10ShaderReflectionConstantBuffer * STDMETHODCALLTYPE d3d10_shader_reflection_GetConstantBufferByIndex(
-        ID3D10ShaderReflection *iface, UINT index)
-{
-    struct d3dcompiler_shader_reflection *reflection = impl_from_ID3D10ShaderReflection(iface);
-
-    TRACE("iface %p, index %u.\n", iface, index);
-
-    if (index >= reflection->constant_buffer_count)
-    {
-        WARN("Invalid argument specified.\n");
-        return &null_constant_buffer.ID3D10ShaderReflectionConstantBuffer_iface;
-    }
-
-    return &reflection->constant_buffers[index].ID3D10ShaderReflectionConstantBuffer_iface;
-}
-
-static struct ID3D10ShaderReflectionConstantBuffer * STDMETHODCALLTYPE d3d10_shader_reflection_GetConstantBufferByName(
-        ID3D10ShaderReflection *iface, const char *name)
-{
-    struct d3dcompiler_shader_reflection *reflection = impl_from_ID3D10ShaderReflection(iface);
-    unsigned int i;
-
-    TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
-
-    if (!name)
-    {
-        WARN("Invalid argument specified.\n");
-        return &null_constant_buffer.ID3D10ShaderReflectionConstantBuffer_iface;
-    }
-
-    for (i = 0; i < reflection->constant_buffer_count; ++i)
-    {
-        struct d3dcompiler_shader_reflection_constant_buffer *d = &reflection->constant_buffers[i];
-
-        if (!strcmp(d->name, name))
-        {
-            TRACE("Returning ID3D10ShaderReflectionConstantBuffer %p.\n", d);
-            return &d->ID3D10ShaderReflectionConstantBuffer_iface;
-        }
-    }
-
-    WARN("Invalid name specified.\n");
-
-    return &null_constant_buffer.ID3D10ShaderReflectionConstantBuffer_iface;
-}
-
-static HRESULT STDMETHODCALLTYPE d3d10_shader_reflection_GetResourceBindingDesc(ID3D10ShaderReflection *iface,
-        UINT index, D3D10_SHADER_INPUT_BIND_DESC *desc)
-{
-    struct d3dcompiler_shader_reflection *reflection = impl_from_ID3D10ShaderReflection(iface);
-
-    TRACE("iface %p, index %u, desc %p.\n", iface, index, desc);
-
-    if (!desc || index >= reflection->bound_resource_count)
-    {
-        WARN("Invalid argument specified.\n");
-        return E_INVALIDARG;
-    }
-
-    memcpy(desc, &reflection->bound_resources[index], sizeof(*desc));
-
-    return S_OK;
-}
-
-static HRESULT STDMETHODCALLTYPE d3d10_shader_reflection_GetInputParameterDesc(ID3D10ShaderReflection *iface,
-        UINT index, D3D10_SIGNATURE_PARAMETER_DESC *desc)
-{
-    struct d3dcompiler_shader_reflection *reflection = impl_from_ID3D10ShaderReflection(iface);
-
-    TRACE("iface %p, index %u, desc %p.\n", iface, index, desc);
-
-    if (!desc || !reflection->isgn || index >= reflection->isgn->element_count)
-    {
-        WARN("Invalid argument specified.\n");
-        return E_INVALIDARG;
-    }
-
-    memcpy(desc, &reflection->isgn->elements[index], sizeof(*desc));
-
-    return S_OK;
-}
-
-static HRESULT STDMETHODCALLTYPE d3d10_shader_reflection_GetOutputParameterDesc(ID3D10ShaderReflection *iface,
-        UINT index, D3D10_SIGNATURE_PARAMETER_DESC *desc)
-{
-    struct d3dcompiler_shader_reflection *reflection = impl_from_ID3D10ShaderReflection(iface);
-
-    TRACE("iface %p, index %u, desc %p.\n", iface, index, desc);
-
-    if (!desc || !reflection->osgn || index >= reflection->osgn->element_count)
-    {
-        WARN("Invalid argument specified.\n");
-        return E_INVALIDARG;
-    }
-
-    memcpy(desc, &reflection->osgn->elements[index], sizeof(*desc));
-
-    return S_OK;
-}
-
-static const struct ID3D10ShaderReflectionVtbl d3d10_shader_reflection_vtbl =
-{
-    d3d10_shader_reflection_QueryInterface,
-    d3d10_shader_reflection_AddRef,
-    d3d10_shader_reflection_Release,
-    d3d10_shader_reflection_GetDesc,
-    d3d10_shader_reflection_GetConstantBufferByIndex,
-    d3d10_shader_reflection_GetConstantBufferByName,
-    d3d10_shader_reflection_GetResourceBindingDesc,
-    d3d10_shader_reflection_GetInputParameterDesc,
-    d3d10_shader_reflection_GetOutputParameterDesc,
-};
-
-static inline struct d3dcompiler_shader_reflection_constant_buffer *impl_from_ID3D10ShaderReflectionConstantBuffer(
-        ID3D10ShaderReflectionConstantBuffer *iface)
-{
-    return CONTAINING_RECORD(iface, struct d3dcompiler_shader_reflection_constant_buffer,
-            ID3D10ShaderReflectionConstantBuffer_iface);
-}
-
-static HRESULT STDMETHODCALLTYPE d3d10_shader_reflection_constant_buffer_GetDesc(
-        ID3D10ShaderReflectionConstantBuffer *iface, D3D10_SHADER_BUFFER_DESC *desc)
-{
-    struct d3dcompiler_shader_reflection_constant_buffer *cb = impl_from_ID3D10ShaderReflectionConstantBuffer(iface);
-
-    TRACE("iface %p, desc %p.\n", iface, desc);
-
-    if (cb == &null_constant_buffer)
-    {
-        WARN("Null constant buffer specified.\n");
-        return E_FAIL;
-    }
-
-    if (!desc)
-    {
-        WARN("Invalid argument specified.\n");
-        return E_FAIL;
-    }
-
-    desc->Name = cb->name;
-    desc->Type = cb->type;
-    desc->Variables = cb->variable_count;
-    desc->Size = cb->size;
-    desc->uFlags = cb->flags;
-
-    return S_OK;
-}
-
-static ID3D10ShaderReflectionVariable * STDMETHODCALLTYPE d3d10_shader_reflection_constant_buffer_GetVariableByIndex(
-        ID3D10ShaderReflectionConstantBuffer *iface, UINT index)
-{
-    struct d3dcompiler_shader_reflection_constant_buffer *cb = impl_from_ID3D10ShaderReflectionConstantBuffer(iface);
-
-    TRACE("iface %p, index %u.\n", iface, index);
-
-    if (index >= cb->variable_count)
-    {
-        WARN("Invalid index specified.\n");
-        return &null_variable.ID3D10ShaderReflectionVariable_iface;
-    }
-
-    return &cb->variables[index].ID3D10ShaderReflectionVariable_iface;
-}
-
-static ID3D10ShaderReflectionVariable * STDMETHODCALLTYPE d3d10_shader_reflection_constant_buffer_GetVariableByName(
-        ID3D10ShaderReflectionConstantBuffer *iface, const char *name)
-{
-    struct d3dcompiler_shader_reflection_constant_buffer *cb = impl_from_ID3D10ShaderReflectionConstantBuffer(iface);
-    unsigned int i;
-
-    TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
-
-    if (!name)
-    {
-        WARN("Invalid argument specified.\n");
-        return &null_variable.ID3D10ShaderReflectionVariable_iface;
-    }
-
-    for (i = 0; i < cb->variable_count; ++i)
-    {
-        struct d3dcompiler_shader_reflection_variable *v = &cb->variables[i];
-
-        if (!strcmp(v->name, name))
-        {
-            TRACE("Returning ID3D10ShaderReflectionVariable %p.\n", v);
-            return &v->ID3D10ShaderReflectionVariable_iface;
-        }
-    }
-
-    WARN("Invalid name specified.\n");
-
-    return &null_variable.ID3D10ShaderReflectionVariable_iface;
-}
-
-static const struct ID3D10ShaderReflectionConstantBufferVtbl d3d10_shader_reflection_constant_buffer_vtbl =
-{
-    d3d10_shader_reflection_constant_buffer_GetDesc,
-    d3d10_shader_reflection_constant_buffer_GetVariableByIndex,
-    d3d10_shader_reflection_constant_buffer_GetVariableByName,
-};
-
-static inline struct d3dcompiler_shader_reflection_variable *impl_from_ID3D10ShaderReflectionVariable(ID3D10ShaderReflectionVariable *iface)
-{
-    return CONTAINING_RECORD(iface, struct d3dcompiler_shader_reflection_variable, ID3D10ShaderReflectionVariable_iface);
-}
-
-static HRESULT STDMETHODCALLTYPE d3d10_shader_reflection_variable_GetDesc(ID3D10ShaderReflectionVariable *iface,
-        D3D10_SHADER_VARIABLE_DESC *desc)
-{
-    struct d3dcompiler_shader_reflection_variable *var = impl_from_ID3D10ShaderReflectionVariable(iface);
-
-    TRACE("iface %p, desc %p.\n", iface, desc);
-
-    if (var == &null_variable)
-    {
-        WARN("Null variable specified.\n");
-        return E_FAIL;
-    }
-
-    if (!desc)
-    {
-        WARN("Invalid argument specified.\n");
-        return E_FAIL;
-    }
-
-    desc->Name = var->name;
-    desc->StartOffset = var->start_offset;
-    desc->Size = var->size;
-    desc->uFlags = var->flags;
-    desc->DefaultValue = var->default_value;
-
-    return S_OK;
-}
-
-static ID3D10ShaderReflectionType * STDMETHODCALLTYPE d3d10_shader_reflection_variable_GetType(
-        ID3D10ShaderReflectionVariable *iface)
-{
-    struct d3dcompiler_shader_reflection_variable *var = impl_from_ID3D10ShaderReflectionVariable(iface);
-
-    TRACE("iface %p.\n", iface);
-
-    return &var->type->ID3D10ShaderReflectionType_iface;
-}
-
-static const struct ID3D10ShaderReflectionVariableVtbl d3d10_shader_reflection_variable_vtbl =
-{
-    d3d10_shader_reflection_variable_GetDesc,
-    d3d10_shader_reflection_variable_GetType,
-};
-
-static inline struct d3dcompiler_shader_reflection_type *impl_from_ID3D10ShaderReflectionType(
-        ID3D10ShaderReflectionType *iface)
-{
-    return CONTAINING_RECORD(iface, struct d3dcompiler_shader_reflection_type, ID3D10ShaderReflectionType_iface);
-}
-
-static HRESULT STDMETHODCALLTYPE d3d10_shader_reflection_type_GetDesc(ID3D10ShaderReflectionType *iface,
-        D3D10_SHADER_TYPE_DESC *desc)
-{
-    struct d3dcompiler_shader_reflection_type *type = impl_from_ID3D10ShaderReflectionType(iface);
-
-    TRACE("iface %p, desc %p.\n", iface, desc);
-
-    if (type == &null_type)
-    {
-        WARN("Null type specified.\n");
-        return E_FAIL;
-    }
-
-    if (!desc)
-    {
-        WARN("Invalid argument specified.\n");
-        return E_FAIL;
-    }
-
-    memcpy(desc, &type->desc, sizeof(*desc));
-
-    return S_OK;
-}
-
-static ID3D10ShaderReflectionType * STDMETHODCALLTYPE d3d10_shader_reflection_type_GetMemberTypeByIndex(
-        ID3D10ShaderReflectionType *iface, UINT index)
-{
-    struct d3dcompiler_shader_reflection_type *type = impl_from_ID3D10ShaderReflectionType(iface);
-
-    TRACE("iface %p, index %u.\n", iface, index);
-
-    if (index >= type->desc.Members)
-    {
-        WARN("Invalid index specified.\n");
-        return &null_type.ID3D10ShaderReflectionType_iface;
-    }
-
-    return &type->members[index].type->ID3D10ShaderReflectionType_iface;
-}
-
-static ID3D10ShaderReflectionType * STDMETHODCALLTYPE d3d10_shader_reflection_type_GetMemberTypeByName(
-        ID3D10ShaderReflectionType *iface, const char *name)
-{
-    struct d3dcompiler_shader_reflection_type *type = impl_from_ID3D10ShaderReflectionType(iface);
-    unsigned int i;
-
-    TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
-
-    if (!name)
-    {
-        WARN("Invalid argument specified.\n");
-        return &null_type.ID3D10ShaderReflectionType_iface;
-    }
-
-    for (i = 0; i < type->desc.Members; ++i)
-    {
-        struct d3dcompiler_shader_reflection_type_member *member = &type->members[i];
-
-        if (!strcmp(member->name, name))
-        {
-            TRACE("Returning ID3D10ShaderReflectionType %p.\n", member->type);
-            return &member->type->ID3D10ShaderReflectionType_iface;
-        }
-    }
-
-    WARN("Invalid name specified.\n");
-
-    return &null_type.ID3D10ShaderReflectionType_iface;
-}
-
-static const char * STDMETHODCALLTYPE d3d10_shader_reflection_type_GetMemberTypeName(
-        ID3D10ShaderReflectionType *iface, UINT index)
-{
-    struct d3dcompiler_shader_reflection_type *type = impl_from_ID3D10ShaderReflectionType(iface);
-
-    TRACE("iface %p, index %u.\n", iface, index);
-
-    if (type == &null_type)
-    {
-        WARN("Null type specified.\n");
-        return "$Invalid";
-    }
-
-    if (index >= type->desc.Members)
-    {
-        WARN("Invalid index specified.\n");
-        return NULL;
-    }
-
-    return type->members[index].name;
-}
-
-static const struct ID3D10ShaderReflectionTypeVtbl d3d10_shader_reflection_type_vtbl =
-{
-    d3d10_shader_reflection_type_GetDesc,
-    d3d10_shader_reflection_type_GetMemberTypeByIndex,
-    d3d10_shader_reflection_type_GetMemberTypeByName,
-    d3d10_shader_reflection_type_GetMemberTypeName,
-};
-
 HRESULT WINAPI D3D10ReflectShader(const void *data, SIZE_T data_size, ID3D10ShaderReflection **reflector)
 {
     struct d3dcompiler_shader_reflection *object;
@@ -2328,7 +1900,7 @@ HRESULT WINAPI D3D10ReflectShader(const void *data, SIZE_T data_size, ID3D10Shad
         return E_OUTOFMEMORY;
     }
 
-    object->ID3D10ShaderReflection_iface.lpVtbl = &d3d10_shader_reflection_vtbl;
+    object->ID3D11ShaderReflection_iface.lpVtbl = &d3dcompiler_shader_reflection_vtbl;
     object->interface_version = D3DCOMPILER_REFLECTION_VERSION_D3D10;
     object->refcount = 1;
 
@@ -2340,7 +1912,7 @@ HRESULT WINAPI D3D10ReflectShader(const void *data, SIZE_T data_size, ID3D10Shad
         return hr;
     }
 
-    *reflector = &object->ID3D10ShaderReflection_iface;
+    *reflector = (ID3D10ShaderReflection *)&object->ID3D11ShaderReflection_iface;
 
     TRACE("Created ID3D10ShaderReflection %p.\n", object);
 
-- 
2.34.1




More information about the wine-devel mailing list