WebGPUSampledTexture.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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.isSampledTexture = true;
  7. this.texture = texture;
  8. this.dimension = GPUTextureViewDimension.TwoD;
  9. this.type = GPUBindingType.SampledTexture;
  10. this.visibility = GPUShaderStage.FRAGMENT;
  11. this.textureGPU = null; // set by the renderer
  12. }
  13. getTexture() {
  14. return this.texture;
  15. }
  16. }
  17. class WebGPUSampledArrayTexture extends WebGPUSampledTexture {
  18. constructor( name, texture ) {
  19. super( name, texture );
  20. this.isSampledArrayTexture = true;
  21. this.dimension = GPUTextureViewDimension.TwoDArray;
  22. }
  23. }
  24. class WebGPUSampled3DTexture extends WebGPUSampledTexture {
  25. constructor( name, texture ) {
  26. super( name, texture );
  27. this.isSampled3DTexture = true;
  28. this.dimension = GPUTextureViewDimension.ThreeD;
  29. }
  30. }
  31. class WebGPUSampledCubeTexture extends WebGPUSampledTexture {
  32. constructor( name, texture ) {
  33. super( name, texture );
  34. this.isSampledCubeTexture = true;
  35. this.dimension = GPUTextureViewDimension.Cube;
  36. }
  37. }
  38. export { WebGPUSampledTexture, WebGPUSampledArrayTexture, WebGPUSampled3DTexture, WebGPUSampledCubeTexture };