ComputeNode.js 733 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import Node from '../core/Node.js';
  2. import { NodeUpdateType } from '../core/constants.js';
  3. class ComputeNode extends Node {
  4. constructor( dispatchCount, workgroupSize = [ 64 ] ) {
  5. super( 'void' );
  6. this.updateType = NodeUpdateType.Object;
  7. this.dispatchCount = dispatchCount;
  8. this.workgroupSize = workgroupSize;
  9. this.computeNode = null;
  10. }
  11. update( { renderer } ) {
  12. renderer.compute( this );
  13. }
  14. generate( builder ) {
  15. const { shaderStage } = builder;
  16. if ( shaderStage === 'compute' ) {
  17. const snippet = this.computeNode.build( builder, 'void' );
  18. if ( snippet !== '' ) {
  19. builder.addFlowCode( snippet );
  20. }
  21. }
  22. }
  23. }
  24. ComputeNode.prototype.isComputeNode = true;
  25. export default ComputeNode;