mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-07-09 06:35:54 +00:00
Add create<T>() method to Module for types
Migrate all uses to use this and the new `unique_type<T>()` and `types()` methods. Remove the `type_mgr()` accessor. `TypeManager` is now an implementation detail of the module, allowing us to unify the allocation of types and nodes (if we so wish). Fixes: tint:337 Bug: tint:307 Change-Id: I233fa9dc73d60515dd721f02ea7ba089ef7d374f Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33667 Commit-Queue: Ben Clayton <bclayton@google.com> Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
parent
0fb5168fc7
commit
7e4ffa0064
@ -17,16 +17,16 @@
|
|||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
namespace ast {
|
||||||
|
|
||||||
TypesBuilder::TypesBuilder(TypeManager* tm)
|
TypesBuilder::TypesBuilder(Module* mod)
|
||||||
: bool_(tm->Get<ast::type::BoolType>()),
|
: bool_(mod->create<ast::type::BoolType>()),
|
||||||
f32(tm->Get<ast::type::F32Type>()),
|
f32(mod->create<ast::type::F32Type>()),
|
||||||
i32(tm->Get<ast::type::I32Type>()),
|
i32(mod->create<ast::type::I32Type>()),
|
||||||
u32(tm->Get<ast::type::U32Type>()),
|
u32(mod->create<ast::type::U32Type>()),
|
||||||
void_(tm->Get<ast::type::VoidType>()),
|
void_(mod->create<ast::type::VoidType>()),
|
||||||
tm_(tm) {}
|
mod_(mod) {}
|
||||||
|
|
||||||
Builder::Builder(tint::Context* c, tint::ast::Module* m)
|
Builder::Builder(tint::Context* c, tint::ast::Module* m)
|
||||||
: ctx(c), mod(m), ty(&m->type_mgr()) {}
|
: ctx(c), mod(m), ty(m) {}
|
||||||
Builder::~Builder() = default;
|
Builder::~Builder() = default;
|
||||||
|
|
||||||
ast::Variable* Builder::Var(const std::string& name,
|
ast::Variable* Builder::Var(const std::string& name,
|
||||||
|
@ -47,8 +47,8 @@ namespace ast {
|
|||||||
class TypesBuilder {
|
class TypesBuilder {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param tm the type manager
|
/// @param mod the module
|
||||||
explicit TypesBuilder(TypeManager* tm);
|
explicit TypesBuilder(Module* mod);
|
||||||
|
|
||||||
/// A boolean type
|
/// A boolean type
|
||||||
ast::type::BoolType* const bool_;
|
ast::type::BoolType* const bool_;
|
||||||
@ -70,80 +70,80 @@ class TypesBuilder {
|
|||||||
/// @return the tint AST type for a 2-element vector of the C type `T`.
|
/// @return the tint AST type for a 2-element vector of the C type `T`.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
ast::type::VectorType* vec2() const {
|
ast::type::VectorType* vec2() const {
|
||||||
return tm_->Get<ast::type::VectorType>(Of<T>(), 2);
|
return mod_->create<ast::type::VectorType>(Of<T>(), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @return the tint AST type for a 3-element vector of the C type `T`.
|
/// @return the tint AST type for a 3-element vector of the C type `T`.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
ast::type::VectorType* vec3() const {
|
ast::type::VectorType* vec3() const {
|
||||||
return tm_->Get<ast::type::VectorType>(Of<T>(), 3);
|
return mod_->create<ast::type::VectorType>(Of<T>(), 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @return the tint AST type for a 4-element vector of the C type `T`.
|
/// @return the tint AST type for a 4-element vector of the C type `T`.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
ast::type::Type* vec4() const {
|
ast::type::Type* vec4() const {
|
||||||
return tm_->Get<ast::type::VectorType>(Of<T>(), 4);
|
return mod_->create<ast::type::VectorType>(Of<T>(), 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @return the tint AST type for a 2x3 matrix of the C type `T`.
|
/// @return the tint AST type for a 2x3 matrix of the C type `T`.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
ast::type::MatrixType* mat2x2() const {
|
ast::type::MatrixType* mat2x2() const {
|
||||||
return tm_->Get<ast::type::MatrixType>(Of<T>(), 2, 2);
|
return mod_->create<ast::type::MatrixType>(Of<T>(), 2, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @return the tint AST type for a 2x3 matrix of the C type `T`.
|
/// @return the tint AST type for a 2x3 matrix of the C type `T`.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
ast::type::MatrixType* mat2x3() const {
|
ast::type::MatrixType* mat2x3() const {
|
||||||
return tm_->Get<ast::type::MatrixType>(Of<T>(), 3, 2);
|
return mod_->create<ast::type::MatrixType>(Of<T>(), 3, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @return the tint AST type for a 2x4 matrix of the C type `T`.
|
/// @return the tint AST type for a 2x4 matrix of the C type `T`.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
ast::type::MatrixType* mat2x4() const {
|
ast::type::MatrixType* mat2x4() const {
|
||||||
return tm_->Get<ast::type::MatrixType>(Of<T>(), 4, 2);
|
return mod_->create<ast::type::MatrixType>(Of<T>(), 4, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @return the tint AST type for a 3x2 matrix of the C type `T`.
|
/// @return the tint AST type for a 3x2 matrix of the C type `T`.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
ast::type::MatrixType* mat3x2() const {
|
ast::type::MatrixType* mat3x2() const {
|
||||||
return tm_->Get<ast::type::MatrixType>(Of<T>(), 2, 3);
|
return mod_->create<ast::type::MatrixType>(Of<T>(), 2, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @return the tint AST type for a 3x3 matrix of the C type `T`.
|
/// @return the tint AST type for a 3x3 matrix of the C type `T`.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
ast::type::MatrixType* mat3x3() const {
|
ast::type::MatrixType* mat3x3() const {
|
||||||
return tm_->Get<ast::type::MatrixType>(Of<T>(), 3, 3);
|
return mod_->create<ast::type::MatrixType>(Of<T>(), 3, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @return the tint AST type for a 3x4 matrix of the C type `T`.
|
/// @return the tint AST type for a 3x4 matrix of the C type `T`.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
ast::type::MatrixType* mat3x4() const {
|
ast::type::MatrixType* mat3x4() const {
|
||||||
return tm_->Get<ast::type::MatrixType>(Of<T>(), 4, 3);
|
return mod_->create<ast::type::MatrixType>(Of<T>(), 4, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @return the tint AST type for a 4x2 matrix of the C type `T`.
|
/// @return the tint AST type for a 4x2 matrix of the C type `T`.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
ast::type::MatrixType* mat4x2() const {
|
ast::type::MatrixType* mat4x2() const {
|
||||||
return tm_->Get<ast::type::MatrixType>(Of<T>(), 2, 4);
|
return mod_->create<ast::type::MatrixType>(Of<T>(), 2, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @return the tint AST type for a 4x3 matrix of the C type `T`.
|
/// @return the tint AST type for a 4x3 matrix of the C type `T`.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
ast::type::MatrixType* mat4x3() const {
|
ast::type::MatrixType* mat4x3() const {
|
||||||
return tm_->Get<ast::type::MatrixType>(Of<T>(), 3, 4);
|
return mod_->create<ast::type::MatrixType>(Of<T>(), 3, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @return the tint AST type for a 4x4 matrix of the C type `T`.
|
/// @return the tint AST type for a 4x4 matrix of the C type `T`.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
ast::type::MatrixType* mat4x4() const {
|
ast::type::MatrixType* mat4x4() const {
|
||||||
return tm_->Get<ast::type::MatrixType>(Of<T>(), 4, 4);
|
return mod_->create<ast::type::MatrixType>(Of<T>(), 4, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @param subtype the array element type
|
/// @param subtype the array element type
|
||||||
/// @param n the array size. 0 represents unbounded
|
/// @param n the array size. 0 represents unbounded
|
||||||
/// @return the tint AST type for a array of size `n` of type `T`
|
/// @return the tint AST type for a array of size `n` of type `T`
|
||||||
ast::type::ArrayType* array(ast::type::Type* subtype, uint32_t n) const {
|
ast::type::ArrayType* array(ast::type::Type* subtype, uint32_t n) const {
|
||||||
return tm_->Get<ast::type::ArrayType>(subtype, n);
|
return mod_->create<ast::type::ArrayType>(subtype, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @return the tint AST type for an array of size `N` of type `T`
|
/// @return the tint AST type for an array of size `N` of type `T`
|
||||||
@ -161,7 +161,7 @@ class TypesBuilder {
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
struct CToAST {};
|
struct CToAST {};
|
||||||
|
|
||||||
TypeManager* const tm_;
|
Module* const mod_;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Helper for building common AST constructs.
|
/// Helper for building common AST constructs.
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <type_traits>
|
||||||
|
#include <unordered_map>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -30,6 +32,10 @@ namespace ast {
|
|||||||
|
|
||||||
/// Represents all the source in a given program.
|
/// Represents all the source in a given program.
|
||||||
class Module {
|
class Module {
|
||||||
|
template <typename T, typename BASE>
|
||||||
|
using EnableIfIsType =
|
||||||
|
typename std::enable_if<std::is_base_of<BASE, T>::value, T>::type;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Module();
|
Module();
|
||||||
/// Move constructor
|
/// Move constructor
|
||||||
@ -78,15 +84,12 @@ class Module {
|
|||||||
/// @returns a string representation of the module
|
/// @returns a string representation of the module
|
||||||
std::string to_str() const;
|
std::string to_str() const;
|
||||||
|
|
||||||
/// @returns the Type Manager
|
|
||||||
ast::TypeManager& type_mgr() { return type_mgr_; }
|
|
||||||
|
|
||||||
/// Creates a new `ast::Node` owned by the Module. When the Module is
|
/// Creates a new `ast::Node` owned by the Module. When the Module is
|
||||||
/// destructed, the `ast::Node` will also be destructed.
|
/// destructed, the `ast::Node` will also be destructed.
|
||||||
/// @param args the arguments to pass to the type constructor
|
/// @param args the arguments to pass to the type constructor
|
||||||
/// @returns the node pointer
|
/// @returns the node pointer
|
||||||
template <typename T, typename... ARGS>
|
template <typename T, typename... ARGS>
|
||||||
T* create(ARGS&&... args) {
|
EnableIfIsType<T, ast::Node>* create(ARGS&&... args) {
|
||||||
static_assert(std::is_base_of<ast::Node, T>::value,
|
static_assert(std::is_base_of<ast::Node, T>::value,
|
||||||
"T does not derive from ast::Node");
|
"T does not derive from ast::Node");
|
||||||
auto uptr = std::make_unique<T>(std::forward<ARGS>(args)...);
|
auto uptr = std::make_unique<T>(std::forward<ARGS>(args)...);
|
||||||
@ -95,6 +98,38 @@ class Module {
|
|||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Creates a new `ast::Type` owned by the Module.
|
||||||
|
/// When the Module is destructed, owned Module and the returned
|
||||||
|
/// `ast::Type` will also be destructed.
|
||||||
|
/// Types are unique (de-aliased), and so `create()` for the same `T` and
|
||||||
|
/// arguments will return the same pointer.
|
||||||
|
/// @param args the arguments to pass to the type constructor
|
||||||
|
/// @returns the de-aliased type pointer
|
||||||
|
template <typename T, typename... ARGS>
|
||||||
|
EnableIfIsType<T, ast::type::Type>* create(ARGS&&... args) {
|
||||||
|
static_assert(std::is_base_of<ast::type::Type, T>::value,
|
||||||
|
"T does not derive from ast::type::Type");
|
||||||
|
return type_mgr_.Get<T>(std::forward<ARGS>(args)...);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Moves the type `ty` to the Module, returning a pointer to the unique
|
||||||
|
/// (de-aliased) type.
|
||||||
|
/// When the Module is destructed, the returned `ast::Type` will also be
|
||||||
|
/// destructed.
|
||||||
|
/// @param ty the type to add to the module
|
||||||
|
/// @returns the de-aliased type pointer
|
||||||
|
template <typename T>
|
||||||
|
EnableIfIsType<T, ast::type::Type>* unique_type(std::unique_ptr<T> ty) {
|
||||||
|
return static_cast<T*>(type_mgr_.Get(std::move(ty)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns all the declared types in the module
|
||||||
|
/// @returns the mapping from name string to type.
|
||||||
|
const std::unordered_map<std::string, std::unique_ptr<ast::type::Type>>&
|
||||||
|
types() {
|
||||||
|
return type_mgr_.types();
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Module(const Module&) = delete;
|
Module(const Module&) = delete;
|
||||||
|
|
||||||
|
@ -80,9 +80,9 @@ TEST_F(StorageTextureTypeTest, TypeName) {
|
|||||||
TEST_F(StorageTextureTypeTest, F32Type) {
|
TEST_F(StorageTextureTypeTest, F32Type) {
|
||||||
Context ctx;
|
Context ctx;
|
||||||
ast::Module mod;
|
ast::Module mod;
|
||||||
ast::type::Type* s = mod.type_mgr().Get(std::make_unique<StorageTextureType>(
|
ast::type::Type* s = mod.create<StorageTextureType>(
|
||||||
TextureDimension::k2dArray, AccessControl::kReadOnly,
|
TextureDimension::k2dArray, AccessControl::kReadOnly,
|
||||||
ImageFormat::kRgba32Float));
|
ImageFormat::kRgba32Float);
|
||||||
TypeDeterminer td(&ctx, &mod);
|
TypeDeterminer td(&ctx, &mod);
|
||||||
|
|
||||||
ASSERT_TRUE(td.Determine()) << td.error();
|
ASSERT_TRUE(td.Determine()) << td.error();
|
||||||
@ -94,9 +94,9 @@ TEST_F(StorageTextureTypeTest, F32Type) {
|
|||||||
TEST_F(StorageTextureTypeTest, U32Type) {
|
TEST_F(StorageTextureTypeTest, U32Type) {
|
||||||
Context ctx;
|
Context ctx;
|
||||||
ast::Module mod;
|
ast::Module mod;
|
||||||
ast::type::Type* s = mod.type_mgr().Get(std::make_unique<StorageTextureType>(
|
ast::type::Type* s = mod.create<StorageTextureType>(
|
||||||
TextureDimension::k2dArray, AccessControl::kReadOnly,
|
TextureDimension::k2dArray, AccessControl::kReadOnly,
|
||||||
ImageFormat::kRgba8Unorm));
|
ImageFormat::kRgba8Unorm);
|
||||||
TypeDeterminer td(&ctx, &mod);
|
TypeDeterminer td(&ctx, &mod);
|
||||||
|
|
||||||
ASSERT_TRUE(td.Determine()) << td.error();
|
ASSERT_TRUE(td.Determine()) << td.error();
|
||||||
@ -108,9 +108,9 @@ TEST_F(StorageTextureTypeTest, U32Type) {
|
|||||||
TEST_F(StorageTextureTypeTest, I32Type) {
|
TEST_F(StorageTextureTypeTest, I32Type) {
|
||||||
Context ctx;
|
Context ctx;
|
||||||
ast::Module mod;
|
ast::Module mod;
|
||||||
ast::type::Type* s = mod.type_mgr().Get(std::make_unique<StorageTextureType>(
|
ast::type::Type* s = mod.create<StorageTextureType>(
|
||||||
TextureDimension::k2dArray, AccessControl::kReadOnly,
|
TextureDimension::k2dArray, AccessControl::kReadOnly,
|
||||||
ImageFormat::kRgba32Sint));
|
ImageFormat::kRgba32Sint);
|
||||||
TypeDeterminer td(&ctx, &mod);
|
TypeDeterminer td(&ctx, &mod);
|
||||||
|
|
||||||
ASSERT_TRUE(td.Determine()) << td.error();
|
ASSERT_TRUE(td.Determine()) << td.error();
|
||||||
|
@ -3253,8 +3253,8 @@ ast::type::Type* FunctionEmitter::RemapStorageClass(ast::type::Type* type,
|
|||||||
const auto* ast_ptr_type = type->AsPointer();
|
const auto* ast_ptr_type = type->AsPointer();
|
||||||
const auto sc = GetStorageClassForPointerValue(result_id);
|
const auto sc = GetStorageClassForPointerValue(result_id);
|
||||||
if (ast_ptr_type->storage_class() != sc) {
|
if (ast_ptr_type->storage_class() != sc) {
|
||||||
return parser_impl_.get_module().type_mgr().Get(
|
return parser_impl_.get_module().create<ast::type::PointerType>(
|
||||||
std::make_unique<ast::type::PointerType>(ast_ptr_type->type(), sc));
|
ast_ptr_type->type(), sc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return type;
|
return type;
|
||||||
|
@ -196,8 +196,7 @@ ParserImpl::ParserImpl(Context* ctx, const std::vector<uint32_t>& spv_binary)
|
|||||||
: Reader(ctx),
|
: Reader(ctx),
|
||||||
spv_binary_(spv_binary),
|
spv_binary_(spv_binary),
|
||||||
fail_stream_(&success_, &errors_),
|
fail_stream_(&success_, &errors_),
|
||||||
bool_type_(
|
bool_type_(ast_module_.create<ast::type::BoolType>()),
|
||||||
ast_module_.type_mgr().Get(std::make_unique<ast::type::BoolType>())),
|
|
||||||
namer_(fail_stream_),
|
namer_(fail_stream_),
|
||||||
enum_converter_(fail_stream_),
|
enum_converter_(fail_stream_),
|
||||||
tools_context_(kInputEnv) {
|
tools_context_(kInputEnv) {
|
||||||
@ -286,8 +285,7 @@ ast::type::Type* ParserImpl::ConvertType(uint32_t type_id) {
|
|||||||
|
|
||||||
switch (spirv_type->kind()) {
|
switch (spirv_type->kind()) {
|
||||||
case spvtools::opt::analysis::Type::kVoid:
|
case spvtools::opt::analysis::Type::kVoid:
|
||||||
return save(
|
return save(ast_module_.create<ast::type::VoidType>());
|
||||||
ast_module_.type_mgr().Get(std::make_unique<ast::type::VoidType>()));
|
|
||||||
case spvtools::opt::analysis::Type::kBool:
|
case spvtools::opt::analysis::Type::kBool:
|
||||||
return save(bool_type_);
|
return save(bool_type_);
|
||||||
case spvtools::opt::analysis::Type::kInteger:
|
case spvtools::opt::analysis::Type::kInteger:
|
||||||
@ -317,8 +315,7 @@ ast::type::Type* ParserImpl::ConvertType(uint32_t type_id) {
|
|||||||
case spvtools::opt::analysis::Type::kImage:
|
case spvtools::opt::analysis::Type::kImage:
|
||||||
// Fake it for sampler and texture types. These are handled in an
|
// Fake it for sampler and texture types. These are handled in an
|
||||||
// entirely different way.
|
// entirely different way.
|
||||||
return save(
|
return save(ast_module_.create<ast::type::VoidType>());
|
||||||
ast_module_.type_mgr().Get(std::make_unique<ast::type::VoidType>()));
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -651,10 +648,8 @@ bool ParserImpl::RegisterEntryPoints() {
|
|||||||
ast::type::Type* ParserImpl::ConvertType(
|
ast::type::Type* ParserImpl::ConvertType(
|
||||||
const spvtools::opt::analysis::Integer* int_ty) {
|
const spvtools::opt::analysis::Integer* int_ty) {
|
||||||
if (int_ty->width() == 32) {
|
if (int_ty->width() == 32) {
|
||||||
auto* signed_ty =
|
ast::type::Type* signed_ty = ast_module_.create<ast::type::I32Type>();
|
||||||
ast_module_.type_mgr().Get(std::make_unique<ast::type::I32Type>());
|
ast::type::Type* unsigned_ty = ast_module_.create<ast::type::U32Type>();
|
||||||
auto* unsigned_ty =
|
|
||||||
ast_module_.type_mgr().Get(std::make_unique<ast::type::U32Type>());
|
|
||||||
signed_type_for_[unsigned_ty] = signed_ty;
|
signed_type_for_[unsigned_ty] = signed_ty;
|
||||||
unsigned_type_for_[signed_ty] = unsigned_ty;
|
unsigned_type_for_[signed_ty] = unsigned_ty;
|
||||||
return int_ty->IsSigned() ? signed_ty : unsigned_ty;
|
return int_ty->IsSigned() ? signed_ty : unsigned_ty;
|
||||||
@ -666,7 +661,7 @@ ast::type::Type* ParserImpl::ConvertType(
|
|||||||
ast::type::Type* ParserImpl::ConvertType(
|
ast::type::Type* ParserImpl::ConvertType(
|
||||||
const spvtools::opt::analysis::Float* float_ty) {
|
const spvtools::opt::analysis::Float* float_ty) {
|
||||||
if (float_ty->width() == 32) {
|
if (float_ty->width() == 32) {
|
||||||
return ast_module_.type_mgr().Get(std::make_unique<ast::type::F32Type>());
|
return ast_module_.create<ast::type::F32Type>();
|
||||||
}
|
}
|
||||||
Fail() << "unhandled float width: " << float_ty->width();
|
Fail() << "unhandled float width: " << float_ty->width();
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -679,19 +674,17 @@ ast::type::Type* ParserImpl::ConvertType(
|
|||||||
if (ast_elem_ty == nullptr) {
|
if (ast_elem_ty == nullptr) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
auto* this_ty = ast_module_.type_mgr().Get(
|
auto* this_ty =
|
||||||
std::make_unique<ast::type::VectorType>(ast_elem_ty, num_elem));
|
ast_module_.create<ast::type::VectorType>(ast_elem_ty, num_elem);
|
||||||
// Generate the opposite-signedness vector type, if this type is integral.
|
// Generate the opposite-signedness vector type, if this type is integral.
|
||||||
if (unsigned_type_for_.count(ast_elem_ty)) {
|
if (unsigned_type_for_.count(ast_elem_ty)) {
|
||||||
auto* other_ty =
|
auto* other_ty = ast_module_.create<ast::type::VectorType>(
|
||||||
ast_module_.type_mgr().Get(std::make_unique<ast::type::VectorType>(
|
unsigned_type_for_[ast_elem_ty], num_elem);
|
||||||
unsigned_type_for_[ast_elem_ty], num_elem));
|
|
||||||
signed_type_for_[other_ty] = this_ty;
|
signed_type_for_[other_ty] = this_ty;
|
||||||
unsigned_type_for_[this_ty] = other_ty;
|
unsigned_type_for_[this_ty] = other_ty;
|
||||||
} else if (signed_type_for_.count(ast_elem_ty)) {
|
} else if (signed_type_for_.count(ast_elem_ty)) {
|
||||||
auto* other_ty =
|
auto* other_ty = ast_module_.create<ast::type::VectorType>(
|
||||||
ast_module_.type_mgr().Get(std::make_unique<ast::type::VectorType>(
|
signed_type_for_[ast_elem_ty], num_elem);
|
||||||
signed_type_for_[ast_elem_ty], num_elem));
|
|
||||||
unsigned_type_for_[other_ty] = this_ty;
|
unsigned_type_for_[other_ty] = this_ty;
|
||||||
signed_type_for_[this_ty] = other_ty;
|
signed_type_for_[this_ty] = other_ty;
|
||||||
}
|
}
|
||||||
@ -708,8 +701,8 @@ ast::type::Type* ParserImpl::ConvertType(
|
|||||||
if (ast_scalar_ty == nullptr) {
|
if (ast_scalar_ty == nullptr) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return ast_module_.type_mgr().Get(std::make_unique<ast::type::MatrixType>(
|
return ast_module_.create<ast::type::MatrixType>(ast_scalar_ty, num_rows,
|
||||||
ast_scalar_ty, num_rows, num_columns));
|
num_columns);
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::type::Type* ParserImpl::ConvertType(
|
ast::type::Type* ParserImpl::ConvertType(
|
||||||
@ -722,7 +715,7 @@ ast::type::Type* ParserImpl::ConvertType(
|
|||||||
if (!ApplyArrayDecorations(rtarr_ty, ast_type.get())) {
|
if (!ApplyArrayDecorations(rtarr_ty, ast_type.get())) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return ast_module_.type_mgr().Get(std::move(ast_type));
|
return ast_module_.unique_type(std::move(ast_type));
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::type::Type* ParserImpl::ConvertType(
|
ast::type::Type* ParserImpl::ConvertType(
|
||||||
@ -767,7 +760,7 @@ ast::type::Type* ParserImpl::ConvertType(
|
|||||||
if (remap_buffer_block_type_.count(elem_type_id)) {
|
if (remap_buffer_block_type_.count(elem_type_id)) {
|
||||||
remap_buffer_block_type_.insert(type_mgr_->GetId(arr_ty));
|
remap_buffer_block_type_.insert(type_mgr_->GetId(arr_ty));
|
||||||
}
|
}
|
||||||
return ast_module_.type_mgr().Get(std::move(ast_type));
|
return ast_module_.unique_type(std::move(ast_type));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ParserImpl::ApplyArrayDecorations(
|
bool ParserImpl::ApplyArrayDecorations(
|
||||||
@ -892,10 +885,9 @@ ast::type::Type* ParserImpl::ConvertType(
|
|||||||
std::move(ast_members));
|
std::move(ast_members));
|
||||||
|
|
||||||
namer_.SuggestSanitizedName(type_id, "S");
|
namer_.SuggestSanitizedName(type_id, "S");
|
||||||
auto ast_struct_type = std::make_unique<ast::type::StructType>(
|
|
||||||
namer_.GetName(type_id), ast_struct);
|
|
||||||
|
|
||||||
auto* result = ast_module_.type_mgr().Get(std::move(ast_struct_type));
|
auto* result = ast_module_.create<ast::type::StructType>(
|
||||||
|
namer_.GetName(type_id), ast_struct);
|
||||||
id_to_type_[type_id] = result;
|
id_to_type_[type_id] = result;
|
||||||
if (num_non_writable_members == members.size()) {
|
if (num_non_writable_members == members.size()) {
|
||||||
read_only_struct_types_.insert(result);
|
read_only_struct_types_.insert(result);
|
||||||
@ -935,8 +927,8 @@ ast::type::Type* ParserImpl::ConvertType(
|
|||||||
ast_storage_class = ast::StorageClass::kStorageBuffer;
|
ast_storage_class = ast::StorageClass::kStorageBuffer;
|
||||||
remap_buffer_block_type_.insert(type_id);
|
remap_buffer_block_type_.insert(type_id);
|
||||||
}
|
}
|
||||||
return ast_module_.type_mgr().Get(
|
return ast_module_.create<ast::type::PointerType>(ast_elem_ty,
|
||||||
std::make_unique<ast::type::PointerType>(ast_elem_ty, ast_storage_class));
|
ast_storage_class);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ParserImpl::RegisterTypes() {
|
bool ParserImpl::RegisterTypes() {
|
||||||
@ -1065,10 +1057,8 @@ void ParserImpl::MaybeGenerateAlias(uint32_t type_id,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto name = namer_.GetName(type_id);
|
const auto name = namer_.GetName(type_id);
|
||||||
auto* ast_alias_type = ast_module_.type_mgr()
|
auto* ast_alias_type =
|
||||||
.Get(std::make_unique<ast::type::AliasType>(
|
ast_module_.create<ast::type::AliasType>(name, ast_underlying_type);
|
||||||
name, ast_underlying_type))
|
|
||||||
->AsAlias();
|
|
||||||
// Record this new alias as the AST type for this SPIR-V ID.
|
// Record this new alias as the AST type for this SPIR-V ID.
|
||||||
id_to_type_[type_id] = ast_alias_type;
|
id_to_type_[type_id] = ast_alias_type;
|
||||||
ast_module_.AddConstructedType(ast_alias_type);
|
ast_module_.AddConstructedType(ast_alias_type);
|
||||||
@ -1169,8 +1159,7 @@ ast::Variable* ParserImpl::MakeVariable(uint32_t id,
|
|||||||
auto access = read_only_struct_types_.count(type)
|
auto access = read_only_struct_types_.count(type)
|
||||||
? ast::AccessControl::kReadOnly
|
? ast::AccessControl::kReadOnly
|
||||||
: ast::AccessControl::kReadWrite;
|
: ast::AccessControl::kReadWrite;
|
||||||
type = ast_module_.type_mgr().Get(
|
type = ast_module_.create<ast::type::AccessControlType>(access, type);
|
||||||
std::make_unique<ast::type::AccessControlType>(access, type));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* ast_var = create<ast::Variable>(namer_.Name(id), sc, type);
|
auto* ast_var = create<ast::Variable>(namer_.Name(id), sc, type);
|
||||||
@ -1363,9 +1352,8 @@ ast::Expression* ParserImpl::MakeNullValue(ast::type::Type* type) {
|
|||||||
if (type->IsMatrix()) {
|
if (type->IsMatrix()) {
|
||||||
const auto* mat_ty = type->AsMatrix();
|
const auto* mat_ty = type->AsMatrix();
|
||||||
// Matrix components are columns
|
// Matrix components are columns
|
||||||
auto* column_ty =
|
auto* column_ty = ast_module_.create<ast::type::VectorType>(mat_ty->type(),
|
||||||
ast_module_.type_mgr().Get(std::make_unique<ast::type::VectorType>(
|
mat_ty->rows());
|
||||||
mat_ty->type(), mat_ty->rows()));
|
|
||||||
ast::ExpressionList ast_components;
|
ast::ExpressionList ast_components;
|
||||||
for (size_t i = 0; i < mat_ty->columns(); ++i) {
|
for (size_t i = 0; i < mat_ty->columns(); ++i) {
|
||||||
ast_components.emplace_back(MakeNullValue(column_ty));
|
ast_components.emplace_back(MakeNullValue(column_ty));
|
||||||
@ -1446,15 +1434,13 @@ ast::type::Type* ParserImpl::GetSignedIntMatchingShape(ast::type::Type* other) {
|
|||||||
if (other == nullptr) {
|
if (other == nullptr) {
|
||||||
Fail() << "no type provided";
|
Fail() << "no type provided";
|
||||||
}
|
}
|
||||||
auto* i32 =
|
auto* i32 = ast_module_.create<ast::type::I32Type>();
|
||||||
ast_module_.type_mgr().Get(std::make_unique<ast::type::I32Type>());
|
|
||||||
if (other->IsF32() || other->IsU32() || other->IsI32()) {
|
if (other->IsF32() || other->IsU32() || other->IsI32()) {
|
||||||
return i32;
|
return i32;
|
||||||
}
|
}
|
||||||
auto* vec_ty = other->AsVector();
|
auto* vec_ty = other->AsVector();
|
||||||
if (vec_ty) {
|
if (vec_ty) {
|
||||||
return ast_module_.type_mgr().Get(
|
return ast_module_.create<ast::type::VectorType>(i32, vec_ty->size());
|
||||||
std::make_unique<ast::type::VectorType>(i32, vec_ty->size()));
|
|
||||||
}
|
}
|
||||||
Fail() << "required numeric scalar or vector, but got " << other->type_name();
|
Fail() << "required numeric scalar or vector, but got " << other->type_name();
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -1466,15 +1452,13 @@ ast::type::Type* ParserImpl::GetUnsignedIntMatchingShape(
|
|||||||
Fail() << "no type provided";
|
Fail() << "no type provided";
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
auto* u32 =
|
auto* u32 = ast_module_.create<ast::type::U32Type>();
|
||||||
ast_module_.type_mgr().Get(std::make_unique<ast::type::U32Type>());
|
|
||||||
if (other->IsF32() || other->IsU32() || other->IsI32()) {
|
if (other->IsF32() || other->IsU32() || other->IsI32()) {
|
||||||
return u32;
|
return u32;
|
||||||
}
|
}
|
||||||
auto* vec_ty = other->AsVector();
|
auto* vec_ty = other->AsVector();
|
||||||
if (vec_ty) {
|
if (vec_ty) {
|
||||||
return ast_module_.type_mgr().Get(
|
return ast_module_.create<ast::type::VectorType>(u32, vec_ty->size());
|
||||||
std::make_unique<ast::type::VectorType>(u32, vec_ty->size()));
|
|
||||||
}
|
}
|
||||||
Fail() << "required numeric scalar or vector, but got " << other->type_name();
|
Fail() << "required numeric scalar or vector, but got " << other->type_name();
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -1632,11 +1616,9 @@ ast::type::Type* ParserImpl::GetTypeForHandleVar(
|
|||||||
}
|
}
|
||||||
ast::type::Type* ast_store_type = nullptr;
|
ast::type::Type* ast_store_type = nullptr;
|
||||||
if (usage.IsSampler()) {
|
if (usage.IsSampler()) {
|
||||||
ast_store_type =
|
ast_store_type = ast_module_.create<ast::type::SamplerType>(
|
||||||
ast_module_.type_mgr().Get(std::make_unique<ast::type::SamplerType>(
|
usage.IsComparisonSampler() ? ast::type::SamplerKind::kComparisonSampler
|
||||||
usage.IsComparisonSampler()
|
: ast::type::SamplerKind::kSampler);
|
||||||
? ast::type::SamplerKind::kComparisonSampler
|
|
||||||
: ast::type::SamplerKind::kSampler));
|
|
||||||
} else if (usage.IsTexture()) {
|
} else if (usage.IsTexture()) {
|
||||||
const auto* ptr_type = def_use_mgr_->GetDef(var.type_id());
|
const auto* ptr_type = def_use_mgr_->GetDef(var.type_id());
|
||||||
if (!ptr_type) {
|
if (!ptr_type) {
|
||||||
@ -1689,17 +1671,14 @@ ast::type::Type* ParserImpl::GetTypeForHandleVar(
|
|||||||
// OpImage variable with an OpImage*Dref* instruction. In WGSL we must
|
// OpImage variable with an OpImage*Dref* instruction. In WGSL we must
|
||||||
// treat that as a depth texture.
|
// treat that as a depth texture.
|
||||||
if (image_type->depth() || usage.IsDepthTexture()) {
|
if (image_type->depth() || usage.IsDepthTexture()) {
|
||||||
ast_store_type = ast_module_.type_mgr().Get(
|
ast_store_type = ast_module_.create<ast::type::DepthTextureType>(dim);
|
||||||
std::make_unique<ast::type::DepthTextureType>(dim));
|
|
||||||
} else if (image_type->is_multisampled()) {
|
} else if (image_type->is_multisampled()) {
|
||||||
// Multisampled textures are never depth textures.
|
// Multisampled textures are never depth textures.
|
||||||
ast_store_type = ast_module_.type_mgr().Get(
|
ast_store_type = ast_module_.create<ast::type::MultisampledTextureType>(
|
||||||
std::make_unique<ast::type::MultisampledTextureType>(
|
dim, ast_sampled_component_type);
|
||||||
dim, ast_sampled_component_type));
|
|
||||||
} else {
|
} else {
|
||||||
ast_store_type = ast_module_.type_mgr().Get(
|
ast_store_type = ast_module_.create<ast::type::SampledTextureType>(
|
||||||
std::make_unique<ast::type::SampledTextureType>(
|
dim, ast_sampled_component_type);
|
||||||
dim, ast_sampled_component_type));
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Make a storage texture.
|
// Make a storage texture.
|
||||||
@ -1731,8 +1710,8 @@ ast::type::Type* ParserImpl::GetTypeForHandleVar(
|
|||||||
if (format == ast::type::ImageFormat::kNone) {
|
if (format == ast::type::ImageFormat::kNone) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
ast_store_type = ast_module_.type_mgr().Get(
|
ast_store_type = ast_module_.create<ast::type::StorageTextureType>(
|
||||||
std::make_unique<ast::type::StorageTextureType>(dim, access, format));
|
dim, access, format);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Fail() << "unsupported: UniformConstant variable is not a recognized "
|
Fail() << "unsupported: UniformConstant variable is not a recognized "
|
||||||
@ -1741,8 +1720,8 @@ ast::type::Type* ParserImpl::GetTypeForHandleVar(
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
// Form the pointer type.
|
// Form the pointer type.
|
||||||
return ast_module_.type_mgr().Get(std::make_unique<ast::type::PointerType>(
|
return ast_module_.create<ast::type::PointerType>(
|
||||||
ast_store_type, ast::StorageClass::kUniformConstant));
|
ast_store_type, ast::StorageClass::kUniformConstant);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ParserImpl::RegisterHandleUsage() {
|
bool ParserImpl::RegisterHandleUsage() {
|
||||||
|
@ -308,7 +308,7 @@ Expect<bool> ParserImpl::expect_global_decl() {
|
|||||||
if (!expect("struct declaration", Token::Type::kSemicolon))
|
if (!expect("struct declaration", Token::Type::kSemicolon))
|
||||||
return Failure::kErrored;
|
return Failure::kErrored;
|
||||||
|
|
||||||
auto* type = module_.type_mgr().Get(std::move(str.value));
|
auto* type = module_.unique_type(std::move(str.value));
|
||||||
register_constructed(type->AsStruct()->name(), type);
|
register_constructed(type->AsStruct()->name(), type);
|
||||||
module_.AddConstructedType(type);
|
module_.AddConstructedType(type);
|
||||||
return true;
|
return true;
|
||||||
@ -462,9 +462,8 @@ Maybe<ast::type::Type*> ParserImpl::texture_sampler_types() {
|
|||||||
if (subtype.errored)
|
if (subtype.errored)
|
||||||
return Failure::kErrored;
|
return Failure::kErrored;
|
||||||
|
|
||||||
return module_.type_mgr().Get(
|
return module_.create<ast::type::SampledTextureType>(dim.value,
|
||||||
std::make_unique<ast::type::SampledTextureType>(dim.value,
|
subtype.value);
|
||||||
subtype.value));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto ms_dim = multisampled_texture_type();
|
auto ms_dim = multisampled_texture_type();
|
||||||
@ -475,9 +474,8 @@ Maybe<ast::type::Type*> ParserImpl::texture_sampler_types() {
|
|||||||
if (subtype.errored)
|
if (subtype.errored)
|
||||||
return Failure::kErrored;
|
return Failure::kErrored;
|
||||||
|
|
||||||
return module_.type_mgr().Get(
|
return module_.create<ast::type::MultisampledTextureType>(ms_dim.value,
|
||||||
std::make_unique<ast::type::MultisampledTextureType>(ms_dim.value,
|
subtype.value);
|
||||||
subtype.value));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto storage = storage_texture_type();
|
auto storage = storage_texture_type();
|
||||||
@ -490,9 +488,8 @@ Maybe<ast::type::Type*> ParserImpl::texture_sampler_types() {
|
|||||||
if (format.errored)
|
if (format.errored)
|
||||||
return Failure::kErrored;
|
return Failure::kErrored;
|
||||||
|
|
||||||
return module_.type_mgr().Get(
|
return module_.create<ast::type::StorageTextureType>(
|
||||||
std::make_unique<ast::type::StorageTextureType>(
|
storage->first, storage->second, format.value);
|
||||||
storage->first, storage->second, format.value));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Failure::kNoMatch;
|
return Failure::kNoMatch;
|
||||||
@ -503,12 +500,12 @@ Maybe<ast::type::Type*> ParserImpl::texture_sampler_types() {
|
|||||||
// | SAMPLER_COMPARISON
|
// | SAMPLER_COMPARISON
|
||||||
Maybe<ast::type::Type*> ParserImpl::sampler_type() {
|
Maybe<ast::type::Type*> ParserImpl::sampler_type() {
|
||||||
if (match(Token::Type::kSampler))
|
if (match(Token::Type::kSampler))
|
||||||
return module_.type_mgr().Get(std::make_unique<ast::type::SamplerType>(
|
return module_.create<ast::type::SamplerType>(
|
||||||
ast::type::SamplerKind::kSampler));
|
ast::type::SamplerKind::kSampler);
|
||||||
|
|
||||||
if (match(Token::Type::kComparisonSampler))
|
if (match(Token::Type::kComparisonSampler))
|
||||||
return module_.type_mgr().Get(std::make_unique<ast::type::SamplerType>(
|
return module_.create<ast::type::SamplerType>(
|
||||||
ast::type::SamplerKind::kComparisonSampler));
|
ast::type::SamplerKind::kComparisonSampler);
|
||||||
|
|
||||||
return Failure::kNoMatch;
|
return Failure::kNoMatch;
|
||||||
}
|
}
|
||||||
@ -636,20 +633,20 @@ ParserImpl::storage_texture_type() {
|
|||||||
// | TEXTURE_DEPTH_CUBE_ARRAY
|
// | TEXTURE_DEPTH_CUBE_ARRAY
|
||||||
Maybe<ast::type::Type*> ParserImpl::depth_texture_type() {
|
Maybe<ast::type::Type*> ParserImpl::depth_texture_type() {
|
||||||
if (match(Token::Type::kTextureDepth2d))
|
if (match(Token::Type::kTextureDepth2d))
|
||||||
return module_.type_mgr().Get(std::make_unique<ast::type::DepthTextureType>(
|
return module_.create<ast::type::DepthTextureType>(
|
||||||
ast::type::TextureDimension::k2d));
|
ast::type::TextureDimension::k2d);
|
||||||
|
|
||||||
if (match(Token::Type::kTextureDepth2dArray))
|
if (match(Token::Type::kTextureDepth2dArray))
|
||||||
return module_.type_mgr().Get(std::make_unique<ast::type::DepthTextureType>(
|
return module_.create<ast::type::DepthTextureType>(
|
||||||
ast::type::TextureDimension::k2dArray));
|
ast::type::TextureDimension::k2dArray);
|
||||||
|
|
||||||
if (match(Token::Type::kTextureDepthCube))
|
if (match(Token::Type::kTextureDepthCube))
|
||||||
return module_.type_mgr().Get(std::make_unique<ast::type::DepthTextureType>(
|
return module_.create<ast::type::DepthTextureType>(
|
||||||
ast::type::TextureDimension::kCube));
|
ast::type::TextureDimension::kCube);
|
||||||
|
|
||||||
if (match(Token::Type::kTextureDepthCubeArray))
|
if (match(Token::Type::kTextureDepthCubeArray))
|
||||||
return module_.type_mgr().Get(std::make_unique<ast::type::DepthTextureType>(
|
return module_.create<ast::type::DepthTextureType>(
|
||||||
ast::type::TextureDimension::kCubeArray));
|
ast::type::TextureDimension::kCubeArray);
|
||||||
|
|
||||||
return Failure::kNoMatch;
|
return Failure::kNoMatch;
|
||||||
}
|
}
|
||||||
@ -834,8 +831,8 @@ Expect<ParserImpl::TypedIdentifier> ParserImpl::expect_variable_ident_decl(
|
|||||||
for (auto* deco : access_decos) {
|
for (auto* deco : access_decos) {
|
||||||
// If we have an access control decoration then we take it and wrap our
|
// If we have an access control decoration then we take it and wrap our
|
||||||
// type up with that decoration
|
// type up with that decoration
|
||||||
ty = module_.type_mgr().Get(std::make_unique<ast::type::AccessControlType>(
|
ty = module_.create<ast::type::AccessControlType>(deco->AsAccess()->value(),
|
||||||
deco->AsAccess()->value(), ty));
|
ty);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TypedIdentifier{ty, ident.value, ident.source};
|
return TypedIdentifier{ty, ident.value, ident.source};
|
||||||
@ -894,8 +891,7 @@ Maybe<ast::type::Type*> ParserImpl::type_alias() {
|
|||||||
if (!type.matched)
|
if (!type.matched)
|
||||||
return add_error(peek(), "invalid type alias");
|
return add_error(peek(), "invalid type alias");
|
||||||
|
|
||||||
auto* alias = module_.type_mgr().Get(
|
auto* alias = module_.create<ast::type::AliasType>(name.value, type.value);
|
||||||
std::make_unique<ast::type::AliasType>(name.value, type.value));
|
|
||||||
register_constructed(name.value, alias);
|
register_constructed(name.value, alias);
|
||||||
|
|
||||||
return alias->AsAlias();
|
return alias->AsAlias();
|
||||||
@ -953,16 +949,16 @@ Maybe<ast::type::Type*> ParserImpl::type_decl(ast::DecorationList& decos) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (match(Token::Type::kBool))
|
if (match(Token::Type::kBool))
|
||||||
return module_.type_mgr().Get(std::make_unique<ast::type::BoolType>());
|
return module_.create<ast::type::BoolType>();
|
||||||
|
|
||||||
if (match(Token::Type::kF32))
|
if (match(Token::Type::kF32))
|
||||||
return module_.type_mgr().Get(std::make_unique<ast::type::F32Type>());
|
return module_.create<ast::type::F32Type>();
|
||||||
|
|
||||||
if (match(Token::Type::kI32))
|
if (match(Token::Type::kI32))
|
||||||
return module_.type_mgr().Get(std::make_unique<ast::type::I32Type>());
|
return module_.create<ast::type::I32Type>();
|
||||||
|
|
||||||
if (match(Token::Type::kU32))
|
if (match(Token::Type::kU32))
|
||||||
return module_.type_mgr().Get(std::make_unique<ast::type::U32Type>());
|
return module_.create<ast::type::U32Type>();
|
||||||
|
|
||||||
if (t.IsVec2() || t.IsVec3() || t.IsVec4()) {
|
if (t.IsVec2() || t.IsVec3() || t.IsVec4()) {
|
||||||
next(); // Consume the peek
|
next(); // Consume the peek
|
||||||
@ -1020,8 +1016,7 @@ Expect<ast::type::Type*> ParserImpl::expect_type_decl_pointer() {
|
|||||||
if (subtype.errored)
|
if (subtype.errored)
|
||||||
return Failure::kErrored;
|
return Failure::kErrored;
|
||||||
|
|
||||||
return module_.type_mgr().Get(
|
return module_.create<ast::type::PointerType>(subtype.value, sc.value);
|
||||||
std::make_unique<ast::type::PointerType>(subtype.value, sc.value));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1038,8 +1033,7 @@ Expect<ast::type::Type*> ParserImpl::expect_type_decl_vector(Token t) {
|
|||||||
if (subtype.errored)
|
if (subtype.errored)
|
||||||
return Failure::kErrored;
|
return Failure::kErrored;
|
||||||
|
|
||||||
return module_.type_mgr().Get(
|
return module_.create<ast::type::VectorType>(subtype.value, count);
|
||||||
std::make_unique<ast::type::VectorType>(subtype.value, count));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Expect<ast::type::Type*> ParserImpl::expect_type_decl_array(
|
Expect<ast::type::Type*> ParserImpl::expect_type_decl_array(
|
||||||
@ -1061,7 +1055,7 @@ Expect<ast::type::Type*> ParserImpl::expect_type_decl_array(
|
|||||||
|
|
||||||
auto ty = std::make_unique<ast::type::ArrayType>(subtype.value, size);
|
auto ty = std::make_unique<ast::type::ArrayType>(subtype.value, size);
|
||||||
ty->set_decorations(std::move(decos));
|
ty->set_decorations(std::move(decos));
|
||||||
return module_.type_mgr().Get(std::move(ty));
|
return module_.unique_type(std::move(ty));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1085,8 +1079,7 @@ Expect<ast::type::Type*> ParserImpl::expect_type_decl_matrix(Token t) {
|
|||||||
if (subtype.errored)
|
if (subtype.errored)
|
||||||
return Failure::kErrored;
|
return Failure::kErrored;
|
||||||
|
|
||||||
return module_.type_mgr().Get(
|
return module_.create<ast::type::MatrixType>(subtype.value, rows, columns);
|
||||||
std::make_unique<ast::type::MatrixType>(subtype.value, rows, columns));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// storage_class
|
// storage_class
|
||||||
@ -1254,7 +1247,7 @@ Maybe<ast::Function*> ParserImpl::function_decl(ast::DecorationList& decos) {
|
|||||||
// | VOID
|
// | VOID
|
||||||
Maybe<ast::type::Type*> ParserImpl::function_type_decl() {
|
Maybe<ast::type::Type*> ParserImpl::function_type_decl() {
|
||||||
if (match(Token::Type::kVoid))
|
if (match(Token::Type::kVoid))
|
||||||
return module_.type_mgr().Get(std::make_unique<ast::type::VoidType>());
|
return module_.create<ast::type::VoidType>();
|
||||||
|
|
||||||
return type_decl();
|
return type_decl();
|
||||||
}
|
}
|
||||||
@ -2613,25 +2606,23 @@ Maybe<ast::AssignmentStatement*> ParserImpl::assignment_stmt() {
|
|||||||
Maybe<ast::Literal*> ParserImpl::const_literal() {
|
Maybe<ast::Literal*> ParserImpl::const_literal() {
|
||||||
auto t = peek();
|
auto t = peek();
|
||||||
if (match(Token::Type::kTrue)) {
|
if (match(Token::Type::kTrue)) {
|
||||||
auto* type =
|
auto* type = module_.create<ast::type::BoolType>();
|
||||||
module_.type_mgr().Get(std::make_unique<ast::type::BoolType>());
|
|
||||||
return create<ast::BoolLiteral>(type, true);
|
return create<ast::BoolLiteral>(type, true);
|
||||||
}
|
}
|
||||||
if (match(Token::Type::kFalse)) {
|
if (match(Token::Type::kFalse)) {
|
||||||
auto* type =
|
auto* type = module_.create<ast::type::BoolType>();
|
||||||
module_.type_mgr().Get(std::make_unique<ast::type::BoolType>());
|
|
||||||
return create<ast::BoolLiteral>(type, false);
|
return create<ast::BoolLiteral>(type, false);
|
||||||
}
|
}
|
||||||
if (match(Token::Type::kSintLiteral)) {
|
if (match(Token::Type::kSintLiteral)) {
|
||||||
auto* type = module_.type_mgr().Get(std::make_unique<ast::type::I32Type>());
|
auto* type = module_.create<ast::type::I32Type>();
|
||||||
return create<ast::SintLiteral>(type, t.to_i32());
|
return create<ast::SintLiteral>(type, t.to_i32());
|
||||||
}
|
}
|
||||||
if (match(Token::Type::kUintLiteral)) {
|
if (match(Token::Type::kUintLiteral)) {
|
||||||
auto* type = module_.type_mgr().Get(std::make_unique<ast::type::U32Type>());
|
auto* type = module_.create<ast::type::U32Type>();
|
||||||
return create<ast::UintLiteral>(type, t.to_u32());
|
return create<ast::UintLiteral>(type, t.to_u32());
|
||||||
}
|
}
|
||||||
if (match(Token::Type::kFloatLiteral)) {
|
if (match(Token::Type::kFloatLiteral)) {
|
||||||
auto* type = module_.type_mgr().Get(std::make_unique<ast::type::F32Type>());
|
auto* type = module_.create<ast::type::F32Type>();
|
||||||
return create<ast::FloatLiteral>(type, t.to_f32());
|
return create<ast::FloatLiteral>(type, t.to_f32());
|
||||||
}
|
}
|
||||||
return Failure::kNoMatch;
|
return Failure::kNoMatch;
|
||||||
|
@ -30,7 +30,7 @@ TEST_F(ParserImplTest, FunctionTypeDecl_Void) {
|
|||||||
auto p = parser("void");
|
auto p = parser("void");
|
||||||
|
|
||||||
auto& mod = p->get_module();
|
auto& mod = p->get_module();
|
||||||
auto* v = mod.type_mgr().Get(std::make_unique<ast::type::VoidType>());
|
auto* v = mod.create<ast::type::VoidType>();
|
||||||
|
|
||||||
auto e = p->function_type_decl();
|
auto e = p->function_type_decl();
|
||||||
EXPECT_TRUE(e.matched);
|
EXPECT_TRUE(e.matched);
|
||||||
@ -43,9 +43,8 @@ TEST_F(ParserImplTest, FunctionTypeDecl_Type) {
|
|||||||
auto p = parser("vec2<f32>");
|
auto p = parser("vec2<f32>");
|
||||||
|
|
||||||
auto& mod = p->get_module();
|
auto& mod = p->get_module();
|
||||||
auto* f32 = mod.type_mgr().Get(std::make_unique<ast::type::F32Type>());
|
auto* f32 = mod.create<ast::type::F32Type>();
|
||||||
auto* vec2 =
|
auto* vec2 = mod.create<ast::type::VectorType>(f32, 2);
|
||||||
mod.type_mgr().Get(std::make_unique<ast::type::VectorType>(f32, 2));
|
|
||||||
|
|
||||||
auto e = p->function_type_decl();
|
auto e = p->function_type_decl();
|
||||||
EXPECT_TRUE(e.matched);
|
EXPECT_TRUE(e.matched);
|
||||||
|
@ -31,7 +31,7 @@ TEST_F(ParserImplTest, ParamList_Single) {
|
|||||||
auto p = parser("a : i32");
|
auto p = parser("a : i32");
|
||||||
|
|
||||||
auto& mod = p->get_module();
|
auto& mod = p->get_module();
|
||||||
auto* i32 = mod.type_mgr().Get(std::make_unique<ast::type::I32Type>());
|
auto* i32 = mod.create<ast::type::I32Type>();
|
||||||
|
|
||||||
auto e = p->expect_param_list();
|
auto e = p->expect_param_list();
|
||||||
ASSERT_FALSE(p->has_error()) << p->error();
|
ASSERT_FALSE(p->has_error()) << p->error();
|
||||||
@ -52,10 +52,9 @@ TEST_F(ParserImplTest, ParamList_Multiple) {
|
|||||||
auto p = parser("a : i32, b: f32, c: vec2<f32>");
|
auto p = parser("a : i32, b: f32, c: vec2<f32>");
|
||||||
|
|
||||||
auto& mod = p->get_module();
|
auto& mod = p->get_module();
|
||||||
auto* i32 = mod.type_mgr().Get(std::make_unique<ast::type::I32Type>());
|
auto* i32 = mod.create<ast::type::I32Type>();
|
||||||
auto* f32 = mod.type_mgr().Get(std::make_unique<ast::type::F32Type>());
|
auto* f32 = mod.create<ast::type::F32Type>();
|
||||||
auto* vec2 =
|
auto* vec2 = mod.create<ast::type::VectorType>(f32, 2);
|
||||||
mod.type_mgr().Get(std::make_unique<ast::type::VectorType>(f32, 2));
|
|
||||||
|
|
||||||
auto e = p->expect_param_list();
|
auto e = p->expect_param_list();
|
||||||
ASSERT_FALSE(p->has_error()) << p->error();
|
ASSERT_FALSE(p->has_error()) << p->error();
|
||||||
|
@ -193,7 +193,7 @@ TEST_F(ParserImplTest, PrimaryExpression_Cast) {
|
|||||||
auto p = parser("f32(1)");
|
auto p = parser("f32(1)");
|
||||||
|
|
||||||
auto& mod = p->get_module();
|
auto& mod = p->get_module();
|
||||||
auto* f32 = mod.type_mgr().Get(std::make_unique<ast::type::F32Type>());
|
auto* f32 = mod.create<ast::type::F32Type>();
|
||||||
|
|
||||||
auto e = p->primary_expression();
|
auto e = p->primary_expression();
|
||||||
EXPECT_TRUE(e.matched);
|
EXPECT_TRUE(e.matched);
|
||||||
@ -215,7 +215,7 @@ TEST_F(ParserImplTest, PrimaryExpression_Bitcast) {
|
|||||||
auto p = parser("bitcast<f32>(1)");
|
auto p = parser("bitcast<f32>(1)");
|
||||||
|
|
||||||
auto& mod = p->get_module();
|
auto& mod = p->get_module();
|
||||||
auto* f32 = mod.type_mgr().Get(std::make_unique<ast::type::F32Type>());
|
auto* f32 = mod.create<ast::type::F32Type>();
|
||||||
|
|
||||||
auto e = p->primary_expression();
|
auto e = p->primary_expression();
|
||||||
EXPECT_TRUE(e.matched);
|
EXPECT_TRUE(e.matched);
|
||||||
|
@ -26,7 +26,7 @@ TEST_F(ParserImplTest, StructBodyDecl_Parses) {
|
|||||||
auto p = parser("{a : i32;}");
|
auto p = parser("{a : i32;}");
|
||||||
|
|
||||||
auto& mod = p->get_module();
|
auto& mod = p->get_module();
|
||||||
auto* i32 = mod.type_mgr().Get(std::make_unique<ast::type::I32Type>());
|
auto* i32 = mod.create<ast::type::I32Type>();
|
||||||
|
|
||||||
auto m = p->expect_struct_body_decl();
|
auto m = p->expect_struct_body_decl();
|
||||||
ASSERT_FALSE(p->has_error());
|
ASSERT_FALSE(p->has_error());
|
||||||
|
@ -27,7 +27,7 @@ TEST_F(ParserImplTest, StructMember_Parses) {
|
|||||||
auto p = parser("a : i32;");
|
auto p = parser("a : i32;");
|
||||||
|
|
||||||
auto& mod = p->get_module();
|
auto& mod = p->get_module();
|
||||||
auto* i32 = mod.type_mgr().Get(std::make_unique<ast::type::I32Type>());
|
auto* i32 = mod.create<ast::type::I32Type>();
|
||||||
|
|
||||||
auto decos = p->decoration_list();
|
auto decos = p->decoration_list();
|
||||||
EXPECT_FALSE(decos.errored);
|
EXPECT_FALSE(decos.errored);
|
||||||
@ -53,7 +53,7 @@ TEST_F(ParserImplTest, StructMember_ParsesWithDecoration) {
|
|||||||
auto p = parser("[[offset(2)]] a : i32;");
|
auto p = parser("[[offset(2)]] a : i32;");
|
||||||
|
|
||||||
auto& mod = p->get_module();
|
auto& mod = p->get_module();
|
||||||
auto* i32 = mod.type_mgr().Get(std::make_unique<ast::type::I32Type>());
|
auto* i32 = mod.create<ast::type::I32Type>();
|
||||||
|
|
||||||
auto decos = p->decoration_list();
|
auto decos = p->decoration_list();
|
||||||
EXPECT_FALSE(decos.errored);
|
EXPECT_FALSE(decos.errored);
|
||||||
@ -82,7 +82,7 @@ TEST_F(ParserImplTest, StructMember_ParsesWithMultipleDecorations) {
|
|||||||
[[offset(4)]] a : i32;)");
|
[[offset(4)]] a : i32;)");
|
||||||
|
|
||||||
auto& mod = p->get_module();
|
auto& mod = p->get_module();
|
||||||
auto* i32 = mod.type_mgr().Get(std::make_unique<ast::type::I32Type>());
|
auto* i32 = mod.create<ast::type::I32Type>();
|
||||||
|
|
||||||
auto decos = p->decoration_list();
|
auto decos = p->decoration_list();
|
||||||
EXPECT_FALSE(decos.errored);
|
EXPECT_FALSE(decos.errored);
|
||||||
|
@ -29,7 +29,7 @@ TEST_F(ParserImplTest, TypeDecl_ParsesType) {
|
|||||||
auto p = parser("type a = i32");
|
auto p = parser("type a = i32");
|
||||||
|
|
||||||
auto& mod = p->get_module();
|
auto& mod = p->get_module();
|
||||||
auto* i32 = mod.type_mgr().Get(std::make_unique<ast::type::I32Type>());
|
auto* i32 = mod.create<ast::type::I32Type>();
|
||||||
|
|
||||||
auto t = p->type_alias();
|
auto t = p->type_alias();
|
||||||
EXPECT_FALSE(p->has_error());
|
EXPECT_FALSE(p->has_error());
|
||||||
|
@ -48,9 +48,8 @@ TEST_F(ParserImplTest, TypeDecl_Identifier) {
|
|||||||
|
|
||||||
auto& mod = p->get_module();
|
auto& mod = p->get_module();
|
||||||
|
|
||||||
auto* int_type = mod.type_mgr().Get(std::make_unique<ast::type::I32Type>());
|
auto* int_type = mod.create<ast::type::I32Type>();
|
||||||
auto* alias_type =
|
auto* alias_type = mod.create<ast::type::AliasType>("A", int_type);
|
||||||
mod.type_mgr().Get(std::make_unique<ast::type::AliasType>("A", int_type));
|
|
||||||
|
|
||||||
p->register_constructed("A", alias_type);
|
p->register_constructed("A", alias_type);
|
||||||
|
|
||||||
@ -81,7 +80,7 @@ TEST_F(ParserImplTest, TypeDecl_Bool) {
|
|||||||
auto p = parser("bool");
|
auto p = parser("bool");
|
||||||
|
|
||||||
auto& mod = p->get_module();
|
auto& mod = p->get_module();
|
||||||
auto* bool_type = mod.type_mgr().Get(std::make_unique<ast::type::BoolType>());
|
auto* bool_type = mod.create<ast::type::BoolType>();
|
||||||
|
|
||||||
auto t = p->type_decl();
|
auto t = p->type_decl();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
@ -95,7 +94,7 @@ TEST_F(ParserImplTest, TypeDecl_F32) {
|
|||||||
auto p = parser("f32");
|
auto p = parser("f32");
|
||||||
|
|
||||||
auto& mod = p->get_module();
|
auto& mod = p->get_module();
|
||||||
auto* float_type = mod.type_mgr().Get(std::make_unique<ast::type::F32Type>());
|
auto* float_type = mod.create<ast::type::F32Type>();
|
||||||
|
|
||||||
auto t = p->type_decl();
|
auto t = p->type_decl();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
@ -109,7 +108,7 @@ TEST_F(ParserImplTest, TypeDecl_I32) {
|
|||||||
auto p = parser("i32");
|
auto p = parser("i32");
|
||||||
|
|
||||||
auto& mod = p->get_module();
|
auto& mod = p->get_module();
|
||||||
auto* int_type = mod.type_mgr().Get(std::make_unique<ast::type::I32Type>());
|
auto* int_type = mod.create<ast::type::I32Type>();
|
||||||
|
|
||||||
auto t = p->type_decl();
|
auto t = p->type_decl();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
@ -123,7 +122,7 @@ TEST_F(ParserImplTest, TypeDecl_U32) {
|
|||||||
auto p = parser("u32");
|
auto p = parser("u32");
|
||||||
|
|
||||||
auto& mod = p->get_module();
|
auto& mod = p->get_module();
|
||||||
auto* uint_type = mod.type_mgr().Get(std::make_unique<ast::type::U32Type>());
|
auto* uint_type = mod.create<ast::type::U32Type>();
|
||||||
|
|
||||||
auto t = p->type_decl();
|
auto t = p->type_decl();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
@ -740,8 +739,8 @@ TEST_F(ParserImplTest, TypeDecl_Sampler) {
|
|||||||
auto p = parser("sampler");
|
auto p = parser("sampler");
|
||||||
|
|
||||||
auto& mod = p->get_module();
|
auto& mod = p->get_module();
|
||||||
auto* type = mod.type_mgr().Get(std::make_unique<ast::type::SamplerType>(
|
auto* type =
|
||||||
ast::type::SamplerKind::kSampler));
|
mod.create<ast::type::SamplerType>(ast::type::SamplerKind::kSampler);
|
||||||
|
|
||||||
auto t = p->type_decl();
|
auto t = p->type_decl();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
@ -757,9 +756,8 @@ TEST_F(ParserImplTest, TypeDecl_Texture_Old) {
|
|||||||
|
|
||||||
auto& mod = p->get_module();
|
auto& mod = p->get_module();
|
||||||
ast::type::F32Type f32;
|
ast::type::F32Type f32;
|
||||||
auto* type =
|
auto* type = mod.create<ast::type::SampledTextureType>(
|
||||||
mod.type_mgr().Get(std::make_unique<ast::type::SampledTextureType>(
|
ast::type::TextureDimension::kCube, &f32);
|
||||||
ast::type::TextureDimension::kCube, &f32));
|
|
||||||
|
|
||||||
auto t = p->type_decl();
|
auto t = p->type_decl();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
@ -776,9 +774,8 @@ TEST_F(ParserImplTest, TypeDecl_Texture) {
|
|||||||
|
|
||||||
ast::type::F32Type f32;
|
ast::type::F32Type f32;
|
||||||
auto& mod = p->get_module();
|
auto& mod = p->get_module();
|
||||||
auto* type =
|
auto* type = mod.create<ast::type::SampledTextureType>(
|
||||||
mod.type_mgr().Get(std::make_unique<ast::type::SampledTextureType>(
|
ast::type::TextureDimension::kCube, &f32);
|
||||||
ast::type::TextureDimension::kCube, &f32));
|
|
||||||
|
|
||||||
auto t = p->type_decl();
|
auto t = p->type_decl();
|
||||||
EXPECT_TRUE(t.matched);
|
EXPECT_TRUE(t.matched);
|
||||||
|
@ -237,7 +237,7 @@ bool BoundArrayAccessorsTransform::ProcessAccessExpression(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
auto* u32 = mod_->type_mgr().Get(std::make_unique<ast::type::U32Type>());
|
auto* u32 = mod_->create<ast::type::U32Type>();
|
||||||
|
|
||||||
ast::ExpressionList cast_expr;
|
ast::ExpressionList cast_expr;
|
||||||
cast_expr.push_back(expr->idx_expr());
|
cast_expr.push_back(expr->idx_expr());
|
||||||
|
@ -222,7 +222,7 @@ void VertexPullingTransform::AddVertexStorageBuffers() {
|
|||||||
ary_decos.push_back(create<ast::StrideDecoration>(4u, Source{}));
|
ary_decos.push_back(create<ast::StrideDecoration>(4u, Source{}));
|
||||||
internal_array->set_decorations(std::move(ary_decos));
|
internal_array->set_decorations(std::move(ary_decos));
|
||||||
|
|
||||||
auto* internal_array_type = mod_->type_mgr().Get(std::move(internal_array));
|
auto* internal_array_type = mod_->unique_type(std::move(internal_array));
|
||||||
|
|
||||||
// Creating the struct type
|
// Creating the struct type
|
||||||
ast::StructMemberList members;
|
ast::StructMemberList members;
|
||||||
@ -235,10 +235,8 @@ void VertexPullingTransform::AddVertexStorageBuffers() {
|
|||||||
ast::StructDecorationList decos;
|
ast::StructDecorationList decos;
|
||||||
decos.push_back(create<ast::StructBlockDecoration>(Source{}));
|
decos.push_back(create<ast::StructBlockDecoration>(Source{}));
|
||||||
|
|
||||||
auto* struct_type =
|
auto* struct_type = mod_->create<ast::type::StructType>(
|
||||||
mod_->type_mgr().Get(std::make_unique<ast::type::StructType>(
|
kStructName, create<ast::Struct>(std::move(decos), std::move(members)));
|
||||||
kStructName,
|
|
||||||
create<ast::Struct>(std::move(decos), std::move(members))));
|
|
||||||
|
|
||||||
for (uint32_t i = 0; i < vertex_state_->vertex_buffers.size(); ++i) {
|
for (uint32_t i = 0; i < vertex_state_->vertex_buffers.size(); ++i) {
|
||||||
// The decorated variable with struct type
|
// The decorated variable with struct type
|
||||||
@ -411,21 +409,20 @@ ast::Expression* VertexPullingTransform::AccessVec(uint32_t buffer,
|
|||||||
}
|
}
|
||||||
|
|
||||||
return create<ast::TypeConstructorExpression>(
|
return create<ast::TypeConstructorExpression>(
|
||||||
mod_->type_mgr().Get(
|
mod_->create<ast::type::VectorType>(base_type, count),
|
||||||
std::make_unique<ast::type::VectorType>(base_type, count)),
|
|
||||||
std::move(expr_list));
|
std::move(expr_list));
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::type::Type* VertexPullingTransform::GetU32Type() {
|
ast::type::Type* VertexPullingTransform::GetU32Type() {
|
||||||
return mod_->type_mgr().Get(std::make_unique<ast::type::U32Type>());
|
return mod_->create<ast::type::U32Type>();
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::type::Type* VertexPullingTransform::GetI32Type() {
|
ast::type::Type* VertexPullingTransform::GetI32Type() {
|
||||||
return mod_->type_mgr().Get(std::make_unique<ast::type::I32Type>());
|
return mod_->create<ast::type::I32Type>();
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::type::Type* VertexPullingTransform::GetF32Type() {
|
ast::type::Type* VertexPullingTransform::GetF32Type() {
|
||||||
return mod_->type_mgr().Get(std::make_unique<ast::type::F32Type>());
|
return mod_->create<ast::type::F32Type>();
|
||||||
}
|
}
|
||||||
|
|
||||||
VertexBufferLayoutDescriptor::VertexBufferLayoutDescriptor() = default;
|
VertexBufferLayoutDescriptor::VertexBufferLayoutDescriptor() = default;
|
||||||
|
@ -46,10 +46,9 @@ class VertexPullingTransformHelper {
|
|||||||
|
|
||||||
// Create basic module with an entry point and vertex function
|
// Create basic module with an entry point and vertex function
|
||||||
void InitBasicModule() {
|
void InitBasicModule() {
|
||||||
auto* func = create<ast::Function>(
|
auto* func = create<ast::Function>("main", ast::VariableList{},
|
||||||
"main", ast::VariableList{},
|
mod_->create<ast::type::VoidType>(),
|
||||||
mod_->type_mgr().Get(std::make_unique<ast::type::VoidType>()),
|
create<ast::BlockStatement>());
|
||||||
create<ast::BlockStatement>());
|
|
||||||
func->add_decoration(
|
func->add_decoration(
|
||||||
create<ast::StageDecoration>(ast::PipelineStage::kVertex, Source{}));
|
create<ast::StageDecoration>(ast::PipelineStage::kVertex, Source{}));
|
||||||
mod()->AddFunction(func);
|
mod()->AddFunction(func);
|
||||||
@ -125,10 +124,9 @@ TEST_F(VertexPullingTransformTest, Error_InvalidEntryPoint) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(VertexPullingTransformTest, Error_EntryPointWrongStage) {
|
TEST_F(VertexPullingTransformTest, Error_EntryPointWrongStage) {
|
||||||
auto* func = create<ast::Function>(
|
auto* func = create<ast::Function>("main", ast::VariableList{},
|
||||||
"main", ast::VariableList{},
|
mod()->create<ast::type::VoidType>(),
|
||||||
mod()->type_mgr().Get(std::make_unique<ast::type::VoidType>()),
|
create<ast::BlockStatement>());
|
||||||
create<ast::BlockStatement>());
|
|
||||||
func->add_decoration(
|
func->add_decoration(
|
||||||
create<ast::StageDecoration>(ast::PipelineStage::kFragment, Source{}));
|
create<ast::StageDecoration>(ast::PipelineStage::kFragment, Source{}));
|
||||||
mod()->AddFunction(func);
|
mod()->AddFunction(func);
|
||||||
|
@ -83,7 +83,7 @@ void TypeDeterminer::set_referenced_from_function_if_needed(
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool TypeDeterminer::Determine() {
|
bool TypeDeterminer::Determine() {
|
||||||
for (auto& iter : mod_->type_mgr().types()) {
|
for (auto& iter : mod_->types()) {
|
||||||
auto& type = iter.second;
|
auto& type = iter.second;
|
||||||
if (!type->IsTexture() || !type->AsTexture()->IsStorage()) {
|
if (!type->IsTexture() || !type->AsTexture()->IsStorage()) {
|
||||||
continue;
|
continue;
|
||||||
@ -339,8 +339,7 @@ bool TypeDeterminer::DetermineArrayAccessor(
|
|||||||
ret = parent_type->AsVector()->type();
|
ret = parent_type->AsVector()->type();
|
||||||
} else if (parent_type->IsMatrix()) {
|
} else if (parent_type->IsMatrix()) {
|
||||||
auto* m = parent_type->AsMatrix();
|
auto* m = parent_type->AsMatrix();
|
||||||
ret = mod_->type_mgr().Get(
|
ret = mod_->create<ast::type::VectorType>(m->type(), m->rows());
|
||||||
std::make_unique<ast::type::VectorType>(m->type(), m->rows()));
|
|
||||||
} else {
|
} else {
|
||||||
set_error(expr->source(), "invalid parent type (" +
|
set_error(expr->source(), "invalid parent type (" +
|
||||||
parent_type->type_name() +
|
parent_type->type_name() +
|
||||||
@ -350,15 +349,15 @@ bool TypeDeterminer::DetermineArrayAccessor(
|
|||||||
|
|
||||||
// If we're extracting from a pointer, we return a pointer.
|
// If we're extracting from a pointer, we return a pointer.
|
||||||
if (res->IsPointer()) {
|
if (res->IsPointer()) {
|
||||||
ret = mod_->type_mgr().Get(std::make_unique<ast::type::PointerType>(
|
ret = mod_->create<ast::type::PointerType>(
|
||||||
ret, res->AsPointer()->storage_class()));
|
ret, res->AsPointer()->storage_class());
|
||||||
} else if (parent_type->IsArray() &&
|
} else if (parent_type->IsArray() &&
|
||||||
!parent_type->AsArray()->type()->is_scalar()) {
|
!parent_type->AsArray()->type()->is_scalar()) {
|
||||||
// If we extract a non-scalar from an array then we also get a pointer. We
|
// If we extract a non-scalar from an array then we also get a pointer. We
|
||||||
// will generate a Function storage class variable to store this
|
// will generate a Function storage class variable to store this
|
||||||
// into.
|
// into.
|
||||||
ret = mod_->type_mgr().Get(std::make_unique<ast::type::PointerType>(
|
ret =
|
||||||
ret, ast::StorageClass::kFunction));
|
mod_->create<ast::type::PointerType>(ret, ast::StorageClass::kFunction);
|
||||||
}
|
}
|
||||||
expr->set_result_type(ret);
|
expr->set_result_type(ret);
|
||||||
|
|
||||||
@ -522,13 +521,11 @@ bool TypeDeterminer::DetermineIntrinsic(ast::IdentifierExpression* ident,
|
|||||||
}
|
}
|
||||||
if (ident->intrinsic() == ast::Intrinsic::kAny ||
|
if (ident->intrinsic() == ast::Intrinsic::kAny ||
|
||||||
ident->intrinsic() == ast::Intrinsic::kAll) {
|
ident->intrinsic() == ast::Intrinsic::kAll) {
|
||||||
expr->func()->set_result_type(
|
expr->func()->set_result_type(mod_->create<ast::type::BoolType>());
|
||||||
mod_->type_mgr().Get(std::make_unique<ast::type::BoolType>()));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (ident->intrinsic() == ast::Intrinsic::kArrayLength) {
|
if (ident->intrinsic() == ast::Intrinsic::kArrayLength) {
|
||||||
expr->func()->set_result_type(
|
expr->func()->set_result_type(mod_->create<ast::type::U32Type>());
|
||||||
mod_->type_mgr().Get(std::make_unique<ast::type::U32Type>()));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (ast::intrinsic::IsFloatClassificationIntrinsic(ident->intrinsic())) {
|
if (ast::intrinsic::IsFloatClassificationIntrinsic(ident->intrinsic())) {
|
||||||
@ -538,14 +535,12 @@ bool TypeDeterminer::DetermineIntrinsic(ast::IdentifierExpression* ident,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* bool_type =
|
auto* bool_type = mod_->create<ast::type::BoolType>();
|
||||||
mod_->type_mgr().Get(std::make_unique<ast::type::BoolType>());
|
|
||||||
|
|
||||||
auto* param_type = expr->params()[0]->result_type()->UnwrapPtrIfNeeded();
|
auto* param_type = expr->params()[0]->result_type()->UnwrapPtrIfNeeded();
|
||||||
if (param_type->IsVector()) {
|
if (param_type->IsVector()) {
|
||||||
expr->func()->set_result_type(
|
expr->func()->set_result_type(mod_->create<ast::type::VectorType>(
|
||||||
mod_->type_mgr().Get(std::make_unique<ast::type::VectorType>(
|
bool_type, param_type->AsVector()->size()));
|
||||||
bool_type, param_type->AsVector()->size())));
|
|
||||||
} else {
|
} else {
|
||||||
expr->func()->set_result_type(bool_type);
|
expr->func()->set_result_type(bool_type);
|
||||||
}
|
}
|
||||||
@ -666,8 +661,7 @@ bool TypeDeterminer::DetermineIntrinsic(ast::IdentifierExpression* ident,
|
|||||||
std::make_unique<ast::intrinsic::TextureSignature>(param));
|
std::make_unique<ast::intrinsic::TextureSignature>(param));
|
||||||
|
|
||||||
if (texture->IsDepth()) {
|
if (texture->IsDepth()) {
|
||||||
expr->func()->set_result_type(
|
expr->func()->set_result_type(mod_->create<ast::type::F32Type>());
|
||||||
mod_->type_mgr().Get(std::make_unique<ast::type::F32Type>()));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -688,13 +682,11 @@ bool TypeDeterminer::DetermineIntrinsic(ast::IdentifierExpression* ident,
|
|||||||
set_error(expr->source(), "unknown texture type for texture sampling");
|
set_error(expr->source(), "unknown texture type for texture sampling");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
expr->func()->set_result_type(
|
expr->func()->set_result_type(mod_->create<ast::type::VectorType>(type, 4));
|
||||||
mod_->type_mgr().Get(std::make_unique<ast::type::VectorType>(type, 4)));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (ident->intrinsic() == ast::Intrinsic::kDot) {
|
if (ident->intrinsic() == ast::Intrinsic::kDot) {
|
||||||
expr->func()->set_result_type(
|
expr->func()->set_result_type(mod_->create<ast::type::F32Type>());
|
||||||
mod_->type_mgr().Get(std::make_unique<ast::type::F32Type>()));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (ident->intrinsic() == ast::Intrinsic::kOuterProduct) {
|
if (ident->intrinsic() == ast::Intrinsic::kOuterProduct) {
|
||||||
@ -711,10 +703,9 @@ bool TypeDeterminer::DetermineIntrinsic(ast::IdentifierExpression* ident,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
expr->func()->set_result_type(
|
expr->func()->set_result_type(mod_->create<ast::type::MatrixType>(
|
||||||
mod_->type_mgr().Get(std::make_unique<ast::type::MatrixType>(
|
mod_->create<ast::type::F32Type>(), param0_type->AsVector()->size(),
|
||||||
mod_->type_mgr().Get(std::make_unique<ast::type::F32Type>()),
|
param1_type->AsVector()->size()));
|
||||||
param0_type->AsVector()->size(), param1_type->AsVector()->size())));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (ident->intrinsic() == ast::Intrinsic::kSelect) {
|
if (ident->intrinsic() == ast::Intrinsic::kSelect) {
|
||||||
@ -861,9 +852,8 @@ bool TypeDeterminer::DetermineIdentifier(ast::IdentifierExpression* expr) {
|
|||||||
} else if (var->type()->IsPointer()) {
|
} else if (var->type()->IsPointer()) {
|
||||||
expr->set_result_type(var->type());
|
expr->set_result_type(var->type());
|
||||||
} else {
|
} else {
|
||||||
expr->set_result_type(
|
expr->set_result_type(mod_->create<ast::type::PointerType>(
|
||||||
mod_->type_mgr().Get(std::make_unique<ast::type::PointerType>(
|
var->type(), var->storage_class()));
|
||||||
var->type(), var->storage_class())));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
set_referenced_from_function_if_needed(var);
|
set_referenced_from_function_if_needed(var);
|
||||||
@ -1055,8 +1045,8 @@ bool TypeDeterminer::DetermineMemberAccessor(
|
|||||||
|
|
||||||
// If we're extracting from a pointer, we return a pointer.
|
// If we're extracting from a pointer, we return a pointer.
|
||||||
if (res->IsPointer()) {
|
if (res->IsPointer()) {
|
||||||
ret = mod_->type_mgr().Get(std::make_unique<ast::type::PointerType>(
|
ret = mod_->create<ast::type::PointerType>(
|
||||||
ret, res->AsPointer()->storage_class()));
|
ret, res->AsPointer()->storage_class());
|
||||||
}
|
}
|
||||||
} else if (data_type->IsVector()) {
|
} else if (data_type->IsVector()) {
|
||||||
auto* vec = data_type->AsVector();
|
auto* vec = data_type->AsVector();
|
||||||
@ -1067,15 +1057,14 @@ bool TypeDeterminer::DetermineMemberAccessor(
|
|||||||
ret = vec->type();
|
ret = vec->type();
|
||||||
// If we're extracting from a pointer, we return a pointer.
|
// If we're extracting from a pointer, we return a pointer.
|
||||||
if (res->IsPointer()) {
|
if (res->IsPointer()) {
|
||||||
ret = mod_->type_mgr().Get(std::make_unique<ast::type::PointerType>(
|
ret = mod_->create<ast::type::PointerType>(
|
||||||
ret, res->AsPointer()->storage_class()));
|
ret, res->AsPointer()->storage_class());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// The vector will have a number of components equal to the length of the
|
// The vector will have a number of components equal to the length of the
|
||||||
// swizzle. This assumes the validator will check that the swizzle
|
// swizzle. This assumes the validator will check that the swizzle
|
||||||
// is correct.
|
// is correct.
|
||||||
ret = mod_->type_mgr().Get(
|
ret = mod_->create<ast::type::VectorType>(vec->type(), size);
|
||||||
std::make_unique<ast::type::VectorType>(vec->type(), size));
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
set_error(
|
set_error(
|
||||||
@ -1106,13 +1095,11 @@ bool TypeDeterminer::DetermineBinary(ast::BinaryExpression* expr) {
|
|||||||
if (expr->IsLogicalAnd() || expr->IsLogicalOr() || expr->IsEqual() ||
|
if (expr->IsLogicalAnd() || expr->IsLogicalOr() || expr->IsEqual() ||
|
||||||
expr->IsNotEqual() || expr->IsLessThan() || expr->IsGreaterThan() ||
|
expr->IsNotEqual() || expr->IsLessThan() || expr->IsGreaterThan() ||
|
||||||
expr->IsLessThanEqual() || expr->IsGreaterThanEqual()) {
|
expr->IsLessThanEqual() || expr->IsGreaterThanEqual()) {
|
||||||
auto* bool_type =
|
auto* bool_type = mod_->create<ast::type::BoolType>();
|
||||||
mod_->type_mgr().Get(std::make_unique<ast::type::BoolType>());
|
|
||||||
auto* param_type = expr->lhs()->result_type()->UnwrapPtrIfNeeded();
|
auto* param_type = expr->lhs()->result_type()->UnwrapPtrIfNeeded();
|
||||||
if (param_type->IsVector()) {
|
if (param_type->IsVector()) {
|
||||||
expr->set_result_type(
|
expr->set_result_type(mod_->create<ast::type::VectorType>(
|
||||||
mod_->type_mgr().Get(std::make_unique<ast::type::VectorType>(
|
bool_type, param_type->AsVector()->size()));
|
||||||
bool_type, param_type->AsVector()->size())));
|
|
||||||
} else {
|
} else {
|
||||||
expr->set_result_type(bool_type);
|
expr->set_result_type(bool_type);
|
||||||
}
|
}
|
||||||
@ -1125,20 +1112,18 @@ bool TypeDeterminer::DetermineBinary(ast::BinaryExpression* expr) {
|
|||||||
// Note, the ordering here matters. The later checks depend on the prior
|
// Note, the ordering here matters. The later checks depend on the prior
|
||||||
// checks having been done.
|
// checks having been done.
|
||||||
if (lhs_type->IsMatrix() && rhs_type->IsMatrix()) {
|
if (lhs_type->IsMatrix() && rhs_type->IsMatrix()) {
|
||||||
expr->set_result_type(
|
expr->set_result_type(mod_->create<ast::type::MatrixType>(
|
||||||
mod_->type_mgr().Get(std::make_unique<ast::type::MatrixType>(
|
lhs_type->AsMatrix()->type(), lhs_type->AsMatrix()->rows(),
|
||||||
lhs_type->AsMatrix()->type(), lhs_type->AsMatrix()->rows(),
|
rhs_type->AsMatrix()->columns()));
|
||||||
rhs_type->AsMatrix()->columns())));
|
|
||||||
|
|
||||||
} else if (lhs_type->IsMatrix() && rhs_type->IsVector()) {
|
} else if (lhs_type->IsMatrix() && rhs_type->IsVector()) {
|
||||||
auto* mat = lhs_type->AsMatrix();
|
auto* mat = lhs_type->AsMatrix();
|
||||||
expr->set_result_type(mod_->type_mgr().Get(
|
expr->set_result_type(
|
||||||
std::make_unique<ast::type::VectorType>(mat->type(), mat->rows())));
|
mod_->create<ast::type::VectorType>(mat->type(), mat->rows()));
|
||||||
} else if (lhs_type->IsVector() && rhs_type->IsMatrix()) {
|
} else if (lhs_type->IsVector() && rhs_type->IsMatrix()) {
|
||||||
auto* mat = rhs_type->AsMatrix();
|
auto* mat = rhs_type->AsMatrix();
|
||||||
expr->set_result_type(
|
expr->set_result_type(
|
||||||
mod_->type_mgr().Get(std::make_unique<ast::type::VectorType>(
|
mod_->create<ast::type::VectorType>(mat->type(), mat->columns()));
|
||||||
mat->type(), mat->columns())));
|
|
||||||
} else if (lhs_type->IsMatrix()) {
|
} else if (lhs_type->IsMatrix()) {
|
||||||
// matrix * scalar
|
// matrix * scalar
|
||||||
expr->set_result_type(lhs_type);
|
expr->set_result_type(lhs_type);
|
||||||
@ -1197,8 +1182,7 @@ bool TypeDeterminer::DetermineStorageTextureSubtype(
|
|||||||
case ast::type::ImageFormat::kRg32Uint:
|
case ast::type::ImageFormat::kRg32Uint:
|
||||||
case ast::type::ImageFormat::kRgba16Uint:
|
case ast::type::ImageFormat::kRgba16Uint:
|
||||||
case ast::type::ImageFormat::kRgba32Uint: {
|
case ast::type::ImageFormat::kRgba32Uint: {
|
||||||
tex->set_type(
|
tex->set_type(mod_->create<ast::type::U32Type>());
|
||||||
mod_->type_mgr().Get(std::make_unique<ast::type::U32Type>()));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1214,8 +1198,7 @@ bool TypeDeterminer::DetermineStorageTextureSubtype(
|
|||||||
case ast::type::ImageFormat::kRg32Sint:
|
case ast::type::ImageFormat::kRg32Sint:
|
||||||
case ast::type::ImageFormat::kRgba16Sint:
|
case ast::type::ImageFormat::kRgba16Sint:
|
||||||
case ast::type::ImageFormat::kRgba32Sint: {
|
case ast::type::ImageFormat::kRgba32Sint: {
|
||||||
tex->set_type(
|
tex->set_type(mod_->create<ast::type::I32Type>());
|
||||||
mod_->type_mgr().Get(std::make_unique<ast::type::I32Type>()));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1226,8 +1209,7 @@ bool TypeDeterminer::DetermineStorageTextureSubtype(
|
|||||||
case ast::type::ImageFormat::kRg32Float:
|
case ast::type::ImageFormat::kRg32Float:
|
||||||
case ast::type::ImageFormat::kRgba16Float:
|
case ast::type::ImageFormat::kRgba16Float:
|
||||||
case ast::type::ImageFormat::kRgba32Float: {
|
case ast::type::ImageFormat::kRgba32Float: {
|
||||||
tex->set_type(
|
tex->set_type(mod_->create<ast::type::F32Type>());
|
||||||
mod_->type_mgr().Get(std::make_unique<ast::type::F32Type>()));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1786,9 +1786,8 @@ TEST_P(Intrinsic_StorageTextureOperation, TextureLoadRo) {
|
|||||||
ast::type::I32Type i32;
|
ast::type::I32Type i32;
|
||||||
auto coords_type = get_coords_type(dim, &i32);
|
auto coords_type = get_coords_type(dim, &i32);
|
||||||
|
|
||||||
ast::type::Type* texture_type =
|
ast::type::Type* texture_type = mod->create<ast::type::StorageTextureType>(
|
||||||
mod->type_mgr().Get(std::make_unique<ast::type::StorageTextureType>(
|
dim, ast::AccessControl::kReadOnly, format);
|
||||||
dim, ast::AccessControl::kReadOnly, format));
|
|
||||||
|
|
||||||
ast::ExpressionList call_params;
|
ast::ExpressionList call_params;
|
||||||
|
|
||||||
@ -4549,14 +4548,13 @@ TEST_P(TypeDeterminerTextureIntrinsicTest, Call) {
|
|||||||
switch (param.texture_kind) {
|
switch (param.texture_kind) {
|
||||||
case ast::intrinsic::test::TextureKind::kRegular:
|
case ast::intrinsic::test::TextureKind::kRegular:
|
||||||
Var("texture", ast::StorageClass::kNone,
|
Var("texture", ast::StorageClass::kNone,
|
||||||
mod->type_mgr().Get<ast::type::SampledTextureType>(
|
mod->create<ast::type::SampledTextureType>(param.texture_dimension,
|
||||||
param.texture_dimension, datatype));
|
datatype));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ast::intrinsic::test::TextureKind::kDepth:
|
case ast::intrinsic::test::TextureKind::kDepth:
|
||||||
Var("texture", ast::StorageClass::kNone,
|
Var("texture", ast::StorageClass::kNone,
|
||||||
mod->type_mgr().Get<ast::type::DepthTextureType>(
|
mod->create<ast::type::DepthTextureType>(param.texture_dimension));
|
||||||
param.texture_dimension));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,14 +183,13 @@ TEST_P(HlslGeneratorIntrinsicTextureTest, Call) {
|
|||||||
switch (param.texture_kind) {
|
switch (param.texture_kind) {
|
||||||
case ast::intrinsic::test::TextureKind::kRegular:
|
case ast::intrinsic::test::TextureKind::kRegular:
|
||||||
Var("texture", ast::StorageClass::kNone,
|
Var("texture", ast::StorageClass::kNone,
|
||||||
mod->type_mgr().Get<ast::type::SampledTextureType>(
|
mod->create<ast::type::SampledTextureType>(param.texture_dimension,
|
||||||
param.texture_dimension, datatype));
|
datatype));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ast::intrinsic::test::TextureKind::kDepth:
|
case ast::intrinsic::test::TextureKind::kDepth:
|
||||||
Var("texture", ast::StorageClass::kNone,
|
Var("texture", ast::StorageClass::kNone,
|
||||||
mod->type_mgr().Get<ast::type::DepthTextureType>(
|
mod->create<ast::type::DepthTextureType>(param.texture_dimension));
|
||||||
param.texture_dimension));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1618,14 +1618,14 @@ TEST_P(IntrinsicTextureTest, Call) {
|
|||||||
switch (param.texture_kind) {
|
switch (param.texture_kind) {
|
||||||
case ast::intrinsic::test::TextureKind::kRegular:
|
case ast::intrinsic::test::TextureKind::kRegular:
|
||||||
tex = Var("texture", ast::StorageClass::kNone,
|
tex = Var("texture", ast::StorageClass::kNone,
|
||||||
mod->type_mgr().Get<ast::type::SampledTextureType>(
|
mod->create<ast::type::SampledTextureType>(
|
||||||
param.texture_dimension, datatype));
|
param.texture_dimension, datatype));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ast::intrinsic::test::TextureKind::kDepth:
|
case ast::intrinsic::test::TextureKind::kDepth:
|
||||||
tex = Var("texture", ast::StorageClass::kNone,
|
tex = Var(
|
||||||
mod->type_mgr().Get<ast::type::DepthTextureType>(
|
"texture", ast::StorageClass::kNone,
|
||||||
param.texture_dimension));
|
mod->create<ast::type::DepthTextureType>(param.texture_dimension));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user