Skip to content
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

metal validation crash on macos #511

Closed
aentity opened this issue Sep 4, 2020 · 4 comments · Fixed by #830
Closed

metal validation crash on macos #511

aentity opened this issue Sep 4, 2020 · 4 comments · Fixed by #830
Labels
bug Something isn't working help wanted Extra attention is needed question Further information is requested

Comments

@aentity
Copy link
Contributor

aentity commented Sep 4, 2020

Using: ff15ebc (current master, wgpu 0.6)

Error:

validateFunctionArguments:3478: failed assertion `Vertex Function(main0): argument _17[0] from buffer(0) with offset(0) and length(68) has space for 68 bytes, but argument has a length(80).'

Backtrace (release, sorry):

thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
    frame #0: 0x00007fff683a92c6 libsystem_kernel.dylib`__pthread_kill + 10
    frame #1: 0x000000010167f80d libsystem_pthread.dylib`pthread_kill + 284
    frame #2: 0x00007fff683136a6 libsystem_c.dylib`abort + 127
    frame #3: 0x00007fff682dc20d libsystem_c.dylib`__assert_rtn + 324
    frame #4: 0x00007fff409886b6 Metal`MTLReportFailure + 567
    frame #5: 0x00007fff5ab1719b MetalTools`validateFunctionArguments(id<MTLDevice>, NSString*, NSString, NSArray*, MTLDebugFunctionArgument*, unsigned long, MTLDebugFunctionArgument, unsigned long, MTLDebugFunctionArgument, unsigned long) + 1019
    frame #6: 0x00007fff5ab16854 MetalTools`-[MTLDebugRenderCommandEncoder validateCommonDrawErrors:instanceCount:baseInstance:maxVertexID:] + 805
    frame #7: 0x00007fff5ab17fe2 MetalTools`-[MTLDebugRenderCommandEncoder validateDrawIndexedPrimitives:indexCount:indexType:indexBuffer:indexBufferOffset:instanceCount:function:] + 187
    frame #8: 0x00007fff5ab183af MetalTools`-[MTLDebugRenderCommandEncoder drawIndexedPrimitives:indexCount:indexType:indexBuffer:indexBufferOffset:] + 133
    frame #9: 0x0000000100053711 _foo`gfx_backend_metal::command::exec_render::h123d51eaa38d7465(encoder=0x0000000102964200, command=<unavailable>, resources=<unavailable>) + 2497 [opt]
    frame #10: 0x000000010005d1f2 _foo`_$LT$gfx_backend_metal..command..CommandBuffer$u20$as$u20$gfx_hal..command..CommandBuffer$LT$gfx_backend_metal..Backend$GT$$GT$::draw_indexed::hcd6421e98acd2ef3(self=<unavailable>, indices=<unavailable>, base_vertex=<unavailable>, instances=<unavailable>) + 210 [opt]
    frame #11: 0x00000001006dee5b _foo`wgpu_core::command::render::_$LT$impl$u20$wgpu_core..hub..Global$LT$G$GT$$GT$::command_encoder_run_render_pass_impl::h4fb173dda8bd6f8d(self=<unavailable>, encoder_id=<unavailable>, base=<unavailable>, color_attachments=<unavailable>, depth_stencil_attachment=<unavailable>) + 43851 [opt]
    frame #12: 0x000000010070ddad _foo`_$LT$wgpu..RenderPass$u20$as$u20$core..ops..drop..Drop$GT$::drop::hf0bc6f2fdaf89448(self=<unavailable>) + 157 [opt]
    frame #13: 0x00000001000d11d8 _foo`iced_wgpu::backend::Backend::flush::h274c2929d22fb18e(self=<unavailable>, device=<unavailable>, scale_factor=<unavailable>, transformation=<unavailable>, layer=<unavailable>, staging_belt=<unavailable>, encoder=<unavailable>, target=<unavailable>, target_width=<unavailable>, target_height=<unavailable>) + 1080 [opt]

Is uniform iced uses aligned ok?

@aentity
Copy link
Contributor Author

aentity commented Sep 4, 2020

I think it's quad.vert, 4*4*4 + 4 = 68 (repr(C) sizeof)), which explains 68 in above error message:

layout (set = 0, binding = 0) uniform Globals {
    mat4 u_Transform;
    float u_Scale;
};

so I think fix can be to have last float be a vec4 or have vec3 unused, so the expected sizeof matches:

layout (set = 0, binding = 0) uniform Globals {
    mat4 u_Transform;
    float u_Scale;
    vec3 unused;
};

@hecrj
Copy link
Member

hecrj commented Sep 5, 2020

Does the validation crash happen in a particular example?

@hecrj hecrj added bug Something isn't working question Further information is requested help wanted Extra attention is needed labels Sep 5, 2020
@aentity
Copy link
Contributor Author

aentity commented Sep 14, 2020

Sorry for delay, no it is just when I run iced integration in project inside xcode; if "Metal Validation" (default) is enabled, I see this crash.

My proposed fix did not fix issue; I'm trying now with:

layout (set = 0, binding = 0) uniform Globals {
    mat4 u_Transform;
    vec4 u_Scales;
};

to see if same error occurs. A workaround is to turn off metal validation in xcode.

aentity added a commit to aentity/iced that referenced this issue Sep 14, 2020
aentity added a commit to aentity/iced that referenced this issue Sep 14, 2020
@aentity
Copy link
Contributor Author

aentity commented Sep 15, 2020

FYI: PR I posted fixes metal gpu validation error on macos/ios

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants