Skip to content

Commit

Permalink
spirv-val: Add Duplicate EntryPoint Builtin check (KhronosGroup#5678)
Browse files Browse the repository at this point in the history
* spirv-val: Add Decoration::builtin()
* spirv-val: Add Duplicate EntryPoint Builtin check
* spirv-val: Handle Built-ins in/out of block
* spirv-val: Remove extra CheckBuiltInVariable
  • Loading branch information
spencer-lunarg authored May 29, 2024
1 parent 77c40be commit 3d24089
Show file tree
Hide file tree
Showing 5 changed files with 467 additions and 117 deletions.
10 changes: 10 additions & 0 deletions source/val/decoration.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ namespace val {
// params_ = vector { 2 }
// struct_member_index_ = 2
//
// Example 4: Decoration for a Builtin:
// OpDecorate %var BuiltIn FragDepth
// dec_type_ = spv::Decoration::BuiltIn
// params_ = vector { FragDepth }
// struct_member_index_ = kInvalidMember
//
class Decoration {
public:
enum { kInvalidMember = -1 };
Expand All @@ -68,6 +74,10 @@ class Decoration {
spv::Decoration dec_type() const { return dec_type_; }
std::vector<uint32_t>& params() { return params_; }
const std::vector<uint32_t>& params() const { return params_; }
spv::BuiltIn builtin() const {
assert(dec_type_ == spv::Decoration::BuiltIn);
return spv::BuiltIn(params_[0]);
}

inline bool operator<(const Decoration& rhs) const {
// Note: Sort by struct_member_index_ first, then type, so look up can be
Expand Down
Loading

0 comments on commit 3d24089

Please sign in to comment.