Use crevice std140_size_static everywhere (#3168)

# Objective

- Use `std140_size_static()` everywhere instead of manual sizes as the crevice rewrite appears to have fixed all the problems as it claimed to do.

I've tested `3d_scene_pipelined`, `bevymark_pipelined`, and `load_gltf_pipelined` and all three look fine.
This commit is contained in:
Robert Swain 2021-11-22 21:44:05 +00:00
parent 900acc6154
commit 65e834ce8d
4 changed files with 14 additions and 20 deletions

View file

@ -25,7 +25,9 @@ use bevy_render2::{
render_resource::*, render_resource::*,
renderer::{RenderContext, RenderDevice, RenderQueue}, renderer::{RenderContext, RenderDevice, RenderQueue},
texture::*, texture::*,
view::{ExtractedView, ViewUniformOffset, ViewUniforms, VisibleEntities, VisibleEntity}, view::{
ExtractedView, ViewUniform, ViewUniformOffset, ViewUniforms, VisibleEntities, VisibleEntity,
},
}; };
use bevy_transform::components::GlobalTransform; use bevy_transform::components::GlobalTransform;
use crevice::std140::AsStd140; use crevice::std140::AsStd140;
@ -155,9 +157,7 @@ impl FromWorld for ShadowPipeline {
ty: BindingType::Buffer { ty: BindingType::Buffer {
ty: BufferBindingType::Uniform, ty: BufferBindingType::Uniform,
has_dynamic_offset: true, has_dynamic_offset: true,
// TODO: change this to ViewUniform::std140_size_static once crevice fixes this! min_binding_size: BufferSize::new(ViewUniform::std140_size_static() as u64),
// Context: https://github.com/LPGhatguy/crevice/issues/29
min_binding_size: BufferSize::new(144),
}, },
count: None, count: None,
}, },

View file

@ -1,6 +1,6 @@
use crate::{ use crate::{
LightMeta, NotShadowCaster, NotShadowReceiver, ShadowPipeline, ViewLightsUniformOffset, GpuLights, LightMeta, NotShadowCaster, NotShadowReceiver, ShadowPipeline,
ViewShadowBindings, ViewLightsUniformOffset, ViewShadowBindings,
}; };
use bevy_app::Plugin; use bevy_app::Plugin;
use bevy_asset::{Assets, Handle, HandleUntyped}; use bevy_asset::{Assets, Handle, HandleUntyped};
@ -18,7 +18,7 @@ use bevy_render2::{
render_resource::*, render_resource::*,
renderer::{RenderDevice, RenderQueue}, renderer::{RenderDevice, RenderQueue},
texture::{BevyDefault, GpuImage, Image, TextureFormatPixelInfo}, texture::{BevyDefault, GpuImage, Image, TextureFormatPixelInfo},
view::{ComputedVisibility, ViewUniformOffset, ViewUniforms}, view::{ComputedVisibility, ViewUniform, ViewUniformOffset, ViewUniforms},
RenderApp, RenderStage, RenderApp, RenderStage,
}; };
use bevy_transform::components::GlobalTransform; use bevy_transform::components::GlobalTransform;
@ -180,9 +180,7 @@ impl FromWorld for MeshPipeline {
ty: BindingType::Buffer { ty: BindingType::Buffer {
ty: BufferBindingType::Uniform, ty: BufferBindingType::Uniform,
has_dynamic_offset: true, has_dynamic_offset: true,
// TODO: change this to ViewUniform::std140_size_static once crevice fixes this! min_binding_size: BufferSize::new(ViewUniform::std140_size_static() as u64),
// Context: https://github.com/LPGhatguy/crevice/issues/29
min_binding_size: BufferSize::new(144),
}, },
count: None, count: None,
}, },
@ -193,9 +191,7 @@ impl FromWorld for MeshPipeline {
ty: BindingType::Buffer { ty: BindingType::Buffer {
ty: BufferBindingType::Uniform, ty: BufferBindingType::Uniform,
has_dynamic_offset: true, has_dynamic_offset: true,
// TODO: change this to GpuLights::std140_size_static once crevice fixes this! min_binding_size: BufferSize::new(GpuLights::std140_size_static() as u64),
// Context: https://github.com/LPGhatguy/crevice/issues/29
min_binding_size: BufferSize::new(1424),
}, },
count: None, count: None,
}, },
@ -252,9 +248,7 @@ impl FromWorld for MeshPipeline {
ty: BindingType::Buffer { ty: BindingType::Buffer {
ty: BufferBindingType::Uniform, ty: BufferBindingType::Uniform,
has_dynamic_offset: true, has_dynamic_offset: true,
// TODO: change this to MeshUniform::std140_size_static once crevice fixes this! min_binding_size: BufferSize::new(MeshUniform::std140_size_static() as u64),
// Context: https://github.com/LPGhatguy/crevice/issues/29
min_binding_size: BufferSize::new(144),
}, },
count: None, count: None,
}], }],

View file

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

View file

@ -19,12 +19,13 @@ use bevy_render2::{
render_resource::*, render_resource::*,
renderer::{RenderDevice, RenderQueue}, renderer::{RenderDevice, RenderQueue},
texture::{BevyDefault, Image}, texture::{BevyDefault, Image},
view::{ComputedVisibility, ViewUniformOffset, ViewUniforms}, view::{ComputedVisibility, ViewUniform, ViewUniformOffset, ViewUniforms},
RenderWorld, RenderWorld,
}; };
use bevy_transform::components::GlobalTransform; use bevy_transform::components::GlobalTransform;
use bevy_utils::HashMap; use bevy_utils::HashMap;
use bytemuck::{Pod, Zeroable}; use bytemuck::{Pod, Zeroable};
use crevice::std140::AsStd140;
pub struct SpritePipeline { pub struct SpritePipeline {
view_layout: BindGroupLayout, view_layout: BindGroupLayout,
@ -43,9 +44,7 @@ impl FromWorld for SpritePipeline {
ty: BindingType::Buffer { ty: BindingType::Buffer {
ty: BufferBindingType::Uniform, ty: BufferBindingType::Uniform,
has_dynamic_offset: true, has_dynamic_offset: true,
// TODO: change this to ViewUniform::std140_size_static once crevice fixes this! min_binding_size: BufferSize::new(ViewUniform::std140_size_static() as u64),
// Context: https://github.com/LPGhatguy/crevice/issues/29
min_binding_size: BufferSize::new(144),
}, },
count: None, count: None,
}], }],