test_config.ts (2879B)
1 import { assert, hasFeature } from '../util/util.js'; 2 3 export type TestConfig = { 4 /** 5 * Enable debug-level logs (normally logged via `Fixture.debug()`). 6 */ 7 enableDebugLogs: boolean; 8 9 /** 10 * Maximum number of subcases in flight at once, within a case. Once this many 11 * are in flight, wait for a subcase to finish before starting the next one. 12 */ 13 maxSubcasesInFlight: number; 14 15 /** 16 * After this many subcases run on the page, run `attemptGarbageCollection()`. 17 * Setting to `Infinity` disables this. Setting to 1 attempts GC every time (slow!). 18 */ 19 subcasesBetweenAttemptingGC: number; 20 21 /** 22 * After this many cases use a device, destroy and replace it to free GPU resources. 23 * Setting to `Infinity` disables this. Setting to 1 gets a new device every time (slow!). 24 */ 25 casesBetweenReplacingDevice: number; 26 27 testHeartbeatCallback: () => void; 28 29 noRaceWithRejectOnTimeout: boolean; 30 31 /** 32 * Logger for debug messages from the test framework 33 * (that can't be captured in the logs of a test). 34 */ 35 frameworkDebugLog?: (msg: string) => void; 36 37 /** 38 * Controls the emission of loops in constant-evaluation shaders under 39 * 'webgpu:shader,execution,expression,*' 40 * FXC is extremely slow to compile shaders with loops unrolled, where as the 41 * MSL compiler is extremely slow to compile with loops rolled. 42 */ 43 unrollConstEvalLoops: boolean; 44 45 /** 46 * Whether or not we're running in compatibility mode. 47 */ 48 compatibility: boolean; 49 50 /** 51 * Whether or not to request a fallback adapter. 52 */ 53 forceFallbackAdapter: boolean; 54 55 /** 56 * Enforce the default limits on the adapter 57 */ 58 enforceDefaultLimits: boolean; 59 60 /** 61 * Block all features on the adapter 62 */ 63 blockAllFeatures: boolean; 64 65 /** 66 * Whether to enable the `logToWebSocket` function used for out-of-band test logging. 67 */ 68 logToWebSocket: boolean; 69 }; 70 71 /** Test configuration options. Globally modifiable global state. */ 72 export const globalTestConfig: TestConfig = { 73 enableDebugLogs: false, 74 maxSubcasesInFlight: 100, 75 subcasesBetweenAttemptingGC: 5000, 76 casesBetweenReplacingDevice: Infinity, 77 testHeartbeatCallback: () => {}, 78 noRaceWithRejectOnTimeout: false, 79 unrollConstEvalLoops: false, 80 compatibility: false, 81 forceFallbackAdapter: false, 82 enforceDefaultLimits: false, 83 blockAllFeatures: false, 84 logToWebSocket: false, 85 }; 86 87 // Check if a device is a compatibility device. 88 // Note: The CTS generally, requires that if globalTestConfig.compatibility 89 // is true then the device MUST be a compatibility device since the CTS 90 // is trying to test that compatibility devices have the correct validation. 91 export function isCompatibilityDevice(device: GPUDevice) { 92 if (globalTestConfig.compatibility) { 93 assert(!hasFeature(device.features, 'core-features-and-limits')); 94 } 95 return globalTestConfig.compatibility; 96 }