Commit Graph

615 Commits

Author SHA1 Message Date
Russell Epstein e4390067fa Versioning.
WebKit-7613.1.1

Canonical link: https://commits.webkit.org/240838@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281459 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-23 18:38:34 +00:00
David Kilzer d3c1e70fc1 [Metal ANGLE] Fix over-autorelease of rx::DisplayMtl::getMetalDeviceMatchingAttribute() and various Objective-C leaks
<https://webkit.org/b/229128>
<rdar://problem/81964007>

Reviewed by Alex Christensen.

* src/libANGLE/renderer/metal/DisplayMtl.h:
(rx::DisplayMtl::getMetalDeviceMatchingAttribute):
- Change to return mtl::AutoObjCPtr<> to make ownership clear.
(rx::DisplayMtl::mMetalDevice):
- No need to initialize to nil.

* src/libANGLE/renderer/metal/DisplayMtl.mm:
(rx::DisplayMtl::initializeImpl):
- Update for changes to getMetalDeviceMatchingAttribute().
(rx::DisplayMtl::getMetalDeviceMatchingAttribute):
- Change to return mtl::AutoObjCPtr<> to make ownership clear.
- Fix leak of `deviceList`, `externalGPUs`, `integratedGPUs`, and
  `discreteGPUs`.
- Use mtl::adoptObjCObj<>() to prevent leak of
  MTLCreateSystemDefaultDevice().

* src/libANGLE/renderer/metal/IOSurfaceSurfaceMtl.mm:
- Fix leak of `captureDescriptor` in two different if blocks.

* src/libANGLE/renderer/metal/ProgramMtl.mm:
- Fix leak of `funcConstants` in early return on error path.

* src/libANGLE/renderer/metal/ProvokingVertexHelper.mm:
(rx::ProvokingVertexHelper::getSpecializedShader):
- Fix leak of `fcValues`.

* src/libANGLE/renderer/metal/SurfaceMtl.mm:
- Fix leak of `captureDescriptor` in two different if blocks.

* src/libANGLE/renderer/metal/mtl_common.h:
(rx::mtl::WrappedObject::retainAssign):
- Move statement inside #if/#endif that isn't needed for ARC.
(rx::mtl::WrappedObject::unretainAssign): Add.
(rx::mtl::AutoObjCPtr::AutoObjCPtr): Add.
(rx::mtl::adoptObjCObj): Add.
- Add a helper method to adopt an Objective-C object to
  eliminate the need to autorelease a +1 retained object before
  an mtl::AutoObjCPtr<> object wraps it.  Modeled after
  WTF::RetainPtr<> in WebKit.

* src/libANGLE/renderer/metal/mtl_state_cache.mm:
(rx::mtl::RenderPipelineCache::createRenderPipelineState):
(rx::mtl::ProvokingVertexComputePipelineCache::createComputePipelineState):
- Use adoptObjCObj<>() to fix potential leak on the early return
  path since these methods return an mtl::AutoObjCPtr<>.


Canonical link: https://commits.webkit.org/240610@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281160 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-17 20:32:30 +00:00
David Kilzer e7b2ba4278 "make analyze" should run clang static analyzer in deep mode
<https://webkit.org/b/229127>
<rdar://problem/81960587>

Reviewed by Alexey Proskuryakov.

.:

* Makefile.shared:
- Add "analyze" argument to xcodebuild command when invoking
  "make analyze" to run clang static analyzer in deep mode.
  Simplify "make analyze" since $(PATH_TO_SCAN_BUILD) does not
  need to be set.

Source/ThirdParty/ANGLE:

* ANGLE.xcodeproj/project.pbxproj:
- Treat "analyze" the same as "build" for "ACTION" environment
  variable.

Source/WebCore:

* Scripts/generate-derived-sources.sh:
- Treat "analyze" the same as "build" for "ACTION" environment
  variable.

Source/WebKit:

* Scripts/generate-derived-sources.sh:
* WebKit.xcodeproj/project.pbxproj:
- Treat "analyze" the same as "build" for "ACTION" environment
  variable.

Source/WebKitLegacy/mac:

* migrate-headers.sh:
- Treat "analyze" the same as "build" for "ACTION" environment
  variable.

Tools:

* DumpRenderTree/Scripts/generate-derived-sources.sh:
* WebKitTestRunner/Scripts/generate-derived-sources.sh:
- Treat "analyze" the same as "build" for "ACTION" environment
  variable.


Canonical link: https://commits.webkit.org/240548@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281088 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-16 16:31:24 +00:00
Kimmo Kinnunen 87795dfc3b ANGLE Cocoa compiles contents of ContextEAGL on mac
https://bugs.webkit.org/show_bug.cgi?id=228987

Patch by Kimmo Kinnunen <kkinnunen@apple.com> on 2021-08-12
Reviewed by Kenneth Russell.

Add include guards that are consistent with other EAGL files.

* src/libANGLE/renderer/gl/eagl/ContextEAGL.cpp:

Canonical link: https://commits.webkit.org/240468@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280962 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-12 13:01:27 +00:00
Kimmo Kinnunen 349caca5b9 ANGLE Cocoa compiles parts of HLSL translator, vulkan translator, libgl api, capture redundantly
https://bugs.webkit.org/show_bug.cgi?id=228986

Patch by Kimmo Kinnunen <kkinnunen@apple.com> on 2021-08-12
Reviewed by Kenneth Russell.

Remove following from ANGLE (dynamic) target:
- HLSL translator and tree ops used only by it
- Vulkan translator output
- libgl API validation implementation
- API trace capture implementation (was only partially compiled)

The features are not part of Cocoa use of ANGLE, and should
not be compiled as such.
Does not affect the binary size more than few kilobytes.

* ANGLE.xcodeproj/project.pbxproj:
* Configurations/ANGLE-dynamic.xcconfig:

Canonical link: https://commits.webkit.org/240465@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280959 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-12 10:16:20 +00:00
Kyle Piddington 98052bba59 Avoid infinite recursion when command buffer creation fails
https://bugs.webkit.org/show_bug.cgi?id=228978
<rdar://79224824>

Reviewed by Kenneth Russell.

In cases where the MTLCommandBuffer is not a valid metal object,
we can end up in an infinite recursive loop during draw call setup. Refactor setupDraw to take no more than two attempts through the setup function.

Testing: Ran WebGL tests, use case samples. Set up synthetic
repro forcing bail out path, saw WebGL content fail to render
instead of a web process crash.

* src/libANGLE/renderer/metal/ContextMtl.h:
* src/libANGLE/renderer/metal/ContextMtl.mm:
(rx::ContextMtl::setupDraw):
(rx::ContextMtl::setupDrawImpl):


Canonical link: https://commits.webkit.org/240444@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280926 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-11 20:04:36 +00:00
Kimmo Kinnunen c40e806df2 Cherry-pick ANGLE: Revise WebGL's shaderSource validation
https://bugs.webkit.org/show_bug.cgi?id=228951

Patch by Kimmo Kinnunen <kkinnunen@apple.com> on 2021-08-11
Reviewed by Kenneth Russell.

Source/ThirdParty/ANGLE:

Cherry-pick ANGLE commit: b4fd46288aa65d61dc9c7140c7d1cdba3f4cdf9a
From: Kenneth Russell <kbr@chromium.org>
Date: Wed, 27 Jan 2021 15:56:58 -0800
Revise WebGL's shaderSource validation.

Per discussion in the WebGL working group, shaderSource no longer
generates INVALID_VALUE for sources containing characters outside the
ESSL character set. Compilation and/or linking is still specified to
fail when illegal constructs are used.

With this change, https://github.com/KhronosGroup/WebGL/pull/3206
passes with the passthrough command decoder.

Revise WebGL compatibility tests to follow the new rules.

* src/libANGLE/validationES2.cpp:
(gl::ValidateShaderSource):
* src/tests/gl_tests/WebGLCompatibilityTest.cpp:

LayoutTests:

Fixes tests:
webgl/1.0.x/conformance/misc/invalid-passed-params.html
webgl/1.0.x/conformance/glsl/bugs/character-set.html
webgl/2.0.y/conformance/misc/invalid-passed-params.html
webgl/2.0.y/conformance/glsl/bugs/character-set.html

* TestExpectations:

Canonical link: https://commits.webkit.org/240428@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280904 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-11 11:20:55 +00:00
Russell Epstein 788086b3b8 Versioning.
WebKit-7612.2.1

Canonical link: https://commits.webkit.org/240370@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280791 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-09 20:07:12 +00:00
Kocsen Chung 9a66910b77 Versioning.
WebKit-7612.2.1

Canonical link: https://commits.webkit.org/240364@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280780 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-09 16:39:27 +00:00
Russell Epstein e09283eaa2 Versioning.
WebKit-7612.1.27

Canonical link: https://commits.webkit.org/240068@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280428 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-29 17:12:03 +00:00
Dean Jackson 070b8db9d0 3.5 MB system-wide footprint impact due to thread-locals in libANGLE
https://bugs.webkit.org/show_bug.cgi?id=228240
rdar://79504783

Reviewed by Ken Russell and Geoff Garen.

Apple's dyld has a bug where thread_local variables are dirtied on
process launch, causing a memory regression. Work around this
temporarily in ANGLE by using pthread thread local storage.

I don't expect this to be upstreamed to ANGLE unless they
want it. If it isn't, this patch will have to be applied until
the dyld bug is fixed.

* src/libANGLE/Context.cpp: Implement some methods to get/set what was
the global variable gCurrentValidContext.
(gl::GetCurrentValidContextTLSIndex):
(gl::GetCurrentValidContextTLS):
(gl::SetCurrentValidContextTLS):
(gl::Context::setContextLost):
* src/libANGLE/Context.h:
* src/libGLESv2/global_state.cpp: Ditto, but for gCurrentThread.
(egl::GetCurrentThreadTLSIndex):
(egl::GetCurrentThreadTLS):
(egl::SetCurrentThreadTLS):
(egl::GetCurrentThread):
(egl::SetContextCurrent):
* src/libGLESv2/global_state.h:
(gl::GetGlobalContext):
(gl::GetValidGlobalContext):

Canonical link: https://commits.webkit.org/239996@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280349 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-27 21:36:17 +00:00
Kyle Piddington 92929e41e3 Build Default Metal library offline
https://bugs.webkit.org/show_bug.cgi?id=227333

<rdar://79923371>

This patch compiles and creates a Metal library at build time, storing
the library as a compiled binary file. This library is baked into the dylib,
and is loaded at context creation time.

Unlike the previous version of this patch, this patch does not save or store the .metallib on disk, but rather
bakes it into a binary.

Fixed internal build breaks by skipping Metallib bake script.

Reviewed by Kenneth Russell.

* ANGLE.xcodeproj/project.pbxproj:
* Configurations/ANGLE-dynamic.xcconfig:
* src/libANGLE/renderer/metal/DisplayMtl.mm:
(rx::DisplayMtl::initializeShaderLibrary):
* src/libANGLE/renderer/metal/mtl_utils.h:


Canonical link: https://commits.webkit.org/239752@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280010 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-16 23:59:37 +00:00
Truitt Savell 4add64cb47 Unreviewed, reverting r279980.
Broke Internal Builds

Reverted changeset:

"Build Default Metal library offline"
https://bugs.webkit.org/show_bug.cgi?id=227333
https://commits.webkit.org/r279980

Canonical link: https://commits.webkit.org/239729@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279986 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-16 16:13:49 +00:00
Kyle Piddington 9b88bc8fb9 Build Default Metal library offline
https://bugs.webkit.org/show_bug.cgi?id=227333

<rdar://79923371>

This patch compiles and creates a Metal library at build time, storing
the library as a compiled binary file. This library is baked into the dylib,
and is loaded at context creation time.

Unlike the previous version of this patch, this patch does not save or store the .metallib on disk, but rather
bakes it into a binary.

Reviewed by Kenneth Russell.

* ANGLE.xcodeproj/project.pbxproj:
* Configurations/ANGLE-dynamic.xcconfig:
* src/libANGLE/renderer/metal/DisplayMtl.mm:
(rx::DisplayMtl::initializeShaderLibrary):
* src/libANGLE/renderer/metal/mtl_utils.h:


Canonical link: https://commits.webkit.org/239723@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279980 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-16 07:19:05 +00:00
Kyle Piddington 87c3878e26 WebGL2 demo doesn't work due to failing compilation to metal backend
https://bugs.webkit.org/show_bug.cgi?id=226865
Source/ThirdParty/ANGLE:

Fix translation of struct-arrays to contain the array type as well.
Reviewed by Dean Jackson.

* src/compiler/translator/TranslatorMetalDirect/SeparateCompoundStructDeclarations.cpp:

LayoutTests:

Fix translation of struct-arrays to contain the array type as well.
Reviewed by Dean Jackson.

* fast/canvas/webgl/shader-with-struct-array.html: Added.
* fast/canvas/webgl/shader-with-struct-array-expected.txt: Added.


Canonical link: https://commits.webkit.org/239711@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279968 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-15 22:56:57 +00:00
Ruben Turcios 533b089dc9 Versioning.
WebKit-7612.1.25

Canonical link: https://commits.webkit.org/239691@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279948 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-15 16:09:01 +00:00
Kyle Piddington 4e0e6820ad rAF driven WebGL submits excessive amount of GPU work when frames are slow
https://bugs.webkit.org/show_bug.cgi?id=227059

Reviewed by Dean Jackson.

Advertise GL_ARB_sync for the Metal backend.
    Since GL_ARB_sync is core in OpenGL ES 3.0 and the Metal backend advertises OpenGL ES 3.0,
    the API must be working already.

Limit in-flight WebGL frames to three frames. Do not continue preparation for display
    until the commands for the oldest frame have been executed by the GPU.

This limits the impact slow frames have, especially in the
    case where the compositor skip frames and WebKit would issue a new slow frame
    on top of the skipped frame.

Source/ThirdParty/ANGLE:

	An additional change ensures that Nvidia configs, which do not support MTLEvents
	to a level of conformance required (See http://crbug.com/1136673), continue to run. The more powerful eGPUs will not experience throttling to the same level as integrated GPUS.
* src/libANGLE/renderer/metal/DisplayMtl.mm:
(rx::DisplayMtl::initializeExtensions const):

Source/WebCore:

An additional change ensures that Nvidia configs, which do not support MTLEvents
to a level of conformance required (See http://crbug.com/1136673), continue to run. The more powerful eGPUs will not experience throttling to the same level as integrated GPUS.

* Headers.cmake:
* WebCore.xcodeproj/project.pbxproj:
* platform/graphics/GraphicsContextGLAttributes.h:
* platform/graphics/angle/GraphicsContextGLANGLE.cpp:
(WebCore::GraphicsContextGLOpenGL::waitAndUpdateOldestFrame):
* platform/graphics/angle/GraphicsContextGLANGLEUtilities.h:
(WebCore::ScopedGLFence::ScopedGLFence):
(WebCore::ScopedGLFence::~ScopedGLFence):
(WebCore::ScopedGLFence::operator=):
(WebCore::ScopedGLFence::reset):
(WebCore::ScopedGLFence::abandon):
(WebCore::ScopedGLFence::fenceSync):
(WebCore::ScopedGLFence::operator GLsync const):
(WebCore::ScopedGLFence::operator bool const):
* platform/graphics/cocoa/GraphicsContextGLOpenGLCocoa.mm:
(WebCore::InitializeEGLDisplay):
(WebCore::GraphicsContextGLOpenGL::GraphicsContextGLOpenGL):
(WebCore::GraphicsContextGLOpenGL::~GraphicsContextGLOpenGL):
(WebCore::GraphicsContextGLOpenGL::prepareForDisplay):
* platform/graphics/opengl/GraphicsContextGLOpenGL.h:


Canonical link: https://commits.webkit.org/239635@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279883 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-13 19:28:19 +00:00
Kyle Piddington bae773d753 WebGL shader link error in iOS 15 beta: "Internal error compiling shader with Metal backend"
https://bugs.webkit.org/show_bug.cgi?id=227723

The sequence operator can be used to combine statements. Our initial
logic did not account for this.
Source/ThirdParty/ANGLE:

Reviewed by Dean Jackson.

* src/compiler/translator/TranslatorMetalDirect/SeparateCompoundExpressions.cpp:
(sh::Separator::isStandaloneExpr):

LayoutTests:

Reviewed by Dean Jackson.

* fast/canvas/webgl/shader-with-comma-op-expected.txt: Added.
* fast/canvas/webgl/shader-with-comma-op.html: Added.


Canonical link: https://commits.webkit.org/239469@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279656 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-07 19:35:41 +00:00
Ruben Turcios ec22083ba8 Versioning.
WebKit-7612.1.24

Canonical link: https://commits.webkit.org/239433@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279612 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-06 20:19:59 +00:00
Kyle Piddington ad942b15d4 REGRESSION (r279466): [Big Sur] webgl/1.0.3/conformance & webgl/2.0.0/conformance are failing
https://bugs.webkit.org/show_bug.cgi?id=227596
Provide Intel workaround for Big Sur systems. Atan and invariant have
issues on older systems, and require us to disable fastmath to produce correct results.

Reviewed by Kenneth Russell.

* include/platform/FeaturesMtl.h:
* src/compiler/translator/TranslatorMetalDirect.h:
(sh::TranslatorMetalReflection::reset):
* src/compiler/translator/TranslatorMetalDirect/EmitMetal.cpp:
(GenMetalTraverser::emitPostQualifier):
(GenMetalTraverser::visitUnary):
(GenMetalTraverser::visitAggregate):
* src/libANGLE/renderer/metal/DisplayMtl.mm:
(rx::DisplayMtl::initializeFeatures):
* src/libANGLE/renderer/metal/ProgramMtl.h:
(rx::ProgramMtl::getTranslatedShaderInfo const):
* src/libANGLE/renderer/metal/ProgramMtl.mm:
* src/libANGLE/renderer/metal/mtl_glslang_mtl_utils.h:
* src/libANGLE/renderer/metal/mtl_glslang_mtl_utils.mm:
(rx::mtl::GlslangGetMSL):
* src/libANGLE/renderer/metal/mtl_render_utils.h:
* src/libANGLE/renderer/metal/mtl_render_utils.mm:
(rx::mtl::TransformFeedbackUtils::createMslXfbLibrary):
(rx::mtl::TransformFeedbackUtils::getTransformFeedbackRenderPipeline):
* src/libANGLE/renderer/metal/mtl_utils.h:
* src/libANGLE/renderer/metal/mtl_utils.mm:
(rx::mtl::CreateShaderLibrary):


Canonical link: https://commits.webkit.org/239429@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279606 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-06 19:33:10 +00:00
Ben Nham 3339882450 Unreviewed, reverting r279172.
Broke WebGL context construction on some devices.

Reverted changeset:

"rAF driven WebGL submits excessive amount of GPU work when frames are slow"
https://bugs.webkit.org/show_bug.cgi?id=227059
https://commits.webkit.org/r279172



Canonical link: https://commits.webkit.org/239349@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279497 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-02 06:01:51 +00:00
Kyle Piddington 3fb9dec121 BabylonJS Under water demo is slower than it should be on Intel
https://bugs.webkit.org/show_bug.cgi?id=227226

Remove fastMath restriction on Intel
Removing fastmath in all scenarios leads to unacceptable performance on integrated graphics
Currently, webgl conformance tests and the Safari tests don't have any invariance tests that show invariance issues. deQP tests are similarly passing.
In Metal-ANGLE, gl_position and gl_fragcoord are valid attributes to be marked as invariant. All others will be ignored.

Reviewed by Kenneth Russell.

* src/compiler/translator/TranslatorMetalDirect/EmitMetal.cpp:
(GenMetalTraverser::emitPostQualifier):
* src/libANGLE/renderer/metal/mtl_utils.mm:
(rx::mtl::CreateShaderLibrary):


Canonical link: https://commits.webkit.org/239322@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279466 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-01 17:03:17 +00:00
Kimmo Kinnunen df5857f351 ASSERT in webgl/1.0.x/conformance/glsl/misc/uninitialized-local-global-variables.html IdGen ASSERT(*base != '_');
https://bugs.webkit.org/show_bug.cgi?id=227482

Patch by Kimmo Kinnunen <kkinnunen@apple.com> on 2021-06-30
Reviewed by Kenneth Russell.

Give unnamed structs normal "_<number>" name.
The original code thought it gave "ANGLE__unnamed<number>", but in reality it
gave "__unnamed<number>".
Since other constructs already create names of form "_<number>", it is unwarranted to
special case this particular case to give "_unnamed<number>" or "ANGLE_unnamed<number" or
"ANGLE_<number>".

* src/compiler/translator/TranslatorMetalDirect/SeparateCompoundStructDeclarations.cpp:
* src/tests/compiler_tests/MSLOutput_test.cpp:
(TEST_F):

Canonical link: https://commits.webkit.org/239287@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279426 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-30 18:33:36 +00:00
Kimmo Kinnunen 63be7cf4ee ANGLE Metal primitive restart range computation could index with size_t
https://bugs.webkit.org/show_bug.cgi?id=227449

Patch by Kimmo Kinnunen <kkinnunen@apple.com> on 2021-06-29
Reviewed by Kenneth Russell.

Make the `calculateRestartRanges()` a bit simpler in order
for it to be easier to understand.

* src/libANGLE/renderer/metal/BufferMtl.h:
(rx::IndexRange::IndexRange):
Add documentation what the mtl::IndexRange is.
Add constructor so that `std::vector::emplace_back()` works.

* src/libANGLE/renderer/metal/BufferMtl.mm:
(rx::calculateRestartRanges):
Index with size_t to make it simpler to understand if the index
overflows or not.
Use reinterpret_cast in order to not accidentally cast away
const from `mtl::BufferRef::mapReadOnly()`.
Skip the non-marker elements with `continue` to avoid deep nesting.
Give a name to the restart range marker value.
Remove intermediate variable `value = bufferData[i]` as it is never
used more than once. This simplifies the code as the do-while loop
does not need to check the if condition as the loop ending condition
already checks.
Make the array a returned result instead of out variable.

(rx::BufferMtl::getRestartIndices):

Canonical link: https://commits.webkit.org/239239@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279373 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-29 13:53:43 +00:00
Kimmo Kinnunen 3011fc4aa4 ANGLE Metal primitive restart range computation should not be done unless primitive restart is enabled
https://bugs.webkit.org/show_bug.cgi?id=227452

Patch by Kimmo Kinnunen <kkinnunen@apple.com> on 2021-06-29
Reviewed by Kenneth Russell.

Primitive restart needs to scan the whole index buffer for values.
This should not be done unless needed.

* src/libANGLE/renderer/metal/VertexArrayMtl.mm:
(rx::VertexArrayMtl::getDrawIndices):
First check for primitive restart enabledness.
Compute the primitive restart values after this.
The algoritm should succeed when the count of primitive
restart ranges is zero, and it does not do much of work.
Use the restart range vector as reference, so that no copy
would be done.
Add spaces the if statements, comments and references.
Move the else arm of the if statement with return statement
to body of the function to reduce nesting.

Canonical link: https://commits.webkit.org/239238@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279372 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-29 13:52:16 +00:00
Kimmo Kinnunen 4690710aea iPhone 6S - iOS 15.0 - unable to retrieve WebGL2 context
https://bugs.webkit.org/show_bug.cgi?id=226975
rdar://78966563

Patch by Kimmo Kinnunen <kkinnunen@apple.com> on 2021-06-28
Reviewed by Kenneth Russell.

Limit the OpenGL ES 3.0 contexts to iOS GPU Family 3, not
4.

The limit was most likely added to guard sample_compare
lod_options properties .lod and .gradient. However, these
are always supported on iOS.

Currently there is already ES 3.0 features implemented
in ANGLE that are guarded by iOS GPU Family 3.

Fixes WebGL 2.0 to work on iPhone6s and similar
devices  (A9, A9X).

* src/libANGLE/renderer/metal/DisplayMtl.mm:
(rx::DisplayMtl::getMaxSupportedESVersion const):

Canonical link: https://commits.webkit.org/239202@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279327 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-28 10:03:13 +00:00
Kimmo Kinnunen e884da4b86 ANGLE Metal index buffer left mapped when building primitive restart ranges
https://bugs.webkit.org/show_bug.cgi?id=227371

Patch by Kimmo Kinnunen <kkinnunen@apple.com> on 2021-06-28
Reviewed by Kenneth Russell.

* src/libANGLE/renderer/metal/BufferMtl.mm:
(rx::calculateRestartRanges):
Add unmap.

Canonical link: https://commits.webkit.org/239201@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279326 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-28 10:02:43 +00:00
Myles C. Maxfield a1956bafd6 [macOS] WebGL content is unable to use the discrete GPU
https://bugs.webkit.org/show_bug.cgi?id=227408
<rdar://problem/79216506>

Reviewed by Dean Jackson.

Source/ThirdParty/ANGLE:

There appears to be a key collision:

Source/ThirdParty/ANGLE/include/platform/PlatformMethods.h:#define EGL_PLATFORM_ANGLE_PLATFORM_METHODS_ANGLEX 0x3482
Source/ThirdParty/ANGLE/include/EGL/eglext_angle.h:#define EGL_POWER_PREFERENCE_ANGLE 0x3482

Both these keys seem to be accepted by EGL_GetPlatformDisplayEXT().

This patch just changes the value of one of them to a value I picked out of a hat, just so they don't conflict.
We should work with upstream to either:
A) Find a better solution (maybe disambiguate these values based on which function is accepting them), or
B) Make a robust way to make sure keys don't collide in the future.

* include/platform/PlatformMethods.h:

Source/WebCore:

Simply pass along the power preference into ANGLE. This is read in
DisplayMtl::getMetalDeviceMatchingAttribute().

No new tests. I _think_ this is untestable, because the web exposed power preference is being set correctly.
We’re correctly reporting to the web content that they have successfully asked for a high power context.
We’re just not honoring that internally. If the test is a performance test, or checks the renderer string,
that test would be hardware-dependent, and couldn’t be a regular layout test.

* platform/graphics/cocoa/GraphicsContextGLOpenGLCocoa.mm:
(WebCore::InitializeEGLDisplay):


Canonical link: https://commits.webkit.org/239179@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279303 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-26 00:39:22 +00:00
Ruben Turcios 8e12736b4b Versioning.
WebKit-7612.1.21

Canonical link: https://commits.webkit.org/239143@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279264 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-25 01:27:32 +00:00
Ruben Turcios a1d8878c5f Versioning.
WebKit-7612.1.22

Canonical link: https://commits.webkit.org/239142@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279263 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-25 01:26:16 +00:00
John Cunningham e58a7f2a96 [ANGLE Metal] - Set barriers on transform feedback buffers only up to the in use buffer count
https://bugs.webkit.org/show_bug.cgi?id=227272
<rdar://79587861>

Patch by John Cunningham <johncunningham@apple.com> on 2021-06-24
Reviewed by Dean Jackson.

* src/libANGLE/renderer/metal/ContextMtl.mm:
(rx::ContextMtl::onEndTransformFeedback):

Canonical link: https://commits.webkit.org/239135@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279251 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-24 23:11:48 +00:00
Kyle Piddington 69d6623083 Fix incorrect indexing / out of bounds access in getRestartIndices
https://bugs.webkit.org/show_bug.cgi?id=227274
<rdar://79244789>

In the case where a restart index is present in the last element of an index array, we can accidently
access out of bounds. Fix this by checking boundaries, and fixing other indexing errors

Tests: Ran deqp/functional/gles3/primitiverestart suite. Passed 8 tests.

Reviewed by Dean Jackson.

* src/libANGLE/renderer/metal/BufferMtl.mm:
(rx::calculateRestartRanges):


Canonical link: https://commits.webkit.org/239099@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279213 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-24 06:52:56 +00:00
Kyle Piddington 18bb7353fd Guard against compile failures of the default libraries
https://bugs.webkit.org/show_bug.cgi?id=227239
<rdar://79037623>

Under certain events (High memory usage), the MTLCompilerService can fail when creating the default library.
Guard against nil pipelines by failing GL calls instead, if this happens. While this can create rendering artifacts
due to missing blits / conversions, this can at least avoid crashing the process.

Reviewed by Dean Jackson.

* src/libANGLE/renderer/metal/mtl_render_utils.h:
* src/libANGLE/renderer/metal/mtl_render_utils.mm:
(rx::mtl::ClearUtils::setupClearWithDraw):
(rx::mtl::ClearUtils::clearWithDraw):
(rx::mtl::ColorBlitUtils::setupColorBlitWithDraw):
(rx::mtl::ColorBlitUtils::blitColorWithDraw):
(rx::mtl::DepthStencilBlitUtils::setupDepthStencilBlitWithDraw):
(rx::mtl::DepthStencilBlitUtils::blitDepthStencilWithDraw):
(rx::mtl::VertexFormatConversionUtils::setupCommonConvertVertexFormatToFloat):
(rx::mtl::VertexFormatConversionUtils::expandVertexFormatComponentsVS):
(rx::mtl::VertexFormatConversionUtils::setupCommonExpandVertexFormatComponents):


Canonical link: https://commits.webkit.org/239098@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279212 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-24 06:51:14 +00:00
Kimmo Kinnunen 015174d173 rAF driven WebGL submits excessive amount of GPU work when frames are slow
https://bugs.webkit.org/show_bug.cgi?id=227059
<rdar://problem/79385858>

Patch by Kimmo Kinnunen <kkinnunen@apple.com> on 2021-06-23
Reviewed by Kenneth Russell.

Source/ThirdParty/ANGLE:

Advertise GL_ARB_sync for the Metal backend.
Since GL_ARB_sync is core in OpenGL ES 3.0 and the Metal backend advertises OpenGL ES 3.0,
the API must be working already.

* src/libANGLE/renderer/metal/DisplayMtl.mm:
(rx::DisplayMtl::initializeExtensions const):

Source/WebCore:

Limit in-flight WebGL frames to three frames. Do not continue preparation for display
until the commands for the oldest frame have been executed by the GPU.

This limits the impact slow frames have, especially in the
case where the compositor skip frames and WebKit would issue a new slow frame
on top of the skipped frame.

No new tests, tested manually with the pages referenced from the bugs.

* WebCore.xcodeproj/project.pbxproj:
* platform/graphics/angle/GraphicsContextGLANGLE.cpp:
(WebCore::GraphicsContextGLOpenGL::waitAndUpdateOldestFrame):
* platform/graphics/angle/GraphicsContextGLANGLEUtilities.h:
(WebCore::ScopedGLFence::ScopedGLFence):
(WebCore::ScopedGLFence::operator=):
(WebCore::ScopedGLFence::~ScopedGLFence):
(WebCore::ScopedGLFence::reset):
(WebCore::ScopedGLFence::abandon):
(WebCore::ScopedGLFence::fenceSync):
(WebCore::ScopedGLFence::operator GLsync const):
* platform/graphics/cocoa/GraphicsContextGLOpenGLCocoa.mm:
(WebCore::GraphicsContextGLOpenGL::GraphicsContextGLOpenGL):
(WebCore::GraphicsContextGLOpenGL::~GraphicsContextGLOpenGL):
(WebCore::GraphicsContextGLOpenGL::prepareForDisplay):
* platform/graphics/opengl/GraphicsContextGLOpenGL.h:

Canonical link: https://commits.webkit.org/239069@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279172 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-23 17:08:51 +00:00
Dean Jackson 04dd9264c5 [ANGLE] Support importing external MTLTextures
https://bugs.webkit.org/show_bug.cgi?id=226690

Reviewed by Tim Horton.

Support MTLTextures as GL textures.
Merge https://chromium-review.googlesource.com/c/angle/angle/+/2820178

* ANGLE.xcodeproj/project.pbxproj:
* extensions/EGL_ANGLE_metal_texture_client_buffer.txt: Added.
* include/EGL/eglext_angle.h:
* src/common/utilities.cpp:
(egl::IsExternalImageTarget):
* src/libANGLE/Caps.cpp:
(egl::DisplayExtensions::getStrings const):
* src/libANGLE/Caps.h:
* src/libANGLE/renderer/metal/BUILD.gn:
* src/libANGLE/renderer/metal/DisplayMtl.h:
* src/libANGLE/renderer/metal/DisplayMtl.mm:
(rx::DisplayMtl::createImage):
(rx::DisplayMtl::createExternalImageSibling):
(rx::DisplayMtl::generateExtensions const):
(rx::DisplayMtl::validateImageClientBuffer const):
(rx::DisplayMtl::initializeExtensions const):
* src/libANGLE/renderer/metal/ImageMtl.h: Added.
(rx::TextureImageSiblingMtl::getTexture const):
(rx::TextureImageSiblingMtl::getFormatMtl const):
(rx::ImageMtl::getTexture const):
(rx::ImageMtl::getImageTextureType const):
(rx::ImageMtl::getImageLevel const):
(rx::ImageMtl::getImageLayer const):
* src/libANGLE/renderer/metal/ImageMtl.mm: Added.
(rx::TextureImageSiblingMtl::TextureImageSiblingMtl):
(rx::TextureImageSiblingMtl::~TextureImageSiblingMtl):
(rx::TextureImageSiblingMtl::ValidateClientBuffer):
(rx::TextureImageSiblingMtl::initialize):
(rx::TextureImageSiblingMtl::initImpl):
(rx::TextureImageSiblingMtl::onDestroy):
(rx::TextureImageSiblingMtl::getFormat const):
(rx::TextureImageSiblingMtl::isRenderable const):
(rx::TextureImageSiblingMtl::isTexturable const):
(rx::TextureImageSiblingMtl::getSize const):
(rx::TextureImageSiblingMtl::getSamples const):
(rx::ImageMtl::ImageMtl):
(rx::ImageMtl::~ImageMtl):
(rx::ImageMtl::onDestroy):
(rx::ImageMtl::initialize):
(rx::ImageMtl::orphan):
* src/libANGLE/renderer/metal/RenderBufferMtl.mm:
(rx::RenderbufferMtl::setStorageEGLImageTarget):
* src/libANGLE/renderer/metal/TextureMtl.mm:
(rx::TextureMtl::setEGLImageTarget):
* src/libANGLE/renderer/metal/gen_mtl_format_table.py:
(gen_image_map_switch_mac_case.gen_format_assign_code):
(gen_image_mtl_to_angle_switch_string):
(main):
* src/libANGLE/renderer/metal/mtl_common.h:
* src/libANGLE/renderer/metal/mtl_format_table_autogen.mm:
(rx::mtl::Format::MetalToAngleFormatID):
* src/libANGLE/renderer/metal/mtl_format_utils.h:
* src/libANGLE/validationEGL.cpp:
(egl::ValidateCreateImage):
* src/tests/BUILD.gn:
* src/tests/gl_tests/ImageTest.cpp:
(angle::TEST_P):
* src/tests/gl_tests/ImageTestMetal.mm: Added.
(angle::ScopeMetalTextureRef::ScopeMetalTextureRef):
(angle::ScopeMetalTextureRef::~ScopeMetalTextureRef):
(angle::ScopeMetalTextureRef::get const):
(angle::ScopeMetalTextureRef::operator id<MTLTexture> const):
(angle::ScopeMetalTextureRef::operator=):
(angle::ScopeMetalTextureRef::release):
(angle::CreateMetalTexture2D):
(angle::ImageTestMetal::ImageTestMetal):
(angle::ImageTestMetal::getMtlDevice):
(angle::ImageTestMetal::createMtlTexture2D):
(angle::ImageTestMetal::verifyResultsTexture):
(angle::ImageTestMetal::verifyResults2D):
(angle::ImageTestMetal::reinterpretHelper):
(angle::ImageTestMetal::hasImageNativeMetalTextureExt const):
(angle::ImageTestMetal::hasOESExt const):
(angle::ImageTestMetal::hasBaseExt const):
(angle::ImageTestMetal::sourceMetalTarget2D_helper):
(angle::TEST_P):

Canonical link: https://commits.webkit.org/239052@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279143 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-22 20:33:10 +00:00
Russell Epstein 6fbe355662 Versioning.
WebKit-7612.1.21

Canonical link: https://commits.webkit.org/239007@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279090 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-21 23:57:37 +00:00
Kyle Piddington e4a2ce1458 [Metal ANGLE] Shaders with reserved metal keywords do not translate, nor do shaders with struct and variable names that are the same except prefixed by an underscore
https://bugs.webkit.org/show_bug.cgi?id=226660

Source/ThirdParty/ANGLE:

Fix keyword translation problem by correcting symbol space. This avoids renaming structs unnecessarily

Reviewed by Dean Jackson.

* src/compiler/translator/TranslatorMetalDirect/RewriteKeywords.cpp:
(sh::Rewriter::createRenamed):

LayoutTests:

Reviewed by Dean Jackson.

* fast/canvas/webgl/shader-with-reserved-keyword-expected.txt: Added.
* fast/canvas/webgl/shader-with-reserved-keyword.html: Added.


Canonical link: https://commits.webkit.org/238941@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279016 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-17 22:35:36 +00:00
Kimmo Kinnunen 024e766395 ANGLE Metal gl sync objects do not work in case of listener being needed
https://bugs.webkit.org/show_bug.cgi?id=227024

Patch by Kimmo Kinnunen <kkinnunen@apple.com> on 2021-06-16
Reviewed by Per Arne Vollan.

Source/ThirdParty/ANGLE:

Add an assert to notice when MTLSharedEventListener instantiation
fails. Without this, the fence implementation would not signal
the completion until the timeout would pass.

* src/libANGLE/renderer/metal/DisplayMtl.mm:
(rx::DisplayMtl::getOrCreateSharedEventListener):

Source/WebKit:

Make MTLSharedEventListener instantiatable by adding IOKit messages
39 and 40 to IOSurfaceRootUserClientMessageFilter.

The MTLSharedEventListener init would fail, and ANGLE would fail to
make the shared event signal the event listener. This would cause
all glClientWaitSync calls to wait the full timeout time.

No new tests, WebGL2 sync object implementation does not support
non-zero timeout values that would be needed to detect the failure.
Standalone test-cases would need the test runner being sandboxed,
which is not implemented currently.

* WebProcess/com.apple.WebProcess.sb.in:

Canonical link: https://commits.webkit.org/238860@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278929 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-16 11:52:04 +00:00
Kimmo Kinnunen b42dae08f4 ANGLE Metal AutoObjCPtr == nullptr comparison is inverted
https://bugs.webkit.org/show_bug.cgi?id=227026

Patch by Kimmo Kinnunen <kkinnunen@apple.com> on 2021-06-16
Reviewed by Anders Carlsson.

Make it more correct and add != nullptr variant for
consistency.

Use std::nullptr_t instead of const std::nullptr_t &
in all functions for consistency.

* src/libANGLE/renderer/metal/mtl_common.h:
(rx::mtl::AutoObjCPtr::operator== const):
(rx::mtl::AutoObjCPtr::operator!= const):

Canonical link: https://commits.webkit.org/238857@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278926 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-16 08:40:42 +00:00
Kyle Piddington 32f797aa14 Tensorflow.js Broken in Safari 15
https://bugs.webkit.org/show_bug.cgi?id=226953

Tensorflow shaders use a 'NAN' uniform. This is a reserved keyword
in metal. Add NAN to the reserved list.

'inf' constants need to be replaced with INFINITY, much like nan constants need to be replaced with NAN
Reviewed by Kenneth Russell.

* src/compiler/translator/TranslatorMetalDirect.cpp:
(sh::GetMslKeywords):


Canonical link: https://commits.webkit.org/238839@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278898 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-15 21:02:52 +00:00
Alex Christensen 1fb2b472d3 Fix typo in r276318
https://bugs.webkit.org/show_bug.cgi?id=227041
<rdar://76284889>

Reviewed by Chris Dumez.

@ uses the string @(DYLIB_INSTALL_NAME_BASE)
$ uses the value of the environment variable.
This turns out to be an important difference.

* Configurations/ANGLE-dynamic.xcconfig:



Canonical link: https://commits.webkit.org/238835@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278893 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-15 20:12:47 +00:00
Ruben Turcios bd708bb50d Versioning.
WebKit-7612.1.20

Canonical link: https://commits.webkit.org/238791@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278844 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-14 18:44:12 +00:00
Eleni Maria Stea fc53e9fdf2 ANGLE EGL and GLES libraries should link with lib dl.
https://bugs.webkit.org/show_bug.cgi?id=226920

Patch by Eleni Maria Stea <estea@igalia.com> on 2021-06-11
Reviewed by Kenneth Russell.

GLES and EGL that are generated from ANGLE should link
with libdl because they use dlsym and dlopen. Also,
with the updated CMakeLists.txt we can safely link with libEGL
when USE_ANGLE_WEBGL is set because the symbols of EGL are now
found.

* CMakeLists.txt:

Canonical link: https://commits.webkit.org/238727@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278768 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-11 18:08:32 +00:00
Don Olmstead b24fb52704 [CMake] Make ANGLE library types configurable
https://bugs.webkit.org/show_bug.cgi?id=226840

Reviewed by Kenneth Russell.

The type for ANGLE's libraries was being hard coded. Now the libraries can be set by
specifying the _LIBRARY_TYPE which defaults to STATIC. Windows platforms override this
and use SHARED libraries.

Additionally make compiling ANGLE's EGL library contingent on USE_ANGLE_EGL being enabled
since its not used otherwise.

* CMakeLists.txt:
* PlatformFTW.cmake:
* PlatformWin.cmake:


Canonical link: https://commits.webkit.org/238689@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278726 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-10 20:17:19 +00:00
Ruben Turcios 20307a3cb5 Versioning.
WebKit-7612.1.18

Canonical link: https://commits.webkit.org/238565@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278567 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-07 19:46:05 +00:00
Kyle Piddington eebcad1e1b Add 'mix' override with bool-vectors to MSL translator
https://bugs.webkit.org/show_bug.cgi?id=226366

Source/ThirdParty/ANGLE:

Reviewed by Dean Jackson.

Add in 'mix' overrides, and logic for selecting mix with bool when necessary.

* src/compiler/translator/TranslatorMetalDirect/EmitMetal.cpp:
(GetOperatorString):
(GenMetalTraverser::visitAggregate):
* src/compiler/translator/TranslatorMetalDirect/ProgramPrelude.cpp:

LayoutTests:

Add a short test to ensure bool-vectors can be used in mix.
Reviewed by Dean Jackson.

* fast/canvas/webgl/shader-mix-with-bool-expected.txt: Added.


Canonical link: https://commits.webkit.org/238392@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278362 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-02 17:01:48 +00:00
Kyle Piddington aca0cf89c3 [Metal ANGLE] transformFeedback samples on webglsamples.org do not render correctly
https://bugs.webkit.org/show_bug.cgi?id=226285
<rdar://78524773>

Reviewed by Dean Jackson.

Metal ANGLE does not render these samples correctly, for a number of reasons.
For transform_feedback_interleaved and seperated, We need to start a new renderEncoder to get the results from the transform feedback.
for transform_feedback-seperated_2, we need to invalidate the current render pass descriptor in order to switch to the rasterizer-enabled version of the shader.
Testing: Ran all transform feedback tests from deqp suite to ensure no regressions are present.

* src/libANGLE/renderer/metal/ContextMtl.h:
* src/libANGLE/renderer/metal/ContextMtl.mm:
(rx::ContextMtl::drawTriFanArraysWithBaseVertex):
(rx::ContextMtl::drawArraysImpl):
(rx::ContextMtl::drawTriFanElements):
(rx::ContextMtl::prepareForTransformFeedbackPassTwo):
(rx::ContextMtl::drawLineLoopElements):
(rx::ContextMtl::drawElementsImpl):
(rx::ContextMtl::onEndTransformFeedback):
* src/libANGLE/renderer/metal/TransformFeedbackMtl.mm:
(rx::TransformFeedbackMtl::end):


Canonical link: https://commits.webkit.org/238368@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278335 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-02 01:01:06 +00:00
Kimmo Kinnunen df03fa86d7 ANGLE Metal translator pre-rotation code is unused and it asserts when used
https://bugs.webkit.org/show_bug.cgi?id=226262

Patch by Kimmo Kinnunen <kkinnunen@apple.com> on 2021-06-01
Reviewed by Dean Jackson.

Remove the pre-rotation code. It is Android specific and most likely it is useful
only when ANGLE is used as the drawing mechanism for the primary app window picture.
Thus most likely it is not useful in WebKit on Cocoa platforms where the window
server does the compositing.

* src/compiler/translator/TranslatorMetalDirect.cpp:
(sh::TranslatorMetalDirect::translateImpl):
* src/compiler/translator/TranslatorMetalDirect.h:
* src/libANGLE/renderer/metal/ContextMtl.h:
* src/libANGLE/renderer/metal/ContextMtl.mm:
(rx::ContextMtl::handleDirtyDriverUniforms):

Canonical link: https://commits.webkit.org/238335@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278298 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-01 08:01:43 +00:00
Kimmo Kinnunen 76f0c2f930 Cherry-pick ANGLE: Add array bounds checks for WebGL shaders
https://bugs.webkit.org/show_bug.cgi?id=226397

Patch by Kimmo Kinnunen <kkinnunen@apple.com> on 2021-05-31
Reviewed by Dean Jackson.

Cherry-pick ANGLE commit b0d39ba2aba218402ff2f32f6e16f18cf4975ff4
At the moment does not affect any WebKit client.
Makes the code consistent with OpenGL.
Makes it easier to understand same change in Metal backend.

Upstream description:
Add array bounds checks for WebGL shaders
WebGL shaders may contain OOB array accesses which in turn
cause undefined behavior, which may result in security
issues. This was detected as an UNKNOWN READ by UBSAN while
testing with SwANGLE.

* src/libANGLE/renderer/vulkan/ShaderVk.cpp:
(rx::ShaderVk::compile):

Canonical link: https://commits.webkit.org/238333@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278296 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-01 06:18:35 +00:00
Kimmo Kinnunen 571d09e8db ANGLE Metal translator should always collect variables
https://bugs.webkit.org/show_bug.cgi?id=226261

Patch by Kimmo Kinnunen <kkinnunen@apple.com> on 2021-05-28
Reviewed by Dean Jackson.

Always collect the variables when translating GLSL to Metal.
This way tests that invoke translation without SH_VARIABLES still
work.

* src/compiler/translator/TranslatorMetalDirect.cpp:
(sh::TranslatorMetalDirect::translateImpl):
* src/compiler/translator/TranslatorMetalDirect.h:

Canonical link: https://commits.webkit.org/238235@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278192 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 07:15:43 +00:00