vrclient: Factor out ivrcompositor_submit_dxvk().
This commit is contained in:
parent
66e149f87f
commit
53b798a62f
1 changed files with 79 additions and 80 deletions
|
@ -583,6 +583,77 @@ static EVRCompositorError ivrcompositor_submit_wined3d(
|
|||
return 0;
|
||||
}
|
||||
|
||||
#if !defined(__APPLE__) || defined(__x86_64__)
|
||||
static EVRCompositorError ivrcompositor_submit_dxvk(
|
||||
EVRCompositorError (*cpp_func)(void *, EVREye, Texture_t *, VRTextureBounds_t *, EVRSubmitFlags),
|
||||
void *linux_side, EVREye eye, Texture_t *texture, VRTextureBounds_t *bounds, EVRSubmitFlags flags,
|
||||
unsigned int version, struct compositor_data *user_data, IDXGIVkInteropSurface *dxvk_surface)
|
||||
{
|
||||
struct VRVulkanTextureData_t vkdata;
|
||||
IDXGIVkInteropDevice *dxvk_device;
|
||||
struct Texture_t vktexture;
|
||||
|
||||
VkImage image_handle;
|
||||
VkImageLayout image_layout;
|
||||
VkImageCreateInfo image_info;
|
||||
VkImageSubresourceRange subresources;
|
||||
|
||||
EVRCompositorError err;
|
||||
|
||||
dxvk_surface->lpVtbl->GetDevice(dxvk_surface, &dxvk_device);
|
||||
|
||||
user_data->dxvk_device = dxvk_device;
|
||||
|
||||
dxvk_device->lpVtbl->GetVulkanHandles(dxvk_device, &vkdata.m_pInstance,
|
||||
&vkdata.m_pPhysicalDevice, &vkdata.m_pDevice);
|
||||
|
||||
dxvk_device->lpVtbl->GetSubmissionQueue(dxvk_device, &vkdata.m_pQueue, &vkdata.m_nQueueFamilyIndex);
|
||||
|
||||
/* DXVK needs this to be initialized correctly */
|
||||
image_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
|
||||
image_info.pNext = NULL;
|
||||
|
||||
dxvk_surface->lpVtbl->GetVulkanImageInfo(dxvk_surface, &image_handle, &image_layout, &image_info);
|
||||
|
||||
load_vk_unwrappers();
|
||||
|
||||
vkdata.m_nImage = (uint64_t)image_handle;
|
||||
vkdata.m_pDevice = get_native_VkDevice(vkdata.m_pDevice);
|
||||
vkdata.m_pPhysicalDevice = get_native_VkPhysicalDevice(vkdata.m_pPhysicalDevice);
|
||||
vkdata.m_pInstance = get_native_VkInstance(vkdata.m_pInstance);
|
||||
vkdata.m_pQueue = get_native_VkQueue(vkdata.m_pQueue);
|
||||
vkdata.m_nWidth = image_info.extent.width;
|
||||
vkdata.m_nHeight = image_info.extent.height;
|
||||
vkdata.m_nFormat = image_info.format;
|
||||
vkdata.m_nSampleCount = image_info.samples;
|
||||
|
||||
vktexture = *texture;
|
||||
vktexture.handle = &vkdata;
|
||||
vktexture.eType = TextureType_Vulkan;
|
||||
|
||||
subresources.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
|
||||
subresources.baseMipLevel = 0;
|
||||
subresources.levelCount = image_info.mipLevels;
|
||||
subresources.baseArrayLayer = 0;
|
||||
subresources.layerCount = image_info.arrayLayers;
|
||||
|
||||
dxvk_device->lpVtbl->TransitionSurfaceLayout(dxvk_device, dxvk_surface, &subresources,
|
||||
image_layout, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL);
|
||||
dxvk_device->lpVtbl->FlushRenderingCommands(dxvk_device);
|
||||
dxvk_device->lpVtbl->LockSubmissionQueue(dxvk_device);
|
||||
|
||||
err = cpp_func(linux_side, eye, &vktexture, bounds, flags);
|
||||
|
||||
dxvk_device->lpVtbl->ReleaseSubmissionQueue(dxvk_device);
|
||||
dxvk_device->lpVtbl->TransitionSurfaceLayout(dxvk_device, dxvk_surface, &subresources,
|
||||
VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, image_layout);
|
||||
|
||||
dxvk_device->lpVtbl->Release(dxvk_device);
|
||||
dxvk_surface->lpVtbl->Release(dxvk_surface);
|
||||
return err;
|
||||
}
|
||||
#endif
|
||||
|
||||
EVRCompositorError ivrcompositor_submit(
|
||||
EVRCompositorError (*cpp_func)(void *, EVREye, Texture_t *, VRTextureBounds_t *, EVRSubmitFlags),
|
||||
void *linux_side, EVREye eye, Texture_t *texture, VRTextureBounds_t *bounds, EVRSubmitFlags flags,
|
||||
|
@ -591,10 +662,6 @@ EVRCompositorError ivrcompositor_submit(
|
|||
IWineD3D11Texture2D *wine_texture;
|
||||
IUnknown *texture_iface;
|
||||
HRESULT hr;
|
||||
#if !defined(__APPLE__) || defined(__x86_64__)
|
||||
IDXGIVkInteropSurface *dxvk_surface;
|
||||
IDXGIVkInteropDevice *dxvk_device;
|
||||
#endif
|
||||
|
||||
TRACE("%p, %#x, %p, %p, %#x\n", linux_side, eye, texture, bounds, flags);
|
||||
|
||||
|
@ -614,82 +681,15 @@ EVRCompositorError ivrcompositor_submit(
|
|||
}
|
||||
|
||||
#if !defined(__APPLE__) || defined(__x86_64__)
|
||||
hr = texture_iface->lpVtbl->QueryInterface(texture_iface,
|
||||
&IID_IDXGIVkInteropSurface, (void **)&dxvk_surface);
|
||||
{
|
||||
IDXGIVkInteropSurface *dxvk_surface;
|
||||
|
||||
if (SUCCEEDED(hr)) {
|
||||
struct VRVulkanTextureData_t vkdata;
|
||||
struct Texture_t vktexture;
|
||||
|
||||
VkImage image_handle;
|
||||
VkImageLayout image_layout;
|
||||
VkImageCreateInfo image_info;
|
||||
VkImageSubresourceRange subresources;
|
||||
|
||||
EVRCompositorError err;
|
||||
|
||||
dxvk_surface->lpVtbl->GetDevice(
|
||||
dxvk_surface, &dxvk_device);
|
||||
|
||||
user_data->dxvk_device = dxvk_device;
|
||||
|
||||
dxvk_device->lpVtbl->GetVulkanHandles(
|
||||
dxvk_device,
|
||||
&vkdata.m_pInstance,
|
||||
&vkdata.m_pPhysicalDevice,
|
||||
&vkdata.m_pDevice);
|
||||
|
||||
dxvk_device->lpVtbl->GetSubmissionQueue(
|
||||
dxvk_device,
|
||||
&vkdata.m_pQueue,
|
||||
&vkdata.m_nQueueFamilyIndex);
|
||||
|
||||
// DXVK needs this to be initialized correctly
|
||||
image_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
|
||||
image_info.pNext = NULL;
|
||||
|
||||
dxvk_surface->lpVtbl->GetVulkanImageInfo(
|
||||
dxvk_surface, &image_handle,
|
||||
&image_layout, &image_info);
|
||||
|
||||
load_vk_unwrappers();
|
||||
|
||||
vkdata.m_nImage = (uint64_t)image_handle;
|
||||
vkdata.m_pDevice = get_native_VkDevice(vkdata.m_pDevice);
|
||||
vkdata.m_pPhysicalDevice = get_native_VkPhysicalDevice(vkdata.m_pPhysicalDevice);
|
||||
vkdata.m_pInstance = get_native_VkInstance(vkdata.m_pInstance);
|
||||
vkdata.m_pQueue = get_native_VkQueue(vkdata.m_pQueue);
|
||||
vkdata.m_nWidth = image_info.extent.width;
|
||||
vkdata.m_nHeight = image_info.extent.height;
|
||||
vkdata.m_nFormat = image_info.format;
|
||||
vkdata.m_nSampleCount = image_info.samples;
|
||||
|
||||
vktexture = *texture;
|
||||
vktexture.handle = &vkdata;
|
||||
vktexture.eType = TextureType_Vulkan;
|
||||
|
||||
subresources.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
|
||||
subresources.baseMipLevel = 0;
|
||||
subresources.levelCount = image_info.mipLevels;
|
||||
subresources.baseArrayLayer = 0;
|
||||
subresources.layerCount = image_info.arrayLayers;
|
||||
|
||||
dxvk_device->lpVtbl->TransitionSurfaceLayout(
|
||||
dxvk_device, dxvk_surface, &subresources,
|
||||
image_layout, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL);
|
||||
dxvk_device->lpVtbl->FlushRenderingCommands(dxvk_device);
|
||||
dxvk_device->lpVtbl->LockSubmissionQueue(dxvk_device);
|
||||
|
||||
err = cpp_func(linux_side, eye, &vktexture, bounds, flags);
|
||||
|
||||
dxvk_device->lpVtbl->ReleaseSubmissionQueue(dxvk_device);
|
||||
dxvk_device->lpVtbl->TransitionSurfaceLayout(
|
||||
dxvk_device, dxvk_surface, &subresources,
|
||||
VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, image_layout);
|
||||
|
||||
dxvk_device->lpVtbl->Release(dxvk_device);
|
||||
dxvk_surface->lpVtbl->Release(dxvk_surface);
|
||||
return err;
|
||||
if (SUCCEEDED(hr = texture_iface->lpVtbl->QueryInterface(texture_iface,
|
||||
&IID_IDXGIVkInteropSurface, (void **)&dxvk_surface)))
|
||||
{
|
||||
return ivrcompositor_submit_dxvk(cpp_func, linux_side,
|
||||
eye, texture, bounds, flags, version, user_data, dxvk_surface);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -697,7 +697,6 @@ EVRCompositorError ivrcompositor_submit(
|
|||
return cpp_func(linux_side, eye, texture, bounds, flags);
|
||||
}
|
||||
|
||||
|
||||
case TextureType_Vulkan:
|
||||
{
|
||||
struct VRVulkanTextureData_t our_vkdata, our_depth_vkdata, *their_vkdata;
|
||||
|
|
Loading…
Reference in a new issue