-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changed Msaa to take level rather than int #6954
Changes from 1 commit
c02613b
5f1f5be
3741651
79b0d02
bd3e955
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -61,11 +61,12 @@ impl Plugin for ViewPlugin { | |||||||
/// # use bevy_app::prelude::App; | ||||||||
/// # use bevy_render::prelude::Msaa; | ||||||||
/// App::new() | ||||||||
/// .insert_resource(Msaa { samples: 4 }) | ||||||||
/// .insert_resource(Msaa::from(MultiSampleLevel::Sample4)) | ||||||||
/// .run(); | ||||||||
/// ``` | ||||||||
#[derive(Resource, Clone, ExtractResource, Reflect)] | ||||||||
#[reflect(Resource)] | ||||||||
#[non_exhaustive] | ||||||||
pub struct Msaa { | ||||||||
/// The number of samples to run for Multi-Sample Anti-Aliasing. Higher numbers result in | ||||||||
/// smoother edges. | ||||||||
|
@@ -74,15 +75,35 @@ pub struct Msaa { | |||||||
/// Note that WGPU currently only supports 1 or 4 samples. | ||||||||
/// Ultimately we plan on supporting whatever is natively supported on a given device. | ||||||||
/// Check out this issue for more info: <https://github.com/gfx-rs/wgpu/issues/1832> | ||||||||
pub samples: u32, | ||||||||
pub level: MultiSampleLevel, | ||||||||
} | ||||||||
|
||||||||
impl Msaa { | ||||||||
pub fn samples(&self) -> u32 { | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
this should probably be inlined |
||||||||
self.level as u32 | ||||||||
} | ||||||||
} | ||||||||
|
||||||||
impl Default for Msaa { | ||||||||
fn default() -> Self { | ||||||||
Self { samples: 4 } | ||||||||
Self { | ||||||||
level: MultiSampleLevel::Sample4, | ||||||||
} | ||||||||
} | ||||||||
} | ||||||||
|
||||||||
impl From<MultiSampleLevel> for Msaa { | ||||||||
fn from(level: MultiSampleLevel) -> Self { | ||||||||
Self { level } | ||||||||
} | ||||||||
} | ||||||||
|
||||||||
#[derive(Clone, Copy, Reflect, PartialEq)] | ||||||||
pub enum MultiSampleLevel { | ||||||||
Off = 1, | ||||||||
Sample4 = 4, | ||||||||
} | ||||||||
Comment on lines
+104
to
+107
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't we also add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Never mind, the support for this has been merged into Wgpu but not released yet. |
||||||||
|
||||||||
#[derive(Component)] | ||||||||
pub struct ExtractedView { | ||||||||
pub projection: Mat4, | ||||||||
|
@@ -334,15 +355,15 @@ fn prepare_view_targets( | |||||||
}, | ||||||||
) | ||||||||
.default_view, | ||||||||
sampled: (msaa.samples > 1).then(|| { | ||||||||
sampled: (msaa.level as u32 > 1).then(|| { | ||||||||
texture_cache | ||||||||
.get( | ||||||||
&render_device, | ||||||||
TextureDescriptor { | ||||||||
label: Some("main_texture_sampled"), | ||||||||
size, | ||||||||
mip_level_count: 1, | ||||||||
sample_count: msaa.samples, | ||||||||
sample_count: msaa.level as u32, | ||||||||
dimension: TextureDimension::D2, | ||||||||
format: main_texture_format, | ||||||||
usage: TextureUsages::RENDER_ATTACHMENT, | ||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,11 +2,11 @@ | |
//! Shows the effects of different blend modes. | ||
//! The `fade_transparency` system smoothly changes the transparency over time. | ||
|
||
use bevy::prelude::*; | ||
use bevy::{prelude::*, render::view::MultiSampleLevel}; | ||
|
||
fn main() { | ||
App::new() | ||
.insert_resource(Msaa { samples: 4 }) | ||
.insert_resource(Msaa::from(MultiSampleLevel::Sample4)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rather than complicate this with two types, maybe it should just be a flat enum? |
||
.add_plugins(DefaultPlugins) | ||
.add_startup_system(setup) | ||
.add_system(fade_transparency) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wha the reason for this addition?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only 1 and 4 are supported for now by wgpu: gfx-rs/wgpu#1832
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But shouldn't this then be applied to the
MultiSampleLevel
enum (which would gain the new levels) and notMsaa
struct (which shouldn't receive any new fields due to that)?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup this should be on the new enum
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed