Commit 1850492e by Mohan Maiya Committed by Commit Bot

Vulkan: Disable OES_vertex_type_10_10_10_2 on GLES 2.0

- Because of the difference in the SNORM to FLOAT conversion formula between GLES 2.0 and 3.0, OES_vertex_type_10_10_10_2 is disabled when the context version is lower than 3.0. - Modify test conversion formula to be compliant with GLES 3.0 equation Bug: angleproject:3868 Test: angle_end2end_tests --gtest_filter=VertexAttributeTest*Packed*Vulkan Change-Id: I8b85d8146ee05353bc40fa0022f05d6634c33110 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1792197 Commit-Queue: Mohan Maiya <m.maiya@samsung.com> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 2328d65a
......@@ -110,9 +110,9 @@
"src/libANGLE/renderer/vulkan/shaders/gen/ConvertVertex.comp.00000007.inc":
"bb62a58562d954c5a0946c291c2afca2",
"src/libANGLE/renderer/vulkan/shaders/gen/ConvertVertex.comp.00000008.inc":
"b5340976023d009e8c80aa9798ac7680",
"5228214dc4d40eebed9b66806d604ef0",
"src/libANGLE/renderer/vulkan/shaders/gen/ConvertVertex.comp.00000009.inc":
"cdcabde7e530a7030d377f3a01a78fec",
"18cf63360b3030cb637dd1129bd04e6b",
"src/libANGLE/renderer/vulkan/shaders/gen/ConvertVertex.comp.0000000A.inc":
"61b2ac99ab77bea128bfe97dd34b4fa7",
"src/libANGLE/renderer/vulkan/shaders/gen/ConvertVertex.comp.0000000B.inc":
......@@ -142,9 +142,9 @@
"src/libANGLE/renderer/vulkan/shaders/gen/ConvertVertex.comp.00000017.inc":
"c9a4c3100ce405279425855655f1ef50",
"src/libANGLE/renderer/vulkan/shaders/gen/ConvertVertex.comp.00000018.inc":
"ccbcd91094e7e9308573b3033f674e2c",
"5f2b521b8c31ecf08d2776c554c0c699",
"src/libANGLE/renderer/vulkan/shaders/gen/ConvertVertex.comp.00000019.inc":
"628e93148792a85a1fa0c688e1686a1d",
"4b364dc33cf595d2fa382b9321f48dbc",
"src/libANGLE/renderer/vulkan/shaders/gen/ConvertVertex.comp.0000001A.inc":
"ee4f06ba87a3dde490e01a0ec4561e10",
"src/libANGLE/renderer/vulkan/shaders/gen/ConvertVertex.comp.0000001B.inc":
......@@ -154,9 +154,9 @@
"src/libANGLE/renderer/vulkan/shaders/gen/ConvertVertex.comp.0000001D.inc":
"72bbe32670195bcf4be9d1edd8152178",
"src/libANGLE/renderer/vulkan/shaders/gen/ConvertVertex.comp.0000001E.inc":
"6c4b93206f5b905fc384f9ea629ab91d",
"e5131c8ba46eaf2674aad854eb3bc787",
"src/libANGLE/renderer/vulkan/shaders/gen/ConvertVertex.comp.0000001F.inc":
"e6269fe4949548993371aaef33c63dda",
"45f2705df7389be715506e9c3e484d74",
"src/libANGLE/renderer/vulkan/shaders/gen/ConvertVertex.comp.00000020.inc":
"d79651c76fdfefb0949ae18e006a6d22",
"src/libANGLE/renderer/vulkan/shaders/gen/ConvertVertex.comp.00000021.inc":
......@@ -170,9 +170,9 @@
"src/libANGLE/renderer/vulkan/shaders/gen/ConvertVertex.comp.00000025.inc":
"25b270092f8e6a1bfeb3c6f5e441d792",
"src/libANGLE/renderer/vulkan/shaders/gen/ConvertVertex.comp.00000026.inc":
"5c71117a27b9b60653453a2a72a90cb5",
"a77252550fef5aa63bb49faecb6de265",
"src/libANGLE/renderer/vulkan/shaders/gen/ConvertVertex.comp.00000027.inc":
"757a459d8b68e2c5e74c596ffbeecee5",
"1bac85ed8b670bbe4b68ffa4064bf31f",
"src/libANGLE/renderer/vulkan/shaders/gen/ConvertVertex.comp.00000028.inc":
"d6cfcf49825f3da242d0f8935b0e30f6",
"src/libANGLE/renderer/vulkan/shaders/gen/ConvertVertex.comp.00000029.inc":
......@@ -294,7 +294,7 @@
"src/libANGLE/renderer/vulkan/shaders/src/ConvertIndexIndirectLineLoop.comp":
"a543a28fc1fe53eefd5949ee3b4428f3",
"src/libANGLE/renderer/vulkan/shaders/src/ConvertVertex.comp":
"88d434e43a01906e6a6b1dd5d5e45cdc",
"6d034ff271e17c0a4f8a12b8eec2970d",
"src/libANGLE/renderer/vulkan/shaders/src/FullScreenQuad.vert":
"805ec8b2f87d4bd4242dc5b1c58ba3b4",
"src/libANGLE/renderer/vulkan/shaders/src/ImageClear.frag":
......
......@@ -824,7 +824,7 @@ const ExtensionInfoMap &GetExtensionInfoMap()
map["GL_EXT_color_buffer_float"] = enableableExtension(&Extensions::colorBufferFloat);
map["GL_OES_vertex_half_float"] = enableableExtension(&Extensions::vertexHalfFloat);
map["GL_OES_vertex_array_object"] = enableableExtension(&Extensions::vertexArrayObject);
map["GL_OES_vertex_type_10_10_10_2"] = enableableExtension(&Extensions::vertexAttribType101010102);
map["GL_OES_vertex_type_10_10_10_2"] = enableableExtension(&Extensions::vertexAttribType1010102);
map["GL_KHR_debug"] = esOnlyExtension(&Extensions::debug);
map["GL_OES_texture_border_clamp"] = enableableExtension(&Extensions::textureBorderClamp);
// TODO(jmadill): Enable this when complete.
......
......@@ -386,7 +386,7 @@ struct Extensions
bool vertexArrayObject = false;
// GL_OES_vertex_type_10_10_10_2
bool vertexAttribType101010102 = false;
bool vertexAttribType1010102 = false;
// GL_KHR_debug
bool debug = false;
......
......@@ -3283,6 +3283,11 @@ Extensions Context::generateSupportedExtensions() const
supportedExtensions.textureFloatLinear = false;
supportedExtensions.textureHalfFloatLinear = false;
}
// Because of the difference in the SNORM to FLOAT conversion formula
// between GLES 2.0 and 3.0, vertex type 10_10_10_2 is disabled
// when the context version is lower than 3.0
supportedExtensions.vertexAttribType1010102 = false;
}
if (getClientVersion() < ES_3_1)
......@@ -9351,9 +9356,9 @@ void StateCache::updateVertexAttribTypesValidation(Context *context)
? VertexAttribTypeCase::Valid
: VertexAttribTypeCase::Invalid;
VertexAttribTypeCase vertexType101010102Validity =
(context->getExtensions().vertexAttribType101010102) ? VertexAttribTypeCase::ValidSize3or4
: VertexAttribTypeCase::Invalid;
VertexAttribTypeCase vertexType1010102Validity =
(context->getExtensions().vertexAttribType1010102) ? VertexAttribTypeCase::ValidSize3or4
: VertexAttribTypeCase::Invalid;
if (context->getClientMajorVersion() <= 2)
{
......@@ -9365,8 +9370,6 @@ void StateCache::updateVertexAttribTypesValidation(Context *context)
{VertexAttribType::Float, VertexAttribTypeCase::Valid},
{VertexAttribType::Fixed, VertexAttribTypeCase::Valid},
{VertexAttribType::HalfFloatOES, halfFloatValidity},
{VertexAttribType::Int1010102, vertexType101010102Validity},
{VertexAttribType::UnsignedInt1010102, vertexType101010102Validity},
}};
}
else
......@@ -9384,8 +9387,8 @@ void StateCache::updateVertexAttribTypesValidation(Context *context)
{VertexAttribType::Int2101010, VertexAttribTypeCase::ValidSize4Only},
{VertexAttribType::HalfFloatOES, halfFloatValidity},
{VertexAttribType::UnsignedInt2101010, VertexAttribTypeCase::ValidSize4Only},
{VertexAttribType::Int1010102, vertexType101010102Validity},
{VertexAttribType::UnsignedInt1010102, vertexType101010102Validity},
{VertexAttribType::Int1010102, vertexType1010102Validity},
{VertexAttribType::UnsignedInt1010102, vertexType1010102Validity},
}};
mCachedIntegerVertexAttribTypesValidation = {{
......
......@@ -50,6 +50,18 @@ void CopyXYZ10W2ToXYZW32FVertexData(const uint8_t *input,
size_t count,
uint8_t *output);
template <bool isSigned, bool normalized>
void CopyXYZ10ToXYZW32FVertexData(const uint8_t *input,
size_t stride,
size_t count,
uint8_t *output);
template <bool isSigned, bool normalized>
void CopyW2XYZ10ToXYZW32FVertexData(const uint8_t *input,
size_t stride,
size_t count,
uint8_t *output);
} // namespace rx
#include "copyvertex.inc.h"
......
......@@ -193,8 +193,8 @@ inline void CopyTo32FVertexData(const uint8_t *input, size_t stride, size_t coun
{
if (NL::is_signed)
{
const float divisor = 1.0f / (2 * static_cast<float>(NL::max()) + 1);
offsetOutput[j] = (2 * static_cast<float>(offsetInput[j]) + 1) * divisor;
offsetOutput[j] = static_cast<float>(offsetInput[j]) / NL::max();
offsetOutput[j] = (offsetOutput[j] >= -1.0f) ? (offsetOutput[j]) : (-1.0f);
}
else
{
......
......@@ -285,7 +285,8 @@ SrcType loadSourceComponent(uint cd)
valueAsUint |= signExtension;
}
int valueAsInt = int(valueAsUint);
SrcType value = (2 * float(valueAsInt) + 1) / valueMask;
SrcType value = float(valueAsInt) / (valueMask >> 1);
value = max(value, float(-1));
#elif UnormToFloat || RGB10A2UnormToFloat || RGB10X2UnormToFloat
float positiveMax = valueMask;
// Scale [0, P] to [0, 1]
......
......@@ -92,7 +92,7 @@ void RendererVk::ensureCapsInitialized() const
mNativeExtensions.eglSync = true;
mNativeExtensions.vertexAttribType101010102 = true;
mNativeExtensions.vertexAttribType1010102 = true;
// We use secondary command buffers almost everywhere and they require a feature to be
// able to execute in the presence of queries. As a result, we won't support queries
......
......@@ -100,9 +100,15 @@ GLfloat Normalize2(T value)
{
static_assert(std::is_integral<T>::value, "Integer required.");
if (std::is_signed<T>::value)
return static_cast<float>(value * 2 + 1) / 3.0f;
{
GLfloat outputValue = static_cast<float>(value) / 1.0f;
outputValue = (outputValue >= -1.0f) ? (outputValue) : (-1.0f);
return outputValue;
}
else
{
return static_cast<float>(value) / 3.0f;
}
}
template <typename DestT, typename SrcT>
......@@ -792,6 +798,8 @@ TEST_P(VertexAttributeTest, SignedPacked1010102ExtensionNormalized)
expectedNormalizedTypeSize4[i * 4 + 3] = Normalize2<GLshort>(unpackedInput[i][3]);
}
TestData data4(GL_INT_10_10_10_2_OES, GL_TRUE, Source::IMMEDIATE, packedInput.data(),
expectedNormalizedTypeSize4.data());
TestData bufferedData4(GL_INT_10_10_10_2_OES, GL_TRUE, Source::BUFFER, packedInput.data(),
expectedNormalizedTypeSize4.data());
TestData data3(GL_INT_10_10_10_2_OES, GL_TRUE, Source::IMMEDIATE, packedInput.data(),
......@@ -799,8 +807,8 @@ TEST_P(VertexAttributeTest, SignedPacked1010102ExtensionNormalized)
TestData bufferedData3(GL_INT_10_10_10_2_OES, GL_TRUE, Source::BUFFER, packedInput.data(),
expectedNormalizedTypeSize3.data());
std::array<std::pair<const TestData &, GLint>, 3> dataSet = {
{{bufferedData4, 4}, {data3, 3}, {bufferedData3, 3}}};
std::array<std::pair<const TestData &, GLint>, 4> dataSet = {
{{data4, 4}, {bufferedData4, 4}, {data3, 3}, {bufferedData3, 3}}};
for (auto data : dataSet)
{
......
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