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.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. }
  12. getTexture() {
  13. return this.texture;
  14. }
  15. }
  16. WebGPUSampledTexture.prototype.isSampledTexture = true;
  17. class WebGPUSampledArrayTexture extends WebGPUSampledTexture {
  18. constructor( name ) {
  19. super( name );
  20. this.dimension = GPUTextureViewDimension.TwoDArray;
  21. }
  22. }
  23. WebGPUSampledArrayTexture.prototype.isSampledArrayTexture = true;
  24. class WebGPUSampled3DTexture extends WebGPUSampledTexture {
  25. constructor( name ) {
  26. super( name );
  27. this.dimension = GPUTextureViewDimension.ThreeD;
  28. }
  29. }
  30. WebGPUSampled3DTexture.prototype.isSampled3DTexture = true;
  31. class WebGPUSampledCubeTexture extends WebGPUSampledTexture {
  32. constructor( name ) {
  33. super( name );
  34. this.dimension = GPUTextureViewDimension.Cube;
  35. }
  36. }
  37. WebGPUSampledCubeTexture.prototype.isSampledCubeTexture = true;
  38. export { WebGPUSampledTexture, WebGPUSampledArrayTexture, WebGPUSampled3DTexture, WebGPUSampledCubeTexture };