-
Notifications
You must be signed in to change notification settings - Fork 302
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
Consider putting most of the writeTexture validation on the device timeline. #2680
Comments
FTR, this was changed in #832. It's technically possible to move this validation to the device timeline, but in actual practice the content timeline (content process) must always do similar computations in order to figure out how much data (from
The specific reason people run into this is that the
cc @Richard-Yunchao who recently did work on this |
IMHO it's weird that the spec has somewhat complex content-side validation for just this method and not the others. It doesn't help implementations (since there needs to be duplicated validation), nor developers (this one call is different and can just throw, they get the error quicker but that's not that much more of an improvement). For the spec we don't need to say much since under the as-if rule, browsers are free to optimize this. IMHO again, there is no perfect solution for handling the For reference this pseudo code should compute exactly the data needed for valid calls to BlockSizeData blockData = GetBlockSizeDataFor(dest.format, aspect);
if (!blockData.valid) {return 0;} // No need to send data, it is a validation error anyway
GPUExtent3D sizeInBlocks = copySize / blockData.blockSize;
// Maybe sizeInBlocks = max(sizeInBlocks, {1, 1, 1});
size_t blocksPerRow = dataLayout.bytesPerRow ?
bytesPerRow / blockSize.bytesPerBlock :
sizeInBlocks.width;
size_t rowsPerImage = dataLayout.rowsPerImage ?? sizeInBlocks.height;
// No need for overflow checks! That's done in the device timeline
size_t blockCount =
sizeInBlocks.width +
blocksPerRow * (
sizeInBlocks.height - 1 +
rowsPerImage * (sizeInBlocks.depth - 1));
return blockCount * blockData.bytesPerBlock; |
OK, I think moving it to the device timeline is fine. I think your pseudocode needs to get slightly more complex, since it needs to handle all valid cases correctly including zero-sized copies (which are generally valid but we shouldn't no-op because other validation is still supposed to run). |
There's been agreement to proceed with this. Moving to needs-spec. |
Right now
GPUQueue.writeTexture
runsvalidating linear layout
on the content timeline and raises an exception if it fails. There doesn't seem to be a strong reason why that's the case, and this is duplicating validation code in browsers to be both in the GPU process and the content process. We should run that validation on the device timeline instead.The text was updated successfully, but these errors were encountered: