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

hotglsl ShaderType vs ShaderStage #990

Open
cstrode3 opened this issue Feb 10, 2025 · 1 comment
Open

hotglsl ShaderType vs ShaderStage #990

cstrode3 opened this issue Feb 10, 2025 · 1 comment

Comments

@cstrode3
Copy link

Hello, I wanna start by saying I'm probably wrong about this somehow, as I'm very new to nannou, and rust in general. So, sorry if I missed something obvious. Anyway, I was trying to run some of the example files with cargo, but I kept getting this error:

error[E0433]: failed to resolve: could not find `ShaderType` in `hotglsl`
   --> nannou_isf/src/pipeline.rs:419:31
    |
419 |             let ty = hotglsl::ShaderType::Fragment;
    |                               ^^^^^^^^^^ could not find `ShaderType` in `hotglsl`

For more information about this error, try `rustc --explain E0433`.
error: could not compile `nannou_isf` (lib) due to 1 previous error

I looked through the code at that line, and couldn't immediately figure out what was wrong. I tried updating everything with cargo update and rustup update, but that didn't seem to fix it. I went though the code on github to make sure that the code was the same on the same line, and it was. So I decided to look through the crate on docs.rs, but I couldn't find any mention of ShaderType anywhere in the documentation. I eventually decided to make a change to the pipeline.rs file on my computer and changed the reference on line 419 from ShaderType to ShaderStage, because it looked like that enum was serving the same purpose that ShaderType was trying to serve. Here's the whole function just for more context:

pub fn compile_isf_shader(
    device: &wgpu::Device,
    path: &Path,
) -> (Option<wgpu::ShaderModule>, Option<ShaderError>) {
    let res = std::fs::read_to_string(&path)
        .map_err(ShaderError::from)
        .and_then(|s| isf::parse(&s).map(|isf| (s, isf)).map_err(From::from))
        .and_then(|(old_str, isf)| {
            let isf_str = crate::glsl_string_from_isf(&isf);
            let new_str = crate::prefix_isf_glsl_str(&isf_str, old_str);
            let ty = hotglsl::ShaderStage::Fragment; // Changed ShaderType to ShaderStage
            hotglsl::compile_str(&new_str, ty).map_err(From::from)
        });
    let (bytes, error) = split_result(res);
    let module = bytes.map(|b| wgpu::shader_from_spirv_bytes(device, &b));
    (module, error)
}

I added a comment to make it clear what I changed.

Anyway everything seems to be working as expected now. I'm sorry of this is poorly formatted or missing important information. This is my first time creating a Github Issue.

@tychedelia
Copy link
Collaborator

Hi! We're in the middle of a big rewrite at the moment. I'm glad you were able to get it working -- we're soon to deprecate this code, and so it's possible that it's just breaking on main atm. I'll take a look later and see if I can incorporate your fix :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants