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
{{ message }}
Repository navigation
Metal Validation Layers require sourceBytesPerImage >= 512 bytes #537
Also, sourceBytesPerRow must be >= 64, but that's fine because WebGPU has rowPitch be a multiple of 256.
This has some validation implications on permissible values for imageHeight or (zPitch in #519), and it also means that imageHeight == 0 cannot truly mean "tightly packed" in #517.
Good point! Working around this may be annoying, and given the fact we already require some buffer offset and pitch alignment, it only seems logical to require the slice alignment as well. We can leave imageHeight == 0 only valid for cases of depth == 1, as suggested earlier by @Kangz IIRC.
Maybe this validation triggers in the Metal validation layer only when the copy is more than one slice. We could split copies of N slices into N copies of one slice to work around the issue. Also the Metal validation layers often warn about things that we haven't noticed causing bugs in practice. It would be nice to have confirmation that this is indeed a constraint of Metal.
@Kangz splitting would only work if each slice is at least 4 byte aligned in Metal, so there's got to be some alignment restriction on our slices, might as well be 512.
I'm not sure what the alignment restriction is; 512 is a minimum and not an alignment. Since the row pitch alignment is 256, I think this only affects one case: rowPitch = 256 bytes, height = 1, depth > 1.
@austinEng: Do you remember what texture format you are copying to? This limit may exist to prevent one from copying a region smaller than one block of a block-compressed format.
I don't remember the exact format, but it definitely wasn't block-compressed. It was 128 x 128 and either rgba8-unorm or depth32-float. Would it be possible for you to ask the Metal team about this specific validation?
#537 (comment) gives validation rules that are already present in WebGPU. It seems like this might have been a Metal debug device bug. @litherum can you confirm and close this issue if it is the case?
The requirement isn't hardcoded to 512 bytes. The requirement is that the sourceBytesPerImage is greater than the row size of the image times the height of the image.
Activity
kvark commentedon Jan 8, 2020
Good point! Working around this may be annoying, and given the fact we already require some buffer offset and pitch alignment, it only seems logical to require the slice alignment as well. We can leave
imageHeight == 0only valid for cases ofdepth == 1, as suggested earlier by @Kangz IIRC.Kangz commentedon Jan 8, 2020
Maybe this validation triggers in the Metal validation layer only when the copy is more than one slice. We could split copies of N slices into N copies of one slice to work around the issue. Also the Metal validation layers often warn about things that we haven't noticed causing bugs in practice. It would be nice to have confirmation that this is indeed a constraint of Metal.
kainino0x commentedon Jan 8, 2020
My guess is that things that validation layers catch that otherwise work are usually problematic on some iOS devices.
kvark commentedon Jan 8, 2020
@Kangz splitting would only work if each slice is at least 4 byte aligned in Metal, so there's got to be some alignment restriction on our slices, might as well be 512.
kainino0x commentedon Jan 8, 2020
I'm not sure what the alignment restriction is; 512 is a minimum and not an alignment. Since the row pitch alignment is 256, I think this only affects one case: rowPitch = 256 bytes, height = 1, depth > 1.
kvark commentedon Jan 9, 2020
@kainino0x bummer, you are right. This looks pretty minor then and can be trivially worked around.
JusSn commentedon Jan 28, 2020
@austinEng: Do you remember what texture format you are copying to? This limit may exist to prevent one from copying a region smaller than one block of a block-compressed format.
austinEng commentedon Jan 28, 2020
I don't remember the exact format, but it definitely wasn't block-compressed. It was 128 x 128 and either rgba8-unorm or depth32-float. Would it be possible for you to ask the Metal team about this specific validation?
JusSn commentedon Jan 28, 2020
@austinEng Yeah, that was their response to my asking :/ I'll keep digging!
JusSn commentedon Feb 3, 2020
Kangz commentedon Nov 3, 2021
#537 (comment) gives validation rules that are already present in WebGPU. It seems like this might have been a Metal debug device bug. @litherum can you confirm and close this issue if it is the case?
Kangz commentedon Dec 14, 2021
I think we should just close this, and see if we find the Metal Debug Device error again when running the CTS against it.
litherum commentedon Dec 15, 2021
The requirement isn't hardcoded to 512 bytes. The requirement is that the sourceBytesPerImage is greater than the row size of the image times the height of the image.
kainino0x commentedon Dec 15, 2021
Huh. In that case, it should be accounted for in the spec with:
So if it was just that, I guess we had some bug at the time we saw that debug error. (And the debug error was rather confusing.)
litherum commentedon Dec 15, 2021
I filed rdar://86501218 about improving the error message to be more descriptive.
Update WGSL const -> let and remove '-> void' (gpuweb#537)