Skip to content

Commit

Permalink
Validate functions from packed_4x8_integer_dot_product (#3188)
Browse files Browse the repository at this point in the history
Validates builtin functions:
 dot4I8Packed
 dot4U8Packed
 pack4xI8
 pack4xI8Clamp
 pack4xU8
 pack4xU8Clamp
 unpack4xI8
 unpack4xU8

Issue: #3180
  • Loading branch information
dneto0 authored Dec 19, 2023
1 parent eb1892c commit f20c5f7
Show file tree
Hide file tree
Showing 9 changed files with 494 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/webgpu/listing_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -1726,6 +1726,14 @@
"webgpu:shader,validation,expression,call,builtin,cosh:values:*": { "subcaseMS": 0.272 },
"webgpu:shader,validation,expression,call,builtin,degrees:integer_argument:*": { "subcaseMS": 1.311 },
"webgpu:shader,validation,expression,call,builtin,degrees:values:*": { "subcaseMS": 0.303 },
"webgpu:shader,validation,expression,call,builtin,dot4I8Packed:bad_args:*": { "subcaseMS": 0.302 },
"webgpu:shader,validation,expression,call,builtin,dot4I8Packed:must_use:*": { "subcaseMS": 0.300 },
"webgpu:shader,validation,expression,call,builtin,dot4I8Packed:supported:*": { "subcaseMS": 1.100 },
"webgpu:shader,validation,expression,call,builtin,dot4I8Packed:unsupported:*": { "subcaseMS": 7.250 },
"webgpu:shader,validation,expression,call,builtin,dot4U8Packed:bad_args:*": { "subcaseMS": 0.401 },
"webgpu:shader,validation,expression,call,builtin,dot4U8Packed:must_use:*": { "subcaseMS": 0.100 },
"webgpu:shader,validation,expression,call,builtin,dot4U8Packed:supported:*": { "subcaseMS": 0.401 },
"webgpu:shader,validation,expression,call,builtin,dot4U8Packed:unsupported:*": { "subcaseMS": 3.200 },
"webgpu:shader,validation,expression,call,builtin,exp2:integer_argument:*": { "subcaseMS": 0.967 },
"webgpu:shader,validation,expression,call,builtin,exp2:values:*": { "subcaseMS": 0.410 },
"webgpu:shader,validation,expression,call,builtin,exp:integer_argument:*": { "subcaseMS": 1.356 },
Expand All @@ -1743,6 +1751,22 @@
"webgpu:shader,validation,expression,call,builtin,log:values:*": { "subcaseMS": 0.291 },
"webgpu:shader,validation,expression,call,builtin,modf:integer_argument:*": { "subcaseMS": 1.089 },
"webgpu:shader,validation,expression,call,builtin,modf:values:*": { "subcaseMS": 1.866 },
"webgpu:shader,validation,expression,call,builtin,pack4xI8:bad_args:*": { "subcaseMS": 0.000 },
"webgpu:shader,validation,expression,call,builtin,pack4xI8:must_use:*": { "subcaseMS": 0.000 },
"webgpu:shader,validation,expression,call,builtin,pack4xI8:supported:*": { "subcaseMS": 0.100 },
"webgpu:shader,validation,expression,call,builtin,pack4xI8:unsupported:*": { "subcaseMS": 0.300 },
"webgpu:shader,validation,expression,call,builtin,pack4xI8Clamp:bad_args:*": { "subcaseMS": 0.100 },
"webgpu:shader,validation,expression,call,builtin,pack4xI8Clamp:must_use:*": { "subcaseMS": 0.000 },
"webgpu:shader,validation,expression,call,builtin,pack4xI8Clamp:supported:*": { "subcaseMS": 0.101 },
"webgpu:shader,validation,expression,call,builtin,pack4xI8Clamp:unsupported:*": { "subcaseMS": 0.300 },
"webgpu:shader,validation,expression,call,builtin,pack4xU8:bad_args:*": { "subcaseMS": 0.200 },
"webgpu:shader,validation,expression,call,builtin,pack4xU8:must_use:*": { "subcaseMS": 0.000 },
"webgpu:shader,validation,expression,call,builtin,pack4xU8:supported:*": { "subcaseMS": 0.000 },
"webgpu:shader,validation,expression,call,builtin,pack4xU8:unsupported:*": { "subcaseMS": 0.300 },
"webgpu:shader,validation,expression,call,builtin,pack4xU8Clamp:bad_args:*": { "subcaseMS": 0.100 },
"webgpu:shader,validation,expression,call,builtin,pack4xU8Clamp:must_use:*": { "subcaseMS": 0.000 },
"webgpu:shader,validation,expression,call,builtin,pack4xU8Clamp:supported:*": { "subcaseMS": 0.000 },
"webgpu:shader,validation,expression,call,builtin,pack4xU8Clamp:unsupported:*": { "subcaseMS": 0.351 },
"webgpu:shader,validation,expression,call,builtin,radians:integer_argument:*": { "subcaseMS": 1.811 },
"webgpu:shader,validation,expression,call,builtin,radians:values:*": { "subcaseMS": 0.382 },
"webgpu:shader,validation,expression,call,builtin,round:integer_argument:*": { "subcaseMS": 1.834 },
Expand All @@ -1759,6 +1783,14 @@
"webgpu:shader,validation,expression,call,builtin,sqrt:values:*": { "subcaseMS": 0.302 },
"webgpu:shader,validation,expression,call,builtin,tan:integer_argument:*": { "subcaseMS": 1.734 },
"webgpu:shader,validation,expression,call,builtin,tan:values:*": { "subcaseMS": 0.350 },
"webgpu:shader,validation,expression,call,builtin,unpack4xI8:bad_args:*": { "subcaseMS": 0.100 },
"webgpu:shader,validation,expression,call,builtin,unpack4xI8:must_use:*": { "subcaseMS": 0.000 },
"webgpu:shader,validation,expression,call,builtin,unpack4xI8:supported:*": { "subcaseMS": 0.100 },
"webgpu:shader,validation,expression,call,builtin,unpack4xI8:unsupported:*": { "subcaseMS": 0.351 },
"webgpu:shader,validation,expression,call,builtin,unpack4xU8:bad_args:*": { "subcaseMS": 0.100 },
"webgpu:shader,validation,expression,call,builtin,unpack4xU8:must_use:*": { "subcaseMS": 0.000 },
"webgpu:shader,validation,expression,call,builtin,unpack4xU8:supported:*": { "subcaseMS": 0.100 },
"webgpu:shader,validation,expression,call,builtin,unpack4xU8:unsupported:*": { "subcaseMS": 0.301 },
"webgpu:shader,validation,functions,alias_analysis:aliasing_inside_function:*": { "subcaseMS": 1.200 },
"webgpu:shader,validation,functions,alias_analysis:member_accessors:*": { "subcaseMS": 1.656 },
"webgpu:shader,validation,functions,alias_analysis:one_pointer_one_module_scope:*": { "subcaseMS": 1.598 },
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
export const description = `Validate dot4I8Packed`;

import { makeTestGroup } from '../../../../../../common/framework/test_group.js';
import { keysOf } from '../../../../../../common/util/data_tables.js';
import { ShaderValidationTest } from '../../../shader_validation_test.js';

const kFeature = 'packed_4x8_integer_dot_product';
const kFn = 'dot4I8Packed';
const kGoodArgs = '(1u,2u)';
const kBadArgs = {
'0args': '()',
'1args': '(1u)',
'3args': '(1u,2u,3u)',
'0i32': '(1i,2u)',
'0f32': '(1f,2u)',
'0bool': '(false,2u)',
'0vec2u': '(vec2u(),2u)',
'1i32': '(1u,2i)',
'1f32': '(1u,2f)',
'1bool': '(1u,true)',
'1vec2u': '(1u,vec2u())',
};

export const g = makeTestGroup(ShaderValidationTest);

g.test('unsupported')
.desc(`Test absence of ${kFn} when ${kFeature} is not supported.`)
.params(u => u.combine('requires', [false, true]))
.fn(t => {
t.skipIfLanguageFeatureSupported(kFeature);
const preamble = t.params.requires ? `requires ${kFeature}; ` : '';
const code = `${preamble}const c = ${kFn}${kGoodArgs};`;
t.expectCompileResult(false, code);
});

g.test('supported')
.desc(`Test presence of ${kFn} when ${kFeature} is supported.`)
.params(u => u.combine('requires', [false, true]))
.fn(t => {
t.requireLanguageFeatureOrSkipTestCase(kFeature);
const preamble = t.params.requires ? `requires ${kFeature}; ` : '';
const code = `${preamble}const c = ${kFn}${kGoodArgs};`;
t.expectCompileResult(true, code);
});

g.test('bad_args')
.desc(`Test compilation failure of ${kFn} with bad arguments`)
.params(u => u.combine('arg', keysOf(kBadArgs)))
.fn(t => {
t.requireLanguageFeatureOrSkipTestCase(kFeature);
t.expectCompileResult(false, `const c = ${kFn}${kBadArgs[t.params.arg]};`);
});

g.test('must_use')
.desc(`Result of ${kFn} must be used`)
.fn(t => {
t.requireLanguageFeatureOrSkipTestCase(kFeature);
t.expectCompileResult(false, `fn f() { ${kFn}${kGoodArgs}; }`);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
export const description = `Validate dot4U8Packed`;

import { makeTestGroup } from '../../../../../../common/framework/test_group.js';
import { keysOf } from '../../../../../../common/util/data_tables.js';
import { ShaderValidationTest } from '../../../shader_validation_test.js';

const kFeature = 'packed_4x8_integer_dot_product';
const kFn = 'dot4U8Packed';
const kGoodArgs = '(1u,2u)';
const kBadArgs = {
'0args': '()',
'1args': '(1u)',
'3args': '(1u,2u,3u)',
'0i32': '(1i,2u)',
'0f32': '(1f,2u)',
'0bool': '(false,2u)',
'0vec2u': '(vec2u(),2u)',
'1i32': '(1u,2i)',
'1f32': '(1u,2f)',
'1bool': '(1u,true)',
'1vec2u': '(1u,vec2u())',
};

export const g = makeTestGroup(ShaderValidationTest);

g.test('unsupported')
.desc(`Test absence of ${kFn} when ${kFeature} is not supported.`)
.params(u => u.combine('requires', [false, true]))
.fn(t => {
t.skipIfLanguageFeatureSupported(kFeature);
const preamble = t.params.requires ? `requires ${kFeature}; ` : '';
const code = `${preamble}const c = ${kFn}${kGoodArgs};`;
t.expectCompileResult(false, code);
});

g.test('supported')
.desc(`Test presence of ${kFn} when ${kFeature} is supported.`)
.params(u => u.combine('requires', [false, true]))
.fn(t => {
t.requireLanguageFeatureOrSkipTestCase(kFeature);
const preamble = t.params.requires ? `requires ${kFeature}; ` : '';
const code = `${preamble}const c = ${kFn}${kGoodArgs};`;
t.expectCompileResult(true, code);
});

g.test('bad_args')
.desc(`Test compilation failure of ${kFn} with bad arguments`)
.params(u => u.combine('arg', keysOf(kBadArgs)))
.fn(t => {
t.requireLanguageFeatureOrSkipTestCase(kFeature);
t.expectCompileResult(false, `const c = ${kFn}${kBadArgs[t.params.arg]};`);
});

g.test('must_use')
.desc(`Result of ${kFn} must be used`)
.fn(t => {
t.requireLanguageFeatureOrSkipTestCase(kFeature);
t.expectCompileResult(false, `fn f() { ${kFn}${kGoodArgs}; }`);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
export const description = `Validate pack4xI8`;

import { makeTestGroup } from '../../../../../../common/framework/test_group.js';
import { keysOf } from '../../../../../../common/util/data_tables.js';
import { ShaderValidationTest } from '../../../shader_validation_test.js';

const kFeature = 'packed_4x8_integer_dot_product';
const kFn = 'pack4xI8';
const kGoodArgs = '(vec4i())';
const kBadArgs = {
'0args': '()',
'2args': '(vec4i(),vec4i())',
'0i32': '(1i)',
'0f32': '(1f)',
'0bool': '(false)',
'0vec4u': '(vec4u())',
'0vec4f': '(vec4f())',
'0vec4b': '(vec4<bool>())',
'0vec2i': '(vec2i())',
'0vec3i': '(vec3i())',
};

export const g = makeTestGroup(ShaderValidationTest);

g.test('unsupported')
.desc(`Test absence of ${kFn} when ${kFeature} is not supported.`)
.params(u => u.combine('requires', [false, true]))
.fn(t => {
t.skipIfLanguageFeatureSupported(kFeature);
const preamble = t.params.requires ? `requires ${kFeature}; ` : '';
const code = `${preamble}const c = ${kFn}${kGoodArgs};`;
t.expectCompileResult(false, code);
});

g.test('supported')
.desc(`Test presence of ${kFn} when ${kFeature} is supported.`)
.params(u => u.combine('requires', [false, true]))
.fn(t => {
t.requireLanguageFeatureOrSkipTestCase(kFeature);
const preamble = t.params.requires ? `requires ${kFeature}; ` : '';
const code = `${preamble}const c = ${kFn}${kGoodArgs};`;
t.expectCompileResult(true, code);
});

g.test('bad_args')
.desc(`Test compilation failure of ${kFn} with bad arguments`)
.params(u => u.combine('arg', keysOf(kBadArgs)))
.fn(t => {
t.requireLanguageFeatureOrSkipTestCase(kFeature);
t.expectCompileResult(false, `const c = ${kFn}${kBadArgs[t.params.arg]};`);
});

g.test('must_use')
.desc(`Result of ${kFn} must be used`)
.fn(t => {
t.requireLanguageFeatureOrSkipTestCase(kFeature);
t.expectCompileResult(false, `fn f() { ${kFn}${kGoodArgs}; }`);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
export const description = `Validate pack4xI8Clamp`;

import { makeTestGroup } from '../../../../../../common/framework/test_group.js';
import { keysOf } from '../../../../../../common/util/data_tables.js';
import { ShaderValidationTest } from '../../../shader_validation_test.js';

const kFeature = 'packed_4x8_integer_dot_product';
const kFn = 'pack4xI8Clamp';
const kGoodArgs = '(vec4i())';
const kBadArgs = {
'0args': '()',
'2args': '(vec4i(),vec4i())',
'0i32': '(1i)',
'0f32': '(1f)',
'0bool': '(false)',
'0vec4u': '(vec4u())',
'0vec4f': '(vec4f())',
'0vec4b': '(vec4<bool>())',
'0vec2i': '(vec2i())',
'0vec3i': '(vec3i())',
};

export const g = makeTestGroup(ShaderValidationTest);

g.test('unsupported')
.desc(`Test absence of ${kFn} when ${kFeature} is not supported.`)
.params(u => u.combine('requires', [false, true]))
.fn(t => {
t.skipIfLanguageFeatureSupported(kFeature);
const preamble = t.params.requires ? `requires ${kFeature}; ` : '';
const code = `${preamble}const c = ${kFn}${kGoodArgs};`;
t.expectCompileResult(false, code);
});

g.test('supported')
.desc(`Test presence of ${kFn} when ${kFeature} is supported.`)
.params(u => u.combine('requires', [false, true]))
.fn(t => {
t.requireLanguageFeatureOrSkipTestCase(kFeature);
const preamble = t.params.requires ? `requires ${kFeature}; ` : '';
const code = `${preamble}const c = ${kFn}${kGoodArgs};`;
t.expectCompileResult(true, code);
});

g.test('bad_args')
.desc(`Test compilation failure of ${kFn} with bad arguments`)
.params(u => u.combine('arg', keysOf(kBadArgs)))
.fn(t => {
t.requireLanguageFeatureOrSkipTestCase(kFeature);
t.expectCompileResult(false, `const c = ${kFn}${kBadArgs[t.params.arg]};`);
});

g.test('must_use')
.desc(`Result of ${kFn} must be used`)
.fn(t => {
t.requireLanguageFeatureOrSkipTestCase(kFeature);
t.expectCompileResult(false, `fn f() { ${kFn}${kGoodArgs}; }`);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
export const description = `Validate pack4xU8`;

import { makeTestGroup } from '../../../../../../common/framework/test_group.js';
import { keysOf } from '../../../../../../common/util/data_tables.js';
import { ShaderValidationTest } from '../../../shader_validation_test.js';

const kFeature = 'packed_4x8_integer_dot_product';
const kFn = 'pack4xU8';
const kGoodArgs = '(vec4u())';
const kBadArgs = {
'0args': '()',
'2args': '(vec4u(),vec4u())',
'0i32': '(1i)',
'0f32': '(1f)',
'0bool': '(false)',
'0vec4i': '(vec4i())',
'0vec4f': '(vec4f())',
'0vec4b': '(vec4<bool>())',
'0vec2u': '(vec2u())',
'0vec3u': '(vec3u())',
};

export const g = makeTestGroup(ShaderValidationTest);

g.test('unsupported')
.desc(`Test absence of ${kFn} when ${kFeature} is not supported.`)
.params(u => u.combine('requires', [false, true]))
.fn(t => {
t.skipIfLanguageFeatureSupported(kFeature);
const preamble = t.params.requires ? `requires ${kFeature}; ` : '';
const code = `${preamble}const c = ${kFn}${kGoodArgs};`;
t.expectCompileResult(false, code);
});

g.test('supported')
.desc(`Test presence of ${kFn} when ${kFeature} is supported.`)
.params(u => u.combine('requires', [false, true]))
.fn(t => {
t.requireLanguageFeatureOrSkipTestCase(kFeature);
const preamble = t.params.requires ? `requires ${kFeature}; ` : '';
const code = `${preamble}const c = ${kFn}${kGoodArgs};`;
t.expectCompileResult(true, code);
});

g.test('bad_args')
.desc(`Test compilation failure of ${kFn} with bad arguments`)
.params(u => u.combine('arg', keysOf(kBadArgs)))
.fn(t => {
t.requireLanguageFeatureOrSkipTestCase(kFeature);
t.expectCompileResult(false, `const c = ${kFn}${kBadArgs[t.params.arg]};`);
});

g.test('must_use')
.desc(`Result of ${kFn} must be used`)
.fn(t => {
t.requireLanguageFeatureOrSkipTestCase(kFeature);
t.expectCompileResult(false, `fn f() { ${kFn}${kGoodArgs}; }`);
});
Loading

0 comments on commit f20c5f7

Please sign in to comment.