diff --git a/assets/shaders/hot.vert b/assets/shaders/hot.vert index 71a610e6e8..1809b220df 100644 --- a/assets/shaders/hot.vert +++ b/assets/shaders/hot.vert @@ -2,7 +2,7 @@ layout(location = 0) in vec3 Vertex_Position; -layout(set = 0, binding = 0) uniform Camera { +layout(set = 0, binding = 0) uniform CameraViewProj { mat4 ViewProj; }; diff --git a/crates/bevy_pbr/src/render_graph/forward_pipeline/forward.frag b/crates/bevy_pbr/src/render_graph/forward_pipeline/forward.frag index fc043c0db5..cf6e3bcf79 100644 --- a/crates/bevy_pbr/src/render_graph/forward_pipeline/forward.frag +++ b/crates/bevy_pbr/src/render_graph/forward_pipeline/forward.frag @@ -14,7 +14,7 @@ layout(location = 2) in vec2 v_Uv; layout(location = 0) out vec4 o_Target; -layout(set = 0, binding = 0) uniform Camera { +layout(set = 0, binding = 0) uniform CameraViewProj { mat4 ViewProj; }; diff --git a/crates/bevy_pbr/src/render_graph/forward_pipeline/forward.vert b/crates/bevy_pbr/src/render_graph/forward_pipeline/forward.vert index 028a86389c..bbba55ea7c 100644 --- a/crates/bevy_pbr/src/render_graph/forward_pipeline/forward.vert +++ b/crates/bevy_pbr/src/render_graph/forward_pipeline/forward.vert @@ -8,7 +8,7 @@ layout(location = 0) out vec3 v_Position; layout(location = 1) out vec3 v_Normal; layout(location = 2) out vec2 v_Uv; -layout(set = 0, binding = 0) uniform Camera { +layout(set = 0, binding = 0) uniform CameraViewProj { mat4 ViewProj; }; diff --git a/crates/bevy_render/src/camera/active_cameras.rs b/crates/bevy_render/src/camera/active_cameras.rs index d6e0a9c060..030c296c98 100644 --- a/crates/bevy_render/src/camera/active_cameras.rs +++ b/crates/bevy_render/src/camera/active_cameras.rs @@ -1,3 +1,5 @@ +use crate::renderer::RenderResourceBindings; + use super::Camera; use bevy_ecs::{ entity::Entity, @@ -5,22 +7,29 @@ use bevy_ecs::{ }; use bevy_utils::HashMap; +#[derive(Debug, Default)] +pub struct ActiveCamera { + pub entity: Option, + pub bindings: RenderResourceBindings, +} + #[derive(Debug, Default)] pub struct ActiveCameras { - pub cameras: HashMap>, + cameras: HashMap, } impl ActiveCameras { pub fn add(&mut self, name: &str) { - self.cameras.insert(name.to_string(), None); + self.cameras + .insert(name.to_string(), ActiveCamera::default()); } - pub fn set(&mut self, name: &str, entity: Entity) { - self.cameras.insert(name.to_string(), Some(entity)); + pub fn get(&self, name: &str) -> Option<&ActiveCamera> { + self.cameras.get(name) } - pub fn get(&self, name: &str) -> Option { - self.cameras.get(name).and_then(|e| *e) + pub fn get_mut(&mut self, name: &str) -> Option<&mut ActiveCamera> { + self.cameras.get_mut(name) } } @@ -29,11 +38,11 @@ pub fn active_cameras_system( query: Query<(Entity, &Camera)>, ) { for (name, active_camera) in active_cameras.cameras.iter_mut() { - if active_camera.is_none() { + if active_camera.entity.is_none() { for (camera_entity, camera) in query.iter() { if let Some(ref current_name) = camera.name { if current_name == name { - *active_camera = Some(camera_entity); + active_camera.entity = Some(camera_entity); } } } diff --git a/crates/bevy_render/src/render_graph/nodes/camera_node.rs b/crates/bevy_render/src/render_graph/nodes/camera_node.rs index 7b814304d9..fdf2c021e6 100644 --- a/crates/bevy_render/src/render_graph/nodes/camera_node.rs +++ b/crates/bevy_render/src/render_graph/nodes/camera_node.rs @@ -3,7 +3,7 @@ use crate::{ render_graph::{CommandQueue, Node, ResourceSlots, SystemNode}, renderer::{ BufferId, BufferInfo, BufferMapMode, BufferUsage, RenderContext, RenderResourceBinding, - RenderResourceBindings, RenderResourceContext, + RenderResourceContext, }, }; use bevy_core::AsBytes; @@ -50,7 +50,6 @@ impl SystemNode for CameraNode { config.0 = Some(CameraNodeState { camera_name: self.camera_name.clone(), command_queue: self.command_queue.clone(), - camera_buffer: None, staging_buffer: None, }) }); @@ -58,53 +57,43 @@ impl SystemNode for CameraNode { } } +const CAMERA_VIEW_PROJ: &str = "CameraViewProj"; +const CAMERA_VIEW: &str = "CameraView"; + #[derive(Debug, Default)] pub struct CameraNodeState { command_queue: CommandQueue, camera_name: Cow<'static, str>, - camera_buffer: Option, staging_buffer: Option, } +const MATRIX_SIZE: usize = std::mem::size_of::<[[f32; 4]; 4]>(); + pub fn camera_node_system( mut state: Local, - active_cameras: Res, + mut active_cameras: ResMut, render_resource_context: Res>, - // PERF: this write on RenderResourceAssignments will prevent this system from running in - // parallel with other systems that do the same - mut render_resource_bindings: ResMut, - query: Query<(&Camera, &GlobalTransform)>, + mut query: Query<(&Camera, &GlobalTransform)>, ) { let render_resource_context = &**render_resource_context; - let (camera, global_transform) = if let Some(entity) = active_cameras.get(&state.camera_name) { - query.get(entity).unwrap() - } else { - return; - }; + let ((camera, global_transform), bindings) = + if let Some(active_camera) = active_cameras.get_mut(&state.camera_name) { + if let Some(entity) = active_camera.entity { + (query.get_mut(entity).unwrap(), &mut active_camera.bindings) + } else { + return; + } + } else { + return; + }; let staging_buffer = if let Some(staging_buffer) = state.staging_buffer { render_resource_context.map_buffer(staging_buffer, BufferMapMode::Write); staging_buffer } else { - let size = std::mem::size_of::<[[f32; 4]; 4]>(); - let buffer = render_resource_context.create_buffer(BufferInfo { - size, - buffer_usage: BufferUsage::COPY_DST | BufferUsage::UNIFORM, - ..Default::default() - }); - render_resource_bindings.set( - &state.camera_name, - RenderResourceBinding::Buffer { - buffer, - range: 0..size as u64, - dynamic_index: None, - }, - ); - state.camera_buffer = Some(buffer); - let staging_buffer = render_resource_context.create_buffer(BufferInfo { - size, + size: MATRIX_SIZE * 2, buffer_usage: BufferUsage::COPY_SRC | BufferUsage::MAP_WRITE, mapped_at_creation: true, }); @@ -113,25 +102,74 @@ pub fn camera_node_system( staging_buffer }; - let matrix_size = std::mem::size_of::<[[f32; 4]; 4]>(); - let camera_matrix: [f32; 16] = - (camera.projection_matrix * global_transform.compute_matrix().inverse()).to_cols_array(); + if bindings.get(CAMERA_VIEW_PROJ).is_none() { + let buffer = render_resource_context.create_buffer(BufferInfo { + size: MATRIX_SIZE, + buffer_usage: BufferUsage::COPY_DST | BufferUsage::UNIFORM, + ..Default::default() + }); + bindings.set( + CAMERA_VIEW_PROJ, + RenderResourceBinding::Buffer { + buffer, + range: 0..MATRIX_SIZE as u64, + dynamic_index: None, + }, + ); + } + + if bindings.get(CAMERA_VIEW).is_none() { + let buffer = render_resource_context.create_buffer(BufferInfo { + size: MATRIX_SIZE, + buffer_usage: BufferUsage::COPY_DST | BufferUsage::UNIFORM, + ..Default::default() + }); + bindings.set( + CAMERA_VIEW, + RenderResourceBinding::Buffer { + buffer, + range: 0..MATRIX_SIZE as u64, + dynamic_index: None, + }, + ); + } + + let view = global_transform.compute_matrix(); + + if let Some(RenderResourceBinding::Buffer { buffer, .. }) = bindings.get(CAMERA_VIEW) { + render_resource_context.write_mapped_buffer( + staging_buffer, + 0..MATRIX_SIZE as u64, + &mut |data, _renderer| { + data[0..MATRIX_SIZE].copy_from_slice(view.to_cols_array_2d().as_bytes()); + }, + ); + state.command_queue.copy_buffer_to_buffer( + staging_buffer, + 0, + *buffer, + 0, + MATRIX_SIZE as u64, + ); + } + + if let Some(RenderResourceBinding::Buffer { buffer, .. }) = bindings.get(CAMERA_VIEW_PROJ) { + let view_proj = camera.projection_matrix * view.inverse(); + render_resource_context.write_mapped_buffer( + staging_buffer, + MATRIX_SIZE as u64..(2 * MATRIX_SIZE) as u64, + &mut |data, _renderer| { + data[0..MATRIX_SIZE].copy_from_slice(view_proj.to_cols_array_2d().as_bytes()); + }, + ); + state.command_queue.copy_buffer_to_buffer( + staging_buffer, + MATRIX_SIZE as u64, + *buffer, + 0, + MATRIX_SIZE as u64, + ); + } - render_resource_context.write_mapped_buffer( - staging_buffer, - 0..matrix_size as u64, - &mut |data, _renderer| { - data[0..matrix_size].copy_from_slice(camera_matrix.as_bytes()); - }, - ); render_resource_context.unmap_buffer(staging_buffer); - - let camera_buffer = state.camera_buffer.unwrap(); - state.command_queue.copy_buffer_to_buffer( - staging_buffer, - 0, - camera_buffer, - 0, - matrix_size as u64, - ); } diff --git a/crates/bevy_render/src/render_graph/nodes/pass_node.rs b/crates/bevy_render/src/render_graph/nodes/pass_node.rs index e105f9bc90..66fef3c857 100644 --- a/crates/bevy_render/src/render_graph/nodes/pass_node.rs +++ b/crates/bevy_render/src/render_graph/nodes/pass_node.rs @@ -9,33 +9,29 @@ use crate::{ prelude::Visible, render_graph::{Node, ResourceSlotInfo, ResourceSlots}, renderer::{ - BindGroup, BindGroupId, BufferId, RenderContext, RenderResourceBindings, RenderResourceType, + BindGroupId, BufferId, RenderContext, RenderResourceBindings, RenderResourceContext, + RenderResourceType, }, }; use bevy_asset::{Assets, Handle}; use bevy_ecs::{ query::{QueryState, ReadOnlyFetch, WorldQuery}, - world::World, + world::{Mut, World}, }; -use bevy_utils::tracing::debug; -use std::{fmt, ops::Deref}; - -#[derive(Debug)] -struct CameraInfo { - name: String, - bind_group_id: Option, -} +use bevy_utils::{tracing::debug, HashMap}; +use std::fmt; pub struct PassNode { descriptor: PassDescriptor, inputs: Vec, - cameras: Vec, + cameras: Vec, color_attachment_input_indices: Vec>, color_resolve_target_indices: Vec>, depth_stencil_attachment_input_index: Option, default_clear_color_inputs: Vec, camera_bind_group_descriptor: BindGroupDescriptor, query_state: Option>, + commands: Vec, } impl fmt::Debug for PassNode { @@ -129,14 +125,12 @@ impl PassNode { default_clear_color_inputs: Vec::new(), camera_bind_group_descriptor, query_state: None, + commands: Vec::new(), } } pub fn add_camera(&mut self, camera_name: &str) { - self.cameras.push(CameraInfo { - name: camera_name.to_string(), - bind_group_id: None, - }); + self.cameras.push(camera_name.to_string()); } pub fn use_default_clear_color(&mut self, color_attachment_index: usize) { @@ -153,7 +147,81 @@ where } fn prepare(&mut self, world: &mut World) { - self.query_state.get_or_insert_with(|| world.query()); + let query_state = self.query_state.get_or_insert_with(|| world.query()); + let cameras = &self.cameras; + let commands = &mut self.commands; + world.resource_scope(|mut active_cameras: Mut, world| { + let mut pipeline_camera_commands = HashMap::default(); + let pipelines = world.get_resource::>().unwrap(); + let render_resource_context = &**world + .get_resource::>() + .unwrap(); + + for camera_name in cameras.iter() { + let active_camera = if let Some(active_camera) = active_cameras.get_mut(camera_name) + { + active_camera + } else { + continue; + }; + + let visible_entities = if let Some(entity) = active_camera.entity { + world.get::(entity).unwrap() + } else { + continue; + }; + for visible_entity in visible_entities.iter() { + if query_state.get(world, visible_entity.entity).is_err() { + // visible entity does not match the Pass query + continue; + } + + let draw = if let Some(draw) = world.get::(visible_entity.entity) { + draw + } else { + continue; + }; + + if let Some(visible) = world.get::(visible_entity.entity) { + if !visible.is_visible { + continue; + } + } + for render_command in draw.render_commands.iter() { + commands.push(render_command.clone()); + // whenever a new pipeline is set, ensure the relevant camera bind groups are set + if let RenderCommand::SetPipeline { pipeline } = render_command { + let bind_groups = pipeline_camera_commands + .entry(pipeline.clone_weak()) + .or_insert_with(|| { + let descriptor = pipelines.get(pipeline).unwrap(); + let layout = descriptor.get_layout().unwrap(); + let mut commands = Vec::new(); + for bind_group_descriptor in layout.bind_groups.iter() { + if let Some(bind_group) = + active_camera.bindings.update_bind_group( + bind_group_descriptor, + render_resource_context, + ) + { + commands.push(RenderCommand::SetBindGroup { + index: bind_group_descriptor.index, + bind_group: bind_group.id, + dynamic_uniform_indices: bind_group + .dynamic_uniform_indices + .clone(), + }) + } + } + commands + }); + + commands.extend(bind_groups.iter().cloned()); + } + } + } + } + }); } fn update( @@ -163,10 +231,6 @@ where input: &ResourceSlots, _output: &mut ResourceSlots, ) { - let render_resource_bindings = world.get_resource::().unwrap(); - let pipelines = world.get_resource::>().unwrap(); - let active_cameras = world.get_resource::().unwrap(); - for (i, color_attachment) in self.descriptor.color_attachments.iter_mut().enumerate() { if self.default_clear_color_inputs.contains(&i) { if let Some(default_clear_color) = world.get_resource::() { @@ -192,158 +256,88 @@ where .attachment = TextureAttachment::Id(input.get(input_index).unwrap().get_texture().unwrap()); } - for camera_info in self.cameras.iter_mut() { - let camera_binding = - if let Some(camera_binding) = render_resource_bindings.get(&camera_info.name) { - camera_binding.clone() - } else { - continue; - }; - if render_context - .resources() - .bind_group_descriptor_exists(self.camera_bind_group_descriptor.id) - { - let camera_bind_group = BindGroup::build().add_binding(0, camera_binding).finish(); - render_context - .resources() - .create_bind_group(self.camera_bind_group_descriptor.id, &camera_bind_group); - camera_info.bind_group_id = Some(camera_bind_group.id); - } - } - let query_state = self.query_state.as_mut().unwrap(); - let cameras = &self.cameras; - let camera_bind_group_descriptor = &self.camera_bind_group_descriptor; + let render_resource_bindings = world.get_resource::().unwrap(); + let pipelines = world.get_resource::>().unwrap(); + + let mut draw_state = DrawState::default(); + let commands = &mut self.commands; render_context.begin_pass( &self.descriptor, &render_resource_bindings, &mut |render_pass| { - for camera_info in cameras.iter() { - let camera_bind_group_id= if let Some(bind_group_id) = camera_info.bind_group_id { - bind_group_id - } else { - continue; - }; - - // get an ordered list of entities visible to the camera - let visible_entities = if let Some(camera_entity) = active_cameras.get(&camera_info.name) { - world.get::(camera_entity).unwrap() - } else { - continue; - }; - - // attempt to draw each visible entity - let mut draw_state = DrawState::default(); - for visible_entity in visible_entities.iter() { - if query_state.get(world, visible_entity.entity).is_err() { - // visible entity does not match the Pass query + for render_command in commands.drain(..) { + match render_command { + RenderCommand::SetPipeline { pipeline } => { + if draw_state.is_pipeline_set(pipeline.clone_weak()) { continue; } - - let draw = if let Some(draw) = world.get::(visible_entity.entity) { - draw + render_pass.set_pipeline(&pipeline); + let descriptor = pipelines.get(&pipeline).unwrap(); + draw_state.set_pipeline(&pipeline, descriptor); + } + RenderCommand::DrawIndexed { + base_vertex, + indices, + instances, + } => { + if draw_state.can_draw_indexed() { + render_pass.draw_indexed( + indices.clone(), + base_vertex, + instances.clone(), + ); } else { - continue; - }; - - if let Some(visible) = world.get::(visible_entity.entity) { - if !visible.is_visible { - continue; - } - } - - // each Draw component contains an ordered list of render commands. we turn those into actual render commands here - for render_command in draw.render_commands.iter() { - match render_command { - RenderCommand::SetPipeline { pipeline } => { - if draw_state.is_pipeline_set(pipeline.clone_weak()) { - continue; - } - render_pass.set_pipeline(pipeline); - let descriptor = pipelines.get(pipeline).unwrap(); - draw_state.set_pipeline(pipeline, descriptor); - - // try to set current camera bind group - let layout = descriptor.get_layout().unwrap(); - if let Some(descriptor) = layout.get_bind_group(0) { - if descriptor == camera_bind_group_descriptor { - draw_state.set_bind_group(0, camera_bind_group_id); - render_pass.set_bind_group( - 0, - descriptor.id, - camera_bind_group_id, - None - ); - } - } - } - RenderCommand::DrawIndexed { - base_vertex, - indices, - instances, - } => { - if draw_state.can_draw_indexed() { - render_pass.draw_indexed( - indices.clone(), - *base_vertex, - instances.clone(), - ); - } else { - debug!("Could not draw indexed because the pipeline layout wasn't fully set for pipeline: {:?}", draw_state.pipeline); - } - } - RenderCommand::Draw { vertices, instances } => { - if draw_state.can_draw() { - render_pass.draw(vertices.clone(), instances.clone()); - } else { - debug!("Could not draw because the pipeline layout wasn't fully set for pipeline: {:?}", draw_state.pipeline); - } - } - RenderCommand::SetVertexBuffer { - buffer, - offset, - slot, - } => { - if draw_state.is_vertex_buffer_set(*slot, *buffer, *offset) { - continue; - } - render_pass.set_vertex_buffer(*slot, *buffer, *offset); - draw_state.set_vertex_buffer(*slot, *buffer, *offset); - } - RenderCommand::SetIndexBuffer { buffer, offset, index_format } => { - if draw_state.is_index_buffer_set(*buffer, *offset, *index_format) { - continue; - } - render_pass.set_index_buffer(*buffer, *offset, *index_format); - draw_state.set_index_buffer(*buffer, *offset, *index_format); - } - RenderCommand::SetBindGroup { - index, - bind_group, - dynamic_uniform_indices, - } => { - if dynamic_uniform_indices.is_none() && draw_state.is_bind_group_set(*index, *bind_group) { - continue; - } - let pipeline = pipelines.get(draw_state.pipeline.as_ref().unwrap()).unwrap(); - let layout = pipeline.get_layout().unwrap(); - let bind_group_descriptor = layout.get_bind_group(*index).unwrap(); - render_pass.set_bind_group( - *index, - bind_group_descriptor.id, - *bind_group, - dynamic_uniform_indices - .as_ref() - .map(|indices| indices.deref()), - ); - draw_state.set_bind_group(*index, *bind_group); - } - } + debug!("Could not draw indexed because the pipeline layout wasn't fully set for pipeline: {:?}", draw_state.pipeline); } } + RenderCommand::Draw { vertices, instances } => { + if draw_state.can_draw() { + render_pass.draw(vertices.clone(), instances.clone()); + } else { + debug!("Could not draw because the pipeline layout wasn't fully set for pipeline: {:?}", draw_state.pipeline); + } + } + RenderCommand::SetVertexBuffer { + buffer, + offset, + slot, + } => { + if draw_state.is_vertex_buffer_set(slot, buffer, offset) { + continue; + } + render_pass.set_vertex_buffer(slot, buffer, offset); + draw_state.set_vertex_buffer(slot, buffer, offset); + } + RenderCommand::SetIndexBuffer { buffer, offset, index_format } => { + if draw_state.is_index_buffer_set(buffer, offset, index_format) { + continue; + } + render_pass.set_index_buffer(buffer, offset, index_format); + draw_state.set_index_buffer(buffer, offset, index_format); + } + RenderCommand::SetBindGroup { + index, + bind_group, + dynamic_uniform_indices, + } => { + if dynamic_uniform_indices.is_none() && draw_state.is_bind_group_set(index, bind_group) { + continue; + } + let pipeline = pipelines.get(draw_state.pipeline.as_ref().unwrap()).unwrap(); + let layout = pipeline.get_layout().unwrap(); + let bind_group_descriptor = layout.get_bind_group(index).unwrap(); + render_pass.set_bind_group( + index, + bind_group_descriptor.id, + bind_group, + dynamic_uniform_indices.as_deref() + ); + draw_state.set_bind_group(index, bind_group); + } } - }, - ); + } + }); } } diff --git a/crates/bevy_render/src/shader/shader_reflect.rs b/crates/bevy_render/src/shader/shader_reflect.rs index fe1ff7167f..78a5f306f1 100644 --- a/crates/bevy_render/src/shader/shader_reflect.rs +++ b/crates/bevy_render/src/shader/shader_reflect.rs @@ -153,23 +153,17 @@ fn reflect_binding( _ => panic!("Unsupported bind type {:?}.", binding.descriptor_type), }; - let mut shader_stage = match shader_stage { + let shader_stage = match shader_stage { ReflectShaderStageFlags::COMPUTE => BindingShaderStage::COMPUTE, ReflectShaderStageFlags::VERTEX => BindingShaderStage::VERTEX, ReflectShaderStageFlags::FRAGMENT => BindingShaderStage::FRAGMENT, _ => panic!("Only one specified shader stage is supported."), }; - let name = name.to_string(); - - if name == "Camera" { - shader_stage = BindingShaderStage::VERTEX | BindingShaderStage::FRAGMENT; - } - BindingDescriptor { index: binding.binding, bind_type, - name, + name: name.to_string(), shader_stage, } } @@ -325,7 +319,7 @@ mod tests { layout(location = 2) in uvec4 I_TestInstancing_Property; layout(location = 0) out vec4 v_Position; - layout(set = 0, binding = 0) uniform Camera { + layout(set = 0, binding = 0) uniform CameraViewProj { mat4 ViewProj; }; layout(set = 1, binding = 0) uniform texture2D Texture; @@ -381,12 +375,12 @@ mod tests { 0, vec![BindingDescriptor { index: 0, - name: "Camera".into(), + name: "CameraViewProj".into(), bind_type: BindType::Uniform { has_dynamic_offset: false, property: UniformProperty::Struct(vec![UniformProperty::Mat4]), }, - shader_stage: BindingShaderStage::VERTEX | BindingShaderStage::FRAGMENT, + shader_stage: BindingShaderStage::VERTEX, }] ), BindGroupDescriptor::new( diff --git a/crates/bevy_render/src/wireframe/wireframe.vert b/crates/bevy_render/src/wireframe/wireframe.vert index 4782840212..87b32a667a 100644 --- a/crates/bevy_render/src/wireframe/wireframe.vert +++ b/crates/bevy_render/src/wireframe/wireframe.vert @@ -2,7 +2,7 @@ layout(location = 0) in vec3 Vertex_Position; -layout(set = 0, binding = 0) uniform Camera { +layout(set = 0, binding = 0) uniform CameraViewProj { mat4 ViewProj; }; diff --git a/crates/bevy_sprite/src/render/sprite.vert b/crates/bevy_sprite/src/render/sprite.vert index 23c77d38c7..2a0cc68e3a 100644 --- a/crates/bevy_sprite/src/render/sprite.vert +++ b/crates/bevy_sprite/src/render/sprite.vert @@ -6,7 +6,7 @@ layout(location = 2) in vec2 Vertex_Uv; layout(location = 0) out vec2 v_Uv; -layout(set = 0, binding = 0) uniform Camera { +layout(set = 0, binding = 0) uniform CameraViewProj { mat4 ViewProj; }; diff --git a/crates/bevy_sprite/src/render/sprite_sheet.vert b/crates/bevy_sprite/src/render/sprite_sheet.vert index d4ddabad7d..72e0f5de93 100644 --- a/crates/bevy_sprite/src/render/sprite_sheet.vert +++ b/crates/bevy_sprite/src/render/sprite_sheet.vert @@ -7,7 +7,7 @@ layout(location = 2) in vec2 Vertex_Uv; layout(location = 0) out vec2 v_Uv; layout(location = 1) out vec4 v_Color; -layout(set = 0, binding = 0) uniform Camera { +layout(set = 0, binding = 0) uniform CameraViewProj { mat4 ViewProj; }; diff --git a/crates/bevy_ui/src/render/ui.vert b/crates/bevy_ui/src/render/ui.vert index 2268af642b..3a00b11f40 100644 --- a/crates/bevy_ui/src/render/ui.vert +++ b/crates/bevy_ui/src/render/ui.vert @@ -6,7 +6,7 @@ layout(location = 2) in vec2 Vertex_Uv; layout(location = 0) out vec2 v_Uv; -layout(set = 0, binding = 0) uniform Camera { +layout(set = 0, binding = 0) uniform CameraViewProj { mat4 ViewProj; }; diff --git a/examples/shader/array_texture.rs b/examples/shader/array_texture.rs index 8dd6e0b627..a94f6a6f12 100644 --- a/examples/shader/array_texture.rs +++ b/examples/shader/array_texture.rs @@ -33,7 +33,7 @@ const VERTEX_SHADER: &str = r#" layout(location = 0) in vec3 Vertex_Position; layout(location = 0) out vec4 v_Position; -layout(set = 0, binding = 0) uniform Camera { +layout(set = 0, binding = 0) uniform CameraViewProj { mat4 ViewProj; }; layout(set = 1, binding = 0) uniform Transform { diff --git a/examples/shader/mesh_custom_attribute.rs b/examples/shader/mesh_custom_attribute.rs index 98abf9c68e..a2a5f5be64 100644 --- a/examples/shader/mesh_custom_attribute.rs +++ b/examples/shader/mesh_custom_attribute.rs @@ -29,7 +29,7 @@ layout(location = 0) in vec3 Vertex_Position; layout(location = 1) in vec3 Vertex_Color; layout(location = 0) out vec3 v_color; -layout(set = 0, binding = 0) uniform Camera { +layout(set = 0, binding = 0) uniform CameraViewProj { mat4 ViewProj; }; layout(set = 1, binding = 0) uniform Transform { diff --git a/examples/shader/shader_custom_material.rs b/examples/shader/shader_custom_material.rs index 029031b373..acd9b3146b 100644 --- a/examples/shader/shader_custom_material.rs +++ b/examples/shader/shader_custom_material.rs @@ -29,7 +29,7 @@ struct MyMaterial { const VERTEX_SHADER: &str = r#" #version 450 layout(location = 0) in vec3 Vertex_Position; -layout(set = 0, binding = 0) uniform Camera { +layout(set = 0, binding = 0) uniform CameraViewProj { mat4 ViewProj; }; layout(set = 1, binding = 0) uniform Transform { diff --git a/examples/shader/shader_defs.rs b/examples/shader/shader_defs.rs index f6f5cb715d..52827d6e95 100644 --- a/examples/shader/shader_defs.rs +++ b/examples/shader/shader_defs.rs @@ -37,7 +37,7 @@ struct MyMaterial { const VERTEX_SHADER: &str = r#" #version 450 layout(location = 0) in vec3 Vertex_Position; -layout(set = 0, binding = 0) uniform Camera { +layout(set = 0, binding = 0) uniform CameraViewProj { mat4 ViewProj; }; layout(set = 1, binding = 0) uniform Transform {