-
-
Notifications
You must be signed in to change notification settings - Fork 36k
Closed
Labels
TSLThree.js Shading LanguageThree.js Shading Language
Milestone
Description
Description
There still exists some bugs with #30971, the return value of atomic* functions are not properly handled when pointerNode is a struct storage buffer. I find it has something to do with the pointerNode's type being void.
Reproduction steps
- See the code below
Code
const DrawIndirectInfo = struct(
{
vertexCount: "uint",
instanceCount: { type: "uint", atomic: true },
firstVertex: "uint",
firstInstance: "uint",
offset: "uint",
},
"DrawIndirectInfo"
);
const indirect = new THREE.IndirectStorageBufferAttribute(new Uint32Array(5), 5);
const drawBuffer = storage(indirect, DrawIndirectInfo).label("drawBuffer");
const foo = instancedArray(1, "uint").toAtomic().label("foo");
const updateDrawBuffer = Fn(() => {
If(instanceIndex.equal(0), () => {
const count = atomicAdd(drawBuffer.get("instanceCount"), uint(1)).toConst("count");
const bar = atomicAdd(foo.element(0), uint(1)).toConst("bar");
});
})().debug((builder, code) => console.log(code)).compute(1, [1]);
renderer.computeAsync(updateDrawBuffer);
Live example
Screenshots

Version
176
Device
No response
Browser
No response
OS
No response
Metadata
Metadata
Assignees
Labels
TSLThree.js Shading LanguageThree.js Shading Language