Skip to content

Commit

Permalink
Web: Disable WebGPU button if WebGPU is not supported (close #216)
Browse files Browse the repository at this point in the history
  • Loading branch information
MikhailGorobets committed Aug 28, 2024
1 parent 12428ec commit c632314
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions SampleBase/src/Emscripten/resources/emscripten_template.html.in
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@
<div class="card">
<h1>Select Graphics API</h1>
<div class="button-container">
<button class="webgl" onclick="loadWasm('gles')" @DILIGENT_DISABLE_WEBGL@ >WebGL</button>
<button class="webgpu" onclick="loadWasm('wgpu')">WebGPU</button>
<button class="webgl" id="webgl-button" onclick="loadWasm('gles')" @DILIGENT_DISABLE_WEBGL@>WebGL</button>
<button class="webgpu" id="webgpu-button" onclick="loadWasm('wgpu')">WebGPU</button>
</div>
</div>
<div class="loading-indicator" id="loading-indicator">
Expand All @@ -223,6 +223,13 @@
}
}

function checkWebGPUSupport() {
const webgpuButton = document.getElementById('webgpu-button');
if (!navigator.gpu) {
webgpuButton.disabled = true;
}
}

var initWebGPUDevice = (async () => {
const requiredFeatures = [
"depth-clip-control",
Expand Down Expand Up @@ -308,6 +315,7 @@
};

detectBrowser();
checkWebGPUSupport()

window.onerror = function () {
console.log("onerror: " + event);
Expand Down

0 comments on commit c632314

Please sign in to comment.