forked from Kitware/vtk-js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into average_ip_scalar_fix
- Loading branch information
Showing
21 changed files
with
706 additions
and
256 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
import macro from 'vtk.js/Sources/macro'; | ||
|
||
// ---------------------------------------------------------------------------- | ||
// vtkWebGPUBindGroup methods | ||
// ---------------------------------------------------------------------------- | ||
|
||
function vtkWebGPUBindGroup(publicAPI, model) { | ||
// Set our className | ||
model.classHierarchy.push('vtkWebGPUBindGroup'); | ||
|
||
publicAPI.addBindable = (bindable) => { | ||
// only add new bindables | ||
for (let i = 0; i < model.bindables.length; i++) { | ||
if (model.bindables[i] === bindable) { | ||
return; | ||
} | ||
} | ||
model.bindables.push(bindable); | ||
publicAPI.modified(); | ||
}; | ||
|
||
publicAPI.getBindGroupLayout = (device) => { | ||
const entries = []; | ||
for (let i = 0; i < model.bindables.length; i++) { | ||
const entry = model.bindables[i].getBindGroupLayoutEntry(); | ||
entry.binding = i; | ||
entries.push(entry); | ||
} | ||
return device.getBindGroupLayout({ entries }); | ||
}; | ||
|
||
publicAPI.getBindGroup = (device) => { | ||
// check mtime | ||
let mtime = publicAPI.getMTime(); | ||
for (let i = 0; i < model.bindables.length; i++) { | ||
const tm = model.bindables[i].getBindGroupTime(); | ||
mtime = tm > mtime ? tm : mtime; | ||
} | ||
if (mtime < model.bindGroupTime.getMTime()) { | ||
return model.bindGroup; | ||
} | ||
|
||
const entries = []; | ||
for (let i = 0; i < model.bindables.length; i++) { | ||
const entry = model.bindables[i].getBindGroupEntry(); | ||
entry.binding = i; | ||
entries.push(entry); | ||
} | ||
|
||
model.bindGroup = device.getHandle().createBindGroup({ | ||
layout: publicAPI.getBindGroupLayout(device), | ||
entries, | ||
}); | ||
model.bindGroupTime.modified(); | ||
|
||
return model.bindGroup; | ||
}; | ||
|
||
publicAPI.getShaderCode = (pipeline) => { | ||
const lines = []; | ||
const bgroup = pipeline.getBindGroupLayoutCount(model.name); | ||
for (let i = 0; i < model.bindables.length; i++) { | ||
lines.push(model.bindables[i].getShaderCode(i, bgroup)); | ||
} | ||
return lines.join('\n'); | ||
}; | ||
} | ||
|
||
// ---------------------------------------------------------------------------- | ||
// Object factory | ||
// ---------------------------------------------------------------------------- | ||
|
||
const DEFAULT_VALUES = { | ||
device: null, | ||
handle: null, | ||
name: null, | ||
}; | ||
|
||
// ---------------------------------------------------------------------------- | ||
|
||
export function extend(publicAPI, model, initialValues = {}) { | ||
Object.assign(model, DEFAULT_VALUES, initialValues); | ||
|
||
// Object methods | ||
macro.obj(publicAPI, model); | ||
|
||
model.bindables = []; | ||
|
||
model.bindGroupTime = {}; | ||
macro.obj(model.bindGroupTime, { mtime: 0 }); | ||
|
||
macro.get(publicAPI, model, [ | ||
'bindGroupTime', | ||
'handle', | ||
'sizeInBytes', | ||
'usage', | ||
]); | ||
macro.setGet(publicAPI, model, [ | ||
'name', | ||
'device', | ||
'arrayInformation', | ||
'sourceTime', | ||
]); | ||
|
||
vtkWebGPUBindGroup(publicAPI, model); | ||
} | ||
|
||
// ---------------------------------------------------------------------------- | ||
|
||
export const newInstance = macro.newInstance(extend); | ||
|
||
// ---------------------------------------------------------------------------- | ||
|
||
export default { newInstance, extend }; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.