Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[meta] Vulkan problems #1112

Closed
kvark opened this issue Dec 28, 2016 · 3 comments
Closed

[meta] Vulkan problems #1112

kvark opened this issue Dec 28, 2016 · 3 comments

Comments

@kvark
Copy link
Member

kvark commented Dec 28, 2016

Here is a list of problems that we need to solve in order to have a viable Vulkan backend:

  1. Resource states. When recording commands, we need to know the initial state of each resource. This can't be automatically tracked, since, when recording, we don't know the order of submission.
    • Solution A: define a "default" state, which a resource is expected to be between command buffer executions, and enforce the relevant transitions at the end of recording.
  2. Command pools. A pool is externally synchronized, so we can't allow two command buffers being recorded in parallel if they share the same pool.
  3. Command buffer fences. Any CPU-accessible resource can't be modified while GPU is working on it. Command buffers are there too. We should keep extra command buffers somewhere and re-cycle the ones that finished execution.
    • Solution A: when an encoder is submitted, we can have a special flag saying that it should be reset, in which case the inner command buffer is replaced with another one from the pool.
  4. Initial resource data. A typical user task is to load a texture and use it as an SRV, never modifying it. Out model was built to allow that resource to be loaded asynchronously from multiple threads, on the backends that support it at least. However, in Vulkan we'd have to create a staging resource first, fill it up, and then use a transfer queue operation to copy the contents into the target (DEVICE_LOCAL) resource. Hence, we'd need an execution context for such operation.
    • Solution A: remove the corresponding API, encourage to use Usage::Upload directly by the user
    • Solution B: keep the API but return an error on the backends that don't support it. Apparently, only Metal and D3D11 support it natively. We can have a capability flag to indicate that.
@Bastacyclop
Copy link
Contributor

What if explicitly creating a memory::Usage::Upload resource and submitting a copy command was the 'official' way to upload data into a memory::Usage::Data resource ? It does complicates things a bit for the user but still feels intuitive. It makes the user aware of previously implicit copies (at least I think there are ?) and makes him want to directly load data into the upload resource to avoid an additionnal copy, which is good ? I don't know if all the backends would be able to efficiently support this workflow though.

@kvark
Copy link
Member Author

kvark commented Dec 28, 2016

@Bastacyclop yes, that would be a valid course of action. All the backends would support it just fine. The only downside is - user inconvenience, and it's not like we can do anything about it on Vulkan...

@msiglreith
Copy link
Contributor

Superseeded by our low level API #1102 and vulkan portability issue #1354

adamnemecek pushed a commit to adamnemecek/gfx that referenced this issue Apr 1, 2021
1112: Expose adapter specific formats features via Extension, support for storage read+write r=kvark a=Wumpf

**Connections**
Draft until gfx-rs#3559 landed (then update and comment two lines in)
New & improved replacement for gfx-rs#1109

PR for wgpu-rs to be opened once there's some confidence that this is that it should look like. [Preview](https://github.com/gfx-rs/wgpu-rs/compare/master...Wumpf:texture-format-feature-query?expand=1)

**Description**
Adapter exposes now per texture format specific features. Feature struct defined as allowed usages + flags. Flags describe only storage texture usage so far.

Query not used for validation unless `TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES` feature is enabled on a device. Otherwise uses hardcoded feature set guaranteed by webgpu.
Storage read/write binding can then be used as a consequence (storage atomic has no effect yet).

**Testing**
Manual testing with my fluid sim project through wgpu-rs which covers storage r/w for a few different formats and storage in general for formats that don't support this usage by default at all.
Ran tests and a couple of samples to see if anything broke with the feature disabled.

Co-authored-by: Andreas Reich <r_andreas2@web.de>
adamnemecek pushed a commit to adamnemecek/gfx that referenced this issue Apr 1, 2021
1140: Enable storage read/write format feature r=kvark a=Wumpf

**Connections**
gfx-rs#1112

**Description**
Use `wgt::TextureFormatFeatureFlags::STORAGE_READ_WRITE` in `get_texture_format_features`.
This has been waiting for a gfx update which was enabled by @elartista 's workaround in gfx-rs#1136 \o/

Co-authored-by: Andreas Reich <r_andreas2@web.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants