WebGPUBuffer.js 661 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import WebGPUBinding from './WebGPUBinding.js';
  2. import { getFloatLength } from './WebGPUBufferUtils.js';
  3. class WebGPUBuffer extends WebGPUBinding {
  4. constructor( name, type, buffer = null ) {
  5. super( name );
  6. this.isBuffer = true;
  7. this.bytesPerElement = Float32Array.BYTES_PER_ELEMENT;
  8. this.type = type;
  9. this.visibility = GPUShaderStage.VERTEX;
  10. this.usage = GPUBufferUsage.COPY_DST;
  11. this.buffer = buffer;
  12. this.bufferGPU = null; // set by the renderer
  13. }
  14. getByteLength() {
  15. return getFloatLength( this.buffer.byteLength );
  16. }
  17. getBuffer() {
  18. return this.buffer;
  19. }
  20. update() {
  21. return true;
  22. }
  23. }
  24. export default WebGPUBuffer;