vkd3d: include/vkd3d.h Source File

vkd3d 1.19 The vkd3d 3D Graphics Library

Loading...
Searching...
No Matches
vkd3d.h
Go to the documentation of this file.
1/*
2 * Copyright 2016 Józef Kucia for CodeWeavers
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 */
18
19#ifndef __VKD3D_H
20#define __VKD3D_H
21
22#include <vkd3d_types.h>
23
24#ifndef VKD3D_NO_WIN32_TYPES
25# include <vkd3d_windows.h>
26# include <vkd3d_d3d12.h>
27#endif /* VKD3D_NO_WIN32_TYPES */
28
29#ifndef VKD3D_NO_VULKAN_H
30# include <vulkan/vulkan.h>
31#endif /* VKD3D_NO_VULKAN_H */
32
33#ifdef __cplusplus
34extern "C" {
35#endif /* __cplusplus */
36
48
50 enum vkd3d_structure_type
51{
53 VKD3D_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
55 VKD3D_STRUCTURE_TYPE_DEVICE_CREATE_INFO,
57 VKD3D_STRUCTURE_TYPE_IMAGE_RESOURCE_CREATE_INFO,
58
63 VKD3D_STRUCTURE_TYPE_OPTIONAL_INSTANCE_EXTENSIONS_INFO,
64
69 VKD3D_STRUCTURE_TYPE_OPTIONAL_DEVICE_EXTENSIONS_INFO,
74 VKD3D_STRUCTURE_TYPE_APPLICATION_INFO,
75
80 VKD3D_STRUCTURE_TYPE_HOST_TIME_DOMAIN_INFO,
81
82 VKD3D_FORCE_32_BIT_ENUM(VKD3D_STRUCTURE_TYPE),
83};
84
85enum vkd3d_api_version
86{
87 VKD3D_API_VERSION_1_0,
88 VKD3D_API_VERSION_1_1,
89 VKD3D_API_VERSION_1_2,
90 VKD3D_API_VERSION_1_3,
91 VKD3D_API_VERSION_1_4,
92 VKD3D_API_VERSION_1_5,
93 VKD3D_API_VERSION_1_6,
94 VKD3D_API_VERSION_1_7,
95 VKD3D_API_VERSION_1_8,
96 VKD3D_API_VERSION_1_9,
97 VKD3D_API_VERSION_1_10,
98 VKD3D_API_VERSION_1_11,
99 VKD3D_API_VERSION_1_12,
100 VKD3D_API_VERSION_1_13,
101 VKD3D_API_VERSION_1_14,
102 VKD3D_API_VERSION_1_15,
103 VKD3D_API_VERSION_1_16,
104 VKD3D_API_VERSION_1_17,
105 VKD3D_API_VERSION_1_18,
106 VKD3D_API_VERSION_1_19,
107
108 VKD3D_FORCE_32_BIT_ENUM(VKD3D_API_VERSION),
109};
110
111typedef HRESULT (*PFN_vkd3d_signal_event)(HANDLE event);
112
113typedef void * (*PFN_vkd3d_thread)(void *data);
114
115typedef void * (*PFN_vkd3d_create_thread)(PFN_vkd3d_thread thread_main, void *data);
116typedef HRESULT (*PFN_vkd3d_join_thread)(void *thread);
117
118struct vkd3d_instance;
119
123 struct vkd3d_instance_create_info
124{
126 enum vkd3d_structure_type type;
128 const void *next;
129
131 PFN_vkd3d_signal_event pfn_signal_event;
137 PFN_vkd3d_create_thread pfn_create_thread;
143 PFN_vkd3d_join_thread pfn_join_thread;
145 size_t wchar_size;
146
151 PFN_vkGetInstanceProcAddr pfn_vkGetInstanceProcAddr;
152
157 const char * const *instance_extensions;
159 uint32_t instance_extension_count;
160};
161
169 struct vkd3d_optional_instance_extensions_info
170{
172 enum vkd3d_structure_type type;
174 const void *next;
175
180 const char * const *extensions;
182 uint32_t extension_count;
183};
184
192 struct vkd3d_application_info
193{
195 enum vkd3d_structure_type type;
197 const void *next;
198
204 const char *application_name;
206 uint32_t application_version;
207
211 const char *engine_name;
216 uint32_t engine_version;
217
222 enum vkd3d_api_version api_version;
223};
224
232 struct vkd3d_host_time_domain_info
233{
235 enum vkd3d_structure_type type;
237 const void *next;
238
245 uint64_t ticks_per_second;
246};
247
251 struct vkd3d_device_create_info
252{
254 enum vkd3d_structure_type type;
256 const void *next;
257
260 D3D_FEATURE_LEVEL minimum_feature_level;
261
266 struct vkd3d_instance *instance;
271 const struct vkd3d_instance_create_info *instance_create_info;
272
279 VkPhysicalDevice vk_physical_device;
280
285 const char * const *device_extensions;
287 uint32_t device_extension_count;
288
293 IUnknown *parent;
298 LUID adapter_luid;
299};
300
308 struct vkd3d_optional_device_extensions_info
309{
311 enum vkd3d_structure_type type;
313 const void *next;
314
319 const char * const *extensions;
321 uint32_t extension_count;
322};
323
330#define VKD3D_RESOURCE_INITIAL_STATE_TRANSITION 0x00000001
335#define VKD3D_RESOURCE_PRESENT_STATE_TRANSITION 0x00000002
336
341 struct vkd3d_image_resource_create_info
342{
344 enum vkd3d_structure_type type;
346 const void *next;
347
349 VkImage vk_image;
351 D3D12_RESOURCE_DESC desc;
356 unsigned int flags;
376 D3D12_RESOURCE_STATES present_state;
377};
378
379#ifdef LIBVKD3D_SOURCE
380# define VKD3D_API VKD3D_EXPORT
381#else
382# define VKD3D_API VKD3D_IMPORT
383#endif
384
385#ifndef VKD3D_NO_PROTOTYPES
386
387VKD3D_API HRESULT vkd3d_create_instance(const struct vkd3d_instance_create_info *create_info,
388 struct vkd3d_instance **instance);
389VKD3D_API ULONG vkd3d_instance_decref(struct vkd3d_instance *instance);
390VKD3D_API VkInstance vkd3d_instance_get_vk_instance(struct vkd3d_instance *instance);
391VKD3D_API ULONG vkd3d_instance_incref(struct vkd3d_instance *instance);
392
393VKD3D_API HRESULT vkd3d_create_device(const struct vkd3d_device_create_info *create_info,
394 REFIID iid, void **device);
395VKD3D_API IUnknown *vkd3d_get_device_parent(ID3D12Device *device);
396VKD3D_API VkDevice vkd3d_get_vk_device(ID3D12Device *device);
397VKD3D_API VkPhysicalDevice vkd3d_get_vk_physical_device(ID3D12Device *device);
398VKD3D_API struct vkd3d_instance *vkd3d_instance_from_device(ID3D12Device *device);
399
400VKD3D_API uint32_t vkd3d_get_vk_queue_family_index(ID3D12CommandQueue *queue);
401
429VKD3D_API VkQueue vkd3d_acquire_vk_queue(ID3D12CommandQueue *queue);
430
441VKD3D_API void vkd3d_release_vk_queue(ID3D12CommandQueue *queue);
442
443VKD3D_API HRESULT vkd3d_create_image_resource(ID3D12Device *device,
444 const struct vkd3d_image_resource_create_info *create_info, ID3D12Resource **resource);
445VKD3D_API ULONG vkd3d_resource_decref(ID3D12Resource *resource);
446VKD3D_API ULONG vkd3d_resource_incref(ID3D12Resource *resource);
447
448VKD3D_API HRESULT vkd3d_serialize_root_signature(const D3D12_ROOT_SIGNATURE_DESC *desc,
449 D3D_ROOT_SIGNATURE_VERSION version, ID3DBlob **blob, ID3DBlob **error_blob);
450VKD3D_API HRESULT vkd3d_create_root_signature_deserializer(const void *data, SIZE_T data_size,
451 REFIID iid, void **deserializer);
452
453VKD3D_API VkFormat vkd3d_get_vk_format(DXGI_FORMAT format);
454
455/* 1.1 */
456VKD3D_API DXGI_FORMAT vkd3d_get_dxgi_format(VkFormat format);
457
458/* 1.2 */
459VKD3D_API HRESULT vkd3d_serialize_versioned_root_signature(const D3D12_VERSIONED_ROOT_SIGNATURE_DESC *desc,
460 ID3DBlob **blob, ID3DBlob **error_blob);
461VKD3D_API HRESULT vkd3d_create_versioned_root_signature_deserializer(const void *data, SIZE_T data_size,
462 REFIID iid, void **deserializer);
463
476VKD3D_API void vkd3d_set_log_callback(PFN_vkd3d_log callback);
477
490VKD3D_API HRESULT vkd3d_queue_signal_on_cpu(ID3D12CommandQueue *queue,
491 ID3D12Fence *fence, uint64_t value);
492
493#endif /* VKD3D_NO_PROTOTYPES */
494
495/*
496 * Function pointer typedefs for vkd3d functions.
497 */
498typedef HRESULT (*PFN_vkd3d_create_instance)(const struct vkd3d_instance_create_info *create_info,
499 struct vkd3d_instance **instance);
500typedef ULONG (*PFN_vkd3d_instance_decref)(struct vkd3d_instance *instance);
501typedef VkInstance (*PFN_vkd3d_instance_get_vk_instance)(struct vkd3d_instance *instance);
502typedef ULONG (*PFN_vkd3d_instance_incref)(struct vkd3d_instance *instance);
503
504typedef HRESULT (*PFN_vkd3d_create_device)(const struct vkd3d_device_create_info *create_info,
505 REFIID iid, void **device);
506typedef IUnknown * (*PFN_vkd3d_get_device_parent)(ID3D12Device *device);
507typedef VkDevice (*PFN_vkd3d_get_vk_device)(ID3D12Device *device);
508typedef VkPhysicalDevice (*PFN_vkd3d_get_vk_physical_device)(ID3D12Device *device);
509typedef struct vkd3d_instance * (*PFN_vkd3d_instance_from_device)(ID3D12Device *device);
510
511typedef uint32_t (*PFN_vkd3d_get_vk_queue_family_index)(ID3D12CommandQueue *queue);
512typedef VkQueue (*PFN_vkd3d_acquire_vk_queue)(ID3D12CommandQueue *queue);
513typedef void (*PFN_vkd3d_release_vk_queue)(ID3D12CommandQueue *queue);
514
515typedef HRESULT (*PFN_vkd3d_create_image_resource)(ID3D12Device *device,
516 const struct vkd3d_image_resource_create_info *create_info, ID3D12Resource **resource);
517typedef ULONG (*PFN_vkd3d_resource_decref)(ID3D12Resource *resource);
518typedef ULONG (*PFN_vkd3d_resource_incref)(ID3D12Resource *resource);
519
520typedef HRESULT (*PFN_vkd3d_serialize_root_signature)(const D3D12_ROOT_SIGNATURE_DESC *desc,
521 D3D_ROOT_SIGNATURE_VERSION version, ID3DBlob **blob, ID3DBlob **error_blob);
522typedef HRESULT (*PFN_vkd3d_create_root_signature_deserializer)(const void *data, SIZE_T data_size,
523 REFIID iid, void **deserializer);
524
525typedef VkFormat (*PFN_vkd3d_get_vk_format)(DXGI_FORMAT format);
526
527/* 1.1 */
528typedef DXGI_FORMAT (*PFN_vkd3d_get_dxgi_format)(VkFormat format);
529
530/* 1.2 */
531typedef HRESULT (*PFN_vkd3d_serialize_versioned_root_signature)(const D3D12_VERSIONED_ROOT_SIGNATURE_DESC *desc,
532 ID3DBlob **blob, ID3DBlob **error_blob);
533typedef HRESULT (*PFN_vkd3d_create_versioned_root_signature_deserializer)(const void *data, SIZE_T data_size,
534 REFIID iid, void **deserializer);
535
537 typedef void (*PFN_vkd3d_set_log_callback)(PFN_vkd3d_log callback);
538
540 typedef HRESULT (*PFN_vkd3d_queue_signal_on_cpu)(ID3D12CommandQueue *queue,
541 ID3D12Fence *fence, uint64_t value);
542
543#ifdef __cplusplus
544}
545#endif /* __cplusplus */
546
547#endif /* __VKD3D_H */
vkd3d_application_info
A chained structure to specify application information.
Definition vkd3d.h:193
vkd3d_application_info::engine_version
uint32_t engine_version
The engine version, to be passed to the Vulkan implementation.
Definition vkd3d.h:216
vkd3d_application_info::next
const void * next
Optional pointer to a structure containing further parameters.
Definition vkd3d.h:197
vkd3d_application_info::api_version
enum vkd3d_api_version api_version
The vkd3d API version to use, to guarantee backward compatibility of the shared library.
Definition vkd3d.h:222
vkd3d_application_info::engine_name
const char * engine_name
The engine name, to be passed to the Vulkan implementation.
Definition vkd3d.h:211
vkd3d_application_info::type
enum vkd3d_structure_type type
Must be set to VKD3D_STRUCTURE_TYPE_APPLICATION_INFO.
Definition vkd3d.h:195
vkd3d_application_info::application_name
const char * application_name
The application's name, to be passed to the Vulkan implementation.
Definition vkd3d.h:204
vkd3d_application_info::application_version
uint32_t application_version
The application's version, to be passed to the Vulkan implementation.
Definition vkd3d.h:206
vkd3d_device_create_info
A chained structure containing device creation parameters.
Definition vkd3d.h:252
vkd3d_device_create_info::instance
struct vkd3d_instance * instance
The vkd3d instance to use to create a device.
Definition vkd3d.h:266
vkd3d_device_create_info::adapter_luid
LUID adapter_luid
The adapter LUID to be set for the device.
Definition vkd3d.h:298
vkd3d_device_create_info::instance_create_info
const struct vkd3d_instance_create_info * instance_create_info
The parameters used to create an instance, which is then used to create a device.
Definition vkd3d.h:271
vkd3d_device_create_info::parent
IUnknown * parent
An object to be set as the device parent.
Definition vkd3d.h:293
vkd3d_device_create_info::device_extension_count
uint32_t device_extension_count
The number of elements in the device_extensions array.
Definition vkd3d.h:287
vkd3d_device_create_info::minimum_feature_level
D3D_FEATURE_LEVEL minimum_feature_level
The minimum feature level to request.
Definition vkd3d.h:260
vkd3d_device_create_info::device_extensions
const char *const * device_extensions
A list of Vulkan device extensions to request.
Definition vkd3d.h:285
vkd3d_device_create_info::next
const void * next
Optional pointer to a structure containing further parameters.
Definition vkd3d.h:256
vkd3d_device_create_info::type
enum vkd3d_structure_type type
Must be set to VKD3D_STRUCTURE_TYPE_DEVICE_CREATE_INFO.
Definition vkd3d.h:254
vkd3d_device_create_info::vk_physical_device
VkPhysicalDevice vk_physical_device
The Vulkan physical device to use.
Definition vkd3d.h:279
vkd3d_host_time_domain_info
A chained structure to specify the host time domain.
Definition vkd3d.h:233
vkd3d_host_time_domain_info::type
enum vkd3d_structure_type type
Must be set to VKD3D_STRUCTURE_TYPE_HOST_TIME_DOMAIN_INFO.
Definition vkd3d.h:235
vkd3d_host_time_domain_info::next
const void * next
Optional pointer to a structure containing further parameters.
Definition vkd3d.h:237
vkd3d_host_time_domain_info::ticks_per_second
uint64_t ticks_per_second
The number of clock ticks per second, used for GetClockCalibration().
Definition vkd3d.h:245
vkd3d_image_resource_create_info
A chained structure containing the parameters to create a D3D12 resource backed by a Vulkan image.
Definition vkd3d.h:342
vkd3d_image_resource_create_info::next
const void * next
Optional pointer to a structure containing further parameters.
Definition vkd3d.h:346
vkd3d_image_resource_create_info::vk_image
VkImage vk_image
The Vulkan image that backs the resource.
Definition vkd3d.h:349
vkd3d_image_resource_create_info::present_state
D3D12_RESOURCE_STATES present_state
This field specifies how to handle resource state D3D12_RESOURCE_STATE_PRESENT for the resource.
Definition vkd3d.h:376
vkd3d_image_resource_create_info::flags
unsigned int flags
A combination of zero or more flags.
Definition vkd3d.h:356
vkd3d_image_resource_create_info::desc
D3D12_RESOURCE_DESC desc
The resource description.
Definition vkd3d.h:351
vkd3d_image_resource_create_info::type
enum vkd3d_structure_type type
Must be set to VKD3D_STRUCTURE_TYPE_IMAGE_RESOURCE_CREATE_INFO.
Definition vkd3d.h:344
vkd3d_instance_create_info
A chained structure containing instance creation parameters.
Definition vkd3d.h:124
vkd3d_instance_create_info::wchar_size
size_t wchar_size
The size of type WCHAR.
Definition vkd3d.h:145
vkd3d_instance_create_info::instance_extensions
const char *const * instance_extensions
A list of Vulkan instance extensions to request.
Definition vkd3d.h:157
vkd3d_instance_create_info::instance_extension_count
uint32_t instance_extension_count
The number of elements in the instance_extensions array.
Definition vkd3d.h:159
vkd3d_instance_create_info::pfn_signal_event
PFN_vkd3d_signal_event pfn_signal_event
An pointer to a function to signal events.
Definition vkd3d.h:131
vkd3d_instance_create_info::pfn_vkGetInstanceProcAddr
PFN_vkGetInstanceProcAddr pfn_vkGetInstanceProcAddr
A pointer to the vkGetInstanceProcAddr Vulkan function, which will be used to load all the other Vulk...
Definition vkd3d.h:151
vkd3d_instance_create_info::next
const void * next
Optional pointer to a structure containing further parameters.
Definition vkd3d.h:128
vkd3d_instance_create_info::type
enum vkd3d_structure_type type
Must be set to VKD3D_STRUCTURE_TYPE_INSTANCE_CREATE_INFO.
Definition vkd3d.h:126
vkd3d_instance_create_info::pfn_join_thread
PFN_vkd3d_join_thread pfn_join_thread
An optional pointer to a function to join threads.
Definition vkd3d.h:143
vkd3d_instance_create_info::pfn_create_thread
PFN_vkd3d_create_thread pfn_create_thread
An optional pointer to a function to create threads.
Definition vkd3d.h:137
vkd3d_optional_device_extensions_info
A chained structure to specify optional device extensions.
Definition vkd3d.h:309
vkd3d_optional_device_extensions_info::extension_count
uint32_t extension_count
The number of elements in the extensions array.
Definition vkd3d.h:321
vkd3d_optional_device_extensions_info::extensions
const char *const * extensions
A list of optional Vulkan device extensions to request.
Definition vkd3d.h:319
vkd3d_optional_device_extensions_info::type
enum vkd3d_structure_type type
Must be set to VKD3D_STRUCTURE_TYPE_OPTIONAL_DEVICE_EXTENSIONS_INFO.
Definition vkd3d.h:311
vkd3d_optional_device_extensions_info::next
const void * next
Optional pointer to a structure containing further parameters.
Definition vkd3d.h:313
vkd3d_optional_instance_extensions_info
A chained structure to specify optional instance extensions.
Definition vkd3d.h:170
vkd3d_optional_instance_extensions_info::extension_count
uint32_t extension_count
The number of elements in the extensions array.
Definition vkd3d.h:182
vkd3d_optional_instance_extensions_info::type
enum vkd3d_structure_type type
Must be set to VKD3D_STRUCTURE_TYPE_OPTIONAL_INSTANCE_EXTENSIONS_INFO.
Definition vkd3d.h:172
vkd3d_optional_instance_extensions_info::next
const void * next
Optional pointer to a structure containing further parameters.
Definition vkd3d.h:174
vkd3d_optional_instance_extensions_info::extensions
const char *const * extensions
A list of optional Vulkan instance extensions to request.
Definition vkd3d.h:180
vkd3d_acquire_vk_queue
VKD3D_API VkQueue vkd3d_acquire_vk_queue(ID3D12CommandQueue *queue)
Acquire the Vulkan queue backing a command queue.
PFN_vkd3d_queue_signal_on_cpu
HRESULT(* PFN_vkd3d_queue_signal_on_cpu)(ID3D12CommandQueue *queue, ID3D12Fence *fence, uint64_t value)
Type of vkd3d_queue_signal_on_cpu().
Definition vkd3d.h:540
vkd3d_queue_signal_on_cpu
VKD3D_API HRESULT vkd3d_queue_signal_on_cpu(ID3D12CommandQueue *queue, ID3D12Fence *fence, uint64_t value)
Signal a fence on the CPU once all the currently outstanding queue work is submitted to Vulkan.
vkd3d_set_log_callback
VKD3D_API void vkd3d_set_log_callback(PFN_vkd3d_log callback)
Set a callback to be called when vkd3d outputs debug logging.
vkd3d_structure_type
vkd3d_structure_type
The type of a chained structure.
Definition vkd3d.h:51
VKD3D_STRUCTURE_TYPE_HOST_TIME_DOMAIN_INFO
@ VKD3D_STRUCTURE_TYPE_HOST_TIME_DOMAIN_INFO
The structure is a vkd3d_host_time_domain_info structure.
Definition vkd3d.h:80
VKD3D_STRUCTURE_TYPE_OPTIONAL_INSTANCE_EXTENSIONS_INFO
@ VKD3D_STRUCTURE_TYPE_OPTIONAL_INSTANCE_EXTENSIONS_INFO
The structure is a vkd3d_optional_instance_extensions_info structure.
Definition vkd3d.h:63
VKD3D_STRUCTURE_TYPE_INSTANCE_CREATE_INFO
@ VKD3D_STRUCTURE_TYPE_INSTANCE_CREATE_INFO
The structure is a vkd3d_instance_create_info structure.
Definition vkd3d.h:53
VKD3D_STRUCTURE_TYPE_DEVICE_CREATE_INFO
@ VKD3D_STRUCTURE_TYPE_DEVICE_CREATE_INFO
The structure is a vkd3d_device_create_info structure.
Definition vkd3d.h:55
VKD3D_STRUCTURE_TYPE_OPTIONAL_DEVICE_EXTENSIONS_INFO
@ VKD3D_STRUCTURE_TYPE_OPTIONAL_DEVICE_EXTENSIONS_INFO
The structure is a vkd3d_optional_device_extensions_info structure.
Definition vkd3d.h:69
VKD3D_STRUCTURE_TYPE_IMAGE_RESOURCE_CREATE_INFO
@ VKD3D_STRUCTURE_TYPE_IMAGE_RESOURCE_CREATE_INFO
The structure is a vkd3d_image_resource_create_info structure.
Definition vkd3d.h:57
VKD3D_STRUCTURE_TYPE_APPLICATION_INFO
@ VKD3D_STRUCTURE_TYPE_APPLICATION_INFO
The structure is a vkd3d_application_info structure.
Definition vkd3d.h:74
vkd3d_release_vk_queue
VKD3D_API void vkd3d_release_vk_queue(ID3D12CommandQueue *queue)
Release the Vulkan queue backing a command queue.
PFN_vkd3d_set_log_callback
void(* PFN_vkd3d_set_log_callback)(PFN_vkd3d_log callback)
Type of vkd3d_set_log_callback().
Definition vkd3d.h:537
vkd3d_types.h
This file contains definitions for basic types used by vkd3d libraries.