Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/d3dcompiler_43/reflection.c | 16 ++++++++++++++++ dlls/d3dcompiler_43/tests/reflection.c | 12 +++++++----- 2 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/dlls/d3dcompiler_43/reflection.c b/dlls/d3dcompiler_43/reflection.c index e492011c55f..050ddc47829 100644 --- a/dlls/d3dcompiler_43/reflection.c +++ b/dlls/d3dcompiler_43/reflection.c @@ -51,6 +51,7 @@ struct d3dcompiler_shader_reflection_type
D3D11_SHADER_TYPE_DESC desc; struct d3dcompiler_shader_reflection_type_member *members; + char *name_string; };
struct d3dcompiler_shader_reflection_type_member @@ -222,6 +223,7 @@ static void d3dcompiler_shader_reflection_type_destroy(struct wine_rb_entry *ent HeapFree(GetProcessHeap(), 0, t->members); }
+ heap_free(t->name_string); HeapFree(GetProcessHeap(), 0, t); }
@@ -1244,6 +1246,20 @@ static HRESULT d3dcompiler_parse_type(struct d3dcompiler_shader_reflection_type } }
+ if ((type->reflection->target & D3DCOMPILER_SHADER_TARGET_VERSION_MASK) >= 0x500) + { + read_dword(&ptr, &offset); + if (!(type->name_string = heap_alloc(strlen(data + offset) + 1))) + { + ERR("Failed to allocate name memory.\n"); + heap_free(members); + return E_OUTOFMEMORY; + } + strcpy(type->name_string, data + offset); + desc->Name = type->name_string; + TRACE("Name %s\n", debugstr_a(type->name_string)); + } + type->members = members;
return S_OK; diff --git a/dlls/d3dcompiler_43/tests/reflection.c b/dlls/d3dcompiler_43/tests/reflection.c index 2c1c9028bbb..1b9d2d418d9 100644 --- a/dlls/d3dcompiler_43/tests/reflection.c +++ b/dlls/d3dcompiler_43/tests/reflection.c @@ -1207,11 +1207,11 @@ static const struct {
static const D3D11_SHADER_TYPE_DESC test_reflection_constant_buffer_type_result[] = { - {D3D11_SVC_INTERFACE_POINTER, D3D11_SVT_INTERFACE_POINTER, 1, 4, 0, 1, 0}, - {D3D_SVC_SCALAR, D3D_SVT_FLOAT, 1, 1, 0, 1, 0}, - {D3D_SVC_SCALAR, D3D_SVT_FLOAT, 1, 1, 2, 1, 0}, - {D3D_SVC_SCALAR, D3D_SVT_INT, 1, 1, 0, 1, 0}, - {D3D_SVC_STRUCT, D3D_SVT_VOID, 1, 2, 0, 1, 0}, + {D3D11_SVC_INTERFACE_POINTER, D3D11_SVT_INTERFACE_POINTER, 1, 4, 0, 1, 0, "iTest"}, + {D3D_SVC_SCALAR, D3D_SVT_FLOAT, 1, 1, 0, 1, 0, "float"}, + {D3D_SVC_SCALAR, D3D_SVT_FLOAT, 1, 1, 2, 1, 0, "float"}, + {D3D_SVC_SCALAR, D3D_SVT_INT, 1, 1, 0, 1, 0, "int"}, + {D3D_SVC_STRUCT, D3D_SVT_VOID, 1, 2, 0, 1, 0, "s"}, };
static void test_reflection_constant_buffer(void) @@ -1459,6 +1459,8 @@ static void test_reflection_constant_buffer(void) i, tdesc.Elements, ptdesc->Elements); ok(tdesc.Offset == ptdesc->Offset, "GetDesc(%u) Offset failed, got %u, expected %u\n", i, tdesc.Offset, ptdesc->Offset); + ok(!strcmp(tdesc.Name, ptdesc->Name), "GetDesc(%u) Name failed, got %s, expected %s\n", + i, tdesc.Name, ptdesc->Name); }
/* types */
On Fri, Jul 12, 2019 at 7:32 PM Zebediah Figura zfigura@codeweavers.com wrote:
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
dlls/d3dcompiler_43/reflection.c | 16 ++++++++++++++++ dlls/d3dcompiler_43/tests/reflection.c | 12 +++++++----- 2 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/dlls/d3dcompiler_43/reflection.c b/dlls/d3dcompiler_43/reflection.c index e492011c55f..050ddc47829 100644 --- a/dlls/d3dcompiler_43/reflection.c +++ b/dlls/d3dcompiler_43/reflection.c @@ -51,6 +51,7 @@ struct d3dcompiler_shader_reflection_type
D3D11_SHADER_TYPE_DESC desc; struct d3dcompiler_shader_reflection_type_member *members;
- char *name_string;
};
This is okay, an alternative is to use the same "char *name;" used in all the other reflection structures.
- if ((type->reflection->target & D3DCOMPILER_SHADER_TARGET_VERSION_MASK) >= 0x500)
- {
read_dword(&ptr, &offset);
if (!(type->name_string = heap_alloc(strlen(data + offset) + 1)))
{
ERR("Failed to allocate name memory.\n");
heap_free(members);
return E_OUTOFMEMORY;
}
strcpy(type->name_string, data + offset);
desc->Name = type->name_string;
TRACE("Name %s\n", debugstr_a(type->name_string));
- }
This could be simplified a bit by making use of copy_name().