mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-01-28 13:05:02 -08:00
libs/vkd3d: Support both native and Win32 wchar_t.
This commit is contained in:
parent
1f51eebe12
commit
3019a3e8f1
@ -37,7 +37,7 @@ void vkd3d_dbg_printf(enum vkd3d_dbg_level level, const char *function,
|
||||
|
||||
const char *vkd3d_dbg_sprintf(const char *fmt, ...) VKD3D_PRINTF_FUNC(1, 2) DECLSPEC_HIDDEN;
|
||||
const char *debugstr_a(const char *str) DECLSPEC_HIDDEN;
|
||||
const char *debugstr_w(const WCHAR *wstr) DECLSPEC_HIDDEN;
|
||||
const char *debugstr_w(const WCHAR *wstr, size_t wchar_size) DECLSPEC_HIDDEN;
|
||||
|
||||
#define VKD3D_DBG_LOG(level) \
|
||||
do { \
|
||||
|
@ -34,6 +34,7 @@ struct vkd3d_device_create_info
|
||||
{
|
||||
D3D_FEATURE_LEVEL minimum_feature_level;
|
||||
vkd3d_signal_event_pfn signal_event_pfn;
|
||||
size_t wchar_size;
|
||||
};
|
||||
|
||||
/* resource flags */
|
||||
|
@ -21,6 +21,10 @@
|
||||
|
||||
#if !defined(_WIN32) || defined(__WIDL__)
|
||||
|
||||
# if !defined(__WIDL__) && !defined(VKD3D_WIN32_WCHAR)
|
||||
# include <wchar.h>
|
||||
# endif
|
||||
|
||||
# ifdef __GNUC__
|
||||
# define DECLSPEC_ALIGN(x) __attribute__((aligned(x)))
|
||||
# endif
|
||||
@ -72,7 +76,11 @@ typedef unsigned long ULONG_PTR;
|
||||
|
||||
typedef ULONG_PTR SIZE_T;
|
||||
|
||||
# ifdef VKD3D_WIN32_WCHAR
|
||||
typedef unsigned short WCHAR;
|
||||
# else
|
||||
typedef wchar_t WCHAR;
|
||||
# endif /* VKD3D_WIN32_WCHAR */
|
||||
typedef void *HANDLE;
|
||||
|
||||
/* GUID */
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#define VKD3D_DEBUG_BUFFER_COUNT 64
|
||||
#define VKD3D_DEBUG_BUFFER_SIZE 512
|
||||
@ -161,10 +162,10 @@ const char *debugstr_a(const char *str)
|
||||
return buffer;
|
||||
}
|
||||
|
||||
const char *debugstr_w(const WCHAR *wstr)
|
||||
static const char *debugstr_w16(const uint16_t *wstr)
|
||||
{
|
||||
char *buffer, *ptr;
|
||||
WCHAR c;
|
||||
uint16_t c;
|
||||
|
||||
if (!wstr)
|
||||
return "(null)";
|
||||
@ -220,3 +221,70 @@ const char *debugstr_w(const WCHAR *wstr)
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
static const char *debugstr_w32(const uint32_t *wstr)
|
||||
{
|
||||
char *buffer, *ptr;
|
||||
uint32_t c;
|
||||
|
||||
if (!wstr)
|
||||
return "(null)";
|
||||
|
||||
ptr = buffer = get_buffer();
|
||||
|
||||
*ptr++ = '"';
|
||||
while ((c = *wstr++) && ptr <= buffer + VKD3D_DEBUG_BUFFER_SIZE - 10)
|
||||
{
|
||||
int escape_char;
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case '"':
|
||||
case '\\':
|
||||
case '\n':
|
||||
case '\r':
|
||||
case '\t':
|
||||
escape_char = c;
|
||||
break;
|
||||
default:
|
||||
escape_char = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (escape_char)
|
||||
{
|
||||
*ptr++ = '\\';
|
||||
*ptr++ = escape_char;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isprint(c))
|
||||
{
|
||||
*ptr++ = c;
|
||||
}
|
||||
else
|
||||
{
|
||||
*ptr++ = '\\';
|
||||
sprintf(ptr, "%04x", c);
|
||||
ptr += 4;
|
||||
}
|
||||
}
|
||||
*ptr++ = '"';
|
||||
|
||||
if (c)
|
||||
{
|
||||
*ptr++ = '.';
|
||||
*ptr++ = '.';
|
||||
*ptr++ = '.';
|
||||
}
|
||||
*ptr = '\0';
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
const char *debugstr_w(const WCHAR *wstr, size_t wchar_size)
|
||||
{
|
||||
if (wchar_size == 2)
|
||||
return debugstr_w16((const uint16_t *)wstr);
|
||||
return debugstr_w32((const uint32_t *)wstr);
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ HRESULT WINAPI D3D12CreateDevice(IUnknown *adapter,
|
||||
|
||||
create_info.minimum_feature_level = minimum_feature_level;
|
||||
create_info.signal_event_pfn = vkd3d_signal_event;
|
||||
create_info.wchar_size = sizeof(WCHAR);
|
||||
|
||||
return vkd3d_create_device(&create_info, riid, device);
|
||||
}
|
||||
|
@ -338,7 +338,9 @@ static HRESULT STDMETHODCALLTYPE d3d12_fence_SetPrivateDataInterface(ID3D12Fence
|
||||
|
||||
static HRESULT STDMETHODCALLTYPE d3d12_fence_SetName(ID3D12Fence *iface, const WCHAR *name)
|
||||
{
|
||||
FIXME("iface %p, name %s stub!\n", iface, debugstr_w(name));
|
||||
struct d3d12_fence *fence = impl_from_ID3D12Fence(iface);
|
||||
|
||||
FIXME("iface %p, name %s stub!\n", iface, debugstr_w(name, fence->device->wchar_size));
|
||||
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
@ -817,7 +819,9 @@ static HRESULT STDMETHODCALLTYPE d3d12_command_allocator_SetPrivateDataInterface
|
||||
|
||||
static HRESULT STDMETHODCALLTYPE d3d12_command_allocator_SetName(ID3D12CommandAllocator *iface, const WCHAR *name)
|
||||
{
|
||||
FIXME("iface %p, name %s stub!\n", iface, debugstr_w(name));
|
||||
struct d3d12_command_allocator *allocator = impl_from_ID3D12CommandAllocator(iface);
|
||||
|
||||
FIXME("iface %p, name %s stub!\n", iface, debugstr_w(name, allocator->device->wchar_size));
|
||||
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
@ -1340,7 +1344,9 @@ static HRESULT STDMETHODCALLTYPE d3d12_command_list_SetPrivateDataInterface(ID3D
|
||||
|
||||
static HRESULT STDMETHODCALLTYPE d3d12_command_list_SetName(ID3D12GraphicsCommandList *iface, const WCHAR *name)
|
||||
{
|
||||
FIXME("iface %p, name %s stub!\n", iface, debugstr_w(name));
|
||||
struct d3d12_command_list *list = impl_from_ID3D12GraphicsCommandList(iface);
|
||||
|
||||
FIXME("iface %p, name %s stub!\n", iface, debugstr_w(name, list->device->wchar_size));
|
||||
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
@ -3468,7 +3474,9 @@ static HRESULT STDMETHODCALLTYPE d3d12_command_queue_SetPrivateDataInterface(ID3
|
||||
|
||||
static HRESULT STDMETHODCALLTYPE d3d12_command_queue_SetName(ID3D12CommandQueue *iface, const WCHAR *name)
|
||||
{
|
||||
FIXME("iface %p, name %s stub!\n", iface, debugstr_w(name));
|
||||
struct d3d12_command_queue *command_queue = impl_from_ID3D12CommandQueue(iface);
|
||||
|
||||
FIXME("iface %p, name %s stub!\n", iface, debugstr_w(name, command_queue->device->wchar_size));
|
||||
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
@ -3865,7 +3873,9 @@ static HRESULT STDMETHODCALLTYPE d3d12_command_signature_SetPrivateDataInterface
|
||||
|
||||
static HRESULT STDMETHODCALLTYPE d3d12_command_signature_SetName(ID3D12CommandSignature *iface, const WCHAR *name)
|
||||
{
|
||||
FIXME("iface %p, name %s stub!\n", iface, debugstr_w(name));
|
||||
struct d3d12_command_signature *signature = impl_from_ID3D12CommandSignature(iface);
|
||||
|
||||
FIXME("iface %p, name %s stub!\n", iface, debugstr_w(name, signature->device->wchar_size));
|
||||
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
@ -818,7 +818,9 @@ static HRESULT STDMETHODCALLTYPE d3d12_device_SetPrivateDataInterface(ID3D12Devi
|
||||
|
||||
static HRESULT STDMETHODCALLTYPE d3d12_device_SetName(ID3D12Device *iface, const WCHAR *name)
|
||||
{
|
||||
FIXME("iface %p, name %s stub!\n", iface, debugstr_w(name));
|
||||
struct d3d12_device *device = impl_from_ID3D12Device(iface);
|
||||
|
||||
FIXME("iface %p, name %s stub!\n", iface, debugstr_w(name, device->wchar_size));
|
||||
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
@ -1233,8 +1235,10 @@ static HRESULT STDMETHODCALLTYPE d3d12_device_CreateSharedHandle(ID3D12Device *i
|
||||
ID3D12DeviceChild *object, const SECURITY_ATTRIBUTES *attributes, DWORD access,
|
||||
const WCHAR *name, HANDLE *handle)
|
||||
{
|
||||
struct d3d12_device *device = impl_from_ID3D12Device(iface);
|
||||
|
||||
FIXME("iface %p, object %p, attributes %p, access %#x, name %s, handle %p stub!\n",
|
||||
iface, object, attributes, access, debugstr_w(name), handle);
|
||||
iface, object, attributes, access, debugstr_w(name, device->wchar_size), handle);
|
||||
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
@ -1251,8 +1255,10 @@ static HRESULT STDMETHODCALLTYPE d3d12_device_OpenSharedHandle(ID3D12Device *ifa
|
||||
static HRESULT STDMETHODCALLTYPE d3d12_device_OpenSharedHandleByName(ID3D12Device *iface,
|
||||
const WCHAR *name, DWORD access, HANDLE *handle)
|
||||
{
|
||||
struct d3d12_device *device = impl_from_ID3D12Device(iface);
|
||||
|
||||
FIXME("iface %p, name %s, access %#x, handle %p stub!\n",
|
||||
iface, debugstr_w(name), access, handle);
|
||||
iface, debugstr_w(name, device->wchar_size), access, handle);
|
||||
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
@ -1565,6 +1571,7 @@ static HRESULT d3d12_device_init(struct d3d12_device *device,
|
||||
}
|
||||
|
||||
device->signal_event = create_info->signal_event_pfn;
|
||||
device->wchar_size = create_info->wchar_size;
|
||||
|
||||
if (FAILED(hr = vkd3d_fence_worker_start(&device->fence_worker, device)))
|
||||
{
|
||||
|
@ -424,7 +424,9 @@ static HRESULT STDMETHODCALLTYPE d3d12_resource_SetPrivateDataInterface(ID3D12Re
|
||||
|
||||
static HRESULT STDMETHODCALLTYPE d3d12_resource_SetName(ID3D12Resource *iface, const WCHAR *name)
|
||||
{
|
||||
FIXME("iface %p, name %s stub!\n", iface, debugstr_w(name));
|
||||
struct d3d12_resource *resource = impl_from_ID3D12Resource(iface);
|
||||
|
||||
FIXME("iface %p, name %s stub!\n", iface, debugstr_w(name, resource->device->wchar_size));
|
||||
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
@ -1488,7 +1490,9 @@ static HRESULT STDMETHODCALLTYPE d3d12_descriptor_heap_SetPrivateDataInterface(I
|
||||
|
||||
static HRESULT STDMETHODCALLTYPE d3d12_descriptor_heap_SetName(ID3D12DescriptorHeap *iface, const WCHAR *name)
|
||||
{
|
||||
FIXME("iface %p, name %s stub!\n", iface, debugstr_w(name));
|
||||
struct d3d12_descriptor_heap *heap = impl_from_ID3D12DescriptorHeap(iface);
|
||||
|
||||
FIXME("iface %p, name %s stub!\n", iface, debugstr_w(name, heap->device->wchar_size));
|
||||
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
@ -1688,7 +1692,9 @@ static HRESULT STDMETHODCALLTYPE d3d12_query_heap_SetPrivateDataInterface(ID3D12
|
||||
|
||||
static HRESULT STDMETHODCALLTYPE d3d12_query_heap_SetName(ID3D12QueryHeap *iface, const WCHAR *name)
|
||||
{
|
||||
FIXME("iface %p, name %s stub!\n", iface, debugstr_w(name));
|
||||
struct d3d12_query_heap *heap = impl_from_ID3D12QueryHeap(iface);
|
||||
|
||||
FIXME("iface %p, name %s stub!\n", iface, debugstr_w(name, heap->device->wchar_size));
|
||||
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
@ -141,7 +141,9 @@ static HRESULT STDMETHODCALLTYPE d3d12_root_signature_SetPrivateDataInterface(ID
|
||||
|
||||
static HRESULT STDMETHODCALLTYPE d3d12_root_signature_SetName(ID3D12RootSignature *iface, const WCHAR *name)
|
||||
{
|
||||
FIXME("iface %p, name %s stub!\n", iface, debugstr_w(name));
|
||||
struct d3d12_root_signature *root_signature = impl_from_ID3D12RootSignature(iface);
|
||||
|
||||
FIXME("iface %p, name %s stub!\n", iface, debugstr_w(name, root_signature->device->wchar_size));
|
||||
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
@ -1077,7 +1079,9 @@ static HRESULT STDMETHODCALLTYPE d3d12_pipeline_state_SetPrivateDataInterface(ID
|
||||
|
||||
static HRESULT STDMETHODCALLTYPE d3d12_pipeline_state_SetName(ID3D12PipelineState *iface, const WCHAR *name)
|
||||
{
|
||||
FIXME("iface %p, name %s stub!\n", iface, debugstr_w(name));
|
||||
struct d3d12_pipeline_state *state = impl_from_ID3D12PipelineState(iface);
|
||||
|
||||
FIXME("iface %p, name %s stub!\n", iface, debugstr_w(name, state->device->wchar_size));
|
||||
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
@ -520,6 +520,7 @@ struct d3d12_device
|
||||
VkPhysicalDevice vk_physical_device;
|
||||
struct vkd3d_vk_device_procs vk_procs;
|
||||
vkd3d_signal_event_pfn signal_event;
|
||||
size_t wchar_size;
|
||||
|
||||
struct vkd3d_gpu_va_allocator gpu_va_allocator;
|
||||
struct vkd3d_fence_worker fence_worker;
|
||||
|
Loading…
x
Reference in New Issue
Block a user