mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-16 00:17:03 +00:00
Move all classes from namespace type to namespace sem
Bug: tint:724 Change-Id: I4eeabab9b00b6b28f61645bd95d326fb48609bf0 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48362 Reviewed-by: Ben Clayton <bclayton@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Antonio Maiorano <amaiorano@google.com>
This commit is contained in:
committed by
Commit Bot service account
parent
3aa226138e
commit
3751fd2290
@@ -100,83 +100,83 @@ ast::Builtin EnumConverter::ToBuiltin(SpvBuiltIn b) {
|
||||
return ast::Builtin::kNone;
|
||||
}
|
||||
|
||||
type::TextureDimension EnumConverter::ToDim(SpvDim dim, bool arrayed) {
|
||||
sem::TextureDimension EnumConverter::ToDim(SpvDim dim, bool arrayed) {
|
||||
if (arrayed) {
|
||||
switch (dim) {
|
||||
case SpvDim2D:
|
||||
return type::TextureDimension::k2dArray;
|
||||
return sem::TextureDimension::k2dArray;
|
||||
case SpvDimCube:
|
||||
return type::TextureDimension::kCubeArray;
|
||||
return sem::TextureDimension::kCubeArray;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
Fail() << "arrayed dimension must be 1D, 2D, or Cube. Got " << int(dim);
|
||||
return type::TextureDimension::kNone;
|
||||
return sem::TextureDimension::kNone;
|
||||
}
|
||||
// Assume non-arrayed
|
||||
switch (dim) {
|
||||
case SpvDim1D:
|
||||
return type::TextureDimension::k1d;
|
||||
return sem::TextureDimension::k1d;
|
||||
case SpvDim2D:
|
||||
return type::TextureDimension::k2d;
|
||||
return sem::TextureDimension::k2d;
|
||||
case SpvDim3D:
|
||||
return type::TextureDimension::k3d;
|
||||
return sem::TextureDimension::k3d;
|
||||
case SpvDimCube:
|
||||
return type::TextureDimension::kCube;
|
||||
return sem::TextureDimension::kCube;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
Fail() << "invalid dimension: " << int(dim);
|
||||
return type::TextureDimension::kNone;
|
||||
return sem::TextureDimension::kNone;
|
||||
}
|
||||
|
||||
type::ImageFormat EnumConverter::ToImageFormat(SpvImageFormat fmt) {
|
||||
sem::ImageFormat EnumConverter::ToImageFormat(SpvImageFormat fmt) {
|
||||
switch (fmt) {
|
||||
case SpvImageFormatUnknown:
|
||||
return type::ImageFormat::kNone;
|
||||
return sem::ImageFormat::kNone;
|
||||
|
||||
// 8 bit channels
|
||||
case SpvImageFormatRgba8:
|
||||
return type::ImageFormat::kRgba8Unorm;
|
||||
return sem::ImageFormat::kRgba8Unorm;
|
||||
case SpvImageFormatRgba8Snorm:
|
||||
return type::ImageFormat::kRgba8Snorm;
|
||||
return sem::ImageFormat::kRgba8Snorm;
|
||||
case SpvImageFormatRgba8ui:
|
||||
return type::ImageFormat::kRgba8Uint;
|
||||
return sem::ImageFormat::kRgba8Uint;
|
||||
case SpvImageFormatRgba8i:
|
||||
return type::ImageFormat::kRgba8Sint;
|
||||
return sem::ImageFormat::kRgba8Sint;
|
||||
|
||||
// 16 bit channels
|
||||
case SpvImageFormatRgba16ui:
|
||||
return type::ImageFormat::kRgba16Uint;
|
||||
return sem::ImageFormat::kRgba16Uint;
|
||||
case SpvImageFormatRgba16i:
|
||||
return type::ImageFormat::kRgba16Sint;
|
||||
return sem::ImageFormat::kRgba16Sint;
|
||||
case SpvImageFormatRgba16f:
|
||||
return type::ImageFormat::kRgba16Float;
|
||||
return sem::ImageFormat::kRgba16Float;
|
||||
|
||||
// 32 bit channels
|
||||
case SpvImageFormatR32ui:
|
||||
return type::ImageFormat::kR32Uint;
|
||||
return sem::ImageFormat::kR32Uint;
|
||||
case SpvImageFormatR32i:
|
||||
return type::ImageFormat::kR32Sint;
|
||||
return sem::ImageFormat::kR32Sint;
|
||||
case SpvImageFormatR32f:
|
||||
return type::ImageFormat::kR32Float;
|
||||
return sem::ImageFormat::kR32Float;
|
||||
case SpvImageFormatRg32ui:
|
||||
return type::ImageFormat::kRg32Uint;
|
||||
return sem::ImageFormat::kRg32Uint;
|
||||
case SpvImageFormatRg32i:
|
||||
return type::ImageFormat::kRg32Sint;
|
||||
return sem::ImageFormat::kRg32Sint;
|
||||
case SpvImageFormatRg32f:
|
||||
return type::ImageFormat::kRg32Float;
|
||||
return sem::ImageFormat::kRg32Float;
|
||||
case SpvImageFormatRgba32ui:
|
||||
return type::ImageFormat::kRgba32Uint;
|
||||
return sem::ImageFormat::kRgba32Uint;
|
||||
case SpvImageFormatRgba32i:
|
||||
return type::ImageFormat::kRgba32Sint;
|
||||
return sem::ImageFormat::kRgba32Sint;
|
||||
case SpvImageFormatRgba32f:
|
||||
return type::ImageFormat::kRgba32Float;
|
||||
return sem::ImageFormat::kRgba32Float;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
Fail() << "invalid image format: " << int(fmt);
|
||||
return type::ImageFormat::kNone;
|
||||
return sem::ImageFormat::kNone;
|
||||
}
|
||||
|
||||
} // namespace spirv
|
||||
|
||||
@@ -58,13 +58,13 @@ class EnumConverter {
|
||||
/// @param dim the SPIR-V Dim value
|
||||
/// @param arrayed true if the texture is arrayed
|
||||
/// @returns a Tint AST texture dimension
|
||||
type::TextureDimension ToDim(SpvDim dim, bool arrayed);
|
||||
sem::TextureDimension ToDim(SpvDim dim, bool arrayed);
|
||||
|
||||
/// Converts a SPIR-V Image Format to a Tint ImageFormat
|
||||
/// On failure, logs an error and returns kNone
|
||||
/// @param fmt the SPIR-V format
|
||||
/// @returns a Tint AST format
|
||||
type::ImageFormat ToImageFormat(SpvImageFormat fmt);
|
||||
sem::ImageFormat ToImageFormat(SpvImageFormat fmt);
|
||||
|
||||
private:
|
||||
/// Registers a failure and returns a stream for log diagnostics.
|
||||
|
||||
@@ -243,7 +243,7 @@ struct DimCase {
|
||||
SpvDim dim;
|
||||
bool arrayed;
|
||||
bool expect_success;
|
||||
type::TextureDimension expected;
|
||||
sem::TextureDimension expected;
|
||||
};
|
||||
inline std::ostream& operator<<(std::ostream& out, DimCase dc) {
|
||||
out << "DimCase{ SpvDim:" << int(dc.dim) << " arrayed?:" << int(dc.arrayed)
|
||||
@@ -287,38 +287,37 @@ INSTANTIATE_TEST_SUITE_P(
|
||||
SpvDimTest,
|
||||
testing::Values(
|
||||
// Non-arrayed
|
||||
DimCase{SpvDim1D, false, true, type::TextureDimension::k1d},
|
||||
DimCase{SpvDim2D, false, true, type::TextureDimension::k2d},
|
||||
DimCase{SpvDim3D, false, true, type::TextureDimension::k3d},
|
||||
DimCase{SpvDimCube, false, true, type::TextureDimension::kCube},
|
||||
DimCase{SpvDim1D, false, true, sem::TextureDimension::k1d},
|
||||
DimCase{SpvDim2D, false, true, sem::TextureDimension::k2d},
|
||||
DimCase{SpvDim3D, false, true, sem::TextureDimension::k3d},
|
||||
DimCase{SpvDimCube, false, true, sem::TextureDimension::kCube},
|
||||
// Arrayed
|
||||
DimCase{SpvDim2D, true, true, type::TextureDimension::k2dArray},
|
||||
DimCase{SpvDimCube, true, true, type::TextureDimension::kCubeArray}));
|
||||
DimCase{SpvDim2D, true, true, sem::TextureDimension::k2dArray},
|
||||
DimCase{SpvDimCube, true, true, sem::TextureDimension::kCubeArray}));
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
EnumConverterBad,
|
||||
SpvDimTest,
|
||||
testing::Values(
|
||||
// Invalid SPIR-V dimensionality.
|
||||
DimCase{SpvDimMax, false, false, type::TextureDimension::kNone},
|
||||
DimCase{SpvDimMax, true, false, type::TextureDimension::kNone},
|
||||
DimCase{SpvDimMax, false, false, sem::TextureDimension::kNone},
|
||||
DimCase{SpvDimMax, true, false, sem::TextureDimension::kNone},
|
||||
// Vulkan non-arrayed dimensionalities not supported by WGSL.
|
||||
DimCase{SpvDimRect, false, false, type::TextureDimension::kNone},
|
||||
DimCase{SpvDimBuffer, false, false, type::TextureDimension::kNone},
|
||||
DimCase{SpvDimSubpassData, false, false, type::TextureDimension::kNone},
|
||||
DimCase{SpvDimRect, false, false, sem::TextureDimension::kNone},
|
||||
DimCase{SpvDimBuffer, false, false, sem::TextureDimension::kNone},
|
||||
DimCase{SpvDimSubpassData, false, false, sem::TextureDimension::kNone},
|
||||
// Arrayed dimensionalities not supported by WGSL
|
||||
DimCase{SpvDim3D, true, false, type::TextureDimension::kNone},
|
||||
DimCase{SpvDimRect, true, false, type::TextureDimension::kNone},
|
||||
DimCase{SpvDimBuffer, true, false, type::TextureDimension::kNone},
|
||||
DimCase{SpvDimSubpassData, true, false,
|
||||
type::TextureDimension::kNone}));
|
||||
DimCase{SpvDim3D, true, false, sem::TextureDimension::kNone},
|
||||
DimCase{SpvDimRect, true, false, sem::TextureDimension::kNone},
|
||||
DimCase{SpvDimBuffer, true, false, sem::TextureDimension::kNone},
|
||||
DimCase{SpvDimSubpassData, true, false, sem::TextureDimension::kNone}));
|
||||
|
||||
// ImageFormat
|
||||
|
||||
struct ImageFormatCase {
|
||||
SpvImageFormat format;
|
||||
bool expect_success;
|
||||
type::ImageFormat expected;
|
||||
sem::ImageFormat expected;
|
||||
};
|
||||
inline std::ostream& operator<<(std::ostream& out, ImageFormatCase ifc) {
|
||||
out << "ImageFormatCase{ SpvImageFormat:" << int(ifc.format)
|
||||
@@ -362,70 +361,68 @@ INSTANTIATE_TEST_SUITE_P(
|
||||
SpvImageFormatTest,
|
||||
testing::Values(
|
||||
// Unknown. This is used for sampled images.
|
||||
ImageFormatCase{SpvImageFormatUnknown, true, type::ImageFormat::kNone},
|
||||
ImageFormatCase{SpvImageFormatUnknown, true, sem::ImageFormat::kNone},
|
||||
// 8 bit channels
|
||||
ImageFormatCase{SpvImageFormatRgba8, true,
|
||||
type::ImageFormat::kRgba8Unorm},
|
||||
sem::ImageFormat::kRgba8Unorm},
|
||||
ImageFormatCase{SpvImageFormatRgba8Snorm, true,
|
||||
type::ImageFormat::kRgba8Snorm},
|
||||
sem::ImageFormat::kRgba8Snorm},
|
||||
ImageFormatCase{SpvImageFormatRgba8ui, true,
|
||||
type::ImageFormat::kRgba8Uint},
|
||||
sem::ImageFormat::kRgba8Uint},
|
||||
ImageFormatCase{SpvImageFormatRgba8i, true,
|
||||
type::ImageFormat::kRgba8Sint},
|
||||
sem::ImageFormat::kRgba8Sint},
|
||||
// 16 bit channels
|
||||
ImageFormatCase{SpvImageFormatRgba16ui, true,
|
||||
type::ImageFormat::kRgba16Uint},
|
||||
sem::ImageFormat::kRgba16Uint},
|
||||
ImageFormatCase{SpvImageFormatRgba16i, true,
|
||||
type::ImageFormat::kRgba16Sint},
|
||||
sem::ImageFormat::kRgba16Sint},
|
||||
ImageFormatCase{SpvImageFormatRgba16f, true,
|
||||
type::ImageFormat::kRgba16Float},
|
||||
sem::ImageFormat::kRgba16Float},
|
||||
// 32 bit channels
|
||||
// ... 1 channel
|
||||
ImageFormatCase{SpvImageFormatR32ui, true, type::ImageFormat::kR32Uint},
|
||||
ImageFormatCase{SpvImageFormatR32i, true, type::ImageFormat::kR32Sint},
|
||||
ImageFormatCase{SpvImageFormatR32f, true, type::ImageFormat::kR32Float},
|
||||
ImageFormatCase{SpvImageFormatR32ui, true, sem::ImageFormat::kR32Uint},
|
||||
ImageFormatCase{SpvImageFormatR32i, true, sem::ImageFormat::kR32Sint},
|
||||
ImageFormatCase{SpvImageFormatR32f, true, sem::ImageFormat::kR32Float},
|
||||
// ... 2 channels
|
||||
ImageFormatCase{SpvImageFormatRg32ui, true,
|
||||
type::ImageFormat::kRg32Uint},
|
||||
ImageFormatCase{SpvImageFormatRg32i, true,
|
||||
type::ImageFormat::kRg32Sint},
|
||||
sem::ImageFormat::kRg32Uint},
|
||||
ImageFormatCase{SpvImageFormatRg32i, true, sem::ImageFormat::kRg32Sint},
|
||||
ImageFormatCase{SpvImageFormatRg32f, true,
|
||||
type::ImageFormat::kRg32Float},
|
||||
sem::ImageFormat::kRg32Float},
|
||||
// ... 4 channels
|
||||
ImageFormatCase{SpvImageFormatRgba32ui, true,
|
||||
type::ImageFormat::kRgba32Uint},
|
||||
sem::ImageFormat::kRgba32Uint},
|
||||
ImageFormatCase{SpvImageFormatRgba32i, true,
|
||||
type::ImageFormat::kRgba32Sint},
|
||||
sem::ImageFormat::kRgba32Sint},
|
||||
ImageFormatCase{SpvImageFormatRgba32f, true,
|
||||
type::ImageFormat::kRgba32Float}));
|
||||
sem::ImageFormat::kRgba32Float}));
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
EnumConverterBad,
|
||||
SpvImageFormatTest,
|
||||
testing::Values(
|
||||
// Scanning in order from the SPIR-V spec.
|
||||
ImageFormatCase{SpvImageFormatRg16f, false, type::ImageFormat::kNone},
|
||||
ImageFormatCase{SpvImageFormatRg16f, false, sem::ImageFormat::kNone},
|
||||
ImageFormatCase{SpvImageFormatR11fG11fB10f, false,
|
||||
type::ImageFormat::kNone},
|
||||
ImageFormatCase{SpvImageFormatR16f, false, type::ImageFormat::kNone},
|
||||
ImageFormatCase{SpvImageFormatRgb10A2, false, type::ImageFormat::kNone},
|
||||
ImageFormatCase{SpvImageFormatRg16, false, type::ImageFormat::kNone},
|
||||
ImageFormatCase{SpvImageFormatRg8, false, type::ImageFormat::kNone},
|
||||
ImageFormatCase{SpvImageFormatR16, false, type::ImageFormat::kNone},
|
||||
ImageFormatCase{SpvImageFormatR8, false, type::ImageFormat::kNone},
|
||||
sem::ImageFormat::kNone},
|
||||
ImageFormatCase{SpvImageFormatR16f, false, sem::ImageFormat::kNone},
|
||||
ImageFormatCase{SpvImageFormatRgb10A2, false, sem::ImageFormat::kNone},
|
||||
ImageFormatCase{SpvImageFormatRg16, false, sem::ImageFormat::kNone},
|
||||
ImageFormatCase{SpvImageFormatRg8, false, sem::ImageFormat::kNone},
|
||||
ImageFormatCase{SpvImageFormatR16, false, sem::ImageFormat::kNone},
|
||||
ImageFormatCase{SpvImageFormatR8, false, sem::ImageFormat::kNone},
|
||||
ImageFormatCase{SpvImageFormatRgba16Snorm, false,
|
||||
type::ImageFormat::kNone},
|
||||
sem::ImageFormat::kNone},
|
||||
ImageFormatCase{SpvImageFormatRg16Snorm, false,
|
||||
type::ImageFormat::kNone},
|
||||
ImageFormatCase{SpvImageFormatRg8Snorm, false,
|
||||
type::ImageFormat::kNone},
|
||||
ImageFormatCase{SpvImageFormatRg16i, false, type::ImageFormat::kNone},
|
||||
ImageFormatCase{SpvImageFormatRg8i, false, type::ImageFormat::kNone},
|
||||
ImageFormatCase{SpvImageFormatR8i, false, type::ImageFormat::kNone},
|
||||
sem::ImageFormat::kNone},
|
||||
ImageFormatCase{SpvImageFormatRg8Snorm, false, sem::ImageFormat::kNone},
|
||||
ImageFormatCase{SpvImageFormatRg16i, false, sem::ImageFormat::kNone},
|
||||
ImageFormatCase{SpvImageFormatRg8i, false, sem::ImageFormat::kNone},
|
||||
ImageFormatCase{SpvImageFormatR8i, false, sem::ImageFormat::kNone},
|
||||
ImageFormatCase{SpvImageFormatRgb10a2ui, false,
|
||||
type::ImageFormat::kNone},
|
||||
ImageFormatCase{SpvImageFormatRg16ui, false, type::ImageFormat::kNone},
|
||||
ImageFormatCase{SpvImageFormatRg8ui, false, type::ImageFormat::kNone}));
|
||||
sem::ImageFormat::kNone},
|
||||
ImageFormatCase{SpvImageFormatRg16ui, false, sem::ImageFormat::kNone},
|
||||
ImageFormatCase{SpvImageFormatRg8ui, false, sem::ImageFormat::kNone}));
|
||||
|
||||
} // namespace
|
||||
} // namespace spirv
|
||||
|
||||
@@ -724,8 +724,8 @@ FunctionEmitter::FunctionEmitter(ParserImpl* pi,
|
||||
fail_stream_(pi->fail_stream()),
|
||||
namer_(pi->namer()),
|
||||
function_(function),
|
||||
i32_(builder_.create<type::I32>()),
|
||||
u32_(builder_.create<type::U32>()),
|
||||
i32_(builder_.create<sem::I32>()),
|
||||
u32_(builder_.create<sem::U32>()),
|
||||
sample_mask_in_id(0u),
|
||||
sample_mask_out_id(0u),
|
||||
ep_info_(ep_info) {
|
||||
@@ -931,7 +931,7 @@ bool FunctionEmitter::ParseFunctionDeclaration(FunctionDeclaration* decl) {
|
||||
return success();
|
||||
}
|
||||
|
||||
type::Type* FunctionEmitter::GetVariableStoreType(
|
||||
sem::Type* FunctionEmitter::GetVariableStoreType(
|
||||
const spvtools::opt::Instruction& var_decl_inst) {
|
||||
const auto type_id = var_decl_inst.type_id();
|
||||
auto* var_ref_type = type_mgr_->GetType(type_id);
|
||||
@@ -2029,7 +2029,7 @@ TypedExpression FunctionEmitter::MakeExpression(uint32_t id) {
|
||||
<< id;
|
||||
return {};
|
||||
case SkipReason::kPointSizeBuiltinValue: {
|
||||
auto* f32 = create<type::F32>();
|
||||
auto* f32 = create<sem::F32>();
|
||||
return {f32,
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
Source{}, create<ast::FloatLiteral>(Source{}, f32, 1.0f))};
|
||||
@@ -3145,8 +3145,8 @@ bool FunctionEmitter::EmitStatement(const spvtools::opt::Instruction& inst) {
|
||||
}
|
||||
auto expr = MakeExpression(ptr_id);
|
||||
// The load result type is the pointee type of its operand.
|
||||
TINT_ASSERT(expr.type->Is<type::Pointer>());
|
||||
expr.type = expr.type->As<type::Pointer>()->type();
|
||||
TINT_ASSERT(expr.type->Is<sem::Pointer>());
|
||||
expr.type = expr.type->As<sem::Pointer>()->type();
|
||||
return EmitConstDefOrWriteToHoistedVar(inst, expr);
|
||||
}
|
||||
|
||||
@@ -3242,7 +3242,7 @@ TypedExpression FunctionEmitter::MaybeEmitCombinatorialValue(
|
||||
|
||||
const auto opcode = inst.opcode();
|
||||
|
||||
type::Type* ast_type =
|
||||
sem::Type* ast_type =
|
||||
inst.type_id() != 0 ? parser_impl_.ConvertType(inst.type_id()) : nullptr;
|
||||
|
||||
auto binary_op = ConvertBinaryOp(opcode);
|
||||
@@ -3388,7 +3388,7 @@ TypedExpression FunctionEmitter::EmitGlslStd450ExtInst(
|
||||
auto* func = create<ast::IdentifierExpression>(
|
||||
Source{}, builder_.Symbols().Register(name));
|
||||
ast::ExpressionList operands;
|
||||
type::Type* first_operand_type = nullptr;
|
||||
sem::Type* first_operand_type = nullptr;
|
||||
// All parameters to GLSL.std.450 extended instructions are IDs.
|
||||
for (uint32_t iarg = 2; iarg < inst.NumInOperands(); ++iarg) {
|
||||
TypedExpression operand = MakeOperand(inst, iarg);
|
||||
@@ -3630,7 +3630,7 @@ TypedExpression FunctionEmitter::MakeAccessChain(
|
||||
type_mgr_->FindPointerToType(pointee_type_id, storage_class);
|
||||
auto* ast_pointer_type = parser_impl_.ConvertType(pointer_type_id);
|
||||
TINT_ASSERT(ast_pointer_type);
|
||||
TINT_ASSERT(ast_pointer_type->Is<type::Pointer>());
|
||||
TINT_ASSERT(ast_pointer_type->Is<sem::Pointer>());
|
||||
current_expr = TypedExpression{ast_pointer_type, next_expr};
|
||||
}
|
||||
return current_expr;
|
||||
@@ -3794,7 +3794,7 @@ ast::Expression* FunctionEmitter::MakeTrue(const Source& source) const {
|
||||
}
|
||||
|
||||
ast::Expression* FunctionEmitter::MakeFalse(const Source& source) const {
|
||||
type::Bool bool_type;
|
||||
sem::Bool bool_type;
|
||||
return create<ast::ScalarConstructorExpression>(
|
||||
source, create<ast::BoolLiteral>(source, parser_impl_.Bool(), false));
|
||||
}
|
||||
@@ -3815,8 +3815,8 @@ TypedExpression FunctionEmitter::MakeVectorShuffle(
|
||||
// Generate an ast::TypeConstructor expression.
|
||||
// Assume the literal indices are valid, and there is a valid number of them.
|
||||
auto source = GetSourceForInst(inst);
|
||||
type::Vector* result_type =
|
||||
parser_impl_.ConvertType(inst.type_id())->As<type::Vector>();
|
||||
sem::Vector* result_type =
|
||||
parser_impl_.ConvertType(inst.type_id())->As<sem::Vector>();
|
||||
ast::ExpressionList values;
|
||||
for (uint32_t i = 2; i < inst.NumInOperands(); ++i) {
|
||||
const auto index = inst.GetSingleWordInOperand(i);
|
||||
@@ -3907,7 +3907,7 @@ bool FunctionEmitter::RegisterLocallyDefinedValues() {
|
||||
if (type) {
|
||||
if (type->AsPointer()) {
|
||||
if (const auto* ast_type = parser_impl_.ConvertType(inst.type_id())) {
|
||||
if (auto* ptr = ast_type->As<type::Pointer>()) {
|
||||
if (auto* ptr = ast_type->As<sem::Pointer>()) {
|
||||
info->storage_class = ptr->storage_class();
|
||||
}
|
||||
}
|
||||
@@ -3952,21 +3952,21 @@ ast::StorageClass FunctionEmitter::GetStorageClassForPointerValue(uint32_t id) {
|
||||
const auto type_id = def_use_mgr_->GetDef(id)->type_id();
|
||||
if (type_id) {
|
||||
auto* ast_type = parser_impl_.ConvertType(type_id);
|
||||
if (ast_type && ast_type->Is<type::Pointer>()) {
|
||||
return ast_type->As<type::Pointer>()->storage_class();
|
||||
if (ast_type && ast_type->Is<sem::Pointer>()) {
|
||||
return ast_type->As<sem::Pointer>()->storage_class();
|
||||
}
|
||||
}
|
||||
return ast::StorageClass::kNone;
|
||||
}
|
||||
|
||||
type::Type* FunctionEmitter::RemapStorageClass(type::Type* type,
|
||||
uint32_t result_id) {
|
||||
if (const auto* ast_ptr_type = type->As<type::Pointer>()) {
|
||||
sem::Type* FunctionEmitter::RemapStorageClass(sem::Type* type,
|
||||
uint32_t result_id) {
|
||||
if (const auto* ast_ptr_type = type->As<sem::Pointer>()) {
|
||||
// Remap an old-style storage buffer pointer to a new-style storage
|
||||
// buffer pointer.
|
||||
const auto sc = GetStorageClassForPointerValue(result_id);
|
||||
if (ast_ptr_type->storage_class() != sc) {
|
||||
return builder_.create<type::Pointer>(ast_ptr_type->type(), sc);
|
||||
return builder_.create<sem::Pointer>(ast_ptr_type->type(), sc);
|
||||
}
|
||||
}
|
||||
return type;
|
||||
@@ -4149,7 +4149,7 @@ TypedExpression FunctionEmitter::MakeNumericConversion(
|
||||
return {};
|
||||
}
|
||||
|
||||
type::Type* expr_type = nullptr;
|
||||
sem::Type* expr_type = nullptr;
|
||||
if ((opcode == SpvOpConvertSToF) || (opcode == SpvOpConvertUToF)) {
|
||||
if (arg_expr.type->is_integer_scalar_or_vector()) {
|
||||
expr_type = requested_type;
|
||||
@@ -4214,7 +4214,7 @@ bool FunctionEmitter::EmitFunctionCall(const spvtools::opt::Instruction& inst) {
|
||||
<< inst.PrettyPrint();
|
||||
}
|
||||
|
||||
if (result_type->Is<type::Void>()) {
|
||||
if (result_type->Is<sem::Void>()) {
|
||||
return nullptr !=
|
||||
AddStatement(create<ast::CallStatement>(Source{}, call_expr));
|
||||
}
|
||||
@@ -4277,7 +4277,7 @@ TypedExpression FunctionEmitter::MakeIntrinsicCall(
|
||||
Source{}, builder_.Symbols().Register(name));
|
||||
|
||||
ast::ExpressionList params;
|
||||
type::Type* first_operand_type = nullptr;
|
||||
sem::Type* first_operand_type = nullptr;
|
||||
for (uint32_t iarg = 0; iarg < inst.NumInOperands(); ++iarg) {
|
||||
TypedExpression operand = MakeOperand(inst, iarg);
|
||||
if (first_operand_type == nullptr) {
|
||||
@@ -4309,8 +4309,8 @@ TypedExpression FunctionEmitter::MakeSimpleSelect(
|
||||
// - you can't select over pointers or pointer vectors, unless you also have
|
||||
// a VariablePointers* capability, which is not allowed in by WebGPU.
|
||||
auto* op_ty = operand1.type;
|
||||
if (op_ty->Is<type::Vector>() || op_ty->is_float_scalar() ||
|
||||
op_ty->is_integer_scalar() || op_ty->Is<type::Bool>()) {
|
||||
if (op_ty->Is<sem::Vector>() || op_ty->is_float_scalar() ||
|
||||
op_ty->is_integer_scalar() || op_ty->Is<sem::Bool>()) {
|
||||
ast::ExpressionList params;
|
||||
params.push_back(operand1.expr);
|
||||
params.push_back(operand2.expr);
|
||||
@@ -4348,18 +4348,18 @@ const spvtools::opt::Instruction* FunctionEmitter::GetImage(
|
||||
return image;
|
||||
}
|
||||
|
||||
type::Texture* FunctionEmitter::GetImageType(
|
||||
sem::Texture* FunctionEmitter::GetImageType(
|
||||
const spvtools::opt::Instruction& image) {
|
||||
type::Pointer* ptr_type = parser_impl_.GetTypeForHandleVar(image);
|
||||
sem::Pointer* ptr_type = parser_impl_.GetTypeForHandleVar(image);
|
||||
if (!parser_impl_.success()) {
|
||||
Fail();
|
||||
return nullptr;
|
||||
}
|
||||
if (!ptr_type || !ptr_type->type()->UnwrapAll()->Is<type::Texture>()) {
|
||||
if (!ptr_type || !ptr_type->type()->UnwrapAll()->Is<sem::Texture>()) {
|
||||
Fail() << "invalid texture type for " << image.PrettyPrint();
|
||||
return nullptr;
|
||||
}
|
||||
return As<type::Texture>(ptr_type->type()->UnwrapAll());
|
||||
return As<sem::Texture>(ptr_type->type()->UnwrapAll());
|
||||
}
|
||||
|
||||
ast::Expression* FunctionEmitter::GetImageExpression(
|
||||
@@ -4409,12 +4409,12 @@ bool FunctionEmitter::EmitImageAccess(const spvtools::opt::Instruction& inst) {
|
||||
}
|
||||
}
|
||||
|
||||
type::Pointer* texture_ptr_type = parser_impl_.GetTypeForHandleVar(*image);
|
||||
sem::Pointer* texture_ptr_type = parser_impl_.GetTypeForHandleVar(*image);
|
||||
if (!texture_ptr_type) {
|
||||
return Fail();
|
||||
}
|
||||
type::Texture* texture_type =
|
||||
texture_ptr_type->type()->UnwrapAll()->As<type::Texture>();
|
||||
sem::Texture* texture_type =
|
||||
texture_ptr_type->type()->UnwrapAll()->As<sem::Texture>();
|
||||
if (!texture_type) {
|
||||
return Fail();
|
||||
}
|
||||
@@ -4516,7 +4516,7 @@ bool FunctionEmitter::EmitImageAccess(const spvtools::opt::Instruction& inst) {
|
||||
}
|
||||
TypedExpression lod = MakeOperand(inst, arg_index);
|
||||
// When sampling from a depth texture, the Lod operand must be an I32.
|
||||
if (texture_type->Is<type::DepthTexture>()) {
|
||||
if (texture_type->Is<sem::DepthTexture>()) {
|
||||
// Convert it to a signed integer type.
|
||||
lod = ToI32(lod);
|
||||
}
|
||||
@@ -4524,8 +4524,8 @@ bool FunctionEmitter::EmitImageAccess(const spvtools::opt::Instruction& inst) {
|
||||
image_operands_mask ^= SpvImageOperandsLodMask;
|
||||
arg_index++;
|
||||
} else if ((opcode == SpvOpImageFetch) &&
|
||||
(texture_type->Is<type::SampledTexture>() ||
|
||||
texture_type->Is<type::DepthTexture>())) {
|
||||
(texture_type->Is<sem::SampledTexture>() ||
|
||||
texture_type->Is<sem::DepthTexture>())) {
|
||||
// textureLoad on sampled texture and depth texture requires an explicit
|
||||
// level-of-detail parameter.
|
||||
params.push_back(parser_impl_.MakeNullValue(i32_));
|
||||
@@ -4550,9 +4550,9 @@ bool FunctionEmitter::EmitImageAccess(const spvtools::opt::Instruction& inst) {
|
||||
<< inst.PrettyPrint();
|
||||
}
|
||||
switch (texture_type->dim()) {
|
||||
case type::TextureDimension::k2d:
|
||||
case type::TextureDimension::k2dArray:
|
||||
case type::TextureDimension::k3d:
|
||||
case sem::TextureDimension::k2d:
|
||||
case sem::TextureDimension::k2dArray:
|
||||
case sem::TextureDimension::k3d:
|
||||
break;
|
||||
default:
|
||||
return Fail() << "ConstOffset is only permitted for 2D, 2D Arrayed, "
|
||||
@@ -4588,7 +4588,7 @@ bool FunctionEmitter::EmitImageAccess(const spvtools::opt::Instruction& inst) {
|
||||
// The result type, derived from the SPIR-V instruction.
|
||||
auto* result_type = parser_impl_.ConvertType(inst.type_id());
|
||||
auto* result_component_type = result_type;
|
||||
if (auto* result_vector_type = result_type->As<type::Vector>()) {
|
||||
if (auto* result_vector_type = result_type->As<sem::Vector>()) {
|
||||
result_component_type = result_vector_type->type();
|
||||
}
|
||||
|
||||
@@ -4603,7 +4603,7 @@ bool FunctionEmitter::EmitImageAccess(const spvtools::opt::Instruction& inst) {
|
||||
// dref gather vec4 ImageFetch vec4 TODO(dneto)
|
||||
// Construct a 4-element vector with the result from the builtin in the
|
||||
// first component.
|
||||
if (texture_type->Is<type::DepthTexture>()) {
|
||||
if (texture_type->Is<sem::DepthTexture>()) {
|
||||
if (is_non_dref_sample || (opcode == SpvOpImageFetch)) {
|
||||
value = create<ast::TypeConstructorExpression>(
|
||||
Source{},
|
||||
@@ -4631,7 +4631,7 @@ bool FunctionEmitter::EmitImageAccess(const spvtools::opt::Instruction& inst) {
|
||||
// or vice versa. Perform a bitcast.
|
||||
value = create<ast::BitcastExpression>(Source{}, result_type, call_expr);
|
||||
}
|
||||
if (!expected_component_type->Is<type::F32>() &&
|
||||
if (!expected_component_type->Is<sem::F32>() &&
|
||||
IsSampledImageAccess(opcode)) {
|
||||
// WGSL permits sampled image access only on float textures.
|
||||
// Reject this case in the SPIR-V reader, at least until SPIR-V validation
|
||||
@@ -4675,7 +4675,7 @@ bool FunctionEmitter::EmitImageQuery(const spvtools::opt::Instruction& inst) {
|
||||
}
|
||||
exprs.push_back(
|
||||
create<ast::CallExpression>(Source{}, dims_ident, dims_args));
|
||||
if (type::IsTextureArray(texture_type->dim())) {
|
||||
if (sem::IsTextureArray(texture_type->dim())) {
|
||||
auto* layers_ident = create<ast::IdentifierExpression>(
|
||||
Source{}, builder_.Symbols().Register("textureNumLayers"));
|
||||
exprs.push_back(create<ast::CallExpression>(
|
||||
@@ -4750,14 +4750,14 @@ ast::ExpressionList FunctionEmitter::MakeCoordinateOperandsForImageAccess(
|
||||
if (!raw_coords.type) {
|
||||
return {};
|
||||
}
|
||||
type::Texture* texture_type = GetImageType(*image);
|
||||
sem::Texture* texture_type = GetImageType(*image);
|
||||
if (!texture_type) {
|
||||
return {};
|
||||
}
|
||||
type::TextureDimension dim = texture_type->dim();
|
||||
sem::TextureDimension dim = texture_type->dim();
|
||||
// Number of regular coordinates.
|
||||
uint32_t num_axes = type::NumCoordinateAxes(dim);
|
||||
bool is_arrayed = type::IsTextureArray(dim);
|
||||
uint32_t num_axes = sem::NumCoordinateAxes(dim);
|
||||
bool is_arrayed = sem::IsTextureArray(dim);
|
||||
if ((num_axes == 0) || (num_axes > 3)) {
|
||||
Fail() << "unsupported image dimensionality for "
|
||||
<< texture_type->type_name() << " prompted by "
|
||||
@@ -4769,7 +4769,7 @@ ast::ExpressionList FunctionEmitter::MakeCoordinateOperandsForImageAccess(
|
||||
if (component_type->is_float_scalar() ||
|
||||
component_type->is_integer_scalar()) {
|
||||
num_coords_supplied = 1;
|
||||
} else if (auto* vec_type = raw_coords.type->As<type::Vector>()) {
|
||||
} else if (auto* vec_type = raw_coords.type->As<sem::Vector>()) {
|
||||
component_type = vec_type->type();
|
||||
num_coords_supplied = vec_type->size();
|
||||
}
|
||||
@@ -4796,7 +4796,7 @@ ast::ExpressionList FunctionEmitter::MakeCoordinateOperandsForImageAccess(
|
||||
raw_coords]() -> ast::Expression* {
|
||||
auto* swizzle_type = (num_axes == 1)
|
||||
? component_type
|
||||
: create<type::Vector>(component_type, num_axes);
|
||||
: create<sem::Vector>(component_type, num_axes);
|
||||
auto* swizzle = create<ast::MemberAccessorExpression>(
|
||||
Source{}, raw_coords.expr, PrefixSwizzle(num_axes));
|
||||
return ToSignedIfUnsigned({swizzle_type, swizzle}).expr;
|
||||
@@ -4830,8 +4830,8 @@ ast::ExpressionList FunctionEmitter::MakeCoordinateOperandsForImageAccess(
|
||||
ast::Expression* FunctionEmitter::ConvertTexelForStorage(
|
||||
const spvtools::opt::Instruction& inst,
|
||||
TypedExpression texel,
|
||||
type::Texture* texture_type) {
|
||||
auto* storage_texture_type = texture_type->As<type::StorageTexture>();
|
||||
sem::Texture* texture_type) {
|
||||
auto* storage_texture_type = texture_type->As<sem::StorageTexture>();
|
||||
auto* src_type = texel.type;
|
||||
if (!storage_texture_type) {
|
||||
Fail() << "writing to other than storage texture: " << inst.PrettyPrint();
|
||||
@@ -4848,14 +4848,14 @@ ast::Expression* FunctionEmitter::ConvertTexelForStorage(
|
||||
}
|
||||
|
||||
const uint32_t dest_count =
|
||||
dest_type->is_scalar() ? 1 : dest_type->As<type::Vector>()->size();
|
||||
dest_type->is_scalar() ? 1 : dest_type->As<sem::Vector>()->size();
|
||||
if (dest_count == 3) {
|
||||
Fail() << "3-channel storage textures are not supported: "
|
||||
<< inst.PrettyPrint();
|
||||
return nullptr;
|
||||
}
|
||||
const uint32_t src_count =
|
||||
src_type->is_scalar() ? 1 : src_type->As<type::Vector>()->size();
|
||||
src_type->is_scalar() ? 1 : src_type->As<sem::Vector>()->size();
|
||||
if (src_count < dest_count) {
|
||||
Fail() << "texel has too few components for storage texture: " << src_count
|
||||
<< " provided but " << dest_count
|
||||
@@ -4925,8 +4925,8 @@ TypedExpression FunctionEmitter::ToSignedIfUnsigned(TypedExpression value) {
|
||||
if (!value.type || !value.type->is_unsigned_scalar_or_vector()) {
|
||||
return value;
|
||||
}
|
||||
if (auto* vec_type = value.type->As<type::Vector>()) {
|
||||
auto* new_type = create<type::Vector>(i32_, vec_type->size());
|
||||
if (auto* vec_type = value.type->As<sem::Vector>()) {
|
||||
auto* new_type = create<sem::Vector>(i32_, vec_type->size());
|
||||
return {new_type, create<ast::TypeConstructorExpression>(
|
||||
Source{}, new_type, ast::ExpressionList{value.expr})};
|
||||
}
|
||||
@@ -4976,10 +4976,9 @@ TypedExpression FunctionEmitter::MakeOuterProduct(
|
||||
// Synthesize the result.
|
||||
auto col = MakeOperand(inst, 0);
|
||||
auto row = MakeOperand(inst, 1);
|
||||
auto* col_ty = col.type->As<type::Vector>();
|
||||
auto* row_ty = row.type->As<type::Vector>();
|
||||
auto* result_ty =
|
||||
parser_impl_.ConvertType(inst.type_id())->As<type::Matrix>();
|
||||
auto* col_ty = col.type->As<sem::Vector>();
|
||||
auto* row_ty = row.type->As<sem::Vector>();
|
||||
auto* result_ty = parser_impl_.ConvertType(inst.type_id())->As<sem::Matrix>();
|
||||
if (!col_ty || !col_ty || !result_ty || result_ty->type() != col_ty->type() ||
|
||||
result_ty->type() != row_ty->type() ||
|
||||
result_ty->columns() != row_ty->size() ||
|
||||
|
||||
@@ -512,7 +512,7 @@ class FunctionEmitter {
|
||||
/// @param type the AST type
|
||||
/// @param result_id the SPIR-V ID for the locally defined value
|
||||
/// @returns an possibly updated type
|
||||
type::Type* RemapStorageClass(type::Type* type, uint32_t result_id);
|
||||
sem::Type* RemapStorageClass(sem::Type* type, uint32_t result_id);
|
||||
|
||||
/// Marks locally defined values when they should get a 'const'
|
||||
/// definition in WGSL, or a 'var' definition at an outer scope.
|
||||
@@ -853,7 +853,7 @@ class FunctionEmitter {
|
||||
/// Function parameters
|
||||
ast::VariableList params;
|
||||
/// Function return type
|
||||
type::Type* return_type;
|
||||
sem::Type* return_type;
|
||||
/// Function decorations
|
||||
ast::DecorationList decorations;
|
||||
};
|
||||
@@ -866,7 +866,7 @@ class FunctionEmitter {
|
||||
|
||||
/// @returns the store type for the OpVariable instruction, or
|
||||
/// null on failure.
|
||||
type::Type* GetVariableStoreType(
|
||||
sem::Type* GetVariableStoreType(
|
||||
const spvtools::opt::Instruction& var_decl_inst);
|
||||
|
||||
/// Returns an expression for an instruction operand. Signedness conversion is
|
||||
@@ -934,7 +934,7 @@ class FunctionEmitter {
|
||||
/// Get the AST texture the SPIR-V image memory object declaration.
|
||||
/// @param inst the SPIR-V memory object declaration for the image.
|
||||
/// @returns a texture type, or null on error
|
||||
type::Texture* GetImageType(const spvtools::opt::Instruction& inst);
|
||||
sem::Texture* GetImageType(const spvtools::opt::Instruction& inst);
|
||||
|
||||
/// Get the expression for the image operand from the first operand to the
|
||||
/// given instruction.
|
||||
@@ -971,7 +971,7 @@ class FunctionEmitter {
|
||||
ast::Expression* ConvertTexelForStorage(
|
||||
const spvtools::opt::Instruction& inst,
|
||||
TypedExpression texel,
|
||||
type::Texture* texture_type);
|
||||
sem::Texture* texture_type);
|
||||
|
||||
/// Returns an expression for an OpSelect, if its operands are scalars
|
||||
/// or vectors. These translate directly to WGSL select. Otherwise, return
|
||||
@@ -1133,8 +1133,8 @@ class FunctionEmitter {
|
||||
FailStream& fail_stream_;
|
||||
Namer& namer_;
|
||||
const spvtools::opt::Function& function_;
|
||||
type::I32* const i32_; // The unique I32 type object.
|
||||
type::U32* const u32_; // The unique U32 type object.
|
||||
sem::I32* const i32_; // The unique I32 type object.
|
||||
sem::U32* const u32_; // The unique U32 type object.
|
||||
|
||||
// The SPIR-V ID for the SampleMask input variable.
|
||||
uint32_t sample_mask_in_id;
|
||||
|
||||
@@ -231,7 +231,7 @@ ParserImpl::ParserImpl(const std::vector<uint32_t>& spv_binary)
|
||||
: Reader(),
|
||||
spv_binary_(spv_binary),
|
||||
fail_stream_(&success_, &errors_),
|
||||
bool_type_(builder_.create<type::Bool>()),
|
||||
bool_type_(builder_.create<sem::Bool>()),
|
||||
namer_(fail_stream_),
|
||||
enum_converter_(fail_stream_),
|
||||
tools_context_(kInputEnv) {
|
||||
@@ -289,7 +289,7 @@ Program ParserImpl::program() {
|
||||
return tint::Program(std::move(builder_));
|
||||
}
|
||||
|
||||
type::Type* ParserImpl::ConvertType(uint32_t type_id) {
|
||||
sem::Type* ParserImpl::ConvertType(uint32_t type_id) {
|
||||
if (!success_) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -310,7 +310,7 @@ type::Type* ParserImpl::ConvertType(uint32_t type_id) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto save = [this, type_id, spirv_type](type::Type* type) {
|
||||
auto save = [this, type_id, spirv_type](sem::Type* type) {
|
||||
if (type != nullptr) {
|
||||
id_to_type_[type_id] = type;
|
||||
MaybeGenerateAlias(type_id, spirv_type);
|
||||
@@ -320,7 +320,7 @@ type::Type* ParserImpl::ConvertType(uint32_t type_id) {
|
||||
|
||||
switch (spirv_type->kind()) {
|
||||
case spvtools::opt::analysis::Type::kVoid:
|
||||
return save(builder_.create<type::Void>());
|
||||
return save(builder_.create<sem::Void>());
|
||||
case spvtools::opt::analysis::Type::kBool:
|
||||
return save(bool_type_);
|
||||
case spvtools::opt::analysis::Type::kInteger:
|
||||
@@ -350,7 +350,7 @@ type::Type* ParserImpl::ConvertType(uint32_t type_id) {
|
||||
case spvtools::opt::analysis::Type::kImage:
|
||||
// Fake it for sampler and texture types. These are handled in an
|
||||
// entirely different way.
|
||||
return save(builder_.create<type::Void>());
|
||||
return save(builder_.create<sem::Void>());
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -694,11 +694,11 @@ bool ParserImpl::RegisterEntryPoints() {
|
||||
return success_;
|
||||
}
|
||||
|
||||
type::Type* ParserImpl::ConvertType(
|
||||
sem::Type* ParserImpl::ConvertType(
|
||||
const spvtools::opt::analysis::Integer* int_ty) {
|
||||
if (int_ty->width() == 32) {
|
||||
type::Type* signed_ty = builder_.create<type::I32>();
|
||||
type::Type* unsigned_ty = builder_.create<type::U32>();
|
||||
sem::Type* signed_ty = builder_.create<sem::I32>();
|
||||
sem::Type* unsigned_ty = builder_.create<sem::U32>();
|
||||
signed_type_for_[unsigned_ty] = signed_ty;
|
||||
unsigned_type_for_[signed_ty] = unsigned_ty;
|
||||
return int_ty->IsSigned() ? signed_ty : unsigned_ty;
|
||||
@@ -707,39 +707,39 @@ type::Type* ParserImpl::ConvertType(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
type::Type* ParserImpl::ConvertType(
|
||||
sem::Type* ParserImpl::ConvertType(
|
||||
const spvtools::opt::analysis::Float* float_ty) {
|
||||
if (float_ty->width() == 32) {
|
||||
return builder_.create<type::F32>();
|
||||
return builder_.create<sem::F32>();
|
||||
}
|
||||
Fail() << "unhandled float width: " << float_ty->width();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
type::Type* ParserImpl::ConvertType(
|
||||
sem::Type* ParserImpl::ConvertType(
|
||||
const spvtools::opt::analysis::Vector* vec_ty) {
|
||||
const auto num_elem = vec_ty->element_count();
|
||||
auto* ast_elem_ty = ConvertType(type_mgr_->GetId(vec_ty->element_type()));
|
||||
if (ast_elem_ty == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
auto* this_ty = builder_.create<type::Vector>(ast_elem_ty, num_elem);
|
||||
auto* this_ty = builder_.create<sem::Vector>(ast_elem_ty, num_elem);
|
||||
// Generate the opposite-signedness vector type, if this type is integral.
|
||||
if (unsigned_type_for_.count(ast_elem_ty)) {
|
||||
auto* other_ty = builder_.create<type::Vector>(
|
||||
unsigned_type_for_[ast_elem_ty], num_elem);
|
||||
auto* other_ty =
|
||||
builder_.create<sem::Vector>(unsigned_type_for_[ast_elem_ty], num_elem);
|
||||
signed_type_for_[other_ty] = this_ty;
|
||||
unsigned_type_for_[this_ty] = other_ty;
|
||||
} else if (signed_type_for_.count(ast_elem_ty)) {
|
||||
auto* other_ty =
|
||||
builder_.create<type::Vector>(signed_type_for_[ast_elem_ty], num_elem);
|
||||
builder_.create<sem::Vector>(signed_type_for_[ast_elem_ty], num_elem);
|
||||
unsigned_type_for_[other_ty] = this_ty;
|
||||
signed_type_for_[this_ty] = other_ty;
|
||||
}
|
||||
return this_ty;
|
||||
}
|
||||
|
||||
type::Type* ParserImpl::ConvertType(
|
||||
sem::Type* ParserImpl::ConvertType(
|
||||
const spvtools::opt::analysis::Matrix* mat_ty) {
|
||||
const auto* vec_ty = mat_ty->element_type()->AsVector();
|
||||
const auto* scalar_ty = vec_ty->element_type();
|
||||
@@ -749,10 +749,10 @@ type::Type* ParserImpl::ConvertType(
|
||||
if (ast_scalar_ty == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
return builder_.create<type::Matrix>(ast_scalar_ty, num_rows, num_columns);
|
||||
return builder_.create<sem::Matrix>(ast_scalar_ty, num_rows, num_columns);
|
||||
}
|
||||
|
||||
type::Type* ParserImpl::ConvertType(
|
||||
sem::Type* ParserImpl::ConvertType(
|
||||
const spvtools::opt::analysis::RuntimeArray* rtarr_ty) {
|
||||
auto* ast_elem_ty = ConvertType(type_mgr_->GetId(rtarr_ty->element_type()));
|
||||
if (ast_elem_ty == nullptr) {
|
||||
@@ -762,10 +762,10 @@ type::Type* ParserImpl::ConvertType(
|
||||
if (!ParseArrayDecorations(rtarr_ty, &decorations)) {
|
||||
return nullptr;
|
||||
}
|
||||
return create<type::ArrayType>(ast_elem_ty, 0, std::move(decorations));
|
||||
return create<sem::ArrayType>(ast_elem_ty, 0, std::move(decorations));
|
||||
}
|
||||
|
||||
type::Type* ParserImpl::ConvertType(
|
||||
sem::Type* ParserImpl::ConvertType(
|
||||
const spvtools::opt::analysis::Array* arr_ty) {
|
||||
const auto elem_type_id = type_mgr_->GetId(arr_ty->element_type());
|
||||
auto* ast_elem_ty = ConvertType(elem_type_id);
|
||||
@@ -807,8 +807,8 @@ type::Type* ParserImpl::ConvertType(
|
||||
if (remap_buffer_block_type_.count(elem_type_id)) {
|
||||
remap_buffer_block_type_.insert(type_mgr_->GetId(arr_ty));
|
||||
}
|
||||
return create<type::ArrayType>(ast_elem_ty, static_cast<uint32_t>(num_elem),
|
||||
std::move(decorations));
|
||||
return create<sem::ArrayType>(ast_elem_ty, static_cast<uint32_t>(num_elem),
|
||||
std::move(decorations));
|
||||
}
|
||||
|
||||
bool ParserImpl::ParseArrayDecorations(
|
||||
@@ -840,7 +840,7 @@ bool ParserImpl::ParseArrayDecorations(
|
||||
return true;
|
||||
}
|
||||
|
||||
type::Type* ParserImpl::ConvertType(
|
||||
sem::Type* ParserImpl::ConvertType(
|
||||
uint32_t type_id,
|
||||
const spvtools::opt::analysis::Struct* struct_ty) {
|
||||
// Compute the struct decoration.
|
||||
@@ -947,7 +947,7 @@ type::Type* ParserImpl::ConvertType(
|
||||
namer_.SuggestSanitizedName(type_id, "S");
|
||||
|
||||
auto name = namer_.GetName(type_id);
|
||||
auto* result = builder_.create<type::StructType>(
|
||||
auto* result = builder_.create<sem::StructType>(
|
||||
builder_.Symbols().Register(name), ast_struct);
|
||||
id_to_type_[type_id] = result;
|
||||
if (num_non_writable_members == members.size()) {
|
||||
@@ -957,8 +957,8 @@ type::Type* ParserImpl::ConvertType(
|
||||
return result;
|
||||
}
|
||||
|
||||
type::Type* ParserImpl::ConvertType(uint32_t type_id,
|
||||
const spvtools::opt::analysis::Pointer*) {
|
||||
sem::Type* ParserImpl::ConvertType(uint32_t type_id,
|
||||
const spvtools::opt::analysis::Pointer*) {
|
||||
const auto* inst = def_use_mgr_->GetDef(type_id);
|
||||
const auto pointee_type_id = inst->GetSingleWordInOperand(1);
|
||||
const auto storage_class = SpvStorageClass(inst->GetSingleWordInOperand(0));
|
||||
@@ -987,7 +987,7 @@ type::Type* ParserImpl::ConvertType(uint32_t type_id,
|
||||
ast_storage_class = ast::StorageClass::kStorage;
|
||||
remap_buffer_block_type_.insert(type_id);
|
||||
}
|
||||
return builder_.create<type::Pointer>(ast_elem_ty, ast_storage_class);
|
||||
return builder_.create<sem::Pointer>(ast_elem_ty, ast_storage_class);
|
||||
}
|
||||
|
||||
bool ParserImpl::RegisterTypes() {
|
||||
@@ -1020,7 +1020,7 @@ bool ParserImpl::EmitScalarSpecConstants() {
|
||||
// that is OpSpecConstantTrue, OpSpecConstantFalse, or OpSpecConstant.
|
||||
for (auto& inst : module_->types_values()) {
|
||||
// These will be populated for a valid scalar spec constant.
|
||||
type::Type* ast_type = nullptr;
|
||||
sem::Type* ast_type = nullptr;
|
||||
ast::ScalarConstructorExpression* ast_expr = nullptr;
|
||||
|
||||
switch (inst.opcode()) {
|
||||
@@ -1036,17 +1036,17 @@ bool ParserImpl::EmitScalarSpecConstants() {
|
||||
case SpvOpSpecConstant: {
|
||||
ast_type = ConvertType(inst.type_id());
|
||||
const uint32_t literal_value = inst.GetSingleWordInOperand(0);
|
||||
if (ast_type->Is<type::I32>()) {
|
||||
if (ast_type->Is<sem::I32>()) {
|
||||
ast_expr = create<ast::ScalarConstructorExpression>(
|
||||
Source{},
|
||||
create<ast::SintLiteral>(Source{}, ast_type,
|
||||
static_cast<int32_t>(literal_value)));
|
||||
} else if (ast_type->Is<type::U32>()) {
|
||||
} else if (ast_type->Is<sem::U32>()) {
|
||||
ast_expr = create<ast::ScalarConstructorExpression>(
|
||||
Source{},
|
||||
create<ast::UintLiteral>(Source{}, ast_type,
|
||||
static_cast<uint32_t>(literal_value)));
|
||||
} else if (ast_type->Is<type::F32>()) {
|
||||
} else if (ast_type->Is<sem::F32>()) {
|
||||
float float_value;
|
||||
// Copy the bits so we can read them as a float.
|
||||
std::memcpy(&float_value, &literal_value, sizeof(float_value));
|
||||
@@ -1113,7 +1113,7 @@ void ParserImpl::MaybeGenerateAlias(uint32_t type_id,
|
||||
return;
|
||||
}
|
||||
const auto name = namer_.GetName(type_id);
|
||||
auto* ast_alias_type = builder_.create<type::Alias>(
|
||||
auto* ast_alias_type = builder_.create<sem::Alias>(
|
||||
builder_.Symbols().Register(name), ast_underlying_type);
|
||||
// Record this new alias as the AST type for this SPIR-V ID.
|
||||
id_to_type_[type_id] = ast_alias_type;
|
||||
@@ -1158,7 +1158,7 @@ bool ParserImpl::EmitModuleScopeVariables() {
|
||||
if (!success_) {
|
||||
return false;
|
||||
}
|
||||
type::Type* ast_type = nullptr;
|
||||
sem::Type* ast_type = nullptr;
|
||||
if (spirv_storage_class == SpvStorageClassUniformConstant) {
|
||||
// These are opaque handles: samplers or textures
|
||||
ast_type = GetTypeForHandleVar(var);
|
||||
@@ -1172,14 +1172,14 @@ bool ParserImpl::EmitModuleScopeVariables() {
|
||||
"SPIR-V type with ID: "
|
||||
<< var.type_id();
|
||||
}
|
||||
if (!ast_type->Is<type::Pointer>()) {
|
||||
if (!ast_type->Is<sem::Pointer>()) {
|
||||
return Fail() << "variable with ID " << var.result_id()
|
||||
<< " has non-pointer type " << var.type_id();
|
||||
}
|
||||
}
|
||||
|
||||
auto* ast_store_type = ast_type->As<type::Pointer>()->type();
|
||||
auto ast_storage_class = ast_type->As<type::Pointer>()->storage_class();
|
||||
auto* ast_store_type = ast_type->As<sem::Pointer>()->type();
|
||||
auto ast_storage_class = ast_type->As<sem::Pointer>()->storage_class();
|
||||
ast::Expression* ast_constructor = nullptr;
|
||||
if (var.NumInOperands() > 1) {
|
||||
// SPIR-V initializers are always constants.
|
||||
@@ -1242,7 +1242,7 @@ const spvtools::opt::analysis::IntConstant* ParserImpl::GetArraySize(
|
||||
|
||||
ast::Variable* ParserImpl::MakeVariable(uint32_t id,
|
||||
ast::StorageClass sc,
|
||||
type::Type* type,
|
||||
sem::Type* type,
|
||||
bool is_const,
|
||||
ast::Expression* constructor,
|
||||
ast::DecorationList decorations) {
|
||||
@@ -1256,7 +1256,7 @@ ast::Variable* ParserImpl::MakeVariable(uint32_t id,
|
||||
auto access = read_only_struct_types_.count(type)
|
||||
? ast::AccessControl::kReadOnly
|
||||
: ast::AccessControl::kReadWrite;
|
||||
type = builder_.create<type::AccessControl>(access, type);
|
||||
type = builder_.create<sem::AccessControl>(access, type);
|
||||
}
|
||||
|
||||
for (auto& deco : GetDecorationsFor(id)) {
|
||||
@@ -1298,7 +1298,7 @@ ast::Variable* ParserImpl::MakeVariable(uint32_t id,
|
||||
"SampleMask must be an array of 1 element.";
|
||||
}
|
||||
special_builtins_[id] = spv_builtin;
|
||||
type = builder_.create<type::U32>();
|
||||
type = builder_.create<sem::U32>();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@@ -1382,25 +1382,25 @@ TypedExpression ParserImpl::MakeConstantExpression(uint32_t id) {
|
||||
// So canonicalization should map that way too.
|
||||
// Currently "null<type>" is missing from the WGSL parser.
|
||||
// See https://bugs.chromium.org/p/tint/issues/detail?id=34
|
||||
if (ast_type->Is<type::U32>()) {
|
||||
if (ast_type->Is<sem::U32>()) {
|
||||
return {ast_type,
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
Source{}, create<ast::UintLiteral>(source, ast_type,
|
||||
spirv_const->GetU32()))};
|
||||
}
|
||||
if (ast_type->Is<type::I32>()) {
|
||||
if (ast_type->Is<sem::I32>()) {
|
||||
return {ast_type,
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
Source{}, create<ast::SintLiteral>(source, ast_type,
|
||||
spirv_const->GetS32()))};
|
||||
}
|
||||
if (ast_type->Is<type::F32>()) {
|
||||
if (ast_type->Is<sem::F32>()) {
|
||||
return {ast_type,
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
Source{}, create<ast::FloatLiteral>(source, ast_type,
|
||||
spirv_const->GetFloat()))};
|
||||
}
|
||||
if (ast_type->Is<type::Bool>()) {
|
||||
if (ast_type->Is<sem::Bool>()) {
|
||||
const bool value = spirv_const->AsNullConstant()
|
||||
? false
|
||||
: spirv_const->AsBoolConstant()->value();
|
||||
@@ -1444,7 +1444,7 @@ TypedExpression ParserImpl::MakeConstantExpression(uint32_t id) {
|
||||
return {};
|
||||
}
|
||||
|
||||
ast::Expression* ParserImpl::MakeNullValue(type::Type* type) {
|
||||
ast::Expression* ParserImpl::MakeNullValue(sem::Type* type) {
|
||||
// TODO(dneto): Use the no-operands constructor syntax when it becomes
|
||||
// available in Tint.
|
||||
// https://github.com/gpuweb/gpuweb/issues/685
|
||||
@@ -1458,23 +1458,23 @@ ast::Expression* ParserImpl::MakeNullValue(type::Type* type) {
|
||||
auto* original_type = type;
|
||||
type = type->UnwrapIfNeeded();
|
||||
|
||||
if (type->Is<type::Bool>()) {
|
||||
if (type->Is<sem::Bool>()) {
|
||||
return create<ast::ScalarConstructorExpression>(
|
||||
Source{}, create<ast::BoolLiteral>(Source{}, type, false));
|
||||
}
|
||||
if (type->Is<type::U32>()) {
|
||||
if (type->Is<sem::U32>()) {
|
||||
return create<ast::ScalarConstructorExpression>(
|
||||
Source{}, create<ast::UintLiteral>(Source{}, type, 0u));
|
||||
}
|
||||
if (type->Is<type::I32>()) {
|
||||
if (type->Is<sem::I32>()) {
|
||||
return create<ast::ScalarConstructorExpression>(
|
||||
Source{}, create<ast::SintLiteral>(Source{}, type, 0));
|
||||
}
|
||||
if (type->Is<type::F32>()) {
|
||||
if (type->Is<sem::F32>()) {
|
||||
return create<ast::ScalarConstructorExpression>(
|
||||
Source{}, create<ast::FloatLiteral>(Source{}, type, 0.0f));
|
||||
}
|
||||
if (const auto* vec_ty = type->As<type::Vector>()) {
|
||||
if (const auto* vec_ty = type->As<sem::Vector>()) {
|
||||
ast::ExpressionList ast_components;
|
||||
for (size_t i = 0; i < vec_ty->size(); ++i) {
|
||||
ast_components.emplace_back(MakeNullValue(vec_ty->type()));
|
||||
@@ -1482,10 +1482,10 @@ ast::Expression* ParserImpl::MakeNullValue(type::Type* type) {
|
||||
return create<ast::TypeConstructorExpression>(Source{}, type,
|
||||
std::move(ast_components));
|
||||
}
|
||||
if (const auto* mat_ty = type->As<type::Matrix>()) {
|
||||
if (const auto* mat_ty = type->As<sem::Matrix>()) {
|
||||
// Matrix components are columns
|
||||
auto* column_ty =
|
||||
builder_.create<type::Vector>(mat_ty->type(), mat_ty->rows());
|
||||
builder_.create<sem::Vector>(mat_ty->type(), mat_ty->rows());
|
||||
ast::ExpressionList ast_components;
|
||||
for (size_t i = 0; i < mat_ty->columns(); ++i) {
|
||||
ast_components.emplace_back(MakeNullValue(column_ty));
|
||||
@@ -1493,7 +1493,7 @@ ast::Expression* ParserImpl::MakeNullValue(type::Type* type) {
|
||||
return create<ast::TypeConstructorExpression>(Source{}, type,
|
||||
std::move(ast_components));
|
||||
}
|
||||
if (auto* arr_ty = type->As<type::ArrayType>()) {
|
||||
if (auto* arr_ty = type->As<sem::ArrayType>()) {
|
||||
ast::ExpressionList ast_components;
|
||||
for (size_t i = 0; i < arr_ty->size(); ++i) {
|
||||
ast_components.emplace_back(MakeNullValue(arr_ty->type()));
|
||||
@@ -1501,7 +1501,7 @@ ast::Expression* ParserImpl::MakeNullValue(type::Type* type) {
|
||||
return create<ast::TypeConstructorExpression>(Source{}, original_type,
|
||||
std::move(ast_components));
|
||||
}
|
||||
if (auto* struct_ty = type->As<type::StructType>()) {
|
||||
if (auto* struct_ty = type->As<sem::StructType>()) {
|
||||
ast::ExpressionList ast_components;
|
||||
for (auto* member : struct_ty->impl()->members()) {
|
||||
ast_components.emplace_back(MakeNullValue(member->type()));
|
||||
@@ -1513,7 +1513,7 @@ ast::Expression* ParserImpl::MakeNullValue(type::Type* type) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
TypedExpression ParserImpl::MakeNullExpression(type::Type* type) {
|
||||
TypedExpression ParserImpl::MakeNullExpression(sem::Type* type) {
|
||||
return {type, MakeNullValue(type)};
|
||||
}
|
||||
|
||||
@@ -1567,7 +1567,7 @@ TypedExpression ParserImpl::RectifyOperandSignedness(
|
||||
|
||||
TypedExpression ParserImpl::RectifySecondOperandSignedness(
|
||||
const spvtools::opt::Instruction& inst,
|
||||
type::Type* first_operand_type,
|
||||
sem::Type* first_operand_type,
|
||||
TypedExpression&& second_operand_expr) {
|
||||
if ((first_operand_type != second_operand_expr.type) &&
|
||||
AssumesSecondOperandSignednessMatchesFirstOperand(inst.opcode())) {
|
||||
@@ -1580,8 +1580,8 @@ TypedExpression ParserImpl::RectifySecondOperandSignedness(
|
||||
return std::move(second_operand_expr);
|
||||
}
|
||||
|
||||
type::Type* ParserImpl::ForcedResultType(const spvtools::opt::Instruction& inst,
|
||||
type::Type* first_operand_type) {
|
||||
sem::Type* ParserImpl::ForcedResultType(const spvtools::opt::Instruction& inst,
|
||||
sem::Type* first_operand_type) {
|
||||
const auto opcode = inst.opcode();
|
||||
if (AssumesResultSignednessMatchesFirstOperand(opcode)) {
|
||||
return first_operand_type;
|
||||
@@ -1596,36 +1596,34 @@ type::Type* ParserImpl::ForcedResultType(const spvtools::opt::Instruction& inst,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
type::Type* ParserImpl::GetSignedIntMatchingShape(type::Type* other) {
|
||||
sem::Type* ParserImpl::GetSignedIntMatchingShape(sem::Type* other) {
|
||||
if (other == nullptr) {
|
||||
Fail() << "no type provided";
|
||||
}
|
||||
auto* i32 = builder_.create<type::I32>();
|
||||
if (other->Is<type::F32>() || other->Is<type::U32>() ||
|
||||
other->Is<type::I32>()) {
|
||||
auto* i32 = builder_.create<sem::I32>();
|
||||
if (other->Is<sem::F32>() || other->Is<sem::U32>() || other->Is<sem::I32>()) {
|
||||
return i32;
|
||||
}
|
||||
auto* vec_ty = other->As<type::Vector>();
|
||||
auto* vec_ty = other->As<sem::Vector>();
|
||||
if (vec_ty) {
|
||||
return builder_.create<type::Vector>(i32, vec_ty->size());
|
||||
return builder_.create<sem::Vector>(i32, vec_ty->size());
|
||||
}
|
||||
Fail() << "required numeric scalar or vector, but got " << other->type_name();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
type::Type* ParserImpl::GetUnsignedIntMatchingShape(type::Type* other) {
|
||||
sem::Type* ParserImpl::GetUnsignedIntMatchingShape(sem::Type* other) {
|
||||
if (other == nullptr) {
|
||||
Fail() << "no type provided";
|
||||
return nullptr;
|
||||
}
|
||||
auto* u32 = builder_.create<type::U32>();
|
||||
if (other->Is<type::F32>() || other->Is<type::U32>() ||
|
||||
other->Is<type::I32>()) {
|
||||
auto* u32 = builder_.create<sem::U32>();
|
||||
if (other->Is<sem::F32>() || other->Is<sem::U32>() || other->Is<sem::I32>()) {
|
||||
return u32;
|
||||
}
|
||||
auto* vec_ty = other->As<type::Vector>();
|
||||
auto* vec_ty = other->As<sem::Vector>();
|
||||
if (vec_ty) {
|
||||
return builder_.create<type::Vector>(u32, vec_ty->size());
|
||||
return builder_.create<sem::Vector>(u32, vec_ty->size());
|
||||
}
|
||||
Fail() << "required numeric scalar or vector, but got " << other->type_name();
|
||||
return nullptr;
|
||||
@@ -1634,7 +1632,7 @@ type::Type* ParserImpl::GetUnsignedIntMatchingShape(type::Type* other) {
|
||||
TypedExpression ParserImpl::RectifyForcedResultType(
|
||||
TypedExpression expr,
|
||||
const spvtools::opt::Instruction& inst,
|
||||
type::Type* first_operand_type) {
|
||||
sem::Type* first_operand_type) {
|
||||
auto* forced_result_ty = ForcedResultType(inst, first_operand_type);
|
||||
if ((forced_result_ty == nullptr) || (forced_result_ty == expr.type)) {
|
||||
return expr;
|
||||
@@ -1813,7 +1811,7 @@ ParserImpl::GetSpirvTypeForHandleMemoryObjectDeclaration(
|
||||
return raw_handle_type;
|
||||
}
|
||||
|
||||
type::Pointer* ParserImpl::GetTypeForHandleVar(
|
||||
sem::Pointer* ParserImpl::GetTypeForHandleVar(
|
||||
const spvtools::opt::Instruction& var) {
|
||||
auto where = handle_type_.find(&var);
|
||||
if (where != handle_type_.end()) {
|
||||
@@ -1897,11 +1895,11 @@ type::Pointer* ParserImpl::GetTypeForHandleVar(
|
||||
}
|
||||
|
||||
// Construct the Tint handle type.
|
||||
type::Type* ast_store_type = nullptr;
|
||||
sem::Type* ast_store_type = nullptr;
|
||||
if (usage.IsSampler()) {
|
||||
ast_store_type = builder_.create<type::Sampler>(
|
||||
usage.IsComparisonSampler() ? type::SamplerKind::kComparisonSampler
|
||||
: type::SamplerKind::kSampler);
|
||||
ast_store_type = builder_.create<sem::Sampler>(
|
||||
usage.IsComparisonSampler() ? sem::SamplerKind::kComparisonSampler
|
||||
: sem::SamplerKind::kSampler);
|
||||
} else if (usage.IsTexture()) {
|
||||
const spvtools::opt::analysis::Image* image_type =
|
||||
type_mgr_->GetType(raw_handle_type->result_id())->AsImage();
|
||||
@@ -1911,9 +1909,9 @@ type::Pointer* ParserImpl::GetTypeForHandleVar(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const type::TextureDimension dim =
|
||||
const sem::TextureDimension dim =
|
||||
enum_converter_.ToDim(image_type->dim(), image_type->is_arrayed());
|
||||
if (dim == type::TextureDimension::kNone) {
|
||||
if (dim == sem::TextureDimension::kNone) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -1930,13 +1928,13 @@ type::Pointer* ParserImpl::GetTypeForHandleVar(
|
||||
// OpImage variable with an OpImage*Dref* instruction. In WGSL we must
|
||||
// treat that as a depth texture.
|
||||
if (image_type->depth() || usage.IsDepthTexture()) {
|
||||
ast_store_type = builder_.create<type::DepthTexture>(dim);
|
||||
ast_store_type = builder_.create<sem::DepthTexture>(dim);
|
||||
} else if (image_type->is_multisampled()) {
|
||||
// Multisampled textures are never depth textures.
|
||||
ast_store_type = builder_.create<type::MultisampledTexture>(
|
||||
ast_store_type = builder_.create<sem::MultisampledTexture>(
|
||||
dim, ast_sampled_component_type);
|
||||
} else {
|
||||
ast_store_type = builder_.create<type::SampledTexture>(
|
||||
ast_store_type = builder_.create<sem::SampledTexture>(
|
||||
dim, ast_sampled_component_type);
|
||||
}
|
||||
} else {
|
||||
@@ -1944,13 +1942,12 @@ type::Pointer* ParserImpl::GetTypeForHandleVar(
|
||||
? ast::AccessControl::kReadOnly
|
||||
: ast::AccessControl::kWriteOnly;
|
||||
const auto format = enum_converter_.ToImageFormat(image_type->format());
|
||||
if (format == type::ImageFormat::kNone) {
|
||||
if (format == sem::ImageFormat::kNone) {
|
||||
return nullptr;
|
||||
}
|
||||
auto* subtype =
|
||||
type::StorageTexture::SubtypeFor(format, builder_.Types());
|
||||
ast_store_type = builder_.create<type::AccessControl>(
|
||||
access, builder_.create<type::StorageTexture>(dim, format, subtype));
|
||||
auto* subtype = sem::StorageTexture::SubtypeFor(format, builder_.Types());
|
||||
ast_store_type = builder_.create<sem::AccessControl>(
|
||||
access, builder_.create<sem::StorageTexture>(dim, format, subtype));
|
||||
}
|
||||
} else {
|
||||
Fail() << "unsupported: UniformConstant variable is not a recognized "
|
||||
@@ -1960,55 +1957,55 @@ type::Pointer* ParserImpl::GetTypeForHandleVar(
|
||||
}
|
||||
|
||||
// Form the pointer type.
|
||||
auto* result = builder_.create<type::Pointer>(
|
||||
auto* result = builder_.create<sem::Pointer>(
|
||||
ast_store_type, ast::StorageClass::kUniformConstant);
|
||||
// Remember it for later.
|
||||
handle_type_[&var] = result;
|
||||
return result;
|
||||
}
|
||||
|
||||
type::Type* ParserImpl::GetComponentTypeForFormat(type::ImageFormat format) {
|
||||
sem::Type* ParserImpl::GetComponentTypeForFormat(sem::ImageFormat format) {
|
||||
switch (format) {
|
||||
case type::ImageFormat::kR8Uint:
|
||||
case type::ImageFormat::kR16Uint:
|
||||
case type::ImageFormat::kRg8Uint:
|
||||
case type::ImageFormat::kR32Uint:
|
||||
case type::ImageFormat::kRg16Uint:
|
||||
case type::ImageFormat::kRgba8Uint:
|
||||
case type::ImageFormat::kRg32Uint:
|
||||
case type::ImageFormat::kRgba16Uint:
|
||||
case type::ImageFormat::kRgba32Uint:
|
||||
return builder_.create<type::U32>();
|
||||
case sem::ImageFormat::kR8Uint:
|
||||
case sem::ImageFormat::kR16Uint:
|
||||
case sem::ImageFormat::kRg8Uint:
|
||||
case sem::ImageFormat::kR32Uint:
|
||||
case sem::ImageFormat::kRg16Uint:
|
||||
case sem::ImageFormat::kRgba8Uint:
|
||||
case sem::ImageFormat::kRg32Uint:
|
||||
case sem::ImageFormat::kRgba16Uint:
|
||||
case sem::ImageFormat::kRgba32Uint:
|
||||
return builder_.create<sem::U32>();
|
||||
|
||||
case type::ImageFormat::kR8Sint:
|
||||
case type::ImageFormat::kR16Sint:
|
||||
case type::ImageFormat::kRg8Sint:
|
||||
case type::ImageFormat::kR32Sint:
|
||||
case type::ImageFormat::kRg16Sint:
|
||||
case type::ImageFormat::kRgba8Sint:
|
||||
case type::ImageFormat::kRg32Sint:
|
||||
case type::ImageFormat::kRgba16Sint:
|
||||
case type::ImageFormat::kRgba32Sint:
|
||||
return builder_.create<type::I32>();
|
||||
case sem::ImageFormat::kR8Sint:
|
||||
case sem::ImageFormat::kR16Sint:
|
||||
case sem::ImageFormat::kRg8Sint:
|
||||
case sem::ImageFormat::kR32Sint:
|
||||
case sem::ImageFormat::kRg16Sint:
|
||||
case sem::ImageFormat::kRgba8Sint:
|
||||
case sem::ImageFormat::kRg32Sint:
|
||||
case sem::ImageFormat::kRgba16Sint:
|
||||
case sem::ImageFormat::kRgba32Sint:
|
||||
return builder_.create<sem::I32>();
|
||||
|
||||
case type::ImageFormat::kR8Unorm:
|
||||
case type::ImageFormat::kRg8Unorm:
|
||||
case type::ImageFormat::kRgba8Unorm:
|
||||
case type::ImageFormat::kRgba8UnormSrgb:
|
||||
case type::ImageFormat::kBgra8Unorm:
|
||||
case type::ImageFormat::kBgra8UnormSrgb:
|
||||
case type::ImageFormat::kRgb10A2Unorm:
|
||||
case type::ImageFormat::kR8Snorm:
|
||||
case type::ImageFormat::kRg8Snorm:
|
||||
case type::ImageFormat::kRgba8Snorm:
|
||||
case type::ImageFormat::kR16Float:
|
||||
case type::ImageFormat::kR32Float:
|
||||
case type::ImageFormat::kRg16Float:
|
||||
case type::ImageFormat::kRg11B10Float:
|
||||
case type::ImageFormat::kRg32Float:
|
||||
case type::ImageFormat::kRgba16Float:
|
||||
case type::ImageFormat::kRgba32Float:
|
||||
return builder_.create<type::F32>();
|
||||
case sem::ImageFormat::kR8Unorm:
|
||||
case sem::ImageFormat::kRg8Unorm:
|
||||
case sem::ImageFormat::kRgba8Unorm:
|
||||
case sem::ImageFormat::kRgba8UnormSrgb:
|
||||
case sem::ImageFormat::kBgra8Unorm:
|
||||
case sem::ImageFormat::kBgra8UnormSrgb:
|
||||
case sem::ImageFormat::kRgb10A2Unorm:
|
||||
case sem::ImageFormat::kR8Snorm:
|
||||
case sem::ImageFormat::kRg8Snorm:
|
||||
case sem::ImageFormat::kRgba8Snorm:
|
||||
case sem::ImageFormat::kR16Float:
|
||||
case sem::ImageFormat::kR32Float:
|
||||
case sem::ImageFormat::kRg16Float:
|
||||
case sem::ImageFormat::kRg11B10Float:
|
||||
case sem::ImageFormat::kRg32Float:
|
||||
case sem::ImageFormat::kRgba16Float:
|
||||
case sem::ImageFormat::kRgba32Float:
|
||||
return builder_.create<sem::F32>();
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -2016,56 +2013,56 @@ type::Type* ParserImpl::GetComponentTypeForFormat(type::ImageFormat format) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
type::Type* ParserImpl::GetTexelTypeForFormat(type::ImageFormat format) {
|
||||
sem::Type* ParserImpl::GetTexelTypeForFormat(sem::ImageFormat format) {
|
||||
auto* component_type = GetComponentTypeForFormat(format);
|
||||
if (!component_type) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
switch (format) {
|
||||
case type::ImageFormat::kR16Float:
|
||||
case type::ImageFormat::kR16Sint:
|
||||
case type::ImageFormat::kR16Uint:
|
||||
case type::ImageFormat::kR32Float:
|
||||
case type::ImageFormat::kR32Sint:
|
||||
case type::ImageFormat::kR32Uint:
|
||||
case type::ImageFormat::kR8Sint:
|
||||
case type::ImageFormat::kR8Snorm:
|
||||
case type::ImageFormat::kR8Uint:
|
||||
case type::ImageFormat::kR8Unorm:
|
||||
case sem::ImageFormat::kR16Float:
|
||||
case sem::ImageFormat::kR16Sint:
|
||||
case sem::ImageFormat::kR16Uint:
|
||||
case sem::ImageFormat::kR32Float:
|
||||
case sem::ImageFormat::kR32Sint:
|
||||
case sem::ImageFormat::kR32Uint:
|
||||
case sem::ImageFormat::kR8Sint:
|
||||
case sem::ImageFormat::kR8Snorm:
|
||||
case sem::ImageFormat::kR8Uint:
|
||||
case sem::ImageFormat::kR8Unorm:
|
||||
// One channel
|
||||
return component_type;
|
||||
|
||||
case type::ImageFormat::kRg11B10Float:
|
||||
case type::ImageFormat::kRg16Float:
|
||||
case type::ImageFormat::kRg16Sint:
|
||||
case type::ImageFormat::kRg16Uint:
|
||||
case type::ImageFormat::kRg32Float:
|
||||
case type::ImageFormat::kRg32Sint:
|
||||
case type::ImageFormat::kRg32Uint:
|
||||
case type::ImageFormat::kRg8Sint:
|
||||
case type::ImageFormat::kRg8Snorm:
|
||||
case type::ImageFormat::kRg8Uint:
|
||||
case type::ImageFormat::kRg8Unorm:
|
||||
case sem::ImageFormat::kRg11B10Float:
|
||||
case sem::ImageFormat::kRg16Float:
|
||||
case sem::ImageFormat::kRg16Sint:
|
||||
case sem::ImageFormat::kRg16Uint:
|
||||
case sem::ImageFormat::kRg32Float:
|
||||
case sem::ImageFormat::kRg32Sint:
|
||||
case sem::ImageFormat::kRg32Uint:
|
||||
case sem::ImageFormat::kRg8Sint:
|
||||
case sem::ImageFormat::kRg8Snorm:
|
||||
case sem::ImageFormat::kRg8Uint:
|
||||
case sem::ImageFormat::kRg8Unorm:
|
||||
// Two channels
|
||||
return builder_.create<type::Vector>(component_type, 2);
|
||||
return builder_.create<sem::Vector>(component_type, 2);
|
||||
|
||||
case type::ImageFormat::kBgra8Unorm:
|
||||
case type::ImageFormat::kBgra8UnormSrgb:
|
||||
case type::ImageFormat::kRgb10A2Unorm:
|
||||
case type::ImageFormat::kRgba16Float:
|
||||
case type::ImageFormat::kRgba16Sint:
|
||||
case type::ImageFormat::kRgba16Uint:
|
||||
case type::ImageFormat::kRgba32Float:
|
||||
case type::ImageFormat::kRgba32Sint:
|
||||
case type::ImageFormat::kRgba32Uint:
|
||||
case type::ImageFormat::kRgba8Sint:
|
||||
case type::ImageFormat::kRgba8Snorm:
|
||||
case type::ImageFormat::kRgba8Uint:
|
||||
case type::ImageFormat::kRgba8Unorm:
|
||||
case type::ImageFormat::kRgba8UnormSrgb:
|
||||
case sem::ImageFormat::kBgra8Unorm:
|
||||
case sem::ImageFormat::kBgra8UnormSrgb:
|
||||
case sem::ImageFormat::kRgb10A2Unorm:
|
||||
case sem::ImageFormat::kRgba16Float:
|
||||
case sem::ImageFormat::kRgba16Sint:
|
||||
case sem::ImageFormat::kRgba16Uint:
|
||||
case sem::ImageFormat::kRgba32Float:
|
||||
case sem::ImageFormat::kRgba32Sint:
|
||||
case sem::ImageFormat::kRgba32Uint:
|
||||
case sem::ImageFormat::kRgba8Sint:
|
||||
case sem::ImageFormat::kRgba8Snorm:
|
||||
case sem::ImageFormat::kRgba8Uint:
|
||||
case sem::ImageFormat::kRgba8Unorm:
|
||||
case sem::ImageFormat::kRgba8UnormSrgb:
|
||||
// Four channels
|
||||
return builder_.create<type::Vector>(component_type, 4);
|
||||
return builder_.create<sem::Vector>(component_type, 4);
|
||||
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -61,7 +61,7 @@ using DecorationList = std::vector<Decoration>;
|
||||
/// An AST expression with its type.
|
||||
struct TypedExpression {
|
||||
/// The type
|
||||
type::Type* type = nullptr;
|
||||
sem::Type* type = nullptr;
|
||||
/// The expression
|
||||
ast::Expression* expr = nullptr;
|
||||
};
|
||||
@@ -132,7 +132,7 @@ class ParserImpl : Reader {
|
||||
/// after the internal representation of the module has been built.
|
||||
/// @param type_id the SPIR-V ID of a type.
|
||||
/// @returns a Tint type, or nullptr
|
||||
type::Type* ConvertType(uint32_t type_id);
|
||||
sem::Type* ConvertType(uint32_t type_id);
|
||||
|
||||
/// Emits an alias type declaration for the given type, if necessary, and
|
||||
/// also updates the mapping of the SPIR-V type ID to the alias type.
|
||||
@@ -294,7 +294,7 @@ class ParserImpl : Reader {
|
||||
/// in the error case
|
||||
ast::Variable* MakeVariable(uint32_t id,
|
||||
ast::StorageClass sc,
|
||||
type::Type* type,
|
||||
sem::Type* type,
|
||||
bool is_const,
|
||||
ast::Expression* constructor,
|
||||
ast::DecorationList decorations);
|
||||
@@ -307,12 +307,12 @@ class ParserImpl : Reader {
|
||||
/// Creates an AST expression node for the null value for the given type.
|
||||
/// @param type the AST type
|
||||
/// @returns a new expression
|
||||
ast::Expression* MakeNullValue(type::Type* type);
|
||||
ast::Expression* MakeNullValue(sem::Type* type);
|
||||
|
||||
/// Make a typed expression for the null value for the given type.
|
||||
/// @param type the AST type
|
||||
/// @returns a new typed expression
|
||||
TypedExpression MakeNullExpression(type::Type* type);
|
||||
TypedExpression MakeNullExpression(sem::Type* type);
|
||||
|
||||
/// Converts a given expression to the signedness demanded for an operand
|
||||
/// of the given SPIR-V instruction, if required. If the instruction assumes
|
||||
@@ -337,7 +337,7 @@ class ParserImpl : Reader {
|
||||
/// @returns second_operand_expr, or a cast of it
|
||||
TypedExpression RectifySecondOperandSignedness(
|
||||
const spvtools::opt::Instruction& inst,
|
||||
type::Type* first_operand_type,
|
||||
sem::Type* first_operand_type,
|
||||
TypedExpression&& second_operand_expr);
|
||||
|
||||
/// Returns the "forced" result type for the given SPIR-V instruction.
|
||||
@@ -348,8 +348,8 @@ class ParserImpl : Reader {
|
||||
/// @param inst the SPIR-V instruction
|
||||
/// @param first_operand_type the AST type for the first operand.
|
||||
/// @returns the forced AST result type, or nullptr if no forcing is required.
|
||||
type::Type* ForcedResultType(const spvtools::opt::Instruction& inst,
|
||||
type::Type* first_operand_type);
|
||||
sem::Type* ForcedResultType(const spvtools::opt::Instruction& inst,
|
||||
sem::Type* first_operand_type);
|
||||
|
||||
/// Returns a signed integer scalar or vector type matching the shape (scalar,
|
||||
/// vector, and component bit width) of another type, which itself is a
|
||||
@@ -357,7 +357,7 @@ class ParserImpl : Reader {
|
||||
/// requirement.
|
||||
/// @param other the type whose shape must be matched
|
||||
/// @returns the signed scalar or vector type
|
||||
type::Type* GetSignedIntMatchingShape(type::Type* other);
|
||||
sem::Type* GetSignedIntMatchingShape(sem::Type* other);
|
||||
|
||||
/// Returns a signed integer scalar or vector type matching the shape (scalar,
|
||||
/// vector, and component bit width) of another type, which itself is a
|
||||
@@ -365,7 +365,7 @@ class ParserImpl : Reader {
|
||||
/// requirement.
|
||||
/// @param other the type whose shape must be matched
|
||||
/// @returns the unsigned scalar or vector type
|
||||
type::Type* GetUnsignedIntMatchingShape(type::Type* other);
|
||||
sem::Type* GetUnsignedIntMatchingShape(sem::Type* other);
|
||||
|
||||
/// Wraps the given expression in an as-cast to the given expression's type,
|
||||
/// when the underlying operation produces a forced result type different
|
||||
@@ -378,10 +378,10 @@ class ParserImpl : Reader {
|
||||
TypedExpression RectifyForcedResultType(
|
||||
TypedExpression expr,
|
||||
const spvtools::opt::Instruction& inst,
|
||||
type::Type* first_operand_type);
|
||||
sem::Type* first_operand_type);
|
||||
|
||||
/// @returns the registered boolean type.
|
||||
type::Type* Bool() const { return bool_type_; }
|
||||
sem::Type* Bool() const { return bool_type_; }
|
||||
|
||||
/// Bookkeeping used for tracking the "position" builtin variable.
|
||||
struct BuiltInPositionInfo {
|
||||
@@ -469,18 +469,18 @@ class ParserImpl : Reader {
|
||||
/// @param var the OpVariable instruction
|
||||
/// @returns the Tint AST type for the poiner-to-{sampler|texture} or null on
|
||||
/// error
|
||||
type::Pointer* GetTypeForHandleVar(const spvtools::opt::Instruction& var);
|
||||
sem::Pointer* GetTypeForHandleVar(const spvtools::opt::Instruction& var);
|
||||
|
||||
/// Returns the channel component type corresponding to the given image
|
||||
/// format.
|
||||
/// @param format image texel format
|
||||
/// @returns the component type, one of f32, i32, u32
|
||||
type::Type* GetComponentTypeForFormat(type::ImageFormat format);
|
||||
sem::Type* GetComponentTypeForFormat(sem::ImageFormat format);
|
||||
|
||||
/// Returns texel type corresponding to the given image format.
|
||||
/// @param format image texel format
|
||||
/// @returns the texel format
|
||||
type::Type* GetTexelTypeForFormat(type::ImageFormat format);
|
||||
sem::Type* GetTexelTypeForFormat(sem::ImageFormat format);
|
||||
|
||||
/// Returns the SPIR-V instruction with the given ID, or nullptr.
|
||||
/// @param id the SPIR-V result ID
|
||||
@@ -509,20 +509,19 @@ class ParserImpl : Reader {
|
||||
|
||||
private:
|
||||
/// Converts a specific SPIR-V type to a Tint type. Integer case
|
||||
type::Type* ConvertType(const spvtools::opt::analysis::Integer* int_ty);
|
||||
sem::Type* ConvertType(const spvtools::opt::analysis::Integer* int_ty);
|
||||
/// Converts a specific SPIR-V type to a Tint type. Float case
|
||||
type::Type* ConvertType(const spvtools::opt::analysis::Float* float_ty);
|
||||
sem::Type* ConvertType(const spvtools::opt::analysis::Float* float_ty);
|
||||
/// Converts a specific SPIR-V type to a Tint type. Vector case
|
||||
type::Type* ConvertType(const spvtools::opt::analysis::Vector* vec_ty);
|
||||
sem::Type* ConvertType(const spvtools::opt::analysis::Vector* vec_ty);
|
||||
/// Converts a specific SPIR-V type to a Tint type. Matrix case
|
||||
type::Type* ConvertType(const spvtools::opt::analysis::Matrix* mat_ty);
|
||||
sem::Type* ConvertType(const spvtools::opt::analysis::Matrix* mat_ty);
|
||||
/// Converts a specific SPIR-V type to a Tint type. RuntimeArray case
|
||||
/// @param rtarr_ty the Tint type
|
||||
type::Type* ConvertType(
|
||||
const spvtools::opt::analysis::RuntimeArray* rtarr_ty);
|
||||
sem::Type* ConvertType(const spvtools::opt::analysis::RuntimeArray* rtarr_ty);
|
||||
/// Converts a specific SPIR-V type to a Tint type. Array case
|
||||
/// @param arr_ty the Tint type
|
||||
type::Type* ConvertType(const spvtools::opt::analysis::Array* arr_ty);
|
||||
sem::Type* ConvertType(const spvtools::opt::analysis::Array* arr_ty);
|
||||
/// Converts a specific SPIR-V type to a Tint type. Struct case.
|
||||
/// SPIR-V allows distinct struct type definitions for two OpTypeStruct
|
||||
/// that otherwise have the same set of members (and struct and member
|
||||
@@ -534,15 +533,15 @@ class ParserImpl : Reader {
|
||||
/// not significant to the optimizer's module representation.
|
||||
/// @param type_id the SPIR-V ID for the type.
|
||||
/// @param struct_ty the Tint type
|
||||
type::Type* ConvertType(uint32_t type_id,
|
||||
const spvtools::opt::analysis::Struct* struct_ty);
|
||||
sem::Type* ConvertType(uint32_t type_id,
|
||||
const spvtools::opt::analysis::Struct* struct_ty);
|
||||
/// Converts a specific SPIR-V type to a Tint type. Pointer case
|
||||
/// The pointer to gl_PerVertex maps to nullptr, and instead is recorded
|
||||
/// in member #builtin_position_.
|
||||
/// @param type_id the SPIR-V ID for the type.
|
||||
/// @param ptr_ty the Tint type
|
||||
type::Type* ConvertType(uint32_t type_id,
|
||||
const spvtools::opt::analysis::Pointer* ptr_ty);
|
||||
sem::Type* ConvertType(uint32_t type_id,
|
||||
const spvtools::opt::analysis::Pointer* ptr_ty);
|
||||
|
||||
/// Parses the array or runtime-array decorations.
|
||||
/// @param spv_type the SPIR-V array or runtime-array type.
|
||||
@@ -573,7 +572,7 @@ class ParserImpl : Reader {
|
||||
spvtools::MessageConsumer message_consumer_;
|
||||
|
||||
// The registered boolean type.
|
||||
type::Type* bool_type_;
|
||||
sem::Type* bool_type_;
|
||||
|
||||
// An object used to store and generate names for SPIR-V objects.
|
||||
Namer namer_;
|
||||
@@ -609,12 +608,12 @@ class ParserImpl : Reader {
|
||||
std::unordered_set<uint32_t> ignored_imports_;
|
||||
|
||||
// Maps a SPIR-V type ID to the corresponding Tint type.
|
||||
std::unordered_map<uint32_t, type::Type*> id_to_type_;
|
||||
std::unordered_map<uint32_t, sem::Type*> id_to_type_;
|
||||
|
||||
// Maps an unsigned type corresponding to the given signed type.
|
||||
std::unordered_map<type::Type*, type::Type*> signed_type_for_;
|
||||
std::unordered_map<sem::Type*, sem::Type*> signed_type_for_;
|
||||
// Maps an signed type corresponding to the given unsigned type.
|
||||
std::unordered_map<type::Type*, type::Type*> unsigned_type_for_;
|
||||
std::unordered_map<sem::Type*, sem::Type*> unsigned_type_for_;
|
||||
|
||||
// Bookkeeping for the gl_Position builtin.
|
||||
// In Vulkan SPIR-V, it's the 0 member of the gl_PerVertex structure.
|
||||
@@ -634,7 +633,7 @@ class ParserImpl : Reader {
|
||||
std::unordered_set<uint32_t> remap_buffer_block_type_;
|
||||
|
||||
// The struct types with only read-only members.
|
||||
std::unordered_set<type::Type*> read_only_struct_types_;
|
||||
std::unordered_set<sem::Type*> read_only_struct_types_;
|
||||
|
||||
// The IDs of scalar spec constants
|
||||
std::unordered_set<uint32_t> scalar_spec_constants_;
|
||||
@@ -659,7 +658,7 @@ class ParserImpl : Reader {
|
||||
// usages implied by usages of the memory-object-declaration.
|
||||
std::unordered_map<const spvtools::opt::Instruction*, Usage> handle_usage_;
|
||||
// The inferred pointer type for the given handle variable.
|
||||
std::unordered_map<const spvtools::opt::Instruction*, type::Pointer*>
|
||||
std::unordered_map<const spvtools::opt::Instruction*, sem::Pointer*>
|
||||
handle_type_;
|
||||
|
||||
/// Maps the SPIR-V ID of a module-scope builtin variable that should be
|
||||
|
||||
@@ -75,7 +75,7 @@ TEST_F(SpvParserTest, ConvertType_Void) {
|
||||
EXPECT_TRUE(p->BuildInternalModule());
|
||||
|
||||
auto* type = p->ConvertType(1);
|
||||
EXPECT_TRUE(type->Is<type::Void>());
|
||||
EXPECT_TRUE(type->Is<sem::Void>());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ TEST_F(SpvParserTest, ConvertType_Bool) {
|
||||
EXPECT_TRUE(p->BuildInternalModule());
|
||||
|
||||
auto* type = p->ConvertType(100);
|
||||
EXPECT_TRUE(type->Is<type::Bool>());
|
||||
EXPECT_TRUE(type->Is<sem::Bool>());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ TEST_F(SpvParserTest, ConvertType_I32) {
|
||||
EXPECT_TRUE(p->BuildInternalModule());
|
||||
|
||||
auto* type = p->ConvertType(2);
|
||||
EXPECT_TRUE(type->Is<type::I32>());
|
||||
EXPECT_TRUE(type->Is<sem::I32>());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ TEST_F(SpvParserTest, ConvertType_U32) {
|
||||
EXPECT_TRUE(p->BuildInternalModule());
|
||||
|
||||
auto* type = p->ConvertType(3);
|
||||
EXPECT_TRUE(type->Is<type::U32>());
|
||||
EXPECT_TRUE(type->Is<sem::U32>());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ TEST_F(SpvParserTest, ConvertType_F32) {
|
||||
EXPECT_TRUE(p->BuildInternalModule());
|
||||
|
||||
auto* type = p->ConvertType(4);
|
||||
EXPECT_TRUE(type->Is<type::F32>());
|
||||
EXPECT_TRUE(type->Is<sem::F32>());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
}
|
||||
|
||||
@@ -155,19 +155,19 @@ TEST_F(SpvParserTest, ConvertType_VecOverF32) {
|
||||
EXPECT_TRUE(p->BuildInternalModule());
|
||||
|
||||
auto* v2xf32 = p->ConvertType(20);
|
||||
EXPECT_TRUE(v2xf32->Is<type::Vector>());
|
||||
EXPECT_TRUE(v2xf32->As<type::Vector>()->type()->Is<type::F32>());
|
||||
EXPECT_EQ(v2xf32->As<type::Vector>()->size(), 2u);
|
||||
EXPECT_TRUE(v2xf32->Is<sem::Vector>());
|
||||
EXPECT_TRUE(v2xf32->As<sem::Vector>()->type()->Is<sem::F32>());
|
||||
EXPECT_EQ(v2xf32->As<sem::Vector>()->size(), 2u);
|
||||
|
||||
auto* v3xf32 = p->ConvertType(30);
|
||||
EXPECT_TRUE(v3xf32->Is<type::Vector>());
|
||||
EXPECT_TRUE(v3xf32->As<type::Vector>()->type()->Is<type::F32>());
|
||||
EXPECT_EQ(v3xf32->As<type::Vector>()->size(), 3u);
|
||||
EXPECT_TRUE(v3xf32->Is<sem::Vector>());
|
||||
EXPECT_TRUE(v3xf32->As<sem::Vector>()->type()->Is<sem::F32>());
|
||||
EXPECT_EQ(v3xf32->As<sem::Vector>()->size(), 3u);
|
||||
|
||||
auto* v4xf32 = p->ConvertType(40);
|
||||
EXPECT_TRUE(v4xf32->Is<type::Vector>());
|
||||
EXPECT_TRUE(v4xf32->As<type::Vector>()->type()->Is<type::F32>());
|
||||
EXPECT_EQ(v4xf32->As<type::Vector>()->size(), 4u);
|
||||
EXPECT_TRUE(v4xf32->Is<sem::Vector>());
|
||||
EXPECT_TRUE(v4xf32->As<sem::Vector>()->type()->Is<sem::F32>());
|
||||
EXPECT_EQ(v4xf32->As<sem::Vector>()->size(), 4u);
|
||||
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
}
|
||||
@@ -182,19 +182,19 @@ TEST_F(SpvParserTest, ConvertType_VecOverI32) {
|
||||
EXPECT_TRUE(p->BuildInternalModule());
|
||||
|
||||
auto* v2xi32 = p->ConvertType(20);
|
||||
EXPECT_TRUE(v2xi32->Is<type::Vector>());
|
||||
EXPECT_TRUE(v2xi32->As<type::Vector>()->type()->Is<type::I32>());
|
||||
EXPECT_EQ(v2xi32->As<type::Vector>()->size(), 2u);
|
||||
EXPECT_TRUE(v2xi32->Is<sem::Vector>());
|
||||
EXPECT_TRUE(v2xi32->As<sem::Vector>()->type()->Is<sem::I32>());
|
||||
EXPECT_EQ(v2xi32->As<sem::Vector>()->size(), 2u);
|
||||
|
||||
auto* v3xi32 = p->ConvertType(30);
|
||||
EXPECT_TRUE(v3xi32->Is<type::Vector>());
|
||||
EXPECT_TRUE(v3xi32->As<type::Vector>()->type()->Is<type::I32>());
|
||||
EXPECT_EQ(v3xi32->As<type::Vector>()->size(), 3u);
|
||||
EXPECT_TRUE(v3xi32->Is<sem::Vector>());
|
||||
EXPECT_TRUE(v3xi32->As<sem::Vector>()->type()->Is<sem::I32>());
|
||||
EXPECT_EQ(v3xi32->As<sem::Vector>()->size(), 3u);
|
||||
|
||||
auto* v4xi32 = p->ConvertType(40);
|
||||
EXPECT_TRUE(v4xi32->Is<type::Vector>());
|
||||
EXPECT_TRUE(v4xi32->As<type::Vector>()->type()->Is<type::I32>());
|
||||
EXPECT_EQ(v4xi32->As<type::Vector>()->size(), 4u);
|
||||
EXPECT_TRUE(v4xi32->Is<sem::Vector>());
|
||||
EXPECT_TRUE(v4xi32->As<sem::Vector>()->type()->Is<sem::I32>());
|
||||
EXPECT_EQ(v4xi32->As<sem::Vector>()->size(), 4u);
|
||||
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
}
|
||||
@@ -209,19 +209,19 @@ TEST_F(SpvParserTest, ConvertType_VecOverU32) {
|
||||
EXPECT_TRUE(p->BuildInternalModule());
|
||||
|
||||
auto* v2xu32 = p->ConvertType(20);
|
||||
EXPECT_TRUE(v2xu32->Is<type::Vector>());
|
||||
EXPECT_TRUE(v2xu32->As<type::Vector>()->type()->Is<type::U32>());
|
||||
EXPECT_EQ(v2xu32->As<type::Vector>()->size(), 2u);
|
||||
EXPECT_TRUE(v2xu32->Is<sem::Vector>());
|
||||
EXPECT_TRUE(v2xu32->As<sem::Vector>()->type()->Is<sem::U32>());
|
||||
EXPECT_EQ(v2xu32->As<sem::Vector>()->size(), 2u);
|
||||
|
||||
auto* v3xu32 = p->ConvertType(30);
|
||||
EXPECT_TRUE(v3xu32->Is<type::Vector>());
|
||||
EXPECT_TRUE(v3xu32->As<type::Vector>()->type()->Is<type::U32>());
|
||||
EXPECT_EQ(v3xu32->As<type::Vector>()->size(), 3u);
|
||||
EXPECT_TRUE(v3xu32->Is<sem::Vector>());
|
||||
EXPECT_TRUE(v3xu32->As<sem::Vector>()->type()->Is<sem::U32>());
|
||||
EXPECT_EQ(v3xu32->As<sem::Vector>()->size(), 3u);
|
||||
|
||||
auto* v4xu32 = p->ConvertType(40);
|
||||
EXPECT_TRUE(v4xu32->Is<type::Vector>());
|
||||
EXPECT_TRUE(v4xu32->As<type::Vector>()->type()->Is<type::U32>());
|
||||
EXPECT_EQ(v4xu32->As<type::Vector>()->size(), 4u);
|
||||
EXPECT_TRUE(v4xu32->Is<sem::Vector>());
|
||||
EXPECT_TRUE(v4xu32->As<sem::Vector>()->type()->Is<sem::U32>());
|
||||
EXPECT_EQ(v4xu32->As<sem::Vector>()->size(), 4u);
|
||||
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
}
|
||||
@@ -261,58 +261,58 @@ TEST_F(SpvParserTest, ConvertType_MatrixOverF32) {
|
||||
EXPECT_TRUE(p->BuildInternalModule());
|
||||
|
||||
auto* m22 = p->ConvertType(22);
|
||||
EXPECT_TRUE(m22->Is<type::Matrix>());
|
||||
EXPECT_TRUE(m22->As<type::Matrix>()->type()->Is<type::F32>());
|
||||
EXPECT_EQ(m22->As<type::Matrix>()->rows(), 2u);
|
||||
EXPECT_EQ(m22->As<type::Matrix>()->columns(), 2u);
|
||||
EXPECT_TRUE(m22->Is<sem::Matrix>());
|
||||
EXPECT_TRUE(m22->As<sem::Matrix>()->type()->Is<sem::F32>());
|
||||
EXPECT_EQ(m22->As<sem::Matrix>()->rows(), 2u);
|
||||
EXPECT_EQ(m22->As<sem::Matrix>()->columns(), 2u);
|
||||
|
||||
auto* m23 = p->ConvertType(23);
|
||||
EXPECT_TRUE(m23->Is<type::Matrix>());
|
||||
EXPECT_TRUE(m23->As<type::Matrix>()->type()->Is<type::F32>());
|
||||
EXPECT_EQ(m23->As<type::Matrix>()->rows(), 2u);
|
||||
EXPECT_EQ(m23->As<type::Matrix>()->columns(), 3u);
|
||||
EXPECT_TRUE(m23->Is<sem::Matrix>());
|
||||
EXPECT_TRUE(m23->As<sem::Matrix>()->type()->Is<sem::F32>());
|
||||
EXPECT_EQ(m23->As<sem::Matrix>()->rows(), 2u);
|
||||
EXPECT_EQ(m23->As<sem::Matrix>()->columns(), 3u);
|
||||
|
||||
auto* m24 = p->ConvertType(24);
|
||||
EXPECT_TRUE(m24->Is<type::Matrix>());
|
||||
EXPECT_TRUE(m24->As<type::Matrix>()->type()->Is<type::F32>());
|
||||
EXPECT_EQ(m24->As<type::Matrix>()->rows(), 2u);
|
||||
EXPECT_EQ(m24->As<type::Matrix>()->columns(), 4u);
|
||||
EXPECT_TRUE(m24->Is<sem::Matrix>());
|
||||
EXPECT_TRUE(m24->As<sem::Matrix>()->type()->Is<sem::F32>());
|
||||
EXPECT_EQ(m24->As<sem::Matrix>()->rows(), 2u);
|
||||
EXPECT_EQ(m24->As<sem::Matrix>()->columns(), 4u);
|
||||
|
||||
auto* m32 = p->ConvertType(32);
|
||||
EXPECT_TRUE(m32->Is<type::Matrix>());
|
||||
EXPECT_TRUE(m32->As<type::Matrix>()->type()->Is<type::F32>());
|
||||
EXPECT_EQ(m32->As<type::Matrix>()->rows(), 3u);
|
||||
EXPECT_EQ(m32->As<type::Matrix>()->columns(), 2u);
|
||||
EXPECT_TRUE(m32->Is<sem::Matrix>());
|
||||
EXPECT_TRUE(m32->As<sem::Matrix>()->type()->Is<sem::F32>());
|
||||
EXPECT_EQ(m32->As<sem::Matrix>()->rows(), 3u);
|
||||
EXPECT_EQ(m32->As<sem::Matrix>()->columns(), 2u);
|
||||
|
||||
auto* m33 = p->ConvertType(33);
|
||||
EXPECT_TRUE(m33->Is<type::Matrix>());
|
||||
EXPECT_TRUE(m33->As<type::Matrix>()->type()->Is<type::F32>());
|
||||
EXPECT_EQ(m33->As<type::Matrix>()->rows(), 3u);
|
||||
EXPECT_EQ(m33->As<type::Matrix>()->columns(), 3u);
|
||||
EXPECT_TRUE(m33->Is<sem::Matrix>());
|
||||
EXPECT_TRUE(m33->As<sem::Matrix>()->type()->Is<sem::F32>());
|
||||
EXPECT_EQ(m33->As<sem::Matrix>()->rows(), 3u);
|
||||
EXPECT_EQ(m33->As<sem::Matrix>()->columns(), 3u);
|
||||
|
||||
auto* m34 = p->ConvertType(34);
|
||||
EXPECT_TRUE(m34->Is<type::Matrix>());
|
||||
EXPECT_TRUE(m34->As<type::Matrix>()->type()->Is<type::F32>());
|
||||
EXPECT_EQ(m34->As<type::Matrix>()->rows(), 3u);
|
||||
EXPECT_EQ(m34->As<type::Matrix>()->columns(), 4u);
|
||||
EXPECT_TRUE(m34->Is<sem::Matrix>());
|
||||
EXPECT_TRUE(m34->As<sem::Matrix>()->type()->Is<sem::F32>());
|
||||
EXPECT_EQ(m34->As<sem::Matrix>()->rows(), 3u);
|
||||
EXPECT_EQ(m34->As<sem::Matrix>()->columns(), 4u);
|
||||
|
||||
auto* m42 = p->ConvertType(42);
|
||||
EXPECT_TRUE(m42->Is<type::Matrix>());
|
||||
EXPECT_TRUE(m42->As<type::Matrix>()->type()->Is<type::F32>());
|
||||
EXPECT_EQ(m42->As<type::Matrix>()->rows(), 4u);
|
||||
EXPECT_EQ(m42->As<type::Matrix>()->columns(), 2u);
|
||||
EXPECT_TRUE(m42->Is<sem::Matrix>());
|
||||
EXPECT_TRUE(m42->As<sem::Matrix>()->type()->Is<sem::F32>());
|
||||
EXPECT_EQ(m42->As<sem::Matrix>()->rows(), 4u);
|
||||
EXPECT_EQ(m42->As<sem::Matrix>()->columns(), 2u);
|
||||
|
||||
auto* m43 = p->ConvertType(43);
|
||||
EXPECT_TRUE(m43->Is<type::Matrix>());
|
||||
EXPECT_TRUE(m43->As<type::Matrix>()->type()->Is<type::F32>());
|
||||
EXPECT_EQ(m43->As<type::Matrix>()->rows(), 4u);
|
||||
EXPECT_EQ(m43->As<type::Matrix>()->columns(), 3u);
|
||||
EXPECT_TRUE(m43->Is<sem::Matrix>());
|
||||
EXPECT_TRUE(m43->As<sem::Matrix>()->type()->Is<sem::F32>());
|
||||
EXPECT_EQ(m43->As<sem::Matrix>()->rows(), 4u);
|
||||
EXPECT_EQ(m43->As<sem::Matrix>()->columns(), 3u);
|
||||
|
||||
auto* m44 = p->ConvertType(44);
|
||||
EXPECT_TRUE(m44->Is<type::Matrix>());
|
||||
EXPECT_TRUE(m44->As<type::Matrix>()->type()->Is<type::F32>());
|
||||
EXPECT_EQ(m44->As<type::Matrix>()->rows(), 4u);
|
||||
EXPECT_EQ(m44->As<type::Matrix>()->columns(), 4u);
|
||||
EXPECT_TRUE(m44->Is<sem::Matrix>());
|
||||
EXPECT_TRUE(m44->As<sem::Matrix>()->type()->Is<sem::F32>());
|
||||
EXPECT_EQ(m44->As<sem::Matrix>()->rows(), 4u);
|
||||
EXPECT_EQ(m44->As<sem::Matrix>()->columns(), 4u);
|
||||
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
}
|
||||
@@ -326,15 +326,15 @@ TEST_F(SpvParserTest, ConvertType_RuntimeArray) {
|
||||
|
||||
auto* type = p->ConvertType(10);
|
||||
ASSERT_NE(type, nullptr);
|
||||
EXPECT_TRUE(type->Is<type::ArrayType>());
|
||||
auto* arr_type = type->As<type::ArrayType>();
|
||||
EXPECT_TRUE(type->Is<sem::ArrayType>());
|
||||
auto* arr_type = type->As<sem::ArrayType>();
|
||||
EXPECT_TRUE(arr_type->IsRuntimeArray());
|
||||
ASSERT_NE(arr_type, nullptr);
|
||||
EXPECT_EQ(arr_type->size(), 0u);
|
||||
EXPECT_EQ(arr_type->decorations().size(), 0u);
|
||||
auto* elem_type = arr_type->type();
|
||||
ASSERT_NE(elem_type, nullptr);
|
||||
EXPECT_TRUE(elem_type->Is<type::U32>());
|
||||
EXPECT_TRUE(elem_type->Is<sem::U32>());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
}
|
||||
|
||||
@@ -361,7 +361,7 @@ TEST_F(SpvParserTest, ConvertType_RuntimeArray_ArrayStride_Valid) {
|
||||
EXPECT_TRUE(p->BuildInternalModule());
|
||||
auto* type = p->ConvertType(10);
|
||||
ASSERT_NE(type, nullptr);
|
||||
auto* arr_type = type->As<type::ArrayType>();
|
||||
auto* arr_type = type->As<sem::ArrayType>();
|
||||
EXPECT_TRUE(arr_type->IsRuntimeArray());
|
||||
ASSERT_NE(arr_type, nullptr);
|
||||
ASSERT_EQ(arr_type->decorations().size(), 1u);
|
||||
@@ -409,15 +409,15 @@ TEST_F(SpvParserTest, ConvertType_Array) {
|
||||
|
||||
auto* type = p->ConvertType(10);
|
||||
ASSERT_NE(type, nullptr);
|
||||
EXPECT_TRUE(type->Is<type::ArrayType>());
|
||||
auto* arr_type = type->As<type::ArrayType>();
|
||||
EXPECT_TRUE(type->Is<sem::ArrayType>());
|
||||
auto* arr_type = type->As<sem::ArrayType>();
|
||||
EXPECT_FALSE(arr_type->IsRuntimeArray());
|
||||
ASSERT_NE(arr_type, nullptr);
|
||||
EXPECT_EQ(arr_type->size(), 42u);
|
||||
EXPECT_EQ(arr_type->decorations().size(), 0u);
|
||||
auto* elem_type = arr_type->type();
|
||||
ASSERT_NE(elem_type, nullptr);
|
||||
EXPECT_TRUE(elem_type->Is<type::U32>());
|
||||
EXPECT_TRUE(elem_type->Is<sem::U32>());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
}
|
||||
|
||||
@@ -496,8 +496,8 @@ TEST_F(SpvParserTest, ConvertType_ArrayStride_Valid) {
|
||||
|
||||
auto* type = p->ConvertType(10);
|
||||
ASSERT_NE(type, nullptr);
|
||||
EXPECT_TRUE(type->Is<type::ArrayType>());
|
||||
auto* arr_type = type->As<type::ArrayType>();
|
||||
EXPECT_TRUE(type->Is<sem::ArrayType>());
|
||||
auto* arr_type = type->As<sem::ArrayType>();
|
||||
ASSERT_NE(arr_type, nullptr);
|
||||
|
||||
ASSERT_EQ(arr_type->decorations().size(), 1u);
|
||||
@@ -550,10 +550,10 @@ TEST_F(SpvParserTest, ConvertType_StructTwoMembers) {
|
||||
|
||||
auto* type = p->ConvertType(10);
|
||||
ASSERT_NE(type, nullptr);
|
||||
EXPECT_TRUE(type->Is<type::StructType>());
|
||||
EXPECT_TRUE(type->Is<sem::StructType>());
|
||||
|
||||
Program program = p->program();
|
||||
EXPECT_THAT(program.str(type->As<type::StructType>()->impl()), Eq(R"(Struct{
|
||||
EXPECT_THAT(program.str(type->As<sem::StructType>()->impl()), Eq(R"(Struct{
|
||||
StructMember{field0: __u32}
|
||||
StructMember{field1: __f32}
|
||||
}
|
||||
@@ -571,10 +571,10 @@ TEST_F(SpvParserTest, ConvertType_StructWithBlockDecoration) {
|
||||
|
||||
auto* type = p->ConvertType(10);
|
||||
ASSERT_NE(type, nullptr);
|
||||
EXPECT_TRUE(type->Is<type::StructType>());
|
||||
EXPECT_TRUE(type->Is<sem::StructType>());
|
||||
|
||||
Program program = p->program();
|
||||
EXPECT_THAT(program.str(type->As<type::StructType>()->impl()), Eq(R"(Struct{
|
||||
EXPECT_THAT(program.str(type->As<sem::StructType>()->impl()), Eq(R"(Struct{
|
||||
[[block]]
|
||||
StructMember{field0: __u32}
|
||||
}
|
||||
@@ -596,10 +596,10 @@ TEST_F(SpvParserTest, ConvertType_StructWithMemberDecorations) {
|
||||
|
||||
auto* type = p->ConvertType(10);
|
||||
ASSERT_NE(type, nullptr);
|
||||
EXPECT_TRUE(type->Is<type::StructType>());
|
||||
EXPECT_TRUE(type->Is<sem::StructType>());
|
||||
|
||||
Program program = p->program();
|
||||
EXPECT_THAT(program.str(type->As<type::StructType>()->impl()), Eq(R"(Struct{
|
||||
EXPECT_THAT(program.str(type->As<sem::StructType>()->impl()), Eq(R"(Struct{
|
||||
StructMember{[[ offset 0 ]] field0: __f32}
|
||||
StructMember{[[ offset 8 ]] field1: __vec_2__f32}
|
||||
StructMember{[[ offset 16 ]] field2: __mat_2_2__f32}
|
||||
@@ -645,10 +645,10 @@ TEST_F(SpvParserTest, ConvertType_PointerInput) {
|
||||
EXPECT_TRUE(p->BuildInternalModule());
|
||||
|
||||
auto* type = p->ConvertType(3);
|
||||
EXPECT_TRUE(type->Is<type::Pointer>());
|
||||
auto* ptr_ty = type->As<type::Pointer>();
|
||||
EXPECT_TRUE(type->Is<sem::Pointer>());
|
||||
auto* ptr_ty = type->As<sem::Pointer>();
|
||||
EXPECT_NE(ptr_ty, nullptr);
|
||||
EXPECT_TRUE(ptr_ty->type()->Is<type::F32>());
|
||||
EXPECT_TRUE(ptr_ty->type()->Is<sem::F32>());
|
||||
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kInput);
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
}
|
||||
@@ -661,10 +661,10 @@ TEST_F(SpvParserTest, ConvertType_PointerOutput) {
|
||||
EXPECT_TRUE(p->BuildInternalModule());
|
||||
|
||||
auto* type = p->ConvertType(3);
|
||||
EXPECT_TRUE(type->Is<type::Pointer>());
|
||||
auto* ptr_ty = type->As<type::Pointer>();
|
||||
EXPECT_TRUE(type->Is<sem::Pointer>());
|
||||
auto* ptr_ty = type->As<sem::Pointer>();
|
||||
EXPECT_NE(ptr_ty, nullptr);
|
||||
EXPECT_TRUE(ptr_ty->type()->Is<type::F32>());
|
||||
EXPECT_TRUE(ptr_ty->type()->Is<sem::F32>());
|
||||
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kOutput);
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
}
|
||||
@@ -677,10 +677,10 @@ TEST_F(SpvParserTest, ConvertType_PointerUniform) {
|
||||
EXPECT_TRUE(p->BuildInternalModule());
|
||||
|
||||
auto* type = p->ConvertType(3);
|
||||
EXPECT_TRUE(type->Is<type::Pointer>());
|
||||
auto* ptr_ty = type->As<type::Pointer>();
|
||||
EXPECT_TRUE(type->Is<sem::Pointer>());
|
||||
auto* ptr_ty = type->As<sem::Pointer>();
|
||||
EXPECT_NE(ptr_ty, nullptr);
|
||||
EXPECT_TRUE(ptr_ty->type()->Is<type::F32>());
|
||||
EXPECT_TRUE(ptr_ty->type()->Is<sem::F32>());
|
||||
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kUniform);
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
}
|
||||
@@ -693,10 +693,10 @@ TEST_F(SpvParserTest, ConvertType_PointerWorkgroup) {
|
||||
EXPECT_TRUE(p->BuildInternalModule());
|
||||
|
||||
auto* type = p->ConvertType(3);
|
||||
EXPECT_TRUE(type->Is<type::Pointer>());
|
||||
auto* ptr_ty = type->As<type::Pointer>();
|
||||
EXPECT_TRUE(type->Is<sem::Pointer>());
|
||||
auto* ptr_ty = type->As<sem::Pointer>();
|
||||
EXPECT_NE(ptr_ty, nullptr);
|
||||
EXPECT_TRUE(ptr_ty->type()->Is<type::F32>());
|
||||
EXPECT_TRUE(ptr_ty->type()->Is<sem::F32>());
|
||||
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kWorkgroup);
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
}
|
||||
@@ -709,10 +709,10 @@ TEST_F(SpvParserTest, ConvertType_PointerUniformConstant) {
|
||||
EXPECT_TRUE(p->BuildInternalModule());
|
||||
|
||||
auto* type = p->ConvertType(3);
|
||||
EXPECT_TRUE(type->Is<type::Pointer>());
|
||||
auto* ptr_ty = type->As<type::Pointer>();
|
||||
EXPECT_TRUE(type->Is<sem::Pointer>());
|
||||
auto* ptr_ty = type->As<sem::Pointer>();
|
||||
EXPECT_NE(ptr_ty, nullptr);
|
||||
EXPECT_TRUE(ptr_ty->type()->Is<type::F32>());
|
||||
EXPECT_TRUE(ptr_ty->type()->Is<sem::F32>());
|
||||
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kUniformConstant);
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
}
|
||||
@@ -725,10 +725,10 @@ TEST_F(SpvParserTest, ConvertType_PointerStorageBuffer) {
|
||||
EXPECT_TRUE(p->BuildInternalModule());
|
||||
|
||||
auto* type = p->ConvertType(3);
|
||||
EXPECT_TRUE(type->Is<type::Pointer>());
|
||||
auto* ptr_ty = type->As<type::Pointer>();
|
||||
EXPECT_TRUE(type->Is<sem::Pointer>());
|
||||
auto* ptr_ty = type->As<sem::Pointer>();
|
||||
EXPECT_NE(ptr_ty, nullptr);
|
||||
EXPECT_TRUE(ptr_ty->type()->Is<type::F32>());
|
||||
EXPECT_TRUE(ptr_ty->type()->Is<sem::F32>());
|
||||
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kStorage);
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
}
|
||||
@@ -741,10 +741,10 @@ TEST_F(SpvParserTest, ConvertType_PointerImage) {
|
||||
EXPECT_TRUE(p->BuildInternalModule());
|
||||
|
||||
auto* type = p->ConvertType(3);
|
||||
EXPECT_TRUE(type->Is<type::Pointer>());
|
||||
auto* ptr_ty = type->As<type::Pointer>();
|
||||
EXPECT_TRUE(type->Is<sem::Pointer>());
|
||||
auto* ptr_ty = type->As<sem::Pointer>();
|
||||
EXPECT_NE(ptr_ty, nullptr);
|
||||
EXPECT_TRUE(ptr_ty->type()->Is<type::F32>());
|
||||
EXPECT_TRUE(ptr_ty->type()->Is<sem::F32>());
|
||||
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kImage);
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
}
|
||||
@@ -757,10 +757,10 @@ TEST_F(SpvParserTest, ConvertType_PointerPrivate) {
|
||||
EXPECT_TRUE(p->BuildInternalModule());
|
||||
|
||||
auto* type = p->ConvertType(3);
|
||||
EXPECT_TRUE(type->Is<type::Pointer>());
|
||||
auto* ptr_ty = type->As<type::Pointer>();
|
||||
EXPECT_TRUE(type->Is<sem::Pointer>());
|
||||
auto* ptr_ty = type->As<sem::Pointer>();
|
||||
EXPECT_NE(ptr_ty, nullptr);
|
||||
EXPECT_TRUE(ptr_ty->type()->Is<type::F32>());
|
||||
EXPECT_TRUE(ptr_ty->type()->Is<sem::F32>());
|
||||
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kPrivate);
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
}
|
||||
@@ -773,10 +773,10 @@ TEST_F(SpvParserTest, ConvertType_PointerFunction) {
|
||||
EXPECT_TRUE(p->BuildInternalModule());
|
||||
|
||||
auto* type = p->ConvertType(3);
|
||||
EXPECT_TRUE(type->Is<type::Pointer>());
|
||||
auto* ptr_ty = type->As<type::Pointer>();
|
||||
EXPECT_TRUE(type->Is<sem::Pointer>());
|
||||
auto* ptr_ty = type->As<sem::Pointer>();
|
||||
EXPECT_NE(ptr_ty, nullptr);
|
||||
EXPECT_TRUE(ptr_ty->type()->Is<type::F32>());
|
||||
EXPECT_TRUE(ptr_ty->type()->Is<sem::F32>());
|
||||
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kFunction);
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
}
|
||||
@@ -792,17 +792,17 @@ TEST_F(SpvParserTest, ConvertType_PointerToPointer) {
|
||||
|
||||
auto* type = p->ConvertType(3);
|
||||
EXPECT_NE(type, nullptr);
|
||||
EXPECT_TRUE(type->Is<type::Pointer>());
|
||||
EXPECT_TRUE(type->Is<sem::Pointer>());
|
||||
|
||||
auto* ptr_ty = type->As<type::Pointer>();
|
||||
auto* ptr_ty = type->As<sem::Pointer>();
|
||||
EXPECT_NE(ptr_ty, nullptr);
|
||||
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kInput);
|
||||
EXPECT_TRUE(ptr_ty->type()->Is<type::Pointer>());
|
||||
EXPECT_TRUE(ptr_ty->type()->Is<sem::Pointer>());
|
||||
|
||||
auto* ptr_ptr_ty = ptr_ty->type()->As<type::Pointer>();
|
||||
auto* ptr_ptr_ty = ptr_ty->type()->As<sem::Pointer>();
|
||||
EXPECT_NE(ptr_ptr_ty, nullptr);
|
||||
EXPECT_EQ(ptr_ptr_ty->storage_class(), ast::StorageClass::kOutput);
|
||||
EXPECT_TRUE(ptr_ptr_ty->type()->Is<type::F32>());
|
||||
EXPECT_TRUE(ptr_ptr_ty->type()->Is<sem::F32>());
|
||||
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
}
|
||||
@@ -815,7 +815,7 @@ TEST_F(SpvParserTest, ConvertType_Sampler_PretendVoid) {
|
||||
EXPECT_TRUE(p->BuildInternalModule());
|
||||
|
||||
auto* type = p->ConvertType(1);
|
||||
EXPECT_TRUE(type->Is<type::Void>());
|
||||
EXPECT_TRUE(type->Is<sem::Void>());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
}
|
||||
|
||||
@@ -828,7 +828,7 @@ TEST_F(SpvParserTest, ConvertType_Image_PretendVoid) {
|
||||
EXPECT_TRUE(p->BuildInternalModule());
|
||||
|
||||
auto* type = p->ConvertType(1);
|
||||
EXPECT_TRUE(type->Is<type::Void>());
|
||||
EXPECT_TRUE(type->Is<sem::Void>());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
}
|
||||
|
||||
@@ -841,7 +841,7 @@ TEST_F(SpvParserTest, ConvertType_SampledImage_PretendVoid) {
|
||||
EXPECT_TRUE(p->BuildInternalModule());
|
||||
|
||||
auto* type = p->ConvertType(1);
|
||||
EXPECT_TRUE(type->Is<type::Void>());
|
||||
EXPECT_TRUE(type->Is<sem::Void>());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
}
|
||||
|
||||
|
||||
@@ -173,7 +173,7 @@ ParserImpl::FunctionHeader::FunctionHeader(const FunctionHeader&) = default;
|
||||
ParserImpl::FunctionHeader::FunctionHeader(Source src,
|
||||
std::string n,
|
||||
ast::VariableList p,
|
||||
type::Type* ret_ty,
|
||||
sem::Type* ret_ty,
|
||||
ast::DecorationList ret_decos)
|
||||
: source(src),
|
||||
name(n),
|
||||
@@ -243,11 +243,11 @@ Token ParserImpl::peek() {
|
||||
}
|
||||
|
||||
void ParserImpl::register_constructed(const std::string& name,
|
||||
type::Type* type) {
|
||||
sem::Type* type) {
|
||||
registered_constructs_[name] = type;
|
||||
}
|
||||
|
||||
type::Type* ParserImpl::get_constructed(const std::string& name) {
|
||||
sem::Type* ParserImpl::get_constructed(const std::string& name) {
|
||||
if (registered_constructs_.find(name) == registered_constructs_.end()) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -507,7 +507,7 @@ Maybe<ParserImpl::VarDeclInfo> ParserImpl::variable_decl() {
|
||||
// | sampled_texture_type LESS_THAN type_decl GREATER_THAN
|
||||
// | multisampled_texture_type LESS_THAN type_decl GREATER_THAN
|
||||
// | storage_texture_type LESS_THAN image_storage_type GREATER_THAN
|
||||
Maybe<type::Type*> ParserImpl::texture_sampler_types() {
|
||||
Maybe<sem::Type*> ParserImpl::texture_sampler_types() {
|
||||
auto type = sampler_type();
|
||||
if (type.matched)
|
||||
return type;
|
||||
@@ -524,7 +524,7 @@ Maybe<type::Type*> ParserImpl::texture_sampler_types() {
|
||||
if (subtype.errored)
|
||||
return Failure::kErrored;
|
||||
|
||||
return builder_.create<type::SampledTexture>(dim.value, subtype.value);
|
||||
return builder_.create<sem::SampledTexture>(dim.value, subtype.value);
|
||||
}
|
||||
|
||||
auto ms_dim = multisampled_texture_type();
|
||||
@@ -535,8 +535,8 @@ Maybe<type::Type*> ParserImpl::texture_sampler_types() {
|
||||
if (subtype.errored)
|
||||
return Failure::kErrored;
|
||||
|
||||
return builder_.create<type::MultisampledTexture>(ms_dim.value,
|
||||
subtype.value);
|
||||
return builder_.create<sem::MultisampledTexture>(ms_dim.value,
|
||||
subtype.value);
|
||||
}
|
||||
|
||||
auto storage = storage_texture_type();
|
||||
@@ -550,9 +550,9 @@ Maybe<type::Type*> ParserImpl::texture_sampler_types() {
|
||||
return Failure::kErrored;
|
||||
|
||||
auto* subtype =
|
||||
type::StorageTexture::SubtypeFor(format.value, builder_.Types());
|
||||
return builder_.create<type::StorageTexture>(storage.value, format.value,
|
||||
subtype);
|
||||
sem::StorageTexture::SubtypeFor(format.value, builder_.Types());
|
||||
return builder_.create<sem::StorageTexture>(storage.value, format.value,
|
||||
subtype);
|
||||
}
|
||||
|
||||
return Failure::kNoMatch;
|
||||
@@ -561,13 +561,12 @@ Maybe<type::Type*> ParserImpl::texture_sampler_types() {
|
||||
// sampler_type
|
||||
// : SAMPLER
|
||||
// | SAMPLER_COMPARISON
|
||||
Maybe<type::Type*> ParserImpl::sampler_type() {
|
||||
Maybe<sem::Type*> ParserImpl::sampler_type() {
|
||||
if (match(Token::Type::kSampler))
|
||||
return builder_.create<type::Sampler>(type::SamplerKind::kSampler);
|
||||
return builder_.create<sem::Sampler>(sem::SamplerKind::kSampler);
|
||||
|
||||
if (match(Token::Type::kComparisonSampler))
|
||||
return builder_.create<type::Sampler>(
|
||||
type::SamplerKind::kComparisonSampler);
|
||||
return builder_.create<sem::Sampler>(sem::SamplerKind::kComparisonSampler);
|
||||
|
||||
return Failure::kNoMatch;
|
||||
}
|
||||
@@ -579,33 +578,33 @@ Maybe<type::Type*> ParserImpl::sampler_type() {
|
||||
// | TEXTURE_SAMPLED_3D
|
||||
// | TEXTURE_SAMPLED_CUBE
|
||||
// | TEXTURE_SAMPLED_CUBE_ARRAY
|
||||
Maybe<type::TextureDimension> ParserImpl::sampled_texture_type() {
|
||||
Maybe<sem::TextureDimension> ParserImpl::sampled_texture_type() {
|
||||
if (match(Token::Type::kTextureSampled1d))
|
||||
return type::TextureDimension::k1d;
|
||||
return sem::TextureDimension::k1d;
|
||||
|
||||
if (match(Token::Type::kTextureSampled2d))
|
||||
return type::TextureDimension::k2d;
|
||||
return sem::TextureDimension::k2d;
|
||||
|
||||
if (match(Token::Type::kTextureSampled2dArray))
|
||||
return type::TextureDimension::k2dArray;
|
||||
return sem::TextureDimension::k2dArray;
|
||||
|
||||
if (match(Token::Type::kTextureSampled3d))
|
||||
return type::TextureDimension::k3d;
|
||||
return sem::TextureDimension::k3d;
|
||||
|
||||
if (match(Token::Type::kTextureSampledCube))
|
||||
return type::TextureDimension::kCube;
|
||||
return sem::TextureDimension::kCube;
|
||||
|
||||
if (match(Token::Type::kTextureSampledCubeArray))
|
||||
return type::TextureDimension::kCubeArray;
|
||||
return sem::TextureDimension::kCubeArray;
|
||||
|
||||
return Failure::kNoMatch;
|
||||
}
|
||||
|
||||
// multisampled_texture_type
|
||||
// : TEXTURE_MULTISAMPLED_2D
|
||||
Maybe<type::TextureDimension> ParserImpl::multisampled_texture_type() {
|
||||
Maybe<sem::TextureDimension> ParserImpl::multisampled_texture_type() {
|
||||
if (match(Token::Type::kTextureMultisampled2d))
|
||||
return type::TextureDimension::k2d;
|
||||
return sem::TextureDimension::k2d;
|
||||
|
||||
return Failure::kNoMatch;
|
||||
}
|
||||
@@ -615,15 +614,15 @@ Maybe<type::TextureDimension> ParserImpl::multisampled_texture_type() {
|
||||
// | TEXTURE_STORAGE_2D
|
||||
// | TEXTURE_STORAGE_2D_ARRAY
|
||||
// | TEXTURE_STORAGE_3D
|
||||
Maybe<type::TextureDimension> ParserImpl::storage_texture_type() {
|
||||
Maybe<sem::TextureDimension> ParserImpl::storage_texture_type() {
|
||||
if (match(Token::Type::kTextureStorage1d))
|
||||
return type::TextureDimension::k1d;
|
||||
return sem::TextureDimension::k1d;
|
||||
if (match(Token::Type::kTextureStorage2d))
|
||||
return type::TextureDimension::k2d;
|
||||
return sem::TextureDimension::k2d;
|
||||
if (match(Token::Type::kTextureStorage2dArray))
|
||||
return type::TextureDimension::k2dArray;
|
||||
return sem::TextureDimension::k2dArray;
|
||||
if (match(Token::Type::kTextureStorage3d))
|
||||
return type::TextureDimension::k3d;
|
||||
return sem::TextureDimension::k3d;
|
||||
|
||||
return Failure::kNoMatch;
|
||||
}
|
||||
@@ -633,20 +632,19 @@ Maybe<type::TextureDimension> ParserImpl::storage_texture_type() {
|
||||
// | TEXTURE_DEPTH_2D_ARRAY
|
||||
// | TEXTURE_DEPTH_CUBE
|
||||
// | TEXTURE_DEPTH_CUBE_ARRAY
|
||||
Maybe<type::Type*> ParserImpl::depth_texture_type() {
|
||||
Maybe<sem::Type*> ParserImpl::depth_texture_type() {
|
||||
if (match(Token::Type::kTextureDepth2d))
|
||||
return builder_.create<type::DepthTexture>(type::TextureDimension::k2d);
|
||||
return builder_.create<sem::DepthTexture>(sem::TextureDimension::k2d);
|
||||
|
||||
if (match(Token::Type::kTextureDepth2dArray))
|
||||
return builder_.create<type::DepthTexture>(
|
||||
type::TextureDimension::k2dArray);
|
||||
return builder_.create<sem::DepthTexture>(sem::TextureDimension::k2dArray);
|
||||
|
||||
if (match(Token::Type::kTextureDepthCube))
|
||||
return builder_.create<type::DepthTexture>(type::TextureDimension::kCube);
|
||||
return builder_.create<sem::DepthTexture>(sem::TextureDimension::kCube);
|
||||
|
||||
if (match(Token::Type::kTextureDepthCubeArray))
|
||||
return builder_.create<type::DepthTexture>(
|
||||
type::TextureDimension::kCubeArray);
|
||||
return builder_.create<sem::DepthTexture>(
|
||||
sem::TextureDimension::kCubeArray);
|
||||
|
||||
return Failure::kNoMatch;
|
||||
}
|
||||
@@ -687,112 +685,112 @@ Maybe<type::Type*> ParserImpl::depth_texture_type() {
|
||||
// | RGBA32UINT
|
||||
// | RGBA32SINT
|
||||
// | RGBA32FLOAT
|
||||
Expect<type::ImageFormat> ParserImpl::expect_image_storage_type(
|
||||
Expect<sem::ImageFormat> ParserImpl::expect_image_storage_type(
|
||||
const std::string& use) {
|
||||
if (match(Token::Type::kFormatR8Unorm))
|
||||
return type::ImageFormat::kR8Unorm;
|
||||
return sem::ImageFormat::kR8Unorm;
|
||||
|
||||
if (match(Token::Type::kFormatR8Snorm))
|
||||
return type::ImageFormat::kR8Snorm;
|
||||
return sem::ImageFormat::kR8Snorm;
|
||||
|
||||
if (match(Token::Type::kFormatR8Uint))
|
||||
return type::ImageFormat::kR8Uint;
|
||||
return sem::ImageFormat::kR8Uint;
|
||||
|
||||
if (match(Token::Type::kFormatR8Sint))
|
||||
return type::ImageFormat::kR8Sint;
|
||||
return sem::ImageFormat::kR8Sint;
|
||||
|
||||
if (match(Token::Type::kFormatR16Uint))
|
||||
return type::ImageFormat::kR16Uint;
|
||||
return sem::ImageFormat::kR16Uint;
|
||||
|
||||
if (match(Token::Type::kFormatR16Sint))
|
||||
return type::ImageFormat::kR16Sint;
|
||||
return sem::ImageFormat::kR16Sint;
|
||||
|
||||
if (match(Token::Type::kFormatR16Float))
|
||||
return type::ImageFormat::kR16Float;
|
||||
return sem::ImageFormat::kR16Float;
|
||||
|
||||
if (match(Token::Type::kFormatRg8Unorm))
|
||||
return type::ImageFormat::kRg8Unorm;
|
||||
return sem::ImageFormat::kRg8Unorm;
|
||||
|
||||
if (match(Token::Type::kFormatRg8Snorm))
|
||||
return type::ImageFormat::kRg8Snorm;
|
||||
return sem::ImageFormat::kRg8Snorm;
|
||||
|
||||
if (match(Token::Type::kFormatRg8Uint))
|
||||
return type::ImageFormat::kRg8Uint;
|
||||
return sem::ImageFormat::kRg8Uint;
|
||||
|
||||
if (match(Token::Type::kFormatRg8Sint))
|
||||
return type::ImageFormat::kRg8Sint;
|
||||
return sem::ImageFormat::kRg8Sint;
|
||||
|
||||
if (match(Token::Type::kFormatR32Uint))
|
||||
return type::ImageFormat::kR32Uint;
|
||||
return sem::ImageFormat::kR32Uint;
|
||||
|
||||
if (match(Token::Type::kFormatR32Sint))
|
||||
return type::ImageFormat::kR32Sint;
|
||||
return sem::ImageFormat::kR32Sint;
|
||||
|
||||
if (match(Token::Type::kFormatR32Float))
|
||||
return type::ImageFormat::kR32Float;
|
||||
return sem::ImageFormat::kR32Float;
|
||||
|
||||
if (match(Token::Type::kFormatRg16Uint))
|
||||
return type::ImageFormat::kRg16Uint;
|
||||
return sem::ImageFormat::kRg16Uint;
|
||||
|
||||
if (match(Token::Type::kFormatRg16Sint))
|
||||
return type::ImageFormat::kRg16Sint;
|
||||
return sem::ImageFormat::kRg16Sint;
|
||||
|
||||
if (match(Token::Type::kFormatRg16Float))
|
||||
return type::ImageFormat::kRg16Float;
|
||||
return sem::ImageFormat::kRg16Float;
|
||||
|
||||
if (match(Token::Type::kFormatRgba8Unorm))
|
||||
return type::ImageFormat::kRgba8Unorm;
|
||||
return sem::ImageFormat::kRgba8Unorm;
|
||||
|
||||
if (match(Token::Type::kFormatRgba8UnormSrgb))
|
||||
return type::ImageFormat::kRgba8UnormSrgb;
|
||||
return sem::ImageFormat::kRgba8UnormSrgb;
|
||||
|
||||
if (match(Token::Type::kFormatRgba8Snorm))
|
||||
return type::ImageFormat::kRgba8Snorm;
|
||||
return sem::ImageFormat::kRgba8Snorm;
|
||||
|
||||
if (match(Token::Type::kFormatRgba8Uint))
|
||||
return type::ImageFormat::kRgba8Uint;
|
||||
return sem::ImageFormat::kRgba8Uint;
|
||||
|
||||
if (match(Token::Type::kFormatRgba8Sint))
|
||||
return type::ImageFormat::kRgba8Sint;
|
||||
return sem::ImageFormat::kRgba8Sint;
|
||||
|
||||
if (match(Token::Type::kFormatBgra8Unorm))
|
||||
return type::ImageFormat::kBgra8Unorm;
|
||||
return sem::ImageFormat::kBgra8Unorm;
|
||||
|
||||
if (match(Token::Type::kFormatBgra8UnormSrgb))
|
||||
return type::ImageFormat::kBgra8UnormSrgb;
|
||||
return sem::ImageFormat::kBgra8UnormSrgb;
|
||||
|
||||
if (match(Token::Type::kFormatRgb10A2Unorm))
|
||||
return type::ImageFormat::kRgb10A2Unorm;
|
||||
return sem::ImageFormat::kRgb10A2Unorm;
|
||||
|
||||
if (match(Token::Type::kFormatRg11B10Float))
|
||||
return type::ImageFormat::kRg11B10Float;
|
||||
return sem::ImageFormat::kRg11B10Float;
|
||||
|
||||
if (match(Token::Type::kFormatRg32Uint))
|
||||
return type::ImageFormat::kRg32Uint;
|
||||
return sem::ImageFormat::kRg32Uint;
|
||||
|
||||
if (match(Token::Type::kFormatRg32Sint))
|
||||
return type::ImageFormat::kRg32Sint;
|
||||
return sem::ImageFormat::kRg32Sint;
|
||||
|
||||
if (match(Token::Type::kFormatRg32Float))
|
||||
return type::ImageFormat::kRg32Float;
|
||||
return sem::ImageFormat::kRg32Float;
|
||||
|
||||
if (match(Token::Type::kFormatRgba16Uint))
|
||||
return type::ImageFormat::kRgba16Uint;
|
||||
return sem::ImageFormat::kRgba16Uint;
|
||||
|
||||
if (match(Token::Type::kFormatRgba16Sint))
|
||||
return type::ImageFormat::kRgba16Sint;
|
||||
return sem::ImageFormat::kRgba16Sint;
|
||||
|
||||
if (match(Token::Type::kFormatRgba16Float))
|
||||
return type::ImageFormat::kRgba16Float;
|
||||
return sem::ImageFormat::kRgba16Float;
|
||||
|
||||
if (match(Token::Type::kFormatRgba32Uint))
|
||||
return type::ImageFormat::kRgba32Uint;
|
||||
return sem::ImageFormat::kRgba32Uint;
|
||||
|
||||
if (match(Token::Type::kFormatRgba32Sint))
|
||||
return type::ImageFormat::kRgba32Sint;
|
||||
return sem::ImageFormat::kRgba32Sint;
|
||||
|
||||
if (match(Token::Type::kFormatRgba32Float))
|
||||
return type::ImageFormat::kRgba32Float;
|
||||
return sem::ImageFormat::kRgba32Float;
|
||||
|
||||
return add_error(peek().source(), "invalid format", use);
|
||||
}
|
||||
@@ -831,7 +829,7 @@ Expect<ParserImpl::TypedIdentifier> ParserImpl::expect_variable_ident_decl(
|
||||
for (auto* deco : access_decos) {
|
||||
// If we have an access control decoration then we take it and wrap our
|
||||
// type up with that decoration
|
||||
ty = builder_.create<type::AccessControl>(
|
||||
ty = builder_.create<sem::AccessControl>(
|
||||
deco->As<ast::AccessDecoration>()->value(), ty);
|
||||
}
|
||||
|
||||
@@ -871,7 +869,7 @@ Maybe<ast::StorageClass> ParserImpl::variable_storage_decoration() {
|
||||
|
||||
// type_alias
|
||||
// : TYPE IDENT EQUAL type_decl
|
||||
Maybe<type::Type*> ParserImpl::type_alias() {
|
||||
Maybe<sem::Type*> ParserImpl::type_alias() {
|
||||
auto t = peek();
|
||||
if (!t.IsType())
|
||||
return Failure::kNoMatch;
|
||||
@@ -893,7 +891,7 @@ Maybe<type::Type*> ParserImpl::type_alias() {
|
||||
if (!type.matched)
|
||||
return add_error(peek(), "invalid type alias");
|
||||
|
||||
auto* alias = builder_.create<type::Alias>(
|
||||
auto* alias = builder_.create<sem::Alias>(
|
||||
builder_.Symbols().Register(name.value), type.value);
|
||||
register_constructed(name.value, alias);
|
||||
|
||||
@@ -924,7 +922,7 @@ Maybe<type::Type*> ParserImpl::type_alias() {
|
||||
// | MAT4x3 LESS_THAN type_decl GREATER_THAN
|
||||
// | MAT4x4 LESS_THAN type_decl GREATER_THAN
|
||||
// | texture_sampler_types
|
||||
Maybe<type::Type*> ParserImpl::type_decl() {
|
||||
Maybe<sem::Type*> ParserImpl::type_decl() {
|
||||
auto decos = decoration_list();
|
||||
if (decos.errored)
|
||||
return Failure::kErrored;
|
||||
@@ -941,7 +939,7 @@ Maybe<type::Type*> ParserImpl::type_decl() {
|
||||
return type.value;
|
||||
}
|
||||
|
||||
Maybe<type::Type*> ParserImpl::type_decl(ast::DecorationList& decos) {
|
||||
Maybe<sem::Type*> ParserImpl::type_decl(ast::DecorationList& decos) {
|
||||
auto t = peek();
|
||||
if (match(Token::Type::kIdentifier)) {
|
||||
auto* ty = get_constructed(t.to_str());
|
||||
@@ -952,16 +950,16 @@ Maybe<type::Type*> ParserImpl::type_decl(ast::DecorationList& decos) {
|
||||
}
|
||||
|
||||
if (match(Token::Type::kBool))
|
||||
return builder_.create<type::Bool>();
|
||||
return builder_.create<sem::Bool>();
|
||||
|
||||
if (match(Token::Type::kF32))
|
||||
return builder_.create<type::F32>();
|
||||
return builder_.create<sem::F32>();
|
||||
|
||||
if (match(Token::Type::kI32))
|
||||
return builder_.create<type::I32>();
|
||||
return builder_.create<sem::I32>();
|
||||
|
||||
if (match(Token::Type::kU32))
|
||||
return builder_.create<type::U32>();
|
||||
return builder_.create<sem::U32>();
|
||||
|
||||
if (t.IsVec2() || t.IsVec3() || t.IsVec4()) {
|
||||
next(); // Consume the peek
|
||||
@@ -991,7 +989,7 @@ Maybe<type::Type*> ParserImpl::type_decl(ast::DecorationList& decos) {
|
||||
return Failure::kNoMatch;
|
||||
}
|
||||
|
||||
Expect<type::Type*> ParserImpl::expect_type(const std::string& use) {
|
||||
Expect<sem::Type*> ParserImpl::expect_type(const std::string& use) {
|
||||
auto type = type_decl();
|
||||
if (type.errored)
|
||||
return Failure::kErrored;
|
||||
@@ -1000,10 +998,10 @@ Expect<type::Type*> ParserImpl::expect_type(const std::string& use) {
|
||||
return type.value;
|
||||
}
|
||||
|
||||
Expect<type::Type*> ParserImpl::expect_type_decl_pointer() {
|
||||
Expect<sem::Type*> ParserImpl::expect_type_decl_pointer() {
|
||||
const char* use = "ptr declaration";
|
||||
|
||||
return expect_lt_gt_block(use, [&]() -> Expect<type::Type*> {
|
||||
return expect_lt_gt_block(use, [&]() -> Expect<sem::Type*> {
|
||||
auto sc = expect_storage_class(use);
|
||||
if (sc.errored)
|
||||
return Failure::kErrored;
|
||||
@@ -1015,11 +1013,11 @@ Expect<type::Type*> ParserImpl::expect_type_decl_pointer() {
|
||||
if (subtype.errored)
|
||||
return Failure::kErrored;
|
||||
|
||||
return builder_.create<type::Pointer>(subtype.value, sc.value);
|
||||
return builder_.create<sem::Pointer>(subtype.value, sc.value);
|
||||
});
|
||||
}
|
||||
|
||||
Expect<type::Type*> ParserImpl::expect_type_decl_vector(Token t) {
|
||||
Expect<sem::Type*> ParserImpl::expect_type_decl_vector(Token t) {
|
||||
uint32_t count = 2;
|
||||
if (t.IsVec3())
|
||||
count = 3;
|
||||
@@ -1032,14 +1030,14 @@ Expect<type::Type*> ParserImpl::expect_type_decl_vector(Token t) {
|
||||
if (subtype.errored)
|
||||
return Failure::kErrored;
|
||||
|
||||
return builder_.create<type::Vector>(subtype.value, count);
|
||||
return builder_.create<sem::Vector>(subtype.value, count);
|
||||
}
|
||||
|
||||
Expect<type::Type*> ParserImpl::expect_type_decl_array(
|
||||
Expect<sem::Type*> ParserImpl::expect_type_decl_array(
|
||||
ast::DecorationList decos) {
|
||||
const char* use = "array declaration";
|
||||
|
||||
return expect_lt_gt_block(use, [&]() -> Expect<type::Type*> {
|
||||
return expect_lt_gt_block(use, [&]() -> Expect<sem::Type*> {
|
||||
auto subtype = expect_type(use);
|
||||
if (subtype.errored)
|
||||
return Failure::kErrored;
|
||||
@@ -1052,11 +1050,11 @@ Expect<type::Type*> ParserImpl::expect_type_decl_array(
|
||||
size = val.value;
|
||||
}
|
||||
|
||||
return create<type::ArrayType>(subtype.value, size, std::move(decos));
|
||||
return create<sem::ArrayType>(subtype.value, size, std::move(decos));
|
||||
});
|
||||
}
|
||||
|
||||
Expect<type::Type*> ParserImpl::expect_type_decl_matrix(Token t) {
|
||||
Expect<sem::Type*> ParserImpl::expect_type_decl_matrix(Token t) {
|
||||
uint32_t rows = 2;
|
||||
uint32_t columns = 2;
|
||||
if (t.IsMat3x2() || t.IsMat3x3() || t.IsMat3x4()) {
|
||||
@@ -1076,7 +1074,7 @@ Expect<type::Type*> ParserImpl::expect_type_decl_matrix(Token t) {
|
||||
if (subtype.errored)
|
||||
return Failure::kErrored;
|
||||
|
||||
return builder_.create<type::Matrix>(subtype.value, rows, columns);
|
||||
return builder_.create<sem::Matrix>(subtype.value, rows, columns);
|
||||
}
|
||||
|
||||
// storage_class
|
||||
@@ -1121,7 +1119,7 @@ Expect<ast::StorageClass> ParserImpl::expect_storage_class(
|
||||
|
||||
// struct_decl
|
||||
// : struct_decoration_decl* STRUCT IDENT struct_body_decl
|
||||
Maybe<type::StructType*> ParserImpl::struct_decl(ast::DecorationList& decos) {
|
||||
Maybe<sem::StructType*> ParserImpl::struct_decl(ast::DecorationList& decos) {
|
||||
auto t = peek();
|
||||
auto source = t.source();
|
||||
|
||||
@@ -1136,7 +1134,7 @@ Maybe<type::StructType*> ParserImpl::struct_decl(ast::DecorationList& decos) {
|
||||
if (body.errored)
|
||||
return Failure::kErrored;
|
||||
|
||||
return create<type::StructType>(
|
||||
return create<sem::StructType>(
|
||||
builder_.Symbols().Register(name.value),
|
||||
create<ast::Struct>(source, std::move(body.value), std::move(decos)));
|
||||
}
|
||||
@@ -1227,9 +1225,9 @@ Maybe<ast::Function*> ParserImpl::function_decl(ast::DecorationList& decos) {
|
||||
// function_type_decl
|
||||
// : type_decl
|
||||
// | VOID
|
||||
Maybe<type::Type*> ParserImpl::function_type_decl() {
|
||||
Maybe<sem::Type*> ParserImpl::function_type_decl() {
|
||||
if (match(Token::Type::kVoid))
|
||||
return builder_.create<type::Void>();
|
||||
return builder_.create<sem::Void>();
|
||||
|
||||
return type_decl();
|
||||
}
|
||||
@@ -1261,7 +1259,7 @@ Maybe<ParserImpl::FunctionHeader> ParserImpl::function_header() {
|
||||
}
|
||||
}
|
||||
|
||||
type::Type* return_type = nullptr;
|
||||
sem::Type* return_type = nullptr;
|
||||
ast::DecorationList return_decorations;
|
||||
|
||||
if (match(Token::Type::kArrow)) {
|
||||
@@ -1282,7 +1280,7 @@ Maybe<ParserImpl::FunctionHeader> ParserImpl::function_header() {
|
||||
return_type = type.value;
|
||||
}
|
||||
|
||||
if (return_type->Is<type::Void>()) {
|
||||
if (return_type->Is<sem::Void>()) {
|
||||
// crbug.com/tint/677: void has been removed from the language
|
||||
deprecated(tok.source(),
|
||||
"omit '-> void' for functions that do not return a value");
|
||||
@@ -2726,19 +2724,19 @@ Maybe<ast::AssignmentStatement*> ParserImpl::assignment_stmt() {
|
||||
Maybe<ast::Literal*> ParserImpl::const_literal() {
|
||||
auto t = peek();
|
||||
if (match(Token::Type::kTrue)) {
|
||||
auto* type = builder_.create<type::Bool>();
|
||||
auto* type = builder_.create<sem::Bool>();
|
||||
return create<ast::BoolLiteral>(Source{}, type, true);
|
||||
}
|
||||
if (match(Token::Type::kFalse)) {
|
||||
auto* type = builder_.create<type::Bool>();
|
||||
auto* type = builder_.create<sem::Bool>();
|
||||
return create<ast::BoolLiteral>(Source{}, type, false);
|
||||
}
|
||||
if (match(Token::Type::kSintLiteral)) {
|
||||
auto* type = builder_.create<type::I32>();
|
||||
auto* type = builder_.create<sem::I32>();
|
||||
return create<ast::SintLiteral>(Source{}, type, t.to_i32());
|
||||
}
|
||||
if (match(Token::Type::kUintLiteral)) {
|
||||
auto* type = builder_.create<type::U32>();
|
||||
auto* type = builder_.create<sem::U32>();
|
||||
return create<ast::UintLiteral>(Source{}, type, t.to_u32());
|
||||
}
|
||||
if (match(Token::Type::kFloatLiteral)) {
|
||||
@@ -2747,7 +2745,7 @@ Maybe<ast::Literal*> ParserImpl::const_literal() {
|
||||
next(); // Consume 'f'
|
||||
add_error(p.source(), "float literals must not be suffixed with 'f'");
|
||||
}
|
||||
auto* type = builder_.create<type::F32>();
|
||||
auto* type = builder_.create<sem::F32>();
|
||||
return create<ast::FloatLiteral>(Source{}, type, t.to_f32());
|
||||
}
|
||||
return Failure::kNoMatch;
|
||||
|
||||
@@ -199,7 +199,7 @@ class ParserImpl {
|
||||
/// variable_ident_decl().
|
||||
struct TypedIdentifier {
|
||||
/// Parsed type.
|
||||
type::Type* type = nullptr;
|
||||
sem::Type* type = nullptr;
|
||||
/// Parsed identifier.
|
||||
std::string name;
|
||||
/// Source to the identifier.
|
||||
@@ -222,7 +222,7 @@ class ParserImpl {
|
||||
FunctionHeader(Source src,
|
||||
std::string n,
|
||||
ast::VariableList p,
|
||||
type::Type* ret_ty,
|
||||
sem::Type* ret_ty,
|
||||
ast::DecorationList ret_decos);
|
||||
/// Destructor
|
||||
~FunctionHeader();
|
||||
@@ -238,7 +238,7 @@ class ParserImpl {
|
||||
/// Function parameters
|
||||
ast::VariableList params;
|
||||
/// Function return type
|
||||
type::Type* return_type;
|
||||
sem::Type* return_type;
|
||||
/// Function return type decorations
|
||||
ast::DecorationList return_type_decorations;
|
||||
};
|
||||
@@ -252,7 +252,7 @@ class ParserImpl {
|
||||
/// Variable storage class
|
||||
ast::StorageClass storage_class;
|
||||
/// Variable type
|
||||
type::Type* type;
|
||||
sem::Type* type;
|
||||
};
|
||||
|
||||
/// Creates a new parser using the given file
|
||||
@@ -328,11 +328,11 @@ class ParserImpl {
|
||||
/// Registers a constructed type into the parser
|
||||
/// @param name the constructed name
|
||||
/// @param type the constructed type
|
||||
void register_constructed(const std::string& name, type::Type* type);
|
||||
void register_constructed(const std::string& name, sem::Type* type);
|
||||
/// Retrieves a constructed type
|
||||
/// @param name The name to lookup
|
||||
/// @returns the constructed type for `name` or `nullptr` if not found
|
||||
type::Type* get_constructed(const std::string& name);
|
||||
sem::Type* get_constructed(const std::string& name);
|
||||
|
||||
/// Parses the `translation_unit` grammar element
|
||||
void translation_unit();
|
||||
@@ -362,15 +362,15 @@ class ParserImpl {
|
||||
Maybe<ast::StorageClass> variable_storage_decoration();
|
||||
/// Parses a `type_alias` grammar element
|
||||
/// @returns the type alias or nullptr on error
|
||||
Maybe<type::Type*> type_alias();
|
||||
Maybe<sem::Type*> type_alias();
|
||||
/// Parses a `type_decl` grammar element
|
||||
/// @returns the parsed Type or nullptr if none matched.
|
||||
Maybe<type::Type*> type_decl();
|
||||
Maybe<sem::Type*> type_decl();
|
||||
/// Parses a `type_decl` grammar element with the given pre-parsed
|
||||
/// decorations.
|
||||
/// @param decos the list of decorations for the type.
|
||||
/// @returns the parsed Type or nullptr if none matched.
|
||||
Maybe<type::Type*> type_decl(ast::DecorationList& decos);
|
||||
Maybe<sem::Type*> type_decl(ast::DecorationList& decos);
|
||||
/// Parses a `storage_class` grammar element, erroring on parse failure.
|
||||
/// @param use a description of what was being parsed if an error was raised.
|
||||
/// @returns the storage class or StorageClass::kNone if none matched
|
||||
@@ -379,7 +379,7 @@ class ParserImpl {
|
||||
/// `struct_decoration_decl*` provided as `decos`.
|
||||
/// @returns the struct type or nullptr on error
|
||||
/// @param decos the list of decorations for the struct declaration.
|
||||
Maybe<type::StructType*> struct_decl(ast::DecorationList& decos);
|
||||
Maybe<sem::StructType*> struct_decl(ast::DecorationList& decos);
|
||||
/// Parses a `struct_body_decl` grammar element, erroring on parse failure.
|
||||
/// @returns the struct members
|
||||
Expect<ast::StructMemberList> expect_struct_body_decl();
|
||||
@@ -396,31 +396,31 @@ class ParserImpl {
|
||||
Maybe<ast::Function*> function_decl(ast::DecorationList& decos);
|
||||
/// Parses a `texture_sampler_types` grammar element
|
||||
/// @returns the parsed Type or nullptr if none matched.
|
||||
Maybe<type::Type*> texture_sampler_types();
|
||||
Maybe<sem::Type*> texture_sampler_types();
|
||||
/// Parses a `sampler_type` grammar element
|
||||
/// @returns the parsed Type or nullptr if none matched.
|
||||
Maybe<type::Type*> sampler_type();
|
||||
Maybe<sem::Type*> sampler_type();
|
||||
/// Parses a `multisampled_texture_type` grammar element
|
||||
/// @returns returns the multisample texture dimension or kNone if none
|
||||
/// matched.
|
||||
Maybe<type::TextureDimension> multisampled_texture_type();
|
||||
Maybe<sem::TextureDimension> multisampled_texture_type();
|
||||
/// Parses a `sampled_texture_type` grammar element
|
||||
/// @returns returns the sample texture dimension or kNone if none matched.
|
||||
Maybe<type::TextureDimension> sampled_texture_type();
|
||||
Maybe<sem::TextureDimension> sampled_texture_type();
|
||||
/// Parses a `storage_texture_type` grammar element
|
||||
/// @returns returns the storage texture dimension.
|
||||
/// Returns kNone if none matched.
|
||||
Maybe<type::TextureDimension> storage_texture_type();
|
||||
Maybe<sem::TextureDimension> storage_texture_type();
|
||||
/// Parses a `depth_texture_type` grammar element
|
||||
/// @returns the parsed Type or nullptr if none matched.
|
||||
Maybe<type::Type*> depth_texture_type();
|
||||
Maybe<sem::Type*> depth_texture_type();
|
||||
/// Parses a `image_storage_type` grammar element
|
||||
/// @param use a description of what was being parsed if an error was raised
|
||||
/// @returns returns the image format or kNone if none matched.
|
||||
Expect<type::ImageFormat> expect_image_storage_type(const std::string& use);
|
||||
Expect<sem::ImageFormat> expect_image_storage_type(const std::string& use);
|
||||
/// Parses a `function_type_decl` grammar element
|
||||
/// @returns the parsed type or nullptr otherwise
|
||||
Maybe<type::Type*> function_type_decl();
|
||||
Maybe<sem::Type*> function_type_decl();
|
||||
/// Parses a `function_header` grammar element
|
||||
/// @returns the parsed function header
|
||||
Maybe<FunctionHeader> function_header();
|
||||
@@ -784,12 +784,12 @@ class ParserImpl {
|
||||
/// Used to ensure that all decorations are consumed.
|
||||
bool expect_decorations_consumed(const ast::DecorationList& list);
|
||||
|
||||
Expect<type::Type*> expect_type_decl_pointer();
|
||||
Expect<type::Type*> expect_type_decl_vector(Token t);
|
||||
Expect<type::Type*> expect_type_decl_array(ast::DecorationList decos);
|
||||
Expect<type::Type*> expect_type_decl_matrix(Token t);
|
||||
Expect<sem::Type*> expect_type_decl_pointer();
|
||||
Expect<sem::Type*> expect_type_decl_vector(Token t);
|
||||
Expect<sem::Type*> expect_type_decl_array(ast::DecorationList decos);
|
||||
Expect<sem::Type*> expect_type_decl_matrix(Token t);
|
||||
|
||||
Expect<type::Type*> expect_type(const std::string& use);
|
||||
Expect<sem::Type*> expect_type(const std::string& use);
|
||||
|
||||
Maybe<ast::Statement*> non_block_statement();
|
||||
Maybe<ast::Statement*> for_header_initializer();
|
||||
@@ -810,7 +810,7 @@ class ParserImpl {
|
||||
uint32_t sync_depth_ = 0;
|
||||
std::vector<Token::Type> sync_tokens_;
|
||||
int silence_errors_ = 0;
|
||||
std::unordered_map<std::string, type::Type*> registered_constructs_;
|
||||
std::unordered_map<std::string, sem::Type*> registered_constructs_;
|
||||
ProgramBuilder builder_;
|
||||
size_t max_errors_ = 25;
|
||||
};
|
||||
|
||||
@@ -28,8 +28,8 @@ TEST_F(ParserImplTest, ConstExpr_TypeDecl) {
|
||||
ASSERT_TRUE(e->Is<ast::TypeConstructorExpression>());
|
||||
|
||||
auto* t = e->As<ast::TypeConstructorExpression>();
|
||||
ASSERT_TRUE(t->type()->Is<type::Vector>());
|
||||
EXPECT_EQ(t->type()->As<type::Vector>()->size(), 2u);
|
||||
ASSERT_TRUE(t->type()->Is<sem::Vector>());
|
||||
EXPECT_EQ(t->type()->As<sem::Vector>()->size(), 2u);
|
||||
|
||||
ASSERT_EQ(t->values().size(), 2u);
|
||||
auto& v = t->values();
|
||||
|
||||
@@ -34,9 +34,9 @@ TEST_F(ParserImplTest, DepthTextureType_2d) {
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
ASSERT_NE(t.value, nullptr);
|
||||
ASSERT_TRUE(t->Is<type::Texture>());
|
||||
ASSERT_TRUE(t->Is<type::DepthTexture>());
|
||||
EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::k2d);
|
||||
ASSERT_TRUE(t->Is<sem::Texture>());
|
||||
ASSERT_TRUE(t->Is<sem::DepthTexture>());
|
||||
EXPECT_EQ(t->As<sem::Texture>()->dim(), sem::TextureDimension::k2d);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
@@ -46,9 +46,9 @@ TEST_F(ParserImplTest, DepthTextureType_2dArray) {
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
ASSERT_NE(t.value, nullptr);
|
||||
ASSERT_TRUE(t->Is<type::Texture>());
|
||||
ASSERT_TRUE(t->Is<type::DepthTexture>());
|
||||
EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::k2dArray);
|
||||
ASSERT_TRUE(t->Is<sem::Texture>());
|
||||
ASSERT_TRUE(t->Is<sem::DepthTexture>());
|
||||
EXPECT_EQ(t->As<sem::Texture>()->dim(), sem::TextureDimension::k2dArray);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
@@ -58,9 +58,9 @@ TEST_F(ParserImplTest, DepthTextureType_Cube) {
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
ASSERT_NE(t.value, nullptr);
|
||||
ASSERT_TRUE(t->Is<type::Texture>());
|
||||
ASSERT_TRUE(t->Is<type::DepthTexture>());
|
||||
EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::kCube);
|
||||
ASSERT_TRUE(t->Is<sem::Texture>());
|
||||
ASSERT_TRUE(t->Is<sem::DepthTexture>());
|
||||
EXPECT_EQ(t->As<sem::Texture>()->dim(), sem::TextureDimension::kCube);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
@@ -70,9 +70,9 @@ TEST_F(ParserImplTest, DepthTextureType_CubeArray) {
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
ASSERT_NE(t.value, nullptr);
|
||||
ASSERT_TRUE(t->Is<type::Texture>());
|
||||
ASSERT_TRUE(t->Is<type::DepthTexture>());
|
||||
EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::kCubeArray);
|
||||
ASSERT_TRUE(t->Is<sem::Texture>());
|
||||
ASSERT_TRUE(t->Is<sem::DepthTexture>());
|
||||
EXPECT_EQ(t->As<sem::Texture>()->dim(), sem::TextureDimension::kCubeArray);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
|
||||
@@ -34,14 +34,14 @@ TEST_F(ParserImplTest, FunctionDecl) {
|
||||
|
||||
EXPECT_EQ(f->symbol(), p->builder().Symbols().Get("main"));
|
||||
ASSERT_NE(f->return_type(), nullptr);
|
||||
EXPECT_TRUE(f->return_type()->Is<type::Void>());
|
||||
EXPECT_TRUE(f->return_type()->Is<sem::Void>());
|
||||
|
||||
ASSERT_EQ(f->params().size(), 2u);
|
||||
EXPECT_EQ(f->params()[0]->symbol(), p->builder().Symbols().Get("a"));
|
||||
EXPECT_EQ(f->params()[1]->symbol(), p->builder().Symbols().Get("b"));
|
||||
|
||||
ASSERT_NE(f->return_type(), nullptr);
|
||||
EXPECT_TRUE(f->return_type()->Is<type::Void>());
|
||||
EXPECT_TRUE(f->return_type()->Is<sem::Void>());
|
||||
|
||||
auto* body = f->body();
|
||||
ASSERT_EQ(body->size(), 1u);
|
||||
@@ -62,10 +62,10 @@ TEST_F(ParserImplTest, FunctionDecl_DecorationList) {
|
||||
|
||||
EXPECT_EQ(f->symbol(), p->builder().Symbols().Get("main"));
|
||||
ASSERT_NE(f->return_type(), nullptr);
|
||||
EXPECT_TRUE(f->return_type()->Is<type::Void>());
|
||||
EXPECT_TRUE(f->return_type()->Is<sem::Void>());
|
||||
ASSERT_EQ(f->params().size(), 0u);
|
||||
ASSERT_NE(f->return_type(), nullptr);
|
||||
EXPECT_TRUE(f->return_type()->Is<type::Void>());
|
||||
EXPECT_TRUE(f->return_type()->Is<sem::Void>());
|
||||
|
||||
auto& decorations = f->decorations();
|
||||
ASSERT_EQ(decorations.size(), 1u);
|
||||
@@ -100,10 +100,10 @@ fn main() { return; })");
|
||||
|
||||
EXPECT_EQ(f->symbol(), p->builder().Symbols().Get("main"));
|
||||
ASSERT_NE(f->return_type(), nullptr);
|
||||
EXPECT_TRUE(f->return_type()->Is<type::Void>());
|
||||
EXPECT_TRUE(f->return_type()->Is<sem::Void>());
|
||||
ASSERT_EQ(f->params().size(), 0u);
|
||||
ASSERT_NE(f->return_type(), nullptr);
|
||||
EXPECT_TRUE(f->return_type()->Is<type::Void>());
|
||||
EXPECT_TRUE(f->return_type()->Is<sem::Void>());
|
||||
|
||||
auto& decorations = f->decorations();
|
||||
ASSERT_EQ(decorations.size(), 2u);
|
||||
@@ -145,10 +145,10 @@ fn main() { return; })");
|
||||
|
||||
EXPECT_EQ(f->symbol(), p->builder().Symbols().Get("main"));
|
||||
ASSERT_NE(f->return_type(), nullptr);
|
||||
EXPECT_TRUE(f->return_type()->Is<type::Void>());
|
||||
EXPECT_TRUE(f->return_type()->Is<sem::Void>());
|
||||
ASSERT_EQ(f->params().size(), 0u);
|
||||
ASSERT_NE(f->return_type(), nullptr);
|
||||
EXPECT_TRUE(f->return_type()->Is<type::Void>());
|
||||
EXPECT_TRUE(f->return_type()->Is<sem::Void>());
|
||||
|
||||
auto& decos = f->decorations();
|
||||
ASSERT_EQ(decos.size(), 2u);
|
||||
@@ -187,7 +187,7 @@ TEST_F(ParserImplTest, FunctionDecl_ReturnTypeDecorationList) {
|
||||
|
||||
EXPECT_EQ(f->symbol(), p->builder().Symbols().Get("main"));
|
||||
ASSERT_NE(f->return_type(), nullptr);
|
||||
EXPECT_TRUE(f->return_type()->Is<type::F32>());
|
||||
EXPECT_TRUE(f->return_type()->Is<sem::F32>());
|
||||
ASSERT_EQ(f->params().size(), 0u);
|
||||
|
||||
auto& decorations = f->decorations();
|
||||
|
||||
@@ -30,7 +30,7 @@ TEST_F(ParserImplTest, FunctionHeader) {
|
||||
ASSERT_EQ(f->params.size(), 2u);
|
||||
EXPECT_EQ(f->params[0]->symbol(), p->builder().Symbols().Get("a"));
|
||||
EXPECT_EQ(f->params[1]->symbol(), p->builder().Symbols().Get("b"));
|
||||
EXPECT_TRUE(f->return_type->Is<type::Void>());
|
||||
EXPECT_TRUE(f->return_type->Is<sem::Void>());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionHeader_DecoratedReturnType) {
|
||||
@@ -42,7 +42,7 @@ TEST_F(ParserImplTest, FunctionHeader_DecoratedReturnType) {
|
||||
|
||||
EXPECT_EQ(f->name, "main");
|
||||
EXPECT_EQ(f->params.size(), 0u);
|
||||
EXPECT_TRUE(f->return_type->Is<type::F32>());
|
||||
EXPECT_TRUE(f->return_type->Is<sem::F32>());
|
||||
ASSERT_EQ(f->return_type_decorations.size(), 1u);
|
||||
auto* loc = f->return_type_decorations[0]->As<ast::LocationDecoration>();
|
||||
ASSERT_TRUE(loc != nullptr);
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace {
|
||||
TEST_F(ParserImplTest, FunctionTypeDecl_Void) {
|
||||
auto p = parser("void");
|
||||
|
||||
auto* v = p->builder().create<type::Void>();
|
||||
auto* v = p->builder().create<sem::Void>();
|
||||
|
||||
auto e = p->function_type_decl();
|
||||
EXPECT_TRUE(e.matched);
|
||||
@@ -34,8 +34,8 @@ TEST_F(ParserImplTest, FunctionTypeDecl_Void) {
|
||||
TEST_F(ParserImplTest, FunctionTypeDecl_Type) {
|
||||
auto p = parser("vec2<f32>");
|
||||
|
||||
auto* f32 = p->builder().create<type::F32>();
|
||||
auto* vec2 = p->builder().create<type::Vector>(f32, 2);
|
||||
auto* f32 = p->builder().create<sem::F32>();
|
||||
auto* vec2 = p->builder().create<sem::Vector>(f32, 2);
|
||||
|
||||
auto e = p->function_type_decl();
|
||||
EXPECT_TRUE(e.matched);
|
||||
|
||||
@@ -34,7 +34,7 @@ TEST_F(ParserImplTest, GlobalConstantDecl) {
|
||||
EXPECT_TRUE(e->is_const());
|
||||
EXPECT_EQ(e->symbol(), p->builder().Symbols().Get("a"));
|
||||
ASSERT_NE(e->declared_type(), nullptr);
|
||||
EXPECT_TRUE(e->declared_type()->Is<type::F32>());
|
||||
EXPECT_TRUE(e->declared_type()->Is<sem::F32>());
|
||||
|
||||
EXPECT_EQ(e->source().range.begin.line, 1u);
|
||||
EXPECT_EQ(e->source().range.begin.column, 5u);
|
||||
@@ -115,7 +115,7 @@ TEST_F(ParserImplTest, GlobalConstantDec_ConstantId) {
|
||||
EXPECT_TRUE(e->is_const());
|
||||
EXPECT_EQ(e->symbol(), p->builder().Symbols().Get("a"));
|
||||
ASSERT_NE(e->declared_type(), nullptr);
|
||||
EXPECT_TRUE(e->declared_type()->Is<type::F32>());
|
||||
EXPECT_TRUE(e->declared_type()->Is<sem::F32>());
|
||||
|
||||
EXPECT_EQ(e->source().range.begin.line, 1u);
|
||||
EXPECT_EQ(e->source().range.begin.column, 24u);
|
||||
|
||||
@@ -84,10 +84,10 @@ TEST_F(ParserImplTest, GlobalDecl_TypeAlias) {
|
||||
|
||||
auto program = p->program();
|
||||
ASSERT_EQ(program.AST().ConstructedTypes().size(), 1u);
|
||||
ASSERT_TRUE(program.AST().ConstructedTypes()[0]->Is<type::Alias>());
|
||||
ASSERT_TRUE(program.AST().ConstructedTypes()[0]->Is<sem::Alias>());
|
||||
EXPECT_EQ(
|
||||
program.Symbols().NameFor(
|
||||
program.AST().ConstructedTypes()[0]->As<type::Alias>()->symbol()),
|
||||
program.AST().ConstructedTypes()[0]->As<sem::Alias>()->symbol()),
|
||||
"A");
|
||||
}
|
||||
|
||||
@@ -102,12 +102,12 @@ type B = A;)");
|
||||
|
||||
auto program = p->program();
|
||||
ASSERT_EQ(program.AST().ConstructedTypes().size(), 2u);
|
||||
ASSERT_TRUE(program.AST().ConstructedTypes()[0]->Is<type::StructType>());
|
||||
auto* str = program.AST().ConstructedTypes()[0]->As<type::StructType>();
|
||||
ASSERT_TRUE(program.AST().ConstructedTypes()[0]->Is<sem::StructType>());
|
||||
auto* str = program.AST().ConstructedTypes()[0]->As<sem::StructType>();
|
||||
EXPECT_EQ(str->symbol(), program.Symbols().Get("A"));
|
||||
|
||||
ASSERT_TRUE(program.AST().ConstructedTypes()[1]->Is<type::Alias>());
|
||||
auto* alias = program.AST().ConstructedTypes()[1]->As<type::Alias>();
|
||||
ASSERT_TRUE(program.AST().ConstructedTypes()[1]->Is<sem::Alias>());
|
||||
auto* alias = program.AST().ConstructedTypes()[1]->As<sem::Alias>();
|
||||
EXPECT_EQ(alias->symbol(), program.Symbols().Get("B"));
|
||||
EXPECT_EQ(alias->type(), str);
|
||||
}
|
||||
@@ -165,9 +165,9 @@ TEST_F(ParserImplTest, GlobalDecl_ParsesStruct) {
|
||||
|
||||
auto* t = program.AST().ConstructedTypes()[0];
|
||||
ASSERT_NE(t, nullptr);
|
||||
ASSERT_TRUE(t->Is<type::StructType>());
|
||||
ASSERT_TRUE(t->Is<sem::StructType>());
|
||||
|
||||
auto* str = t->As<type::StructType>();
|
||||
auto* str = t->As<sem::StructType>();
|
||||
EXPECT_EQ(str->symbol(), program.Symbols().Get("A"));
|
||||
EXPECT_EQ(str->impl()->members().size(), 2u);
|
||||
}
|
||||
@@ -183,16 +183,16 @@ TEST_F(ParserImplTest, GlobalDecl_Struct_WithStride) {
|
||||
|
||||
auto* t = program.AST().ConstructedTypes()[0];
|
||||
ASSERT_NE(t, nullptr);
|
||||
ASSERT_TRUE(t->Is<type::StructType>());
|
||||
ASSERT_TRUE(t->Is<sem::StructType>());
|
||||
|
||||
auto* str = t->As<type::StructType>();
|
||||
auto* str = t->As<sem::StructType>();
|
||||
EXPECT_EQ(str->symbol(), program.Symbols().Get("A"));
|
||||
EXPECT_EQ(str->impl()->members().size(), 1u);
|
||||
EXPECT_FALSE(str->IsBlockDecorated());
|
||||
|
||||
const auto* ty = str->impl()->members()[0]->type();
|
||||
ASSERT_TRUE(ty->Is<type::ArrayType>());
|
||||
const auto* arr = ty->As<type::ArrayType>();
|
||||
ASSERT_TRUE(ty->Is<sem::ArrayType>());
|
||||
const auto* arr = ty->As<sem::ArrayType>();
|
||||
|
||||
ASSERT_EQ(arr->decorations().size(), 1u);
|
||||
auto* stride = arr->decorations()[0];
|
||||
@@ -210,9 +210,9 @@ TEST_F(ParserImplTest, GlobalDecl_Struct_WithDecoration) {
|
||||
|
||||
auto* t = program.AST().ConstructedTypes()[0];
|
||||
ASSERT_NE(t, nullptr);
|
||||
ASSERT_TRUE(t->Is<type::StructType>());
|
||||
ASSERT_TRUE(t->Is<sem::StructType>());
|
||||
|
||||
auto* str = t->As<type::StructType>();
|
||||
auto* str = t->As<sem::StructType>();
|
||||
EXPECT_EQ(str->symbol(), program.Symbols().Get("A"));
|
||||
EXPECT_EQ(str->impl()->members().size(), 1u);
|
||||
EXPECT_TRUE(str->IsBlockDecorated());
|
||||
|
||||
@@ -31,7 +31,7 @@ TEST_F(ParserImplTest, GlobalVariableDecl_WithoutConstructor) {
|
||||
ASSERT_NE(e.value, nullptr);
|
||||
|
||||
EXPECT_EQ(e->symbol(), p->builder().Symbols().Get("a"));
|
||||
EXPECT_TRUE(e->declared_type()->Is<type::F32>());
|
||||
EXPECT_TRUE(e->declared_type()->Is<sem::F32>());
|
||||
EXPECT_EQ(e->declared_storage_class(), ast::StorageClass::kPrivate);
|
||||
|
||||
EXPECT_EQ(e->source().range.begin.line, 1u);
|
||||
@@ -54,7 +54,7 @@ TEST_F(ParserImplTest, GlobalVariableDecl_WithConstructor) {
|
||||
ASSERT_NE(e.value, nullptr);
|
||||
|
||||
EXPECT_EQ(e->symbol(), p->builder().Symbols().Get("a"));
|
||||
EXPECT_TRUE(e->declared_type()->Is<type::F32>());
|
||||
EXPECT_TRUE(e->declared_type()->Is<sem::F32>());
|
||||
EXPECT_EQ(e->declared_storage_class(), ast::StorageClass::kPrivate);
|
||||
|
||||
EXPECT_EQ(e->source().range.begin.line, 1u);
|
||||
@@ -80,7 +80,7 @@ TEST_F(ParserImplTest, GlobalVariableDecl_WithDecoration) {
|
||||
|
||||
EXPECT_EQ(e->symbol(), p->builder().Symbols().Get("a"));
|
||||
ASSERT_NE(e->declared_type(), nullptr);
|
||||
EXPECT_TRUE(e->declared_type()->Is<type::F32>());
|
||||
EXPECT_TRUE(e->declared_type()->Is<sem::F32>());
|
||||
EXPECT_EQ(e->declared_storage_class(), ast::StorageClass::kUniform);
|
||||
|
||||
EXPECT_EQ(e->source().range.begin.line, 1u);
|
||||
@@ -110,7 +110,7 @@ TEST_F(ParserImplTest, GlobalVariableDecl_WithDecoration_MulitpleGroups) {
|
||||
|
||||
EXPECT_EQ(e->symbol(), p->builder().Symbols().Get("a"));
|
||||
ASSERT_NE(e->declared_type(), nullptr);
|
||||
EXPECT_TRUE(e->declared_type()->Is<type::F32>());
|
||||
EXPECT_TRUE(e->declared_type()->Is<sem::F32>());
|
||||
EXPECT_EQ(e->declared_storage_class(), ast::StorageClass::kUniform);
|
||||
|
||||
EXPECT_EQ(e->source().range.begin.line, 1u);
|
||||
@@ -180,7 +180,7 @@ TEST_F(ParserImplTest, GlobalVariableDecl_SamplerImplicitStorageClass) {
|
||||
ASSERT_NE(e.value, nullptr);
|
||||
|
||||
EXPECT_EQ(e->symbol(), p->builder().Symbols().Get("s"));
|
||||
EXPECT_TRUE(e->declared_type()->Is<type::Sampler>());
|
||||
EXPECT_TRUE(e->declared_type()->Is<sem::Sampler>());
|
||||
EXPECT_EQ(e->declared_storage_class(), ast::StorageClass::kUniformConstant);
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ TEST_F(ParserImplTest, GlobalVariableDecl_TextureImplicitStorageClass) {
|
||||
ASSERT_NE(e.value, nullptr);
|
||||
|
||||
EXPECT_EQ(e->symbol(), p->builder().Symbols().Get("s"));
|
||||
EXPECT_TRUE(e->declared_type()->UnwrapAll()->Is<type::Texture>());
|
||||
EXPECT_TRUE(e->declared_type()->UnwrapAll()->Is<sem::Texture>());
|
||||
EXPECT_EQ(e->declared_storage_class(), ast::StorageClass::kUniformConstant);
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ TEST_F(ParserImplTest, GlobalVariableDecl_StorageClassIn_Deprecated) {
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
|
||||
EXPECT_EQ(e->symbol(), p->builder().Symbols().Get("a"));
|
||||
EXPECT_TRUE(e->declared_type()->Is<type::F32>());
|
||||
EXPECT_TRUE(e->declared_type()->Is<sem::F32>());
|
||||
EXPECT_EQ(e->declared_storage_class(), ast::StorageClass::kInput);
|
||||
|
||||
EXPECT_EQ(
|
||||
@@ -231,7 +231,7 @@ TEST_F(ParserImplTest, GlobalVariableDecl_StorageClassOut_Deprecated) {
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
|
||||
EXPECT_EQ(e->symbol(), p->builder().Symbols().Get("a"));
|
||||
EXPECT_TRUE(e->declared_type()->Is<type::F32>());
|
||||
EXPECT_TRUE(e->declared_type()->Is<sem::F32>());
|
||||
EXPECT_EQ(e->declared_storage_class(), ast::StorageClass::kOutput);
|
||||
|
||||
EXPECT_EQ(
|
||||
|
||||
@@ -31,7 +31,7 @@ TEST_F(ParserImplTest, ImageStorageType_R8Unorm) {
|
||||
auto p = parser("r8unorm");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, type::ImageFormat::kR8Unorm);
|
||||
EXPECT_EQ(t.value, sem::ImageFormat::kR8Unorm);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ TEST_F(ParserImplTest, ImageStorageType_R8Snorm) {
|
||||
auto p = parser("r8snorm");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, type::ImageFormat::kR8Snorm);
|
||||
EXPECT_EQ(t.value, sem::ImageFormat::kR8Snorm);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ TEST_F(ParserImplTest, ImageStorageType_R8Uint) {
|
||||
auto p = parser("r8uint");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, type::ImageFormat::kR8Uint);
|
||||
EXPECT_EQ(t.value, sem::ImageFormat::kR8Uint);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ TEST_F(ParserImplTest, ImageStorageType_R8Sint) {
|
||||
auto p = parser("r8sint");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, type::ImageFormat::kR8Sint);
|
||||
EXPECT_EQ(t.value, sem::ImageFormat::kR8Sint);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ TEST_F(ParserImplTest, ImageStorageType_R16Uint) {
|
||||
auto p = parser("r16uint");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, type::ImageFormat::kR16Uint);
|
||||
EXPECT_EQ(t.value, sem::ImageFormat::kR16Uint);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ TEST_F(ParserImplTest, ImageStorageType_R16Sint) {
|
||||
auto p = parser("r16sint");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, type::ImageFormat::kR16Sint);
|
||||
EXPECT_EQ(t.value, sem::ImageFormat::kR16Sint);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ TEST_F(ParserImplTest, ImageStorageType_R16Float) {
|
||||
auto p = parser("r16float");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, type::ImageFormat::kR16Float);
|
||||
EXPECT_EQ(t.value, sem::ImageFormat::kR16Float);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rg8Unorm) {
|
||||
auto p = parser("rg8unorm");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, type::ImageFormat::kRg8Unorm);
|
||||
EXPECT_EQ(t.value, sem::ImageFormat::kRg8Unorm);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rg8Snorm) {
|
||||
auto p = parser("rg8snorm");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, type::ImageFormat::kRg8Snorm);
|
||||
EXPECT_EQ(t.value, sem::ImageFormat::kRg8Snorm);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rg8Uint) {
|
||||
auto p = parser("rg8uint");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, type::ImageFormat::kRg8Uint);
|
||||
EXPECT_EQ(t.value, sem::ImageFormat::kRg8Uint);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rg8Sint) {
|
||||
auto p = parser("rg8sint");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, type::ImageFormat::kRg8Sint);
|
||||
EXPECT_EQ(t.value, sem::ImageFormat::kRg8Sint);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ TEST_F(ParserImplTest, ImageStorageType_R32Uint) {
|
||||
auto p = parser("r32uint");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, type::ImageFormat::kR32Uint);
|
||||
EXPECT_EQ(t.value, sem::ImageFormat::kR32Uint);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ TEST_F(ParserImplTest, ImageStorageType_R32Sint) {
|
||||
auto p = parser("r32sint");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, type::ImageFormat::kR32Sint);
|
||||
EXPECT_EQ(t.value, sem::ImageFormat::kR32Sint);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ TEST_F(ParserImplTest, ImageStorageType_R32Float) {
|
||||
auto p = parser("r32float");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, type::ImageFormat::kR32Float);
|
||||
EXPECT_EQ(t.value, sem::ImageFormat::kR32Float);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rg16Uint) {
|
||||
auto p = parser("rg16uint");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, type::ImageFormat::kRg16Uint);
|
||||
EXPECT_EQ(t.value, sem::ImageFormat::kRg16Uint);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rg16Sint) {
|
||||
auto p = parser("rg16sint");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, type::ImageFormat::kRg16Sint);
|
||||
EXPECT_EQ(t.value, sem::ImageFormat::kRg16Sint);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rg16Float) {
|
||||
auto p = parser("rg16float");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, type::ImageFormat::kRg16Float);
|
||||
EXPECT_EQ(t.value, sem::ImageFormat::kRg16Float);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba8Unorm) {
|
||||
auto p = parser("rgba8unorm");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, type::ImageFormat::kRgba8Unorm);
|
||||
EXPECT_EQ(t.value, sem::ImageFormat::kRgba8Unorm);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba8UnormSrgb) {
|
||||
auto p = parser("rgba8unorm_srgb");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, type::ImageFormat::kRgba8UnormSrgb);
|
||||
EXPECT_EQ(t.value, sem::ImageFormat::kRgba8UnormSrgb);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
@@ -183,7 +183,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba8Snorm) {
|
||||
auto p = parser("rgba8snorm");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, type::ImageFormat::kRgba8Snorm);
|
||||
EXPECT_EQ(t.value, sem::ImageFormat::kRgba8Snorm);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba8Uint) {
|
||||
auto p = parser("rgba8uint");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, type::ImageFormat::kRgba8Uint);
|
||||
EXPECT_EQ(t.value, sem::ImageFormat::kRgba8Uint);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba8Sint) {
|
||||
auto p = parser("rgba8sint");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, type::ImageFormat::kRgba8Sint);
|
||||
EXPECT_EQ(t.value, sem::ImageFormat::kRgba8Sint);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
@@ -207,7 +207,7 @@ TEST_F(ParserImplTest, ImageStorageType_Bgra8Unorm) {
|
||||
auto p = parser("bgra8unorm");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, type::ImageFormat::kBgra8Unorm);
|
||||
EXPECT_EQ(t.value, sem::ImageFormat::kBgra8Unorm);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
@@ -215,7 +215,7 @@ TEST_F(ParserImplTest, ImageStorageType_Bgra8UnormSrgb) {
|
||||
auto p = parser("bgra8unorm_srgb");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, type::ImageFormat::kBgra8UnormSrgb);
|
||||
EXPECT_EQ(t.value, sem::ImageFormat::kBgra8UnormSrgb);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
@@ -223,7 +223,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgb10A2Unorm) {
|
||||
auto p = parser("rgb10a2unorm");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, type::ImageFormat::kRgb10A2Unorm);
|
||||
EXPECT_EQ(t.value, sem::ImageFormat::kRgb10A2Unorm);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
@@ -231,7 +231,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rg11B10Float) {
|
||||
auto p = parser("rg11b10float");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, type::ImageFormat::kRg11B10Float);
|
||||
EXPECT_EQ(t.value, sem::ImageFormat::kRg11B10Float);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
@@ -239,7 +239,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rg32Uint) {
|
||||
auto p = parser("rg32uint");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, type::ImageFormat::kRg32Uint);
|
||||
EXPECT_EQ(t.value, sem::ImageFormat::kRg32Uint);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
@@ -247,7 +247,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rg32Sint) {
|
||||
auto p = parser("rg32sint");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, type::ImageFormat::kRg32Sint);
|
||||
EXPECT_EQ(t.value, sem::ImageFormat::kRg32Sint);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
@@ -255,7 +255,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rg32Float) {
|
||||
auto p = parser("rg32float");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, type::ImageFormat::kRg32Float);
|
||||
EXPECT_EQ(t.value, sem::ImageFormat::kRg32Float);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
@@ -263,7 +263,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba16Uint) {
|
||||
auto p = parser("rgba16uint");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, type::ImageFormat::kRgba16Uint);
|
||||
EXPECT_EQ(t.value, sem::ImageFormat::kRgba16Uint);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
@@ -271,7 +271,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba16Sint) {
|
||||
auto p = parser("rgba16sint");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, type::ImageFormat::kRgba16Sint);
|
||||
EXPECT_EQ(t.value, sem::ImageFormat::kRgba16Sint);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
@@ -279,7 +279,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba16Float) {
|
||||
auto p = parser("rgba16float");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, type::ImageFormat::kRgba16Float);
|
||||
EXPECT_EQ(t.value, sem::ImageFormat::kRgba16Float);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
@@ -287,7 +287,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba32Uint) {
|
||||
auto p = parser("rgba32uint");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, type::ImageFormat::kRgba32Uint);
|
||||
EXPECT_EQ(t.value, sem::ImageFormat::kRgba32Uint);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
@@ -295,7 +295,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba32Sint) {
|
||||
auto p = parser("rgba32sint");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, type::ImageFormat::kRgba32Sint);
|
||||
EXPECT_EQ(t.value, sem::ImageFormat::kRgba32Sint);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
@@ -303,7 +303,7 @@ TEST_F(ParserImplTest, ImageStorageType_Rgba32Float) {
|
||||
auto p = parser("rgba32float");
|
||||
auto t = p->expect_image_storage_type("test");
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, type::ImageFormat::kRgba32Float);
|
||||
EXPECT_EQ(t.value, sem::ImageFormat::kRgba32Float);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace {
|
||||
TEST_F(ParserImplTest, ParamList_Single) {
|
||||
auto p = parser("a : i32");
|
||||
|
||||
auto* i32 = p->builder().create<type::I32>();
|
||||
auto* i32 = p->builder().create<sem::I32>();
|
||||
|
||||
auto e = p->expect_param_list();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
@@ -42,9 +42,9 @@ TEST_F(ParserImplTest, ParamList_Single) {
|
||||
TEST_F(ParserImplTest, ParamList_Multiple) {
|
||||
auto p = parser("a : i32, b: f32, c: vec2<f32>");
|
||||
|
||||
auto* i32 = p->builder().create<type::I32>();
|
||||
auto* f32 = p->builder().create<type::F32>();
|
||||
auto* vec2 = p->builder().create<type::Vector>(f32, 2);
|
||||
auto* i32 = p->builder().create<sem::I32>();
|
||||
auto* f32 = p->builder().create<sem::F32>();
|
||||
auto* vec2 = p->builder().create<sem::Vector>(f32, 2);
|
||||
|
||||
auto e = p->expect_param_list();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
@@ -100,8 +100,8 @@ TEST_F(ParserImplTest, ParamList_Decorations) {
|
||||
"[[builtin(position)]] coord : vec4<f32>, "
|
||||
"[[location(1)]] loc1 : f32");
|
||||
|
||||
auto* f32 = p->builder().create<type::F32>();
|
||||
auto* vec4 = p->builder().create<type::Vector>(f32, 4);
|
||||
auto* f32 = p->builder().create<sem::F32>();
|
||||
auto* vec4 = p->builder().create<sem::Vector>(f32, 4);
|
||||
|
||||
auto e = p->expect_param_list();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
|
||||
@@ -237,7 +237,7 @@ TEST_F(ParserImplTest, PrimaryExpression_ParenExpr_InvalidExpr) {
|
||||
TEST_F(ParserImplTest, PrimaryExpression_Cast) {
|
||||
auto p = parser("f32(1)");
|
||||
|
||||
auto* f32 = p->builder().create<type::F32>();
|
||||
auto* f32 = p->builder().create<sem::F32>();
|
||||
|
||||
auto e = p->primary_expression();
|
||||
EXPECT_TRUE(e.matched);
|
||||
@@ -258,7 +258,7 @@ TEST_F(ParserImplTest, PrimaryExpression_Cast) {
|
||||
TEST_F(ParserImplTest, PrimaryExpression_Bitcast) {
|
||||
auto p = parser("bitcast<f32>(1)");
|
||||
|
||||
auto* f32 = p->builder().create<type::F32>();
|
||||
auto* f32 = p->builder().create<sem::F32>();
|
||||
|
||||
auto e = p->primary_expression();
|
||||
EXPECT_TRUE(e.matched);
|
||||
|
||||
@@ -32,7 +32,7 @@ TEST_F(ParserImplTest, SampledTextureType_1d) {
|
||||
auto t = p->sampled_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, type::TextureDimension::k1d);
|
||||
EXPECT_EQ(t.value, sem::TextureDimension::k1d);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ TEST_F(ParserImplTest, SampledTextureType_2d) {
|
||||
auto t = p->sampled_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, type::TextureDimension::k2d);
|
||||
EXPECT_EQ(t.value, sem::TextureDimension::k2d);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ TEST_F(ParserImplTest, SampledTextureType_2dArray) {
|
||||
auto t = p->sampled_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, type::TextureDimension::k2dArray);
|
||||
EXPECT_EQ(t.value, sem::TextureDimension::k2dArray);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ TEST_F(ParserImplTest, SampledTextureType_3d) {
|
||||
auto t = p->sampled_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, type::TextureDimension::k3d);
|
||||
EXPECT_EQ(t.value, sem::TextureDimension::k3d);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ TEST_F(ParserImplTest, SampledTextureType_Cube) {
|
||||
auto t = p->sampled_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, type::TextureDimension::kCube);
|
||||
EXPECT_EQ(t.value, sem::TextureDimension::kCube);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ TEST_F(ParserImplTest, SampledTextureType_kCubeArray) {
|
||||
auto t = p->sampled_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, type::TextureDimension::kCubeArray);
|
||||
EXPECT_EQ(t.value, sem::TextureDimension::kCubeArray);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
|
||||
@@ -34,8 +34,8 @@ TEST_F(ParserImplTest, SamplerType_Sampler) {
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
ASSERT_NE(t.value, nullptr);
|
||||
ASSERT_TRUE(t->Is<type::Sampler>());
|
||||
EXPECT_FALSE(t->As<type::Sampler>()->IsComparison());
|
||||
ASSERT_TRUE(t->Is<sem::Sampler>());
|
||||
EXPECT_FALSE(t->As<sem::Sampler>()->IsComparison());
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
@@ -45,8 +45,8 @@ TEST_F(ParserImplTest, SamplerType_ComparisonSampler) {
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
ASSERT_NE(t.value, nullptr);
|
||||
ASSERT_TRUE(t->Is<type::Sampler>());
|
||||
EXPECT_TRUE(t->As<type::Sampler>()->IsComparison());
|
||||
ASSERT_TRUE(t->Is<sem::Sampler>());
|
||||
EXPECT_TRUE(t->As<sem::Sampler>()->IsComparison());
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ TEST_F(ParserImplTest, StorageTextureType_1d) {
|
||||
auto t = p->storage_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, type::TextureDimension::k1d);
|
||||
EXPECT_EQ(t.value, sem::TextureDimension::k1d);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ TEST_F(ParserImplTest, StorageTextureType_2d) {
|
||||
auto t = p->storage_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, type::TextureDimension::k2d);
|
||||
EXPECT_EQ(t.value, sem::TextureDimension::k2d);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ TEST_F(ParserImplTest, StorageTextureType_2dArray) {
|
||||
auto t = p->storage_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, type::TextureDimension::k2dArray);
|
||||
EXPECT_EQ(t.value, sem::TextureDimension::k2dArray);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ TEST_F(ParserImplTest, StorageTextureType_3d) {
|
||||
auto t = p->storage_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_EQ(t.value, type::TextureDimension::k3d);
|
||||
EXPECT_EQ(t.value, sem::TextureDimension::k3d);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ TEST_F(ParserImplTest, StructBodyDecl_Parses) {
|
||||
auto p = parser("{a : i32;}");
|
||||
|
||||
auto& builder = p->builder();
|
||||
auto* i32 = builder.create<type::I32>();
|
||||
auto* i32 = builder.create<sem::I32>();
|
||||
|
||||
auto m = p->expect_struct_body_decl();
|
||||
ASSERT_FALSE(p->has_error());
|
||||
|
||||
@@ -38,8 +38,8 @@ TEST_F(ParserImplTest, TextureSamplerTypes_Sampler) {
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
ASSERT_NE(t.value, nullptr);
|
||||
ASSERT_TRUE(t->Is<type::Sampler>());
|
||||
ASSERT_FALSE(t->As<type::Sampler>()->IsComparison());
|
||||
ASSERT_TRUE(t->Is<sem::Sampler>());
|
||||
ASSERT_FALSE(t->As<sem::Sampler>()->IsComparison());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, TextureSamplerTypes_SamplerComparison) {
|
||||
@@ -49,8 +49,8 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SamplerComparison) {
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
ASSERT_NE(t.value, nullptr);
|
||||
ASSERT_TRUE(t->Is<type::Sampler>());
|
||||
ASSERT_TRUE(t->As<type::Sampler>()->IsComparison());
|
||||
ASSERT_TRUE(t->Is<sem::Sampler>());
|
||||
ASSERT_TRUE(t->As<sem::Sampler>()->IsComparison());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, TextureSamplerTypes_DepthTexture) {
|
||||
@@ -60,9 +60,9 @@ TEST_F(ParserImplTest, TextureSamplerTypes_DepthTexture) {
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
ASSERT_NE(t.value, nullptr);
|
||||
ASSERT_TRUE(t->Is<type::Texture>());
|
||||
ASSERT_TRUE(t->Is<type::DepthTexture>());
|
||||
EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::k2d);
|
||||
ASSERT_TRUE(t->Is<sem::Texture>());
|
||||
ASSERT_TRUE(t->Is<sem::DepthTexture>());
|
||||
EXPECT_EQ(t->As<sem::Texture>()->dim(), sem::TextureDimension::k2d);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_F32) {
|
||||
@@ -72,10 +72,10 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_F32) {
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
ASSERT_NE(t.value, nullptr);
|
||||
ASSERT_TRUE(t->Is<type::Texture>());
|
||||
ASSERT_TRUE(t->Is<type::SampledTexture>());
|
||||
ASSERT_TRUE(t->As<type::SampledTexture>()->type()->Is<type::F32>());
|
||||
EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::k1d);
|
||||
ASSERT_TRUE(t->Is<sem::Texture>());
|
||||
ASSERT_TRUE(t->Is<sem::SampledTexture>());
|
||||
ASSERT_TRUE(t->As<sem::SampledTexture>()->type()->Is<sem::F32>());
|
||||
EXPECT_EQ(t->As<sem::Texture>()->dim(), sem::TextureDimension::k1d);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_I32) {
|
||||
@@ -85,10 +85,10 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_I32) {
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
ASSERT_NE(t.value, nullptr);
|
||||
ASSERT_TRUE(t->Is<type::Texture>());
|
||||
ASSERT_TRUE(t->Is<type::SampledTexture>());
|
||||
ASSERT_TRUE(t->As<type::SampledTexture>()->type()->Is<type::I32>());
|
||||
EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::k2d);
|
||||
ASSERT_TRUE(t->Is<sem::Texture>());
|
||||
ASSERT_TRUE(t->Is<sem::SampledTexture>());
|
||||
ASSERT_TRUE(t->As<sem::SampledTexture>()->type()->Is<sem::I32>());
|
||||
EXPECT_EQ(t->As<sem::Texture>()->dim(), sem::TextureDimension::k2d);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_U32) {
|
||||
@@ -98,10 +98,10 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_U32) {
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
ASSERT_NE(t.value, nullptr);
|
||||
ASSERT_TRUE(t->Is<type::Texture>());
|
||||
ASSERT_TRUE(t->Is<type::SampledTexture>());
|
||||
ASSERT_TRUE(t->As<type::SampledTexture>()->type()->Is<type::U32>());
|
||||
EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::k3d);
|
||||
ASSERT_TRUE(t->Is<sem::Texture>());
|
||||
ASSERT_TRUE(t->Is<sem::SampledTexture>());
|
||||
ASSERT_TRUE(t->As<sem::SampledTexture>()->type()->Is<sem::U32>());
|
||||
EXPECT_EQ(t->As<sem::Texture>()->dim(), sem::TextureDimension::k3d);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_Invalid) {
|
||||
@@ -151,10 +151,10 @@ TEST_F(ParserImplTest, TextureSamplerTypes_MultisampledTexture_I32) {
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
ASSERT_NE(t.value, nullptr);
|
||||
ASSERT_TRUE(t->Is<type::Texture>());
|
||||
ASSERT_TRUE(t->Is<type::MultisampledTexture>());
|
||||
ASSERT_TRUE(t->As<type::MultisampledTexture>()->type()->Is<type::I32>());
|
||||
EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::k2d);
|
||||
ASSERT_TRUE(t->Is<sem::Texture>());
|
||||
ASSERT_TRUE(t->Is<sem::MultisampledTexture>());
|
||||
ASSERT_TRUE(t->As<sem::MultisampledTexture>()->type()->Is<sem::I32>());
|
||||
EXPECT_EQ(t->As<sem::Texture>()->dim(), sem::TextureDimension::k2d);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, TextureSamplerTypes_MultisampledTexture_Invalid) {
|
||||
@@ -205,11 +205,11 @@ TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_Readonly1dR8Unorm) {
|
||||
EXPECT_FALSE(t.errored);
|
||||
ASSERT_NE(t.value, nullptr);
|
||||
|
||||
ASSERT_TRUE(t->Is<type::Texture>());
|
||||
ASSERT_TRUE(t->Is<type::StorageTexture>());
|
||||
EXPECT_EQ(t->As<type::StorageTexture>()->image_format(),
|
||||
type::ImageFormat::kR8Unorm);
|
||||
EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::k1d);
|
||||
ASSERT_TRUE(t->Is<sem::Texture>());
|
||||
ASSERT_TRUE(t->Is<sem::StorageTexture>());
|
||||
EXPECT_EQ(t->As<sem::StorageTexture>()->image_format(),
|
||||
sem::ImageFormat::kR8Unorm);
|
||||
EXPECT_EQ(t->As<sem::Texture>()->dim(), sem::TextureDimension::k1d);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_Writeonly2dR16Float) {
|
||||
@@ -220,11 +220,11 @@ TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_Writeonly2dR16Float) {
|
||||
EXPECT_FALSE(t.errored);
|
||||
ASSERT_NE(t.value, nullptr);
|
||||
|
||||
ASSERT_TRUE(t->Is<type::Texture>());
|
||||
ASSERT_TRUE(t->Is<type::StorageTexture>());
|
||||
EXPECT_EQ(t->As<type::StorageTexture>()->image_format(),
|
||||
type::ImageFormat::kR16Float);
|
||||
EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::k2d);
|
||||
ASSERT_TRUE(t->Is<sem::Texture>());
|
||||
ASSERT_TRUE(t->Is<sem::StorageTexture>());
|
||||
EXPECT_EQ(t->As<sem::StorageTexture>()->image_format(),
|
||||
sem::ImageFormat::kR16Float);
|
||||
EXPECT_EQ(t->As<sem::Texture>()->dim(), sem::TextureDimension::k2d);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_InvalidType) {
|
||||
|
||||
@@ -22,23 +22,23 @@ namespace {
|
||||
TEST_F(ParserImplTest, TypeDecl_ParsesType) {
|
||||
auto p = parser("type a = i32");
|
||||
|
||||
auto* i32 = p->builder().create<type::I32>();
|
||||
auto* i32 = p->builder().create<sem::I32>();
|
||||
|
||||
auto t = p->type_alias();
|
||||
EXPECT_FALSE(p->has_error());
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_TRUE(t.matched);
|
||||
ASSERT_NE(t.value, nullptr);
|
||||
ASSERT_TRUE(t->Is<type::Alias>());
|
||||
auto* alias = t->As<type::Alias>();
|
||||
ASSERT_TRUE(alias->type()->Is<type::I32>());
|
||||
ASSERT_TRUE(t->Is<sem::Alias>());
|
||||
auto* alias = t->As<sem::Alias>();
|
||||
ASSERT_TRUE(alias->type()->Is<sem::I32>());
|
||||
ASSERT_EQ(alias->type(), i32);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_ParsesStruct_Ident) {
|
||||
auto p = parser("type a = B");
|
||||
|
||||
type::StructType str(p->builder().Symbols().Get("B"), {});
|
||||
sem::StructType str(p->builder().Symbols().Get("B"), {});
|
||||
p->register_constructed("B", &str);
|
||||
|
||||
auto t = p->type_alias();
|
||||
@@ -46,12 +46,12 @@ TEST_F(ParserImplTest, TypeDecl_ParsesStruct_Ident) {
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_TRUE(t.matched);
|
||||
ASSERT_NE(t.value, nullptr);
|
||||
ASSERT_TRUE(t->Is<type::Alias>());
|
||||
auto* alias = t->As<type::Alias>();
|
||||
ASSERT_TRUE(t->Is<sem::Alias>());
|
||||
auto* alias = t->As<sem::Alias>();
|
||||
EXPECT_EQ(p->builder().Symbols().NameFor(alias->symbol()), "a");
|
||||
ASSERT_TRUE(alias->type()->Is<type::StructType>());
|
||||
ASSERT_TRUE(alias->type()->Is<sem::StructType>());
|
||||
|
||||
auto* s = alias->type()->As<type::StructType>();
|
||||
auto* s = alias->type()->As<sem::StructType>();
|
||||
EXPECT_EQ(s->symbol(), p->builder().Symbols().Get("B"));
|
||||
EXPECT_EQ(s->symbol(), p->builder().Symbols().Get("B"));
|
||||
}
|
||||
|
||||
@@ -34,9 +34,9 @@ TEST_F(ParserImplTest, TypeDecl_Identifier) {
|
||||
|
||||
auto& builder = p->builder();
|
||||
|
||||
auto* int_type = builder.create<type::I32>();
|
||||
auto* int_type = builder.create<sem::I32>();
|
||||
auto* alias_type =
|
||||
builder.create<type::Alias>(builder.Symbols().Register("A"), int_type);
|
||||
builder.create<sem::Alias>(builder.Symbols().Register("A"), int_type);
|
||||
|
||||
p->register_constructed("A", alias_type);
|
||||
|
||||
@@ -45,9 +45,9 @@ TEST_F(ParserImplTest, TypeDecl_Identifier) {
|
||||
EXPECT_FALSE(t.errored);
|
||||
ASSERT_NE(t.value, nullptr) << p->error();
|
||||
EXPECT_EQ(t.value, alias_type);
|
||||
ASSERT_TRUE(t->Is<type::Alias>());
|
||||
ASSERT_TRUE(t->Is<sem::Alias>());
|
||||
|
||||
auto* alias = t->As<type::Alias>();
|
||||
auto* alias = t->As<sem::Alias>();
|
||||
EXPECT_EQ(p->builder().Symbols().NameFor(alias->symbol()), "A");
|
||||
EXPECT_EQ(alias->type(), int_type);
|
||||
}
|
||||
@@ -67,56 +67,56 @@ TEST_F(ParserImplTest, TypeDecl_Bool) {
|
||||
auto p = parser("bool");
|
||||
|
||||
auto& builder = p->builder();
|
||||
auto* bool_type = builder.create<type::Bool>();
|
||||
auto* bool_type = builder.create<sem::Bool>();
|
||||
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
ASSERT_NE(t.value, nullptr) << p->error();
|
||||
EXPECT_EQ(t.value, bool_type);
|
||||
ASSERT_TRUE(t->Is<type::Bool>());
|
||||
ASSERT_TRUE(t->Is<sem::Bool>());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_F32) {
|
||||
auto p = parser("f32");
|
||||
|
||||
auto& builder = p->builder();
|
||||
auto* float_type = builder.create<type::F32>();
|
||||
auto* float_type = builder.create<sem::F32>();
|
||||
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
ASSERT_NE(t.value, nullptr) << p->error();
|
||||
EXPECT_EQ(t.value, float_type);
|
||||
ASSERT_TRUE(t->Is<type::F32>());
|
||||
ASSERT_TRUE(t->Is<sem::F32>());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_I32) {
|
||||
auto p = parser("i32");
|
||||
|
||||
auto& builder = p->builder();
|
||||
auto* int_type = builder.create<type::I32>();
|
||||
auto* int_type = builder.create<sem::I32>();
|
||||
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
ASSERT_NE(t.value, nullptr) << p->error();
|
||||
EXPECT_EQ(t.value, int_type);
|
||||
ASSERT_TRUE(t->Is<type::I32>());
|
||||
ASSERT_TRUE(t->Is<sem::I32>());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_U32) {
|
||||
auto p = parser("u32");
|
||||
|
||||
auto& builder = p->builder();
|
||||
auto* uint_type = builder.create<type::U32>();
|
||||
auto* uint_type = builder.create<sem::U32>();
|
||||
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
ASSERT_NE(t.value, nullptr) << p->error();
|
||||
EXPECT_EQ(t.value, uint_type);
|
||||
ASSERT_TRUE(t->Is<type::U32>());
|
||||
ASSERT_TRUE(t->Is<sem::U32>());
|
||||
}
|
||||
|
||||
struct VecData {
|
||||
@@ -138,8 +138,8 @@ TEST_P(VecTest, Parse) {
|
||||
EXPECT_FALSE(t.errored);
|
||||
ASSERT_NE(t.value, nullptr) << p->error();
|
||||
ASSERT_FALSE(p->has_error());
|
||||
EXPECT_TRUE(t->Is<type::Vector>());
|
||||
EXPECT_EQ(t->As<type::Vector>()->size(), params.count);
|
||||
EXPECT_TRUE(t->Is<sem::Vector>());
|
||||
EXPECT_EQ(t->As<sem::Vector>()->size(), params.count);
|
||||
}
|
||||
INSTANTIATE_TEST_SUITE_P(ParserImplTest,
|
||||
VecTest,
|
||||
@@ -226,10 +226,10 @@ TEST_F(ParserImplTest, TypeDecl_Ptr) {
|
||||
EXPECT_FALSE(t.errored);
|
||||
ASSERT_NE(t.value, nullptr) << p->error();
|
||||
ASSERT_FALSE(p->has_error());
|
||||
ASSERT_TRUE(t->Is<type::Pointer>());
|
||||
ASSERT_TRUE(t->Is<sem::Pointer>());
|
||||
|
||||
auto* ptr = t->As<type::Pointer>();
|
||||
ASSERT_TRUE(ptr->type()->Is<type::F32>());
|
||||
auto* ptr = t->As<sem::Pointer>();
|
||||
ASSERT_TRUE(ptr->type()->Is<sem::F32>());
|
||||
ASSERT_EQ(ptr->storage_class(), ast::StorageClass::kFunction);
|
||||
}
|
||||
|
||||
@@ -240,15 +240,15 @@ TEST_F(ParserImplTest, TypeDecl_Ptr_ToVec) {
|
||||
EXPECT_FALSE(t.errored);
|
||||
ASSERT_NE(t.value, nullptr) << p->error();
|
||||
ASSERT_FALSE(p->has_error());
|
||||
ASSERT_TRUE(t->Is<type::Pointer>());
|
||||
ASSERT_TRUE(t->Is<sem::Pointer>());
|
||||
|
||||
auto* ptr = t->As<type::Pointer>();
|
||||
ASSERT_TRUE(ptr->type()->Is<type::Vector>());
|
||||
auto* ptr = t->As<sem::Pointer>();
|
||||
ASSERT_TRUE(ptr->type()->Is<sem::Vector>());
|
||||
ASSERT_EQ(ptr->storage_class(), ast::StorageClass::kFunction);
|
||||
|
||||
auto* vec = ptr->type()->As<type::Vector>();
|
||||
auto* vec = ptr->type()->As<sem::Vector>();
|
||||
ASSERT_EQ(vec->size(), 2u);
|
||||
ASSERT_TRUE(vec->type()->Is<type::F32>());
|
||||
ASSERT_TRUE(vec->type()->Is<sem::F32>());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Ptr_MissingLessThan) {
|
||||
@@ -338,12 +338,12 @@ TEST_F(ParserImplTest, TypeDecl_Array) {
|
||||
EXPECT_FALSE(t.errored);
|
||||
ASSERT_NE(t.value, nullptr) << p->error();
|
||||
ASSERT_FALSE(p->has_error());
|
||||
ASSERT_TRUE(t->Is<type::ArrayType>());
|
||||
ASSERT_TRUE(t->Is<sem::ArrayType>());
|
||||
|
||||
auto* a = t->As<type::ArrayType>();
|
||||
auto* a = t->As<sem::ArrayType>();
|
||||
ASSERT_FALSE(a->IsRuntimeArray());
|
||||
ASSERT_EQ(a->size(), 5u);
|
||||
ASSERT_TRUE(a->type()->Is<type::F32>());
|
||||
ASSERT_TRUE(a->type()->Is<sem::F32>());
|
||||
EXPECT_EQ(a->decorations().size(), 0u);
|
||||
}
|
||||
|
||||
@@ -354,12 +354,12 @@ TEST_F(ParserImplTest, TypeDecl_Array_Stride) {
|
||||
EXPECT_FALSE(t.errored);
|
||||
ASSERT_NE(t.value, nullptr) << p->error();
|
||||
ASSERT_FALSE(p->has_error());
|
||||
ASSERT_TRUE(t->Is<type::ArrayType>());
|
||||
ASSERT_TRUE(t->Is<sem::ArrayType>());
|
||||
|
||||
auto* a = t->As<type::ArrayType>();
|
||||
auto* a = t->As<sem::ArrayType>();
|
||||
ASSERT_FALSE(a->IsRuntimeArray());
|
||||
ASSERT_EQ(a->size(), 5u);
|
||||
ASSERT_TRUE(a->type()->Is<type::F32>());
|
||||
ASSERT_TRUE(a->type()->Is<sem::F32>());
|
||||
|
||||
ASSERT_EQ(a->decorations().size(), 1u);
|
||||
auto* stride = a->decorations()[0];
|
||||
@@ -374,11 +374,11 @@ TEST_F(ParserImplTest, TypeDecl_Array_Runtime_Stride) {
|
||||
EXPECT_FALSE(t.errored);
|
||||
ASSERT_NE(t.value, nullptr) << p->error();
|
||||
ASSERT_FALSE(p->has_error());
|
||||
ASSERT_TRUE(t->Is<type::ArrayType>());
|
||||
ASSERT_TRUE(t->Is<sem::ArrayType>());
|
||||
|
||||
auto* a = t->As<type::ArrayType>();
|
||||
auto* a = t->As<sem::ArrayType>();
|
||||
ASSERT_TRUE(a->IsRuntimeArray());
|
||||
ASSERT_TRUE(a->type()->Is<type::F32>());
|
||||
ASSERT_TRUE(a->type()->Is<sem::F32>());
|
||||
|
||||
ASSERT_EQ(a->decorations().size(), 1u);
|
||||
auto* stride = a->decorations()[0];
|
||||
@@ -393,11 +393,11 @@ TEST_F(ParserImplTest, TypeDecl_Array_MultipleDecorations_OneBlock) {
|
||||
EXPECT_FALSE(t.errored);
|
||||
ASSERT_NE(t.value, nullptr) << p->error();
|
||||
ASSERT_FALSE(p->has_error());
|
||||
ASSERT_TRUE(t->Is<type::ArrayType>());
|
||||
ASSERT_TRUE(t->Is<sem::ArrayType>());
|
||||
|
||||
auto* a = t->As<type::ArrayType>();
|
||||
auto* a = t->As<sem::ArrayType>();
|
||||
ASSERT_TRUE(a->IsRuntimeArray());
|
||||
ASSERT_TRUE(a->type()->Is<type::F32>());
|
||||
ASSERT_TRUE(a->type()->Is<sem::F32>());
|
||||
|
||||
auto& decos = a->decorations();
|
||||
ASSERT_EQ(decos.size(), 2u);
|
||||
@@ -414,11 +414,11 @@ TEST_F(ParserImplTest, TypeDecl_Array_MultipleDecorations_MultipleBlocks) {
|
||||
EXPECT_FALSE(t.errored);
|
||||
ASSERT_NE(t.value, nullptr) << p->error();
|
||||
ASSERT_FALSE(p->has_error());
|
||||
ASSERT_TRUE(t->Is<type::ArrayType>());
|
||||
ASSERT_TRUE(t->Is<sem::ArrayType>());
|
||||
|
||||
auto* a = t->As<type::ArrayType>();
|
||||
auto* a = t->As<sem::ArrayType>();
|
||||
ASSERT_TRUE(a->IsRuntimeArray());
|
||||
ASSERT_TRUE(a->type()->Is<type::F32>());
|
||||
ASSERT_TRUE(a->type()->Is<sem::F32>());
|
||||
|
||||
auto& decos = a->decorations();
|
||||
ASSERT_EQ(decos.size(), 2u);
|
||||
@@ -517,11 +517,11 @@ TEST_F(ParserImplTest, TypeDecl_Array_Runtime) {
|
||||
EXPECT_FALSE(t.errored);
|
||||
ASSERT_NE(t.value, nullptr) << p->error();
|
||||
ASSERT_FALSE(p->has_error());
|
||||
ASSERT_TRUE(t->Is<type::ArrayType>());
|
||||
ASSERT_TRUE(t->Is<sem::ArrayType>());
|
||||
|
||||
auto* a = t->As<type::ArrayType>();
|
||||
auto* a = t->As<sem::ArrayType>();
|
||||
ASSERT_TRUE(a->IsRuntimeArray());
|
||||
ASSERT_TRUE(a->type()->Is<type::U32>());
|
||||
ASSERT_TRUE(a->type()->Is<sem::U32>());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Array_Runtime_Vec) {
|
||||
@@ -531,9 +531,9 @@ TEST_F(ParserImplTest, TypeDecl_Array_Runtime_Vec) {
|
||||
EXPECT_FALSE(t.errored);
|
||||
ASSERT_NE(t.value, nullptr) << p->error();
|
||||
ASSERT_FALSE(p->has_error());
|
||||
ASSERT_TRUE(t->Is<type::ArrayType>());
|
||||
ASSERT_TRUE(t->Is<sem::ArrayType>());
|
||||
|
||||
auto* a = t->As<type::ArrayType>();
|
||||
auto* a = t->As<sem::ArrayType>();
|
||||
ASSERT_TRUE(a->IsRuntimeArray());
|
||||
ASSERT_TRUE(a->type()->is_unsigned_integer_vector());
|
||||
}
|
||||
@@ -628,8 +628,8 @@ TEST_P(MatrixTest, Parse) {
|
||||
EXPECT_FALSE(t.errored);
|
||||
ASSERT_NE(t.value, nullptr) << p->error();
|
||||
ASSERT_FALSE(p->has_error());
|
||||
EXPECT_TRUE(t->Is<type::Matrix>());
|
||||
auto* mat = t->As<type::Matrix>();
|
||||
EXPECT_TRUE(t->Is<sem::Matrix>());
|
||||
auto* mat = t->As<sem::Matrix>();
|
||||
EXPECT_EQ(mat->rows(), params.rows);
|
||||
EXPECT_EQ(mat->columns(), params.columns);
|
||||
}
|
||||
@@ -746,32 +746,32 @@ TEST_F(ParserImplTest, TypeDecl_Sampler) {
|
||||
auto p = parser("sampler");
|
||||
|
||||
auto& builder = p->builder();
|
||||
auto* type = builder.create<type::Sampler>(type::SamplerKind::kSampler);
|
||||
auto* type = builder.create<sem::Sampler>(sem::SamplerKind::kSampler);
|
||||
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
ASSERT_NE(t.value, nullptr) << p->error();
|
||||
EXPECT_EQ(t.value, type);
|
||||
ASSERT_TRUE(t->Is<type::Sampler>());
|
||||
ASSERT_FALSE(t->As<type::Sampler>()->IsComparison());
|
||||
ASSERT_TRUE(t->Is<sem::Sampler>());
|
||||
ASSERT_FALSE(t->As<sem::Sampler>()->IsComparison());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_Texture) {
|
||||
auto p = parser("texture_cube<f32>");
|
||||
|
||||
auto& builder = p->builder();
|
||||
auto* type = builder.create<type::SampledTexture>(
|
||||
type::TextureDimension::kCube, ty.f32());
|
||||
auto* type = builder.create<sem::SampledTexture>(sem::TextureDimension::kCube,
|
||||
ty.f32());
|
||||
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
ASSERT_NE(t.value, nullptr);
|
||||
EXPECT_EQ(t.value, type);
|
||||
ASSERT_TRUE(t->Is<type::Texture>());
|
||||
ASSERT_TRUE(t->Is<type::SampledTexture>());
|
||||
ASSERT_TRUE(t->As<type::SampledTexture>()->type()->Is<type::F32>());
|
||||
ASSERT_TRUE(t->Is<sem::Texture>());
|
||||
ASSERT_TRUE(t->Is<sem::SampledTexture>());
|
||||
ASSERT_TRUE(t->As<sem::SampledTexture>()->type()->Is<sem::F32>());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -27,7 +27,7 @@ TEST_F(ParserImplTest, VariableDecl_Parses) {
|
||||
EXPECT_FALSE(v.errored);
|
||||
EXPECT_EQ(v->name, "my_var");
|
||||
EXPECT_NE(v->type, nullptr);
|
||||
EXPECT_TRUE(v->type->Is<type::F32>());
|
||||
EXPECT_TRUE(v->type->Is<sem::F32>());
|
||||
|
||||
EXPECT_EQ(v->source.range.begin.line, 1u);
|
||||
EXPECT_EQ(v->source.range.begin.column, 5u);
|
||||
@@ -62,7 +62,7 @@ TEST_F(ParserImplTest, VariableDecl_WithStorageClass) {
|
||||
EXPECT_FALSE(v.errored);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
EXPECT_EQ(v->name, "my_var");
|
||||
EXPECT_TRUE(v->type->Is<type::F32>());
|
||||
EXPECT_TRUE(v->type->Is<sem::F32>());
|
||||
EXPECT_EQ(v->storage_class, ast::StorageClass::kPrivate);
|
||||
|
||||
EXPECT_EQ(v->source.range.begin.line, 1u);
|
||||
|
||||
@@ -28,7 +28,7 @@ TEST_F(ParserImplTest, VariableIdentDecl_Parses) {
|
||||
ASSERT_FALSE(decl.errored);
|
||||
ASSERT_EQ(decl->name, "my_var");
|
||||
ASSERT_NE(decl->type, nullptr);
|
||||
ASSERT_TRUE(decl->type->Is<type::F32>());
|
||||
ASSERT_TRUE(decl->type->Is<sem::F32>());
|
||||
|
||||
ASSERT_EQ(decl->source.range.begin.line, 1u);
|
||||
ASSERT_EQ(decl->source.range.begin.column, 1u);
|
||||
@@ -84,11 +84,10 @@ TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithTextureAccessDeco_Read) {
|
||||
ASSERT_FALSE(decl.errored);
|
||||
ASSERT_EQ(decl->name, "my_var");
|
||||
ASSERT_NE(decl->type, nullptr);
|
||||
ASSERT_TRUE(decl->type->Is<type::AccessControl>());
|
||||
EXPECT_TRUE(decl->type->As<type::AccessControl>()->IsReadOnly());
|
||||
ASSERT_TRUE(decl->type->As<type::AccessControl>()
|
||||
->type()
|
||||
->Is<type::StorageTexture>());
|
||||
ASSERT_TRUE(decl->type->Is<sem::AccessControl>());
|
||||
EXPECT_TRUE(decl->type->As<sem::AccessControl>()->IsReadOnly());
|
||||
ASSERT_TRUE(
|
||||
decl->type->As<sem::AccessControl>()->type()->Is<sem::StorageTexture>());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithTextureAccessDeco_Write) {
|
||||
@@ -99,11 +98,10 @@ TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithTextureAccessDeco_Write) {
|
||||
ASSERT_FALSE(decl.errored);
|
||||
ASSERT_EQ(decl->name, "my_var");
|
||||
ASSERT_NE(decl->type, nullptr);
|
||||
ASSERT_TRUE(decl->type->Is<type::AccessControl>());
|
||||
EXPECT_TRUE(decl->type->As<type::AccessControl>()->IsWriteOnly());
|
||||
ASSERT_TRUE(decl->type->As<type::AccessControl>()
|
||||
->type()
|
||||
->Is<type::StorageTexture>());
|
||||
ASSERT_TRUE(decl->type->Is<sem::AccessControl>());
|
||||
EXPECT_TRUE(decl->type->As<sem::AccessControl>()->IsWriteOnly());
|
||||
ASSERT_TRUE(
|
||||
decl->type->As<sem::AccessControl>()->type()->Is<sem::StorageTexture>());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_Read) {
|
||||
@@ -127,8 +125,8 @@ TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_Read) {
|
||||
ASSERT_FALSE(decl.errored);
|
||||
ASSERT_EQ(decl->name, "my_var");
|
||||
ASSERT_NE(decl->type, nullptr);
|
||||
ASSERT_TRUE(decl->type->Is<type::AccessControl>());
|
||||
EXPECT_TRUE(decl->type->As<type::AccessControl>()->IsReadOnly());
|
||||
ASSERT_TRUE(decl->type->Is<sem::AccessControl>());
|
||||
EXPECT_TRUE(decl->type->As<sem::AccessControl>()->IsReadOnly());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_ReadWrite) {
|
||||
@@ -152,8 +150,8 @@ TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_ReadWrite) {
|
||||
ASSERT_FALSE(decl.errored);
|
||||
ASSERT_EQ(decl->name, "my_var");
|
||||
ASSERT_NE(decl->type, nullptr);
|
||||
ASSERT_TRUE(decl->type->Is<type::AccessControl>());
|
||||
EXPECT_TRUE(decl->type->As<type::AccessControl>()->IsReadWrite());
|
||||
ASSERT_TRUE(decl->type->Is<sem::AccessControl>());
|
||||
EXPECT_TRUE(decl->type->As<sem::AccessControl>()->IsReadWrite());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, VariableIdentDecl_MultipleAccessDecoFail) {
|
||||
|
||||
Reference in New Issue
Block a user