From 27e1cf92ad130416aea97255e0793406a85c8f27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois?= Date: Mon, 29 May 2023 17:25:32 +0200 Subject: [PATCH] shader_prepass example: disable MSAA for maximum compatibility (#8504) # Objective Since #8446, example `shader_prepass` logs the following error on my mac m1: ``` ERROR bevy_render::render_resource::pipeline_cache: failed to process shader: error: Entry point fragment at Fragment is invalid = Argument 1 varying error = Capability MULTISAMPLED_SHADING is not supported ``` The example display the 3d scene but doesn't change with the preps selected Maybe related to this update in naga: https://github.com/gfx-rs/naga/commit/cc3a8ac73773e2223c3d45fbc1b22607026e2ec0 ## Solution - Disable MSAA in the example, and check if it's enabled in the shader --- assets/shaders/show_prepass.wgsl | 5 +++++ examples/shader/shader_prepass.rs | 2 ++ 2 files changed, 7 insertions(+) diff --git a/assets/shaders/show_prepass.wgsl b/assets/shaders/show_prepass.wgsl index 7369cdadae..cef987d884 100644 --- a/assets/shaders/show_prepass.wgsl +++ b/assets/shaders/show_prepass.wgsl @@ -15,9 +15,14 @@ var settings: ShowPrepassSettings; @fragment fn fragment( @builtin(position) frag_coord: vec4, +#ifdef MULTISAMPLED @builtin(sample_index) sample_index: u32, +#endif #import bevy_pbr::mesh_vertex_output ) -> @location(0) vec4 { +#ifndef MULTISAMPLED + let sample_index = 0u; +#endif if settings.show_depth == 1u { let depth = prepass_depth(frag_coord, sample_index); return vec4(depth, depth, depth, 1.0); diff --git a/examples/shader/shader_prepass.rs b/examples/shader/shader_prepass.rs index d71cede1aa..e7f848a042 100644 --- a/examples/shader/shader_prepass.rs +++ b/examples/shader/shader_prepass.rs @@ -28,6 +28,8 @@ fn main() { }) .add_systems(Startup, setup) .add_systems(Update, (rotate, toggle_prepass_view)) + // Disabling MSAA for maximum compatibility. Shader prepass with MSAA needs GPU capability MULTISAMPLED_SHADING + .insert_resource(Msaa::Off) .run(); }