src/libANGLE/renderer/vulkan/RenderbufferVk.cpp


Log

Author Commit Date CI Message
Igor Nazarov 74816e9e 2024-08-29T15:58:22 Vulkan: Cleanup RenderTargetVk release/destroy methods Current implementation of `release()` and `destroy()` methods does not actually invalidate state of the object. All they do is manage the Framebuffer cache. The `release()` method renamed to `releaseFramebuffers()` to match its behavior. Added new `releaseImageAndViews()` method that calls `releaseFramebuffers()` and also null the pointers in order to catch invalid usage in ASSSERTs (for example: usage of `SurfaceVk::mColorRenderTarget` after swapchain recreation but before ANI processing). `destroy()` is updated to also call `reset()`. `releaseFramebuffers()` is only used in `TextureVk` class. In case of `releaseImageViews()`, arrays are cleared, so there is no point calling `releaseImageAndViews()`. In case of `refreshImageViews()`, render targets may be reused, since all pointers remain valid. `RenderbufferVk` and `WindowSurfaceVk` are using new `releaseImageAndViews()` and updated `destroy()` methods. Other changes: - Replace clearing of RT arrays in `TextureVk::setImageHelper()` with ASSERTs. - Fix ASSERT in `TextureVk::releaseImageViews()`, but it seems that this code path is impossible. Bug: b/234769934 Change-Id: I431d25b81dd4dd343149c12e680e5c997aa18436 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5822575 Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Igor Nazarov <i.nazarov@samsung.com>
Mohan Maiya 06f1b72f 2024-06-03T08:59:46 Vulkan: Bugfix in MSRTT emulation Transient multisampled images should have no mips. Enforce this requirement when MSRTT is being emulated Bug: angleproject:4836 Tests: MultisampledRenderToTexture*MultipleLevelsMultisample* Change-Id: I6df21bbb49a4c45aa3ee321f7d49b81f55352562 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5601347 Commit-Queue: mohan maiya <m.maiya@samsung.com> Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 65f8dc8e 2024-06-12T17:01:54 Vulkan: Remove traces of VK_MSRTSS_GOOGLEX Devices that shipped this unreleased extension should have long been updated to VK_MSRTSS_EXT Bug: angleproject:4836 Change-Id: I23736ebf28afd4a6f3b5b0d5a6417b3e7564c293 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5627575 Auto-Submit: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Yuxin Hu <yuxinhu@google.com> Reviewed-by: Yuxin Hu <yuxinhu@google.com>
Charlie Lao 1a9a703b 2024-05-21T11:14:40 Vulkan: Add DeviceQueueIndex to Context/BufferHelper/ImageHelper This CL adds a utility class DeviceQueueIndex, which encapsulates queueFamilyIndex and the queueIndex into one integer value so that we can pass around to barrier function. vk::Context and BufferHelper and ImageHelper class now keeps mCurrentDeviceQueueIndex instead of mCurrentQueueFamilyIndex. For All contexts by default it gets the default queue from renderer (which is always the one corresponding to Medium priority). For ContextVk, when priority changes it update mCurrentDeviceQueueIndex to match new context priority. Bug: b/337135577 Change-Id: I62cc483cfdb3e974d38db074e671c57299300074 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5555903 Reviewed-by: Yuxin Hu <yuxinhu@google.com> Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Charlie Lao b22cce5f 2024-05-21T10:55:27 Vulkan: Remove Renderer::getDeviceQueueIndex Renderer::getDeviceQueueIndex() returns queueFamilyIndex. There is a function that already returns mCurrentQueueFamilyIndex, so this function is now removed. This CL also renames ImageHelper::isQueueChangeNeccesary to isQueueFamilyChangeNeccesary Bug: b/337135577 Change-Id: I3cd9ded1414d1389e162aaa5399c231a987f871e Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5553067 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Yuxin Hu <yuxinhu@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 914fe61b 2024-03-15T13:20:49 Vulkan: Rename RendererVk.* to vk_renderer.* Done in a separate CL from the move to namespace vk to avoid possible rebase-time confusion with the file name change. Bug: angleproject:8564 Change-Id: Ibab79029834b88514d4466a7a4c076b1352bc450 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5370107 Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com> Commit-Queue: Amirali Abdolrashidi <abdolrashidi@google.com>
Shahbaz Youssefi 60aaf4a0 2024-03-14T12:58:56 Vulkan: Move renderer to namespace vk This class is agnostic of EGL. This change moves it to namespace vk for use with the OpenCL implementation Bug: angleproject:8564 Change-Id: I57f7807d6af8b3d5d7f8efbaf8b5d537a930f881 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5371324 Reviewed-by: Austin Annestrand <a.annestrand@samsung.com> Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Chris Forbes 6367f541 2024-01-25T10:16:04 Vulkan: supply YcbcrConversionDesc earlier Previously, the AHB import path would allow ImageHelper to build a bogus YcbcrConversionDesc (in initExternal) and then later overwrite it with what it wanted. The intermediate state was not necessarily valid, and could cause assertion failures and VVL errors. Instead, have ImageHelper clients provide the conversion they want upfront. In the non-external case, build an appropriate conversion for formats which need them, before delegating to initExternal. Bug: b/315387961 Change-Id: Icc8f561bb2de0289ceec56d41978b8c4651a47a2 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5232769 Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Chris Forbes <chrisforbes@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Amirali Abdolrashidi e7418836 2023-08-16T14:25:52 Vulkan: Add context flushing as OOM fallback * As a new fallback for out-of-memory errors, if an allocation results in device OOM, the context is flushed and the allocation is retried. * Functions related to buffer/image allocations now return a VkResult value instead of angle::Result, which will be bubbled up to a higher level for safer handling. * The OOM is no longer handled at the level where the allocation happens, but is moved up to the context. * Added two functions to ContextVk for allocating memory for images and buffer suballocations, which also include the fallback options. * initBufferAllocation(): Uses BufferHelper::initSuballocation() * initImageAllocation(): Uses ImageHelper::initMemory() * Moved initNonZeroMemory() out of the following functions: * BufferHelper::initSuballocation() * Moved to ContextVk::initBufferAllocation(). * ImageHelper::initMemory() * Moved to ContextVk::initImageAllocation(). * Also moved to new function: ImageHelper::initMemoryAndNonZeroFillIfNeeded(). This function replaced the rest of initMemory() usages outside initImageAllocation(). * New macros for memory allocation * VK_RESULT_TRY() * If the output of the command inside it is not VK_SUCCESS, it will return with the error result from the command. * VK_RESULT_CHECK() * If the output of the command inside it is not VK_SUCCESS, it will return with the input error. * Added a test in which allocation would fail due to too much pending garbage without the fix on some platforms. The test ends once there has been a submission. * New suite: UniformBufferMemoryTest * Added a similar test for flushing texture-related pending garbage. * New suite: Texture2DMemoryTestES3 Bug: b/280304441 Change-Id: I60248ce39eae80b5a8ffe4723d8a1c5641087f23 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4787949 Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Amirali Abdolrashidi <abdolrashidi@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Cody Northrop ec308b35 2023-05-15T15:03:10 Vulkan: Add feature to limit sample count to 2 This CL adds a feature called `limitSampleCountTo2`. Using it will have the Vulkan backend limit max samples to 2. Why 2? That's the minimum required in Vulkan to multisample without error. Here's an example validation error: vkCmdResolveImage: srcImage sample count is VK_SAMPLE_COUNT_1_BIT. The Vulkan spec states: srcImage must have a sample count equal to any valid sample count value other than VK_SAMPLE_COUNT_1_BIT. https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-vkCmdResolveImage-srcImage-00257 Using a limit as opposed to forcing a value allows non-multisampling (sample count of 1) to continue working. To see how tests fare when the feature is set, see the following test results that force the value on: https://chromium-review.googlesource.com/c/angle/angle/+/4534098/4 Test: adb shell setprop debug.angle.feature_overrides_enabled limitSampleCountTo2 Bug: b/279498079 Bug: angleproject:8162 Change-Id: I1df2822709151e6084c32055b5aff444e0b10db5 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4518562 Commit-Queue: Cody Northrop <cnorthrop@google.com> Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Greg Schlomoff <gregschlom@google.com> Reviewed-by: Charlie Lao <cclao@google.com>
Igor Nazarov 233c128b 2023-01-17T19:21:58 Vulkan: Fix UBs when deleted attachment is used in a RenderPass. Problem: - "RenderbufferVk"/"TextureVk" with "mOwnsImage == false" used as RenderPass attachment. - "RenderbufferVk"/"TextureVk" deleted. - Owning resource is destroyed ("EGLImage" and all siblings / "EGLSurface"). - Crash (UB) may happen when ending RenderPass, flushing or executing commands. Fix adds tracking of "vk::ImageSourceID" value in "vk::RenderPassAttachment" - IDs of objects, that originally provide "vk::ImageHelper" images. This is necessary, because when using EGLImage, there may be multiple "TextureVk" objects with same "vk::ImageHelper", and need to call "finalizeImageLayout()" for the correct attachment. Bug: angleproject:8032 Test: angle_end2end_tests --gtest_filter=ImageTest*DeletedWhileInUse* Test: angle_end2end_tests --gtest_filter=PbufferTest.UseAsFramebufferColorThenDestroy* Change-Id: I50fdd9d6b6a9677adad2262373303b46de1dee4c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4296014 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Igor Nazarov <i.nazarov@samsung.com>
Igor Nazarov b194c21a 2023-02-24T15:41:00 Vulkan: Enforce ContextPriority in ShareGroup and with EGLImage This CL enforces single Context Priority for all Contexts in a Share Group. This is necessary until Vulkan Semaphores will be used to automatically synchronize Resource access between Contexts. Contexts Priority updated when new Contexts is added to the Share Group. New Priority will be the highest among all ever existed Contexts (except if Priority is locked). When Contexts Priority changes, all flushed commands are submitted to the old VkQueue and semaphore is inserted into the new VkQueue. Currently opened RenderPasses and commands will not be flushed. When EGLImage is used in a Context, all Contexts in that Share Group locked (forever) to the Default Priority (Medium). This is done to simplify the implementation and because of the current limitations (lack of mutex protection across Context Share Groups). Notes: - the EGL_CONTEXT_PRIORITY_LEVEL_IMG will report initial priority. - below tests fail on G996B without this CL. Bug: angleproject:8039 Test: angle_end2end_tests --gtest_filter=MultithreadingTestES3.RenderThenSampleDifferentContextPriority* Test: angle_end2end_tests --gtest_filter=MultithreadingTestES3.RenderThenSampleInNewContextWithDifferentPriority* Test: angle_end2end_tests --gtest_filter=MultithreadingTestES3.RenderThenSampleDifferentContextPriorityUsingEGLImage* Change-Id: Ia6a2f0084d39168a58fd7ec33edc90ece9cead05 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4289750 Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Igor Nazarov <i.nazarov@samsung.com>
Kaiyi Li ac0a4a7d 2023-02-03T15:34:32 Add finer memory allocation type ... so that when we hit an OOM we have better understanding on why. Bug: b/266466279 Test: trigger a Vulkan OOM, see detailed allocation logging info Change-Id: I71c1ebd83e18ddb22e7abfd29a785bf4ad6454dc Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4219365 Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com> Reviewed-by: Charlie Lao <cclao@google.com> Auto-Submit: Kaiyi Li <kaiyili@google.com> Commit-Queue: Amirali Abdolrashidi <abdolrashidi@google.com>
Shahbaz Youssefi 626b10c1 2022-12-20T20:22:19 Vulkan: Add read/write depth/stencil layouts This CL only adds the layouts in the list, but does not use them. The layouts are renamed for consistency in this change. Bug: angleproject:7899 Bug: b/192477489 Change-Id: I47986c7252d32626e9f26c6670c0a4e3496fe0c8 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4116736 Reviewed-by: Yuxin Hu <yuxinhu@google.com> Reviewed-by: Charlie Lao <cclao@google.com> Auto-Submit: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi fd75686e 2022-12-07T16:40:54 Vulkan: Fix EGL image queue change vs threads ANGLE records commands (a queue transfer and layout transition) when an external image is bound to a texture or a renderbuffer. If another thread starts using these resources, the recorded commands should have been flushed. The application is not required to synchronize between the threads in this case (or at least, there are applications that don't). Bug: b/261552549 Change-Id: I9f345316269baf5f10576dbef73b86924efd5c6f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4088903 Auto-Submit: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Charlie Lao <cclao@google.com>
Charlie Lao 02cc4cd5 2022-12-07T12:03:26 Vulkan: Remove ImageHelper::mImageAndViewGarbage This was introduced in crrev.com/c/3449450. At that time this is necessary, because we can not copy mUse for immediate view garbage collection. Now with recent work, mUse is copyable, we no longer need to accumulate the view garbage. They can be released immediately with a copy of image's mUse. Bug: b/261737134 Change-Id: Ic4393f8c4ee7c0e3be4669a0a557507c909a77ab Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4087323 Reviewed-by: Yuxin Hu <yuxinhu@google.com> Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi ff46a03a 2022-08-25T20:19:02 Vulkan: Use VK_EXT_multisampled_render_to_single_sampled Previously, the GOOGLEX version was used. The EXT version is favored now. Bug: angleproject:4836 Change-Id: Ie41d750b0729f0b3a14d1937fbf2dd386b65dd59 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3857993 Reviewed-by: Yuxin Hu <yuxinhu@google.com> Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Charlie Lao 72e457fe 2022-06-03T15:36:01 Vulkan: Promptly destroy cached framebuffer when it becomes invalid When Texture gets respecified, the VkFramebuffer cache created out of it becomes invalid and will never possibly get used. Before this CL, we never clear such invalid framebuffer objects from the cache. This CL keeps a reference to the cache key in each attachment and will immediately destroy the cached VkFramebuffer object when one of the attachment has become invalid. Bug: b/234769934 Change-Id: Ib01f6dffe9211084b1ada340081daf905e3f1bef Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3682164 Reviewed-by: Ian Elliott <ianelliott@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Charlie Lao <cclao@google.com>
Amirali Abdolrashidi 37c53684 2022-04-05T15:03:14 Split Context ResourceUseList to RP Commandbuffers * Split the resource use lists retained in context between the render pass command buffer and the outside render pass command buffer, mostly in vk_helper.cpp and ContextVk.cpp. Bug: angleproject:7103 Change-Id: Ib696bdec2c545cd7df9ae4ab86c54a294041d908 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3573581 Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Jamie Madill 2dd13ebb 2022-04-21T11:25:00 Track Surface color & depth/stencil init separately. This clears up some trace testing confusion due when robust resource init is enabled, and the app clears color but not depth on the default surface. Bug: angleproject:7221 Change-Id: Id97871aec32ad831b663aaa9116e04b582ab5a36 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3600375 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Shahbaz Youssefi c5271e8e 2022-04-04T23:28:35 Vulkan: Emulate GL_KHR_blend_equation_advanced Based on a change by Brandon Schade <b.schade@samsung.com> In the translator, when advanced blend is enabled, an input attachment is added. Based on the listed advanced blend equations, emulation code is added that performs those equations' functions. The blend equation itself is passed through a driver uniform. Note that the advanced blend extension only allows a single output to use advanced blend, and that should be at location 0. In the Vulkan backend, when advanced blend is used, the driver uniform to select the equation is updated and normal blending is disabled. Bug: angleproject:3586 Change-Id: Icc42e8be238d34fca149087eb9cfe616a7643a6b Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3575738 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Yuxin Hu <yuxinhu@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Yuxin Hu 1cef917c 2022-03-02T23:50:11 Reland "Remove ImageViewHelper from ResourceUseList" This is a reland of 126e967de3978f0dc4f6cf0fa3f9749366ea39ba Original change's description: > Remove ImageViewHelper from ResourceUseList > > Instead of keeping a dedicated SharedResourceUse mUse for > ImageViewHelper, let ImageViewHelper take ImageHelper.mUse > for lifetime tracking. ImageViewHelper no longer needs to > add its' own mUse in the ResourceUseList through retain() > calls, and this should cut the ResourceUseList size by > almost half. For instance, in the trace aztec_ruins, > the maximum ResourceUseList size before the change is 3643, > and the maximum ResourceUseList size after the change is 1694. > Since ImageViewHelper no longer needs to keep SharedResourceUse > mUse as a class memberWe can remove the inheritance from > Resource class, and make ImageViewHelper simply a NonCopyable class. > Bug: angleproject:6717 > Change-Id: I460e83f5f3c1d6ef9722b9f3c9a5ba9552563cb9 > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3449450 > Reviewed-by: Charlie Lao <cclao@google.com> > Reviewed-by: Jamie Madill <jmadill@chromium.org> > Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> > Commit-Queue: Yuxin Hu <yuxinhu@google.com> Bug: angleproject:6717 Change-Id: I3aa9785d7dcdc8db82847f1586f8cd7d5c838d7c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3501194 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Yuxin Hu <yuxinhu@google.com>
Shahbaz Youssefi 8390196a 2022-02-26T02:36:22 Revert "Remove ImageViewHelper from ResourceUseList" This reverts commit 126e967de3978f0dc4f6cf0fa3f9749366ea39ba. Reason for revert: Hits an ASSERT about too much garbage being accumulated. anglebug.com/7063 Original change's description: > Remove ImageViewHelper from ResourceUseList > > Instead of keeping a dedicated SharedResourceUse mUse for > ImageViewHelper, let ImageViewHelper take ImageHelper.mUse > for lifetime tracking. ImageViewHelper no longer needs to > add its' own mUse in the ResourceUseList through retain() > calls, and this should cut the ResourceUseList size by > almost half. For instance, in the trace aztec_ruins, > the maximum ResourceUseList size before the change is 3643, > and the maximum ResourceUseList size after the change is 1694. > Since ImageViewHelper no longer needs to keep SharedResourceUse > mUse as a class memberWe can remove the inheritance from > Resource class, and make ImageViewHelper simply a NonCopyable class. > > Bug: angleproject:6717 > Change-Id: I460e83f5f3c1d6ef9722b9f3c9a5ba9552563cb9 > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3449450 > Reviewed-by: Charlie Lao <cclao@google.com> > Reviewed-by: Jamie Madill <jmadill@chromium.org> > Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> > Commit-Queue: Yuxin Hu <yuxinhu@google.com> Bug: angleproject:6717 Change-Id: Iea3d40458e2cc5be6ab0257ba6df8b82a4eeecda No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3491345 Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Yuxin Hu 126e967d 2022-02-09T01:46:25 Remove ImageViewHelper from ResourceUseList Instead of keeping a dedicated SharedResourceUse mUse for ImageViewHelper, let ImageViewHelper take ImageHelper.mUse for lifetime tracking. ImageViewHelper no longer needs to add its' own mUse in the ResourceUseList through retain() calls, and this should cut the ResourceUseList size by almost half. For instance, in the trace aztec_ruins, the maximum ResourceUseList size before the change is 3643, and the maximum ResourceUseList size after the change is 1694. Since ImageViewHelper no longer needs to keep SharedResourceUse mUse as a class memberWe can remove the inheritance from Resource class, and make ImageViewHelper simply a NonCopyable class. Bug: angleproject:6717 Change-Id: I460e83f5f3c1d6ef9722b9f3c9a5ba9552563cb9 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3449450 Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Yuxin Hu <yuxinhu@google.com>
Mohan Maiya cf4b50c5 2022-02-14T14:12:13 Vulkan: Retain images before changeLayoutAndQueue This change d9882db5f694c1c added retain calls for images in some places. Such retains are needed for textures and renderbuffers as well. Bug: angleproject:4628 Change-Id: I6b08033870f82851cc62a123bfd9c780812f17b5 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3462801 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Shahbaz Youssefi acd8fc76 2021-12-16T01:05:02 Vulkan: Distinguish RP and outside-RP command buffer types What goes inside and outside a render pass command buffer is largely mutually exclusive. Moreover, the size and frequency of allocations is different between the two. This change distinguishes the C++ types used for inside and outside render pass command buffers: - The type now documents which command buffer a function is able to receive. - `isRenderPass` flag passing, checking and asserting is largely removed. - A follow up change experiments with using different (Vulkan vs ANGLE) secondary command buffers for inside and outside RP command buffers. - A future change could specialize the pool behaviors per command buffer type. Bug: angleproject:6811 Change-Id: Ia4bc669d26ac7e94e8a0dfb9b361666c82f42cc3 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3344373 Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Charlie Lao caf6433a 2022-01-04T14:37:29 Vulkan: Rename releaseStagingBuffer to releaseStagedUpdate There is no more per ImageHelper dynamic buffer for staging, and this function is not just removing staging buffer, but removing all staged updates. Rename it to reflect what it actually does. Bug: b/208323792 Change-Id: I5a2182291848a9e137ed29b888f31215664b46fd Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3367078 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Charlie Lao <cclao@google.com>
Shahbaz Youssefi a400e76d 2021-12-22T12:24:13 Vulkan: Don't expose MSRTT without VK_KHR_depth_stencil_resolve Previously, ANGLE exposed the EXT_multisampled_render_to_texture extension even if VK_KHR_depth_stencil_resolve was not available. This was due to scarcity of drivers on the bots with support for this extension and allowed partial testing. This is no longer true. Additionally, this cleans up the expectations because old and buggy drivers are now simultaneously filtered out. Bug: angleproject:6845 Change-Id: I8c285a5fa5d9beeb98b48d8b056cdc8779cce6fd Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3353895 Reviewed-by: Yuly Novikov <ynovikov@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 6fe13477 2021-11-11T00:47:14 Vulkan: Add external's pNext to ANGLE_external_objects_flags ANGLE was chaining VkImageFormatListCreateInfoKHR to VkImageCreateInfo::pNext to support sRGB extensions. For external images, it was unknown whether that was valid because there was no way to know if external used an identical chain of pNexts. This was causing a discrepancy between images created by Chrome and those created by ANGLE as part of an import. This change updates ANGLE_external_objects_flags to take in the pNext chain external has used to create the image so ANGLE could create the image identically. Bug: chromium:1266094 Change-Id: I479b9e7ff39d437425dc91c79834880749766f99 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3274177 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Peng Huang <penghuang@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Charlie Lao 856a0e03 2021-09-01T18:09:14 Vulkan: Make vk::Format from struct to class With all the recent changes that there are two actualImageFormatIDs, retrieve the actual format requires pass in a renderable boolean. And the vertex format also has a similar requirement to the real format may differ depends on if it is compressed or not. This struct no longer safe to expose the underline data members directly. This CL turns it into a class and expose the actual format via method that requires renderable or compressed boolean. Bug: b/196456356 Change-Id: Ie2f8308cc408bde1b0787e0b392e143187cc4425 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3139236 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Charlie Lao 8ea87a67 2021-08-17T18:46:36 Vulkan: Avoid texture format fallback when possible Some texture formats are not renderable on some hardware. For example, R4G4B4A4 are not renderable on nvidia and not blendable on ARM. R5G5B5A1 are also not blendable on nvidia. Right now when we generate format table, we are being most conservative, picking an actual format that is always renderable and blendable. This means when R4G4B4A4 is used on one of these GPUs, we are always falling back to R8G8B8A8 regardless if the texture is actually being used as color attachment or not. This CL adds a actualRenderableImageFormatID field in vk::Format. Initially we will pick actualImageFormatID which only ensures texture sample capability. If later on the texture is being attached to FBO, then we will switch to actualRenderableImageFormatID and do data copy if necessary. This way we save memory and reduce texture bandwidth for most usage of these textures. For renderBuffer and surfaces and EGLImages, we always pick the renderable textures. Bug: b/196456356 Change-Id: I02eec3365c2a317b0d1bad6dbdc3e741114c5bba Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3104514 Reviewed-by: Ian Elliott <ianelliott@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Charlie Lao <cclao@google.com>
Charlie Lao 8ce42fd3 2021-08-24T17:33:05 Vulkan: Remove mFormat from ImageHelper The only thing we need from ImageHelper::mFormat is to get intendedImageFormat. This CL simplifies the interface by simply pass in intendedImageFormat into initExternal so that ImageHelper class will not need to reference to vk::Format at all. Bug: b/196456356 Change-Id: I5fcb0d7226cae44dc865a7cfb0149d74e5756f11 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3111451 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Charlie Lao 11fd7a14 2021-08-18T13:46:30 Vulkan: Pass actualFormatID directly into ImageHelper::initExternal Since vk::Format alone won't tell us what the actual format is. This CL let caller pass actualFormatID directly into ImageHelper::initExternal() call and let ImageHelper object keeps record of mActualFormatID without need to refer to vk::Format object. Bug: b/196456356 Change-Id: I3c47caae7f946805a32f57519348528f8d47cf4a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3104513 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Jamie Madill a8f1a916 2021-08-26T17:53:56 GetTexImage: Remove syncState calls & add early error exit. Instead of calling syncState to force the Vulkan staged textures to flush, we ensure the Texture is marked initialized by sending a message up to the Texture when there are no more pending updates. Also adds handling for textures with extra mips. Instead of crashing, we now return an error with a warning. Also adds a test with a texture that has extra (outside the mip chain) defined levels. Also adds a test and handling for empty texture levels. This should lead to more consistent behaviour in the trace test serialization logic, where often the prior logic would behave differently depending on if GetImage was called from MEC or from the serialization code. Also updates the generateMipmap logic to syncState after calling initializeContents so the updates happen in the correct order on Vulkan. Bug: angleproject:5133 Bug: angleproject:6336 Change-Id: Iab1c2a22b9f9435e7f3c0f870c86bbed3460482e Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3123168 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Cody Northrop <cnorthrop@google.com> Reviewed-by: Tim Van Patten <timvp@google.com>
Charlie Lao cf24931a 2021-08-17T10:48:23 Vulkan: Add ImageHelper::getActualFormat() This is preparation for future CLs. In the future vk::Format may not tell you what actual format is. This CL adds a new method of ImageHelper::getActualFormatID() and ImageHelper::getActualFormat() so that we can use these two APIs and avoid using vk::Format, thus reduce reliance on vk::Format. Bug: b/196456356 Change-Id: Ic50e664e033feb5e066f40269c33cffe96024172 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3100319 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Ian Elliott <ianelliott@google.com>
Jamie Madill c61fd919 2021-08-25T08:29:55 Fix array texture readback with GetTexImage. According to the desktop GL specs, GetTexImage retrieves entire mips of a texture for 2D array and cube array textures. The prior code was only retrieving one layer and didn't have any way to get the layers other than layer zero. Fix this by using similar logic to how we read back 3D textures. Also adds regression tests to GetImageTest. Bug: angleproject:5133 Bug: angleproject:6132 Change-Id: I8b22bc10ac1fdfe6389ac309450b92681f087cda Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3118266 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Cody Northrop <cnorthrop@google.com> Reviewed-by: Tim Van Patten <timvp@google.com>
Peter Kasting 0d06c3cf 2021-07-26T04:30:39 Fix some instances of -Wunused-but-set-variable. Bug: chromium:1203071 Change-Id: I144165ae5ec47aba88658030a6ba3e371bf31ee7 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3053616 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Jeff Vigil d2b659f9 2021-03-25T15:40:58 EGL: implement EGL_EXT_protected_content Context Add Validation check to Contexts and Surfaces Add Vulkan protected memory features and properties Add protected member to Surfaces and Contexts Implement hasProtectedContent in Vulkan Add QueueFamily helper, extent DeviceQueueMap Protected Swapchains always on for Android Add EGLProtectedContentTest Test: angle_end2end_test --gtest_filter=EGLProtectedContentTest Bug: angleproject:3965 Change-Id: I9352b1e594f71bb4e89cee7137a468940d186b1b Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2800413 Commit-Queue: Mohan Maiya <m.maiya@samsung.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Charlie Lao 92d3912d 2021-04-01T10:49:14 Vulkan: Remove maxLevel and immutable from ImageHelper::initExternal Now that we have removed mBaseLevel and mMaxLevel from ImageHelper class in previous two CLs. The initExternal function can be modified to not pass in base/max level information. This CL also removes immutable from argument and let caller directly pass in firstLevel to it. Bug: b/181800403 Change-Id: I595c1faffabc7582af35a9578b2ecdf00c39207f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2800414 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Ian Elliott <ianelliott@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Charlie Lao b5a71140 2020-08-20T17:24:21 Vulkan: Make storage actually immutable for immutable textures The immutable textures are intended to be "immutable". Right now we are still re-allocating VkImage object based on base_level and max_level. This causes a problem for rendering to a level that is beyond [base_level, max_level], which is totally within OpenGL spec. This CL makes an immutable texture always allocate from 0 to max levels that are specified by a glTexStorage call. Changing base_level will not trigger re-allocation of VkImage object. Bug: b/181800403 Change-Id: I4b4ddea17b7f6f7bfd8f36bfe8bb3a35b5c180b6 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2368038 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Ian Elliott <ianelliott@google.com> Commit-Queue: Charlie Lao <cclao@google.com>
Shahbaz Youssefi d1462228 2021-03-09T11:25:36 Vulkan: Use VK_EXT_multisampled_render_to_single_sampled Additionally, makes the emulation path not require independentResolveNone. This was only used to select the NONE resolve mode when the attachment format doesn't have either of depth or stencil aspects, but it's ok to specify the same resolve mode for both aspects even if one aspect is missing. Bug: chromium:1088005 Change-Id: Ifc37cbf5331145179c5927853b996a0d62b871ee Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2743666 Reviewed-by: David Reveman <reveman@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Mohan Maiya 4afd0f27 2021-02-17T13:35:57 Vulkan: Add VK_KHR_image_format_list support to initExternal The code for initializing a VkImage with VK_KHR_image_format_list extension support is now internal to initExternal. Also provides a flag to inform callers when VK_KHR_image_format_list support is enabled. Bug: angleproject:5520 Change-Id: Ie2ade93d1403ab3f9cbcf7d80684bbca201d5d8d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2702159 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Mohan Maiya <m.maiya@samsung.com>
Mohan Maiya 2b69462e 2021-02-12T15:55:00 Vulkan: Consolidate image format list initialization code HardwareBufferImageSiblingVkAndroid, RenderbufferVk, SurfaceVk and TextureVk all had similar code to initialize VkImage with VK_KHR_image_format_list extension support. Consolidate all of them into a helper. Bug: angleproject:5520 Change-Id: Ib7ac582a35a26c0da15879e688bcaf0c2a92ea87 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2692641 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Mohan Maiya <m.maiya@samsung.com>
Shahbaz Youssefi eae262e7 2021-01-27T13:56:49 Vulkan: Fix image layout barriers for tessellation shaders Also fixes a bug where invalid stages may be specified for example if AllGraphicsReadOnly or DepthStencilReadOnly layouts are used and geometry or tessellation shaders are not supported by the implementation. Bug: angleproject:5557 Change-Id: Ia25a6aec8138c67701c63da65783263d8a7bda27 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2653911 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Jamie Madill 2e9706d8 2021-01-08T17:29:42 Vulkan: Use angle::FormatID instead of VkFormat. This change switches the internal enums we pass around from VkFormat to FormatID. The end goal of the refactor is to allow the Vulkan back-end to store packed tables indexed by FormatID. Because VkFormat has large gaps in its enum space we'd otherwise need to use unordered data structures like unordered_map. The change removes the redundant VkFormat storage from vk::Format and uses a new table query to return the VkFormat that 1:1 matches an angle::FormatID. We also include a reverse mapping for use with native Vulkan get functions for Android. Also moves sRGB conversion functions into renderer_utils. A couple sRGB formats that don't exist in GL are no longer handled by the sRGB conversion functions. These formats should be extremely rare. Bug: angleproject:5438 Change-Id: Id8b49773ca0c556f9f5a6a10fcf0d9762b93bbea Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2618204 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Ian Elliott <ianelliott@google.com>
Jamie Madill e91097bf 2020-12-29T14:05:56 Vulkan: Clean up "actual"/"intended" naming. Clarifies that the GL internal format is an "intended" format and the Vulkan formats are "actual" formats. This makes all the format fields use the same consistent naming pattern. Bug: angleproject:5438 Change-Id: I935a49895109e9e06eae5ef98d5614dfd1128ff8 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2605728 Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Shahbaz Youssefi 56330564 2020-12-10T00:46:04 Vulkan: Support layered framebuffers This feature is introduced by geometry shaders, where all the layers of a texture can be attached to a framebuffer. The geometry shader would use gl_Layer to decide which layer the primitive should be rendered to. Bug: angleproject:3571 Change-Id: Ib2ae8e227b226295f9e2f62f6b230839070bc95c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2582711 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Brandon Schade 777749aa 2020-11-13T09:43:31 Vulkan: Fix image copies with renderbuffers When doing an EXT_copy_image copy, renderbuffers were being recreated due to a mismatch in sample count values. Bug: angleproject:3593 Test: dEQP-GLES31.functional.copy_image.*renderbuffer* Change-Id: Ic6b85ea098ab6382b56520b1ca6b76ac25801b54 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2538076 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 9e7f08fc 2020-11-06T16:55:51 Vulkan: Fix incorrect reordering of barriers Take the following situation, a simple copy from image to buffer: ANGLE_TRY(contextVk->onBufferTransferWrite(buffer)); ANGLE_TRY(contextVk->onImageTransferRead(aspectFlags, image)); CommandBuffer &commandBuffer = contextVk->getOutsideRenderPassCommandBuffer(); commandBuffer.copyImageToBuffer(imageHandle, layout, bufferHandle, 1, regions); Both `onBufferTransferWrite` and `onImageTransferRead` may flush either the outsideRP or insideRP command buffers. If buffer is not previously used, but image is used: - onBufferTransferWrite: buffer usage is recorded in outsideRP1 - onImageTransferREad: outsiderRP1 is flushed, outsideRP2 is started - copyImageToBuffer: recorded on outsideRP2, but buffer usage not recorded there - A following command that uses the buffer and requires barrier doesn't close outsideRP2 as it believes it was not used there Bug: angleproject:5319 Change-Id: Ib8994083fbc21969a538cda3784adee57b089415 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2523388 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Mohan Maiya a391674c 2020-11-09T16:16:49 Vulkan: Support VK_KHR_image_format_list for RenderBuffers RenderBuffers are now created with VK_KHR_image_format_list extension support enabled. We only enable those tests where the EGL image's source is a RenderBuffer but not those tests where the EGL image's target is a RenderBuffer. There are some corner cases related to glReadPixles that need to be resolved to unblock those tests. Bug: angleproject:3756 Bug: angleproject:5281 Test: ImageTest.SourceRenderbuffer*Vulkan Change-Id: I643a9d74d14473cc7df59fa6e25acab7d1c9aad1 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2528475 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Mohan Maiya <m.maiya@samsung.com>
Brandon Schade 1e494cae 2020-10-07T19:26:01 Vulkan: Add support for EXT_copy_image Add support for GL_EXT_copy_image which allows image data transfer between image objects. This is implemented by using the vkCmdCopyImage API call. Bug: angleproject:3593 Test: dEQP-GLES31.functional.copy_image.* Change-Id: I30a34a8711b5d2e5834064d7453e03d6ec0df478 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2393955 Commit-Queue: Brandon Schade <b.schade@samsung.com> Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Jamie Madill 97843bda 2020-10-30T17:03:36 Vulkan: Fix EGL Surface robust init. The error here was related to using a single cache variable for the robust init setting for all the surfaces in a DisplayVk. Fix this by passing down the robust init setting from the SurfaceVk to image init. Bug: angleproject:5274 Change-Id: I9bc9c20990268d1d5166411fb53f8f2593fd1971 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2510694 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Charlie Lao 86ca5d2b 2020-10-01T11:56:05 Vulkan: Add plumbing to render pass when ImageHelper gets deleted ImageHelper object is not refcounted and garbage collected and endRenderPass call is deferred until next render pass starts. This caused a situation that an ImageHelper object gets deleted while still referenced in the open render pass. This CL make sure that we call into all shared context's open renderpass when an image goes away so that they can take appropriate action for this. Bug: b/169618408 Change-Id: I5075e805980084db82ca3e699462272eee5d2d59 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2443571 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Charlie Lao <cclao@google.com>
Shahbaz Youssefi a76b6836 2020-09-17T22:40:42 Vulkan: Support MSRTT depth/stencil resolve VK_KHR_depth_stencil_resolve is used by this change to resolve depth/stencil multisampled-render-to-texture renderbuffers. This extension is not widely supported yet. If it's not present, the depth/stencil resolve operation is silently ignored and the renderbuffer acts as a normal multisampled one. This is not correct, but our primary user (Chrome), and most applications don't care for the resolved depth/stencil data. In fact, it's recommended for the depth/stencil attachment to be invalidated after rendering. Exposing EXT_multisampled_render_to_texture even in the absence of depth/stencil resolve allows the majority of the applications to still take advantage of MSRTT color attachments. Bug: angleproject:4836 Change-Id: I6ba4187344a0c9330d2c77bdc5e2c6fc5483c299 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2417645 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Shahbaz Youssefi f39e0f01 2020-09-07T23:07:37 Vulkan: Use subpass to unresolve render-to-texture attachments GL_EXT_multisampled_render_to_texture allows singlesampled textures to be used with multisampled framebuffers in such a way that the final resolve operation is automatically done. In Vulkan terminology, the render-to-texture GL attachment is used as a Vulkan subpass resolve attachment with an implicit (ideally-)lazy-memory multisampled image as the color attachment. This extension expects that if the texture is drawn to after the automatic resolve, the implicit multisampled image would take its fragment colors from the singlesampled image. In other words, the opposite of a resolve operation should be automatically performed at the start of the render pass. This change refers to this operation as "unresolve". The goal of this extension is to allow tiling GPUs to always keep multisampled data on tile memory and only ever load/store singlesampled data. The latter is achieved by using a subpass resolve attachment and setting storeOp of the multisampled color attachment to DONT_CARE. This change achieves the former by using an initial subpass that uses the resolve attachment as input attachment, draws into the multisampled color attachment and sets loadOp of said attachment to DONT_CARE. Bug: angleproject:4881 Change-Id: I99f410530365963567c77a7d62fc9db1500e5e3e Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2397206 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Shahbaz Youssefi edc0d2ee 2020-09-15T16:02:05 Vulkan: Disallow loadOp=LOAD for MSRTT depth/stencil textures EXT_multisampled_render_buffer2 specifies that depth/stencil textures are expected to be in a perpetual state of invalidated, except during rendering. This change makes sure that they never use loadOp=LOAD. Additionally fixes a bug where clears applied to MSRTT depth/stencil textures didn't take effect because they were applied to the multisampled image (since the resolved image was not given to the render target). Bug: angleproject:4836 Bug: angleproject:5063 Change-Id: I4506f4de415dca6c222111a1ae62017d2fb1e2b1 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2412848 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Shahbaz Youssefi 37457d08 2020-09-15T14:38:53 Vulkan: Support MSRTT color renderbuffers Color renderbuffers are similar to multisampled-render-to-texture textures, but much simpler. The same mechanism is used to implement them. Bug: angleproject:4836 Change-Id: I298529c9fd1b03e78b1e37cdbe595e66166ee130 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2412847 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Shahbaz Youssefi d8b037d6 2020-09-15T05:05:14 Change renderbuffer width/height/sample types to GLsizei This matches the types used by GL and stored in the state. setStorage and setStorageMultisampled calls were using size_t instead with a number of unnecessary casts in places which are now removed. Bug: angleproject:4836 Change-Id: Ibb570f0c088a6f29abe10f513de27c30ba4dd098 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2411697 Reviewed-by: Jonah Ryan-Davis <jonahr@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi b3a8f0bc 2020-09-11T15:41:16 Distinguish MSRTT renderbuffers in the front-end glRenderbufferStorageMultisampleEXT has different semantics from glRenderbufferStorageMultisample. This change makes this differentiation in the front-end and passes a flag to the backends. This extension is currently only supported on Vulkan and D3D backends. Support for the former will be done in a follow up. Support for the latter is not planned. Bug: angleproject:4836 Change-Id: I75bc3d7990a4b1ce06264280a386d5e467983b7d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2405396 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Shahbaz Youssefi a0d048a4 2020-08-27T12:03:02 Vulkan: Fool-proof usage of GL and VK level indices Using boxed types, this change allows the compiler to catch errors when a level index in one space (e.g. GL) is mistakenly used in another space (e.g. VK). This change uncovered a number of bugs due to such mistakes which are fixed. Mistakes are still possible when the index is explicitly extracted, for example to be given to a Vulkan command, or when it's created, for example when retrieved from gl::ImageIndex::getLevelIndex. Future work can include using gl::LevelIndex in gl::ImageIndex directly to alleviate the latter at least. Bug: angleproject:4880 Change-Id: I6427c68c3bc096f771402f51c8554d8171758aa9 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2380232 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com>
Jamie Madill eb85c021 2020-08-05T15:07:15 Vulkan: Refactor Context CommandBuffer query. getOutsideRenderPassCommandBuffer returns the command buffer directly since it's now stateless and cannot throw an error. All the RenderPass begin/end and flushing are done by the dependency functions (buffer/ image read/write). Bug: angleproject:4911 Change-Id: I5e7806be9d0e1b5e358524bd485298d660fac942 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2339544 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Courtney Goeltzenleuchter <courtneygo@google.com>
Jamie Madill 23daea2f 2020-08-06T10:40:00 Vulkan: Rename CommandBuffer get method. This method will no longer end the RenderPass in a following CL. Renaming it in a split CL makes the review diff simple. Bug: angleproject:4911 Change-Id: Id48257884dccb7c86f7de2cc9ca95e651fb68df7 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2340788 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Courtney Goeltzenleuchter <courtneygo@google.com>
Jamie Madill adc250c3 2020-07-31T21:11:05 Vulkan: Refactor ImageViewHelper serials. Instead of storing a dictionary of serials to specific image views we now store a single 32-bit serial combined with subresource info. The serials combined with a subresource info (level/layer) gives a unique identifier for each ImageView in the ImageViewHelper for the descriptor set cache and the Framebuffer cache. Also moves ImageView serial allocation to initialization and release. This means we no longer need to use "getAssign" methods and instead we use a few init methods to ensure the serials stay allocated. Bug: angleproject:4911 Change-Id: Ia6af76ae16b3ff5d4a83974bde05cc704064b079 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2333395 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Shahbaz Youssefi dcc56215 2020-07-19T01:12:09 Vulkan: Implement GL_EXT_multisampled_render_to_texture This change allows the use of resolve attachments in the Vulkan backend. GL_EXT_multisampled_render_to_texture is implemented using this feature. The infrastructure for specifying resolve attachments is designed with eventual support for GL_EXT_multisampled_render_to_texture2 in mind as well as optimizations to glBlitFramebuffer() and multisampled backbuffers. Proper support for glRenderbufferStorageMultisampledEXT is still missing from this change. All tests use this for the depth/stencil attachment and don't read back the data. Currently, the depth/stencil attachment is created as a normal multisampled image. Bug: angleproject:4836 Change-Id: I110a7f63312ae61a657b6094adf7d97c92bd5843 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2304170 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Cody Northrop cc846039 2020-07-27T21:05:11 Capture/Replay: Fix GetTexImage on Luminance GetTexImageANGLE and GetRenderbufferImageANGLE use ReadPixels to pull texture data. Luminance is not a renderable format, so it is not supported by ReadPixels. To support this, override Luminance formats to their underlying internal format. Test: angle_end2end_test --gtest_filter="*GetTexImage*" Bug: b/160014453 Bug: angleproject:4058 Change-Id: Id19344c2e2c06386a871338833e35b7747cb966b Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2321740 Reviewed-by: Manh Nguyen <nguyenmh@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Cody Northrop <cnorthrop@google.com>
Jamie Madill d657e1d7 2020-04-24T13:13:18 Vulkan: Defer framebuffer clears. This works by storing the deferred clears in the ImageHelper's staging buffers. We apply the deferred clears onto the RenderPass right before we begin to draw. Storing the clears in the ImageHelper solves problems where we clear GL Textures in a Framebuffer and then unbind the Textures and sample from them. Or do other commands like CopyTexImage. Note that because the staging buffer clears only handle full-image clears we need to immediately apply some scissored clears where before we would use the RP. This should be a pretty rare occurrence and it is possible to optimize that in the future. Reduces the RenderPass count in the Manhattan "frame 10" trace from max 22 to max 20. May improve perf slightly on Android or may have effects too small to measure. Should not regress performance. Bug: angleproject:4517 Change-Id: I02150d531022afb903f1058f070937ec6337bd88 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2142711 Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Jamie Madill 1fc354fa 2020-04-22T11:49:00 Re-land: "Vulkan: Forward RenderBuffer/Surface dirty messages." Re-land fixes ASSERT on Android GLES. Previously we were only forwarding Texture staging changes to the Framebuffer for re-sync. We could miss out on clears that were staged in Surfaces and Renderbuffer attachments. Complete the chain by making the SurfaceVk and RenderbufferVk forward notifications from the VkImage. Bug: angleproject:4517 Change-Id: I91d31213b115a58546b574caa574eebbb098266c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2159294 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Jamie Madill 623d0443 2020-04-21T15:15:03 Revert "Vulkan: Forward RenderBuffer/Surface dirty messages." This reverts commit 3fb33ade6ec8f286797bff5645304df580b1a963. Reason for revert: Causing WebGL test failures on GLES/ANGLE/Android. Bug: chromium:1072739 Original change's description: > Vulkan: Forward RenderBuffer/Surface dirty messages. > > Previously we were only forwarding Texture staging changes to the > Framebuffer for re-sync. We could miss out on clears that were staged > in Surfaces and Renderbuffer attachments. Complete the chain by making > the SurfaceVk and RenderbufferVk forward notifications from the > VkImage. > > Bug: angleproject:4517 > Change-Id: I15f36c225517e915f656d0c2464a99631ef9f945 > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2150699 > Reviewed-by: Cody Northrop <cnorthrop@google.com> > Commit-Queue: Jamie Madill <jmadill@chromium.org> TBR=cnorthrop@google.com,timvp@google.com,jmadill@chromium.org # Not skipping CQ checks because original CL landed > 1 day ago. Bug: angleproject:4517 Change-Id: I4fd4d79dc11da0ba86065d3a80975de4c791a2a0 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2159288 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Jamie Madill 3fb33ade 2020-04-09T15:27:12 Vulkan: Forward RenderBuffer/Surface dirty messages. Previously we were only forwarding Texture staging changes to the Framebuffer for re-sync. We could miss out on clears that were staged in Surfaces and Renderbuffer attachments. Complete the chain by making the SurfaceVk and RenderbufferVk forward notifications from the VkImage. Bug: angleproject:4517 Change-Id: I15f36c225517e915f656d0c2464a99631ef9f945 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2150699 Reviewed-by: Cody Northrop <cnorthrop@google.com> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Jamie Madill 2a0c3596 2020-03-31T15:36:45 Vulkan: Clean up robust and emulated image clears. This change consolidates image clears in multiple places into a single site in ImageHelper initialization. It adds support for appending clear image commands as well as prepend (the default). We prepend clears because image initialization happens after data upload. The Vulkan robust clear path now works like the other back-ends. The change flushed out a bug where partially uninitialized CopyTexImage was not correctly initializing a texture before triggering a full resource clear. Texture::copyImage now uses a workaround where we first init the image before clearing it. After the init we upload the new data. We'll use the appending clears path when implementing deferred clears. Bug: angleproject:4517 Change-Id: If9212f3b8cdd0fc8b7e729d364530801a644e164 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2130627 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Cody Northrop <cnorthrop@google.com>
Xiaoxuan Liu b07816d6 2020-01-02T15:13:37 Vulkan: Add robust init for NULL texture image. In gl::ReadPixels(), ValidateReadPixels() will try to flush staged updates before readPixels. In the case where a texture was initialized with null RGBA data, no Framebuffer dirty bits are set, and thus the staged clear would never be flushed from the staged updates. 1. Add robust init in TextureVk::initImage to ensure image is initialized. Test: ./angle_end2end_tests --gtest_filter=\ RobustResourceInitTest*_Vulkan_AllocateNonZeroMemory 2. Update stageSubresourceRobustClear() to kEmulatedInitColorValue in the case where robust resource was initialized without full RGBA format to update init value of robust resource. Test: texture-attachment-formats.html in webgl_conformance_vulkan_passthrough_tests. 3. Revert "Suppress Vulkan RobustResourceInit tests." Revert commit a8e6a463121b9920564fb6efd7f2c857d7023fe3. Reason for revert: re-enable related robust tests. Bug: angleproject:4255 Change-Id: I79f20e0c02c2f1b1cd68ab590f0f765229f9e780 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1985503 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill aa09ca69 2020-02-24T13:33:30 Vulkan: Update ContextVk command buffer access methods. Use the following names: - flushAndBeginRenderPass - endRenderPassAndGetCommandBuffer - flushAndGetPrimaryCommandBuffer This clarifies that a flush is part of the method. Bug: angleproject:4029 Change-Id: I6c870761339ea7aa39c83142200781ba39ad6a4b Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2068129 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Courtney Goeltzenleuchter <courtneygo@google.com> Reviewed-by: Tim Van Patten <timvp@google.com>
Jamie Madill c58458e6 2020-02-19T14:51:41 Vulkan: Remove CommandGraph code. Also updates relevant comments to no longer refer to a graph. Bug: angleproject:4029 Change-Id: Ic29716e9ae4926870f902947d49d8fee7af98662 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2057804 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Jamie Madill 0a9c0b7b 2020-02-19T14:55:04 Vulkan: Fix image queue changes with graph disabled. These again weren't being tested on the CQ. Probably necessary for some image sharing scenarios. Bug: angleproject:4029 Change-Id: Iccbebf127e2ec6fdb74dd213998674fff77b75b2 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2065529 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Michael Spang <spang@chromium.org>
Ian Elliott c6458072 2019-12-05T11:45:10 Fix multisample renderbuffer compliance (e.g. 3->4 samples) This change ensures that the following spec language is correctly implemented: the resulting value for RENDERBUFFER_SAMPLES is guaranteed to be greater than or equal to samples and no more than the next larger sample count supported by the implementation. For example, if 2, 4, and 8 samples are supported, and if 5 samples are requested, ANGLE should use 8 samples, and return 8 when GL_RENDERBUFFER_SAMPLES is queried. Note: There is a known problem with NVIDIA OpenGL driver that causes another test to be expected to fail. Bug: angleproject:2222 Bug: angleproject:4196 Change-Id: I28921badf9568427799b0af347198b5df06c2aaa Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1954444 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Ian Elliott <ianelliott@google.com>
Jamie Madill bb35bb4e 2019-10-29T17:17:04 Vulkan: Implement simple case ANGLE_get_image. A couple cases are left unimplemented: Incomplete/unused Textures. This leads to a slightly more tricky implementation. Since we need to read back from the staging buffer we will need to flush the Image contents to a temporary buffer. Depth/stencil readback. Requires a more complex pixel packing step. 3D/Cube/2D Array readback. Also requires a more complex packing step. Bug: angleproject:3944 Change-Id: Ic5d9a606177ba7e3e5ab945feb5f555afa11741f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1879964 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Cody Northrop <cnorthrop@google.com>
Jamie Madill dfc20daf 2019-10-28T13:51:42 Plumb more logic for ANGLE_get_image. Also implements and tests validation / negative API. Bug: angleproject:3944 Change-Id: I3385a4255f4fab6a12eee2abfa5ffcce2107359a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1879961 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Cody Northrop <cnorthrop@google.com>
Jamie Madill 68591eff 2019-10-13T15:05:23 Vulkan: Store ImageView access in the graph. This will ensure we don't destroy the image views when they are still in use by other Contexts. Bug: angleproject:2464 Change-Id: I1d3ba2ad241250e31ea32873446c4cb23971750d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1843236 Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Jamie Madill beacd8c8 2019-10-17T14:34:02 Vulkan: Rename format fields. Renames 'angleFormat' to 'intendedFormat'. Also renames 'bufferFormat' and 'imageFormat' to 'actualImageFormat' and 'actualBufferFormat'. This renaming should make it clearer to the reader what the meaning of the different format fields are. Intended format is the front-end format and the actual formats are the formats we pass to Vulkan. Also updates the documentation. Bug: angleproject:4009 Change-Id: If61bf7250e88f7ed3d452718574c963d718e27b2 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1866077 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill a14555a7 2019-10-13T15:05:22 Vulkan: Refactor RenderTargetVk ImageViews. Instead of storing a pointer to an ImageView, store a pointer to an ImageViewHelper. The level and layer index are all that's needed to pull the right image view from the ImageViewHelper. Will make it easier to store ImageView references in the graph to track lifetime. Bug: angleproject:2464 Change-Id: I773fa79a89ceefc99ff70e4eed4985f9f01fe26a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1857549 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Ian Elliott <ianelliott@google.com> Reviewed-by: Courtney Goeltzenleuchter <courtneygo@google.com>
Jamie Madill 0b9ebe58 2019-10-15T11:15:42 Vulkan: Add "ImageViewHelper". This allows views to track a different lifetime than vk::ImageHelper. This in turn will fix the race condition on ContextVk destruction when releasing ImageViews owned by TextureVk and RenderbufferVk. For now this is a refactoring change only. Bug: angleproject:2464 Change-Id: I9581975bd5d4913233bbed8439dd4a632cc78a2a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1843231 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Ian Elliott <ianelliott@google.com>
Jamie Madill 88bc4d3d 2019-10-04T20:41:24 Vulkan: Get rid of "fetch" level/layer image views. Instead always use 2D array views when rendering to cube maps. We need to keep the "fetch" image view for the main image for emulating seamless cube map textures on GL 2.0. We also use it for some texture copying init. These uses could potentially be replaced with sample instructions if we wanted to remove this last "fetch" view. Bug: angleproject:3975 Change-Id: I90f9be9fc6542d8ec27f6722132c1b27acf72176 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1842226 Reviewed-by: Courtney Goeltzenleuchter <courtneygo@google.com> Reviewed-by: Cody Northrop <cnorthrop@google.com> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Jamie Madill f10bf6bf 2019-09-26T10:27:18 Vulkan: Implement multi-threaded GL. The main component of this change is to make vk::BufferHelper, vk::ImageHelper and vk::SyncHelper use a common path. We introduce a new "vk::SharedGarbage" helper class that stores small lists of garbage from individual objects like an ImageHelper or BufferHelper. The SharedGarbage is stored in the RendererVk with the ResourceUse of the helper object. The ResourceUse tells RendererVk when it is safe to destroy the GarbageObjects. New "onGraphAccess" commands are added in a few places to enable the common garbage collection path. A couple Context-only resources like default attributes now are referenced where they were not before. Also reorganizes some functions so we can add a few helpful ASSERTs to our graph dependencies. Added "updateCurrentAccessNodes" for this. Also adds a "RendererScoped" helper to replace many uses of "ContextScoped". The multithreading EGL tests mostly pass but have some remaining flakiness so cannot yet be enabled. Bug: angleproject:2464 Change-Id: Ia3e3ae8848d731abf3f21ebe04c33e381e130be0 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1808444 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Cody Northrop cb16fb5f 2019-08-29T16:53:55 Vulkan: Support texture base and max levels The Vulkan backend uses a vkImage that matches the number of effective levels in the GL texture. This is due to the fact that GL textures can have really strange layouts that only make sense when base level and max level are applied. For instance, take the following layout with disjoint mip levels: Level 0: 4x4 RGBA Level 1: 2x2 RGBA Level 2: 10x10 RGB If base level is set to zero and max level is set to 1, the image is still considered mip-complete: Level 0: 4x4 RGBA ==> Base Level 0 ==> Level 0: 4x4 RGBA Level 1: 2x2 RGBA ==> Max Level 1 ==> Level 1: 2x2 RGBA Level 2: 10x10 RGB If base and max level are then both set to 2, the texture is still considered complete, but of a different size and format: Level 0: 4x4 RGBA Level 1: 2x2 RGBA Level 2: 10x10 RGB ==> Base/Max Level 2 ==> Level 2: 10x10 RGB When the base or max level is changed, we must recreate the vkImage to match the new level count. To support that, we: - Stage updates from the current image to the new image - Only stage updates if there aren't already staged updates for a level - Free the current image and so it can be recreated at the next draw This CL does the following: - Refactors TextureVk::copyImageDataToBuffer to support staging updates without flush - Adds TextureVk::copyImageDataToBufferAndGetData to support previous use model - Adds TextureVk::changeLevels, triggered during syncState, which stages updates and releases the current image. - Updates ImageHelper::flushStagedUpdates to understand base/max levels - Updates TextureVk::ensureImageInitialized and TextureVk::generateMipmap to account for base/max level - Tracks base and max levels in ImageHelper - Adds ImageHelper::stageSubresourceUpdateFromBuffer to support this use case - Adds ImageHelper::isUpdateStaged to determine if changeLevels should propagate data - Makes gl::TextureTypeToTarget available for use outside of ImageIndex - Enables several deqp and end2end tests Bug: angleproject:3148 Test: dEQP-GLES3.functional.texture.mipmap.*base_level* Test: dEQP-GLES3.functional.texture.mipmap.*max_level* Change-Id: I14ca071c9c62eb310dfed7ef9290dc65fc3ff696 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1776933 Reviewed-by: Courtney Goeltzenleuchter <courtneygo@google.com> Commit-Queue: Cody Northrop <cnorthrop@google.com>
Jamie Madill b540da89 2019-09-19T14:19:12 Vulkan: Use ResourceUse to track object lifetime. With the new resource tracking scheme the CommandGraph, tracking a "Context serial" aka "current" serial is no longer necessary for CommandGraphResources. Serial tracking has been moved to the shared ResourceUse struct that gets updated on a command submission. Thus we don't need to store the serial as a current separate piece of info in BufferHelper/ImageHelper. Will lead to further redesign for the multi-threading support for Vulkan. Bug: angleproject:2464 Change-Id: I1ae4bcc27fcfb93422b4ab4c9682a458e482f295 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1785990 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Mingyu Hu 7e44ec26 2019-08-26T15:59:48 GL_EXT_multisampled_render_to_texture extension. Part 1. Adding new parameters for extension without adding any real code change. Since no new code paths were added, we expect all tests to pass as before. Bug: angleproject:980428 Change-Id: I551b46a66f422eabd357fd021e00cf266a991efb Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1772377 Commit-Queue: Rafael Cintron <rafael.cintron@microsoft.com> Reviewed-by: Rafael Cintron <rafael.cintron@microsoft.com> Reviewed-by: Geoff Lang <geofflang@chromium.org>
James Darpinian 7e48c9eb 2019-08-06T17:17:19 Add explicit integer casts WebKit uses the -Wshorten-64-to-32 flag which warns on these cases. Bug: 3439 Change-Id: I8c1de60da0f173ca2036e2120e79b857f5f2775f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1740866 Commit-Queue: James Darpinian <jdarpinian@chromium.org> Reviewed-by: Kenneth Russell <kbr@chromium.org>
Jamie Madill c327370e 2019-07-23T12:54:12 Vulkan: Pass VkExtent3D to TextureHelper::init. Bug: angleproject:3189 Change-Id: I4b95240bb32fbc2b3d0c8f097e0552d0fe23417d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1713094 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Cody Northrop <cnorthrop@google.com>
Shahbaz Youssefi f2a1c384 2019-05-21T16:32:49 Vulkan: Implement multisampled framebuffers Simultaneously implements ANGLE_framebuffer_multisample and ES3 multisampled framebuffers. Additionally, implements ES3 framebuffer blitting where multisampled framebuffers are involved. Bug: angleproject:3203 Bug: angleproject:3204 Bug: angleproject:3200 Change-Id: I5694a30f71168e807688a9568e3742b81d907918 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1622667 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Yuly Novikov <ynovikov@chromium.org>
Geoff Lang ee244c77 2019-05-06T10:30:18 Vulkan: Move command graph and garbage to ContextVk. To support multithreading, contexts should manage their own command graphs and garbage. This allows safe access to vulkan resources such as command pools without thread synchronization. BUG=angleproject:2464 Change-Id: I930149bc9f0793028761ee05ab50b8c0a4dec98a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1516515 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi ce9be8c7 2019-05-24T09:35:06 Vulkan: Have a cubemap as 2D-array view handy Previously, only texture copies used a shader that performed texelFetch(). To support cubemaps, a hack was used to temporarily create a 2D array view. With upcoming support for multisample resolve, more shaders will be using texelFetch() all requiring this workaround. This change instead makes sure that a separate view is created for cubemaps for the purpose of being used with these shaders. As a result, we have three logical views on textures and render targets: - Draw: a view that can be used as a color/depth/stencil attachment - Read: a view that can be used to sample from - Fetch: a view that can be used to fetch from The fetch view is generally the same as the read view, except for cube maps. Bug: angleproject:3200 Change-Id: I21547f728c16f0aa8f0fcae152c400b5cc1565da Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1628585 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Jamie Madill 6722009e 2019-05-20T11:12:53 Vulkan: Handle dirty RTs with state messages. Prior to this CL we were handling dirty state change notifications by flushing the RT Images just prior to use or just after they were changed. This could lead to a few redundant checks in several places. It also meant we needed an owner pointer from the RT to the parent Image. This pointer would be null for Surfaces and Renderbuffers. This cleans up the image flushing logic to be handled by dirty bit notifications. When an app updates an attached Texture with TexSubImage or related calls it will send a notification to the Framebuffer. The Framebuffer then sets a dirty contents bit that is handled in the implementation. In Vulkan this means flushing the dirty bits. Requires adding a flag to the FramebufferImpl class to determine if we need to syncState before we checkStatus. Adding the option allows us to only call syncState for the GL back-end. Not calling syncState allows the robust resource init operation to happen *before* we syncState. Which in turn allows FramebuffeVk to initialize the VkImages in one go. Added new regression tests for Texture updates. This might not cover all cases. I found it was very hard to trigger some of the resource update staging in TextureVk. Bug: angleproject:3427 Change-Id: Idfa177436ba7fcb9d398f2b67922e085f778f82a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1601552 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Jamie Madill 0631e19b 2019-04-18T16:09:12 Vulkan: Rename Vulkan "Texture" format to "Image" Also adds some comments to vk_format_utils.h. Bug: angleproject:3372 Change-Id: I529b9b189e4cdfd400c3c981a47139727d9954ab Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1565062 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Shahbaz Youssefi 95c0fae6 2019-04-16T22:46:08 Vulkan: Clear surface images if emulated format This was done for renderbuffers but was missing for surfaces. Bug: angleproject:2722 Change-Id: I019805d6ca43eef86d2d46e7c72c1013803f2139 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1570149 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Shahbaz Youssefi 65d10f3b 2019-03-21T16:30:31 Vulkan: Implement robust resource initialization If a texture or renderbuffer needs to be cleared for robust access or due to having emulated channels, it is immediately cleared. The former relies on a front-end feature that optimizes robust access clears only to levels and layers that are not fully initialized through data upload. Bug: angleproject:2722 Change-Id: Icdab856eb4ffe963f78569b6d80d9ff5cb27ff9b Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1535056 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Shahbaz Youssefi 2660b503 2019-03-21T12:08:40 Vulkan: Restore CommandBuffer to namespace vk Moved vk::CommandBuffer and vk::SecondaryCommandBuffer to vk::priv:: and aliased vk::CommandBuffer to one or the other. This allows the rest of the classes to continue seeing vk::CommandBuffer as they used to do. Used a special alias for the primary command buffer that gets submitted (vk::PrimaryCommandBuffer). Bug: angleproject:3136 Change-Id: I61236fd182230991db7395d05e3da3be5e3f45be Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1534456 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Tobin Ehlis 134425c7 2019-03-15T17:02:17 Vulkan:Integrate SecondaryCommandBuffers Integrate the custom SecondaryCommandBuffer type into the CommandGraph nodes by adding new ANGLE_USE_CUSTOM_VULKAN_CMD_BUFFERS define that can be set in the BUILD gn args with angle_enable_custom_vulkan_cmd_buffers set to "true." Initially the custom cmd buffers are disabled by default. This adds some support functions to SecondaryCommandBuffer to make the integration easier by matching the wrapped cmd buffer interface: initialize(), end(), valid(). Bug: angleproject:3136 Change-Id: Ib910554583192550757bb8ce89914e3ea8737988 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1526556 Commit-Queue: Tobin Ehlis <tobine@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Geoff Lang 009696c5 2019-01-31T14:47:07 Vulkan: Support EGL_ANDROID_image_native_buffer on Android. BUG=angleproject:2668 BUG=angleproject:3121 Change-Id: I0dfb2ec0737ebd963b0fadb78cf720a90874f00b Reviewed-on: https://chromium-review.googlesource.com/c/1452264 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Geoff Lang eca36cb5 2019-01-18T14:03:52 Vulkan: Support EGL images sourced from cube maps. Store an image array offset and source texture type in ImageVk to select the correct cube face from the source texture. BUG=angleproject:2668 Change-Id: I03ad25feccb769c906dd28fb573ec342e7816863 Reviewed-on: https://chromium-review.googlesource.com/c/1422542 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Geoff Lang 4a298703 2019-01-18T10:49:36 Vulkan: Support creating EGL images from non-zero mipmaps of textures. Store a mip offset in TextureVK to apply to all operations on the ImageHelper. There is no need to store the mip offset in RenderbufferVk because it creates the resource with the mip offset on the call to setStorageEGLImageTarget. Store a mipmap level in the RenderTargetVk object so that clear operations will target the correct mipmap of the image. BUG=angleproject:2668 Change-Id: Ie976e3dd3a8de8135a7fbb8c84bd51eec0dddce8 Reviewed-on: https://chromium-review.googlesource.com/c/1422059 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>