Skip to content

Commit 46b54d9

Browse files
KangzDawn LUCI CQ
authored andcommitted
dawn.node: add support for the experimental subgroup extensions.
In addition to adding the FeatureName enums, it adds a new IDL file, DawnExtensions.idl that's merged along with Browser.idl and webgpu.idl and will contain IDL for Dawn-specific extensions. Also updates idlgen to support merging enums. Bug: dawn:464 Change-Id: I02bd8e210c52dda038f0fac68bbcc275274cd74b Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/146387 Reviewed-by: Ben Clayton <[email protected]> Kokoro: Kokoro <[email protected]> Commit-Queue: Corentin Wallez <[email protected]>
1 parent 08fa11f commit 46b54d9

File tree

4 files changed

+46
-0
lines changed

4 files changed

+46
-0
lines changed

src/dawn/node/binding/Converter.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1610,6 +1610,12 @@ bool Converter::Convert(wgpu::FeatureName& out, interop::GPUFeatureName in) {
16101610
case interop::GPUFeatureName::kFloat32Filterable:
16111611
out = wgpu::FeatureName::Float32Filterable;
16121612
return true;
1613+
case interop::GPUFeatureName::kChromiumExperimentalSubgroups:
1614+
out = wgpu::FeatureName::ChromiumExperimentalSubgroups;
1615+
return true;
1616+
case interop::GPUFeatureName::kChromiumExperimentalSubgroupUniformControlFlow:
1617+
out = wgpu::FeatureName::ChromiumExperimentalSubgroupUniformControlFlow;
1618+
return true;
16131619
}
16141620
return false;
16151621
}
@@ -1649,6 +1655,12 @@ bool Converter::Convert(interop::GPUFeatureName& out, wgpu::FeatureName in) {
16491655
case wgpu::FeatureName::Float32Filterable:
16501656
out = interop::GPUFeatureName::kFloat32Filterable;
16511657
return true;
1658+
case wgpu::FeatureName::ChromiumExperimentalSubgroups:
1659+
out = interop::GPUFeatureName::kChromiumExperimentalSubgroups;
1660+
return true;
1661+
case wgpu::FeatureName::ChromiumExperimentalSubgroupUniformControlFlow:
1662+
out = interop::GPUFeatureName::kChromiumExperimentalSubgroupUniformControlFlow;
1663+
return true;
16521664

16531665
case wgpu::FeatureName::PipelineStatisticsQuery:
16541666
case wgpu::FeatureName::DawnInternalUsages:

src/dawn/node/interop/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ idlgen(
2323
IDLS
2424
"${CMAKE_CURRENT_SOURCE_DIR}/Browser.idl"
2525
"${WEBGPU_IDL_PATH}"
26+
"${CMAKE_CURRENT_SOURCE_DIR}/DawnExtensions.idl"
2627
DEPENDS
2728
"${CMAKE_CURRENT_SOURCE_DIR}/WebGPUCommon.tmpl"
2829
OUTPUT
@@ -35,6 +36,7 @@ idlgen(
3536
IDLS
3637
"${CMAKE_CURRENT_SOURCE_DIR}/Browser.idl"
3738
"${WEBGPU_IDL_PATH}"
39+
"${CMAKE_CURRENT_SOURCE_DIR}/DawnExtensions.idl"
3840
DEPENDS
3941
"${CMAKE_CURRENT_SOURCE_DIR}/WebGPUCommon.tmpl"
4042
OUTPUT
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2023 The Dawn Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
// An IDL file that adds support for Dawn extensions that are not part of the
16+
// upstream webgpu.idl.
17+
18+
enum GPUFeatureName {
19+
"chromium-experimental-subgroups",
20+
"chromium-experimental-subgroup-uniform-control-flow",
21+
};

tools/src/cmd/idlgen/main.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ func simplify(in *ast.File) (*ast.File, declarations) {
205205
interfaces := map[string]*ast.Interface{}
206206
mixins := map[string]*ast.Mixin{}
207207
includes := []*ast.Includes{}
208+
enums := map[string]*ast.Enum{}
208209
for _, d := range in.Declarations {
209210
switch d := d.(type) {
210211
case *ast.Interface:
@@ -222,6 +223,16 @@ func simplify(in *ast.File) (*ast.File, declarations) {
222223
s.declarations[d.Name] = d
223224
case *ast.Includes:
224225
includes = append(includes, d)
226+
case *ast.Enum:
227+
if e, ok := enums[d.Name]; ok {
228+
// Merge partial enums into one enum
229+
e.Values = append(e.Values, d.Values...)
230+
} else {
231+
clone := *d
232+
d := &clone
233+
enums[d.Name] = d
234+
s.declarations[d.Name] = d
235+
}
225236
default:
226237
if name := nameOf(d); name != "" {
227238
s.declarations[nameOf(d)] = d

0 commit comments

Comments
 (0)