Skip to content

Commit

Permalink
Point to internal crate.
Browse files Browse the repository at this point in the history
  • Loading branch information
tychedelia committed Nov 23, 2024
1 parent 5e9b38f commit 7d40381
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 32 deletions.
4 changes: 2 additions & 2 deletions crates/bevy_naga_oil/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "naga_oil"
version = "0.16.0"
name = "bevy_naga_oil"
version = "0.15.0-dev"
edition = "2021"
license = "MIT OR Apache-2.0"
description = "a crate for combining and manipulating shaders using naga IR"
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_naga_oil/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Naga Organised Integration Library (`naga-oil`) is a crate for combining and manipulating shaders.
Naga Organised Integration Library (`bevy_naga-oil`) is a crate for combining and manipulating shaders.

- `compose` presents a modular shader composition framework
- `prune` strips shaders down to required parts
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_naga_oil/examples/pbr_compose_test.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::borrow::Cow;

use naga_oil::compose::{
use bevy_naga_oil::compose::{
ComposableModuleDescriptor, Composer, ComposerError, NagaModuleDescriptor,
};
#[allow(unused_variables, dead_code)]
Expand Down
6 changes: 3 additions & 3 deletions crates/bevy_render/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ktx2 = ["dep:ktx2", "bevy_image/ktx2"]

multi_threaded = ["bevy_tasks/multi_threaded"]

shader_format_glsl = ["naga/glsl-in", "naga/wgsl-out", "naga_oil/glsl"]
shader_format_glsl = ["naga/glsl-in", "naga/wgsl-out", "bevy_naga_oil/glsl"]
shader_format_spirv = ["wgpu/spirv", "naga/spv-in", "naga/spv-out"]

# Enable SPIR-V shader passthrough
Expand Down Expand Up @@ -98,12 +98,12 @@ offset-allocator = "0.2"

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
# Omit the `glsl` feature in non-WebAssembly by default.
naga_oil = { version = "0.16", default-features = false, features = [
bevy_naga_oil = { path = "../bevy_naga_oil", version = "0.15.0-dev", default-features = false, features = [
"test_shader",
] }

[target.'cfg(target_arch = "wasm32")'.dependencies]
naga_oil = "0.16"
bevy_naga_oil = { path = "../bevy_naga_oil", version = "0.15.0-dev" }
js-sys = "0.3"
web-sys = { version = "0.3.67", features = [
'Blob',
Expand Down
18 changes: 9 additions & 9 deletions crates/bevy_render/src/render_resource/pipeline_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ struct ShaderCache {
shaders: HashMap<AssetId<Shader>, Shader>,
import_path_shaders: HashMap<ShaderImport, AssetId<Shader>>,
waiting_on_import: HashMap<ShaderImport, Vec<AssetId<Shader>>>,
composer: naga_oil::compose::Composer,
composer: bevy_naga_oil::compose::Composer,
}

#[derive(Clone, PartialEq, Eq, Debug, Hash)]
Expand Down Expand Up @@ -172,9 +172,9 @@ impl ShaderCache {
);

#[cfg(debug_assertions)]
let composer = naga_oil::compose::Composer::default();
let composer = bevy_naga_oil::compose::Composer::default();
#[cfg(not(debug_assertions))]
let composer = naga_oil::compose::Composer::non_validating();
let composer = bevy_naga_oil::compose::Composer::non_validating();

let composer = composer.with_capabilities(capabilities);

Expand All @@ -188,7 +188,7 @@ impl ShaderCache {
}

fn add_import_to_composer(
composer: &mut naga_oil::compose::Composer,
composer: &mut bevy_naga_oil::compose::Composer,
import_path_shaders: &HashMap<ShaderImport, AssetId<Shader>>,
shaders: &HashMap<AssetId<Shader>, Shader>,
import: &ShaderImport,
Expand Down Expand Up @@ -291,19 +291,19 @@ impl ShaderCache {
.chain(shader.shader_defs.iter().cloned())
.map(|def| match def {
ShaderDefVal::Bool(k, v) => {
(k, naga_oil::compose::ShaderDefValue::Bool(v))
(k, bevy_naga_oil::compose::ShaderDefValue::Bool(v))
}
ShaderDefVal::Int(k, v) => {
(k, naga_oil::compose::ShaderDefValue::Int(v))
(k, bevy_naga_oil::compose::ShaderDefValue::Int(v))
}
ShaderDefVal::UInt(k, v) => {
(k, naga_oil::compose::ShaderDefValue::UInt(v))
(k, bevy_naga_oil::compose::ShaderDefValue::UInt(v))
}
})
.collect::<std::collections::HashMap<_, _>>();

let naga = self.composer.make_naga_module(
naga_oil::compose::NagaModuleDescriptor {
bevy_naga_oil::compose::NagaModuleDescriptor {
shader_defs,
..shader.into()
},
Expand Down Expand Up @@ -982,7 +982,7 @@ pub enum PipelineCacheError {
#[error(ignore)]
ShaderNotLoaded(AssetId<Shader>),

ProcessShaderError(naga_oil::compose::ComposerError),
ProcessShaderError(bevy_naga_oil::compose::ComposerError),
#[display("Shader import not yet available.")]
ShaderImportNotYetAvailable,
#[display("Could not create shader module: {_0}")]
Expand Down
32 changes: 16 additions & 16 deletions crates/bevy_render/src/render_resource/shader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub struct Shader {
pub import_path: ShaderImport,
pub imports: Vec<ShaderImport>,
// extra imports not specified in the source string
pub additional_imports: Vec<naga_oil::compose::ImportDefinition>,
pub additional_imports: Vec<bevy_naga_oil::compose::ImportDefinition>,
// any shader defs that will be included when this module is used
pub shader_defs: Vec<ShaderDefVal>,
// we must store strong handles to our dependencies to stop them
Expand All @@ -38,7 +38,7 @@ pub struct Shader {

impl Shader {
fn preprocess(source: &str, path: &str) -> (ShaderImport, Vec<ShaderImport>) {
let (import_path, imports, _) = naga_oil::compose::get_preprocessor_data(source);
let (import_path, imports, _) = bevy_naga_oil::compose::get_preprocessor_data(source);

let import_path = import_path
.map(ShaderImport::Custom)
Expand Down Expand Up @@ -142,20 +142,20 @@ impl Shader {
}
}

impl<'a> From<&'a Shader> for naga_oil::compose::ComposableModuleDescriptor<'a> {
impl<'a> From<&'a Shader> for bevy_naga_oil::compose::ComposableModuleDescriptor<'a> {
fn from(shader: &'a Shader) -> Self {
let shader_defs = shader
.shader_defs
.iter()
.map(|def| match def {
ShaderDefVal::Bool(name, b) => {
(name.clone(), naga_oil::compose::ShaderDefValue::Bool(*b))
(name.clone(), bevy_naga_oil::compose::ShaderDefValue::Bool(*b))
}
ShaderDefVal::Int(name, i) => {
(name.clone(), naga_oil::compose::ShaderDefValue::Int(*i))
(name.clone(), bevy_naga_oil::compose::ShaderDefValue::Int(*i))
}
ShaderDefVal::UInt(name, i) => {
(name.clone(), naga_oil::compose::ShaderDefValue::UInt(*i))
(name.clone(), bevy_naga_oil::compose::ShaderDefValue::UInt(*i))
}
})
.collect();
Expand All @@ -165,7 +165,7 @@ impl<'a> From<&'a Shader> for naga_oil::compose::ComposableModuleDescriptor<'a>
ShaderImport::Custom(_) => None,
};

naga_oil::compose::ComposableModuleDescriptor {
bevy_naga_oil::compose::ComposableModuleDescriptor {
source: shader.source.as_str(),
file_path: &shader.path,
language: (&shader.source).into(),
Expand All @@ -176,9 +176,9 @@ impl<'a> From<&'a Shader> for naga_oil::compose::ComposableModuleDescriptor<'a>
}
}

impl<'a> From<&'a Shader> for naga_oil::compose::NagaModuleDescriptor<'a> {
impl<'a> From<&'a Shader> for bevy_naga_oil::compose::NagaModuleDescriptor<'a> {
fn from(shader: &'a Shader) -> Self {
naga_oil::compose::NagaModuleDescriptor {
bevy_naga_oil::compose::NagaModuleDescriptor {
source: shader.source.as_str(),
file_path: &shader.path,
shader_type: (&shader.source).into(),
Expand Down Expand Up @@ -206,12 +206,12 @@ impl Source {
}
}

impl From<&Source> for naga_oil::compose::ShaderLanguage {
impl From<&Source> for bevy_naga_oil::compose::ShaderLanguage {
fn from(value: &Source) -> Self {
match value {
Source::Wgsl(_) => naga_oil::compose::ShaderLanguage::Wgsl,
Source::Wgsl(_) => bevy_naga_oil::compose::ShaderLanguage::Wgsl,
#[cfg(any(feature = "shader_format_glsl", target_arch = "wasm32"))]
Source::Glsl(_, _) => naga_oil::compose::ShaderLanguage::Glsl,
Source::Glsl(_, _) => bevy_naga_oil::compose::ShaderLanguage::Glsl,
#[cfg(all(not(feature = "shader_format_glsl"), not(target_arch = "wasm32")))]
Source::Glsl(_, _) => panic!(
"GLSL is not supported in this configuration; use the feature `shader_format_glsl`"
Expand All @@ -221,14 +221,14 @@ impl From<&Source> for naga_oil::compose::ShaderLanguage {
}
}

impl From<&Source> for naga_oil::compose::ShaderType {
impl From<&Source> for bevy_naga_oil::compose::ShaderType {
fn from(value: &Source) -> Self {
match value {
Source::Wgsl(_) => naga_oil::compose::ShaderType::Wgsl,
Source::Wgsl(_) => bevy_naga_oil::compose::ShaderType::Wgsl,
#[cfg(any(feature = "shader_format_glsl", target_arch = "wasm32"))]
Source::Glsl(_, shader_stage) => match shader_stage {
naga::ShaderStage::Vertex => naga_oil::compose::ShaderType::GlslVertex,
naga::ShaderStage::Fragment => naga_oil::compose::ShaderType::GlslFragment,
naga::ShaderStage::Vertex => bevy_naga_oil::compose::ShaderType::GlslVertex,
naga::ShaderStage::Fragment => bevy_naga_oil::compose::ShaderType::GlslFragment,
naga::ShaderStage::Compute => panic!("glsl compute not yet implemented"),
},
#[cfg(all(not(feature = "shader_format_glsl"), not(target_arch = "wasm32")))]
Expand Down

0 comments on commit 7d40381

Please sign in to comment.