-
Notifications
You must be signed in to change notification settings - Fork 136
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 errors when running piet-gpu in the Xcode debugger #166
Comments
Based on the zulip conversation, and looking at the SPIRV-Cross and MoltenVK source code, I made up a quick and dirty change to diff --git a/piet-gpu-hal/src/metal.rs b/piet-gpu-hal/src/metal.rs
index e3157d4..0c3b1a1 100644
--- a/piet-gpu-hal/src/metal.rs
+++ b/piet-gpu-hal/src/metal.rs
@@ -136,6 +136,7 @@ impl MtlInstance {
let () = msg_send![ns_view, setWantsLayer: YES];
let bounds: CGRect = msg_send![ns_view, bounds];
let () = msg_send![metal_layer, setFrame: bounds];
+ metal_layer.set_framebuffer_only(false);
if !ns_window.is_null() {
let scale_factor: CGFloat = msg_send![ns_window, backingScaleFactor];
@@ -464,6 +465,13 @@ impl crate::backend::CmdBuf<MtlDevice> for CmdBuf {
encoder.set_texture(img_ix, Some(&image.texture));
img_ix += 1;
}
+ const BUFFER_SIZE_BUFFER_INDEX: usize = 25;
+ let buffer_size_constants: [u32; 1] = [0];
+ encoder.set_bytes(
+ BUFFER_SIZE_BUFFER_INDEX as NSUInteger,
+ mem::size_of_val(&buffer_size_constants) as NSUInteger,
+ &buffer_size_constants as *const u32 as _,
+ );
let workgroup_count = metal::MTLSize {
width: workgroup_count.0 as u64,
height: workgroup_count.1 as u64, Note that even without validation error, on a M1 Mac you still get incorrect colors, so #154 still needs to be fixed. In regards to the diff above, I'm pretty sure |
With vello now using WGPU as a backend this is not relevant anymore. |
When trying to run piet-gpu in the Xcode debugger, I got the following error:
And indeed if you look at for example binning.msl, you have a parameter constant
uint* spvBufferSizeConstants [[buffer(25)]]
even though there doesn't seem to be any buffer assigned to 25 in metal.rs'sfn dispatch()
.Having this fixed would make investigating problems on macOS easier.
As I asked on zulip, it seems to be related to the use of the
--msl-decoration-binding
flag passed to SPIRV-Cross.By the way here's a step-by-step way to run the
winit
app in the Xcode debugger:cargo build
.winit
executable in the file selection dialog. It should be in thetarget/debug
subdirectory of your copy of the repo.The text was updated successfully, but these errors were encountered: