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

Burn the batch context with fire #751

Closed
kvark opened this issue May 22, 2015 · 4 comments
Closed

Burn the batch context with fire #751

kvark opened this issue May 22, 2015 · 4 comments

Comments

@kvark
Copy link
Member

kvark commented May 22, 2015

It can be used to save on mesh/program cloning (which have allocations!) when creating lots of batches. However, I'm convinced it brings more trouble than the benefit (#510, #464, #351). Besides, it can just be moved outside of gfx-rs crate.

The problem with the Context, outside of it just being another thing to consider or think about, is that it doesn't have a very safe interface. Thus, it could be fine to use inside another library as an implementation detail, but not fine to expose it to the user. I may end up moving it out and using it for gfx_scene, but I'll hesitate to do it until mesh/program cloning shows up in the profiler.

Let's burn this thing! We only really need a Batch trait and two kinds of batches: one with everything in it (batch::Full?), and another one with just the core components that have to be bound together (batch::Core). This is a breaking change supposedly for gfx-0.6

Objections? @csherratt @cmr @bjz

@milibopp
Copy link
Contributor

I guess then gfx-rs would be unopinionated about how to share a resource. How does this work at the moment? I understand that e.g. a mesh is only a handle to a buffer on the GPU. What are its ownership semantics and when does it free the underlying resource?

@kvark
Copy link
Member Author

kvark commented May 24, 2015

@aepsil0n resources are reference-counted now anyway (they were not when Context was introduced), so they are shared. The only thing Context was providing is allocation-free copying of batches.

Since the mesh just has attributes pointing to GPU buffers, these get logically freed when the mesh goes out of scope (assuming it's the unique holder). The actual release call is done upon Device::cleanup(), typically right after the buffers swap.

@ghost
Copy link

ghost commented May 25, 2015

This sounds good to me.

@kvark
Copy link
Member Author

kvark commented May 26, 2015

Fixed in #757

@kvark kvark closed this as completed May 26, 2015
adamnemecek pushed a commit to adamnemecek/gfx that referenced this issue Apr 1, 2021
751: Convert Extensions + Capabilities into Features r=kvark a=cwfitzgerald

**Connections**

Based on upcoming webgpu changes.

**Description**

Does what it says on the tin. The only notable change was classifying the AnisotropicFiltering extension as a WebGPU extension (per gpuweb/gpuweb#696, but no idea if that's the correct interpretation)

**Testing**

Will be tested by upcoming wgpu-rs PR.

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
Projects
None yet
Development

No branches or pull requests

2 participants