MCPcopy Index your code
hub / github.com/processing/p5.js / _ensureGeometryBuffers

Method _ensureGeometryBuffers

src/webgpu/p5.RendererWebGPU.js:808–826  ·  view source on GitHub ↗
(buffers, indices, indexType)

Source from the content-addressed store, hash-verified

806 }
807
808 _ensureGeometryBuffers(buffers, indices, indexType) {
809 if (!indices) return;
810
811 const device = this.device;
812
813 const buffer = device.createBuffer({
814 size: Math.ceil((indices.length * indexType.BYTES_PER_ELEMENT) / 4) * 4,
815 usage: GPUBufferUsage.INDEX | GPUBufferUsage.COPY_DST,
816 mappedAtCreation: true,
817 });
818
819 // Write index data to buffer
820 const mapping = new indexType(buffer.getMappedRange());
821 mapping.set(indices);
822 buffer.unmap();
823
824 buffers.indexBuffer = buffer;
825 buffers.indexBufferType = indexType === Uint32Array ? 'uint32' : 'uint16';
826 }
827
828 _freeBuffers(buffers) {
829 const destroyIfExists = (buf) => {

Callers

nothing calls this directly

Calls 1

setMethod · 0.45

Tested by

no test coverage detected