mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-07-01 10:53:33 +00:00
tint: Generalize sem::Vector to allow 16bits subtype
This patch make `sem::Vector::Size()` and `Align()` more general to prepare for subtypes of 16bits, e.g. f16. Previously these methods assert that the subtypes are of 4bytes. Change-Id: Ic939f177e87faabdf17d1d404cee82a91072a179 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/90163 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Ben Clayton <bclayton@google.com> Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
This commit is contained in:
parent
ed6ff9c948
commit
c4b380b8af
@ -52,33 +52,17 @@ bool Vector::IsConstructible() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Vector::Size() const {
|
uint32_t Vector::Size() const {
|
||||||
return SizeOf(width_);
|
return subtype_->Size() * width_;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Vector::Align() const {
|
uint32_t Vector::Align() const {
|
||||||
return AlignOf(width_);
|
switch (width_) {
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t Vector::SizeOf(uint32_t width) {
|
|
||||||
switch (width) {
|
|
||||||
case 2:
|
case 2:
|
||||||
return 8;
|
return subtype_->Size() * 2;
|
||||||
case 3:
|
case 3:
|
||||||
return 12;
|
return subtype_->Size() * 4;
|
||||||
case 4:
|
case 4:
|
||||||
return 16;
|
return subtype_->Size() * 4;
|
||||||
}
|
|
||||||
return 0; // Unreachable
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t Vector::AlignOf(uint32_t width) {
|
|
||||||
switch (width) {
|
|
||||||
case 2:
|
|
||||||
return 8;
|
|
||||||
case 3:
|
|
||||||
return 16;
|
|
||||||
case 4:
|
|
||||||
return 16;
|
|
||||||
}
|
}
|
||||||
return 0; // Unreachable
|
return 0; // Unreachable
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user