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

Implement Descriptor Array Extension #711

Merged
merged 1 commit into from
Jun 11, 2020

Conversation

cwfitzgerald
Copy link
Member

@cwfitzgerald cwfitzgerald commented Jun 10, 2020

Connections

Blocked on gfx-rs/gfx#3269 and does some funky git overrides to get CI to return meaningful results what will be removed once that PR lands and is published.

Description

This PR implements the TEXTURE_BINDING_ARRAY native extension. This allows users to specify a uniform sized array of textures for use in shaders.

As a corollary, this PR rustifies the Bind Group and Bind Group Layout interface. Two main actions were taken when doing this:

  • Types that were able to be shared among wgt, wgc, and wgpu-rs were moved into wgt.
  • Types that had references to other wgpu-rs specific structures were duplicated into wgc with wgpu-rs structures replaced with the appropriate ID. Notes were added to the wgc types that they were duplicated directly from wgpu-rs.

From what I can tell, this resulted in a significant reduction in code complexity when dealing with bind groups, favoring strong types over runtime assertions.

Naga validation of arrays of textures was not implemented.

Documentation was added to extensions to help users understand what underlying tech was being relied on as well as the platforms it should be expected to work on. I think this pattern should be implemented across the board for extensions as it makes them much more user friendly to use.

Testing

There is an example included in the wgpu-rs PR which was used for testing this feature. It worked on DX12, Vulkan, and Metal (MSL > 2.0), as was expected.

Additionally the other examples were run and are still verified to run.

@cwfitzgerald cwfitzgerald requested a review from kvark June 10, 2020 05:48
Copy link
Member

@kvark kvark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is some impressive work!
I was worried that you mixed the binding model struct refactor into this extension PR, but the code appears to be much nicer now, and I'll be happy to have this extension supported.
Below is a few concerns and questions. Sorry about the annoying "don't match on a reference" notes! :)

wgpu-core/src/binding_model.rs Show resolved Hide resolved
@@ -135,32 +64,30 @@ pub struct BufferBinding {
pub size: wgt::BufferSize,
}

#[repr(C)]
/// Duplicated in wgpu-rs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's great that the doc comment is used, but it doesn't really explain what the structure is :)
Maybe lets turn it into a regular comment, or a //Note:?

pub layout: BindGroupLayoutId,
pub entries: *const BindGroupEntry,
pub entries_length: usize,
pub bindings: Vec<BindGroupEntry>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this be using a slice &'a []?

wgpu-core/src/binding_model.rs Show resolved Hide resolved
wgpu-core/src/conv.rs Show resolved Hide resolved
wgpu-core/src/validation.rs Outdated Show resolved Hide resolved
wgpu-core/src/validation.rs Outdated Show resolved Hide resolved
wgpu-types/src/lib.rs Show resolved Hide resolved
wgpu-types/src/lib.rs Outdated Show resolved Hide resolved
wgpu-types/src/lib.rs Show resolved Hide resolved
@cwfitzgerald
Copy link
Member Author

Everything should be fixed now. Still waiting on the publishing of the backends so I can fix up cargo deps and make CI pass, but other than that, we're all set. wgpu-rs pr coming very shortly

wgpu-core/src/binding_model.rs Outdated Show resolved Hide resolved
@cwfitzgerald
Copy link
Member Author

Alright, we should be all ready.

wgpu-core/src/binding_model.rs Outdated Show resolved Hide resolved
@cwfitzgerald
Copy link
Member Author

Yay!
bors r=kvark

@bors
Copy link
Contributor

bors bot commented Jun 11, 2020

@bors bors bot merged commit 64ae590 into gfx-rs:master Jun 11, 2020
@cwfitzgerald cwfitzgerald deleted the descriptor-arrays branch June 11, 2020 03:46
bors bot added a commit to gfx-rs/wgpu-rs that referenced this pull request Jun 11, 2020
360: Implement TEXTURE_BINDING_ARRAY extension r=kvark a=cwfitzgerald

This extends gfx-rs/wgpu#711 into wgpu-rs.

Notable changes: 
- Added an example showing off both this extension and the future descriptor indexing extension.
- Changed the framework so there is a static function showing what extensions you need. This is provided by the trait,, which defaults to no extensions, so existing examples and new ones don't have to care about extensions.

Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
kvark pushed a commit to kvark/wgpu that referenced this pull request Jun 3, 2021
360: Implement TEXTURE_BINDING_ARRAY extension r=kvark a=cwfitzgerald

This extends gfx-rs#711 into wgpu-rs.

Notable changes: 
- Added an example showing off both this extension and the future descriptor indexing extension.
- Changed the framework so there is a static function showing what extensions you need. This is provided by the trait,, which defaults to no extensions, so existing examples and new ones don't have to care about extensions.

Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
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.

None yet

2 participants