3939#include " dawn/native/Format.h"
4040#include " dawn/native/IntegerTypes.h"
4141#include " dawn/native/PerStage.h"
42+ #include " dawn/native/Serializable.h"
4243
4344#include " dawn/native/dawn_platform.h"
4445
@@ -69,51 +70,57 @@ enum class BindingInfoType {
6970};
7071
7172// A mirror of wgpu::BufferBindingLayout for use inside dawn::native.
72- struct BufferBindingInfo {
73+ #define BUFFER_BINDING_INFO_MEMBER (X ) \
74+ X (wgpu::BufferBindingType, type) \
75+ X (uint64_t , minBindingSize) \
76+ /* hasDynamicOffset is always false in shader reflection */ \
77+ X (bool , hasDynamicOffset)
78+ DAWN_SERIALIZABLE (struct , BufferBindingInfo, BUFFER_BINDING_INFO_MEMBER) {
7379 static BufferBindingInfo From (const BufferBindingLayout& layout);
74-
75- wgpu::BufferBindingType type;
76- uint64_t minBindingSize;
77-
78- // Always false in shader reflection.
79- bool hasDynamicOffset = false ;
80-
81- bool operator ==(const BufferBindingInfo& other) const = default ;
8280};
81+ #undef BUFFER_BINDING_INFO_MEMBER
8382
8483// A mirror of wgpu::TextureBindingLayout for use inside dawn::native.
85- struct TextureBindingInfo {
84+ #define TEXTURE_BINDING_INFO_MEMBER (X ) \
85+ /* For shader reflection UnfilterableFloat is never used and the sample type is Float */ \
86+ /* for any texture_Nd<f32>. */ \
87+ X (wgpu::TextureSampleType, sampleType) \
88+ X (wgpu::TextureViewDimension, viewDimension) \
89+ X (bool , multisampled)
90+ DAWN_SERIALIZABLE (struct , TextureBindingInfo, TEXTURE_BINDING_INFO_MEMBER) {
8691 static TextureBindingInfo From (const TextureBindingLayout& layout);
87-
88- // For shader reflection UnfilterableFloat is never used and the sample type is Float for any
89- // texture_Nd<f32>.
90- wgpu::TextureSampleType sampleType;
91- wgpu::TextureViewDimension viewDimension;
92- bool multisampled;
93-
94- bool operator ==(const TextureBindingInfo& other) const = default ;
9592};
93+ #undef TEXTURE_BINDING_INFO_MEMBER
9694
9795// A mirror of wgpu::StorageTextureBindingLayout for use inside dawn::native.
98- struct StorageTextureBindingInfo {
96+ #define STORAGE_TEXTURE_BINDING_INFO_MEMBER (X ) \
97+ X (wgpu::TextureFormat, format) \
98+ X (wgpu::TextureViewDimension, viewDimension) \
99+ X (wgpu::StorageTextureAccess, access)
100+ DAWN_SERIALIZABLE (struct , StorageTextureBindingInfo, STORAGE_TEXTURE_BINDING_INFO_MEMBER) {
99101 static StorageTextureBindingInfo From (const StorageTextureBindingLayout& layout);
100-
101- wgpu::TextureFormat format;
102- wgpu::TextureViewDimension viewDimension;
103- wgpu::StorageTextureAccess access;
104-
105- bool operator ==(const StorageTextureBindingInfo& other) const = default ;
106102};
103+ #undef STORAGE_TEXTURE_BINDING_INFO_MEMBER
107104
108105// A mirror of wgpu::SamplerBindingLayout for use inside dawn::native.
109- struct SamplerBindingInfo {
106+ #define SAMPLER_BINDING_INFO_MEMBER (X ) \
107+ /* For shader reflection NonFiltering is never used and Filtering is used for */ \
108+ /* any `sampler`. */ \
109+ X (wgpu::SamplerBindingType, type)
110+ DAWN_SERIALIZABLE (struct , SamplerBindingInfo, SAMPLER_BINDING_INFO_MEMBER) {
110111 static SamplerBindingInfo From (const SamplerBindingLayout& layout);
112+ };
113+ #undef SAMPLER_BINDING_INFO_MEMBER
111114
112- // For shader reflection NonFiltering is never used and Filtering is used for any `sampler`.
113- wgpu::SamplerBindingType type;
115+ // A mirror of wgpu::ExternalTextureBindingLayout for use inside dawn::native.
116+ #define EXTERNAL_TEXTURE_BINDING_INFO_MEMBER (X ) // ExternalTextureBindingInfo has no member
117+ DAWN_SERIALIZABLE (struct , ExternalTextureBindingInfo, EXTERNAL_TEXTURE_BINDING_INFO_MEMBER){};
118+ #undef EXTERNAL_TEXTURE_BINDING_INFO_MEMBER
114119
115- bool operator ==(const SamplerBindingInfo& other) const = default ;
116- };
120+ // Internal to vulkan only.
121+ #define INPUT_ATTACHMENT_BINDING_INFO_MEMBER (X ) X(wgpu::TextureSampleType, sampleType)
122+ DAWN_SERIALIZABLE (struct , InputAttachmentBindingInfo, INPUT_ATTACHMENT_BINDING_INFO_MEMBER){};
123+ #undef INPUT_ATTACHMENT_BINDING_INFO_MEMBER
117124
118125// A mirror of wgpu::StaticSamplerBindingLayout for use inside dawn::native.
119126struct StaticSamplerBindingInfo {
@@ -130,18 +137,6 @@ struct StaticSamplerBindingInfo {
130137 bool operator ==(const StaticSamplerBindingInfo& other) const = default ;
131138};
132139
133- // A mirror of wgpu::ExternalTextureBindingLayout for use inside dawn::native.
134- struct ExternalTextureBindingInfo {
135- bool operator ==(const ExternalTextureBindingInfo& other) const = default ;
136- };
137-
138- // Internal to vulkan only.
139- struct InputAttachmentBindingInfo {
140- wgpu::TextureSampleType sampleType;
141-
142- bool operator ==(const InputAttachmentBindingInfo& other) const = default ;
143- };
144-
145140struct BindingInfo {
146141 BindingNumber binding;
147142 wgpu::ShaderStage visibility;
@@ -165,12 +160,11 @@ struct BindingInfo {
165160BindingInfoType GetBindingInfoType (const BindingInfo& bindingInfo);
166161
167162// Match tint::BindingPoint, can convert to/from tint::BindingPoint using ToTint and FromTint.
168- struct BindingSlot {
169- BindGroupIndex group;
170- BindingNumber binding;
171-
172- constexpr bool operator ==(const BindingSlot& rhs) const = default ;
173- };
163+ #define BINDING_SLOT_MEMBER (X ) \
164+ X (BindGroupIndex, group) \
165+ X (BindingNumber, binding)
166+ DAWN_SERIALIZABLE (struct , BindingSlot, BINDING_SLOT_MEMBER){};
167+ #undef BINDING_SLOT_MEMBER
174168
175169struct PerStageBindingCounts {
176170 uint32_t sampledTextureCount;
0 commit comments