Skip to content

Commit

Permalink
matdbg: fix matinfo use case (#7325)
Browse files Browse the repository at this point in the history
- Make sure matinfo works by selecting a default backend in the
   absence of activeShaders.
 - Add options to select backend in matinfo mode.
 - Workaround cursor misplacement for monaco
 - Refactor menu sections into a common element.
  • Loading branch information
poweifeng authored Nov 2, 2023
1 parent 4fd7c41 commit 46e6664
Show file tree
Hide file tree
Showing 2 changed files with 251 additions and 63 deletions.
16 changes: 16 additions & 0 deletions libs/matdbg/web/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,19 @@ async function statusLoop(isConnected, onStatus) {
setTimeout(() => statusLoop(isConnected, onStatus), STATUS_LOOP_TIMEOUT)
}
}

// Use browser User-agent to guess the current backend. This is mainly for matinfo which does
// not have a running backend.
function guessBackend() {
const AGENTS_TO_BACKEND = [
['Mac OS', 'metal'],
['Windows', 'opengl'],
['Linux', 'vulkan'],
];

const result = AGENTS_TO_BACKEND.filter((agent_backend) => {
return window.navigator.userAgent.search(agent_backend[0]);
}).map((agent_backend) => agent_backend[1]);

return result.length > 0 ? result[0] : null;
}
Loading

0 comments on commit 46e6664

Please sign in to comment.