src/libANGLE/renderer/metal/mtl_state_cache.mm

Branch


Log

Author Commit Date CI Message
Tom Sepez 25390156 2025-08-21T00:13:19 Suppress unsafe buffers on a file-by-file basis in src/ [1 of N] In this CL, we suppress many files but stop short of actually enabling the warning by not removing the line from the unsafe_buffers_paths.txt file. That will happen in a follow-on CL, along with resolving any stragglers missed here. This is mostly a manual change so as to familiarize myself with the kinds of issues faced by the Angle codebase when applying buffer safety warnings. -- Re-generate affected hashes. -- Clang-format applied to all changed files. -- Add a few missing .reserve() calls to vectors as noticed. -- Fix some mismatches between file names and header comments. -- Be more consistent with header comment format (blank lines and trailing //-only lines when a filename comment adjoins license boilerplate). Bug: b/436880895 Change-Id: I3bde5cc2059acbe8345057289214f1a26f1c34aa Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6869022 Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Le Hoang Quyen f6a350de 2025-04-17T20:43:08 Metal: fix rasterSamplecount not used in comparing render passes. RenderPassDesc's rasterSamplecount was not used to comparing two render passes' descriptors. Note: no reported bug found related to this missing comparison yet. This bug most likely affects render passes without any attachment (PLS?). Because if the 2 render passes have the same attachments, their rasterSamplecount values must also be equal. There was also a missing rasterSamplecount comparison in RenderPipelineOutputDesc::operator==. However, this function is not used. When comparing two render pipelines, RenderPipelineDesc::operator== is used instead, which is currently implemented using memcmp. So removing the former to avoid confusions. Bug: angleproject:411845677 Change-Id: Ic9b1867226561d096c1fb8ca2194b657d29daa18 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6468238 Reviewed-by: Kenneth Russell <kbr@chromium.org> Commit-Queue: Quyen Le <lehoangquyen@chromium.org>
Geoff Lang 4d478713 2025-04-03T08:10:40 Revert "Metal: Make StateCache descriptors hash consistent" This reverts commit 4334125be506e0c2c5dde4cfc29b31a7ff2bdec6. Reason for revert: Pipeline creation failures. Bug: chromium:407310859 Original change's description: > Metal: Make StateCache descriptors hash consistent > > Various descriptors would compare equality and do hashing based on the > underlying storage. The storage contains alignment padding and > bitfields. The contents of these are not defined, even when the > constructors tried to memset and memcpy. > > The various hash and compare functions also seemed to be missing some > elements, like rasterSampleCount. > > Missing == on fields and hashing unused memory may lead to inconsistency > where a==b is true but hash(a) != hash(b). > > Fix by: > Remove the memset/memcpy and write out the operator== and > hash() consistently. > > Initialize the members to their default values. > > Use uint32_t : 1 instead of bool if the struct tries to optimize for > size, since mixing types stops the packing. > > Use uint32_t to get the alignment to uint32_t, which is mostly what > is expected. > > Use uint32 someVar : N where N is payload bits + padding bits for > the last member. This way the assignment clears the padding bits. > The goal os to get the operator== to compare the padding bits, which > lets the compiler elide the memberwise compares and use word-wise > compares where it makes sense. > > This is an attempt to fix rare crashes related to map inserts > and lookups. std::unordered_map will crash if operator== is not > consistent with hash. > > Bug: angleproject:403372465 > Change-Id: I0a3a2ff327ac9f65e7d41bc9585cda54ce93ab86 > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6355828 > Commit-Queue: Kimmo Kinnunen <kkinnunen@apple.com> > Auto-Submit: Kimmo Kinnunen <kkinnunen@apple.com> > Reviewed-by: Alexey Knyazev <lexa.knyazev@gmail.com> > Reviewed-by: Geoff Lang <geofflang@chromium.org> Bug: angleproject:403372465 Change-Id: Id111c0728b603776fd8085fd395819bb5aa14722 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6428466 Commit-Queue: Quyen Le <lehoangquyen@chromium.org> Reviewed-by: Quyen Le <lehoangquyen@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Kimmo Kinnunen 4334125b 2025-03-14T16:12:32 Metal: Make StateCache descriptors hash consistent Various descriptors would compare equality and do hashing based on the underlying storage. The storage contains alignment padding and bitfields. The contents of these are not defined, even when the constructors tried to memset and memcpy. The various hash and compare functions also seemed to be missing some elements, like rasterSampleCount. Missing == on fields and hashing unused memory may lead to inconsistency where a==b is true but hash(a) != hash(b). Fix by: Remove the memset/memcpy and write out the operator== and hash() consistently. Initialize the members to their default values. Use uint32_t : 1 instead of bool if the struct tries to optimize for size, since mixing types stops the packing. Use uint32_t to get the alignment to uint32_t, which is mostly what is expected. Use uint32 someVar : N where N is payload bits + padding bits for the last member. This way the assignment clears the padding bits. The goal os to get the operator== to compare the padding bits, which lets the compiler elide the memberwise compares and use word-wise compares where it makes sense. This is an attempt to fix rare crashes related to map inserts and lookups. std::unordered_map will crash if operator== is not consistent with hash. Bug: angleproject:403372465 Change-Id: I0a3a2ff327ac9f65e7d41bc9585cda54ce93ab86 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6355828 Commit-Queue: Kimmo Kinnunen <kkinnunen@apple.com> Auto-Submit: Kimmo Kinnunen <kkinnunen@apple.com> Reviewed-by: Alexey Knyazev <lexa.knyazev@gmail.com> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Kimmo Kinnunen d4083c79 2025-01-31T15:06:36 Metal: Make ObjCPtr available to all modules Move ObjCPtr implementation to src/common/ObjCPtr.h, angle::ObjCPtr so that it's available also outside libANGLE. Bug: angleproject:393263506 Change-Id: I8ecd5632c7ae33ef4b409fc820fad229e91bc0ab Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6219318 Auto-Submit: Kimmo Kinnunen <kkinnunen@apple.com> Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Kimmo Kinnunen <kkinnunen@apple.com>
Kimmo Kinnunen 4e5f2ca3 2025-01-31T14:30:05 Metal: Rewrite AutoObjCPtr as ObjCPtr Rewrite without WrappedObject base class, the base class only convolutes things and does not help. This way the class can be moved upwards in the software layers in subsequent commits. Fix the class so that it can be used with ObjCPtr<T> and ObjCPtr<id<P>> signatures, to resemble other smart pointers. Remove the Auto prefix, ObjCPtr should be relatable to other smart pointers such as unique_ptr. Bug: angleproject:393263506 Change-Id: Ia5a5728514b7f9182c2ec8380c04716e8b9d2351 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6219317 Auto-Submit: Kimmo Kinnunen <kkinnunen@apple.com> Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Kimmo Kinnunen <kkinnunen@apple.com>
Kimmo Kinnunen bee34ea7 2025-01-30T18:39:00 Metal: Remove redundant AutoObjCObj template alias Some members were held with AutoObjCObj<T> and some with AutoObjCPtr<T *>. Use the latter. Bug: angleproject:393263506 Change-Id: I9d8d56e9ffe3281d5e9087de7959249cbb4b9bd4 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6216872 Auto-Submit: Kimmo Kinnunen <kkinnunen@apple.com> Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
Kimmo Kinnunen 5cf94ffa 2024-08-20T10:41:40 Metal: Use pipeline rasterSampleCount Use MTLRenderPipelineDescriptor rasterSampleCount instead of sampleCount. This avoids the use of the deprecation macro. Availability: iOS 8.0 (min: 15.0), mac Catalyst 13.1 (min: 16.5), macOS 10.11 (min: 10.15), tvOS 11.0 (min: 15.0), visionOS 1.0+ Bug: angleproject:360147118 Change-Id: I7009a7d7b39ecb763e23f4b97441fb45a64a891d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5797134 Auto-Submit: Kimmo Kinnunen <kkinnunen@apple.com> Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Alexey Knyazev <lexa.knyazev@gmail.com> Commit-Queue: Kimmo Kinnunen <kkinnunen@apple.com>
Kimmo Kinnunen 25237423 2024-08-20T15:22:32 Metal: Remove ifdefs for primitive topology class MTLPrimitiveTopologyClass availability iOS 12.0, minimum runtime 15.0. Remove the ifdefs. Hardcoding ANGLE_IOS_DEPLOY_TARGET is dangerous, likely it has never been correct. Remove. Should use __IPHONE_OS_VERSION_MIN_REQUIRED. Bug: angleproject:360147118 Change-Id: I43d7a364fa0237af1ee1f546015ae884fc373b15 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5797141 Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Alexey Knyazev <lexa.knyazev@gmail.com> Commit-Queue: Kimmo Kinnunen <kkinnunen@apple.com> Auto-Submit: Kimmo Kinnunen <kkinnunen@apple.com>
Alexey Knyazev 17c4741d 2023-09-01T00:00:00 Metal: Disable blending for masked out attachments Avoid pipeline failure when the following conditions are simultaneously true for the same color attachment: * Dual-source blending is enabled * All color channels are masked out * There is no bound fragment output Bug: angleproject:8015 Change-Id: Ie60f4f6dff5a9023677ea9b581e920b0e1e53532 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4836558 Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Kenneth Russell <kbr@chromium.org> Commit-Queue: Alexey Knyazev <lexa.knyazev@gmail.com>
Alexey Knyazev 817f4b81 2023-07-10T00:00:00 Restrict color writemasks for RGB9_E5 color buffers Per-channel write operations to shared exponent color buffers are loosely defined and may cause driver validation errors. Restricted the set of allowed color writemasks for RGB9_E5 color buffers so that RGB channels must be either all enabled or all disabled. Added a Metal-specific adjustment to ignore alpha writemask for RGB9_E5 color buffers. Removed an unused function from RenderPipelineColorAttachmentDesc. Bug: angleproject:8043 Change-Id: I902c3b70ddc6d8e65069d98a4a02a82122f413a5 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4685566 Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Geoff Lang 3a0da09d 2023-06-22T15:07:11 Metal: Cache compute pipelines for provoking vertex emulation Remove ProvokingVertexComputePipelineCache and update ProvokingVertexHelper to use the PipelineCache. Bug: chromium:1329376 Change-Id: Ifca89fbb572d850c806b24f124fb86c65eec4f11 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4637204 Reviewed-by: Quyen Le <lehoangquyen@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
Geoff Lang fbf9e3c7 2023-06-12T16:58:04 Metal: Use the per-context pipeline cache for RenderUtils The various RenderUtils classes created hundreds of RenderPipelineCache objects which did not reliquish their pipelines for the life of the Display. Hook them into the per-context PipelineCache so that they share the total pipeline limit with programs. Make RenderUtils fully RAII and store it in a unique_ptr in DisplayMtl. Remove RenderPipelineCache. Bug: chromium:1329376 Change-Id: I265e4e05fd3fd1da34932de36803cfe977f1f6a0 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4607153 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Quyen Le <lehoangquyen@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
Geoff Lang b46344bb 2023-06-12T13:50:40 Metal: Cache render pipelines at the context level Cache Metal render pipelines in a new mtl::PipelineCache which lives at the context level. This allows us to clean up unused pipelines from programs that are not actively used. The cache limits were chosen based on running Chromium. Without a limit, the total number of pipelines peaks at ~200. With frequent GCs, the active working set usually sits at ~60 pipelines. Bug: chromium:1329376 Change-Id: Ifa83b797c893684294e16dd638f6b3a35e1d043f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4608486 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Quyen Le <lehoangquyen@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
Geoff Lang 0e31cb40 2023-06-12T13:46:23 Turn CreateMTLRenderPipelineDescriptor into a method Refactor CreateMTLRenderPipelineDescriptor into a method on RenderPipelineDesc so it's externally visible. Bug: chromium:1329376 Change-Id: I22780b630ff9230ae2f3912c3bf4fd70a78d3ce5 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4608485 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: Quyen Le <lehoangquyen@chromium.org>
Geoff Lang bd5a7f24 2023-06-12T13:22:43 Metal: Set alphaToCoverageEnabled in checkIfPipelineChanged alphaToCoverageEnabled was tweaked to false for non-multisampled rendering cases in RenderPipelineCache::createRenderPipelineState but this caused a copy and could be done much earlier during context state syncing. Bug: chromium:1329376 Change-Id: I37a461554e1e2b162313b4a952baa1526356db3d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4608484 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: Quyen Le <lehoangquyen@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Roman Lavrov 21f16cb1 2023-06-09T17:30:38 Disable clang-format on ANGLE features autogen outputs Updates the script to produce reasonably formatted code without clang-format. Autogen files moved to autogen/ sub-directories because clang-format does not support per-file settings ;( This allows to run this codegen very quickly (~50ms on my machine) Bug: angleproject:8193 Change-Id: Ie84282090d574ebb4debe3edcfd82f983f27a5ff Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4604578 Commit-Queue: Roman Lavrov <romanl@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Alexey Knyazev 7bc4b7e3 2023-03-27T00:00:00 Metal: Implement OES_sample_variables New ESSL built-ins are mapped to their Metal counterparts and tweaked to follow OpenGL ES semantics when needed. Fixed A2C interaction with sample coverage by emulating the former on non-Apple GPUs. Bug: angleproject:8097 Fixed: angleproject:5087 Change-Id: I5d28a941af5cbc14743a3930731529f11f55febd Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4404896 Reviewed-by: Kenneth Russell <kbr@chromium.org> Reviewed-by: Kyle Piddington <kpiddington@apple.com> Commit-Queue: Alexey Knyazev <lexa.knyazev@gmail.com>
Dan Glastonbury bf5a007a 2022-06-16T14:21:08 Metal: Ensure render pass has at least one valid render target. Extend MTLRenderPipelineDescriptor validation to ensure that there is at least one valid render target set for the the render pipeline. This is required for certain families of metal devices to avoid a validation failure inside the metal framework. Moving the failure here will cause the app using ANGLE to return a GL error instead of crashing the process. Bug: angleproject:7436 Change-Id: I594d92492a22a61a720dbe7021843c8460b389b8 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4109310 Reviewed-by: Jonah Ryan-Davis <jonahr@google.com> Reviewed-by: Kimmo Kinnunen <kkinnunen@apple.com> Commit-Queue: Kyle Piddington <kpiddington@apple.com>
Dan Glastonbury 1d2b20f5 2022-12-23T14:21:10 Metal: Fix Metal API deprecation warnings macOS 13/iphoneOS 16 deprecated Metal APIs, causing warnings when building ANGLE targeting Ventura as the minimum supported OS. WebKit handles deprecated APIs by selectively silencing warnings around the affected code. This change adds ANGLE_APPLE_ALLOW_DEPRECATED_{BEGIN/END} and wraps code generating warnings to silence the warning. Bug: angleproject:7908 Change-Id: I7469652e0f4e0cf41ae3c295c2e3ae6bbd72e949 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4121822 Reviewed-by: Kenneth Russell <kbr@chromium.org> Commit-Queue: Kenneth Russell <kbr@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>
Austin Eng 91ee237f 2022-11-17T03:19:34 Revert "Metal: Skip disabled draw buffers" This reverts commit 4b084310d7bbb33631d58a461eb5814c12220926. Reason for revert: Crashing in webgl2_conformance_metal_passthrough_tests https://chromium-review.googlesource.com/c/angle/angle/+/4003180/comments/6e35ee21_38288238a 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: I485691bdcc4214ed6958f606591f23331bfbea53 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4032391 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Auto-Submit: Austin Eng <enga@google.com> Reviewed-by: Austin Eng <enga@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Alexey Knyazev 4b084310 2022-11-04T00:00:00 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>
Kimmo Kinnunen c47e7711 2022-11-04T10:32:14 Metal: remove duplicate code in RenderPassDesc conversion Remove duplicate code that was due to a rebase error in "Metal: Remove use of ANGLE_MTL_AUTORELEASE from mtl_state_cache" 415ff51b8005ab462c3bd883dff75d31499132dc Bug: angleproject:7813 Bug: angleproject:6833 Change-Id: If4af7a49033f31dfa1e10571388e8ad9922939e8 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4003223 Auto-Submit: Kimmo Kinnunen <kkinnunen@apple.com> Commit-Queue: Alexey Knyazev <lexa.knyazev@gmail.com> Commit-Queue: Kimmo Kinnunen <kkinnunen@apple.com> Reviewed-by: Kenneth Russell <kbr@chromium.org>
Kimmo Kinnunen 415ff51b 2021-12-17T17:20:25 Metal: Remove use of ANGLE_MTL_AUTORELEASE from mtl_state_cache The code doesn't use autoreleasepool, instead all instances are subsequently retained. Use AutoObjCPtr to adopt the reference and maintain ownership explicitly. This is work towards minimizing memory leaks by minimizing the use of autoreleasepool and accounting for the references explicitly. Bug: angleproject:6833 Change-Id: I77fe323683e4abb9b4ab17723949c56dd636ae32 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3347643 Reviewed-by: Jamie Madill <jmadill@chromium.org> Auto-Submit: Kimmo Kinnunen <kkinnunen@apple.com> Reviewed-by: Kenneth Russell <kbr@chromium.org> Commit-Queue: Kenneth Russell <kbr@chromium.org> Reviewed-by: John Cunningham <johncunningham@apple.com>
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>
Geoff Lang 6ddbfa39 2022-05-09T09:06:16 Metal: Log the shader source when a shader fails to translate Refactor Metal logging to include a message string. Bug: chromium:1322521 Change-Id: I3a7b5c36fcf140b3664ad96a9da924819326bf94 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3634725 Reviewed-by: Quyen Le <lehoangquyen@chromium.org> Commit-Queue: Kenneth Russell <kbr@chromium.org> Reviewed-by: Kenneth Russell <kbr@chromium.org>
Shahbaz Youssefi 400d9fe4 2022-04-23T01:08:19 Rename feature files to *_autogen.h To clarify further that they are not to be edited by hand. Bug: angleproject:6435 Change-Id: Iaf79706d2b688a43b3ebb65700cfbdd71a49a742 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3603842 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Kimmo Kinnunen 624e3c3d 2021-12-17T15:30:54 Fix dangerous use of AutoObjCPtr after ownership identity change Metal new* methods create objects with +1 retain count. AutoObjCPtr is intended to adopt this reference. Otherwise, like before this patch, the AutoObjCPtr holds object with +2 count. Before this patch, some but not all call sites donated the extra retain count to autoreleasepool "out of band", and as such the code did not leak that much. Bug: angleproject:6831 Change-Id: I72bcbc712f2cadbcbc6148c6aedfa7e151314518 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3347641 Reviewed-by: John Cunningham <johncunningham@apple.com> Reviewed-by: Kenneth Russell <kbr@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
John Cunningham 42bd4fc2 2021-12-10T14:58:17 Metal: add ANGLE_metal_create_context_ownership_identity. This Metal-specific EGL extension allows a given context and the GPU resources it allocates to be associated with a particular task ID on the system, for system-level bookkeeping purposes. Bug: angleproject:6795 Change-Id: I19ee0993564169b01c4a450e63dcfacd339b98b5 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3335172 Reviewed-by: Jonah Ryan-Davis <jonahr@google.com> Reviewed-by: Kenneth Russell <kbr@chromium.org> Commit-Queue: Kenneth Russell <kbr@chromium.org>
Gregg Tavares 2d6caae4 2021-12-10T17:25:58 Metal: Add maximum render target size validation Bug: angleproject:6790 Change-Id: I4a7e7285e040cc68e4fc16bb653f6d1512f541c9 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3331671 Reviewed-by: Kenneth Russell <kbr@chromium.org> Commit-Queue: Gregg Tavares <gman@chromium.org>
Kyle Piddington ec5d3795 2021-11-09T13:23:43 Metal: Fix InvalidateCopyThenBlend Render pass descriptor was not being changed due to blend state not being checked when looking for equality. Bug: angleproject:6669 Change-Id: Ic85dbec29ddb53a8c7e2e708f1ac0c99512e7248 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3270596 Commit-Queue: Kenneth Russell <kbr@chromium.org> Reviewed-by: Kenneth Russell <kbr@chromium.org> Reviewed-by: Gregg Tavares <gman@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
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>
Alexey Knyazev 9bc86c50 2020-10-13T13:26:08 Metal: Implement OES_draw_buffers_indexed Bug: angleproject:2634 Bug: angleproject:4394 Change-Id: Id6e6c6bdea2b1ff3d974e92e067ed63e1b4e4582 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2465919 Commit-Queue: Alexey Knyazev <lexa.knyazev@gmail.com> Reviewed-by: Le Hoang Quyen <le.hoang.q@gmail.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Le Hoang Quyen 9ff58e26 2020-09-27T15:27:12 Metal: Implement sampler object & shadow compare mode Note: GL_TEXTURE_COMPARE_MODE=GL_NONE is not supported on shadow sampler for now. Bug: angleproject:2634 Change-Id: I470bad6322e78ef1408e4334e1e778821df7cbf1 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2433332 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 80d4901a 2020-09-26T19:22:00 Metal: Support integer textures. Bug: angleproject:2634 Bug: angleproject:5154 Change-Id: Iffea26fe2c683557b4fa7c13fddf3523294b47d4 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2433329 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 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 d7149f2a 2020-08-26T19:44:54 Metal: Disable unused attribute slots. If an attribute slot is unused and user enables it but doesn't bind any buffer, Metal validation layer will complain that a buffer slot is missing (even though the slot is not used inside shader). Fix: if shader program doesn't use an attribute slot or there is no buffer bound to it, then disable that attribute. Bug: angleproject:2634 Change-Id: Ib56e0bf64bab13efce8b2972bfe386e26f45e50e Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2392171 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 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 4f247baf 2020-08-23T22:58:56 Metal: Implement EXT_draw_buffers & ANGLE_framebuffer_blit Bug: angleproject:2634 Change-Id: I769ca7e113e660870e9b31dafb706c313db8ac24 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2332146 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jonah Ryan-Davis <jonahr@google.com>
Le Hoang Quyen 9277ee74 2020-07-06T12:40:58 Metal: Implement MSAA default framebuffer. GL_SAMPLE_COVERAGE_VALUE is implemented by inserting gl_SampleMask writing logic to fragment shader. New test added: MultisampleTest.ContentPresevedAfterInterruption. - Skip on D3D11 (Bug: angleproject:4609) Bug: angleproject:2634 Change-Id: Ib44daf0baccc36ea320596d81713156047da059c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2281783 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 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 3c00eee2 2020-05-11T00:50:00 Metal: Use bit fields for state descriptor caching. This reduces size of state descriptors and increase hashing performance. Bug: angleproject:2634 Change-Id: Ida1a17a4fb30a053dafc82a3f7501b448e16e818 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2192570 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Le Hoang Quyen fbe6c1d2 2019-12-14T21:54:34 Metal: correctly clamp stencil reference values According to GL spec: - If stencil ref value is larger than max value the stencil buffer can represent, clamp it to max value (2^bits - 1) - The stencil clear value & mask will be truncated to stencil buffer's bits instead of clamping. Metal API is very vague on how it handles the stencil ref value larger than the stencil bits can represent, so we need to handle it manually. In fact, the Metal API seems to have bugs when dealing with large stencil ref value, i.e. > 0xff for example. Bug: angleproject:2634 Change-Id: I86f61f0bfd19dfc0fa459c84d98785a1af857a6b Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1966185 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 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 75875885 2019-11-20T01:04:00 Metal: Fix glDisable(GL_DEPTH_TEST) didn't disable depth write Per standard glDisable(GL_DEPTH_TEST) will disable depth write also regardless of the value of glDepthMask() Tests done: - dEQP.GLES2/functional_fragment_ops_depth_stencil_stencil_*_no_depth Bug: angleproject:2634 Change-Id: I3b101b8c0b3060f5ddbb18d3f97d7d6889cdec01 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1966184 Commit-Queue: Jamie Madill <jmadill@chromium.org> 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>