WebGPUSampledTexture.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import WebGPUBinding from './WebGPUBinding.js';
  2. import { GPUBindingType, GPUTextureViewDimension } from './constants.js';
  3. class WebGPUSampledTexture extends WebGPUBinding {
  4. constructor( name, texture ) {
  5. super( name );
  6. this.texture = texture;
  7. this.dimension = GPUTextureViewDimension.TwoD;
  8. this.type = GPUBindingType.SampledTexture;
  9. this.visibility = GPUShaderStage.FRAGMENT;
  10. this.textureGPU = null; // set by the renderer
  11. Object.defineProperty( this, 'isSampledTexture', { value: true } );
  12. }
  13. }
  14. class WebGPUSampledArrayTexture extends WebGPUSampledTexture {
  15. constructor( name ) {
  16. super( name );
  17. this.dimension = GPUTextureViewDimension.TwoDArray;
  18. Object.defineProperty( this, 'isSampledArrayTexture', { value: true } );
  19. }
  20. }
  21. class WebGPUSampled3DTexture extends WebGPUSampledTexture {
  22. constructor( name ) {
  23. super( name );
  24. this.dimension = GPUTextureViewDimension.ThreeD;
  25. Object.defineProperty( this, 'isSampled3DTexture', { value: true } );
  26. }
  27. }
  28. class WebGPUSampledCubeTexture extends WebGPUSampledTexture {
  29. constructor( name ) {
  30. super( name );
  31. this.dimension = GPUTextureViewDimension.Cube;
  32. Object.defineProperty( this, 'isSampledCubeTexture', { value: true } );
  33. }
  34. }
  35. export { WebGPUSampledTexture, WebGPUSampledArrayTexture, WebGPUSampled3DTexture, WebGPUSampledCubeTexture };