-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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 4 commits
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 |
---|---|---|
|
@@ -60,8 +60,9 @@ impl Plugin for ViewPlugin { | |
/// ``` | ||
/// # use bevy_app::prelude::App; | ||
/// # use bevy_render::prelude::Msaa; | ||
/// # use bevy_render::prelude::MultiSampleLevel; | ||
/// App::new() | ||
/// .insert_resource(Msaa { samples: 4 }) | ||
/// .insert_resource(Msaa::from(MultiSampleLevel::Sample4)) | ||
/// .run(); | ||
/// ``` | ||
#[derive(Resource, Clone, ExtractResource, Reflect)] | ||
|
@@ -74,15 +75,36 @@ 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 { | ||
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)] | ||
#[non_exhaustive] | ||
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 +356,15 @@ fn prepare_view_targets( | |
}, | ||
) | ||
.default_view, | ||
sampled: (msaa.samples > 1).then(|| { | ||
sampled: (msaa.samples() > 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.samples(), | ||
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.
this should probably be inlined