tint: Add TINT_REFLECT() & ForeachField()

This uses template and macro magic to reflect the fields of a class.

Dawn:
* Reflect the fields of the types that are used by Dawn's stream::Stream<T> specializations, and use tint::ForeachField() to call StreamIn().

Fuzzers:
* Replace tint::fuzzers::DataBuilder::BuildImpl<T> specializations with the new reflection system.
* static_assert that the type is either POD or reflected. Add a specialization for std::optional which was missing.

Move tint::transform::BindingPoints into MultiplanarExternalTexture, as this is only used by MultiplanarExternalTexture.

All this reduces fragility of the struct declarations slipping out of sync with the uses.

Bug: tint:1640
Change-Id: I08729c1c356f1b427e85983efe3c2678fc2ce717
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101001
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
This commit is contained in:
Ben Clayton
2022-09-02 11:40:19 +00:00
committed by Dawn LUCI CQ
parent bd6bcf1e0c
commit 648bd7b4be
16 changed files with 359 additions and 135 deletions

View File

@@ -19,6 +19,7 @@
#include <functional>
#include "src/tint/reflection.h"
#include "src/tint/utils/hash.h"
namespace tint::sem {
@@ -30,6 +31,9 @@ struct BindingPoint {
/// The `@binding` part of the binding point
uint32_t binding = 0;
/// Reflect the fields of this class so that it can be used by tint::ForeachField()
TINT_REFLECT(group, binding);
/// Equality operator
/// @param rhs the BindingPoint to compare against
/// @returns true if this BindingPoint is equal to `rhs`