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

Make the last 2 arguments to copyBufferToBuffer optional #4807

Open
greggman opened this issue Aug 8, 2024 · 2 comments
Open

Make the last 2 arguments to copyBufferToBuffer optional #4807

greggman opened this issue Aug 8, 2024 · 2 comments
Labels
api WebGPU API
Milestone

Comments

@greggman
Copy link
Contributor

greggman commented Aug 8, 2024

copyBufferToBuffer currently has this signature:

encoder.copyBufferToBuffer(source, sourceOffset, destination, destinationOffset, size)

Where all 5 parameters are required. So far, 9 times out of 10 I"m copying one entire buffer to another entire buffer, so I"m wondering, could we make destinationOffset default to 0 and size default to min(sourceBuffer.size - sourceOffset, destinationBuffer.size - destinationOffset)?

Then I could just do

encoder.copyBufferToBuffer(someStorageBuffer, 0, someMappableBuffer)

vs what I have to do now

encoder.copyBufferToBuffer(someStorageBuffer, 0, someMappableBuffer, 0, someMappableBuffer.size)

It"s really only a minor inconvenience so not a big deal but I thought I"d ask anyway. writeBuffer has defaults for offset and size.

@greggman greggman added the api WebGPU API label Aug 8, 2024
@Kangz Kangz added this to the Milestone 1 milestone Aug 19, 2024
@kainino0x
Copy link
Contributor

I think I would just default to sourceBuffer.size - sourceOffset rather than min(...), but otherwise SGTM

@greggman
Copy link
Contributor Author

I think I agree sourceBuffer.sze - sourceOffset is better

Without min

copy(bigSrcBuffer, 0, smallDestBuffer)

fails which tells you smallDestBuffer was too small to take the entire src buffer which is probably a good error? Of course you wouldn"t get an error copying smallSrc->bigDst

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api WebGPU API
Projects
None yet
Development

No branches or pull requests

3 participants