Hash :
54d4bfe5
Author :
Date :
2021-09-28T17:27:57
Update ANGLE Metal to Webkit at Sept 29 2021
This commit merges changes from Webkit into ANGLE upstream.
The following commits were used:
Current:
https://git.webkit.org/?p=WebKit.git;a=commit;h=e01d0bda8f4b7dc2fd834b92802d15d8c15735f
Previous:
https://git.webkit.org/?p=WebKit.git;a=commit;h=492f078198748e8ff248eea0bb979cf79e5f5adfj
The following commits were merged in from the Webkit Repository:
(Hashes from git://git.webkit.org/WebKit-https.git)
03ea44c78ce5665d4ec9add271260121cbc7bc6c
Problems with drawElements in some conditions
https://bugs.webkit.org/show_bug.cgi?id=230107
c8dc8e0c4d1109d39a62eb197b45e95132380290
ANGLE Metal: single-component swizzles do not compile
https://bugs.webkit.org/show_bug.cgi?id=230472
7285dbaaf5af15877d6c332b30ef7a4d67225460
webgl-compressed-texture-s3tc-srgb.html fails on Intel+AMD Metal
https://bugs.webkit.org/show_bug.cgi?id=229941
4c72f92967ecd2a095666fef431384c4f5f60fb4
fragcolor-fragdata-invariant.html fails
https://bugs.webkit.org/show_bug.cgi?id=223317
cd943145467f54e5928793c0dd3dfa2313c007dd
ANGLE Metal index buffer restart range cache could be maintained..
https://bugs.webkit.org/show_bug.cgi?id=227451
f075ff77e592eabd54dd659a8e13617cc5faedc8
ANGLE Metal infinities and NaNs generated with incorrect syntax
https://bugs.webkit.org/show_bug.cgi?id=229439
5862073269122f4b2d43d96d3922757557755e86
[Metal ANGLE] Fix over-autorelease of
rx::DisplayMtl::getMetalDeviceMatchingAttribute()...
<https://webkit.org/b/229128>
85f797ad31db048cb82cbafd428ef77f0b839312 ANGLE Cocoa compiles....
https://bugs.webkit.org/show_bug.cgi?id=228987
a67918ba279ad4842b6ae84a79c3f1c0cdc35ace Avoid infinite recursion...
https://bugs.webkit.org/show_bug.cgi?id=228978
d341f67de0033adcf1ec6373ace6a54b06c4a031
Cherry-pick ANGLE: Revise WebGL's shaderSource validation
https://bugs.webkit.org/show_bug.cgi?id=228951
1e2714d981e97de8234ba055570dfdf56e8b6944
3.5 MB system-wide footprint impact due to thread-locals...
https://bugs.webkit.org/show_bug.cgi?id=228240
d32e5cca34081997d32504b0b56c18b9703ff3be
Build Default Metal library offline
https://bugs.webkit.org/show_bug.cgi?id=227333
33702279faccfd4c8d1c8a6d549925f9ca9a4e8f
WebGL2 demo doesn't work due to failing compilation....
https://bugs.webkit.org/show_bug.cgi?id=226865
0a075885d242db38c4e435a6597173dc3b082173
rAF driven WebGL submits excessive amount of GPU work...
https://bugs.webkit.org/show_bug.cgi?id=227059
f38a92b3e7c17efda269caa7066e7ffe2f828e72
WebGL shader link error in iOS 15 beta: "Internal error..."
https://bugs.webkit.org/show_bug.cgi?id=227723
98d48f011d561531470d97f26a022767b5452fb7
REGRESSION (r279466): [Big Sur] webgl/1.0.3/conformance &...
https://bugs.webkit.org/show_bug.cgi?id=227596
Bug: angleproject:6471
Change-Id: I07166d0dc4b5c3579d98353485b3245b81c7b882
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3194322
Reviewed-by: Jonah Ryan-Davis <jonahr@google.com>
Reviewed-by: Kenneth Russell <kbr@chromium.org>
Commit-Queue: Jonah Ryan-Davis <jonahr@google.com>
Commit-Queue: Kyle Piddington <kpiddington@apple.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201
//
// Copyright 2014 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.
//
// global_state.h : Defines functions for querying the thread-local GL and EGL state.
#ifndef LIBGLESV2_GLOBALSTATE_H_
#define LIBGLESV2_GLOBALSTATE_H_
#include "libANGLE/Context.h"
#include "libANGLE/Debug.h"
#include "libANGLE/Thread.h"
#include "libANGLE/features.h"
#if defined(ANGLE_PLATFORM_APPLE)
# include "common/tls.h"
#endif
#include <mutex>
namespace angle
{
using GlobalMutex = std::recursive_mutex;
// - 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 size_t kAndroidOpenGLTlsSlot = 3;
#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
} // namespace angle
namespace egl
{
class Debug;
class Thread;
#if defined(ANGLE_PLATFORM_APPLE)
extern Thread *GetCurrentThreadTLS();
extern void SetCurrentThreadTLS(Thread *thread);
#else
extern thread_local Thread *gCurrentThread;
#endif
angle::GlobalMutex &GetGlobalMutex();
gl::Context *GetGlobalLastContext();
void SetGlobalLastContext(gl::Context *context);
Thread *GetCurrentThread();
Debug *GetDebug();
// Sync the current context from Thread to global state.
class ScopedSyncCurrentContextFromThread
{
public:
ScopedSyncCurrentContextFromThread(egl::Thread *thread);
~ScopedSyncCurrentContextFromThread();
private:
egl::Thread *const mThread;
};
} // namespace egl
#define ANGLE_SCOPED_GLOBAL_LOCK() \
std::lock_guard<angle::GlobalMutex> globalMutexLock(egl::GetGlobalMutex())
namespace gl
{
ANGLE_INLINE Context *GetGlobalContext()
{
#if defined(ANGLE_PLATFORM_ANDROID)
// TODO: Replace this branch with a compile time flag (http://anglebug.com/4764)
if (angle::gUseAndroidOpenGLTlsSlot)
{
return static_cast<gl::Context *>(ANGLE_ANDROID_GET_GL_TLS()[angle::kAndroidOpenGLTlsSlot]);
}
#endif
#if defined(ANGLE_PLATFORM_APPLE)
egl::Thread *currentThread = egl::GetCurrentThreadTLS();
#else
egl::Thread *currentThread = egl::gCurrentThread;
#endif
ASSERT(currentThread);
return currentThread->getContext();
}
ANGLE_INLINE Context *GetValidGlobalContext()
{
#if defined(ANGLE_PLATFORM_ANDROID)
// TODO: Replace this branch with a compile time flag (http://anglebug.com/4764)
if (angle::gUseAndroidOpenGLTlsSlot)
{
Context *context =
static_cast<gl::Context *>(ANGLE_ANDROID_GET_GL_TLS()[angle::kAndroidOpenGLTlsSlot]);
if (context && !context->isContextLost())
{
return context;
}
}
#endif
#if defined(ANGLE_PLATFORM_APPLE)
return GetCurrentValidContextTLS();
#else
return gCurrentValidContext;
#endif
}
// Generate a context lost error on the context if it is non-null and lost.
void GenerateContextLostErrorOnContext(Context *context);
void GenerateContextLostErrorOnCurrentGlobalContext();
#if defined(ANGLE_FORCE_CONTEXT_CHECK_EVERY_CALL)
// TODO(b/177574181): This should be handled in a backend-specific way.
// if previous context different from current context, dirty all state
static ANGLE_INLINE void DirtyContextIfNeeded(Context *context)
{
if (context && context != egl::GetGlobalLastContext())
{
context->dirtyAllState();
SetGlobalLastContext(context);
}
}
#endif
ANGLE_INLINE std::unique_lock<angle::GlobalMutex> GetContextLock(Context *context)
{
#if defined(ANGLE_FORCE_CONTEXT_CHECK_EVERY_CALL)
auto lock = std::unique_lock<angle::GlobalMutex>(egl::GetGlobalMutex());
DirtyContextIfNeeded(context);
return lock;
#else
return context->isShared() ? std::unique_lock<angle::GlobalMutex>(egl::GetGlobalMutex())
: std::unique_lock<angle::GlobalMutex>();
#endif
}
} // namespace gl
#endif // LIBGLESV2_GLOBALSTATE_H_