From 0c1432e671248ca2c8f6d0509d4eb25954e15bad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zef=20Kucia?= Date: Fri, 7 Oct 2016 13:26:39 +0200 Subject: [PATCH] libs/vkd3d: Move D3D12CreateDevice() to libvkd3d-utils. --- include/private/vkd3d_memory.h | 56 ++++++++++++++++++++++++++ libs/vkd3d-utils/vkd3d_utils_main.c | 17 ++++++++ libs/vkd3d-utils/vkd3d_utils_private.h | 2 +- libs/vkd3d/vkd3d_main.c | 17 -------- libs/vkd3d/vkd3d_private.h | 31 +------------- 5 files changed, 75 insertions(+), 48 deletions(-) create mode 100644 include/private/vkd3d_memory.h diff --git a/include/private/vkd3d_memory.h b/include/private/vkd3d_memory.h new file mode 100644 index 00000000..4b64a162 --- /dev/null +++ b/include/private/vkd3d_memory.h @@ -0,0 +1,56 @@ +/* + * Copyright 2016 Józef Kucia for CodeWeavers + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#ifndef __VKD3D_MEMORY_H +#define __VKD3D_MEMORY_H + +#include "vkd3d_debug.h" + +static inline void *vkd3d_malloc(size_t size) +{ + void *ptr; + if (!(ptr = malloc(size))) + ERR("Out of memory.\n"); + return ptr; +} + +static inline void *vkd3d_realloc(void *ptr, size_t size) +{ + if (!(ptr = realloc(ptr, size))) + ERR("Out of memory.\n"); + return ptr; +} + +static inline void *vkd3d_calloc(size_t count, size_t size) +{ + void *ptr; + if (!(ptr = calloc(count, size))) + ERR("Out of memory.\n"); + return ptr; +} + +static inline void vkd3d_free(void *ptr) +{ + free(ptr); +} + +#endif /* __VKD3D_MEMORY_H */ diff --git a/libs/vkd3d-utils/vkd3d_utils_main.c b/libs/vkd3d-utils/vkd3d_utils_main.c index efe636e9..e0b6c303 100644 --- a/libs/vkd3d-utils/vkd3d_utils_main.c +++ b/libs/vkd3d-utils/vkd3d_utils_main.c @@ -28,3 +28,20 @@ HRESULT WINAPI D3D12GetDebugInterface(REFIID riid, void **debug) return E_NOTIMPL; } + +HRESULT WINAPI D3D12CreateDevice(IUnknown *adapter, + D3D_FEATURE_LEVEL minimum_feature_level, REFIID riid, void **device) +{ + struct vkd3d_device_create_info create_info; + + TRACE("adapter %p, minimum_feature_level %#x, riid %s, device %p.\n", + adapter, minimum_feature_level, debugstr_guid(riid), device); + + if (adapter) + FIXME("Ignoring adapter %p.\n", adapter); + + create_info.minimum_feature_level = minimum_feature_level; + create_info.signal_event_pfn = VKD3DSignalEvent; + + return vkd3d_create_device(&create_info, riid, device); +} diff --git a/libs/vkd3d-utils/vkd3d_utils_private.h b/libs/vkd3d-utils/vkd3d_utils_private.h index b942d43a..a6405760 100644 --- a/libs/vkd3d-utils/vkd3d_utils_private.h +++ b/libs/vkd3d-utils/vkd3d_utils_private.h @@ -27,6 +27,6 @@ #define NONAMELESSUNION #include "vkd3d_debug.h" -#include "d3d12.h" +#include "vkd3d.h" #endif /* __VKD3D_UTILS_PRIVATE_H */ diff --git a/libs/vkd3d/vkd3d_main.c b/libs/vkd3d/vkd3d_main.c index 04164ee9..5235a1fc 100644 --- a/libs/vkd3d/vkd3d_main.c +++ b/libs/vkd3d/vkd3d_main.c @@ -51,23 +51,6 @@ HRESULT WINAPI vkd3d_create_device(const struct vkd3d_device_create_info *create riid, device); } -HRESULT WINAPI D3D12CreateDevice(IUnknown *adapter, D3D_FEATURE_LEVEL minimum_feature_level, - REFIID riid, void **device) -{ - struct vkd3d_device_create_info create_info; - - TRACE("adapter %p, minimum_feature_level %#x, riid %s, device %p.\n", - adapter, minimum_feature_level, debugstr_guid(riid), device); - - if (adapter) - FIXME("Ignoring adapter %p.\n", adapter); - - create_info.minimum_feature_level = minimum_feature_level; - create_info.signal_event_pfn = VKD3DSignalEvent; - - return vkd3d_create_device(&create_info, riid, device); -} - /* Events */ HANDLE WINAPI VKD3DCreateEvent(void) { diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h index d0ffb821..2a57ec03 100644 --- a/libs/vkd3d/vkd3d_private.h +++ b/libs/vkd3d/vkd3d_private.h @@ -26,8 +26,7 @@ #define COBJMACROS #define NONAMELESSUNION #include "vkd3d.h" -#include "vkd3d_common.h" -#include "vkd3d_debug.h" +#include "vkd3d_memory.h" #include "vkd3d_vulkan.h" #include @@ -275,34 +274,6 @@ VkFormat vk_format_from_dxgi_format(DXGI_FORMAT format) DECLSPEC_HIDDEN; bool vkd3d_array_reserve(void **elements, size_t *capacity, size_t element_count, size_t element_size) DECLSPEC_HIDDEN; -static inline void *vkd3d_malloc(size_t size) -{ - void *ptr; - if (!(ptr = malloc(size))) - ERR("Out of memory.\n"); - return ptr; -} - -static inline void *vkd3d_realloc(void *ptr, size_t size) -{ - if (!(ptr = realloc(ptr, size))) - ERR("Out of memory.\n"); - return ptr; -} - -static inline void *vkd3d_calloc(size_t count, size_t size) -{ - void *ptr; - if (!(ptr = calloc(count, size))) - ERR("Out of memory.\n"); - return ptr; -} - -static inline void vkd3d_free(void *ptr) -{ - free(ptr); -} - HRESULT hresult_from_vk_result(VkResult vr) DECLSPEC_HIDDEN; HRESULT vkd3d_load_vk_instance_procs(struct vkd3d_vk_instance_procs *procs,