From 7ae5f737c66a2d9f6b05cb61c7d24e2523a1fcdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Beaufort?= Date: Fri, 1 Dec 2023 15:44:48 +0100 Subject: [PATCH] Parse memory heaps adapter info --- index.js | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 016a293..8cd7486 100644 --- a/index.js +++ b/index.js @@ -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; @@ -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:')]), ]), @@ -556,4 +576,4 @@ async function main() { }); } -main(); \ No newline at end of file +main();