mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-18 17:35:30 +00:00
tint: Fix set of overrides in the shader interface
Since overrides can be used to size workgroup arrays and also as initializers to module-scope variables, we cannot just consider overrides that are directly referenced in the shader functions. This change makes the Resolver track references to overrides whilst resolving array types and module-scope variable declarations, so that they are included in the set of overrides reported by the Inspector in these scenarios. Fixed: tint:1762 Change-Id: If7501abf3ddcb87a87134ddd578aa4904d204de6 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110460 Reviewed-by: Ben Clayton <bclayton@google.com> Commit-Queue: James Price <jrprice@google.com> Auto-Submit: James Price <jrprice@google.com> Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
committed by
Dawn LUCI CQ
parent
e32457fa11
commit
9e15952e2d
@@ -23,6 +23,7 @@
|
||||
#include "src/tint/sem/node.h"
|
||||
#include "src/tint/sem/type.h"
|
||||
#include "src/tint/utils/compiler_macros.h"
|
||||
#include "src/tint/utils/unique_vector.h"
|
||||
|
||||
// Forward declarations
|
||||
namespace tint::sem {
|
||||
@@ -229,6 +230,17 @@ class Array final : public Castable<Array, Type> {
|
||||
/// @returns true if this array is runtime sized
|
||||
bool IsRuntimeSized() const { return std::holds_alternative<RuntimeArrayCount>(count_); }
|
||||
|
||||
/// Records that this array type (transitively) references the given override variable.
|
||||
/// @param var the module-scope override variable
|
||||
void AddTransitivelyReferencedOverride(const GlobalVariable* var) {
|
||||
referenced_overrides_.Add(var);
|
||||
}
|
||||
|
||||
/// @returns all transitively referenced override variables
|
||||
const utils::UniqueVector<const GlobalVariable*, 4>& TransitivelyReferencedOverrides() const {
|
||||
return referenced_overrides_;
|
||||
}
|
||||
|
||||
/// @param symbols the program's symbol table
|
||||
/// @returns the name for this type that closely resembles how it would be
|
||||
/// declared in WGSL.
|
||||
@@ -241,6 +253,7 @@ class Array final : public Castable<Array, Type> {
|
||||
const uint32_t size_;
|
||||
const uint32_t stride_;
|
||||
const uint32_t implicit_stride_;
|
||||
utils::UniqueVector<const GlobalVariable*, 4> referenced_overrides_;
|
||||
};
|
||||
|
||||
} // namespace tint::sem
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "src/tint/sem/binding_point.h"
|
||||
#include "src/tint/sem/expression.h"
|
||||
#include "src/tint/sem/parameter_usage.h"
|
||||
#include "src/tint/utils/unique_vector.h"
|
||||
|
||||
// Forward declarations
|
||||
namespace tint::ast {
|
||||
@@ -182,11 +183,23 @@ class GlobalVariable final : public Castable<GlobalVariable, Variable> {
|
||||
/// @returns the location value for the parameter, if set
|
||||
std::optional<uint32_t> Location() const { return location_; }
|
||||
|
||||
/// Records that this variable (transitively) references the given override variable.
|
||||
/// @param var the module-scope override variable
|
||||
void AddTransitivelyReferencedOverride(const GlobalVariable* var) {
|
||||
referenced_overrides_.Add(var);
|
||||
}
|
||||
|
||||
/// @returns all transitively referenced override variables
|
||||
const utils::UniqueVector<const GlobalVariable*, 4>& TransitivelyReferencedOverrides() const {
|
||||
return referenced_overrides_;
|
||||
}
|
||||
|
||||
private:
|
||||
const sem::BindingPoint binding_point_;
|
||||
|
||||
tint::OverrideId override_id_;
|
||||
std::optional<uint32_t> location_;
|
||||
utils::UniqueVector<const GlobalVariable*, 4> referenced_overrides_;
|
||||
};
|
||||
|
||||
/// Parameter is a function parameter
|
||||
|
||||
Reference in New Issue
Block a user