xgpu
Version:
XGPU is an extendable library for WebGPU that provides a higher-level, easy-to-use interface for building rendering engines or processing numeric data. It handles automatic data binding, buffer alignment, variable declarations in shaders, and more. XGPU i
25 lines (24 loc) • 981 B
JavaScript
export class DrawConfig {
vertexCount = -1;
instanceCount = 1;
firstVertexId = 0;
firstInstanceId = 0;
baseVertex = 0;
indexBuffer;
pipeline;
setupDrawCompleted = false;
constructor(renderPipeline) {
this.pipeline = renderPipeline;
}
draw(renderPass) {
//console.log("DrawConfig.draw")
if (this.indexBuffer) {
//console.log(this.indexBuffer.nbPoint, this.instanceCount, this.firstVertexId, this.baseVertex, this.firstInstanceId)
renderPass.setIndexBuffer(this.indexBuffer.gpuResource, this.indexBuffer.dataType, this.indexBuffer.offset, this.indexBuffer.getBufferSize());
renderPass.drawIndexed(this.indexBuffer.nbPoint, this.instanceCount, this.firstVertexId, this.baseVertex, this.firstInstanceId);
}
else {
renderPass.draw(this.vertexCount, this.instanceCount, this.firstVertexId, this.firstInstanceId);
}
}
}