Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

kvark
Copy link
Contributor

@kvark kvark commented Jun 13, 2020

Follow-up to #746 , see investigation in #514 (comment)
Closes #859

This is an alternative fix/evolution of RODS (problem described in #859) that came to mind, and I like it much more. Creating a view could be done by limiting the available usages (through this view) to only read from the texture. This means we no longer need additional GPURenderPassDescriptor fields, and we don't need to change GPUTextureBinding.

Specifying the read-only property at the view creation matches D3D12 API, where the user specifies D3D12_DSV_FLAGS. It also allows the implementation to avoid creating UAVs for viewing textures that support STORAGE usage if the user doesn't need to write to the storage (i.e. if they use "readonly-storage-texture" binding).

The spec is bare-bones here. I'll be happy to write it down in more detail once/if we agree about the direction here.


Preview | Diff

@Kangz
Copy link
Contributor

Kangz commented Jun 15, 2020

Thanks for putting this up, it looks much nicer than the previous solution. If I understand correctly, a depth-stencil view would use the following layout:

  • If readonly is false: VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL
  • If readonly is true: VK_IMAGE_LAYOUT_GENERAL or VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL depending on the Vulkan WG's answer.

I think it might be best to allow for future expansion where depth and stencil can independently be readonly. This could be done with GPUTextureAspect readOnlyAspects. WDYT?

@kainino0x
Copy link
Contributor

From meeting: unresolved: want to have benchmarks vs GENERAL layout

@kvark
Copy link
Contributor Author

kvark commented Jun 15, 2020

Update: I prototyped a solution suggested in KhronosGroup/Vulkan-Docs#1291 (comment), and it appears to work well. So the current spec has no issues, and we can keep it.

Having any kind of benchmarks of image layouts would still be very useful!

I also think it's worth keeping this PR open for discussion, albeit at lower priority than before. It's useful because it works better for D3D12.

@kainino0x
Copy link
Contributor

Very nice!

@kainino0x
Copy link
Contributor

kainino0x commented Jun 15, 2020

So I suppose we would also still ideally like:

  • benchmark or analysis of SHADER_READ_ONLY vs DEPTH_STENCIL_READ_ONLY for sampled depth/stencil textures that aren't used as attachments (as SHADER_READ_ONLY could theoretically be more optimal)
  • views that are read-only in either or both aspects for D3D12

AFAIU we already have the signals in WebGPU that would allow us to use DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL/DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL when a DS texture is used only as an attachment; is that right?
With an extension, we could allow sampling of the readonly aspect (but that seems low priority).

@Kangz
Copy link
Contributor

Kangz commented Jun 18, 2020

Thanks @kvark for raising this issue with on the Vulkan repo. If I understand correctly, there is no longer an issue for implementability on Vulkan because the following would work:

For bindgroup creation the VkImageLayout of a depth-stencil texture binding would be:

  • VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL for textures both renderable and sampleable.
  • VK_IMAGE_LAYOUT_SHADER_READONLY_OPTIMAL for only sampleable textures.

Then for vkCmdBeginRenderPass the VkImageLayout would be:

  • VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL if the pass is readonly (or the correct partially readonly layout when we support that in WebGPU).
  • VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL otherwise.

I don't really have concerns with for D3D12 DSV creation because IMHO there's few enough render passes in a frame that they can be created on demand. So I don't think we need this PR either. (and there's no need for benchmark! woot)

@kvark kvark changed the base branch from master to main June 23, 2020 13:14
@kvark kvark changed the title Read-only GPUTextureView [WIP] Read-only GPUTextureView Jul 2, 2020
@kvark kvark marked this pull request as draft September 15, 2020 14:13
@Kangz
Copy link
Contributor

Kangz commented Dec 22, 2021

I think that with the Vulkan issue fixed, this can be closed. We haven't had issue implementing readonly depth-stencil in Dawn either.

@Kangz Kangz closed this Dec 22, 2021
ben-clayton pushed a commit to ben-clayton/gpuweb that referenced this pull request Sep 6, 2022
…uweb#860)

* Add api,operation,command_buffer,render,state_tracking:* - Part I

This patch implements the first part of the operation test
api,operation,command_buffer,render,state_tracking:*:
- Setting index buffer states multiple times in different orders
  still keeps the correctness of each draw call.

* Small fixes

* Rebase to main

* Address reviewer's comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants