src/libANGLE/renderer/vulkan/vk_helpers.h


Log

Author Commit Date CI Message
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>
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>
Mohan Maiya 26a54260 2021-05-26T16:53:29 Reland "Vulkan: Handle immutable sampler state change in TextureVk" This is a reland of 349c08300e08bc809c448d62e0ad969ecb17c047 Skip YUV tests on Pixel2 Original change's description: > Vulkan: Handle immutable sampler state change in TextureVk > > Transitioning between sources in RGB and YUV colorspace or between > YUV formats with different layout should force the recreation of > pipeline layout and the invalidation of texture's sampler. > > Only textures that are EGLImage targets are handled for now. > > Bug: b/155487768 > Bug: angleproject:5033 > Bug: angleproject:5773 > Test: ImageTest.SourceAHBTarget2DExternalCycleThrough*Vulkan > Change-Id: I02d5763e7f89b910313e14b57bfc5403113dfbb2 > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2924415 > Reviewed-by: Jamie Madill <jmadill@chromium.org> > Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> > Commit-Queue: Mohan Maiya <m.maiya@samsung.com> Bug: b/155487768 Bug: angleproject:5033 Bug: angleproject:5773 Change-Id: Ie3791bc6f6e9b53eb0db23759a14fdc038c8f5b6 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2939354 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Sunny Sachanandani 03d8e7c9 2021-06-04T21:22:52 Revert "Vulkan: Handle immutable sampler state change in TextureVk" This reverts commit 349c08300e08bc809c448d62e0ad969ecb17c047. Reason for revert: anglebug.com/6028 Original change's description: > Vulkan: Handle immutable sampler state change in TextureVk > > Transitioning between sources in RGB and YUV colorspace or between > YUV formats with different layout should force the recreation of > pipeline layout and the invalidation of texture's sampler. > > Only textures that are EGLImage targets are handled for now. > > Bug: b/155487768 > Bug: angleproject:5033 > Bug: angleproject:5773 > Test: ImageTest.SourceAHBTarget2DExternalCycleThrough*Vulkan > Change-Id: I02d5763e7f89b910313e14b57bfc5403113dfbb2 > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2924415 > Reviewed-by: Jamie Madill <jmadill@chromium.org> > Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> > Commit-Queue: Mohan Maiya <m.maiya@samsung.com> Bug: b/155487768 Bug: angleproject:5033 Bug: angleproject:5773 Bug: angleproject:6028 Change-Id: Ib8b3b54ff61f26910df2af4a6b894b3d2d5906bb No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2941547 Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> Commit-Queue: Sunny Sachanandani <sunnyps@chromium.org>
Mohan Maiya 349c0830 2021-05-26T16:53:29 Vulkan: Handle immutable sampler state change in TextureVk Transitioning between sources in RGB and YUV colorspace or between YUV formats with different layout should force the recreation of pipeline layout and the invalidation of texture's sampler. Only textures that are EGLImage targets are handled for now. Bug: b/155487768 Bug: angleproject:5033 Bug: angleproject:5773 Test: ImageTest.SourceAHBTarget2DExternalCycleThrough*Vulkan Change-Id: I02d5763e7f89b910313e14b57bfc5403113dfbb2 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2924415 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Mohan Maiya <m.maiya@samsung.com>
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>
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 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>
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>
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>
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>
Mohan Maiya 6073af53 2021-03-08T11:21:31 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>
Shahbaz Youssefi e366e2c3 2021-02-27T01:00:02 Vulkan: Keep dynamic buffer's free list trimmed ContextVk's staging buffer never gets a chance to free its free buffer list. During application load time, a large amount of memory may be allocated from this buffer to stage texture updates and they would remain throughout the life of the application. This change ensures that the free buffer list doesn't grow unbounded. In the Manhattan trace, this saves >1GB of memory on Linux. There are now three policies for vk::DynamicBuffer: - Always reuse buffers: This is useful for dynamic buffers that make frequent small allocations, such as default uniforms, driver uniforms, default vertex attributes and UBO updates. - Never reuse buffers: This is for situations where the buffer is unlikely to be used after some initial usage, such as texture data upload or vertex format emulation (as the conversion result is cached, so it's never redone). - Limited reuse of buffers: For the staging buffer in the context which is shared by all immutable texture data uploads, it's useful to keep a limited number of buffers (1 in this change) to support future texture streaming while allowing a large number of buffers allocated in a burst to be discarded. Bug: angleproject:5690 Change-Id: Ic39ce61e6beb3165dbce4b668e1d3984a2b35986 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2725499 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Shahbaz Youssefi e96d1744 2021-02-12T14:14:02 Vulkan: Optimize glMemoryBarrier Previous to this change, glMemoryBarrier was processed as it is issued. This made it impossible to know whether a draw call would follow or a dispatch call, and what resources it would use. The render pass was conservatively broken due to this limitation. To address this limitation, handling of glMemoryBarrier is deferred until the next draw or dispatch call. Note that glMemoryBarrier acts as two barriers: - An execution+memory barrier: shader writes are made visible to subsequent accesses - Another execution barrier: shader accesses are finished before subsequent writes An important observation is that for most resources, ANGLE actually necessarily has to issue memory barriers automatically to conform with Vulkan. In terms of memory barrier thus, ANGLE already does the right thing except for when there's no binding change. This means WaW hazards (i.e. storage buffer and image writes) with no binding change require a memory barrier as a result of glMemoryBarrier. In all other cases, it's enough for glMemoryBarrier to break the render pass if necessary and ensure that corresponding bindings are marked dirty (for the execution or memory barriers to happen automatically later). Bug: angleproject:5070 Change-Id: Ide359c43362f8a78805ecf797a91de7aa79221f9 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2693473 Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Mohan Maiya 4afd0f27 2021-02-17T13:35:57 Vulkan: Add VK_KHR_image_format_list support to initExternal The code for initializing a VkImage with VK_KHR_image_format_list extension support is now internal to initExternal. Also provides a flag to inform callers when VK_KHR_image_format_list support is enabled. Bug: angleproject:5520 Change-Id: Ie2ade93d1403ab3f9cbcf7d80684bbca201d5d8d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2702159 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Mohan Maiya <m.maiya@samsung.com>
Shahbaz Youssefi e8c0aa81 2021-01-26T23:40:36 Vulkan: Clean up transform feedback extension pause/resume 1. The xfb counter buffer barrier issued was wrong, following a typo in the spec. This barrier is now correctly issued using the usual barrier APIs. 2. A mechanism was added to automatically pause/resume transform feedback when a program pipeline needs to be rebound. This is incorrect as it misses the xfb counter buffer barrier. The render pass is broken instead if transform feedback is active/unpaused and the program pipeline is changed. 3. The transform feedback counter buffers are now disposed of when transform feedback is ended. This avoids an unnecessary barrier that this change would have otherwise incurred (and hence render pass break) in Manhattan which repurposes the same transform feedback object. Bug: angleproject:5528 Change-Id: I1ffe8b4b8975645ba43afd70e9cdbb0765529da5 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2651647 Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Ian Elliott 60b03e62 2021-02-16T14:31:19 Create getRotatedExtents() and related methods Created: - WindowsSurfaceVk::getRotatedWidth() - WindowsSurfaceVk::getRotatedHeight() - RenderTarget::getRotatedExtents() - ImageHelper::getRotatedExtents() - ImageHelper::getRotatedLevelExtents2D() Note: The FramebufferVk class doesn't use any of these methods Bug: b/175793022 Change-Id: I64395688bfdb172d32853763743fc5f266a6b792 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2686102 Commit-Queue: Ian Elliott <ianelliott@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Mohan Maiya 2b69462e 2021-02-12T15:55:00 Vulkan: Consolidate image format list initialization code HardwareBufferImageSiblingVkAndroid, RenderbufferVk, SurfaceVk and TextureVk all had similar code to initialize VkImage with VK_KHR_image_format_list extension support. Consolidate all of them into a helper. Bug: angleproject:5520 Change-Id: Ib7ac582a35a26c0da15879e688bcaf0c2a92ea87 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2692641 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Mohan Maiya <m.maiya@samsung.com>
Shahbaz Youssefi 79ae52dd 2021-02-11T14:18:41 Vulkan: Fix missing visibility barrier for host-visible buffer writes See https://chromium-review.googlesource.com/c/angle/angle/+/1661252 for context. This was accidentally broken during the command graph rework. This will eventually be validated by syncval. See https://github.com/KhronosGroup/Vulkan-ValidationLayers/issues/2329. Bug: angleproject:5070 Change-Id: Ic16fa900e554d46e54b42fc3fbe0f96d5327fa0f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2689379 Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 031dd5c5 2021-02-11T14:56:43 Vulkan: Add fast path for pack buffer copies When vkCmdCopyImageToBuffer is possible, it is used to implement glReadPixels with PBO instead of a CPU readback. A few tests are added to verify synchronization between pack/unpack and compute shader writes. Bug: angleproject:5070 Change-Id: Ia5da0feb31348f6b52d164b973ff95e2a0510582 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2691466 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Ian Elliott <ianelliott@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Ian Elliott ce540d8c 2021-02-01T17:38:10 Create MSAA-swapchain windows' VkImages differently The actual VkImage needs to have rotated extents, but the ImageHelper needs to have non-rotated extents in order for the rest of ANGLE's pre-rotation to work. Bug: b/175793022 Change-Id: I6fa25ab8c636886787ac50b194e566111308f30b Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2666514 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Cody Northrop <cnorthrop@google.com> Commit-Queue: Ian Elliott <ianelliott@google.com>
Shahbaz Youssefi eae262e7 2021-01-27T13:56:49 Vulkan: Fix image layout barriers for tessellation shaders Also fixes a bug where invalid stages may be specified for example if AllGraphicsReadOnly or DepthStencilReadOnly layouts are used and geometry or tessellation shaders are not supported by the implementation. Bug: angleproject:5557 Change-Id: Ia25a6aec8138c67701c63da65783263d8a7bda27 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2653911 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Jamie Madill b912eec5 2020-11-27T11:08:41 Vulkan: Support GL_EXT_tessellation_shader. Shader translator changes done in http://crrev.com/c/2633936 Adds a new DIRTY_BIT_PATCH_VERTICES state to Context. Supportes state query and transform feedback. 4 test suppressions remain as follow-up fixes. Adds a new varying packing mode for a simple Vulkan rule set. Based on work by Mohan Maiya (m.maiya@samsung.com). Test: dEQP-GLES31.functional.tessellation.* Bug: angleproject:3572 Change-Id: I4cad2cca30adb754fd12c83027673906541f566a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2568234 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Mohan Maiya <m.maiya@samsung.com> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Jamie Madill 2e9706d8 2021-01-08T17:29:42 Vulkan: Use angle::FormatID instead of VkFormat. This change switches the internal enums we pass around from VkFormat to FormatID. The end goal of the refactor is to allow the Vulkan back-end to store packed tables indexed by FormatID. Because VkFormat has large gaps in its enum space we'd otherwise need to use unordered data structures like unordered_map. The change removes the redundant VkFormat storage from vk::Format and uses a new table query to return the VkFormat that 1:1 matches an angle::FormatID. We also include a reverse mapping for use with native Vulkan get functions for Android. Also moves sRGB conversion functions into renderer_utils. A couple sRGB formats that don't exist in GL are no longer handled by the sRGB conversion functions. These formats should be extremely rare. Bug: angleproject:5438 Change-Id: Id8b49773ca0c556f9f5a6a10fcf0d9762b93bbea Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2618204 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Ian Elliott <ianelliott@google.com>
Shahbaz Youssefi a7158eb5 2021-01-06T21:33:24 Vulkan: Fix image leak in staged updates in ImageHelper When removing superseding updates, the superseded update was not released, causing a memory leak. This change also makes SubresourceUpdate non-copyable and correctly implements the move assignment operator such that swap between different update types are correct. As a result, the destructor can now ASSERT that the image is not leaked. Bug: chromium:1146516 Bug: chromium:1163354 Change-Id: I7531c91d8559c23b2e09159118fe645d12fc601f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2613201 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Mohan Maiya 98b56e60 2020-12-12T16:28:21 Vulkan: Accumulate internal cache stats in renderer The CacheStats of all internal caches are accumulated by the renderer. In order to see the hit ratios of all caches, the following GN args must be enabled: is_debug = true angle_enable_perf_counter_output = true Bug: angleproject:5447 Test: Manual verification with angle_end2end_tests Change-Id: Iaca3249192e9e4e130d8291b7759c459d79b06ee Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2588430 Commit-Queue: Mohan Maiya <m.maiya@samsung.com> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Shahbaz Youssefi 56330564 2020-12-10T00:46:04 Vulkan: Support layered framebuffers This feature is introduced by geometry shaders, where all the layers of a texture can be attached to a framebuffer. The geometry shader would use gl_Layer to decide which layer the primitive should be rendered to. Bug: angleproject:3571 Change-Id: Ib2ae8e227b226295f9e2f62f6b230839070bc95c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2582711 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Shahbaz Youssefi f691b3b5 2020-12-02T13:11:54 Vulkan: Support PrimitivesGenerated query This query uses the Vulkan transform feedback extension. In GL, GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN and GL_PRIMITIVES_GENERATED queries can be independently begun/ended. However, Vulkan requires that queries from pools of the same type can only be active one at a time. This forbids the two GL queries from being handled by two VK queries when they are simultaneously begun. This change makes these queries share their QueryHelper objects. The Vulkan transform feedback queries unconditionally retrieve both results anyway, so this is just a matter of making sure the two GL queries are merged as one when they are simultaneously used. The change fixes a number of issues as collateral: - TransformFeedbackPrimitivesWritten queries when !emulated were not released - Stashed queries were never released - If no render pass is open when a query ends, then getResult(no_wait) ended up waiting Bug: angleproject:5404 Change-Id: I8ce13ea76ffd31b3152ded7c713c6466d0315504 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2573580 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Shahbaz Youssefi 2c8bc1b7 2020-11-26T16:06:24 Vulkan: Clean up render pass query code In preparation for support of primitives generated queries. Bug: angleproject:5404 Change-Id: Ic123aaff33f8903994ff8fcc9158954ac023ec13 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2562126 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com>
Jamie Madill e56fd224 2020-12-01T09:44:38 Vulkan: Fix BufferHelper leaks in DynamicBuffer. We were leaking BufferHelper pointers in a couple cases. Fix these systematically by using a unique_ptr template. This leak was detected running ANGLE with LSAN enabled. Bug: angleproject:5377 Change-Id: I30ab235105cf74fae2cfc62a22dde534e2d07e81 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2567641 Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Alexis Hétu <sugoi@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Jamie Madill bccaaffd 2020-11-27T16:33:09 Vulkan: Use XFB queries with the XFB extension. This will enable accurate XFB primitive counts when using tessellation and geometry shaders. Adds new vk::QueryResult and gl::QueryTypeMap helper classes. Based on contributions by Mohan Maiya (m.maiya@samsung.com). Bug: angleproject:3572 Change-Id: Ie3f496deda887c13bb4ad7ab430e31d615849bfd Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2564002 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Mohan Maiya <m.maiya@samsung.com>
Shahbaz Youssefi a5da17cd 2020-11-26T17:09:37 Vulkan: Remove vk:: inside namespace vk Bug: angleproject:5404 Change-Id: I51df1ad69a65b17621a3cbe4e5d55621cc9ae6ec Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2562683 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 5850c748 2020-11-20T22:14:27 Vulkan: Emulated RGB copies in compute The copy between emulated RGB formats can take a number of paths: - Sample from src (reinterpreted as UINT), output to dst - Sample from src, output to temp buffer, copy to dst - Copy src to temp buffer, output to dst - Copy src to temp buffer, convert to another temp buffer, copy to dst While directly sampling from src and outputting to dst is more efficient, these are not always possible. The former may not have SAMPLED_IMAGE usage bit for the reinterpreted UINT format, and the latter may not have STORAGE_IMAGE usage at all. This change takes the universal approach of using two temp buffers. The ConvertVertex shader is used to transform between RGB and RGBA when copying from the first temp buffer to the second. Bug: angleproject:5278 Change-Id: I63d916cfdb4c389f5b817d89cd7348fdea703ce5 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2556467 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Brandon Schade <b.schade@samsung.com>
Shahbaz Youssefi b6ec24ab 2020-11-14T00:24:52 Vulkan: Support format reinterpretation in imageBuffers This is done by creating multiple buffer views over the buffer based on the format specified by the attached shaders. Bug: angleproject:3573 Change-Id: I0372a988938050cc092d8a0959a59d1c893fc6f4 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2536909 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Shahbaz Youssefi 61a117fa 2020-11-16T12:48:11 Vulkan: Fix aliasing format for non-layered image bindings This was correctly handled for layered bindings by the change anglebug.com/3885#c20. This change uses the same mechanism for non-layered bindings. Bug: angleproject:5347 Change-Id: Ida55b3589d0bdbe5d824c1614c9bf9f867a7f652 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2541182 Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Mohan Maiya f197ebac 2020-11-16T15:16:56 Vulkan: Add EXT_external_buffer support Addition of buffer support for external memory Also adds new end2end tests for these usecases * SubData update * map/unmap buffer * dispatch compute with external buffer Bug: angleproject:5073 Test: ExternalBufferTestES31.*Vulkan Change-Id: Ib3cccaca77b76830effe49d3731782552e7424ec Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2525105 Commit-Queue: Mohan Maiya <m.maiya@samsung.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 86d7e4d8 2020-11-10T15:55:34 Vulkan: Support texture buffers Texture buffers are placed in the same descriptor set with the rest of the textures. However, the different code paths that handle textures have special cases for texture buffers as they create a different descriptor type (texel buffer instead of combined image sampler). Image view serials are used to track the buffer view serials as well so the texture descriptor cache can handle texture buffers as well. This CL is missing storage texel buffer support. Bug: angleproject:3573 Change-Id: Iff80ca22ff9b9957a0c9a3c7aaada1fa54b24ec8 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2532653 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Shahbaz Youssefi 60641abc 2020-11-16T16:12:31 Vulkan: Make ImageViewHelper a Resource Bug: angleproject:3573 Change-Id: I12e70418b3b971e802bc911409e170cbf8c61915 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2542223 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Jamie Madill cdf280c0 2020-11-13T10:14:58 Vulkan: Fix serial handling for queries Previous serial mechanism wasn't reliable. QueryHelper is now a vk::Resource and uses the vk::Resource lifecycle. Also added some utility methods to QueryVk to deal with stashed queries. Any question we want to ask about mQueryHelper we want to ask about the stashed queries as well. Bug: b/169055809 Bug: b/169788986 Bug: b/170312581 Change-Id: Ia34a7a433e61a2543cfb09491ebab55b054a26c9 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2537718 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Courtney Goeltzenleuchter <courtneygo@google.com>
Shahbaz Youssefi 9e7f08fc 2020-11-06T16:55:51 Vulkan: Fix incorrect reordering of barriers Take the following situation, a simple copy from image to buffer: ANGLE_TRY(contextVk->onBufferTransferWrite(buffer)); ANGLE_TRY(contextVk->onImageTransferRead(aspectFlags, image)); CommandBuffer &commandBuffer = contextVk->getOutsideRenderPassCommandBuffer(); commandBuffer.copyImageToBuffer(imageHandle, layout, bufferHandle, 1, regions); Both `onBufferTransferWrite` and `onImageTransferRead` may flush either the outsideRP or insideRP command buffers. If buffer is not previously used, but image is used: - onBufferTransferWrite: buffer usage is recorded in outsideRP1 - onImageTransferREad: outsiderRP1 is flushed, outsideRP2 is started - copyImageToBuffer: recorded on outsideRP2, but buffer usage not recorded there - A following command that uses the buffer and requires barrier doesn't close outsideRP2 as it believes it was not used there Bug: angleproject:5319 Change-Id: Ib8994083fbc21969a538cda3784adee57b089415 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2523388 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Jamie Madill f19a4a20 2020-11-08T10:37:33 Vulkan: Move CommandBuffer management to RendererVk. This consolidates all relevant logic in a single place. We no longer need to interact with ContextVk in the worker thread. This switches the fixed pointer array size to a dynamically sized vector. Some of the EGL and ANGLE tests would use a large number of Contexts and we were consistently running out of available command buffers which would cause a deadlock situation. We can trust other parts of the code to throttle the application if it starts to get too far ahead of the device and dispense with the hard coded limit in the command buffer allocator itself. The resulting code is also quite a bit simpler and doesn't need a condition variable. Also fixes missing initialization in SecondaryCommandBuffer. Bug: b/172704839 Change-Id: Icc3a3daf5d6b272db556c0e4c93fb793583966a5 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2525143 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Courtney Goeltzenleuchter <courtneygo@google.com>
Jamie Madill e6a302a0 2020-11-07T10:49:15 Vulkan: Move vk::CommandQueue to RendererVk. This consolidates most of the command processor vs queue logic in one place. It also has a number of incidental changes related to fences: - syncs now do not store a shared fence. instead they call command apis to wait for a particular serial with a timeout. this is not yet fully implemented in CommandProcessor. - surface swap history stores a serial instead of a fence. because the RendererVk class stores the command batches, we no longer have to do messy things with ContextVk. - it is no longer possible to ask for a wait on a serial that isn't in the command queue. Also adds mutex synchronization around the RendererVk methods. Bug: angleproject:5217 Bug: b/172704839 Change-Id: I5faf0e24bb6ede79a927ab149b80bfa8baca4620 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2524548 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Courtney Goeltzenleuchter <courtneygo@google.com> Reviewed-by: Tim Van Patten <timvp@google.com>
Charlie Lao b22f8e8e 2020-10-29T15:50:39 Vulkan: Add specialization constants for surface rotation This plumbing through the specialization constant for surface rotation from ContextVk to pipeline program creation. It has not been used yet, so expecting no real functional change. This CL also converts lineRasterEmulation to use the same specialization constant path as surface rotation. Bug: b/171750979 Change-Id: Ic08c4f8bb576424d1752015e874d0977a58d78bb Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2508837 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Ian Elliott <ianelliott@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Jamie Madill c8a7c033 2020-11-07T09:12:47 Vulkan: Move primary command buffer to CommandQueue. This brings CommandQueue one step closer to the worker thread. Bug: b/172704839 Change-Id: I35225c5f302e34e3feb38a35c22b6d8e6f4ad10c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2524543 Reviewed-by: Courtney Goeltzenleuchter <courtneygo@google.com> Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Mohan Maiya 18fcb4ad 2020-11-06T07:22:17 Vulkan: Enable a subset of ImageTest colorspace tests This patch does the following - 1. Expose EGL_KHR_image_gl_colorspace only if the underlying ICD supports VK_KHR_image_format_list extension 2. Create VkImageViews from EGLimage's format 3. Fix bugs in ImageTest colorspace tests Bug: angleproject:3756 Bug: angleproject:5281 Test: angle_end2end_tests.exe --gtest_filter=ImageTest*Colorspace*Vulkan Change-Id: I618ae009e83d0a6b27a0a50165f736784717e404 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2523670 Commit-Queue: Mohan Maiya <m.maiya@samsung.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Mohan Maiya 55934550 2020-11-05T07:13:39 Vulkan: Don't refresh image views unnecessarily If the underlying ICD supports VK_KHR_image_format_list extension we will have created both the linear and sRGB image views, reuse them instead of refreshing them. Bug: angleproject:3609 Bug: angleproject:4561 Bug: angleproject:5281 Change-Id: Ie34f08b3554a07f94911bebf925e38d702bc3c36 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2518387 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Mohan Maiya <m.maiya@samsung.com>
Shahbaz Youssefi d77e85a8 2020-11-03T22:23:18 Vulkan: Store image updates per level This optimization allows iterating only over updates of a certain level or range of levels, instead of having to iterate over every update and filter out the ones matching the desired level(s). Bug: angleproject:4891 Change-Id: Ied04f4b28f05d37b9add61c7f4d54cc328c0be86 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2519095 Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Brandon Schade 1e494cae 2020-10-07T19:26:01 Vulkan: Add support for EXT_copy_image Add support for GL_EXT_copy_image which allows image data transfer between image objects. This is implemented by using the vkCmdCopyImage API call. Bug: angleproject:3593 Test: dEQP-GLES31.functional.copy_image.* Change-Id: I30a34a8711b5d2e5834064d7453e03d6ec0df478 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2393955 Commit-Queue: Brandon Schade <b.schade@samsung.com> Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi a0e91016 2020-10-30T10:01:36 Vulkan: Don't break the render pass on scissor change Prior to this change, the render area was decided when the render pass was started, and remained fixed. If a small scissor was initially used, this created a render pass with a small area. If then the scissor region was expanded, the render pass was broken. This change instead expands the render area on scissor change to avoid breaking the render pass. If glInvalidateSubFramebuffer previously successfully resulted in storeOp=DONT_CARE, this optimization may need to undo that. As a result, the invalidate area is stored in the render pass and if the render area grows beyond that, invalidate is undone. Bug: angleproject:4988 Change-Id: I4e8039dec53a95a193a97cb40db3f71e397568d6 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2508983 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Shahbaz Youssefi 4989667a 2020-11-03T16:28:37 Vulkan: Make ImageHelper::flushStagedUpdates take gl::LevelIndex More consistent with the rest of the public functions in this class. Bug: angleproject:4891 Change-Id: I72c7c3d21f8287cc1711772671c6e7ad524fd096 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2518179 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 019e3f77 2020-11-02T17:20:19 Vulkan: Use dst access masks to determine if barrier is needed Src access mask may be 0 with WAR barriers. Bug: angleproject:5290 Change-Id: I798d4c36aa7d3d14db333a7e86794e13c8137f96 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2514841 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Mohan Maiya 3fcf17e6 2020-11-02T12:51:35 Vulkan: Bug fix in sRGBDecode logic When a sampler's GL_TEXTURE_SRGB_DECODE_EXT state was toggled between GL_DECODE_EXT and GL_SKIP_DECODE_EXT VkImageViews of the TextureVk object were not being updated. Add sRGB_decode state as part of ImageViewSubresourceSerial so we retrieve the correct VkImageView from the texture cache. Bug: angleproject:3609 Tests: angle_end2end_tests --gtest_filter=SRGBTextureTestES3.SRGBDecodeSamplerParameterToggle*Vulkan Change-Id: I897e461957d408b5a5b4f03fefc05f2e9684c7b7 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2514900 Commit-Queue: Mohan Maiya <m.maiya@samsung.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Jamie Madill 97843bda 2020-10-30T17:03:36 Vulkan: Fix EGL Surface robust init. The error here was related to using a single cache variable for the robust init setting for all the surfaces in a DisplayVk. Fix this by passing down the robust init setting from the SurfaceVk to image init. Bug: angleproject:5274 Change-Id: I9bc9c20990268d1d5166411fb53f8f2593fd1971 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2510694 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Tim Van Patten fcd35965 2020-09-29T14:15:51 Vulkan: Make DescriptorPoolHelper a Resource Descriptor pools need to live as long as the descriptor sets that are allocated from them. Using Serials while building a command to judge a pool's lifetime is prone to errors, since a command's Serial value isn't known until the command is submitted, leading to deleting pools too early relative to when the descriptor set is actually used. This CL updates DescriptorPoolHelper to inherit from Resource, so the descriptor pools can be retain()'ed. This allows the Resource's counter to indicate that a pool is in use until the command's Serial is known and can be recorded to indicate when the command completes. This prevents descriptor pools from being destroyed before the command completes (while the descriptor sets are still in use), or even before the command has been submitted. Destroying a descriptor pool resets all of the descriptors that were allocated from it, which can trigger a variety of VVL errors depending on when it's erroneously performed. This CL also adds the necessary retain() calls for the descriptor pools. In particular, the pools need to be retained each time a cached descriptor set that was allocated from it is re-used. This is relatively simple with the current design, since we always clear the descriptor set caches whenever a new pool is allocated, so the descriptor pool binding is always accurate. Bug: angleproject:5030 Test: VulkanMultithreadingTest::MultiContextDrawSmallDescriptorPools() Change-Id: Iac9e7efef338f169a6bf8ac3b2140e03dd326641 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2504457 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Courtney Goeltzenleuchter <courtneygo@google.com> Commit-Queue: Tim Van Patten <timvp@google.com>
Jamie Madill 9e3eec54 2020-10-25T15:44:09 Revert "Vulkan: Make DescriptorPoolHelper a Resource" This reverts commit 5dcd29a6e532e4bd617af8767d488120b57f3b2c. Reason for revert: Breaking the ANGLE -> Chromium roller: https://chromium-review.googlesource.com/c/chromium/src/+/2496281 Original change's description: > Vulkan: Make DescriptorPoolHelper a Resource > > Descriptor pools need to live as long as the descriptor sets that are > allocated from them. Using Serials while building a command to judge a > pool's lifetime is prone to errors, since a command's Serial value > isn't known until the command is submitted, leading to deleting pools > too early relative to when the descriptor set is actually used. > > This CL updates DescriptorPoolHelper to inherit from Resource, so the > descriptor pools can be retain()'ed. This allows the Resource's counter > to indicate that a pool is in use until the command's Serial is known > and can be recorded to indicate when the command completes. This > prevents descriptor pools from being destroyed before the command > completes (while the descriptor sets are still in use), or even before > the command has been submitted. Destroying a descriptor pool resets all > of the descriptors that were allocated from it, which can trigger a > variety of VVL errors depending on when it's erroneously performed. > > This CL also adds the necessary retain() calls for the descriptor pools. > In particular, the pools need to be retained each time a cached > descriptor set that was allocated from it is re-used. This is relatively > simple with the current design, since we always clear the descriptor set > caches whenever a new pool is allocated, so the descriptor pool binding > is always accurate. > > Bug: angleproject:5030 > Test: MultithreadingTest::MultiContextDrawSmallDescriptorPools() > Change-Id: I5fdeeb46159448dfd679d7169e423048348be5ab > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2437609 > Commit-Queue: Tim Van Patten <timvp@google.com> > Reviewed-by: Jamie Madill <jmadill@chromium.org> > Reviewed-by: Courtney Goeltzenleuchter <courtneygo@google.com> TBR=courtneygo@google.com,timvp@google.com,jmadill@chromium.org # Not skipping CQ checks because original CL landed > 1 day ago. Bug: angleproject:5030 Change-Id: I0fd6d9a0e1b0989b22368ef98652281288699deb Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2497222 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill 33e30205 2020-10-17T19:03:45 Vulkan: sRGB cleanups. A few fixes to how we check for the sRGB override in the TextureVk class. In at least one instance there was a potential edge case where in syncState we might not create the Texture with the mutable bit the second time through the function. Bug: angleproject:5176 Change-Id: I4f1ca6e469b10514c3a0de3120be9ade62568084 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2482292 Reviewed-by: Mohan Maiya <m.maiya@samsung.com> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Tim Van Patten 5dcd29a6 2020-09-29T14:15:51 Vulkan: Make DescriptorPoolHelper a Resource Descriptor pools need to live as long as the descriptor sets that are allocated from them. Using Serials while building a command to judge a pool's lifetime is prone to errors, since a command's Serial value isn't known until the command is submitted, leading to deleting pools too early relative to when the descriptor set is actually used. This CL updates DescriptorPoolHelper to inherit from Resource, so the descriptor pools can be retain()'ed. This allows the Resource's counter to indicate that a pool is in use until the command's Serial is known and can be recorded to indicate when the command completes. This prevents descriptor pools from being destroyed before the command completes (while the descriptor sets are still in use), or even before the command has been submitted. Destroying a descriptor pool resets all of the descriptors that were allocated from it, which can trigger a variety of VVL errors depending on when it's erroneously performed. This CL also adds the necessary retain() calls for the descriptor pools. In particular, the pools need to be retained each time a cached descriptor set that was allocated from it is re-used. This is relatively simple with the current design, since we always clear the descriptor set caches whenever a new pool is allocated, so the descriptor pool binding is always accurate. Bug: angleproject:5030 Test: MultithreadingTest::MultiContextDrawSmallDescriptorPools() Change-Id: I5fdeeb46159448dfd679d7169e423048348be5ab Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2437609 Commit-Queue: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Courtney Goeltzenleuchter <courtneygo@google.com>
Courtney Goeltzenleuchter ed876984 2020-10-03T11:00:36 Vulkan: functionally complete worker thread Working on enhancing worker thread to completely own primary command buffers. This will include not only processing SCBs from main thread into a primary, but also submitting those command buffers to the queue. The CommandProcessor is a vk::Context so it can handle errors in the worker thread. When the main thread submits tasks to the worker thread it also syncs any outstanding errors from the worker. Include asynchronousCommandProcessing feature that will control whether the worker thread task does it's work in parallel or not. If false, we wait for the thread to complete it's work before letting the main thread continue. If true, the thread can execute in parallel with the main thread. Bug: b/154030730 Bug: b/161912801 Change-Id: I00f8f013d6cbb2af12a172c4f7927855db2f0ebf Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2328992 Commit-Queue: Courtney Goeltzenleuchter <courtneygo@google.com> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill 2072ce50 2020-10-18T16:44:09 Rename "NonLinear" to "SRGB". In OpenGL parlance there are really only two color spaces: Linear and SRGB. Vulkan is much more complicated with linear and nonlinear SRGB, and multiple non-SRGB linear color spaces. Keep things simple by working with OpenGL nomenclature. Bug: angleproject:5176 Change-Id: Ia730a9a666a2b3325194b86dc588e7fd226c4183 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2483466 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Mohan Maiya <m.maiya@samsung.com> Reviewed-by: Courtney Goeltzenleuchter <courtneygo@google.com>
Mohan Maiya 7bbe497a 2020-10-16T14:46:45 Vulkan: Implement EXT_texture_sRGB_decode Implement EXT_texture_sRGB_decode. This builds on the existing functionality from EXT_texture_sRGB_override, with 2 major edge cases: 1. sRGB_decode allows the texture state to be overridden by sampler state, which is implemented by forcing a a texture state sync during updateActiveTextures if a texture is bound to the same unit as a sampler with that state 2. texelFetch calls require us to reenable decoding, regardless of decode state. We add a new compiler pass (FlagSamplersWithTexelFetch) to mark samplers that are used with texelFetch in order to support this. This change also re-enables EXT_texture_sRGB_R8, which was disabled due to a dEQP bug that this change will bypass. Bug: angleproject:3609 Bug: angleproject:4503 Test: dEQP.GLES31/functional_srgb_texture_decode_skip_decode_* Test: GLES31/functional_state_query_texture_*_srgb_decode_* Test: GLES31/functional_state_query_sampler_*_srgb_decode_* Test: GLES31/functional_debug_negative_coverage_*_srgb_decode_* Test: GLES31/functional_android_extension_pack_extensions_ext_texture_srgb_decode Test: angle_end2end_tests --gtest_filter=SRGBTextureTest.*Vulkan* Change-Id: I4a67e487dc82e2f57c8c87d4bcd8ef442b6fe220 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2359481 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Courtney Goeltzenleuchter f51e99fb 2020-10-13T11:38:28 Vulkan: Remove serial from RenderPassHelper We don't delete RenderPass's so no need to keep a serial. This simplifies things for coming threading code. Bug: b/169788986 Change-Id: I2577b17bc1f6af163725389589d7cd62d09eea13 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2468538 Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Courtney Goeltzenleuchter <courtneygo@google.com>
Charlie Lao df6b7298 2020-10-12T13:39:09 Vulkan: Use StoreOp_None_QCOM for read only depth stencil buffer For read only depth stencil buffers, there is no need to store depth or stencil value. But we can not use DontCare for storeOp because vulkan core spec says DontCare indicates data is undefined after this. VK_QCOM_render_pass_store_ops extension introduces a new store op that will leave data defined but skip the store. This CL utilize this if the extension is available. Bug: angleproject:5055 Change-Id: I104f3d01eb342a2d0cc900f342430e901bde1bff Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2462604 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Shahbaz Youssefi 68bd685a 2020-10-10T22:58:41 Reland: "4 Vulkan content defined CLs." Reland "Vulkan: Avoid content restore by detecting no-op stencil" This relands commit 243d0f899e443cd931c78aba7489382dff79edbb. Reland "Vulkan: Restore at the end of RP if write-after-invalidate" This relands commit e5d52ac3b9a00656acdd912ee8cd62dd14784075. Reland "Vulkan: Invalidate/restore depth/stencil separately." This relands commit 61fa0878964a796f6d3b3c13bc3a3849403ecdbd. Reland "Vulkan: Move content-defined tracking to ImageHelper" This relands commit 2392e6b34c0ddfbfd7b4c3cb67323ba463e11a57. Reason for revert: Caused crashes in Fuchsia x64 and on ARM. Reland fixes content defined for external images. Original CL message: Content-defined tracking was done in render targets prior to this change. This had multiple drawbacks: - When a framebuffer attachment is changed (including the first time it's set), it's unknown whether the contents of the attachment is defined. - Invalidate takes effect at the end of render pass, at which point the render target objects may be gone. Attachment ImageHelpers are however correctly tracked. This change moves content-defined tracking to the ImageHelper itself, and tracks it per subresource. ImageHelper::onWrite() now receives the subresource that is being written, and marks it as having defined content. A future optimization can make use of this change to ImageHelper::onWrite to track "dirty" subresources. This can lead to the removal of unnecessary barriers when same-kind writes are done on different subresources of the image. See http://anglebug.com/3347#c15 Bug: b/167275320 Bug: angleproject:4836 Bug: angleproject:5159 Change-Id: If5c1ae7152657fd7c94db7d55bea4fb9ddf835ba Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2464825 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Jamie Madill d6b1c17b 2020-10-10T14:29:15 Revert 4 Vulkan content defined CLs. Revert "Vulkan: Avoid content restore by detecting no-op stencil" This reverts commit 243d0f899e443cd931c78aba7489382dff79edbb. Revert "Vulkan: Restore at the end of RP if write-after-invalidate" This reverts commit e5d52ac3b9a00656acdd912ee8cd62dd14784075. Revert "Vulkan: Invalidate/restore depth/stencil separately." This reverts commit 61fa0878964a796f6d3b3c13bc3a3849403ecdbd. Revert "Vulkan: Move content-defined tracking to ImageHelper" This reverts commit 2392e6b34c0ddfbfd7b4c3cb67323ba463e11a57. Causes crashes in Fuchsia x64 and on ARM. Original CL message: Content-defined tracking was done in render targets prior to this change. This had multiple drawbacks: - When a framebuffer attachment is changed (including the first time it's set), it's unknown whether the contents of the attachment is defined. - Invalidate takes effect at the end of render pass, at which point the render target objects may be gone. Attachment ImageHelpers are however correctly tracked. This change moves content-defined tracking to the ImageHelper itself, and tracks it per subresource. ImageHelper::onWrite() now receives the subresource that is being written, and marks it as having defined content. A future optimization can make use of this change to ImageHelper::onWrite to track "dirty" subresources. This can lead to the removal of unnecessary barriers when same-kind writes are done on different subresources of the image. See http://anglebug.com/3347#c15 Bug: b/167275320 Bug: angleproject:4836 Bug: angleproject:5159 Change-Id: I93d9dfe973caa7ce70aefa46b5b7d04a8637efb3 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2464822 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Shahbaz Youssefi 243d0f89 2020-10-08T21:54:45 Vulkan: Avoid content restore by detecting no-op stencil Previously, as long as stencil was enabled, it was considered that it is also being modified. This caused stencil invalidate to be undone in a number of situations, such as: - glEnable(GL_STENCIL_TEST); // with func/ops default - glDrawArrays(); - glInvalidateFramebuffer([GL_STENCIL_ATTACHMENT]); - glClear(GL_DEPTH_BUFFER_BIT); - Close render pass In the above scenario, invalidation of stencil was undone at the end of render pass. In this change, the following cases are considered read-only stencil: - Func = GL_NEVER, stencilFail = GL_KEEP - Func = GL_ALWAYS, stencilPassDepth* = GL_KEEP - stencilFail = GL_KEEP, stencilPassDepth* = GL_KEEP Note that while the above scenario is fixed for no-op stencil, a similar issue persists if stencil was not no-op. The reason stencil invalidate is undone in that case is due to the fact that it's assumed any command after the invalidate call will be a draw call that outputs to stencil, but that is not the case with the glClear call in this example. Bug: angleproject:4836 Change-Id: Ie2ea2d52b7c8ee2394f5456773a7ef434e2b2b16 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2461465 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Ian Elliott <ianelliott@google.com>
Shahbaz Youssefi e5d52ac3 2020-10-08T14:26:22 Vulkan: Restore at the end of RP if write-after-invalidate If a depth/stencil attachment is invalidated, but subsequently drawn to in the same render pass, undo the invalidate when the render pass is closed. Adapted from https://chromium-review.googlesource.com/c/angle/angle/+/2386478. Bug: b/167275320 Bug: angleproject:4836 Change-Id: I17a35bfd692ddc403ceaa6ec44b5c4f16ff9eed6 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2461464 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Ian Elliott <ianelliott@google.com>
Shahbaz Youssefi 5081f89b 2020-10-02T01:15:37 Vulkan: Support invalidate of MSRTT attachments Invalidate was previously affecting only the storeOp of the color and depth/stencil attachments. With multisampled-render-to-texture attachments, the storeOp of the resolve attachments were not being affected. This change implements the latter, attempting to remove the attachment altogether if possible. With MSRTT depth/stencil buffers, this makes possible the ability to never write depth/stencil data to memory. Bug: angleproject:4836 Change-Id: I53599e2f4ed6c390dfd03bf226274f6f53f438bb Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2437506 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Shahbaz Youssefi 2392e6b3 2020-10-07T23:59:43 Vulkan: Move content-defined tracking to ImageHelper Content-defined tracking was done in render targets prior to this change. This had multiple drawbacks: - When a framebuffer attachment is changed (including the first time it's set), it's unknown whether the contents of the attachment is defined. - Invalidate takes effect at the end of render pass, at which point the render target objects may be gone. Attachment ImageHelpers are however correctly tracked. This change moves content-defined tracking to the ImageHelper itself, and tracks it per subresource. ImageHelper::onWrite() now receives the subresource that is being written, and marks it as having defined content. A future optimization can make use of this change to ImageHelper::onWrite to track "dirty" subresources. This can lead to the removal of unnecessary barriers when same-kind writes are done on different subresources of the image. See http://anglebug.com/3347#c15 Bug: b/167275320 Bug: angleproject:4836 Change-Id: Iabd1dace4eae9eb379453a9eb7ec6eafc9db1aef Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2462036 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Ian Elliott <ianelliott@google.com>
Shahbaz Youssefi 887b1346 2020-10-02T01:12:01 Vulkan: Add resolve/unresolve counters With this change, render-pass-related counters are calculated at render pass creation time and stored alongside the render pass handle (and serial) in the render pass cache. On every use, the render pass' counters are accumulated over the global counters. Additionally, this change adds MSRTT resolve and unresolve counters to render pass counters. Bug: angleproject:4836 Change-Id: If15a789e5a7d66c7ea5a2315bc76fe045ce57491 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2444099 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Charlie Lao 77e3d0ae 2020-09-25T14:12:04 Vulkan: Defer the depthStencil buffer layout change to endRenderPass Depth stencil layout may change while we build the render pass, depending on the read/write access been made. Right now we are always inserting a layout change barrier at the start of render pass. Later on when the read/write property changes, we insert another layout change barrier. Similarly, we maintain the attachmentOps and RenderPassDesc::mPackedColorAttachmentRangeAndDSAccess as we changes read/write access. This makes code quite commplicated. This CL moves mReadOnlyDepthStencilMode from FramebufferVK to CommandBufferHelper object and we only maintain that boolean while we updating the read/write access. Then at the end of render pass or when depthStencil image is deleted, we update attachmentOps and mRenderPassDesc and layout transition all at once and only done once. This simplifies the read only depth stencil mode implementation a lot. Bug: b/168953278 Change-Id: Ie263b4526c82a9858e5d1f141ea58f499187a3ca Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2432075 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Charlie Lao 86ca5d2b 2020-10-01T11:56:05 Vulkan: Add plumbing to render pass when ImageHelper gets deleted ImageHelper object is not refcounted and garbage collected and endRenderPass call is deferred until next render pass starts. This caused a situation that an ImageHelper object gets deleted while still referenced in the open render pass. This CL make sure that we call into all shared context's open renderpass when an image goes away so that they can take appropriate action for this. Bug: b/169618408 Change-Id: I5075e805980084db82ca3e699462272eee5d2d59 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2443571 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Charlie Lao <cclao@google.com>
Shahbaz Youssefi c5494728 2020-10-02T00:55:28 Vulkan: Free up 2 bits in PackedAttachmentOpsDesc These bits will be used to aid in invalidation of multisampled-render-to-texture attachments. Bug: angleproject:4836 Change-Id: Ib2b438386f8cd8c057bc0ef16144b9d2ddbc1594 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2444097 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Courtney Goeltzenleuchter 34f66126 2020-09-10T15:59:22 Vulkan: Check that its okay to add commands It can be hard to tell sometimes when the mRenderPassCommands or mOutSideRenderPassCommands command buffers have changed and there have been some issues with code that locally caches a pointer to a commandBuffer that then becomes invalid. This change adds checking so that if a command is being added to a commandBuffer that's been closed (e.g. submitted for processing) then we hit an assert. Bug: b/168144059 Change-Id: If5d37c462e3bcb51f6ec2ca44c27a2fad4e57c19 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2405812 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Courtney Goeltzenleuchter <courtneygo@google.com>
Shahbaz Youssefi 43163491 2020-09-22T11:45:06 Vulkan: Unresolve depth/stencil MSRTT attachments Using the same shader that unresolves color, this change allows depth/stencil to be unresolved as well. In turn, this allows the depth and stencil loadOp/storeOp of the implicit multisampled image associated with a multisampled-render-to-texture renderbuffer to be set to DONT_CARE. Stencil unresolve depends on VK_EXT_shader_stencil_export. In the absence of this extension, the stencil aspect is not unresolved and must continue to use loadOp=LOAD and storeOp=STORE. This is not ideal, but the expected use-case of depth/stencil MSRTT renderbuffers is that they get invalidated, so that load and store wouldn't happen in practice. Bug: angleproject:4836 Change-Id: I9939d1e15e10fa8ed285acdd6fe6edb42c59054f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2427049 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Tim Van Patten 2663e601 2020-09-24T18:28:31 Vulkan: Dynamically grow descriptor pool sizes Initial testing using benchmarks shows that the majority of the descriptor pools allocate fewer than 32 descriptor sets worth of descriptors. This CL reduces the initial size of each pool from 128 to 32 to reduce memory consumption. Additionally, when a pool is exhausted and a new one is created, the size of the pool doubles each time, up to a max of 512 descriptor sets worth of descriptors. This allows us to aggressively increase the size of the pools that appear to be very hot and decrease the total number of pools created. Bug: angleproject:5067 Test: CQ Change-Id: I190059cf04134902d6251d475dd908c1cbb82b58 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2430193 Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Tim Van Patten <timvp@google.com>
Charlie Lao d2d9e682 2020-09-15T16:06:42 Vulkan: Use DepthStencilReadOnly when it is read only. We are tracking depth and stencil read or write during the renderpass. We can use that to switch to DepthStencilReadOnly layout if both depth and stencil are not writing. This allows drivers to optimize out the storeOp for the renderpass. Bug: b/168953278 Change-Id: Id82e06b4bae1ae8c83d880bb5e58accfa61f8191 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2411336 Commit-Queue: Charlie Lao <cclao@google.com> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill 68a5baeb 2020-09-23T22:13:03 Revert "Vulkan: Implement a SharedResourceUse pool" This reverts commit de335c16855f11d1f0a6f0b37bee30c8a09a6c1d. Reason for revert: Might actually regress CPU overhead perf. Unsure but it's possible the reported perf improvement was due to variance. Original change's description: > Vulkan: Implement a SharedResourceUse pool > > When adding a Resource to the ResourceUseList of ContextVk > we constructed a new SharedResourceUse object for tracking > and update of the Resource's Serial. We would then delete > it after releasing the resource. This incurs repeated > memory operation costs. > > Instead we now allocate a pool of SharedResourceUse objects > and acquire and release from this pool as needed. > > VTune profile of the Manhattan 30 offscreen benchmark > shows the CPU occupancy of bufferRead decrease from an > average of 0.9% -> 0.6% and imageRead decreases from > an average of 0.4% -> 0.3%. The bottleneck for both > these methods is the retain() method that leverages > the new SharedResourceUse pool. > > Bug: angleproject:4950 > Change-Id: Ib4f67c6f101d4b2de118014546e6cc14ad108703 > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2396597 > Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> > Reviewed-by: Jamie Madill <jmadill@chromium.org> > Commit-Queue: Mohan Maiya <m.maiya@samsung.com> TBR=syoussefi@chromium.org,jmadill@chromium.org,m.maiya@samsung.com # Not skipping CQ checks because original CL landed > 1 day ago. Bug: angleproject:4950 Change-Id: I40081551c3db67d6e55182fea40119946ed16ac3 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2426479 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Tim Van Patten ed899835 2020-09-11T21:21:55 Vulkan: Allocate descriptor pools with layouts Descriptor set layouts and pools are very tightly coupled, since their binding types and counts must match to ensure the number of available descriptor sets within a pool remains accurate. To enforce this, the descriptor pools will now keep a copy of the VkDescriptorSetLayout that the pool was created for, which is verified when a descriptor set is allocated from the pool. If the handles don't match, an ASSERT() will fire. Bug: angleproject:5033 Test: CQ Change-Id: I4faf82c24f31052e57b656c968788bb0c131b619 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2407282 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Courtney Goeltzenleuchter <courtneygo@google.com> Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Tim Van Patten <timvp@google.com>
Ian Elliott a7e03ed7 2020-09-21T14:56:00 Vulkan: Further refine invalidate for depth/stencil Bug: angleproject:5079 Change-Id: Idc732b1e6729b2776d66c63c3ae2bd94e11bdbb5 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2422684 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Ian Elliott <ianelliott@google.com>
Ian Elliott 7b7e52fa 2020-09-21T13:17:25 Vulkan: Fix copy-paste error in hasCopyImageView A previous CL had a copy-and-paste error in hasCopyImageView(). It was calling getFetchImageView().valid() instead of getCopyImageView().valid(). Bug: b/161993151 Change-Id: I40335ad51585735e9d68781557693ede67096e7d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2422085 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Ian Elliott <ianelliott@google.com> Commit-Queue: Ian Elliott <ianelliott@google.com>
Mohan Maiya de335c16 2020-09-14T12:04:20 Vulkan: Implement a SharedResourceUse pool When adding a Resource to the ResourceUseList of ContextVk we constructed a new SharedResourceUse object for tracking and update of the Resource's Serial. We would then delete it after releasing the resource. This incurs repeated memory operation costs. Instead we now allocate a pool of SharedResourceUse objects and acquire and release from this pool as needed. VTune profile of the Manhattan 30 offscreen benchmark shows the CPU occupancy of bufferRead decrease from an average of 0.9% -> 0.6% and imageRead decreases from an average of 0.4% -> 0.3%. The bottleneck for both these methods is the retain() method that leverages the new SharedResourceUse pool. Bug: angleproject:4950 Change-Id: Ib4f67c6f101d4b2de118014546e6cc14ad108703 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2396597 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Mohan Maiya <m.maiya@samsung.com>
Jamie Madill 357caadb 2020-09-16T21:44:56 Vulkan: Optimize Attribute Change Perf (2/5) This patch series optimizes programs that use the pattern: for (;;) { glVertexAttribPointer(...) glDraw(...) } Change 2: Micro-optimize XFB resume CPU overhead. We don't need to set resume on every new command buffer. We only need to set the dirty bit when we have an unexpected pause. In total the patch series reduces test iteration time by 25%. Test: DrawCallPerfBenchmark.Run/vulkan_attrib_change Bug: angleproject:5045 Bug: b/168493024 Change-Id: I8f6c68ff0513be4f405276e395d80bc1a185a061 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2409174 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 37457d08 2020-09-15T14:38:53 Vulkan: Support MSRTT color renderbuffers Color renderbuffers are similar to multisampled-render-to-texture textures, but much simpler. The same mechanism is used to implement them. Bug: angleproject:4836 Change-Id: I298529c9fd1b03e78b1e37cdbe595e66166ee130 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2412847 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com>
Tim Van Patten f12e4123 2020-08-25T12:01:12 Vulkan: Match descriptor pool sizes to descriptor set layouts When a descriptor pool is created, a list of descriptor types and counts are given to vkCreateDescriptorPool(). Later, when allocating a descriptor set from the pool, we pass along a descriptor set layout to vkAllocateDescriptorSets() which is used to determine how many of each type of descriptor (i.e. binding) to allocate from the pool. In order for our "free descriptor set" counts to be accurate for each pool, the descriptor pools need to be created with descriptor counts that match the descriptor set layout binding counts. This change fixes a bug where the descriptor set layouts were created with more bindings than the descriptor pool sizes, causing the "free descriptor set" count to be inaccurate, leading to allocating too many descriptor sets from a pool. Bug: angleproject:3570 Test: VulkanDescriptorSetTest Change-Id: I660bf02d29a1291391fb15f39e6479bf348d0f83 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2391114 Commit-Queue: Tim Van Patten <timvp@google.com> Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>