Skip to content

Commit

Permalink
Request adapters using featureLevel:compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
beaufortfrancois committed Dec 10, 2024
1 parent a952b0e commit 9a7c460
Show file tree
Hide file tree
Showing 10 changed files with 125 additions and 154 deletions.
6 changes: 0 additions & 6 deletions src/common/framework/test_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ export type TestConfig = {
*/
unrollConstEvalLoops: boolean;

/**
* Feature level for the adapter request.
*/
featureLevel: string | null;

/**
* Whether or not we're running in compatibility mode.
*/
Expand All @@ -62,7 +57,6 @@ export const globalTestConfig: TestConfig = {
testHeartbeatCallback: () => {},
noRaceWithRejectOnTimeout: false,
unrollConstEvalLoops: false,
featureLevel: null,
compatibility: false,
forceFallbackAdapter: false,
logToWebSocket: false,
Expand Down
8 changes: 1 addition & 7 deletions src/common/runtime/cmdline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ for (let i = 0; i < sys.args.length; ++i) {
globalTestConfig.unrollConstEvalLoops = true;
} else if (a === '--compat') {
globalTestConfig.compatibility = true;
globalTestConfig.featureLevel = 'compatibility';
} else if (a === '--force-fallback-adapter') {
globalTestConfig.forceFallbackAdapter = true;
} else if (a === '--log-to-websocket') {
Expand All @@ -121,14 +120,9 @@ for (let i = 0; i < sys.args.length; ++i) {

let codeCoverage: CodeCoverageProvider | undefined = undefined;

if (
globalTestConfig.featureLevel ||
globalTestConfig.compatibility ||
globalTestConfig.forceFallbackAdapter
) {
if (globalTestConfig.compatibility || globalTestConfig.forceFallbackAdapter) {
// MAINTENANCE_TODO: remove the cast once compatibilityMode is officially added
setDefaultRequestAdapterOptions({
featureLevel: globalTestConfig.featureLevel,
compatibilityMode: globalTestConfig.compatibility,
forceFallbackAdapter: globalTestConfig.forceFallbackAdapter,
} as GPURequestAdapterOptions);
Expand Down
13 changes: 1 addition & 12 deletions src/common/runtime/helper/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ export function optionWorkerMode(
export interface CTSOptions {
worker: WorkerMode | null;
debug: boolean;
featureLevel: 'core' | 'compatibility' | null;
compatibility: boolean;
forceFallbackAdapter: boolean;
unrollConstEvalLoops: boolean;
Expand All @@ -62,7 +61,6 @@ export interface CTSOptions {
export const kDefaultCTSOptions: CTSOptions = {
worker: null,
debug: true,
featureLevel: null,
compatibility: false,
forceFallbackAdapter: false,
unrollConstEvalLoops: false,
Expand Down Expand Up @@ -100,16 +98,7 @@ export const kCTSOptionsInfo: OptionsInfos<CTSOptions> = {
],
},
debug: { description: 'show more info' },
featureLevel: {
description: 'set feature level for some tests',
parser: optionString,
selectValueDescriptions: [
{ value: null, description: 'default' },
{ value: 'core', description: 'core' },
{ value: 'compatibility', description: 'compatibility' },
],
},
compatibility: { description: 'run in compatibility mode (non-standard)' },
compatibility: { description: 'run in compatibility mode' },
forceFallbackAdapter: { description: 'pass forceFallbackAdapter: true to requestAdapter' },
unrollConstEvalLoops: { description: 'unroll const eval loops in WGSL' },
powerPreference: {
Expand Down
6 changes: 2 additions & 4 deletions src/common/runtime/helper/utils_worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,16 @@ export interface WorkerTestRunRequest {
* Set config environment for workers with ctsOptions and return a Logger.
*/
export function setupWorkerEnvironment(ctsOptions: CTSOptions): Logger {
const { featureLevel, powerPreference, compatibility } = ctsOptions;
const { powerPreference, compatibility } = ctsOptions;
globalTestConfig.enableDebugLogs = ctsOptions.debug;
globalTestConfig.unrollConstEvalLoops = ctsOptions.unrollConstEvalLoops;
globalTestConfig.featureLevel = featureLevel;
globalTestConfig.compatibility = compatibility;
globalTestConfig.logToWebSocket = ctsOptions.logToWebSocket;

const log = new Logger();

if (featureLevel || powerPreference || compatibility) {
if (powerPreference || compatibility) {
setDefaultRequestAdapterOptions({
...(featureLevel && { featureLevel }),
...(powerPreference && { powerPreference }),
// MAINTENANCE_TODO: Change this to whatever the option ends up being
...(compatibility && { compatibilityMode: true }),
Expand Down
9 changes: 2 additions & 7 deletions src/common/runtime/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ for (let i = 0; i < sys.args.length; ++i) {
Colors.enabled = true;
} else if (a === '--compat') {
globalTestConfig.compatibility = true;
globalTestConfig.featureLevel = 'compatibility';
} else if (a === '--coverage') {
emitCoverage = true;
} else if (a === '--force-fallback-adapter') {
Expand Down Expand Up @@ -120,14 +119,10 @@ for (let i = 0; i < sys.args.length; ++i) {

let codeCoverage: CodeCoverageProvider | undefined = undefined;

if (
globalTestConfig.featureLevel ||
globalTestConfig.compatibility ||
globalTestConfig.forceFallbackAdapter
) {
console.log("server");
if (globalTestConfig.compatibility || globalTestConfig.forceFallbackAdapter) {
// MAINTENANCE_TODO: remove the cast once compatibilityMode is officially added
setDefaultRequestAdapterOptions({
featureLevel: globalTestConfig.featureLevel,
compatibilityMode: globalTestConfig.compatibility,
forceFallbackAdapter: globalTestConfig.forceFallbackAdapter,
} as GPURequestAdapterOptions);
Expand Down
5 changes: 2 additions & 3 deletions src/common/runtime/standalone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const { queries: qs, options } = parseSearchParamLikeWithOptions(
kStandaloneOptionsInfos,
window.location.search || rootQuerySpec
);
const { runnow, featureLevel, powerPreference, compatibility, forceFallbackAdapter } = options;
const { runnow, powerPreference, compatibility, forceFallbackAdapter } = options;
globalTestConfig.enableDebugLogs = options.debug;
globalTestConfig.unrollConstEvalLoops = options.unrollConstEvalLoops;
globalTestConfig.compatibility = compatibility;
Expand Down Expand Up @@ -81,9 +81,8 @@ stopButtonElem.addEventListener('click', () => {
stopRequested = true;
});

if (featureLevel || powerPreference || compatibility || forceFallbackAdapter) {
if (powerPreference || compatibility || forceFallbackAdapter) {
setDefaultRequestAdapterOptions({
...(featureLevel && { featureLevel }),
...(powerPreference && { powerPreference }),
// MAINTENANCE_TODO: Change this to whatever the option ends up being
...(compatibility && { compatibilityMode: true }),
Expand Down
4 changes: 4 additions & 0 deletions src/common/util/navigator_gpu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ export function setDefaultRequestAdapterOptions(options: GPURequestAdapterOption
throw new Error('must call setDefaultRequestAdapterOptions before getGPU');
}
defaultRequestAdapterOptions = { ...options };
// MAINTENANCE_TODO: remove this once compatibilityMode is removed.
defaultRequestAdapterOptions.featureLevel =
'compatibilityMode' in options && options.compatibilityMode ? 'compatibility' : 'core';

}

export function getDefaultRequestAdapterOptions() {
Expand Down
220 changes: 110 additions & 110 deletions src/resources/cache/hashes.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9a7c460

Please sign in to comment.