bevyengine / bevy

A refreshingly simple data-driven game engine built in Rust
https://bevyengine.org
Apache License 2.0
35.12k stars 3.45k forks source link

Bevy 0.8.1 3d_shapes example crashes on startup - macOS #6495

Open ThousandthStar opened 1 year ago

ThousandthStar commented 1 year ago

Bevy

0.8.1

Relevant system information

If your bug is rendering-related, copy the adapter info that appears when you run Bevy.

`AdapterInfo { name: "Intel(R) Iris(TM) Plus Graphics 645", vendor: 0, device: 0, device_type: IntegratedGpu, backend: Metal }`

You should also consider testing the examples of our upstream dependencies to help isolate any setup-specific issue:

What you did

cargo run --example 3d_shapes

What went wrong

The app starts up then instantly crashes

Additional information

3D works with Bevy 0.7, but not 0.8 and after.

Logs

2022-11-06T13:10:00.760272Z  WARN metal::device: Shader warnings: Compilation succeeded with: 

program_source:197:25: warning: unused variable 'in'
    const FragmentInput in = { is_front, varyings_1.world_position, varyings_1.world_normal, varyings_1.uv };
                        ^
program_source:19:29: warning: unused variable 'POINT_LIGHT_FLAGS_SHADOWS_ENABLED_BIT'
constexpr constant unsigned POINT_LIGHT_FLAGS_SHADOWS_ENABLED_BIT = 1u;
                            ^
program_source:20:29: warning: unused variable 'POINT_LIGHT_FLAGS_SPOT_LIGHT_Y_NEGATIVE'
constexpr constant unsigned POINT_LIGHT_FLAGS_SPOT_LIGHT_Y_NEGATIVE = 2u;
                            ^
program_source:21:29: warning: unused variable 'DIRECTIONAL_LIGHT_FLAGS_SHADOWS_ENABLED_BIT'
constexpr constant unsigned DIRECTIONAL_LIGHT_FLAGS_SHADOWS_ENABLED_BIT = 1u;
                            ^
program_source:22:29: warning: unused variable 'MESH_FLAGS_SHADOW_RECEIVER_BIT'
constexpr constant unsigned MESH_FLAGS_SHADOW_RECEIVER_BIT = 1u;
                            ^

2022-11-06T13:10:00.842787Z ERROR wgpu::backend::direct: Shader translation error for stage FRAGMENT: Metal: Compilation failed: 

program_source:687:32: error: no matching function for call to 'dot'
    float NdotV_3 = metal::max(metal::dot(in_1.N, in_1.V), 0.00009999999747378752);
                               ^~~~~~~~~~
/System/Library/PrivateFrameworks/GPUCompiler.framework/Versions/3902/Libraries/lib/clang/902.3/include/metal/metal_geometric:171:30: note: candidate template ignored: requirement '_geometric_binary_func_enable<float __attribute__((ext_vector_type(3))), float __attribute__((packed_vector_type(3)))>::value' was not satisfied [with T = float __attribute__((ext_vector_type(3))), U = float __attribute__((packed_vector_type(3)))]
METAL_FUNC make_scalar_t<_O> dot(T x, U y)
                             ^
program_source:693:25: error: no matching function for call to 'reflect'
    metal::float3 R_3 = metal::reflect(-in_1.V, in_1.N);
                        ^~~~~~~~~~~~~~
/System/Library/PrivateFrameworks/GPUCompiler.framework/Versions/3902/Libraries/lib/clang/902.3/include/metal/metal_geometric:354:15: note: candidate template ignored: requirement '_geometric_binary_func_enable<float __attribute__((packed_vector_type(3))), float __attribute__((ext_vector_type(3)))>::value' was not satisfied [with T = float __attribute__((packed_vector_type(3))), U = float __attribute__((ext_vector_type(3)))]
METAL_FUNC _O reflect(T i, U n)
              ^

2022-11-06T13:10:00.842862Z ERROR wgpu::backend::direct: Please report it to https://github.com/gfx-rs/naga    
2022-11-06T13:10:00.842931Z ERROR wgpu::backend::direct: Handling wgpu errors as fatal by default    
thread 'main' panicked at 'wgpu error: Validation Error

Caused by:
    In Device::create_render_pipeline
      note: label = `pbr_opaque_mesh_pipeline`
    Internal error in FRAGMENT shader: Metal: Compilation failed: 

program_source:687:32: error: no matching function for call to 'dot'
    float NdotV_3 = metal::max(metal::dot(in_1.N, in_1.V), 0.00009999999747378752);
                               ^~~~~~~~~~
/System/Library/PrivateFrameworks/GPUCompiler.framework/Versions/3902/Libraries/lib/clang/902.3/include/metal/metal_geometric:171:30: note: candidate template ignored: requirement '_geometric_binary_func_enable<float __attribute__((ext_vector_type(3))), float __attribute__((packed_vector_type(3)))>::value' was not satisfied [with T = float __attribute__((ext_vector_type(3))), U = float __attribute__((packed_vector_type(3)))]
METAL_FUNC make_scalar_t<_O> dot(T x, U y)
                             ^
program_source:693:25: error: no matching function for call to 'reflect'
    metal::float3 R_3 = metal::reflect(-in_1.V, in_1.N);
                        ^~~~~~~~~~~~~~
/System/Library/PrivateFrameworks/GPUCompiler.framework/Versions/3902/Libraries/lib/clang/902.3/include/metal/metal_geometric:354:15: note: candidate template ignored: requirement '_geometric_binary_func_enable<float __attribute__((packed_vector_type(3))), float __attribute__((ext_vector_type(3)))>::value' was not satisfied [with T = float __attribute__((packed_vector_type(3))), U = float __attribute__((ext_vector_type(3)))]
METAL_FUNC _O reflect(T i, U n)
alice-i-cecile commented 1 year ago

Useful to know. Does this fail on main as well for you?

ThousandthStar commented 1 year ago

It fails on main as well.

mockersf commented 1 year ago

works for me on macOS 12.5

AdapterInfo { name: "Apple M1 Max", vendor: 0, device: 0, device_type: IntegratedGpu, driver: "", driver_info: "", backend: Metal }

Could be due to the old macOS version, or the intel graphics. Given the error messages, it seems the shaders are trying to use functions not available, so I would say it's the macOS version

alice-i-cecile commented 1 year ago

To isolate this further, I'd suggest testing this upstream, on the wgpu examples.

superdump commented 1 year ago

The user noted on Discord that they did test wgpu examples. However, looking at the error message, it looks like a dot product has to be used and the examples may not do that.

@cwfitzgerald ping for wgpu support on old macOS.

ThousandthStar commented 1 year ago

I just tested the remaining wgpu examples (had only tested cube). They all work fine, except conservative-raster, which gives this error:

`thread 'main' panicked at 'Adapter does not support required features for this example: CONSERVATIVE_RASTERIZATION', wgpu/examples/conservative-raster/../framework.rs:195:5`

That has to with my Adapter, and not my macOS version. Please let me know if I should try some other things.

EDIT: Looking at bevy_render dependencies,bevy-0.8.1 uses wgpu version 0.13.1 . bevy-0.7 uses version 0.12 .