Prepare crevice for vendored release (#3394)

# Objective

- Our crevice is still called "crevice", which we can't use for a release
- Users would need to use our "crevice" directly to be able to use the derive macro

## Solution

- Rename crevice to bevy_crevice, and crevice-derive to bevy-crevice-derive
- Re-export it from bevy_render, and use it from bevy_render everywhere
- Fix derive macro to work either from bevy_render, from bevy_crevice, or from bevy

## Remaining

- It is currently re-exported as `bevy::render::bevy_crevice`, is it the path we want?
- After a brief suggestion to Cart, I changed the version to follow Bevy version instead of crevice, do we want that?
- Crevice README.md need to be updated
- in the `Cargo.toml`, there are a few things to change. How do we want to change them? How do we keep attributions to original Crevice?
```
authors = ["Lucien Greathouse <me@lpghatguy.com>"]
documentation = "https://docs.rs/crevice"
homepage = "https://github.com/LPGhatguy/crevice"
repository = "https://github.com/LPGhatguy/crevice"
```


Co-authored-by: François <8672791+mockersf@users.noreply.github.com>
Co-authored-by: Carter Anderson <mcanders1@gmail.com>
This commit is contained in:
François 2021-12-23 22:49:12 +00:00
parent aeba9faf04
commit 79d36e7c28
55 changed files with 161 additions and 117 deletions

View file

@ -102,7 +102,6 @@ ron = "0.7.0"
serde = { version = "1", features = ["derive"] }
# Needed to poll Task examples
futures-lite = "1.11.3"
crevice = { path = "crates/crevice", version = "0.8.0", features = ["glam"] }
[[example]]
name = "hello_world"

View file

@ -1,12 +1,12 @@
[package]
name = "crevice"
description = "Create GLSL-compatible versions of structs with explicitly-initialized padding"
version = "0.8.0"
name = "bevy_crevice"
description = "Create GLSL-compatible versions of structs with explicitly-initialized padding (Bevy version)"
version = "0.5.0"
edition = "2021"
authors = ["Lucien Greathouse <me@lpghatguy.com>"]
documentation = "https://docs.rs/crevice"
homepage = "https://github.com/LPGhatguy/crevice"
repository = "https://github.com/LPGhatguy/crevice"
repository = "https://github.com/bevyengine/bevy"
readme = "README.md"
keywords = ["glsl", "std140", "std430"]
license = "MIT OR Apache-2.0"
@ -23,7 +23,7 @@ std = []
# default-members = ["crevice-derive", "crevice-tests"]
[dependencies]
crevice-derive = { version = "0.8.0", path = "crevice-derive" }
bevy-crevice-derive = { version = "0.5.0", path = "bevy-crevice-derive" }
bytemuck = "1.4.1"
mint = "0.5.8"

View file

@ -1,8 +1,19 @@
# Crevice
# Bevy Crevice
[![GitHub CI Status](https://github.com/LPGhatguy/crevice/workflows/CI/badge.svg)](https://github.com/LPGhatguy/crevice/actions)
[![crevice on crates.io](https://img.shields.io/crates/v/crevice.svg)](https://crates.io/crates/crevice)
[![crevice docs](https://img.shields.io/badge/docs-docs.rs-orange.svg)](https://docs.rs/crevice)
This is a fork of [Crevice](https://crates.io/crates/crevice) for
[Bevy](https://bevyengine.org).
For use outside of Bevy, you should consider
using [Crevice](https://crates.io/crates/crevice) directly.
It was forked to allow better integration in Bevy:
* Easier derive macro usage, without needing to depend on `Crevice` directly.
* Use of unmerged features (as of the fork), like
[Array Support](https://github.com/LPGhatguy/crevice/pull/27/).
* Renaming of traits and macros to better match Bevy API.
## Crevice
Crevice creates GLSL-compatible versions of types through the power of derive
macros. Generated structures provide an [`as_bytes`][std140::Std140::as_bytes]
@ -21,7 +32,7 @@ other math libraries by use of the mint crate. Crevice currently supports:
* mint 0.5, enabled by default
* cgmath 0.18, using the `cgmath` feature
* nalgebra 0.29, using the `nalgebra` feature
* glam 0.19, using the `glam` feature
* glam 0.20, using the `glam` feature
PRs are welcome to add or update math libraries to Crevice.
@ -50,7 +61,7 @@ uniform MAIN {
```
```rust
use crevice::std140::{AsStd140, Std140};
use bevy_crevice::std140::{AsStd140, Std140};
#[derive(AsStd140)]
struct MainUniform {
@ -93,7 +104,7 @@ buffer POINT_LIGHTS {
```
```rust
use crevice::std140::{self, AsStd140};
use bevy_crevice::std140::{self, AsStd140};
#[derive(AsStd140)]
struct PointLight {

View file

@ -1,12 +1,12 @@
[package]
name = "crevice-derive"
description = "Derive crate for the 'crevice' crate"
version = "0.8.0"
name = "bevy-crevice-derive"
description = "Derive crate for the 'crevice' crate (Bevy version)"
version = "0.5.0"
edition = "2018"
authors = ["Lucien Greathouse <me@lpghatguy.com>"]
documentation = "https://docs.rs/crevice-derive"
homepage = "https://github.com/LPGhatguy/crevice"
repository = "https://github.com/LPGhatguy/crevice"
repository = "https://github.com/bevyengine/bevy"
license = "MIT OR Apache-2.0"
[features]
@ -24,3 +24,4 @@ proc-macro = true
syn = "1.0.40"
quote = "1.0.7"
proc-macro2 = "1.0.21"
bevy_macro_utils = { path = "../../bevy_macro_utils", version = "0.5.0" }

View file

@ -3,6 +3,8 @@ use quote::quote;
use syn::{parse_quote, Data, DeriveInput, Fields, Path};
pub fn emit(input: DeriveInput) -> TokenStream {
let bevy_crevice_path = crate::bevy_crevice_path();
let fields = match &input.data {
Data::Struct(data) => match &data.fields {
Fields::Named(fields) => fields,
@ -12,8 +14,8 @@ pub fn emit(input: DeriveInput) -> TokenStream {
Data::Enum(_) | Data::Union(_) => panic!("Only structs are supported"),
};
let base_trait_path: Path = parse_quote!(::crevice::glsl::Glsl);
let struct_trait_path: Path = parse_quote!(::crevice::glsl::GlslStruct);
let base_trait_path: Path = parse_quote!(#bevy_crevice_path::glsl::Glsl);
let struct_trait_path: Path = parse_quote!(#bevy_crevice_path::glsl::GlslStruct);
let name = input.ident;
let name_str = Literal::string(&name.to_string());
@ -23,14 +25,14 @@ pub fn emit(input: DeriveInput) -> TokenStream {
let glsl_fields = fields.named.iter().map(|field| {
let field_ty = &field.ty;
let field_name_str = Literal::string(&field.ident.as_ref().unwrap().to_string());
let field_as = quote! {<#field_ty as ::crevice::glsl::GlslArray>};
let field_as = quote! {<#field_ty as #bevy_crevice_path::glsl::GlslArray>};
quote! {
s.push_str("\t");
s.push_str(#field_as::NAME);
s.push_str(" ");
s.push_str(#field_name_str);
<#field_as::ArraySize as ::crevice::glsl::DimensionList>::push_to_string(s);
<#field_as::ArraySize as #bevy_crevice_path::glsl::DimensionList>::push_to_string(s);
s.push_str(";\n");
}
});

View file

@ -8,10 +8,12 @@ pub fn emit(
mod_name: &'static str,
min_struct_alignment: usize,
) -> TokenStream {
let bevy_crevice_path = crate::bevy_crevice_path();
let mod_name = Ident::new(mod_name, Span::call_site());
let trait_name = Ident::new(trait_name, Span::call_site());
let mod_path: Path = parse_quote!(::crevice::#mod_name);
let mod_path: Path = parse_quote!(#bevy_crevice_path::#mod_name);
let trait_path: Path = parse_quote!(#mod_path::#trait_name);
let as_trait_name = format_ident!("As{}", trait_name);
@ -63,7 +65,7 @@ pub fn emit(
let field_alignments = fields.iter().map(|field| layout_alignment_of_ty(&field.ty));
let struct_alignment = quote! {
::crevice::internal::max_arr([
#bevy_crevice_path::internal::max_arr([
#min_struct_alignment,
#(#field_alignments,)*
])
@ -139,13 +141,13 @@ pub fn emit(
// We set our target alignment to the larger of the
// alignment due to the previous field and the alignment
// requirement of the next field.
let alignment = ::crevice::internal::max(
let alignment = #bevy_crevice_path::internal::max(
#next_field_or_self_alignment,
min_alignment,
);
// Using everything we've got, compute our padding amount.
::crevice::internal::align_offset(starting_offset, alignment)
#bevy_crevice_path::internal::align_offset(starting_offset, alignment)
}
}
})
@ -222,7 +224,7 @@ pub fn emit(
let size = ::core::mem::size_of::<Self>();
let align = <Self as #trait_path>::ALIGNMENT;
let zeroed: Self = ::crevice::internal::bytemuck::Zeroable::zeroed();
let zeroed: Self = #bevy_crevice_path::internal::bytemuck::Zeroable::zeroed();
#[derive(Debug)]
struct Field {
@ -253,13 +255,13 @@ pub fn emit(
#pad_fn_impls
#struct_definition
unsafe impl #impl_generics ::crevice::internal::bytemuck::Zeroable for #generated_name #ty_generics #where_clause {}
unsafe impl #impl_generics ::crevice::internal::bytemuck::Pod for #generated_name #ty_generics #where_clause {}
unsafe impl #impl_generics #bevy_crevice_path::internal::bytemuck::Zeroable for #generated_name #ty_generics #where_clause {}
unsafe impl #impl_generics #bevy_crevice_path::internal::bytemuck::Pod for #generated_name #ty_generics #where_clause {}
unsafe impl #impl_generics #mod_path::#trait_name for #generated_name #ty_generics #where_clause {
const ALIGNMENT: usize = #struct_alignment;
const PAD_AT_END: bool = true;
type Padded = #padded_path<Self, {::crevice::internal::align_offset(
type Padded = #padded_path<Self, {#bevy_crevice_path::internal::align_offset(
::core::mem::size_of::<#generated_name>(),
#struct_alignment
)}>;
@ -272,7 +274,7 @@ pub fn emit(
Self::Output {
#generated_struct_field_init
..::crevice::internal::bytemuck::Zeroable::zeroed()
..#bevy_crevice_path::internal::bytemuck::Zeroable::zeroed()
}
}

View file

@ -0,0 +1,60 @@
mod glsl;
mod layout;
use bevy_macro_utils::BevyManifest;
use proc_macro::TokenStream as CompilerTokenStream;
use syn::{parse_macro_input, DeriveInput, Path};
#[proc_macro_derive(AsStd140)]
pub fn derive_as_std140(input: CompilerTokenStream) -> CompilerTokenStream {
let input = parse_macro_input!(input as DeriveInput);
let expanded = layout::emit(input, "Std140", "std140", 16);
CompilerTokenStream::from(expanded)
}
#[proc_macro_derive(AsStd430)]
pub fn derive_as_std430(input: CompilerTokenStream) -> CompilerTokenStream {
let input = parse_macro_input!(input as DeriveInput);
let expanded = layout::emit(input, "Std430", "std430", 0);
CompilerTokenStream::from(expanded)
}
#[proc_macro_derive(GlslStruct)]
pub fn derive_glsl_struct(input: CompilerTokenStream) -> CompilerTokenStream {
let input = parse_macro_input!(input as DeriveInput);
let expanded = glsl::emit(input);
CompilerTokenStream::from(expanded)
}
const BEVY: &str = "bevy";
const BEVY_CREVICE: &str = "bevy_crevice";
const BEVY_RENDER: &str = "bevy_render";
fn bevy_crevice_path() -> Path {
let bevy_manifest = BevyManifest::default();
bevy_manifest
.maybe_get_path(crate::BEVY)
.map(|bevy_path| {
let mut segments = bevy_path.segments;
segments.push(BevyManifest::parse_str("render"));
segments.push(BevyManifest::parse_str("render_resource"));
Path {
leading_colon: None,
segments,
}
})
.or_else(|| bevy_manifest.maybe_get_path(crate::BEVY_RENDER))
.map(|bevy_render_path| {
let mut segments = bevy_render_path.segments;
segments.push(BevyManifest::parse_str("render_resource"));
Path {
leading_colon: None,
segments,
}
})
.unwrap_or_else(|| bevy_manifest.get_path(crate::BEVY_CREVICE))
}

View file

@ -7,8 +7,8 @@ edition = "2018"
wgpu-validation = ["wgpu", "naga", "futures"]
[dependencies]
crevice = { path = ".." }
crevice-derive = { path = "../crevice-derive", features = ["debug-methods"] }
bevy_crevice = { path = ".." }
bevy-crevice-derive = { path = "../bevy-crevice-derive", features = ["debug-methods"] }
anyhow = "1.0.44"
bytemuck = "1.7.2"

View file

@ -2,9 +2,9 @@ use std::borrow::Cow;
use std::fmt::Debug;
use std::marker::PhantomData;
use crevice::glsl::{Glsl, GlslStruct};
use crevice::std140::{AsStd140, Std140};
use crevice::std430::{AsStd430, Std430};
use bevy_crevice::glsl::{Glsl, GlslStruct};
use bevy_crevice::std140::{AsStd140, Std140};
use bevy_crevice::std430::{AsStd430, Std430};
use futures::executor::block_on;
use wgpu::util::DeviceExt;

View file

@ -15,9 +15,9 @@ fn test_round_trip_primitive<T>(_value: T) {}
#[macro_use]
mod util;
use crevice::glsl::GlslStruct;
use crevice::std140::AsStd140;
use crevice::std430::AsStd430;
use bevy_crevice::glsl::GlslStruct;
use bevy_crevice::std140::AsStd140;
use bevy_crevice::std430::AsStd430;
use mint::{ColumnMatrix2, ColumnMatrix3, ColumnMatrix4, Vector2, Vector3, Vector4};
#[test]

View file

@ -1,6 +1,6 @@
//! Defines traits and types for generating GLSL code from Rust definitions.
pub use crevice_derive::GlslStruct;
pub use bevy_crevice_derive::GlslStruct;
use std::marker::PhantomData;
/// Type-level linked list of array dimensions

View file

@ -56,7 +56,7 @@ uniform MAIN {
```
```rust
use crevice::std140::{AsStd140, Std140};
use bevy_crevice::std140::{AsStd140, Std140};
#[derive(AsStd140)]
struct MainUniform {
@ -100,7 +100,7 @@ buffer POINT_LIGHTS {
```
```rust
use crevice::std140::{self, AsStd140};
use bevy_crevice::std140::{self, AsStd140};
#[derive(AsStd140)]
struct PointLight {

View file

@ -15,4 +15,4 @@ pub use self::traits::*;
#[cfg(feature = "std")]
pub use self::writer::*;
pub use crevice_derive::AsStd140;
pub use bevy_crevice_derive::AsStd140;

View file

@ -25,7 +25,7 @@ buffer FROBS {
```
```
use crevice::std140::{self, AsStd140};
use bevy_crevice::std140::{self, AsStd140};
#[derive(AsStd140)]
struct Frob {

View file

@ -89,7 +89,7 @@ uniform CAMERA {
```
```no_run
use crevice::std140::{AsStd140, Std140};
use bevy_crevice::std140::{AsStd140, Std140};
#[derive(AsStd140)]
struct CameraUniform {

View file

@ -32,7 +32,7 @@ buffer POINT_LIGHTS {
```
```
use crevice::std140::{self, AsStd140};
use bevy_crevice::std140::{self, AsStd140};
#[derive(AsStd140)]
struct PointLight {

View file

@ -13,4 +13,4 @@ pub use self::traits::*;
#[cfg(feature = "std")]
pub use self::writer::*;
pub use crevice_derive::AsStd430;
pub use bevy_crevice_derive::AsStd430;

View file

@ -25,7 +25,7 @@ buffer FROBS {
```
```
use crevice::std430::{self, AsStd430};
use bevy_crevice::std430::{self, AsStd430};
#[derive(AsStd430)]
struct Frob {

View file

@ -89,7 +89,7 @@ uniform CAMERA {
```
```no_run
use crevice::std430::{AsStd430, Std430};
use bevy_crevice::std430::{AsStd430, Std430};
#[derive(AsStd430)]
struct CameraUniform {

View file

@ -32,7 +32,7 @@ buffer POINT_LIGHTS {
```
```
use crevice::std430::{self, AsStd430};
use bevy_crevice::std430::{self, AsStd430};
#[derive(AsStd430)]
struct PointLight {

View file

@ -1,5 +1,5 @@
use crevice::glsl::GlslStruct;
use crevice::std140::AsStd140;
use bevy_crevice::glsl::GlslStruct;
use bevy_crevice::std140::AsStd140;
#[test]
fn there_and_back_again() {

View file

@ -30,13 +30,13 @@ impl Default for BevyManifest {
}
impl BevyManifest {
pub fn get_path(&self, name: &str) -> syn::Path {
pub fn maybe_get_path(&self, name: &str) -> Option<syn::Path> {
const BEVY: &str = "bevy";
const BEVY_INTERNAL: &str = "bevy_internal";
let find_in_deps = |deps: &DepsSet| -> Option<syn::Path> {
let package = if let Some(dep) = deps.get(name) {
return Some(get_path(dep.package().unwrap_or(name)));
return Some(Self::parse_str(dep.package().unwrap_or(name)));
} else if let Some(dep) = deps.get(BEVY) {
dep.package().unwrap_or(BEVY)
} else if let Some(dep) = deps.get(BEVY_INTERNAL) {
@ -45,9 +45,9 @@ impl BevyManifest {
return None;
};
let mut path = get_path(package);
let mut path = Self::parse_str::<syn::Path>(package);
if let Some(module) = name.strip_prefix("bevy_") {
path.segments.push(parse_str(module));
path.segments.push(Self::parse_str(module));
}
Some(path)
};
@ -57,16 +57,15 @@ impl BevyManifest {
deps.and_then(find_in_deps)
.or_else(|| deps_dev.and_then(find_in_deps))
.unwrap_or_else(|| get_path(name))
}
}
pub fn get_path(&self, name: &str) -> syn::Path {
self.maybe_get_path(name)
.unwrap_or_else(|| Self::parse_str(name))
}
fn get_path(path: &str) -> syn::Path {
parse_str(path)
}
fn parse_str<T: syn::parse::Parse>(path: &str) -> T {
syn::parse(path.parse::<TokenStream>().unwrap()).unwrap()
pub fn parse_str<T: syn::parse::Parse>(path: &str) -> T {
syn::parse(path.parse::<TokenStream>().unwrap()).unwrap()
}
}
/// Derive a label trait

View file

@ -29,5 +29,4 @@ bevy_window = { path = "../bevy_window", version = "0.5.0" }
bitflags = "1.2"
# direct dependency required for derive macro
bytemuck = { version = "1", features = ["derive"] }
crevice = { path = "../crevice", version = "0.8.0", features = ["glam"] }
wgpu = { version = "0.12.0", features = ["spirv"] }

View file

@ -7,11 +7,13 @@ use bevy_reflect::TypeUuid;
use bevy_render::{
color::Color,
render_asset::{PrepareAssetError, RenderAsset, RenderAssetPlugin, RenderAssets},
render_resource::{BindGroup, Buffer, BufferInitDescriptor, BufferUsages},
render_resource::{
std140::{AsStd140, Std140},
BindGroup, Buffer, BufferInitDescriptor, BufferUsages,
},
renderer::RenderDevice,
texture::Image,
};
use crevice::std140::{AsStd140, Std140};
use wgpu::{BindGroupDescriptor, BindGroupEntry, BindingResource};
pub const DEFAULT_STANDARD_MATERIAL_HANDLE: HandleUntyped =

View file

@ -22,14 +22,13 @@ use bevy_render::{
EntityRenderCommand, PhaseItem, RenderCommandResult, RenderPhase, SetItemPipeline,
TrackedRenderPass,
},
render_resource::*,
render_resource::{std140::AsStd140, *},
renderer::{RenderContext, RenderDevice, RenderQueue},
texture::*,
view::{ExtractedView, ViewUniform, ViewUniformOffset, ViewUniforms, VisibleEntities},
};
use bevy_transform::components::GlobalTransform;
use bevy_utils::{tracing::warn, HashMap};
use crevice::std140::AsStd140;
use std::num::NonZeroU32;
#[derive(Debug, Hash, PartialEq, Eq, Clone, SystemLabel)]

View file

@ -15,14 +15,13 @@ use bevy_render::{
render_asset::RenderAssets,
render_component::{ComponentUniforms, DynamicUniformIndex, UniformComponentPlugin},
render_phase::{EntityRenderCommand, RenderCommandResult, TrackedRenderPass},
render_resource::*,
render_resource::{std140::AsStd140, *},
renderer::{RenderDevice, RenderQueue},
texture::{BevyDefault, GpuImage, Image, TextureFormatPixelInfo},
view::{ComputedVisibility, ViewUniform, ViewUniformOffset, ViewUniforms},
RenderApp, RenderStage,
};
use bevy_transform::components::GlobalTransform;
use crevice::std140::AsStd140;
use wgpu::{
Extent3d, ImageCopyTexture, ImageDataLayout, Origin3d, SamplerBindingType, TextureDimension,
TextureFormat, TextureViewDescriptor,

View file

@ -19,11 +19,10 @@ use bevy_render::{
DrawFunctions, EntityRenderCommand, RenderCommandResult, RenderPhase, SetItemPipeline,
TrackedRenderPass,
},
render_resource::*,
render_resource::{std140::AsStd140, *},
renderer::RenderDevice,
view::{ExtractedView, Msaa, VisibleEntities},
};
use crevice::std140::AsStd140;
// NOTE: These must match the bit flags in bevy_pbr2/src/render/pbr.wgsl!
bitflags::bitflags! {

View file

@ -25,6 +25,7 @@ webgl = ["wgpu/webgl"]
bevy_app = { path = "../bevy_app", version = "0.5.0" }
bevy_asset = { path = "../bevy_asset", version = "0.5.0" }
bevy_core = { path = "../bevy_core", version = "0.5.0" }
bevy_crevice = { path = "../bevy_crevice", version = "0.5.0", features = ["glam"] }
bevy_derive = { path = "../bevy_derive", version = "0.5.0" }
bevy_ecs = { path = "../bevy_ecs", version = "0.5.0" }
bevy_math = { path = "../bevy_math", version = "0.5.0" }
@ -52,4 +53,3 @@ hex = "0.4.2"
hexasphere = "6.0.0"
parking_lot = "0.11.0"
regex = "1.5"
crevice = { path = "../crevice", version = "0.8.0", features = ["glam"] }

View file

@ -1,5 +1,5 @@
use crate::{
render_resource::DynamicUniformVec,
render_resource::{std140::AsStd140, DynamicUniformVec},
renderer::{RenderDevice, RenderQueue},
RenderApp, RenderStage,
};
@ -14,7 +14,6 @@ use bevy_ecs::{
RunSystem, SystemParamItem,
},
};
use crevice::std140::AsStd140;
use std::{marker::PhantomData, ops::Deref};
/// Stores the index of a uniform inside of [`ComponentUniforms`].

View file

@ -40,3 +40,5 @@ pub use wgpu::{
TextureViewDimension, VertexAttribute, VertexBufferLayout as RawVertexBufferLayout,
VertexFormat, VertexState as RawVertexState, VertexStepMode,
};
pub use bevy_crevice::*;

View file

@ -1,8 +1,8 @@
use crate::{
render_resource::std140::{self, AsStd140, DynamicUniform, Std140},
render_resource::Buffer,
renderer::{RenderDevice, RenderQueue},
};
use crevice::std140::{self, AsStd140, DynamicUniform, Std140};
use std::num::NonZeroU64;
use wgpu::{BindingResource, BufferBinding, BufferDescriptor, BufferUsages};

View file

@ -10,7 +10,7 @@ pub use window::*;
use crate::{
camera::{ExtractedCamera, ExtractedCameraNames},
render_resource::{DynamicUniformVec, Texture, TextureView},
render_resource::{std140::AsStd140, DynamicUniformVec, Texture, TextureView},
renderer::{RenderDevice, RenderQueue},
texture::{BevyDefault, TextureCache},
RenderApp, RenderStage,
@ -19,7 +19,6 @@ use bevy_app::{App, Plugin};
use bevy_ecs::prelude::*;
use bevy_math::{Mat4, Vec3};
use bevy_transform::components::GlobalTransform;
use crevice::std140::AsStd140;
pub struct ViewPlugin;

View file

@ -26,7 +26,6 @@ bevy_utils = { path = "../bevy_utils", version = "0.5.0" }
# other
bytemuck = { version = "1.5", features = ["derive"] }
crevice = { path = "../crevice", version = "0.8.0", features = ["glam"] }
guillotiere = "0.6.0"
thiserror = "1.0"
rectangle-pack = "0.4"

View file

@ -16,7 +16,7 @@ use bevy_render::{
color::Color,
render_asset::RenderAssets,
render_phase::{Draw, DrawFunctions, RenderPhase, TrackedRenderPass},
render_resource::*,
render_resource::{std140::AsStd140, *},
renderer::{RenderDevice, RenderQueue},
texture::{BevyDefault, Image},
view::{ComputedVisibility, ViewUniform, ViewUniformOffset, ViewUniforms},
@ -25,7 +25,6 @@ use bevy_render::{
use bevy_transform::components::GlobalTransform;
use bevy_utils::HashMap;
use bytemuck::{Pod, Zeroable};
use crevice::std140::AsStd140;
pub struct SpritePipeline {
view_layout: BindGroupLayout,

View file

@ -32,4 +32,3 @@ stretch = "0.3.2"
serde = { version = "1", features = ["derive"] }
smallvec = { version = "1.6", features = ["union", "const_generics"] }
bytemuck = { version = "1.5", features = ["derive"] }
crevice = { path = "../crevice", version = "0.8.0", features = ["glam"] }

View file

@ -1,10 +1,11 @@
use bevy_ecs::prelude::*;
use bevy_render::{
render_resource::*, renderer::RenderDevice, texture::BevyDefault, view::ViewUniform,
render_resource::{std140::AsStd140, *},
renderer::RenderDevice,
texture::BevyDefault,
view::ViewUniform,
};
use crevice::std140::AsStd140;
pub struct UiPipeline {
pub view_layout: BindGroupLayout,
pub image_layout: BindGroupLayout,

View file

@ -1,30 +0,0 @@
mod glsl;
mod layout;
use proc_macro::TokenStream as CompilerTokenStream;
use syn::{parse_macro_input, DeriveInput};
#[proc_macro_derive(AsStd140)]
pub fn derive_as_std140(input: CompilerTokenStream) -> CompilerTokenStream {
let input = parse_macro_input!(input as DeriveInput);
let expanded = layout::emit(input, "Std140", "std140", 16);
CompilerTokenStream::from(expanded)
}
#[proc_macro_derive(AsStd430)]
pub fn derive_as_std430(input: CompilerTokenStream) -> CompilerTokenStream {
let input = parse_macro_input!(input as DeriveInput);
let expanded = layout::emit(input, "Std430", "std430", 0);
CompilerTokenStream::from(expanded)
}
#[proc_macro_derive(GlslStruct)]
pub fn derive_glsl_struct(input: CompilerTokenStream) -> CompilerTokenStream {
let input = parse_macro_input!(input as DeriveInput);
let expanded = glsl::emit(input);
CompilerTokenStream::from(expanded)
}

View file

@ -15,13 +15,15 @@ use bevy::{
AddRenderCommand, DrawFunctions, EntityRenderCommand, RenderCommandResult, RenderPhase,
SetItemPipeline, TrackedRenderPass,
},
render_resource::*,
render_resource::{
std140::{AsStd140, Std140},
*,
},
renderer::RenderDevice,
view::{ExtractedView, Msaa},
RenderApp, RenderStage,
},
};
use crevice::std140::{AsStd140, Std140};
fn main() {
App::new()

View file

@ -18,6 +18,8 @@ crates=(
bevy_diagnostic
bevy_transform
bevy_window
bevy_crevice/bevy-crevice-derive
bevy_crevice
bevy_render
bevy_core_pipeline
bevy_input