WebGPUSampledTexture.js 1.3 KB

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