Skip to content

Commit

Permalink
Fit more on screen
Browse files Browse the repository at this point in the history
  • Loading branch information
greggman committed Feb 2, 2024
1 parent 4f3ed36 commit 25abacf
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 28 deletions.
29 changes: 22 additions & 7 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
--text-color: #006;
--error-text-color: red;

--adapter-background-color: #CCC;
--section-header-background-color: #CCC;
--section-background-color: #DDD;
--table-background-color: #EEE;
--even-row-color: rgba(0, 0, 0, 0.05);
--hover-color: rgba(0, 0, 0, 0.2);
Expand All @@ -52,7 +53,8 @@
--text-color: #0F0;
--error-text-color: #F66;

--adapter-background-color: #444;
--section-header-background-color: #444;
--section-background-color: #333;
--table-background-color: #222;
--even-row-color: rgba(255, 255, 255, 0.05);
--hover-color: rgba(255, 255, 255, 0.2);
Expand Down Expand Up @@ -90,14 +92,17 @@
justify-content: flex-start;
}
h2 {
margin: 0.5em 0 0.5em 0;
margin: 0;
}
h2, td {
padding: 0 10px 0 10px;
}
.logo {
height: 1.5em;
}
table.misc {
min-width: 100%;
}
.misc td:nth-child(2) {
white-space: pre;
}
Expand All @@ -108,15 +113,22 @@
#content {
margin: 0 auto;
}
.adapters {
.adapters,
.others {
display: inline-flex;
flex-wrap: wrap;
}
.adapter {
background: var(--adapter-background-color);
.adapter,
.other {
background: var(--section-background-color);
margin-right: 10px;
margin-bottom: 10px;
}
.adapter h2,
.other h2 {
padding: 0.5em 10px 0.5em 10px;
background: var(--section-header-background-color);
}
.name>td,
.section>td {
font-size: larger;
Expand Down Expand Up @@ -178,11 +190,14 @@
text-align: right;
}
.adapters,
.others,
.adapter,
.other,
table {
width: 100%;
}
.adapter {
.adapter,
.other {
margin-right: 0;
}
tr {
Expand Down
54 changes: 33 additions & 21 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -416,32 +416,34 @@ class WorkerHelper {
}
}

async function checkMisc({haveFallback}) {
addElemToDocument(createHeading('h2', '-', 'WGSL language features:'));

addElemToDocument(el('table', { className: 'misc' }, [
el('tbody', {}, [
...setLikeToTableRows(navigator.gpu.wgslLanguageFeatures || []),
function checkWGSLLanguageFeatures(parent) {
parent.appendChild(el('div', {className: 'other'}, [
(createHeading('h2', '-', 'WGSL language features:')),
el('table', { className: 'misc' }, [
el('tbody', {}, [
...setLikeToTableRows(navigator.gpu.wgslLanguageFeatures || []),
]),
]),
]));
}

addElemToDocument(createHeading('h2', '-', 'misc:'));

function checkMisc(parent, {haveFallback}) {
const obj = {};
const presentationFormat = navigator.gpu.getPreferredCanvasFormat();
obj.getPreferredCanvasFormat = presentationFormat;
if (!haveFallback) {
obj['fallback adapter'] = 'not supported';
}

addElemToDocument(el('table', { className: 'misc' }, [
el('tbody', {}, mapLikeToTableRows(obj)),
parent.appendChild(el('div', {className: 'other'}, [
(createHeading('h2', '-', 'misc:')),
el('table', { className: 'misc' }, [
el('tbody', {}, mapLikeToTableRows(obj)),
]),
]));
}

async function checkWorkers(workerType) {
addElemToDocument(createHeading('h2', '=', `${workerType} workers:`));

async function getWorkerInfo(workerType) {
const canvas = document.createElement('canvas');
const offscreen = !!canvas.transferControlToOffscreen
let offscreenCanvas = offscreen && canvas.transferControlToOffscreen();
Expand All @@ -456,10 +458,9 @@ async function checkWorkers(workerType) {
worker = new WorkerHelper('worker.js', workerType);
await worker.ready();
} catch(error) {
addElemToDocument(el('table', { className: 'worker' }, [
return el('table', { className: 'worker' }, [
el('tbody', {}, setLikeToTableRows(undefined)),
]));
return;
]);
}
const {rAF, gpu, adapter, device, compat, context, offscreen: offscreenSupported, twoD } = await worker.getMessage('checkWebGPU', {canvas: offscreenCanvas}, [offscreenCanvas]);
addSupportsRow('webgpu API', gpu, 'exists', 'n/a');
Expand All @@ -480,8 +481,15 @@ async function checkWorkers(workerType) {
addSupportsRow('OffscreenCanvas', offscreenSupported);
addSupportsRow('CanvasRenderingContext2D', twoD);

addElemToDocument(el('table', { className: 'worker' }, [
return el('table', { className: 'worker' }, [
el('tbody', {}, mapLikeToTableRows(obj, false)),
]);
}

async function checkWorker(parent, workerType) {
parent.appendChild(el('div', {className: 'other'}, [
createHeading('h2', '=', `${workerType} workers:`),
await getWorkerInfo(workerType),
]));
}

Expand Down Expand Up @@ -616,10 +624,14 @@ async function main() {
createHeading('h2', '=', `${adapterIds.size > 1 ? `#${ndx + 1} ` : ''}${(adapterIds.size > 1) ? `${desc}` : ''}`),
elem,
]))));
await checkMisc({haveFallback});
await checkWorkers('dedicated');
await checkWorkers('shared');
await checkWorkers('service');

const others = el('div', {className: 'others'})
addElemToDocument(others);
checkWGSLLanguageFeatures(others);
checkMisc(others, {haveFallback});
await checkWorker(others, 'dedicated');
await checkWorker(others, 'shared');
await checkWorker(others, 'service');

// Add a copy handler to massage the text for plain text.
document.addEventListener('copy', (event) => {
Expand Down

0 comments on commit 25abacf

Please sign in to comment.