diff --git a/crates/bevy_render/src/render_resource/shader.rs b/crates/bevy_render/src/render_resource/shader.rs index 465fbb193d35a..7b10677784c8f 100644 --- a/crates/bevy_render/src/render_resource/shader.rs +++ b/crates/bevy_render/src/render_resource/shader.rs @@ -259,30 +259,24 @@ impl AssetLoader for ShaderLoader { ) -> BoxedFuture<'a, Result> { Box::pin(async move { let ext = load_context.path().extension().unwrap().to_str().unwrap(); - + let path = load_context.asset_path().to_string(); + // On windows, the path will inconsistently use \ or /. + // TODO: remove this once AssetPath forces cross-platform "slash" consistency. See #10511 + let path = path.replace(std::path::MAIN_SEPARATOR, "/"); let mut bytes = Vec::new(); reader.read_to_end(&mut bytes).await?; let mut shader = match ext { "spv" => Shader::from_spirv(bytes, load_context.path().to_string_lossy()), - "wgsl" => Shader::from_wgsl( - String::from_utf8(bytes)?, - load_context.path().to_string_lossy(), - ), - "vert" => Shader::from_glsl( - String::from_utf8(bytes)?, - naga::ShaderStage::Vertex, - load_context.path().to_string_lossy(), - ), - "frag" => Shader::from_glsl( - String::from_utf8(bytes)?, - naga::ShaderStage::Fragment, - load_context.path().to_string_lossy(), - ), - "comp" => Shader::from_glsl( - String::from_utf8(bytes)?, - naga::ShaderStage::Compute, - load_context.path().to_string_lossy(), - ), + "wgsl" => Shader::from_wgsl(String::from_utf8(bytes)?, path), + "vert" => { + Shader::from_glsl(String::from_utf8(bytes)?, naga::ShaderStage::Vertex, path) + } + "frag" => { + Shader::from_glsl(String::from_utf8(bytes)?, naga::ShaderStage::Fragment, path) + } + "comp" => { + Shader::from_glsl(String::from_utf8(bytes)?, naga::ShaderStage::Compute, path) + } _ => panic!("unhandled extension: {ext}"), };