2018-02-14 12:35:52 +01:00
|
|
|
/*
|
|
|
|
* Copyright 2018 Józef Kucia 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 "config.h"
|
|
|
|
#include "wine/port.h"
|
|
|
|
|
2018-05-23 21:02:16 +02:00
|
|
|
#define VK_NO_PROTOTYPES
|
|
|
|
#define VKD3D_NO_VULKAN_H
|
|
|
|
#define VKD3D_NO_WIN32_TYPES
|
2018-06-01 13:10:22 +02:00
|
|
|
#define WINE_VK_HOST
|
2018-05-23 21:02:16 +02:00
|
|
|
|
2018-02-14 12:35:52 +01:00
|
|
|
#include "wine/debug.h"
|
2018-05-23 21:02:18 +02:00
|
|
|
#include "wine/heap.h"
|
2018-05-23 21:02:16 +02:00
|
|
|
#include "wine/vulkan.h"
|
2018-05-23 21:02:18 +02:00
|
|
|
#include "wine/vulkan_driver.h"
|
2018-05-23 21:02:16 +02:00
|
|
|
|
2018-02-14 12:35:52 +01:00
|
|
|
#include "d3d12.h"
|
|
|
|
|
2018-05-23 21:02:16 +02:00
|
|
|
#include <vkd3d.h>
|
|
|
|
|
2018-02-14 12:35:52 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(d3d12);
|
2018-05-25 12:09:13 +02:00
|
|
|
WINE_DECLARE_DEBUG_CHANNEL(winediag);
|
2018-02-14 12:35:52 +01:00
|
|
|
|
|
|
|
HRESULT WINAPI D3D12GetDebugInterface(REFIID iid, void **debug)
|
|
|
|
{
|
2018-08-15 12:03:24 +02:00
|
|
|
TRACE("iid %s, debug %p.\n", debugstr_guid(iid), debug);
|
2018-02-14 12:35:52 +01:00
|
|
|
|
2018-08-15 12:03:24 +02:00
|
|
|
WARN("Returning DXGI_ERROR_SDK_COMPONENT_MISSING.\n");
|
|
|
|
return DXGI_ERROR_SDK_COMPONENT_MISSING;
|
2018-02-14 12:35:52 +01:00
|
|
|
}
|
|
|
|
|
2019-03-07 11:21:21 +01:00
|
|
|
HRESULT WINAPI D3D12EnableExperimentalFeatures(UINT feature_count,
|
|
|
|
const IID *iids, void *configurations, UINT *configurations_sizes)
|
|
|
|
{
|
|
|
|
FIXME("feature_count %u, iids %p, configurations %p, configurations_sizes %p stub!\n",
|
|
|
|
feature_count, iids, configurations, configurations_sizes);
|
|
|
|
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2018-05-23 21:02:18 +02:00
|
|
|
static HRESULT d3d12_signal_event(HANDLE event)
|
|
|
|
{
|
|
|
|
return SetEvent(event) ? S_OK : E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct d3d12_thread_data
|
|
|
|
{
|
|
|
|
PFN_vkd3d_thread main_pfn;
|
|
|
|
void *data;
|
|
|
|
};
|
|
|
|
|
|
|
|
static DWORD WINAPI d3d12_thread_main(void *data)
|
|
|
|
{
|
|
|
|
struct d3d12_thread_data *thread_data = data;
|
|
|
|
|
|
|
|
thread_data->main_pfn(thread_data->data);
|
|
|
|
heap_free(thread_data);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void *d3d12_create_thread(PFN_vkd3d_thread main_pfn, void *data)
|
|
|
|
{
|
|
|
|
struct d3d12_thread_data *thread_data;
|
|
|
|
HANDLE thread;
|
|
|
|
|
|
|
|
if (!(thread_data = heap_alloc(sizeof(*thread_data))))
|
|
|
|
{
|
|
|
|
ERR("Failed to allocate thread data.\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
thread_data->main_pfn = main_pfn;
|
|
|
|
thread_data->data = data;
|
|
|
|
|
|
|
|
if (!(thread = CreateThread(NULL, 0, d3d12_thread_main, thread_data, 0, NULL)))
|
|
|
|
heap_free(thread_data);
|
|
|
|
|
|
|
|
return thread;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT d3d12_join_thread(void *handle)
|
|
|
|
{
|
|
|
|
HANDLE thread = handle;
|
|
|
|
DWORD ret;
|
|
|
|
|
|
|
|
if ((ret = WaitForSingleObject(thread, INFINITE)) != WAIT_OBJECT_0)
|
|
|
|
ERR("Failed to wait for thread, ret %#x.\n", ret);
|
|
|
|
CloseHandle(thread);
|
|
|
|
return ret == WAIT_OBJECT_0 ? S_OK : E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct vulkan_funcs *get_vk_funcs(void)
|
|
|
|
{
|
|
|
|
const struct vulkan_funcs *vk_funcs;
|
|
|
|
HDC hdc;
|
|
|
|
|
|
|
|
hdc = GetDC(0);
|
|
|
|
vk_funcs = __wine_get_vulkan_driver(hdc, WINE_VULKAN_DRIVER_VERSION);
|
|
|
|
ReleaseDC(0, hdc);
|
|
|
|
return vk_funcs;
|
|
|
|
}
|
|
|
|
|
2018-02-14 12:35:52 +01:00
|
|
|
HRESULT WINAPI D3D12CreateDevice(IUnknown *adapter, D3D_FEATURE_LEVEL minimum_feature_level,
|
|
|
|
REFIID iid, void **device)
|
|
|
|
{
|
2018-05-23 21:02:18 +02:00
|
|
|
struct vkd3d_instance_create_info instance_create_info;
|
|
|
|
struct vkd3d_device_create_info device_create_info;
|
|
|
|
const struct vulkan_funcs *vk_funcs;
|
|
|
|
|
2018-05-31 12:39:04 +02:00
|
|
|
static const char * const instance_extensions[] =
|
|
|
|
{
|
|
|
|
VK_KHR_SURFACE_EXTENSION_NAME,
|
|
|
|
VK_KHR_WIN32_SURFACE_EXTENSION_NAME,
|
|
|
|
};
|
|
|
|
static const char * const device_extensions[] =
|
|
|
|
{
|
|
|
|
VK_KHR_SWAPCHAIN_EXTENSION_NAME,
|
|
|
|
};
|
|
|
|
|
2018-05-23 21:02:18 +02:00
|
|
|
TRACE("adapter %p, minimum_feature_level %#x, iid %s, device %p.\n",
|
2018-02-14 12:35:52 +01:00
|
|
|
adapter, minimum_feature_level, debugstr_guid(iid), device);
|
|
|
|
|
2018-05-23 21:02:18 +02:00
|
|
|
if (!(vk_funcs = get_vk_funcs()))
|
|
|
|
{
|
2018-05-25 12:09:13 +02:00
|
|
|
ERR_(winediag)("Failed to load Wine Vulkan driver.\n");
|
2018-05-23 21:02:18 +02:00
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
FIXME("Ignoring adapter %p.\n", adapter);
|
|
|
|
|
|
|
|
memset(&instance_create_info, 0, sizeof(instance_create_info));
|
|
|
|
instance_create_info.type = VKD3D_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
|
|
|
|
instance_create_info.pfn_signal_event = d3d12_signal_event;
|
|
|
|
instance_create_info.pfn_create_thread = d3d12_create_thread;
|
|
|
|
instance_create_info.pfn_join_thread = d3d12_join_thread;
|
|
|
|
instance_create_info.wchar_size = sizeof(WCHAR);
|
|
|
|
instance_create_info.pfn_vkGetInstanceProcAddr
|
|
|
|
= (PFN_vkGetInstanceProcAddr)vk_funcs->p_vkGetInstanceProcAddr;
|
2018-05-31 12:39:04 +02:00
|
|
|
instance_create_info.instance_extensions = instance_extensions;
|
|
|
|
instance_create_info.instance_extension_count = ARRAY_SIZE(instance_extensions);
|
2018-05-23 21:02:18 +02:00
|
|
|
|
|
|
|
memset(&device_create_info, 0, sizeof(device_create_info));
|
|
|
|
device_create_info.type = VKD3D_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
|
|
|
|
device_create_info.minimum_feature_level = minimum_feature_level;
|
|
|
|
device_create_info.instance_create_info = &instance_create_info;
|
2018-05-31 12:39:04 +02:00
|
|
|
device_create_info.device_extensions = device_extensions;
|
|
|
|
device_create_info.device_extension_count = ARRAY_SIZE(device_extensions);
|
2018-05-23 21:02:18 +02:00
|
|
|
|
|
|
|
return vkd3d_create_device(&device_create_info, iid, device);
|
2018-02-14 12:35:52 +01:00
|
|
|
}
|
2018-05-23 21:02:16 +02:00
|
|
|
|
|
|
|
HRESULT WINAPI D3D12CreateRootSignatureDeserializer(const void *data, SIZE_T data_size,
|
|
|
|
REFIID iid, void **deserializer)
|
|
|
|
{
|
|
|
|
TRACE("data %p, data_size %lu, iid %s, deserializer %p.\n",
|
|
|
|
data, data_size, debugstr_guid(iid), deserializer);
|
|
|
|
|
|
|
|
return vkd3d_create_root_signature_deserializer(data, data_size, iid, deserializer);
|
|
|
|
}
|
2018-05-23 21:02:17 +02:00
|
|
|
|
|
|
|
HRESULT WINAPI D3D12SerializeRootSignature(const D3D12_ROOT_SIGNATURE_DESC *root_signature_desc,
|
|
|
|
D3D_ROOT_SIGNATURE_VERSION version, ID3DBlob **blob, ID3DBlob **error_blob)
|
|
|
|
{
|
|
|
|
TRACE("root_signature_desc %p, version %#x, blob %p, error_blob %p.\n",
|
|
|
|
root_signature_desc, version, blob, error_blob);
|
|
|
|
|
|
|
|
return vkd3d_serialize_root_signature(root_signature_desc, version, blob, error_blob);
|
|
|
|
}
|
2019-03-07 11:21:22 +01:00
|
|
|
|
|
|
|
HRESULT WINAPI D3D12SerializeVersionedRootSignature(const D3D12_VERSIONED_ROOT_SIGNATURE_DESC *desc,
|
|
|
|
ID3DBlob **blob, ID3DBlob **error_blob)
|
|
|
|
{
|
|
|
|
FIXME("desc %p, blob %p, error_blob %p partial-stub!\n",
|
|
|
|
desc, blob, error_blob);
|
|
|
|
|
|
|
|
if (desc->Version == D3D_ROOT_SIGNATURE_VERSION_1_0)
|
|
|
|
return D3D12SerializeRootSignature(&desc->Desc_1_0, desc->Version, blob, error_blob);
|
|
|
|
|
|
|
|
FIXME("Unsupported version %#x.\n", desc->Version);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|