do not depend on spirv on wasm target (#689)
do not use spirv for wasm target
This commit is contained in:
parent
9db8ae7a16
commit
fccfa12d3b
10
CHANGELOG.md
10
CHANGELOG.md
@ -3,19 +3,19 @@
|
|||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
- [Do not depend on spirv on wasm32 target][689]
|
||||||
- [Another fast compile flag for macOS][552]
|
- [Another fast compile flag for macOS][552]
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- Breaking Change: [sRGB awareness for `Color`][616]
|
- Breaking Change: [sRGB awareness for `Color`][616]
|
||||||
- Color is now assumed to be provided in the non-linear sRGB colorspace, and constructors such as `Color::rgb` and `Color::rgba` will be converted to linear sRGB under-the-hood.
|
- Color is now assumed to be provided in the non-linear sRGB colorspace, and constructors such as `Color::rgb` and `Color::rgba` will be converted to linear sRGB under-the-hood.
|
||||||
- This allows drop-in use of colors from most applications.
|
- This allows drop-in use of colors from most applications.
|
||||||
- New methods `Color::rgb_linear` and `Color::rgba_linear` will accept colors already in linear sRGB (the old behavior)
|
- New methods `Color::rgb_linear` and `Color::rgba_linear` will accept colors already in linear sRGB (the old behavior)
|
||||||
- Individual color-components must now be accessed through setters and getters: `.r`, `.g`, `.b`, `.a`, `.set_r`, `.set_g`, `.set_b`, `.set_a`, and the corresponding methods with the `*_linear` suffix.
|
- Individual color-components must now be accessed through setters and getters: `.r`, `.g`, `.b`, `.a`, `.set_r`, `.set_g`, `.set_b`, `.set_a`, and the corresponding methods with the `*_linear` suffix.
|
||||||
- Despawning an entity multiple times causes a debug-level log message to be emitted instead of a panic [649] [651]
|
- Despawning an entity multiple times causes a debug-level log message to be emitted instead of a panic [649] [651]
|
||||||
|
|
||||||
|
[689]: https://github.com/bevyengine/bevy/pull/689
|
||||||
[552]: https://github.com/bevyengine/bevy/pull/552
|
[552]: https://github.com/bevyengine/bevy/pull/552
|
||||||
[616]: https://github.com/bevyengine/bevy/pull/616
|
[616]: https://github.com/bevyengine/bevy/pull/616
|
||||||
[649]: https://github.com/bevyengine/bevy/pull/649
|
[649]: https://github.com/bevyengine/bevy/pull/649
|
||||||
@ -43,7 +43,7 @@
|
|||||||
- e.g. `query.iter().par_iter(batch_size).for_each(/* ... */)`
|
- e.g. `query.iter().par_iter(batch_size).for_each(/* ... */)`
|
||||||
- [Added gamepad support using Gilrs][280]
|
- [Added gamepad support using Gilrs][280]
|
||||||
- [Implement WASM support for bevy_winit][503]
|
- [Implement WASM support for bevy_winit][503]
|
||||||
- [Create winit canvas under WebAssembly][506]
|
- [Create winit canvas under WebAssembly][506]
|
||||||
- [Implement single threaded task scheduler for WebAssembly][496]
|
- [Implement single threaded task scheduler for WebAssembly][496]
|
||||||
- [Support for binary glTF (.glb).][271]
|
- [Support for binary glTF (.glb).][271]
|
||||||
- [Support for `Or` in ECS queries.][358]
|
- [Support for `Or` in ECS queries.][358]
|
||||||
@ -72,7 +72,7 @@
|
|||||||
- [Add `AppBuilder::add_startup_stage_|before/after`][505]
|
- [Add `AppBuilder::add_startup_stage_|before/after`][505]
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- [Transform rewrite][374]
|
- [Transform rewrite][374]
|
||||||
- [Use generational entity ids and other optimizations][504]
|
- [Use generational entity ids and other optimizations][504]
|
||||||
- [Optimize transform systems to only run on changes.][417]
|
- [Optimize transform systems to only run on changes.][417]
|
||||||
|
@ -27,7 +27,6 @@ bevy_window = { path = "../bevy_window", version = "0.2.1" }
|
|||||||
bevy_utils = { path = "../bevy_utils", version = "0.2.1" }
|
bevy_utils = { path = "../bevy_utils", version = "0.2.1" }
|
||||||
|
|
||||||
# rendering
|
# rendering
|
||||||
spirv-reflect = "0.2.3"
|
|
||||||
image = { version = "0.23", default-features = false }
|
image = { version = "0.23", default-features = false }
|
||||||
|
|
||||||
# misc
|
# misc
|
||||||
@ -45,7 +44,10 @@ hex = "0.4.2"
|
|||||||
hexasphere = "1.0.0"
|
hexasphere = "1.0.0"
|
||||||
parking_lot = "0.11.0"
|
parking_lot = "0.11.0"
|
||||||
|
|
||||||
[target.'cfg(not(target_os = "ios"))'.dependencies]
|
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||||
|
spirv-reflect = "0.2.3"
|
||||||
|
|
||||||
|
[target.'cfg(all(not(target_os = "ios"), not(target_arch = "wasm32")))'.dependencies]
|
||||||
bevy-glsl-to-spirv = "0.1.7"
|
bevy-glsl-to-spirv = "0.1.7"
|
||||||
|
|
||||||
[target.'cfg(target_os = "ios")'.dependencies]
|
[target.'cfg(target_os = "ios")'.dependencies]
|
||||||
|
@ -1,8 +1,26 @@
|
|||||||
#[allow(clippy::module_inception)]
|
#[allow(clippy::module_inception)]
|
||||||
mod shader;
|
mod shader;
|
||||||
mod shader_defs;
|
mod shader_defs;
|
||||||
|
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
|
mod shader_reflect;
|
||||||
|
|
||||||
|
#[cfg(target_arch = "wasm32")]
|
||||||
|
#[path = "shader_reflect_wasm.rs"]
|
||||||
mod shader_reflect;
|
mod shader_reflect;
|
||||||
|
|
||||||
pub use shader::*;
|
pub use shader::*;
|
||||||
pub use shader_defs::*;
|
pub use shader_defs::*;
|
||||||
pub use shader_reflect::*;
|
pub use shader_reflect::*;
|
||||||
|
|
||||||
|
use crate::pipeline::{BindGroupDescriptor, VertexBufferDescriptor};
|
||||||
|
|
||||||
|
/// Defines the memory layout of a shader
|
||||||
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
|
pub struct ShaderLayout {
|
||||||
|
pub bind_groups: Vec<BindGroupDescriptor>,
|
||||||
|
pub vertex_buffer_descriptors: Vec<VertexBufferDescriptor>,
|
||||||
|
pub entry_point: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub const GL_VERTEX_INDEX: &str = "gl_VertexIndex";
|
||||||
|
@ -10,7 +10,7 @@ pub enum ShaderStage {
|
|||||||
Compute,
|
Compute,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(target_os = "ios"))]
|
#[cfg(all(not(target_os = "ios"), not(target_arch = "wasm32")))]
|
||||||
impl Into<bevy_glsl_to_spirv::ShaderType> for ShaderStage {
|
impl Into<bevy_glsl_to_spirv::ShaderType> for ShaderStage {
|
||||||
fn into(self) -> bevy_glsl_to_spirv::ShaderType {
|
fn into(self) -> bevy_glsl_to_spirv::ShaderType {
|
||||||
match self {
|
match self {
|
||||||
@ -21,7 +21,7 @@ impl Into<bevy_glsl_to_spirv::ShaderType> for ShaderStage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(target_os = "ios"))]
|
#[cfg(all(not(target_os = "ios"), not(target_arch = "wasm32")))]
|
||||||
fn glsl_to_spirv(
|
fn glsl_to_spirv(
|
||||||
glsl_source: &str,
|
glsl_source: &str,
|
||||||
stage: ShaderStage,
|
stage: ShaderStage,
|
||||||
@ -116,6 +116,7 @@ impl Shader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
pub fn get_spirv(&self, macros: Option<&[String]>) -> Vec<u32> {
|
pub fn get_spirv(&self, macros: Option<&[String]>) -> Vec<u32> {
|
||||||
match self.source {
|
match self.source {
|
||||||
ShaderSource::Spirv(ref bytes) => bytes.clone(),
|
ShaderSource::Spirv(ref bytes) => bytes.clone(),
|
||||||
@ -123,9 +124,13 @@ impl Shader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(unused_variables)]
|
||||||
pub fn get_spirv_shader(&self, macros: Option<&[String]>) -> Shader {
|
pub fn get_spirv_shader(&self, macros: Option<&[String]>) -> Shader {
|
||||||
Shader {
|
Shader {
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
source: ShaderSource::Spirv(self.get_spirv(macros)),
|
source: ShaderSource::Spirv(self.get_spirv(macros)),
|
||||||
|
#[cfg(target_arch = "wasm32")]
|
||||||
|
source: self.source.clone(),
|
||||||
stage: self.stage,
|
stage: self.stage,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -143,12 +148,31 @@ impl Shader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// All stages in a shader program
|
/// All stages in a shader program
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
|
||||||
pub struct ShaderStages {
|
pub struct ShaderStages {
|
||||||
pub vertex: Handle<Shader>,
|
pub vertex: Handle<Shader>,
|
||||||
pub fragment: Option<Handle<Shader>>,
|
pub fragment: Option<Handle<Shader>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub struct ShaderStagesIterator<'a> {
|
||||||
|
shader_stages: &'a ShaderStages,
|
||||||
|
state: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> Iterator for ShaderStagesIterator<'a> {
|
||||||
|
type Item = Handle<Shader>;
|
||||||
|
|
||||||
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
|
let ret = match self.state {
|
||||||
|
0 => Some(self.shader_stages.vertex),
|
||||||
|
1 => self.shader_stages.fragment,
|
||||||
|
_ => None,
|
||||||
|
};
|
||||||
|
self.state += 1;
|
||||||
|
ret
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl ShaderStages {
|
impl ShaderStages {
|
||||||
pub fn new(vertex_shader: Handle<Shader>) -> Self {
|
pub fn new(vertex_shader: Handle<Shader>) -> Self {
|
||||||
ShaderStages {
|
ShaderStages {
|
||||||
@ -156,4 +180,11 @@ impl ShaderStages {
|
|||||||
fragment: None,
|
fragment: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn iter(&self) -> ShaderStagesIterator {
|
||||||
|
ShaderStagesIterator {
|
||||||
|
shader_stages: &self,
|
||||||
|
state: 0,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ use crate::{
|
|||||||
BindGroupDescriptor, BindType, BindingDescriptor, BindingShaderStage, InputStepMode,
|
BindGroupDescriptor, BindType, BindingDescriptor, BindingShaderStage, InputStepMode,
|
||||||
UniformProperty, VertexAttributeDescriptor, VertexBufferDescriptor, VertexFormat,
|
UniformProperty, VertexAttributeDescriptor, VertexBufferDescriptor, VertexFormat,
|
||||||
},
|
},
|
||||||
|
shader::{ShaderLayout, GL_VERTEX_INDEX},
|
||||||
texture::{TextureComponentType, TextureViewDimension},
|
texture::{TextureComponentType, TextureViewDimension},
|
||||||
};
|
};
|
||||||
use bevy_core::AsBytes;
|
use bevy_core::AsBytes;
|
||||||
@ -16,16 +17,6 @@ use spirv_reflect::{
|
|||||||
ShaderModule,
|
ShaderModule,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Defines the memory layout of a shader
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
||||||
pub struct ShaderLayout {
|
|
||||||
pub bind_groups: Vec<BindGroupDescriptor>,
|
|
||||||
pub vertex_buffer_descriptors: Vec<VertexBufferDescriptor>,
|
|
||||||
pub entry_point: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub const GL_VERTEX_INDEX: &str = "gl_VertexIndex";
|
|
||||||
|
|
||||||
impl ShaderLayout {
|
impl ShaderLayout {
|
||||||
pub fn from_spirv(spirv_data: &[u32], bevy_conventions: bool) -> ShaderLayout {
|
pub fn from_spirv(spirv_data: &[u32], bevy_conventions: bool) -> ShaderLayout {
|
||||||
match ShaderModule::load_u8_data(spirv_data.as_bytes()) {
|
match ShaderModule::load_u8_data(spirv_data.as_bytes()) {
|
||||||
|
7
crates/bevy_render/src/shader/shader_reflect_wasm.rs
Normal file
7
crates/bevy_render/src/shader/shader_reflect_wasm.rs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
use crate::shader::ShaderLayout;
|
||||||
|
|
||||||
|
impl ShaderLayout {
|
||||||
|
pub fn from_spirv(_spirv_data: &[u32], _bevy_conventions: bool) -> ShaderLayout {
|
||||||
|
panic!("reflecting shader layout from spirv data is not available");
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user