Skip to content

Commit e5db8e9

Browse files
authored
TSL: Deprecated storageObject() (#29982)
* deprecated `storageObject()` * add tag * cleanup * Update webgpu_compute_birds.jpg
1 parent 5fa82c7 commit e5db8e9

File tree

6 files changed

+28
-15
lines changed

6 files changed

+28
-15
lines changed
95.9 KB
Loading

examples/webgpu_compute_audio.html

+3-7
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,10 @@
101101

102102
waveArray = instancedArray( waveBuffer );
103103

104-
// read-only buffer
105-
106-
const waveNode = instancedArray( waveBuffer );
107-
108104
// The Pixel Buffer Object (PBO) is required to get the GPU computed data to the CPU in the WebGL2 fallback.
109105
// As used in `renderer.getArrayBufferAsync( waveArray.value )`.
110106

111-
// waveNode.setPBO( true );
107+
waveArray.setPBO( true );
112108

113109
// params
114110

@@ -127,14 +123,14 @@
127123

128124
const time = index.mul( pitch );
129125

130-
let wave = waveNode.element( time );
126+
let wave = waveArray.element( time );
131127

132128

133129
// delay
134130

135131
for ( let i = 1; i < 7; i ++ ) {
136132

137-
const waveOffset = waveNode.element( index.sub( delayOffset.mul( sampleRate ).mul( i ) ).mul( pitch ) );
133+
const waveOffset = waveArray.element( index.sub( delayOffset.mul( sampleRate ).mul( i ) ).mul( pitch ) );
138134
const waveOffsetVolume = waveOffset.mul( delayVolume.div( i * i ) );
139135

140136
wave = wave.add( waveOffsetVolume );

examples/webgpu_compute_birds.html

+6
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,12 @@
213213
const velocityStorage = attributeArray( velocityArray, 'vec3' ).label( 'velocityStorage' );
214214
const phaseStorage = attributeArray( phaseArray, 'float' ).label( 'phaseStorage' );
215215

216+
// The Pixel Buffer Object (PBO) is required to get the GPU computed data in the WebGL2 fallback.
217+
218+
positionStorage.setPBO( true );
219+
velocityStorage.setPBO( true );
220+
phaseStorage.setPBO( true );
221+
216222
// Define Uniforms. Uniforms only need to be defined once rather than per shader.
217223

218224
effectController = {

src/nodes/accessors/StorageBufferNode.js

+17-5
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ class StorageBufferNode extends BufferNode {
2828

2929
this.access = NodeAccess.READ_WRITE;
3030
this.isAtomic = false;
31+
this.isPBO = false;
3132

32-
this.bufferObject = false;
3333
this.bufferCount = bufferCount;
3434

3535
this._attribute = null;
@@ -84,14 +84,20 @@ class StorageBufferNode extends BufferNode {
8484

8585
}
8686

87-
setBufferObject( value ) {
87+
setPBO( value ) {
8888

89-
this.bufferObject = value;
89+
this.isPBO = value;
9090

9191
return this;
9292

9393
}
9494

95+
getPBO() {
96+
97+
return this.isPBO;
98+
99+
}
100+
95101
setAccess( value ) {
96102

97103
this.access = value;
@@ -172,6 +178,12 @@ class StorageBufferNode extends BufferNode {
172178

173179
export default StorageBufferNode;
174180

175-
// Read-Write Storage
176181
export const storage = ( value, type, count ) => nodeObject( new StorageBufferNode( value, type, count ) );
177-
export const storageObject = ( value, type, count ) => nodeObject( new StorageBufferNode( value, type, count ).setBufferObject( true ) );
182+
183+
export const storageObject = ( value, type, count ) => { // @deprecated, r171
184+
185+
console.warn( 'THREE.TSL: "storageObject()" is deprecated. Use "storage().setPBO( true )" instead.' );
186+
187+
return storage( value, type, count ).setPBO( true );
188+
189+
};

src/nodes/utils/StorageArrayElementNode.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class StorageArrayElementNode extends ArrayElementNode {
3333

3434
if ( builder.isAvailable( 'storageBuffer' ) === false ) {
3535

36-
if ( this.node.bufferObject === true ) {
36+
if ( this.node.isPBO === true ) {
3737

3838
builder.setupPBO( this.node );
3939

@@ -55,7 +55,7 @@ class StorageArrayElementNode extends ArrayElementNode {
5555

5656
if ( builder.isAvailable( 'storageBuffer' ) === false ) {
5757

58-
if ( this.node.bufferObject === true && isAssignContext !== true ) {
58+
if ( this.node.isPBO === true && isAssignContext !== true && ( this.node.value.isInstancedBufferAttribute || builder.shaderStage !== 'compute' ) ) {
5959

6060
snippet = builder.generatePBO( this );
6161

test/e2e/puppeteer.js

-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ const exceptionList = [
113113
// Awaiting for WebGL backend support
114114
'webgpu_clearcoat',
115115
'webgpu_compute_audio',
116-
"webgpu_compute_birds",
117116
'webgpu_compute_texture',
118117
'webgpu_compute_texture_pingpong',
119118
"webgpu_compute_water",

0 commit comments

Comments
 (0)