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

macOS: BufferUsage::all() breaks examples #1383

Closed
colinmarc opened this issue Jun 9, 2020 · 9 comments
Closed

macOS: BufferUsage::all() breaks examples #1383

colinmarc opened this issue Jun 9, 2020 · 9 comments

Comments

@colinmarc
Copy link
Contributor

Running the triangle example on a fresh install of macOS with the vulkan SDK, I get a blue screen but no triangles:

Screenshot 2020-06-09 at 23 24 26

My laptop is a 2020 macbook air, still with the new computer smell, and an integrated GPU.

I'm more than happy to debug myself, given some direction! I'm not really sure where to start.

@colinmarc
Copy link
Contributor Author

colinmarc commented Jun 9, 2020

Also, just running the simplest example from the guide:

let source_content = 0..64;
let source =
    CpuAccessibleBuffer::from_iter(device.clone(), BufferUsage::all(), false, source_content)
        .expect("failed to create buffer");

let dest_content = (0..64).map(|_| 0_i32);
let dest =
    CpuAccessibleBuffer::from_iter(device.clone(), BufferUsage::all(), false, dest_content)
        .expect("failed to create buffer");

let mut builder = AutoCommandBufferBuilder::new(device.clone(), queue.family()).unwrap();
builder.copy_buffer(source.clone(), dest.clone()).unwrap();
let command_buffer = builder.build().unwrap();

command_buffer
    .execute(queue.clone())
    .unwrap()
    .then_signal_fence_and_flush()
    .unwrap()
    .wait(None)
    .unwrap();

let src_content = source.read().unwrap();
let dest_content = dest.read().unwrap();
assert_eq!(&*src_content, &*dest_content);

It doesn't seem to actually do the thing.

thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63]`,
 right: `[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]`', src/main.rs:63:5

@AustinJ235
Copy link
Member

Related: #1368 (comment)

Cause is still unknown at this time. I don't have access to macOS hardware either. You could try using previous versions of the macOS deps here:

[target.'cfg(target_os = "macos")'.dependencies]

Maybe using another queue from the returned queue families? Maybe try broadening the ImageUsage on the Swapchain:

ImageUsage::color_attachment(),

Not sure anything seems to be possible. If there a debugging tools available you could try to find one and see if it gives any errors or warnings.

@colinmarc

This comment has been minimized.

@colinmarc

This comment has been minimized.

@colinmarc

This comment has been minimized.

@colinmarc
Copy link
Contributor Author

Sorry for spamming! Hopefully my debugging process is useful to someone.

I got git bisect working with DYLD_LIBRARY_PATH="$HOME/src/MoltenVK/Package/Release/MoltenVK/macOS/dynamic:$VULKAN_SDK/lib:${DYLD_LIBRARY_PATH:-}", and I've isolated the issue to commit 25a1e056 in MoltenVK.

It looks like the issue is something with BufferUsage::all(). When I change the way the buffers are created in the memory copy example from

let source = CpuAccessibleBuffer::from_iter(device.clone(), BufferUsage::all(), false, source_content)?;
let dest = CpuAccessibleBuffer::from_iter(device.clone(), BufferUsage::all(), false, dest_content)?;

to

let source = CpuAccessibleBuffer::from_iter(device.clone(), BufferUsage::transfer_source(), false, source_content)?;
let dest = CpuAccessibleBuffer::from_iter(device.clone(), BufferUsage::transfer_dest(), false, dest_content)?;

Then it suddenly works. Similarly, changing the code in the triangle example to use BufferUsage::vertex_buffer() works, too.

My question: should I make a PR to change the examples or is this a bug in BufferUsage::all?

@colinmarc colinmarc changed the title macOS: no triangles macOS: BufferUsage::all() breaks examples Jun 10, 2020
@colinmarc colinmarc changed the title macOS: BufferUsage::all() breaks examples macOS: BufferUsage::all() breaks examples Jun 10, 2020
@AustinJ235
Copy link
Member

Certainly wondering if there was a change in spec or something that changed how usages work. In practice having a broad usage shouldn't cause issues, it may just be nonoptimal. Changing the guide to further explain usages instead of using BufferUsage::all() everywhere would probably be a good idea and all the examples also.

As to why this is causing poor behaviour I note quite sure.

@Xazzzi
Copy link

Xazzzi commented Jun 13, 2020

I have same behaviour on mid 2015 mac pro, tweaking BufferUsage worked.
For me simplest example - filling cpu accessible buffer with constant - stops working when either of usage flags are set:

uniform_texel_buffer: true,
storage_texel_buffer: true,

Which seems related to the commmit @colinmarc pointed to.

@stetrevor
Copy link

For me,it worked after I changed the host_cached argument from false to true in all CpuAccessibleBuffer​::​from_iter calls. Both the buffer copy example and the triangle example work now.

From:

let​ source ​=​ CpuAccessibleBuffer​::​from_iter​(device.​clone​(), BufferUsage​::​transfer_source​(), ​false, source_content)?;

To:

let​ source ​=​ CpuAccessibleBuffer​::​from_iter​(device.​clone​(), BufferUsage​::​transfer_source​(), ​true, source_content)?;

@Rua Rua closed this as completed Dec 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants