mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
libs/vkd3d: Introduce vkd3d_format.
This commit is contained in:
parent
9620873b55
commit
ab883caaff
@ -22,6 +22,44 @@
|
||||
|
||||
#include "vkd3d_private.h"
|
||||
|
||||
static const struct vkd3d_format vkd3d_formats[] =
|
||||
{
|
||||
{DXGI_FORMAT_R32G32B32A32_FLOAT, VK_FORMAT_R32G32B32A32_SFLOAT, 16, VK_IMAGE_ASPECT_COLOR_BIT},
|
||||
{DXGI_FORMAT_R32G32B32A32_UINT, VK_FORMAT_R32G32B32A32_UINT, 16, VK_IMAGE_ASPECT_COLOR_BIT},
|
||||
{DXGI_FORMAT_R32G32B32A32_SINT, VK_FORMAT_R32G32B32A32_SINT, 16, VK_IMAGE_ASPECT_COLOR_BIT},
|
||||
{DXGI_FORMAT_R32G32B32_FLOAT, VK_FORMAT_R32G32B32_SFLOAT, 12, VK_IMAGE_ASPECT_COLOR_BIT},
|
||||
{DXGI_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_R8G8B8A8_UNORM, 4, VK_IMAGE_ASPECT_COLOR_BIT},
|
||||
{DXGI_FORMAT_R32_FLOAT, VK_FORMAT_R32_SFLOAT, 4, VK_IMAGE_ASPECT_COLOR_BIT},
|
||||
{DXGI_FORMAT_B8G8R8A8_UNORM, VK_FORMAT_B8G8R8A8_UNORM, 4, VK_IMAGE_ASPECT_COLOR_BIT},
|
||||
};
|
||||
|
||||
const struct vkd3d_format *vkd3d_get_format(DXGI_FORMAT dxgi_format)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(vkd3d_formats); ++i)
|
||||
{
|
||||
if (vkd3d_formats[i].dxgi_format == dxgi_format)
|
||||
return &vkd3d_formats[i];
|
||||
}
|
||||
|
||||
FIXME("Unhandled DXGI format %#x.\n", dxgi_format);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
VkFormat vk_format_from_dxgi_format(DXGI_FORMAT dxgi_format)
|
||||
{
|
||||
const struct vkd3d_format *format;
|
||||
|
||||
if (!(format = vkd3d_get_format(dxgi_format)))
|
||||
{
|
||||
FIXME("Unhandled format %#x.\n", dxgi_format);
|
||||
return VK_FORMAT_UNDEFINED;
|
||||
}
|
||||
|
||||
return format->vk_format;
|
||||
}
|
||||
|
||||
bool vkd3d_array_reserve(void **elements, size_t *capacity, size_t element_count, size_t element_size)
|
||||
{
|
||||
size_t new_capacity, max_capacity;
|
||||
@ -159,30 +197,6 @@ const char *debug_vk_memory_property_flags(VkMemoryPropertyFlags flags)
|
||||
return vkd3d_dbg_sprintf("%s", &buffer[3]);
|
||||
}
|
||||
|
||||
VkFormat vk_format_from_dxgi_format(DXGI_FORMAT format)
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
case DXGI_FORMAT_R32G32B32A32_FLOAT:
|
||||
return VK_FORMAT_R32G32B32A32_SFLOAT;
|
||||
case DXGI_FORMAT_R32G32B32A32_UINT:
|
||||
return VK_FORMAT_R32G32B32A32_UINT;
|
||||
case DXGI_FORMAT_R32G32B32A32_SINT:
|
||||
return VK_FORMAT_R32G32B32A32_SINT;
|
||||
case DXGI_FORMAT_R32G32B32_FLOAT:
|
||||
return VK_FORMAT_R32G32B32_SFLOAT;
|
||||
case DXGI_FORMAT_R8G8B8A8_UNORM:
|
||||
return VK_FORMAT_R8G8B8A8_UNORM;
|
||||
case DXGI_FORMAT_R32_FLOAT:
|
||||
return VK_FORMAT_R32_SFLOAT;
|
||||
case DXGI_FORMAT_B8G8R8A8_UNORM:
|
||||
return VK_FORMAT_B8G8R8A8_UNORM;
|
||||
default:
|
||||
FIXME("Unhandled format %#x.\n", format);
|
||||
return VK_FORMAT_UNDEFINED;
|
||||
}
|
||||
}
|
||||
|
||||
HRESULT hresult_from_vk_result(VkResult vr)
|
||||
{
|
||||
switch (vr)
|
||||
|
@ -275,6 +275,16 @@ HRESULT d3d12_device_create(const struct vkd3d_device_create_info *create_info,
|
||||
struct d3d12_device **device) DECLSPEC_HIDDEN;
|
||||
|
||||
/* utils */
|
||||
struct vkd3d_format
|
||||
{
|
||||
DXGI_FORMAT dxgi_format;
|
||||
VkFormat vk_format;
|
||||
size_t byte_count;
|
||||
VkImageAspectFlags vk_aspect_mask;
|
||||
};
|
||||
|
||||
const struct vkd3d_format *vkd3d_get_format(DXGI_FORMAT dxgi_format) DECLSPEC_HIDDEN;
|
||||
|
||||
BOOL is_valid_feature_level(D3D_FEATURE_LEVEL feature_level) DECLSPEC_HIDDEN;
|
||||
BOOL check_feature_level_support(D3D_FEATURE_LEVEL feature_level) DECLSPEC_HIDDEN;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user