Skip to content

Add WebGPU Bare device type for testing without optional features#8555

Merged
mvaligursky merged 3 commits intomainfrom
mv-webgpu-bare
Mar 25, 2026
Merged

Add WebGPU Bare device type for testing without optional features#8555
mvaligursky merged 3 commits intomainfrom
mv-webgpu-bare

Conversation

@mvaligursky
Copy link
Copy Markdown
Contributor

@mvaligursky mvaligursky commented Mar 25, 2026

Adds DEVICETYPE_WEBGPU_BARE ('webgpu:bare') — a WebGPU device mode that requests no optional features and uses default spec limits, simulating the most constrained WebGPU environment (e.g. iOS devices without float32-filterable or compressed textures).

Changes:

  • Add DEVICETYPE_WEBGPU_BARE constant to the engine public API
  • createGraphicsDevice recognizes webgpu:bare in the deviceTypes array and creates a bare WebGPU device accordingly
  • WebgpuGraphicsDevice.createDevice() skips all optional feature requests and uses default spec limits when in bare mode
  • Add "WebGPU Bare" option to the examples device selector (development builds only)
  • Add @config WEBGPU_BARE_DISABLED tag support for examples incompatible with bare mode
  • Fix @config parser regex bug where \s+ matched newlines, causing value-less flags (e.g. HIDDEN, WEBGL_DISABLED) to swallow the next @config line as their value

API Changes:

  • New constant: DEVICETYPE_WEBGPU_BARE ('webgpu:bare')
    const device = await pc.createGraphicsDevice(canvas, {
        deviceTypes: [pc.DEVICETYPE_WEBGPU_BARE]
    });

Adds DEVICETYPE_WEBGPU_BARE ('webgpu:bare') — a WebGPU device mode that
requests no optional features and uses default spec limits, simulating
the most constrained WebGPU environment.

Also fixes @config parser regex bug where \s+ matched newlines, causing
value-less flags to swallow the next @config line as their value.

Made-with: Cursor
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new “bare” WebGPU device selection (DEVICETYPE_WEBGPU_BARE / 'webgpu:bare') to help test the engine and examples under a constrained WebGPU configuration (no optional features; default limits behavior), plus updates the examples UI/config parsing to support selecting and disabling this mode.

Changes:

  • Introduces DEVICETYPE_WEBGPU_BARE in the engine and routes it through createGraphicsDevice to initialize WebGPU in “bare” mode.
  • Updates WebGPU device creation to optionally skip requesting optional adapter features / copying adapter limits.
  • Extends the examples device selector and @config parsing/handling to support WEBGPU_BARE_DISABLED, and fixes the @config regex newline swallowing issue.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/platform/graphics/webgpu/webgpu-graphics-device.js Adds “bare” feature-level handling to skip optional features/limits during WebGPU device creation.
src/platform/graphics/graphics-device-create.js Recognizes 'webgpu:bare' in deviceTypes and passes a feature-level option into WebGPU initialization.
src/platform/graphics/constants.js Exposes the new DEVICETYPE_WEBGPU_BARE constant in the public graphics constants.
examples/utils/utils.mjs Fixes @config parsing regex to avoid \\s+ consuming newlines.
examples/src/examples/test/radix-sort.example.mjs Marks radix-sort example as incompatible with bare WebGPU via WEBGPU_BARE_DISABLED.
examples/src/app/constants.mjs Adds 'webgpu:bare' constant for the examples app.
examples/src/app/components/DeviceSelector.mjs Adds “WebGPU Bare” option (dev-only) and improves WebGPU-family fallback handling.
examples/iframe/utils.mjs Fixes @config parsing regex; adds webgpu:bare selection and WEBGPU_BARE_DISABLED handling.
examples/iframe/loader.mjs Reports the selected WebGPU variant back to the UI when the engine is still in the WebGPU family.
Comments suppressed due to low confidence (2)

examples/utils/utils.mjs:52

  • While adding support for WEBGPU_BARE_DISABLED, the ExampleConfig typedef above parseConfig isn't updated to include this flag. Updating the typedef will keep generated metadata / editor IntelliSense in sync with the supported @config keys.
export const parseConfig = (script) => {
    const regex = /\/\/ @config (\S+)(?:[ \t]+([^\n]+))?/g;
    let match;
    /** @type {Record<string, any>} */
    const config = {};
    while ((match = regex.exec(script)) !== null) {
        const key = match[1].trim();
        const val = match[2]?.trim();
        config[key] = /true|false/.test(val) ? val === 'true' : val ?? true;
    }

examples/iframe/utils.mjs:113

  • updateDeviceType now also reads config.WEBGPU_BARE_DISABLED, but the JSDoc type for config only lists WEBGPU_DISABLED / WEBGL_DISABLED. Please update the JSDoc shape so the supported config flags are accurately documented.
/**
 * @param {{ WEBGPU_DISABLED: boolean; WEBGL_DISABLED: boolean; }} config - The configuration object.
 */
export function updateDeviceType(config) {
    const savedDevice = localStorage.getItem('preferredGraphicsDevice') ?? 'webgl2';

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/platform/graphics/webgpu/webgpu-graphics-device.js
Comment thread src/platform/graphics/webgpu/webgpu-graphics-device.js Outdated
Comment thread src/platform/graphics/graphics-device-create.js
@mvaligursky mvaligursky merged commit ad2e9ff into main Mar 25, 2026
8 checks passed
@mvaligursky mvaligursky deleted the mv-webgpu-bare branch March 25, 2026 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants