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