vkd3d: Implement d3d12_query_heap_SetName().

Signed-off-by: Zhiyi Zhang <zzhang@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zhiyi Zhang 2019-01-30 00:44:31 +03:30 committed by Alexandre Julliard
parent 3b1af3c85d
commit d0e2802a35
8 changed files with 231 additions and 3 deletions

View File

@ -59,7 +59,8 @@ noinst_LTLIBRARIES = libvkd3d-common.la
libvkd3d_common_la_SOURCES = \
include/private/vkd3d_debug.h \
libs/vkd3d-common/debug.c \
libs/vkd3d-common/memory.c
libs/vkd3d-common/memory.c \
libs/vkd3d-common/utf8.c
lib_LTLIBRARIES = libvkd3d-shader.la libvkd3d.la libvkd3d-utils.la
@ -88,6 +89,7 @@ libvkd3d_la_SOURCES = \
include/private/vkd3d_common.h \
include/private/vkd3d_debug.h \
include/private/vkd3d_memory.h \
include/private/vkd3d_utf8.h \
include/private/vkd3d_test.h \
include/vkd3d_d3d12.idl \
include/vkd3d_d3dcommon.idl \

View File

@ -0,0 +1,26 @@
/*
* Copyright 2019 Zhiyi Zhang for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __VKD3D_UTF8_H
#define __VKD3D_UTF8_H
#include "vkd3d_common.h"
char *vkd3d_strdup_w_utf8(const WCHAR *wstr, size_t wchar_size) DECLSPEC_HIDDEN;
#endif /* __VKD3D_UTF8_H */

162
libs/vkd3d-common/utf8.c Normal file
View File

@ -0,0 +1,162 @@
/*
* Copyright 2000 Alexandre Julliard
* Copyright 2019 Zhiyi Zhang for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "vkd3d_memory.h"
#include "vkd3d_utf8.h"
#include <inttypes.h>
static size_t vkd3d_utf8_len(uint32_t c)
{
/* 0x00-0x7f: 1 byte */
if (c < 0x80)
return 1;
/* 0x80-0x7ff: 2 bytes */
if (c < 0x800)
return 2;
/* 0x800-0xffff: 3 bytes */
if (c < 0x10000)
return 3;
/* 0x10000-0x10ffff: 4 bytes */
return 4;
}
static void vkd3d_utf8_append(char **dst, uint32_t c)
{
char *d = *dst;
/* 0x00-0x7f: 1 byte */
if (c < 0x80)
{
d[0] = c;
*dst += 1;
return;
}
/* 0x80-0x7ff: 2 bytes */
if (c < 0x800)
{
d[1] = 0x80 | (c & 0x3f);
c >>= 6;
d[0] = 0xc0 | c;
*dst += 2;
return;
}
/* 0x800-0xffff: 3 bytes */
if (c < 0x10000) /* 0x800-0xffff: 3 bytes */
{
d[2] = 0x80 | (c & 0x3f);
c >>= 6;
d[1] = 0x80 | (c & 0x3f);
c >>= 6;
d[0] = 0xe0 | c;
*dst += 3;
return;
}
/* 0x10000-0x10ffff: 4 bytes */
d[3] = 0x80 | (c & 0x3f);
c >>= 6;
d[2] = 0x80 | (c & 0x3f);
c >>= 6;
d[1] = 0x80 | (c & 0x3f);
c >>= 6;
d[0] = 0xf0 | c;
*dst += 4;
}
static uint32_t vkd3d_utf16_read(const uint16_t **src)
{
const uint16_t *s = *src;
if (s[0] < 0xd800 || s[0] > 0xdfff) /* Not a surrogate pair. */
{
*src += 1;
return s[0];
}
if (s[0] > 0xdbff /* Invalid high surrogate. */
|| s[1] < 0xdc00 || s[1] > 0xdfff) /* Invalid low surrogate. */
{
*src += 1;
return 0;
}
*src += 2;
return 0x10000 + ((s[0] & 0x3ff) << 10) + (s[1] & 0x3ff);
}
static char *vkd3d_strdup_w16_utf8(const uint16_t *wstr)
{
const uint16_t *src = wstr;
size_t dst_size = 0;
uint32_t c;
char *dst;
while (*src)
{
if (!(c = vkd3d_utf16_read(&src)))
continue;
dst_size += vkd3d_utf8_len(c);
}
++dst_size;
if (!(dst = vkd3d_malloc(dst_size)))
return NULL;
src = wstr;
while (*src)
{
if (!(c = vkd3d_utf16_read(&src)))
continue;
vkd3d_utf8_append(&dst, c);
}
*dst = 0;
return dst;
}
static char *vkd3d_strdup_w32_utf8(const uint32_t *wstr)
{
const uint32_t *src = wstr;
size_t dst_size = 0;
char *dst;
while (*src)
dst_size += vkd3d_utf8_len(*src++);
++dst_size;
if (!(dst = vkd3d_malloc(dst_size)))
return NULL;
src = wstr;
while (*src)
vkd3d_utf8_append(&dst, *src++);
*dst = 0;
return dst;
}
char *vkd3d_strdup_w_utf8(const WCHAR *wstr, size_t wchar_size)
{
if (wchar_size == 2)
return vkd3d_strdup_w16_utf8((const uint16_t *)wstr);
return vkd3d_strdup_w32_utf8((const uint32_t *)wstr);
}

View File

@ -84,6 +84,7 @@ static const char * const required_device_extensions[] =
static const struct vkd3d_optional_extension_info optional_device_extensions[] =
{
{VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME, offsetof(struct vkd3d_vulkan_info, KHR_push_descriptor)},
{VK_EXT_DEBUG_MARKER_EXTENSION_NAME, offsetof(struct vkd3d_vulkan_info, EXT_debug_marker)},
{VK_EXT_TRANSFORM_FEEDBACK_EXTENSION_NAME,
offsetof(struct vkd3d_vulkan_info, EXT_transform_feedback)},
{VK_EXT_VERTEX_ATTRIBUTE_DIVISOR_EXTENSION_NAME,

View File

@ -2730,9 +2730,10 @@ static HRESULT STDMETHODCALLTYPE d3d12_query_heap_SetName(ID3D12QueryHeap *iface
{
struct d3d12_query_heap *heap = impl_from_ID3D12QueryHeap(iface);
FIXME("iface %p, name %s stub!\n", iface, debugstr_w(name, heap->device->wchar_size));
TRACE("iface %p, name %s.\n", iface, debugstr_w(name, heap->device->wchar_size));
return E_NOTIMPL;
return vkd3d_set_vk_object_name(heap->device, (uint64_t)heap->vk_query_pool,
VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT, name);
}
static HRESULT STDMETHODCALLTYPE d3d12_query_heap_GetDevice(ID3D12QueryHeap *iface,

View File

@ -642,3 +642,32 @@ HRESULT vkd3d_set_private_data_interface(struct vkd3d_private_store *store,
pthread_mutex_unlock(&store->mutex);
return hr;
}
HRESULT vkd3d_set_vk_object_name(struct d3d12_device *device, uint64_t vk_object,
VkDebugReportObjectTypeEXT vk_object_type, const WCHAR *name)
{
const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
VkDebugMarkerObjectNameInfoEXT info;
char *name_utf8;
VkResult vr;
if (!name)
return E_INVALIDARG;
if (!device->vk_info.EXT_debug_marker)
return S_OK;
if (!(name_utf8 = vkd3d_strdup_w_utf8(name, device->wchar_size)))
return E_OUTOFMEMORY;
info.sType = VK_STRUCTURE_TYPE_DEBUG_MARKER_OBJECT_NAME_INFO_EXT;
info.pNext = NULL;
info.objectType = vk_object_type;
info.object = vk_object;
info.pObjectName = name_utf8;
vr = VK_CALL(vkDebugMarkerSetObjectNameEXT(device->vk_device, &info));
vkd3d_free(name_utf8);
return hresult_from_vk_result(vr);
}

View File

@ -25,6 +25,7 @@
#include "vkd3d_common.h"
#include "vkd3d_memory.h"
#include "vkd3d_utf8.h"
#include "list.h"
#include "rbtree.h"
@ -87,6 +88,7 @@ struct vkd3d_vulkan_info
bool EXT_debug_report;
/* device extensions */
bool KHR_push_descriptor;
bool EXT_debug_marker;
bool EXT_transform_feedback;
bool EXT_vertex_attribute_divisor;
@ -1026,4 +1028,7 @@ static inline void vkd3d_set_thread_name(const char *name)
#endif
}
HRESULT vkd3d_set_vk_object_name(struct d3d12_device *device, uint64_t vk_object,
VkDebugReportObjectTypeEXT vk_object_type, const WCHAR *name) DECLSPEC_HIDDEN;
#endif /* __VKD3D_PRIVATE_H */

View File

@ -174,6 +174,8 @@ VK_DEVICE_PFN(vkSetEvent)
VK_DEVICE_PFN(vkUnmapMemory)
VK_DEVICE_PFN(vkUpdateDescriptorSets)
VK_DEVICE_PFN(vkWaitForFences)
/* VK_EXT_debug_marker */
VK_DEVICE_EXT_PFN(vkDebugMarkerSetObjectNameEXT)
/* VK_KHR_push_descriptor */
VK_DEVICE_EXT_PFN(vkCmdPushDescriptorSetKHR)
/* VK_EXT_transform_feedback */