Add semantic::Struct::SizeNoPadding

This is the size of the structure without the trailing alignment
padding. This is what the Dawn needs from the Inspector.

Fixed: tint:653
Change-Id: Iaa01ba949e114973e4a33e084fc10ef9e111016c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/45120
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
Ben Clayton
2021-03-17 21:54:13 +00:00
committed by Commit Bot service account
parent 96829ed314
commit ad97343214
7 changed files with 170 additions and 5 deletions

View File

@@ -23,8 +23,13 @@ namespace semantic {
Struct::Struct(type::Struct* type,
StructMemberList members,
uint32_t align,
uint32_t size)
: type_(type), members_(std::move(members)), align_(align), size_(size) {}
uint32_t size,
uint32_t size_no_padding)
: type_(type),
members_(std::move(members)),
align_(align),
size_(size),
size_no_padding_(size_no_padding) {}
Struct::~Struct() = default;

View File

@@ -46,10 +46,13 @@ class Struct : public Castable<Struct, Node> {
/// @param members the structure members
/// @param align the byte alignment of the structure
/// @param size the byte size of the structure
/// @param size_no_padding size of the members without the end of structure
/// alignment padding
Struct(type::Struct* type,
StructMemberList members,
uint32_t align,
uint32_t size);
uint32_t size,
uint32_t size_no_padding);
/// Destructor
~Struct() override;
@@ -72,11 +75,16 @@ class Struct : public Castable<Struct, Node> {
/// decoration.
uint32_t Size() const { return size_; }
/// @returns the byte size of the members without the end of structure
/// alignment padding
uint32_t SizeNoPadding() const { return size_no_padding_; }
private:
type::Struct* const type_;
StructMemberList const members_;
uint32_t const align_;
uint32_t const size_;
uint32_t const size_no_padding_;
};
/// StructMember holds the semantic information for structure members.