MCPcopy Create free account
hub / github.com/ChartGPU/ChartGPU / encodeCompute

Function encodeCompute

src/renderers/createScatterDensityRenderer.ts:471–505  ·  view source on GitHub ↗
(encoder)

Source from the content-addressed store, hash-verified

469 };
470
471 const encodeCompute: ScatterDensityRenderer['encodeCompute'] = (encoder) => {
472 assertNotDisposed();
473 if (!hasPrepared) return;
474 if (!computeDirty) return;
475 if (!binsBuffer || !maxBuffer || !computeBindGroup || lastPointCount <= 0) {
476 computeDirty = false;
477 return;
478 }
479 if (!lastPlotScissor || lastPlotScissor.w <= 0 || lastPlotScissor.h <= 0) {
480 computeDirty = false;
481 return;
482 }
483
484 // Clear bins + max.
485 device.queue.writeBuffer(binsBuffer, 0, zeroBinsStaging.buffer, 0, binsCapacityU32 * 4);
486 device.queue.writeBuffer(maxBuffer, 0, new Uint32Array([0]).buffer);
487
488 const binTotal = (lastBinCountX * lastBinCountY) | 0;
489 const visibleCount = Math.max(0, (lastVisibleEnd - lastVisibleStart) | 0);
490
491 const pass = encoder.beginComputePass({ label: 'scatterDensity/computePass' });
492 pass.setBindGroup(0, computeBindGroup);
493
494 pass.setPipeline(binPointsPipeline);
495 const wg = 256;
496 const groupsPoints = Math.ceil(visibleCount / wg);
497 if (groupsPoints > 0) pass.dispatchWorkgroups(groupsPoints);
498
499 pass.setPipeline(reduceMaxPipeline);
500 const groupsBins = Math.ceil(binTotal / wg);
501 if (groupsBins > 0) pass.dispatchWorkgroups(groupsBins);
502
503 pass.end();
504 computeDirty = false;
505 };
506
507 const render: ScatterDensityRenderer['render'] = (passEncoder) => {
508 assertNotDisposed();

Callers

nothing calls this directly

Calls 1

assertNotDisposedFunction · 0.70

Tested by

no test coverage detected