diff --git a/pipelined/bevy_pbr2/src/render/mod.rs b/pipelined/bevy_pbr2/src/render/mod.rs index 445d921d630cb..92ff97d231c16 100644 --- a/pipelined/bevy_pbr2/src/render/mod.rs +++ b/pipelined/bevy_pbr2/src/render/mod.rs @@ -488,6 +488,10 @@ pub fn queue_meshes( ) { let mesh_meta = mesh_meta.into_inner(); + if view_meta.uniforms.len() == 0 { + return; + } + light_meta.shadow_view_bind_group.get_or_insert_with(|| { render_device.create_bind_group(&BindGroupDescriptor { entries: &[BindGroupEntry { diff --git a/pipelined/bevy_render2/src/render_resource/uniform_vec.rs b/pipelined/bevy_render2/src/render_resource/uniform_vec.rs index 18134740ce892..164b1c895e963 100644 --- a/pipelined/bevy_render2/src/render_resource/uniform_vec.rs +++ b/pipelined/bevy_render2/src/render_resource/uniform_vec.rs @@ -44,6 +44,11 @@ impl UniformVec { }) } + #[inline] + pub fn len(&self) -> usize { + self.values.len() + } + #[inline] pub fn capacity(&self) -> usize { self.capacity @@ -145,6 +150,11 @@ impl DynamicUniformVec { self.uniform_vec.binding() } + #[inline] + pub fn len(&self) -> usize { + self.uniform_vec.len() + } + #[inline] pub fn capacity(&self) -> usize { self.uniform_vec.capacity() diff --git a/pipelined/bevy_render2/src/renderer/render_device.rs b/pipelined/bevy_render2/src/renderer/render_device.rs index 2063a95ead12e..2cb437c1222ee 100644 --- a/pipelined/bevy_render2/src/renderer/render_device.rs +++ b/pipelined/bevy_render2/src/renderer/render_device.rs @@ -36,7 +36,10 @@ impl RenderDevice { /// Creates a shader module from either SPIR-V or WGSL source code. #[inline] - pub fn create_shader_module<'a>(&self, desc: impl Into>) -> wgpu::ShaderModule { + pub fn create_shader_module<'a>( + &self, + desc: impl Into>, + ) -> wgpu::ShaderModule { self.device.create_shader_module(&desc.into()) } diff --git a/pipelined/bevy_sprite2/src/render/mod.rs b/pipelined/bevy_sprite2/src/render/mod.rs index 3e1de274f7878..1c2e1b80065b3 100644 --- a/pipelined/bevy_sprite2/src/render/mod.rs +++ b/pipelined/bevy_sprite2/src/render/mod.rs @@ -2,7 +2,18 @@ use crate::Sprite; use bevy_asset::{Assets, Handle}; use bevy_ecs::{prelude::*, system::SystemState}; use bevy_math::{Mat4, Vec2, Vec3, Vec4Swizzles}; -use bevy_render2::{core_pipeline::Transparent2dPhase, mesh::{shape::Quad, Indices, Mesh, VertexAttributeValues}, render_asset::RenderAssets, render_graph::{Node, NodeRunError, RenderGraphContext}, render_phase::{Draw, DrawFunctions, Drawable, RenderPhase, TrackedRenderPass}, render_resource::*, renderer::{RenderContext, RenderDevice}, shader::Shader, texture::{BevyDefault, Image}, view::{ViewMeta, ViewUniform, ViewUniformOffset}}; +use bevy_render2::{ + core_pipeline::Transparent2dPhase, + mesh::{shape::Quad, Indices, Mesh, VertexAttributeValues}, + render_asset::RenderAssets, + render_graph::{Node, NodeRunError, RenderGraphContext}, + render_phase::{Draw, DrawFunctions, Drawable, RenderPhase, TrackedRenderPass}, + render_resource::*, + renderer::{RenderContext, RenderDevice}, + shader::Shader, + texture::{BevyDefault, Image}, + view::{ViewMeta, ViewUniform, ViewUniformOffset}, +}; use bevy_transform::components::GlobalTransform; use bevy_utils::slab::{FrameSlabMap, FrameSlabMapKey}; use bytemuck::{Pod, Zeroable}; @@ -276,6 +287,10 @@ pub fn queue_sprites( gpu_images: Res>, mut views: Query<&mut RenderPhase>, ) { + if view_meta.uniforms.len() == 0 { + return; + } + // TODO: define this without needing to check every frame sprite_meta.view_bind_group.get_or_insert_with(|| { render_device.create_bind_group(&BindGroupDescriptor {