Commit 3b1fe64f by Frank Henigman Committed by Commit Bot

Vulkan: allow a list of fallback formats.

Allow a list of fallback formats as well as a single one in the format map. The first supported format is used. No functional change. BUG=angleproject:2655 Change-Id: Ica312b7899471a7a65184a6921713b79da056f31 Reviewed-on: https://chromium-review.googlesource.com/1214847Reviewed-by: 's avatarYuly Novikov <ynovikov@chromium.org> Commit-Queue: Yuly Novikov <ynovikov@chromium.org>
parent a59ae05b
......@@ -66,7 +66,7 @@
"Vulkan format:src/libANGLE/renderer/angle_format_map.json":
"ea6dfe3ebbc86e04f0d4b9f568ba22ae",
"Vulkan format:src/libANGLE/renderer/vulkan/gen_vk_format_table.py":
"4a69cb1e69194ca237b94642edbd3f69",
"1d7d1b6a1f2b4b6f5080197c56b908b4",
"Vulkan format:src/libANGLE/renderer/vulkan/vk_format_map.json":
"f7cb189ab41f1ce48ff26e7c328c5cd0",
"Vulkan internal shader programs:src/libANGLE/renderer/vulkan/gen_vk_internal_shaders.py":
......@@ -82,7 +82,7 @@
"Vulkan mandatory format support table:src/libANGLE/renderer/vulkan/vk_mandatory_format_support_data.json":
"fa2bd54c1bb0ab2cf1d386061a4bc5c5",
"Vulkan mandatory format support table:third_party/vulkan-headers/src/registry/vk.xml":
"c73903f9411b54db01d4891bc24ebd0e",
"de9fb16e43de8ab4b69f673c2ca03704",
"packed enum:src/common/gen_packed_gl_enums.py":
"a9b1c38b4e4d8a1038e743be323f1a51",
"packed enum:src/common/packed_egl_enums.json":
......@@ -92,7 +92,7 @@
"proc table:src/libGLESv2/gen_proc_table.py":
"027bfd5a8a8dffe91f492bf199029cde",
"proc table:src/libGLESv2/proc_table_data.json":
"2c452ae503df669222e85961ab75fb22",
"77dd1356708c3c8014bb22f890db6e08",
"uniform type:src/common/gen_uniform_type_table.py":
"59cb4ffd0f584c4bd37f2f4ff59a2b93"
}
\ No newline at end of file
......@@ -69,79 +69,82 @@ internalFormat = {internal_format};
break;
"""
texture_basic_template = """textureFormatID = angle::FormatID::{texture};
texture_basic_template = """textureFormatID = {texture};
vkTextureFormat = {vk_texture_format};
textureInitializerFunction = {texture_initializer};"""
texture_struct_template="{{{texture}, {vk_texture_format}, {texture_initializer}}}"
texture_fallback_template = """{{
static constexpr TextureFormatInitInfo kInfo[] = {{{texture_list}}};
initTextureFallback(physicalDevice, kInfo, ArraySize(kInfo));
}}"""
texture_fallback_template = """initTextureFallback(physicalDevice,
angle::FormatID::{texture},
{vk_texture_format},
{texture_initializer},
angle::FormatID::{texture_fallback},
{vk_texture_format_fallback},
{texture_initializer_fallback});"""
buffer_basic_template = """bufferFormatID = angle::FormatID::{buffer};
buffer_basic_template = """bufferFormatID = {buffer};
vkBufferFormat = {vk_buffer_format};
vertexLoadFunction = {vertex_load_function};
vertexLoadRequiresConversion = {vertex_load_converts};"""
buffer_fallback_template = """initBufferFallback(physicalDevice,
angle::FormatID::{buffer},
{vk_buffer_format},
{vertex_load_function},
{vertex_load_converts},
angle::FormatID::{buffer_fallback},
{vk_buffer_format_fallback},
{vertex_load_function_fallback});"""
buffer_struct_template="""{{{buffer}, {vk_buffer_format}, {vertex_load_function},
{vertex_load_converts}}}"""
buffer_fallback_template = """{{
static constexpr BufferFormatInitInfo kInfo[] = {{{buffer_list}}};
initBufferFallback(physicalDevice, kInfo, ArraySize(kInfo));
}}"""
def gen_format_case(angle, internal_format, vk_json_data):
vk_map = vk_json_data["map"]
vk_overrides = vk_json_data["overrides"]
vk_fallbacks = vk_json_data["fallbacks"]
args = { "format_id" : angle }
args = dict(format_id=angle, internal_format=internal_format,
texture_template="", buffer_template="")
if ((angle not in vk_map) and (angle not in vk_overrides) and
(angle not in vk_fallbacks)) or angle == 'NONE':
return empty_format_entry_template.format(**args)
def get_formats_and_template(format, type, basic_template, fallback_template):
def get_formats(format, type):
format = vk_overrides.get(format, {}).get(type, format)
fallback = vk_fallbacks.get(format, {}).get(type, "NONE")
if format not in vk_map:
format = "NONE"
template = ""
elif fallback == "NONE":
template = basic_template
else:
template = fallback_template
return format, fallback, template
texture_format, texture_fallback, texture_template = get_formats_and_template(
angle, "texture", texture_basic_template, texture_fallback_template)
buffer_format, buffer_fallback, buffer_template = get_formats_and_template(
angle, "buffer", buffer_basic_template, buffer_fallback_template)
args.update(
internal_format=internal_format,
texture_template=texture_template,
texture=texture_format,
vk_texture_format=vk_map[texture_format],
texture_initializer=angle_format.get_internal_format_initializer(internal_format,
texture_format),
texture_fallback=texture_fallback,
vk_texture_format_fallback=vk_map[texture_fallback],
texture_initializer_fallback=angle_format.get_internal_format_initializer(internal_format,
texture_fallback),
buffer_template=buffer_template,
buffer=buffer_format,
vk_buffer_format=vk_map[buffer_format],
vertex_load_function=angle_format.get_vertex_copy_function(angle, buffer_format),
vertex_load_converts='false' if angle == buffer_format else 'true',
buffer_fallback=buffer_fallback,
vk_buffer_format_fallback=vk_map[buffer_fallback],
vertex_load_function_fallback=angle_format.get_vertex_copy_function(angle, buffer_fallback),
)
return []
fallbacks = vk_fallbacks.get(format, {}).get(type, [])
if not isinstance(fallbacks, list):
fallbacks = [fallbacks]
return [format] + fallbacks
def texture_args(format):
return dict(
texture="angle::FormatID::" + format,
vk_texture_format=vk_map[format],
texture_initializer=angle_format.get_internal_format_initializer(internal_format,
format)
)
def buffer_args(format):
return dict(
buffer="angle::FormatID::" + format,
vk_buffer_format=vk_map[format],
vertex_load_function=angle_format.get_vertex_copy_function(angle, format),
vertex_load_converts='false' if angle == format else 'true',
)
textures = get_formats(angle, "texture")
if len(textures) == 1:
args.update(texture_template=texture_basic_template)
args.update(texture_args(textures[0]))
elif len(textures) > 1:
args.update(
texture_template=texture_fallback_template,
texture_list=", ".join(texture_struct_template.format(**texture_args(i))
for i in textures)
)
buffers = get_formats(angle, "buffer")
if len(buffers) == 1:
args.update(buffer_template=buffer_basic_template)
args.update(buffer_args(buffers[0]))
elif len(buffers) > 1:
args.update(
buffer_template=buffer_fallback_template,
buffer_list=", ".join(buffer_struct_template.format(**buffer_args(i)) for i in buffers)
)
return format_entry_template.format(**args).format(**args)
......
......@@ -480,10 +480,12 @@ void Format::initialize(VkPhysicalDevice physicalDevice, const angle::Format &an
case angle::FormatID::D24_UNORM_S8_UINT:
internalFormat = GL_DEPTH24_STENCIL8;
initTextureFallback(physicalDevice, angle::FormatID::D24_UNORM_S8_UINT,
VK_FORMAT_D24_UNORM_S8_UINT, nullptr,
angle::FormatID::D32_FLOAT_S8X24_UINT, VK_FORMAT_D32_SFLOAT_S8_UINT,
nullptr);
{
static constexpr TextureFormatInitInfo kInfo[] = {
{angle::FormatID::D24_UNORM_S8_UINT, VK_FORMAT_D24_UNORM_S8_UINT, nullptr},
{angle::FormatID::D32_FLOAT_S8X24_UINT, VK_FORMAT_D32_SFLOAT_S8_UINT, nullptr}};
initTextureFallback(physicalDevice, kInfo, ArraySize(kInfo));
}
bufferFormatID = angle::FormatID::D24_UNORM_S8_UINT;
vkBufferFormat = VK_FORMAT_D24_UNORM_S8_UINT;
vertexLoadFunction = nullptr;
......@@ -492,10 +494,12 @@ void Format::initialize(VkPhysicalDevice physicalDevice, const angle::Format &an
case angle::FormatID::D24_UNORM_X8_UINT:
internalFormat = GL_DEPTH_COMPONENT24;
initTextureFallback(physicalDevice, angle::FormatID::D24_UNORM_S8_UINT,
VK_FORMAT_D24_UNORM_S8_UINT, nullptr,
angle::FormatID::D32_FLOAT_S8X24_UINT, VK_FORMAT_D32_SFLOAT_S8_UINT,
nullptr);
{
static constexpr TextureFormatInitInfo kInfo[] = {
{angle::FormatID::D24_UNORM_S8_UINT, VK_FORMAT_D24_UNORM_S8_UINT, nullptr},
{angle::FormatID::D32_FLOAT_S8X24_UINT, VK_FORMAT_D32_SFLOAT_S8_UINT, nullptr}};
initTextureFallback(physicalDevice, kInfo, ArraySize(kInfo));
}
bufferFormatID = angle::FormatID::NONE;
vkBufferFormat = VK_FORMAT_UNDEFINED;
vertexLoadFunction = nullptr;
......@@ -515,9 +519,12 @@ void Format::initialize(VkPhysicalDevice physicalDevice, const angle::Format &an
case angle::FormatID::D32_FLOAT_S8X24_UINT:
internalFormat = GL_DEPTH32F_STENCIL8;
initTextureFallback(
physicalDevice, angle::FormatID::D32_FLOAT_S8X24_UINT, VK_FORMAT_D32_SFLOAT_S8_UINT,
nullptr, angle::FormatID::D24_UNORM_S8_UINT, VK_FORMAT_D24_UNORM_S8_UINT, nullptr);
{
static constexpr TextureFormatInitInfo kInfo[] = {
{angle::FormatID::D32_FLOAT_S8X24_UINT, VK_FORMAT_D32_SFLOAT_S8_UINT, nullptr},
{angle::FormatID::D24_UNORM_S8_UINT, VK_FORMAT_D24_UNORM_S8_UINT, nullptr}};
initTextureFallback(physicalDevice, kInfo, ArraySize(kInfo));
}
bufferFormatID = angle::FormatID::D32_FLOAT_S8X24_UINT;
vkBufferFormat = VK_FORMAT_D32_SFLOAT_S8_UINT;
vertexLoadFunction = CopyNativeVertexData<GLfloat, 3, 3, 0>;
......@@ -737,10 +744,14 @@ void Format::initialize(VkPhysicalDevice physicalDevice, const angle::Format &an
textureFormatID = angle::FormatID::R16G16B16A16_SNORM;
vkTextureFormat = VK_FORMAT_R16G16B16A16_SNORM;
textureInitializerFunction = nullptr;
initBufferFallback(
physicalDevice, angle::FormatID::R16G16B16A16_SNORM, VK_FORMAT_R16G16B16A16_SNORM,
CopyNativeVertexData<GLshort, 4, 4, 0>, false, angle::FormatID::R32G32B32A32_FLOAT,
VK_FORMAT_R32G32B32A32_SFLOAT, CopyTo32FVertexData<GLshort, 4, 4, true>);
{
static constexpr BufferFormatInitInfo kInfo[] = {
{angle::FormatID::R16G16B16A16_SNORM, VK_FORMAT_R16G16B16A16_SNORM,
CopyNativeVertexData<GLshort, 4, 4, 0>, false},
{angle::FormatID::R32G32B32A32_FLOAT, VK_FORMAT_R32G32B32A32_SFLOAT,
CopyTo32FVertexData<GLshort, 4, 4, true>, true}};
initBufferFallback(physicalDevice, kInfo, ArraySize(kInfo));
}
break;
case angle::FormatID::R16G16B16A16_SSCALED:
......@@ -748,11 +759,14 @@ void Format::initialize(VkPhysicalDevice physicalDevice, const angle::Format &an
textureFormatID = angle::FormatID::R16G16B16A16_SSCALED;
vkTextureFormat = VK_FORMAT_R16G16B16A16_SSCALED;
textureInitializerFunction = nullptr;
initBufferFallback(physicalDevice, angle::FormatID::R16G16B16A16_SSCALED,
VK_FORMAT_R16G16B16A16_SSCALED,
CopyNativeVertexData<GLshort, 4, 4, 0>, false,
angle::FormatID::R32G32B32A32_FLOAT, VK_FORMAT_R32G32B32A32_SFLOAT,
CopyTo32FVertexData<GLshort, 4, 4, false>);
{
static constexpr BufferFormatInitInfo kInfo[] = {
{angle::FormatID::R16G16B16A16_SSCALED, VK_FORMAT_R16G16B16A16_SSCALED,
CopyNativeVertexData<GLshort, 4, 4, 0>, false},
{angle::FormatID::R32G32B32A32_FLOAT, VK_FORMAT_R32G32B32A32_SFLOAT,
CopyTo32FVertexData<GLshort, 4, 4, false>, true}};
initBufferFallback(physicalDevice, kInfo, ArraySize(kInfo));
}
break;
case angle::FormatID::R16G16B16A16_UINT:
......@@ -771,10 +785,14 @@ void Format::initialize(VkPhysicalDevice physicalDevice, const angle::Format &an
textureFormatID = angle::FormatID::R16G16B16A16_UNORM;
vkTextureFormat = VK_FORMAT_R16G16B16A16_UNORM;
textureInitializerFunction = nullptr;
initBufferFallback(
physicalDevice, angle::FormatID::R16G16B16A16_UNORM, VK_FORMAT_R16G16B16A16_UNORM,
CopyNativeVertexData<GLushort, 4, 4, 0>, false, angle::FormatID::R32G32B32A32_FLOAT,
VK_FORMAT_R32G32B32A32_SFLOAT, CopyTo32FVertexData<GLushort, 4, 4, true>);
{
static constexpr BufferFormatInitInfo kInfo[] = {
{angle::FormatID::R16G16B16A16_UNORM, VK_FORMAT_R16G16B16A16_UNORM,
CopyNativeVertexData<GLushort, 4, 4, 0>, false},
{angle::FormatID::R32G32B32A32_FLOAT, VK_FORMAT_R32G32B32A32_SFLOAT,
CopyTo32FVertexData<GLushort, 4, 4, true>, true}};
initBufferFallback(physicalDevice, kInfo, ArraySize(kInfo));
}
break;
case angle::FormatID::R16G16B16A16_USCALED:
......@@ -782,11 +800,14 @@ void Format::initialize(VkPhysicalDevice physicalDevice, const angle::Format &an
textureFormatID = angle::FormatID::R16G16B16A16_USCALED;
vkTextureFormat = VK_FORMAT_R16G16B16A16_USCALED;
textureInitializerFunction = nullptr;
initBufferFallback(physicalDevice, angle::FormatID::R16G16B16A16_USCALED,
VK_FORMAT_R16G16B16A16_USCALED,
CopyNativeVertexData<GLushort, 4, 4, 0>, false,
angle::FormatID::R32G32B32A32_FLOAT, VK_FORMAT_R32G32B32A32_SFLOAT,
CopyTo32FVertexData<GLushort, 4, 4, false>);
{
static constexpr BufferFormatInitInfo kInfo[] = {
{angle::FormatID::R16G16B16A16_USCALED, VK_FORMAT_R16G16B16A16_USCALED,
CopyNativeVertexData<GLushort, 4, 4, 0>, false},
{angle::FormatID::R32G32B32A32_FLOAT, VK_FORMAT_R32G32B32A32_SFLOAT,
CopyTo32FVertexData<GLushort, 4, 4, false>, true}};
initBufferFallback(physicalDevice, kInfo, ArraySize(kInfo));
}
break;
case angle::FormatID::R16G16B16_FLOAT:
......@@ -816,10 +837,14 @@ void Format::initialize(VkPhysicalDevice physicalDevice, const angle::Format &an
textureFormatID = angle::FormatID::R16G16B16_SNORM;
vkTextureFormat = VK_FORMAT_R16G16B16_SNORM;
textureInitializerFunction = nullptr;
initBufferFallback(physicalDevice, angle::FormatID::R16G16B16_SNORM,
VK_FORMAT_R16G16B16_SNORM, CopyNativeVertexData<GLshort, 3, 3, 0>,
false, angle::FormatID::R32G32B32_FLOAT, VK_FORMAT_R32G32B32_SFLOAT,
CopyTo32FVertexData<GLshort, 3, 3, true>);
{
static constexpr BufferFormatInitInfo kInfo[] = {
{angle::FormatID::R16G16B16_SNORM, VK_FORMAT_R16G16B16_SNORM,
CopyNativeVertexData<GLshort, 3, 3, 0>, false},
{angle::FormatID::R32G32B32_FLOAT, VK_FORMAT_R32G32B32_SFLOAT,
CopyTo32FVertexData<GLshort, 3, 3, true>, true}};
initBufferFallback(physicalDevice, kInfo, ArraySize(kInfo));
}
break;
case angle::FormatID::R16G16B16_SSCALED:
......@@ -827,10 +852,14 @@ void Format::initialize(VkPhysicalDevice physicalDevice, const angle::Format &an
textureFormatID = angle::FormatID::R16G16B16_SSCALED;
vkTextureFormat = VK_FORMAT_R16G16B16_SSCALED;
textureInitializerFunction = nullptr;
initBufferFallback(physicalDevice, angle::FormatID::R16G16B16_SSCALED,
VK_FORMAT_R16G16B16_SSCALED, CopyNativeVertexData<GLshort, 3, 3, 0>,
false, angle::FormatID::R32G32B32_FLOAT, VK_FORMAT_R32G32B32_SFLOAT,
CopyTo32FVertexData<GLshort, 3, 3, false>);
{
static constexpr BufferFormatInitInfo kInfo[] = {
{angle::FormatID::R16G16B16_SSCALED, VK_FORMAT_R16G16B16_SSCALED,
CopyNativeVertexData<GLshort, 3, 3, 0>, false},
{angle::FormatID::R32G32B32_FLOAT, VK_FORMAT_R32G32B32_SFLOAT,
CopyTo32FVertexData<GLshort, 3, 3, false>, true}};
initBufferFallback(physicalDevice, kInfo, ArraySize(kInfo));
}
break;
case angle::FormatID::R16G16B16_UINT:
......@@ -849,10 +878,14 @@ void Format::initialize(VkPhysicalDevice physicalDevice, const angle::Format &an
textureFormatID = angle::FormatID::R16G16B16_UNORM;
vkTextureFormat = VK_FORMAT_R16G16B16_UNORM;
textureInitializerFunction = nullptr;
initBufferFallback(physicalDevice, angle::FormatID::R16G16B16_UNORM,
VK_FORMAT_R16G16B16_UNORM, CopyNativeVertexData<GLushort, 3, 3, 0>,
false, angle::FormatID::R32G32B32_FLOAT, VK_FORMAT_R32G32B32_SFLOAT,
CopyTo32FVertexData<GLushort, 3, 3, true>);
{
static constexpr BufferFormatInitInfo kInfo[] = {
{angle::FormatID::R16G16B16_UNORM, VK_FORMAT_R16G16B16_UNORM,
CopyNativeVertexData<GLushort, 3, 3, 0>, false},
{angle::FormatID::R32G32B32_FLOAT, VK_FORMAT_R32G32B32_SFLOAT,
CopyTo32FVertexData<GLushort, 3, 3, true>, true}};
initBufferFallback(physicalDevice, kInfo, ArraySize(kInfo));
}
break;
case angle::FormatID::R16G16B16_USCALED:
......@@ -860,10 +893,14 @@ void Format::initialize(VkPhysicalDevice physicalDevice, const angle::Format &an
textureFormatID = angle::FormatID::R16G16B16_USCALED;
vkTextureFormat = VK_FORMAT_R16G16B16_USCALED;
textureInitializerFunction = nullptr;
initBufferFallback(physicalDevice, angle::FormatID::R16G16B16_USCALED,
VK_FORMAT_R16G16B16_USCALED, CopyNativeVertexData<GLushort, 3, 3, 0>,
false, angle::FormatID::R32G32B32_FLOAT, VK_FORMAT_R32G32B32_SFLOAT,
CopyTo32FVertexData<GLushort, 3, 3, false>);
{
static constexpr BufferFormatInitInfo kInfo[] = {
{angle::FormatID::R16G16B16_USCALED, VK_FORMAT_R16G16B16_USCALED,
CopyNativeVertexData<GLushort, 3, 3, 0>, false},
{angle::FormatID::R32G32B32_FLOAT, VK_FORMAT_R32G32B32_SFLOAT,
CopyTo32FVertexData<GLushort, 3, 3, false>, true}};
initBufferFallback(physicalDevice, kInfo, ArraySize(kInfo));
}
break;
case angle::FormatID::R16G16_FLOAT:
......@@ -893,10 +930,14 @@ void Format::initialize(VkPhysicalDevice physicalDevice, const angle::Format &an
textureFormatID = angle::FormatID::R16G16_SNORM;
vkTextureFormat = VK_FORMAT_R16G16_SNORM;
textureInitializerFunction = nullptr;
initBufferFallback(physicalDevice, angle::FormatID::R16G16_SNORM,
VK_FORMAT_R16G16_SNORM, CopyNativeVertexData<GLshort, 2, 2, 0>,
false, angle::FormatID::R32G32_FLOAT, VK_FORMAT_R32G32_SFLOAT,
CopyTo32FVertexData<GLshort, 2, 2, true>);
{
static constexpr BufferFormatInitInfo kInfo[] = {
{angle::FormatID::R16G16_SNORM, VK_FORMAT_R16G16_SNORM,
CopyNativeVertexData<GLshort, 2, 2, 0>, false},
{angle::FormatID::R32G32_FLOAT, VK_FORMAT_R32G32_SFLOAT,
CopyTo32FVertexData<GLshort, 2, 2, true>, true}};
initBufferFallback(physicalDevice, kInfo, ArraySize(kInfo));
}
break;
case angle::FormatID::R16G16_SSCALED:
......@@ -904,10 +945,14 @@ void Format::initialize(VkPhysicalDevice physicalDevice, const angle::Format &an
textureFormatID = angle::FormatID::R16G16_SSCALED;
vkTextureFormat = VK_FORMAT_R16G16_SSCALED;
textureInitializerFunction = nullptr;
initBufferFallback(physicalDevice, angle::FormatID::R16G16_SSCALED,
VK_FORMAT_R16G16_SSCALED, CopyNativeVertexData<GLshort, 2, 2, 0>,
false, angle::FormatID::R32G32_FLOAT, VK_FORMAT_R32G32_SFLOAT,
CopyTo32FVertexData<GLshort, 2, 2, false>);
{
static constexpr BufferFormatInitInfo kInfo[] = {
{angle::FormatID::R16G16_SSCALED, VK_FORMAT_R16G16_SSCALED,
CopyNativeVertexData<GLshort, 2, 2, 0>, false},
{angle::FormatID::R32G32_FLOAT, VK_FORMAT_R32G32_SFLOAT,
CopyTo32FVertexData<GLshort, 2, 2, false>, true}};
initBufferFallback(physicalDevice, kInfo, ArraySize(kInfo));
}
break;
case angle::FormatID::R16G16_UINT:
......@@ -926,10 +971,14 @@ void Format::initialize(VkPhysicalDevice physicalDevice, const angle::Format &an
textureFormatID = angle::FormatID::R16G16_UNORM;
vkTextureFormat = VK_FORMAT_R16G16_UNORM;
textureInitializerFunction = nullptr;
initBufferFallback(physicalDevice, angle::FormatID::R16G16_UNORM,
VK_FORMAT_R16G16_UNORM, CopyNativeVertexData<GLushort, 2, 2, 0>,
false, angle::FormatID::R32G32_FLOAT, VK_FORMAT_R32G32_SFLOAT,
CopyTo32FVertexData<GLushort, 2, 2, true>);
{
static constexpr BufferFormatInitInfo kInfo[] = {
{angle::FormatID::R16G16_UNORM, VK_FORMAT_R16G16_UNORM,
CopyNativeVertexData<GLushort, 2, 2, 0>, false},
{angle::FormatID::R32G32_FLOAT, VK_FORMAT_R32G32_SFLOAT,
CopyTo32FVertexData<GLushort, 2, 2, true>, true}};
initBufferFallback(physicalDevice, kInfo, ArraySize(kInfo));
}
break;
case angle::FormatID::R16G16_USCALED:
......@@ -937,10 +986,14 @@ void Format::initialize(VkPhysicalDevice physicalDevice, const angle::Format &an
textureFormatID = angle::FormatID::R16G16_USCALED;
vkTextureFormat = VK_FORMAT_R16G16_USCALED;
textureInitializerFunction = nullptr;
initBufferFallback(physicalDevice, angle::FormatID::R16G16_USCALED,
VK_FORMAT_R16G16_USCALED, CopyNativeVertexData<GLushort, 2, 2, 0>,
false, angle::FormatID::R32G32_FLOAT, VK_FORMAT_R32G32_SFLOAT,
CopyTo32FVertexData<GLushort, 2, 2, false>);
{
static constexpr BufferFormatInitInfo kInfo[] = {
{angle::FormatID::R16G16_USCALED, VK_FORMAT_R16G16_USCALED,
CopyNativeVertexData<GLushort, 2, 2, 0>, false},
{angle::FormatID::R32G32_FLOAT, VK_FORMAT_R32G32_SFLOAT,
CopyTo32FVertexData<GLushort, 2, 2, false>, true}};
initBufferFallback(physicalDevice, kInfo, ArraySize(kInfo));
}
break;
case angle::FormatID::R16_FLOAT:
......@@ -970,10 +1023,14 @@ void Format::initialize(VkPhysicalDevice physicalDevice, const angle::Format &an
textureFormatID = angle::FormatID::R16_SNORM;
vkTextureFormat = VK_FORMAT_R16_SNORM;
textureInitializerFunction = nullptr;
initBufferFallback(physicalDevice, angle::FormatID::R16_SNORM, VK_FORMAT_R16_SNORM,
CopyNativeVertexData<GLshort, 1, 1, 0>, false,
angle::FormatID::R32_FLOAT, VK_FORMAT_R32_SFLOAT,
CopyTo32FVertexData<GLshort, 1, 1, true>);
{
static constexpr BufferFormatInitInfo kInfo[] = {
{angle::FormatID::R16_SNORM, VK_FORMAT_R16_SNORM,
CopyNativeVertexData<GLshort, 1, 1, 0>, false},
{angle::FormatID::R32_FLOAT, VK_FORMAT_R32_SFLOAT,
CopyTo32FVertexData<GLshort, 1, 1, true>, true}};
initBufferFallback(physicalDevice, kInfo, ArraySize(kInfo));
}
break;
case angle::FormatID::R16_SSCALED:
......@@ -981,10 +1038,14 @@ void Format::initialize(VkPhysicalDevice physicalDevice, const angle::Format &an
textureFormatID = angle::FormatID::R16_SSCALED;
vkTextureFormat = VK_FORMAT_R16_SSCALED;
textureInitializerFunction = nullptr;
initBufferFallback(physicalDevice, angle::FormatID::R16_SSCALED, VK_FORMAT_R16_SSCALED,
CopyNativeVertexData<GLshort, 1, 1, 0>, false,
angle::FormatID::R32_FLOAT, VK_FORMAT_R32_SFLOAT,
CopyTo32FVertexData<GLshort, 1, 1, false>);
{
static constexpr BufferFormatInitInfo kInfo[] = {
{angle::FormatID::R16_SSCALED, VK_FORMAT_R16_SSCALED,
CopyNativeVertexData<GLshort, 1, 1, 0>, false},
{angle::FormatID::R32_FLOAT, VK_FORMAT_R32_SFLOAT,
CopyTo32FVertexData<GLshort, 1, 1, false>, true}};
initBufferFallback(physicalDevice, kInfo, ArraySize(kInfo));
}
break;
case angle::FormatID::R16_UINT:
......@@ -1003,10 +1064,14 @@ void Format::initialize(VkPhysicalDevice physicalDevice, const angle::Format &an
textureFormatID = angle::FormatID::R16_UNORM;
vkTextureFormat = VK_FORMAT_R16_UNORM;
textureInitializerFunction = nullptr;
initBufferFallback(physicalDevice, angle::FormatID::R16_UNORM, VK_FORMAT_R16_UNORM,
CopyNativeVertexData<GLushort, 1, 1, 0>, false,
angle::FormatID::R32_FLOAT, VK_FORMAT_R32_SFLOAT,
CopyTo32FVertexData<GLushort, 1, 1, true>);
{
static constexpr BufferFormatInitInfo kInfo[] = {
{angle::FormatID::R16_UNORM, VK_FORMAT_R16_UNORM,
CopyNativeVertexData<GLushort, 1, 1, 0>, false},
{angle::FormatID::R32_FLOAT, VK_FORMAT_R32_SFLOAT,
CopyTo32FVertexData<GLushort, 1, 1, true>, true}};
initBufferFallback(physicalDevice, kInfo, ArraySize(kInfo));
}
break;
case angle::FormatID::R16_USCALED:
......@@ -1014,10 +1079,14 @@ void Format::initialize(VkPhysicalDevice physicalDevice, const angle::Format &an
textureFormatID = angle::FormatID::R16_USCALED;
vkTextureFormat = VK_FORMAT_R16_USCALED;
textureInitializerFunction = nullptr;
initBufferFallback(physicalDevice, angle::FormatID::R16_USCALED, VK_FORMAT_R16_USCALED,
CopyNativeVertexData<GLushort, 1, 1, 0>, false,
angle::FormatID::R32_FLOAT, VK_FORMAT_R32_SFLOAT,
CopyTo32FVertexData<GLushort, 1, 1, false>);
{
static constexpr BufferFormatInitInfo kInfo[] = {
{angle::FormatID::R16_USCALED, VK_FORMAT_R16_USCALED,
CopyNativeVertexData<GLushort, 1, 1, 0>, false},
{angle::FormatID::R32_FLOAT, VK_FORMAT_R32_SFLOAT,
CopyTo32FVertexData<GLushort, 1, 1, false>, true}};
initBufferFallback(physicalDevice, kInfo, ArraySize(kInfo));
}
break;
case angle::FormatID::R32G32B32A32_FIXED:
......@@ -1301,10 +1370,14 @@ void Format::initialize(VkPhysicalDevice physicalDevice, const angle::Format &an
textureFormatID = angle::FormatID::R8G8B8A8_SNORM;
vkTextureFormat = VK_FORMAT_R8G8B8A8_SNORM;
textureInitializerFunction = nullptr;
initBufferFallback(
physicalDevice, angle::FormatID::R8G8B8A8_SNORM, VK_FORMAT_R8G8B8A8_SNORM,
CopyNativeVertexData<GLbyte, 4, 4, 0>, false, angle::FormatID::R32G32B32A32_FLOAT,
VK_FORMAT_R32G32B32A32_SFLOAT, CopyTo32FVertexData<GLbyte, 4, 4, true>);
{
static constexpr BufferFormatInitInfo kInfo[] = {
{angle::FormatID::R8G8B8A8_SNORM, VK_FORMAT_R8G8B8A8_SNORM,
CopyNativeVertexData<GLbyte, 4, 4, 0>, false},
{angle::FormatID::R32G32B32A32_FLOAT, VK_FORMAT_R32G32B32A32_SFLOAT,
CopyTo32FVertexData<GLbyte, 4, 4, true>, true}};
initBufferFallback(physicalDevice, kInfo, ArraySize(kInfo));
}
break;
case angle::FormatID::R8G8B8A8_SSCALED:
......@@ -1312,10 +1385,14 @@ void Format::initialize(VkPhysicalDevice physicalDevice, const angle::Format &an
textureFormatID = angle::FormatID::R8G8B8A8_SSCALED;
vkTextureFormat = VK_FORMAT_R8G8B8A8_SSCALED;
textureInitializerFunction = nullptr;
initBufferFallback(
physicalDevice, angle::FormatID::R8G8B8A8_SSCALED, VK_FORMAT_R8G8B8A8_SSCALED,
CopyNativeVertexData<GLbyte, 4, 4, 0>, false, angle::FormatID::R32G32B32A32_FLOAT,
VK_FORMAT_R32G32B32A32_SFLOAT, CopyTo32FVertexData<GLbyte, 4, 4, false>);
{
static constexpr BufferFormatInitInfo kInfo[] = {
{angle::FormatID::R8G8B8A8_SSCALED, VK_FORMAT_R8G8B8A8_SSCALED,
CopyNativeVertexData<GLbyte, 4, 4, 0>, false},
{angle::FormatID::R32G32B32A32_FLOAT, VK_FORMAT_R32G32B32A32_SFLOAT,
CopyTo32FVertexData<GLbyte, 4, 4, false>, true}};
initBufferFallback(physicalDevice, kInfo, ArraySize(kInfo));
}
break;
case angle::FormatID::R8G8B8A8_TYPELESS:
......@@ -1342,10 +1419,14 @@ void Format::initialize(VkPhysicalDevice physicalDevice, const angle::Format &an
textureFormatID = angle::FormatID::R8G8B8A8_UNORM;
vkTextureFormat = VK_FORMAT_R8G8B8A8_UNORM;
textureInitializerFunction = nullptr;
initBufferFallback(
physicalDevice, angle::FormatID::R8G8B8A8_UNORM, VK_FORMAT_R8G8B8A8_UNORM,
CopyNativeVertexData<GLubyte, 4, 4, 0>, false, angle::FormatID::R32G32B32A32_FLOAT,
VK_FORMAT_R32G32B32A32_SFLOAT, CopyTo32FVertexData<GLubyte, 4, 4, true>);
{
static constexpr BufferFormatInitInfo kInfo[] = {
{angle::FormatID::R8G8B8A8_UNORM, VK_FORMAT_R8G8B8A8_UNORM,
CopyNativeVertexData<GLubyte, 4, 4, 0>, false},
{angle::FormatID::R32G32B32A32_FLOAT, VK_FORMAT_R32G32B32A32_SFLOAT,
CopyTo32FVertexData<GLubyte, 4, 4, true>, true}};
initBufferFallback(physicalDevice, kInfo, ArraySize(kInfo));
}
break;
case angle::FormatID::R8G8B8A8_UNORM_SRGB:
......@@ -1357,10 +1438,14 @@ void Format::initialize(VkPhysicalDevice physicalDevice, const angle::Format &an
textureFormatID = angle::FormatID::R8G8B8A8_USCALED;
vkTextureFormat = VK_FORMAT_R8G8B8A8_USCALED;
textureInitializerFunction = nullptr;
initBufferFallback(
physicalDevice, angle::FormatID::R8G8B8A8_USCALED, VK_FORMAT_R8G8B8A8_USCALED,
CopyNativeVertexData<GLubyte, 4, 4, 0>, false, angle::FormatID::R32G32B32A32_FLOAT,
VK_FORMAT_R32G32B32A32_SFLOAT, CopyTo32FVertexData<GLubyte, 4, 4, false>);
{
static constexpr BufferFormatInitInfo kInfo[] = {
{angle::FormatID::R8G8B8A8_USCALED, VK_FORMAT_R8G8B8A8_USCALED,
CopyNativeVertexData<GLubyte, 4, 4, 0>, false},
{angle::FormatID::R32G32B32A32_FLOAT, VK_FORMAT_R32G32B32A32_SFLOAT,
CopyTo32FVertexData<GLubyte, 4, 4, false>, true}};
initBufferFallback(physicalDevice, kInfo, ArraySize(kInfo));
}
break;
case angle::FormatID::R8G8B8_SINT:
......@@ -1379,10 +1464,14 @@ void Format::initialize(VkPhysicalDevice physicalDevice, const angle::Format &an
textureFormatID = angle::FormatID::R8G8B8_SNORM;
vkTextureFormat = VK_FORMAT_R8G8B8_SNORM;
textureInitializerFunction = nullptr;
initBufferFallback(physicalDevice, angle::FormatID::R8G8B8_SNORM,
VK_FORMAT_R8G8B8_SNORM, CopyNativeVertexData<GLbyte, 3, 3, 0>, false,
angle::FormatID::R32G32B32_FLOAT, VK_FORMAT_R32G32B32_SFLOAT,
CopyTo32FVertexData<GLbyte, 3, 3, true>);
{
static constexpr BufferFormatInitInfo kInfo[] = {
{angle::FormatID::R8G8B8_SNORM, VK_FORMAT_R8G8B8_SNORM,
CopyNativeVertexData<GLbyte, 3, 3, 0>, false},
{angle::FormatID::R32G32B32_FLOAT, VK_FORMAT_R32G32B32_SFLOAT,
CopyTo32FVertexData<GLbyte, 3, 3, true>, true}};
initBufferFallback(physicalDevice, kInfo, ArraySize(kInfo));
}
break;
case angle::FormatID::R8G8B8_SSCALED:
......@@ -1390,10 +1479,14 @@ void Format::initialize(VkPhysicalDevice physicalDevice, const angle::Format &an
textureFormatID = angle::FormatID::R8G8B8_SSCALED;
vkTextureFormat = VK_FORMAT_R8G8B8_SSCALED;
textureInitializerFunction = nullptr;
initBufferFallback(physicalDevice, angle::FormatID::R8G8B8_SSCALED,
VK_FORMAT_R8G8B8_SSCALED, CopyNativeVertexData<GLbyte, 3, 3, 0>,
false, angle::FormatID::R32G32B32_FLOAT, VK_FORMAT_R32G32B32_SFLOAT,
CopyTo32FVertexData<GLbyte, 3, 3, false>);
{
static constexpr BufferFormatInitInfo kInfo[] = {
{angle::FormatID::R8G8B8_SSCALED, VK_FORMAT_R8G8B8_SSCALED,
CopyNativeVertexData<GLbyte, 3, 3, 0>, false},
{angle::FormatID::R32G32B32_FLOAT, VK_FORMAT_R32G32B32_SFLOAT,
CopyTo32FVertexData<GLbyte, 3, 3, false>, true}};
initBufferFallback(physicalDevice, kInfo, ArraySize(kInfo));
}
break;
case angle::FormatID::R8G8B8_UINT:
......@@ -1412,10 +1505,14 @@ void Format::initialize(VkPhysicalDevice physicalDevice, const angle::Format &an
textureFormatID = angle::FormatID::R8G8B8A8_UNORM;
vkTextureFormat = VK_FORMAT_R8G8B8A8_UNORM;
textureInitializerFunction = Initialize4ComponentData<GLubyte, 0x00, 0x00, 0x00, 0xFF>;
initBufferFallback(physicalDevice, angle::FormatID::R8G8B8_UNORM,
VK_FORMAT_R8G8B8_UNORM, CopyNativeVertexData<GLubyte, 3, 3, 0>,
false, angle::FormatID::R32G32B32_FLOAT, VK_FORMAT_R32G32B32_SFLOAT,
CopyTo32FVertexData<GLubyte, 3, 3, true>);
{
static constexpr BufferFormatInitInfo kInfo[] = {
{angle::FormatID::R8G8B8_UNORM, VK_FORMAT_R8G8B8_UNORM,
CopyNativeVertexData<GLubyte, 3, 3, 0>, false},
{angle::FormatID::R32G32B32_FLOAT, VK_FORMAT_R32G32B32_SFLOAT,
CopyTo32FVertexData<GLubyte, 3, 3, true>, true}};
initBufferFallback(physicalDevice, kInfo, ArraySize(kInfo));
}
break;
case angle::FormatID::R8G8B8_UNORM_SRGB:
......@@ -1427,10 +1524,14 @@ void Format::initialize(VkPhysicalDevice physicalDevice, const angle::Format &an
textureFormatID = angle::FormatID::R8G8B8_USCALED;
vkTextureFormat = VK_FORMAT_R8G8B8_USCALED;
textureInitializerFunction = nullptr;
initBufferFallback(physicalDevice, angle::FormatID::R8G8B8_USCALED,
VK_FORMAT_R8G8B8_USCALED, CopyNativeVertexData<GLubyte, 3, 3, 0>,
false, angle::FormatID::R32G32B32_FLOAT, VK_FORMAT_R32G32B32_SFLOAT,
CopyTo32FVertexData<GLubyte, 3, 3, false>);
{
static constexpr BufferFormatInitInfo kInfo[] = {
{angle::FormatID::R8G8B8_USCALED, VK_FORMAT_R8G8B8_USCALED,
CopyNativeVertexData<GLubyte, 3, 3, 0>, false},
{angle::FormatID::R32G32B32_FLOAT, VK_FORMAT_R32G32B32_SFLOAT,
CopyTo32FVertexData<GLubyte, 3, 3, false>, true}};
initBufferFallback(physicalDevice, kInfo, ArraySize(kInfo));
}
break;
case angle::FormatID::R8G8_SINT:
......@@ -1449,10 +1550,14 @@ void Format::initialize(VkPhysicalDevice physicalDevice, const angle::Format &an
textureFormatID = angle::FormatID::R8G8_SNORM;
vkTextureFormat = VK_FORMAT_R8G8_SNORM;
textureInitializerFunction = nullptr;
initBufferFallback(physicalDevice, angle::FormatID::R8G8_SNORM, VK_FORMAT_R8G8_SNORM,
CopyNativeVertexData<GLbyte, 2, 2, 0>, false,
angle::FormatID::R32G32_FLOAT, VK_FORMAT_R32G32_SFLOAT,
CopyTo32FVertexData<GLbyte, 2, 2, true>);
{
static constexpr BufferFormatInitInfo kInfo[] = {
{angle::FormatID::R8G8_SNORM, VK_FORMAT_R8G8_SNORM,
CopyNativeVertexData<GLbyte, 2, 2, 0>, false},
{angle::FormatID::R32G32_FLOAT, VK_FORMAT_R32G32_SFLOAT,
CopyTo32FVertexData<GLbyte, 2, 2, true>, true}};
initBufferFallback(physicalDevice, kInfo, ArraySize(kInfo));
}
break;
case angle::FormatID::R8G8_SSCALED:
......@@ -1460,10 +1565,14 @@ void Format::initialize(VkPhysicalDevice physicalDevice, const angle::Format &an
textureFormatID = angle::FormatID::R8G8_SSCALED;
vkTextureFormat = VK_FORMAT_R8G8_SSCALED;
textureInitializerFunction = nullptr;
initBufferFallback(physicalDevice, angle::FormatID::R8G8_SSCALED,
VK_FORMAT_R8G8_SSCALED, CopyNativeVertexData<GLbyte, 2, 2, 0>, false,
angle::FormatID::R32G32_FLOAT, VK_FORMAT_R32G32_SFLOAT,
CopyTo32FVertexData<GLbyte, 2, 2, false>);
{
static constexpr BufferFormatInitInfo kInfo[] = {
{angle::FormatID::R8G8_SSCALED, VK_FORMAT_R8G8_SSCALED,
CopyNativeVertexData<GLbyte, 2, 2, 0>, false},
{angle::FormatID::R32G32_FLOAT, VK_FORMAT_R32G32_SFLOAT,
CopyTo32FVertexData<GLbyte, 2, 2, false>, true}};
initBufferFallback(physicalDevice, kInfo, ArraySize(kInfo));
}
break;
case angle::FormatID::R8G8_UINT:
......@@ -1482,10 +1591,14 @@ void Format::initialize(VkPhysicalDevice physicalDevice, const angle::Format &an
textureFormatID = angle::FormatID::R8G8_UNORM;
vkTextureFormat = VK_FORMAT_R8G8_UNORM;
textureInitializerFunction = nullptr;
initBufferFallback(physicalDevice, angle::FormatID::R8G8_UNORM, VK_FORMAT_R8G8_UNORM,
CopyNativeVertexData<GLubyte, 2, 2, 0>, false,
angle::FormatID::R32G32_FLOAT, VK_FORMAT_R32G32_SFLOAT,
CopyTo32FVertexData<GLubyte, 2, 2, true>);
{
static constexpr BufferFormatInitInfo kInfo[] = {
{angle::FormatID::R8G8_UNORM, VK_FORMAT_R8G8_UNORM,
CopyNativeVertexData<GLubyte, 2, 2, 0>, false},
{angle::FormatID::R32G32_FLOAT, VK_FORMAT_R32G32_SFLOAT,
CopyTo32FVertexData<GLubyte, 2, 2, true>, true}};
initBufferFallback(physicalDevice, kInfo, ArraySize(kInfo));
}
break;
case angle::FormatID::R8G8_USCALED:
......@@ -1493,10 +1606,14 @@ void Format::initialize(VkPhysicalDevice physicalDevice, const angle::Format &an
textureFormatID = angle::FormatID::R8G8_USCALED;
vkTextureFormat = VK_FORMAT_R8G8_USCALED;
textureInitializerFunction = nullptr;
initBufferFallback(physicalDevice, angle::FormatID::R8G8_USCALED,
VK_FORMAT_R8G8_USCALED, CopyNativeVertexData<GLubyte, 2, 2, 0>,
false, angle::FormatID::R32G32_FLOAT, VK_FORMAT_R32G32_SFLOAT,
CopyTo32FVertexData<GLubyte, 2, 2, false>);
{
static constexpr BufferFormatInitInfo kInfo[] = {
{angle::FormatID::R8G8_USCALED, VK_FORMAT_R8G8_USCALED,
CopyNativeVertexData<GLubyte, 2, 2, 0>, false},
{angle::FormatID::R32G32_FLOAT, VK_FORMAT_R32G32_SFLOAT,
CopyTo32FVertexData<GLubyte, 2, 2, false>, true}};
initBufferFallback(physicalDevice, kInfo, ArraySize(kInfo));
}
break;
case angle::FormatID::R8_SINT:
......@@ -1515,10 +1632,14 @@ void Format::initialize(VkPhysicalDevice physicalDevice, const angle::Format &an
textureFormatID = angle::FormatID::R8_SNORM;
vkTextureFormat = VK_FORMAT_R8_SNORM;
textureInitializerFunction = nullptr;
initBufferFallback(physicalDevice, angle::FormatID::R8_SNORM, VK_FORMAT_R8_SNORM,
CopyNativeVertexData<GLbyte, 1, 1, 0>, false,
angle::FormatID::R32_FLOAT, VK_FORMAT_R32_SFLOAT,
CopyTo32FVertexData<GLbyte, 1, 1, true>);
{
static constexpr BufferFormatInitInfo kInfo[] = {
{angle::FormatID::R8_SNORM, VK_FORMAT_R8_SNORM,
CopyNativeVertexData<GLbyte, 1, 1, 0>, false},
{angle::FormatID::R32_FLOAT, VK_FORMAT_R32_SFLOAT,
CopyTo32FVertexData<GLbyte, 1, 1, true>, true}};
initBufferFallback(physicalDevice, kInfo, ArraySize(kInfo));
}
break;
case angle::FormatID::R8_SSCALED:
......@@ -1526,10 +1647,14 @@ void Format::initialize(VkPhysicalDevice physicalDevice, const angle::Format &an
textureFormatID = angle::FormatID::R8_SSCALED;
vkTextureFormat = VK_FORMAT_R8_SSCALED;
textureInitializerFunction = nullptr;
initBufferFallback(physicalDevice, angle::FormatID::R8_SSCALED, VK_FORMAT_R8_SSCALED,
CopyNativeVertexData<GLbyte, 1, 1, 0>, false,
angle::FormatID::R32_FLOAT, VK_FORMAT_R32_SFLOAT,
CopyTo32FVertexData<GLbyte, 1, 1, false>);
{
static constexpr BufferFormatInitInfo kInfo[] = {
{angle::FormatID::R8_SSCALED, VK_FORMAT_R8_SSCALED,
CopyNativeVertexData<GLbyte, 1, 1, 0>, false},
{angle::FormatID::R32_FLOAT, VK_FORMAT_R32_SFLOAT,
CopyTo32FVertexData<GLbyte, 1, 1, false>, true}};
initBufferFallback(physicalDevice, kInfo, ArraySize(kInfo));
}
break;
case angle::FormatID::R8_UINT:
......@@ -1548,10 +1673,14 @@ void Format::initialize(VkPhysicalDevice physicalDevice, const angle::Format &an
textureFormatID = angle::FormatID::R8_UNORM;
vkTextureFormat = VK_FORMAT_R8_UNORM;
textureInitializerFunction = nullptr;
initBufferFallback(physicalDevice, angle::FormatID::R8_UNORM, VK_FORMAT_R8_UNORM,
CopyNativeVertexData<GLubyte, 1, 1, 0>, false,
angle::FormatID::R32_FLOAT, VK_FORMAT_R32_SFLOAT,
CopyTo32FVertexData<GLubyte, 1, 1, true>);
{
static constexpr BufferFormatInitInfo kInfo[] = {
{angle::FormatID::R8_UNORM, VK_FORMAT_R8_UNORM,
CopyNativeVertexData<GLubyte, 1, 1, 0>, false},
{angle::FormatID::R32_FLOAT, VK_FORMAT_R32_SFLOAT,
CopyTo32FVertexData<GLubyte, 1, 1, true>, true}};
initBufferFallback(physicalDevice, kInfo, ArraySize(kInfo));
}
break;
case angle::FormatID::R8_USCALED:
......@@ -1559,10 +1688,14 @@ void Format::initialize(VkPhysicalDevice physicalDevice, const angle::Format &an
textureFormatID = angle::FormatID::R8_USCALED;
vkTextureFormat = VK_FORMAT_R8_USCALED;
textureInitializerFunction = nullptr;
initBufferFallback(physicalDevice, angle::FormatID::R8_USCALED, VK_FORMAT_R8_USCALED,
CopyNativeVertexData<GLubyte, 1, 1, 0>, false,
angle::FormatID::R32_FLOAT, VK_FORMAT_R32_SFLOAT,
CopyTo32FVertexData<GLubyte, 1, 1, false>);
{
static constexpr BufferFormatInitInfo kInfo[] = {
{angle::FormatID::R8_USCALED, VK_FORMAT_R8_USCALED,
CopyNativeVertexData<GLubyte, 1, 1, 0>, false},
{angle::FormatID::R32_FLOAT, VK_FORMAT_R32_SFLOAT,
CopyTo32FVertexData<GLubyte, 1, 1, false>, true}};
initBufferFallback(physicalDevice, kInfo, ArraySize(kInfo));
}
break;
case angle::FormatID::R9G9B9E5_SHAREDEXP:
......
......@@ -63,6 +63,30 @@ bool HasFullBufferFormatSupport(VkPhysicalDevice physicalDevice, VkFormat vkForm
return formatProperties.bufferFeatures & VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT;
}
using SupportTest = bool (*)(VkPhysicalDevice physicalDevice, VkFormat vkFormat);
template <class FormatInitInfo>
int FindSupportedFormat(VkPhysicalDevice physicalDevice,
const FormatInitInfo *info,
int numInfo,
SupportTest hasSupport)
{
ASSERT(numInfo > 1);
const int last = numInfo - 1;
for (int i = 0; i < last; ++i)
{
ASSERT(info[i].format != angle::FormatID::NONE);
if (hasSupport(physicalDevice, info[i].vkFormat))
return i;
}
// List must contain a supported item. We failed on all the others so the last one must be it.
ASSERT(info[last].format != angle::FormatID::NONE);
ASSERT(hasSupport(physicalDevice, info[last].vkFormat));
return last;
}
} // anonymous namespace
namespace vk
......@@ -105,58 +129,24 @@ Format::Format()
}
void Format::initTextureFallback(VkPhysicalDevice physicalDevice,
angle::FormatID format,
VkFormat vkFormat,
InitializeTextureDataFunction initializer,
angle::FormatID fallbackFormat,
VkFormat fallbackVkFormat,
InitializeTextureDataFunction fallbackInitializer)
const TextureFormatInitInfo *info,
int numInfo)
{
ASSERT(format != angle::FormatID::NONE);
ASSERT(fallbackFormat != angle::FormatID::NONE);
if (HasFullTextureFormatSupport(physicalDevice, vkFormat))
{
textureFormatID = format;
vkTextureFormat = vkFormat;
textureInitializerFunction = initializer;
}
else
{
textureFormatID = fallbackFormat;
vkTextureFormat = fallbackVkFormat;
textureInitializerFunction = fallbackInitializer;
ASSERT(HasFullTextureFormatSupport(physicalDevice, vkTextureFormat));
}
int i = FindSupportedFormat(physicalDevice, info, numInfo, HasFullTextureFormatSupport);
textureFormatID = info[i].format;
vkTextureFormat = info[i].vkFormat;
textureInitializerFunction = info[i].initializer;
}
void Format::initBufferFallback(VkPhysicalDevice physicalDevice,
angle::FormatID format,
VkFormat vkFormat,
VertexCopyFunction function,
bool functionConverts,
angle::FormatID fallbackFormat,
VkFormat fallbackVkFormat,
VertexCopyFunction fallbackFunction)
{
ASSERT(format != angle::FormatID::NONE);
ASSERT(fallbackFormat != angle::FormatID::NONE);
if (HasFullBufferFormatSupport(physicalDevice, vkFormat))
{
bufferFormatID = format;
vkBufferFormat = vkFormat;
vertexLoadFunction = function;
vertexLoadRequiresConversion = functionConverts;
}
else
{
bufferFormatID = fallbackFormat;
vkBufferFormat = fallbackVkFormat;
vertexLoadFunction = fallbackFunction;
vertexLoadRequiresConversion = true;
ASSERT(HasFullBufferFormatSupport(physicalDevice, vkBufferFormat));
}
const BufferFormatInitInfo *info,
int numInfo)
{
int i = FindSupportedFormat(physicalDevice, info, numInfo, HasFullBufferFormatSupport);
bufferFormatID = info[i].format;
vkBufferFormat = info[i].vkFormat;
vertexLoadFunction = info[i].vertexLoadFunction;
vertexLoadRequiresConversion = info[i].vertexLoadRequiresConversion;
}
const angle::Format &Format::textureFormat() const
......
......@@ -33,6 +33,21 @@ void GetFormatProperties(VkPhysicalDevice physicalDevice,
VkFormat vkFormat,
VkFormatProperties *propertiesOut);
struct TextureFormatInitInfo final
{
angle::FormatID format;
VkFormat vkFormat;
InitializeTextureDataFunction initializer;
};
struct BufferFormatInitInfo final
{
angle::FormatID format;
VkFormat vkFormat;
VertexCopyFunction vertexLoadFunction;
bool vertexLoadRequiresConversion;
};
struct Format final : private angle::NonCopyable
{
Format();
......@@ -43,21 +58,11 @@ struct Format final : private angle::NonCopyable
void initialize(VkPhysicalDevice physicalDevice, const angle::Format &angleFormat);
void initTextureFallback(VkPhysicalDevice physicalDevice,
angle::FormatID format,
VkFormat vkFormat,
InitializeTextureDataFunction initializer,
angle::FormatID fallbackFormat,
VkFormat fallbackVkFormat,
InitializeTextureDataFunction fallbackInitializer);
const TextureFormatInitInfo *info,
int numInfo);
void initBufferFallback(VkPhysicalDevice physicalDevice,
angle::FormatID format,
VkFormat vkFormat,
VertexCopyFunction function,
bool functionConverts,
angle::FormatID fallbackFormat,
VkFormat fallbackVkFormat,
VertexCopyFunction fallbackFunction);
const BufferFormatInitInfo *info,
int numInfo);
const angle::Format &textureFormat() const;
const angle::Format &bufferFormat() const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment