src/libANGLE/renderer/metal/mtl_command_buffer.h


Log

Author Commit Date CI Message
Alexey Knyazev a36c459e 2024-08-20T00:00:00 Metal: Remove redundant symbol redeclarations MTLBlitOptionRowLinearPVRTC - macOS 11.0 (min compile 12.0) - iOS/tvOS 9.0 (min compile 17.0) MTLBarrierScope - macOS 10.14 (min compile 12.0) - iOS/tvOS 12.0 (min compile 17.0) MTLBarrierScopeRenderTargets - Moved compile guards to call sites MTLRenderStages, MTLRenderStageVertex, MTLRenderStageFragment - macOS 10.13 (min compile 12.0) - iOS/tvOS 10.0 (min compile 17.0) Bug: angleproject:360147119 Change-Id: I7dac46accde63be486a7de918284bbd6e8367a4e Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5806896 Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Kimmo Kinnunen <kkinnunen@apple.com> Commit-Queue: Alexey Knyazev <lexa.knyazev@gmail.com>
Kimmo Kinnunen 2758d4dc 2024-08-20T16:00:07 Metal: Remove shared event related ifdefs Shared events are supported by iOS 12, macOS 10.14, included in the minimum versions iOS 15, macOS 10.15. Bug: angleproject:360147118 Change-Id: I5b62dade045f9d50864ef1906cb22a18fd09e4da Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5797150 Auto-Submit: Kimmo Kinnunen <kkinnunen@apple.com> Reviewed-by: Alexey Knyazev <lexa.knyazev@gmail.com> Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Le Hoang Quyen 1a191b1d 2024-08-16T17:31:38 Metal: add an option to emulate DontCare loadOp with randomized Clear. This is useful for testing undefined initial values caused by DontCare MTLLoadAction on non-tiled GPUs. Bug: angleproject:42261786 Change-Id: Id5c4a9ee8510a8a9143bdd67e276bfcf2bd7eaa5 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5791386 Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Kenneth Russell <kbr@chromium.org> Commit-Queue: Quyen Le <lehoangquyen@chromium.org>
Le Hoang Quyen ee25dddb 2024-08-09T01:03:26 Metal: Properly clear render pass' attachment with an emulated alpha. When a texture is created with emulated format such as RGB, its alpha channel is initialized to 1 and the write mask is configured such that the alpha value won't be overwritten or set to other values. However, if we use this texture as an attachment in a render pass, and DontCare loadAction is used, the alpha value would be initialized with garbage values. No draw calls within the render pass would change these garbage values because the configured write mask already prevents that. Thus the garbage alpha values would be stored in the memory after the render pass ends. This bug also affects MSRTT's unresolve step, because it uses a draw call to blit the resolve texture to the MSAA texture. However, the alpha write is disabled thus the MSAA texture will remain having garbage alpha values. The fix for this bug is that: if we detect that the texture has emulated format and its loadAction is DontCare, we change it to Clear action to clear the alpha channel to 1. Bug: angleproject:42261786 Change-Id: I994849bd4b3c3ab51698833d1cc520376ae6de44 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5773347 Reviewed-by: Kenneth Russell <kbr@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Auto-Submit: Quyen Le <lehoangquyen@chromium.org> Commit-Queue: Quyen Le <lehoangquyen@chromium.org>
Le Hoang Quyen a89ca6c8 2024-07-30T17:14:50 Metal: Fully implement unresolve step for MSRTT. This CL also uses memoryless for implicit MS textures in EXT_multisampled_render_to_texture render passes. Bug: angleproject:42261786 Change-Id: Ic20450574c4c670d05ca846587ced05488012270 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5746181 Reviewed-by: Alexey Knyazev <lexa.knyazev@gmail.com> Reviewed-by: Kenneth Russell <kbr@chromium.org> Commit-Queue: Quyen Le <lehoangquyen@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Le Hoang Quyen 198de044 2024-07-30T15:44:03 Metal: fix wrong render encoder's serial assignment mtl::RenderCommandEncoder object is created once and reused multiple times. We should re-assign a new serial whenever we reuse it, instead of assigning once in constructor. bug: angleproject:40644888 Change-Id: I18120c91dddd5b279fcec7a9099833e97ec1c37c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5746179 Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Kenneth Russell <kbr@chromium.org> Commit-Queue: Quyen Le <lehoangquyen@chromium.org>
Le Hoang Quyen 251067ed 2024-05-03T22:36:11 Metal: don't break render pass when uploading a texture. Bug: b/337214693 Change-Id: Ib2dc77c364a72f2973cbc3882f6125bffbc0a11b Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5514948 Reviewed-by: Kenneth Russell <kbr@chromium.org> Commit-Queue: Quyen Le <lehoangquyen@chromium.org>
Le Hoang Quyen 9ccb9b41 2024-05-03T22:23:03 Metal: fix incorrect tracking if blit & render encoder coexist Currently mtl::CommandBuffer tracks only one active command encoder. However this tracking is wrong if a blit/compute encoder is created without ending the current render encoder. Blit/compute and render encoders are allowed to coexist because the actual rendering encoding is deferred. The bug would happen for e.g. if: - There is an active render encoder. - ContextMtl::getBlitCommandEncoderWithoutEndingRenderEncoder() is called. - In this case, active encoder will be set to the blit encoder. - Later when blit encoder is ended, tracked active encoder would be set to null even though it should be the render encoder. This CL fixes the bug by tracking separate active blit/compute & render encoders. Bug: angleproject:7643 Bug: angleproject:8685 Change-Id: I9893402ecd4c0388aa0153acdb2be04315563086 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5514184 Reviewed-by: Kenneth Russell <kbr@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Quyen Le <lehoangquyen@chromium.org>
Kimmo Kinnunen e38cf95a 2024-03-06T16:26:54 Metal: Release prov. vertex buffers on event set Fixes a memory leak where provoking vertex buffers would never be released for sequence: 1. draw with flat shading 2. Create EGL fence sync object with Metal event 3. .. 4. Go to 1 Bug: angleproject:8586 Change-Id: I5b302cef82414e4a2886c4a7f570c1bf73a83238 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5349340 Reviewed-by: Kenneth Russell <kbr@chromium.org> Auto-Submit: Kimmo Kinnunen <kkinnunen@apple.com> Commit-Queue: Kenneth Russell <kbr@chromium.org>
Geoff Lang bd5dce9a 2023-11-21T15:39:04 Metal: Use MTLEvent instead of MTLSharedEvent when possible Refactor mtl::Sync to be abstract and have multiple implementations using either MTLEvent or MTLSharedEvent. Use MTLEvent in all cases except for EGL Syncs when the user sets the sync type to EGL_SYNC_METAL_SHARED_EVENT_ANGLE. Determine completion of the sync object by watching for completion of the command buffer where the event's signaling was enqueued. Avoid any sleep loops by waiting on a condition_variable which is notified when the completed queue serial is updated. Forked from CLs by sky@ and kbr@ Bug: angleproject:8153 Change-Id: I4547444b596366496c811cb9954872b85ab14ad8 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5133706 Reviewed-by: Kenneth Russell <kbr@chromium.org> Commit-Queue: Kenneth Russell <kbr@chromium.org>
Le Hoang Quyen 98d79260 2023-11-09T10:15:11 Metal: use release-consume order for queue's serials. Currently mtl::CommandQueue's mCommittedBufferSerial, mCompletedBufferSerial use relaxed memory order for load & store. They should use consume & release memory order respectively instead. Bug: angleproject:8406 Change-Id: I871259f1a6cca0e63d6c24b7592e7b80fd443dff Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5015524 Reviewed-by: Kenneth Russell <kbr@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Quyen Le <lehoangquyen@chromium.org>
Geoff Lang 1b8ab538 2023-09-05T13:44:40 Metal: Use a flat hash map for tracking resource ids. This set is very mutable. It makes many insertions, allocating memory each time. Useing a absl::flat_unordered_set we can avoid allocating memory at insertion time. This was a hotspot for Google Earth, taking up about 10% of ANGLE's CPU time. Bug: angleproject:8301 Change-Id: I7363ea8fdc5ff230a289af7c1ae25dc577188a18 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4843709 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Kenneth Russell aea88562 2023-05-19T16:52:43 Reland "Metal: Optimized BufferSubData per device" This reverts commit ee64836f702332adaca58d9f452063a04b2da955 , relanding the patch stack described there. Between patchsets 1 and 5: - The shadow buffer allocation has been replaced with a multimap of precisely-sized buffers, rather than rounding up buffer sizes. - Garbage collection of shadow buffers is triggered in three situations: - A certain number of context switches have occurred; this number was hand-tuned to avoid GC every frame. - A certain number of command buffer submissions has occurred; this number was hand-tuned to GC no more often than every few seconds on representative workloads. - The total size of the allocated shadow buffers is more than 1 MB, and either more than twice the size at the last garbage collection, or 64 MB more than at the last garbage collection. In this case, aggressive GC is performed in order to reclaim shadow buffers more quickly. Performance before and after these changes appears identical on microbenchmarks. On one Figma test case, comparing GPU memory allocated inside the BufferManager, peak consumption is decreased by over 75%, and steady-state consumption decreases by over 88%. Patchset 6 adds a needed workaround for a bug in the AMDMTLBronzeDriver affecting uploads of client-side data, and therefore some dEQP tests. It also streamlines the aggressive GC. Bug: angleproject:7544 Change-Id: I81b061f0b33c27fa403527fa12d626f4e9c88ebe Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4497413 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Alexey Knyazev e809e7bd 2023-03-13T00:00:00 Reland "Implement EXT_depth_clamp" This is a reland of commit f8c1418319ac2aef4b3101e322005b1d0f73120f Host GPU bugs are observable in iOS Simulator Original change's description: > Implement EXT_depth_clamp > > * Added depthClamp to the RasterizerState > * Added DepthWriteTest end2end tests covering > both clipped and clamped depth writes > > Capture > * Updated serialized rasterizer state > * Updated CaptureMidExecutionSetup > > OpenGL > * Requires GL 3.2 or ARB_depth_clamp > on desktop contexts > * Maps to EXT_depth_clamp on ES > > D3D11 > * Maps to the opposite of > D3D11_RASTERIZER_DESC.DepthClipEnable > * The new tests uncover several edge cases where > a workaround is needed to implement unextended > OpenGL semantics on top of D3D > > Metal > * Maps to the setDepthClipMode command > > Bug: angleproject:8047 > Bug: angleproject:8077 > Change-Id: I1b3448e5b84443e4be18af9bc22d2f8495ac8267 > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4347753 > Reviewed-by: Geoff Lang <geofflang@chromium.org> > Commit-Queue: Alexey Knyazev <lexa.knyazev@gmail.com> Bug: angleproject:8047 Bug: angleproject:8077 Change-Id: I8c5f8304276c97c51b2c3382cd2764592ee0c3fe Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4349938 Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Alexey Knyazev <lexa.knyazev@gmail.com>
Yuxin Hu 4a77b0f5 2023-03-18T00:16:24 Revert "Implement EXT_depth_clamp" This reverts commit f8c1418319ac2aef4b3101e322005b1d0f73120f. Reason for revert: This change breaks angle_end2end_tests on Metal backend: https://ci.chromium.org/ui/p/chromium/builders/ci/ios-angle-intel/26035/overview Original change's description: > Implement EXT_depth_clamp > > * Added depthClamp to the RasterizerState > * Added DepthWriteTest end2end tests covering > both clipped and clamped depth writes > > Capture > * Updated serialized rasterizer state > * Updated CaptureMidExecutionSetup > > OpenGL > * Requires GL 3.2 or ARB_depth_clamp > on desktop contexts > * Maps to EXT_depth_clamp on ES > > D3D11 > * Maps to the opposite of > D3D11_RASTERIZER_DESC.DepthClipEnable > * The new tests uncover several edge cases where > a workaround is needed to implement unextended > OpenGL semantics on top of D3D > > Metal > * Maps to the setDepthClipMode command > > Bug: angleproject:8047 > Bug: angleproject:8077 > Change-Id: I1b3448e5b84443e4be18af9bc22d2f8495ac8267 > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4347753 > Reviewed-by: Geoff Lang <geofflang@chromium.org> > Commit-Queue: Alexey Knyazev <lexa.knyazev@gmail.com> Bug: angleproject:8047 Bug: angleproject:8077 Change-Id: I829add68c006c72b7b4acf03aee3efa8a9a16fac No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4350876 Reviewed-by: Alexis Hétu <sugoi@google.com> Reviewed-by: Yuxin Hu <yuxinhu@google.com> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> Commit-Queue: Yuxin Hu <yuxinhu@google.com>
Alexey Knyazev f8c14183 2023-03-13T00:00:00 Implement EXT_depth_clamp * Added depthClamp to the RasterizerState * Added DepthWriteTest end2end tests covering both clipped and clamped depth writes Capture * Updated serialized rasterizer state * Updated CaptureMidExecutionSetup OpenGL * Requires GL 3.2 or ARB_depth_clamp on desktop contexts * Maps to EXT_depth_clamp on ES D3D11 * Maps to the opposite of D3D11_RASTERIZER_DESC.DepthClipEnable * The new tests uncover several edge cases where a workaround is needed to implement unextended OpenGL semantics on top of D3D Metal * Maps to the setDepthClipMode command Bug: angleproject:8047 Bug: angleproject:8077 Change-Id: I1b3448e5b84443e4be18af9bc22d2f8495ac8267 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4347753 Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Alexey Knyazev <lexa.knyazev@gmail.com>
Kenneth Russell ee64836f 2023-02-11T17:56:06 Revert "Metal: Optimized BufferSubData per device" This reverts commit 968041b54770af8917001d8fe9b52a881cfed0b2. Includes the following patches: git revert -n 995db1f66bcf87fc9e47d908fb2a885e810d2567 \ 9a6c90c8f802b4d107a081bfccaf4be007e7af54 \ dbd47e378582ef86db52c7379cd220cf0b2c8193 \ 369b320f92f54774879e8b8faff834fc8db0793e \ 4abae6f97586448712e2dc1cced4a678b0901d7b \ 968041b54770af8917001d8fe9b52a881cfed0b2 Several conflicts with top-of-tree were resolved during this revert. The aim is to reland this with additional code which will reduce the amount of excess buffer memory allocated, and release the resources associated with temporary buffer allocations. Bug: angleproject:7544 Change-Id: Ib7a6bc2ab1c2f23cb43112cd980106e2898c3826 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4240556 Reviewed-by: Kimmo Kinnunen <kkinnunen@apple.com> Reviewed-by: Gregg Tavares <gman@chromium.org> Commit-Queue: Kenneth Russell <kbr@chromium.org>
Kenneth Russell c799074c 2023-02-06T21:52:41 Metal: Implement EXT_disjoint_timer_query. Time-elapsed query objects allocate and deallocate storage slots in the CommandQueue. Command buffers register themselves with these slots (if active) upon allocation, and upon completion, accumulate their execution time in the slot. Query objects accurately track completion and report the total accumulated execution time for all command buffers issued while the time-elapsed query was active. Timestamp queries are not implemented. A pointer to implementation suggestions has been added to the code. Tested with the WebGL conformance test: conformance/extensions/ext-disjoint-timer-query.html Fixed: angleproject:7828 Change-Id: Ia022d0f3a52f2098bd01cf96f7cc20e3d347197e Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4226410 Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Kyle Piddington <kpiddington@apple.com> Commit-Queue: Kenneth Russell <kbr@chromium.org>
Gregg Tavares 91ff986c 2022-12-19T14:30:25 Metal:Switch to NoWait in eglReleaseTexImage Now that eglWaitUntilWorkScheduled is implemented in ANGLE and called in Chromium we can set this to NoWait Bug: angleproject:7890 Change-Id: Ib6fbda18b940873409653a968aa956bc728025a8 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4117714 Reviewed-by: Kenneth Russell <kbr@chromium.org> Commit-Queue: Gregg Tavares <gman@chromium.org>
Chris Dalton a4db9477 2022-10-06T10:35:39 Implement pixel local storage with metal::read_write textures Metal's programmable blending feature isn't available on non-Apple Silicon, so on these devices we have to polyfill pixel local storage using read_write textures, which can also be coherent if raster_order_groups are supported. This change leverages the existing PLS transformation to images, and implements just enough shader image functionality in Metal to support the pixel local storage usecase. Missing shader image features are marked with UNIMPLEMENTED(). Bug: angleproject:7279 Bug: angleproject:7792 Bug: angleproject:7794 Bug: angleproject:7797 Bug: angleproject:7803 Change-Id: Ia96a714693d352d57351a1bae4f45437dde000e4 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3993363 Reviewed-by: Kenneth Russell <kbr@chromium.org> Reviewed-by: Quyen Le <lehoangquyen@chromium.org> Commit-Queue: Chris Dalton <chris@rive.app> Reviewed-by: Kyle Piddington <kpiddington@apple.com>
Alexey Knyazev 81e9dc56 2022-11-04T00:00:00 Reland "Metal: Skip disabled draw buffers" This is a reland of commit 4b084310d7bbb33631d58a461eb5814c12220926 Do not try to create a command encoder with no attachments since it may crash some Metal drivers. Do not reset pipeline descriptors. Original change's description: > Metal: Skip disabled draw buffers > > When creating render pass descriptors, do not > assign textures to disabled color attachments. > > When creating pipeline descriptors, reset > pixel formats of disabled color attachments. > > Exit early when MTLRenderCommandEncoder is not created. > > Added: > * DrawBuffersTest.None > * DrawBuffersTest.NoneWithDepth > * DrawBuffersTest.NoneWithStencil > * DrawBuffersTestES3.DrawWithDisabledIncompatibleAttachment > > Fixes: > * conformance2/rendering/fs-color-type-mismatch-color-buffer-type.html > > Bug: angleproject:6430 > Change-Id: I7f650c761f757985b027388c350c01340a83fd51 > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4003180 > Reviewed-by: Kenneth Russell <kbr@chromium.org> > Reviewed-by: Geoff Lang <geofflang@chromium.org> > Commit-Queue: Alexey Knyazev <lexa.knyazev@gmail.com> Bug: angleproject:6430 Change-Id: I13977bd7ef32c4c85420706215b4f4d3a65629ca Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4030310 Commit-Queue: Alexey Knyazev <lexa.knyazev@gmail.com> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Gregg Tavares 968041b5 2022-08-19T12:11:23 Metal: Optimized BufferSubData per device Adds a staging buffer path which means there are 4 paths for bufferSubData. 1. direct copy * get a pointer to the buffer * copy the new data to the buffer * if the buffer is managed, tell metal which part was updated 2. use a shadow copy * copy the data to a shadow copy * copy the entire shadow to a new buffer * start using the new buffer 3. use a new buffer * get a new buffer (or unused) * put the new data in the new buffer * blit any unchanged data from the old buffer to the new buffer * start using the new buffer 4. use a staging buffer * get a staging buffer * put the new data in the staging buffer * blit from the staging buffer to the existing buffer. Further, there are 3 types of memory storage modes. Managed, Staged, Private. Based on the GPU type different storage modes and different paths in different sitatutions are more performant. So, add feature flags to select paths by GPU. Bug: angleproject:7544 Change-Id: I741dd1874201043416374194bd2001ded8dbd9b4 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3842641 Reviewed-by: Kyle Piddington <kpiddington@apple.com> Reviewed-by: Kenneth Russell <kbr@chromium.org> Reviewed-by: Quyen Le <lehoangquyen@chromium.org> Commit-Queue: Gregg Tavares <gman@chromium.org>
Gregg Tavares 2c4f7187 2022-08-30T11:33:56 Metal: Stop pre-creating the Provoking Vertex CmdBuffer The provoking vertex command buffer was being created regardless if whether or not it was used which is left over from when the backend used to pre-enqueue command buffers. That's no longer true so we don't need to pre-create this command buffer. I think this adds a 5% perf increase to the MotionMark "Leaves" test. Bug: angleproject:7619 Change-Id: Ic921911eeef0f063ea6eba8ba7c307157243b938 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3863739 Reviewed-by: Kenneth Russell <kbr@chromium.org> Commit-Queue: Gregg Tavares <gman@chromium.org>
Gregg Tavares 8a0351a5 2022-05-26T14:29:21 Metal:Dynamically choose max draw buffers. The code was hard coded to 4 which is lower than OpenGL's 8. This implementation keeps a hard coded array of size 8 in rx::mtl::RenderPassDesc and rx::mtl::RenderPipelineOutputDesc but only uses up to the display's limit. Bug: angleproject:7280 Bug: angleproject:5730 Change-Id: Idd7e64dc47697882b44540804159566158e1e924 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3671695 Reviewed-by: Kenneth Russell <kbr@chromium.org> Commit-Queue: Gregg Tavares <gman@chromium.org>
Gregg Tavares e79ed0dc 2022-03-25T17:15:30 Metal: Fix for not submitting command buffers in order First I added a check that CommandBuffers are committed in order as the design requires that they are. This showed several tests asserting including the angle end2end test, OcclusionQueriesNoSurfaceTestES3.SwitchingContextsWithQuery/ES3_Metal and also several others. The check is cheap and helps catch bugs so it seems prudent to have it. Unfortunately, AFAICT, there is no trival fix. The issue is ContextMtl::flushCommandBuffer commits the outstanding commandbuffers but then, if there is/was a query in progress, more work needs to be done. That work calls ContextMtl::getBlitCommandEncoder which calls ContextMtl::ensureCommandBufferReady which calls ProvokingVertexHelper::ensureCommandBufferReady which ends up making a new command buffer. That command buffer should be committed before switching to a new context but the code that would commit it has already executed. It's not at all clear to me how to refactor the code to do this correctly. The simplest solution is to call ContextMlt::flushCommandBuffer twice which I know is gross but at least it fixes the bug and optimizing and/or refactoring can be done separately. Bug: angleproject:7131 Change-Id: Idb11efb35f6ad2fd890a5db15d3791c07586bf34 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3553939 Reviewed-by: Kenneth Russell <kbr@chromium.org> Commit-Queue: Gregg Tavares <gman@chromium.org>
Alexey Knyazev 7c616871 2022-02-01T15:12:53 Metal: Implement ANGLE_base_vertex_base_instance Includes command buffer and MSL translator updates. The DrawElementsInstancedBaseVertexBaseInstance tests from DrawBaseVertexVariantsTest suite fail for dynamic draw and stream draw buffer usages. Bug: angleproject:6963 Change-Id: I6caa144860356d5fc85948b72458bec282ea3a3b Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3429819 Reviewed-by: Kyle Piddington <kpiddington@apple.com> Reviewed-by: Kenneth Russell <kbr@chromium.org> Commit-Queue: Kenneth Russell <kbr@chromium.org>
Kimmo Kinnunen b465a736 2021-12-21T12:52:40 Metal: Remove redundant CommandQueue::mMetalCmdBuffersTmp Instead of a member variable, instantiate the temporary at the use site. Bug: angleproject:6842 Change-Id: I64848bc937ce2945e6ac55adea8a6dffcaf9b00d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3347649 Reviewed-by: Kenneth Russell <kbr@chromium.org> Reviewed-by: John Cunningham <johncunningham@apple.com> Commit-Queue: Jonah Ryan-Davis <jonahr@google.com>
Kyle Piddington 1bd1a3db 2022-01-06T15:08:48 Metal: Canvas resizing causes webpage to run out of memory For https://bugs.webkit.org/show_bug.cgi?id=232122 Introduce a maximum resident amount of memory that a single command buffer can use, before forcing a flush. As part of ensuring that a command buffer is ready, check to see if this limit is exceeded. if so, flush the command buffer, and create a new one. Bug: angleproject:6880 Change-Id: I5e89735d05adbc174237ab79b006a75bbe89e560 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3369922 Reviewed-by: Gregg Tavares <gman@chromium.org> Reviewed-by: Kenneth Russell <kbr@chromium.org> Commit-Queue: Kyle Piddington <kpiddington@apple.com>
Kenneth Russell da3db87e 2021-07-06T14:00:58 Upstream latest changes to Metal backend from Apple to 7/1/2021 This CL merges in the ANGLE changes between these two WebKit commits: https://git.webkit.org/?p=WebKit.git;a=commit;h=8648b353ab1d7730438c2e08319e1a4d64982c31 https://git.webkit.org/?p=WebKit.git;a=commit;h=166e4924a52971d6a32ad48247a439b16c00e062 Include provoking vertex buffer out of bounds fix from https://bugs.webkit.org/show_bug.cgi?id=230107 Fix bad merge of resetting of dirty bits, breaking DepthStencilFormatsTest.DepthTextureRender test and perhaps others. Disable GL_APPLE_clip_distance when the direct-to-Metal compiler is active. It can not yet handle the gl_ClipDistance array. Disable use of rectangular textures for IOSurfaces. Metal can bind IOSurfaces to 2D textures, and this was passing all tests in the SPIR-V Metal backend. Introducing rectangular textures breaks the SPIR-V Metal backend, and the tests currently fail on the direct-to-Metal backend. Fix several bugs with ProvokingVertex, which was causing both the SpirV and Direct backends to incorrectly draw indices. (https://bugs.webkit.org/show_bug.cgi?id=230107) Skip the following tests on the Metal backend which is still failing RobustResourceInitTestES3.BlitDepthStencilAfterClearBuffer GLSLTest_ES3.GLVertexIDIntegerTextureDrawArrays/ES3_Metal With these changes, angle_end2end_tests again runs to completion. Bug: angleproject:6395 Change-Id: I3cc58f531426a95fc8f177a4ad87f56c1855a546 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3167010 Reviewed-by: Jonah Ryan-Davis <jonahr@google.com> Reviewed-by: Kenneth Russell <kbr@chromium.org> Commit-Queue: Kyle Piddington <kpiddington@apple.com>
Kyle Piddington d33a2222 2021-04-26T16:56:15 Upstream Apple's direct-to-Metal backend: compile libANGLE. This change is meant to merge the metal backend changes from Apple's direct-to-Metal backend. Taken from Kyle Piddington's CL: https://chromium-review.googlesource.com/c/angle/angle/+/2857366/ The goal of this CL is to merge the metal backend code in a state that compiles, but not to switch the Metal backend over to using the direct-to-metal backend yet. Bug: angleproject:5505 Bug: angleproject:6127 Change-Id: If6783e06e0086b3a1dd25c6f53caca5cfc96cb86 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2950067 Reviewed-by: Jonah Ryan-Davis <jonahr@google.com> Reviewed-by: Kenneth Russell <kbr@chromium.org> Commit-Queue: Jonah Ryan-Davis <jonahr@google.com>
Le Hoang Quyen 8a50b42b 2020-10-24T19:29:12 Metal: Convert index & vertex format on GPU when possible. - When converting vertex buffer: - if there is no render pass active, use compute shader to convert. - if there is a render pass active and device supports explicit memory barrier then convert the buffer in vertex shader with direct buffer write and insert a memory barrier. - if there is a render pass active and device doesn't support explicit memory barrier then convert the buffer on CPU. Bug: angleproject:2634 Change-Id: I5346e3a2adb855f40e46a3912d9db404a4482e0f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2434025 Commit-Queue: Le Hoang Quyen <le.hoang.q@gmail.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jonah Ryan-Davis <jonahr@google.com>
Le Hoang Quyen 37e84651 2020-09-27T13:47:36 Metal: Partially implement EXT_debug_marker Partially implemented to make it easier to debug. Only debug group is supported for now. Bug: angleproject:2634 Change-Id: I029dd4283790fb57a6964aad89c37d092e3378e5 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2433331 Commit-Queue: Le Hoang Quyen <le.hoang.q@gmail.com> Reviewed-by: Jonah Ryan-Davis <jonahr@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Le Hoang Quyen 0e5e6078 2020-09-26T23:31:24 Metal: Use MipmapNativeLevel class to store native mip lvl This is to avoid wrong native level in Metal, for example, not taking into account the OpenGL base level. Bug: angleproject:2634 Change-Id: I3a7a3ac41bdbd91a47755bb4ca11bd579c182e04 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2433326 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Le Hoang Quyen 6dfd855a 2020-03-25T03:02:08 Metal: Implement fence sync Bug: angleproject:2634 Change-Id: If1f7bb12c0e661c8e4b5677798a92440995819e4 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2433325 Commit-Queue: Le Hoang Quyen <le.hoang.q@gmail.com> Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Le Hoang Quyen 6136cbcb 2020-09-23T21:31:05 Metal: Implement transform feedback - XFB is currently emulated by writing to storage buffers. - Metal doesn't allow vertex shader to both write to storage buffers and to stage output (i.e clip position). So if GL_RASTERIZER_DISCARD is NOT enabled, the draw with XFB enabled will have 2 passes: + First pass: vertex shader writes to XFB buffers + not write to stage output + disable rasterizer. + Second pass: vertex shader writes to stage output (i.e. [[position]]) + enable rasterizer. If GL_RASTERIZER_DISCARD is enabled, the second pass is omitted. + This effectively executes the same vertex shader twice. TODO: possible improvement is writing vertex outputs to buffer in first pass then re-use that buffer as input for second pass which has a passthrough vertex shader. - If GL_RASTERIZER_DISCARD is enabled, and XFB is enabled: + Only first pass above will be executed, and the render pass will use an empty 1x1 texture attachment since rasterization is not needed. - If GL_RASTERIZER_DISCARD is enabled, but XFB is NOT enabled: + we still enable Metal rasterizer. + but vertex shader must emulate the discard by writing gl_Position = (-3, -3, -3, 1). This effectively moves the vertex out of clip space's visible area. + This is because GLSL still allows vertex shader to write to stage output when rasterizer is disabled. However, Metal doesn't allow that. In Metal, if rasterizer is disabled, then vertex shader must not write to stage output. - See src/libANGLE/renderer/metal/doc/TransformFeedback.md for more details. Bug: angleproject:2634 Change-Id: I6c700e031052560326b7f660ee7597202d38e6aa Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2408594 Reviewed-by: Jonah Ryan-Davis <jonahr@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jonah Ryan-Davis <jonahr@google.com>
Le Hoang Quyen 1677cf14 2020-09-13T20:14:59 Metal: Implement Uniform buffers Uniform buffer is implemented in two forms: - If number of ubo used in shader program is low, each buffer will use one discrete Metal buffer slot. - If number of ubo used is large, they will be embedded into one Metal argument buffer. Argument buffer is similar to Vulkan descriptor set. This is due to limit of number of Metal's discrete buffer slots which is only 31 and over half of them are already used by vertex attributes, default uniforms, driver uniforms, etc. The downside is that whenever a buffer binding is changed, the argument buffer must be updated also. Added empty TransformFeedbackMtl implementation to enable ES3 context creation on Metal. Bug: angleproject:2634 Change-Id: I69325696fac735cb45ab88ab55468c0991abc317 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2408593 Commit-Queue: Le Hoang Quyen <le.hoang.q@gmail.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jonah Ryan-Davis <jonahr@google.com>
Le Hoang Quyen bdecaf33 2020-08-04T20:16:27 Metal: Implement PBO. Bug: angleproject:2634 Change-Id: I77f085227298bf46361825d1886e04830dc9987a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2336558 Commit-Queue: Le Hoang Quyen <le.hoang.q@gmail.com> Reviewed-by: Jonah Ryan-Davis <jonahr@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Le Hoang Quyen 50704dc3 2020-08-04T12:08:00 Metal: Implement EXT_occlusion_query_boolean. - Metal's occlusion(called visibility) query operates per render pass. Implementation details are in src/libANGLE/renderer/metal/doc/OcclusionQueries.md. - New tests: - OcclusionQueriesTest.ClearNotCounted. - OcclusionQueriesTest.MultiQueries (failure on OpenGL/D3D11 back-end). Bug: angleproject:2634 Change-Id: Idd1327b5472d0e8c2b69307a7f04a1da4a847a40 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2336121 Commit-Queue: Le Hoang Quyen <le.hoang.q@gmail.com> Reviewed-by: back sept 10 - Jamie Madill <jmadill@chromium.org> Reviewed-by: Jonah Ryan-Davis <jonahr@google.com>
Le Hoang Quyen 91004654 2020-08-25T01:08:00 Metal: Implement ANGLE_robust_resource_initialization. Bug: angleproject:4929 Bug: angleproject:2634 Change-Id: Ib99b810059420e69d939f1bbb644c2b95de62850 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2374826 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jonah Ryan-Davis <jonahr@google.com>
Le Hoang Quyen acda9dde 2020-08-08T18:36:57 Metal: Implement GL_OES_texture_3D Bug: angleproject:2634 Change-Id: I8c46493ac28fe1bbfdb29ee3a60b23076bbc4c0c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2336119 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jonah Ryan-Davis <jonahr@google.com>
Le Hoang Quyen 113c5e29 2020-05-11T22:49:03 Metal: deferred render command encoder creation. MTLRenderCommandEncoder creation will be deferred until a render pass ends. Commands will be stored into a back-end owned buffer during render pass. At the end of the render pass, those commands will be re-encoded into an actual MTLRenderCommandEncoder. Benefits: - Useful for future implementation of occlusion query buffer where it could be allocated right before the end of a render pass to be big enough to store all queries within the render pass. - It's possible to change load option (deferred clear) as long as there is no draw call issued yet. This is not implemented yet. - Possibility of commands' re-ordering. Bug: angleproject:2634 Change-Id: I1348716aa882c0540d9120bf175d8dac13fb58bd Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2193196 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jonah Ryan-Davis <jonahr@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Le Hoang Quyen d1860ea1 2019-11-19T23:04:00 Metal: support OES_depth_texture Also added Depth32 & Depth16 texture data upload tests. Bug: angleproject:2634 Change-Id: I103f1cda1dc915f0dc8b04f7aaa2d8c0f9220cda Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1919281 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Le Hoang Quyen e5b474c6 2019-11-19T23:04:00 Metal: support ANGLE_instance_arrays/EXT_instance_arrays Also added TRIANGLE_FAN & LINE_LOOP instanced draws test cases. Bug: angleproject:2634 Change-Id: I84740a7221ab49710cf23767c81fa2d303aad364 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1919280 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Le Hoang Quyen 05af7590 2019-11-20T01:04:00 Metal: Fix FramebufferMtl's read-after-delete Due to late verification, ContextMtl might call onFinishedDrawingToFrameBuffer() on a deleted framebuffer object inside syncState() Fix: - Switch to call onStartedDrawingToFrameBuffer() on new FBO instead of calling onFinishedDrawingToFrameBuffer() on old (and possibly deleted) FBO. - Also discard framebuffer only takes effect per render pass. The discard flag will be reset when render pass starts. Bug: angleproject:4144 Change-Id: I7c6c96862892f1c241ce4af3b61862fa4b710a94 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1924101 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jonah Ryan-Davis <jonahr@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Le Quyen fe26bae4 2019-10-29T18:38:53 Metal backend implementation pt 2 This is without Metal specific shader translator implemented yet. Bug: angleproject:2634 Change-Id: I95d589442251c9ba111bd05a2dc379a36739046c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1855069 Reviewed-by: Jonah Ryan-Davis <jonahr@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>