[PATCH v4 10/11] d3dcompiler: implement d3d10 ShaderReflectionVariable methods.

Connor McAdams conmanx360 at gmail.com
Mon Oct 28 12:15:39 CDT 2019


Adds the methods for d3d10 ShaderReflectionVariable interface, as well
as fills in the constant buffer methods that use the
ShaderReflectionVariable interface.

Signed-off-by: Connor McAdams <conmanx360 at gmail.com>
---
 dlls/d3dcompiler_43/reflection.c | 87 ++++++++++++++++++++++++++++++--
 1 file changed, 84 insertions(+), 3 deletions(-)

diff --git a/dlls/d3dcompiler_43/reflection.c b/dlls/d3dcompiler_43/reflection.c
index d6b55eae1b..334275b189 100644
--- a/dlls/d3dcompiler_43/reflection.c
+++ b/dlls/d3dcompiler_43/reflection.c
@@ -963,15 +963,45 @@ static HRESULT STDMETHODCALLTYPE d3d10_shader_reflection_constant_buffer_GetDesc
 static ID3D10ShaderReflectionVariable * STDMETHODCALLTYPE d3d10_shader_reflection_constant_buffer_GetVariableByIndex(
         ID3D10ShaderReflectionConstantBuffer *iface, UINT index)
 {
-    FIXME("iface %p, index %d stub!\n", iface, index);
+    struct d3dcompiler_shader_reflection_constant_buffer *This = impl_from_ID3D10ShaderReflectionConstantBuffer(iface);
 
-    return &null_variable.ID3D10ShaderReflectionVariable_iface;
+    TRACE("iface %p, index %u\n", iface, index);
+
+    if (index >= This->variable_count)
+    {
+        WARN("Invalid index specified\n");
+        return &null_variable.ID3D10ShaderReflectionVariable_iface;
+    }
+
+    return &This->variables[index].ID3D10ShaderReflectionVariable_iface;
 }
 
 static ID3D10ShaderReflectionVariable * STDMETHODCALLTYPE d3d10_shader_reflection_constant_buffer_GetVariableByName(
         ID3D10ShaderReflectionConstantBuffer *iface, const char *name)
 {
-    FIXME("iface %p, name %s stub!\n", iface, name);
+    struct d3dcompiler_shader_reflection_constant_buffer *This = 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 < This->variable_count; ++i)
+    {
+        struct d3dcompiler_shader_reflection_variable *v = &This->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;
 }
@@ -1073,6 +1103,56 @@ static const struct ID3D11ShaderReflectionConstantBufferVtbl d3dcompiler_shader_
     d3dcompiler_shader_reflection_constant_buffer_GetVariableByName,
 };
 
+/* ID3D10ShaderReflectionVariable methods */
+
+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 *This = impl_from_ID3D10ShaderReflectionVariable(iface);
+
+    TRACE("iface %p, desc %p\n", iface, desc);
+
+    if (This == &null_variable)
+    {
+        WARN("Null variable specified\n");
+        return E_FAIL;
+    }
+
+    if (!desc)
+    {
+        WARN("Invalid argument specified\n");
+        return E_FAIL;
+    }
+
+    desc->Name = This->name;
+    desc->StartOffset = This->start_offset;
+    desc->Size = This->size;
+    desc->uFlags = This->flags;
+    desc->DefaultValue = This->default_value;
+
+    return S_OK;
+}
+
+static ID3D10ShaderReflectionType * STDMETHODCALLTYPE d3d10_shader_reflection_variable_GetType(
+        ID3D10ShaderReflectionVariable *iface)
+{
+    FIXME("iface %p stub!\n", iface);
+
+    return &null_type.ID3D10ShaderReflectionType_iface;
+}
+
+static const struct ID3D10ShaderReflectionVariableVtbl d3d10_shader_reflection_variable_vtbl =
+{
+    /* ID3D10ShaderReflectionVariable methods */
+    d3d10_shader_reflection_variable_GetDesc,
+    d3d10_shader_reflection_variable_GetType,
+};
+
 /* ID3D11ShaderReflectionVariable methods */
 
 static inline struct d3dcompiler_shader_reflection_variable *impl_from_ID3D11ShaderReflectionVariable(ID3D11ShaderReflectionVariable *iface)
@@ -1613,6 +1693,7 @@ static HRESULT d3dcompiler_parse_variables(struct d3dcompiler_shader_reflection_
         DWORD offset;
 
         v->ID3D11ShaderReflectionVariable_iface.lpVtbl = &d3dcompiler_shader_reflection_variable_vtbl;
+        v->ID3D10ShaderReflectionVariable_iface.lpVtbl = &d3d10_shader_reflection_variable_vtbl;
         v->constant_buffer = cb;
 
         read_dword(&ptr, &offset);
-- 
2.20.1




More information about the wine-devel mailing list