Cleanup GLSL writer.
This Cl removes the boolean return values from most of the GLSL writer methods. The diagnostics are used to determine if the generation was successful. The writer itself just continues until complete. Change-Id: Ia64968eaa6a0aa39a9713fa78f3e743f2de38b44 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/127020 Reviewed-by: Ben Clayton <bclayton@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
parent
c480632ed6
commit
e6e5998e2b
|
@ -45,7 +45,8 @@ Result Generate(const Program* program, const Options& options, const std::strin
|
|||
|
||||
// Generate the GLSL code.
|
||||
auto impl = std::make_unique<GeneratorImpl>(&sanitized_result.program, options.version);
|
||||
result.success = impl->Generate();
|
||||
impl->Generate();
|
||||
result.success = impl->Diagnostics().empty();
|
||||
result.error = impl->Diagnostics().str();
|
||||
result.glsl = impl->result();
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -83,135 +83,111 @@ class GeneratorImpl : public TextGenerator {
|
|||
GeneratorImpl(const Program* program, const Version& version);
|
||||
~GeneratorImpl();
|
||||
|
||||
/// @returns true on successful generation; false otherwise
|
||||
bool Generate();
|
||||
/// Generates the GLSL shader
|
||||
void Generate();
|
||||
|
||||
/// Record an extension directive within the generator
|
||||
/// @param ext the extension to record
|
||||
/// @returns true if the extension directive was recorded successfully
|
||||
bool RecordExtension(const ast::Enable* ext);
|
||||
void RecordExtension(const ast::Enable* ext);
|
||||
/// Handles an index accessor expression
|
||||
/// @param out the output of the expression stream
|
||||
/// @param expr the expression to emit
|
||||
/// @returns true if the index accessor was emitted
|
||||
bool EmitIndexAccessor(utils::StringStream& out, const ast::IndexAccessorExpression* expr);
|
||||
void EmitIndexAccessor(utils::StringStream& out, const ast::IndexAccessorExpression* expr);
|
||||
/// Handles an assignment statement
|
||||
/// @param stmt the statement to emit
|
||||
/// @returns true if the statement was emitted successfully
|
||||
bool EmitAssign(const ast::AssignmentStatement* stmt);
|
||||
void EmitAssign(const ast::AssignmentStatement* stmt);
|
||||
/// Handles emission of bitwise operators (&|) on bool scalars and vectors
|
||||
/// @param out the output of the expression stream
|
||||
/// @param expr the binary expression
|
||||
/// @returns true if the expression was emitted, false otherwise
|
||||
bool EmitBitwiseBoolOp(utils::StringStream& out, const ast::BinaryExpression* expr);
|
||||
void EmitBitwiseBoolOp(utils::StringStream& out, const ast::BinaryExpression* expr);
|
||||
/// Handles generating a binary expression
|
||||
/// @param out the output of the expression stream
|
||||
/// @param expr the binary expression
|
||||
/// @returns true if the expression was emitted, false otherwise
|
||||
bool EmitFloatModulo(utils::StringStream& out, const ast::BinaryExpression* expr);
|
||||
void EmitFloatModulo(utils::StringStream& out, const ast::BinaryExpression* expr);
|
||||
/// Handles generating the modulo operator on float vector operands
|
||||
/// @param out the output of the expression stream
|
||||
/// @param expr the binary expression
|
||||
/// @returns true if the expression was emitted, false otherwise
|
||||
bool EmitBinary(utils::StringStream& out, const ast::BinaryExpression* expr);
|
||||
void EmitBinary(utils::StringStream& out, const ast::BinaryExpression* expr);
|
||||
/// Handles generating a bitcast expression
|
||||
/// @param out the output of the expression stream
|
||||
/// @param expr the expression
|
||||
/// @returns true if the binary expression was emitted
|
||||
bool EmitVectorRelational(utils::StringStream& out, const ast::BinaryExpression* expr);
|
||||
void EmitVectorRelational(utils::StringStream& out, const ast::BinaryExpression* expr);
|
||||
/// Handles generating a vector relational expression
|
||||
/// @param out the output of the expression stream
|
||||
/// @param expr the expression
|
||||
/// @returns true if the vector relational expression was emitted
|
||||
bool EmitBitcast(utils::StringStream& out, const ast::BitcastExpression* expr);
|
||||
void EmitBitcast(utils::StringStream& out, const ast::BitcastExpression* expr);
|
||||
/// Emits a list of statements
|
||||
/// @param stmts the statement list
|
||||
/// @returns true if the statements were emitted successfully
|
||||
bool EmitStatements(utils::VectorRef<const ast::Statement*> stmts);
|
||||
void EmitStatements(utils::VectorRef<const ast::Statement*> stmts);
|
||||
/// Emits a list of statements with an indentation
|
||||
/// @param stmts the statement list
|
||||
/// @returns true if the statements were emitted successfully
|
||||
bool EmitStatementsWithIndent(utils::VectorRef<const ast::Statement*> stmts);
|
||||
void EmitStatementsWithIndent(utils::VectorRef<const ast::Statement*> stmts);
|
||||
/// Handles a block statement
|
||||
/// @param stmt the statement to emit
|
||||
/// @returns true if the statement was emitted successfully
|
||||
bool EmitBlock(const ast::BlockStatement* stmt);
|
||||
void EmitBlock(const ast::BlockStatement* stmt);
|
||||
/// Handles a break statement
|
||||
/// @param stmt the statement to emit
|
||||
/// @returns true if the statement was emitted successfully
|
||||
bool EmitBreak(const ast::BreakStatement* stmt);
|
||||
void EmitBreak(const ast::BreakStatement* stmt);
|
||||
/// Handles a break-if statement
|
||||
/// @param stmt the statement to emit
|
||||
/// @returns true if the statement was emitted successfully
|
||||
bool EmitBreakIf(const ast::BreakIfStatement* stmt);
|
||||
void EmitBreakIf(const ast::BreakIfStatement* stmt);
|
||||
/// Handles generating a call expression
|
||||
/// @param out the output of the expression stream
|
||||
/// @param expr the call expression
|
||||
/// @returns true if the call expression is emitted
|
||||
bool EmitCall(utils::StringStream& out, const ast::CallExpression* expr);
|
||||
void EmitCall(utils::StringStream& out, const ast::CallExpression* expr);
|
||||
/// Handles generating a function call expression
|
||||
/// @param out the output of the expression stream
|
||||
/// @param call the call expression
|
||||
/// @param fn the function being called
|
||||
/// @returns true if the expression is emitted
|
||||
bool EmitFunctionCall(utils::StringStream& out, const sem::Call* call, const sem::Function* fn);
|
||||
void EmitFunctionCall(utils::StringStream& out, const sem::Call* call, const sem::Function* fn);
|
||||
/// Handles generating a builtin call expression
|
||||
/// @param out the output of the expression stream
|
||||
/// @param call the call expression
|
||||
/// @param builtin the builtin being called
|
||||
/// @returns true if the expression is emitted
|
||||
bool EmitBuiltinCall(utils::StringStream& out,
|
||||
void EmitBuiltinCall(utils::StringStream& out,
|
||||
const sem::Call* call,
|
||||
const sem::Builtin* builtin);
|
||||
/// Handles generating a value conversion expression
|
||||
/// @param out the output of the expression stream
|
||||
/// @param call the call expression
|
||||
/// @param conv the value conversion
|
||||
/// @returns true if the expression is emitted
|
||||
bool EmitValueConversion(utils::StringStream& out,
|
||||
void EmitValueConversion(utils::StringStream& out,
|
||||
const sem::Call* call,
|
||||
const sem::ValueConversion* conv);
|
||||
/// Handles generating a value constructor expression
|
||||
/// @param out the output of the expression stream
|
||||
/// @param call the call expression
|
||||
/// @param ctor the value constructor
|
||||
/// @returns true if the expression is emitted
|
||||
bool EmitValueConstructor(utils::StringStream& out,
|
||||
void EmitValueConstructor(utils::StringStream& out,
|
||||
const sem::Call* call,
|
||||
const sem::ValueConstructor* ctor);
|
||||
/// Handles generating a barrier builtin call
|
||||
/// @param out the output of the expression stream
|
||||
/// @param builtin the semantic information for the barrier builtin
|
||||
/// @returns true if the call expression is emitted
|
||||
bool EmitBarrierCall(utils::StringStream& out, const sem::Builtin* builtin);
|
||||
void EmitBarrierCall(utils::StringStream& out, const sem::Builtin* builtin);
|
||||
/// Handles generating an atomic builtin call for a workgroup variable
|
||||
/// @param out the output of the expression stream
|
||||
/// @param expr the call expression
|
||||
/// @param builtin the semantic information for the atomic builtin
|
||||
/// @returns true if the call expression is emitted
|
||||
bool EmitWorkgroupAtomicCall(utils::StringStream& out,
|
||||
void EmitWorkgroupAtomicCall(utils::StringStream& out,
|
||||
const ast::CallExpression* expr,
|
||||
const sem::Builtin* builtin);
|
||||
/// Handles generating an array.length() call
|
||||
/// @param out the output of the expression stream
|
||||
/// @param expr the call expression
|
||||
/// @returns true if the array length expression is emitted
|
||||
bool EmitArrayLength(utils::StringStream& out, const ast::CallExpression* expr);
|
||||
void EmitArrayLength(utils::StringStream& out, const ast::CallExpression* expr);
|
||||
/// Handles generating a call to `bitfieldExtract`
|
||||
/// @param out the output of the expression stream
|
||||
/// @param expr the call expression
|
||||
/// @returns true if the expression is emitted
|
||||
bool EmitExtractBits(utils::StringStream& out, const ast::CallExpression* expr);
|
||||
void EmitExtractBits(utils::StringStream& out, const ast::CallExpression* expr);
|
||||
/// Handles generating a call to `bitfieldInsert`
|
||||
/// @param out the output of the expression stream
|
||||
/// @param expr the call expression
|
||||
/// @returns true if the expression is emitted
|
||||
bool EmitInsertBits(utils::StringStream& out, const ast::CallExpression* expr);
|
||||
void EmitInsertBits(utils::StringStream& out, const ast::CallExpression* expr);
|
||||
/// Emulates 'fma' on GLSL ES, where it is unsupported.
|
||||
/// @param out the output of the expression stream
|
||||
/// @param expr the fma() expression
|
||||
/// @returns true if the expression is emitted
|
||||
bool EmitEmulatedFMA(utils::StringStream& out, const ast::CallExpression* expr);
|
||||
void EmitEmulatedFMA(utils::StringStream& out, const ast::CallExpression* expr);
|
||||
/// Create a float literal zero AST node, and associated semantic nodes.
|
||||
/// @param stmt the statement which will own the semantic expression node
|
||||
/// @returns an AST expression representing 0.0f
|
||||
|
@ -222,130 +198,109 @@ class GeneratorImpl : public TextGenerator {
|
|||
/// @param out the output of the expression stream
|
||||
/// @param call the call expression
|
||||
/// @param builtin the semantic information for the texture builtin
|
||||
/// @returns true if the call expression is emitted
|
||||
bool EmitTextureCall(utils::StringStream& out,
|
||||
void EmitTextureCall(utils::StringStream& out,
|
||||
const sem::Call* call,
|
||||
const sem::Builtin* builtin);
|
||||
/// Handles generating a call to the `select()` builtin
|
||||
/// @param out the output of the expression stream
|
||||
/// @param expr the call expression
|
||||
/// @returns true if the call expression is emitted
|
||||
bool EmitCountOneBitsCall(utils::StringStream& out, const ast::CallExpression* expr);
|
||||
void EmitCountOneBitsCall(utils::StringStream& out, const ast::CallExpression* expr);
|
||||
/// Handles generating a call to the `countOneBits()` builtin
|
||||
/// @param out the output of the expression stream
|
||||
/// @param expr the call expression
|
||||
/// @param builtin the semantic information for the builtin
|
||||
/// @returns true if the call expression is emitted
|
||||
bool EmitSelectCall(utils::StringStream& out,
|
||||
void EmitSelectCall(utils::StringStream& out,
|
||||
const ast::CallExpression* expr,
|
||||
const sem::Builtin* builtin);
|
||||
/// Handles generating a call to the `dot()` builtin
|
||||
/// @param out the output of the expression stream
|
||||
/// @param expr the call expression
|
||||
/// @param builtin the semantic information for the builtin
|
||||
/// @returns true if the call expression is emitted
|
||||
bool EmitDotCall(utils::StringStream& out,
|
||||
void EmitDotCall(utils::StringStream& out,
|
||||
const ast::CallExpression* expr,
|
||||
const sem::Builtin* builtin);
|
||||
/// Handles generating a call to the `modf()` builtin
|
||||
/// @param out the output of the expression stream
|
||||
/// @param expr the call expression
|
||||
/// @param builtin the semantic information for the builtin
|
||||
/// @returns true if the call expression is emitted
|
||||
bool EmitModfCall(utils::StringStream& out,
|
||||
void EmitModfCall(utils::StringStream& out,
|
||||
const ast::CallExpression* expr,
|
||||
const sem::Builtin* builtin);
|
||||
/// Handles generating a call to the `frexp()` builtin
|
||||
/// @param out the output of the expression stream
|
||||
/// @param expr the call expression
|
||||
/// @param builtin the semantic information for the builtin
|
||||
/// @returns true if the call expression is emitted
|
||||
bool EmitFrexpCall(utils::StringStream& out,
|
||||
void EmitFrexpCall(utils::StringStream& out,
|
||||
const ast::CallExpression* expr,
|
||||
const sem::Builtin* builtin);
|
||||
/// Handles generating a call to the `degrees()` builtin
|
||||
/// @param out the output of the expression stream
|
||||
/// @param expr the call expression
|
||||
/// @param builtin the semantic information for the builtin
|
||||
/// @returns true if the call expression is emitted
|
||||
bool EmitDegreesCall(utils::StringStream& out,
|
||||
void EmitDegreesCall(utils::StringStream& out,
|
||||
const ast::CallExpression* expr,
|
||||
const sem::Builtin* builtin);
|
||||
/// Handles generating a call to the `radians()` builtin
|
||||
/// @param out the output of the expression stream
|
||||
/// @param expr the call expression
|
||||
/// @param builtin the semantic information for the builtin
|
||||
/// @returns true if the call expression is emitted
|
||||
bool EmitRadiansCall(utils::StringStream& out,
|
||||
void EmitRadiansCall(utils::StringStream& out,
|
||||
const ast::CallExpression* expr,
|
||||
const sem::Builtin* builtin);
|
||||
/// Handles generating a call to the `quantizeToF16()` intrinsic
|
||||
/// @param out the output of the expression stream
|
||||
/// @param expr the call expression
|
||||
/// @param builtin the semantic information for the builtin
|
||||
/// @returns true if the call expression is emitted
|
||||
bool EmitQuantizeToF16Call(utils::StringStream& out,
|
||||
void EmitQuantizeToF16Call(utils::StringStream& out,
|
||||
const ast::CallExpression* expr,
|
||||
const sem::Builtin* builtin);
|
||||
/// Handles a case statement
|
||||
/// @param stmt the statement
|
||||
/// @returns true if the statement was emitted successfully
|
||||
bool EmitCase(const ast::CaseStatement* stmt);
|
||||
void EmitCase(const ast::CaseStatement* stmt);
|
||||
/// Handles generating a discard statement
|
||||
/// @param stmt the discard statement
|
||||
/// @returns true if the statement was successfully emitted
|
||||
bool EmitDiscard(const ast::DiscardStatement* stmt);
|
||||
void EmitDiscard(const ast::DiscardStatement* stmt);
|
||||
/// Handles a continue statement
|
||||
/// @param stmt the statement to emit
|
||||
/// @returns true if the statement was emitted successfully
|
||||
bool EmitContinue(const ast::ContinueStatement* stmt);
|
||||
void EmitContinue(const ast::ContinueStatement* stmt);
|
||||
/// Handles generate an Expression
|
||||
/// @param out the output of the expression stream
|
||||
/// @param expr the expression
|
||||
/// @returns true if the expression was emitted
|
||||
bool EmitExpression(utils::StringStream& out, const ast::Expression* expr);
|
||||
void EmitExpression(utils::StringStream& out, const ast::Expression* expr);
|
||||
/// Handles generating a function
|
||||
/// @param func the function to generate
|
||||
/// @returns true if the function was emitted
|
||||
bool EmitFunction(const ast::Function* func);
|
||||
void EmitFunction(const ast::Function* func);
|
||||
|
||||
/// Handles emitting a global variable
|
||||
/// @param global the global variable
|
||||
/// @returns true on success
|
||||
bool EmitGlobalVariable(const ast::Variable* global);
|
||||
void EmitGlobalVariable(const ast::Variable* global);
|
||||
|
||||
/// Handles emitting a global variable with the uniform address space
|
||||
/// @param var the AST node for the 'var'
|
||||
/// @param sem the semantic node for the 'var'
|
||||
/// @returns true on success
|
||||
bool EmitUniformVariable(const ast::Var* var, const sem::Variable* sem);
|
||||
void EmitUniformVariable(const ast::Var* var, const sem::Variable* sem);
|
||||
|
||||
/// Handles emitting a global variable with the storage address space
|
||||
/// @param var the AST node for the 'var'
|
||||
/// @param sem the semantic node for the 'var'
|
||||
/// @returns true on success
|
||||
bool EmitStorageVariable(const ast::Var* var, const sem::Variable* sem);
|
||||
void EmitStorageVariable(const ast::Var* var, const sem::Variable* sem);
|
||||
|
||||
/// Handles emitting a global variable with the handle address space
|
||||
/// @param var the AST node for the 'var'
|
||||
/// @param sem the semantic node for the 'var'
|
||||
/// @returns true on success
|
||||
bool EmitHandleVariable(const ast::Var* var, const sem::Variable* sem);
|
||||
void EmitHandleVariable(const ast::Var* var, const sem::Variable* sem);
|
||||
|
||||
/// Handles emitting a global variable with the private address space
|
||||
/// @param var the global variable
|
||||
/// @returns true on success
|
||||
bool EmitPrivateVariable(const sem::Variable* var);
|
||||
void EmitPrivateVariable(const sem::Variable* var);
|
||||
|
||||
/// Handles emitting a global variable with the workgroup address space
|
||||
/// @param var the global variable
|
||||
/// @returns true on success
|
||||
bool EmitWorkgroupVariable(const sem::Variable* var);
|
||||
void EmitWorkgroupVariable(const sem::Variable* var);
|
||||
|
||||
/// Handles emitting a global variable with the input or output address space
|
||||
/// @param var the global variable
|
||||
/// @returns true on success
|
||||
bool EmitIOVariable(const sem::GlobalVariable* var);
|
||||
void EmitIOVariable(const sem::GlobalVariable* var);
|
||||
|
||||
/// Handles emitting interpolation qualifiers
|
||||
/// @param out the output of the expression stream
|
||||
|
@ -356,62 +311,49 @@ class GeneratorImpl : public TextGenerator {
|
|||
/// @param out the output of the expression stream
|
||||
/// @param var the global variable semantics
|
||||
/// @param attrs the attributes
|
||||
/// @returns true if the attributes were emitted
|
||||
bool EmitAttributes(utils::StringStream& out,
|
||||
void EmitAttributes(utils::StringStream& out,
|
||||
const sem::GlobalVariable* var,
|
||||
utils::VectorRef<const ast::Attribute*> attrs);
|
||||
/// Handles emitting the entry point function
|
||||
/// @param func the entry point
|
||||
/// @returns true if the entry point function was emitted
|
||||
bool EmitEntryPointFunction(const ast::Function* func);
|
||||
void EmitEntryPointFunction(const ast::Function* func);
|
||||
/// Handles an if statement
|
||||
/// @param stmt the statement to emit
|
||||
/// @returns true if the statement was successfully emitted
|
||||
bool EmitIf(const ast::IfStatement* stmt);
|
||||
void EmitIf(const ast::IfStatement* stmt);
|
||||
/// Handles a constant value
|
||||
/// @param out the output stream
|
||||
/// @param constant the constant value to emit
|
||||
/// @returns true if the constant value was successfully emitted
|
||||
bool EmitConstant(utils::StringStream& out, const constant::Value* constant);
|
||||
void EmitConstant(utils::StringStream& out, const constant::Value* constant);
|
||||
/// Handles a literal
|
||||
/// @param out the output stream
|
||||
/// @param lit the literal to emit
|
||||
/// @returns true if the literal was successfully emitted
|
||||
bool EmitLiteral(utils::StringStream& out, const ast::LiteralExpression* lit);
|
||||
void EmitLiteral(utils::StringStream& out, const ast::LiteralExpression* lit);
|
||||
/// Handles a loop statement
|
||||
/// @param stmt the statement to emit
|
||||
/// @returns true if the statement was emitted
|
||||
bool EmitLoop(const ast::LoopStatement* stmt);
|
||||
void EmitLoop(const ast::LoopStatement* stmt);
|
||||
/// Handles a for loop statement
|
||||
/// @param stmt the statement to emit
|
||||
/// @returns true if the statement was emitted
|
||||
bool EmitForLoop(const ast::ForLoopStatement* stmt);
|
||||
void EmitForLoop(const ast::ForLoopStatement* stmt);
|
||||
/// Handles a while statement
|
||||
/// @param stmt the statement to emit
|
||||
/// @returns true if the statement was emitted
|
||||
bool EmitWhile(const ast::WhileStatement* stmt);
|
||||
void EmitWhile(const ast::WhileStatement* stmt);
|
||||
/// Handles generating an identifier expression
|
||||
/// @param out the output of the expression stream
|
||||
/// @param expr the identifier expression
|
||||
/// @returns true if the identifier was emitted
|
||||
bool EmitIdentifier(utils::StringStream& out, const ast::IdentifierExpression* expr);
|
||||
void EmitIdentifier(utils::StringStream& out, const ast::IdentifierExpression* expr);
|
||||
/// Handles a member accessor expression
|
||||
/// @param out the output of the expression stream
|
||||
/// @param expr the member accessor expression
|
||||
/// @returns true if the member accessor was emitted
|
||||
bool EmitMemberAccessor(utils::StringStream& out, const ast::MemberAccessorExpression* expr);
|
||||
void EmitMemberAccessor(utils::StringStream& out, const ast::MemberAccessorExpression* expr);
|
||||
/// Handles return statements
|
||||
/// @param stmt the statement to emit
|
||||
/// @returns true if the statement was successfully emitted
|
||||
bool EmitReturn(const ast::ReturnStatement* stmt);
|
||||
void EmitReturn(const ast::ReturnStatement* stmt);
|
||||
/// Handles statement
|
||||
/// @param stmt the statement to emit
|
||||
/// @returns true if the statement was emitted
|
||||
bool EmitStatement(const ast::Statement* stmt);
|
||||
void EmitStatement(const ast::Statement* stmt);
|
||||
/// Handles generating a switch statement
|
||||
/// @param stmt the statement to emit
|
||||
/// @returns true if the statement was emitted
|
||||
bool EmitSwitch(const ast::SwitchStatement* stmt);
|
||||
void EmitSwitch(const ast::SwitchStatement* stmt);
|
||||
/// Handles generating type
|
||||
/// @param out the output stream
|
||||
/// @param type the type to generate
|
||||
|
@ -420,8 +362,7 @@ class GeneratorImpl : public TextGenerator {
|
|||
/// @param name the name of the variable, used for array emission.
|
||||
/// @param name_printed (optional) if not nullptr and an array was printed
|
||||
/// then the boolean is set to true.
|
||||
/// @returns true if the type is emitted
|
||||
bool EmitType(utils::StringStream& out,
|
||||
void EmitType(utils::StringStream& out,
|
||||
const type::Type* type,
|
||||
builtin::AddressSpace address_space,
|
||||
builtin::Access access,
|
||||
|
@ -433,8 +374,7 @@ class GeneratorImpl : public TextGenerator {
|
|||
/// @param address_space the address space of the variable
|
||||
/// @param access the access control type of the variable
|
||||
/// @param name the name to emit
|
||||
/// @returns true if the type is emitted
|
||||
bool EmitTypeAndName(utils::StringStream& out,
|
||||
void EmitTypeAndName(utils::StringStream& out,
|
||||
const type::Type* type,
|
||||
builtin::AddressSpace address_space,
|
||||
builtin::Access access,
|
||||
|
@ -443,35 +383,28 @@ class GeneratorImpl : public TextGenerator {
|
|||
/// this function will simply return `true` without emitting anything.
|
||||
/// @param buffer the text buffer that the type declaration will be written to
|
||||
/// @param ty the struct to generate
|
||||
/// @returns true if the struct is emitted
|
||||
bool EmitStructType(TextBuffer* buffer, const sem::Struct* ty);
|
||||
void EmitStructType(TextBuffer* buffer, const sem::Struct* ty);
|
||||
/// Handles generating the members of a structure
|
||||
/// @param buffer the text buffer that the struct members will be written to
|
||||
/// @param ty the struct to generate
|
||||
/// @returns true if the struct members are emitted
|
||||
bool EmitStructMembers(TextBuffer* buffer, const sem::Struct* ty);
|
||||
void EmitStructMembers(TextBuffer* buffer, const sem::Struct* ty);
|
||||
/// Handles a unary op expression
|
||||
/// @param out the output of the expression stream
|
||||
/// @param expr the expression to emit
|
||||
/// @returns true if the expression was emitted
|
||||
bool EmitUnaryOp(utils::StringStream& out, const ast::UnaryOpExpression* expr);
|
||||
void EmitUnaryOp(utils::StringStream& out, const ast::UnaryOpExpression* expr);
|
||||
/// Emits the zero value for the given type
|
||||
/// @param out the output stream
|
||||
/// @param type the type to emit the value for
|
||||
/// @returns true if the zero value was successfully emitted.
|
||||
bool EmitZeroValue(utils::StringStream& out, const type::Type* type);
|
||||
void EmitZeroValue(utils::StringStream& out, const type::Type* type);
|
||||
/// Handles generating a 'var' declaration
|
||||
/// @param var the variable to generate
|
||||
/// @returns true if the variable was emitted
|
||||
bool EmitVar(const ast::Var* var);
|
||||
void EmitVar(const ast::Var* var);
|
||||
/// Handles generating a function-scope 'let' declaration
|
||||
/// @param let the variable to generate
|
||||
/// @returns true if the variable was emitted
|
||||
bool EmitLet(const ast::Let* let);
|
||||
void EmitLet(const ast::Let* let);
|
||||
/// Handles generating a module-scope 'let' declaration
|
||||
/// @param let the 'let' to emit
|
||||
/// @returns true if the variable was emitted
|
||||
bool EmitProgramConstVariable(const ast::Variable* let);
|
||||
void EmitProgramConstVariable(const ast::Variable* let);
|
||||
/// Handles generating a builtin method name
|
||||
/// @param builtin the semantic info for the builtin
|
||||
/// @returns the name or "" if not valid
|
||||
|
@ -510,9 +443,8 @@ class GeneratorImpl : public TextGenerator {
|
|||
/// Where:
|
||||
/// `buffer` is the body of the generated function
|
||||
/// `params` is the name of all the generated function parameters
|
||||
/// @returns true if the call expression is emitted
|
||||
template <typename F>
|
||||
bool CallBuiltinHelper(utils::StringStream& out,
|
||||
void CallBuiltinHelper(utils::StringStream& out,
|
||||
const ast::CallExpression* call,
|
||||
const sem::Builtin* builtin,
|
||||
F&& build);
|
||||
|
@ -523,7 +455,7 @@ class GeneratorImpl : public TextGenerator {
|
|||
type::Type* BoolTypeToUint(const type::Type* type);
|
||||
|
||||
TextBuffer helpers_; // Helper functions emitted at the top of the output
|
||||
std::function<bool()> emit_continuing_;
|
||||
std::function<void()> emit_continuing_;
|
||||
std::unordered_map<const sem::Builtin*, std::string> builtins_;
|
||||
std::unordered_map<const type::Vector*, std::string> dynamic_vector_write_;
|
||||
std::unordered_map<const type::Vector*, std::string> int_dot_funcs_;
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
|
||||
#include "src/tint/utils/string_stream.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::writer::glsl {
|
||||
|
@ -31,7 +33,8 @@ TEST_F(GlslGeneratorImplTest_Expression, IndexAccessor) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
|
||||
gen.EmitExpression(out, expr);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "ary[5]");
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
#include "src/tint/writer/glsl/test_helper.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
namespace tint::writer::glsl {
|
||||
namespace {
|
||||
|
||||
|
@ -29,7 +31,8 @@ TEST_F(GlslGeneratorImplTest_Assign, Emit_Assign) {
|
|||
|
||||
gen.increment_indent();
|
||||
|
||||
ASSERT_TRUE(gen.EmitStatement(assign)) << gen.Diagnostics();
|
||||
gen.EmitStatement(assign);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), " lhs = rhs;\n");
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
#include "src/tint/utils/string_stream.h"
|
||||
#include "src/tint/writer/glsl/test_helper.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::writer::glsl {
|
||||
|
@ -59,7 +61,8 @@ TEST_P(GlslBinaryTest, Emit_f32) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
|
||||
gen.EmitExpression(out, expr);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), params.result);
|
||||
}
|
||||
TEST_P(GlslBinaryTest, Emit_f16) {
|
||||
|
@ -87,7 +90,8 @@ TEST_P(GlslBinaryTest, Emit_f16) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
|
||||
gen.EmitExpression(out, expr);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), params.result);
|
||||
}
|
||||
TEST_P(GlslBinaryTest, Emit_u32) {
|
||||
|
@ -106,7 +110,8 @@ TEST_P(GlslBinaryTest, Emit_u32) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
|
||||
gen.EmitExpression(out, expr);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), params.result);
|
||||
}
|
||||
TEST_P(GlslBinaryTest, Emit_i32) {
|
||||
|
@ -130,7 +135,8 @@ TEST_P(GlslBinaryTest, Emit_i32) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
|
||||
gen.EmitExpression(out, expr);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), params.result);
|
||||
}
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
|
@ -165,7 +171,8 @@ TEST_F(GlslGeneratorImplTest_Binary, Multiply_VectorScalar_f32) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
|
||||
gen.EmitExpression(out, expr);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "(a * 1.0f)");
|
||||
}
|
||||
|
||||
|
@ -183,7 +190,8 @@ TEST_F(GlslGeneratorImplTest_Binary, Multiply_VectorScalar_f16) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
|
||||
gen.EmitExpression(out, expr);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "(a * 1.0hf)");
|
||||
}
|
||||
|
||||
|
@ -199,7 +207,8 @@ TEST_F(GlslGeneratorImplTest_Binary, Multiply_ScalarVector_f32) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
|
||||
gen.EmitExpression(out, expr);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "(1.0f * a)");
|
||||
}
|
||||
|
||||
|
@ -217,7 +226,8 @@ TEST_F(GlslGeneratorImplTest_Binary, Multiply_ScalarVector_f16) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
|
||||
gen.EmitExpression(out, expr);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "(1.0hf * a)");
|
||||
}
|
||||
|
||||
|
@ -232,7 +242,8 @@ TEST_F(GlslGeneratorImplTest_Binary, Multiply_MatrixScalar_f32) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
|
||||
gen.EmitExpression(out, expr);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "(mat * 1.0f)");
|
||||
}
|
||||
|
||||
|
@ -249,7 +260,8 @@ TEST_F(GlslGeneratorImplTest_Binary, Multiply_MatrixScalar_f16) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
|
||||
gen.EmitExpression(out, expr);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "(mat * 1.0hf)");
|
||||
}
|
||||
|
||||
|
@ -264,7 +276,8 @@ TEST_F(GlslGeneratorImplTest_Binary, Multiply_ScalarMatrix_f32) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
|
||||
gen.EmitExpression(out, expr);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "(1.0f * mat)");
|
||||
}
|
||||
|
||||
|
@ -281,7 +294,8 @@ TEST_F(GlslGeneratorImplTest_Binary, Multiply_ScalarMatrix_f16) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
|
||||
gen.EmitExpression(out, expr);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "(1.0hf * mat)");
|
||||
}
|
||||
|
||||
|
@ -296,7 +310,8 @@ TEST_F(GlslGeneratorImplTest_Binary, Multiply_MatrixVector_f32) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
|
||||
gen.EmitExpression(out, expr);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "(mat * vec3(1.0f))");
|
||||
}
|
||||
|
||||
|
@ -313,7 +328,8 @@ TEST_F(GlslGeneratorImplTest_Binary, Multiply_MatrixVector_f16) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
|
||||
gen.EmitExpression(out, expr);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "(mat * f16vec3(1.0hf))");
|
||||
}
|
||||
|
||||
|
@ -328,7 +344,8 @@ TEST_F(GlslGeneratorImplTest_Binary, Multiply_VectorMatrix_f32) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
|
||||
gen.EmitExpression(out, expr);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "(vec3(1.0f) * mat)");
|
||||
}
|
||||
|
||||
|
@ -345,7 +362,8 @@ TEST_F(GlslGeneratorImplTest_Binary, Multiply_VectorMatrix_f16) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
|
||||
gen.EmitExpression(out, expr);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "(f16vec3(1.0hf) * mat)");
|
||||
}
|
||||
|
||||
|
@ -359,7 +377,8 @@ TEST_F(GlslGeneratorImplTest_Binary, Multiply_MatrixMatrix_f32) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
|
||||
gen.EmitExpression(out, expr);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "(lhs * rhs)");
|
||||
}
|
||||
|
||||
|
@ -375,7 +394,8 @@ TEST_F(GlslGeneratorImplTest_Binary, Multiply_MatrixMatrix_f16) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
EXPECT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
|
||||
gen.EmitExpression(out, expr);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "(lhs * rhs)");
|
||||
}
|
||||
|
||||
|
@ -389,7 +409,8 @@ TEST_F(GlslGeneratorImplTest_Binary, ModF32) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
|
||||
gen.EmitExpression(out, expr);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "tint_float_modulo(a, b)");
|
||||
}
|
||||
|
||||
|
@ -405,7 +426,8 @@ TEST_F(GlslGeneratorImplTest_Binary, ModF16) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
|
||||
gen.EmitExpression(out, expr);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "tint_float_modulo(a, b)");
|
||||
}
|
||||
|
||||
|
@ -419,7 +441,8 @@ TEST_F(GlslGeneratorImplTest_Binary, ModVec3F32) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
|
||||
gen.EmitExpression(out, expr);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "tint_float_modulo(a, b)");
|
||||
}
|
||||
|
||||
|
@ -435,7 +458,8 @@ TEST_F(GlslGeneratorImplTest_Binary, ModVec3F16) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
|
||||
gen.EmitExpression(out, expr);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "tint_float_modulo(a, b)");
|
||||
}
|
||||
|
||||
|
@ -449,7 +473,8 @@ TEST_F(GlslGeneratorImplTest_Binary, ModVec3F32ScalarF32) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
|
||||
gen.EmitExpression(out, expr);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "tint_float_modulo(a, b)");
|
||||
}
|
||||
|
||||
|
@ -465,7 +490,8 @@ TEST_F(GlslGeneratorImplTest_Binary, ModVec3F16ScalarF16) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
|
||||
gen.EmitExpression(out, expr);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "tint_float_modulo(a, b)");
|
||||
}
|
||||
|
||||
|
@ -479,7 +505,8 @@ TEST_F(GlslGeneratorImplTest_Binary, ModScalarF32Vec3F32) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
|
||||
gen.EmitExpression(out, expr);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "tint_float_modulo(a, b)");
|
||||
}
|
||||
|
||||
|
@ -495,7 +522,8 @@ TEST_F(GlslGeneratorImplTest_Binary, ModScalarF16Vec3F16) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
|
||||
gen.EmitExpression(out, expr);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "tint_float_modulo(a, b)");
|
||||
}
|
||||
|
||||
|
@ -513,7 +541,8 @@ TEST_F(GlslGeneratorImplTest_Binary, ModMixedVec3ScalarF32) {
|
|||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
vec3 tint_float_modulo(vec3 lhs, vec3 rhs) {
|
||||
|
@ -557,7 +586,8 @@ TEST_F(GlslGeneratorImplTest_Binary, ModMixedVec3ScalarF16) {
|
|||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
#extension GL_AMD_gpu_shader_half_float : require
|
||||
|
||||
|
@ -596,7 +626,8 @@ TEST_F(GlslGeneratorImplTest_Binary, Logical_And) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
|
||||
gen.EmitExpression(out, expr);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "(tint_tmp)");
|
||||
EXPECT_EQ(gen.result(), R"(bool tint_tmp = a;
|
||||
if (tint_tmp) {
|
||||
|
@ -621,7 +652,8 @@ TEST_F(GlslGeneratorImplTest_Binary, Logical_Multi) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
|
||||
gen.EmitExpression(out, expr);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "(tint_tmp)");
|
||||
EXPECT_EQ(gen.result(), R"(bool tint_tmp_1 = a;
|
||||
if (tint_tmp_1) {
|
||||
|
@ -648,7 +680,8 @@ TEST_F(GlslGeneratorImplTest_Binary, Logical_Or) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitExpression(out, expr)) << gen.Diagnostics();
|
||||
gen.EmitExpression(out, expr);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "(tint_tmp)");
|
||||
EXPECT_EQ(gen.result(), R"(bool tint_tmp = a;
|
||||
if (!tint_tmp) {
|
||||
|
@ -679,7 +712,8 @@ TEST_F(GlslGeneratorImplTest_Binary, If_WithLogical) {
|
|||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.EmitStatement(expr)) << gen.Diagnostics();
|
||||
gen.EmitStatement(expr);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(bool tint_tmp = a;
|
||||
if (tint_tmp) {
|
||||
tint_tmp = b;
|
||||
|
@ -715,7 +749,8 @@ TEST_F(GlslGeneratorImplTest_Binary, Return_WithLogical) {
|
|||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.EmitStatement(expr)) << gen.Diagnostics();
|
||||
gen.EmitStatement(expr);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(bool tint_tmp_1 = a;
|
||||
if (tint_tmp_1) {
|
||||
tint_tmp_1 = b;
|
||||
|
@ -746,7 +781,8 @@ TEST_F(GlslGeneratorImplTest_Binary, Assign_WithLogical) {
|
|||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.EmitStatement(expr)) << gen.Diagnostics();
|
||||
gen.EmitStatement(expr);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(bool tint_tmp_1 = b;
|
||||
if (!tint_tmp_1) {
|
||||
tint_tmp_1 = c;
|
||||
|
@ -778,7 +814,8 @@ TEST_F(GlslGeneratorImplTest_Binary, Decl_WithLogical) {
|
|||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.EmitStatement(decl)) << gen.Diagnostics();
|
||||
gen.EmitStatement(decl);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(bool tint_tmp_1 = b;
|
||||
if (tint_tmp_1) {
|
||||
tint_tmp_1 = c;
|
||||
|
@ -820,7 +857,8 @@ TEST_F(GlslGeneratorImplTest_Binary, Call_WithLogical) {
|
|||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.EmitStatement(expr)) << gen.Diagnostics();
|
||||
gen.EmitStatement(expr);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(bool tint_tmp = a;
|
||||
if (tint_tmp) {
|
||||
tint_tmp = b;
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
|
||||
#include "src/tint/utils/string_stream.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::writer::glsl {
|
||||
|
@ -31,7 +33,8 @@ TEST_F(GlslGeneratorImplTest_Bitcast, EmitExpression_Bitcast_Float) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitExpression(out, bitcast)) << gen.Diagnostics();
|
||||
gen.EmitExpression(out, bitcast);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "intBitsToFloat(a)");
|
||||
}
|
||||
|
||||
|
@ -43,7 +46,8 @@ TEST_F(GlslGeneratorImplTest_Bitcast, EmitExpression_Bitcast_Int) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitExpression(out, bitcast)) << gen.Diagnostics();
|
||||
gen.EmitExpression(out, bitcast);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "int(a)");
|
||||
}
|
||||
|
||||
|
@ -55,7 +59,8 @@ TEST_F(GlslGeneratorImplTest_Bitcast, EmitExpression_Bitcast_Uint) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitExpression(out, bitcast)) << gen.Diagnostics();
|
||||
gen.EmitExpression(out, bitcast);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "uint(a)");
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
#include "src/tint/writer/glsl/test_helper.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
namespace tint::writer::glsl {
|
||||
namespace {
|
||||
|
||||
|
@ -26,8 +28,8 @@ TEST_F(GlslGeneratorImplTest_Block, Emit_Block) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
gen.increment_indent();
|
||||
|
||||
ASSERT_TRUE(gen.EmitStatement(b)) << gen.Diagnostics();
|
||||
gen.EmitStatement(b);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"( {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
#include "src/tint/writer/glsl/test_helper.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
namespace tint::writer::glsl {
|
||||
namespace {
|
||||
|
||||
|
@ -26,8 +28,8 @@ TEST_F(GlslGeneratorImplTest_Break, Emit_Break) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
gen.increment_indent();
|
||||
|
||||
ASSERT_TRUE(gen.EmitStatement(b)) << gen.Diagnostics();
|
||||
gen.EmitStatement(b);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), " break;\n");
|
||||
}
|
||||
|
||||
|
|
|
@ -351,7 +351,8 @@ TEST_F(GlslGeneratorImplTest_Builtin, Builtin_Call) {
|
|||
|
||||
gen.increment_indent();
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.Diagnostics();
|
||||
gen.EmitExpression(out, call);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "dot(param1, param2)");
|
||||
}
|
||||
|
||||
|
@ -364,7 +365,8 @@ TEST_F(GlslGeneratorImplTest_Builtin, Select_Scalar) {
|
|||
|
||||
gen.increment_indent();
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.Diagnostics();
|
||||
gen.EmitExpression(out, call);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "(true ? b : a)");
|
||||
}
|
||||
|
||||
|
@ -377,7 +379,8 @@ TEST_F(GlslGeneratorImplTest_Builtin, Select_Vector) {
|
|||
|
||||
gen.increment_indent();
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.Diagnostics();
|
||||
gen.EmitExpression(out, call);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "tint_select(a, b, bvec2(true, false))");
|
||||
}
|
||||
|
||||
|
@ -394,7 +397,8 @@ TEST_F(GlslGeneratorImplTest_Builtin, FMA_f32) {
|
|||
|
||||
gen.increment_indent();
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.Diagnostics();
|
||||
gen.EmitExpression(out, call);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "((a) * (b) + (c))");
|
||||
}
|
||||
|
||||
|
@ -412,7 +416,8 @@ TEST_F(GlslGeneratorImplTest_Builtin, FMA_f16) {
|
|||
|
||||
gen.increment_indent();
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.Diagnostics();
|
||||
gen.EmitExpression(out, call);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "((a) * (b) + (c))");
|
||||
}
|
||||
|
||||
|
@ -422,7 +427,8 @@ TEST_F(GlslGeneratorImplTest_Builtin, Runtime_Modf_Scalar_f32) {
|
|||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
struct modf_result_f32 {
|
||||
|
@ -458,7 +464,8 @@ TEST_F(GlslGeneratorImplTest_Builtin, Runtime_Modf_Scalar_f16) {
|
|||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
#extension GL_AMD_gpu_shader_half_float : require
|
||||
|
||||
|
@ -493,7 +500,8 @@ TEST_F(GlslGeneratorImplTest_Builtin, Runtime_Modf_Vector_f32) {
|
|||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
struct modf_result_vec3_f32 {
|
||||
|
@ -529,7 +537,8 @@ TEST_F(GlslGeneratorImplTest_Builtin, Runtime_Modf_Vector_f16) {
|
|||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
#extension GL_AMD_gpu_shader_half_float : require
|
||||
|
||||
|
@ -563,7 +572,8 @@ TEST_F(GlslGeneratorImplTest_Builtin, Const_Modf_Scalar_f32) {
|
|||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
struct modf_result_f32 {
|
||||
|
@ -591,7 +601,8 @@ TEST_F(GlslGeneratorImplTest_Builtin, Const_Modf_Scalar_f16) {
|
|||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
#extension GL_AMD_gpu_shader_half_float : require
|
||||
|
||||
|
@ -618,7 +629,8 @@ TEST_F(GlslGeneratorImplTest_Builtin, Const_Modf_Vector_f32) {
|
|||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
struct modf_result_vec3_f32 {
|
||||
|
@ -646,7 +658,8 @@ TEST_F(GlslGeneratorImplTest_Builtin, Const_Modf_Vector_f16) {
|
|||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
#extension GL_AMD_gpu_shader_half_float : require
|
||||
|
||||
|
@ -674,7 +687,8 @@ TEST_F(GlslGeneratorImplTest_Builtin, Runtime_Frexp_Scalar_f32) {
|
|||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
struct frexp_result_f32 {
|
||||
|
@ -710,7 +724,8 @@ TEST_F(GlslGeneratorImplTest_Builtin, Runtime_Frexp_Scalar_f16) {
|
|||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
#extension GL_AMD_gpu_shader_half_float : require
|
||||
|
||||
|
@ -745,7 +760,8 @@ TEST_F(GlslGeneratorImplTest_Builtin, Runtime_Frexp_Vector_f32) {
|
|||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
struct frexp_result_vec3_f32 {
|
||||
|
@ -781,7 +797,8 @@ TEST_F(GlslGeneratorImplTest_Builtin, Runtime_Frexp_Vector_f16) {
|
|||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
#extension GL_AMD_gpu_shader_half_float : require
|
||||
|
||||
|
@ -815,7 +832,8 @@ TEST_F(GlslGeneratorImplTest_Builtin, Const_Frexp_Scalar_f32) {
|
|||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
struct frexp_result_f32 {
|
||||
|
@ -843,7 +861,8 @@ TEST_F(GlslGeneratorImplTest_Builtin, Const_Frexp_Scalar_f16) {
|
|||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
#extension GL_AMD_gpu_shader_half_float : require
|
||||
|
||||
|
@ -870,7 +889,8 @@ TEST_F(GlslGeneratorImplTest_Builtin, Const_Frexp_Vector_f32) {
|
|||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
struct frexp_result_vec3_f32 {
|
||||
|
@ -898,7 +918,8 @@ TEST_F(GlslGeneratorImplTest_Builtin, Const_Frexp_Vector_f16) {
|
|||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
#extension GL_AMD_gpu_shader_half_float : require
|
||||
|
||||
|
@ -927,7 +948,8 @@ TEST_F(GlslGeneratorImplTest_Builtin, Degrees_Scalar_f32) {
|
|||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
float tint_degrees(float param_0) {
|
||||
|
@ -955,7 +977,8 @@ TEST_F(GlslGeneratorImplTest_Builtin, Degrees_Vector_f32) {
|
|||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
vec3 tint_degrees(vec3 param_0) {
|
||||
|
@ -985,7 +1008,8 @@ TEST_F(GlslGeneratorImplTest_Builtin, Degrees_Scalar_f16) {
|
|||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
#extension GL_AMD_gpu_shader_half_float : require
|
||||
|
||||
|
@ -1016,7 +1040,8 @@ TEST_F(GlslGeneratorImplTest_Builtin, Degrees_Vector_f16) {
|
|||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
#extension GL_AMD_gpu_shader_half_float : require
|
||||
|
||||
|
@ -1045,7 +1070,8 @@ TEST_F(GlslGeneratorImplTest_Builtin, Radians_Scalar_f32) {
|
|||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
float tint_radians(float param_0) {
|
||||
|
@ -1073,7 +1099,8 @@ TEST_F(GlslGeneratorImplTest_Builtin, Radians_Vector_f32) {
|
|||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
vec3 tint_radians(vec3 param_0) {
|
||||
|
@ -1103,7 +1130,8 @@ TEST_F(GlslGeneratorImplTest_Builtin, Radians_Scalar_f16) {
|
|||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
#extension GL_AMD_gpu_shader_half_float : require
|
||||
|
||||
|
@ -1134,7 +1162,8 @@ TEST_F(GlslGeneratorImplTest_Builtin, Radians_Vector_f16) {
|
|||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
#extension GL_AMD_gpu_shader_half_float : require
|
||||
|
||||
|
@ -1165,7 +1194,8 @@ TEST_F(GlslGeneratorImplTest_Builtin, ExtractBits) {
|
|||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
uvec3 tint_extract_bits(uvec3 v, uint offset, uint count) {
|
||||
|
@ -1199,7 +1229,8 @@ TEST_F(GlslGeneratorImplTest_Builtin, InsertBits) {
|
|||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
uvec3 tint_insert_bits(uvec3 v, uvec3 n, uint offset, uint count) {
|
||||
|
@ -1230,7 +1261,8 @@ TEST_F(GlslGeneratorImplTest_Builtin, Pack4x8Snorm) {
|
|||
WrapInFunction(Decl(Var("r", call)));
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
vec4 p1 = vec4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
|
@ -1248,7 +1280,8 @@ TEST_F(GlslGeneratorImplTest_Builtin, Pack4x8Unorm) {
|
|||
WrapInFunction(Decl(Var("r", call)));
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
vec4 p1 = vec4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
|
@ -1266,7 +1299,8 @@ TEST_F(GlslGeneratorImplTest_Builtin, Pack2x16Snorm) {
|
|||
WrapInFunction(Decl(Var("r", call)));
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
vec2 p1 = vec2(0.0f, 0.0f);
|
||||
|
@ -1284,7 +1318,8 @@ TEST_F(GlslGeneratorImplTest_Builtin, Pack2x16Unorm) {
|
|||
WrapInFunction(Decl(Var("r", call)));
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
vec2 p1 = vec2(0.0f, 0.0f);
|
||||
|
@ -1302,7 +1337,8 @@ TEST_F(GlslGeneratorImplTest_Builtin, Pack2x16Float) {
|
|||
WrapInFunction(Decl(Var("r", call)));
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
vec2 p1 = vec2(0.0f, 0.0f);
|
||||
|
@ -1320,7 +1356,8 @@ TEST_F(GlslGeneratorImplTest_Builtin, Unpack4x8Snorm) {
|
|||
WrapInFunction(Decl(Var("r", call)));
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
uint p1 = 0u;
|
||||
|
@ -1338,7 +1375,8 @@ TEST_F(GlslGeneratorImplTest_Builtin, Unpack4x8Unorm) {
|
|||
WrapInFunction(Decl(Var("r", call)));
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
uint p1 = 0u;
|
||||
|
@ -1356,7 +1394,8 @@ TEST_F(GlslGeneratorImplTest_Builtin, Unpack2x16Snorm) {
|
|||
WrapInFunction(Decl(Var("r", call)));
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
uint p1 = 0u;
|
||||
|
@ -1374,7 +1413,8 @@ TEST_F(GlslGeneratorImplTest_Builtin, Unpack2x16Unorm) {
|
|||
WrapInFunction(Decl(Var("r", call)));
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
uint p1 = 0u;
|
||||
|
@ -1392,7 +1432,8 @@ TEST_F(GlslGeneratorImplTest_Builtin, Unpack2x16Float) {
|
|||
WrapInFunction(Decl(Var("r", call)));
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
uint p1 = 0u;
|
||||
|
@ -1416,7 +1457,8 @@ TEST_F(GlslGeneratorImplTest_Builtin, StorageBarrier) {
|
|||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
|
||||
|
@ -1439,7 +1481,8 @@ TEST_F(GlslGeneratorImplTest_Builtin, WorkgroupBarrier) {
|
|||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
|
||||
|
@ -1456,7 +1499,8 @@ TEST_F(GlslGeneratorImplTest_Builtin, DotI32) {
|
|||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
int tint_int_dot(ivec3 a, ivec3 b) {
|
||||
|
@ -1482,7 +1526,8 @@ TEST_F(GlslGeneratorImplTest_Builtin, DotU32) {
|
|||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
uint tint_int_dot(uvec3 a, uvec3 b) {
|
||||
|
@ -1508,7 +1553,8 @@ TEST_F(GlslGeneratorImplTest_Builtin, QuantizeToF16_Scalar) {
|
|||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
float tint_quantizeToF16(float param_0) {
|
||||
|
@ -1535,7 +1581,8 @@ TEST_F(GlslGeneratorImplTest_Builtin, QuantizeToF16_Vec2) {
|
|||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
vec2 tint_quantizeToF16(vec2 param_0) {
|
||||
|
@ -1562,7 +1609,8 @@ TEST_F(GlslGeneratorImplTest_Builtin, QuantizeToF16_Vec3) {
|
|||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
vec3 tint_quantizeToF16(vec3 param_0) {
|
||||
|
@ -1591,7 +1639,8 @@ TEST_F(GlslGeneratorImplTest_Builtin, QuantizeToF16_Vec4) {
|
|||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
vec4 tint_quantizeToF16(vec4 param_0) {
|
||||
|
|
|
@ -289,7 +289,8 @@ TEST_P(GlslGeneratorBuiltinTextureTest, Call) {
|
|||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
|
||||
auto expected = expected_texture_overload(param.overload);
|
||||
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
#include "src/tint/utils/string_stream.h"
|
||||
#include "src/tint/writer/glsl/test_helper.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::writer::glsl {
|
||||
|
@ -32,7 +34,8 @@ TEST_F(GlslGeneratorImplTest_Call, EmitExpression_Call_WithoutParams) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.Diagnostics();
|
||||
gen.EmitExpression(out, call);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "my_func()");
|
||||
}
|
||||
|
||||
|
@ -52,7 +55,8 @@ TEST_F(GlslGeneratorImplTest_Call, EmitExpression_Call_WithParams) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.Diagnostics();
|
||||
gen.EmitExpression(out, call);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "my_func(param1, param2)");
|
||||
}
|
||||
|
||||
|
@ -72,7 +76,8 @@ TEST_F(GlslGeneratorImplTest_Call, EmitStatement_Call) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
gen.increment_indent();
|
||||
ASSERT_TRUE(gen.EmitStatement(call)) << gen.Diagnostics();
|
||||
gen.EmitStatement(call);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), " my_func(param1, param2);\n");
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
#include "src/tint/writer/glsl/test_helper.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::writer::glsl {
|
||||
|
@ -29,8 +31,7 @@ TEST_F(GlslGeneratorImplTest_Case, Emit_Case) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
gen.increment_indent();
|
||||
|
||||
ASSERT_TRUE(gen.EmitCase(s->body[0])) << gen.Diagnostics();
|
||||
gen.EmitCase(s->body[0]);
|
||||
EXPECT_EQ(gen.result(), R"( case 5: {
|
||||
break;
|
||||
}
|
||||
|
@ -44,8 +45,8 @@ TEST_F(GlslGeneratorImplTest_Case, Emit_Case_BreaksByDefault) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
gen.increment_indent();
|
||||
|
||||
ASSERT_TRUE(gen.EmitCase(s->body[0])) << gen.Diagnostics();
|
||||
gen.EmitCase(s->body[0]);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"( case 5: {
|
||||
break;
|
||||
}
|
||||
|
@ -66,8 +67,8 @@ TEST_F(GlslGeneratorImplTest_Case, Emit_Case_MultipleSelectors) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
gen.increment_indent();
|
||||
|
||||
ASSERT_TRUE(gen.EmitCase(s->body[0])) << gen.Diagnostics();
|
||||
gen.EmitCase(s->body[0]);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"( case 5:
|
||||
case 6: {
|
||||
break;
|
||||
|
@ -82,8 +83,8 @@ TEST_F(GlslGeneratorImplTest_Case, Emit_Case_Default) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
gen.increment_indent();
|
||||
|
||||
ASSERT_TRUE(gen.EmitCase(s->body[0])) << gen.Diagnostics();
|
||||
gen.EmitCase(s->body[0]);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"( default: {
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
#include "src/tint/utils/string_stream.h"
|
||||
#include "src/tint/writer/glsl/test_helper.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::writer::glsl {
|
||||
|
@ -29,7 +31,8 @@ TEST_F(GlslGeneratorImplTest_Cast, EmitExpression_Cast_Scalar) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitExpression(out, cast)) << gen.Diagnostics();
|
||||
gen.EmitExpression(out, cast);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "1.0f");
|
||||
}
|
||||
|
||||
|
@ -40,7 +43,8 @@ TEST_F(GlslGeneratorImplTest_Cast, EmitExpression_Cast_Vector) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitExpression(out, cast)) << gen.Diagnostics();
|
||||
gen.EmitExpression(out, cast);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "vec3(1.0f, 2.0f, 3.0f)");
|
||||
}
|
||||
|
||||
|
|
|
@ -28,8 +28,8 @@ TEST_F(GlslGeneratorImplTest_Constructor, Bool) {
|
|||
WrapInFunction(Expr(false));
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_THAT(gen.result(), HasSubstr("false"));
|
||||
}
|
||||
|
||||
|
@ -37,8 +37,8 @@ TEST_F(GlslGeneratorImplTest_Constructor, Int) {
|
|||
WrapInFunction(Expr(-12345_i));
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_THAT(gen.result(), HasSubstr("-12345"));
|
||||
}
|
||||
|
||||
|
@ -46,8 +46,8 @@ TEST_F(GlslGeneratorImplTest_Constructor, UInt) {
|
|||
WrapInFunction(Expr(56779_u));
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_THAT(gen.result(), HasSubstr("56779u"));
|
||||
}
|
||||
|
||||
|
@ -56,8 +56,8 @@ TEST_F(GlslGeneratorImplTest_Constructor, Float) {
|
|||
WrapInFunction(Expr(f32((1 << 30) - 4)));
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_THAT(gen.result(), HasSubstr("1073741824.0f"));
|
||||
}
|
||||
|
||||
|
@ -68,8 +68,8 @@ TEST_F(GlslGeneratorImplTest_Constructor, F16) {
|
|||
WrapInFunction(Expr(f16((1 << 15) - 8)));
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_THAT(gen.result(), HasSubstr("32752.0hf"));
|
||||
}
|
||||
|
||||
|
@ -77,8 +77,8 @@ TEST_F(GlslGeneratorImplTest_Constructor, Type_Float) {
|
|||
WrapInFunction(Call<f32>(-1.2e-5_f));
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_THAT(gen.result(), HasSubstr("-0.00001200000042445026f"));
|
||||
}
|
||||
|
||||
|
@ -88,8 +88,8 @@ TEST_F(GlslGeneratorImplTest_Constructor, Type_F16) {
|
|||
WrapInFunction(Call<f16>(-1.2e-3_h));
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_THAT(gen.result(), HasSubstr("-0.0011997222900390625hf"));
|
||||
}
|
||||
|
||||
|
@ -97,8 +97,8 @@ TEST_F(GlslGeneratorImplTest_Constructor, Type_Bool) {
|
|||
WrapInFunction(Call<bool>(true));
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_THAT(gen.result(), HasSubstr("true"));
|
||||
}
|
||||
|
||||
|
@ -106,8 +106,8 @@ TEST_F(GlslGeneratorImplTest_Constructor, Type_Int) {
|
|||
WrapInFunction(Call<i32>(-12345_i));
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_THAT(gen.result(), HasSubstr("-12345"));
|
||||
}
|
||||
|
||||
|
@ -115,8 +115,8 @@ TEST_F(GlslGeneratorImplTest_Constructor, Type_Uint) {
|
|||
WrapInFunction(Call<u32>(12345_u));
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_THAT(gen.result(), HasSubstr("12345u"));
|
||||
}
|
||||
|
||||
|
@ -124,8 +124,8 @@ TEST_F(GlslGeneratorImplTest_Constructor, Type_Vec_F32) {
|
|||
WrapInFunction(vec3<f32>(1_f, 2_f, 3_f));
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_THAT(gen.result(), HasSubstr("vec3(1.0f, 2.0f, 3.0f)"));
|
||||
}
|
||||
|
||||
|
@ -135,8 +135,8 @@ TEST_F(GlslGeneratorImplTest_Constructor, Type_Vec_F16) {
|
|||
WrapInFunction(vec3<f16>(1_h, 2_h, 3_h));
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_THAT(gen.result(), HasSubstr("f16vec3(1.0hf, 2.0hf, 3.0hf)"));
|
||||
}
|
||||
|
||||
|
@ -144,8 +144,8 @@ TEST_F(GlslGeneratorImplTest_Constructor, Type_Vec_Empty_F32) {
|
|||
WrapInFunction(vec3<f32>());
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_THAT(gen.result(), HasSubstr("vec3(0.0f)"));
|
||||
}
|
||||
|
||||
|
@ -155,8 +155,8 @@ TEST_F(GlslGeneratorImplTest_Constructor, Type_Vec_Empty_F16) {
|
|||
WrapInFunction(vec3<f16>());
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_THAT(gen.result(), HasSubstr("f16vec3(0.0hf)"));
|
||||
}
|
||||
|
||||
|
@ -164,8 +164,8 @@ TEST_F(GlslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_F32_Literal) {
|
|||
WrapInFunction(vec3<f32>(2_f));
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_THAT(gen.result(), HasSubstr("vec3(2.0f)"));
|
||||
}
|
||||
|
||||
|
@ -175,8 +175,8 @@ TEST_F(GlslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_F16_Literal) {
|
|||
WrapInFunction(vec3<f16>(2_h));
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_THAT(gen.result(), HasSubstr("f16vec3(2.0hf)"));
|
||||
}
|
||||
|
||||
|
@ -186,8 +186,8 @@ TEST_F(GlslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_F32_Var) {
|
|||
WrapInFunction(var, cast);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_THAT(gen.result(), HasSubstr(R"(float v = 2.0f;
|
||||
vec3 tint_symbol = vec3(v);)"));
|
||||
}
|
||||
|
@ -200,8 +200,8 @@ TEST_F(GlslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_F16_Var) {
|
|||
WrapInFunction(var, cast);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_THAT(gen.result(), HasSubstr(R"(float16_t v = 2.0hf;
|
||||
f16vec3 tint_symbol = f16vec3(v);)"));
|
||||
}
|
||||
|
@ -210,8 +210,8 @@ TEST_F(GlslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_Bool) {
|
|||
WrapInFunction(vec3<bool>(true));
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_THAT(gen.result(), HasSubstr("bvec3(true)"));
|
||||
}
|
||||
|
||||
|
@ -219,8 +219,8 @@ TEST_F(GlslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_Int) {
|
|||
WrapInFunction(vec3<i32>(2_i));
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_THAT(gen.result(), HasSubstr("ivec3(2)"));
|
||||
}
|
||||
|
||||
|
@ -228,8 +228,8 @@ TEST_F(GlslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_UInt) {
|
|||
WrapInFunction(vec3<u32>(2_u));
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_THAT(gen.result(), HasSubstr("uvec3(2u)"));
|
||||
}
|
||||
|
||||
|
@ -237,9 +237,8 @@ TEST_F(GlslGeneratorImplTest_Constructor, Type_Mat_F32) {
|
|||
WrapInFunction(mat2x3<f32>(vec3<f32>(1_f, 2_f, 3_f), vec3<f32>(3_f, 4_f, 5_f)));
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_THAT(gen.result(), HasSubstr("mat2x3(vec3(1.0f, 2.0f, 3.0f), vec3(3.0f, 4.0f, 5.0f))"));
|
||||
}
|
||||
|
||||
|
@ -249,9 +248,8 @@ TEST_F(GlslGeneratorImplTest_Constructor, Type_Mat_F16) {
|
|||
WrapInFunction(mat2x3<f16>(vec3<f16>(1_h, 2_h, 3_h), vec3<f16>(3_h, 4_h, 5_h)));
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_THAT(gen.result(),
|
||||
HasSubstr("f16mat2x3(f16vec3(1.0hf, 2.0hf, 3.0hf), f16vec3(3.0hf, 4.0hf, 5.0hf))"));
|
||||
}
|
||||
|
@ -276,9 +274,8 @@ TEST_F(GlslGeneratorImplTest_Constructor, Type_Mat_Complex_F32) {
|
|||
WrapInFunction(ctor);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_THAT(gen.result(), HasSubstr("mat4(vec4(2.0f, 3.0f, 4.0f, 8.0f), vec4(0.0f), "
|
||||
"vec4(7.0f), vec4(42.0f, 21.0f, 6.0f, -5.0f))"));
|
||||
}
|
||||
|
@ -305,9 +302,8 @@ TEST_F(GlslGeneratorImplTest_Constructor, Type_Mat_Complex_F16) {
|
|||
WrapInFunction(ctor);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_THAT(gen.result(),
|
||||
HasSubstr("f16mat4(f16vec4(2.0hf, 3.0hf, 4.0hf, 8.0hf), f16vec4(0.0hf), "
|
||||
"f16vec4(7.0hf), f16vec4(42.0hf, 21.0hf, 6.0hf, -5.0hf))"));
|
||||
|
@ -317,9 +313,8 @@ TEST_F(GlslGeneratorImplTest_Constructor, Type_Mat_Empty_F32) {
|
|||
WrapInFunction(mat2x3<f32>());
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_THAT(gen.result(), HasSubstr("mat2x3 tint_symbol = mat2x3(vec3(0.0f), vec3(0.0f))"));
|
||||
}
|
||||
|
||||
|
@ -329,9 +324,8 @@ TEST_F(GlslGeneratorImplTest_Constructor, Type_Mat_Empty_F16) {
|
|||
WrapInFunction(mat2x3<f16>());
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_THAT(gen.result(),
|
||||
HasSubstr("f16mat2x3 tint_symbol = f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf))"));
|
||||
}
|
||||
|
@ -348,9 +342,8 @@ TEST_F(GlslGeneratorImplTest_Constructor, Type_Mat_Identity_F32) {
|
|||
WrapInFunction(m_1, m_2);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_THAT(gen.result(), HasSubstr("mat4 m_2 = mat4(m_1);"));
|
||||
}
|
||||
|
||||
|
@ -368,9 +361,8 @@ TEST_F(GlslGeneratorImplTest_Constructor, Type_Mat_Identity_F16) {
|
|||
WrapInFunction(m_1, m_2);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_THAT(gen.result(), HasSubstr("f16mat4 m_2 = f16mat4(m_1);"));
|
||||
}
|
||||
|
||||
|
@ -379,8 +371,8 @@ TEST_F(GlslGeneratorImplTest_Constructor, Type_Array) {
|
|||
vec3<f32>(4_f, 5_f, 6_f), vec3<f32>(7_f, 8_f, 9_f)));
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_THAT(gen.result(), HasSubstr("vec3[3](vec3(1.0f, 2.0f, 3.0f), "
|
||||
"vec3(4.0f, 5.0f, 6.0f), "
|
||||
"vec3(7.0f, 8.0f, 9.0f))"));
|
||||
|
@ -390,8 +382,8 @@ TEST_F(GlslGeneratorImplTest_Constructor, Type_Array_Empty) {
|
|||
WrapInFunction(Call(ty.array(ty.vec3<f32>(), 3_u)));
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_THAT(gen.result(), HasSubstr("vec3[3](vec3(0.0f), vec3(0.0f), vec3(0.0f))"));
|
||||
}
|
||||
|
||||
|
@ -405,8 +397,8 @@ TEST_F(GlslGeneratorImplTest_Constructor, Type_Struct) {
|
|||
WrapInFunction(Call(ty.Of(str), 1_i, 2_f, vec3<i32>(3_i, 4_i, 5_i)));
|
||||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_THAT(gen.result(), HasSubstr("S(1, 2.0f, ivec3(3, 4, 5))"));
|
||||
}
|
||||
|
||||
|
@ -420,8 +412,8 @@ TEST_F(GlslGeneratorImplTest_Constructor, Type_Struct_Empty) {
|
|||
WrapInFunction(Call(ty.Of(str)));
|
||||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_THAT(gen.result(), HasSubstr("S(0"));
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
#include "src/tint/writer/glsl/test_helper.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
namespace tint::writer::glsl {
|
||||
namespace {
|
||||
|
||||
|
@ -27,7 +29,8 @@ TEST_F(GlslGeneratorImplTest_Continue, Emit_Continue) {
|
|||
|
||||
gen.increment_indent();
|
||||
|
||||
ASSERT_TRUE(gen.EmitStatement(loop)) << gen.Diagnostics();
|
||||
gen.EmitStatement(loop);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"( while (true) {
|
||||
if (false) {
|
||||
break;
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
#include "src/tint/writer/glsl/test_helper.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
namespace tint::writer::glsl {
|
||||
namespace {
|
||||
|
||||
|
@ -28,8 +30,8 @@ TEST_F(GlslGeneratorImplTest_Discard, Emit_Discard) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
gen.increment_indent();
|
||||
|
||||
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.Diagnostics();
|
||||
gen.EmitStatement(stmt);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), " discard;\n");
|
||||
}
|
||||
|
||||
|
|
|
@ -36,8 +36,8 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Function) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
gen.increment_indent();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"( #version 310 es
|
||||
|
||||
void my_func() {
|
||||
|
@ -56,8 +56,8 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Function_Name_Collision) {
|
|||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
gen.increment_indent();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_THAT(gen.result(), HasSubstr(R"( void tint_symbol() {
|
||||
return;
|
||||
})"));
|
||||
|
@ -77,8 +77,8 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Function_WithParams) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
gen.increment_indent();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"( #version 310 es
|
||||
|
||||
void my_func(float a, int b) {
|
||||
|
@ -95,8 +95,8 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_NoReturn_Void)
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
precision highp float;
|
||||
|
||||
|
@ -114,8 +114,8 @@ TEST_F(GlslGeneratorImplTest_Function, PtrParameter) {
|
|||
ty.f32(), utils::Vector{Return(Deref("foo"))});
|
||||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_THAT(gen.result(), HasSubstr(R"(float f(inout float foo) {
|
||||
return foo;
|
||||
}
|
||||
|
@ -142,8 +142,8 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_WithInOutVars)
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
precision highp float;
|
||||
|
||||
|
@ -183,8 +183,8 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_WithInOut_Built
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
precision highp float;
|
||||
|
||||
|
@ -236,8 +236,8 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_SharedStruct_Di
|
|||
utils::Vector{Stage(ast::PipelineStage::kFragment)});
|
||||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
precision highp float;
|
||||
|
||||
|
@ -375,8 +375,8 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_Uniform) {
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
precision highp float;
|
||||
|
||||
|
@ -416,8 +416,8 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_UniformStr
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
precision highp float;
|
||||
|
||||
|
@ -457,8 +457,8 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_RW_Storage
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
precision highp float;
|
||||
|
||||
|
@ -504,8 +504,8 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_RO_Storage
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(),
|
||||
R"(#version 310 es
|
||||
precision highp float;
|
||||
|
@ -550,8 +550,8 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_WO_Storage
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
precision highp float;
|
||||
|
||||
|
@ -595,8 +595,8 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_StorageBuf
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
precision highp float;
|
||||
|
||||
|
@ -642,8 +642,8 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_Called_By_EntryPoint_With_
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
precision highp float;
|
||||
|
||||
|
@ -688,8 +688,8 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_Called_By_EntryPoint_With_
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(),
|
||||
R"(#version 310 es
|
||||
precision highp float;
|
||||
|
@ -725,8 +725,8 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_WithNameCollisi
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
precision highp float;
|
||||
|
||||
|
@ -751,8 +751,8 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_Compute) {
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
|
||||
|
@ -770,8 +770,8 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_Compute_WithWor
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
layout(local_size_x = 2, local_size_y = 4, local_size_z = 6) in;
|
||||
|
@ -792,8 +792,8 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_Compute_WithWor
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
layout(local_size_x = 2, local_size_y = 3, local_size_z = 4) in;
|
||||
|
@ -815,11 +815,13 @@ TEST_F(GlslGeneratorImplTest_Function,
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
EXPECT_FALSE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_EQ(
|
||||
gen.Diagnostics().str(),
|
||||
R"(error: override-expressions should have been removed with the SubstituteOverride transform)");
|
||||
R"(error: override-expressions should have been removed with the SubstituteOverride transform
|
||||
error: override-expressions should have been removed with the SubstituteOverride transform
|
||||
error: override-expressions should have been removed with the SubstituteOverride transform
|
||||
error: override-expressions should have been removed with the SubstituteOverride transform)");
|
||||
}
|
||||
|
||||
TEST_F(GlslGeneratorImplTest_Function, Emit_Function_WithArrayParams) {
|
||||
|
@ -829,8 +831,8 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Function_WithArrayParams) {
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
void my_func(float a[5]) {
|
||||
|
@ -847,8 +849,8 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Function_WithArrayReturn) {
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
float[5] my_func() {
|
||||
|
@ -911,8 +913,8 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Multiple_EntryPoint_With_Same_Module
|
|||
}
|
||||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
struct Data {
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
#include "src/tint/utils/string_stream.h"
|
||||
#include "src/tint/writer/glsl/test_helper.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
namespace tint::writer::glsl {
|
||||
namespace {
|
||||
|
||||
|
@ -29,7 +31,8 @@ TEST_F(GlslGeneratorImplTest_Identifier, EmitIdentifierExpression) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitExpression(out, i)) << gen.Diagnostics();
|
||||
gen.EmitExpression(out, i);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "foo");
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
#include "src/tint/writer/glsl/test_helper.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
namespace tint::writer::glsl {
|
||||
namespace {
|
||||
|
||||
|
@ -30,7 +32,8 @@ TEST_F(GlslGeneratorImplTest_If, Emit_If) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
gen.increment_indent();
|
||||
ASSERT_TRUE(gen.EmitStatement(i)) << gen.Diagnostics();
|
||||
gen.EmitStatement(i);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"( if (cond) {
|
||||
return;
|
||||
}
|
||||
|
@ -52,8 +55,8 @@ TEST_F(GlslGeneratorImplTest_If, Emit_IfWithElseIf) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
gen.increment_indent();
|
||||
|
||||
ASSERT_TRUE(gen.EmitStatement(i)) << gen.Diagnostics();
|
||||
gen.EmitStatement(i);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"( if (cond) {
|
||||
return;
|
||||
} else {
|
||||
|
@ -77,8 +80,8 @@ TEST_F(GlslGeneratorImplTest_If, Emit_IfWithElse) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
gen.increment_indent();
|
||||
|
||||
ASSERT_TRUE(gen.EmitStatement(i)) << gen.Diagnostics();
|
||||
gen.EmitStatement(i);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"( if (cond) {
|
||||
return;
|
||||
} else {
|
||||
|
@ -92,9 +95,7 @@ TEST_F(GlslGeneratorImplTest_If, Emit_IfWithMultiple) {
|
|||
GlobalVar("else_cond", ty.bool_(), builtin::AddressSpace::kPrivate);
|
||||
|
||||
auto* else_cond = Expr("else_cond");
|
||||
|
||||
auto* else_body = Block(Return());
|
||||
|
||||
auto* else_body_2 = Block(Return());
|
||||
|
||||
auto* cond = Expr("cond");
|
||||
|
@ -105,8 +106,8 @@ TEST_F(GlslGeneratorImplTest_If, Emit_IfWithMultiple) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
gen.increment_indent();
|
||||
|
||||
ASSERT_TRUE(gen.EmitStatement(i)) << gen.Diagnostics();
|
||||
gen.EmitStatement(i);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"( if (cond) {
|
||||
return;
|
||||
} else {
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
#include "src/tint/utils/string_stream.h"
|
||||
#include "src/tint/writer/glsl/test_helper.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::writer::glsl {
|
||||
|
@ -41,7 +43,8 @@ TEST_P(GlslImportData_SingleParamTest, FloatScalar) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.Diagnostics();
|
||||
gen.EmitCall(out, expr);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), std::string(param.glsl_name) + "(1.0f)");
|
||||
}
|
||||
INSTANTIATE_TEST_SUITE_P(GlslGeneratorImplTest_Import,
|
||||
|
@ -80,7 +83,8 @@ TEST_P(GlslImportData_SingleIntParamTest, IntScalar) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.Diagnostics();
|
||||
gen.EmitCall(out, expr);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), std::string(param.glsl_name) + "(1)");
|
||||
}
|
||||
INSTANTIATE_TEST_SUITE_P(GlslGeneratorImplTest_Import,
|
||||
|
@ -97,7 +101,8 @@ TEST_P(GlslImportData_SingleVectorParamTest, FloatVector) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.Diagnostics();
|
||||
gen.EmitCall(out, expr);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(
|
||||
out.str(),
|
||||
std::string(param.glsl_name) +
|
||||
|
@ -140,7 +145,8 @@ TEST_P(GlslImportData_DualParam_ScalarTest, Float) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.Diagnostics();
|
||||
gen.EmitCall(out, expr);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), std::string(param.glsl_name) + "(1.0f, 2.0f)");
|
||||
}
|
||||
INSTANTIATE_TEST_SUITE_P(GlslGeneratorImplTest_Import,
|
||||
|
@ -162,7 +168,8 @@ TEST_P(GlslImportData_DualParam_VectorTest, Float) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.Diagnostics();
|
||||
gen.EmitCall(out, expr);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(),
|
||||
std::string(param.glsl_name) + "(vec3(1.0f, 2.0f, 3.0f), vec3(4.0f, 5.0f, 6.0f))");
|
||||
}
|
||||
|
@ -187,7 +194,8 @@ TEST_P(GlslImportData_DualParam_Int_Test, IntScalar) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.Diagnostics();
|
||||
gen.EmitCall(out, expr);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), std::string(param.glsl_name) + "(1, 2)");
|
||||
}
|
||||
INSTANTIATE_TEST_SUITE_P(GlslGeneratorImplTest_Import,
|
||||
|
@ -205,7 +213,8 @@ TEST_P(GlslImportData_TripleParam_ScalarTest, Float) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.Diagnostics();
|
||||
gen.EmitCall(out, expr);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), std::string(param.glsl_name) + "(1.0f, 2.0f, 3.0f)");
|
||||
}
|
||||
INSTANTIATE_TEST_SUITE_P(GlslGeneratorImplTest_Import,
|
||||
|
@ -225,7 +234,8 @@ TEST_P(GlslImportData_TripleParam_VectorTest, Float) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.Diagnostics();
|
||||
gen.EmitCall(out, expr);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(),
|
||||
std::string(param.glsl_name) +
|
||||
R"((vec3(1.0f, 2.0f, 3.0f), vec3(4.0f, 5.0f, 6.0f), vec3(7.0f, 8.0f, 9.0f)))");
|
||||
|
@ -246,7 +256,8 @@ TEST_P(GlslImportData_TripleParam_Int_Test, IntScalar) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.Diagnostics();
|
||||
gen.EmitCall(out, expr);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), std::string(param.glsl_name) + "(1, 2, 3)");
|
||||
}
|
||||
INSTANTIATE_TEST_SUITE_P(GlslGeneratorImplTest_Import,
|
||||
|
@ -262,7 +273,8 @@ TEST_F(GlslGeneratorImplTest_Import, GlslImportData_Determinant) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.Diagnostics();
|
||||
gen.EmitCall(out, expr);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), std::string("determinant(var)"));
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
#include "src/tint/ast/variable_decl_statement.h"
|
||||
#include "src/tint/writer/glsl/test_helper.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::writer::glsl {
|
||||
|
@ -33,8 +35,8 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_Loop) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
gen.increment_indent();
|
||||
|
||||
ASSERT_TRUE(gen.EmitStatement(l)) << gen.Diagnostics();
|
||||
gen.EmitStatement(l);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"( while (true) {
|
||||
break;
|
||||
}
|
||||
|
@ -54,8 +56,8 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_LoopWithContinuing) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
gen.increment_indent();
|
||||
|
||||
ASSERT_TRUE(gen.EmitStatement(l)) << gen.Diagnostics();
|
||||
gen.EmitStatement(l);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"( while (true) {
|
||||
break;
|
||||
{
|
||||
|
@ -78,8 +80,8 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_LoopWithContinuing_BreakIf) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
gen.increment_indent();
|
||||
|
||||
ASSERT_TRUE(gen.EmitStatement(l)) << gen.Diagnostics();
|
||||
gen.EmitStatement(l);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"( while (true) {
|
||||
break;
|
||||
{
|
||||
|
@ -115,8 +117,8 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_LoopNestedWithContinuing) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
gen.increment_indent();
|
||||
|
||||
ASSERT_TRUE(gen.EmitStatement(outer)) << gen.Diagnostics();
|
||||
gen.EmitStatement(outer);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"( while (true) {
|
||||
while (true) {
|
||||
break;
|
||||
|
@ -154,8 +156,8 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_LoopWithVarUsedInContinuing) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
gen.increment_indent();
|
||||
|
||||
ASSERT_TRUE(gen.EmitStatement(outer)) << gen.Diagnostics();
|
||||
gen.EmitStatement(outer);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"( while (true) {
|
||||
float lhs = 2.5f;
|
||||
float other = 0.0f;
|
||||
|
@ -179,8 +181,8 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoop) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
gen.increment_indent();
|
||||
|
||||
ASSERT_TRUE(gen.EmitStatement(f)) << gen.Diagnostics();
|
||||
gen.EmitStatement(f);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"( {
|
||||
for(; ; ) {
|
||||
return;
|
||||
|
@ -201,8 +203,8 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithSimpleInit) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
gen.increment_indent();
|
||||
|
||||
ASSERT_TRUE(gen.EmitStatement(f)) << gen.Diagnostics();
|
||||
gen.EmitStatement(f);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"( {
|
||||
for(int i = 0; ; ) {
|
||||
return;
|
||||
|
@ -225,8 +227,8 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtInit) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
gen.increment_indent();
|
||||
|
||||
ASSERT_TRUE(gen.EmitStatement(f)) << gen.Diagnostics();
|
||||
gen.EmitStatement(f);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"( {
|
||||
bool tint_tmp = t;
|
||||
if (tint_tmp) {
|
||||
|
@ -253,8 +255,8 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithSimpleCond) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
gen.increment_indent();
|
||||
|
||||
ASSERT_TRUE(gen.EmitStatement(f)) << gen.Diagnostics();
|
||||
gen.EmitStatement(f);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"( {
|
||||
for(; true; ) {
|
||||
a_statement();
|
||||
|
@ -278,8 +280,8 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtCond) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
gen.increment_indent();
|
||||
|
||||
ASSERT_TRUE(gen.EmitStatement(f)) << gen.Diagnostics();
|
||||
gen.EmitStatement(f);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"( {
|
||||
while (true) {
|
||||
bool tint_tmp = t;
|
||||
|
@ -306,8 +308,8 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithSimpleCont) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
gen.increment_indent();
|
||||
|
||||
ASSERT_TRUE(gen.EmitStatement(f)) << gen.Diagnostics();
|
||||
gen.EmitStatement(f);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"( {
|
||||
for(; ; i = (i + 1)) {
|
||||
return;
|
||||
|
@ -332,8 +334,8 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtCont) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
gen.increment_indent();
|
||||
|
||||
ASSERT_TRUE(gen.EmitStatement(f)) << gen.Diagnostics();
|
||||
gen.EmitStatement(f);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"( {
|
||||
while (true) {
|
||||
return;
|
||||
|
@ -358,8 +360,8 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithSimpleInitCondCont) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
gen.increment_indent();
|
||||
|
||||
ASSERT_TRUE(gen.EmitStatement(f)) << gen.Diagnostics();
|
||||
gen.EmitStatement(f);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"( {
|
||||
for(int i = 0; true; i = (i + 1)) {
|
||||
return;
|
||||
|
@ -386,8 +388,8 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtInitCondCont) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
gen.increment_indent();
|
||||
|
||||
ASSERT_TRUE(gen.EmitStatement(f)) << gen.Diagnostics();
|
||||
gen.EmitStatement(f);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"( {
|
||||
bool tint_tmp = t;
|
||||
if (tint_tmp) {
|
||||
|
@ -422,8 +424,8 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_While) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
gen.increment_indent();
|
||||
|
||||
ASSERT_TRUE(gen.EmitStatement(f)) << gen.Diagnostics();
|
||||
gen.EmitStatement(f);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"( while(true) {
|
||||
return;
|
||||
}
|
||||
|
@ -441,8 +443,8 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_While_WithContinue) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
gen.increment_indent();
|
||||
|
||||
ASSERT_TRUE(gen.EmitStatement(f)) << gen.Diagnostics();
|
||||
gen.EmitStatement(f);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"( while(true) {
|
||||
continue;
|
||||
}
|
||||
|
@ -465,8 +467,8 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_WhileWithMultiStmtCond) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
gen.increment_indent();
|
||||
|
||||
ASSERT_TRUE(gen.EmitStatement(f)) << gen.Diagnostics();
|
||||
gen.EmitStatement(f);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"( while (true) {
|
||||
bool tint_tmp = t;
|
||||
if (tint_tmp) {
|
||||
|
|
|
@ -12,10 +12,11 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "src/tint/ast/stage_attribute.h"
|
||||
#include "src/tint/writer/glsl/test_helper.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::writer::glsl {
|
||||
|
@ -118,8 +119,8 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor, EmitExpression_MemberAccessor) {
|
|||
WrapInFunction(Var("expr", ty.f32(), expr));
|
||||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
struct Data {
|
||||
|
@ -169,8 +170,8 @@ TEST_P(GlslGeneratorImplTest_MemberAccessor_StorageBufferLoad, Test) {
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_THAT(gen.result(), HasSubstr(p.expected));
|
||||
}
|
||||
|
||||
|
@ -222,7 +223,8 @@ TEST_P(GlslGeneratorImplTest_MemberAccessor_StorageBufferStore, Test) {
|
|||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_THAT(gen.result(), HasSubstr(p.expected));
|
||||
}
|
||||
|
||||
|
@ -277,8 +279,9 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor, StorageBuffer_Store_Matrix_Empty) {
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
auto* expected =
|
||||
R"(#version 310 es
|
||||
precision highp float;
|
||||
|
@ -330,8 +333,8 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor, StorageBuffer_Load_Matrix_Single_El
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
auto* expected =
|
||||
R"(#version 310 es
|
||||
precision highp float;
|
||||
|
@ -378,8 +381,8 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor,
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
auto* expected =
|
||||
R"(#version 310 es
|
||||
precision highp float;
|
||||
|
@ -426,8 +429,8 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor,
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
auto* expected =
|
||||
R"(#version 310 es
|
||||
precision highp float;
|
||||
|
@ -473,8 +476,8 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor, StorageBuffer_Store_ToArray) {
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
auto* expected =
|
||||
R"(#version 310 es
|
||||
precision highp float;
|
||||
|
@ -526,8 +529,8 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor, StorageBuffer_Load_MultiLevel) {
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
auto* expected =
|
||||
R"(#version 310 es
|
||||
precision highp float;
|
||||
|
@ -587,8 +590,8 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor, StorageBuffer_Load_MultiLevel_Swizz
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
auto* expected =
|
||||
R"(#version 310 es
|
||||
precision highp float;
|
||||
|
@ -649,8 +652,8 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor,
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
auto* expected =
|
||||
R"(#version 310 es
|
||||
precision highp float;
|
||||
|
@ -710,8 +713,8 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor, StorageBuffer_Load_MultiLevel_Index
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
auto* expected =
|
||||
R"(#version 310 es
|
||||
precision highp float;
|
||||
|
@ -770,8 +773,8 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor, StorageBuffer_Store_MultiLevel) {
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
auto* expected =
|
||||
R"(#version 310 es
|
||||
precision highp float;
|
||||
|
@ -831,8 +834,8 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor, StorageBuffer_Store_Swizzle_SingleL
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
auto* expected =
|
||||
R"(#version 310 es
|
||||
precision highp float;
|
||||
|
@ -870,7 +873,8 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor, Swizzle_xyz) {
|
|||
WrapInFunction(var, expr);
|
||||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_THAT(gen.result(), HasSubstr("my_vec.xyz"));
|
||||
}
|
||||
|
||||
|
@ -880,7 +884,8 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor, Swizzle_gbr) {
|
|||
WrapInFunction(var, expr);
|
||||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_THAT(gen.result(), HasSubstr("my_vec.gbr"));
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
#include "src/tint/ast/id_attribute.h"
|
||||
#include "src/tint/writer/glsl/test_helper.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::writer::glsl {
|
||||
|
@ -27,8 +29,8 @@ TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_GlobalLet) {
|
|||
WrapInFunction(Decl(var));
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.EmitProgramConstVariable(var)) << gen.Diagnostics();
|
||||
gen.EmitProgramConstVariable(var);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), "const float pos[3] = float[3](1.0f, 2.0f, 3.0f);\n");
|
||||
}
|
||||
|
||||
|
@ -40,9 +42,8 @@ TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_AInt) {
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
void f() {
|
||||
|
@ -60,9 +61,8 @@ TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_AFloat) {
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
void f() {
|
||||
|
@ -80,9 +80,8 @@ TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_i32) {
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
void f() {
|
||||
|
@ -100,9 +99,8 @@ TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_u32) {
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
void f() {
|
||||
|
@ -120,9 +118,8 @@ TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_f32) {
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
void f() {
|
||||
|
@ -142,9 +139,8 @@ TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_f16) {
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
#extension GL_AMD_gpu_shader_half_float : require
|
||||
|
||||
|
@ -163,9 +159,8 @@ TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_vec3_AInt) {
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
void f() {
|
||||
|
@ -183,9 +178,8 @@ TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_vec3_AFloat) {
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
void f() {
|
||||
|
@ -203,9 +197,8 @@ TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_vec3_f32) {
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
void f() {
|
||||
|
@ -225,9 +218,8 @@ TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_vec3_f16) {
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
#extension GL_AMD_gpu_shader_half_float : require
|
||||
|
||||
|
@ -246,9 +238,8 @@ TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_mat2x3_AFloat) {
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
void f() {
|
||||
|
@ -266,9 +257,8 @@ TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_mat2x3_f32) {
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
void f() {
|
||||
|
@ -288,9 +278,8 @@ TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_mat2x3_f16) {
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
#extension GL_AMD_gpu_shader_half_float : require
|
||||
|
||||
|
@ -309,9 +298,8 @@ TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_arr_f32) {
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
void f() {
|
||||
|
@ -332,9 +320,8 @@ TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_arr_vec2_bool) {
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
void f() {
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
#include "src/tint/writer/glsl/test_helper.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::writer::glsl {
|
||||
|
@ -26,10 +28,9 @@ TEST_F(GlslGeneratorImplTest_Return, Emit_Return) {
|
|||
WrapInFunction(r);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
gen.increment_indent();
|
||||
|
||||
ASSERT_TRUE(gen.EmitStatement(r)) << gen.Diagnostics();
|
||||
gen.EmitStatement(r);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), " return;\n");
|
||||
}
|
||||
|
||||
|
@ -38,10 +39,9 @@ TEST_F(GlslGeneratorImplTest_Return, Emit_ReturnWithValue) {
|
|||
Func("f", utils::Empty, ty.i32(), utils::Vector{r});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
gen.increment_indent();
|
||||
|
||||
ASSERT_TRUE(gen.EmitStatement(r)) << gen.Diagnostics();
|
||||
gen.EmitStatement(r);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), " return 123;\n");
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
#include "src/tint/ast/variable_decl_statement.h"
|
||||
#include "src/tint/writer/glsl/test_helper.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::writer::glsl {
|
||||
|
@ -38,8 +40,8 @@ TEST_F(GlslSanitizerTest, Call_ArrayLength) {
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
|
||||
auto got = gen.result();
|
||||
auto* expect = R"(#version 310 es
|
||||
|
@ -78,8 +80,8 @@ TEST_F(GlslSanitizerTest, Call_ArrayLength_OtherMembersInStruct) {
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
|
||||
auto got = gen.result();
|
||||
auto* expect = R"(#version 310 es
|
||||
|
@ -122,8 +124,8 @@ TEST_F(GlslSanitizerTest, Call_ArrayLength_ViaLets) {
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
|
||||
auto got = gen.result();
|
||||
auto* expect = R"(#version 310 es
|
||||
|
@ -159,8 +161,8 @@ TEST_F(GlslSanitizerTest, PromoteArrayInitializerToConstVar) {
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
|
||||
auto got = gen.result();
|
||||
auto* expect = R"(#version 310 es
|
||||
|
@ -201,8 +203,8 @@ TEST_F(GlslSanitizerTest, PromoteStructInitializerToConstVar) {
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
|
||||
auto got = gen.result();
|
||||
auto* expect = R"(#version 310 es
|
||||
|
@ -247,8 +249,8 @@ TEST_F(GlslSanitizerTest, SimplifyPointersBasic) {
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
|
||||
auto got = gen.result();
|
||||
auto* expect = R"(#version 310 es
|
||||
|
@ -296,8 +298,8 @@ TEST_F(GlslSanitizerTest, SimplifyPointersComplexChain) {
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
|
||||
auto got = gen.result();
|
||||
auto* expect = R"(#version 310 es
|
||||
|
|
|
@ -12,10 +12,11 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "src/tint/number.h"
|
||||
#include "src/tint/writer/glsl/test_helper.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
using ::testing::HasSubstr;
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
|
@ -48,7 +49,8 @@ TEST_F(GlslGeneratorImplTest_StorageBuffer, Align) {
|
|||
|
||||
// TODO(crbug.com/tint/1421) offsets do not currently work on GLSL ES.
|
||||
// They will likely require manual padding.
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
struct Nephews {
|
||||
|
@ -70,8 +72,8 @@ TEST_F(GlslGeneratorImplTest_StorageBuffer, Align_Desktop) {
|
|||
TestAlign(this);
|
||||
|
||||
GeneratorImpl& gen = Build(Version(Version::Standard::kDesktop, 4, 4));
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 440
|
||||
|
||||
struct Nephews {
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
#include "src/tint/writer/glsl/test_helper.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::writer::glsl {
|
||||
|
@ -35,10 +37,9 @@ TEST_F(GlslGeneratorImplTest_Switch, Emit_Switch) {
|
|||
WrapInFunction(s);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
gen.increment_indent();
|
||||
|
||||
ASSERT_TRUE(gen.EmitStatement(s)) << gen.Diagnostics();
|
||||
gen.EmitStatement(s);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"( switch(cond) {
|
||||
case 5: {
|
||||
break;
|
||||
|
@ -62,10 +63,9 @@ TEST_F(GlslGeneratorImplTest_Switch, Emit_Switch_MixedDefault) {
|
|||
WrapInFunction(s);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
gen.increment_indent();
|
||||
|
||||
ASSERT_TRUE(gen.EmitStatement(s)) << gen.Diagnostics();
|
||||
gen.EmitStatement(s);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"( switch(cond) {
|
||||
case 5:
|
||||
default: {
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
#include "src/tint/writer/glsl/test_helper.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
namespace tint::writer::glsl {
|
||||
namespace {
|
||||
|
||||
|
@ -32,8 +34,8 @@ TEST_F(GlslGeneratorImplTest, Generate) {
|
|||
Func("my_func", utils::Empty, ty.void_(), utils::Empty);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
void my_func() {
|
||||
|
@ -46,8 +48,8 @@ TEST_F(GlslGeneratorImplTest, GenerateDesktop) {
|
|||
Func("my_func", utils::Empty, ty.void_(), utils::Empty);
|
||||
|
||||
GeneratorImpl& gen = Build(Version(Version::Standard::kDesktop, 4, 4));
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 440
|
||||
|
||||
void my_func() {
|
||||
|
@ -69,8 +71,8 @@ TEST_F(GlslGeneratorImplTest, GenerateSampleIndexES) {
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = Build(Version(Version::Standard::kES, 3, 1));
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
#extension GL_OES_sample_variables : require
|
||||
|
||||
|
@ -94,8 +96,8 @@ TEST_F(GlslGeneratorImplTest, GenerateSampleIndexDesktop) {
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = Build(Version(Version::Standard::kDesktop, 4, 4));
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 440
|
||||
|
||||
int my_func() {
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "src/tint/ast/call_statement.h"
|
||||
#include "src/tint/ast/stage_attribute.h"
|
||||
#include "src/tint/type/depth_texture.h"
|
||||
|
@ -24,6 +23,8 @@
|
|||
#include "src/tint/utils/string_stream.h"
|
||||
#include "src/tint/writer/glsl/test_helper.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
using ::testing::HasSubstr;
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
@ -40,9 +41,9 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Array) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitType(out, program->TypeOf(ty), builtin::AddressSpace::kUndefined,
|
||||
builtin::Access::kReadWrite, "ary"))
|
||||
<< gen.Diagnostics();
|
||||
gen.EmitType(out, program->TypeOf(ty), builtin::AddressSpace::kUndefined,
|
||||
builtin::Access::kReadWrite, "ary");
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "bool ary[4]");
|
||||
}
|
||||
|
||||
|
@ -53,9 +54,9 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_ArrayOfArray) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitType(out, program->TypeOf(ty), builtin::AddressSpace::kUndefined,
|
||||
builtin::Access::kReadWrite, "ary"))
|
||||
<< gen.Diagnostics();
|
||||
gen.EmitType(out, program->TypeOf(ty), builtin::AddressSpace::kUndefined,
|
||||
builtin::Access::kReadWrite, "ary");
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "bool ary[5][4]");
|
||||
}
|
||||
|
||||
|
@ -66,9 +67,9 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_ArrayOfArrayOfArray) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitType(out, program->TypeOf(ty), builtin::AddressSpace::kUndefined,
|
||||
builtin::Access::kReadWrite, "ary"))
|
||||
<< gen.Diagnostics();
|
||||
gen.EmitType(out, program->TypeOf(ty), builtin::AddressSpace::kUndefined,
|
||||
builtin::Access::kReadWrite, "ary");
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "bool ary[6][5][4]");
|
||||
}
|
||||
|
||||
|
@ -79,9 +80,9 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Array_WithoutName) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitType(out, program->TypeOf(ty), builtin::AddressSpace::kUndefined,
|
||||
builtin::Access::kReadWrite, ""))
|
||||
<< gen.Diagnostics();
|
||||
gen.EmitType(out, program->TypeOf(ty), builtin::AddressSpace::kUndefined,
|
||||
builtin::Access::kReadWrite, "");
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "bool[4]");
|
||||
}
|
||||
|
||||
|
@ -91,9 +92,8 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Bool) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitType(out, bool_, builtin::AddressSpace::kUndefined,
|
||||
builtin::Access::kReadWrite, ""))
|
||||
<< gen.Diagnostics();
|
||||
gen.EmitType(out, bool_, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "");
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "bool");
|
||||
}
|
||||
|
||||
|
@ -103,9 +103,8 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_F32) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(
|
||||
gen.EmitType(out, f32, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, ""))
|
||||
<< gen.Diagnostics();
|
||||
gen.EmitType(out, f32, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "");
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "float");
|
||||
}
|
||||
|
||||
|
@ -117,9 +116,8 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_F16) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(
|
||||
gen.EmitType(out, f16, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, ""))
|
||||
<< gen.Diagnostics();
|
||||
gen.EmitType(out, f16, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "");
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "float16_t");
|
||||
}
|
||||
|
||||
|
@ -129,9 +127,8 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_I32) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(
|
||||
gen.EmitType(out, i32, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, ""))
|
||||
<< gen.Diagnostics();
|
||||
gen.EmitType(out, i32, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "");
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "int");
|
||||
}
|
||||
|
||||
|
@ -143,9 +140,8 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Matrix_F32) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitType(out, mat2x3, builtin::AddressSpace::kUndefined,
|
||||
builtin::Access::kReadWrite, ""))
|
||||
<< gen.Diagnostics();
|
||||
gen.EmitType(out, mat2x3, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "");
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "mat2x3");
|
||||
}
|
||||
|
||||
|
@ -159,9 +155,8 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Matrix_F16) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitType(out, mat2x3, builtin::AddressSpace::kUndefined,
|
||||
builtin::Access::kReadWrite, ""))
|
||||
<< gen.Diagnostics();
|
||||
gen.EmitType(out, mat2x3, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "");
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "f16mat2x3");
|
||||
}
|
||||
|
||||
|
@ -176,7 +171,8 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_StructDecl) {
|
|||
|
||||
TextGenerator::TextBuffer buf;
|
||||
auto* sem_s = program->TypeOf(s)->As<sem::Struct>();
|
||||
ASSERT_TRUE(gen.EmitStructType(&buf, sem_s)) << gen.Diagnostics();
|
||||
gen.EmitStructType(&buf, sem_s);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(buf.String(), R"(struct S {
|
||||
int a;
|
||||
float b;
|
||||
|
@ -196,9 +192,8 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Struct) {
|
|||
|
||||
auto* sem_s = program->TypeOf(s)->As<sem::Struct>();
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitType(out, sem_s, builtin::AddressSpace::kUndefined,
|
||||
builtin::Access::kReadWrite, ""))
|
||||
<< gen.Diagnostics();
|
||||
gen.EmitType(out, sem_s, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "");
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "S");
|
||||
}
|
||||
|
||||
|
@ -210,8 +205,8 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Struct_NameCollision) {
|
|||
GlobalVar("g", ty.Of(s), builtin::AddressSpace::kPrivate);
|
||||
|
||||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_THAT(gen.result(), HasSubstr(R"(struct S {
|
||||
int tint_symbol;
|
||||
float tint_symbol_1;
|
||||
|
@ -230,7 +225,8 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Struct_WithOffsetAttributes) {
|
|||
|
||||
TextGenerator::TextBuffer buf;
|
||||
auto* sem_s = program->TypeOf(s)->As<sem::Struct>();
|
||||
ASSERT_TRUE(gen.EmitStructType(&buf, sem_s)) << gen.Diagnostics();
|
||||
gen.EmitStructType(&buf, sem_s);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(buf.String(), R"(struct S {
|
||||
int a;
|
||||
float b;
|
||||
|
@ -245,9 +241,8 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_U32) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(
|
||||
gen.EmitType(out, u32, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, ""))
|
||||
<< gen.Diagnostics();
|
||||
gen.EmitType(out, u32, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "");
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "uint");
|
||||
}
|
||||
|
||||
|
@ -258,9 +253,8 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Vector_F32) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(
|
||||
gen.EmitType(out, vec3, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, ""))
|
||||
<< gen.Diagnostics();
|
||||
gen.EmitType(out, vec3, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "");
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "vec3");
|
||||
}
|
||||
|
||||
|
@ -273,9 +267,8 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Vector_F16) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(
|
||||
gen.EmitType(out, vec3, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, ""))
|
||||
<< gen.Diagnostics();
|
||||
gen.EmitType(out, vec3, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "");
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "f16vec3");
|
||||
}
|
||||
|
||||
|
@ -285,9 +278,8 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Void) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitType(out, void_, builtin::AddressSpace::kUndefined,
|
||||
builtin::Access::kReadWrite, ""))
|
||||
<< gen.Diagnostics();
|
||||
gen.EmitType(out, void_, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "");
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "void");
|
||||
}
|
||||
|
||||
|
@ -297,9 +289,8 @@ TEST_F(GlslGeneratorImplTest_Type, EmitSampler) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_FALSE(gen.EmitType(out, sampler, builtin::AddressSpace::kUndefined,
|
||||
builtin::Access::kReadWrite, ""))
|
||||
<< gen.Diagnostics();
|
||||
gen.EmitType(out, sampler, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "");
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
}
|
||||
|
||||
TEST_F(GlslGeneratorImplTest_Type, EmitSamplerComparison) {
|
||||
|
@ -308,9 +299,8 @@ TEST_F(GlslGeneratorImplTest_Type, EmitSamplerComparison) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_FALSE(gen.EmitType(out, sampler, builtin::AddressSpace::kUndefined,
|
||||
builtin::Access::kReadWrite, ""))
|
||||
<< gen.Diagnostics();
|
||||
gen.EmitType(out, sampler, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "");
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
}
|
||||
|
||||
struct GlslDepthTextureData {
|
||||
|
@ -341,7 +331,8 @@ TEST_P(GlslDepthTexturesTest, Emit) {
|
|||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_THAT(gen.result(), HasSubstr(params.result));
|
||||
}
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
|
@ -368,8 +359,8 @@ TEST_F(GlslDepthMultisampledTexturesTest, Emit) {
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_THAT(gen.result(), HasSubstr("sampler2DMS tex;"));
|
||||
}
|
||||
|
||||
|
@ -414,8 +405,8 @@ TEST_P(GlslSampledTexturesTest, Emit) {
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_THAT(gen.result(), HasSubstr(params.result));
|
||||
}
|
||||
INSTANTIATE_TEST_SUITE_P(GlslGeneratorImplTest_Type,
|
||||
|
@ -519,9 +510,8 @@ TEST_F(GlslGeneratorImplTest_Type, EmitMultisampledTexture) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(
|
||||
gen.EmitType(out, s, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, ""))
|
||||
<< gen.Diagnostics();
|
||||
gen.EmitType(out, s, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "");
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "highp sampler2DMS");
|
||||
}
|
||||
|
||||
|
@ -552,8 +542,8 @@ TEST_P(GlslStorageTexturesTest, Emit) {
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_THAT(gen.result(), HasSubstr(params.result));
|
||||
}
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
#include "src/tint/utils/string_stream.h"
|
||||
#include "src/tint/writer/glsl/test_helper.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
namespace tint::writer::glsl {
|
||||
namespace {
|
||||
|
||||
|
@ -28,7 +30,8 @@ TEST_F(GlslUnaryOpTest, AddressOf) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitExpression(out, op)) << gen.Diagnostics();
|
||||
gen.EmitExpression(out, op);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "expr");
|
||||
}
|
||||
|
||||
|
@ -40,7 +43,8 @@ TEST_F(GlslUnaryOpTest, Complement) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitExpression(out, op)) << gen.Diagnostics();
|
||||
gen.EmitExpression(out, op);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "~(expr)");
|
||||
}
|
||||
|
||||
|
@ -53,7 +57,8 @@ TEST_F(GlslUnaryOpTest, Indirection) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitExpression(out, op)) << gen.Diagnostics();
|
||||
gen.EmitExpression(out, op);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "expr");
|
||||
}
|
||||
|
||||
|
@ -65,7 +70,8 @@ TEST_F(GlslUnaryOpTest, Not) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitExpression(out, op)) << gen.Diagnostics();
|
||||
gen.EmitExpression(out, op);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "!(expr)");
|
||||
}
|
||||
|
||||
|
@ -77,7 +83,8 @@ TEST_F(GlslUnaryOpTest, Negation) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitExpression(out, op)) << gen.Diagnostics();
|
||||
gen.EmitExpression(out, op);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "-(expr)");
|
||||
}
|
||||
|
||||
|
@ -88,7 +95,8 @@ TEST_F(GlslUnaryOpTest, IntMin) {
|
|||
GeneratorImpl& gen = Build();
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitExpression(out, op)) << gen.Diagnostics();
|
||||
gen.EmitExpression(out, op);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(out.str(), "(-2147483647 - 1)");
|
||||
}
|
||||
|
||||
|
|
|
@ -12,9 +12,10 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "src/tint/writer/glsl/test_helper.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
using ::testing::HasSubstr;
|
||||
|
||||
namespace tint::writer::glsl {
|
||||
|
@ -29,8 +30,8 @@ TEST_F(GlslGeneratorImplTest_UniformBuffer, Simple) {
|
|||
GlobalVar("simple", ty.Of(simple), builtin::AddressSpace::kUniform, Group(0_a), Binding(0_a));
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
struct Simple {
|
||||
|
@ -49,8 +50,8 @@ TEST_F(GlslGeneratorImplTest_UniformBuffer, Simple_Desktop) {
|
|||
GlobalVar("simple", ty.Of(simple), builtin::AddressSpace::kUniform, Group(0_a), Binding(0_a));
|
||||
|
||||
GeneratorImpl& gen = Build(Version(Version::Standard::kDesktop, 4, 4));
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 440
|
||||
|
||||
struct Simple {
|
||||
|
|
|
@ -12,10 +12,11 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "src/tint/ast/variable_decl_statement.h"
|
||||
#include "src/tint/writer/glsl/test_helper.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::writer::glsl {
|
||||
|
@ -31,10 +32,9 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement) {
|
|||
WrapInFunction(stmt);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
gen.increment_indent();
|
||||
|
||||
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.Diagnostics();
|
||||
gen.EmitStatement(stmt);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), " float a = 0.0f;\n");
|
||||
}
|
||||
|
||||
|
@ -44,10 +44,9 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Let) {
|
|||
WrapInFunction(stmt);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
gen.increment_indent();
|
||||
|
||||
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.Diagnostics();
|
||||
gen.EmitStatement(stmt);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), " float a = 0.0f;\n");
|
||||
}
|
||||
|
||||
|
@ -57,10 +56,9 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const) {
|
|||
WrapInFunction(stmt);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
gen.increment_indent();
|
||||
|
||||
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.Diagnostics();
|
||||
gen.EmitStatement(stmt);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), ""); // Not a mistake - 'const' is inlined
|
||||
}
|
||||
|
||||
|
@ -73,9 +71,8 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_AInt
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
void f() {
|
||||
|
@ -94,9 +91,8 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_AFlo
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
void f() {
|
||||
|
@ -115,9 +111,8 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_i32)
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
void f() {
|
||||
|
@ -136,9 +131,8 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_u32)
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
void f() {
|
||||
|
@ -157,9 +151,8 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_f32)
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
void f() {
|
||||
|
@ -180,9 +173,8 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_f16)
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
#extension GL_AMD_gpu_shader_half_float : require
|
||||
|
||||
|
@ -202,9 +194,8 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_vec3
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
void f() {
|
||||
|
@ -223,9 +214,8 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_vec3
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
void f() {
|
||||
|
@ -244,9 +234,8 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_vec3
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
void f() {
|
||||
|
@ -267,9 +256,8 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_vec3
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
#extension GL_AMD_gpu_shader_half_float : require
|
||||
|
||||
|
@ -289,9 +277,8 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_mat2
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
void f() {
|
||||
|
@ -310,9 +297,8 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_mat2
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
void f() {
|
||||
|
@ -333,9 +319,8 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_mat2
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
#extension GL_AMD_gpu_shader_half_float : require
|
||||
|
||||
|
@ -355,9 +340,8 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_arr_
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
void f() {
|
||||
|
@ -376,9 +360,8 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_arr_
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
void f() {
|
||||
|
@ -397,9 +380,8 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_arr_
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
void f() {
|
||||
|
@ -419,9 +401,8 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_arr_
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
struct S {
|
||||
|
@ -448,9 +429,8 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_arr_
|
|||
});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(#version 310 es
|
||||
|
||||
void f() {
|
||||
|
@ -466,10 +446,9 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Array) {
|
|||
WrapInFunction(var, Expr("a"));
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
gen.increment_indent();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_THAT(gen.result(),
|
||||
HasSubstr(" float a[5] = float[5](0.0f, 0.0f, 0.0f, 0.0f, 0.0f);\n"));
|
||||
}
|
||||
|
@ -480,10 +459,9 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Private) {
|
|||
WrapInFunction(Expr("a"));
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
gen.increment_indent();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_THAT(gen.result(), HasSubstr(" float a = 0.0f;\n"));
|
||||
}
|
||||
|
||||
|
@ -494,8 +472,8 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Initialize
|
|||
WrapInFunction(stmt);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.Diagnostics();
|
||||
gen.EmitStatement(stmt);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(vec3 a = vec3(0.0f);
|
||||
)");
|
||||
}
|
||||
|
@ -509,8 +487,8 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Initialize
|
|||
WrapInFunction(stmt);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.Diagnostics();
|
||||
gen.EmitStatement(stmt);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(), R"(f16vec3 a = f16vec3(0.0hf);
|
||||
)");
|
||||
}
|
||||
|
@ -522,8 +500,8 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Initialize
|
|||
WrapInFunction(stmt);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.Diagnostics();
|
||||
gen.EmitStatement(stmt);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(),
|
||||
R"(mat2x3 a = mat2x3(vec3(0.0f), vec3(0.0f));
|
||||
)");
|
||||
|
@ -538,8 +516,8 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Initialize
|
|||
WrapInFunction(stmt);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.EmitStatement(stmt)) << gen.Diagnostics();
|
||||
gen.EmitStatement(stmt);
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_EQ(gen.result(),
|
||||
R"(f16mat2x3 a = f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf));
|
||||
)");
|
||||
|
|
|
@ -12,11 +12,12 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "src/tint/ast/id_attribute.h"
|
||||
#include "src/tint/ast/stage_attribute.h"
|
||||
#include "src/tint/writer/glsl/test_helper.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
using ::testing::HasSubstr;
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
@ -35,8 +36,8 @@ TEST_F(GlslGeneratorImplTest_WorkgroupVar, Basic) {
|
|||
WorkgroupSize(1_i),
|
||||
});
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_THAT(gen.result(), HasSubstr("shared float wg;\n"));
|
||||
}
|
||||
|
||||
|
@ -51,8 +52,8 @@ TEST_F(GlslGeneratorImplTest_WorkgroupVar, Aliased) {
|
|||
WorkgroupSize(1_i),
|
||||
});
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
|
||||
gen.Generate();
|
||||
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
|
||||
EXPECT_THAT(gen.result(), HasSubstr("shared float wg;\n"));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue