Signed-off-by: Zhiyi Zhang zzhang@codeweavers.com --- libs/vkd3d/resource.c | 23 +++++++++++++++++++++-- libs/vkd3d/vkd3d_private.h | 1 + 2 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/libs/vkd3d/resource.c b/libs/vkd3d/resource.c index 7afcaea..3f8e05e 100644 --- a/libs/vkd3d/resource.c +++ b/libs/vkd3d/resource.c @@ -736,6 +736,7 @@ static ULONG d3d12_resource_decref(struct d3d12_resource *resource)
if (!refcount) { + if (resource->name) vkd3d_free(resource->name); vkd3d_private_store_destroy(&resource->private_store); d3d12_resource_destroy(resource, resource->device); vkd3d_free(resource); @@ -842,10 +843,27 @@ static HRESULT STDMETHODCALLTYPE d3d12_resource_SetPrivateDataInterface(ID3D12Re static HRESULT STDMETHODCALLTYPE d3d12_resource_SetName(ID3D12Resource *iface, const WCHAR *name) { struct d3d12_resource *resource = impl_from_ID3D12Resource(iface); + HRESULT hr;
- FIXME("iface %p, name %s stub!\n", iface, debugstr_w(name, resource->device->wchar_size)); + TRACE("iface %p, name %s.\n", iface, debugstr_w(name, resource->device->wchar_size));
- return E_NOTIMPL; + if (resource->vk_memory) + { + hr = vkd3d_set_vk_object_name(resource->device, (uint64_t)resource->vk_memory, + VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT, name); + if (FAILED(hr)) return hr; + } + + if (d3d12_resource_is_buffer(resource)) + hr = vkd3d_set_vk_object_name(resource->device, (uint64_t)resource->u.vk_buffer, + VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT, name); + else + hr = vkd3d_set_vk_object_name(resource->device, (uint64_t)resource->u.vk_image, + VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, name); + + if (FAILED(hr)) return hr; + + return vkd3d_set_name(&resource->name, name, resource->device->wchar_size); }
static HRESULT STDMETHODCALLTYPE d3d12_resource_GetDevice(ID3D12Resource *iface, @@ -1118,6 +1136,7 @@ static HRESULT d3d12_resource_init(struct d3d12_resource *resource, struct d3d12 resource->ID3D12Resource_iface.lpVtbl = &d3d12_resource_vtbl; resource->refcount = 1; resource->internal_refcount = 1; + resource->name = NULL;
resource->desc = *desc;
diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h index eb4d794..fbabc39 100644 --- a/libs/vkd3d/vkd3d_private.h +++ b/libs/vkd3d/vkd3d_private.h @@ -292,6 +292,7 @@ struct d3d12_resource ID3D12Resource ID3D12Resource_iface; LONG refcount; LONG internal_refcount; + WCHAR *name;
D3D12_RESOURCE_DESC desc;