vrclient_x64: Support submitting D3D12 textures.

CW-Bug-Id: #23542
This commit is contained in:
Yuxuan Shui 2024-04-15 11:00:19 +01:00 committed by Arkadiusz Hiler
parent e3798c1adb
commit a3711d4747
4 changed files with 492 additions and 63 deletions

View file

@ -1,6 +1,7 @@
#include <stdarg.h>
#include <stddef.h>
#include <stdint.h>
#include <vulkan/vulkan.h>
#ifndef __cplusplus
#include "unixlib.h"
@ -15,6 +16,8 @@ void *create_LinuxMatchmakingServerListResponse(void *win);
#ifndef __cplusplus
typedef struct ID3D11Device ID3D11Device;
typedef struct IDXGIVkInteropDevice IDXGIVkInteropDevice;
typedef struct ID3D12DXVKInteropDevice ID3D12DXVKInteropDevice;
typedef struct ID3D12CommandQueue ID3D12CommandQueue;
struct client_core_data
{
@ -24,13 +27,44 @@ struct client_core_data
SIZE_T created_interfaces_size;
};
#define VK_PROCS \
X(vkAllocateCommandBuffers) \
X(vkBeginCommandBuffer) \
X(vkEndCommandBuffer) \
X(vkQueueSubmit) \
X(vkQueueWaitIdle) \
X(vkFreeCommandBuffers) \
X(vkCmdPipelineBarrier) \
X(vkCreateCommandPool) \
X(vkDestroyCommandPool) \
X(vkDestroyFence) \
X(vkCreateFence) \
X(vkWaitForFences) \
X(vkResetFences)
struct compositor_data
{
ID3D11Device *d3d11_device;
/* Vulkan queues aren't thread safe whereas D3D ones are. And
* the OpenVR runtime could use the Vulkan queue in some functions.
* So we need to lock the vulkan queues to prevent unsafe access using
* IDXGIVkInteropDevice or ID3D12DXVKInteropDevice interfaces. */
IDXGIVkInteropDevice *dxvk_device;
ID3D12DXVKInteropDevice *d3d12_device;
ID3D12CommandQueue *d3d12_queue;
BOOL d3d11_explicit_handoff, handoff_called;
void *client_core_linux_side;
#define X(proc) PFN_##proc p_##proc;
VK_PROCS
#undef X
VkDevice vk_device;
VkQueue vk_queue;
VkCommandPool vk_command_pool;
VkCommandBuffer vk_command_buffers[4];
VkFence vk_fences[4];
int command_buffer_index;
#ifndef __x86_64__
/* Digital action state change fixup hack. */
struct
@ -65,6 +99,7 @@ extern iface_destructor find_iface_destructor( const char *iface_version );
extern void init_rtti( char *base );
struct w_steam_iface *create_win_interface(const char *name, void *linux_side);
void free_compositor_data_d3d12_device(void);
struct generic_interface
{
@ -78,6 +113,13 @@ extern w_Texture_t vrclient_translate_texture_dxvk( const w_Texture_t *texture,
VkImageLayout *image_layout, VkImageCreateInfo *image_info );
#endif /* __dxvk_interop_h__ */
#ifdef __ID3D12DXVKInteropDevice_INTERFACE_DEFINED__
extern w_Texture_t vrclient_translate_texture_d3d12( const w_Texture_t *texture, w_VRVulkanTextureData_t *vkdata,
ID3D12DXVKInteropDevice *d3d12_device, ID3D12Resource *d3d12_resource,
ID3D12CommandQueue *d3d12_queue, VkImageLayout *image_layout,
VkImageCreateInfo *image_info );
#endif /* __ID3D12DXVKInteropDevice_INTERFACE_DEFINED__ */
#include "vrclient_generated.h"
#endif /* __cplusplus */