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