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

[Merged by Bors] - Shader Processor: process imported shader #3290

Closed

Conversation

mockersf
Copy link
Member

@mockersf mockersf commented Dec 10, 2021

Objective

  • I want to be able to use #ifdef and other processor directives in an imported shader

Solution

  • Process imported shader strings

@github-actions github-actions bot added the S-Needs-Triage This issue needs to be labelled label Dec 10, 2021
@mockersf mockersf added A-Rendering Drawing game state to the screen C-Feature A new feature, making something new possible and removed S-Needs-Triage This issue needs to be labelled labels Dec 10, 2021
@cart cart added this to the Bevy 0.6 milestone Dec 10, 2021
Copy link
Member

@cart cart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we actually need to loop here / reprocess the same lines over and over. Once a line has been processed, it should never needs to be re-processed. I think we could make this more efficient by just recursively running the shader processor on import text prior to appending it to the final output.

crates/bevy_render/src/render_resource/shader.rs Outdated Show resolved Hide resolved
@mockersf
Copy link
Member Author

mockersf commented Dec 21, 2021

I don't think we actually need to loop here

It's to have the possibility of nested imports. It's probably not necessary to loop over everything until nothing changed, but It was funnier to write that way and I don't think it should take too long to process text...
I added a test for nested import.

@mockersf mockersf force-pushed the shader-processor-on-imports branch from d98872c to 71447f9 Compare December 21, 2021 23:40
@mockersf
Copy link
Member Author

no more loop...

@mockersf mockersf changed the title Shader Processor: loop over shader until everything has been processed Shader Processor: process imported shader Dec 21, 2021
@cart
Copy link
Member

cart commented Dec 22, 2021

Awesome. Thats exactly what I was thinking of :)

@cart
Copy link
Member

cart commented Dec 22, 2021

bors r+

bors bot pushed a commit that referenced this pull request Dec 22, 2021
# Objective

- I want to be able to use `#ifdef` and other processor directives in an imported shader

## Solution

- Process imported shader strings


Co-authored-by: François <[email protected]>
@bors bors bot changed the title Shader Processor: process imported shader [Merged by Bors] - Shader Processor: process imported shader Dec 22, 2021
@bors bors bot closed this Dec 22, 2021
bors bot pushed a commit that referenced this pull request Dec 22, 2021
# Objective

- 3d examples fail to run in webgl2 because of unsupported texture formats or texture too large

## Solution

- switch to supported formats if a feature is enabled. I choose a feature instead of a build target to not conflict with a potential webgpu support

Very inspired by superdump@6813b2e, and need #3290 to work.

I named the feature `webgl2`, but it's only needed if one want to use PBR in webgl2. Examples using only 2D already work.

Co-authored-by: François <[email protected]>
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-Feature A new feature, making something new possible
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants