webgpuPipelineContext.ts 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import { IPipelineContext } from '../IPipelineContext';
  2. import { Nullable } from '../../types';
  3. import { WebGPUEngine } from '../webgpuEngine';
  4. import { InternalTexture } from 'Materials';
  5. /** @hidden */
  6. export interface IWebGPUPipelineContext {
  7. textureBinding: number;
  8. samplerBinding: number;
  9. texture: InternalTexture;
  10. }
  11. /** @hidden */
  12. export class WebGPUPipelineContext implements IPipelineContext {
  13. public engine: WebGPUEngine;
  14. public vertexShaderCode: string;
  15. public fragmentShaderCode: string;
  16. public stages: Nullable<GPURenderPipelineStageDescriptor>;
  17. // public vertexInputDescriptor: GPUVertexAttributeDescriptor[] = [];
  18. public bindGroupLayouts: (GPUBindGroupLayout | undefined)[];
  19. public renderPipeline: GPURenderPipeline;
  20. public samplers: { [name: string]: Nullable<IWebGPUPipelineContext> } = { };
  21. // Default implementation.
  22. public onCompiled?: () => void;
  23. public get isAsync() {
  24. return false;
  25. }
  26. public get isReady(): boolean {
  27. if (this.stages) {
  28. return true;
  29. }
  30. return false;
  31. }
  32. public _handlesSpectorRebuildCallback(onCompiled: (program: any) => void): void {
  33. // Nothing to do yet for spector.
  34. }
  35. }