Skip to content

Commit

Permalink
Parse memory heaps adapter info
Browse files Browse the repository at this point in the history
  • Loading branch information
beaufortfrancois authored and greggman committed Dec 1, 2023
1 parent a3f6bc5 commit 7ae5f73
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,26 @@ function markDifferencesInLimits(adapter) {
);
}

function parseAdapterInfo(adapterInfo) {
return Object.fromEntries(
mapLikeToKeyValueArray(adapterInfo).map(([k, v]) => {
if (k !== "memoryHeaps") {
return [k, v];
}
const value = adapterInfo.memoryHeaps.map(({ size, properties }) => {
const heapProperties = [];
for (const [k, v] of Object.entries(GPUHeapProperty)) {
if ((parseInt(properties, 10) & v) !== 0) {
heapProperties.push(k);
}
}
return `[ size: ${size}, properties: ${heapProperties.join(" | ")} ]`;
});
return [k, [value.join(", ")]];
}),
);
}

async function adapterToElements(adapter) {
if (!adapter) {
return;
Expand All @@ -274,7 +294,7 @@ async function adapterToElements(adapter) {
el('tr', {className: 'section'}, [
el('td', {colSpan: 2}, [createHeading('div', '-', 'adapter info:')]),
]),
...mapLikeToTableRows(adapterInfo),
...mapLikeToTableRows(parseAdapterInfo(adapterInfo)),
el('tr', {className: 'section'}, [
el('td', {colSpan: 2}, [createHeading('div', '-', 'flags:')]),
]),
Expand Down Expand Up @@ -556,4 +576,4 @@ async function main() {
});
}

main();
main();

0 comments on commit 7ae5f73

Please sign in to comment.