Loading...
Searching...
No Matches
vkd3d.h File Reference

This file contains definitions for the vkd3d library. More...

`#include <vkd3d_types.h>`
`#include <vkd3d_windows.h>`
`#include <vkd3d_d3d12.h>`
`#include <vulkan/vulkan.h>`
Include dependency graph for vkd3d.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Data Structures

struct | vkd3d_instance_create_info
| A chained structure containing instance creation parameters. More...
struct | vkd3d_optional_instance_extensions_info
| A chained structure to specify optional instance extensions. More...
struct | vkd3d_application_info
| A chained structure to specify application information. More...
struct | vkd3d_host_time_domain_info
| A chained structure to specify the host time domain. More...
struct | vkd3d_device_create_info
| A chained structure containing device creation parameters. More...
struct | vkd3d_optional_device_extensions_info
| A chained structure to specify optional device extensions. More...
struct | vkd3d_image_resource_create_info
| A chained structure containing the parameters to create a D3D12 resource backed by a Vulkan image. More...

## Macros

#define | VKD3D_RESOURCE_INITIAL_STATE_TRANSITION 0x00000001
| When specified as a flag of vkd3d_image_resource_create_info, it means that vkd3d will do the initial transition operation on the image from VK_IMAGE_LAYOUT_UNDEFINED to its appropriate Vulkan layout (depending on its D3D12 resource state).
#define | VKD3D_RESOURCE_PRESENT_STATE_TRANSITION 0x00000002
| When specified as a flag of vkd3d_image_resource_create_info, it means that field present_state is honored.
#define | VKD3D_API VKD3D_IMPORT

## Typedefs

typedef HRESULT(* | PFN_vkd3d_signal_event) (HANDLE event)
typedef void *(* | PFN_vkd3d_thread) (void *data)
typedef void *(* | PFN_vkd3d_create_thread) (PFN_vkd3d_thread thread_main, void *data)
typedef HRESULT(* | PFN_vkd3d_join_thread) (void *thread)
typedef HRESULT(* | PFN_vkd3d_create_instance) (const struct vkd3d_instance_create_info *create_info, struct vkd3d_instance **instance)
typedef ULONG(* | PFN_vkd3d_instance_decref) (struct vkd3d_instance *instance)
typedef VkInstance(* | PFN_vkd3d_instance_get_vk_instance) (struct vkd3d_instance *instance)
typedef ULONG(* | PFN_vkd3d_instance_incref) (struct vkd3d_instance *instance)
typedef HRESULT(* | PFN_vkd3d_create_device) (const struct vkd3d_device_create_info *create_info, REFIID iid, void **device)
typedef IUnknown *(* | PFN_vkd3d_get_device_parent) (ID3D12Device *device)
typedef VkDevice(* | PFN_vkd3d_get_vk_device) (ID3D12Device *device)
typedef VkPhysicalDevice(* | PFN_vkd3d_get_vk_physical_device) (ID3D12Device *device)
typedef struct vkd3d_instance *(* | PFN_vkd3d_instance_from_device) (ID3D12Device *device)
typedef uint32_t(* | PFN_vkd3d_get_vk_queue_family_index) (ID3D12CommandQueue *queue)
typedef VkQueue(* | PFN_vkd3d_acquire_vk_queue) (ID3D12CommandQueue *queue)
typedef void(* | PFN_vkd3d_release_vk_queue) (ID3D12CommandQueue *queue)
typedef HRESULT(* | PFN_vkd3d_create_image_resource) (ID3D12Device *device, const struct vkd3d_image_resource_create_info *create_info, ID3D12Resource **resource)
typedef ULONG(* | PFN_vkd3d_resource_decref) (ID3D12Resource *resource)
typedef ULONG(* | PFN_vkd3d_resource_incref) (ID3D12Resource *resource)
typedef HRESULT(* | PFN_vkd3d_serialize_root_signature) (const D3D12_ROOT_SIGNATURE_DESC *desc, D3D_ROOT_SIGNATURE_VERSION version, ID3DBlob **blob, ID3DBlob **error_blob)
typedef HRESULT(* | PFN_vkd3d_create_root_signature_deserializer) (const void *data, SIZE_T data_size, REFIID iid, void **deserializer)
typedef VkFormat(* | PFN_vkd3d_get_vk_format) (DXGI_FORMAT format)
typedef DXGI_FORMAT(* | PFN_vkd3d_get_dxgi_format) (VkFormat format)
typedef HRESULT(* | PFN_vkd3d_serialize_versioned_root_signature) (const D3D12_VERSIONED_ROOT_SIGNATURE_DESC *desc, ID3DBlob **blob, ID3DBlob **error_blob)
typedef HRESULT(* | PFN_vkd3d_create_versioned_root_signature_deserializer) (const void *data, SIZE_T data_size, REFIID iid, void **deserializer)
typedef void(* | PFN_vkd3d_set_log_callback) (PFN_vkd3d_log callback)
| Type of vkd3d_set_log_callback().
typedef HRESULT(* | PFN_vkd3d_queue_signal_on_cpu) (ID3D12CommandQueue *queue, ID3D12Fence *fence, uint64_t value)
| Type of vkd3d_queue_signal_on_cpu().

## Enumerations

enum

vkd3d_structure_type {
VKD3D_STRUCTURE_TYPE_INSTANCE_CREATE_INFO , VKD3D_STRUCTURE_TYPE_DEVICE_CREATE_INFO , VKD3D_STRUCTURE_TYPE_IMAGE_RESOURCE_CREATE_INFO , VKD3D_STRUCTURE_TYPE_OPTIONAL_INSTANCE_EXTENSIONS_INFO ,
VKD3D_STRUCTURE_TYPE_OPTIONAL_DEVICE_EXTENSIONS_INFO , VKD3D_STRUCTURE_TYPE_APPLICATION_INFO , VKD3D_STRUCTURE_TYPE_HOST_TIME_DOMAIN_INFO , VKD3D_FORCE_32_BIT_ENUM =(VKD3D_STRUCTURE_TYPE)
}

| The type of a chained structure. More...

enum

vkd3d_api_version {
VKD3D_API_VERSION_1_0 , VKD3D_API_VERSION_1_1 , VKD3D_API_VERSION_1_2 , VKD3D_API_VERSION_1_3 ,
VKD3D_API_VERSION_1_4 , VKD3D_API_VERSION_1_5 , VKD3D_API_VERSION_1_6 , VKD3D_API_VERSION_1_7 ,
VKD3D_API_VERSION_1_8 , VKD3D_API_VERSION_1_9 , VKD3D_API_VERSION_1_10 , VKD3D_API_VERSION_1_11 ,
VKD3D_API_VERSION_1_12 , VKD3D_API_VERSION_1_13 , VKD3D_API_VERSION_1_14 , VKD3D_API_VERSION_1_15 ,
VKD3D_API_VERSION_1_16 , VKD3D_API_VERSION_1_17 , VKD3D_API_VERSION_1_18 , VKD3D_API_VERSION_1_19 ,
VKD3D_API_VERSION_2_0 , VKD3D_FORCE_32_BIT_ENUM =(VKD3D_STRUCTURE_TYPE)
}

## Functions

VKD3D_API HRESULT | vkd3d_create_instance (const struct vkd3d_instance_create_info *create_info, struct vkd3d_instance **instance)
VKD3D_API ULONG | vkd3d_instance_decref (struct vkd3d_instance *instance)
VKD3D_API VkInstance | vkd3d_instance_get_vk_instance (struct vkd3d_instance *instance)
VKD3D_API ULONG | vkd3d_instance_incref (struct vkd3d_instance *instance)
VKD3D_API HRESULT | vkd3d_create_device (const struct vkd3d_device_create_info *create_info, REFIID iid, void **device)
VKD3D_API IUnknown * | vkd3d_get_device_parent (ID3D12Device *device)
VKD3D_API VkDevice | vkd3d_get_vk_device (ID3D12Device *device)
VKD3D_API VkPhysicalDevice | vkd3d_get_vk_physical_device (ID3D12Device *device)
VKD3D_API struct vkd3d_instance * | vkd3d_instance_from_device (ID3D12Device *device)
VKD3D_API uint32_t | vkd3d_get_vk_queue_family_index (ID3D12CommandQueue *queue)
VKD3D_API VkQueue | vkd3d_acquire_vk_queue (ID3D12CommandQueue *queue)
| Acquire the Vulkan queue backing a command queue.
VKD3D_API void | vkd3d_release_vk_queue (ID3D12CommandQueue *queue)
| Release the Vulkan queue backing a command queue.
VKD3D_API HRESULT | vkd3d_create_image_resource (ID3D12Device *device, const struct vkd3d_image_resource_create_info *create_info, ID3D12Resource **resource)
VKD3D_API ULONG | vkd3d_resource_decref (ID3D12Resource *resource)
VKD3D_API ULONG | vkd3d_resource_incref (ID3D12Resource *resource)
VKD3D_API HRESULT | vkd3d_serialize_root_signature (const D3D12_ROOT_SIGNATURE_DESC *desc, D3D_ROOT_SIGNATURE_VERSION version, ID3DBlob **blob, ID3DBlob **error_blob)
VKD3D_API HRESULT | vkd3d_create_root_signature_deserializer (const void *data, SIZE_T data_size, REFIID iid, void **deserializer)
VKD3D_API VkFormat | vkd3d_get_vk_format (DXGI_FORMAT format)
VKD3D_API DXGI_FORMAT | vkd3d_get_dxgi_format (VkFormat format)
VKD3D_API HRESULT | vkd3d_serialize_versioned_root_signature (const D3D12_VERSIONED_ROOT_SIGNATURE_DESC *desc, ID3DBlob **blob, ID3DBlob **error_blob)
VKD3D_API HRESULT | vkd3d_create_versioned_root_signature_deserializer (const void *data, SIZE_T data_size, REFIID iid, void **deserializer)
VKD3D_API void | vkd3d_set_log_callback (PFN_vkd3d_log callback)
| Set a callback to be called when vkd3d outputs debug logging.
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.

## Detailed Description

This file contains definitions for the vkd3d library.

The vkd3d library is a 3D graphics library built on top of Vulkan. It has an API very similar, but not identical, to Direct3D 12.

Since
  1.0

## Macro Definition Documentation

## VKD3D_RESOURCE_INITIAL_STATE_TRANSITION

#define VKD3D_RESOURCE_INITIAL_STATE_TRANSITION 0x00000001

When specified as a flag of vkd3d_image_resource_create_info, it means that vkd3d will do the initial transition operation on the image from VK_IMAGE_LAYOUT_UNDEFINED to its appropriate Vulkan layout (depending on its D3D12 resource state).

If this flag is not specified the caller is responsible for transitioning the Vulkan image to the appropriate layout.

## Typedef Documentation

## PFN_vkd3d_queue_signal_on_cpu

typedef HRESULT(* PFN_vkd3d_queue_signal_on_cpu) (ID3D12CommandQueue *queue, ID3D12Fence *fence, uint64_t value)

Type of vkd3d_queue_signal_on_cpu().

Since
  1.15

## PFN_vkd3d_set_log_callback

typedef void(* PFN_vkd3d_set_log_callback) (PFN_vkd3d_log callback)

Type of vkd3d_set_log_callback().

Since
  1.4

## Enumeration Type Documentation

## vkd3d_structure_type

enum vkd3d_structure_type

The type of a chained structure.

Enumerator
VKD3D_STRUCTURE_TYPE_INSTANCE_CREATE_INFO | The structure is a vkd3d_instance_create_info structure.
VKD3D_STRUCTURE_TYPE_DEVICE_CREATE_INFO | The structure is a vkd3d_device_create_info structure.
VKD3D_STRUCTURE_TYPE_IMAGE_RESOURCE_CREATE_INFO | The structure is a vkd3d_image_resource_create_info structure.

VKD3D_STRUCTURE_TYPE_OPTIONAL_INSTANCE_EXTENSIONS_INFO

The structure is a vkd3d_optional_instance_extensions_info structure.

Since
  1.1

VKD3D_STRUCTURE_TYPE_OPTIONAL_DEVICE_EXTENSIONS_INFO

The structure is a vkd3d_optional_device_extensions_info structure.

Since
  1.2

VKD3D_STRUCTURE_TYPE_APPLICATION_INFO

The structure is a vkd3d_application_info structure.

Since
  1.2

VKD3D_STRUCTURE_TYPE_HOST_TIME_DOMAIN_INFO

The structure is a vkd3d_host_time_domain_info structure.

Since
  1.3

## Function Documentation

## vkd3d_acquire_vk_queue()

VKD3D_API VkQueue vkd3d_acquire_vk_queue | ( | ID3D12CommandQueue * | queue | ) |

Acquire the Vulkan queue backing a command queue.

While a queue is acquired by the client, it is locked so that neither the vkd3d library nor other threads can submit work to it. For that reason it should be released as soon as possible with vkd3d_release_vk_queue(). The lock is not reentrant, so the same queue must not be acquired more than once by the same thread.

Work submitted through the Direct3D 12 API exposed by vkd3d is not always immediately submitted to the Vulkan queue; sometimes it is kept in another internal queue, which might not necessarily be empty at the time vkd3d_acquire_vk_queue() is called. For this reason, work submitted directly to the Vulkan queue might appear to the Vulkan driver as being submitted before other work submitted though the Direct3D 12 API. If this is not desired, it is recommended to synchronize work submission using an ID3D12Fence object:

1. submit work through the Direct3D 12 API;
2. call vkd3d_queue_signal_on_cpu();
3. wait for the fence to be signalled;
4. call vkd3d_acquire_vk_queue(); it is guaranteed that all work submitted at point 1 has already been submitted to Vulkan (though not necessarily executed).

Since
  1.0

## 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.

The fence will be signalled on the CPU (as if ID3D12Fence_Signal() was called) once all the work submitted through the Direct3D 12 API before vkd3d_queue_signal_on_cpu() is called has left the internal queue and has been submitted to the underlying Vulkan queue. Read the documentation for vkd3d_acquire_vk_queue() for more details.

Since
  1.15

## vkd3d_release_vk_queue()

VKD3D_API void vkd3d_release_vk_queue | ( | ID3D12CommandQueue * | queue | ) |

Release the Vulkan queue backing a command queue.

This must be paired to an earlier corresponding vkd3d_acquire_vk_queue(). After this function is called, the Vulkan queue returned by vkd3d_acquire_vk_queue() must not be used any more.

Since
  1.0

## 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.

If NULL, or if this function has not been called, libvkd3d will print all enabled log output to stderr.

Calling this function will also set the log callback for libvkd3d-shader.

Parameters

  callback | Callback function to set.

Since
  1.4