Skip to content

Commit

Permalink
add gpu info
Browse files Browse the repository at this point in the history
  • Loading branch information
greggman committed Jul 2, 2024
1 parent f3c17a7 commit ef736f4
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 14 deletions.
37 changes: 23 additions & 14 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -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();
20 changes: 20 additions & 0 deletions test/tests/gpu-info.js
Original file line number Diff line number Diff line change
@@ -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, () => {});
});
}

0 comments on commit ef736f4

Please sign in to comment.