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

Extend AsBindGroup macro with support for RenderAssetUsages #14047

Open
davids91 opened this issue Jun 27, 2024 · 0 comments
Open

Extend AsBindGroup macro with support for RenderAssetUsages #14047

davids91 opened this issue Jun 27, 2024 · 0 comments
Labels
C-Enhancement A new feature S-Needs-Triage This issue needs to be labelled

Comments

@davids91
Copy link

davids91 commented Jun 27, 2024

What problem does this solve or what need does it fill?

When having large amount of data used in a compute shader, which does not change frequently; It does not need to be uploaded to the GPU in every loop.

e.g.:

#[derive(Resource, Clone, AsBindGroup, TypePath, ExtractResource)]
#[type_path = "MyAmazingData"]
pub struct MyAmazingData {
    #[storage_texture(0, image_format = Rgba8Unorm, access = ReadWrite)]
    pub output_texture: Handle<Image>,

    #[uniform(1, visibility(compute))]
    pub frequently_changing_data: Vec3,

    #[storage(2,  visibility(compute), read_only)]
    pub(crate) large_data: Vec<u32>,
}

What solution would you like?

Extend the AsBindGroup macro with optional RenderAssetUsage attributes: render_usage(...) where the options render_world or cpu_world where the default value would be cpu_world.

#[derive(Resource, Clone, AsBindGroup, TypePath, ExtractResource)]
#[type_path = "MyAmazingData"]
pub struct MyAmazingData {
    #[storage_texture(0, image_format = Rgba8Unorm, access = ReadWrite)]
    pub output_texture: Handle<Image>,

    #[uniform(1, visibility(compute))]
    pub frequently_changing_data: Vec3,

    #[storage(2,  visibility(compute), read_only, render_usage(render_world))]
    pub(crate) large_data: Vec<u32>,
}

What alternative(s) have you considered?

I have looked everywhere to make this happen, and have not found any way to do this; The closest to a solution for this
was extending the concept described in #8440

Additional context

Here is a GPU profile for a voxel raytracer using bevy:
image
image

The actual rendering does not take up a significant amount of time, instead the voxel data is being copied in every frame to the GPU.
image

The function taking ~500ms in each loop is only calling as_bind_group, here

@davids91 davids91 added C-Enhancement A new feature S-Needs-Triage This issue needs to be labelled labels Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Enhancement A new feature S-Needs-Triage This issue needs to be labelled
Projects
None yet
Development

No branches or pull requests

1 participant