зеркало из https://github.com/AvaloniaUI/angle.git
Support BGRA_1010102 IOSurfaces in CGL and Vulkan.
Bug: chromium:1100599 Change-Id: I7bc2c2e35490e28e9f6fe8f2e0c26cdea50650b9 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2275731 Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Jonah Ryan-Davis <jonahr@google.com> Commit-Queue: Geoff Lang <geofflang@chromium.org>
This commit is contained in:
Родитель
5671c2bd08
Коммит
49108a1283
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
}
|
|
@ -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"
|
||||
}
|
|
@ -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"
|
||||
}
|
|
@ -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":
|
||||
|
|
|
@ -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":
|
||||
|
|
|
@ -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"
|
||||
}
|
|
@ -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):
|
||||
|
|
|
@ -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<uint32_t>(src->red);
|
||||
dst->G = static_cast<uint32_t>(src->green);
|
||||
dst->B = static_cast<uint32_t>(src->blue);
|
||||
dst->A = static_cast<uint32_t>(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<uint32_t>(*src), &dst->red, &dst->green, &dst->blue);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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<GLuint>::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<GLuint>::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<GLuint>::max(), true, false, false, gl::VertexAttribType::InvalidEnum },
|
||||
{ FormatID::B10G10R10A2_UNORM, GL_BGR10_A2_ANGLEX, GL_BGR10_A2_ANGLEX, GenerateMip<B10G10R10A2>, NoCopyFunctions, ReadColor<B10G10R10A2, GLfloat>, WriteColor<B10G10R10A2, GLfloat>, GL_UNSIGNED_NORMALIZED, 10, 10, 10, 2, 0, 0, 0, 4, std::numeric_limits<GLuint>::max(), false, false, false, gl::VertexAttribType::UnsignedInt2101010 },
|
||||
{ FormatID::B4G4R4A4_UNORM, GL_BGRA4_ANGLEX, GL_RGBA4, GenerateMip<A4R4G4B4>, NoCopyFunctions, ReadColor<A4R4G4B4, GLfloat>, WriteColor<A4R4G4B4, GLfloat>, GL_UNSIGNED_NORMALIZED, 4, 4, 4, 4, 0, 0, 0, 2, std::numeric_limits<GLuint>::max(), false, false, false, gl::VertexAttribType::InvalidEnum },
|
||||
{ FormatID::B5G5R5A1_UNORM, GL_BGR5_A1_ANGLEX, GL_RGB5_A1, GenerateMip<A1R5G5B5>, NoCopyFunctions, ReadColor<A1R5G5B5, GLfloat>, WriteColor<A1R5G5B5, GLfloat>, GL_UNSIGNED_NORMALIZED, 5, 5, 5, 1, 0, 0, 0, 2, std::numeric_limits<GLuint>::max(), false, false, false, gl::VertexAttribType::InvalidEnum },
|
||||
{ FormatID::B5G6R5_UNORM, GL_BGR565_ANGLEX, GL_RGB565, GenerateMip<B5G6R5>, NoCopyFunctions, ReadColor<B5G6R5, GLfloat>, WriteColor<B5G6R5, GLfloat>, GL_UNSIGNED_NORMALIZED, 5, 6, 5, 0, 0, 0, 0, 2, std::numeric_limits<GLuint>::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:
|
||||
|
|
|
@ -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" ],
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -421,6 +421,11 @@
|
|||
"GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT": "LoadToNative<GLushort, 1>"
|
||||
}
|
||||
},
|
||||
"GL_BGR10_A2_ANGLEX": {
|
||||
"B10G10R10A2_UNORM": {
|
||||
"GL_UNSIGNED_INT_2_10_10_10_REV": "LoadToNative<GLuint, 1>"
|
||||
}
|
||||
},
|
||||
"GL_BGRA8_SRGB_ANGLEX" : {
|
||||
"B8G8R8A8_UNORM_SRGB": {
|
||||
"GL_UNSIGNED_BYTE": "LoadToNative<GLubyte, 4>"
|
||||
|
|
|
@ -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<GLuint, 1>, 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)
|
||||
|
|
|
@ -35,13 +35,14 @@ struct IOSurfaceFormatInfo
|
|||
};
|
||||
|
||||
// clang-format off
|
||||
constexpr std::array<IOSurfaceFormatInfo, 6> 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<IOSurfaceFormatInfo, 7> 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
|
||||
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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<GLuint, 1, 1, 0>;
|
||||
vertexLoadRequiresConversion = false;
|
||||
break;
|
||||
|
||||
case angle::FormatID::B4G4R4A4_UNORM:
|
||||
internalFormat = GL_BGRA4_ANGLEX;
|
||||
actualImageFormatID = angle::FormatID::B4G4R4A4_UNORM;
|
||||
|
|
|
@ -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<uint8_t, 4> dataArray{data.R, data.G, data.B, data.A};
|
||||
doClearTest(ioSurface, internalFormat, type, dataArray);
|
||||
}
|
||||
|
||||
template <typename T, size_t dataSize>
|
||||
void doClearTest(const ScopedIOSurfaceRef &ioSurface,
|
||||
GLenum internalFormat,
|
||||
GLenum type,
|
||||
const std::array<T, dataSize> &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<T, dataSize> 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<uint8_t, 2> 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<uint8_t, 1> 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<uint16_t, 1> 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<uint32_t, 1> 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
|
||||
|
|
Загрузка…
Ссылка в новой задаче