diff options
Diffstat (limited to 'chromium/third_party/angle/src/common')
26 files changed, 714 insertions, 147 deletions
diff --git a/chromium/third_party/angle/src/common/PackedEnums.cpp b/chromium/third_party/angle/src/common/PackedEnums.cpp index aeb80238cf5..364b69dfb4a 100644 --- a/chromium/third_party/angle/src/common/PackedEnums.cpp +++ b/chromium/third_party/angle/src/common/PackedEnums.cpp @@ -24,6 +24,8 @@ TextureType TextureTargetToType(TextureTarget target) case TextureTarget::CubeMapPositiveY: case TextureTarget::CubeMapPositiveZ: return TextureType::CubeMap; + case TextureTarget::CubeMapArray: + return TextureType::CubeMapArray; case TextureTarget::External: return TextureType::External; case TextureTarget::Rectangle: @@ -71,6 +73,8 @@ TextureTarget NonCubeTextureTypeToTarget(TextureType type) return TextureTarget::_2DMultisampleArray; case TextureType::_3D: return TextureTarget::_3D; + case TextureType::CubeMapArray: + return TextureTarget::CubeMapArray; case TextureType::VideoImage: return TextureTarget::VideoImage; default: @@ -132,6 +136,12 @@ TextureType SamplerTypeToTextureType(GLenum samplerType) case GL_SAMPLER_CUBE_SHADOW: return TextureType::CubeMap; + case GL_SAMPLER_CUBE_MAP_ARRAY: + case GL_INT_SAMPLER_CUBE_MAP_ARRAY: + case GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY: + case GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW: + return TextureType::CubeMapArray; + case GL_SAMPLER_2D_ARRAY: case GL_INT_SAMPLER_2D_ARRAY: case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY: @@ -183,6 +193,7 @@ bool IsArrayTextureType(TextureType type) { case TextureType::_2DArray: case TextureType::_2DMultisampleArray: + case TextureType::CubeMapArray: return true; default: return false; diff --git a/chromium/third_party/angle/src/common/PackedGLEnums_autogen.cpp b/chromium/third_party/angle/src/common/PackedGLEnums_autogen.cpp index ee8bf4600e8..be0d8801a28 100644 --- a/chromium/third_party/angle/src/common/PackedGLEnums_autogen.cpp +++ b/chromium/third_party/angle/src/common/PackedGLEnums_autogen.cpp @@ -1993,6 +1993,8 @@ TextureTarget FromGLenum<TextureTarget>(GLenum from) return TextureTarget::CubeMapPositiveZ; case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: return TextureTarget::CubeMapNegativeZ; + case GL_TEXTURE_CUBE_MAP_ARRAY: + return TextureTarget::CubeMapArray; case GL_TEXTURE_VIDEO_IMAGE_WEBGL: return TextureTarget::VideoImage; default: @@ -2030,6 +2032,8 @@ GLenum ToGLenum(TextureTarget from) return GL_TEXTURE_CUBE_MAP_POSITIVE_Z; case TextureTarget::CubeMapNegativeZ: return GL_TEXTURE_CUBE_MAP_NEGATIVE_Z; + case TextureTarget::CubeMapArray: + return GL_TEXTURE_CUBE_MAP_ARRAY; case TextureTarget::VideoImage: return GL_TEXTURE_VIDEO_IMAGE_WEBGL; default: @@ -2081,6 +2085,9 @@ std::ostream &operator<<(std::ostream &os, TextureTarget value) case TextureTarget::CubeMapNegativeZ: os << "GL_TEXTURE_CUBE_MAP_NEGATIVE_Z"; break; + case TextureTarget::CubeMapArray: + os << "GL_TEXTURE_CUBE_MAP_ARRAY"; + break; case TextureTarget::VideoImage: os << "GL_TEXTURE_VIDEO_IMAGE_WEBGL"; break; @@ -2112,6 +2119,8 @@ TextureType FromGLenum<TextureType>(GLenum from) return TextureType::Rectangle; case GL_TEXTURE_CUBE_MAP: return TextureType::CubeMap; + case GL_TEXTURE_CUBE_MAP_ARRAY: + return TextureType::CubeMapArray; case GL_TEXTURE_VIDEO_IMAGE_WEBGL: return TextureType::VideoImage; default: @@ -2139,6 +2148,8 @@ GLenum ToGLenum(TextureType from) return GL_TEXTURE_RECTANGLE_ANGLE; case TextureType::CubeMap: return GL_TEXTURE_CUBE_MAP; + case TextureType::CubeMapArray: + return GL_TEXTURE_CUBE_MAP_ARRAY; case TextureType::VideoImage: return GL_TEXTURE_VIDEO_IMAGE_WEBGL; default: @@ -2175,6 +2186,9 @@ std::ostream &operator<<(std::ostream &os, TextureType value) case TextureType::CubeMap: os << "GL_TEXTURE_CUBE_MAP"; break; + case TextureType::CubeMapArray: + os << "GL_TEXTURE_CUBE_MAP_ARRAY"; + break; case TextureType::VideoImage: os << "GL_TEXTURE_VIDEO_IMAGE_WEBGL"; break; diff --git a/chromium/third_party/angle/src/common/PackedGLEnums_autogen.h b/chromium/third_party/angle/src/common/PackedGLEnums_autogen.h index 6be5f87c1ba..2affe18ebad 100644 --- a/chromium/third_party/angle/src/common/PackedGLEnums_autogen.h +++ b/chromium/third_party/angle/src/common/PackedGLEnums_autogen.h @@ -515,10 +515,11 @@ enum class TextureTarget : uint8_t CubeMapNegativeY = 10, CubeMapPositiveZ = 11, CubeMapNegativeZ = 12, - VideoImage = 13, + CubeMapArray = 13, + VideoImage = 14, - InvalidEnum = 14, - EnumCount = 14, + InvalidEnum = 15, + EnumCount = 15, }; template <> @@ -536,10 +537,11 @@ enum class TextureType : uint8_t External = 5, Rectangle = 6, CubeMap = 7, - VideoImage = 8, + CubeMapArray = 8, + VideoImage = 9, - InvalidEnum = 9, - EnumCount = 9, + InvalidEnum = 10, + EnumCount = 10, }; template <> diff --git a/chromium/third_party/angle/src/common/PoolAlloc.cpp b/chromium/third_party/angle/src/common/PoolAlloc.cpp index 724e07e0668..27dd9305a8b 100644 --- a/chromium/third_party/angle/src/common/PoolAlloc.cpp +++ b/chromium/third_party/angle/src/common/PoolAlloc.cpp @@ -37,7 +37,14 @@ PoolAllocator::PoolAllocator(int growthIncrement, int allocationAlignment) #endif mLocked(false) { + initialize(growthIncrement, allocationAlignment); +} + +void PoolAllocator::initialize(int pageSize, int alignment) +{ + mAlignment = alignment; #if !defined(ANGLE_DISABLE_POOL_ALLOC) + mPageSize = pageSize; if (mAlignment == 1) { // This is a special fast-path where fastAllocation() is enabled diff --git a/chromium/third_party/angle/src/common/PoolAlloc.h b/chromium/third_party/angle/src/common/PoolAlloc.h index 1c902bfdd75..df55a2755f0 100644 --- a/chromium/third_party/angle/src/common/PoolAlloc.h +++ b/chromium/third_party/angle/src/common/PoolAlloc.h @@ -125,7 +125,7 @@ class PoolAllocator : angle::NonCopyable public: static const int kDefaultAlignment = 16; // - // Create PoolAllocator. If alignment is be set to 1 byte then fastAllocate() + // Create PoolAllocator. If alignment is set to 1 byte then fastAllocate() // function can be used to make allocations with less overhead. // PoolAllocator(int growthIncrement = 8 * 1024, int allocationAlignment = kDefaultAlignment); @@ -136,6 +136,11 @@ class PoolAllocator : angle::NonCopyable ~PoolAllocator(); // + // Initialize page size and alignment after construction + // + void initialize(int pageSize, int alignment); + + // // Call push() to establish a new place to pop memory to. Does not // have to be called to get things started. // diff --git a/chromium/third_party/angle/src/common/event_tracer.h b/chromium/third_party/angle/src/common/event_tracer.h index 750f9efc070..128d88b9e0d 100644 --- a/chromium/third_party/angle/src/common/event_tracer.h +++ b/chromium/third_party/angle/src/common/event_tracer.h @@ -6,7 +6,7 @@ #define COMMON_EVENT_TRACER_H_ #include "common/platform.h" -#include "platform/Platform.h" +#include "platform/PlatformMethods.h" namespace angle { diff --git a/chromium/third_party/angle/src/common/gen_uniform_type_table.py b/chromium/third_party/angle/src/common/gen_uniform_type_table.py index eeee30be35c..faa87e698b4 100644 --- a/chromium/third_party/angle/src/common/gen_uniform_type_table.py +++ b/chromium/third_party/angle/src/common/gen_uniform_type_table.py @@ -16,19 +16,23 @@ all_uniform_types = [ "GL_FLOAT_MAT2", "GL_FLOAT_MAT2x3", "GL_FLOAT_MAT2x4", "GL_FLOAT_MAT3", "GL_FLOAT_MAT3x2", "GL_FLOAT_MAT3x4", "GL_FLOAT_MAT4", "GL_FLOAT_MAT4x2", "GL_FLOAT_MAT4x3", "GL_FLOAT_VEC2", "GL_FLOAT_VEC3", "GL_FLOAT_VEC4", "GL_IMAGE_2D", "GL_IMAGE_2D_ARRAY", "GL_IMAGE_3D", - "GL_IMAGE_CUBE", "GL_INT", "GL_INT_IMAGE_2D", "GL_INT_IMAGE_2D_ARRAY", "GL_INT_IMAGE_3D", - "GL_INT_IMAGE_CUBE", "GL_INT_SAMPLER_2D", "GL_INT_SAMPLER_2D_ARRAY", - "GL_INT_SAMPLER_2D_MULTISAMPLE", "GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY", "GL_INT_SAMPLER_3D", - "GL_INT_SAMPLER_CUBE", "GL_INT_VEC2", "GL_INT_VEC3", "GL_INT_VEC4", "GL_SAMPLER_2D", + "GL_IMAGE_CUBE", "GL_IMAGE_CUBE_MAP_ARRAY", "GL_INT", "GL_INT_IMAGE_2D", + "GL_INT_IMAGE_2D_ARRAY", "GL_INT_IMAGE_3D", "GL_INT_IMAGE_CUBE", "GL_INT_IMAGE_CUBE_MAP_ARRAY", + "GL_INT_SAMPLER_2D", "GL_INT_SAMPLER_2D_ARRAY", "GL_INT_SAMPLER_2D_MULTISAMPLE", + "GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY", "GL_INT_SAMPLER_3D", "GL_INT_SAMPLER_CUBE", + "GL_INT_SAMPLER_CUBE_MAP_ARRAY", "GL_INT_VEC2", "GL_INT_VEC3", "GL_INT_VEC4", "GL_SAMPLER_2D", "GL_SAMPLER_2D_ARRAY", "GL_SAMPLER_2D_ARRAY_SHADOW", "GL_SAMPLER_2D_MULTISAMPLE", "GL_SAMPLER_2D_MULTISAMPLE_ARRAY", "GL_SAMPLER_2D_RECT_ANGLE", "GL_SAMPLER_2D_SHADOW", - "GL_SAMPLER_3D", "GL_SAMPLER_CUBE", "GL_SAMPLER_CUBE_SHADOW", "GL_SAMPLER_EXTERNAL_OES", - "GL_UNSIGNED_INT", "GL_UNSIGNED_INT_ATOMIC_COUNTER", "GL_UNSIGNED_INT_IMAGE_2D", - "GL_UNSIGNED_INT_IMAGE_2D_ARRAY", "GL_UNSIGNED_INT_IMAGE_3D", "GL_UNSIGNED_INT_IMAGE_CUBE", - "GL_UNSIGNED_INT_SAMPLER_2D", "GL_UNSIGNED_INT_SAMPLER_2D_ARRAY", - "GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE", "GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY", - "GL_UNSIGNED_INT_SAMPLER_3D", "GL_UNSIGNED_INT_SAMPLER_CUBE", "GL_UNSIGNED_INT_VEC2", - "GL_UNSIGNED_INT_VEC3", "GL_UNSIGNED_INT_VEC4", "GL_SAMPLER_VIDEO_IMAGE_WEBGL" + "GL_SAMPLER_3D", "GL_SAMPLER_CUBE", "GL_SAMPLER_CUBE_MAP_ARRAY", "GL_SAMPLER_CUBE_SHADOW", + "GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW", "GL_SAMPLER_EXTERNAL_OES", "GL_UNSIGNED_INT", + "GL_UNSIGNED_INT_ATOMIC_COUNTER", "GL_UNSIGNED_INT_IMAGE_2D", "GL_UNSIGNED_INT_IMAGE_2D_ARRAY", + "GL_UNSIGNED_INT_IMAGE_3D", "GL_UNSIGNED_INT_IMAGE_CUBE", + "GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY", "GL_UNSIGNED_INT_SAMPLER_2D", + "GL_UNSIGNED_INT_SAMPLER_2D_ARRAY", "GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE", + "GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY", "GL_UNSIGNED_INT_SAMPLER_3D", + "GL_UNSIGNED_INT_SAMPLER_CUBE", "GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY", + "GL_UNSIGNED_INT_VEC2", "GL_UNSIGNED_INT_VEC3", "GL_UNSIGNED_INT_VEC4", + "GL_SAMPLER_VIDEO_IMAGE_WEBGL" ] # Uniform texture types. Be wary of substrings finding the wrong types. @@ -46,6 +50,7 @@ texture_types = { "CUBE_SHADOW": "CUBE_MAP", "EXTERNAL_OES": "EXTERNAL_OES", "RECT": "RECTANGLE", + "CUBE_MAP_ARRAY": "CUBE_MAP_ARRAY", "VIDEO_IMAGE_WEBGL": "VIDEO_IMAGE_WEBGL", } diff --git a/chromium/third_party/angle/src/common/mathutil.h b/chromium/third_party/angle/src/common/mathutil.h index f47d2175744..b1388fdd1a5 100644 --- a/chromium/third_party/angle/src/common/mathutil.h +++ b/chromium/third_party/angle/src/common/mathutil.h @@ -504,6 +504,7 @@ inline float normalizedToFloat(T input) { static_assert(std::numeric_limits<T>::is_integer, "T must be an integer."); static_assert(inputBitCount < (sizeof(T) * 8), "T must have more bits than inputBitCount."); + ASSERT((input & ~((1 << inputBitCount) - 1)) == 0); if (inputBitCount > 23) { diff --git a/chromium/third_party/angle/src/common/packed_gl_enums.json b/chromium/third_party/angle/src/common/packed_gl_enums.json index 3c38c6e0241..1bdd50955b9 100644 --- a/chromium/third_party/angle/src/common/packed_gl_enums.json +++ b/chromium/third_party/angle/src/common/packed_gl_enums.json @@ -188,6 +188,7 @@ "External": "GL_TEXTURE_EXTERNAL_OES", "Rectangle": "GL_TEXTURE_RECTANGLE_ANGLE", "CubeMap": "GL_TEXTURE_CUBE_MAP", + "CubeMapArray": "GL_TEXTURE_CUBE_MAP_ARRAY", "VideoImage": "GL_TEXTURE_VIDEO_IMAGE_WEBGL" }, "TextureTarget": @@ -205,6 +206,7 @@ "CubeMapNegativeY": "GL_TEXTURE_CUBE_MAP_NEGATIVE_Y", "CubeMapPositiveZ": "GL_TEXTURE_CUBE_MAP_POSITIVE_Z", "CubeMapNegativeZ": "GL_TEXTURE_CUBE_MAP_NEGATIVE_Z", + "CubeMapArray": "GL_TEXTURE_CUBE_MAP_ARRAY", "VideoImage": "GL_TEXTURE_VIDEO_IMAGE_WEBGL" }, "VertexArrayType": diff --git a/chromium/third_party/angle/src/common/string_utils.cpp b/chromium/third_party/angle/src/common/string_utils.cpp index a693e21cc5d..7fe3bfa41b0 100644 --- a/chromium/third_party/angle/src/common/string_utils.cpp +++ b/chromium/third_party/angle/src/common/string_utils.cpp @@ -18,6 +18,19 @@ #include "common/platform.h" #include "common/system_utils.h" +namespace +{ + +bool EndsWithSuffix(const char *str, + const size_t strLen, + const char *suffix, + const size_t suffixLen) +{ + return suffixLen <= strLen && strncmp(str + strLen - suffixLen, suffix, suffixLen) == 0; +} + +} // anonymous namespace + namespace angle { @@ -178,15 +191,19 @@ bool BeginsWith(const std::string &str, const std::string &prefix, const size_t return strncmp(str.c_str(), prefix.c_str(), prefixLength) == 0; } -bool EndsWith(const std::string &str, const char *suffix) +bool EndsWith(const std::string &str, const std::string &suffix) { - const auto len = strlen(suffix); - if (len > str.size()) - return false; + return EndsWithSuffix(str.c_str(), str.length(), suffix.c_str(), suffix.length()); +} - const char *end = str.c_str() + str.size() - len; +bool EndsWith(const std::string &str, const char *suffix) +{ + return EndsWithSuffix(str.c_str(), str.length(), suffix, strlen(suffix)); +} - return memcmp(end, suffix, len) == 0; +bool EndsWith(const char *str, const char *suffix) +{ + return EndsWithSuffix(str, strlen(str), suffix, strlen(suffix)); } void ToLower(std::string *str) diff --git a/chromium/third_party/angle/src/common/string_utils.h b/chromium/third_party/angle/src/common/string_utils.h index 540a423dd89..0b9f8650c02 100644 --- a/chromium/third_party/angle/src/common/string_utils.h +++ b/chromium/third_party/angle/src/common/string_utils.h @@ -69,10 +69,19 @@ bool BeginsWith(const char *str, const char *prefix); bool BeginsWith(const std::string &str, const std::string &prefix, const size_t prefixLength); // Check if the string str ends with the given suffix. -// Suffix may not be NUL and needs to be NULL terminated. +// The comparison is case sensitive. +bool EndsWith(const std::string &str, const std::string &suffix); + +// Check if the string str ends with the given suffix. +// Suffix may not be NULL and needs to be NULL terminated. // The comparison is case sensitive. bool EndsWith(const std::string &str, const char *suffix); +// Check if the string str ends with the given suffix. +// str and suffix may not be NULL and need to be NULL terminated. +// The comparison is case sensitive. +bool EndsWith(const char *str, const char *suffix); + // Convert to lower-case. void ToLower(std::string *str); diff --git a/chromium/third_party/angle/src/common/string_utils_unittest.cpp b/chromium/third_party/angle/src/common/string_utils_unittest.cpp index 04e4b1f5008..f45e78671d4 100644 --- a/chromium/third_party/angle/src/common/string_utils_unittest.cpp +++ b/chromium/third_party/angle/src/common/string_utils_unittest.cpp @@ -202,17 +202,68 @@ TEST_F(BeginsWithTest, Strings) runTest(); } -// Test that EndsWith works correctly. -TEST(EndsWithTest, EndsWith) +class EndsWithTest : public testing::Test { - ASSERT_FALSE(EndsWith("foo", "bar")); - ASSERT_FALSE(EndsWith("", "bar")); - ASSERT_FALSE(EndsWith("foo", "foobar")); - - ASSERT_TRUE(EndsWith("foobar", "bar")); - ASSERT_TRUE(EndsWith("foobar", "")); - ASSERT_TRUE(EndsWith("bar", "bar")); - ASSERT_TRUE(EndsWith("", "")); + public: + EndsWithTest() : mMode(TestMode::CHAR_ARRAY) {} + + enum class TestMode + { + CHAR_ARRAY, + STRING_AND_CHAR_ARRAY, + STRING + }; + + void setMode(TestMode mode) { mMode = mode; } + + bool runEndsWith(const char *str, const char *suffix) + { + if (mMode == TestMode::CHAR_ARRAY) + { + return EndsWith(str, suffix); + } + if (mMode == TestMode::STRING_AND_CHAR_ARRAY) + { + return EndsWith(std::string(str), suffix); + } + return EndsWith(std::string(str), std::string(suffix)); + } + + void runTest() + { + ASSERT_FALSE(EndsWith("foo", "bar")); + ASSERT_FALSE(EndsWith("", "bar")); + ASSERT_FALSE(EndsWith("foo", "foobar")); + + ASSERT_TRUE(EndsWith("foobar", "bar")); + ASSERT_TRUE(EndsWith("foobar", "")); + ASSERT_TRUE(EndsWith("bar", "bar")); + ASSERT_TRUE(EndsWith("", "")); + } + + private: + TestMode mMode; +}; + +// Test that EndsWith works correctly for const char * arguments. +TEST_F(EndsWithTest, CharArrays) +{ + setMode(TestMode::CHAR_ARRAY); + runTest(); +} + +// Test that EndsWith works correctly for std::string and const char * arguments. +TEST_F(EndsWithTest, StringAndCharArray) +{ + setMode(TestMode::STRING_AND_CHAR_ARRAY); + runTest(); +} + +// Test that EndsWith works correctly for std::string arguments. +TEST_F(EndsWithTest, Strings) +{ + setMode(TestMode::STRING); + runTest(); } } // anonymous namespace diff --git a/chromium/third_party/angle/src/common/third_party/base/anglebase/base_export.h b/chromium/third_party/angle/src/common/third_party/base/anglebase/base_export.h index 1af54853368..426047a9927 100644 --- a/chromium/third_party/angle/src/common/third_party/base/anglebase/base_export.h +++ b/chromium/third_party/angle/src/common/third_party/base/anglebase/base_export.h @@ -10,4 +10,4 @@ #define ANGLEBASE_EXPORT -#endif // ANGLEBASE_BASE_EXPORT_H_
\ No newline at end of file +#endif // ANGLEBASE_BASE_EXPORT_H_ diff --git a/chromium/third_party/angle/src/common/third_party/base/anglebase/no_destructor.h b/chromium/third_party/angle/src/common/third_party/base/anglebase/no_destructor.h index de9fc9bf7d0..5090dd9817a 100644 --- a/chromium/third_party/angle/src/common/third_party/base/anglebase/no_destructor.h +++ b/chromium/third_party/angle/src/common/third_party/base/anglebase/no_destructor.h @@ -103,4 +103,4 @@ class NoDestructor } // namespace angle -#endif // ANGLEBASE_NO_DESTRUCTOR_H_
\ No newline at end of file +#endif // ANGLEBASE_NO_DESTRUCTOR_H_ diff --git a/chromium/third_party/angle/src/common/third_party/base/anglebase/sys_byteorder.h b/chromium/third_party/angle/src/common/third_party/base/anglebase/sys_byteorder.h index 43d1777f26f..70d9c275e6c 100644 --- a/chromium/third_party/angle/src/common/third_party/base/anglebase/sys_byteorder.h +++ b/chromium/third_party/angle/src/common/third_party/base/anglebase/sys_byteorder.h @@ -46,4 +46,4 @@ inline uint64_t ByteSwap(uint64_t x) } // namespace angle -#endif // ANGLEBASE_SYS_BYTEORDER_H_
\ No newline at end of file +#endif // ANGLEBASE_SYS_BYTEORDER_H_ diff --git a/chromium/third_party/angle/src/common/tls.cpp b/chromium/third_party/angle/src/common/tls.cpp index 2e5443e8f65..a6c0d04414f 100644 --- a/chromium/third_party/angle/src/common/tls.cpp +++ b/chromium/third_party/angle/src/common/tls.cpp @@ -34,6 +34,8 @@ static vector<DWORD> freeTlsIndices; #endif +bool gUseAndroidOpenGLTlsSlot = false; + TLSIndex CreateTLSIndex() { TLSIndex index; @@ -155,3 +157,10 @@ void *GetTLSValue(TLSIndex index) return pthread_getspecific(index); #endif } + +void SetUseAndroidOpenGLTlsSlot(bool platformTypeVulkan) +{ +#if defined(ANGLE_PLATFORM_ANDROID) + gUseAndroidOpenGLTlsSlot = platformTypeVulkan; +#endif +} diff --git a/chromium/third_party/angle/src/common/tls.h b/chromium/third_party/angle/src/common/tls.h index fbbe19914c5..1032d9ea7e1 100644 --- a/chromium/third_party/angle/src/common/tls.h +++ b/chromium/third_party/angle/src/common/tls.h @@ -9,8 +9,14 @@ #ifndef COMMON_TLS_H_ #define COMMON_TLS_H_ +#include "common/angleutils.h" #include "common/platform.h" +namespace gl +{ +class Context; +} + #ifdef ANGLE_PLATFORM_WINDOWS // TLS does not exist for Windows Store and needs to be emulated @@ -34,6 +40,84 @@ typedef pthread_key_t TLSIndex; # error Unsupported platform. #endif +#if defined(ANGLE_PLATFORM_ANDROID) + +// The following ASM variant provides a much more performant store/retrieve interface +// compared to those provided by the pthread library. These have been derived from code +// in the bionic module of Android -> +// https://cs.android.com/android/platform/superproject/+/master:bionic/libc/platform/bionic/tls.h;l=30 + +# if defined(__aarch64__) +# define ANGLE_ANDROID_GET_GL_TLS() \ + ({ \ + void **__val; \ + __asm__("mrs %0, tpidr_el0" : "=r"(__val)); \ + __val; \ + }) +# elif defined(__arm__) +# define ANGLE_ANDROID_GET_GL_TLS() \ + ({ \ + void **__val; \ + __asm__("mrc p15, 0, %0, c13, c0, 3" : "=r"(__val)); \ + __val; \ + }) +# elif defined(__mips__) +// On mips32r1, this goes via a kernel illegal instruction trap that's +// optimized for v1 +# define ANGLE_ANDROID_GET_GL_TLS() \ + ({ \ + register void **__val asm("v1"); \ + __asm__( \ + ".set push\n" \ + ".set mips32r2\n" \ + "rdhwr %0,$29\n" \ + ".set pop\n" \ + : "=r"(__val)); \ + __val; \ + }) +# elif defined(__i386__) +# define ANGLE_ANDROID_GET_GL_TLS() \ + ({ \ + void **__val; \ + __asm__("movl %%gs:0, %0" : "=r"(__val)); \ + __val; \ + }) +# elif defined(__x86_64__) +# define ANGLE_ANDROID_GET_GL_TLS() \ + ({ \ + void **__val; \ + __asm__("mov %%fs:0, %0" : "=r"(__val)); \ + __val; \ + }) +# else +# error unsupported architecture +# endif + +#endif // ANGLE_PLATFORM_ANDROID + +// - TLS_SLOT_OPENGL and TLS_SLOT_OPENGL_API: These two aren't used by bionic +// itself, but allow the graphics code to access TLS directly rather than +// using the pthread API. +// +// Choose the TLS_SLOT_OPENGL TLS slot with the value that matches value in the header file in +// bionic(tls_defines.h) +constexpr TLSIndex kAndroidOpenGLTlsSlot = 3; + +extern bool gUseAndroidOpenGLTlsSlot; +ANGLE_INLINE bool SetContextToAndroidOpenGLTLSSlot(gl::Context *value) +{ +#if defined(ANGLE_PLATFORM_ANDROID) + if (gUseAndroidOpenGLTlsSlot) + { + ANGLE_ANDROID_GET_GL_TLS()[kAndroidOpenGLTlsSlot] = static_cast<void *>(value); + return true; + } +#endif + return false; +} + +void SetUseAndroidOpenGLTlsSlot(bool platformTypeVulkan); + // TODO(kbr): for POSIX platforms this will have to be changed to take // in a destructor function pointer, to allow the thread-local storage // to be properly deallocated upon thread exit. diff --git a/chromium/third_party/angle/src/common/uniform_type_info_autogen.cpp b/chromium/third_party/angle/src/common/uniform_type_info_autogen.cpp index 739233fcd98..76ef0e75df8 100644 --- a/chromium/third_party/angle/src/common/uniform_type_info_autogen.cpp +++ b/chromium/third_party/angle/src/common/uniform_type_info_autogen.cpp @@ -1,7 +1,7 @@ // GENERATED FILE - DO NOT EDIT. // Generated by gen_uniform_type_table.py. // -// Copyright 2019 The ANGLE Project Authors. All rights reserved. +// Copyright 2020 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // @@ -18,7 +18,7 @@ namespace gl namespace { -constexpr std::array<UniformTypeInfo, 63> kInfoTable = { +constexpr std::array<UniformTypeInfo, 70> kInfoTable = { {{GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, SamplerFormat::InvalidEnum, 0, 0, 0, 0, 0 * 0, 0 * 0, false, false, false, ""}, {GL_BOOL, GL_BOOL, GL_NONE, GL_NONE, GL_NONE, SamplerFormat::InvalidEnum, 1, 1, 1, @@ -65,6 +65,9 @@ constexpr std::array<UniformTypeInfo, 63> kInfoTable = { {GL_IMAGE_CUBE, GL_INT, GL_TEXTURE_CUBE_MAP, GL_NONE, GL_NONE, SamplerFormat::InvalidEnum, 1, 1, 1, sizeof(GLint), sizeof(GLint) * 4, sizeof(GLint) * 1, false, false, true, "intBitsToFloat"}, + {GL_IMAGE_CUBE_MAP_ARRAY, GL_INT, GL_TEXTURE_CUBE_MAP_ARRAY, GL_NONE, GL_NONE, + SamplerFormat::InvalidEnum, 1, 1, 1, sizeof(GLint), sizeof(GLint) * 4, sizeof(GLint) * 1, + false, false, true, "intBitsToFloat"}, {GL_INT, GL_INT, GL_NONE, GL_NONE, GL_BOOL, SamplerFormat::InvalidEnum, 1, 1, 1, sizeof(GLint), sizeof(GLint) * 4, sizeof(GLint) * 1, false, false, false, "intBitsToFloat"}, {GL_INT_IMAGE_2D, GL_INT, GL_TEXTURE_2D, GL_NONE, GL_NONE, SamplerFormat::InvalidEnum, 1, 1, 1, @@ -77,6 +80,9 @@ constexpr std::array<UniformTypeInfo, 63> kInfoTable = { {GL_INT_IMAGE_CUBE, GL_INT, GL_TEXTURE_CUBE_MAP, GL_NONE, GL_NONE, SamplerFormat::InvalidEnum, 1, 1, 1, sizeof(GLint), sizeof(GLint) * 4, sizeof(GLint) * 1, false, false, true, "intBitsToFloat"}, + {GL_INT_IMAGE_CUBE_MAP_ARRAY, GL_INT, GL_TEXTURE_CUBE_MAP_ARRAY, GL_NONE, GL_NONE, + SamplerFormat::InvalidEnum, 1, 1, 1, sizeof(GLint), sizeof(GLint) * 4, sizeof(GLint) * 1, + false, false, true, "intBitsToFloat"}, {GL_INT_SAMPLER_2D, GL_INT, GL_TEXTURE_2D, GL_NONE, GL_NONE, SamplerFormat::Signed, 1, 1, 1, sizeof(GLint), sizeof(GLint) * 4, sizeof(GLint) * 1, true, false, false, "intBitsToFloat"}, {GL_INT_SAMPLER_2D_ARRAY, GL_INT, GL_TEXTURE_2D_ARRAY, GL_NONE, GL_NONE, SamplerFormat::Signed, @@ -93,6 +99,9 @@ constexpr std::array<UniformTypeInfo, 63> kInfoTable = { {GL_INT_SAMPLER_CUBE, GL_INT, GL_TEXTURE_CUBE_MAP, GL_NONE, GL_NONE, SamplerFormat::Signed, 1, 1, 1, sizeof(GLint), sizeof(GLint) * 4, sizeof(GLint) * 1, true, false, false, "intBitsToFloat"}, + {GL_INT_SAMPLER_CUBE_MAP_ARRAY, GL_INT, GL_TEXTURE_CUBE_MAP_ARRAY, GL_NONE, GL_NONE, + SamplerFormat::Signed, 1, 1, 1, sizeof(GLint), sizeof(GLint) * 4, sizeof(GLint) * 1, true, + false, false, "intBitsToFloat"}, {GL_INT_VEC2, GL_INT, GL_NONE, GL_NONE, GL_BOOL_VEC2, SamplerFormat::InvalidEnum, 1, 2, 2, sizeof(GLint), sizeof(GLint) * 4, sizeof(GLint) * 2, false, false, false, "intBitsToFloat"}, {GL_INT_VEC3, GL_INT, GL_NONE, GL_NONE, GL_BOOL_VEC3, SamplerFormat::InvalidEnum, 1, 3, 3, @@ -121,9 +130,15 @@ constexpr std::array<UniformTypeInfo, 63> kInfoTable = { sizeof(GLint), sizeof(GLint) * 4, sizeof(GLint) * 1, true, false, false, "intBitsToFloat"}, {GL_SAMPLER_CUBE, GL_INT, GL_TEXTURE_CUBE_MAP, GL_NONE, GL_NONE, SamplerFormat::Float, 1, 1, 1, sizeof(GLint), sizeof(GLint) * 4, sizeof(GLint) * 1, true, false, false, "intBitsToFloat"}, + {GL_SAMPLER_CUBE_MAP_ARRAY, GL_INT, GL_TEXTURE_CUBE_MAP_ARRAY, GL_NONE, GL_NONE, + SamplerFormat::Float, 1, 1, 1, sizeof(GLint), sizeof(GLint) * 4, sizeof(GLint) * 1, true, + false, false, "intBitsToFloat"}, {GL_SAMPLER_CUBE_SHADOW, GL_INT, GL_TEXTURE_CUBE_MAP, GL_NONE, GL_NONE, SamplerFormat::Shadow, 1, 1, 1, sizeof(GLint), sizeof(GLint) * 4, sizeof(GLint) * 1, true, false, false, "intBitsToFloat"}, + {GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW, GL_INT, GL_NONE, GL_NONE, GL_NONE, SamplerFormat::Shadow, 1, + 1, 1, sizeof(GLint), sizeof(GLint) * 4, sizeof(GLint) * 1, true, false, false, + "intBitsToFloat"}, {GL_SAMPLER_EXTERNAL_OES, GL_INT, GL_TEXTURE_EXTERNAL_OES, GL_NONE, GL_NONE, SamplerFormat::Float, 1, 1, 1, sizeof(GLint), sizeof(GLint) * 4, sizeof(GLint) * 1, true, false, false, "intBitsToFloat"}, @@ -145,6 +160,9 @@ constexpr std::array<UniformTypeInfo, 63> kInfoTable = { {GL_UNSIGNED_INT_IMAGE_CUBE, GL_UNSIGNED_INT, GL_TEXTURE_CUBE_MAP, GL_NONE, GL_NONE, SamplerFormat::InvalidEnum, 1, 1, 1, sizeof(GLuint), sizeof(GLuint) * 4, sizeof(GLuint) * 1, false, false, true, "uintBitsToFloat"}, + {GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY, GL_UNSIGNED_INT, GL_TEXTURE_CUBE_MAP_ARRAY, GL_NONE, + GL_NONE, SamplerFormat::InvalidEnum, 1, 1, 1, sizeof(GLuint), sizeof(GLuint) * 4, + sizeof(GLuint) * 1, false, false, true, "uintBitsToFloat"}, {GL_UNSIGNED_INT_SAMPLER_2D, GL_UNSIGNED_INT, GL_TEXTURE_2D, GL_NONE, GL_NONE, SamplerFormat::Unsigned, 1, 1, 1, sizeof(GLuint), sizeof(GLuint) * 4, sizeof(GLuint) * 1, true, false, false, "uintBitsToFloat"}, @@ -164,6 +182,9 @@ constexpr std::array<UniformTypeInfo, 63> kInfoTable = { {GL_UNSIGNED_INT_SAMPLER_CUBE, GL_UNSIGNED_INT, GL_TEXTURE_CUBE_MAP, GL_NONE, GL_NONE, SamplerFormat::Unsigned, 1, 1, 1, sizeof(GLuint), sizeof(GLuint) * 4, sizeof(GLuint) * 1, true, false, false, "uintBitsToFloat"}, + {GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY, GL_UNSIGNED_INT, GL_TEXTURE_CUBE_MAP_ARRAY, GL_NONE, + GL_NONE, SamplerFormat::Unsigned, 1, 1, 1, sizeof(GLuint), sizeof(GLuint) * 4, + sizeof(GLuint) * 1, true, false, false, "uintBitsToFloat"}, {GL_UNSIGNED_INT_VEC2, GL_UNSIGNED_INT, GL_NONE, GL_NONE, GL_BOOL_VEC2, SamplerFormat::InvalidEnum, 1, 2, 2, sizeof(GLuint), sizeof(GLuint) * 4, sizeof(GLuint) * 2, false, false, false, "uintBitsToFloat"}, @@ -225,88 +246,102 @@ size_t GetTypeInfoIndex(GLenum uniformType) return 20; case GL_IMAGE_CUBE: return 21; - case GL_INT: + case GL_IMAGE_CUBE_MAP_ARRAY: return 22; - case GL_INT_IMAGE_2D: + case GL_INT: return 23; - case GL_INT_IMAGE_2D_ARRAY: + case GL_INT_IMAGE_2D: return 24; - case GL_INT_IMAGE_3D: + case GL_INT_IMAGE_2D_ARRAY: return 25; - case GL_INT_IMAGE_CUBE: + case GL_INT_IMAGE_3D: return 26; - case GL_INT_SAMPLER_2D: + case GL_INT_IMAGE_CUBE: return 27; - case GL_INT_SAMPLER_2D_ARRAY: + case GL_INT_IMAGE_CUBE_MAP_ARRAY: return 28; - case GL_INT_SAMPLER_2D_MULTISAMPLE: + case GL_INT_SAMPLER_2D: return 29; - case GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY: + case GL_INT_SAMPLER_2D_ARRAY: return 30; - case GL_INT_SAMPLER_3D: + case GL_INT_SAMPLER_2D_MULTISAMPLE: return 31; - case GL_INT_SAMPLER_CUBE: + case GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY: return 32; - case GL_INT_VEC2: + case GL_INT_SAMPLER_3D: return 33; - case GL_INT_VEC3: + case GL_INT_SAMPLER_CUBE: return 34; - case GL_INT_VEC4: + case GL_INT_SAMPLER_CUBE_MAP_ARRAY: return 35; - case GL_SAMPLER_2D: + case GL_INT_VEC2: return 36; - case GL_SAMPLER_2D_ARRAY: + case GL_INT_VEC3: return 37; - case GL_SAMPLER_2D_ARRAY_SHADOW: + case GL_INT_VEC4: return 38; - case GL_SAMPLER_2D_MULTISAMPLE: + case GL_SAMPLER_2D: return 39; - case GL_SAMPLER_2D_MULTISAMPLE_ARRAY: + case GL_SAMPLER_2D_ARRAY: return 40; - case GL_SAMPLER_2D_RECT_ANGLE: + case GL_SAMPLER_2D_ARRAY_SHADOW: return 41; - case GL_SAMPLER_2D_SHADOW: + case GL_SAMPLER_2D_MULTISAMPLE: return 42; - case GL_SAMPLER_3D: + case GL_SAMPLER_2D_MULTISAMPLE_ARRAY: return 43; - case GL_SAMPLER_CUBE: + case GL_SAMPLER_2D_RECT_ANGLE: return 44; - case GL_SAMPLER_CUBE_SHADOW: + case GL_SAMPLER_2D_SHADOW: return 45; - case GL_SAMPLER_EXTERNAL_OES: + case GL_SAMPLER_3D: return 46; - case GL_UNSIGNED_INT: + case GL_SAMPLER_CUBE: return 47; - case GL_UNSIGNED_INT_ATOMIC_COUNTER: + case GL_SAMPLER_CUBE_MAP_ARRAY: return 48; - case GL_UNSIGNED_INT_IMAGE_2D: + case GL_SAMPLER_CUBE_SHADOW: return 49; - case GL_UNSIGNED_INT_IMAGE_2D_ARRAY: + case GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW: return 50; - case GL_UNSIGNED_INT_IMAGE_3D: + case GL_SAMPLER_EXTERNAL_OES: return 51; - case GL_UNSIGNED_INT_IMAGE_CUBE: + case GL_UNSIGNED_INT: return 52; - case GL_UNSIGNED_INT_SAMPLER_2D: + case GL_UNSIGNED_INT_ATOMIC_COUNTER: return 53; - case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY: + case GL_UNSIGNED_INT_IMAGE_2D: return 54; - case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE: + case GL_UNSIGNED_INT_IMAGE_2D_ARRAY: return 55; - case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY: + case GL_UNSIGNED_INT_IMAGE_3D: return 56; - case GL_UNSIGNED_INT_SAMPLER_3D: + case GL_UNSIGNED_INT_IMAGE_CUBE: return 57; - case GL_UNSIGNED_INT_SAMPLER_CUBE: + case GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY: return 58; - case GL_UNSIGNED_INT_VEC2: + case GL_UNSIGNED_INT_SAMPLER_2D: return 59; - case GL_UNSIGNED_INT_VEC3: + case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY: return 60; - case GL_UNSIGNED_INT_VEC4: + case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE: return 61; - case GL_SAMPLER_VIDEO_IMAGE_WEBGL: + case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY: return 62; + case GL_UNSIGNED_INT_SAMPLER_3D: + return 63; + case GL_UNSIGNED_INT_SAMPLER_CUBE: + return 64; + case GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY: + return 65; + case GL_UNSIGNED_INT_VEC2: + return 66; + case GL_UNSIGNED_INT_VEC3: + return 67; + case GL_UNSIGNED_INT_VEC4: + return 68; + case GL_SAMPLER_VIDEO_IMAGE_WEBGL: + return 69; default: UNREACHABLE(); return 0; diff --git a/chromium/third_party/angle/src/common/utilities.cpp b/chromium/third_party/angle/src/common/utilities.cpp index e745806a4b3..bcaba611c39 100644 --- a/chromium/third_party/angle/src/common/utilities.cpp +++ b/chromium/third_party/angle/src/common/utilities.cpp @@ -7,7 +7,6 @@ // utilities.cpp: Conversion functions and other utility routines. #include "common/utilities.h" -#include <GLSLANG/ShaderVars.h> #include "GLES3/gl3.h" #include "common/mathutil.h" #include "common/platform.h" @@ -163,6 +162,9 @@ GLenum VariableComponentType(GLenum type) case GL_IMAGE_CUBE: case GL_INT_IMAGE_CUBE: case GL_UNSIGNED_INT_IMAGE_CUBE: + case GL_IMAGE_CUBE_MAP_ARRAY: + case GL_INT_IMAGE_CUBE_MAP_ARRAY: + case GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY: case GL_UNSIGNED_INT_ATOMIC_COUNTER: case GL_SAMPLER_VIDEO_IMAGE_WEBGL: return GL_INT; @@ -313,21 +315,25 @@ int VariableRowCount(GLenum type) case GL_SAMPLER_2D_RECT_ANGLE: case GL_SAMPLER_2D_MULTISAMPLE: case GL_SAMPLER_2D_MULTISAMPLE_ARRAY: + case GL_SAMPLER_CUBE_MAP_ARRAY: case GL_INT_SAMPLER_2D: case GL_INT_SAMPLER_3D: case GL_INT_SAMPLER_CUBE: case GL_INT_SAMPLER_2D_ARRAY: case GL_INT_SAMPLER_2D_MULTISAMPLE: case GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY: + case GL_INT_SAMPLER_CUBE_MAP_ARRAY: case GL_UNSIGNED_INT_SAMPLER_2D: case GL_UNSIGNED_INT_SAMPLER_3D: case GL_UNSIGNED_INT_SAMPLER_CUBE: case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY: case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE: case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY: + case GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY: case GL_SAMPLER_2D_SHADOW: case GL_SAMPLER_CUBE_SHADOW: case GL_SAMPLER_2D_ARRAY_SHADOW: + case GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW: case GL_IMAGE_2D: case GL_INT_IMAGE_2D: case GL_UNSIGNED_INT_IMAGE_2D: @@ -341,6 +347,9 @@ int VariableRowCount(GLenum type) case GL_INT_IMAGE_CUBE: case GL_UNSIGNED_INT_IMAGE_CUBE: case GL_UNSIGNED_INT_ATOMIC_COUNTER: + case GL_IMAGE_CUBE_MAP_ARRAY: + case GL_INT_IMAGE_CUBE_MAP_ARRAY: + case GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY: case GL_SAMPLER_VIDEO_IMAGE_WEBGL: return 1; case GL_FLOAT_MAT2: @@ -378,12 +387,14 @@ int VariableColumnCount(GLenum type) case GL_SAMPLER_2D_ARRAY: case GL_SAMPLER_2D_MULTISAMPLE: case GL_SAMPLER_2D_MULTISAMPLE_ARRAY: + case GL_SAMPLER_CUBE_MAP_ARRAY: case GL_INT_SAMPLER_2D: case GL_INT_SAMPLER_3D: case GL_INT_SAMPLER_CUBE: case GL_INT_SAMPLER_2D_ARRAY: case GL_INT_SAMPLER_2D_MULTISAMPLE: case GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY: + case GL_INT_SAMPLER_CUBE_MAP_ARRAY: case GL_SAMPLER_EXTERNAL_OES: case GL_SAMPLER_2D_RECT_ANGLE: case GL_UNSIGNED_INT_SAMPLER_2D: @@ -392,9 +403,11 @@ int VariableColumnCount(GLenum type) case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY: case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE: case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY: + case GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY: case GL_SAMPLER_2D_SHADOW: case GL_SAMPLER_CUBE_SHADOW: case GL_SAMPLER_2D_ARRAY_SHADOW: + case GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW: case GL_IMAGE_2D: case GL_INT_IMAGE_2D: case GL_UNSIGNED_INT_IMAGE_2D: @@ -404,6 +417,9 @@ int VariableColumnCount(GLenum type) case GL_IMAGE_2D_ARRAY: case GL_INT_IMAGE_2D_ARRAY: case GL_UNSIGNED_INT_IMAGE_2D_ARRAY: + case GL_IMAGE_CUBE_MAP_ARRAY: + case GL_INT_IMAGE_CUBE_MAP_ARRAY: + case GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY: case GL_IMAGE_CUBE: case GL_INT_IMAGE_CUBE: case GL_UNSIGNED_INT_IMAGE_CUBE: @@ -452,6 +468,7 @@ bool IsSamplerType(GLenum type) case GL_SAMPLER_EXTERNAL_OES: case GL_SAMPLER_2D_MULTISAMPLE: case GL_SAMPLER_2D_MULTISAMPLE_ARRAY: + case GL_SAMPLER_CUBE_MAP_ARRAY: case GL_SAMPLER_2D_RECT_ANGLE: case GL_INT_SAMPLER_2D: case GL_INT_SAMPLER_3D: @@ -459,15 +476,18 @@ bool IsSamplerType(GLenum type) case GL_INT_SAMPLER_2D_ARRAY: case GL_INT_SAMPLER_2D_MULTISAMPLE: case GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY: + case GL_INT_SAMPLER_CUBE_MAP_ARRAY: case GL_UNSIGNED_INT_SAMPLER_2D: case GL_UNSIGNED_INT_SAMPLER_3D: case GL_UNSIGNED_INT_SAMPLER_CUBE: case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY: case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE: case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY: + case GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY: case GL_SAMPLER_2D_SHADOW: case GL_SAMPLER_CUBE_SHADOW: case GL_SAMPLER_2D_ARRAY_SHADOW: + case GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW: case GL_SAMPLER_VIDEO_IMAGE_WEBGL: return true; } @@ -502,6 +522,9 @@ bool IsImageType(GLenum type) case GL_IMAGE_2D_ARRAY: case GL_INT_IMAGE_2D_ARRAY: case GL_UNSIGNED_INT_IMAGE_2D_ARRAY: + case GL_IMAGE_CUBE_MAP_ARRAY: + case GL_INT_IMAGE_CUBE_MAP_ARRAY: + case GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY: case GL_IMAGE_CUBE: case GL_INT_IMAGE_CUBE: case GL_UNSIGNED_INT_IMAGE_CUBE: @@ -524,6 +547,9 @@ bool IsImage2DType(GLenum type) case GL_IMAGE_2D_ARRAY: case GL_INT_IMAGE_2D_ARRAY: case GL_UNSIGNED_INT_IMAGE_2D_ARRAY: + case GL_IMAGE_CUBE_MAP_ARRAY: + case GL_INT_IMAGE_CUBE_MAP_ARRAY: + case GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY: case GL_IMAGE_CUBE: case GL_INT_IMAGE_CUBE: case GL_UNSIGNED_INT_IMAGE_CUBE: @@ -887,40 +913,6 @@ bool SamplerNameContainsNonZeroArrayElement(const std::string &name) return false; } -const sh::ShaderVariable *FindShaderVarField(const sh::ShaderVariable &var, - const std::string &fullName, - GLuint *fieldIndexOut) -{ - if (var.fields.empty()) - { - return nullptr; - } - size_t pos = fullName.find_first_of("."); - if (pos == std::string::npos) - { - return nullptr; - } - std::string topName = fullName.substr(0, pos); - if (topName != var.name) - { - return nullptr; - } - std::string fieldName = fullName.substr(pos + 1); - if (fieldName.empty()) - { - return nullptr; - } - for (size_t field = 0; field < var.fields.size(); ++field) - { - if (var.fields[field].name == fieldName) - { - *fieldIndexOut = static_cast<GLuint>(field); - return &var.fields[field]; - } - } - return nullptr; -} - unsigned int ArraySizeProduct(const std::vector<unsigned int> &arraySizes) { unsigned int arraySizeProduct = 1u; @@ -1189,6 +1181,8 @@ const char *GetGenericErrorMessage(EGLint error) return "Bad match."; case EGL_BAD_NATIVE_WINDOW: return "Bad native window."; + case EGL_BAD_NATIVE_PIXMAP: + return "Bad native pixmap."; case EGL_BAD_PARAMETER: return "Bad parameter."; case EGL_BAD_SURFACE: diff --git a/chromium/third_party/angle/src/common/utilities.h b/chromium/third_party/angle/src/common/utilities.h index 3db701c0b8d..a47c55ba1a9 100644 --- a/chromium/third_party/angle/src/common/utilities.h +++ b/chromium/third_party/angle/src/common/utilities.h @@ -66,12 +66,6 @@ std::string StripLastArrayIndex(const std::string &name); bool SamplerNameContainsNonZeroArrayElement(const std::string &name); -// Find the child field which matches 'fullName' == var.name + "." + field.name. -// Return nullptr if not found. -const sh::ShaderVariable *FindShaderVarField(const sh::ShaderVariable &var, - const std::string &fullName, - GLuint *fieldIndexOut); - // Find the range of index values in the provided indices pointer. Primitive restart indices are // only counted in the range if primitive restart is disabled. IndexRange ComputeIndexRange(DrawElementsType indexType, @@ -228,6 +222,15 @@ const char *GetDebugMessageSourceString(GLenum source); const char *GetDebugMessageTypeString(GLenum type); const char *GetDebugMessageSeverityString(GLenum severity); +// For use with EXT_texture_format_sRGB_override and EXT_texture_sRGB_decode +// A texture may either have SRGB decoding forced on, or use whatever decode state is default for +// the texture format. +enum class SrgbOverride +{ + Default = 0, + Enabled +}; + } // namespace gl namespace egl diff --git a/chromium/third_party/angle/src/common/vulkan/BUILD.gn b/chromium/third_party/angle/src/common/vulkan/BUILD.gn index 3ae8d5163cc..6b5b02f4c0d 100644 --- a/chromium/third_party/angle/src/common/vulkan/BUILD.gn +++ b/chromium/third_party/angle/src/common/vulkan/BUILD.gn @@ -7,6 +7,51 @@ import("../../../gni/angle.gni") assert(angle_enable_vulkan) +config("angle_vulkan_lib_android") { + if (is_android) { + libs = [ "vulkan" ] + } +} + +config("angle_vulkan_headers_config") { + if (angle_shared_libvulkan) { + defines = [ "ANGLE_SHARED_LIBVULKAN=1" ] + } +} + +angle_source_set("angle_vulkan_headers") { + sources = [ + "vk_ext_provoking_vertex.h", + "vk_google_filtering_precision.h", + "vk_headers.h", + ] + if (angle_shared_libvulkan) { + public_deps = [ "$angle_root/src/third_party/volk:volk" ] + } else { + public_deps = + [ "$angle_root/third_party/vulkan-headers/src:vulkan_headers" ] + } + public_configs = [ ":angle_vulkan_headers_config" ] +} + +group("angle_vulkan_entry_points") { + public_configs = [ ":angle_vulkan_lib_android" ] + public_deps = [ ":angle_vulkan_headers" ] + if (is_fuchsia) { + public_deps += [ + "$angle_root/src/common/fuchsia_egl", + "//third_party/fuchsia-sdk:vulkan_base", + "//third_party/fuchsia-sdk/sdk/pkg/vulkan", + ] + } else if (!is_android && !is_ggp) { + if (angle_shared_libvulkan) { + data_deps = [ "$angle_root/third_party/vulkan-loader/src:libvulkan" ] + } else { + deps = [ "$angle_root/third_party/vulkan-loader/src:libvulkan" ] + } + } +} + angle_source_set("vulkan") { sources = [ "vulkan_icd.cpp", @@ -14,8 +59,8 @@ angle_source_set("vulkan") { ] public_deps = [ + ":angle_vulkan_entry_points", "$angle_root:angle_common", - "$angle_root/src/libANGLE/renderer/vulkan:angle_vulkan_entry_points", ] defines = [ @@ -35,18 +80,6 @@ angle_source_set("vulkan") { data_deps += [ "$angle_root/third_party/vulkan-tools/src:VkICD_mock_icd" ] } - if (angle_enable_vulkan_validation_layers) { - defines += [ "ANGLE_ENABLE_VULKAN_VALIDATION_LAYERS_BY_DEFAULT" ] - if (is_fuchsia) { - data_deps += [ "//third_party/fuchsia-sdk:vulkan_validation" ] - } else { - data_deps += [ "$angle_root/third_party/vulkan-validation-layers/src:vulkan_validation_layers" ] - if (!is_android) { - data_deps += [ "$angle_root/third_party/vulkan-validation-layers/src:vulkan_gen_json_files" ] - } - } - } - if (angle_enable_swiftshader) { import("$swiftshader_dir/src/Vulkan/vulkan.gni") _sws_icd = "./$swiftshader_icd_file_name" @@ -62,3 +95,15 @@ angle_source_set("vulkan") { ] } } + +group("vulkan_validation_layers") { + data_deps = [] + if (is_fuchsia) { + data_deps += [ "//third_party/fuchsia-sdk:vulkan_validation" ] + } else { + data_deps += [ "$angle_root/third_party/vulkan-validation-layers/src:vulkan_validation_layers" ] + if (!is_android) { + data_deps += [ "$angle_root/third_party/vulkan-validation-layers/src:vulkan_gen_json_files" ] + } + } +} diff --git a/chromium/third_party/angle/src/common/vulkan/vk_ext_provoking_vertex.h b/chromium/third_party/angle/src/common/vulkan/vk_ext_provoking_vertex.h new file mode 100644 index 00000000000..01b439fc302 --- /dev/null +++ b/chromium/third_party/angle/src/common/vulkan/vk_ext_provoking_vertex.h @@ -0,0 +1,70 @@ +// Copyright 2019 The SwiftShader Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef CUSTOM_VK_EXT_PROVOKING_VERTEX_H_ +#define CUSTOM_VK_EXT_PROVOKING_VERTEX_H_ + +#include "vk_headers.h" + +// THIS FILE SHOULD BE DELETED IF VK_EXT_provoking_vertex IS EVER ADDED TO THE VULKAN HEADERS +#ifdef VK_EXT_provoking_vertex +# error \ + "VK_EXT_provoking_vertex is already defined in the Vulkan headers, you can delete this file" +#endif + +static constexpr VkStructureType VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROVOKING_VERTEX_FEATURES_EXT = + static_cast<VkStructureType>(1000254000); +static constexpr VkStructureType + VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_PROVOKING_VERTEX_STATE_CREATE_INFO_EXT = + static_cast<VkStructureType>(1000254001); +static constexpr VkStructureType VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROVOKING_VERTEX_PROPERTIES_EXT = + static_cast<VkStructureType>(1000254002); + +#define VK_EXT_provoking_vertex 1 +#define VK_EXT_PROVOKING_VERTEX_SPEC_VERSION 1 +#define VK_EXT_PROVOKING_VERTEX_EXTENSION_NAME "VK_EXT_provoking_vertex" + +typedef enum VkProvokingVertexModeEXT +{ + VK_PROVOKING_VERTEX_MODE_FIRST_VERTEX_EXT = 0, + VK_PROVOKING_VERTEX_MODE_LAST_VERTEX_EXT = 1, + VK_PROVOKING_VERTEX_MODE_BEGIN_RANGE_EXT = VK_PROVOKING_VERTEX_MODE_FIRST_VERTEX_EXT, + VK_PROVOKING_VERTEX_MODE_END_RANGE_EXT = VK_PROVOKING_VERTEX_MODE_LAST_VERTEX_EXT, + VK_PROVOKING_VERTEX_MODE_RANGE_SIZE_EXT = + (VK_PROVOKING_VERTEX_MODE_LAST_VERTEX_EXT - VK_PROVOKING_VERTEX_MODE_FIRST_VERTEX_EXT + 1), + VK_PROVOKING_VERTEX_MODE_MAX_ENUM_EXT = 0x7FFFFFFF +} VkProvokingVertexModeEXT; + +typedef struct VkPhysicalDeviceProvokingVertexFeaturesEXT +{ + VkStructureType sType; + void *pNext; + VkBool32 provokingVertexLast; +} VkPhysicalDeviceProvokingVertexFeaturesEXT; + +typedef struct VkPhysicalDeviceProvokingVertexPropertiesEXT +{ + VkStructureType sType; + void *pNext; + VkBool32 provokingVertexModePerPipeline; +} VkPhysicalDeviceProvokingVertexPropertiesEXT; + +typedef struct VkPipelineRasterizationProvokingVertexStateCreateInfoEXT +{ + VkStructureType sType; + const void *pNext; + VkProvokingVertexModeEXT provokingVertexMode; +} VkPipelineRasterizationProvokingVertexStateCreateInfoEXT; + +#endif // CUSTOM_VK_EXT_PROVOKING_VERTEX_H_ diff --git a/chromium/third_party/angle/src/common/vulkan/vk_google_filtering_precision.h b/chromium/third_party/angle/src/common/vulkan/vk_google_filtering_precision.h new file mode 100644 index 00000000000..934dc793c6c --- /dev/null +++ b/chromium/third_party/angle/src/common/vulkan/vk_google_filtering_precision.h @@ -0,0 +1,57 @@ +// Copyright 2020 The SwiftShader Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef CUSTOM_VK_GOOGLE_SAMPLER_FILTERING_PRECISION_H_ +#define CUSTOM_VK_GOOGLE_SAMPLER_FILTERING_PRECISION_H_ + +#include "vk_headers.h" + +// THIS FILE SHOULD BE DELETED IF VK_GOOGLE_sampler_filtering_precision IS EVER ADDED TO THE VULKAN +// HEADERS +#ifdef VK_GOOGLE_sampler_filtering_precision +# error \ + "VK_GOOGLE_sampler_filtering_precision is already defined in the Vulkan headers, you can delete this file" +#endif + +static constexpr VkStructureType VK_STRUCTURE_TYPE_SAMPLER_FILTERING_PRECISION_GOOGLE = + static_cast<VkStructureType>(1000264000); + +#define VK_GOOGLE_sampler_filtering_precision 1 +#define VK_GOOGLE_SAMPLER_FILTERING_PRECISION_SPEC_VERSION 1 +#define VK_GOOGLE_SAMPLER_FILTERING_PRECISION_EXTENSION_NAME "VK_GOOGLE_sampler_filtering_precision" + +const int TEXTURE_FILTERING_HINT_CHROMIUM = 0x8AF0; + +typedef enum VkSamplerFilteringPrecisionModeGOOGLE +{ + VK_SAMPLER_FILTERING_PRECISION_MODE_LOW_GOOGLE = 0, + VK_SAMPLER_FILTERING_PRECISION_MODE_HIGH_GOOGLE = 1, + VK_SAMPLER_FILTERING_PRECISION_MODE_BEGIN_RANGE_GOOGLE = + VK_SAMPLER_FILTERING_PRECISION_MODE_LOW_GOOGLE, + VK_SAMPLER_FILTERING_PRECISION_MODE_END_RANGE_GOOGLE = + VK_SAMPLER_FILTERING_PRECISION_MODE_HIGH_GOOGLE, + VK_SAMPLER_FILTERING_PRECISION_MODE_RANGE_SIZE_GOOGLE = + (VK_SAMPLER_FILTERING_PRECISION_MODE_HIGH_GOOGLE - + VK_SAMPLER_FILTERING_PRECISION_MODE_LOW_GOOGLE + 1), + VK_SAMPLER_FILTERING_PRECISION_MODE_MAX_ENUM_GOOGLE = 0x7FFFFFFF +} VkSamplerFilteringPrecisionModeGOOGLE; + +typedef struct VkSamplerFilteringPrecisionGOOGLE +{ + VkStructureType sType; + const void *pNext; + VkSamplerFilteringPrecisionModeGOOGLE samplerFilteringPrecisionMode; +} VkSamplerFilteringPrecisionGOOGLE; + +#endif // CUSTOM_VK_GOOGLE_SAMPLER_FILTERING_PRECISION_H_ diff --git a/chromium/third_party/angle/src/common/vulkan/vk_headers.h b/chromium/third_party/angle/src/common/vulkan/vk_headers.h new file mode 100644 index 00000000000..87316ec8c9c --- /dev/null +++ b/chromium/third_party/angle/src/common/vulkan/vk_headers.h @@ -0,0 +1,85 @@ +// +// Copyright 2016 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// +// vk_headers: +// This file should be included to ensure the vulkan headers are included +// + +#ifndef LIBANGLE_RENDERER_VULKAN_VK_HEADERS_H_ +#define LIBANGLE_RENDERER_VULKAN_VK_HEADERS_H_ + +#if ANGLE_SHARED_LIBVULKAN +# include "third_party/volk/volk.h" +#else +# include <vulkan/vulkan.h> +#endif + +#if !defined(ANGLE_SHARED_LIBVULKAN) + +namespace rx +{ +// VK_EXT_debug_utils +extern PFN_vkCreateDebugUtilsMessengerEXT vkCreateDebugUtilsMessengerEXT; +extern PFN_vkDestroyDebugUtilsMessengerEXT vkDestroyDebugUtilsMessengerEXT; +extern PFN_vkCmdBeginDebugUtilsLabelEXT vkCmdBeginDebugUtilsLabelEXT; +extern PFN_vkCmdEndDebugUtilsLabelEXT vkCmdEndDebugUtilsLabelEXT; +extern PFN_vkCmdInsertDebugUtilsLabelEXT vkCmdInsertDebugUtilsLabelEXT; + +// VK_EXT_debug_report +extern PFN_vkCreateDebugReportCallbackEXT vkCreateDebugReportCallbackEXT; +extern PFN_vkDestroyDebugReportCallbackEXT vkDestroyDebugReportCallbackEXT; + +// VK_KHR_get_physical_device_properties2 +extern PFN_vkGetPhysicalDeviceProperties2KHR vkGetPhysicalDeviceProperties2KHR; +extern PFN_vkGetPhysicalDeviceFeatures2KHR vkGetPhysicalDeviceFeatures2KHR; + +// VK_KHR_external_semaphore_fd +extern PFN_vkImportSemaphoreFdKHR vkImportSemaphoreFdKHR; + +// VK_EXT_external_memory_host +extern PFN_vkGetMemoryHostPointerPropertiesEXT vkGetMemoryHostPointerPropertiesEXT; + +// VK_EXT_transform_feedback +extern PFN_vkCmdBindTransformFeedbackBuffersEXT vkCmdBindTransformFeedbackBuffersEXT; +extern PFN_vkCmdBeginTransformFeedbackEXT vkCmdBeginTransformFeedbackEXT; +extern PFN_vkCmdEndTransformFeedbackEXT vkCmdEndTransformFeedbackEXT; +extern PFN_vkCmdBeginQueryIndexedEXT vkCmdBeginQueryIndexedEXT; +extern PFN_vkCmdEndQueryIndexedEXT vkCmdEndQueryIndexedEXT; +extern PFN_vkCmdDrawIndirectByteCountEXT vkCmdDrawIndirectByteCountEXT; + +extern PFN_vkGetBufferMemoryRequirements2KHR vkGetBufferMemoryRequirements2KHR; +extern PFN_vkGetImageMemoryRequirements2KHR vkGetImageMemoryRequirements2KHR; + +// VK_KHR_external_fence_capabilities +extern PFN_vkGetPhysicalDeviceExternalFencePropertiesKHR + vkGetPhysicalDeviceExternalFencePropertiesKHR; + +// VK_KHR_external_fence_fd +extern PFN_vkGetFenceFdKHR vkGetFenceFdKHR; +extern PFN_vkImportFenceFdKHR vkImportFenceFdKHR; + +// VK_KHR_external_semaphore_capabilities +extern PFN_vkGetPhysicalDeviceExternalSemaphorePropertiesKHR + vkGetPhysicalDeviceExternalSemaphorePropertiesKHR; + +# if defined(ANGLE_PLATFORM_FUCHSIA) +// VK_FUCHSIA_imagepipe_surface +extern PFN_vkCreateImagePipeSurfaceFUCHSIA vkCreateImagePipeSurfaceFUCHSIA; +# endif + +# if defined(ANGLE_PLATFORM_ANDROID) +extern PFN_vkGetAndroidHardwareBufferPropertiesANDROID vkGetAndroidHardwareBufferPropertiesANDROID; +extern PFN_vkGetMemoryAndroidHardwareBufferANDROID vkGetMemoryAndroidHardwareBufferANDROID; +# endif + +# if defined(ANGLE_PLATFORM_GGP) +extern PFN_vkCreateStreamDescriptorSurfaceGGP vkCreateStreamDescriptorSurfaceGGP; +# endif // defined(ANGLE_PLATFORM_GGP) + +} // namespace rx + +#endif // ANGLE_SHARED_LIBVULKAN + +#endif // LIBANGLE_RENDERER_VULKAN_VK_HEADERS_H_ diff --git a/chromium/third_party/angle/src/common/vulkan/vulkan_icd.cpp b/chromium/third_party/angle/src/common/vulkan/vulkan_icd.cpp index bf56c7de6d9..b960575c479 100644 --- a/chromium/third_party/angle/src/common/vulkan/vulkan_icd.cpp +++ b/chromium/third_party/angle/src/common/vulkan/vulkan_icd.cpp @@ -15,6 +15,29 @@ #include "common/debug.h" #include "common/system_utils.h" +#include "common/vulkan/vk_ext_provoking_vertex.h" +#include "common/vulkan/vk_google_filtering_precision.h" + +namespace +{ +void ResetEnvironmentVar(const char *variableName, const Optional<std::string> &value) +{ + if (!value.valid()) + { + return; + } + + if (value.value().empty()) + { + angle::UnsetEnvironmentVar(variableName); + } + else + { + angle::SetEnvironmentVar(variableName, value.value().c_str()); + } +} +} // namespace + namespace angle { @@ -40,8 +63,9 @@ const std::string WrapICDEnvironment(const char *icdEnvironment) constexpr char kLoaderLayersPathEnv[] = "VK_LAYER_PATH"; #endif -constexpr char kLoaderICDFilenamesEnv[] = "VK_ICD_FILENAMES"; -constexpr char kANGLEPreferredDeviceEnv[] = "ANGLE_PREFERRED_DEVICE"; +constexpr char kLoaderICDFilenamesEnv[] = "VK_ICD_FILENAMES"; +constexpr char kANGLEPreferredDeviceEnv[] = "ANGLE_PREFERRED_DEVICE"; +constexpr char kValidationLayersCustomSTypeListEnv[] = "VK_LAYER_CUSTOM_STYPE_LIST"; constexpr uint32_t kMockVendorID = 0xba5eba11; constexpr uint32_t kMockDeviceID = 0xf005ba11; @@ -143,6 +167,12 @@ ScopedVkLoaderEnvironment::ScopedVkLoaderEnvironment(bool enableValidationLayers ERR() << "Error setting environment for Vulkan layers init."; mEnableValidationLayers = false; } + + if (!setCustomExtensionsEnvironment()) + { + ERR() << "Error setting custom list for custom extensions for Vulkan layers init."; + mEnableValidationLayers = false; + } } #endif // !defined(ANGLE_PLATFORM_ANDROID) } @@ -158,15 +188,10 @@ ScopedVkLoaderEnvironment::~ScopedVkLoaderEnvironment() } if (mChangedICDEnv) { - if (mPreviousICDEnv.value().empty()) - { - angle::UnsetEnvironmentVar(kLoaderICDFilenamesEnv); - } - else - { - angle::SetEnvironmentVar(kLoaderICDFilenamesEnv, mPreviousICDEnv.value().c_str()); - } + ResetEnvironmentVar(kLoaderICDFilenamesEnv, mPreviousICDEnv); } + + ResetEnvironmentVar(kValidationLayersCustomSTypeListEnv, mPreviousCustomExtensionsEnv); } bool ScopedVkLoaderEnvironment::setICDEnvironment(const char *icd) @@ -183,6 +208,40 @@ bool ScopedVkLoaderEnvironment::setICDEnvironment(const char *icd) return mChangedICDEnv; } +bool ScopedVkLoaderEnvironment::setCustomExtensionsEnvironment() +{ + struct CustomExtension + { + VkStructureType type; + size_t size; + }; + + CustomExtension customExtensions[] = { + + {VK_STRUCTURE_TYPE_SAMPLER_FILTERING_PRECISION_GOOGLE, + sizeof(VkSamplerFilteringPrecisionGOOGLE)}, + + {VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROVOKING_VERTEX_FEATURES_EXT, + sizeof(VkPhysicalDeviceProvokingVertexFeaturesEXT)}, + }; + + mPreviousCustomExtensionsEnv = angle::GetEnvironmentVar(kValidationLayersCustomSTypeListEnv); + + std::stringstream strstr; + for (CustomExtension &extension : customExtensions) + { + if (strstr.tellp() != std::streampos(0)) + { + strstr << angle::GetPathSeparatorForEnvironmentVar(); + } + + strstr << extension.type << angle::GetPathSeparatorForEnvironmentVar() << extension.size; + } + + return angle::PrependPathToEnvironmentVar(kValidationLayersCustomSTypeListEnv, + strstr.str().c_str()); +} + void ChoosePhysicalDevice(const std::vector<VkPhysicalDevice> &physicalDevices, vk::ICD preferredICD, VkPhysicalDevice *physicalDeviceOut, diff --git a/chromium/third_party/angle/src/common/vulkan/vulkan_icd.h b/chromium/third_party/angle/src/common/vulkan/vulkan_icd.h index f3631a3db0c..c612c15c6de 100644 --- a/chromium/third_party/angle/src/common/vulkan/vulkan_icd.h +++ b/chromium/third_party/angle/src/common/vulkan/vulkan_icd.h @@ -12,7 +12,7 @@ #include "common/Optional.h" #include "common/angleutils.h" -#include "libANGLE/renderer/vulkan/vk_headers.h" +#include "common/vulkan/vk_headers.h" namespace angle { @@ -38,6 +38,7 @@ class ScopedVkLoaderEnvironment : angle::NonCopyable private: bool setICDEnvironment(const char *icd); + bool setCustomExtensionsEnvironment(); bool mEnableValidationLayers; vk::ICD mICD; @@ -45,6 +46,7 @@ class ScopedVkLoaderEnvironment : angle::NonCopyable Optional<std::string> mPreviousCWD; bool mChangedICDEnv; Optional<std::string> mPreviousICDEnv; + Optional<std::string> mPreviousCustomExtensionsEnv; }; void ChoosePhysicalDevice(const std::vector<VkPhysicalDevice> &physicalDevices, |