Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 29 additions & 2 deletions Sources/Rendering/WebGPU/BufferManager/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,10 @@ function packArray(indexBuffer, inArrayData, numComp, outputType, options) {

// pick the right function based on point versus cell data
let flatIdMap = indexBuffer.getFlatIdToPointId();
let flatIdOffset = 0;
if (options.cellData) {
flatIdMap = indexBuffer.getFlatIdToCellId();
flatIdOffset = options.cellOffset || 0;
}

// add data based on number of components
Expand Down Expand Up @@ -141,7 +143,7 @@ function packArray(indexBuffer, inArrayData, numComp, outputType, options) {

// for each entry in the flat array process it
for (let index = 0; index < flatSize; index++) {
const inArrayId = numComp * flatIdMap[index];
const inArrayId = numComp * (flatIdMap[index] - flatIdOffset);
addAPoint(inArrayId);
}

Expand Down Expand Up @@ -298,6 +300,7 @@ function vtkWebGPUBufferManager(publicAPI, model) {
const normals = generateNormals(req.cells, req.dataArray);
const result = packArray(req.indexBuffer, normals, 4, arrayType, {
cellData: true,
cellOffset: req.cellOffset,
});
buffer.createAndWrite(result.nativeArray, gpuUsage);
buffer.setStrideInBytes(
Expand All @@ -314,7 +317,13 @@ function vtkWebGPUBufferManager(publicAPI, model) {
buffer.setStrideInBytes(
vtkWebGPUTypes.getByteStrideFromBufferFormat(req.format)
);
buffer.setArrayInformation([{ offset: 0, format: req.format }]);
buffer.setArrayInformation([
{
offset: 0,
format: req.format,
interpolation: req.interpolation,
},
]);
}

buffer.setSourceTime(req.time);
Expand Down Expand Up @@ -346,6 +355,24 @@ function vtkWebGPUBufferManager(publicAPI, model) {
return publicAPI.getBuffer(buffRequest);
};

publicAPI.getBufferForCellArray = (
dataArray,
indexBuffer,
cellOffset = 0
) => {
const format = _getFormatForDataArray(dataArray);
const buffRequest = {
hash: `cell${dataArray.getMTime()}I${indexBuffer.getMTime()}O${cellOffset}${format}`,
usage: BufferUsage.PointArray,
format,
dataArray,
indexBuffer,
cellData: true,
cellOffset,
};
return publicAPI.getBuffer(buffRequest);
};

publicAPI.getFullScreenQuadBuffer = () => {
if (model.fullScreenQuadBuffer) {
return model.fullScreenQuadBuffer;
Expand Down
Loading
Loading