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] set the image stride to zero when updating a single layer of a 3D texture #4154

Closed
wants to merge 4 commits into from

Conversation

teoxoy
Copy link
Member

@teoxoy teoxoy commented Sep 19, 2023

Checklist

  • Run cargo clippy.
  • Run cargo clippy --target wasm32-unknown-unknown if applicable.
  • Add change to CHANGELOG.md. See simple instructions inside file.

Connections
Follow up to #3063.

Description
See #3063 (comment).

Testing
Test has been modified.

@teoxoy teoxoy force-pushed the msl-copy-0-stride branch 3 times, most recently from a28e28c to d6e4482 Compare September 19, 2023 10:30
@teoxoy
Copy link
Member Author

teoxoy commented Sep 19, 2023

It seems that Metal's validation errors don't surface in CI.
I removed the fix added in the previous PR and the test still succeeded (a68dc10).

@teoxoy
Copy link
Member Author

teoxoy commented Sep 19, 2023

Ah, I think I see why. Is there a way to run the tests under xcode (in CI)? I think we should do that.

cc @nical @cwfitzgerald

@cwfitzgerald
Copy link
Member

We need to set the env var METAL_DEVICE_WRAPPER_TYPE=1 - we should do it in the test harness before wgpu is initialized so they get enabled locally too.

@@ -51,9 +51,16 @@ fn write_texture_subset_2d() {

ctx.queue.submit(None);

let read_buffer = ctx.device.create_buffer(&wgpu::BufferDescriptor {
let read_buffer_0 = ctx.device.create_buffer(&wgpu::BufferDescriptor {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would imho be nice to parameterize this test to have it both do a full update and two piecewise.
The second one can then point to this PR, pointing out that it protects against regressing this

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can probably trigger the validation error with a simpler test case.
Will try to do that instead as opposed to modifying this one.

@cwfitzgerald cwfitzgerald requested a review from a team September 20, 2023 18:57
@teoxoy
Copy link
Member Author

teoxoy commented Sep 21, 2023

We need to set the env var METAL_DEVICE_WRAPPER_TYPE=1 - we should do it in the test harness before wgpu is initialized so they get enabled locally too.

Wouldn't that require #3873? I can add it in CI for now though.

Copy link
Member

@jimblandy jimblandy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea of separating out the test case. The code changes look good.

@teoxoy teoxoy marked this pull request as draft September 21, 2023 16:51
@teoxoy
Copy link
Member Author

teoxoy commented Sep 21, 2023

Besides some other validation errors that we get when I enabled metal's validation, I can't seem to get metal's validation to trigger for this specific case.

Maybe newer versions don't care but older do?
Should we just land the code change to make things consistent? (and revert the test & CI changes for now?)

@cwfitzgerald
Copy link
Member

Wouldn't that require #3873? I can add it in CI for now though

@teoxoy No, you can just add the env var around here https://github.com/gfx-rs/wgpu/blob/trunk/tests/src/lib.rs#L328

As for what to do - split this however you feel is best, as long as at the end we end up:

  • With the change landed
  • With the env var set
  • Test case written

We're where we need to be :)

@teoxoy
Copy link
Member Author

teoxoy commented Sep 22, 2023

@cwfitzgerald question about the env variable:
I can't find any reference to METAL_DEVICE_WRAPPER_TYPE (even though it does seem to work).
I did however find MTL_DEBUG_LAYER & MTL_SHADER_VALIDATION.
I feel like we should use those instead. Thoughts?

@cwfitzgerald
Copy link
Member

I have no idea why we used this, I think this might be what xcode uses? I'm not particularly strongly either way, as long as it does what we want.

@cwfitzgerald
Copy link
Member

#3873 now includes both MTL_DEBUG_LAYER and MTL_SHADER_VALIDATION

@cwfitzgerald
Copy link
Member

@teoxoy what's the status on this?

@teoxoy
Copy link
Member Author

teoxoy commented Jan 9, 2024

From my testing I did at the time, I couldn't produce the validation error I was expecting by not setting image_byte_stride to 0 if extent.depth > 1.

We ran into the validation error for copy_buffer_to_texture in #3063 but not yet for copy_texture_to_buffer. The metal docs have the same requirements for image_byte_stride in both those cases. So, I don't know why I could not produce the validation error.

If someone more familiar with macOS/Metal could help on this front that would be great but it seems that this issue isn't a high priority right now.

I mainly left this open and as draft to remind me to look at it at some later time but closing it and opening an issue sounds like the better approach.

@teoxoy teoxoy closed this Jan 9, 2024
@teoxoy teoxoy deleted the msl-copy-0-stride branch January 9, 2024 11:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants