diff options
Diffstat (limited to 'testing/web-platform/mozilla/tests/webgpu/common/util')
18 files changed, 858 insertions, 0 deletions
diff --git a/testing/web-platform/mozilla/tests/webgpu/common/util/collect_garbage.js b/testing/web-platform/mozilla/tests/webgpu/common/util/collect_garbage.js new file mode 100644 index 0000000000..0c078a11b9 --- /dev/null +++ b/testing/web-platform/mozilla/tests/webgpu/common/util/collect_garbage.js @@ -0,0 +1,59 @@ +/** +* AUTO-GENERATED - DO NOT EDIT. Source: https://github.com/gpuweb/cts +**/import { resolveOnTimeout } from './util.js'; + + +/** + * Attempts to trigger JavaScript garbage collection, either using explicit methods if exposed + * (may be available in testing environments with special browser runtime flags set), or using + * some weird tricks to incur GC pressure. Adopted from the WebGL CTS. + */ +export async function attemptGarbageCollection() { + + const w = globalThis; + if (w.GCController) { + w.GCController.collect(); + return; + } + + if (w.opera && w.opera.collect) { + w.opera.collect(); + return; + } + + try { + w.QueryInterface(Components.interfaces.nsIInterfaceRequestor). + getInterface(Components.interfaces.nsIDOMWindowUtils). + garbageCollect(); + return; + } catch (e) { + + // ignore any failure + } + if (w.gc) { + w.gc(); + return; + } + + if (w.CollectGarbage) { + w.CollectGarbage(); + return; + } + + let i; + function gcRec(n) { + if (n < 1) return; + + let temp = { i: 'ab' + i + i / 100000 }; + + temp = temp + 'foo'; + temp; // dummy use of unused variable + gcRec(n - 1); + } + for (i = 0; i < 1000; i++) { + gcRec(10); + } + + return resolveOnTimeout(35); // Let the event loop run a few frames in case it helps. +} +//# sourceMappingURL=collect_garbage.js.map
\ No newline at end of file diff --git a/testing/web-platform/mozilla/tests/webgpu/common/util/collect_garbage.js.map b/testing/web-platform/mozilla/tests/webgpu/common/util/collect_garbage.js.map new file mode 100644 index 0000000000..59020707d6 --- /dev/null +++ b/testing/web-platform/mozilla/tests/webgpu/common/util/collect_garbage.js.map @@ -0,0 +1 @@ +{"version":3,"file":"collect_garbage.js","names":["resolveOnTimeout","attemptGarbageCollection","w","globalThis","GCController","collect","opera","QueryInterface","Components","interfaces","nsIInterfaceRequestor","getInterface","nsIDOMWindowUtils","garbageCollect","e","gc","CollectGarbage","i","gcRec","n","temp"],"sources":["../../../src/common/util/collect_garbage.ts"],"sourcesContent":["import { resolveOnTimeout } from './util.js';\n\n/* eslint-disable-next-line @typescript-eslint/no-explicit-any */\ndeclare const Components: any;\n\n/**\n * Attempts to trigger JavaScript garbage collection, either using explicit methods if exposed\n * (may be available in testing environments with special browser runtime flags set), or using\n * some weird tricks to incur GC pressure. Adopted from the WebGL CTS.\n */\nexport async function attemptGarbageCollection(): Promise<void> {\n /* eslint-disable-next-line @typescript-eslint/no-explicit-any */\n const w: any = globalThis;\n if (w.GCController) {\n w.GCController.collect();\n return;\n }\n\n if (w.opera && w.opera.collect) {\n w.opera.collect();\n return;\n }\n\n try {\n w.QueryInterface(Components.interfaces.nsIInterfaceRequestor)\n .getInterface(Components.interfaces.nsIDOMWindowUtils)\n .garbageCollect();\n return;\n } catch (e) {\n // ignore any failure\n }\n\n if (w.gc) {\n w.gc();\n return;\n }\n\n if (w.CollectGarbage) {\n w.CollectGarbage();\n return;\n }\n\n let i: number;\n function gcRec(n: number): void {\n if (n < 1) return;\n /* eslint-disable @typescript-eslint/restrict-plus-operands */\n let temp: object | string = { i: 'ab' + i + i / 100000 };\n /* eslint-disable @typescript-eslint/restrict-plus-operands */\n temp = temp + 'foo';\n temp; // dummy use of unused variable\n gcRec(n - 1);\n }\n for (i = 0; i < 1000; i++) {\n gcRec(10);\n }\n\n return resolveOnTimeout(35); // Let the event loop run a few frames in case it helps.\n}\n"],"mappings":";AAAA;AAAA,GAAA,SAASA,gBAAgB,QAAQ,WAAW;;;AAK5C;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,wBAAwB,GAAkB;;EAE9D,MAAMC,CAAM,GAAGC,UAAU;EACzB,IAAID,CAAC,CAACE,YAAY,EAAE;IAClBF,CAAC,CAACE,YAAY,CAACC,OAAO,EAAE;IACxB;EACF;;EAEA,IAAIH,CAAC,CAACI,KAAK,IAAIJ,CAAC,CAACI,KAAK,CAACD,OAAO,EAAE;IAC9BH,CAAC,CAACI,KAAK,CAACD,OAAO,EAAE;IACjB;EACF;;EAEA,IAAI;IACFH,CAAC,CAACK,cAAc,CAACC,UAAU,CAACC,UAAU,CAACC,qBAAqB,CAAC;IAC1DC,YAAY,CAACH,UAAU,CAACC,UAAU,CAACG,iBAAiB,CAAC;IACrDC,cAAc,EAAE;IACnB;EACF,CAAC,CAAC,OAAOC,CAAC,EAAE;;IACV;EAAA;EAGF,IAAIZ,CAAC,CAACa,EAAE,EAAE;IACRb,CAAC,CAACa,EAAE,EAAE;IACN;EACF;;EAEA,IAAIb,CAAC,CAACc,cAAc,EAAE;IACpBd,CAAC,CAACc,cAAc,EAAE;IAClB;EACF;;EAEA,IAAIC,CAAS;EACb,SAASC,KAAK,CAACC,CAAS,EAAQ;IAC9B,IAAIA,CAAC,GAAG,CAAC,EAAE;;IAEX,IAAIC,IAAqB,GAAG,EAAEH,CAAC,EAAE,IAAI,GAAGA,CAAC,GAAGA,CAAC,GAAG,MAAM,CAAC,CAAC;;IAExDG,IAAI,GAAGA,IAAI,GAAG,KAAK;IACnBA,IAAI,CAAC,CAAC;IACNF,KAAK,CAACC,CAAC,GAAG,CAAC,CAAC;EACd;EACA,KAAKF,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAG,IAAI,EAAEA,CAAC,EAAE,EAAE;IACzBC,KAAK,CAAC,EAAE,CAAC;EACX;;EAEA,OAAOlB,gBAAgB,CAAC,EAAE,CAAC,CAAC,CAAC;AAC/B"}
\ No newline at end of file diff --git a/testing/web-platform/mozilla/tests/webgpu/common/util/colors.js b/testing/web-platform/mozilla/tests/webgpu/common/util/colors.js new file mode 100644 index 0000000000..7f8f11eacb --- /dev/null +++ b/testing/web-platform/mozilla/tests/webgpu/common/util/colors.js @@ -0,0 +1,128 @@ +/** +* AUTO-GENERATED - DO NOT EDIT. Source: https://github.com/gpuweb/cts +**/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +/** + * The interface used for formatting strings with color metadata. + * + * Currently Colors will use the 'ansi-colors' module if it can be loaded. + * If it cannot be loaded, then the Colors implementation is a straight pass-through. + * + * Colors may also be a no-op if the current environment does not support colors. + */ +export let Colors; + +try { + + Colors = require('ansi-colors'); +} catch { + const passthrough = (s) => s; + passthrough.enabled = false; + passthrough.reset = passthrough; + passthrough.bold = passthrough; + passthrough.dim = passthrough; + passthrough.italic = passthrough; + passthrough.underline = passthrough; + passthrough.inverse = passthrough; + passthrough.hidden = passthrough; + passthrough.strikethrough = passthrough; + passthrough.black = passthrough; + passthrough.red = passthrough; + passthrough.green = passthrough; + passthrough.yellow = passthrough; + passthrough.blue = passthrough; + passthrough.magenta = passthrough; + passthrough.cyan = passthrough; + passthrough.white = passthrough; + passthrough.gray = passthrough; + passthrough.grey = passthrough; + passthrough.blackBright = passthrough; + passthrough.redBright = passthrough; + passthrough.greenBright = passthrough; + passthrough.yellowBright = passthrough; + passthrough.blueBright = passthrough; + passthrough.magentaBright = passthrough; + passthrough.cyanBright = passthrough; + passthrough.whiteBright = passthrough; + passthrough.bgBlack = passthrough; + passthrough.bgRed = passthrough; + passthrough.bgGreen = passthrough; + passthrough.bgYellow = passthrough; + passthrough.bgBlue = passthrough; + passthrough.bgMagenta = passthrough; + passthrough.bgCyan = passthrough; + passthrough.bgWhite = passthrough; + passthrough.bgBlackBright = passthrough; + passthrough.bgRedBright = passthrough; + passthrough.bgGreenBright = passthrough; + passthrough.bgYellowBright = passthrough; + passthrough.bgBlueBright = passthrough; + passthrough.bgMagentaBright = passthrough; + passthrough.bgCyanBright = passthrough; + passthrough.bgWhiteBright = passthrough; + Colors = passthrough; +} +//# sourceMappingURL=colors.js.map
\ No newline at end of file diff --git a/testing/web-platform/mozilla/tests/webgpu/common/util/colors.js.map b/testing/web-platform/mozilla/tests/webgpu/common/util/colors.js.map new file mode 100644 index 0000000000..581265e20f --- /dev/null +++ b/testing/web-platform/mozilla/tests/webgpu/common/util/colors.js.map @@ -0,0 +1 @@ +{"version":3,"file":"colors.js","names":["Colors","require","passthrough","s","enabled","reset","bold","dim","italic","underline","inverse","hidden","strikethrough","black","red","green","yellow","blue","magenta","cyan","white","gray","grey","blackBright","redBright","greenBright","yellowBright","blueBright","magentaBright","cyanBright","whiteBright","bgBlack","bgRed","bgGreen","bgYellow","bgBlue","bgMagenta","bgCyan","bgWhite","bgBlackBright","bgRedBright","bgGreenBright","bgYellowBright","bgBlueBright","bgMagentaBright","bgCyanBright","bgWhiteBright"],"sources":["../../../src/common/util/colors.ts"],"sourcesContent":["/**\n * The interface used for formatting strings to contain color metadata.\n *\n * Use the interface properties to construct a style, then use the\n * `(s: string): string` function to format the provided string with the given\n * style.\n */\nexport interface Colors {\n // Are colors enabled?\n enabled: boolean;\n\n // Returns the string formatted to contain the specified color or style.\n (s: string): string;\n\n // modifiers\n reset: Colors;\n bold: Colors;\n dim: Colors;\n italic: Colors;\n underline: Colors;\n inverse: Colors;\n hidden: Colors;\n strikethrough: Colors;\n\n // colors\n black: Colors;\n red: Colors;\n green: Colors;\n yellow: Colors;\n blue: Colors;\n magenta: Colors;\n cyan: Colors;\n white: Colors;\n gray: Colors;\n grey: Colors;\n\n // bright colors\n blackBright: Colors;\n redBright: Colors;\n greenBright: Colors;\n yellowBright: Colors;\n blueBright: Colors;\n magentaBright: Colors;\n cyanBright: Colors;\n whiteBright: Colors;\n\n // background colors\n bgBlack: Colors;\n bgRed: Colors;\n bgGreen: Colors;\n bgYellow: Colors;\n bgBlue: Colors;\n bgMagenta: Colors;\n bgCyan: Colors;\n bgWhite: Colors;\n\n // bright background colors\n bgBlackBright: Colors;\n bgRedBright: Colors;\n bgGreenBright: Colors;\n bgYellowBright: Colors;\n bgBlueBright: Colors;\n bgMagentaBright: Colors;\n bgCyanBright: Colors;\n bgWhiteBright: Colors;\n}\n\n/**\n * The interface used for formatting strings with color metadata.\n *\n * Currently Colors will use the 'ansi-colors' module if it can be loaded.\n * If it cannot be loaded, then the Colors implementation is a straight pass-through.\n *\n * Colors may also be a no-op if the current environment does not support colors.\n */\nexport let Colors: Colors;\n\ntry {\n /* eslint-disable-next-line node/no-unpublished-require */\n Colors = require('ansi-colors') as Colors;\n} catch {\n const passthrough = ((s: string) => s) as Colors;\n passthrough.enabled = false;\n passthrough.reset = passthrough;\n passthrough.bold = passthrough;\n passthrough.dim = passthrough;\n passthrough.italic = passthrough;\n passthrough.underline = passthrough;\n passthrough.inverse = passthrough;\n passthrough.hidden = passthrough;\n passthrough.strikethrough = passthrough;\n passthrough.black = passthrough;\n passthrough.red = passthrough;\n passthrough.green = passthrough;\n passthrough.yellow = passthrough;\n passthrough.blue = passthrough;\n passthrough.magenta = passthrough;\n passthrough.cyan = passthrough;\n passthrough.white = passthrough;\n passthrough.gray = passthrough;\n passthrough.grey = passthrough;\n passthrough.blackBright = passthrough;\n passthrough.redBright = passthrough;\n passthrough.greenBright = passthrough;\n passthrough.yellowBright = passthrough;\n passthrough.blueBright = passthrough;\n passthrough.magentaBright = passthrough;\n passthrough.cyanBright = passthrough;\n passthrough.whiteBright = passthrough;\n passthrough.bgBlack = passthrough;\n passthrough.bgRed = passthrough;\n passthrough.bgGreen = passthrough;\n passthrough.bgYellow = passthrough;\n passthrough.bgBlue = passthrough;\n passthrough.bgMagenta = passthrough;\n passthrough.bgCyan = passthrough;\n passthrough.bgWhite = passthrough;\n passthrough.bgBlackBright = passthrough;\n passthrough.bgRedBright = passthrough;\n passthrough.bgGreenBright = passthrough;\n passthrough.bgYellowBright = passthrough;\n passthrough.bgBlueBright = passthrough;\n passthrough.bgMagentaBright = passthrough;\n passthrough.bgCyanBright = passthrough;\n passthrough.bgWhiteBright = passthrough;\n Colors = passthrough;\n}\n"],"mappings":";AAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmEA;AACA;AACA;AACA;AACA;AACA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CAAC4B,WAAW,GAAG5B,WAAW;EACrCA,WAAW,CAAC6B,OAAO,GAAG7B,WAAW;EACjCA,WAAW,CAAC8B,KAAK,GAAG9B,WAAW;EAC/BA,WAAW,CAAC+B,OAAO,GAAG/B,WAAW;EACjCA,WAAW,CAACgC,QAAQ,GAAGhC,WAAW;EAClCA,WAAW,CAACiC,MAAM,GAAGjC,WAAW;EAChCA,WAAW,CAACkC,SAAS,GAAGlC,WAAW;EACnCA,WAAW,CAACmC,MAAM,GAAGnC,WAAW;EAChCA,WAAW,CAACoC,OAAO,GAAGpC,WAAW;EACjCA,WAAW,CAACqC,aAAa,GAAGrC,WAAW;EACvCA,WAAW,CAACsC,WAAW,GAAGtC,WAAW;EACrCA,WAAW,CAACuC,aAAa,GAAGvC,WAAW;EACvCA,WAAW,CAACwC,cAAc,GAAGxC,WAAW;EACxCA,WAAW,CAACyC,YAAY,GAAGzC,WAAW;EACtCA,WAAW,CAAC0C,eAAe,GAAG1C,WAAW;EACzCA,WAAW,CAAC2C,YAAY,GAAG3C,WAAW;EACtCA,WAAW,CAAC4C,aAAa,GAAG5C,WAAW;EACvCF,MAAM,GAAGE,WAAW;AACtB"}
\ No newline at end of file diff --git a/testing/web-platform/mozilla/tests/webgpu/common/util/data_tables.js b/testing/web-platform/mozilla/tests/webgpu/common/util/data_tables.js new file mode 100644 index 0000000000..845cebf1fc --- /dev/null +++ b/testing/web-platform/mozilla/tests/webgpu/common/util/data_tables.js @@ -0,0 +1,40 @@ +/** +* AUTO-GENERATED - DO NOT EDIT. Source: https://github.com/gpuweb/cts +**/ + +export function keysOf(obj) { + return Object.keys(obj); +} + +export function numericKeysOf(obj) { + return Object.keys(obj).map((n) => Number(n)); +} + +/** + * Creates an info lookup object from a more nicely-formatted table. See below for examples. + * + * Note: Using `as const` on the arguments to this function is necessary to infer the correct type. + */ +export function makeTable( + + + + +members, +defaults, +table) + + +{ + const result = {}; + for (const [k, v] of Object.entries(table)) { + const item = {}; + for (let i = 0; i < members.length; ++i) { + item[members[i]] = v[i] ?? defaults[i]; + } + result[k] = item; + } + + return result; +} +//# sourceMappingURL=data_tables.js.map
\ No newline at end of file diff --git a/testing/web-platform/mozilla/tests/webgpu/common/util/data_tables.js.map b/testing/web-platform/mozilla/tests/webgpu/common/util/data_tables.js.map new file mode 100644 index 0000000000..512f535412 --- /dev/null +++ b/testing/web-platform/mozilla/tests/webgpu/common/util/data_tables.js.map @@ -0,0 +1 @@ +{"version":3,"file":"data_tables.js","names":["keysOf","obj","Object","keys","numericKeysOf","map","n","Number","makeTable","members","defaults","table","result","k","v","entries","item","i","length"],"sources":["../../../src/common/util/data_tables.ts"],"sourcesContent":["import { ResolveType, ZipKeysWithValues } from './types.js';\n\nexport type valueof<K> = K[keyof K];\n\nexport function keysOf<T extends string>(obj: { [k in T]: unknown }): readonly T[] {\n return (Object.keys(obj) as unknown[]) as T[];\n}\n\nexport function numericKeysOf<T>(obj: object): readonly T[] {\n return (Object.keys(obj).map(n => Number(n)) as unknown[]) as T[];\n}\n\n/**\n * Creates an info lookup object from a more nicely-formatted table. See below for examples.\n *\n * Note: Using `as const` on the arguments to this function is necessary to infer the correct type.\n */\nexport function makeTable<\n Members extends readonly string[],\n Defaults extends readonly unknown[],\n Table extends { readonly [k: string]: readonly unknown[] }\n>(\n members: Members,\n defaults: Defaults,\n table: Table\n): {\n readonly [k in keyof Table]: ResolveType<ZipKeysWithValues<Members, Table[k], Defaults>>;\n} {\n const result: { [k: string]: { [m: string]: unknown } } = {};\n for (const [k, v] of Object.entries<readonly unknown[]>(table)) {\n const item: { [m: string]: unknown } = {};\n for (let i = 0; i < members.length; ++i) {\n item[members[i]] = v[i] ?? defaults[i];\n }\n result[k] = item;\n }\n /* eslint-disable-next-line @typescript-eslint/no-explicit-any */\n return result as any;\n}\n"],"mappings":";AAAA;AAAA;;AAIA,OAAO,SAASA,MAAM,CAAmBC,GAA0B,EAAgB;EACjF,OAAQC,MAAM,CAACC,IAAI,CAACF,GAAG,CAAC;AAC1B;;AAEA,OAAO,SAASG,aAAa,CAAIH,GAAW,EAAgB;EAC1D,OAAQC,MAAM,CAACC,IAAI,CAACF,GAAG,CAAC,CAACI,GAAG,CAAC,CAAAC,CAAC,KAAIC,MAAM,CAACD,CAAC,CAAC,CAAC;AAC9C;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,SAAS;;;;;AAKvBC,OAAgB;AAChBC,QAAkB;AAClBC,KAAY;;;AAGZ;EACA,MAAMC,MAAiD,GAAG,CAAC,CAAC;EAC5D,KAAK,MAAM,CAACC,CAAC,EAAEC,CAAC,CAAC,IAAIZ,MAAM,CAACa,OAAO,CAAqBJ,KAAK,CAAC,EAAE;IAC9D,MAAMK,IAA8B,GAAG,CAAC,CAAC;IACzC,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGR,OAAO,CAACS,MAAM,EAAE,EAAED,CAAC,EAAE;MACvCD,IAAI,CAACP,OAAO,CAACQ,CAAC,CAAC,CAAC,GAAGH,CAAC,CAACG,CAAC,CAAC,IAAIP,QAAQ,CAACO,CAAC,CAAC;IACxC;IACAL,MAAM,CAACC,CAAC,CAAC,GAAGG,IAAI;EAClB;;EAEA,OAAOJ,MAAM;AACf"}
\ No newline at end of file diff --git a/testing/web-platform/mozilla/tests/webgpu/common/util/navigator_gpu.js b/testing/web-platform/mozilla/tests/webgpu/common/util/navigator_gpu.js new file mode 100644 index 0000000000..75330edbd2 --- /dev/null +++ b/testing/web-platform/mozilla/tests/webgpu/common/util/navigator_gpu.js @@ -0,0 +1,75 @@ +/** +* AUTO-GENERATED - DO NOT EDIT. Source: https://github.com/gpuweb/cts +**/ /// <reference types="@webgpu/types" /> +import { assert } from './util.js'; +/** + * Finds and returns the `navigator.gpu` object (or equivalent, for non-browser implementations). + * Throws an exception if not found. + */ +function defaultGPUProvider() { + assert( + typeof navigator !== 'undefined' && navigator.gpu !== undefined, + 'No WebGPU implementation found'); + + return navigator.gpu; +} + +/** + * GPUProvider is a function that creates and returns a new GPU instance. + * May throw an exception if a GPU cannot be created. + */ + + +let gpuProvider = defaultGPUProvider; + +/** + * Sets the function to create and return a new GPU instance. + */ +export function setGPUProvider(provider) { + assert(impl === undefined, 'setGPUProvider() should not be after getGPU()'); + gpuProvider = provider; +} + +let impl = undefined; + +let defaultRequestAdapterOptions; + +export function setDefaultRequestAdapterOptions(options) { + if (impl) { + throw new Error('must call setDefaultRequestAdapterOptions before getGPU'); + } + defaultRequestAdapterOptions = { ...options }; +} + +/** + * Finds and returns the `navigator.gpu` object (or equivalent, for non-browser implementations). + * Throws an exception if not found. + */ +export function getGPU() { + if (impl) { + return impl; + } + + impl = gpuProvider(); + + if (defaultRequestAdapterOptions) { + + const oldFn = impl.requestAdapter; + impl.requestAdapter = function ( + options) + { + const promise = oldFn.call(this, { ...defaultRequestAdapterOptions, ...(options || {}) }); + void promise.then(async (adapter) => { + if (adapter) { + const info = await adapter.requestAdapterInfo(); + + console.log(info); + } + }); + return promise; + }; + } + + return impl; +} +//# sourceMappingURL=navigator_gpu.js.map
\ No newline at end of file diff --git a/testing/web-platform/mozilla/tests/webgpu/common/util/navigator_gpu.js.map b/testing/web-platform/mozilla/tests/webgpu/common/util/navigator_gpu.js.map new file mode 100644 index 0000000000..cabc9ffd18 --- /dev/null +++ b/testing/web-platform/mozilla/tests/webgpu/common/util/navigator_gpu.js.map @@ -0,0 +1 @@ +{"version":3,"file":"navigator_gpu.js","names":["assert","defaultGPUProvider","navigator","gpu","undefined","gpuProvider","setGPUProvider","provider","impl","defaultRequestAdapterOptions","setDefaultRequestAdapterOptions","options","Error","getGPU","oldFn","requestAdapter","promise","call","then","adapter","info","requestAdapterInfo","console","log"],"sources":["../../../src/common/util/navigator_gpu.ts"],"sourcesContent":["/// <reference types=\"@webgpu/types\" />\n\nimport { assert } from './util.js';\n\n/**\n * Finds and returns the `navigator.gpu` object (or equivalent, for non-browser implementations).\n * Throws an exception if not found.\n */\nfunction defaultGPUProvider(): GPU {\n assert(\n typeof navigator !== 'undefined' && navigator.gpu !== undefined,\n 'No WebGPU implementation found'\n );\n return navigator.gpu;\n}\n\n/**\n * GPUProvider is a function that creates and returns a new GPU instance.\n * May throw an exception if a GPU cannot be created.\n */\nexport type GPUProvider = () => GPU;\n\nlet gpuProvider: GPUProvider = defaultGPUProvider;\n\n/**\n * Sets the function to create and return a new GPU instance.\n */\nexport function setGPUProvider(provider: GPUProvider) {\n assert(impl === undefined, 'setGPUProvider() should not be after getGPU()');\n gpuProvider = provider;\n}\n\nlet impl: GPU | undefined = undefined;\n\nlet defaultRequestAdapterOptions: GPURequestAdapterOptions | undefined;\n\nexport function setDefaultRequestAdapterOptions(options: GPURequestAdapterOptions) {\n if (impl) {\n throw new Error('must call setDefaultRequestAdapterOptions before getGPU');\n }\n defaultRequestAdapterOptions = { ...options };\n}\n\n/**\n * Finds and returns the `navigator.gpu` object (or equivalent, for non-browser implementations).\n * Throws an exception if not found.\n */\nexport function getGPU(): GPU {\n if (impl) {\n return impl;\n }\n\n impl = gpuProvider();\n\n if (defaultRequestAdapterOptions) {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const oldFn = impl.requestAdapter;\n impl.requestAdapter = function (\n options?: GPURequestAdapterOptions\n ): Promise<GPUAdapter | null> {\n const promise = oldFn.call(this, { ...defaultRequestAdapterOptions, ...(options || {}) });\n void promise.then(async adapter => {\n if (adapter) {\n const info = await adapter.requestAdapterInfo();\n // eslint-disable-next-line no-console\n console.log(info);\n }\n });\n return promise;\n };\n }\n\n return impl;\n}\n"],"mappings":";AAAA;AAAA,G,CAAA;AAEA,SAASA,MAAM,QAAQ,WAAW;AAElC;AACA;AACA;AACA;AACA,SAASC,kBAAkB,GAAQ;EACjCD,MAAM;EACJ,OAAOE,SAAS,KAAK,WAAW,IAAIA,SAAS,CAACC,GAAG,KAAKC,SAAS;EAC/D,gCAAgC,CACjC;;EACD,OAAOF,SAAS,CAACC,GAAG;AACtB;;AAEA;AACA;AACA;AACA;;;AAGA,IAAIE,WAAwB,GAAGJ,kBAAkB;;AAEjD;AACA;AACA;AACA,OAAO,SAASK,cAAc,CAACC,QAAqB,EAAE;EACpDP,MAAM,CAACQ,IAAI,KAAKJ,SAAS,EAAE,+CAA+C,CAAC;EAC3EC,WAAW,GAAGE,QAAQ;AACxB;;AAEA,IAAIC,IAAqB,GAAGJ,SAAS;;AAErC,IAAIK,4BAAkE;;AAEtE,OAAO,SAASC,+BAA+B,CAACC,OAAiC,EAAE;EACjF,IAAIH,IAAI,EAAE;IACR,MAAM,IAAII,KAAK,CAAC,yDAAyD,CAAC;EAC5E;EACAH,4BAA4B,GAAG,EAAE,GAAGE,OAAO,CAAC,CAAC;AAC/C;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASE,MAAM,GAAQ;EAC5B,IAAIL,IAAI,EAAE;IACR,OAAOA,IAAI;EACb;;EAEAA,IAAI,GAAGH,WAAW,EAAE;;EAEpB,IAAII,4BAA4B,EAAE;;IAEhC,MAAMK,KAAK,GAAGN,IAAI,CAACO,cAAc;IACjCP,IAAI,CAACO,cAAc,GAAG;IACpBJ,OAAkC;IACN;MAC5B,MAAMK,OAAO,GAAGF,KAAK,CAACG,IAAI,CAAC,IAAI,EAAE,EAAE,GAAGR,4BAA4B,EAAE,IAAIE,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;MACzF,KAAKK,OAAO,CAACE,IAAI,CAAC,OAAMC,OAAO,KAAI;QACjC,IAAIA,OAAO,EAAE;UACX,MAAMC,IAAI,GAAG,MAAMD,OAAO,CAACE,kBAAkB,EAAE;;UAE/CC,OAAO,CAACC,GAAG,CAACH,IAAI,CAAC;QACnB;MACF,CAAC,CAAC;MACF,OAAOJ,OAAO;IAChB,CAAC;EACH;;EAEA,OAAOR,IAAI;AACb"}
\ No newline at end of file diff --git a/testing/web-platform/mozilla/tests/webgpu/common/util/preprocessor.js b/testing/web-platform/mozilla/tests/webgpu/common/util/preprocessor.js new file mode 100644 index 0000000000..23ffe4c45a --- /dev/null +++ b/testing/web-platform/mozilla/tests/webgpu/common/util/preprocessor.js @@ -0,0 +1,150 @@ +/** +* AUTO-GENERATED - DO NOT EDIT. Source: https://github.com/gpuweb/cts +**/import { assert } from './util.js'; // The state of the preprocessor is a stack of States. +var +State; + + +// Have already seen a passing condition; now skipping the rest + + +// The transitions in the state space are the following preprocessor directives: +// - Sibling elif +// - Sibling else +// - Sibling endif +// - Child if +(function (State) {State[State["Seeking"] = 0] = "Seeking";State[State["Passing"] = 1] = "Passing";State[State["Skipping"] = 2] = "Skipping";})(State || (State = {}));class Directive { + + + constructor(depth) { + this.depth = depth; + } + + checkDepth(stack) { + assert( + stack.length === this.depth, + `Number of "$"s must match nesting depth, currently ${stack.length} (e.g. $if $$if $$endif $endif)`); + + } + + +} + +class If extends Directive { + + + constructor(depth, predicate) { + super(depth); + this.predicate = predicate; + } + + applyTo(stack) { + this.checkDepth(stack); + const parentState = stack[stack.length - 1].state; + stack.push({ + allowsFollowingElse: true, + state: + parentState !== State.Passing ? + State.Skipping : + this.predicate ? + State.Passing : + State.Seeking + }); + } +} + +class ElseIf extends If { + applyTo(stack) { + assert(stack.length >= 1); + const { allowsFollowingElse, state: siblingState } = stack.pop(); + this.checkDepth(stack); + assert(allowsFollowingElse, 'pp.elif after pp.else'); + if (siblingState !== State.Seeking) { + stack.push({ allowsFollowingElse: true, state: State.Skipping }); + } else { + super.applyTo(stack); + } + } +} + +class Else extends Directive { + applyTo(stack) { + assert(stack.length >= 1); + const { allowsFollowingElse, state: siblingState } = stack.pop(); + this.checkDepth(stack); + assert(allowsFollowingElse, 'pp.else after pp.else'); + stack.push({ + allowsFollowingElse: false, + state: siblingState === State.Seeking ? State.Passing : State.Skipping + }); + } +} + +class EndIf extends Directive { + applyTo(stack) { + stack.pop(); + this.checkDepth(stack); + } +} + +/** + * A simple template-based, non-line-based preprocessor implementing if/elif/else/endif. + * + * @example + * ``` + * const shader = pp` + * ${pp._if(expr)} + * const x: ${type} = ${value}; + * ${pp._elif(expr)} + * ${pp.__if(expr)} + * ... + * ${pp.__else} + * ... + * ${pp.__endif} + * ${pp._endif}`; + * ``` + * + * @param strings - The array of constant string chunks of the template string. + * @param ...values - The array of interpolated `${}` values within the template string. + */ +export function pp( +strings, +...values) +{ + let result = ''; + const stateStack = [{ allowsFollowingElse: false, state: State.Passing }]; + + for (let i = 0; i < values.length; ++i) { + const passing = stateStack[stateStack.length - 1].state === State.Passing; + if (passing) { + result += strings[i]; + } + + const value = values[i]; + if (value instanceof Directive) { + value.applyTo(stateStack); + } else { + if (passing) { + result += value; + } + } + } + assert(stateStack.length === 1, 'Unterminated preprocessor condition at end of file'); + result += strings[values.length]; + + return result; +} +pp._if = (predicate) => new If(1, predicate); +pp._elif = (predicate) => new ElseIf(1, predicate); +pp._else = new Else(1); +pp._endif = new EndIf(1); +pp.__if = (predicate) => new If(2, predicate); +pp.__elif = (predicate) => new ElseIf(2, predicate); +pp.__else = new Else(2); +pp.__endif = new EndIf(2); +pp.___if = (predicate) => new If(3, predicate); +pp.___elif = (predicate) => new ElseIf(3, predicate); +pp.___else = new Else(3); +pp.___endif = new EndIf(3); +// Add more if needed. +//# sourceMappingURL=preprocessor.js.map
\ No newline at end of file diff --git a/testing/web-platform/mozilla/tests/webgpu/common/util/preprocessor.js.map b/testing/web-platform/mozilla/tests/webgpu/common/util/preprocessor.js.map new file mode 100644 index 0000000000..b58f288efe --- /dev/null +++ b/testing/web-platform/mozilla/tests/webgpu/common/util/preprocessor.js.map @@ -0,0 +1 @@ +{"version":3,"file":"preprocessor.js","names":["assert","State","Directive","constructor","depth","checkDepth","stack","length","If","predicate","applyTo","parentState","state","push","allowsFollowingElse","Passing","Skipping","Seeking","ElseIf","siblingState","pop","Else","EndIf","pp","strings","values","result","stateStack","i","passing","value","_if","_elif","_else","_endif","__if","__elif","__else","__endif","___if","___elif","___else","___endif"],"sources":["../../../src/common/util/preprocessor.ts"],"sourcesContent":["import { assert } from './util.js';\n\n// The state of the preprocessor is a stack of States.\ntype StateStack = { allowsFollowingElse: boolean; state: State }[];\nconst enum State {\n Seeking, // Still looking for a passing condition\n Passing, // Currently inside a passing condition (the root is always in this state)\n Skipping, // Have already seen a passing condition; now skipping the rest\n}\n\n// The transitions in the state space are the following preprocessor directives:\n// - Sibling elif\n// - Sibling else\n// - Sibling endif\n// - Child if\nabstract class Directive {\n private readonly depth: number;\n\n constructor(depth: number) {\n this.depth = depth;\n }\n\n protected checkDepth(stack: StateStack): void {\n assert(\n stack.length === this.depth,\n `Number of \"$\"s must match nesting depth, currently ${stack.length} (e.g. $if $$if $$endif $endif)`\n );\n }\n\n abstract applyTo(stack: StateStack): void;\n}\n\nclass If extends Directive {\n private readonly predicate: boolean;\n\n constructor(depth: number, predicate: boolean) {\n super(depth);\n this.predicate = predicate;\n }\n\n applyTo(stack: StateStack) {\n this.checkDepth(stack);\n const parentState = stack[stack.length - 1].state;\n stack.push({\n allowsFollowingElse: true,\n state:\n parentState !== State.Passing\n ? State.Skipping\n : this.predicate\n ? State.Passing\n : State.Seeking,\n });\n }\n}\n\nclass ElseIf extends If {\n applyTo(stack: StateStack) {\n assert(stack.length >= 1);\n const { allowsFollowingElse, state: siblingState } = stack.pop()!;\n this.checkDepth(stack);\n assert(allowsFollowingElse, 'pp.elif after pp.else');\n if (siblingState !== State.Seeking) {\n stack.push({ allowsFollowingElse: true, state: State.Skipping });\n } else {\n super.applyTo(stack);\n }\n }\n}\n\nclass Else extends Directive {\n applyTo(stack: StateStack) {\n assert(stack.length >= 1);\n const { allowsFollowingElse, state: siblingState } = stack.pop()!;\n this.checkDepth(stack);\n assert(allowsFollowingElse, 'pp.else after pp.else');\n stack.push({\n allowsFollowingElse: false,\n state: siblingState === State.Seeking ? State.Passing : State.Skipping,\n });\n }\n}\n\nclass EndIf extends Directive {\n applyTo(stack: StateStack) {\n stack.pop();\n this.checkDepth(stack);\n }\n}\n\n/**\n * A simple template-based, non-line-based preprocessor implementing if/elif/else/endif.\n *\n * @example\n * ```\n * const shader = pp`\n * ${pp._if(expr)}\n * const x: ${type} = ${value};\n * ${pp._elif(expr)}\n * ${pp.__if(expr)}\n * ...\n * ${pp.__else}\n * ...\n * ${pp.__endif}\n * ${pp._endif}`;\n * ```\n *\n * @param strings - The array of constant string chunks of the template string.\n * @param ...values - The array of interpolated `${}` values within the template string.\n */\nexport function pp(\n strings: TemplateStringsArray,\n ...values: ReadonlyArray<Directive | string | number>\n): string {\n let result = '';\n const stateStack: StateStack = [{ allowsFollowingElse: false, state: State.Passing }];\n\n for (let i = 0; i < values.length; ++i) {\n const passing = stateStack[stateStack.length - 1].state === State.Passing;\n if (passing) {\n result += strings[i];\n }\n\n const value = values[i];\n if (value instanceof Directive) {\n value.applyTo(stateStack);\n } else {\n if (passing) {\n result += value;\n }\n }\n }\n assert(stateStack.length === 1, 'Unterminated preprocessor condition at end of file');\n result += strings[values.length];\n\n return result;\n}\npp._if = (predicate: boolean) => new If(1, predicate);\npp._elif = (predicate: boolean) => new ElseIf(1, predicate);\npp._else = new Else(1);\npp._endif = new EndIf(1);\npp.__if = (predicate: boolean) => new If(2, predicate);\npp.__elif = (predicate: boolean) => new ElseIf(2, predicate);\npp.__else = new Else(2);\npp.__endif = new EndIf(2);\npp.___if = (predicate: boolean) => new If(3, predicate);\npp.___elif = (predicate: boolean) => new ElseIf(3, predicate);\npp.___else = new Else(3);\npp.___endif = new EndIf(3);\n// Add more if needed.\n"],"mappings":";AAAA;AAAA,GAAA,SAASA,MAAM,QAAQ,WAAW,CAAC,CAEnC;AAAA;AAEWC,KAAK;;;AAGJ;;;AAGZ;AACA;AACA;AACA;AACA;AAAA,WAVWA,KAAK,GAALA,KAAK,CAALA,KAAK,6BAALA,KAAK,CAALA,KAAK,6BAALA,KAAK,CAALA,KAAK,kCAALA,KAAK,KAALA,KAAK,QAWhB,MAAeC,SAAS,CAAC;;;EAGvBC,WAAW,CAACC,KAAa,EAAE;IACzB,IAAI,CAACA,KAAK,GAAGA,KAAK;EACpB;;EAEUC,UAAU,CAACC,KAAiB,EA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IS,MAAM,CAAC,CAAC,EAAET,SAAS,CAAC;AAC7Dc,EAAE,CAACkB,OAAO,GAAG,IAAIpB,IAAI,CAAC,CAAC,CAAC;AACxBE,EAAE,CAACmB,QAAQ,GAAG,IAAIpB,KAAK,CAAC,CAAC,CAAC;AAC1B"}
\ No newline at end of file diff --git a/testing/web-platform/mozilla/tests/webgpu/common/util/timeout.js b/testing/web-platform/mozilla/tests/webgpu/common/util/timeout.js new file mode 100644 index 0000000000..32b4660a59 --- /dev/null +++ b/testing/web-platform/mozilla/tests/webgpu/common/util/timeout.js @@ -0,0 +1,8 @@ +/** +* AUTO-GENERATED - DO NOT EDIT. Source: https://github.com/gpuweb/cts +**/ +/** + * Equivalent of `setTimeout`, but redirects to WPT's `step_timeout` when it is defined. + */ +export const timeout = typeof step_timeout !== 'undefined' ? step_timeout : setTimeout; +//# sourceMappingURL=timeout.js.map
\ No newline at end of file diff --git a/testing/web-platform/mozilla/tests/webgpu/common/util/timeout.js.map b/testing/web-platform/mozilla/tests/webgpu/common/util/timeout.js.map new file mode 100644 index 0000000000..0e8fff6f67 --- /dev/null +++ b/testing/web-platform/mozilla/tests/webgpu/common/util/timeout.js.map @@ -0,0 +1 @@ +{"version":3,"file":"timeout.js","names":["timeout","step_timeout","setTimeout"],"sources":["../../../src/common/util/timeout.ts"],"sourcesContent":["/** Defined by WPT. Like `setTimeout`, but applies a timeout multiplier for slow test systems. */\ndeclare const step_timeout: undefined | typeof setTimeout;\n\n/**\n * Equivalent of `setTimeout`, but redirects to WPT's `step_timeout` when it is defined.\n */\nexport const timeout = typeof step_timeout !== 'undefined' ? step_timeout : setTimeout;\n"],"mappings":";AAAA;AAAA;AAGA;AACA;AACA;AACA,OAAO,MAAMA,OAAO,GAAG,OAAOC,YAAY,KAAK,WAAW,GAAGA,YAAY,GAAGC,UAAU"}
\ No newline at end of file diff --git a/testing/web-platform/mozilla/tests/webgpu/common/util/types.js b/testing/web-platform/mozilla/tests/webgpu/common/util/types.js new file mode 100644 index 0000000000..2c224b6d3a --- /dev/null +++ b/testing/web-platform/mozilla/tests/webgpu/common/util/types.js @@ -0,0 +1,60 @@ +/** +* AUTO-GENERATED - DO NOT EDIT. Source: https://github.com/gpuweb/cts +**/ + + + + + + + + + + +export function assertTypeTrue() {} + +/** + * Computes the intersection of a set of types, given the union of those types. + * + * From: https://stackoverflow.com/a/56375136 + */ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +// K exhausted +//# sourceMappingURL=types.js.map
\ No newline at end of file diff --git a/testing/web-platform/mozilla/tests/webgpu/common/util/types.js.map b/testing/web-platform/mozilla/tests/webgpu/common/util/types.js.map new file mode 100644 index 0000000000..084ce36abb --- /dev/null +++ b/testing/web-platform/mozilla/tests/webgpu/common/util/types.js.map @@ -0,0 +1 @@ +{"version":3,"file":"types.js","names":["assertTypeTrue"],"sources":["../../../src/common/util/types.ts"],"sourcesContent":["/** Forces a type to resolve its type definitions, to make it readable/debuggable. */\nexport type ResolveType<T> = T extends object\n ? T extends infer O\n ? { [K in keyof O]: ResolveType<O[K]> }\n : never\n : T;\n\n/** Returns the type `true` iff X and Y are exactly equal */\nexport type TypeEqual<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2\n ? true\n : false;\n\n/* eslint-disable-next-line @typescript-eslint/no-unused-vars */\nexport function assertTypeTrue<T extends true>() {}\n\n/**\n * Computes the intersection of a set of types, given the union of those types.\n *\n * From: https://stackoverflow.com/a/56375136\n */\nexport type UnionToIntersection<U> =\n /* eslint-disable-next-line @typescript-eslint/no-explicit-any */\n (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;\n\n/** \"Type asserts\" that `X` is a subtype of `Y`. */\ntype EnsureSubtype<X, Y> = X extends Y ? X : never;\n\ntype TupleHeadOr<T, Default> = T extends readonly [infer H, ...(readonly unknown[])] ? H : Default;\ntype TupleTailOr<T, Default> = T extends readonly [unknown, ...infer Tail] ? Tail : Default;\ntype TypeOr<T, Default> = T extends undefined ? Default : T;\n\n/**\n * Zips a key tuple type and a value tuple type together into an object.\n *\n * @template Keys Keys of the resulting object.\n * @template Values Values of the resulting object. If a key corresponds to a `Values` member that\n * is undefined or past the end, it defaults to the corresponding `Defaults` member.\n * @template Defaults Default values. If a key corresponds to a `Defaults` member that is past the\n * end, the default falls back to `undefined`.\n */\nexport type ZipKeysWithValues<\n Keys extends readonly string[],\n Values extends readonly unknown[],\n Defaults extends readonly unknown[]\n> =\n //\n Keys extends readonly [infer KHead, ...infer KTail]\n ? {\n readonly [k in EnsureSubtype<KHead, string>]: TypeOr<\n TupleHeadOr<Values, undefined>,\n TupleHeadOr<Defaults, undefined>\n >;\n } &\n ZipKeysWithValues<\n EnsureSubtype<KTail, readonly string[]>,\n TupleTailOr<Values, []>,\n TupleTailOr<Defaults, []>\n >\n : {}; // K exhausted\n"],"mappings":";AAAA;AAAA;;;;;;;;;;;AAaA,OAAO,SAASA,cAAc,GAAmB,CAAC;;AAElD;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCU"}
\ No newline at end of file diff --git a/testing/web-platform/mozilla/tests/webgpu/common/util/util.js b/testing/web-platform/mozilla/tests/webgpu/common/util/util.js new file mode 100644 index 0000000000..3dfd824b12 --- /dev/null +++ b/testing/web-platform/mozilla/tests/webgpu/common/util/util.js @@ -0,0 +1,304 @@ +/** +* AUTO-GENERATED - DO NOT EDIT. Source: https://github.com/gpuweb/cts +**/import { Float16Array } from '../../external/petamoriken/float16/float16.js';import { globalTestConfig } from '../framework/test_config.js';import { Logger } from '../internal/logging/logger.js'; + +import { keysOf } from './data_tables.js'; +import { timeout } from './timeout.js'; + +/** + * Error with arbitrary `extra` data attached, for debugging. + * The extra data is omitted if not running the test in debug mode (`?debug=1`). + */ +export class ErrorWithExtra extends Error { + + + /** + * `extra` function is only called if in debug mode. + * If an `ErrorWithExtra` is passed, its message is used and its extras are passed through. + */ + + + constructor(baseOrMessage, newExtra) { + const message = typeof baseOrMessage === 'string' ? baseOrMessage : baseOrMessage.message; + super(message); + + const oldExtras = baseOrMessage instanceof ErrorWithExtra ? baseOrMessage.extra : {}; + this.extra = Logger.globalDebugMode ? + { ...oldExtras, ...newExtra() } : + { omitted: 'pass ?debug=1' }; + } +} + +/** + * Asserts `condition` is true. Otherwise, throws an `Error` with the provided message. + */ +export function assert(condition, msg) { + if (!condition) { + throw new Error(msg && (typeof msg === 'string' ? msg : msg())); + } +} + +/** If the argument is an Error, throw it. Otherwise, pass it back. */ +export function assertOK(value) { + if (value instanceof Error) { + throw value; + } + return value; +} + +/** + * Resolves if the provided promise rejects; rejects if it does not. + */ +export async function assertReject(p, msg) { + try { + await p; + unreachable(msg); + } catch (ex) { + + // Assertion OK + }} + +/** + * Assert this code is unreachable. Unconditionally throws an `Error`. + */ +export function unreachable(msg) { + throw new Error(msg); +} + +/** + * The `performance` interface. + * It is available in all browsers, but it is not in scope by default in Node. + */ +const perf = typeof performance !== 'undefined' ? performance : require('perf_hooks').performance; + +/** + * Calls the appropriate `performance.now()` depending on whether running in a browser or Node. + */ +export function now() { + return perf.now(); +} + +/** + * Returns a promise which resolves after the specified time. + */ +export function resolveOnTimeout(ms) { + return new Promise((resolve) => { + timeout(() => { + resolve(); + }, ms); + }); +} + +export class PromiseTimeoutError extends Error {} + +/** + * Returns a promise which rejects after the specified time. + */ +export function rejectOnTimeout(ms, msg) { + return new Promise((_resolve, reject) => { + timeout(() => { + reject(new PromiseTimeoutError(msg)); + }, ms); + }); +} + +/** + * Takes a promise `p`, and returns a new one which rejects if `p` takes too long, + * and otherwise passes the result through. + */ +export function raceWithRejectOnTimeout(p, ms, msg) { + if (globalTestConfig.noRaceWithRejectOnTimeout) { + return p; + } + // Setup a promise that will reject after `ms` milliseconds. We cancel this timeout when + // `p` is finalized, so the JavaScript VM doesn't hang around waiting for the timer to + // complete, once the test runner has finished executing the tests. + const timeoutPromise = new Promise((_resolve, reject) => { + const handle = timeout(() => { + reject(new PromiseTimeoutError(msg)); + }, ms); + p = p.finally(() => clearTimeout(handle)); + }); + return Promise.race([p, timeoutPromise]); +} + +/** + * Takes a promise `p` and returns a new one which rejects if `p` resolves or rejects, + * and otherwise resolves after the specified time. + */ +export function assertNotSettledWithinTime( +p, +ms, +msg) +{ + // Rejects regardless of whether p resolves or rejects. + const rejectWhenSettled = p.then(() => Promise.reject(new Error(msg))); + // Resolves after `ms` milliseconds. + const timeoutPromise = new Promise((resolve) => { + const handle = timeout(() => { + resolve(undefined); + }, ms); + p.finally(() => clearTimeout(handle)); + }); + return Promise.race([rejectWhenSettled, timeoutPromise]); +} + +/** + * Returns a `Promise.reject()`, but also registers a dummy `.catch()` handler so it doesn't count + * as an uncaught promise rejection in the runtime. + */ +export function rejectWithoutUncaught(err) { + const p = Promise.reject(err); + // Suppress uncaught promise rejection. + p.catch(() => {}); + return p; +} + +/** + * Makes a copy of a JS `object`, with the keys reordered into sorted order. + */ +export function sortObjectByKey(v) { + const sortedObject = {}; + for (const k of Object.keys(v).sort()) { + sortedObject[k] = v[k]; + } + return sortedObject; +} + +/** + * Determines whether two JS values are equal, recursing into objects and arrays. + * NaN is treated specially, such that `objectEquals(NaN, NaN)`. + */ +export function objectEquals(x, y) { + if (typeof x !== 'object' || typeof y !== 'object') { + if (typeof x === 'number' && typeof y === 'number' && Number.isNaN(x) && Number.isNaN(y)) { + return true; + } + return x === y; + } + if (x === null || y === null) return x === y; + if (x.constructor !== y.constructor) return false; + if (x instanceof Function) return x === y; + if (x instanceof RegExp) return x === y; + if (x === y || x.valueOf() === y.valueOf()) return true; + if (Array.isArray(x) && Array.isArray(y) && x.length !== y.length) return false; + if (x instanceof Date) return false; + if (!(x instanceof Object)) return false; + if (!(y instanceof Object)) return false; + + const x1 = x; + const y1 = y; + const p = Object.keys(x); + return Object.keys(y).every((i) => p.indexOf(i) !== -1) && p.every((i) => objectEquals(x1[i], y1[i])); +} + +/** + * Generates a range of values `fn(0)..fn(n-1)`. + */ +export function range(n, fn) { + return [...new Array(n)].map((_, i) => fn(i)); +} + +/** + * Generates a range of values `fn(0)..fn(n-1)`. + */ +export function* iterRange(n, fn) { + for (let i = 0; i < n; ++i) { + yield fn(i); + } +} + +/** Creates a (reusable) iterable object that maps `f` over `xs`, lazily. */ +export function mapLazy(xs, f) { + return { + *[Symbol.iterator]() { + for (const x of xs) { + yield f(x); + } + } + }; +} + +const TypedArrayBufferViewInstances = [ +new Uint8Array(), +new Uint8ClampedArray(), +new Uint16Array(), +new Uint32Array(), +new Int8Array(), +new Int16Array(), +new Int32Array(), +new Float16Array(), +new Float32Array(), +new Float64Array()]; + + + + + + + + + + + + + + + + + + + + + + + + + +export const kTypedArrayBufferViews = + +{ + ...(() => { + + const result = {}; + for (const v of TypedArrayBufferViewInstances) { + result[v.constructor.name] = v.constructor; + } + return result; + })() +}; +export const kTypedArrayBufferViewKeys = keysOf(kTypedArrayBufferViews); +export const kTypedArrayBufferViewConstructors = Object.values(kTypedArrayBufferViews); + +function subarrayAsU8( +buf, +{ start = 0, length }) +{ + if (buf instanceof ArrayBuffer) { + return new Uint8Array(buf, start, length); + } else if (buf instanceof Uint8Array || buf instanceof Uint8ClampedArray) { + // Don't wrap in new views if we don't need to. + if (start === 0 && (length === undefined || length === buf.byteLength)) { + return buf; + } + } + const byteOffset = buf.byteOffset + start * buf.BYTES_PER_ELEMENT; + const byteLength = + length !== undefined ? + length * buf.BYTES_PER_ELEMENT : + buf.byteLength - (byteOffset - buf.byteOffset); + return new Uint8Array(buf.buffer, byteOffset, byteLength); +} + +/** + * Copy a range of bytes from one ArrayBuffer or TypedArray to another. + * + * `start`/`length` are in elements (or in bytes, if ArrayBuffer). + */ +export function memcpy( +src, +dst) +{ + subarrayAsU8(dst.dst, dst).set(subarrayAsU8(src.src, src)); +} +//# sourceMappingURL=util.js.map
\ No newline at end of file diff --git a/testing/web-platform/mozilla/tests/webgpu/common/util/util.js.map b/testing/web-platform/mozilla/tests/webgpu/common/util/util.js.map new file mode 100644 index 0000000000..4a8ad3bd50 --- /dev/null +++ b/testing/web-platform/mozilla/tests/webgpu/common/util/util.js.map @@ -0,0 +1 @@ +{"version":3,"file":"util.js","names":["Float16Array","globalTestConfig","Logger","keysOf","timeout","ErrorWithExtra","Error","constructor","baseOrMessage","newExtra","message","oldExtras","extra","globalDebugMode","omitted","assert","condition","msg","assertOK","value","assertReject","p","unreachable","ex","perf","performance","require","now","resolveOnTimeout","ms","Promise","resolve","PromiseTimeoutError","rejectOnTimeout","_resolve","reject","raceWithRejectOnTimeout","noRaceWithRejectOnTimeout","timeoutPromise","handle","finally","clearTimeout","race","assertNotSettledWithinTime","rejectWhenSettled","then","undefined","rejectWithoutUncaught","err","catch","sortObjectByKey","v","sortedObject","k","Object","keys","sort","objectEquals","x","y","Number","isNaN","Function","RegExp","valueOf","Array","isArray","length","Date","x1","y1","every","i","indexOf","range","n","fn","map","_","iterRange","mapLazy","xs","f","Symbol","iterator","TypedArrayBufferViewInstances","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","Int8Array","Int16Array","Int32Array","Float32Array","Float64Array","kTypedArrayBufferViews","result","name","kTypedArrayBufferViewKeys","kTypedArrayBufferViewConstructors","values","subarrayAsU8","buf","start","ArrayBuffer","byteLength","byteOffset","BYTES_PER_ELEMENT","buffer","memcpy","src","dst","set"],"sources":["../../../src/common/util/util.ts"],"sourcesContent":["import { Float16Array } from '../../external/petamoriken/float16/float16.js';\nimport { globalTestConfig } from '../framework/test_config.js';\nimport { Logger } from '../internal/logging/logger.js';\n\nimport { keysOf } from './data_tables.js';\nimport { timeout } from './timeout.js';\n\n/**\n * Error with arbitrary `extra` data attached, for debugging.\n * The extra data is omitted if not running the test in debug mode (`?debug=1`).\n */\nexport class ErrorWithExtra extends Error {\n readonly extra: { [k: string]: unknown };\n\n /**\n * `extra` function is only called if in debug mode.\n * If an `ErrorWithExtra` is passed, its message is used and its extras are passed through.\n */\n constructor(message: string, extra: () => {});\n constructor(base: ErrorWithExtra, newExtra: () => {});\n constructor(baseOrMessage: string | ErrorWithExtra, newExtra: () => {}) {\n const message = typeof baseOrMessage === 'string' ? baseOrMessage : baseOrMessage.message;\n super(message);\n\n const oldExtras = baseOrMessage instanceof ErrorWithExtra ? baseOrMessage.extra : {};\n this.extra = Logger.globalDebugMode\n ? { ...oldExtras, ...newExtra() }\n : { omitted: 'pass ?debug=1' };\n }\n}\n\n/**\n * Asserts `condition` is true. Otherwise, throws an `Error` with the provided message.\n */\nexport function assert(condition: boolean, msg?: string | (() => string)): asserts condition {\n if (!condition) {\n throw new Error(msg && (typeof msg === 'string' ? msg : msg()));\n }\n}\n\n/** If the argument is an Error, throw it. Otherwise, pass it back. */\nexport function assertOK<T>(value: Error | T): T {\n if (value instanceof Error) {\n throw value;\n }\n return value;\n}\n\n/**\n * Resolves if the provided promise rejects; rejects if it does not.\n */\nexport async function assertReject(p: Promise<unknown>, msg?: string): Promise<void> {\n try {\n await p;\n unreachable(msg);\n } catch (ex) {\n // Assertion OK\n }\n}\n\n/**\n * Assert this code is unreachable. Unconditionally throws an `Error`.\n */\nexport function unreachable(msg?: string): never {\n throw new Error(msg);\n}\n\n/**\n * The `performance` interface.\n * It is available in all browsers, but it is not in scope by default in Node.\n */\nconst perf = typeof performance !== 'undefined' ? performance : require('perf_hooks').performance;\n\n/**\n * Calls the appropriate `performance.now()` depending on whether running in a browser or Node.\n */\nexport function now(): number {\n return perf.now();\n}\n\n/**\n * Returns a promise which resolves after the specified time.\n */\nexport function resolveOnTimeout(ms: number): Promise<void> {\n return new Promise(resolve => {\n timeout(() => {\n resolve();\n }, ms);\n });\n}\n\nexport class PromiseTimeoutError extends Error {}\n\n/**\n * Returns a promise which rejects after the specified time.\n */\nexport function rejectOnTimeout(ms: number, msg: string): Promise<never> {\n return new Promise((_resolve, reject) => {\n timeout(() => {\n reject(new PromiseTimeoutError(msg));\n }, ms);\n });\n}\n\n/**\n * Takes a promise `p`, and returns a new one which rejects if `p` takes too long,\n * and otherwise passes the result through.\n */\nexport function raceWithRejectOnTimeout<T>(p: Promise<T>, ms: number, msg: string): Promise<T> {\n if (globalTestConfig.noRaceWithRejectOnTimeout) {\n return p;\n }\n // Setup a promise that will reject after `ms` milliseconds. We cancel this timeout when\n // `p` is finalized, so the JavaScript VM doesn't hang around waiting for the timer to\n // complete, once the test runner has finished executing the tests.\n const timeoutPromise = new Promise((_resolve, reject) => {\n const handle = timeout(() => {\n reject(new PromiseTimeoutError(msg));\n }, ms);\n p = p.finally(() => clearTimeout(handle));\n });\n return Promise.race([p, timeoutPromise]) as Promise<T>;\n}\n\n/**\n * Takes a promise `p` and returns a new one which rejects if `p` resolves or rejects,\n * and otherwise resolves after the specified time.\n */\nexport function assertNotSettledWithinTime(\n p: Promise<unknown>,\n ms: number,\n msg: string\n): Promise<undefined> {\n // Rejects regardless of whether p resolves or rejects.\n const rejectWhenSettled = p.then(() => Promise.reject(new Error(msg)));\n // Resolves after `ms` milliseconds.\n const timeoutPromise = new Promise<undefined>(resolve => {\n const handle = timeout(() => {\n resolve(undefined);\n }, ms);\n p.finally(() => clearTimeout(handle));\n });\n return Promise.race([rejectWhenSettled, timeoutPromise]);\n}\n\n/**\n * Returns a `Promise.reject()`, but also registers a dummy `.catch()` handler so it doesn't count\n * as an uncaught promise rejection in the runtime.\n */\nexport function rejectWithoutUncaught<T>(err: unknown): Promise<T> {\n const p = Promise.reject(err);\n // Suppress uncaught promise rejection.\n p.catch(() => {});\n return p;\n}\n\n/**\n * Makes a copy of a JS `object`, with the keys reordered into sorted order.\n */\nexport function sortObjectByKey(v: { [k: string]: unknown }): { [k: string]: unknown } {\n const sortedObject: { [k: string]: unknown } = {};\n for (const k of Object.keys(v).sort()) {\n sortedObject[k] = v[k];\n }\n return sortedObject;\n}\n\n/**\n * Determines whether two JS values are equal, recursing into objects and arrays.\n * NaN is treated specially, such that `objectEquals(NaN, NaN)`.\n */\nexport function objectEquals(x: unknown, y: unknown): boolean {\n if (typeof x !== 'object' || typeof y !== 'object') {\n if (typeof x === 'number' && typeof y === 'number' && Number.isNaN(x) && Number.isNaN(y)) {\n return true;\n }\n return x === y;\n }\n if (x === null || y === null) return x === y;\n if (x.constructor !== y.constructor) return false;\n if (x instanceof Function) return x === y;\n if (x instanceof RegExp) return x === y;\n if (x === y || x.valueOf() === y.valueOf()) return true;\n if (Array.isArray(x) && Array.isArray(y) && x.length !== y.length) return false;\n if (x instanceof Date) return false;\n if (!(x instanceof Object)) return false;\n if (!(y instanceof Object)) return false;\n\n const x1 = x as { [k: string]: unknown };\n const y1 = y as { [k: string]: unknown };\n const p = Object.keys(x);\n return Object.keys(y).every(i => p.indexOf(i) !== -1) && p.every(i => objectEquals(x1[i], y1[i]));\n}\n\n/**\n * Generates a range of values `fn(0)..fn(n-1)`.\n */\nexport function range<T>(n: number, fn: (i: number) => T): T[] {\n return [...new Array(n)].map((_, i) => fn(i));\n}\n\n/**\n * Generates a range of values `fn(0)..fn(n-1)`.\n */\nexport function* iterRange<T>(n: number, fn: (i: number) => T): Iterable<T> {\n for (let i = 0; i < n; ++i) {\n yield fn(i);\n }\n}\n\n/** Creates a (reusable) iterable object that maps `f` over `xs`, lazily. */\nexport function mapLazy<T, R>(xs: Iterable<T>, f: (x: T) => R): Iterable<R> {\n return {\n *[Symbol.iterator]() {\n for (const x of xs) {\n yield f(x);\n }\n },\n };\n}\n\nconst TypedArrayBufferViewInstances = [\n new Uint8Array(),\n new Uint8ClampedArray(),\n new Uint16Array(),\n new Uint32Array(),\n new Int8Array(),\n new Int16Array(),\n new Int32Array(),\n new Float16Array(),\n new Float32Array(),\n new Float64Array(),\n] as const;\n\nexport type TypedArrayBufferView = typeof TypedArrayBufferViewInstances[number];\n\nexport type TypedArrayBufferViewConstructor<\n A extends TypedArrayBufferView = TypedArrayBufferView\n> = {\n // Interface copied from Uint8Array, and made generic.\n readonly prototype: A;\n readonly BYTES_PER_ELEMENT: number;\n\n new (): A;\n new (elements: Iterable<number>): A;\n new (array: ArrayLike<number> | ArrayBufferLike): A;\n new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): A;\n new (length: number): A;\n\n from(arrayLike: ArrayLike<number>): A;\n /* eslint-disable-next-line @typescript-eslint/no-explicit-any */\n from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): A;\n /* eslint-disable-next-line @typescript-eslint/no-explicit-any */\n from<T>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => number, thisArg?: any): A;\n of(...items: number[]): A;\n};\n\nexport const kTypedArrayBufferViews: {\n readonly [k: string]: TypedArrayBufferViewConstructor;\n} = {\n ...(() => {\n /* eslint-disable-next-line @typescript-eslint/no-explicit-any */\n const result: { [k: string]: any } = {};\n for (const v of TypedArrayBufferViewInstances) {\n result[v.constructor.name] = v.constructor;\n }\n return result;\n })(),\n};\nexport const kTypedArrayBufferViewKeys = keysOf(kTypedArrayBufferViews);\nexport const kTypedArrayBufferViewConstructors = Object.values(kTypedArrayBufferViews);\n\nfunction subarrayAsU8(\n buf: ArrayBuffer | TypedArrayBufferView,\n { start = 0, length }: { start?: number; length?: number }\n): Uint8Array | Uint8ClampedArray {\n if (buf instanceof ArrayBuffer) {\n return new Uint8Array(buf, start, length);\n } else if (buf instanceof Uint8Array || buf instanceof Uint8ClampedArray) {\n // Don't wrap in new views if we don't need to.\n if (start === 0 && (length === undefined || length === buf.byteLength)) {\n return buf;\n }\n }\n const byteOffset = buf.byteOffset + start * buf.BYTES_PER_ELEMENT;\n const byteLength =\n length !== undefined\n ? length * buf.BYTES_PER_ELEMENT\n : buf.byteLength - (byteOffset - buf.byteOffset);\n return new Uint8Array(buf.buffer, byteOffset, byteLength);\n}\n\n/**\n * Copy a range of bytes from one ArrayBuffer or TypedArray to another.\n *\n * `start`/`length` are in elements (or in bytes, if ArrayBuffer).\n */\nexport function memcpy(\n src: { src: ArrayBuffer | TypedArrayBufferView; start?: number; length?: number },\n dst: { dst: ArrayBuffer | TypedArrayBufferView; start?: number }\n): void {\n subarrayAsU8(dst.dst, dst).set(subarrayAsU8(src.src, src));\n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AAG,CAACK,iBAAiB;EAC9BL,GAAG,CAACG,UAAU,IAAIC,UAAU,GAAGJ,GAAG,CAACI,UAAU,CAAC;EACpD,OAAO,IAAIpB,UAAU,CAACgB,GAAG,CAACM,MAAM,EAAEF,UAAU,EAAED,UAAU,CAAC;AAC3D;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASI,MAAM;AACpBC,GAAiF;AACjFC,GAAgE;AAC1D;EACNV,YAAY,CAACU,GAAG,CAACA,GAAG,EAAEA,GAAG,CAAC,CAACC,GAAG,CAACX,YAAY,CAACS,GAAG,CAACA,GAAG,EAAEA,GAAG,CAAC,CAAC;AAC5D"}
\ No newline at end of file diff --git a/testing/web-platform/mozilla/tests/webgpu/common/util/wpt_reftest_wait.js b/testing/web-platform/mozilla/tests/webgpu/common/util/wpt_reftest_wait.js new file mode 100644 index 0000000000..c2fc1f596d --- /dev/null +++ b/testing/web-platform/mozilla/tests/webgpu/common/util/wpt_reftest_wait.js @@ -0,0 +1,25 @@ +/** +* AUTO-GENERATED - DO NOT EDIT. Source: https://github.com/gpuweb/cts +**/import { timeout } from './timeout.js'; // Copied from https://github.com/web-platform-tests/wpt/blob/master/common/reftest-wait.js + +/** + * Remove the `reftest-wait` class on the document element. + * The reftest runner will wait with taking a screenshot while + * this class is present. + * + * See https://web-platform-tests.org/writing-tests/reftests.html#controlling-when-comparison-occurs + */ +export function takeScreenshot() { + document.documentElement.classList.remove('reftest-wait'); +} + +/** + * Call `takeScreenshot()` after a delay of at least `ms` milliseconds. + * @param {number} ms - milliseconds + */ +export function takeScreenshotDelayed(ms) { + timeout(() => { + takeScreenshot(); + }, ms); +} +//# sourceMappingURL=wpt_reftest_wait.js.map
\ No newline at end of file diff --git a/testing/web-platform/mozilla/tests/webgpu/common/util/wpt_reftest_wait.js.map b/testing/web-platform/mozilla/tests/webgpu/common/util/wpt_reftest_wait.js.map new file mode 100644 index 0000000000..a231c5f611 --- /dev/null +++ b/testing/web-platform/mozilla/tests/webgpu/common/util/wpt_reftest_wait.js.map @@ -0,0 +1 @@ +{"version":3,"file":"wpt_reftest_wait.js","names":["timeout","takeScreenshot","document","documentElement","classList","remove","takeScreenshotDelayed","ms"],"sources":["../../../src/common/util/wpt_reftest_wait.ts"],"sourcesContent":["import { timeout } from './timeout.js';\n\n// Copied from https://github.com/web-platform-tests/wpt/blob/master/common/reftest-wait.js\n\n/**\n * Remove the `reftest-wait` class on the document element.\n * The reftest runner will wait with taking a screenshot while\n * this class is present.\n *\n * See https://web-platform-tests.org/writing-tests/reftests.html#controlling-when-comparison-occurs\n */\nexport function takeScreenshot() {\n document.documentElement.classList.remove('reftest-wait');\n}\n\n/**\n * Call `takeScreenshot()` after a delay of at least `ms` milliseconds.\n * @param {number} ms - milliseconds\n */\nexport function takeScreenshotDelayed(ms: number) {\n timeout(() => {\n takeScreenshot();\n }, ms);\n}\n"],"mappings":";AAAA;AAAA,GAAA,SAASA,OAAO,QAAQ,cAAc,CAAC,CAEvC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAc,GAAG;EAC/BC,QAAQ,CAACC,eAAe,CAACC,SAAS,CAACC,MAAM,CAAC,cAAc,CAAC;AAC3D;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASC,qBAAqB,CAACC,EAAU,EAAE;EAChDP,OAAO,CAAC,MAAM;IACZC,cAAc,EAAE;EAClB,CAAC,EAAEM,EAAE,CAAC;AACR"}
\ No newline at end of file |