mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-09 21:47:47 +00:00
resolver: Validate pipline stage use for intrinsics
Use the new [[stage()]] decorations in intrinsics.def to validate that intrinsics are only called from the correct pipeline stages. Fixed: tint:657 Change-Id: I9efda26369c45c6f816bdaa53408d3909db403a1 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/53084 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Reviewed-by: David Neto <dneto@google.com> Commit-Queue: Ben Clayton <bclayton@google.com> Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
committed by
Tint LUCI CQ
parent
7b366475ed
commit
71786c99b3
@@ -96,6 +96,8 @@ type Overload struct {
|
||||
// These indices are consumed by the matchers themselves.
|
||||
// The first index is always a TypeMatcher.
|
||||
ReturnMatcherIndicesOffset *int
|
||||
// StageUses describes the stages an overload can be used in
|
||||
CanBeUsedInStage sem.StageUses
|
||||
}
|
||||
|
||||
// Function is used to create the C++ IntrinsicInfo structure
|
||||
@@ -193,6 +195,7 @@ func (b *intrinsicTableBuilder) buildOverload(o *sem.Overload) (Overload, error)
|
||||
OpenNumbersOffset: b.lut.openNumbers.Add(ob.openNumbers),
|
||||
ParametersOffset: b.lut.parameters.Add(ob.parameters),
|
||||
ReturnMatcherIndicesOffset: ob.returnTypeMatcherIndicesOffset,
|
||||
CanBeUsedInStage: o.CanBeUsedInStage,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -146,6 +146,21 @@ type StageUses struct {
|
||||
Compute bool
|
||||
}
|
||||
|
||||
// List returns the stage uses as a string list
|
||||
func (u StageUses) List() []string {
|
||||
out := []string{}
|
||||
if u.Vertex {
|
||||
out = append(out, "vertex")
|
||||
}
|
||||
if u.Fragment {
|
||||
out = append(out, "fragment")
|
||||
}
|
||||
if u.Compute {
|
||||
out = append(out, "compute")
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// Format implements the fmt.Formatter interface
|
||||
func (o Overload) Format(w fmt.State, verb rune) {
|
||||
fmt.Fprintf(w, "fn %v", o.Function.Name)
|
||||
|
||||
Reference in New Issue
Block a user