gfx-rs / gfx

[maintenance mode] A low-overhead Vulkan-like GPU API for Rust.
http://gfx-rs.github.io/
Apache License 2.0
5.35k stars 551 forks source link

[metal] provide size information to the shaders #3758

Closed kvark closed 3 years ago

kvark commented 3 years ago

Fixes #3757 Closes #3751

The only thing left here is re-binding on descriptor changes. Also need to test to see if it actually works...

kvark commented 3 years ago

After a few more fixes, I confirmed that this works, at least on Boids example.

kvark commented 3 years ago

With https://github.com/gfx-rs/naga/pull/858 and https://github.com/gfx-rs/naga/pull/850 (in an override), I can see the proper array length in the shadow example (to test graphics vs compute in boids). So the gfx-rs part works.

kvark commented 3 years ago

(copying from Matrix for posterity)

I thought about simplifying this, and the only idea I got is to skip the pipeline layout stage, and store a hashmap(group, binding) to buffer size in the command encoder state. This would potentially be a tiny bit slower, since hashmap lookups are slower than areay indexing, but unclear how much.

Another approach - make the contents of the sizes buffer dependent on pipeline layout only, and nothing else. Thix would avoid the need to re-map it to the pipeline, but would potentially have larger buffers with mire stages than necessary...

Neither is a clear win.

kvark commented 3 years ago

I tried the hashmap path, and it seems to work out pretty well, shaving off 50 LOC:

3 files changed, 47 insertions(+), 97 deletions(-)

kvark commented 3 years ago

let's take the risk, need to unblock wgpu post-landing review would be nice! bors r+

bors[bot] commented 3 years ago

Build succeeded: