Skip to content

Metal validation error with multisampling and multiple render passes? #1044

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

Closed
lordnoriyuki opened this issue Nov 24, 2020 · 3 comments
Closed
Assignees
Labels
type: bug Something isn't working

Comments

@lordnoriyuki
Copy link
Contributor

Following up on @kvark noticing a metal validation error in the other issue I filed.

-[MTLDebugRenderCommandEncoder validateFramebufferWithRenderPipelineState:], line 1288: error 'Framebuffer With Render Pipeline State Validation
For color attachment 0, the texture sample count (1) does not match the renderPipelineState colorSampleCount (4).
The sample count (1) does not match the renderPipelineState's sample count (4)

I created a small reproducible case, and the difference between this case and the MSAA line example (which doesn't trigger the metal validation error) is that the resolved target is not the swap chain frame, and I have a second render pass immediately following the multisample pass (that normally is drawing the resolved texture into the swap chain frame, but in this test case isn't actually doing anything).

In a nutshell, it's:

Create encoder
Begin render pass w/ attachment sample_count=4 texture and resolved_target sample_count =1 texture
Set pipeline on render pass where the pipeline has sample_count=4
Begin render pass w/ attachment swapchainframe.output.view and resolved_target None
Queue encoder.finish()

In the above, I'm not doing anything with the textures, setting vertex buffers, or drawing anything. I'm not even setting the pipeline on the second render pass.

Running it with METAL_DEVICE_WRAPPER_TYPE=1 fails with the metal validation error.

If I remove the second render pass (which isn't doing anything since I just begin it and drop it) then the metal validation error doesn't fire. It also fails on the 3rd frame rendered, which makes me think it's some internal state maintained by wgpu that's causing the problem here that's being triggered by multiple render passes.

multisample.zip

@lordnoriyuki
Copy link
Contributor Author

Stack trace:

0   libsystem_kernel.dylib        	0x00007fff20304462 __pthread_kill + 10
1   libsystem_pthread.dylib       	0x00007fff20332610 pthread_kill + 263
2   libsystem_c.dylib             	0x00007fff20285720 abort + 120
3   libsystem_c.dylib             	0x00007fff202849d6 __assert_rtn + 314
4   com.apple.Metal               	0x00007fff2839afe4 MTLReportFailure.cold.1 + 43
5   com.apple.Metal               	0x00007fff283891b2 MTLReportFailure + 538
6   com.apple.Metal               	0x00007fff28382f6a _MTLMessageContextEnd + 987
7   com.apple.gpusw.MetalTools    	0x00007fff20aef2b4 -[MTLDebugRenderCommandEncoder validateFramebufferWithRenderPipelineState:] + 1137
8   com.apple.gpusw.MetalTools    	0x00007fff20aef4c6 -[MTLDebugRenderCommandEncoder setRenderPipelineState:] + 222
9   multisample                   	0x0000000109380895 _$LT$$LP$A$C$$RP$$u20$as$u20$objc..message..MessageArguments$GT$::invoke::h9b4bd79b80a91a0e + 101 (mod.rs:128)
10  multisample                   	0x0000000109357cc4 objc::message::platform::send_unverified::h5d1dc375bf040cc7 + 116 (mod.rs:27)
11  multisample                   	0x000000010935e30f objc::message::send_message::h24e5440c2834aa36 + 58 (mod.rs:178) [inlined]
12  multisample                   	0x000000010935e30f metal::encoder::RenderCommandEncoderRef::set_render_pipeline_state::hf8f670c5ad943290 + 367 (encoder.rs:196)
13  multisample                   	0x000000010928ba0f gfx_backend_metal::command::exec_render::h10a67c71fa7ae88b + 3087 (command.rs:1668)
14  multisample                   	0x0000000109289a78 gfx_backend_metal::command::PreRender::issue_many::he21b8da5c739f10c + 712 (command.rs:993)
15  multisample                   	0x00000001092918d7 _$LT$gfx_backend_metal..command..CommandBuffer$u20$as$u20$gfx_hal..command..CommandBuffer$LT$gfx_backend_metal..Backend$GT$$GT$::next_subpass::_$u7b$$u7b$closure$u7d$$u7d$::hf082e2487f20efad + 263 (command.rs:3488)
16  multisample                   	0x000000010933751f objc::rc::autorelease::autoreleasepool::hd58c6fa6099a1987 + 111 (autorelease.rs:29)
17  multisample                   	0x0000000109291754 _$LT$gfx_backend_metal..command..CommandBuffer$u20$as$u20$gfx_hal..command..CommandBuffer$LT$gfx_backend_metal..Backend$GT$$GT$::next_subpass::h0353ec0ca2045188 + 1076 (command.rs:3487)
18  multisample                   	0x0000000108e65624 _$LT$gfx_backend_metal..command..CommandBuffer$u20$as$u20$gfx_hal..command..CommandBuffer$LT$gfx_backend_metal..Backend$GT$$GT$::begin_render_pass::h9238fe57ffd194a8 + 2068 (command.rs:3452)
19  multisample                   	0x0000000108df8621 wgpu_core::command::render::_$LT$impl$u20$wgpu_core..hub..Global$LT$G$GT$$GT$::command_encoder_run_render_pass_impl::h0da57d700e55df83 + 17249 (render.rs:967)
20  multisample                   	0x0000000108df41e7 wgpu_core::command::render::_$LT$impl$u20$wgpu_core..hub..Global$LT$G$GT$$GT$::command_encoder_run_render_pass::hd7baadf00cb2cd36 + 167 (render.rs:435)
21  multisample                   	0x0000000108f8e138 _$LT$wgpu..backend..direct..Context$u20$as$u20$wgpu..Context$GT$::command_encoder_end_render_pass::h619aad289212b18e + 184 (direct.rs:1568)
22  multisample                   	0x0000000108f68d9b _$LT$wgpu..RenderPass$u20$as$u20$core..ops..drop..Drop$GT$::drop::h08eb53b45fe45b83 + 91 (lib.rs:2318)
23  multisample                   	0x0000000108cdf1f5 core::ptr::drop_in_place::h6738c34ba7857c14 + 21 (mod.rs:179)
24  multisample                   	0x0000000108d04b1c multisample::draw::he37d9e8c6ec3b044 + 1404 (main.rs:254)
25  multisample                   	0x0000000108cef632 multisample::main::_$u7b$$u7b$closure$u7d$$u7d$::h4b985772df717ee6 + 354 (main.rs:170)
26  multisample                   	0x0000000108cec597 _$LT$alloc..boxed..Box$LT$F$C$A$GT$$u20$as$u20$core..ops..function..FnMut$LT$Args$GT$$GT$::call_mut::ha5e8feb59f540f03 + 247 (boxed.rs:1325)
27  multisample                   	0x0000000108d021b6 _$LT$winit..platform_impl..platform..app_state..EventLoopHandler$LT$T$GT$$u20$as$u20$winit..platform_impl..platform..app_state..EventHandler$GT$::handle_nonuser_event::h612b71c94331274e + 246 (app_state.rs:71)
28  multisample                   	0x0000000108d6231e winit::platform_impl::platform::app_state::Handler::handle_nonuser_event::he6386776e192ce08 + 574 (app_state.rs:173)
29  multisample                   	0x0000000108d64147 winit::platform_impl::platform::app_state::AppState::cleared::hc2318257ccf47b2b + 1095 (app_state.rs:333)
30  multisample                   	0x0000000108d5da1e winit::platform_impl::platform::observer::control_flow_end_handler::h894663a27df52f29 + 78 (observer.rs:135)
31  com.apple.CoreFoundation      	0x00007fff20429d9d __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
32  com.apple.CoreFoundation      	0x00007fff20429c2d __CFRunLoopDoObservers + 549
33  com.apple.CoreFoundation      	0x00007fff20429211 __CFRunLoopRun + 1146
34  com.apple.CoreFoundation      	0x00007fff204286be CFRunLoopRunSpecific + 563
35  com.apple.HIToolbox           	0x00007fff28694fd0 RunCurrentEventLoopInMode + 292
36  com.apple.HIToolbox           	0x00007fff28694dcc ReceiveNextEventCommon + 709
37  com.apple.HIToolbox           	0x00007fff28694aef _BlockUntilNextEventMatchingListInModeWithFilter + 64
38  com.apple.AppKit              	0x00007fff22c41f85 _DPSNextEvent + 883
39  com.apple.AppKit              	0x00007fff22c4074b -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1366
40  com.apple.AppKit              	0x00007fff22c32bda -[NSApplication run] + 586
41  multisample                   	0x0000000109450a06 _$LT$$LP$$RP$$u20$as$u20$objc..message..MessageArguments$GT$::invoke::h9450e3547d2d1221 + 70 (mod.rs:128)
42  multisample                   	0x0000000109450922 objc::message::platform::send_unverified::hff2723cd6ff29139 + 98 (mod.rs:27)
43  multisample                   	0x0000000108d02928 objc::message::send_message::hb286756e7e34ee4b + 27 (mod.rs:178) [inlined]
44  multisample                   	0x0000000108d02928 winit::platform_impl::platform::event_loop::EventLoop$LT$T$GT$::run_return::h1e511d15fa6ed3ff + 968 (event_loop.rs:106)
45  multisample                   	0x0000000108d02b34 winit::platform_impl::platform::event_loop::EventLoop$LT$T$GT$::run::hccf2cbce9110d701 + 84 (event_loop.rs:93)
46  multisample                   	0x0000000108cec403 winit::event_loop::EventLoop$LT$T$GT$::run::hc5a8ffe1d1f68e66 + 99 (event_loop.rs:154)
47  multisample                   	0x0000000108d04344 multisample::main::h509f33e5614ab3f6 + 3284 (main.rs:161)
48  multisample                   	0x0000000108cde7ce core::ops::function::FnOnce::call_once::h2a8b81ea8bae57c1 + 14 (function.rs:227)
49  multisample                   	0x0000000108d16661 std::sys_common::backtrace::__rust_begin_short_backtrace::h749a020585da00c2 + 17 (backtrace.rs:125)
50  multisample                   	0x0000000108d12324 std::rt::lang_start::_$u7b$$u7b$closure$u7d$$u7d$::ha793fc021c1872fa + 20 (rt.rs:66)
51  multisample                   	0x00000001097c9f84 core::ops::function::impls::_$LT$impl$u20$core..ops..function..FnOnce$LT$A$GT$$u20$for$u20$$RF$F$GT$::call_once::h4ab201f754b12ec0 + 7 (function.rs:259) [inlined]
52  multisample                   	0x00000001097c9f84 std::panicking::try::do_call::h2d40bab4a9c2dc4b + 7 (panicking.rs:379) [inlined]
53  multisample                   	0x00000001097c9f84 std::panicking::try::he14232182da07291 + 7 (panicking.rs:343) [inlined]
54  multisample                   	0x00000001097c9f84 std::panic::catch_unwind::ha032e0ba57e1000e + 7 (panic.rs:396) [inlined]
55  multisample                   	0x00000001097c9f84 std::rt::lang_start_internal::hebea83fb59fe572e + 644 (rt.rs:51)
56  multisample                   	0x0000000108d12301 std::rt::lang_start::h4038932d2736c529 + 65 (rt.rs:65)
57  multisample                   	0x0000000108d04c22 main + 34
58  libdyld.dylib                 	0x00007fff2034d631 start + 1

@kvark
Copy link
Member

kvark commented Nov 25, 2020

Thank you for filing! I believe this is an issue with gfx-backend-metal, and it's harmless.
I'm on it.

@kvark kvark added the type: bug Something isn't working label Nov 25, 2020
@kvark kvark self-assigned this Nov 25, 2020
bors bot added a commit to gfx-rs/gfx that referenced this issue Nov 27, 2020
3486: [mtl] fix render pass compatibility check wrt sample count r=kvark a=kvark

Addresses gfx-rs/wgpu#1044 on master
PR checklist:
- [x] `make` succeeds (on *nix)
- [ ] `make reftests` succeeds
- [ ] tested examples with the following backends:


Co-authored-by: Dzmitry Malyshau <[email protected]>
@kvark
Copy link
Member

kvark commented Nov 27, 2020

Fixed by gfx-backend-metal-0.6.5

@kvark kvark closed this as completed Nov 27, 2020
cwfitzgerald pushed a commit that referenced this issue Oct 25, 2023
Fixes #1745: Support out-of-order module scope declarations in WGSL
Fixes #1044: Forbid local variable shadowing in WGSL
Fixes #2076: [wgsl-in] no error for duplicated type definition
Fixes #2071: Global item does not support 'const'
Fixes #2105: [wgsl-in] Type aliases for a vecN<T> doesn't work when constructing vec from a single argument
Fixes #1775: Referencing a function without a return type yields an unknown identifier error.
Fixes #2089: Error span reported on the declaration of a variable instead of its use
Fixes #1996: [wgsl-in] Confusing error: "expected unsigned/signed integer literal, found '1'"

Separate parsing from lowering by generating an AST, which desugars as
much as possible down to something like Naga IR. The AST is then used
to resolve identifiers while lowering to Naga IR.

Co-authored-by: Teodor Tanasoaia <[email protected]>
Co-authored-by: Jim Blandy <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants