mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-18 09:25:25 +00:00
inspector: reflect workgroup storage size
This reflects the total size of all workgroup storage-class variables referenced transitively by an entry point. Bug: tint:919 Change-Id: If3a217fea5a875ac18db6de1579f004e368fbb7b Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57740 Reviewed-by: Ben Clayton <bclayton@google.com> Reviewed-by: David Neto <dneto@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Ken Rockot <rockot@google.com>
This commit is contained in:
@@ -14,6 +14,9 @@
|
||||
|
||||
#include "src/sem/type.h"
|
||||
|
||||
#include "src/debug.h"
|
||||
#include "src/sem/array.h"
|
||||
#include "src/sem/atomic_type.h"
|
||||
#include "src/sem/bool_type.h"
|
||||
#include "src/sem/f32_type.h"
|
||||
#include "src/sem/i32_type.h"
|
||||
@@ -21,6 +24,7 @@
|
||||
#include "src/sem/pointer_type.h"
|
||||
#include "src/sem/reference_type.h"
|
||||
#include "src/sem/sampler_type.h"
|
||||
#include "src/sem/struct.h"
|
||||
#include "src/sem/texture_type.h"
|
||||
#include "src/sem/u32_type.h"
|
||||
#include "src/sem/vector_type.h"
|
||||
@@ -52,6 +56,61 @@ const Type* Type::UnwrapRef() const {
|
||||
return type;
|
||||
}
|
||||
|
||||
void Type::GetDefaultAlignAndSize(uint32_t& align, uint32_t& size) const {
|
||||
TINT_ASSERT(Semantic, !As<Reference>());
|
||||
TINT_ASSERT(Semantic, !As<Pointer>());
|
||||
|
||||
static constexpr uint32_t vector_size[] = {
|
||||
/* padding */ 0,
|
||||
/* padding */ 0,
|
||||
/*vec2*/ 8,
|
||||
/*vec3*/ 12,
|
||||
/*vec4*/ 16,
|
||||
};
|
||||
static constexpr uint32_t vector_align[] = {
|
||||
/* padding */ 0,
|
||||
/* padding */ 0,
|
||||
/*vec2*/ 8,
|
||||
/*vec3*/ 16,
|
||||
/*vec4*/ 16,
|
||||
};
|
||||
|
||||
if (is_scalar()) {
|
||||
// Note: Also captures booleans, but these are not host-shareable.
|
||||
align = 4;
|
||||
size = 4;
|
||||
return;
|
||||
}
|
||||
if (auto* vec = As<Vector>()) {
|
||||
TINT_ASSERT(Semantic, vec->size() >= 2 && vec->size() <= 4);
|
||||
align = vector_align[vec->size()];
|
||||
size = vector_size[vec->size()];
|
||||
return;
|
||||
}
|
||||
if (auto* mat = As<Matrix>()) {
|
||||
TINT_ASSERT(Semantic, mat->columns() >= 2 && mat->columns() <= 4);
|
||||
TINT_ASSERT(Semantic, mat->rows() >= 2 && mat->rows() <= 4);
|
||||
align = vector_align[mat->rows()];
|
||||
size = vector_align[mat->rows()] * mat->columns();
|
||||
return;
|
||||
}
|
||||
if (auto* s = As<Struct>()) {
|
||||
align = s->Align();
|
||||
size = s->Size();
|
||||
return;
|
||||
}
|
||||
if (auto* a = As<Array>()) {
|
||||
align = a->Align();
|
||||
size = a->SizeInBytes();
|
||||
return;
|
||||
}
|
||||
if (auto* a = As<Atomic>()) {
|
||||
return a->Type()->GetDefaultAlignAndSize(align, size);
|
||||
}
|
||||
|
||||
TINT_ASSERT(Semantic, false);
|
||||
}
|
||||
|
||||
bool Type::is_scalar() const {
|
||||
return IsAnyOf<F32, U32, I32, Bool>();
|
||||
}
|
||||
|
||||
@@ -52,6 +52,10 @@ class Type : public Castable<Type, Node> {
|
||||
/// @returns the inner type if this is a reference, `this` otherwise
|
||||
const Type* UnwrapRef() const;
|
||||
|
||||
/// @param align the output default alignment in bytes for this type.
|
||||
/// @param size the output default size in bytes for this type.
|
||||
void GetDefaultAlignAndSize(uint32_t& align, uint32_t& size) const;
|
||||
|
||||
/// @returns true if this type is a scalar
|
||||
bool is_scalar() const;
|
||||
/// @returns true if this type is a numeric scalar
|
||||
|
||||
Reference in New Issue
Block a user