Skip to content

Commit

Permalink
MSAA config: address last round of comments
Browse files Browse the repository at this point in the history
  • Loading branch information
armansito committed Nov 1, 2023
1 parent ea29d30 commit 1efb3a5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 25 deletions.
17 changes: 9 additions & 8 deletions examples/with_winit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,16 +365,17 @@ fn run(

// If the user specifies a base color in the CLI we use that. Otherwise we use any
// color specified by the scene. The default is black.
let aa_config = AA_CONFIGS[aa_config_ix as usize];
let base_color = args
.args
.base_color
.or(scene_params.base_color)
.unwrap_or(Color::BLACK);
let antialiasing_method = AA_CONFIGS[aa_config_ix as usize];
let render_params = vello::RenderParams {
base_color: args
.args
.base_color
.or(scene_params.base_color)
.unwrap_or(Color::BLACK),
base_color,
width,
height,
antialiasing_method: aa_config,
antialiasing_method,
};
let mut builder = SceneBuilder::for_scene(&mut scene);
let mut transform = transform;
Expand All @@ -395,7 +396,7 @@ fn run(
stats.samples(),
complexity_shown.then_some(scene_complexity).flatten(),
vsync_on,
aa_config,
antialiasing_method,
);
if let Some(profiling_result) = renderers[render_state.surface.dev_id]
.as_mut()
Expand Down
24 changes: 7 additions & 17 deletions src/shaders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,7 @@ pub fn full_shaders(
)?
}};
($name:ident, $bindings:expr, $defines:expr, $cpu:expr) => {{
add_shader!(
$name,
stringify!($name),
$bindings,
&$defines,
$cpu
)
add_shader!($name, stringify!($name), $bindings, &$defines, $cpu)
}};
($name:ident, $bindings:expr, $defines:expr) => {
add_shader!(
Expand Down Expand Up @@ -285,28 +279,24 @@ pub fn full_shaders(
let [fine_area, fine_msaa8, fine_msaa16] = {
let aa_support = &options.antialiasing_support;
let aa_modes = [
(aa_support.area, None),
(aa_support.msaa8, Some(("fine_msaa8", "msaa8"))),
(aa_support.msaa16, Some(("fine_msaa16", "msaa16"))),
(aa_support.area, 1, "fine_area", None),
(aa_support.msaa8, 0, "fine_msaa8", Some("msaa8")),
(aa_support.msaa16, 0, "fine_msaa16", Some("msaa16")),
];
let mut pipelines = [None, None, None];
for (i, (enabled, msaa_info)) in aa_modes.iter().enumerate() {
for (i, (enabled, offset, label, aa_config)) in aa_modes.iter().enumerate() {
if !enabled {
continue;
}
let (range_end_offset, label, aa_config) = match *msaa_info {
Some((label, config)) => (0, label, Some(config)),
None => (1, "fine_area", None),
};
let mut config = full_config.clone();
if let Some(aa_config) = aa_config {
if let Some(aa_config) = *aa_config {
config.insert("msaa".into());
config.insert(aa_config.into());
}
pipelines[i] = Some(add_shader!(
fine,
label,
fine_resources[..fine_resources.len() - range_end_offset],
fine_resources[..fine_resources.len() - offset],
config,
CpuShaderType::Missing
));
Expand Down

0 comments on commit 1efb3a5

Please sign in to comment.