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

Add an API to reserve a scene #667

Open
PoignardAzur opened this issue Aug 17, 2024 · 2 comments
Open

Add an API to reserve a scene #667

PoignardAzur opened this issue Aug 17, 2024 · 2 comments

Comments

@PoignardAzur
Copy link
Contributor

Vello should provide a SceneMetrics type, which could be returned from a Scene; multiple SceneMetrics could be added together.

Scene should have a new Scene::reserve(metrics) constructor taking a SceneMetrics value.

This could be useful for consumers who want to stitch a large amount of pre-existing scenes together in one pass. The consumer would scan over the scene metrics, reserve one giant scene, and then run a second pass to add the sub-scenes to it.

impl Scene {
  fn metrics(&self) -> SceneMetrics;

  fn reserve(metrics: &SceneMetrics) -> Self;
}

impl SceneMetrics {
  fn add(&self, other: &SceneMetrics) -> SceneMetrics;
}
@PoignardAzur PoignardAzur changed the title Add ways to reserve a scene Add an API to reserve a scene Aug 17, 2024
@DJMcNab
Copy link
Member

DJMcNab commented Aug 19, 2024

I think this would be a useful API to have, although I don't think it's a high priority.

In most cases, you will be rendering more than one frame, and so retaining the giant scene between frames is probably better anyway. Maybe my intuition about the total memory usage of a scene is off, but I expect it to be relatively small?

@PoignardAzur
Copy link
Contributor Author

In most cases, you will be rendering more than one frame, and so retaining the giant scene between frames is probably better anyway.

I disagree it's a better idea.

Forgetting to reset scenes between frames is already a common footgun. The advantage of a reserve-like API is that it lets you write APIs in a more functional style, where they return Scene instead of taking a mutable reference to them.

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

No branches or pull requests

2 participants