mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-09 21:47:47 +00:00
test/tint/builtins: Generate abstract numeric tests
Change-Id: I2da181af0694f73ec4be07ed40e4e70d49b53583 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97140 Commit-Queue: Ben Clayton <bclayton@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Antonio Maiorano <amaiorano@google.com>
This commit is contained in:
committed by
Dawn LUCI CQ
parent
0fba14e3c6
commit
ee36e39296
@@ -70,6 +70,7 @@ func (g *generator) generate(tmpl string, w io.Writer, writeFile WriteFile) erro
|
||||
"IsTemplateNumberParam": is(sem.TemplateNumberParam{}),
|
||||
"IsTemplateTypeParam": is(sem.TemplateTypeParam{}),
|
||||
"IsType": is(sem.Type{}),
|
||||
"IsAbstract": isAbstract,
|
||||
"IsDeclarable": isDeclarable,
|
||||
"IsFirstIn": isFirstIn,
|
||||
"IsLastIn": isLastIn,
|
||||
@@ -205,11 +206,24 @@ func iterate(n int) []int {
|
||||
return out
|
||||
}
|
||||
|
||||
// isDeclarable returns false if the FullyQualifiedName starts with a
|
||||
// leading underscore. These are undeclarable as WGSL does not allow identifers
|
||||
// to have a leading underscore.
|
||||
// isAbstract returns true if the FullyQualifiedName refers to an abstract
|
||||
// numeric type
|
||||
func isAbstract(fqn sem.FullyQualifiedName) bool {
|
||||
switch fqn.Target.GetName() {
|
||||
case "ia", "fa":
|
||||
return true
|
||||
case "vec":
|
||||
return isAbstract(fqn.TemplateArguments[1].(sem.FullyQualifiedName))
|
||||
case "mat":
|
||||
return isAbstract(fqn.TemplateArguments[2].(sem.FullyQualifiedName))
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// isDeclarable returns false if the FullyQualifiedName refers to an abstract
|
||||
// numeric type, or if it starts with a leading underscore.
|
||||
func isDeclarable(fqn sem.FullyQualifiedName) bool {
|
||||
return !strings.HasPrefix(fqn.Target.GetName(), "_")
|
||||
return !isAbstract(fqn) && !strings.HasPrefix(fqn.Target.GetName(), "_")
|
||||
}
|
||||
|
||||
// pascalCase returns the snake-case string s transformed into 'PascalCase',
|
||||
|
||||
@@ -332,7 +332,7 @@ func validate(fqn sem.FullyQualifiedName, uses *sem.StageUses) bool {
|
||||
strings.Contains(elTyName, "sampler"),
|
||||
strings.Contains(elTyName, "texture"):
|
||||
return false // Not storable
|
||||
case elTyName == "fa" || elTyName == "ia":
|
||||
case isAbstract(elTy):
|
||||
return false // Abstract types are not typeable nor supported by arrays
|
||||
}
|
||||
case "ptr":
|
||||
@@ -367,8 +367,8 @@ func validate(fqn sem.FullyQualifiedName, uses *sem.StageUses) bool {
|
||||
}
|
||||
}
|
||||
|
||||
if !isDeclarable(fqn) {
|
||||
return false
|
||||
if strings.HasPrefix(fqn.Target.GetName(), "_") {
|
||||
return false // Core, undeclarable WGSL type
|
||||
}
|
||||
|
||||
for _, arg := range fqn.TemplateArguments {
|
||||
|
||||
Reference in New Issue
Block a user