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

Shaderdef values break shader imports #6996

Closed
aevyrie opened this issue Dec 21, 2022 · 3 comments
Closed

Shaderdef values break shader imports #6996

aevyrie opened this issue Dec 21, 2022 · 3 comments
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide
Milestone

Comments

@aevyrie
Copy link
Member

aevyrie commented Dec 21, 2022

Bevy version

All commits after d44e865

What you did

Followed migration instructions in the PR.

What went wrong

Shader error with:

2022-12-21T07:05:18.759671Z ERROR bevy_render::render_resource::pipeline_cache: failed to process shader:
error: expected constant, found '#'
   ┌─ wgsl:44:49
   │
44 │     directional_lights: array<DirectionalLight, #{MAX_DIRECTIONAL_LIGHTS}u>,
   │                                                 ^ expected constant

Additional information

It appears that PR #5900 breaks imports, because those imports now depend on shaderdefs which users may not have available. In my case, I was attempting to import:

#import bevy_pbr::mesh_view_types

so I could use the View struct, which was giving me the error posted above. The problem was that the import was bringing structs into scope that referred to the MAX_DIRECTIONAL_LIGHTS shaderdef, which my shader did not use. Specifically, it was erroring when it reached struct Lights:

struct Lights {
    // NOTE: this array size must be kept in sync with the constants defined in bevy_pbr/src/render/light.rs
    directional_lights: array<DirectionalLight, #{MAX_DIRECTIONAL_LIGHTS}u>,
@aevyrie aevyrie added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Dec 21, 2022
@aevyrie aevyrie changed the title Shaderdef Breaking Change Shaderdef values break shader imports Dec 21, 2022
@aevyrie aevyrie added A-Rendering Drawing game state to the screen M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide and removed S-Needs-Triage This issue needs to be labelled labels Dec 21, 2022
@aevyrie aevyrie added this to the 0.10 milestone Dec 21, 2022
@aevyrie
Copy link
Member Author

aevyrie commented Dec 21, 2022

I've added this to the 0.10 milestone to ensure at minimum this breaking change is documented prior to release, as the PR does not mention this in the migration guide.

@torsteingrindvik
Copy link
Contributor

torsteingrindvik commented Dec 21, 2022

Duplicate?
#6799

EDIT: Ping @mockersf

@aevyrie
Copy link
Member Author

aevyrie commented Dec 21, 2022

Yup, this is a duplicate, I was searching for shaderdefs and didn't find it.

bors bot pushed a commit that referenced this issue Jan 30, 2023
# Objective

- Fix `post_processing` and `shader_prepass` examples as they fail when compiling shaders due to missing shader defs
- Fixes #6799
- Fixes #6996
- Fixes #7375 
- Supercedes #6997
- Supercedes #7380 

## Solution

- The prepass was broken due to a missing `MAX_CASCADES_PER_LIGHT` shader def. Add it.
- The shader used in the `post_processing` example is applied to a 2D mesh, so use the correct mesh2d_view_bindings shader import.
bors bot pushed a commit that referenced this issue Jan 30, 2023
# Objective

- Fix `post_processing` and `shader_prepass` examples as they fail when compiling shaders due to missing shader defs
- Fixes #6799
- Fixes #6996
- Fixes #7375 
- Supercedes #6997
- Supercedes #7380 

## Solution

- The prepass was broken due to a missing `MAX_CASCADES_PER_LIGHT` shader def. Add it.
- The shader used in the `post_processing` example is applied to a 2D mesh, so use the correct mesh2d_view_bindings shader import.
bors bot pushed a commit that referenced this issue Jan 30, 2023
# Objective

- Fix `post_processing` and `shader_prepass` examples as they fail when compiling shaders due to missing shader defs
- Fixes #6799
- Fixes #6996
- Fixes #7375 
- Supercedes #6997
- Supercedes #7380 

## Solution

- The prepass was broken due to a missing `MAX_CASCADES_PER_LIGHT` shader def. Add it.
- The shader used in the `post_processing` example is applied to a 2D mesh, so use the correct mesh2d_view_bindings shader import.
bors bot pushed a commit that referenced this issue Jan 30, 2023
# Objective

- Fix `post_processing` and `shader_prepass` examples as they fail when compiling shaders due to missing shader defs
- Fixes #6799
- Fixes #6996
- Fixes #7375 
- Supercedes #6997
- Supercedes #7380 

## Solution

- The prepass was broken due to a missing `MAX_CASCADES_PER_LIGHT` shader def. Add it.
- The shader used in the `post_processing` example is applied to a 2D mesh, so use the correct mesh2d_view_bindings shader import.
bors bot pushed a commit that referenced this issue Jan 30, 2023
# Objective

- Fix `post_processing` and `shader_prepass` examples as they fail when compiling shaders due to missing shader defs
- Fixes #6799
- Fixes #6996
- Fixes #7375 
- Supercedes #6997
- Supercedes #7380 

## Solution

- The prepass was broken due to a missing `MAX_CASCADES_PER_LIGHT` shader def. Add it.
- The shader used in the `post_processing` example is applied to a 2D mesh, so use the correct mesh2d_view_bindings shader import.
bors bot pushed a commit that referenced this issue Jan 30, 2023
# Objective

- Fix `post_processing` and `shader_prepass` examples as they fail when compiling shaders due to missing shader defs
- Fixes #6799
- Fixes #6996
- Fixes #7375 
- Supercedes #6997
- Supercedes #7380 

## Solution

- The prepass was broken due to a missing `MAX_CASCADES_PER_LIGHT` shader def. Add it.
- The shader used in the `post_processing` example is applied to a 2D mesh, so use the correct mesh2d_view_bindings shader import.
ItsDoot pushed a commit to ItsDoot/bevy that referenced this issue Feb 1, 2023
# Objective

- Fix `post_processing` and `shader_prepass` examples as they fail when compiling shaders due to missing shader defs
- Fixes bevyengine#6799
- Fixes bevyengine#6996
- Fixes bevyengine#7375 
- Supercedes bevyengine#6997
- Supercedes bevyengine#7380 

## Solution

- The prepass was broken due to a missing `MAX_CASCADES_PER_LIGHT` shader def. Add it.
- The shader used in the `post_processing` example is applied to a 2D mesh, so use the correct mesh2d_view_bindings shader import.
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 M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide
Projects
None yet
3 participants