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

Update instanced buffer attributes array breaks in webGPU #29966

Open
Samsy opened this issue Nov 25, 2024 · 1 comment
Open

Update instanced buffer attributes array breaks in webGPU #29966

Samsy opened this issue Nov 25, 2024 · 1 comment

Comments

@Samsy
Copy link

Samsy commented Nov 25, 2024

Description

1 ) Create an instancedgeometry

2 ) fill it with instancedattributes

3 ) update with new values later

This works in WebGL, but not in WebGPU

This is exactly the break :

OperationError: Failed to execute 'writeBuffer' on 'GPUQueue': Number of bytes to write is too large

Screenshot 2024-11-25 at 17 22 21

My guess is, once the buffer is created, it cannot be replaced ?

Live example

Live fiddle

Uncomment the line 81

Version

last

Device

Desktop

Browser

Chrome

OS

MacOS

@holtsetio
Copy link

holtsetio commented Nov 26, 2024

The issue is this function call in WebGPUAttributeUtils.js:

device.queue.writeBuffer(
	buffer,
	0,
	array,
	range.start * array.BYTES_PER_ELEMENT,
	range.count * array.BYTES_PER_ELEMENT
);

According to the WebGPU API, the writeBuffer command treats the last two arguments (dataOffset and size) as number of elements if the array is a TypedArray, not as number of bytes. So the multiplication by array.BYTES_PER_ELEMENT is wrong and causes the error.

As a dirty workaround until it is fixed you can just not specify an update range or divide the start and count by array.BYTES_PER_ELEMENT.

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

No branches or pull requests

2 participants