WebGPUSampledTexture.js 1.4 KB

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