'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var Extensions = require('../../../../extensions/Extensions.js');

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: [
    Extensions.ExtensionType.WebGPUSystem
  ],
  name: "shader"
};

exports.GpuShaderSystem = GpuShaderSystem;
//# sourceMappingURL=GpuShaderSystem.js.map
