WebGPUBuffer.js 677 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.bytesPerElement = Float32Array.BYTES_PER_ELEMENT;
  7. this.type = type;
  8. this.visibility = GPUShaderStage.VERTEX;
  9. this.usage = GPUBufferUsage.COPY_DST;
  10. this.buffer = buffer;
  11. this.bufferGPU = null; // set by the renderer
  12. }
  13. getByteLength() {
  14. return getFloatLength( this.buffer.byteLength );
  15. }
  16. getBuffer() {
  17. return this.buffer;
  18. }
  19. update() {
  20. return true;
  21. }
  22. }
  23. WebGPUBuffer.prototype.isBuffer = true;
  24. export default WebGPUBuffer;