import { ExtensionType } from '../../../../extensions/Extensions.mjs';

class GpuShaderSystem {
  contextChange(gpu) {
    this._gpu = gpu;
  }
  createProgramLayout(program) {
    const device = this._gpu.device;
    if (!program._gpuLayout) {
      if (program.gpuLayout) {
        const bindGroups = program.gpuLayout.map((group) => device.createBindGroupLayout({ entries: group }));
        const pipelineLayoutDesc = { bindGroupLayouts: bindGroups };
        program._gpuLayout = {
          bindGroups,
          pipeline: device.createPipelineLayout(pipelineLayoutDesc)
        };
      } else {
        program._gpuLayout = {
          bindGroups: null,
          pipeline: "auto"
        };
      }
    }
  }
  destroy() {
    this._gpu = null;
  }
}
/** @ignore */
GpuShaderSystem.extension = {
  type: [
    ExtensionType.WebGPUSystem
  ],
  name: "shader"
};

export { GpuShaderSystem };
//# sourceMappingURL=GpuShaderSystem.mjs.map
