Closed kainino0x closed 6 days ago
IMHO it's probably not worthwhile, while a bit weird, it matches the JS API more and doesn't really have a cost associated with it.
It already doesn't match super well (because we take a raw pointer + length instead of a typed array), but it does still match better.
The place where this causes friction is in wire implementations, where it looks like you should send span(data, dataSize)
but really you should not do this.
Like, should dawn wire just do what you asked and copy the range you gave? Or should wire be smarter and avoid copying the part before the offset (so that logic moves from blink into dawn wire)?
That seems like an implementation detail of dawn::wire? We didn't do it in dawn::wire because we didn't have the texture format in there at the time and didn't want to move complicated logic there. But now we could.
That said it seems somewhat irrelevant to this discussion since that's an optimization under the as-if rule.
Tentatively closing as I'd like to go with no change, but leaving the label to discuss if we want to reopen.
Nov 21 meeting:
On that tangent, see also:
Nov 25 meeting:
While looking at some code in Blink I noticed that in C, there is no point in having
WGPUTextureDataLayout.offset
inwgpuQueueWriteTexture
. It's there because (1) it matches JS and (2) we use the offset inWGPUImageCopyBuffer
. However in C, it's possible to just offset the data pointer instead, withptr + offset
or&ptr[offset]
(where offset is now in array elements, instead of bytes).In webgpu.h we could remove this redundancy by moving
offset
out ofWGPUTextureDataLayout
intoWGPUImageCopyBuffer
. Is that worthwhile?