Texture Streaming#949
Open
bjornbytes wants to merge 5 commits into
Open
Conversation
- Add stream flag to newTexture/newModel. These will load the texture asynchronously on a separate GPU queue when possible, avoiding interrupting the rendering work happening on the main queue. - Add Texture/Model:isReady to check if the asynchronous transfer is complete and the texture is ready to use. It is an error to use a Texture before it's ready. - Vulkan details: - core/gpu texture creation takes a CPU pointer instead of GPU buffer - Texture upload uses VK_EXT_host_image_copy when available/efficient. - Otherwise, falls back to separate transfer queue when available. - Otherwise, falls back to doing the transfer on the graphics queue. Unclear if this is worth it or a good idea, but it sure is cool! Main reason to do it is that WebGPU really wants to take a host pointer for texture data.
Contributor
|
Does this pull the textures off disk asynchronously, too, or is it just the GPU upload that's asynchronous? |
Owner
Author
|
This change just affects the GPU upload. You can wrap texture creation in a task too: lovr.task.start(function()
texture = lovr.graphics.newTexture('file', { stream = true })
end)This gets pretty much all the overhead off of the main CPU thread / GPU queue, including the file read, image decode, GPU memory allocation, and GPU transfer. |
Owner
Author
|
Performance story here is a little more muddled than I hoped
If I was thinking about whether this can/should be merged, the story might be like:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
streamflag tolovr.graphics.newTexture/newModel. This will load the texture(s) asynchronously on a separate GPU queue when possible, avoiding interrupting the rendering work happening on the main queue.Texture/Model:isReadyto check if the asynchronous transfer is complete and the texture is ready to use. It is an error to use a Texture before it's ready.Model:isReadyto see if all of its textures are ready, or you can check individual textures and draw the ready ones withPass:drawPartto do a progressive per-mesh load.VK_EXT_host_image_copywhen available/optimal (for all textures).Main "reason" to do it is that WebGPU really wants to take a CPU pointer for texture data.
Still unclear if this is worth it or a good idea, but it sure is cool!