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

Non-uniform Indexing (Bindless) Textures Validation Failure #6952

Closed
cryscan opened this issue Dec 14, 2022 · 0 comments
Closed

Non-uniform Indexing (Bindless) Textures Validation Failure #6952

cryscan opened this issue Dec 14, 2022 · 0 comments
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior

Comments

@cryscan
Copy link
Contributor

cryscan commented Dec 14, 2022

Bevy version

0.9

AdapterInfo { name: "NVIDIA GeForce MX150", vendor: 4318, device: 7442, device_type: DiscreteGpu, driver: "NVIDIA", driver_info: "470.161.03", backend: Vulkan }

What went wrong

When using non-uniform indexing (bindless) textures in debug mode, shader validation fails and output

2022-12-06T20:06:19.458496Z ERROR bevy_render::render_resource::pipeline_cache: failed to process shader: 
error: Function [68] 'retreive_surface' is invalid
     ┌─ wgsl:1333:1
     │  
1333 │ ╭ fn retreive_surface(material_index: u32, uv: vec2<f32>) -> Surface {
1334 │ │     var surface: Surface;
1335 │ │     let material = material_buffer[material_index];
1336 │ │ 
     · │
1340 │ │         surface.base_color *= textureSampleLevel(textures[id], samplers[id], uv, 0.0);
     │ │                                                  ^^^^^^^^^^^^ naga::Expression [74]
     · │
1363 │ │ 
1364 │ │     return surface;
     │ ╰───────────────────^ naga::Function [68]
     │  
     = Expression [74] is invalid
     = Shader requires capability SAMPLED_TEXTURE_AND_STORAGE_BUFFER_ARRAY_NON_UNIFORM_INDEXING

This error does not happen in release mode.

Additional information

According to this issue and code here, bevy seems to validate the shader with a limited set of constant capabilities. Maybe add the SAMPLED_TEXTURE_AND_STORAGE_BUFFER_ARRAY_NON_UNIFORM_INDEXING capability here could solve the problem?

@cryscan cryscan added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Dec 14, 2022
@cryscan cryscan changed the title Non-uniform Indexing (bindless) textures Non-uniform Indexing (Bindless) Textures Validation Failure Dec 14, 2022
@james7132 james7132 added A-Rendering Drawing game state to the screen and removed S-Needs-Triage This issue needs to be labelled labels Jan 9, 2023
@bors bors bot closed this as completed in 6b38863 Jan 26, 2023
ItsDoot pushed a commit to ItsDoot/bevy that referenced this issue Feb 1, 2023
# Objective

Fixes bevyengine#6952 

## Solution

- Request WGPU capabilities `SAMPLED_TEXTURE_AND_STORAGE_BUFFER_ARRAY_NON_UNIFORM_INDEXING`, `SAMPLER_NON_UNIFORM_INDEXING` and `UNIFORM_BUFFER_AND_STORAGE_TEXTURE_ARRAY_NON_UNIFORM_INDEXING` when corresponding features are enabled.
- Add an example (`shaders/texture_binding_array`) illustrating (and testing) the use of non-uniform indexed textures and samplers.

![image](https://user-images.githubusercontent.com/16053640/209448310-defa4eae-6bcb-460d-9b3d-a3d2fad4316c.png)

## Changelog

- Added new capabilities for shader validation.
- Added example `shaders/texture_binding_array`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants