libs/vkd3d: Move D3D12CreateDevice() to libvkd3d-utils.

This commit is contained in:
Józef Kucia 2016-10-07 13:26:39 +02:00
parent ef6a3d78a2
commit 0c1432e671
5 changed files with 75 additions and 48 deletions

View File

@ -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 */

View File

@ -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);
}

View File

@ -27,6 +27,6 @@
#define NONAMELESSUNION
#include "vkd3d_debug.h"
#include "d3d12.h"
#include "vkd3d.h"
#endif /* __VKD3D_UTILS_PRIVATE_H */

View File

@ -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)
{

View File

@ -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 <assert.h>
@ -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,