[PATCH 6/8] d3dcompiler: Implement ID3D10ShaderReflectionType.

Connor McAdams conmanx360 at gmail.com
Wed Nov 6 17:43:03 CST 2019


Implement methods for ID3D10ShaderReflectionType interface.

Signed-off-by: Connor McAdams <conmanx360 at gmail.com>
---
Extra info, structs being memcpy'd:
typedef struct _D3D10_SHADER_TYPE_DESC {
  D3D10_SHADER_VARIABLE_CLASS Class;
  D3D10_SHADER_VARIABLE_TYPE  Type;
  UINT                        Rows;
  UINT                        Columns;
  UINT                        Elements;
  UINT                        Members;
  UINT                        Offset;
} D3D10_SHADER_TYPE_DESC;

typedef struct _D3D11_SHADER_TYPE_DESC {
  D3D_SHADER_VARIABLE_CLASS Class;
  D3D_SHADER_VARIABLE_TYPE  Type;
  UINT                      Rows;
  UINT                      Columns;
  UINT                      Elements;
  UINT                      Members;
  UINT                      Offset;
  LPCSTR                    Name;
} D3D11_SHADER_TYPE_DESC;
---
 dlls/d3dcompiler_43/reflection.c | 109 +++++++++++++++++++++++++++++++
 1 file changed, 109 insertions(+)

diff --git a/dlls/d3dcompiler_43/reflection.c b/dlls/d3dcompiler_43/reflection.c
index e7e0bb69c9..5856c1e008 100644
--- a/dlls/d3dcompiler_43/reflection.c
+++ b/dlls/d3dcompiler_43/reflection.c
@@ -982,6 +982,114 @@ static const struct ID3D11ShaderReflectionVariableVtbl d3dcompiler_shader_reflec
     d3dcompiler_shader_reflection_variable_GetInterfaceSlot,
 };
 
+/* ID3D10ShaderReflectionType methods */
+#ifndef D3D_COMPILER_VERSION
+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 *reflection = impl_from_ID3D10ShaderReflectionType(iface);
+
+    TRACE("iface %p, desc %p.\n", iface, desc);
+
+    if (reflection == &null_type)
+    {
+        WARN("Null type specified.\n");
+        return E_FAIL;
+    }
+
+    if (!desc)
+    {
+        WARN("Invalid argument specified.\n");
+        return E_FAIL;
+    }
+
+    memcpy(desc, &reflection->desc, sizeof(*desc));
+
+    return S_OK;
+}
+
+static ID3D10ShaderReflectionType * STDMETHODCALLTYPE d3d10_shader_reflection_type_GetMemberTypeByIndex(
+        ID3D10ShaderReflectionType *iface, UINT index)
+{
+    struct d3dcompiler_shader_reflection_type *reflection = impl_from_ID3D10ShaderReflectionType(iface);
+
+    TRACE("iface %p, index %u.\n", iface, index);
+
+    if (index >= reflection->desc.Members)
+    {
+        WARN("Invalid index specified.\n");
+        return &null_type.ID3D10ShaderReflectionType_iface;
+    }
+
+    return &reflection->members[index].type->ID3D10ShaderReflectionType_iface;
+}
+
+static ID3D10ShaderReflectionType * STDMETHODCALLTYPE d3d10_shader_reflection_type_GetMemberTypeByName(
+        ID3D10ShaderReflectionType *iface, const char *name)
+{
+    struct d3dcompiler_shader_reflection_type *reflection = 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 < reflection->desc.Members; ++i)
+    {
+        struct d3dcompiler_shader_reflection_type_member *member = &reflection->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 *reflection = impl_from_ID3D10ShaderReflectionType(iface);
+
+    TRACE("iface %p, index %u.\n", iface, index);
+
+    if (reflection == &null_type)
+    {
+        WARN("Null type specified.\n");
+        return "$Invalid";
+    }
+
+    if (index >= reflection->desc.Members)
+    {
+        WARN("Invalid index specified.\n");
+        return NULL;
+    }
+
+    return reflection->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,
+};
+#endif
+
 /* ID3D11ShaderReflectionType methods */
 
 static inline struct d3dcompiler_shader_reflection_type *impl_from_ID3D11ShaderReflectionType(ID3D11ShaderReflectionType *iface)
@@ -1409,6 +1517,7 @@ 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;
 
-- 
2.20.1




More information about the wine-devel mailing list