From 72721f54be1be36d4a021826dcc54216495f5ebd Mon Sep 17 00:00:00 2001 From: JMS55 <47158642+JMS55@users.noreply.github.com> Date: Fri, 29 Dec 2023 14:58:46 -0800 Subject: [PATCH] Misc cleanup --- .../src/core_3d/main_opaque_pass_3d_node.rs | 2 +- crates/bevy_pbr/src/deferred/mod.rs | 4 +-- crates/bevy_pbr/src/light.rs | 2 +- crates/bevy_pbr/src/material.rs | 12 +++---- crates/bevy_pbr/src/render/mesh.rs | 8 ++--- crates/bevy_pbr/src/ssao/mod.rs | 6 ++-- crates/bevy_render/src/render_resource/mod.rs | 35 ++++++++++--------- 7 files changed, 35 insertions(+), 34 deletions(-) diff --git a/crates/bevy_core_pipeline/src/core_3d/main_opaque_pass_3d_node.rs b/crates/bevy_core_pipeline/src/core_3d/main_opaque_pass_3d_node.rs index 2705d74f119db..7ed385043c8ca 100644 --- a/crates/bevy_core_pipeline/src/core_3d/main_opaque_pass_3d_node.rs +++ b/crates/bevy_core_pipeline/src/core_3d/main_opaque_pass_3d_node.rs @@ -4,7 +4,7 @@ use crate::{ prepass::{DeferredPrepass, DepthPrepass, MotionVectorPrepass, NormalPrepass}, skybox::{SkyboxBindGroup, SkyboxPipelineId}, }; -use bevy_ecs::{prelude::*, query::QueryItem}; +use bevy_ecs::{prelude::World, query::QueryItem}; use bevy_render::{ camera::ExtractedCamera, render_graph::{NodeRunError, RenderGraphContext, ViewNode}, diff --git a/crates/bevy_pbr/src/deferred/mod.rs b/crates/bevy_pbr/src/deferred/mod.rs index 10fa044de2e3c..857556b3501a5 100644 --- a/crates/bevy_pbr/src/deferred/mod.rs +++ b/crates/bevy_pbr/src/deferred/mod.rs @@ -418,7 +418,7 @@ pub fn prepare_deferred_lighting_pipelines( Option<&DebandDither>, Option<&EnvironmentMapLight>, Option<&ShadowFilteringMethod>, - Option<&ScreenSpaceAmbientOcclusionSettings>, + Has, ( Has, Has, @@ -480,7 +480,7 @@ pub fn prepare_deferred_lighting_pipelines( } } - if ssao.is_some() { + if ssao { view_key |= MeshPipelineKey::SCREEN_SPACE_AMBIENT_OCCLUSION; } diff --git a/crates/bevy_pbr/src/light.rs b/crates/bevy_pbr/src/light.rs index c67d0cfe578cd..c67f10911a87e 100644 --- a/crates/bevy_pbr/src/light.rs +++ b/crates/bevy_pbr/src/light.rs @@ -15,7 +15,7 @@ use bevy_render::{ renderer::RenderDevice, view::{InheritedVisibility, RenderLayers, ViewVisibility, VisibleEntities}, }; -use bevy_transform::{components::GlobalTransform, prelude::Transform}; +use bevy_transform::components::{GlobalTransform, Transform}; use bevy_utils::{tracing::warn, HashMap}; use crate::*; diff --git a/crates/bevy_pbr/src/material.rs b/crates/bevy_pbr/src/material.rs index d1c521724269c..f729b5b3e2e38 100644 --- a/crates/bevy_pbr/src/material.rs +++ b/crates/bevy_pbr/src/material.rs @@ -416,7 +416,7 @@ const fn alpha_mode_pipeline_key(alpha_mode: AlphaMode) -> MeshPipelineKey { } } -const fn tonemapping_pipeline_key(tonemapping: Tonemapping) -> MeshPipelineKey { +pub const fn tonemapping_pipeline_key(tonemapping: Tonemapping) -> MeshPipelineKey { match tonemapping { Tonemapping::None => MeshPipelineKey::TONEMAP_METHOD_NONE, Tonemapping::Reinhard => MeshPipelineKey::TONEMAP_METHOD_REINHARD, @@ -431,7 +431,7 @@ const fn tonemapping_pipeline_key(tonemapping: Tonemapping) -> MeshPipelineKey { } } -const fn screen_space_specular_transmission_pipeline_key( +pub const fn screen_space_specular_transmission_pipeline_key( screen_space_transmissive_blur_quality: ScreenSpaceTransmissionQuality, ) -> MeshPipelineKey { match screen_space_transmissive_blur_quality { @@ -472,7 +472,7 @@ pub fn queue_material_meshes( Option<&DebandDither>, Option<&EnvironmentMapLight>, Option<&ShadowFilteringMethod>, - Option<&ScreenSpaceAmbientOcclusionSettings>, + Has, ( Has, Has, @@ -480,7 +480,7 @@ pub fn queue_material_meshes( Has, ), Option<&Camera3d>, - Option<&TemporalJitter>, + Has, Option<&Projection>, &mut RenderPhase, &mut RenderPhase, @@ -532,7 +532,7 @@ pub fn queue_material_meshes( view_key |= MeshPipelineKey::DEFERRED_PREPASS; } - if temporal_jitter.is_some() { + if temporal_jitter { view_key |= MeshPipelineKey::TEMPORAL_JITTER; } @@ -570,7 +570,7 @@ pub fn queue_material_meshes( view_key |= MeshPipelineKey::DEBAND_DITHER; } } - if ssao.is_some() { + if ssao { view_key |= MeshPipelineKey::SCREEN_SPACE_AMBIENT_OCCLUSION; } if let Some(camera_3d) = camera_3d { diff --git a/crates/bevy_pbr/src/render/mesh.rs b/crates/bevy_pbr/src/render/mesh.rs index a983cbad5e094..867f37680ffc4 100644 --- a/crates/bevy_pbr/src/render/mesh.rs +++ b/crates/bevy_pbr/src/render/mesh.rs @@ -272,9 +272,9 @@ pub fn extract_meshes( transform, previous_transform, handle, - not_receiver, + not_shadow_receiver, transmitted_receiver, - not_caster, + not_shadow_caster, no_automatic_batching, )| { if !view_visibility.get() { @@ -282,7 +282,7 @@ pub fn extract_meshes( } let transform = transform.affine(); let previous_transform = previous_transform.map(|t| t.0).unwrap_or(transform); - let mut flags = if not_receiver { + let mut flags = if not_shadow_receiver { MeshFlags::empty() } else { MeshFlags::SHADOW_RECEIVER @@ -305,7 +305,7 @@ pub fn extract_meshes( RenderMeshInstance { mesh_asset_id: handle.id(), transforms, - shadow_caster: !not_caster, + shadow_caster: !not_shadow_caster, material_bind_group_id: MaterialBindGroupId::default(), automatic_batching: !no_automatic_batching, }, diff --git a/crates/bevy_pbr/src/ssao/mod.rs b/crates/bevy_pbr/src/ssao/mod.rs index f78a068163b02..58c975adbe9db 100644 --- a/crates/bevy_pbr/src/ssao/mod.rs +++ b/crates/bevy_pbr/src/ssao/mod.rs @@ -7,7 +7,7 @@ use bevy_core_pipeline::{ }; use bevy_ecs::{ prelude::{Bundle, Component, Entity}, - query::{QueryItem, With}, + query::{Has, QueryItem, With}, reflect::ReflectComponent, schedule::IntoSystemConfigs, system::{Commands, Query, Res, ResMut, Resource}, @@ -612,7 +612,7 @@ fn prepare_ssao_pipelines( views: Query<( Entity, &ScreenSpaceAmbientOcclusionSettings, - Option<&TemporalJitter>, + Has, )>, ) { for (entity, ssao_settings, temporal_jitter) in &views { @@ -621,7 +621,7 @@ fn prepare_ssao_pipelines( &pipeline, SsaoPipelineKey { ssao_settings: ssao_settings.clone(), - temporal_jitter: temporal_jitter.is_some(), + temporal_jitter, }, ); diff --git a/crates/bevy_render/src/render_resource/mod.rs b/crates/bevy_render/src/render_resource/mod.rs index b90a81472f582..eaeacf5b23608 100644 --- a/crates/bevy_render/src/render_resource/mod.rs +++ b/crates/bevy_render/src/render_resource/mod.rs @@ -32,23 +32,24 @@ pub use uniform_buffer::*; // TODO: decide where re-exports should go pub use wgpu::{ - util::BufferInitDescriptor, AdapterInfo as WgpuAdapterInfo, AddressMode, BindGroupDescriptor, - BindGroupEntry, BindGroupLayoutDescriptor, BindGroupLayoutEntry, BindingResource, BindingType, - BlendComponent, BlendFactor, BlendOperation, BlendState, BufferAddress, BufferAsyncError, - BufferBinding, BufferBindingType, BufferDescriptor, BufferSize, BufferUsages, ColorTargetState, - ColorWrites, CommandEncoder, CommandEncoderDescriptor, CompareFunction, ComputePass, - ComputePassDescriptor, ComputePipelineDescriptor as RawComputePipelineDescriptor, - DepthBiasState, DepthStencilState, Extent3d, Face, Features as WgpuFeatures, FilterMode, - FragmentState as RawFragmentState, FrontFace, ImageCopyBuffer, ImageCopyBufferBase, - ImageCopyTexture, ImageCopyTextureBase, ImageDataLayout, ImageSubresourceRange, IndexFormat, - Limits as WgpuLimits, LoadOp, Maintain, MapMode, MultisampleState, Operations, Origin3d, - PipelineLayout, PipelineLayoutDescriptor, PolygonMode, PrimitiveState, PrimitiveTopology, - PushConstantRange, RenderPassColorAttachment, RenderPassDepthStencilAttachment, - RenderPassDescriptor, RenderPipelineDescriptor as RawRenderPipelineDescriptor, - SamplerBindingType, SamplerDescriptor, ShaderModule, ShaderModuleDescriptor, ShaderSource, - ShaderStages, StencilFaceState, StencilOperation, StencilState, StorageTextureAccess, StoreOp, - TextureAspect, TextureDescriptor, TextureDimension, TextureFormat, TextureSampleType, - TextureUsages, TextureViewDescriptor, TextureViewDimension, VertexAttribute, + util::{BufferInitDescriptor, DrawIndexedIndirect}, + AdapterInfo as WgpuAdapterInfo, AddressMode, BindGroupDescriptor, BindGroupEntry, + BindGroupLayoutDescriptor, BindGroupLayoutEntry, BindingResource, BindingType, BlendComponent, + BlendFactor, BlendOperation, BlendState, BufferAddress, BufferAsyncError, BufferBinding, + BufferBindingType, BufferDescriptor, BufferSize, BufferUsages, ColorTargetState, ColorWrites, + CommandEncoder, CommandEncoderDescriptor, CompareFunction, ComputePass, ComputePassDescriptor, + ComputePipelineDescriptor as RawComputePipelineDescriptor, DepthBiasState, DepthStencilState, + Extent3d, Face, Features as WgpuFeatures, FilterMode, FragmentState as RawFragmentState, + FrontFace, ImageCopyBuffer, ImageCopyBufferBase, ImageCopyTexture, ImageCopyTextureBase, + ImageDataLayout, ImageSubresourceRange, IndexFormat, Limits as WgpuLimits, LoadOp, Maintain, + MapMode, MultisampleState, Operations, Origin3d, PipelineLayout, PipelineLayoutDescriptor, + PolygonMode, PrimitiveState, PrimitiveTopology, PushConstantRange, RenderPassColorAttachment, + RenderPassDepthStencilAttachment, RenderPassDescriptor, + RenderPipelineDescriptor as RawRenderPipelineDescriptor, SamplerBindingType, SamplerDescriptor, + ShaderModule, ShaderModuleDescriptor, ShaderSource, ShaderStages, StencilFaceState, + StencilOperation, StencilState, StorageTextureAccess, StoreOp, TextureAspect, + TextureDescriptor, TextureDimension, TextureFormat, TextureSampleType, TextureUsages, + TextureViewDescriptor, TextureViewDimension, VertexAttribute, VertexBufferLayout as RawVertexBufferLayout, VertexFormat, VertexState as RawVertexState, VertexStepMode, };