Adds the methods for d3d10 ShaderReflectionType interface, as well as fills in the ShaderReflectionVariable methods that use the ShaderReflectionType interface.
Signed-off-by: Connor McAdams conmanx360@gmail.com --- dlls/d3dcompiler_43/reflection.c | 115 ++++++++++++++++++++++++++++++- 1 file changed, 113 insertions(+), 2 deletions(-)
diff --git a/dlls/d3dcompiler_43/reflection.c b/dlls/d3dcompiler_43/reflection.c index 334275b189..57b92150d4 100644 --- a/dlls/d3dcompiler_43/reflection.c +++ b/dlls/d3dcompiler_43/reflection.c @@ -1141,9 +1141,11 @@ static HRESULT STDMETHODCALLTYPE d3d10_shader_reflection_variable_GetDesc( static ID3D10ShaderReflectionType * STDMETHODCALLTYPE d3d10_shader_reflection_variable_GetType( ID3D10ShaderReflectionVariable *iface) { - FIXME("iface %p stub!\n", iface); + struct d3dcompiler_shader_reflection_variable *This = impl_from_ID3D10ShaderReflectionVariable(iface);
- return &null_type.ID3D10ShaderReflectionType_iface; + TRACE("iface %p\n", iface); + + return &This->type->ID3D10ShaderReflectionType_iface; }
static const struct ID3D10ShaderReflectionVariableVtbl d3d10_shader_reflection_variable_vtbl = @@ -1225,6 +1227,114 @@ static const struct ID3D11ShaderReflectionVariableVtbl d3dcompiler_shader_reflec d3dcompiler_shader_reflection_variable_GetInterfaceSlot, };
+/* ID3D10ShaderReflectionType methods */ + +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 *This = impl_from_ID3D10ShaderReflectionType(iface); + + TRACE("iface %p, desc %p\n", iface, desc); + + if (This == &null_type) + { + WARN("Null type specified\n"); + return E_FAIL; + } + + if (!desc) + { + WARN("Invalid argument specified\n"); + return E_FAIL; + } + + memcpy(desc, &This->desc, sizeof(*desc)); + + return S_OK; +} + +static ID3D10ShaderReflectionType * STDMETHODCALLTYPE d3d10_shader_reflection_type_GetMemberTypeByIndex( + ID3D10ShaderReflectionType *iface, UINT index) +{ + struct d3dcompiler_shader_reflection_type *This = impl_from_ID3D10ShaderReflectionType(iface); + + TRACE("iface %p, index %u\n", iface, index); + + if (index >= This->desc.Members) + { + WARN("Invalid index specified\n"); + return &null_type.ID3D10ShaderReflectionType_iface; + } + + return &This->members[index].type->ID3D10ShaderReflectionType_iface; +} + +static ID3D10ShaderReflectionType * STDMETHODCALLTYPE d3d10_shader_reflection_type_GetMemberTypeByName( + ID3D10ShaderReflectionType *iface, const char *name) +{ + struct d3dcompiler_shader_reflection_type *This = 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 < This->desc.Members; ++i) + { + struct d3dcompiler_shader_reflection_type_member *member = &This->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 *This = impl_from_ID3D10ShaderReflectionType(iface); + + TRACE("iface %p, index %u\n", iface, index); + + if (This == &null_type) + { + WARN("Null type specified\n"); + return "$Invalid"; + } + + if (index >= This->desc.Members) + { + WARN("Invalid index specified\n"); + return NULL; + } + + return This->members[index].name; +} + +static const struct ID3D10ShaderReflectionTypeVtbl d3d10_shader_reflection_type_vtbl = +{ + /* ID3D10ShaderReflectionType methods */ + d3d10_shader_reflection_type_GetDesc, + d3d10_shader_reflection_type_GetMemberTypeByIndex, + d3d10_shader_reflection_type_GetMemberTypeByName, + d3d10_shader_reflection_type_GetMemberTypeName, +}; + /* ID3D11ShaderReflectionType methods */
static inline struct d3dcompiler_shader_reflection_type *impl_from_ID3D11ShaderReflectionType(ID3D11ShaderReflectionType *iface) @@ -1652,6 +1762,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;