Skip to content

Commit

Permalink
Merge pull request #19 from beaufortfrancois/hdr-canvas
Browse files Browse the repository at this point in the history
Add HDR canvas support in misc section
  • Loading branch information
beaufortfrancois authored Oct 9, 2024
2 parents f577c6d + 1b6c644 commit d6d9542
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -472,13 +472,25 @@ function checkWGSLLanguageFeatures(parent) {
]));
}

function checkMisc(parent, {haveFallback}) {
async function checkMisc(parent, {haveFallback}) {
const obj = {};
const presentationFormat = navigator.gpu.getPreferredCanvasFormat();
obj.getPreferredCanvasFormat = presentationFormat;
if (!haveFallback) {
obj['fallback adapter'] = 'not supported';
}
try {
const adapter = await navigator.gpu.requestAdapter();
const device = await adapter.requestDevice();
const canvas = document.createElement('canvas');
const context = canvas.getContext('webgpu');
context.configure({device, format: presentationFormat, toneMapping: {mode: 'extended'}});
const config = context.getConfiguration();
obj['HDR canvas support'] = config.toneMapping.mode === 'extended' ? 'supported' : 'not supported';
}
catch(error) {
obj['HDR canvas support'] = 'not supported';
}

parent.appendChild(el('div', {className: 'other'}, [
(createHeading('h2', '-', 'misc:')),
Expand Down Expand Up @@ -740,7 +752,7 @@ async function main() {
//const outer = el('div', {className: 'outer'}, [others]);
sectionsElem.appendChild(others);
checkWGSLLanguageFeatures(others);
checkMisc(others, {haveFallback});
await checkMisc(others, {haveFallback});
await checkWorker(others, 'dedicated');
await checkWorker(others, 'shared');
await checkWorker(others, 'service');
Expand Down

0 comments on commit d6d9542

Please sign in to comment.