浏览代码

TSL: Double-check on the parents of the `atomic functions` to prevent errors (#31509)

* Double-check on the parents of the atomic functions to prevent errors.

* Update WGSLNodeBuilder.js
sunag 5 月之前
父节点
当前提交
206a1383ba
共有 2 个文件被更改,包括 13 次插入2 次删除
  1. 1 1
      src/nodes/gpgpu/AtomicFunctionNode.js
  2. 12 1
      src/renderers/webgpu/nodes/WGSLNodeBuilder.js

+ 1 - 1
src/nodes/gpgpu/AtomicFunctionNode.js

@@ -113,7 +113,7 @@ class AtomicFunctionNode extends Node {
 		}
 
 		const methodSnippet = `${ builder.getMethod( method, type ) }( ${ params.join( ', ' ) } )`;
-		const isVoid = parents.length === 1 && parents[ 0 ].isStackNode === true;
+		const isVoid = parents ? ( parents.length === 1 && parents[ 0 ].isStackNode === true ) : false;
 
 		if ( isVoid ) {
 

+ 12 - 1
src/renderers/webgpu/nodes/WGSLNodeBuilder.js

@@ -801,9 +801,20 @@ class WGSLNodeBuilder extends NodeBuilder {
 	 */
 	getNodeAccess( node, shaderStage ) {
 
-		if ( shaderStage !== 'compute' )
+		if ( shaderStage !== 'compute' ) {
+
+			if ( node.isAtomic === true ) {
+
+				console.warn( 'WebGPURenderer: Atomic operations are only supported in compute shaders.' );
+
+				return NodeAccess.READ_WRITE;
+
+			}
+
 			return NodeAccess.READ_ONLY;
 
+		}
+
 		return node.access;
 
 	}

粤ICP备19079148号