vkd3d: Introduce vkd3d_internal_get_vk_format.

Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
This commit is contained in:
Georg Lehmann 2021-06-22 19:31:59 +02:00 committed by Hans-Kristian Arntzen
parent 0d9c7bc3ad
commit a7922a7c85
6 changed files with 23 additions and 10 deletions

View File

@ -63,7 +63,7 @@ static VkGeometryFlagsKHR d3d12_geometry_flags_to_vk(D3D12_RAYTRACING_GEOMETRY_F
return vk_flags;
}
bool vkd3d_acceleration_structure_convert_inputs(
bool vkd3d_acceleration_structure_convert_inputs(const struct d3d12_device *device,
struct vkd3d_acceleration_structure_build_info *info,
const D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS *desc)
{
@ -158,7 +158,7 @@ bool vkd3d_acceleration_structure_convert_inputs(
triangles->maxVertex = max(1, geom_desc->Triangles.VertexCount) - 1;
triangles->vertexStride = geom_desc->Triangles.VertexBuffer.StrideInBytes;
triangles->vertexFormat = vkd3d_get_vk_format(geom_desc->Triangles.VertexFormat);
triangles->vertexFormat = vkd3d_internal_get_vk_format(device, geom_desc->Triangles.VertexFormat);
triangles->vertexData.deviceAddress = geom_desc->Triangles.VertexBuffer.StartAddress;
triangles->transformData.deviceAddress = geom_desc->Triangles.Transform3x4;
break;

View File

@ -8709,7 +8709,7 @@ static void STDMETHODCALLTYPE d3d12_command_list_BuildRaytracingAccelerationStru
return;
}
if (!vkd3d_acceleration_structure_convert_inputs(&build_info, &desc->Inputs))
if (!vkd3d_acceleration_structure_convert_inputs(list->device, &build_info, &desc->Inputs))
{
ERR("Failed to convert inputs.\n");
return;

View File

@ -4367,7 +4367,7 @@ static void STDMETHODCALLTYPE d3d12_device_GetRaytracingAccelerationStructurePre
return;
}
if (!vkd3d_acceleration_structure_convert_inputs(&build_info, desc))
if (!vkd3d_acceleration_structure_convert_inputs(device, &build_info, desc))
{
ERR("Failed to convert inputs.\n");
memset(info, 0, sizeof(*info));

View File

@ -688,7 +688,8 @@ static VkFormat get_swapchain_fallback_format(VkFormat vk_format)
}
}
static HRESULT select_vk_format(const struct vkd3d_vk_device_procs *vk_procs,
static HRESULT select_vk_format(const struct d3d12_device *device,
const struct vkd3d_vk_device_procs *vk_procs,
VkPhysicalDevice vk_physical_device, VkSurfaceKHR vk_surface,
const DXGI_SWAP_CHAIN_DESC1 *swapchain_desc, VkFormat *vk_format)
{
@ -700,7 +701,7 @@ static HRESULT select_vk_format(const struct vkd3d_vk_device_procs *vk_procs,
*vk_format = VK_FORMAT_UNDEFINED;
format = vkd3d_get_vk_format(swapchain_desc->Format);
format = vkd3d_internal_get_vk_format(device, swapchain_desc->Format);
vr = vk_procs->vkGetPhysicalDeviceSurfaceFormatsKHR(vk_physical_device, vk_surface, &format_count, NULL);
if (vr < 0 || !format_count)
@ -1369,8 +1370,9 @@ static HRESULT d3d12_swapchain_create_vulkan_swapchain(struct d3d12_swapchain *s
{
VkPhysicalDevice vk_physical_device = d3d12_swapchain_device(swapchain)->vk_physical_device;
const struct vkd3d_vk_device_procs *vk_procs = d3d12_swapchain_procs(swapchain);
VkSwapchainCreateInfoKHR vk_swapchain_desc;
const struct d3d12_device *device = d3d12_swapchain_device(swapchain);
VkDevice vk_device = d3d12_swapchain_device(swapchain)->vk_device;
VkSwapchainCreateInfoKHR vk_swapchain_desc;
VkFormat vk_format, vk_swapchain_format;
unsigned int width, height, image_count;
VkSurfaceCapabilitiesKHR surface_caps;
@ -1379,13 +1381,13 @@ static HRESULT d3d12_swapchain_create_vulkan_swapchain(struct d3d12_swapchain *s
VkResult vr;
HRESULT hr;
if (!(vk_format = vkd3d_get_vk_format(swapchain->desc.Format)))
if (!(vk_format = vkd3d_internal_get_vk_format(device, swapchain->desc.Format)))
{
WARN("Invalid format %#x.\n", swapchain->desc.Format);
return DXGI_ERROR_INVALID_CALL;
}
if (FAILED(hr = select_vk_format(vk_procs, vk_physical_device,
if (FAILED(hr = select_vk_format(device, vk_procs, vk_physical_device,
swapchain->vk_surface, &swapchain->desc, &vk_swapchain_format)))
return hr;

View File

@ -483,6 +483,16 @@ const struct vkd3d_format *vkd3d_get_format(const struct d3d12_device *device,
return format->dxgi_format ? format : NULL;
}
VkFormat vkd3d_internal_get_vk_format(const struct d3d12_device *device, DXGI_FORMAT dxgi_format)
{
const struct vkd3d_format *format;
if ((format = vkd3d_get_format(device, dxgi_format, false)))
return format->vk_format;
return VK_FORMAT_UNDEFINED;
}
DXGI_FORMAT vkd3d_get_typeless_format(const struct d3d12_device *device, DXGI_FORMAT dxgi_format)
{
const struct vkd3d_format *format = vkd3d_get_format(device, dxgi_format, true);

View File

@ -2821,6 +2821,7 @@ const struct vkd3d_format *vkd3d_get_format(const struct d3d12_device *device,
DXGI_FORMAT vkd3d_get_typeless_format(const struct d3d12_device *device, DXGI_FORMAT dxgi_format);
const struct vkd3d_format *vkd3d_find_uint_format(const struct d3d12_device *device,
DXGI_FORMAT dxgi_format);
VkFormat vkd3d_internal_get_vk_format(const struct d3d12_device *device, DXGI_FORMAT dxgi_format);
HRESULT vkd3d_init_format_info(struct d3d12_device *device);
void vkd3d_cleanup_format_info(struct d3d12_device *device);
@ -3000,7 +3001,7 @@ struct vkd3d_acceleration_structure_build_info
void vkd3d_acceleration_structure_build_info_cleanup(
struct vkd3d_acceleration_structure_build_info *info);
bool vkd3d_acceleration_structure_convert_inputs(
bool vkd3d_acceleration_structure_convert_inputs(const struct d3d12_device *device,
struct vkd3d_acceleration_structure_build_info *info,
const D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS *desc);
void vkd3d_acceleration_structure_emit_postbuild_info(