Add enum for parameter usages.
Currently the ParameterUsages is built entirely from core.def. There are
usages we'd like to use which appear in alternate def files. This Cl
adds a `usages` enum into core.def which allows adding extra usages
above what already appears in core.def
Change-Id: Ibfbdead7a4e875fedce31546f8c1b519efa005f9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/197216
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
diff --git a/src/tint/cmd/fuzz/wgsl/dictionary.txt b/src/tint/cmd/fuzz/wgsl/dictionary.txt
index 82f80c1..1f893aa 100644
--- a/src/tint/cmd/fuzz/wgsl/dictionary.txt
+++ b/src/tint/cmd/fuzz/wgsl/dictionary.txt
@@ -183,6 +183,7 @@
"cross"
"default"
"degrees"
+"depth"
"derivative_uniformity"
"determinant"
"diagnostic"
@@ -198,6 +199,7 @@
"dpdyCoarse"
"dpdyFine"
"dual_source_blending"
+"elements"
"else"
"enable"
"error"
@@ -231,6 +233,7 @@
"global_invocation_id"
"group"
"handle"
+"height"
"i32"
"ia"
"id"
@@ -288,6 +291,7 @@
"modf"
"must_use"
"normalize"
+"num_levels"
"num_workgroups"
"off"
"override"
@@ -345,6 +349,7 @@
"sample_mask"
"sampler"
"sampler_comparison"
+"samples"
"saturate"
"select"
"sign"
@@ -435,6 +440,7 @@
"w"
"warning"
"while"
+"width"
"workgroup"
"workgroupBarrier"
"workgroupUniformLoad"
diff --git a/src/tint/lang/core/core.def b/src/tint/lang/core/core.def
index 26907a3..dce777d 100644
--- a/src/tint/lang/core/core.def
+++ b/src/tint/lang/core/core.def
@@ -224,6 +224,16 @@
input_attachment_index
}
+// These are paramter usages which show up in other def files but not in core.def.
+enum usages {
+ width
+ height
+ depth
+ elements
+ samples
+ num_levels
+}
+
////////////////////////////////////////////////////////////////////////////////
// Primitive types //
////////////////////////////////////////////////////////////////////////////////
diff --git a/src/tint/lang/core/parameter_usage.cc b/src/tint/lang/core/parameter_usage.cc
index 431dec2..4b39093 100644
--- a/src/tint/lang/core/parameter_usage.cc
+++ b/src/tint/lang/core/parameter_usage.cc
@@ -54,18 +54,28 @@
return "ddx";
case ParameterUsage::kDdy:
return "ddy";
+ case ParameterUsage::kDepth:
+ return "depth";
case ParameterUsage::kDepthRef:
return "depth_ref";
+ case ParameterUsage::kElements:
+ return "elements";
+ case ParameterUsage::kHeight:
+ return "height";
case ParameterUsage::kInputAttachment:
return "input_attachment";
case ParameterUsage::kLevel:
return "level";
+ case ParameterUsage::kNumLevels:
+ return "num_levels";
case ParameterUsage::kOffset:
return "offset";
case ParameterUsage::kSampleIndex:
return "sample_index";
case ParameterUsage::kSampler:
return "sampler";
+ case ParameterUsage::kSamples:
+ return "samples";
case ParameterUsage::kSourceLaneIndex:
return "sourceLaneIndex";
case ParameterUsage::kTexture:
@@ -74,6 +84,8 @@
return "value";
case ParameterUsage::kW:
return "w";
+ case ParameterUsage::kWidth:
+ return "width";
case ParameterUsage::kX:
return "x";
case ParameterUsage::kXy:
diff --git a/src/tint/lang/core/parameter_usage.h b/src/tint/lang/core/parameter_usage.h
index 10eecf6..5d16272 100644
--- a/src/tint/lang/core/parameter_usage.h
+++ b/src/tint/lang/core/parameter_usage.h
@@ -53,16 +53,22 @@
kCoords,
kDdx,
kDdy,
+ kDepth,
kDepthRef,
+ kElements,
+ kHeight,
kInputAttachment,
kLevel,
+ kNumLevels,
kOffset,
kSampleIndex,
kSampler,
+ kSamples,
kSourceLaneIndex,
kTexture,
kValue,
kW,
+ kWidth,
kX,
kXy,
kXyz,
diff --git a/src/tint/lang/hlsl/hlsl.def b/src/tint/lang/hlsl/hlsl.def
index 0ccc52f..c101ab8 100644
--- a/src/tint/lang/hlsl/hlsl.def
+++ b/src/tint/lang/hlsl/hlsl.def
@@ -124,5 +124,5 @@
@member_function fn Store3(byte_address_buffer<writable>, offset: u32, value: vec3<u32>)
@member_function fn Store4(byte_address_buffer<writable>, offset: u32, value: vec4<u32>)
-@member_function fn GetDimensions[A: access](byte_address_buffer<A>, ptr<function, u32, writable>)
+@member_function fn GetDimensions[A: access](byte_address_buffer<A>, width: ptr<function, u32, writable>)
diff --git a/src/tint/lang/hlsl/intrinsic/data.cc b/src/tint/lang/hlsl/intrinsic/data.cc
index fa5c6e6..630ef6af 100644
--- a/src/tint/lang/hlsl/intrinsic/data.cc
+++ b/src/tint/lang/hlsl/intrinsic/data.cc
@@ -858,7 +858,7 @@
},
{
/* [21] */
- /* usage */ core::ParameterUsage::kNone,
+ /* usage */ core::ParameterUsage::kWidth,
/* matcher_indices */ MatcherIndicesIndex(16),
},
{
@@ -1431,7 +1431,7 @@
},
{
/* [19] */
- /* fn GetDimensions[A : access](byte_address_buffer<A>, ptr<function, u32, writable>) */
+ /* fn GetDimensions[A : access](byte_address_buffer<A>, width: ptr<function, u32, writable>) */
/* num overloads */ 1,
/* overloads */ OverloadIndex(27),
},
diff --git a/tools/src/tint/intrinsic/resolver/resolve.go b/tools/src/tint/intrinsic/resolver/resolve.go
index 575dd2f..cf2d9a8 100644
--- a/tools/src/tint/intrinsic/resolver/resolve.go
+++ b/tools/src/tint/intrinsic/resolver/resolve.go
@@ -116,8 +116,14 @@
}
}
+ var usages = ast.EnumDecl{}
+ for _, e := range a.Enums {
+ if e.Name == "usages" {
+ usages = e
+ }
+ }
// Calculate the unique parameter names
- r.s.UniqueParameterNames = r.calculateUniqueParameterNames()
+ r.s.UniqueParameterNames = r.calculateUniqueParameterNames(usages)
return r.s, nil
}
@@ -612,9 +618,15 @@
// calculateUniqueParameterNames() iterates over all the parameters of all
// builtin overloads, calculating the list of unique parameter names
-func (r *resolver) calculateUniqueParameterNames() []string {
+func (r *resolver) calculateUniqueParameterNames(usages ast.EnumDecl) []string {
set := map[string]struct{}{"": {}}
names := []string{}
+
+ for _, e := range usages.Entries {
+ set[e.Name] = struct{}{}
+ names = append(names, e.Name)
+ }
+
for _, intrinsics := range [][]*sem.Intrinsic{
r.s.Builtins,
r.s.UnaryOperators,