src/libANGLE/renderer/vulkan/vk_helpers.cpp


Log

Author Commit Date CI Message
Charlie Lao 6c894e82 2021-11-04T14:49:41 Vulkan: Replace BufferVk::getBufferAndOffset() with getBuffer() Now BufferHelper class already keeps offset information. There is no reason for BufferVk to have that information any more. Bug: b/205337962 Change-Id: I6e014fb480bfcd5018ef9231b0fb87a50021f179 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3266147 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Charlie Lao <cclao@google.com>
Charlie Lao 83a670ab 2021-10-29T09:12:26 Vulkan: Implement BufferPool using VMA's virtual allocator VMA's allocation calls used to be sub-allocating a pool of memory. What we really want is sub-allocate a VkBuffer object. VMA recently added support to expose the underlying range allocation algorithm via APIs, which user can use it to sub-allocate any object. This CL uses that new virtual allocation API to sub-allocate from a pool of VkBuffers. In this CL we only switched BufferVk::mBuffer to sub-allocate from the BufferPool object. Bug: b/205337962 Change-Id: Ia6ef00c22e58687e375b31bc12ac515fd89f3488 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3266146 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Charlie Lao <cclao@google.com>
Peng Huang 6e5fd816 2021-12-15T18:31:13 Support more ImageLayout in ConvertImageLayoutToGLImageLayout Bug: chromium:1264439 Change-Id: I35938a65981edf495bd9aafb8bfb17aa3ec9a66c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3341640 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Peng Huang <penghuang@chromium.org>
Mohan Maiya 36fcf80b 2021-12-11T20:55:53 Vulkan: Consolidate SamplerYcbcrConversionCache Now that SamplerDesc and ImageHelper have the fully qualified description of a VkSamplerYcbcrConversion, we can lazy allocate the conversion handle along with streamlining the interface to the SamplerYcbcrConversionCache class. Bug: angleproject:6732 Test: Texture2DTestES3.*Yuv*Vulkan Change-Id: I7deaa0220031bc4c500d88021459017bf937218c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3333629 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: mohan maiya <m.maiya@samsung.com>
Peng Huang 32f572b7 2021-12-03T17:58:51 Support creating EGLImage from VkImage Bug: chromium:1264439 Change-Id: I520182143e748f25b44d0725f3f171b7b33a85d8 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3311131 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Peng Huang <penghuang@chromium.org>
Ian Elliott 24241724 2021-11-22T13:26:53 Reland: Vulkan: Use vkResetQueryPoolEXT when available This is a reland of 97aa5187ed164f1e9a22b64c966f2a747f651bfb Original change's description: > ANGLE currently uses vkCmdResetQueryPool to reset a query pool. As > reported by Arm, this can cause GPU bubbles. It is better to use > vkResetQueryPoolEXT() when available (either by Vulkan 1.2 or by the > VK_EXT_host_query_reset extension). > > Bug: angleproject:6692 > Change-Id: I650d7d0f55bdf6587b75be43cc7bed2dc3eb935a > Reviewed-on: > https://chromium-review.googlesource.com/c/angle/angle/+/3294061 > Commit-Queue: Ian Elliott <ianelliott@google.com> > Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> > Reviewed-by: Charlie Lao <cclao@google.com> Bug: angleproject:6692 Change-Id: Idff87977bd39ccd1d05684e48929f4cd3fa733c7 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3313382 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Ian Elliott <ianelliott@google.com>
Lingfeng Yang 8815245a 2021-12-01T08:58:01 Vulkan: Don't retain in buffer/imageRead unnecessarily mUsedBuffers/images already tracks whether a buffer/image is used in a render pass, so we can add to ContextVk's resource use list only once. Bug: angleproject:6717 Change-Id: Idd528c7f0f3fcb4d8d8879ab6cc7055260ecb45d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3310523 Commit-Queue: Lingfeng Yang <lfy@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 8f6f5a4b 2021-11-30T23:48:30 Vulkan: Fix image respecify's usage tracking When respecifying an image due to mip level count changes, the previous image is staged as an update to the new image. The resource usage info was not being transferred to the image being staged as an update, causing it to be prematurely deleted. Test based on one authored by sugoi@google.com. Bug: chromium:1270658 Bug: angleproject:4835 Change-Id: I215c65ba700d7be608d0910d3cb37fcfdf297a2a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3308921 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Mohan Maiya 44d0ef69 2021-11-25T14:37:38 Vulkan: Enhance SamplerDesc for YUV formats In order to uniquely identify a VkSamplerYcbcrConversion, having just the format is insufficient. We need to account for conversion model and color component range. Refactor SamplerDesc by encapsulating YUV related fields into its own YcbcrConversionDesc. Bug: angleproject:6732 Test: Texture2DTestES3.*Yuv*Vulkan Change-Id: I23114c50646232dccde988a52b0649778ad72a90 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3301899 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Mohan Maiya <m.maiya@samsung.com>
Peng Huang a5e391d7 2021-11-19T17:35:06 Add GL_ANGLE_vulkan_image extension glAcquireTextures & glReleaseTextures are added for sharing texture ownership with an external API. Bug: chromium:1264439 Change-Id: If46d8d230b4f611768b5ff1187674509e42f01e0 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3293921 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Peng Huang <penghuang@chromium.org>
Stephan Hartmann 7f1ab9be 2021-11-25T21:59:51 Vulkan: add explicit template specialization for barrierImpl ImageHelper::barrierImpl with primary command buffer is used in other translation units (SurfaceVk::acquireNextSwapchainImage()). Linking fails if compiler has optimized out symbol for primary command buffer. Bug: chromium:819294 Change-Id: I91d79788ae51d24472e8bd1d20cdb1a375e86300 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3301705 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Peng Huang e00ad443 2021-11-15T20:16:16 Add EGL_ANGLE_vulkan_image extension This extension is for exporting VkImage from EGLImage. The VkImage must be used with the same VkDevice used by ANGLE Vulkan backend. Bug: chromium:1264439 Change-Id: I222d900465cf2716d94fc64f06e240390ec518ac Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3285025 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Peng Huang <penghuang@chromium.org>
Ian Elliott 2fa1adf0 2021-11-24T18:29:13 Revert "Vulkan: Use vkResetQueryPoolEXT when available" This reverts commit 97aa5187ed164f1e9a22b64c966f2a747f651bfb. Reason for revert: This apparently caused crbug.com/1273344 Original change's description: > Vulkan: Use vkResetQueryPoolEXT when available > > ANGLE currently uses vkCmdResetQueryPool to reset a query pool. As > reported by Arm, this can cause GPU bubbles. It is better to use > vkResetQueryPoolEXT() when available (either by Vulkan 1.2 or by the > VK_EXT_host_query_reset extension). > > Bug: angleproject:6692 > Change-Id: I650d7d0f55bdf6587b75be43cc7bed2dc3eb935a > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3294061 > Commit-Queue: Ian Elliott <ianelliott@google.com> > Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> > Reviewed-by: Charlie Lao <cclao@google.com> Bug: angleproject:6692 Change-Id: I70d5eeb0b98f016fd262935194f8f4abee2a72b9 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3300309 Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> Reviewed-by: Ian Elliott <ianelliott@google.com> Reviewed-by: Lingfeng Yang <lfy@google.com> Commit-Queue: Ian Elliott <ianelliott@google.com>
Shahbaz Youssefi 924c8d8a 2021-11-18T22:58:04 Vulkan: Fix image tiling when DRM format modifiers are specified Bug: angleproject:6679 Change-Id: I5198a180608535131b127c135423fb80c6478140 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3292027 Reviewed-by: Craig Stout <cstout@google.com> Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Jeff Vigil 8b60855b 2021-09-15T15:16:10 EGL: implement EGL_KHR_mutable_render_buffer Pass render buffer mode change to WindowSurfaceVk. On mode change trigger OUT_OF_DATE. Then in CreateSwapchain, if new mode, set the Presentation mode and the Image count. OffscreenSurfaceVk ignores mode change. Add MUTABLE_RENDER_BUFFER_BIT to GenerateDefaultConfig. Test: dEQP-EGL.functional.mutable_render_buffer.* Bug: angleproject:3966 Change-Id: I7b59708514bcda10f8d45ce5f9528aa840fcccfa Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3171822 Commit-Queue: Brandon Schade <b.schade@samsung.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Ian Elliott 97aa5187 2021-11-22T13:26:53 Vulkan: Use vkResetQueryPoolEXT when available ANGLE currently uses vkCmdResetQueryPool to reset a query pool. As reported by Arm, this can cause GPU bubbles. It is better to use vkResetQueryPoolEXT() when available (either by Vulkan 1.2 or by the VK_EXT_host_query_reset extension). Bug: angleproject:6692 Change-Id: I650d7d0f55bdf6587b75be43cc7bed2dc3eb935a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3294061 Commit-Queue: Ian Elliott <ianelliott@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com>
Shahbaz Youssefi 3128c055 2021-11-12T14:59:46 Vulkan: Add wait semaphores to queueSubmitOneOff For use in follow up change. Bug: angleproject:3966 Change-Id: I5bfac51ef9d47a6df5d52268d3ce4863b848b1d1 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3279226 Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Lingfeng Yang <lfy@google.com> 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>
Shahbaz Youssefi dbc0c646 2021-11-06T01:09:26 Vulkan: Output the reason for RP closure in command buffer To make it easier when viewing the command buffer in a graphics debugger, this change inserts a marker just before closing the render pass that specifies why the render pass was closed. Bug: angleproject:2472 Change-Id: I862e500cd58332d6e199c853315c560fe6a73dc2 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3265609 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi d2d3a546 2021-11-11T12:22:04 Vulkan: Write perf warnings in command buffer It's much easier to understand what command the perf warning refers to when it's visible in the command buffer using a graphics API debugger. This change creates ANGLE_VK_PERF_WARNING which gives the warning both to the application (through ANGLE_PERF_WARNING) and inserts it in the command buffer. Bug: angleproject:2472 Change-Id: Ie84feed53eca5cda93e1f2bc653fcbf9bcd57b56 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3275839 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 558981c1 2021-11-10T23:13:03 Vulkan: Make write-after-invalidate checks more precise Previously, the size of the command buffer was used as indication for whether the render pass attachments might have been modified after glInvalidateFramebuffer. In that case, the invalidate was undone. This is made more precise by making sure only vkCmdClearAttachments and vkCmdDraw* calls are counted for this purpose. For example, inserting event markers after glInvalidateFramebuffer now retains the invalidation. Note that this can be even further optimized by tracking real writes to attachments. For example, currently a draw call with depth test disabled still undoes the invalidation of the depth buffer, but it shouldn't. Bug: angleproject:5079 Change-Id: I6257b4116a73213884b919bc7f3c86ff39b6aeed Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3274176 Reviewed-by: Ian Elliott <ianelliott@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Tim Van Patten 53371cc0 2021-11-01T20:25:17 Vulkan: Use optimalBufferCopyOffsetAlignment optimalBufferCopyOffsetAlignment is the optimal buffer offset alignment in bytes for vkCmdCopyBufferToImage2KHR, vkCmdCopyBufferToImage, vkCmdCopyImageToBuffer2KHR, and vkCmdCopyImageToBuffer. The per texel alignment requirements are enforced, but applications should use the optimal alignment for optimal performance and power use. To improve efficiency, this CL updates ContextVk::mStagingBuffer's alignment to the max of: - minMemoryMapAlignment - nonCoherentAtomSize - optimalBufferCopyOffsetAlignment On ARM, this is not expected to have any affect, since all three values are 0x40, but other platforms may see a benefit. Bug: angleproject:4297 Change-Id: I9185da111e09c5d782eb1dedb10369727cb9bf51 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3256007 Commit-Queue: Tim Van Patten <timvp@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com>
Tim Van Patten 5d8a89e4 2021-11-02T19:57:04 Vulkan: Always override surface format GL_RGB8 to GL_RGBA8 If an app requests to create a surface with GL_RGB8, override it to be GL_RGBA8 for Android. This is to workaround an issue with the Android Vulkan loader which limits which formats can be used with swapchains. This CL also adds GL_RGB8 back to DisplayVkAndroid::generateConfigs(), effectively reverting the following CL: https://chromium-review.googlesource.com/c/angle/angle/+/3235466 This is being done with this CL (rather than reverting) since these changes are required to handle surfaces created with GL_RGB8. Bug: angleproject:6277 Bug: angleproject:6651 Change-Id: Iad78ea0d7bdf12e1e309ed6a7181f08fac38b9de Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3258143 Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Ian Elliott <ianelliott@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Tim Van Patten <timvp@google.com>
Jamie Madill 4fd4eb50 2021-11-05T11:14:47 Vulkan: Minor cleanups. Makes some VkFlags into VkAccessFlags to aid with code search. Also corrects a few typos. Bug: angleproject:6566 Change-Id: Ia4d14d38bb6d4e8c4c71fed6038c12edae112be9 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3264224 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Tim Van Patten afaa1287 2021-10-26T19:29:44 Vulkan: Don't submit XFB queries when XFB is inactive Consider the following GL commands: glBeginQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN) glBeginTransformFeedback() glDrawArrays() glPauseTransformFeedback() glDrawArrays() glResumeTransformFeedback() glDrawArrays() glEndTransformFeedback() glEndQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN) The renderpass is broken for each of the draw calls, leading to pauseRenderPassQueriesIfActive() and resumeRenderPassQueriesIfActive() being called when the RP is stopped/started. This leads ANGLE to generate 3 TransformFeedbackPrimitivesWritten queries when looping through the "active" queries, since no consideration is made for XFB actually being active/unpaused. ARM doesn't support the TransformFeedbackPrimitivesWritten query when XFB is disabled. Instead, the query is never completed and the results are never available. It could probably be argued that this is an ARM bug, and they should just output '0' if XFB isn't active during the query. Regardless, ANGLE shouldn't be issuing the queries when XFB is no active, since it's wasteful. Bug: angleproject:6622 Test: dEQP.GLES3/functional_transform_feedback* Test: TransformFeedbackTest.TransformFeedbackQueryPausedDrawThenResume Change-Id: I380fb60405d7f538b802bb0df72bf609f0bc58e9 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3246532 Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Tim Van Patten <timvp@google.com>
Shahbaz Youssefi 32b3c963 2021-10-28T11:00:03 Vulkan: Remove MSRTT assertion in the presence of OOM When the MSRTT transient multisampled image is created, the emulated clear staged update is removed (as it's also staged for the single sampled image). This was done after allocating memory for the image, which can fail, leaving the update staged and leading to an ASSERT failure when the texture is used. Technically, the texture should not be used, and that's a Chrome bug where the OOM result from ANGLE is being ignored. This change makes sure the staged update is removed before allocating memory so the multisampled image is in a more consistent state. Bug: chromium:1263046 Change-Id: Ida8923ccbc517f740d76b4c2880086a039fa8a1f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3251580 Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Charlie Lao bae19e06 2021-10-26T13:35:57 Vulkan: Avoid unnecessary wait if mapBufferRange indicates read only When we call BufferVk::mapRangeImpl(), both from internal code paths for data reads or due to glMapBufferRange call, we are not passing the access bit to the call. This CL passes the proper access bits to the call and only wait for GPU writes to finish if access is for read only. This CL also adds access bitfield to the BufferVk::mapImpl() API and have various callers pass in the proper access bits as well. Bug: b/203582620 Change-Id: Ica8493c902dbd7b15996266c81ce0fd4dbfc2520 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3245487 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Charlie Lao <cclao@google.com>
Jamie Madill 191c236a 2021-10-14T17:01:45 Vulkan: Remove "current queue serial". Queries, semaphores, and pipelines instead use the normal vk::Resource design to track their lifetimes. Removes the current serial APIs from all classes. Current serials are still tracked internally in the command queue classes. Bug: b/169788986 Change-Id: Idcd2c2a93bc8225c6f3f7c247eb8fcfb76be1030 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3223644 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Charlie Lao 421dbf20 2021-10-26T19:06:19 Revert "Vulkan: Use different strategy for buffer memory allocation" This reverts commit 0dbe308d91a3526e28fecd9014d873c649f4ef71. Reason for revert: crbug.com/1253325 Original change's description: > Vulkan: Use different strategy for buffer memory allocation > > This CL uses different memory allocation strategy based on the requested > size. If the requested size exceeds 1M, we use dedicated memory > allocation to avoid memory waste associated with the sub-allocator. > Otherwise we uses VMA's sub-allocator pool. This CL creates two sets of > customized pool so that we uses different allocation strategy for each > set of pool: the small pool uses buddy algorithm which favors speed over > memory and large pool uses default algorithm that favors memory saving > over speed. This CL also replaces vmaFindMemoryTypeIndexForBufferInfo > with vmaFindMemoryTypeIndex to avoid create and destroy VkBuffer object > just try to find memoryTypeIndex. > > Bug: b/195588159 > Change-Id: I2bddbfffd77ba2ce6b9389d83a31051c4b748c4d > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2939490 > Commit-Queue: Charlie Lao <cclao@google.com> > Reviewed-by: Jamie Madill <jmadill@chromium.org> > Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> > Reviewed-by: Tim Van Patten <timvp@google.com> Bug: b/195588159 Change-Id: I2c8fe8cb2930d16f5212570d32be68e7c6a6e5f3 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3244258 Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Charlie Lao <cclao@google.com> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Tim Van Patten 9ac2409e 2021-10-26T00:55:06 Reland "Vulkan: Flush descriptor set updates during flush*Commands()" This reverts commit 420e77a64e890ad4c585d72789ca59501be3ac75. Reason for revert: The crash is in ProgramExecutableVk::getOrAllocateShaderResourcesDescriptorSet(), which is unrelated to this change. Creating a CL to reland this (the reland button is failing), to try and investigate further. Original change's description: > Revert "Vulkan: Flush descriptor set updates during flush*Commands()" > > This reverts commit 02b73c2fd738b237f1ab3ecd400feec222903a48. > > Reason for revert: Causes test to crash on Linux/Intel: anglebug.com/6591 > > Original change's description: > > Vulkan: Flush descriptor set updates during flush*Commands() > > > > The intent of this CL is to reduce the number of descriptor set updates > > by delaying the work until all of the GLES commands that could trigger a > > re-update have been performed and the command stream is being flushed. > > To achieve this, flushDescriptorSetUpdates() is being moved from > > setupDraw()/setupDispatch() to > > flushRenderPassCommands()/flushOutsideRPCommands(). > > > > This change also exposed an issue where the BufferView handles were not > > being preserved until flushDescriptorSetUpdates() was called. To resolve > > this, flushDescriptorSetUpdates() is also being called during > > BufferViewHelper::release() before the BufferView memory is released. > > > > Bug: angleproject:5706 > > Change-Id: I61e19af9c0fac891aa2115d72391459b80d22f19 > > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2939385 > > Reviewed-by: Charlie Lao <cclao@google.com> > > Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> > > Reviewed-by: Jamie Madill <jmadill@chromium.org> > > Commit-Queue: Tim Van Patten <timvp@google.com> > > Bug: angleproject:5706 > Bug: angleproject:6591 > Change-Id: I9d1ee3fcb3d1aebc86e60896e0065cab847a92b4 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3233901 > Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> > Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Bug: angleproject:5706 Bug: angleproject:6591 Change-Id: Ibc7e934b82e6cd90e766f43135583f7c45acfe39 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3244024 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Tim Van Patten <timvp@google.com>
Charlie Lao 0dbe308d 2021-07-16T14:26:20 Vulkan: Use different strategy for buffer memory allocation This CL uses different memory allocation strategy based on the requested size. If the requested size exceeds 1M, we use dedicated memory allocation to avoid memory waste associated with the sub-allocator. Otherwise we uses VMA's sub-allocator pool. This CL creates two sets of customized pool so that we uses different allocation strategy for each set of pool: the small pool uses buddy algorithm which favors speed over memory and large pool uses default algorithm that favors memory saving over speed. This CL also replaces vmaFindMemoryTypeIndexForBufferInfo with vmaFindMemoryTypeIndex to avoid create and destroy VkBuffer object just try to find memoryTypeIndex. Bug: b/195588159 Change-Id: I2bddbfffd77ba2ce6b9389d83a31051c4b748c4d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2939490 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Shahbaz Youssefi 52934a5d 2021-10-04T22:19:30 Vulkan: Use the UNDEFINED layout for ExternalPreInitialized According to the spec, the UNDEFINED layout does not invalidate the memory of external images. Bug: angleproject:6460 Change-Id: I682e8c3501cc52431268ff2c3a063467ba9d2a65 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3203796 Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 420e77a6 2021-10-20T15:02:45 Revert "Vulkan: Flush descriptor set updates during flush*Commands()" This reverts commit 02b73c2fd738b237f1ab3ecd400feec222903a48. Reason for revert: Causes test to crash on Linux/Intel: anglebug.com/6591 Original change's description: > Vulkan: Flush descriptor set updates during flush*Commands() > > The intent of this CL is to reduce the number of descriptor set updates > by delaying the work until all of the GLES commands that could trigger a > re-update have been performed and the command stream is being flushed. > To achieve this, flushDescriptorSetUpdates() is being moved from > setupDraw()/setupDispatch() to > flushRenderPassCommands()/flushOutsideRPCommands(). > > This change also exposed an issue where the BufferView handles were not > being preserved until flushDescriptorSetUpdates() was called. To resolve > this, flushDescriptorSetUpdates() is also being called during > BufferViewHelper::release() before the BufferView memory is released. > > Bug: angleproject:5706 > Change-Id: I61e19af9c0fac891aa2115d72391459b80d22f19 > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2939385 > Reviewed-by: Charlie Lao <cclao@google.com> > Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> > Reviewed-by: Jamie Madill <jmadill@chromium.org> > Commit-Queue: Tim Van Patten <timvp@google.com> Bug: angleproject:5706 Bug: angleproject:6591 Change-Id: I9d1ee3fcb3d1aebc86e60896e0065cab847a92b4 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3233901 Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Tim Van Patten 02b73c2f 2021-07-14T15:45:47 Vulkan: Flush descriptor set updates during flush*Commands() The intent of this CL is to reduce the number of descriptor set updates by delaying the work until all of the GLES commands that could trigger a re-update have been performed and the command stream is being flushed. To achieve this, flushDescriptorSetUpdates() is being moved from setupDraw()/setupDispatch() to flushRenderPassCommands()/flushOutsideRPCommands(). This change also exposed an issue where the BufferView handles were not being preserved until flushDescriptorSetUpdates() was called. To resolve this, flushDescriptorSetUpdates() is also being called during BufferViewHelper::release() before the BufferView memory is released. Bug: angleproject:5706 Change-Id: I61e19af9c0fac891aa2115d72391459b80d22f19 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2939385 Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Tim Van Patten <timvp@google.com>
Tim Van Patten eb1d2474 2021-10-04T20:23:26 Vulkan: Add R8G8B8_UNORM to vk_format_map.json The map of R8G8B8_UNORM -> VK_FORMAT_R8G8B8_UNORM is missing from vk_format_map.json. This leads to attempting to get format bits for angle::FormatID::NONE / VK_FORMAT_UNDEFINED. This CL adds R8G8B8_UNORM to vk_format_map.json, so devices that support it, like ARM, can use it. This allows those devices to import AHBs created with R8G8B8_UNORM. This CL also adds some additional ASSERT() and UNREACHABLE() calls to catch missing formats sooner. This allows the EGL tests to pass on ARM devices, but the tests are still skipped due to Qualcomm not having the necessary support for optimal tiling. Bug: angleproject:6277 Test: dEQP-EGL.functional.image* Change-Id: I41b7ead97a10ae80be4b6048d36d0d85ad71784f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3204152 Commit-Queue: Tim Van Patten <timvp@google.com> Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Charlie Lao 22ecd454 2021-07-19T17:28:05 Vulkan: Move BufferMemory class from vk_helpers.h to vk_utils.h In preparation for the StagingBuffer may also use BufferMemory, this CL moves the class to vk_utils.h so that it can be used by any class without create kinks on header file inclusion. Bug: b/195588159 Change-Id: I97ab136be691322fe6284fd1b4b7336fdf1f904f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3040106 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Charlie Lao 8ef1b2a2 2021-07-15T15:27:15 Vulkan: Add BufferMemoryAllocator class BufferMemoryAllocator class will be responsible for memory allocation for vkBuffers. The original Allocator class remains the wrapper for vmaAllocator. Bug: b/195588159 Change-Id: I26d016e2f8d13ba459d0aa0bd4e1ebf4d0d48251 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3036256 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Charlie Lao 6793d50e 2021-10-06T15:48:55 Vulkan: Remove ImageHelper::setFirstAllocatedLevel and Add assertion ImageHelper::mFirstAllocatedLevel is set via ImageHelper::initExternal. There isn't a good use to set the mFirstAllocatedLevel when mImage is invalid, and semantically it is wrong to try to get mFirstAllocatedLevel or format while its storage is invalid (i.e., not allocated). This CL removes ImageHelper::setFirstAllocatedLevel() API all together and added assertion that image is valid when ImageHelper::getFirstAllocatedLevel and getActualFormat and various other get APIs whose value are set during initExternal call. Bug: angleproject:6532 Change-Id: I9c97f488b3e959443fec632540e7f0906a49dc13 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3209838 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Charlie Lao 185e48a7 2021-10-06T18:53:08 Vulkan: Make TextureVk::mRedefinedLevels bitmask of gl::LevelIndex We have gl::LevelIndex and vk::LevelIndex. gl::LevelIndex means level index at OpenGL concept and is used in TextureVk code. vk::LevelIndex means already adjusted with baseLevel and is used by ImageHelper object. This mRedefinedLevel is gl::TexLevelMask type, but it actually is a bit mask of vk::LevelIndex right now. This is inconsistent and confusing. This CL changes it to bit mask of gl::LevelIndex to be consistent with the namespace of "gl". Bug: angleproject:6532 Change-Id: Ic88e373f70d3bd3e3fea676765c82fd0941e245c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3210726 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Charlie Lao <cclao@google.com>
Charlie Lao 6cb599f9 2021-10-06T13:07:27 Vulkan: Change dest to dst for consistency Cleanup only, no functional change. dst aligns better with src. Bug: angleproject:6502 Change-Id: I69821b1aae50a7ce647c7cc876468b6de309eec8 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3208514 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Cody Northrop <cnorthrop@google.com>
Charlie Lao 74b2886f 2021-09-22T13:49:57 Vulkan: Try to use CPU to copy when preserving old buffer data When glBufferSubData is called, we may acquire a new buffer if buffer is still GPU busy. When this happened, we have to preserve buffer content if old buffer has valid data in it. Instead of always use GPU to do copy, this CL will check if GPU is not writing to the buffer, we will just use CPU to do the copy form old buffer to new buffer from the ranges outside subData, controlled by the feature flag preferCPUWhenPreservingBufferData. Bug: b/200067929 Change-Id: I42053104b2be8da5f399cca92e934254988f2fd8 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3177322 Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Charlie Lao <cclao@google.com>
Jamie Madill 4f0e7e7f 2021-10-04T14:50:10 Vulkan: Remove extraCopyBufferRegion workaround. Bug: angleproject:2838 Change-Id: I53ba3cf307f930ae9550d1bfee4650df6e826930 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3202475 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Shahbaz Youssefi 2f1d503b 2021-09-16T21:49:14 Vulkan: Fix Vulkan secondary command buffers This change abstracts initialization, begin/end, reset and recycle of command buffers such that both Vulkan and ANGLE secondary command buffers are supported. Bug: angleproject:6100 Change-Id: I8c79764ac98b599fda08fe45cf8c4f0a6573f0f9 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2987873 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi a097ee2e 2021-09-27T15:18:02 Vulkan: Fix clearing external images with emulated format External images may already have data, and clearing them due to their format being emulated is incorrect. This change makes sure that only the emulated channels are cleared. The RGBXDataPreservedAHB test is based on one contributed by Jason Macnak <natsu@google.com>. Bug: b/192315789 Change-Id: Ibc8953fdac356f2a62a5b46512a51e1916b4a1b6 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3193416 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Shahbaz Youssefi d9882db5 2021-04-16T21:47:25 Vulkan: Destroy unused resources in a timely manner Deletion of garbage that's eligible for immediate cleanup is currently delayed until the next submission. Fix this by checking if garbage can be freed immediately and deleting it right away if it's not used. Some missing retain() calls needed to be added to semaphore operations in order to avoid freeing resources in use by a memory barrier. Based on a change by spang@chromium.org Bug: angleproject:4628 Change-Id: I034c24d7631c973b4546952f7718a0cd4114763f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2832002 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi dc99db91 2021-09-16T21:45:35 Vulkan: Allow Vulkan secondary CBs to count their commands This is used by render pass related code to determine if some command has been issued since a previous event. With ANGLE SecondaryCommandBuffer, the memory pointer where the commands are being written to are used for this purpose. For Vulkan secondary command buffers the code simply increments a counter. Bug: angleproject:6100 Change-Id: I85320f8453bd3325793df85aabde3d42b1eeb22a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3167214 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 2d79918f 2021-09-16T16:43:53 Vulkan: Pass command pool around Preparatory work for re-enabling support for Vulkan secondary command buffers. The command pool being passed around is not yet used. Additionally, the work to allocate, initialize, reset and recycle command buffers has been refactored to a helper class for better abstraction. The CommandBufferHelper class now holds a pointer to the pool it was allocated from for clean up. Each ContextVk has its own command pool, where Vulkan secondary command buffers are allocated from. The command pool that CommandProcessor had was unused and is removed by this change. Bug: angleproject:6100 Change-Id: I0d4fa6a76ef06e88779145ffe9c613518a8eb390 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3167213 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Tim Van Patten 57d59e83 2021-09-07T17:41:11 Vulkan: Add ResourceWrite to track Read and Write Access vk::Resource currently only tracks accesses in general, not which type of access is being performed. This CL adds the new class ResourceWrite to track whether the access is a Read or Read/Write access and when the access completes. This allows a follow-on CL to know when a buffer is being written to by the GPU or if the GPU is only reading from a buffer. Tracking write accesses to buffers is required when attempting to "Ghost" (duplicate) GPU-read-only buffers to prevent breaking the render pass when the CPU maps the buffer memory. Bug: angleproject:5971 Test: ComputeShaderTest.ImageBufferMapWrite Change-Id: I965e3e75730719ccce77334744ae4feae33c6101 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3146319 Commit-Queue: Tim Van Patten <timvp@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com>
Shahbaz Youssefi 458389f2 2021-09-02T22:41:40 Vulkan: Support Linux dma-bufs This change adds support for EGL_EXT_image_dma_buf_import and EGL_EXT_image_dma_buf_import_modifiers on top of Vulkan's VK_EXT_external_memory_dma_buf and VK_EXT_image_drm_format_modifier. Bug: angleproject:6248 Change-Id: I581987f88e9ddcf351dc721f499f63912dca05f9 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3145610 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 371542cd 2021-08-23T23:10:09 Vulkan: Use VK_EXT_load_store_op_none With read-only depth/stencil attachments, ANGLE utilizes storeOp=NONE to optimize memory bandwidth (by avoiding write back of tile memory at the end of the render pass). Simultaneoulsy, this avoids a synchronization hazard with the next write to that depth/stencil image. If a framebuffer contains a depth/stencil attachment but it's unused, ANGLE utilizes loadOp=NONE/storeOp=NONE to effectively remove any memory bandwidth wasted on the attachment. Bug: angleproject:5371 Change-Id: I76cbadbf1194041532ac4b690ffe087298f2de51 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3114232 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com>
Charlie Lao ca70b636 2021-09-09T16:34:34 Vulkan: Reformat staged buffer data using CPU When a R4G4B4A4 texture is attached to FBO, we dynamically choose a new format to fallback to R8G8B8A8 on some GPU that can't render to R4G4B4A4. During this format switch, if we already have a staged buffer update with old format, we must reformat the data to new format. Right now this is done by initImage and flush out staged update and read back and restage. This is very inefficient. This CL adds a new code path that just uses CPU to convert the staged data from old format to new format. Bug: b/198788068 Change-Id: I9b763dafdc9431d4fbbc26169c156b09ac13c815 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3153055 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>
Charlie Lao 0a592aa4 2021-09-01T19:00:24 Vulkan: Add warning when a fallback texture format is used. Emit a performance warning message when a fallback texture format is been used for sampling. Emit a performance warning when we have to do data copy during format fallback transition. Bug: b/196456356 Change-Id: Ifbe66069e506597dbacfefda10e699a8e9f320d5 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3139239 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@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 c5d11128 2021-09-02T18:18:02 Vulkan: Skip but keep incompatible updates. If texture has a level incompatibly specified, right now we are still oding the copy. This will trigger VVL and is incorrect. This CL skip the flush and keep it. Also Add various tests for 16 bit texture format in preparation for future CLs that may pick a more native format for 16 bit texture instead of always fallback to 32 bit. Test: VulkanFramebufferTest.R4G4B4A4TextureSampleOnlyActuallyUses444Format Bug: b/196456356 Change-Id: I9d53a97bb72208b52fb25e429abb49bbbc53c50c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3141030 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Charlie Lao 550bf6ce 2021-09-01T13:09:12 Vulkan: Keep track of data format for staged updates for ImageHelper We stage updates from a buffer or another ImageHelper object, even when the destination ImageHelper object has not been initialized (i.e, format is unknown). And we do not track what data format the staged updates are in. Right now this works because the format we end up choose will always the same as the staged data. But this may not be true in the future. This CL remembers the data format of the staged update and assert at flushStagedUpdate time that the format we staged is the same as the ImageHelper's actual format. Bug: b/196456356 Change-Id: Ib8124a47ca31f7782b9ec89c1fcb7e3000c747b7 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3137419 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Ian Elliott <ianelliott@google.com> 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 ab1a5dbe 2021-08-17T15:42:43 Vulkan: Use angle::Format for ImageViewHelper class ImageViewHelper class only needs actualFormatID. Instead of passing vk::Format to ImageViewHelper, this CL passes actualImageFormatID to the ImageViewHelper API to further reduce the exposure to vk::Format where getting actualImageFormatID needs extra information (renderable or not) Bug: b/196456356 Change-Id: I26afc1f37980a3b2419a66510cf720d79ad0a111 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3101928 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 e98539f0 2021-08-17T14:42:26 Vulkan: Add ImageHelper::getIntendedFormatID() This adds helper API to return intendedFormat directly from ImageHelper object instead of vk::Format, to make API symmetrical. It is also necessary. It is also needed in some places where we no longer have access to vk::Format any more due to refactoring. Bug: b/196456356 Change-Id: Ie0502793623138ded28c3f01320c57ffea2d93df Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3101925 Reviewed-by: Ian Elliott <ianelliott@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Charlie Lao <cclao@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>
Jamie Madill 1fc754b0 2021-08-25T08:34:36 GetTexImage: Read back depth from combined depth/stencil. This at least allows ANGLE to verify some of the depth/stencil pixel data, when using trace serialization. The correct behaviour would be to pack depth/stencil the same way as we unpack it. Bug: angleproject:4688 Bug: angleproject:5133 Change-Id: I5fc6649f577c7bd07aafabc9717c8235a5429e10 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3118267 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Cody Northrop <cnorthrop@google.com> Reviewed-by: Tim Van Patten <timvp@google.com>
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>
Mohan Maiya 5c8bf081 2021-06-08T13:12:24 Vulkan: Add support for YUV internal format extension 1. Add a function to upload YUV image data to textures 2. Modify stageSubresourceUpdate method to account for YUV images 3. Create VkSamplerYcbcrConversion when initializing ImageHelper 4. Update hasImmutableSampler to account for native YUV format support 5. Skip initializeNonZeroMemory for YUV formats Bug: angleproject:5773 Test: Texture2DTestES3.TexStorage2D*Yuv*Vulkan* Change-Id: I270f04bbf903cf2bf19f100eb95f32953d491c39 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2947767 Commit-Queue: Mohan Maiya <m.maiya@samsung.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Tim Van Patten 223cd0ac 2021-06-15T18:46:07 Capture/Replay: Refactor shared context handling This is the initial CL to enable capture/replay of multi-context applications. This CL refactors FrameCapture and FrameCaptureShared to move much of the functionality into FrameCaptureShared, since most everything is shared by Contexts in the share group. For example, the setup of the majority of the GL objects is done in the new SetupReplayContextShared() function in the new $LABEL_capture_context_shared_frame001.cpp file. The setup is performed by (for example): void SetupReplay() { $LABEL::InitReplay(); $LABEL::SetupReplayContextShared(); SetupReplayContext2(); } This performs the shared setup first, followed by the context-specific setup, which may reference shared objects careated by LABEL::SetupReplayContextShared(). No re-capturing is required with this change, since the external APIs (i.e., SetupReplay()) are still the same. Bug: angleproject:5878 Test: Manual MEC and replay of Magic Tiles 3, Candy Crush Soda Saga, Temple Run 2 Change-Id: Iab7bfe651437e9be1dee83514cd97acc20c61d1d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2965780 Commit-Queue: Tim Van Patten <timvp@google.com> Reviewed-by: Cody Northrop <cnorthrop@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Shahbaz Youssefi 913eb916 2021-06-28T12:51:12 Vulkan: (Mostly) re-unify secondary command buffer interfaces SecondaryCommandBuffer and CommandBuffer in vk_wrapper had diverged in API, which this change helps alleviate to some extent. Bug: angleproject:6100 Change-Id: I0d59b24c659afbaf58865b3d85f275c545e3acce Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2987872 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Ian Elliott <ianelliott@google.com>
Shahbaz Youssefi 971ba359 2021-06-23T16:45:33 Add angle::BitMask for creating bit masks angle::BitMask(n) implements the common pattern of angle::Bit(n)-1. Bug: angleproject:6048 Change-Id: Icd56ef1504804add59d0804a7249b3035c96f9c2 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2984099 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Shahbaz Youssefi 4375d6c7 2021-06-18T23:51:23 Vulkan: Support multiview queries When using queries with multiview, Vulkan specifies that N queries are actually produced (N being the number of views) which must be summed by the application. Bug: angleproject:6048 Change-Id: I5ea615536f1a357806b7ea8093280b9122f1d66a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2971562 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com>
Shahbaz Youssefi 5b314268 2021-06-15T17:37:45 Vulkan: Support OVR_multiview and OVR_multiview2 Multiview is supported in Vulkan simply by specifying the number of views in the render pass, and creating the appropriate image views. A number of changes to the way image views and render targets are stored are made to support those that don't cover the entire range of layers. One particular detail that is not implemented in this change is the use of queries in combination with multiview. Vulkan specifies that N queries are actually produced (N being the number of views) which must be summed by the application, but this is not currently done. Bug: angleproject:6048 Change-Id: I1d4a9894c232d3a93d7a97c9fa0eedc334e57469 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2967625 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com>
Shahbaz Youssefi b6adeb2f 2021-06-21T11:11:30 Vulkan: Use pipeline statistics query to emulate primitives generated The VK_QUERY_PIPELINE_STATISTIC_CLIPPING_INVOCATIONS_BIT query produces the same result as the GL primitives generated query. One caveat is that in combination with rasterizer discard this query may not work. This is emulated by disabling rasterizer discard when this query is active and applying an empty scissor instead. When VK_EXT_primitives_generated_query is released and supported, a similar issue with rasterizer discard persists so this change will facilitate using that extension as well. Bug: angleproject:5430 Change-Id: Id45b6f058c5cb6837e04aa64b1efde28c104e4cf Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2976181 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Shahbaz Youssefi 24155b13 2021-06-17T18:09:29 Vulkan: Free DynamicBuffer buffers after dip in allocation size In a pattern like this: - allocate 100 bytes - allocate 200 bytes - allocate 50 bytes - allocate 100000000 bytes - allocate 100 bytes - allocate 200 bytes - allocate 50 bytes The DynamicBuffer class switches to making 100MB allocations even if that allocation was a one-off. A small future allocation would then tie up 100MB in memory for future allocations. Another 100MB is also left tied up in the free list. With this change, if an allocation is made that's less than a quarter of the DynamicBuffer's current allocation size, it's taken as a sign that the previous large allocation was a one-off and the size is moved back to the DynamicBuffer's original initial size. Bug: b/187757166 Change-Id: I0c6f00eec7c81298f9dc41a41cc308510ce76623 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2971004 Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Ian Elliott ebf75698 2021-06-10T18:55:04 Vulkan: Fix AGI clear hierarchy bug for clear commands This approach properly handles outside-render-pass clears. Bug: b/190622922 Change-Id: Ia4a9d6ec13d7da8c4a445af1127e82c03f37e8b2 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2951960 Reviewed-by: Mark Lobodzinski <mark@lunarg.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Ian Elliott <ianelliott@google.com>
Ian Elliott 1fcbf77c 2021-06-10T16:02:31 Vulkan: Fix AGI hierarchy for query commands Treat glBeginQuery* and glEndQuery* commands the same as glDraw* commands, generating a hierarchy. This results in vkCmdBeginQuery and vkCmdEndQuery commands being nested under gl*Query*, instead of being a peer of glDraw* commands. This change necessitated plumbing some of the existing "end" path to return angle::Result. Bug: b/190512191 Change-Id: I898d3fdd9b4b7d86e76dfae2ffc5d6f7316a55ef Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2950926 Reviewed-by: Mark Lobodzinski <mark@lunarg.com> Reviewed-by: Ian Elliott <ianelliott@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Ian Elliott <ianelliott@google.com>
Shahbaz Youssefi 31641b8e 2021-06-05T02:17:47 Declare specialization constants in the AST A new qualifier (EvqSpecConst) is added so that specialization constants can be declared in tree. This enables TVariable references to specialization constants to be validated, which were in fact invalid as every reference declared a new variable. That is fixed. Bug: angleproject:4889 Change-Id: I1711e41cbc5a1260843d2d004d3568bdae11e963 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2941451 Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Charlie Lao b6bd039c 2020-10-06T13:34:53 Vulkan: Fine-grained depth stencil layout transition barrier Gfxbench Manhattan uses depth attachment as texture in the same render pass, which creates a feedback loop. The layout we are using for this has kAllShadersPipelineStageFlags even though it only used by fragment shader. This creates an unnecessary vertex/fragment dependency that hurts performance on some mobile GPUs. This CL split DepthStencilReadOnly to DSAttachmentReadAndFragmentShaderRead, DSAttachmentReadAndAllShadersRead, and DepthStencilAttachmentReadOnly, so that if it is used by fragment shader, we only barrier against fragment stage. If not used by any shader, we don't block any shader stages. To make names consistent, this CL also renames DepthStencilAttachmentAndFragmentShaderRead to DSAttachmentWriteAndFragmentShaderRead, renames DepthStencilAttachmentAndAllShadersRead to DSAttachmentWriteAndAllShadersRead. Bug: b/169891513 Change-Id: Iede497e8af028861f9166a32d122f26dc7aa864a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2453599 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Charlie Lao d151af7b 2021-05-20T10:52:46 Vulkan: Improve generateMipmapsWithBlit barrier usage ImageHelper::generateMipmapsWithBlit() implements glGenerateMipmap using vkCmdBlitImage. For each level it changes layout to VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL and issue a blit. In order to keep all mipmap levels' layout consistent, it issues a vkCmdPipelineBarrier call for the the very last mipmap level to change it to VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL as well. This creates an unnecessary barrier for the next operation, that now it sees a barrier against transfer stage. This CL changes all levels to VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL so that the whole image will have consistent layout. After glGenerateMipmap call, the next reasonable usage is use it in fragment shader, so the barrier is not wasted. Bug: angleproject:5986 Change-Id: I3690ae8417d97bc504fcf036d016f289e6370526 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2909757 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Mohan Maiya 81db1a46 2021-05-20T13:45:26 Vulkan: TextureVk inherits a few attributes from ImageHelper Cache VkImageCreateFlags in ImageHelper. This allows texture target siblings to inherit a few VkImage create attributes thus avoiding image respecification in certain code paths. Bug: angleproject:2514 Bug: angleproject:5281 Test: PbufferTest.ClearAndBindTexImageSrgbSkipDecode*Vulkan Change-Id: Ic7397fabdce185264e06488355ca47f809338519 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2910473 Commit-Queue: Mohan Maiya <m.maiya@samsung.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi cf3af29a 2021-05-14T16:49:36 Vulkan: Optimize respecifying an image When recreating a texture image to change a usage flag or the base/max levels, this change directly places the levels of the previous image as updates to the new image. This is instead of copying the image to a temp one and staging that. Bug: angleproject:4835 Change-Id: Ibc210b9ff0e8d11cba10b1cd9ab262c8f706cea5 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2898417 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com>
Shahbaz Youssefi 8bd3d7d5 2021-05-17T13:45:33 Vulkan: Fix a bug releasing DynamicBuffer-owned buffer There was one instance of BufferVk releasing a buffer it had allocated from a DynamicBuffer. This shouldn't have happened as the DynamicBuffer owns the buffers. Bug: angleproject:5720 Change-Id: I435512f4bb099130126bf3efb48a238fcd9f3ddb Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2896168 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Mohan Maiya <m.maiya@samsung.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Shahbaz Youssefi 9c262ad0 2021-05-14T12:26:48 Vulkan: Cleanup texture image respecify Prior to this change, respecifying a texture image due to usage, base or max level changes incurred a copy of every level and layer to a temporary buffer which was then staged as an update to the new image. This code was somewhat messy (for example with respect to depth/stencil images), error prone (e.g. previously had bugs with compressed textures) and disallowed further optimizations such as in anglebug.com/4835. This change does the following: - ImageHelper::SubresourceUpdate now takes ref-counted images, instead of image pointers. This allows the same image to be staged for multiple updates. - Respecifying an image is still done through a copy, but to an identical (temp) image instead of buffer, and each level of the image is staged as an update. * Further optimization is to stage the old image itself directly as updates to the new image Bug: angleproject:4835 Change-Id: I4a3ef2d616c9ab459ff65f918b0fb6d9a2161b73 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2897537 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com>
Shahbaz Youssefi e354ff1a 2021-03-05T04:07:21 Vulkan: Allow DynamicBuffer suballocation in BufferVk When allocations are made from DynamicBuffer, they suballocate from a possibly larger BufferHelper. In BufferVk, the offset of the suballocation was discarded, which limited the use of DynamicBuffer to a pool of small buffers. This change applies any such offset that may arise from suballocations everywhere, and makes BufferVk use a larger buffer size when the GL_DYNAMIC_* buffer usage hints are provided. Bug: angleproject:5719 Change-Id: I3df3317f7acff1b1b06a5e3e2bb707616a7d0512 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2738650 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Charlie Lao 46a139ad 2021-05-06T11:20:51 Vulkan: set DS layout before using it in the endRenderPass In CommandBufferHelper::endRenderPass(), we are checking depth stencil's initialLayout to change storeOp to None if the layout is read only. But the layout was set after that check, which essentially voids the optimization. This CL moves the finalizeDepthStencilImageLayout() call before the layout is used. This CL also moves the depth stencil loadOp/storeOp to a new function finalizeDepthStencilLoadStoreOp(). When depthImage gets deleted before renderpass ends, we could also apply the same load/store optimization just like we did at endRenderPass() time. Bug: b/187425444 Change-Id: I89814274352f09cbf1f7b58a91bbaf131b983fb1 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2877933 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Charlie Lao <cclao@google.com>
Mohan Maiya 84d22197 2021-04-26T17:11:27 Vulkan: Add device local fallback in findCompatibleMemoryIndex(...) When finding a compatible memory index for an external buffer, we need to have a fallback path that requires just the VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT property. Bug: angleproject:5909 Change-Id: Id3faffb3e357be2e5e6f5fce9e64f0f2889d199a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2862561 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Mohan Maiya <m.maiya@samsung.com>
Jamie Madill ccc0fbaa 2021-03-24T17:56:38 Vulkan: Related fixes for buffer descriptor set cache. Includes some stats counter gathering and a few related refactors and cleanups. Also includes a new overlay widget. Bug: angleproject:5736 Change-Id: Ida8d2cd815c5b598c6a442dd9bbfdf51e9c05180 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2785431 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Tim Van Patten <timvp@google.com>
Mohan Maiya 84b31c03 2021-04-25T08:30:14 Vulkan: Fix bug in VkImageFormatListCreateInfoKHR On some vendors VVL throws the following error, snippet only - [ VUID-VkImageViewCreateInfo-pNext-01585 ] Validation Error ... image was created with a VkImageFormatListCreateInfo in pNext of vkImageCreateInfo, but none of the formats match the VkImageViewCreateInfo::format ... The Vulkan spec states: If a VkImageFormatListCreateInfo structure was included in the pNext chain of the VkImageCreateInfo structure used when creating image and VkImageFormatListCreateInfo::viewFormatCount is not zero then format must be one of the formats in VkImageFormatListCreateInfo::pViewFormats. It looks like VkImageFormatListCreateInfoKHR::pViewFormats needs to contain all formats including the format of the VkImage itself. Bug: angleproject:5281 Change-Id: I93c6900d99791ef4f9f116cb114f068e0a318bf4 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2849566 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Mohan Maiya <m.maiya@samsung.com>
Charlie Lao fb288312 2021-04-12T12:38:03 Vulkan: Consolidate mReadOnlyDepthStencilMode to mRenderPassUsageFlags Since now ImageHelper object has a mRenderPassUsageFlags tracking how it is been used by current RenderPassCommands, we can consolidate mReadOnlyDepthStencilMode into a bit in the mRenderPassUsageFlags. The read only mode is just a special attachment mode, so this makes code more consistent and able to get rid of the extra dword for mReadOnlyDepthStencilMode. Bug: b/181797383 Change-Id: Ie9b7be1c18c392e5b2712bdae6ab6506de8d6d34 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2821942 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 5eac3169 2021-04-09T15:54:11 Vulkan: Support sample/render to depth texture with different LOD Previously we supported read only depth attachment that attachment and sample are using the same texture. It was always assuming it will be read only if the same texture is attached to FBO and same time bound to texture unit. But we never supported if it actually writing to depth texture, but at the different level with sampling. This is supported OpenGL operation as long as the levels render to is outside [base_level, max_level]. Later on, we added support of the above operation, but limited to color buffers. This CL extends the same support of render and sample to the same depth texture with non-overlapping levels. Android game black desert mobile is running into this usage case. Bug: b/181797383 Change-Id: I7ee1d52f27603f933102ad1b098684309449c406 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2819487 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Ian Elliott <ianelliott@google.com>
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 afd32d8e 2021-03-30T15:50:57 Vulkan: Remove mMaxLevel from ImageHelper class This CL removes mMaxLevel from ImageHelper class. Instead, it now uses front end's max level information when possible. Bug: b/181800403 Change-Id: Ie0f6bd11e3ca0d4ddfc98f21261396c4d71b7140 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2796153 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Ian Elliott <ianelliott@google.com>
Charlie Lao 08b7c55c 2021-03-30T13:51:04 Vulkan: Remove mBaseLevel from ImageHelper class This removes mBaseLevel from ImageHelper class. With the mFirstAllocatedLevel tracking exactly which GL level has been allocated, this cached mBaseLevel is no longer needed. Bug: b/181800403 Change-Id: I99d66c93b0c8f1bd20a5811b51f512a27927201e Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2795275 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Ian Elliott <ianelliott@google.com> Reviewed-by: Jamie Madill <jmadill@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>
Charlie Lao fd3b8faf 2021-03-30T11:55:49 Vulkan: Split fragment shader from ColorAttachmentAndAllShadersRead Even though it is not common usage case that the same texture is used as attachment and texture, but aztec ruins is using it. And earlier version of gfxbench's T-Rex also running into this. So performance is still important. This CL splits the texture from fragment shader usage case out so we can have lighter barrier. Bug: angleproject:5780 Change-Id: Ifdcbfe24488fdac62826c5af6ecfbb05f87c0499 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2795269 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Charlie Lao 81432c24 2021-03-19T14:03:02 Vulkan: Rename onImageHelperRelease to finalizeImageLayout Make the API name reflect what it does. With recent changes, this get called from places that are not releasing ImageHelper object, but is try to reference the current layout. This new name makes more sense than onImageHelperRelease (at that time when this API was introduced, it was only called when ImageHelper is being released). Bug: b/175584609 Change-Id: Ie5f5fcdbd97436724d7eb016374d8b4178e7ba1d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2776261 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Charlie Lao 867411a4 2021-03-08T19:08:14 Vulkan: Track images used for both attachment and sampler This CL adds a new layout ImageLayout::ColorAttachmentAndShaderRead. We detect that the same ImageHelper object is used for both sampler and attachment and will pick this new layout instead of ColorAttachment. Bug: b/175584609 Change-Id: I2089f59d4dc1ad4de7edab0e067797adcfa9b020 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2749479 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Charlie Lao da437f26 2021-03-08T19:08:14 Vulkan: Defer color image layout changes at endRenderPass time Right now color render target's image's layout change are done at beginRenderPass time. The problem is that the layout also depends on whether texture is also being used as a sampler or not. That information is not known when renderpass starts. We did some special treatment for depth stencil attachment so that its layout determination is deferred until endRenderPass time. This CL expands that same mechanism to color attachment as well. Right now the color attachment will still pick the same ImageLayout::ColorAttachment layout since the logic to detect it is also used for texture sampling is not there yet. Bug: b/175584609 Change-Id: Id7486174d475f894461578b31d0d40fdd90e808a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2744121 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Charlie Lao <cclao@google.com>
Charlie Lao 378b3261 2021-03-08T18:50:53 Vulkan: Move CommandBufferHelper::reset() closer to constructor This is a mechanical change. Similar to constructor, the reset() function is doing initialization of data members. Move them next to each other helps adding a new data members which requires modifications to both functions. Bug: b/175584609 Change-Id: I11386677bc5c9838104025d6a4ecf6f2b58fa92c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2745842 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Charlie Lao <cclao@google.com>
Mohan Maiya 81dcf078 2021-03-08T11:21:31 Reland "Vulkan: Support EXT_sRGB_write_control" This is a reland of 6073af536cf627742696823edc82c9b0a481a8bc with 2 changes - 1. Don't enable the extension even in nonConformant mode 2. Don't enable VK_KHR_image_format_list for swiftshader Original change's description: > Vulkan: Support EXT_sRGB_write_control > > Implement support for EXT_sRGB_write_control. This extension > requires VK_KHR_image_format_list to be supported. > > The spec requires this functionality to work with glBlitFramebuffer > as well but support for that will be added in a follow up change. > As such, this extension is only exposed in non-conformant mode. > > Bug: angleproject:5075 > Tests: SRGBFramebufferTest.*Vulkan* > Change-Id: I59b38f6cd810a3d0d67ec29f4f19c25f65f70862 > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2617243 > Commit-Queue: Mohan Maiya <m.maiya@samsung.com> > Reviewed-by: Jamie Madill <jmadill@chromium.org> > Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Bug: angleproject:5075 Change-Id: I8e149d196a39c3c4769bfa8690792f3c53831299 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2762647 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Mohan Maiya <m.maiya@samsung.com>
Peng Huang b27740f3 2021-03-09T16:15:15 Revert "Vulkan: Support EXT_sRGB_write_control" This reverts commit 6073af536cf627742696823edc82c9b0a481a8bc. Reason for revert: crbug.com/1186140 Original change's description: > Vulkan: Support EXT_sRGB_write_control > > Implement support for EXT_sRGB_write_control. This extension > requires VK_KHR_image_format_list to be supported. > > The spec requires this functionality to work with glBlitFramebuffer > as well but support for that will be added in a follow up change. > As such, this extension is only exposed in non-conformant mode. > > Bug: angleproject:5075 > Tests: SRGBFramebufferTest.*Vulkan* > Change-Id: I59b38f6cd810a3d0d67ec29f4f19c25f65f70862 > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2617243 > Commit-Queue: Mohan Maiya <m.maiya@samsung.com> > Reviewed-by: Jamie Madill <jmadill@chromium.org> > Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Bug: angleproject:5075,chromium:1186140 Change-Id: Ib0d4d60fe7434fb950f99db2c210aab9af7d2d0e No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2743663 Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> Commit-Queue: Peng Huang <penghuang@chromium.org>