import { ae as n } from "../index-DSGwv2Yx.js";
import p from "./webgpu_backend.js";
function c(a) {
  n(
    "webgpu",
    async () => {
      const i = {
        powerPreference: a?.powerPreference ?? "high-performance"
      };
      console.log("Using custom WebGPU backend with power preference:", i.powerPreference);
      const e = await navigator.gpu.requestAdapter(i), t = {}, o = [];
      e.features.has("timestamp-query") && o.push("timestamp-query"), e.features.has("bgra8unorm-storage") && o.push(["bgra8unorm-storage"]), !a?.disableSubgroups && e.features.has("subgroups") && o.push("subgroups"), t.requiredFeatures = o;
      const r = e.limits;
      t.requiredLimits = {
        maxComputeWorkgroupStorageSize: r.maxComputeWorkgroupStorageSize,
        maxComputeWorkgroupsPerDimension: r.maxComputeWorkgroupsPerDimension,
        maxStorageBufferBindingSize: r.maxStorageBufferBindingSize,
        maxBufferSize: r.maxBufferSize,
        maxComputeWorkgroupSizeX: r.maxComputeWorkgroupSizeX,
        maxComputeInvocationsPerWorkgroup: r.maxComputeInvocationsPerWorkgroup
      };
      const u = await e.requestDevice(t), s = "info" in e ? e.info : "requestAdapterInfo" in e ? (
        // eslint-disable-next-line @typescript-eslint/no-explicit-any
        await e.requestAdapterInfo()
      ) : void 0;
      return new p(u, s);
    },
    3
    /*priority*/
  );
}
export {
  c as registerWebGPUBackend
};
