feat: harden end-to-end simulation workflow
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
let capabilityPromise;
|
||||
|
||||
export function detectWebGpuCapability() {
|
||||
capabilityPromise ??= detect();
|
||||
return capabilityPromise;
|
||||
}
|
||||
|
||||
async function detect() {
|
||||
if (!navigator.gpu) {
|
||||
return { available: false, label: "CPU fallback", detail: "WebGPU API 없음" };
|
||||
}
|
||||
try {
|
||||
const adapter = await navigator.gpu.requestAdapter({ powerPreference: "high-performance" });
|
||||
if (!adapter) {
|
||||
return { available: false, label: "CPU fallback", detail: "WebGPU adapter 없음" };
|
||||
}
|
||||
const info = adapter.info;
|
||||
const adapterName = [info?.vendor, info?.architecture || info?.device]
|
||||
.filter(Boolean)
|
||||
.join(" · ");
|
||||
return {
|
||||
available: true,
|
||||
label: adapterName ? `WebGPU · ${adapterName}` : "WebGPU adapter 준비됨",
|
||||
detail: adapterName || "WebGPU adapter 준비됨",
|
||||
};
|
||||
} catch (error) {
|
||||
return {
|
||||
available: false,
|
||||
label: "CPU fallback",
|
||||
detail: error instanceof Error ? error.message : String(error),
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user