WebGPUSampledTexture.js 1.3 KB

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