From ef736f421d8e6d33917ce5031f7d8593e81d74f1 Mon Sep 17 00:00:00 2001 From: Gregg Tavares Date: Tue, 2 Jul 2024 11:50:46 -0700 Subject: [PATCH] add gpu info --- test/index.js | 37 +++++++++++++++++++++++-------------- test/tests/gpu-info.js | 20 ++++++++++++++++++++ 2 files changed, 43 insertions(+), 14 deletions(-) create mode 100644 test/tests/gpu-info.js diff --git a/test/index.js b/test/index.js index 23bdc33..546c45b 100644 --- a/test/index.js +++ b/test/index.js @@ -1,18 +1,27 @@ /* global mocha */ -import './tests/buffer-views-test.js'; -import './tests/data-definition-test.js'; -import './tests/generate-mipmap-test.js'; -import './tests/attribute-utils-test.js'; -import './tests/texture-utils-test.js'; +import {getInfo} from './tests/gpu-info.js'; -const settings = typeof window === 'undefined' ? {} : Object.fromEntries(new URLSearchParams(window.location.search).entries()); -if (settings.reporter) { - mocha.reporter(settings.reporter); -} -if (settings.grep) { - mocha.grep(new RegExp(settings.grep, 'i'), false); +async function main() { + const settings = typeof window === 'undefined' ? {} : Object.fromEntries(new URLSearchParams(window.location.search).entries()); + if (settings.reporter) { + mocha.reporter(settings.reporter); + } + if (settings.grep) { + mocha.grep(new RegExp(settings.grep, 'i'), false); + } + + await getInfo(); + await Promise.all([ + import('./tests/buffer-views-test.js'), + import('./tests/data-definition-test.js'), + import('./tests/generate-mipmap-test.js'), + import('./tests/attribute-utils-test.js'), + import('./tests/texture-utils-test.js'), + ]); + + mocha.run((failures) => { + window.testsPromiseInfo.resolve(failures); + }); } -mocha.run((failures) => { - window.testsPromiseInfo.resolve(failures); -}); +main(); \ No newline at end of file diff --git a/test/tests/gpu-info.js b/test/tests/gpu-info.js new file mode 100644 index 0000000..c738721 --- /dev/null +++ b/test/tests/gpu-info.js @@ -0,0 +1,20 @@ +import { describe, it } from '../mocha-support.js'; + +function objLikeToObj(objLike) { + const obj = {}; + for (const k in objLike) { + obj[k] = objLike[k]; + } + return obj; +} + +export async function getInfo() { + const adapter = await navigator.gpu.requestAdapter(); + const info = adapter?.info ?? await adapter?.requestAdapterInfo() ?? {}; + const title = JSON.stringify(objLikeToObj(info), null, 2); + + describe('gpu info', () => { + it(title, () => {}); + }); +} +