src/libANGLE/renderer/vulkan/vk_cache_utils.cpp


Log

Author Commit Date CI Message
Charlie Lao 2b8d6bbe 2024-11-01T11:23:35 Vulkan: Use UpdateFullTexturesDescriptorSet when cache missed DescriptorSetDescBuilder::updateDescriptorSet() relies on the cache key to build descriptorSet. UpdateFullTexturesDescriptorSet() builds descriptorSet directly from state, it does not use cache key. Test shows UpdateFullTexturesDescriptorSet is much faster than updateActiveTexturesForCacheMiss and updateDescriptorSet pair. This CL removes updateActiveTexturesForCacheMiss() function and uses UpdateFullTexturesDescriptorSet for cache miss case. The timing code is added around the cache miss functions to measure the time. Old: asphalt_9 average 7,554 nanosec gl_driver2_off: 20,354 nanosec batman_telltale: 12,992 nanosec New: asphalt_9 average 916 nanosec gl_driver2_off: 1,839 nanosec batman_telltale: 3,437 nanosec Bug: angleproject:372268711 Change-Id: I176d67ed732c3fe3a18a079df7c4973aa926087a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5984893 Reviewed-by: Yuxin Hu <yuxinhu@google.com> Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Charlie Lao fbe34df7 2024-10-29T16:19:29 Vulkan: More texture descriptorSet code cleanup Removed unused argument `pipelineType` from updateActiveTexturesForCacheMiss(). Removed unused argument `context` from getReadImageView() Rename getBufferViewAndRecordUse() to getBufferView() since there is no "record use" happening. Moved UpdateFullActiveTexturesDescriptorSet() function from vk_cache_utils.cpp to ProgramExecutableVk.cpp anonymous name space, since it is only used in this file. Bug: angleproject:372268711 Change-Id: Ib7240c1063f727fb52588234e79fba349f9aff9e Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5977481 Reviewed-by: Yuxin Hu <yuxinhu@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Charlie Lao <cclao@google.com>
Rafay Khurram a21b7ad0 2024-04-24T02:11:42 CL/Vulkan: Add skeleton for CLSamplerVk * It is setup to be a wrapper for the SamplerHelper interface Bug: angleproject:42266936 Change-Id: Iac7e80c4d5262687d98a8188a60a24a9be190dc2 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5801184 Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Charlie Lao 5c26ffea 2024-10-29T11:11:38 Vulkan: Optmize descriptorSet cache disable code path Right now the way it works is that it first computes the cache key and then use the cache key to look in the cache. If cache misses, then it builds descriptorSet out of the cache Key. This might make sense if cache is enabled. If cache is disabled then no need to go through the middle man. This CL skip all the cache key build up entirely and directly build descriptorSet out of context state. In this CL, updateFullActiveTextures() and updateDescriptorSet() are merged into one function UpdateFullActiveTexturesDescriptorSet() which updates VkWriteDescriptorSet directly. Bug: angleproject:372268711 Change-Id: I7ba0c60a23b967d1ac903020d04022405c29e354 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5972508 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Yuxin Hu <yuxinhu@google.com> Commit-Queue: Charlie Lao <cclao@google.com>
Shahbaz Youssefi 08c1724f 2024-10-11T14:29:00 Vulkan: Support GL_ARM_shader_framebuffer_fetch_depth_stencil Bug: angleproject:352364582 Change-Id: I63fd78314fa7ebccbf366c252e309a9c0f09c8c1 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5938150 Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Yuxin Hu <yuxinhu@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 65fcf9c4 2024-10-26T10:53:18 Vulkan: Remove redundant dependent feature checks Since [1], when a feature is overriden, the dependent features automatically take the override into account. Tests no longer need to account for dependent features, neither does the logic in the code. [1]:https://chromium-review.googlesource.com/c/angle/angle/+/4749524 Bug: angleproject:42266725 Change-Id: I5440aba4a89cffbe710e26ad7de4cfee783e9bdf Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5967414 Reviewed-by: Yuxin Hu <yuxinhu@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com>
Charlie Lao 9a4c7495 2024-10-15T13:05:28 Vulkan: Add feature flag to enable descriptorSet cache So that we can disable it to compare the performance difference. Bug: angleproject:372268711 Change-Id: I02da254e5d58815741080634a2dd005617aa7432 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5936135 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Yuxin Hu <yuxinhu@google.com>
Charlie Lao 31c80bbf 2024-10-17T10:56:16 Vulkan: Avoid redundant work in updateFullActiveTextures ContextVk keeps mActiveTexturesDesc, which gets updated by UpdatePreCacheActiveTextures(). This is only used for cache lookup. When there is a cache miss, we end up call updateFullActiveTextures() which recomputes DescriptorSetDesc again, which is redundant work. This CL removes mActiveTexturesDesc from ContextVk. UpdatePreCacheActiveTextures has been changed to be a DescriptorSetDescBuilder method so that it can directly update the mDesc. updateFullActiveTextures has been renamed to updateActiveTexturesForCacheMiss which avoid mDesc calculation. updateFullActiveTextures is still kept for now which will be used in next CL when cache is disabled. Bug: b/372268711 Change-Id: Ic9a0cdaa7cefca5f72b599d26d079cef14888f07 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5905766 Reviewed-by: Yuxin Hu <yuxinhu@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Charlie Lao <cclao@google.com>
Shahbaz Youssefi a1584f49 2024-10-11T21:17:32 Vulkan: Qualify framebuffer fetch with "Color" In preparation for depth/stencil framebuffer fetch, many framebuffer fetch symbols are affixed with Color to indicate that they pertain to color framebuffer fetch logic. Bug: angleproject:352364582 Change-Id: I86000ada5e6ef47387dec0b6a3fca589d816cdc2 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5926593 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Yuxin Hu <yuxinhu@google.com>
Shahbaz Youssefi 1608d0be 2024-10-10T16:53:15 Vulkan: Isolate framebuffer fetch no-RP-break optim from DR Prior to [1], changes to framebuffer fetch usage by shaders caused a render pass break. This was due to a limitation of render pass compatibility rules. It also caused other headache, such as needing to clear the render pass cache, recreating pipelines etc. [1]:https://chromium-review.googlesource.com/c/angle/angle/+/3697308 In [1] an important optimization was implemented for tiling GPUs where ANGLE permanently switched to framebuffer fetch mode on first encountering framebuffer fetch use. From that point on, ANGLE would always make every render pass framebuffer fetch compatible. In reality, the render pass break was unnecessary, which became apparent with dynamic rendering (for example that whether the render pass includes input attachments has no bearing on a pipeline that doesn't use input attachments at all). In [2], dynamic rendering kept the render pass break + permanent switch behavior for simplicity. [2]:https://chromium-review.googlesource.com/c/angle/angle/+/5637155 This change untangles the optimization done for legacy render passes from dynamic rendering, allowing dynamic rendering to start every render pass without framebuffer fetch and enable it later if a framebuffer fetch program is used. This is in preparation for supporting depth/stencil framebuffer fetch, where a perma-switch is troublesome (for example in combination with read-only depth/stencil feedback loops). Bug: angleproject:352364582 Change-Id: I31221cf22a28d58b9b2bf188e9c0b786cd0fe3d2 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5923120 Reviewed-by: Yuxin Hu <yuxinhu@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com>
Aurora Zhang 78a694a1 2024-10-10T14:08:31 Bugfix for ms_to_ss in dynamic rendering VkMultisampledRenderToSingleSampledInfoEXT should be added into VkRenderingInfo.pNext when using dynamic rendering pass. Bug: angleproject:370153437 Change-Id: If9377362d95c60e610ec978eb684918de9807342 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5922915 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Mohan Maiya b3d85cce 2024-09-30T14:28:35 Vulkan: Consolidate write colorspace override states ColorspaceState struct is now used to cache write colorspace related states to determine the colorspace of Vulkan draw image views. ImageViewHelper methods are called during initialization and when colorspace related states are toggled dynamically which in turn process these states and determine the final write colorspace. We can now fully support rendering to EGLImages, with colorspace overrides, via texture or renderbuffer EGLImage targets Bug: angleproject:40644776 Tests: ImageTest*Colorspace*Vulkan MultithreadingTestES3.SharedSrgbTextureMultipleContexts*Vulkan ReadPixelsPBOTest.SrgbUnorm*Vulkan Change-Id: I2be2cd3b5b2b4ac8ecb803c34cde2b846cbd1cbe Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5901256 Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: mohan maiya <m.maiya@samsung.com>
Mohan Maiya b38cc7fa 2024-09-30T12:43:09 Vulkan: Consolidate read colorspace override states ColorspaceState struct is now used to cache read colorspace related states to determine the colorspace of Vulkan read image views. ImageViewHelper methods are called during initialization and when colorspace related states are toggled dynamically which in turn process these states and determine the final read colorspace. Bug: angleproject:40644776 Tests: ImageTest*Colorspace*Vulkan SRGBTextureTest.SRGB*TextureParameter*Vulkan SRGBTextureTestES3.SRGBDecodeTexelFetch*Vulkan Change-Id: I16b3666cd80865936b826dc0738fc9210dabeda9 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5901255 Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: mohan maiya <m.maiya@samsung.com>
Charlie Lao b61f9f9e 2024-10-04T11:07:23 Vulkan: Add operator<< for descriptorSet for debugging Right now it is using streamOut() function which is hard to use with WARN(). This replaces the streamOut function with standard c++ operator<< so that we can use in WARN()/INFO() along with other logs for debugging. Bug: b/368566032 Change-Id: Iec98b4c59f360cbbfb8fbdd85d5d1150fcca8f4a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5908773 Reviewed-by: Yuxin Hu <yuxinhu@google.com> Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Charlie Lao eb4eaea9 2024-10-03T17:15:21 Vulkan: Improve SharedCacheKeyManager::addKey performance This function walks a vector of keys. When there are many keys this could be slow. Also when we have to grow the vector size, it involves memory reallocation which means copy the data from old storage to new storage. This CL changes mSharedCacheKeys to use std::deque instead of vector which solves storage reallocation problem. It also adds angle::BitSet64<64> to track all available (i.e., empty) slots in mSharedCacheKeys so that we don't have to loop most of time. You only loop all keys once to find all empty slots and then subsequent addKey() call will be O(1) until all empty slots are used. Bug: b/368566032 Change-Id: I4d32b461761f1cd64380f5527883b84357bb44c1 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5908690 Reviewed-by: Yuxin Hu <yuxinhu@google.com> Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Yuxin Hu eaffa034 2024-09-24T20:56:04 Revert "Vulkan: Consolidate colorspace override states" This reverts commit bffcd235ba6c031603d798daaa98f1cf9a3f3e46. Reason for revert: Breaks Android test `org.skia.skqp.SkQPRunner#UnitTest_DMSAA_dst_read`. Details: https://b.corp.google.com/issues/369388539. Original change's description: > Vulkan: Consolidate colorspace override states > > ColorspaceState struct is now used to cache colorspace related states > and used to determine the colorspace of Vulkan image views. > ImageViewHelper methods are called during initialization and when > colorspace related states are toggled dynamically which in turn process > these states and determine the final read and write colorspaces. > > We can now fully support rendering to EGLImages, with colorspace > overrides, via texture or renderbuffer EGLImage targets > > Bug: angleproject:40644776 > Tests: ImageTest*Colorspace*Vulkan > MultithreadingTestES3.SharedSrgbTextureMultipleContexts*Vulkan > SRGBTextureTest.SRGB*TextureParameter*Vulkan > SRGBTextureTestES3.SRGBDecodeTexelFetch*Vulkan > ReadPixelsPBOTest.SrgbUnorm*Vulkan > Change-Id: I1cc2b5bd834b519b83deab4d80a2fcaabeb271d6 > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5841290 > Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> > Reviewed-by: Charlie Lao <cclao@google.com> > Commit-Queue: mohan maiya <m.maiya@samsung.com> Bug: angleproject:40644776 Change-Id: I5bf6cf2ed0c8ec22fc02d8c3da92673ee85fe002 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5888506 Reviewed-by: Yuxin Hu <yuxinhu@google.com> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> Commit-Queue: Yuxin Hu <yuxinhu@google.com>
Mohan Maiya bffcd235 2024-09-13T14:58:00 Vulkan: Consolidate colorspace override states ColorspaceState struct is now used to cache colorspace related states and used to determine the colorspace of Vulkan image views. ImageViewHelper methods are called during initialization and when colorspace related states are toggled dynamically which in turn process these states and determine the final read and write colorspaces. We can now fully support rendering to EGLImages, with colorspace overrides, via texture or renderbuffer EGLImage targets Bug: angleproject:40644776 Tests: ImageTest*Colorspace*Vulkan MultithreadingTestES3.SharedSrgbTextureMultipleContexts*Vulkan SRGBTextureTest.SRGB*TextureParameter*Vulkan SRGBTextureTestES3.SRGBDecodeTexelFetch*Vulkan ReadPixelsPBOTest.SrgbUnorm*Vulkan Change-Id: I1cc2b5bd834b519b83deab4d80a2fcaabeb271d6 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5841290 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: mohan maiya <m.maiya@samsung.com>
Shahbaz Youssefi 167b9e8d 2024-09-18T21:51:38 Vulkan: Fix pipeline cache store vs monolithic pipeline race The thread that creates monolithic pipelines needs to hold the pipeline cache lock, as well as the thread that stores the pipeline cache contents to the blob cache. Bug: angleproject:42265839 Change-Id: I17cf9d2bb3f27d531f368003cb4ee00007a464fa Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5872715 Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Gowtham Tammana f8fc8ac3 2024-08-05T11:50:11 Vulkan: Remove dependency on ContextVk for CommandBufferHelper Following on the changes in [1], this makes the `CommandBufferHelperCommon` and `OutsideRenderPassCommandBufferHelper` interfaces independent of `ContextVk` state. Any dependency is made explicit. In addition, interfaces that are not specific to GLES context are also updated. [1]: Commit (bcf814fda5 Vulkan: Constrain the dependency on ContextVk in BufferHelper) Bug: angleproject:8544 Change-Id: I7d90ad915e8c14187ab5584453b9e8802bd91e2b Signed-off-by: Gowtham Tammana <g.tammana@samsung.com> Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5319147 Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Mohan Maiya 26cdf621 2024-07-31T14:43:12 Vulkan: Bugfix in dynamic rendering support Fix 2 bugs - 1. Set VkGraphicsPipelineCreateInfo::flags when linking GPLs 2. Chain VkRenderingFragmentShadingRateAttachmentInfoKHR struct in VkRenderingInfo::pNext Bug: angleproject:42267038 Change-Id: I456c75d57ec64926a21dffe93b05e1bbab2cb262 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5754635 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Charlie Lao 7c77bb75 2024-07-24T12:05:29 Vulkan: Remove implicit buffer barrier for shader write When app uses shaders to write to SSBO, right now we are inserting an implicit barrier to ensure WAW are in order. But Spec says that "Explicit synchronization is required to ensure that the effects of buffer and texture data stores performed by shaders will be visible to subsequent operations using the same objects". This CL removes the implicit barrier for buffer write if the current write comes from shaders and relies on explicit glMemoryBarrier to insert a global barrier. Bug: angleproject:350994515 Change-Id: I8ab039610be9be2ded27ea60dab54bdad08502f6 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5719258 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Yuxin Hu <yuxinhu@google.com>
Shahbaz Youssefi 7691cea7 2024-07-22T13:46:14 Vulkan: Remove seamful cubemap emulation Practically, the Vulkan backend is never expected to run on ES2 hardware. It _may_ for WebGL, but seamful cubemap emulation was disabled for webgl anyway. Bug: angleproject:354729454 Change-Id: Iafa20fbdbe232c4df4c777b12e7698ef7a87cf24 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5730143 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Auto-Submit: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Yuxin Hu <yuxinhu@google.com> Reviewed-by: Charlie Lao <cclao@google.com>
Shahbaz Youssefi 1db80b88 2024-07-10T12:47:42 Reland "Vulkan: Use VK_KHR_dynamic_rendering[_local_read]" This is a reland of commit c379ff48043a47e444c388c45270db40d3172d50 Original change's description: > Vulkan: Use VK_KHR_dynamic_rendering[_local_read] > > Bug: angleproject:42267038 > Change-Id: I1f4eb0f309992a9c1c287a69520dadf5eff23b26 > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5637155 > Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> > Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com> > Reviewed-by: Charlie Lao <cclao@google.com> Bug: angleproject:42267038 Change-Id: I083e6963b5421386695e49a9872edbb2016c9763 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5691342 Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com>
Shahbaz Youssefi 1f87cbc9 2024-07-15T13:07:35 Vulkan: Fix late-added resolve attachment tracking Resolve attachments may be added after the fact to a render pass due to glBlitFramebuffer or eglSwapBuffer. Previously, only the resolve image views were tracked by the render pass, and otherwise the state tracking (layout, content defined, etc) treated the resolve images as generically written-to by the render pass. As a result, the render pass was unable to finalize the layout of the resolve images early. Optimizing the layout of the swapchain image when the surface is multisampled for example was not done due to this issue. In this change, when resolve attachments are added late, they are tracked identically to when they are added at the beginning of the render pass, fixing the issues described above. Bug: angleproject:42265625 Bug: angleproject:42266019 Change-Id: I765560762bb8caf39ba1096fb028177201c082d7 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5707470 Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 7d461b21 2024-07-10T14:11:53 Revert "Vulkan: Use VK_KHR_dynamic_rendering[_local_read]" This reverts commit c379ff48043a47e444c388c45270db40d3172d50. Reason for revert: Regresses CPU perf and memory when _not_ using DR Original change's description: > Vulkan: Use VK_KHR_dynamic_rendering[_local_read] > > Bug: angleproject:42267038 > Change-Id: I1f4eb0f309992a9c1c287a69520dadf5eff23b26 > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5637155 > Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> > Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com> > Reviewed-by: Charlie Lao <cclao@google.com> Bug: angleproject:42267038 Change-Id: I3865f0d86813f0eeb9085a92875a33bd449b907f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5691337 Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi c379ff48 2024-06-10T22:01:57 Vulkan: Use VK_KHR_dynamic_rendering[_local_read] Bug: angleproject:42267038 Change-Id: I1f4eb0f309992a9c1c287a69520dadf5eff23b26 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5637155 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com> Reviewed-by: Charlie Lao <cclao@google.com>
Igor Nazarov 7d61980e 2024-06-26T18:39:53 Vulkan: Rename DescriptorSetLayoutDesc update() to addBinding() The `update()` method is never actually used to update the exiting bindings (but rather to add new ones), this change renames the method to `addBinding()` and adds few ASSERTs for clarity. Also, after recent changes in `DescriptorSetLayoutDesc` class, some changes made by `update()` method are irreversible. It is possible to have different descriptions that will produce same layout if use `update()` to rewrite the existing structure. Bug: angleproject:8677 Change-Id: If85eb2b271bc06843ee9326c024d73801d3da091 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5676345 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Amirali Abdolrashidi a1dea207 2024-06-13T11:40:39 Implement KHR_blend_equation_advanced_coherent * Updated the validation for glBlendBarrier() and ~KHR(). * GL state now includes mBlendAdvancedCoherent. * Updated glEnable() to accept GL_BLEND_ADVANCED_COHERENT_KHR. * It can be queried via glGetIntegerv(), etc. * EXTENDED_DIRTY_BIT_BLEND_ADVANCED_COHERENT added. * Added a corresponding bit to ExternalContextState. * If coherence is supported, there should be no need to use blend barriers, as, based on the spec, the advanced blend ops should then follow order like the basic blend ops. * Relevant tests: *GLES31.functional.blend_equation_advanced.coherent* * On Linux/NVIDIA: From "Not supported" to "Passed" Bug: angleproject:42262258 Change-Id: I7e0e43bdc71524eec111c2d3b024fe73c9795e55 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5634381 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Amirali Abdolrashidi <abdolrashidi@google.com> Reviewed-by: Cody Northrop <cnorthrop@google.com> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Shahbaz Youssefi d0744916 2024-05-07T12:52:53 Vulkan: Smaller PackedDescriptorSetBinding Bug: angleproject:8677 Change-Id: Id7bcef8de129514446384a019b6cce95da13b028 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5522755 Auto-Submit: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: mohan maiya <m.maiya@samsung.com> Commit-Queue: Charlie Lao <cclao@google.com>
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 295ff607 2024-06-05T14:49:33 Vulkan: Precompute stageMask of kImageMemoryBarrierData Right now every time we need a pipelineStage in kImageMemoryBarrierData, we are doing a bitwise AND with mSupportedVulkanPipelineStageMask. This get called multiple times from barrier call. This CL adds mImageLayoutAndMemoryBarrierDataMap that has already precomputed all stageMask, thus avoid run time bitwise OR. This CL also precomputes the bufferWritePipelineStageMask so that flushImpl can be use it without construct every time. Bug: b/345279810 Change-Id: I878bd31c967cd217477061976f07df13b043fa7f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5601073 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com>
Mohan Maiya 6aad8a89 2024-05-31T14:46:28 Vulkan: Remove combineAllShadersInPipelineLibrary If we have VK_NULL_HANDLE as the descriptor set layout handle for both pre-rasterization and fragment shader subset pipelines we run into VVL - VUID-VkGraphicsPipelineCreateInfo-pLibraries-06681 Need to work around this by having the renderer store a placeholder descriptor set layout handle for an empty DescriptorSetLayoutDesc that can be reused across all contexts Bug: angleproject:8677 Tests: EGLMultiContextTest.NonSharedContextsReuseDescritorSetLayoutHandle* Change-Id: I22e7f39c497d7f668afe7cb26690f6a9de49831b Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5587990 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi c3a1cae4 2024-04-15T14:58:55 Use angle::SimpleMutex everywhere in libGLESv2 Only cases left that use std::mutex are: - Share group and the context ErrorSet mutexes as they need try_lock() - Anywhere mutexes are used in conjunction with std::condition_variables (as they explicitly require std::mutex) Bug: angleproject:8667 Change-Id: Ib6d68938b0886f9e7c43e023162557990ecfb300 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5453294 Reviewed-by: Roman Lavrov <romanl@google.com> Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Mohan Maiya 97aaad3a 2024-04-20T19:27:13 Vulkan: Pack DescriptorSetLayoutDesc layout Use angle::FastVector instead of arrays to further compact DescriptorSetLayoutDesc layout Bug: angleproject:8677 Tests: VulkanDescriptorSetLayoutDescTest* Change-Id: I5bb7b2ebf0aa5aba3d7c47c45384788245dce3dc Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5470362 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: mohan maiya <m.maiya@samsung.com>
Mohan Maiya a0b721bc 2024-04-23T17:08:58 Vulkan: Optimize DescriptorSetLayout with no bindings There is no need to unpack bindings of DescriptorSetLayoutDesc and call into vkCreateDescriptorSetLayout when there are no bindings. Insert a placeholder vk::DescriptorSetLayout into DescriptorSetLayoutCache. This reduces the number of Vulkan handles created and can be reused across multiple pipelines that have DescriptorSetLayoutDesc with no bindings. Bug: angleproject:8677 Change-Id: Ifc0d199697a95f3a5c037fd85520220a512d7949 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5483308 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com>
Mohan Maiya 48132950 2024-04-17T17:05:07 Vulkan: Optimize DescriptorSetLayoutDesc layout Separate out immutable samplers into its own array so we can remove padding from PackedDescriptorSetBinding which reduces the size of that struct from 16 bytes to 4 bytes. Bug: angleproject:2462 Change-Id: I79d1ab584178202c9b7f34b0c7926edced4e21a8 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5464162 Commit-Queue: mohan maiya <m.maiya@samsung.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com>
Shahbaz Youssefi 80c8b6f0 2024-04-17T10:06:45 Revert "Vulkan: Only enable DS dynamic state if there is DS attachment." This reverts commit 471b50407d7d1c22491d066df77060cb8b9b2f89. The reverted change does not correctly handle UtilsVk functions, leading to validation failures. UtilsVk could be made to not set dynamic state when the depth/stencil attachments are missing, but instead the change is reverted because: - The original issue that prompted this is easily fixable (and fixed in this change) - Disabling depth/stencil dynamic state is not necessarily a performance improvement; every time a pipeline in such a render pass is bound, the driver would have to make sure to no-op the relevant state change if static, which is also costly. Instead, dynamic state may need to be set only once in the entire render pass. Bug: b/223456677 Bug: b/315353258 Bug: angleproject:8242 Change-Id: I8282b87857d6b9285dbcf307c3c6ecf69df5fadb Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5462079 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Yuxin Hu <yuxinhu@google.com>
Mohan Maiya b2aad1bb 2024-04-17T06:12:14 Vulkan: Track valid descriptor set layouts Instead of looping through kMaxDescriptorSetLayoutBindings in `DescriptorSetLayoutDesc::unpackBindings` track valid descriptor set layouts in `DescriptorSetLayoutDesc::update` Bug: angleproject:2462 Change-Id: I1ca2ba72875d9306b6059b14cde39c5d16250be6 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5464160 Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: mohan maiya <m.maiya@samsung.com>
Mohan Maiya c1397510 2024-04-07T21:05:34 Vulkan: Fix data race in WarmUpGraphicsTask std::unordered_map doesn't support simultaneous read and write. Cache placeholder PipelineHelper in WarmUpGraphicsTask and std::move the newly created PipelineHelper when warm up is complete. Bug: angleproject:8297 Change-Id: I1cc4b3cd48147d0080666d5669d61de006c2252d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5431830 Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 4af8dafb 2024-03-10T20:14:18 Vulkan: Enable MSRTT emulation tests on swiftshader Bug: b/309355117 Change-Id: I2d842bc52f9b6af340025654111dfd3f8e9c58a3 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5359654 Commit-Queue: Yuly Novikov <ynovikov@chromium.org> Auto-Submit: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Yuly Novikov <ynovikov@chromium.org>
Mohan Maiya ad13fec3 2024-03-30T15:31:49 Vulkan: warmUpGraphicsPipelineCache(...) shouldn't set state The prepareForWarmUpPipelineCache(...) method would have already setup all necessary state for the warm up task. Make that intent explicit by calling into a method that sets no state. Bug: angleproject:8297 Change-Id: I959d8591045ff05ddb2a410fd0e0eda8dd692d37 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5408796 Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: mohan maiya <m.maiya@samsung.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 13829f20 2024-03-26T23:03:12 Vulkan: Optimize depth/stencil resolve with glBlitFramebuffer Like color resolve, depth/stencil resolve is now also possibly done by modifying the render pass and attaching a depth/stencil resolve attachment. Bug: angleproject:7551 Change-Id: I045e3875e24006d2473a55b6c3856dd768fe8b84 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5398004 Reviewed-by: Yuxin Hu <yuxinhu@google.com> Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi b559efa8 2024-03-26T22:02:41 Vulkan: Allow depth and stencil resolve to be separately added In preparation for optimizing resolve through glBlitFramebuffer for depth/stencil attachments. Bug: angleproject:7551 Change-Id: I57650d82c0cc6e56f44591eadfc42ac794cfef09 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5399140 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com> Reviewed-by: Yuxin Hu <yuxinhu@google.com>
Shahbaz Youssefi c71a67de 2024-03-27T15:50:00 Vulkan: Move pipeline cache graph dump to renderer In preparation for moving some caches to the share group. Bug: angleproject:6565 Bug: angleproject:8629 Change-Id: I1a06a18417502e499da0edb9abb0d510e3ad99ce Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5401513 Auto-Submit: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: mohan maiya <m.maiya@samsung.com>
Shahbaz Youssefi 9475ac40 2023-11-15T10:25:06 Vulkan: Make efficient MSAA resolve possible Prior to this change, using a resolve attachment to implement resolve through glBlitFramebuffer was done by temporarily modifying the source FramebufferVk's framebuffer description. This caused a good deal of complexity; enough to require the render pass to be immediately closed after this optimization. The downsides to this are: - Only one attachment can be efficiently resolved - There is no chance for the MSAA attachment to be invalidated In this change, resolve attachments that are added because of glBlitFramebuffer are stored in the command buffer, with the FramebufferVk completely oblivious to them. When the render pass is closed, either the FramebufferVk's original framebuffer object is used (if no resolve attachments are added) or a temporary one is created to include those resolve attachments. With the above method, the render pass is able to accumulate many resolve attachments as well as have its MSAA attachments be invalidated before it is flushed. For a FramebufferVk that is resolved in this way, there used to be two framebuffers created each time and thrown away as the code alternated between starting a render pass without a resolve attachment and then closing with one. With this change, there is now one framebuffer (without resolve attachments) that is cached in FramebufferVk (and is not recreated every time), and only the framebuffer with resolve attachments is recreated every time. Ultimatley, when VK_KHR_dynamic_rendering is implemented in ANGLE, there would be no framebuffers to create and destroy, and this change paves the way for that support too. WindowSurfaceVk framebuffers are still imagefull. Making them imageless adds unnecessary complication with no benefit. ----------------- To achieve efficient MSAA rendering on tiling hardware, applications should do the following: ``` glBindFramebuffer(GL_FRAMEBUFFER, msaaFBO); // Clear the framebuffer to avoid a load // Or invalidate, if not needed to load: // glInvalidateFramebuffer(GL_DRAW_FRAMEBUFFER, ...); glClear(...); // Draw calls // Resolve into the single sampled framebuffer glBindFramebuffer(GL_DRAW_FRAMEBUFFER, resolveFBO); glBlitFramebuffer(...); // Immediately discard the contents of the MSAA buffer, to avoid store glInvalidateFramebuffer(GL_READ_FRAMEBUFFER, ...); ``` The above would translate to the following Vulkan render pass: - MSAA LOAD_OP_CLEAR/DONT_CARE - MSAA STORE_OP_DONT_CARE - Resolve LOAD_OP_DONT_CARE - Resolve STORE_OP_STORE This makes sure the MSAA data doesn't leave the tile memory and greatly reduces bandwidth usage. Once anglebug.com/4892 is fixed, this would also allow the MSAA image to never be allocated either. Bug: angleproject:7551 Bug: angleproject:8625 Change-Id: Ia9f4d20863d76a013d8495033f95c7b39f77e062 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5388492 Reviewed-by: Yuxin Hu <yuxinhu@google.com> Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com> Commit-Queue: 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>
Mohan Maiya 21d124c4 2024-03-16T10:06:02 Vulkan: Remove support for pipeline cache control For current and upcoming uses for pipeline caches the benefits of having an externally synchronized pipeline cache is minimal at best. Remove support for that and have all caches be internally synchronized by the Vulkan driver. Bug: angleproject:8601 Change-Id: Ic5d9740934641f61b527094aa301e27302b02a57 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5375102 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
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>
Mohan Maiya 91ddf851 2024-03-03T10:57:22 Vulkan: support QCOM foveated rendering extensions Add support for foveated rendering in the vulkan backend. This is done by leveraging the VK_KHR_fragment_shading_rate extension. Bug: angleproject:8484 Change-Id: I0d01d07583f710b2302ea07b19c9d113c73bfe41 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5269907 Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: mohan maiya <m.maiya@samsung.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Austin Annestrand fc440afa 2024-02-16T13:57:32 Vulkan: Move DS builder class to Vk utils Currently, UpdateDescriptorSetsBuilder lives in ShareGroupVk.cpp/h. The UpdateDescriptorSetsBuilder isn't really GL-specific. Thus it can be moved over to vk_cache_utils.h (more of a Vk utility class). Bug: angleproject:8546 Change-Id: I1ead04bab4c5840e6c471cdc7c5db4220e32bd50 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5303540 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Mohan Maiya 6607a2b9 2024-01-17T15:58:20 Vulkan: Add support for VK_EXT_vertex_input_dynamic_state Hook into VK_EXT_vertex_input_dynamic_state so pipeline states that differ only in vertex input state can reuse existing pipelines. Bug: angleproject:7162 Tests: StateChangeTestES3.Vertex* Change-Id: Icd3134dee93fc5fc2e9d284fcfa8c674b62faec8 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5207462 Commit-Queue: mohan maiya <m.maiya@samsung.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Chris Forbes f5f3304a 2024-02-02T16:27:38 Vulkan: Simplify handling of YUV filtering support When the requested filtering mode changes, we need to consider whether it is actually supported by the Vulkan driver. Now that we support renderable YUV textures, there are now three interesting cases: 1) The texture has a VkFormat, and so filtering support can be queried from GPDFP, as was already done. 2) The texture is imported from an opaque AHB using an external format, that format is renderable, and so we have assigned one of the EXTERNALn angle formats. This was *not* covered properly, and would lead to VVL errors or UB. 3) The texture is imported from an opaque AHB using an external format, and we have not assigned an EXTERNALn angle format to it, because the format is not renderable, or the Vulkan driver is missing the external format resolve functionality; In this case the angle format is NONE. This was similarly *not* covered properly, although the code did attempt to protect itself from querying the capabilities of format NONE. VVL errors and UB were still possible. To most simply cover all of these cases, capture whether the image has the VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_LINEAR_FILTER feature upfront, and forget about format lookups in the internals of the YcbcrConversionDesc. Bug: b/315387961 Change-Id: Ie140293d52c2b88bf06ef19bc54bb1c95927b8ce Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5259719 Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Cody Northrop <cnorthrop@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 0c4d6446 2024-01-24T10:38:45 Rework uniform block <-> uniform buffer mapping In GLES, the shader declares which buffer binding a block (uniform, storage or atomic counter) is bound to. For example: layout(binding = 1) uniform ubo0 { ... }; layout(binding = 2) uniform ubo1 { ... }; layout(binding = 1) uniform ubo2 { ... }; In the above, ubo0 and ubo2 use data from the buffer bound to index 2 (through glBindBufferRange), while ubo1 uses data from the buffer bound to index 1. For uniform blocks in particular, omitting the binding is allowed, in which case it is implicitly bound to buffer 0. GLES allows uniform blocks (and only uniform blocks) to remap their bindings through calls to glUniformBlockBinding. This means that the mapping of uniform blocks in the program (ubo0, ubo1, ubo2) to the buffer bindings is not constant. For storage blocks and atomic counter buffers, this binding _is_ constant and is determined at link time. At link time, the mapping of blocks to buffers is determined based on values specified in the shaders. This info is stored was stored in gl::InterfaceBlock::binding (for UBOs and SSBOs), and gl::AtomicCounterBuffer::binding. For clarity, this change renames these members to ...::inShaderBinding. When glUniformBlockBinding is called, the mapping is updated. Prior to this change, gl::InterfaceBlock::binding was directly updated, trumping the mapping determined at link time. A bug here was that after a call to glProgramBinary, GL expects the mappings to reset to their original link-time values, but instead ANGLE restored the mappings to what was configured at the time the binary was retrieved. This change tracks the uniform block -> buffer binding mapping separately from the link results so that the original values can be restored during glProgramBinary. In the process, the support data structures for tracking this mapping are moved to ProgramExecutable and the algorithms are simplified. Program Pipeline Objects maintain this mapping identically to Programs and no longer require a special and more costly path when a buffer state changes. This change prepares for but does not yet fix the more fundamental bug that the dirty bits are tracked in the program executable instead of the context state, which makes changes not propagate to all contexts correctly. Bug: angleproject:8493 Change-Id: Ib0999f49be24db06ebe9a4917d06b90af899611e Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5235883 Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Mohan Maiya ac71a592 2024-01-23T11:56:42 Vulkan: updates to pipeline cache graph dumping logic 1. To dump pipeline cache graph you need to - 1. add "angle_dump_pipeline_cache_graph" compile time flag to args.gn 2. set Android property "angle.dump_pipeline_cache_graph" or envvar ANGLE_DUMP_PIPELINE_CACHE_GRAPH on non-Android platforms before app start 2. Default path for dump on Android is "/data/local/tmp/angle_dumps/" 3. "angle.pipeline_cache_graph_dump_path" Android property or envvar ANGLE_PIPELINE_CACHE_GRAPH_DUMP_PATH on non-Android platforms can be used to configure the dump path Bug: angleproject:6565 Change-Id: I38848aff58f413dd7bdffc9083116bd4b95e4960 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5226054 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: mohan maiya <m.maiya@samsung.com>
Shahbaz Youssefi c6fbf93d 2024-01-19T09:57:12 Vulkan: Fix input attachments leaking into uniform list To communicate the existence of input attachments added to the shader, the translator was adding `ShaderVariable`s for each to the list of uniforms exported from the shader. This was incorrect, as this list is visible to the application through `glGetActiveUniform`. Additionally, this was unnecessarily causing these uniforms to go through program link. Reserving SPIR-V ids for these uniforms, all that is needed from the translator is the mere existence of these input attachments. This change removes the addition of uniforms, and instead exports a bitset. Elsewhere, that bitset is consulted and reserved SPIR-V ids are used. Bug: b/320563594 Bug: angleproject:5792 Change-Id: Id93846cbc3996248f391fd2d5a65af1e48d6d46e Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5215089 Reviewed-by: mohan maiya <m.maiya@samsung.com> Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi fb6b960c 2023-11-27T14:24:28 Remove GL_CHROMIUM_texture_filtering_hint This was using an unregistered Vulkan extension to set the precision of SwiftShader's internal filtering for the sake of Chrome. That's baked in at build instead. Bug: angleproject:8349 Bug: chromium:726075 Change-Id: I12849d2d29d99626f22a92ee9d74366f78658476 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5063344 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Roman Lavrov 8b4901d0 2023-11-06T10:43:14 Avoid GLenum conversion in BlendStateExt blend and equation The following functions now return value as is without ToGLenum conversion (that is often unnecessary): getEquationColorIndexed getEquationAlphaIndexed getSrcColorIndexed getDstColorIndexed getSrcAlphaIndexed getDstAlphaIndexed (at least) getEquationColorIndexed is on the hot path with noticeable performance impact; this CL also moves the implementation to the header to allow inlining. Bug: b/300968773 Change-Id: Ie223abe14b12afd7844686863ee5806945d10e45 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5008031 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Roman Lavrov <romanl@google.com>
Charlie Lao 471b5040 2023-10-26T09:33:29 Vulkan: Only enable DS dynamic state if there is DS attachment. This is discovered while investigating EXT_yuv_target crash in driver. What happens is that UtilsVk::copyImage does not set depth stencil dynamic state since there is no depth stencil attachment. But we enabled dynamic state for D/S, thus driver still does D/S state setup, which sees garbage data and hitting assertion. Even though this is discovered with EXT_yuv_target test, I believe this is a general issue. This CL adds the renderPassDesc.hasDepthAttachment() and hasStencilAttachment() check and enable depth or stencil related dynamic state only if there is depth or stencil attachment. This fixes crash in driver with ImageTestES3.ClearYUVAHB test. This also has added performance benefit that we now completely skips depth/stencil related dynamic state dirty bit handling code, thus reduces state processing CPU overhead. Bug: b/223456677 Change-Id: I3a4fe6d97b14c066d78f8b8ded21c626cb2f376c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4980765 Reviewed-by: Chris Forbes <chrisforbes@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Yuxin Hu <yuxinhu@google.com> Commit-Queue: Charlie Lao <cclao@google.com>
Charlie Lao 43187a24 2023-10-25T09:43:56 Vulkan: remap YUV clearColor component from GL order to vulkan order For EXT_YUV_TARGET, OpenGL and vulkan uses difefrent mapping between YUV to RGB. OpenGL spec says "When clearing YUV Color Buffers, clear color should be defined in yuv color space and so floating point r, g, and b value will be mapped to corresponding y, u and v value and alpha channel will be ignored.", but vulkan spec says "Values in the G, B, and R channels of the color attachment will be written to the Y, CB, and CR channels of the external format image, respectively.". This CL adjusts clear color to remap the clear color from GL ordering to vulkan ordering. This CL also adds a temporary workaround for ARM driver bug where they were looking at unused color attachment instead of resolve attachment. Bug: b/223456677 Change-Id: I9800bffc18ccd9d77b4e86995161cdde06257e1f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4973355 Reviewed-by: Chris Forbes <chrisforbes@google.com> Commit-Queue: Chris Forbes <chrisforbes@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Charlie Lao e4a267e5 2023-10-20T16:10:50 Vulkan: Fix YUV external format resolve attachment load/storeOp When YUV external format resolve attachment is used, and nullColorAttachmentWithExternalFormatResolve is true, the loadOp and storeOp are packed in color attachments.When we setup the resolve attachment, we must use the color attachment information instead of general resolve code path (where there is always a color attachment). Without this fix, the resolve attachment is always uses loadOp=DontCare which is wrong. Bug: b/223456677 Change-Id: Ib41eb438aedbcd9a37c356540e81cdf7b9610a20 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4960502 Reviewed-by: Chris Forbes <chrisforbes@google.com> Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Charlie Lao 4d7fc442 2023-10-18T12:49:06 Vulkan: Fix VK_android_external_format_resolve VVL error part 3 VUID-VkRenderPassAttachmentBeginInfo-pAttachments-parameter: The Vulkan spec states: If attachmentCount is not 0, pAttachments must be a valid pointer to an array of attachmentCount valid VkImageView handles. The bug here is that when nullColorAttachmentWithExternalFormatResolve is true, there is no color attachment, but the RenderPassDesc still appears having a color attachment because we need to store the formatID in it. This CL changes to use mFramebuffer.getImageViews().size() instead of mRenderPassDesc.attachmentCount() which is more correct anyway. Bug: b/223456677 Change-Id: I0f0947f0c642bac9cd18a80525b92c62ef0723ec Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4952969 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Chris Forbes <chrisforbes@google.com>
Charlie Lao 889b01ef 2023-10-17T12:13:10 Vulkan: Fix VK_android_external_format_resolve VVL error part 1 VUID-VkSubpassDescription2-nullColorAttachmentWithExternalFormatResolve-09337: The Vulkan spec states: If the nullColorAttachmentWithExternalFormatResolve property is VK_TRUE and pResolveAttachments is not NULL, for each resolve attachment that has a format of VK_FORMAT_UNDEFINED, the corresponding color attachment must have the value VK_ATTACHMENT_UNUSED VUID-VkFramebufferCreateInfo-attachmentCount-00876 The Vulkan spec states: attachmentCount must be equal to the attachment count specified in renderPass Fix assertion in FramebufferVk::getFramebuffer() Bug: b/223456677 Change-Id: I538a44753a2ba9b432fa3b1814748942cd8a3500 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4948652 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Charlie Lao <cclao@google.com>
Charlie Lao 2e11fcc5 2023-10-16T16:40:35 Vulkan: Fix assertion when YUV image attached to resolve attachment When YUV image attached to resolve attachment, mSamples is 1. Righ now the code assumes resolve is a MSRT attachment, so it asserts mSamples>1. This CL adds a new API packYUVResolveAttachment so that we can assert properly for YUV and MSRT. Bug: b/223456677 Change-Id: Ib65fd3fe1e6561b85395cc27204bbd85c1f464c3 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4942907 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Chris Forbes <chrisforbes@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Charlie Lao fee512d9 2023-10-11T18:22:13 Vulkan: Add mapping between FormatID and externalFormat This CL adds support to query the external format from AHB and convert that to one of angle::FormatID::EXTERNALn. Then at the time to create renderPass, we convert that angle::FormatID::EXTERNALn back to actual vendor specific external format that returned from vulkan driver. With this, the rest of angle code should not need to worry about actual vulkan external formats. This CL is based on Chris Forbes's CL on android gerrit. Bug: b/223456677 Change-Id: I6d8150741bc590809a9962c1a11a6026f1ebbb74 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4932361 Reviewed-by: Chris Forbes <chrisforbes@google.com> Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Roman Lavrov 6154bd93 2023-10-12T15:27:44 Remove binding from DescriptorInfoDesc. The issue with hitting the cache falsely is no longer reproduced (tests added in https://crrev.com/c/4104121) Charlie had changed the cache so mWriteDescriptors are no longer part of this class, so some of those changes might have affected that. Also mDescriptorInfos was previously a map and now is a vector, which imposes a specific ordering - and that might be taking care of the sampler swap hitting the cache falsely. Charlie suggested that https://crrev.com/c/4581881 might have taken care of this as textureUnit was used instead of bindingIndex: https://chromium-review.googlesource.com/c/angle/angle/+/4936096/comment/ad2c0aa0_441bd33d/ Bug: angleproject:7974 Change-Id: I58391790a4362313c07c7bd28ed6f38f30720781 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4936096 Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Roman Lavrov <romanl@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Charlie Lao 9ca025d2 2023-09-18T15:50:48 Flatten BufferVariable/ShaderVariableBuffer/InterfaceBlock struct InterfaceBlock inherits from ShaderVariableBuffer, ShaderVariableBuffer is not a trivially copyable struct, this made InterfaceBlock not trivially copyable. InterfaceBlock is being used by some app traces for uniform blocks. BufferVariable inherits from sh::ShaderVariable which is very complicated and not trivially copyable. This CL flattens all of these three structs to simple structs without inheritance, and wraps all trivially copyable data into one POD struct, thus load/save are cheaper. Bug: b/275102061 Change-Id: I96f89176ce3d3131cb1d3ea3280c3c36c257560f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4874610 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Roman Lavrov <romanl@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 6698fb69 2023-08-25T22:21:32 Vulkan: Stop passing both ProgramExecutable and ...Vk around Now that ProgramExecutableVk is accessible through ProgramExecutable. Bug: angleproject:8297 Change-Id: Ie08770ef97400195d63b87f2d4b7e2a2c8f4ad24 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4812147 Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Yuxin Hu <yuxinhu@google.com>
Shahbaz Youssefi 571b4cdb 2023-08-14T16:55:28 Vulkan: Move pipeline/desc-set layout creation to link job The pipeline and desc-set layout caches are consequently made thread-safe. The reference counter on the layouts are also made atomic. With this change, practically all of the link in the Vulkan backend is moved to the link job. Bug: angleproject:8297 Change-Id: Iba694ece5fc5510d34cce2c34441ae08ca5bb646 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4774787 Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Charlie Lao 03f9dff6 2023-08-21T16:57:12 Separate out std::vector<GLuint> boundTextureUnits from SamplerBinding SamplerBinding struct is trivial copy-able except the std::vector<GLuint> boundTextureUnits. This CL moves boundTextureUnits out of the SamplerBinding struct and becomes a vector in ProgramExecutable. This means all of sampler binding's texture units will be stored in one vector and SamplerBinding will remember where its own texture units is stored in that vector by keeping textureUnitsStartIndex and textureUnitsCount. In other word, SamplerBinding::boundTextureUnits (before this CL) is equivalent to mSamplerBoundTextureUnits[SamplerBinding.textureUnitsStartIndex], ..., mSamplerBoundTextureUnits[SamplerBinding.textureUnitsStartIndex + SamplerBinding.textureUnitsCount - 1] after this CL. With this, ProgramExecutable::mSamplerBindings are load/stored with one readBytes/writeBytes call since it is trivially copyable. Bug: b/275102061 Change-Id: I0974cf940875ecbcf655b4469b3bbc910717f1ec Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4798195 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Roman Lavrov <romanl@google.com> Commit-Queue: Charlie Lao <cclao@google.com>
Mike Schuchardt be60f879 2023-06-28T17:29:45 Workaround for tex buffer type mismatch In the event of a mismatch between a texture buffer format (eg GL_R32F) and the shader sampler type (eg usamplerBuffer), adjust the tex buffer format to match the sampler (eg GL_R32UI). Test: angle_end2end_tests \ --gtest_filter="TextureBufferTestES31.TexBufferFormatMismatch*" Bug: b/233119699 Change-Id: I3461bcecabfe1d96be6350c43c15b32d35265b23 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4769137 Reviewed-by: Cody Northrop <cnorthrop@google.com> Commit-Queue: Mike Schuchardt <mikes@lunarg.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 16cfa28e 2023-08-08T22:08:24 Vulkan: Basic infra for parallel link This change moves pipeline warm up to a parallelizable task, mostly as an exercise to put in the infrastructure for parallel link in the Vulkan backend. Follow up changes will move more of the link step to this task. The end goal is to be able to make the link task independent of ContextVk, which would allow it to be run as an UnlockedTailCall, even if not using a worker thread. Bug: angleproject:8297 Change-Id: I17047162b2a41f0d681d9e3ee33f2e0239b4280d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4764231 Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Charlie Lao 7c69116f 2023-08-08T10:14:47 Vulkan: Fix data race with DynamicDescriptorPool Right now DynamicDescriptorPool::destroyCachedDescriptorSet can be called from garbage clean up thread, while simultaneously accessed from context main thread, and data race will happen and cause bugs. This can only happen when the buffer is not being suballocated. In this case, suballocation owns the bufferBlock and bufferBlock gets destroyed when suballocation is destroyed from garbage collection thread. If buffer is suballocated, the shared group owns pool which owns bufferBlocks and they gets destroyed from shared group with the share group lock. This CL avoids this race problem by release the shared cacheKey when the buffer is released, while we still had the shared group lock. Bug: chromium:1469542 Change-Id: Ic1f99e6b6083d63e4efb9c3f408921da62c006ac Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4761365 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Yuxin Hu <yuxinhu@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Charlie Lao ee019f58 2023-08-01T17:03:24 Group fixed sized data of LinkedUniform into a struct Most of gl::LinkedUniform struct is a basic types and can be simply initialized with memcpy. This CL groups these together and encapsulate them with get APIs. The load/save is now a single memcpy for the entire fixed size data structure of basic types. Bug: b/275102061 Change-Id: I49120c06ec941c783790ac0ecb0ee314a4234b26 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4740298 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Roman Lavrov <romanl@google.com> Commit-Queue: Charlie Lao <cclao@google.com>
Charlie Lao 7bb13226 2023-08-01T12:10:44 Pack booleans inside struct LinkedUniform into bitfields Right now every bool is load/stored as integer, which itself is a memcpy. This CL moves them into a bitfield and load/store with one uint32_t, thus improves efficiency of cache load/save. Bug: b/275102061 Bug: angleproject:8223 Change-Id: Id8e8e8861c8fcbd75dbef6056e4ff6c8ad2fc4a1 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4740292 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Roman Lavrov <romanl@google.com>
Charlie Lao 79973750 2023-07-27T17:53:24 Let UniformLinker uses its own struct instead of LinkedUniform UniformLinker itself needs more detailed information than the final linked uniforms. Right now they are using the same data structure. This CL adds a new structure for linker to use. Since the linker data structure is temporary, we never needs to load/save from cache, we have more freedom here to use complex data types. The benefit of separate out intermediate structure from LinkedUniform is that it allows us to further simplify LinkedUniform structure without change much of ProgramLinkedResource implementation. As result of this, this CL removes field and outerArraySizes (both are std::vector type) from LinkedUniform. Bug: b/275102061 Change-Id: Ic1291b51b8906ac586a2f25eb1dbbe74eae8fdc5 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4727742 Reviewed-by: Roman Lavrov <romanl@google.com> Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Roman Lavrov c0f2f71e 2023-06-27T16:00:09 Use VK_EXT_legacy_dithering when available instead of emulation Yields improvement in gpu power: http://b/284462263#comment45 Bug: b/284462263 Change-Id: I5bfd115557b6baac17c05639118feaebf19c5cd4 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4652590 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Roman Lavrov <romanl@google.com>
Charlie Lao 02292814 2023-06-01T14:46:05 Vulkan: Optimize the usage of FastMap in DescriptorSetDescBuilder While looking at disassemble of DescriptorSetDescBuilder::updateOneShaderBuffer() function, I noticed that there are a lot of CPU cycles spent in FastMap::operator[]. What happend here is that we are increasing size one by one as we build descriptorSet, and that hit `if (mData.size() <= key)` case and we end up resize the underline FastVector, and that resize also initialize the element with zeros, which immediately overwrite by actual data. Since we actually know the eventual size of DescriptorSetDescBuilder::mDesc/mHandles/mDynamicOffsets, we could just switch to angle::FastVector which will avoid this check size and grow every time we write to it. This CL switches the use of FastMap in DescriptorSetDescBuilder to FastVector. The only trick we need to watch out is that previously the new elements are always zero filled and now it does not. So we need to make sure we write every field of structure. This CL also renames WriteDescriptorDescBuilder to WriteDescriptorDescs since when it is read only we are passing it as const reference already, there is no added advantage to have two classes. Bug: b/282194402 Change-Id: I06a063cc51585fc17fbf0d5aa916b9aa0ab88dd4 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4581881 Reviewed-by: Roman Lavrov <romanl@google.com> Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi cafbf6e2 2023-06-22T22:50:32 Vulkan: Simplify active uniform check Bug: angleproject:7220 Change-Id: Ic0f26f3d09bac570d4ed3f791c456d569208424a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4636869 Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi ec1f18db 2023-06-21T10:16:51 Vulkan: Remove ShaderVariableType and flatten info map With the conversion of the interface variable info map keys to SPIR-V ids, there is no longer a benefit to bucket resources by their type. This change removes this bucketing and flattens the map. Bug: angleproject:7220 Change-Id: If83cb02ca9e91f72dddb2deb7313fee40f9f06c3 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4632577 Reviewed-by: Yuxin Hu <yuxinhu@google.com> Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi b5f87c04 2023-06-20T20:22:15 Vulkan: Simplify shader interface variable map The shader interface variable map had a "resource index" -> info map to optimize descriptor set building. That avoided hashing the resource name when the rest of the map was name-based. With the map using SPIR-V ids now, there is no reason to maintain this map; SPIR-V ids can be used to look up the info just as efficiently. Bug: angleproject:7220 Change-Id: I619783dce558a59184955cc314c1f41e6733f1b7 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4630728 Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Yuxin Hu <yuxinhu@google.com>
Shahbaz Youssefi c1ba8e6f 2023-06-20T16:03:20 Vulkan: Flatten shader interface variable maps This change removes duplicate entries added in the shader shader interface variable maps. One level of arrayness (indexed by shader type) is removed from these maps as now there is only a single entry per linked resource/etc. Bug: angleproject:7220 Change-Id: Ibf2d06a0e1f68e68797c2066f36e14cb9e667f77 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4628677 Reviewed-by: Yuxin Hu <yuxinhu@google.com> Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi bbcf54bc 2023-06-16T16:02:08 Vulkan: Refactor uniform/block binding duplication code Previously, resource binding assignment was done as such: ``` for each shader stage assign bindings to textures assign bindings to blocks assign bindings to images etc ``` To deduplicate bindings when the same resource was used in multiple stages, a map was used, keyed by the resource's name, to detect when an already visited resource is encountered in a future stage. This was both inefficient and unnecessarily complicated. With this change, resource binding assignment is done as such: ``` for each texture assign one binding to all shader stages for each block assign one binding to all shader stages for each image assign one binding to all shader stages etc ``` The aforementioned map is removed. Because the resource bindings are now changed, the rest of the code (which sets up the pipeline layout, updates descriptor sets, sets dynamic buffer offsets, etc) are all updated to follow the above pattern. As a result, nested loops are avoided and duplicate entries in the variable map are never visited. Bug: angleproject:7220 Change-Id: Iaff7b5f8b2bada8ac5078d21e5c790bf0d27aca7 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4622011 Reviewed-by: Yuxin Hu <yuxinhu@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com>
Steven Noonan 508eb865 2023-06-19T11:54:06 Vulkan: avoid crash on AMD drivers with MSRTT emulation If you have a multisampled color+depth framebuffer and discard depth before the end of the render pass, ANGLE skips assigning pDepthStencilResolveAttachment. Doing so is fine on most vendors, but on AMD drivers, the application will crash in the user mode driver when calling vkCreateRenderPass2KHR. Simply not adding the depth/stencil resolve structure to the PNext chain avoids the crash and allows the application to function normally. Bug: angleproject:8217 Change-Id: I0dc14c03d2b999e280a4d363e0296fd10812540c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4627280 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Yuly Novikov <ynovikov@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Charlie Lao 2501903e 2023-05-31T11:59:36 Vulkan: Merge UpdateShader***Buffers into updateShaderBuffers Both UpdateShaderUniformBuffers() and DescriptorSetDescBuilder::updateShaderBuffers() walks the list of uniform blocks (or storage blocks). Some of the logic are the same and we are paying that overhead twice. In this CL, UpdateShaderStorageBuffers, UpdateShaderUniformBuffers and UpdateShaderAtomicCounterBuffers functions are merged into DescriptorSetDescBuilder::updateShaderBuffers and DescriptorSetDescBuilder::updateAtomicCounters. In order to handle the usage that same buffer used by multiple shader stages, a new variant of bufferRead() function is added that takes "const gl::ShaderBitSet" instead of single PipelineStage. This also paves way for next CL so that we can call updateOneShaderBuffer individually. Bug: b/282194402 Change-Id: I09d045d6295827b60bdb4c05df9333fe593fa40e Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4574288 Reviewed-by: Roman Lavrov <romanl@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Charlie Lao <cclao@google.com>
Shahbaz Youssefi b0e9bbd7 2023-05-31T14:23:40 Vulkan: Split features for dynamic state When a driver bug with dynamic state is encountered, it is hard to debug which dynamic state exactly is causing an issue, due to the current granularity of disabling all entire state from an extension. With this change, every dynamic state gets its own ANGLE feature, and can be toggled as necessary. Disabling the supportsExtendedDynamicState* features implicitly disables all dependent features. Bug: b/285124778 Bug: b/275210062 Bug: fuchsia:107106 Bug: angleproject:5906 Change-Id: Ic291279872df2d0eb58618ff364ab118bdcc4a9f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4577553 Reviewed-by: Cody Northrop <cnorthrop@google.com> Auto-Submit: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Yuxin Hu <yuxinhu@google.com>
Charlie Lao 01f629e3 2023-05-26T10:23:20 Vulkan: Remove the loop when calling updateShaderBuffers Right now there is a loop of getLinkedShaderStages when calling mShaderBuffersDescriptorDesc.updateShaderBuffers. The shaderType variable is only used to check if block is active or not, and get info.binding. They can be retrieved without loop of shaderType. This CL removes the loop so that we call DescriptorSetDescBuilder::updateShaderBuffers only once. Similar thing is applied to atomic counter buffer and images. Bug: b/282194402 Change-Id: I03f3b4a391e773dfc162877802a2f940311866b8 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4554625 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Charlie Lao 9445fbbe 2023-05-16T10:43:55 Vulkan: Move mWriteDescriptors out of DescriptorSetDescBuilder DescriptorSetDescBuilder has two data structures: mWriteDescriptors, which keeps track of "layout" of descriptorSet, and mDescriptorInfos, which is the actual cache key for descriptorSet. mDescriptorInfos will be updated every time buffer or image changes. But mWriteDescriptors is immutable with buffer/image, it is static per program executable (with exception of InputAttachment). Right now whenever there is a buffer or image change, we call into DescriptorSetDescBuilder and update both mWriteDescriptors and mDescriptorInfos. This CL moves mWriteDescriptors out of DescriptorSetDescBuilder, and stores it in ProgramExecutableVk. To deal with InputAttachment variation, ContextVk makes a copy of mWriteDescriptors when program is bound, and then update inputAttachment with framebuffer information. This not only removes unnecessary update of mWriteDescriptors, but also removes the requirement that mShaderBuffersDescriptorDesc has to reset and rebuild as a whole (because mWriteDescriptors keeps mCurrentInfoIndex which gets incremented as we build). This allows us to do further optimization in future to do piece meal update of mDescriptorInfos with only the changed data. Bug: b/282194402 Change-Id: I443c7c3b85b7a2e2e93c68d40ea102533c43f76a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4540280 Reviewed-by: Roman Lavrov <romanl@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Charlie Lao <cclao@google.com>
Charlie Lao 2c836045 2023-05-18T12:00:41 Vulkan: Remove buffer/image tracking from DescriptorSetDescBuilder Right now DescriptorSetDescBuilder keeps an array of images and buffers as we build DescriptorSet cache key. Later on if we have a cache miss and allocated a new cache entry, we walk the array and tag the images and buffers with newSharedCacheKey. If we have a cache hit, the tracked images/buffers are unused and then cleared. This means the effort of keep track of these buffers are wasted when we have cache hit, which we expect to be most likely. This was initially implemented this way simply because of convenience, but there is really not a need to add another tracker for them, as they are readily available from context state anyway. This CL remove the tracking of images/buffers from DescriptorSetDescBuilder and replaced with context API to tag images and buffers with newSharedCacheKeywhen when we have a cache miss. Bug: b/282194402 Change-Id: I355c2fbabdfc573ce71c0a4281788c942d260271 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4539290 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Roman Lavrov <romanl@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Alexey Knyazev 934a25bc 2023-05-22T00:00:00 Vulkan: Implement EXT_depth_clamp Bug: angleproject:8047 Change-Id: I73244f5dcd6eeeb1889214ee3a611e4ecabbfe7e Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4558744 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Alexey Knyazev <lexa.knyazev@gmail.com>
Hailin Zhang c74dae15 2023-05-12T12:45:44 Vulkan: patch vertex attrib and shader input mismatch. opengl es spec didn't specified vertex attirb input data type mismatch with vertex input data type. For this change, it will change the attrib format to match the vertex input format. while keep the same data size. (expect normalized data) Bug: b/280241844 Change-Id: Ib28a18fe495b779d5bb0e8e43887bd36b0037dba Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4528299 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Hailin Zhang <hailinzhang@google.com>
Alexey Knyazev 7abc5248 2023-05-19T00:00:00 Vulkan: Enable VK_EXT_depth_clamp_zero_one Replaced the 'depth_clamping' workaround with the dedicated extension or explicit fragment depth clamping. Fixed: angleproject:3970 Bug: angleproject:8077 Change-Id: Ia7666fcb3e0e949922c13a3fd11b818cbc5a8e26 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4545084 Commit-Queue: Alexey Knyazev <lexa.knyazev@gmail.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>
Alexey Knyazev b052a5bf 2023-03-31T00:00:00 Vulkan: Implement polygon mode extensions * NV_polygon_mode * ANGLE_polygon_mode Bug: angleproject:1791 Bug: angleproject:8132 Change-Id: I2beffdad0c1569546020b78a9c6d9b8ea87c2100 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4498687 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Alexey Knyazev <lexa.knyazev@gmail.com>
Mike Schuchardt 6732791c 2023-04-05T10:16:13 Vulkan: Include image layout in DS cache key The image layout for a texture can change from GENERAL to SHADER_READ_ONLY_OPTIMAL when switching from rendering with a feedback loop to not. The descriptor set cache needs to take image layout into account otherwise it can return a false hit in this case, resulting in the re-use of a descriptor set with the wrong image layout and validation error VUID-VkDescriptorImageInfo-imageLayout-00344. This change also includes a regression test to reproduce the behavior of the application where it was observed. Test: angle_end2end_tests --gtest_filter="*FeedbackLoopTextureBindings*" Test: Run com.gameloft.android.ANMP.GloftGGHM on Pixel 6 Bug: b/268091452 Change-Id: I80b4e2373963247a83f8ec17028445f54c820e86 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4400824 Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Cody Northrop <cnorthrop@google.com> Commit-Queue: Cody Northrop <cnorthrop@google.com>
Shahbaz Youssefi 97897d92 2023-03-27T16:02:57 Vulkan: Work around driver bug with dynamic primitive restart This CL forces the state to be static on buggy drivers. Bug: b/275210062 Change-Id: Ia3391ecb19c3c9d19c05a83e11da8c718513a4e2 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4374104 Reviewed-by: Yuxin Hu <yuxinhu@google.com> Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@google.com>
Roman Lavrov 8ba78abd 2023-02-28T11:16:08 Reland "MSRTSS uses AppendToPNextChain due to non-NULL pNext." Also fix msrtss->pNext being set to a pointer to a pointer (void* yay!) This is a reland of commit 33df630f9c8944061902b2e38fe65b280f731802 Original change's description: > MSRTSS uses AppendToPNextChain due to non-NULL pNext. > > As discussed in: > https://chromium-review.googlesource.com/c/angle/angle/+/4116675/comment/3097cb31_16922d39/ > > Not currently causing issues as it requires very recent drivers but I > saw the `ASSERT(ptr->pNext == nullptr);` in AddToPNextChain fail > somewhere. > > Bug: angleproject:7899 > Change-Id: Id46162a5aacd3d8599382ce1dfca25aca5e730e1 > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4296801 > Auto-Submit: Roman Lavrov <romanl@google.com> > Commit-Queue: Yuxin Hu <yuxinhu@google.com> > Reviewed-by: Yuxin Hu <yuxinhu@google.com> Bug: angleproject:7899 Change-Id: I597b6633123f161e05e1a5a28b2e8c6c61835e29 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4306827 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Igor Nazarov dbece66f 2023-01-17T19:25:24 Vulkan: Fix move constructor/assignment of Resource classes. Bug in "DynamicallyGrowingPool<Pool>::PoolResource" causes real problems with queries. "QueryPool" may be reused without waiting for the previous use. Bugs "QueryHelper" may affect "mInFlightGpuEventQueries" (not used in "QueryVk"). Updated "FramebufferHelper" move assignment so it uses "Resource" assignment instead of protected member access. Bug: angleproject:8053 Change-Id: I441b62102fcf232456027fb42eefa97ed8958676 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4300050 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Igor Nazarov <i.nazarov@samsung.com>
Roman Lavrov a2a30eac 2023-03-03T14:41:39 Revert "MSRTSS uses AppendToPNextChain due to non-NULL pNext." This reverts commit 33df630f9c8944061902b2e38fe65b280f731802. Reason for revert: appears to crash angle_CtsSkQPTestCases_internal_main_presubmit on panther-userdebug https://r.android.com/2466997 Original change's description: > MSRTSS uses AppendToPNextChain due to non-NULL pNext. > > As discussed in: > https://chromium-review.googlesource.com/c/angle/angle/+/4116675/comment/3097cb31_16922d39/ > > Not currently causing issues as it requires very recent drivers but I > saw the `ASSERT(ptr->pNext == nullptr);` in AddToPNextChain fail > somewhere. > > Bug: angleproject:7899 > Change-Id: Id46162a5aacd3d8599382ce1dfca25aca5e730e1 > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4296801 > Auto-Submit: Roman Lavrov <romanl@google.com> > Commit-Queue: Yuxin Hu <yuxinhu@google.com> > Reviewed-by: Yuxin Hu <yuxinhu@google.com> Bug: angleproject:7899 Change-Id: Ib59bee567b4249077b67f52dcf763d55dc9a7811 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4307769 Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Roman Lavrov 33df630f 2023-02-28T11:16:08 MSRTSS uses AppendToPNextChain due to non-NULL pNext. As discussed in: https://chromium-review.googlesource.com/c/angle/angle/+/4116675/comment/3097cb31_16922d39/ Not currently causing issues as it requires very recent drivers but I saw the `ASSERT(ptr->pNext == nullptr);` in AddToPNextChain fail somewhere. Bug: angleproject:7899 Change-Id: Id46162a5aacd3d8599382ce1dfca25aca5e730e1 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4296801 Auto-Submit: Roman Lavrov <romanl@google.com> Commit-Queue: Yuxin Hu <yuxinhu@google.com> Reviewed-by: Yuxin Hu <yuxinhu@google.com>
Alexey Knyazev dbd5d6df 2023-02-17T00:00:00 Vulkan: Fix border color adjustment for emulated formats Emulated opaque ETC compressed formats are decoded to RGBA8 so the border color must have its alpha as one. Generalized AdjustBorderColor to enforce opaque alpha for opaque formats and to support both ways, in which ANGLE could emulate LUMA formats. Moved AdjustBorderColor to renderer_utils so it could be used with other backends. Bug: angleproject:5978 Change-Id: I9ec44444fd373b1ca6116ebc4447063a014025ce Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4265514 Commit-Queue: Alexey Knyazev <lexa.knyazev@gmail.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>