playcanvas
Version:
PlayCanvas WebGL game engine
41 lines (38 loc) • 1.45 kB
JavaScript
import { TRACEID_PIPELINELAYOUT_ALLOC } from '../../../core/constants.js';
import { DebugHelper, Debug } from '../../../core/debug.js';
/**
* @import { BindGroupFormat } from '../bind-group-format.js'
* @import { WebgpuGraphicsDevice } from './webgpu-graphics-device.js'
*/ var _layoutId = 0;
/**
* Base class for render and compute pipelines.
*
* @ignore
*/ class WebgpuPipeline {
// TODO: this could be cached using bindGroupKey
/**
* @param {BindGroupFormat[]} bindGroupFormats - An array of bind group formats.
* @returns {any} Returns the pipeline layout.
*/ getPipelineLayout(bindGroupFormats) {
var bindGroupLayouts = [];
bindGroupFormats.forEach((format)=>{
bindGroupLayouts.push(format.bindGroupLayout);
});
var desc = {
bindGroupLayouts: bindGroupLayouts
};
_layoutId++;
DebugHelper.setLabel(desc, "PipelineLayoutDescr-" + _layoutId);
/** @type {GPUPipelineLayout} */ var pipelineLayout = this.device.wgpu.createPipelineLayout(desc);
DebugHelper.setLabel(pipelineLayout, "PipelineLayout-" + _layoutId);
Debug.trace(TRACEID_PIPELINELAYOUT_ALLOC, "Alloc: Id " + _layoutId, {
desc: desc,
bindGroupFormats
});
return pipelineLayout;
}
constructor(device){
/** @type {WebgpuGraphicsDevice} */ this.device = device;
}
}
export { WebgpuPipeline };