From 63dc736ecf77f9de9626ed07b692faa488549972 Mon Sep 17 00:00:00 2001 From: hodasemi Date: Sat, 21 Jan 2023 07:31:09 +0100 Subject: [PATCH] Use multisampling for UI texture --- src/overlay/elements/leaderboard/bg_generator.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/overlay/elements/leaderboard/bg_generator.rs b/src/overlay/elements/leaderboard/bg_generator.rs index 7a931a6..bf62cdf 100644 --- a/src/overlay/elements/leaderboard/bg_generator.rs +++ b/src/overlay/elements/leaderboard/bg_generator.rs @@ -19,6 +19,8 @@ impl BackgroundGenerator { color: [f32; 4], image_infos: [(u32, u32); N], ) -> Result<[Arc; N]> { + let max_supported_sample_count = device.max_supported_sample_count(VK_SAMPLE_COUNT_16_BIT); + let vertex_shader = ShaderModule::from_slice( device.clone(), include_bytes!("generator.vert.spv"), @@ -48,7 +50,17 @@ impl BackgroundGenerator { let render_target = RenderTarget::builder() .add_sub_pass( SubPass::builder(image.width(), image.height()) - .set_prepared_targets(&[image.clone()], 0, [0.0, 0.0, 0.0, 0.0], true) + .add_target_info(CustomTarget { + usage: VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT.into(), + format: image.vk_format(), + clear_on_load: true, + store_on_save: true, + attach_sampler: false, + use_as_input: false, + clear_value: ClearValue::Color([0.0, 0.0, 0.0, 0.0]), + }) + .set_sample_count(max_supported_sample_count) + .add_resolve_targets(vec![image.clone()]) .build(&device, &queue)?, ) .build(&device)?; @@ -102,7 +114,7 @@ impl BackgroundGenerator { .default_depth_stencil(false, false) .default_color_blend(vec![VkPipelineColorBlendAttachmentState::default()]) .default_rasterization(VK_CULL_MODE_NONE, VK_FRONT_FACE_COUNTER_CLOCKWISE) - .default_multisample(VK_SAMPLE_COUNT_1_BIT) + .default_multisample(max_supported_sample_count) .add_viewport(viewport) .add_scissor(scissor) .build(