Skip to content

Commit

Permalink
Add WGSL Features, even if they don't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
s-macke committed Jun 26, 2024
1 parent d937366 commit 0f1a98f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
25 changes: 10 additions & 15 deletions src/scripts/features/features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,15 @@ import {GPU} from "../webgpu/gpu";
import {GPUAbstractRunner, RunnerType} from "../AbstractGPURunner";

export class Features extends GPUAbstractRunner {
Destroy(): Promise<void> {
return Promise.resolve(undefined);
async Destroy() {
}
Init(): Promise<void> {
return Promise.resolve(undefined);

async Init() {
}

Run(): Promise<void> {
async Run() {
let element = document.getElementById("info");
element.innerHTML = this.GetFeaturesAsHtml();

return Promise.resolve(undefined);
}

getType(): RunnerType {
Expand Down Expand Up @@ -53,14 +50,12 @@ export class Features extends GPUAbstractRunner {
}

features = GPU.GetWGSLFeatures();
if (features != null) {
s += "<br><h4>WGSL Features</h4>"
if (features.size == 0) {
s += "-- none --";
}
for (let item of features.values()) {
s += item + "<br>";
}
s += "<br><h4>WGSL Features</h4>"
if (features.size == 0) {
s += "-- none --";
}
for (let item of features.values()) {
s += item + "<br>";
}

s += "<br><br><h4>Preferred Output Format</h4>" + navigator.gpu.getPreferredCanvasFormat();
Expand Down
4 changes: 4 additions & 0 deletions src/scripts/webgpu/gpu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ export class GPU {
}

static GetWGSLFeatures(): ReadonlySet<string> {
if (navigator.gpu.wgslLanguageFeatures == null) {
const readonly: ReadonlySet<string> = new Set([]);
return readonly
}
return navigator.gpu.wgslLanguageFeatures
}

Expand Down

0 comments on commit 0f1a98f

Please sign in to comment.