From 1b6c64403a828ee80942a896fb8109707a6e64d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Beaufort?= Date: Tue, 8 Oct 2024 17:09:30 +0200 Subject: [PATCH] Add HDR canvas support in misc section --- index.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 961ad87..a139de3 100644 --- a/index.js +++ b/index.js @@ -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:')), @@ -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');