You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using queue.write_texture to update a subset of a simple 2d texture (no arrays, no mipmaps, etc), metal validation fails with an error of the form:
-[MTLDebugBlitCommandEncoder validateCopyFromBuffer:sourceOffset:sourceBytesPerRow:sourceBytesPerImage:sourceSize:toTexture:destinationSlice:destinationLevel:destinationOrigin:options:]:804: failed assertion `Copy From Buffer Validation
totalBytesUsed(1048576) must be <= [sourceBuffer length](2048).
where totalBytesUsed is equal to the total size of the texture (+ offset if there is one) and sourceBuffer length is the amount of data being passed for that subset of the image that we are trying to update.
The program runs on its own, but validation fails for example when running in xcode which prevents using the associated gpu tooling.
The problem seems to come from destinationBytesPerImage which (somewhat confusingly) expresses the stride between layers of the image (for array textures and 3d textures) rather than the image size (same quantity but not same purpose).
Description
When using
queue.write_texture
to update a subset of a simple 2d texture (no arrays, no mipmaps, etc), metal validation fails with an error of the form:where
totalBytesUsed
is equal to the total size of the texture (+ offset if there is one) andsourceBuffer length
is the amount of data being passed for that subset of the image that we are trying to update.The program runs on its own, but validation fails for example when running in xcode which prevents using the associated gpu tooling.
Relevant metal doc: https://developer.apple.com/documentation/metal/mtlblitcommandencoder/1400752-copy
The problem seems to come from
destinationBytesPerImage
which (somewhat confusingly) expresses the stride between layers of the image (for array textures and 3d textures) rather than the image size (same quantity but not same purpose).The closest I could find online of someone running into a similar issue is: https://stackoverflow.com/questions/43069257/how-to-use-mtlblitcommandencoder-for-copying-interlaced-video-fields-into-a-mtlb
The answer suggests passing 0 as the
destinationBytesPerImage
, I think that it sounds reasonable.Note that letting the user pass
None
inrows_per_image
does not work around the problem because ofwgpu/wgpu-core/src/device/queue.rs
Line 613 in 26f2239
Repro steps
Expected vs observed behavior
Expect the code to run fine when validation is enabled (for example when running in xcode).
Platform
MacOS, wgpu 0.13.1
The text was updated successfully, but these errors were encountered: