diff --git a/extensions/EGL_ANGLE_iosurface_client_buffer.txt b/extensions/EGL_ANGLE_iosurface_client_buffer.txt index 953177ed5..da9dfb575 100644 --- a/extensions/EGL_ANGLE_iosurface_client_buffer.txt +++ b/extensions/EGL_ANGLE_iosurface_client_buffer.txt @@ -108,12 +108,13 @@ Additions to Chapter 3 of the EGL 1.4 Specification (EGL Functions and Errors) --------------------------------------------------------------------------- Texture Type Texture Internal Format --------------------------------------------------------------------------- - GL_UNSIGNED_BYTE GL_RED - GL_UNSIGNED_SHORT GL_R16UI - GL_UNSIGNED_BYTE GL_RG - GL_UNSIGNED_BYTE GL_RGB - GL_UNSIGNED_BYTE GL_BGRA_EXT - GL_HALF_FLOAT GL_RGBA + GL_UNSIGNED_BYTE GL_RED + GL_UNSIGNED_SHORT GL_R16UI + GL_UNSIGNED_BYTE GL_RG + GL_UNSIGNED_BYTE GL_RGB + GL_UNSIGNED_BYTE GL_BGRA_EXT + GL_UNSIGNED_INT_2_10_10_10_REV GL_RGB10_A2 + GL_HALF_FLOAT GL_RGBA --------------------------------------------------------------------------- Table egl.iosurface.formats - Valid combinations of format, type and internal format for IOSurface-backed pbuffers. @@ -148,3 +149,4 @@ Revision History Version 3, 2019/08/13 - Allow RGB internal formats Version 4, 2019/12/28 - Add usage hint; require TEXTURE_RECTANGLE on macOS and TEXTURE_2D on iOS + Version 5, 2020/06/30 - Allow RGB10_A2 internal formats diff --git a/scripts/code_generation_hashes/ANGLE_format.json b/scripts/code_generation_hashes/ANGLE_format.json index 21832d395..cc2c834b0 100644 --- a/scripts/code_generation_hashes/ANGLE_format.json +++ b/scripts/code_generation_hashes/ANGLE_format.json @@ -1,14 +1,14 @@ { "src/libANGLE/renderer/FormatID_autogen.h": - "bbdb3beae2da4629e3583d6d014ebb2d", + "8d1efd0b5c683c121e58a988ba0751c1", "src/libANGLE/renderer/Format_table_autogen.cpp": - "29000a1abc79c129662637f76e7d2a03", + "42e6d1c1688201c7eefb2dd4a69bd1b7", "src/libANGLE/renderer/angle_format.py": "32ba71942c0fd00e6807104f1bb80a3c", "src/libANGLE/renderer/angle_format_data.json": "e5cc162abe241ea9ba270309c8ec1330", "src/libANGLE/renderer/angle_format_map.json": - "c79d833aea7007c7d0d51cdaa9b265a6", + "aa4a0d3463b76858a75787b9cdec8e98", "src/libANGLE/renderer/gen_angle_format_table.py": "8e349a643e81a028ebb54bde3756f9f7" } \ No newline at end of file diff --git a/scripts/code_generation_hashes/ANGLE_load_functions_table.json b/scripts/code_generation_hashes/ANGLE_load_functions_table.json index 58dbe72be..efc6eb581 100644 --- a/scripts/code_generation_hashes/ANGLE_load_functions_table.json +++ b/scripts/code_generation_hashes/ANGLE_load_functions_table.json @@ -4,7 +4,7 @@ "src/libANGLE/renderer/gen_load_functions_table.py": "9b4ea6bcb4eb4c43f48a097a9ec920f1", "src/libANGLE/renderer/load_functions_data.json": - "82e599f6a6cd9a314406f610f71dc660", + "11413aef6add240ad2dbc4e55543f3ac", "src/libANGLE/renderer/load_functions_table_autogen.cpp": - "7a594fed0385de81c402bcd3ff7f6412" + "e0a3003fcb3ec56559d879ab474bdfeb" } \ No newline at end of file diff --git a/scripts/code_generation_hashes/D3D11_format.json b/scripts/code_generation_hashes/D3D11_format.json index 9451d6c71..b674fd835 100644 --- a/scripts/code_generation_hashes/D3D11_format.json +++ b/scripts/code_generation_hashes/D3D11_format.json @@ -4,9 +4,9 @@ "src/libANGLE/renderer/d3d/d3d11/gen_texture_format_table.py": "bf11e3404d4622059b6e9c4e96abf95e", "src/libANGLE/renderer/d3d/d3d11/texture_format_data.json": - "c80708c18348fd89a3b918e58e74c1f8", + "9bef26093805f5499eceb5a615648aea", "src/libANGLE/renderer/d3d/d3d11/texture_format_map.json": "d45aee3519b8c9a15411617bbb00c77f", "src/libANGLE/renderer/d3d/d3d11/texture_format_table_autogen.cpp": - "ef6da258ffbd0245d6a592f5c0f8b455" + "cdd4a23a40c526ef3480599aea11a210" } \ No newline at end of file diff --git a/scripts/code_generation_hashes/DXGI_format.json b/scripts/code_generation_hashes/DXGI_format.json index 1628f1ebd..3fef81dc7 100644 --- a/scripts/code_generation_hashes/DXGI_format.json +++ b/scripts/code_generation_hashes/DXGI_format.json @@ -2,7 +2,7 @@ "src/libANGLE/renderer/angle_format.py": "32ba71942c0fd00e6807104f1bb80a3c", "src/libANGLE/renderer/angle_format_map.json": - "c79d833aea7007c7d0d51cdaa9b265a6", + "aa4a0d3463b76858a75787b9cdec8e98", "src/libANGLE/renderer/d3d/d3d11/dxgi_format_data.json": "3428e4761ccd05f960adffd6ccbd86c5", "src/libANGLE/renderer/d3d/d3d11/dxgi_format_map_autogen.cpp": diff --git a/scripts/code_generation_hashes/GL_format_map.json b/scripts/code_generation_hashes/GL_format_map.json index 6ecc5fdf5..e0af3af89 100644 --- a/scripts/code_generation_hashes/GL_format_map.json +++ b/scripts/code_generation_hashes/GL_format_map.json @@ -2,9 +2,9 @@ "src/libANGLE/es3_format_type_combinations.json": "3c4288394162b20f5ccdc29d3b4eecbb", "src/libANGLE/format_map_autogen.cpp": - "baae22cedf176b776d0a2331abb4abcc", + "f9ed893aeb8aa9a11febc66a8d4f2564", "src/libANGLE/format_map_data.json": - "742cf47524160757a2cec43116dc153c", + "2e5db33b6d6b142b569123f614f3ddb7", "src/libANGLE/gen_format_map.py": "38320d844e6629e09afc5ccdc484e9aa", "src/libANGLE/renderer/angle_format.py": diff --git a/scripts/code_generation_hashes/Vulkan_format.json b/scripts/code_generation_hashes/Vulkan_format.json index 1d911820f..aa2123e9b 100644 --- a/scripts/code_generation_hashes/Vulkan_format.json +++ b/scripts/code_generation_hashes/Vulkan_format.json @@ -2,11 +2,11 @@ "src/libANGLE/renderer/angle_format.py": "32ba71942c0fd00e6807104f1bb80a3c", "src/libANGLE/renderer/angle_format_map.json": - "c79d833aea7007c7d0d51cdaa9b265a6", + "aa4a0d3463b76858a75787b9cdec8e98", "src/libANGLE/renderer/vulkan/gen_vk_format_table.py": "54a7374f93f17da1386600027acca7a3", "src/libANGLE/renderer/vulkan/vk_format_map.json": - "738c8dc36fbe212669944e88ae918f9c", + "5dc3cfb41778806e379876ce9fa427f3", "src/libANGLE/renderer/vulkan/vk_format_table_autogen.cpp": - "c7e01cbf1eded87f4ed9f3bc8b7a567c" + "7882959fda2dbda451164f2afd2e35be" } \ No newline at end of file diff --git a/src/common/angleutils.h b/src/common/angleutils.h index fb73524c3..85fa75acb 100644 --- a/src/common/angleutils.h +++ b/src/common/angleutils.h @@ -203,6 +203,7 @@ inline bool IsLittleEndian() #define GL_INT_64_ANGLEX 0x6ABE #define GL_UINT_64_ANGLEX 0x6ABF #define GL_BGRA8_SRGB_ANGLEX 0x6AC0 +#define GL_BGR10_A2_ANGLEX 0x6AF9 // These are dummy formats used to fit typeless D3D textures that can be bound to EGL pbuffers into // the format system (for extension EGL_ANGLE_d3d_texture_client_buffer): diff --git a/src/image_util/imageformats.cpp b/src/image_util/imageformats.cpp index 2c7b61837..60a300dfd 100644 --- a/src/image_util/imageformats.cpp +++ b/src/image_util/imageformats.cpp @@ -1750,6 +1750,46 @@ void R10G10B10X2::average(R10G10B10X2 *dst, const R10G10B10X2 *src1, const R10G1 dst->B = gl::average(src1->B, src2->B); } +void B10G10R10A2::readColor(gl::ColorUI *dst, const B10G10R10A2 *src) +{ + dst->red = src->R; + dst->green = src->G; + dst->blue = src->B; + dst->alpha = src->A; +} + +void B10G10R10A2::readColor(gl::ColorF *dst, const B10G10R10A2 *src) +{ + dst->red = gl::normalizedToFloat<10>(src->R); + dst->green = gl::normalizedToFloat<10>(src->G); + dst->blue = gl::normalizedToFloat<10>(src->B); + dst->alpha = gl::normalizedToFloat<2>(src->A); +} + +void B10G10R10A2::writeColor(B10G10R10A2 *dst, const gl::ColorUI *src) +{ + dst->R = static_cast(src->red); + dst->G = static_cast(src->green); + dst->B = static_cast(src->blue); + dst->A = static_cast(src->alpha); +} + +void B10G10R10A2::writeColor(B10G10R10A2 *dst, const gl::ColorF *src) +{ + dst->R = gl::floatToNormalized<10, uint32_t>(src->red); + dst->G = gl::floatToNormalized<10, uint32_t>(src->green); + dst->B = gl::floatToNormalized<10, uint32_t>(src->blue); + dst->A = gl::floatToNormalized<2, uint32_t>(src->alpha); +} + +void B10G10R10A2::average(B10G10R10A2 *dst, const B10G10R10A2 *src1, const B10G10R10A2 *src2) +{ + dst->R = gl::average(src1->R, src2->R); + dst->G = gl::average(src1->G, src2->G); + dst->B = gl::average(src1->B, src2->B); + dst->A = gl::average(src1->A, src2->A); +} + void R9G9B9E5::readColor(gl::ColorF *dst, const R9G9B9E5 *src) { gl::convert999E5toRGBFloats(gl::bitCast(*src), &dst->red, &dst->green, &dst->blue); diff --git a/src/image_util/imageformats.h b/src/image_util/imageformats.h index a114815c2..700540f00 100644 --- a/src/image_util/imageformats.h +++ b/src/image_util/imageformats.h @@ -699,6 +699,21 @@ struct R10G10B10X2 }; static_assert(sizeof(R10G10B10X2) == 4, "R10G10B10X2 struct not 32-bits."); +struct B10G10R10A2 +{ + uint32_t B : 10; + uint32_t G : 10; + uint32_t R : 10; + uint32_t A : 2; + + static void readColor(gl::ColorF *dst, const B10G10R10A2 *src); + static void readColor(gl::ColorUI *dst, const B10G10R10A2 *src); + static void writeColor(B10G10R10A2 *dst, const gl::ColorF *src); + static void writeColor(B10G10R10A2 *dst, const gl::ColorUI *src); + static void average(B10G10R10A2 *dst, const B10G10R10A2 *src1, const B10G10R10A2 *src2); +}; +static_assert(sizeof(B10G10R10A2) == 4, "B10G10R10A2 struct not 32-bits."); + struct R9G9B9E5 { uint32_t R : 9; diff --git a/src/libANGLE/format_map_autogen.cpp b/src/libANGLE/format_map_autogen.cpp index b485143df..96e981977 100644 --- a/src/libANGLE/format_map_autogen.cpp +++ b/src/libANGLE/format_map_autogen.cpp @@ -41,6 +41,8 @@ GLenum GetSizedFormatInternal(GLenum format, GLenum type) { case GL_UNSIGNED_BYTE: return GL_BGRA8_EXT; + case GL_UNSIGNED_INT_2_10_10_10_REV: + return GL_BGR10_A2_ANGLEX; case GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT: return GL_BGR5_A1_ANGLEX; case GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT: diff --git a/src/libANGLE/format_map_data.json b/src/libANGLE/format_map_data.json index a3c898406..0df56c35a 100644 --- a/src/libANGLE/format_map_data.json +++ b/src/libANGLE/format_map_data.json @@ -96,7 +96,8 @@ "GL_UNSIGNED_BYTE": "GL_BGRA8_EXT", "GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT": "GL_BGRA4_ANGLEX", "GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT": "GL_BGR5_A1_ANGLEX", - "GL_UNSIGNED_SHORT_5_6_5": "GL_BGR565_ANGLEX" + "GL_UNSIGNED_SHORT_5_6_5": "GL_BGR565_ANGLEX", + "GL_UNSIGNED_INT_2_10_10_10_REV": "GL_BGR10_A2_ANGLEX" }, "GL_SRGB_EXT": { "GL_UNSIGNED_BYTE": "GL_SRGB8" diff --git a/src/libANGLE/formatutils.cpp b/src/libANGLE/formatutils.cpp index 2b8104f45..8314f8cfb 100644 --- a/src/libANGLE/formatutils.cpp +++ b/src/libANGLE/formatutils.cpp @@ -825,6 +825,7 @@ static InternalFormatInfoMap BuildInternalFormatInfoMap() // Special format which is not really supported, so always false for all supports. AddRGBAFormat(&map, GL_BGRX8_ANGLEX, true, 8, 8, 8, 0, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, NeverSupported, NeverSupported, NeverSupported, NeverSupported, NeverSupported); AddRGBAFormat(&map, GL_BGR565_ANGLEX, true, 5, 6, 5, 1, 0, GL_BGRA_EXT, GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_NORMALIZED, false, NeverSupported, NeverSupported, NeverSupported, NeverSupported, NeverSupported); + AddRGBAFormat(&map, GL_BGR10_A2_ANGLEX, true, 10, 10, 10, 2, 0, GL_BGRA_EXT, GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_NORMALIZED, false, NeverSupported, NeverSupported, NeverSupported, NeverSupported, NeverSupported); // Floating point formats // | Internal format |sized| R | G | B | A |S | Format | Type | Component type | SRGB | Texture supported | Filterable | Texture attachment | Renderbuffer | Blend diff --git a/src/libANGLE/renderer/FormatID_autogen.h b/src/libANGLE/renderer/FormatID_autogen.h index fc693a3f6..c04a96057 100644 --- a/src/libANGLE/renderer/FormatID_autogen.h +++ b/src/libANGLE/renderer/FormatID_autogen.h @@ -76,6 +76,7 @@ enum class FormatID ASTC_8x6_UNORM_BLOCK, ASTC_8x8_SRGB_BLOCK, ASTC_8x8_UNORM_BLOCK, + B10G10R10A2_UNORM, B4G4R4A4_UNORM, B5G5R5A1_UNORM, B5G6R5_UNORM, @@ -242,7 +243,7 @@ enum class FormatID X2R10G10B10_USCALED_VERTEX }; -constexpr uint32_t kNumANGLEFormats = 223; +constexpr uint32_t kNumANGLEFormats = 224; } // namespace angle diff --git a/src/libANGLE/renderer/Format_table_autogen.cpp b/src/libANGLE/renderer/Format_table_autogen.cpp index b90a84ea6..a5dd5d4a4 100644 --- a/src/libANGLE/renderer/Format_table_autogen.cpp +++ b/src/libANGLE/renderer/Format_table_autogen.cpp @@ -83,6 +83,7 @@ const Format gFormatInfoTable[] = { { FormatID::ASTC_8x6_UNORM_BLOCK, GL_COMPRESSED_RGBA_ASTC_8x6_KHR, GL_COMPRESSED_RGBA_ASTC_8x6_KHR, nullptr, NoCopyFunctions, nullptr, nullptr, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 0, 0, 0, 16, std::numeric_limits::max(), true, false, false, gl::VertexAttribType::InvalidEnum }, { FormatID::ASTC_8x8_SRGB_BLOCK, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR, nullptr, NoCopyFunctions, nullptr, nullptr, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 0, 0, 0, 16, std::numeric_limits::max(), true, false, false, gl::VertexAttribType::InvalidEnum }, { FormatID::ASTC_8x8_UNORM_BLOCK, GL_COMPRESSED_RGBA_ASTC_8x8_KHR, GL_COMPRESSED_RGBA_ASTC_8x8_KHR, nullptr, NoCopyFunctions, nullptr, nullptr, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 0, 0, 0, 16, std::numeric_limits::max(), true, false, false, gl::VertexAttribType::InvalidEnum }, + { FormatID::B10G10R10A2_UNORM, GL_BGR10_A2_ANGLEX, GL_BGR10_A2_ANGLEX, GenerateMip, NoCopyFunctions, ReadColor, WriteColor, GL_UNSIGNED_NORMALIZED, 10, 10, 10, 2, 0, 0, 0, 4, std::numeric_limits::max(), false, false, false, gl::VertexAttribType::UnsignedInt2101010 }, { FormatID::B4G4R4A4_UNORM, GL_BGRA4_ANGLEX, GL_RGBA4, GenerateMip, NoCopyFunctions, ReadColor, WriteColor, GL_UNSIGNED_NORMALIZED, 4, 4, 4, 4, 0, 0, 0, 2, std::numeric_limits::max(), false, false, false, gl::VertexAttribType::InvalidEnum }, { FormatID::B5G5R5A1_UNORM, GL_BGR5_A1_ANGLEX, GL_RGB5_A1, GenerateMip, NoCopyFunctions, ReadColor, WriteColor, GL_UNSIGNED_NORMALIZED, 5, 5, 5, 1, 0, 0, 0, 2, std::numeric_limits::max(), false, false, false, gl::VertexAttribType::InvalidEnum }, { FormatID::B5G6R5_UNORM, GL_BGR565_ANGLEX, GL_RGB565, GenerateMip, NoCopyFunctions, ReadColor, WriteColor, GL_UNSIGNED_NORMALIZED, 5, 6, 5, 0, 0, 0, 0, 2, std::numeric_limits::max(), false, false, false, gl::VertexAttribType::InvalidEnum }, @@ -271,6 +272,8 @@ FormatID Format::InternalFormatToID(GLenum internalFormat) return FormatID::A32_FLOAT; case GL_ALPHA8_EXT: return FormatID::A8_UNORM; + case GL_BGR10_A2_ANGLEX: + return FormatID::B10G10R10A2_UNORM; case GL_BGR565_ANGLEX: return FormatID::B5G6R5_UNORM; case GL_BGR5_A1_ANGLEX: diff --git a/src/libANGLE/renderer/angle_format_map.json b/src/libANGLE/renderer/angle_format_map.json index 8fdfac233..dd2fa6ddf 100644 --- a/src/libANGLE/renderer/angle_format_map.json +++ b/src/libANGLE/renderer/angle_format_map.json @@ -8,6 +8,7 @@ [ "GL_BGRA8_EXT", "B8G8R8A8_UNORM" ], [ "GL_BGRA8_SRGB_ANGLEX", "B8G8R8A8_UNORM_SRGB"], [ "GL_BGRX8_ANGLEX", "B8G8R8X8_UNORM" ], + [ "GL_BGR10_A2_ANGLEX", "B10G10R10A2_UNORM" ], [ "GL_COMPRESSED_R11_EAC", "EAC_R11_UNORM_BLOCK" ], [ "GL_COMPRESSED_RG11_EAC", "EAC_R11G11_UNORM_BLOCK" ], [ "GL_COMPRESSED_RGB8_ETC2", "ETC2_R8G8B8_UNORM_BLOCK" ], diff --git a/src/libANGLE/renderer/d3d/d3d11/texture_format_data.json b/src/libANGLE/renderer/d3d/d3d11/texture_format_data.json index 9da94b3ac..0a5f84074 100644 --- a/src/libANGLE/renderer/d3d/d3d11/texture_format_data.json +++ b/src/libANGLE/renderer/d3d/d3d11/texture_format_data.json @@ -115,6 +115,15 @@ "fallbackFormat": "R8G8B8A8_UNORM", "glInternalFormat": "GL_BGRX8_ANGLEX" }, + "B10G10R10A2_UNORM": { + "texFormat": "DXGI_FORMAT_R10G10B10A2_UNORM", + "srvFormat": "DXGI_FORMAT_R10G10B10A2_UNORM", + "rtvFormat": "DXGI_FORMAT_R10G10B10A2_UNORM", + "channels": "rgba", + "componentType": "unorm", + "bits": { "red": 10, "green": 10, "blue": 10, "alpha": 2 }, + "glInternalFormat": "GL_RGB10_A2" + }, "BC1_RGBA_UNORM_BLOCK": { "texFormat": "DXGI_FORMAT_BC1_UNORM", "srvFormat": "DXGI_FORMAT_BC1_UNORM", diff --git a/src/libANGLE/renderer/d3d/d3d11/texture_format_table_autogen.cpp b/src/libANGLE/renderer/d3d/d3d11/texture_format_table_autogen.cpp index 6e140a384..fb65cb4a6 100644 --- a/src/libANGLE/renderer/d3d/d3d11/texture_format_table_autogen.cpp +++ b/src/libANGLE/renderer/d3d/d3d11/texture_format_table_autogen.cpp @@ -92,6 +92,20 @@ const Format &Format::Get(GLenum internalFormat, const Renderer11DeviceCaps &dev return info; } } + case GL_BGR10_A2_ANGLEX: + { + static constexpr Format info(GL_BGR10_A2_ANGLEX, + angle::FormatID::B10G10R10A2_UNORM, + DXGI_FORMAT_R10G10B10A2_UNORM, + DXGI_FORMAT_R10G10B10A2_UNORM, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R10G10B10A2_UNORM, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R10G10B10A2_UNORM, + GL_RGBA16_EXT, + nullptr); + return info; + } case GL_BGR565_ANGLEX: { if (SupportsFormat(DXGI_FORMAT_B5G6R5_UNORM, deviceCaps)) diff --git a/src/libANGLE/renderer/gl/cgl/IOSurfaceSurfaceCGL.cpp b/src/libANGLE/renderer/gl/cgl/IOSurfaceSurfaceCGL.cpp index 06a09f30a..afdca4f2e 100644 --- a/src/libANGLE/renderer/gl/cgl/IOSurfaceSurfaceCGL.cpp +++ b/src/libANGLE/renderer/gl/cgl/IOSurfaceSurfaceCGL.cpp @@ -47,12 +47,13 @@ struct IOSurfaceFormatInfo // clang-format off static const IOSurfaceFormatInfo kIOSurfaceFormats[] = { - {GL_RED, GL_UNSIGNED_BYTE, 1, GL_RED, GL_RED, GL_UNSIGNED_BYTE }, - {GL_R16UI, GL_UNSIGNED_SHORT, 2, GL_RED, GL_RED, GL_UNSIGNED_SHORT }, - {GL_RG, GL_UNSIGNED_BYTE, 2, GL_RG, GL_RG, GL_UNSIGNED_BYTE }, - {GL_RGB, GL_UNSIGNED_BYTE, 4, GL_RGBA, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV}, - {GL_BGRA_EXT, GL_UNSIGNED_BYTE, 4, GL_RGBA, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV}, - {GL_RGBA, GL_HALF_FLOAT, 8, GL_RGBA, GL_RGBA, GL_HALF_FLOAT }, + {GL_RED, GL_UNSIGNED_BYTE, 1, GL_RED, GL_RED, GL_UNSIGNED_BYTE }, + {GL_R16UI, GL_UNSIGNED_SHORT, 2, GL_RED, GL_RED, GL_UNSIGNED_SHORT }, + {GL_RG, GL_UNSIGNED_BYTE, 2, GL_RG, GL_RG, GL_UNSIGNED_BYTE }, + {GL_RGB, GL_UNSIGNED_BYTE, 4, GL_RGBA, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV }, + {GL_BGRA_EXT, GL_UNSIGNED_BYTE, 4, GL_RGBA, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV }, + {GL_RGB10_A2, GL_UNSIGNED_INT_2_10_10_10_REV, 4, GL_RGBA, GL_BGRA, GL_UNSIGNED_INT_2_10_10_10_REV}, + {GL_RGBA, GL_HALF_FLOAT, 8, GL_RGBA, GL_RGBA, GL_HALF_FLOAT }, }; // clang-format on diff --git a/src/libANGLE/renderer/load_functions_data.json b/src/libANGLE/renderer/load_functions_data.json index 4b443ea69..ad5777e09 100644 --- a/src/libANGLE/renderer/load_functions_data.json +++ b/src/libANGLE/renderer/load_functions_data.json @@ -421,6 +421,11 @@ "GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT": "LoadToNative" } }, + "GL_BGR10_A2_ANGLEX": { + "B10G10R10A2_UNORM": { + "GL_UNSIGNED_INT_2_10_10_10_REV": "LoadToNative" + } + }, "GL_BGRA8_SRGB_ANGLEX" : { "B8G8R8A8_UNORM_SRGB": { "GL_UNSIGNED_BYTE": "LoadToNative" diff --git a/src/libANGLE/renderer/load_functions_table_autogen.cpp b/src/libANGLE/renderer/load_functions_table_autogen.cpp index 5294f4dda..ea89896ef 100644 --- a/src/libANGLE/renderer/load_functions_table_autogen.cpp +++ b/src/libANGLE/renderer/load_functions_table_autogen.cpp @@ -200,6 +200,18 @@ LoadImageFunctionInfo ALPHA8_EXT_to_R8_UNORM(GLenum type) } } +LoadImageFunctionInfo BGR10_A2_ANGLEX_to_B10G10R10A2_UNORM(GLenum type) +{ + switch (type) + { + case GL_UNSIGNED_INT_2_10_10_10_REV: + return LoadImageFunctionInfo(LoadToNative, false); + default: + UNREACHABLE(); + return LoadImageFunctionInfo(UnreachableLoadFunction, true); + } +} + LoadImageFunctionInfo BGR565_ANGLEX_to_B5G6R5_UNORM(GLenum type) { switch (type) @@ -3191,6 +3203,17 @@ LoadFunctionMap GetLoadFunctionsMap(GLenum internalFormat, FormatID angleFormat) } break; } + case GL_BGR10_A2_ANGLEX: + { + switch (angleFormat) + { + case FormatID::B10G10R10A2_UNORM: + return BGR10_A2_ANGLEX_to_B10G10R10A2_UNORM; + default: + break; + } + break; + } case GL_BGR565_ANGLEX: { switch (angleFormat) diff --git a/src/libANGLE/renderer/vulkan/mac/IOSurfaceSurfaceVkMac.mm b/src/libANGLE/renderer/vulkan/mac/IOSurfaceSurfaceVkMac.mm index e5830d2e6..50357e49e 100644 --- a/src/libANGLE/renderer/vulkan/mac/IOSurfaceSurfaceVkMac.mm +++ b/src/libANGLE/renderer/vulkan/mac/IOSurfaceSurfaceVkMac.mm @@ -35,13 +35,14 @@ struct IOSurfaceFormatInfo }; // clang-format off -constexpr std::array kIOSurfaceFormats = {{ - {GL_RED, GL_UNSIGNED_BYTE, 1, GL_R8 }, - {GL_R16UI, GL_UNSIGNED_SHORT, 2, GL_R16UI }, - {GL_RG, GL_UNSIGNED_BYTE, 2, GL_RG8 }, - {GL_RGB, GL_UNSIGNED_BYTE, 4, GL_BGRA8_EXT}, - {GL_BGRA_EXT, GL_UNSIGNED_BYTE, 4, GL_BGRA8_EXT }, - {GL_RGBA, GL_HALF_FLOAT, 8, GL_RGBA16F }, +constexpr std::array kIOSurfaceFormats = {{ + {GL_RED, GL_UNSIGNED_BYTE, 1, GL_R8 }, + {GL_R16UI, GL_UNSIGNED_SHORT, 2, GL_R16UI }, + {GL_RG, GL_UNSIGNED_BYTE, 2, GL_RG8 }, + {GL_RGB, GL_UNSIGNED_BYTE, 4, GL_BGRA8_EXT}, + {GL_BGRA_EXT, GL_UNSIGNED_BYTE, 4, GL_BGRA8_EXT}, + {GL_RGB10_A2, GL_UNSIGNED_INT_2_10_10_10_REV, 4, GL_BGR10_A2_ANGLEX }, + {GL_RGBA, GL_HALF_FLOAT, 8, GL_RGBA16F }, }}; // clang-format on diff --git a/src/libANGLE/renderer/vulkan/vk_format_map.json b/src/libANGLE/renderer/vulkan/vk_format_map.json index 7d7e6e1b0..8ba09a75d 100644 --- a/src/libANGLE/renderer/vulkan/vk_format_map.json +++ b/src/libANGLE/renderer/vulkan/vk_format_map.json @@ -56,6 +56,7 @@ "R8G8B8A8_UNORM_SRGB": "VK_FORMAT_R8G8B8A8_SRGB", "B8G8R8A8_UNORM": "VK_FORMAT_B8G8R8A8_UNORM", "B8G8R8A8_UNORM_SRGB": "VK_FORMAT_B8G8R8A8_SRGB", + "B10G10R10A2_UNORM": "VK_FORMAT_A2R10G10B10_UNORM_PACK32", "R10G10B10A2_UNORM": "VK_FORMAT_A2B10G10R10_UNORM_PACK32", "R10G10B10A2_SNORM": "VK_FORMAT_A2B10G10R10_SNORM_PACK32", "R10G10B10A2_USCALED": "VK_FORMAT_A2B10G10R10_USCALED_PACK32", diff --git a/src/libANGLE/renderer/vulkan/vk_format_table_autogen.cpp b/src/libANGLE/renderer/vulkan/vk_format_table_autogen.cpp index 3640bece4..1993b17e3 100644 --- a/src/libANGLE/renderer/vulkan/vk_format_table_autogen.cpp +++ b/src/libANGLE/renderer/vulkan/vk_format_table_autogen.cpp @@ -550,6 +550,18 @@ void Format::initialize(RendererVk *renderer, const angle::Format &angleFormat) vertexLoadRequiresConversion = false; break; + case angle::FormatID::B10G10R10A2_UNORM: + internalFormat = GL_BGR10_A2_ANGLEX; + actualImageFormatID = angle::FormatID::B10G10R10A2_UNORM; + vkImageFormat = VK_FORMAT_A2R10G10B10_UNORM_PACK32; + imageInitializerFunction = nullptr; + actualBufferFormatID = angle::FormatID::B10G10R10A2_UNORM; + vkBufferFormat = VK_FORMAT_A2R10G10B10_UNORM_PACK32; + vkBufferFormatIsPacked = true; + vertexLoadFunction = CopyNativeVertexData; + vertexLoadRequiresConversion = false; + break; + case angle::FormatID::B4G4R4A4_UNORM: internalFormat = GL_BGRA4_ANGLEX; actualImageFormatID = angle::FormatID::B4G4R4A4_UNORM; diff --git a/src/tests/egl_tests/EGLIOSurfaceClientBufferTest.cpp b/src/tests/egl_tests/EGLIOSurfaceClientBufferTest.cpp index fbe3e1a11..072c4e3ef 100644 --- a/src/tests/egl_tests/EGLIOSurfaceClientBufferTest.cpp +++ b/src/tests/egl_tests/EGLIOSurfaceClientBufferTest.cpp @@ -175,8 +175,17 @@ class IOSurfaceClientBufferTest : public ANGLETest void doClearTest(const ScopedIOSurfaceRef &ioSurface, GLenum internalFormat, GLenum type, - void *data, - size_t dataSize) + const GLColor &data) + { + std::array dataArray{data.R, data.G, data.B, data.A}; + doClearTest(ioSurface, internalFormat, type, dataArray); + } + + template + void doClearTest(const ScopedIOSurfaceRef &ioSurface, + GLenum internalFormat, + GLenum type, + const std::array &data) { // Bind the IOSurface to a texture and clear it. EGLSurface pbuffer; @@ -203,9 +212,13 @@ class IOSurfaceClientBufferTest : public ANGLETest EXPECT_EGL_SUCCESS(); IOSurfaceLock(ioSurface.get(), kIOSurfaceLockReadOnly, nullptr); - ASSERT_EQ(0, memcmp(IOSurfaceGetBaseAddress(ioSurface.get()), data, dataSize)); + std::array iosurfaceData; + memcpy(iosurfaceData.data(), IOSurfaceGetBaseAddress(ioSurface.get()), + sizeof(T) * data.size()); IOSurfaceUnlock(ioSurface.get(), kIOSurfaceLockReadOnly, nullptr); + ASSERT_EQ(data, iosurfaceData); + result = eglDestroySurface(mDisplay, pbuffer); EXPECT_EGL_TRUE(result); EXPECT_EGL_SUCCESS(); @@ -357,7 +370,7 @@ TEST_P(IOSurfaceClientBufferTest, RenderToBGRA8888IOSurface) ScopedIOSurfaceRef ioSurface = CreateSinglePlaneIOSurface(1, 1, 'BGRA', 4); GLColor color(3, 2, 1, 4); - doClearTest(ioSurface, GL_BGRA_EXT, GL_UNSIGNED_BYTE, &color, sizeof(color)); + doClearTest(ioSurface, GL_BGRA_EXT, GL_UNSIGNED_BYTE, color); } // Test reading from BGRA8888 IOSurfaces @@ -385,7 +398,7 @@ TEST_P(IOSurfaceClientBufferTest, RenderToBGRX8888IOSurface) ScopedIOSurfaceRef ioSurface = CreateSinglePlaneIOSurface(1, 1, 'BGRA', 4); GLColor color(3, 2, 1, 255); - doClearTest(ioSurface, GL_RGB, GL_UNSIGNED_BYTE, &color, sizeof(color)); + doClearTest(ioSurface, GL_RGB, GL_UNSIGNED_BYTE, color); } // Test reading from BGRX8888 IOSurfaces @@ -406,8 +419,8 @@ TEST_P(IOSurfaceClientBufferTest, RenderToRG88IOSurface) ScopedIOSurfaceRef ioSurface = CreateSinglePlaneIOSurface(1, 1, '2C08', 2); - uint8_t color[2] = {1, 2}; - doClearTest(ioSurface, GL_RG, GL_UNSIGNED_BYTE, &color, sizeof(color)); + std::array color{1, 2}; + doClearTest(ioSurface, GL_RG, GL_UNSIGNED_BYTE, color); } // Test reading from RG88 IOSurfaces @@ -428,8 +441,8 @@ TEST_P(IOSurfaceClientBufferTest, RenderToR8IOSurface) ScopedIOSurfaceRef ioSurface = CreateSinglePlaneIOSurface(1, 1, 'L008', 1); - uint8_t color = 1; - doClearTest(ioSurface, GL_RED, GL_UNSIGNED_BYTE, &color, sizeof(color)); + std::array color{1}; + doClearTest(ioSurface, GL_RED, GL_UNSIGNED_BYTE, color); } // Test reading from R8 IOSurfaces @@ -457,12 +470,43 @@ TEST_P(IOSurfaceClientBufferTest, RenderToR16IOSurface) // sooooooo let's test using it ScopedIOSurfaceRef ioSurface = CreateSinglePlaneIOSurface(1, 1, 'L016', 2); - uint16_t color = 257; - doClearTest(ioSurface, GL_R16UI, GL_UNSIGNED_SHORT, &color, sizeof(color)); + std::array color{257}; + doClearTest(ioSurface, GL_R16UI, GL_UNSIGNED_SHORT, color); } // TODO(cwallez@chromium.org): test reading from R16? It returns 0 maybe because samplerRect is // only for floating textures? +// Test using BGRA_1010102 IOSurfaces for rendering +TEST_P(IOSurfaceClientBufferTest, RenderToBGRA1010102IOSurface) +{ + ANGLE_SKIP_TEST_IF(!hasIOSurfaceExt()); + + // This test only works on ES3. + ANGLE_SKIP_TEST_IF(getClientMajorVersion() < 3); + // TODO(http://anglebug.com/4369) + ANGLE_SKIP_TEST_IF(isSwiftshader()); + + ScopedIOSurfaceRef ioSurface = CreateSinglePlaneIOSurface(1, 1, 'l10r', 4); + + std::array color{(0 << 30) | (1 << 22) | (2 << 12) | (3 << 2)}; + doClearTest(ioSurface, GL_RGB10_A2, GL_UNSIGNED_INT_2_10_10_10_REV, color); +} + +// Test reading from BGRA_1010102 IOSurfaces +TEST_P(IOSurfaceClientBufferTest, ReadFromBGRA1010102IOSurface) +{ + ANGLE_SKIP_TEST_IF(!hasIOSurfaceExt()); + + // This test only works on ES3. + ANGLE_SKIP_TEST_IF(getClientMajorVersion() < 3); + + ScopedIOSurfaceRef ioSurface = CreateSinglePlaneIOSurface(1, 1, 'l10r', 4); + + uint32_t color = (3 << 30) | (1 << 22) | (2 << 12) | (3 << 2); + doSampleTest(ioSurface, GL_RGB10_A2, GL_UNSIGNED_INT_2_10_10_10_REV, &color, sizeof(color), + R | G | B); // Don't test alpha, unorm '4' can't be represented with 2 bits. +} + // TODO(cwallez@chromium.org): Test using RGBA half float IOSurfaces ('RGhA') // Test blitting from IOSurface