Commit 3b46885e by Jaedon Lee Committed by Commit Bot

Vulkan: Implement EXT_texture_type_2_10_10_10_REV

- Expose GLES 3.0 feature of 2_10_10_10_REV texture type on GLES 2.0 as EXT. - Handle alpha channel value as 1.0 when used with RGB format. - Add test for "RGB+UNSIGNED_INT_2_10_10_10_REV" case into TextureUploadFormatTest. BUG=angleproject:3232. Test: dEQP-GLES2.capability.extensions.uncompressed_texture_formats.GL_EXT_texture_type_2_10_10_10_REV dEQP-GLES2.functional.fbo.completeness.renderable.texture.*2_10_10_10_rev dEQP-GLES3.functional.fbo.completeness.renderable.texture.*2_10_10_10_rev KHR-GLES2.core.internalformat.*2_10_10_10_rev* KHR-GLES3.core.internalformat.*2_10_10_10_rev* Change-Id: Iac00517971f9242161115c7256117a69093fb5df Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1732618 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent a9389dfe
......@@ -153,6 +153,7 @@ Samsung Electronics, Inc.
Colin Peter
Hyunchang Kim
Hyunseok Ko
Jaedon Lee
Jeff Vigil
Minkyu Jeong
Mohan Maiya
......
{
"src/libANGLE/renderer/FormatID_autogen.h":
"5e017d47bc2eb942cf5717e05e7d072a",
"f127ba841492924a28ffe92e7ead74e9",
"src/libANGLE/renderer/Format_table_autogen.cpp":
"e22b7e416108ca2f738730d5a5be4c21",
"a30ec4e0658eb44634a4c44b8334cde7",
"src/libANGLE/renderer/angle_format.py":
"7ed0a2469779c02567c98e0f2e476843",
"eefe6befdc925574207746fa531165fd",
"src/libANGLE/renderer/angle_format_data.json":
"e39704d451d108335e737c39ad423113",
"src/libANGLE/renderer/angle_format_map.json":
"947fe0a2c3ca1a819a68b4a94bfcf614",
"ce3cf0c03ed74a997dbe9d6b7bf5e6f0",
"src/libANGLE/renderer/gen_angle_format_table.py":
"37f4654bca2bebc7fdec1fc7ca9bc622"
"dfa234d7707682fec20b571d2c16d784"
}
\ No newline at end of file
......@@ -2,7 +2,7 @@
"src/libANGLE/renderer/gen_load_functions_table.py":
"e65c50e84fc38ad34d0eb0bebb84aab6",
"src/libANGLE/renderer/load_functions_data.json":
"c32a5f4b267223629d941ae9fa569a41",
"2225ec8e466cb151fe383fc467d35d65",
"src/libANGLE/renderer/load_functions_table_autogen.cpp":
"03b0e7283d98cca5faf9218b40c49979"
"f4c1c06efea4b69ac29c7f8dff68ea6d"
}
\ No newline at end of file
{
"src/libANGLE/renderer/angle_format.py":
"7ed0a2469779c02567c98e0f2e476843",
"eefe6befdc925574207746fa531165fd",
"src/libANGLE/renderer/d3d/d3d11/gen_texture_format_table.py":
"bf11e3404d4622059b6e9c4e96abf95e",
"src/libANGLE/renderer/d3d/d3d11/texture_format_data.json":
......
{
"src/libANGLE/renderer/angle_format.py":
"7ed0a2469779c02567c98e0f2e476843",
"eefe6befdc925574207746fa531165fd",
"src/libANGLE/renderer/angle_format_map.json":
"947fe0a2c3ca1a819a68b4a94bfcf614",
"ce3cf0c03ed74a997dbe9d6b7bf5e6f0",
"src/libANGLE/renderer/d3d/d3d11/dxgi_format_data.json":
"24f525b05dc665fbbc8c6d68fb863719",
"src/libANGLE/renderer/d3d/d3d11/dxgi_format_map_autogen.cpp":
......
{
"src/libANGLE/es3_format_type_combinations.json":
"a232823cd6430f14e28793ccabb968ee",
"b44b222c27eea6839c0da3076ee540fc",
"src/libANGLE/format_map_autogen.cpp":
"1e1b1c2af35a8a75c4395430d2370758",
"e59660c3ae6360cb8638fc69583ba7a2",
"src/libANGLE/format_map_data.json":
"779798d4879e5f73a5a108e3e3fd3095",
"e7985d3132fa396e8d39a5daee29260a",
"src/libANGLE/gen_format_map.py":
"dbc855d50826670a9e1a4ff2747e7583"
}
\ No newline at end of file
......@@ -2,7 +2,7 @@
"scripts/gl.xml":
"b470cb06b06cbbe7adb2c8129ec85708",
"src/libANGLE/renderer/angle_format.py":
"7ed0a2469779c02567c98e0f2e476843",
"eefe6befdc925574207746fa531165fd",
"src/libANGLE/renderer/gl/DispatchTableGL_autogen.cpp":
"7ebaa7f7525a0fe13f163ec076a8eace",
"src/libANGLE/renderer/gl/DispatchTableGL_autogen.h":
......
{
"src/libANGLE/renderer/angle_format.py":
"7ed0a2469779c02567c98e0f2e476843",
"eefe6befdc925574207746fa531165fd",
"src/libANGLE/renderer/angle_format_map.json":
"947fe0a2c3ca1a819a68b4a94bfcf614",
"ce3cf0c03ed74a997dbe9d6b7bf5e6f0",
"src/libANGLE/renderer/vulkan/gen_vk_format_table.py":
"ed6800108a872709e5e53fde2833aa86",
"src/libANGLE/renderer/vulkan/vk_format_map.json":
"787cb6414e110180885350c3335cb4b4",
"0e63169b162b3720db40e80c80163edb",
"src/libANGLE/renderer/vulkan/vk_format_table_autogen.cpp":
"184391d8ca5be757f975c6fc3f149435"
"8b9e38b91ec6b8b23573e2ef9df5284a"
}
\ No newline at end of file
{
"src/libANGLE/renderer/angle_format.py":
"7ed0a2469779c02567c98e0f2e476843",
"eefe6befdc925574207746fa531165fd",
"src/libANGLE/renderer/vulkan/gen_vk_mandatory_format_support_table.py":
"dab4614bbee0c3fbc5b3ccaaa11ba9d3",
"src/libANGLE/renderer/vulkan/vk_mandatory_format_support_data.json":
......
......@@ -250,6 +250,9 @@ std::string ToString(const T &value)
#define GL_RGB10_A2_SSCALED_ANGLEX 0x6AEC
#define GL_RGB10_A2_USCALED_ANGLEX 0x6AED
// EXT_texture_type_2_10_10_10_REV
#define GL_RGB10_UNORM_ANGLEX 0x6AEE
#define ANGLE_CHECK_GL_ALLOC(context, result) \
ANGLE_CHECK(context, result, "Failed to allocate host memory", GL_OUT_OF_MEMORY)
......
......@@ -1713,6 +1713,43 @@ void R10G10B10A2S::average(R10G10B10A2S *dst, const R10G10B10A2S *src1, const R1
dst->A = gl::average(src1->A, src2->A);
}
void R10G10B10X2::readColor(gl::ColorUI *dst, const R10G10B10X2 *src)
{
dst->red = src->R;
dst->green = src->G;
dst->blue = src->B;
dst->alpha = 0x3;
}
void R10G10B10X2::readColor(gl::ColorF *dst, const R10G10B10X2 *src)
{
dst->red = gl::normalizedToFloat<10>(src->R);
dst->green = gl::normalizedToFloat<10>(src->G);
dst->blue = gl::normalizedToFloat<10>(src->B);
dst->alpha = 1.0f;
}
void R10G10B10X2::writeColor(R10G10B10X2 *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);
}
void R10G10B10X2::writeColor(R10G10B10X2 *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);
}
void R10G10B10X2::average(R10G10B10X2 *dst, const R10G10B10X2 *src1, const R10G10B10X2 *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);
}
void R9G9B9E5::readColor(gl::ColorF *dst, const R9G9B9E5 *src)
{
gl::convert999E5toRGBFloats(gl::bitCast<uint32_t>(*src), &dst->red, &dst->green, &dst->blue);
......@@ -1791,12 +1828,12 @@ void D16::WriteDepthStencil(D16 *dst, const DepthStencil *src)
UNIMPLEMENTED();
}
void D24::ReadDepthStencil(DepthStencil *dst, const D24 *src)
void D24X8::ReadDepthStencil(DepthStencil *dst, const D24X8 *src)
{
dst->depth = gl::normalizedToFloat<24>(src->D);
}
void D24::WriteDepthStencil(D24 *dst, const DepthStencil *src)
void D24X8::WriteDepthStencil(D24X8 *dst, const DepthStencil *src)
{
UNIMPLEMENTED();
}
......@@ -1821,13 +1858,13 @@ void D32::WriteDepthStencil(D32 *dst, const DepthStencil *src)
UNIMPLEMENTED();
}
void D32FS8::ReadDepthStencil(DepthStencil *dst, const D32FS8 *src)
void D32FS8X24::ReadDepthStencil(DepthStencil *dst, const D32FS8X24 *src)
{
dst->depth = src->D;
dst->stencil = gl::getShiftedData<8, 24>(static_cast<uint32_t>(src->S));
}
void D32FS8::WriteDepthStencil(D32FS8 *dst, const DepthStencil *src)
void D32FS8X24::WriteDepthStencil(D32FS8X24 *dst, const DepthStencil *src)
{
dst->D = static_cast<float>(src->depth);
dst->S = src->stencil & 0xFF;
......
......@@ -685,6 +685,20 @@ struct R10G10B10A2S
};
static_assert(sizeof(R10G10B10A2S) == 4, "R10G10B10A2S struct not 32-bits.");
struct R10G10B10X2
{
uint32_t R : 10;
uint32_t G : 10;
uint32_t B : 10;
static void readColor(gl::ColorF *dst, const R10G10B10X2 *src);
static void readColor(gl::ColorUI *dst, const R10G10B10X2 *src);
static void writeColor(R10G10B10X2 *dst, const gl::ColorF *src);
static void writeColor(R10G10B10X2 *dst, const gl::ColorUI *src);
static void average(R10G10B10X2 *dst, const R10G10B10X2 *src1, const R10G10B10X2 *src2);
};
static_assert(sizeof(R10G10B10X2) == 4, "R10G10B10X2 struct not 32-bits.");
struct R9G9B9E5
{
uint32_t R : 9;
......@@ -735,12 +749,12 @@ struct D16
static void WriteDepthStencil(D16 *dst, const DepthStencil *src);
};
struct D24
struct D24X8
{
uint32_t D;
static void ReadDepthStencil(DepthStencil *dst, const D24 *src);
static void WriteDepthStencil(D24 *dst, const DepthStencil *src);
static void ReadDepthStencil(DepthStencil *dst, const D24X8 *src);
static void WriteDepthStencil(D24X8 *dst, const DepthStencil *src);
};
struct D32F
......@@ -759,13 +773,13 @@ struct D32
static void WriteDepthStencil(D32 *dst, const DepthStencil *src);
};
struct D32FS8
struct D32FS8X24
{
float D;
uint32_t S;
static void ReadDepthStencil(DepthStencil *dst, const D32FS8 *src);
static void WriteDepthStencil(D32FS8 *dst, const DepthStencil *src);
static void ReadDepthStencil(DepthStencil *dst, const D32FS8X24 *src);
static void WriteDepthStencil(D32FS8X24 *dst, const DepthStencil *src);
};
} // namespace angle
......
......@@ -1041,6 +1041,32 @@ void LoadRGB10A2ToRGBA8(size_t width,
}
}
void LoadRGB10A2ToRGB10X2(size_t width,
size_t height,
size_t depth,
const uint8_t *input,
size_t inputRowPitch,
size_t inputDepthPitch,
uint8_t *output,
size_t outputRowPitch,
size_t outputDepthPitch)
{
for (size_t z = 0; z < depth; z++)
{
for (size_t y = 0; y < height; y++)
{
const uint32_t *source =
priv::OffsetDataPointer<uint32_t>(input, y, z, inputRowPitch, inputDepthPitch);
uint32_t *dest =
priv::OffsetDataPointer<uint32_t>(output, y, z, outputRowPitch, outputDepthPitch);
for (size_t x = 0; x < width; x++)
{
dest[x] = source[x] | 0xC0000000;
}
}
}
}
void LoadRGB16FToRGB9E5(size_t width,
size_t height,
size_t depth,
......
......@@ -335,6 +335,16 @@ void LoadRGB10A2ToRGBA8(size_t width,
size_t outputRowPitch,
size_t outputDepthPitch);
void LoadRGB10A2ToRGB10X2(size_t width,
size_t height,
size_t depth,
const uint8_t *input,
size_t inputRowPitch,
size_t inputDepthPitch,
uint8_t *output,
size_t outputRowPitch,
size_t outputDepthPitch);
void LoadRGB16FToRGB9E5(size_t width,
size_t height,
size_t depth,
......
......@@ -723,6 +723,7 @@ const ExtensionInfoMap &GetExtensionInfoMap()
map["GL_OES_get_program_binary"] = enableableExtension(&Extensions::getProgramBinary);
map["GL_OES_rgb8_rgba8"] = enableableExtension(&Extensions::rgb8rgba8);
map["GL_EXT_texture_format_BGRA8888"] = enableableExtension(&Extensions::textureFormatBGRA8888);
map["GL_EXT_texture_type_2_10_10_10_REV"] = enableableExtension(&Extensions::textureFormat2101010REV);
map["GL_EXT_read_format_bgra"] = esOnlyExtension(&Extensions::readFormatBGRA);
map["GL_NV_pixel_buffer_object"] = enableableExtension(&Extensions::pixelBufferObject);
map["GL_OES_mapbuffer"] = enableableExtension(&Extensions::mapBuffer);
......
......@@ -160,6 +160,9 @@ struct Extensions
bool textureHalfFloat = false;
bool textureHalfFloatLinear = false;
// GL_EXT_texture_type_2_10_10_10_REV
bool textureFormat2101010REV = false;
// GL_OES_texture_float and GL_OES_texture_float_linear
// Implies that TextureCaps for GL_RGB32F, GL_RGBA32F, GL_ALPHA16F_EXT, GL_LUMINANCE16F_EXT and
// GL_LUMINANCE_ALPHA16F_EXT exist
......
......@@ -167,5 +167,10 @@
[ "GL_RG16_SNORM_EXT", "GL_RG", "GL_SHORT" ],
[ "GL_RGB16_SNORM_EXT", "GL_RGB", "GL_SHORT" ],
[ "GL_RGBA16_SNORM_EXT", "GL_RGBA", "GL_SHORT" ]
],
"From GL_EXT_texture_type_2_10_10_10_REV":
[
[ "GL_RGBA", "GL_RGBA", "GL_UNSIGNED_INT_2_10_10_10_REV" ],
[ "GL_RGB", "GL_RGB", "GL_UNSIGNED_INT_2_10_10_10_REV" ]
]
}
......@@ -311,6 +311,8 @@ GLenum GetSizedFormatInternal(GLenum format, GLenum type)
return GL_RGB8;
case GL_UNSIGNED_INT_10F_11F_11F_REV:
return GL_R11F_G11F_B10F;
case GL_UNSIGNED_INT_2_10_10_10_REV:
return GL_RGB10_UNORM_ANGLEX;
case GL_UNSIGNED_INT_5_9_9_9_REV:
return GL_RGB9_E5;
case GL_UNSIGNED_SHORT:
......@@ -699,6 +701,17 @@ bool ValidES3FormatCombination(GLenum format, GLenum type, GLenum internalFormat
}
break;
}
case GL_UNSIGNED_INT_2_10_10_10_REV:
{
switch (internalFormat)
{
case GL_RGB:
return true;
default:
break;
}
break;
}
case GL_SHORT:
{
switch (internalFormat)
......@@ -935,6 +948,7 @@ bool ValidES3FormatCombination(GLenum format, GLenum type, GLenum internalFormat
{
switch (internalFormat)
{
case GL_RGBA:
case GL_RGB10_A2:
case GL_RGB5_A1:
return true;
......
......@@ -28,6 +28,7 @@
"GL_UNSIGNED_SHORT_5_6_5": "GL_RGB565",
"GL_UNSIGNED_INT_10F_11F_11F_REV": "GL_R11F_G11F_B10F",
"GL_UNSIGNED_INT_5_9_9_9_REV": "GL_RGB9_E5",
"GL_UNSIGNED_INT_2_10_10_10_REV": "GL_RGB10_UNORM_ANGLEX",
"GL_FLOAT": "GL_RGB32F",
"GL_HALF_FLOAT": "GL_RGB16F",
"GL_HALF_FLOAT_OES": "GL_RGB16F"
......
......@@ -958,10 +958,11 @@ static InternalFormatInfoMap BuildInternalFormatInfoMap()
AddRGBAFormat(&map, GL_RGB, false, 8, 8, 8, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, RequireES<2, 0>, NeverSupported);
AddRGBAFormat(&map, GL_RGB, false, 5, 6, 5, 0, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, RequireES<2, 0>, NeverSupported);
AddRGBAFormat(&map, GL_RGB, false, 8, 8, 8, 0, 0, GL_RGB, GL_BYTE, GL_SIGNED_NORMALIZED, false, NeverSupported, NeverSupported, NeverSupported, NeverSupported);
AddRGBAFormat(&map, GL_RGB, false, 10, 10, 10, 0, 0, GL_RGB, GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureFormat2101010REV>, AlwaysSupported, NeverSupported, NeverSupported);
AddRGBAFormat(&map, GL_RGBA, false, 4, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, RequireES<2, 0>, NeverSupported);
AddRGBAFormat(&map, GL_RGBA, false, 5, 5, 5, 1, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, RequireES<2, 0>, NeverSupported);
AddRGBAFormat(&map, GL_RGBA, false, 8, 8, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, RequireES<2, 0>, NeverSupported);
AddRGBAFormat(&map, GL_RGBA, false, 10, 10, 10, 2, 0, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_NORMALIZED, false, NeverSupported, NeverSupported, NeverSupported, NeverSupported);
AddRGBAFormat(&map, GL_RGBA, false, 10, 10, 10, 2, 0, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureFormat2101010REV>, AlwaysSupported, NeverSupported, NeverSupported);
AddRGBAFormat(&map, GL_RGBA, false, 8, 8, 8, 8, 0, GL_RGBA, GL_BYTE, GL_SIGNED_NORMALIZED, false, NeverSupported, NeverSupported, NeverSupported, NeverSupported);
AddRGBAFormat(&map, GL_SRGB, false, 8, 8, 8, 0, 0, GL_SRGB, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, true, RequireExt<&Extensions::sRGB>, AlwaysSupported, NeverSupported, NeverSupported);
AddRGBAFormat(&map, GL_SRGB_ALPHA_EXT, false, 8, 8, 8, 8, 0, GL_SRGB_ALPHA_EXT, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, true, RequireExt<&Extensions::sRGB>, AlwaysSupported, RequireExt<&Extensions::sRGB>, NeverSupported);
......
......@@ -120,6 +120,7 @@ enum class FormatID
R10G10B10A2_UINT,
R10G10B10A2_UNORM,
R10G10B10A2_USCALED,
R10G10B10X2_UNORM,
R11G11B10_FLOAT,
R16G16B16A16_FLOAT,
R16G16B16A16_SINT,
......@@ -216,7 +217,7 @@ enum class FormatID
S8_UINT
};
constexpr uint32_t kNumANGLEFormats = 197;
constexpr uint32_t kNumANGLEFormats = 198;
} // namespace angle
......
......@@ -99,9 +99,9 @@ const Format gFormatInfoTable[] = {
{ FormatID::BPTC_SRGB_ALPHA_UNORM_BLOCK, GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT, GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT, 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::D16_UNORM, GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT16, nullptr, NoCopyFunctions, ReadDepthStencil<D16>, WriteDepthStencil<D16>, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 0, 16, 0, 2, std::numeric_limits<GLuint>::max(), false, false, false, gl::VertexAttribType::InvalidEnum },
{ FormatID::D24_UNORM_S8_UINT, GL_DEPTH24_STENCIL8, GL_DEPTH24_STENCIL8, nullptr, NoCopyFunctions, ReadDepthStencil<D24S8>, WriteDepthStencil<D24S8>, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 0, 24, 8, 4, std::numeric_limits<GLuint>::max(), false, false, false, gl::VertexAttribType::InvalidEnum },
{ FormatID::D24_UNORM_X8_UINT, GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT24, nullptr, NoCopyFunctions, ReadDepthStencil<D24>, WriteDepthStencil<D24>, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 0, 24, 0, 4, std::numeric_limits<GLuint>::max(), false, false, false, gl::VertexAttribType::InvalidEnum },
{ FormatID::D24_UNORM_X8_UINT, GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT24, nullptr, NoCopyFunctions, ReadDepthStencil<D24X8>, WriteDepthStencil<D24X8>, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 0, 24, 0, 4, std::numeric_limits<GLuint>::max(), false, false, false, gl::VertexAttribType::InvalidEnum },
{ FormatID::D32_FLOAT, GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT32F, nullptr, NoCopyFunctions, ReadDepthStencil<D32F>, WriteDepthStencil<D32F>, GL_FLOAT, 0, 0, 0, 0, 0, 32, 0, 4, std::numeric_limits<GLuint>::max(), false, false, false, gl::VertexAttribType::Float },
{ FormatID::D32_FLOAT_S8X24_UINT, GL_DEPTH32F_STENCIL8, GL_DEPTH32F_STENCIL8, nullptr, NoCopyFunctions, ReadDepthStencil<D32FS8>, WriteDepthStencil<D32FS8>, GL_FLOAT, 0, 0, 0, 0, 0, 32, 8, 8, std::numeric_limits<GLuint>::max(), false, false, false, gl::VertexAttribType::Float },
{ FormatID::D32_FLOAT_S8X24_UINT, GL_DEPTH32F_STENCIL8, GL_DEPTH32F_STENCIL8, nullptr, NoCopyFunctions, ReadDepthStencil<D32FS8X24>, WriteDepthStencil<D32FS8X24>, GL_FLOAT, 0, 0, 0, 0, 0, 32, 8, 8, std::numeric_limits<GLuint>::max(), false, false, false, gl::VertexAttribType::Float },
{ FormatID::D32_UNORM, GL_DEPTH_COMPONENT32_OES, GL_DEPTH_COMPONENT32_OES, nullptr, NoCopyFunctions, ReadDepthStencil<D32>, WriteDepthStencil<D32>, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 0, 32, 0, 4, std::numeric_limits<GLuint>::max(), false, false, false, gl::VertexAttribType::InvalidEnum },
{ FormatID::EAC_R11G11_SNORM_BLOCK, GL_COMPRESSED_SIGNED_RG11_EAC, GL_COMPRESSED_SIGNED_RG11_EAC, nullptr, NoCopyFunctions, nullptr, nullptr, GL_SIGNED_NORMALIZED, 11, 11, 0, 0, 0, 0, 0, 16, 0, true, false, false, gl::VertexAttribType::InvalidEnum },
{ FormatID::EAC_R11G11_UNORM_BLOCK, GL_COMPRESSED_RG11_EAC, GL_COMPRESSED_RG11_EAC, nullptr, NoCopyFunctions, nullptr, nullptr, GL_UNSIGNED_NORMALIZED, 11, 11, 0, 0, 0, 0, 0, 16, 0, true, false, false, gl::VertexAttribType::InvalidEnum },
......@@ -127,6 +127,7 @@ const Format gFormatInfoTable[] = {
{ FormatID::R10G10B10A2_UINT, GL_RGB10_A2UI, GL_RGB10_A2UI, GenerateMip<R10G10B10A2>, NoCopyFunctions, ReadColor<R10G10B10A2, GLuint>, WriteColor<R10G10B10A2, GLuint>, GL_UNSIGNED_INT, 10, 10, 10, 2, 0, 0, 0, 4, std::numeric_limits<GLuint>::max(), false, false, false, gl::VertexAttribType::UnsignedInt2101010 },
{ FormatID::R10G10B10A2_UNORM, GL_RGB10_A2, GL_RGB10_A2, GenerateMip<R10G10B10A2>, NoCopyFunctions, ReadColor<R10G10B10A2, GLfloat>, WriteColor<R10G10B10A2, GLfloat>, GL_UNSIGNED_NORMALIZED, 10, 10, 10, 2, 0, 0, 0, 4, std::numeric_limits<GLuint>::max(), false, false, false, gl::VertexAttribType::UnsignedInt2101010 },
{ FormatID::R10G10B10A2_USCALED, GL_RGB10_A2_USCALED_ANGLEX, GL_RGB10_A2_USCALED_ANGLEX, GenerateMip<R10G10B10A2>, NoCopyFunctions, ReadColor<R10G10B10A2, GLuint>, WriteColor<R10G10B10A2, GLuint>, GL_UNSIGNED_INT, 10, 10, 10, 2, 0, 0, 0, 4, std::numeric_limits<GLuint>::max(), false, false, true, gl::VertexAttribType::UnsignedInt2101010 },
{ FormatID::R10G10B10X2_UNORM, GL_RGB10_UNORM_ANGLEX, GL_RGB10_UNORM_ANGLEX, GenerateMip<R10G10B10X2>, NoCopyFunctions, ReadColor<R10G10B10X2, GLfloat>, WriteColor<R10G10B10X2, GLfloat>, GL_UNSIGNED_NORMALIZED, 10, 10, 10, 0, 0, 0, 0, 4, std::numeric_limits<GLuint>::max(), false, false, false, gl::VertexAttribType::UnsignedInt2101010 },
{ FormatID::R11G11B10_FLOAT, GL_R11F_G11F_B10F, GL_R11F_G11F_B10F, GenerateMip<R11G11B10F>, NoCopyFunctions, ReadColor<R11G11B10F, GLfloat>, WriteColor<R11G11B10F, GLfloat>, GL_FLOAT, 11, 11, 10, 0, 0, 0, 0, 4, std::numeric_limits<GLuint>::max(), false, false, false, gl::VertexAttribType::Float },
{ FormatID::R16G16B16A16_FLOAT, GL_RGBA16F, GL_RGBA16F, GenerateMip<R16G16B16A16F>, NoCopyFunctions, ReadColor<R16G16B16A16F, GLfloat>, WriteColor<R16G16B16A16F, GLfloat>, GL_FLOAT, 16, 16, 16, 16, 0, 0, 0, 8, 1, false, false, false, gl::VertexAttribType::HalfFloat },
{ FormatID::R16G16B16A16_SINT, GL_RGBA16I, GL_RGBA16I, GenerateMip<R16G16B16A16S>, NoCopyFunctions, ReadColor<R16G16B16A16S, GLint>, WriteColor<R16G16B16A16S, GLint>, GL_INT, 16, 16, 16, 16, 0, 0, 0, 8, 1, false, false, false, gl::VertexAttribType::Short },
......@@ -523,6 +524,8 @@ FormatID Format::InternalFormatToID(GLenum internalFormat)
return FormatID::R10G10B10A2_SSCALED;
case GL_RGB10_A2_USCALED_ANGLEX:
return FormatID::R10G10B10A2_USCALED;
case GL_RGB10_UNORM_ANGLEX:
return FormatID::R10G10B10X2_UNORM;
case GL_RGB16F:
return FormatID::R16G16B16_FLOAT;
case GL_RGB16I:
......
......@@ -133,6 +133,8 @@ def gl_format_channels(internal_format):
return 'rgba'
if internal_format.find('GL_RGB10_A2') == 0:
return 'rgba'
if internal_format == 'GL_RGB10_UNORM_ANGLEX':
return 'rgb'
channels_pattern = re.compile('GL_(COMPRESSED_)?(SIGNED_)?(ETC\d_)?([A-Z]+)')
match = re.search(channels_pattern, internal_format)
......@@ -165,6 +167,9 @@ def get_internal_format_initializer(internal_format, format_id):
if not gl_format_no_alpha or channels != 'rgba':
return 'nullptr'
elif internal_format == 'GL_RGB10_UNORM_ANGLEX':
return 'nullptr'
elif 'BC1_' in format_id:
# BC1 is a special case since the texture data determines whether each block has an alpha channel or not.
# This if statement is hit by COMPRESSED_RGB_S3TC_DXT1, which is a bit of a mess.
......
......@@ -197,5 +197,6 @@
[ "GL_R32_FIXED_ANGLEX", "R32_FIXED" ],
[ "GL_RG32_FIXED_ANGLEX", "R32G32_FIXED" ],
[ "GL_RGB32_FIXED_ANGLEX", "R32G32B32_FIXED" ],
[ "GL_RGBA32_FIXED_ANGLEX", "R32G32B32A32_FIXED" ]
[ "GL_RGBA32_FIXED_ANGLEX", "R32G32B32A32_FIXED" ],
[ "GL_RGB10_UNORM_ANGLEX", "R10G10B10X2_UNORM" ]
]
......@@ -134,6 +134,8 @@ def get_channel_struct(angle_format):
struct_name += 'D{}'.format(bits['D']) + component_suffix
if channel == 's':
struct_name += 'S{}'.format(bits['S'])
if channel == 'x':
struct_name += 'X{}'.format(bits['X'])
if not is_depth_stencil(angle_format):
struct_name += component_suffix
......
......@@ -209,6 +209,11 @@
"GL_UNSIGNED_INT_2_10_10_10_REV": "LoadToNative<GLuint, 1>"
}
},
"GL_RGB10_UNORM_ANGLEX": {
"R10G10B10A2_UNORM": {
"GL_UNSIGNED_INT_2_10_10_10_REV": "LoadRGB10A2ToRGB10X2"
}
},
"GL_COMPRESSED_SIGNED_RG11_EAC": {
"R16G16_SNORM": {
"GL_UNSIGNED_BYTE": "LoadEACRG11SToRG16"
......
......@@ -2180,6 +2180,18 @@ LoadImageFunctionInfo RGB10_A2_USCALED_ANGLEX_to_default(GLenum type)
}
}
LoadImageFunctionInfo RGB10_UNORM_ANGLEX_to_R10G10B10A2_UNORM(GLenum type)
{
switch (type)
{
case GL_UNSIGNED_INT_2_10_10_10_REV:
return LoadImageFunctionInfo(LoadRGB10A2ToRGB10X2, true);
default:
UNREACHABLE();
return LoadImageFunctionInfo(UnreachableLoadFunction, true);
}
}
LoadImageFunctionInfo RGB16F_to_R16G16B16A16_FLOAT(GLenum type)
{
switch (type)
......@@ -3778,6 +3790,17 @@ LoadFunctionMap GetLoadFunctionsMap(GLenum internalFormat, FormatID angleFormat)
return RGB10_A2_SSCALED_ANGLEX_to_default;
case GL_RGB10_A2_USCALED_ANGLEX:
return RGB10_A2_USCALED_ANGLEX_to_default;
case GL_RGB10_UNORM_ANGLEX:
{
switch (angleFormat)
{
case FormatID::R10G10B10A2_UNORM:
return RGB10_UNORM_ANGLEX_to_R10G10B10A2_UNORM;
default:
break;
}
break;
}
case GL_RGB16F:
{
switch (angleFormat)
......
......@@ -60,6 +60,9 @@ void RendererVk::ensureCapsInitialized() const
mNativeExtensions.translatedShaderSource = true;
mNativeExtensions.discardFramebuffer = true;
// Enable EXT_texture_type_2_10_10_10_REV
mNativeExtensions.textureFormat2101010REV = true;
// Enable EXT_blend_minmax
mNativeExtensions.blendMinMax = true;
......
......@@ -268,6 +268,10 @@
},
"R32G32B32A32_SSCALED": {
"buffer": "R32G32B32A32_FLOAT"
},
"R10G10B10X2_UNORM": {
"buffer": "NONE",
"image": "R10G10B10A2_UNORM"
}
},
"fallbacks": {
......
......@@ -1100,6 +1100,18 @@ void Format::initialize(RendererVk *renderer, const angle::Format &angleFormat)
}
break;
case angle::FormatID::R10G10B10X2_UNORM:
internalFormat = GL_RGB10_UNORM_ANGLEX;
imageFormatID = angle::FormatID::R10G10B10A2_UNORM;
vkImageFormat = VK_FORMAT_A2B10G10R10_UNORM_PACK32;
imageInitializerFunction = nullptr;
bufferFormatID = angle::FormatID::NONE;
vkBufferFormat = VK_FORMAT_UNDEFINED;
vkBufferFormatIsPacked = false;
vertexLoadFunction = nullptr;
vertexLoadRequiresConversion = true;
break;
case angle::FormatID::R11G11B10_FLOAT:
internalFormat = GL_R11F_G11F_B10F;
imageFormatID = angle::FormatID::R11G11B10_FLOAT;
......
......@@ -1349,6 +1349,13 @@ bool ValidateES2TexImageParametersBase(Context *context,
case GL_HALF_FLOAT_OES:
case GL_FLOAT:
break;
case GL_UNSIGNED_INT_2_10_10_10_REV_EXT:
if (!context->getExtensions().textureFormat2101010REV)
{
context->validationError(GL_INVALID_ENUM, kEnumNotSupported);
return false;
}
break;
default:
context->validationError(GL_INVALID_ENUM, kInvalidType);
return false;
......@@ -1402,6 +1409,7 @@ bool ValidateES2TexImageParametersBase(Context *context,
{
case GL_UNSIGNED_BYTE:
case GL_UNSIGNED_SHORT_5_6_5:
case GL_UNSIGNED_INT_2_10_10_10_REV_EXT:
case GL_FLOAT:
case GL_HALF_FLOAT_OES:
break;
......@@ -1418,6 +1426,7 @@ bool ValidateES2TexImageParametersBase(Context *context,
case GL_UNSIGNED_SHORT_5_5_5_1:
case GL_FLOAT:
case GL_HALF_FLOAT_OES:
case GL_UNSIGNED_INT_2_10_10_10_REV_EXT:
break;
default:
context->validationError(GL_INVALID_OPERATION, kMismatchedTypeAndFormat);
......@@ -1685,6 +1694,32 @@ bool ValidateES2TexImageParametersBase(Context *context,
}
break;
case GL_RGB10_A2_EXT:
if (!context->getExtensions().textureFormat2101010REV)
{
context->validationError(GL_INVALID_ENUM, kEnumNotSupported);
return false;
}
if (type != GL_UNSIGNED_INT_2_10_10_10_REV_EXT || format != GL_RGBA)
{
context->validationError(GL_INVALID_OPERATION, kMismatchedTypeAndFormat);
return false;
}
nonEqualFormatsAllowed = true;
break;
case GL_RGB5_A1:
if (context->getExtensions().textureFormat2101010REV &&
type == GL_UNSIGNED_INT_2_10_10_10_REV_EXT && format == GL_RGBA)
{
nonEqualFormatsAllowed = true;
}
break;
default:
context->validationError(GL_INVALID_VALUE, kInvalidInternalFormat);
return false;
......
......@@ -385,6 +385,17 @@ TEST_P(TextureUploadFormatTest, All)
fnTest({GL_RGB10_A2, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV}, {1, 1, 1, 128});
fnTest({GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV}, {8, 8, 8, 255});
fnTest({GL_RGBA, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV}, {1, 1, 1, 128});
}
// RGB+UNSIGNED_INT_2_10_10_10_REV
{
constexpr uint32_t src[] = {
(EncodeNormUint<10>(srcVals[0]) << 0) | (EncodeNormUint<10>(srcVals[1]) << 10) |
(EncodeNormUint<10>(srcVals[2]) << 20) | (EncodeNormUint<2>(srcVals[3]) << 30)};
ZeroAndCopy(srcBuffer, src);
fnTest({GL_RGB, GL_RGB, GL_UNSIGNED_INT_2_10_10_10_REV}, {1, 1, 1, 0});
}
// DEPTH_COMPONENT+UNSIGNED_SHORT
......
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