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

More efficient Buffer and Texture updates #508

Merged
merged 13 commits into from
Apr 19, 2023
Merged

More efficient Buffer and Texture updates #508

merged 13 commits into from
Apr 19, 2023

Conversation

almarklein
Copy link
Member

@almarklein almarklein commented Apr 14, 2023

Closes #321

Todo

  • Introduce a registry that is aware of all buffers and textures, and which ones need an update (uses weakrefs).
  • Make the renderer use that instead of checking all resources whether they need to be synced.
  • Removed a bit of wgpu-specific logic from lights.py
  • Updated the list in Logic in materials is based on details about the wgpu renderer #272 along the way.
  • Removed a print-call from the fly controller.

How it now works

(also added this to the code in a comment).

  • When a resource is first created, it's _wgpu_object attribute is None
    and its _wgpu_flags is unset.
  • When the resource is actually being used somewhere, it will end up
    in the logic that creates a pipeline object (e.g. in _pipeline.py), which
    sets the appropriate usage flags (because that code knows how the resource
    is used) and then uses ensure_wgpu_object to create the object.
  • Resources that need to be synced are tracked in the resource_registry,
    but only go into it when they have their _wgpu_object set (i.e. when
    the resource actually exists on the GPU).
  • Right before the renderer performs a draw, it queries the registry
    and calls update_resource on each.

This PR basically makes the above work, and then removes the old system (which required updates more spread out over the code).

@almarklein almarklein marked this pull request as ready for review April 18, 2023 22:16
@almarklein almarklein requested a review from Korijn as a code owner April 18, 2023 22:16
@almarklein
Copy link
Member Author

almarklein commented Apr 18, 2023

About done. Two validation examples fail. Will look into that, but otherwise this is good for review.

@Korijn Korijn enabled auto-merge (squash) April 19, 2023 21:32
@Korijn Korijn merged commit b5c9e94 into main Apr 19, 2023
@Korijn Korijn deleted the buf-tex-updates branch April 19, 2023 21:39
@almarklein almarklein mentioned this pull request Apr 21, 2023
1 task
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.

Manage updates to buffers and textures more efficiently
2 participants