Skip to content

Commit 2158f3d

Browse files
Ciorazmockersfjanhohenheim
authored
Using Cas instead of CAS #14341 (#14357)
# Objective - Replacing CAS with Cas in CASPlugin - Closes #14341 ## Solution - Simple replace --------- Co-authored-by: François Mockers <francois.mockers@vleue.com> Co-authored-by: Jan Hohenheim <jan@hohenheim.ch> Co-authored-by: François Mockers <mockersf@gmail.com>
1 parent c0b35d0 commit 2158f3d

File tree

3 files changed

+37
-37
lines changed

3 files changed

+37
-37
lines changed

crates/bevy_core_pipeline/src/contrast_adaptive_sharpening/mod.rs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use bevy_render::{
2323

2424
mod node;
2525

26-
pub use node::CASNode;
26+
pub use node::CasNode;
2727

2828
/// Applies a contrast adaptive sharpening (CAS) filter to the camera.
2929
///
@@ -66,28 +66,28 @@ impl Default for ContrastAdaptiveSharpeningSettings {
6666

6767
#[derive(Component, Default, Reflect, Clone)]
6868
#[reflect(Component)]
69-
pub struct DenoiseCAS(bool);
69+
pub struct DenoiseCas(bool);
7070

7171
/// The uniform struct extracted from [`ContrastAdaptiveSharpeningSettings`] attached to a [`Camera`].
7272
/// Will be available for use in the CAS shader.
7373
#[doc(hidden)]
7474
#[derive(Component, ShaderType, Clone)]
75-
pub struct CASUniform {
75+
pub struct CasUniform {
7676
sharpness: f32,
7777
}
7878

7979
impl ExtractComponent for ContrastAdaptiveSharpeningSettings {
8080
type QueryData = &'static Self;
8181
type QueryFilter = With<Camera>;
82-
type Out = (DenoiseCAS, CASUniform);
82+
type Out = (DenoiseCas, CasUniform);
8383

8484
fn extract_component(item: QueryItem<Self::QueryData>) -> Option<Self::Out> {
8585
if !item.enabled || item.sharpening_strength == 0.0 {
8686
return None;
8787
}
8888
Some((
89-
DenoiseCAS(item.denoise),
90-
CASUniform {
89+
DenoiseCas(item.denoise),
90+
CasUniform {
9191
// above 1.0 causes extreme artifacts and fireflies
9292
sharpness: item.sharpening_strength.clamp(0.0, 1.0),
9393
},
@@ -99,9 +99,9 @@ const CONTRAST_ADAPTIVE_SHARPENING_SHADER_HANDLE: Handle<Shader> =
9999
Handle::weak_from_u128(6925381244141981602);
100100

101101
/// Adds Support for Contrast Adaptive Sharpening (CAS).
102-
pub struct CASPlugin;
102+
pub struct CasPlugin;
103103

104-
impl Plugin for CASPlugin {
104+
impl Plugin for CasPlugin {
105105
fn build(&self, app: &mut App) {
106106
load_internal_asset!(
107107
app,
@@ -113,19 +113,19 @@ impl Plugin for CASPlugin {
113113
app.register_type::<ContrastAdaptiveSharpeningSettings>();
114114
app.add_plugins((
115115
ExtractComponentPlugin::<ContrastAdaptiveSharpeningSettings>::default(),
116-
UniformComponentPlugin::<CASUniform>::default(),
116+
UniformComponentPlugin::<CasUniform>::default(),
117117
));
118118

119119
let Some(render_app) = app.get_sub_app_mut(RenderApp) else {
120120
return;
121121
};
122122
render_app
123-
.init_resource::<SpecializedRenderPipelines<CASPipeline>>()
123+
.init_resource::<SpecializedRenderPipelines<CasPipeline>>()
124124
.add_systems(Render, prepare_cas_pipelines.in_set(RenderSet::Prepare));
125125

126126
{
127127
render_app
128-
.add_render_graph_node::<CASNode>(Core3d, Node3d::ContrastAdaptiveSharpening)
128+
.add_render_graph_node::<CasNode>(Core3d, Node3d::ContrastAdaptiveSharpening)
129129
.add_render_graph_edge(
130130
Core3d,
131131
Node3d::Tonemapping,
@@ -142,7 +142,7 @@ impl Plugin for CASPlugin {
142142
}
143143
{
144144
render_app
145-
.add_render_graph_node::<CASNode>(Core2d, Node2d::ContrastAdaptiveSharpening)
145+
.add_render_graph_node::<CasNode>(Core2d, Node2d::ContrastAdaptiveSharpening)
146146
.add_render_graph_edge(
147147
Core2d,
148148
Node2d::Tonemapping,
@@ -163,17 +163,17 @@ impl Plugin for CASPlugin {
163163
let Some(render_app) = app.get_sub_app_mut(RenderApp) else {
164164
return;
165165
};
166-
render_app.init_resource::<CASPipeline>();
166+
render_app.init_resource::<CasPipeline>();
167167
}
168168
}
169169

170170
#[derive(Resource)]
171-
pub struct CASPipeline {
171+
pub struct CasPipeline {
172172
texture_bind_group: BindGroupLayout,
173173
sampler: Sampler,
174174
}
175175

176-
impl FromWorld for CASPipeline {
176+
impl FromWorld for CasPipeline {
177177
fn from_world(render_world: &mut World) -> Self {
178178
let render_device = render_world.resource::<RenderDevice>();
179179
let texture_bind_group = render_device.create_bind_group_layout(
@@ -184,28 +184,28 @@ impl FromWorld for CASPipeline {
184184
texture_2d(TextureSampleType::Float { filterable: true }),
185185
sampler(SamplerBindingType::Filtering),
186186
// CAS Settings
187-
uniform_buffer::<CASUniform>(true),
187+
uniform_buffer::<CasUniform>(true),
188188
),
189189
),
190190
);
191191

192192
let sampler = render_device.create_sampler(&SamplerDescriptor::default());
193193

194-
CASPipeline {
194+
CasPipeline {
195195
texture_bind_group,
196196
sampler,
197197
}
198198
}
199199
}
200200

201201
#[derive(PartialEq, Eq, Hash, Clone, Copy)]
202-
pub struct CASPipelineKey {
202+
pub struct CasPipelineKey {
203203
texture_format: TextureFormat,
204204
denoise: bool,
205205
}
206206

207-
impl SpecializedRenderPipeline for CASPipeline {
208-
type Key = CASPipelineKey;
207+
impl SpecializedRenderPipeline for CasPipeline {
208+
type Key = CasPipelineKey;
209209

210210
fn specialize(&self, key: Self::Key) -> RenderPipelineDescriptor {
211211
let mut shader_defs = vec![];
@@ -237,15 +237,15 @@ impl SpecializedRenderPipeline for CASPipeline {
237237
fn prepare_cas_pipelines(
238238
mut commands: Commands,
239239
pipeline_cache: Res<PipelineCache>,
240-
mut pipelines: ResMut<SpecializedRenderPipelines<CASPipeline>>,
241-
sharpening_pipeline: Res<CASPipeline>,
242-
views: Query<(Entity, &ExtractedView, &DenoiseCAS), With<CASUniform>>,
240+
mut pipelines: ResMut<SpecializedRenderPipelines<CasPipeline>>,
241+
sharpening_pipeline: Res<CasPipeline>,
242+
views: Query<(Entity, &ExtractedView, &DenoiseCas), With<CasUniform>>,
243243
) {
244244
for (entity, view, cas_settings) in &views {
245245
let pipeline_id = pipelines.specialize(
246246
&pipeline_cache,
247247
&sharpening_pipeline,
248-
CASPipelineKey {
248+
CasPipelineKey {
249249
denoise: cas_settings.0,
250250
texture_format: if view.hdr {
251251
ViewTarget::TEXTURE_FORMAT_HDR
@@ -255,9 +255,9 @@ fn prepare_cas_pipelines(
255255
},
256256
);
257257

258-
commands.entity(entity).insert(ViewCASPipeline(pipeline_id));
258+
commands.entity(entity).insert(ViewCasPipeline(pipeline_id));
259259
}
260260
}
261261

262262
#[derive(Component)]
263-
pub struct ViewCASPipeline(CachedRenderPipelineId);
263+
pub struct ViewCasPipeline(CachedRenderPipelineId);

crates/bevy_core_pipeline/src/contrast_adaptive_sharpening/node.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::sync::Mutex;
22

3-
use crate::contrast_adaptive_sharpening::ViewCASPipeline;
3+
use crate::contrast_adaptive_sharpening::ViewCasPipeline;
44
use bevy_ecs::prelude::*;
55
use bevy_render::{
66
extract_component::{ComponentUniforms, DynamicUniformIndex},
@@ -13,21 +13,21 @@ use bevy_render::{
1313
view::{ExtractedView, ViewTarget},
1414
};
1515

16-
use super::{CASPipeline, CASUniform};
16+
use super::{CasPipeline, CasUniform};
1717

18-
pub struct CASNode {
18+
pub struct CasNode {
1919
query: QueryState<
2020
(
2121
&'static ViewTarget,
22-
&'static ViewCASPipeline,
23-
&'static DynamicUniformIndex<CASUniform>,
22+
&'static ViewCasPipeline,
23+
&'static DynamicUniformIndex<CasUniform>,
2424
),
2525
With<ExtractedView>,
2626
>,
2727
cached_bind_group: Mutex<Option<(BufferId, TextureViewId, BindGroup)>>,
2828
}
2929

30-
impl FromWorld for CASNode {
30+
impl FromWorld for CasNode {
3131
fn from_world(world: &mut World) -> Self {
3232
Self {
3333
query: QueryState::new(world),
@@ -36,7 +36,7 @@ impl FromWorld for CASNode {
3636
}
3737
}
3838

39-
impl Node for CASNode {
39+
impl Node for CasNode {
4040
fn update(&mut self, world: &mut World) {
4141
self.query.update_archetypes(world);
4242
}
@@ -49,8 +49,8 @@ impl Node for CASNode {
4949
) -> Result<(), NodeRunError> {
5050
let view_entity = graph.view_entity();
5151
let pipeline_cache = world.resource::<PipelineCache>();
52-
let sharpening_pipeline = world.resource::<CASPipeline>();
53-
let uniforms = world.resource::<ComponentUniforms<CASUniform>>();
52+
let sharpening_pipeline = world.resource::<CasPipeline>();
53+
let uniforms = world.resource::<ComponentUniforms<CasUniform>>();
5454

5555
let Ok((target, pipeline, uniform_index)) = self.query.get_manual(world, view_entity)
5656
else {

crates/bevy_core_pipeline/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub mod prelude {
5252
use crate::{
5353
blit::BlitPlugin,
5454
bloom::BloomPlugin,
55-
contrast_adaptive_sharpening::CASPlugin,
55+
contrast_adaptive_sharpening::CasPlugin,
5656
core_2d::Core2dPlugin,
5757
core_3d::Core3dPlugin,
5858
deferred::copy_lighting_id::CopyDeferredLightingIdPlugin,
@@ -97,7 +97,7 @@ impl Plugin for CorePipelinePlugin {
9797
UpscalingPlugin,
9898
BloomPlugin,
9999
FxaaPlugin,
100-
CASPlugin,
100+
CasPlugin,
101101
MotionBlurPlugin,
102102
DepthOfFieldPlugin,
103103
SmaaPlugin,

0 commit comments

Comments
 (0)