Skip to content

Commit

Permalink
Test 'undefined' in bindGroupLayouts
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiawei-Shao committed Dec 18, 2024
1 parent 44e9950 commit 0e2468d
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions src/webgpu/api/validation/createPipelineLayout.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ g.test('bind_group_layouts,device_mismatch')
}, mismatched);
});

const MaybeNullBindGroupLayoutTypes = ['Null', 'Empty', 'NonEmpty'] as const;
const MaybeNullBindGroupLayoutTypes = ['Null', 'Undefined', 'Empty', 'NonEmpty'] as const;

g.test('bind_group_layouts,null_bind_group_layouts')
.desc(
Expand All @@ -185,7 +185,7 @@ g.test('bind_group_layouts,null_bind_group_layouts')
// Only bindGroupLayout0 is valid and represents null bind group layout, and we don't
// need to care about the other bind group layouts.
return (
t.bindGroupLayout0 === 'Null' &&
(t.bindGroupLayout0 === 'Null' || t.bindGroupLayout0 === 'Undefined') &&
t.bindGroupLayout1 === 'Null' &&
t.bindGroupLayout2 === 'Null' &&
t.bindGroupLayout3 === 'Null'
Expand All @@ -195,7 +195,10 @@ g.test('bind_group_layouts,null_bind_group_layouts')
// represents null bind group layout, and we don't need to care about the other bind
// group layouts.
return (
(t.bindGroupLayout0 === 'Null' || t.bindGroupLayout1 === 'Null') &&
(t.bindGroupLayout0 === 'Null' ||
t.bindGroupLayout0 === 'Undefined' ||
t.bindGroupLayout1 === 'Null' ||
t.bindGroupLayout1 === 'Undefined') &&
t.bindGroupLayout2 === 'Null' &&
t.bindGroupLayout3 === 'Null'
);
Expand All @@ -205,18 +208,25 @@ g.test('bind_group_layouts,null_bind_group_layouts')
// bindGroupLayout3.
return (
(t.bindGroupLayout0 === 'Null' ||
t.bindGroupLayout0 === 'Undefined' ||
t.bindGroupLayout1 === 'Null' ||
t.bindGroupLayout2 === 'Null') &&
t.bindGroupLayout1 === 'Undefined' ||
t.bindGroupLayout2 === 'Null' ||
t.bindGroupLayout2 === 'Undefined') &&
t.bindGroupLayout3 === 'Null'
);
case 4:
// At lease one of the bindGroupLayout0, bindGroupLayout1, bindGroupLayout2 and
// bindGroupLayout3 represents null bind group layout.
return (
t.bindGroupLayout0 === 'Null' ||
t.bindGroupLayout0 === 'Undefined' ||
t.bindGroupLayout1 === 'Null' ||
t.bindGroupLayout1 === 'Undefined' ||
t.bindGroupLayout2 === 'Null' ||
t.bindGroupLayout3 === 'Null'
t.bindGroupLayout2 === 'Undefined' ||
t.bindGroupLayout3 === 'Null' ||
t.bindGroupLayout3 === 'Undefined'
);
default:
return false;
Expand Down Expand Up @@ -245,7 +255,7 @@ g.test('bind_group_layouts,null_bind_group_layouts')
],
});

const bindGroupLayouts: (GPUBindGroupLayout | null)[] = [];
const bindGroupLayouts: (GPUBindGroupLayout | null | undefined)[] = [];

const AddBindGroupLayout = function (
bindGroupLayoutType: (typeof MaybeNullBindGroupLayoutTypes)[number]
Expand All @@ -254,6 +264,9 @@ g.test('bind_group_layouts,null_bind_group_layouts')
case 'Null':
bindGroupLayouts.push(null);
break;
case 'Undefined':
bindGroupLayouts.push(undefined);
break;
case 'Empty':
bindGroupLayouts.push(emptyBindGroupLayout);
break;
Expand Down

0 comments on commit 0e2468d

Please sign in to comment.