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 549 forks source link

WIP remove framebuffer object #3560

Closed kvark closed 3 years ago

kvark commented 3 years ago

Closes #3552

History and motivation

In the new swapchain model, which became the one and only model as of #3327, users are not able to pre-create framebuffers for every swapchain image in advance. We settled on the requirement for the user to create a framebuffer for every frame they render, and then remove it after presenting. This didn't fit into the low-level API too well, and Vulkan backend had to implement the smarts of tracking the use of swapchain-related framebuffers. See more detail by @thorjelly in #3552.

Status

This PR removes framebuffer as a concept, leaving it to be an implementation detail of the backends. Currently it's done for HAL, Vulkan, and Metal. Biggest concerns:

Analysis

Effect on the API: great, simpler API. Especially the new RenderAttachmentInfo struct. We already had a slight divergence with Vulkan on the clear values in begin_render_pass, and this PR makes it look very solid and concise.

Effect on the user: great, less things to manage, especially the fact that we don't have "special" framebuffers versus the regular ones any more.

Effect on performance:

Effect on the code complexity:

Finally, this helps streamlining the path from wgpu to the hardware, as WebGPU doesn't have framebuffers either.

kvark commented 3 years ago

Closing in favor of #3571