Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | 1x 1x | import macro from 'vtk.js/Sources/macros'; // ---------------------------------------------------------------------------- // vtkWebGPUBindGroup methods // ---------------------------------------------------------------------------- function vtkWebGPUBindGroup(publicAPI, model) { // Set our className model.classHierarchy.push('vtkWebGPUBindGroup'); publicAPI.setBindables = (bindables) => { // is there a difference between the old and new list? if (model.bindables.length === bindables.length) { let allMatch = true; for (let i = 0; i < model.bindables.length; i++) { if (model.bindables[i] !== bindables[i]) { allMatch = false; } } if (allMatch) { return; } } // there is a difference model.bindables = bindables; 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().getMTime(); 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, label: model.label, }); model.bindGroupTime.modified(); return model.bindGroup; }; publicAPI.getShaderCode = (pipeline) => { const lines = []; const bgroup = pipeline.getBindGroupLayoutCount(model.label); 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, label: 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, ['label', 'device', 'arrayInformation']); vtkWebGPUBindGroup(publicAPI, model); } // ---------------------------------------------------------------------------- export const newInstance = macro.newInstance(extend); // ---------------------------------------------------------------------------- export default { newInstance, extend }; |