From 10aceb370234f845db092181fa6ab6beba308c4e Mon Sep 17 00:00:00 2001 From: Sylvain Doremus Date: Mon, 19 May 2025 18:48:53 +0200 Subject: [PATCH 1/3] Removed exports for deleted functions. --- include/ShaderAST/Expr/Expr.hpp | 10 ++++++---- include/ShaderAST/Shader.hpp | 8 +++++--- include/ShaderAST/ShaderAllocator.hpp | 6 ++++-- include/ShaderAST/Type/Type.hpp | 5 +++-- include/ShaderWriter/BaseTypes/NonUniform.hpp | 3 +++ include/ShaderWriter/BaseTypes/ReturnWrapper.hpp | 2 ++ include/ShaderWriter/Writer.hpp | 5 +++-- source/CompilerSpirV/SpirVBlock.hpp | 3 +++ source/CompilerSpirV/SpirVFunction.hpp | 3 +++ source/ShaderAST/Visitors/SelectEntryPoint.cpp | 3 +++ test/ShaderWriter/CompileSPIRV.cpp | 2 ++ 11 files changed, 37 insertions(+), 13 deletions(-) diff --git a/include/ShaderAST/Expr/Expr.hpp b/include/ShaderAST/Expr/Expr.hpp index f22c5110..82f73d2c 100644 --- a/include/ShaderAST/Expr/Expr.hpp +++ b/include/ShaderAST/Expr/Expr.hpp @@ -84,11 +84,13 @@ namespace ast::expr class Expr { + private: + Expr( Expr const & ) = delete; + Expr & operator=( Expr const & )noexcept = delete; + Expr( Expr && )noexcept = delete; + Expr & operator=( Expr && ) = delete; + public: - SDAST_API Expr( Expr const & ) = delete; - SDAST_API Expr & operator=( Expr const & )noexcept = delete; - SDAST_API Expr( Expr && )noexcept = delete; - SDAST_API Expr & operator=( Expr && ) = delete; SDAST_API virtual ~Expr()noexcept = default; SDAST_API Expr( ExprCache & exprCache diff --git a/include/ShaderAST/Shader.hpp b/include/ShaderAST/Shader.hpp index 3a91f7b8..10b1c0e5 100644 --- a/include/ShaderAST/Shader.hpp +++ b/include/ShaderAST/Shader.hpp @@ -73,11 +73,13 @@ namespace ast { friend class ShaderBuilder; + private: + Shader( Shader const & ) = delete; + Shader & operator=( Shader const & ) = delete; + Shader & operator=( Shader && rhs )noexcept = delete; + public: - SDAST_API Shader( Shader const & ) = delete; - SDAST_API Shader & operator=( Shader const & ) = delete; SDAST_API Shader( Shader && rhs )noexcept; - SDAST_API Shader & operator=( Shader && rhs )noexcept = delete; SDAST_API explicit Shader( ast::ShaderStage type , ShaderAllocator * allocator = nullptr ); diff --git a/include/ShaderAST/ShaderAllocator.hpp b/include/ShaderAST/ShaderAllocator.hpp index 2b9f03f4..023ca9f7 100644 --- a/include/ShaderAST/ShaderAllocator.hpp +++ b/include/ShaderAST/ShaderAllocator.hpp @@ -99,10 +99,12 @@ namespace ast class ShaderAllocatorBlock { + private: + ShaderAllocatorBlock( ShaderAllocatorBlock const & rhs ) = delete; + ShaderAllocatorBlock & operator=( ShaderAllocatorBlock const & rhs ) = delete; + public: SDAST_API explicit ShaderAllocatorBlock( ShaderAllocator & allocator )noexcept; - SDAST_API ShaderAllocatorBlock( ShaderAllocatorBlock const & rhs ) = delete; - SDAST_API ShaderAllocatorBlock & operator=( ShaderAllocatorBlock const & rhs ) = delete; SDAST_API ShaderAllocatorBlock( ShaderAllocatorBlock && rhs )noexcept; SDAST_API ShaderAllocatorBlock & operator=( ShaderAllocatorBlock && rhs )noexcept; SDAST_API ~ShaderAllocatorBlock()noexcept; diff --git a/include/ShaderAST/Type/Type.hpp b/include/ShaderAST/Type/Type.hpp index abe3d849..bdfa8857 100644 --- a/include/ShaderAST/Type/Type.hpp +++ b/include/ShaderAST/Type/Type.hpp @@ -275,6 +275,9 @@ namespace ast::type friend class TypeCache; friend class Struct; + Type( Type const & ) = delete; + Type & operator=( Type const & ) = delete; + public: SDAST_API Type( TypesCache & typesCache , Kind kind ); @@ -290,8 +293,6 @@ namespace ast::type SDAST_API Type const * getNonMemberType()const; SDAST_API virtual ~Type()noexcept = default; - SDAST_API Type( Type const & ) = delete; - SDAST_API Type & operator=( Type const & ) = delete; Kind getRawKind()const { diff --git a/include/ShaderWriter/BaseTypes/NonUniform.hpp b/include/ShaderWriter/BaseTypes/NonUniform.hpp index de7657b7..25f5eba2 100644 --- a/include/ShaderWriter/BaseTypes/NonUniform.hpp +++ b/include/ShaderWriter/BaseTypes/NonUniform.hpp @@ -13,9 +13,12 @@ namespace sdw struct NonUniformT : public ValueT { + private: NonUniformT( NonUniformT const & rhs ) = delete; NonUniformT & operator=( NonUniformT const & rhs ) = delete; NonUniformT & operator=( NonUniformT && rhs ) = delete; + + public: ~NonUniformT()noexcept override = default; NonUniformT( ShaderWriter & writer diff --git a/include/ShaderWriter/BaseTypes/ReturnWrapper.hpp b/include/ShaderWriter/BaseTypes/ReturnWrapper.hpp index 5a33fcd0..6b15a2a5 100644 --- a/include/ShaderWriter/BaseTypes/ReturnWrapper.hpp +++ b/include/ShaderWriter/BaseTypes/ReturnWrapper.hpp @@ -13,10 +13,12 @@ namespace sdw struct ReturnWrapperT : public ValueT { + private: ReturnWrapperT( ReturnWrapperT const & rhs ) = delete; ReturnWrapperT & operator=( ReturnWrapperT const & rhs ) = delete; ReturnWrapperT & operator=( ReturnWrapperT && rhs )noexcept = delete; + public: ReturnWrapperT( ShaderWriter & writer , expr::ExprPtr expr , bool enabled ); diff --git a/include/ShaderWriter/Writer.hpp b/include/ShaderWriter/Writer.hpp index 77102af1..5da3abc4 100644 --- a/include/ShaderWriter/Writer.hpp +++ b/include/ShaderWriter/Writer.hpp @@ -1037,10 +1037,11 @@ namespace sdw template< typename WriterT > struct WriterScopeT { - public: + private: WriterScopeT( WriterScopeT const & rhs ) = delete; - WriterScopeT & operator=( WriterScopeT const& rhs ) = delete; + WriterScopeT & operator=( WriterScopeT const & rhs ) = delete; + public: WriterScopeT( WriterScopeT && rhs )noexcept : m_writer{ rhs.m_writer } { diff --git a/source/CompilerSpirV/SpirVBlock.hpp b/source/CompilerSpirV/SpirVBlock.hpp index a5e68e8c..d18fac70 100644 --- a/source/CompilerSpirV/SpirVBlock.hpp +++ b/source/CompilerSpirV/SpirVBlock.hpp @@ -48,8 +48,11 @@ namespace spirv struct Block { + private: Block( Block const & rhs ) = delete; Block & operator=( Block const & rhs ) = delete; + + public: SDWSPIRV_API Block( Block && rhs )noexcept; SDWSPIRV_API Block & operator=( Block && rhs )noexcept; SDWSPIRV_API ~Block()noexcept = default; diff --git a/source/CompilerSpirV/SpirVFunction.hpp b/source/CompilerSpirV/SpirVFunction.hpp index b7c6b586..570f377c 100644 --- a/source/CompilerSpirV/SpirVFunction.hpp +++ b/source/CompilerSpirV/SpirVFunction.hpp @@ -115,8 +115,11 @@ namespace spirv struct Function { + private: Function( Function const & rhs ) = delete; Function & operator=( Function const & rhs ) = delete; + + public: SDWSPIRV_API Function( Function && rhs )noexcept = default; SDWSPIRV_API Function & operator=( Function && rhs )noexcept = default; SDWSPIRV_API ~Function()noexcept = default; diff --git a/source/ShaderAST/Visitors/SelectEntryPoint.cpp b/source/ShaderAST/Visitors/SelectEntryPoint.cpp index 8682564d..404212d3 100644 --- a/source/ShaderAST/Visitors/SelectEntryPoint.cpp +++ b/source/ShaderAST/Visitors/SelectEntryPoint.cpp @@ -118,8 +118,11 @@ namespace ast struct Used { + private: Used( Used const & ) = delete; Used & operator=( Used const & ) = delete; + + public: Used( Used && )noexcept = default; Used & operator=( Used && )noexcept = default; diff --git a/test/ShaderWriter/CompileSPIRV.cpp b/test/ShaderWriter/CompileSPIRV.cpp index b2a5a784..760b467a 100644 --- a/test/ShaderWriter/CompileSPIRV.cpp +++ b/test/ShaderWriter/CompileSPIRV.cpp @@ -757,11 +757,13 @@ namespace test { struct SPIRVContext { + private: SPIRVContext( SPIRVContext const & ) = delete; SPIRVContext & operator=( SPIRVContext const & ) = delete; SPIRVContext( SPIRVContext && )noexcept = delete; SPIRVContext & operator=( SPIRVContext && )noexcept = delete; + public: SPIRVContext()noexcept { static const std::vector< uint32_t > spvVersions{ spv1_0, spv1_1, spv1_2, spv1_3, spv1_4, spv1_5, spv1_6 }; From 3a52e91b14fe50c6e167c85ecbac74eb00af0630 Mon Sep 17 00:00:00 2001 From: Sylvain Doremus Date: Mon, 19 May 2025 18:49:56 +0200 Subject: [PATCH 2/3] Added sdw prefix to control statement helper macros. Also added a way to disable them completely, you just need to define SDW_DISABLE_CTRL_MACROS before including Writer.hpp --- include/ShaderWriter/Writer.hpp | 36 ++- .../ShaderWriter/TestWriterCompositeCtors.cpp | 54 ++-- test/ShaderWriter/TestWriterComputeShader.cpp | 4 +- .../TestWriterControlStatements.cpp | 276 +++++++++--------- .../ShaderWriter/TestWriterFragmentShader.cpp | 26 +- test/ShaderWriter/TestWriterFunction.cpp | 40 +-- test/ShaderWriter/TestWriterIncrement.cpp | 8 +- test/ShaderWriter/TestWriterMeshShaderEXT.cpp | 68 ++--- test/ShaderWriter/TestWriterMeshShaderNV.cpp | 68 ++--- .../ShaderWriter/TestWriterMeshShader_EXT.cpp | 68 ++--- test/ShaderWriter/TestWriterMeshShader_NV.cpp | 68 ++--- test/ShaderWriter/TestWriterProgram.cpp | 56 ++-- .../TestWriterRayAnyHitShader.cpp | 10 +- .../TestWriterRayClosestHitShader.cpp | 56 ++-- .../TestWriterRayIntersectionShader.cpp | 16 +- test/ShaderWriter/TestWriterShader.cpp | 40 +-- .../TestWriterSpecConstantDeclarations.cpp | 8 +- test/ShaderWriter/TestWriterTaskShaderEXT.cpp | 24 +- test/ShaderWriter/TestWriterTaskShaderNV.cpp | 24 +- .../ShaderWriter/TestWriterTaskShader_EXT.cpp | 24 +- test/ShaderWriter/TestWriterTaskShader_NV.cpp | 24 +- .../TestWriterTessellationControlShader.cpp | 8 +- 22 files changed, 505 insertions(+), 501 deletions(-) diff --git a/include/ShaderWriter/Writer.hpp b/include/ShaderWriter/Writer.hpp index 5da3abc4..5b9122a2 100644 --- a/include/ShaderWriter/Writer.hpp +++ b/include/ShaderWriter/Writer.hpp @@ -1095,7 +1095,9 @@ namespace sdw } } -#define FOR( Writer, Type, Name, Init, Cond, Incr )\ +#if !defined( SDW_DISABLE_CTRL_MACROS ) + +#define sdwFOR( Writer, Type, Name, Init, Cond, Incr )\ if ( auto writerScope = makeScope( Writer ) )\ {\ auto ctrlVar##Name = ( Writer ).registerLoopVar( #Name, Type::makeType( ( Writer ).getTypesCache() ) );\ @@ -1110,61 +1112,63 @@ namespace sdw , sdw::makeExpr( Writer, incr##Name )\ , [&]()noexcept -#define ROF\ +#define sdwROF\ );\ } -#define WHILE( Writer, Condition )\ +#define sdwWHILE( Writer, Condition )\ ( Writer ).whileStmt( sdw::makeCondition( Condition )\ , [&]()noexcept -#define ELIHW\ +#define sdwELIHW\ ); -#define DOWHILE( Writer, Condition )\ +#define sdwDOWHILE( Writer, Condition )\ ( Writer ).doWhileStmt( sdw::makeCondition( Condition )\ , [&]()noexcept -#define ELIHWOD\ +#define sdwELIHWOD\ ); -#define IF( Writer, Condition )\ +#define sdwIF( Writer, Condition )\ ( Writer ).ifStmt( sdw::makeCondition( Condition )\ , [&]()noexcept -#define ELSE\ +#define sdwELSE\ ).elseStmt( [&]()noexcept -#define ELSEIF( Condition )\ +#define sdwELSEIF( Condition )\ ).elseIfStmt( sdw::makeCondition( Condition )\ , [&]()noexcept -#define FI\ +#define sdwFI\ ).endIf(); -#define SWITCH( Writer, Value )\ +#define sdwSWITCH( Writer, Value )\ if ( auto writerScope = makeScope( Writer ) )\ {\ writerScope->switchStmt( sdw::makeExpr( *writerScope, Value )\ , [&]()noexcept -#define CASE( Literal )\ +#define sdwCASE( Literal )\ writerScope->caseStmt( sdw::makeLiteral( *writerScope, Literal )\ , [&]()noexcept -#define ESAC\ +#define sdwESAC\ ) -#define DEFAULT\ +#define sdwDEFAULT\ writerScope->defaultStmt( [&]()noexcept -#define TLUAFED\ +#define sdwTLUAFED\ ) -#define HCTIWS\ +#define sdwHCTIWS\ ).endSwitch();\ } +#endif + #include "Writer.inl" #endif diff --git a/test/ShaderWriter/TestWriterCompositeCtors.cpp b/test/ShaderWriter/TestWriterCompositeCtors.cpp index ae263581..13430b89 100644 --- a/test/ShaderWriter/TestWriterCompositeCtors.cpp +++ b/test/ShaderWriter/TestWriterCompositeCtors.cpp @@ -387,21 +387,21 @@ namespace auto value0 = writer.declLocale( "value0", vec4( 0.0_f ) ); auto value1 = writer.declLocale( "value1", vec4( 1.0_f ) ); - IF( writer, ssbo[0].a().x() > 0.0_f ) + sdwIF( writer, ssbo[0].a().x() > 0.0_f ) { value1 = ssbo[0].a() * ssbo[0].b(); } - ELSE + sdwELSE { value0 = ssbo[1].a() * ssbo[1].b(); } - FI; + sdwFI; - IF( writer, in.localInvocationIndex == 0_u ) + sdwIF( writer, in.localInvocationIndex == 0_u ) { ssbo[2].a() = value0 + value1; } - FI; + sdwFI; } ); test::writeShader( writer @@ -501,11 +501,11 @@ namespace auto result = writer.declLocale( "result" , Intersection{ writer } ); - IF( writer, sphereRadius < 0.0_f ) + sdwIF( writer, sphereRadius < 0.0_f ) { result.t() = max( 0.0_f, 1.0_f ); } - FI; + sdwFI; writer.returnStmt( result ); } @@ -860,15 +860,15 @@ namespace auto result = writer.declLocale( "result" , all( lhs == rhs ) ); - IF( writer, result ) + sdwIF( writer, result ) { ssbo[0].e() = uvec4( 1u ); } - ELSE + sdwELSE { ssbo[1].e() = uvec4( 0u ); } - FI; + sdwFI; } ); test::writeShader( writer @@ -900,15 +900,15 @@ namespace auto result = writer.declLocale( "result" , any( lhs == rhs ) ); - IF( writer, result ) + sdwIF( writer, result ) { ssbo[0].e() = uvec4( 1u ); } - ELSE + sdwELSE { ssbo[1].e() = uvec4( 0u ); } - FI; + sdwFI; } ); test::writeShader( writer @@ -938,15 +938,15 @@ namespace auto rhs = writer.declLocale( "rhs" , vec4( 1.0_f, 1.0_f, 1.0_f, 1.0_f ) ); - IF( writer, all( lhs == rhs ) ) + sdwIF( writer, all( lhs == rhs ) ) { ssbo[0].e() = uvec4( 1u ); } - ELSE + sdwELSE { ssbo[1].e() = uvec4( 0u ); } - FI; + sdwFI; } ); test::writeShader( writer @@ -976,15 +976,15 @@ namespace auto rhs = writer.declLocale( "rhs" , vec4( 1.0_f, 1.0_f, 1.0_f, 1.0_f ) ); - IF( writer, any( lhs == rhs ) ) + sdwIF( writer, any( lhs == rhs ) ) { ssbo[0].e() = uvec4( 1u ); } - ELSE + sdwELSE { ssbo[1].e() = uvec4( 0u ); } - FI; + sdwFI; } ); test::writeShader( writer @@ -1039,11 +1039,11 @@ namespace { auto v = writer.declLocale< MyStruct >( "v" ); - IF( writer, !all( v.b == vec3( 0.0_f ) ) ) + sdwIF( writer, !all( v.b == vec3( 0.0_f ) ) ) { ssbo[0].e() = uvec4( 1u ); } - FI; + sdwFI; } ); test::writeShader( writer @@ -1145,13 +1145,13 @@ namespace auto result = writer.declLocale( "result" , vec4( 0.0_f ) ); - FOR( writer, sdw::UInt, i, 0_u, i < ssbo[0].e().x(), ++i ) + sdwFOR( writer, sdw::UInt, i, 0_u, i < ssbo[0].e().x(), ++i ) { auto value = writer.declLocale( "value" , normalize( values[i] + ssbo[0].b().xyz() ) ); result.xyz() += value; } - ROF; + sdwROF; // final radiance is average of all the cones radiances ssbo[0].a() = result; @@ -1160,20 +1160,20 @@ namespace auto result = writer.declLocale( "result" , vec4( 0.0_f ) ); - FOR( writer, sdw::UInt, i, 0_u, i < ssbo[0].e().x(), ++i ) + sdwFOR( writer, sdw::UInt, i, 0_u, i < ssbo[0].e().x(), ++i ) { auto value = writer.declLocale( "value" , normalize( values[i] + ssbo[0].b().xyz() ) ); result.xyz() += value; } - ROF; + sdwROF; - IF( writer, in.localInvocationIndex == 0_u ) + sdwIF( writer, in.localInvocationIndex == 0_u ) { // final radiance is average of all the cones radiances ssbo[0].a() = result; } - FI; + sdwFI; } ); test::writeShader( writer diff --git a/test/ShaderWriter/TestWriterComputeShader.cpp b/test/ShaderWriter/TestWriterComputeShader.cpp index ab03bce4..cce20573 100644 --- a/test/ShaderWriter/TestWriterComputeShader.cpp +++ b/test/ShaderWriter/TestWriterComputeShader.cpp @@ -317,14 +317,14 @@ namespace auto color = writer.declLocale( "color" , decodeColor( voxels[in.globalInvocationID.x()].colorMask ) ); - IF( writer, color.a() > 0.0_f ) + sdwIF( writer, color.a() > 0.0_f ) { auto coord = writer.declLocale( "coord" , ivec3( unflatten( in.globalInvocationID.x() , uvec3( writer.cast< UInt >( c3d_voxelResolution ) ) ) ) ); result.store( coord, color ); } - FI; + sdwFI; voxels[in.globalInvocationID.x()].colorMask = 0_u; } ); diff --git a/test/ShaderWriter/TestWriterControlStatements.cpp b/test/ShaderWriter/TestWriterControlStatements.cpp index b1b545b5..21b6be00 100644 --- a/test/ShaderWriter/TestWriterControlStatements.cpp +++ b/test/ShaderWriter/TestWriterControlStatements.cpp @@ -15,11 +15,11 @@ namespace { auto ctrlVar = writer.declLocale< sdw::Int >( "ctrlVar", 1_i ); - IF( writer, ctrlVar != 0_i ) + sdwIF( writer, ctrlVar != 0_i ) { auto i = writer.declLocale< sdw::Int >( "i" ); } - FI; + sdwFI; } ); test::writeShader( writer , testCounts, CurrentCompilers ); @@ -33,15 +33,15 @@ namespace writer.implementMain( [&]( sdw::VertexIn in, sdw::VertexOut out ) { auto ctrlVar = writer.declLocale< sdw::Int >( "ctrlVar", 1_i ); - IF( writer, ctrlVar != 0_i ) + sdwIF( writer, ctrlVar != 0_i ) { auto i = writer.declLocale< sdw::Int >( "i" ); } - ELSE + sdwELSE { auto j = writer.declLocale< sdw::Int >( "j" ); } - FI; + sdwFI; } ); test::writeShader( writer , testCounts, CurrentCompilers ); @@ -56,15 +56,15 @@ namespace { auto ctrlVar1 = writer.declLocale< sdw::Int >( "ctrlVar1", 1_i ); auto ctrlVar2 = writer.declLocale< sdw::Int >( "ctrlVar2", 0_i ); - IF( writer, ctrlVar1 != 0_i ) + sdwIF( writer, ctrlVar1 != 0_i ) { auto i = writer.declLocale< sdw::Int >( "i" ); } - ELSEIF( ctrlVar2 != 0_i ) + sdwELSEIF( ctrlVar2 != 0_i ) { auto j = writer.declLocale< sdw::Int >( "j" ); } - FI; + sdwFI; } ); test::writeShader( writer , testCounts, CurrentCompilers ); @@ -79,19 +79,19 @@ namespace { auto ctrlVar1 = writer.declLocale< sdw::Int >( "ctrlVar1", 1_i ); auto ctrlVar2 = writer.declLocale< sdw::Int >( "ctrlVar2", 0_i ); - IF( writer, ctrlVar1 != 0_i ) + sdwIF( writer, ctrlVar1 != 0_i ) { auto i = writer.declLocale< sdw::Int >( "i" ); } - ELSEIF( ctrlVar2 != 0_i ) + sdwELSEIF( ctrlVar2 != 0_i ) { auto j = writer.declLocale< sdw::Int >( "j" ); } - ELSE + sdwELSE { auto k = writer.declLocale< sdw::Int >( "k" ); } - FI; + sdwFI; } ); test::writeShader( writer , testCounts, CurrentCompilers ); @@ -105,20 +105,20 @@ namespace writer.implementMain( [&]( sdw::VertexIn in, sdw::VertexOut out ) { auto ctrl = writer.declLocale< sdw::Int >( "ctrl" ); - SWITCH( writer, ctrl ) + sdwSWITCH( writer, ctrl ) { - CASE( 0 ) + sdwCASE( 0 ) { auto i = writer.declLocale< sdw::Int >( "i" ); } - ESAC; - CASE( 1 ) + sdwESAC; + sdwCASE( 1 ) { auto j = writer.declLocale< sdw::Int >( "j" ); } - ESAC; + sdwESAC; } - HCTIWS; + sdwHCTIWS; } ); test::writeShader( writer , testCounts, CurrentCompilers ); @@ -131,11 +131,11 @@ namespace sdw::VertexWriter writer{ &testCounts.allocator }; writer.implementMain( [&]( sdw::VertexIn in, sdw::VertexOut out ) { - FOR( writer, sdw::Int, ctrlVar, 0_i, ctrlVar < 20_i, ctrlVar += 10_i ) + sdwFOR( writer, sdw::Int, ctrlVar, 0_i, ctrlVar < 20_i, ctrlVar += 10_i ) { auto i = writer.declLocale( "i", ctrlVar ); } - ROF; + sdwROF; } ); test::writeShader( writer , testCounts, CurrentCompilers ); @@ -148,11 +148,11 @@ namespace sdw::VertexWriter writer{ &testCounts.allocator }; writer.implementMain( [&]( sdw::VertexIn in, sdw::VertexOut out ) { - FOR( writer, sdw::Int, ctrlVar, 0_i, ctrlVar < 20_i, ++ctrlVar ) + sdwFOR( writer, sdw::Int, ctrlVar, 0_i, ctrlVar < 20_i, ++ctrlVar ) { auto i = writer.declLocale( "i", ctrlVar ); } - ROF; + sdwROF; } ); test::writeShader( writer , testCounts, CurrentCompilers ); @@ -165,11 +165,11 @@ namespace sdw::VertexWriter writer{ &testCounts.allocator }; writer.implementMain( [&]( sdw::VertexIn in, sdw::VertexOut out ) { - FOR( writer, sdw::Int, ctrlVar, 0_i, ctrlVar < 20_i, ctrlVar++ ) + sdwFOR( writer, sdw::Int, ctrlVar, 0_i, ctrlVar < 20_i, ctrlVar++ ) { auto i = writer.declLocale( "i", ctrlVar ); } - ROF; + sdwROF; } ); test::writeShader( writer , testCounts, CurrentCompilers ); @@ -183,11 +183,11 @@ namespace sdw::VertexWriter writer{ &testCounts.allocator }; writer.implementMain( [&]( sdw::VertexIn in, sdw::VertexOut out ) { - FOR( writer, sdw::Int, ctrlVar, 20_i, ctrlVar > 0_i, --ctrlVar ) + sdwFOR( writer, sdw::Int, ctrlVar, 20_i, ctrlVar > 0_i, --ctrlVar ) { auto i = writer.declLocale( "i", ctrlVar ); } - ROF; + sdwROF; } ); test::writeShader( writer , testCounts, CurrentCompilers ); @@ -202,10 +202,10 @@ namespace sdw::VertexWriter writer{ &testCounts.allocator }; writer.implementMain( [&]( sdw::VertexIn in, sdw::VertexOut out ) { - FOR( writer, sdw::Int, ctrlVar, 20_i, ctrlVar > 0_i, ctrlVar-- ) + sdwFOR( writer, sdw::Int, ctrlVar, 20_i, ctrlVar > 0_i, ctrlVar-- ) { } - ROF; + sdwROF; } ); test::writeShader( writer , testCounts, CurrentCompilers ); @@ -220,31 +220,31 @@ namespace sdw::VertexWriter writer{ &testCounts.allocator }; writer.implementMain( [&]( sdw::VertexIn in, sdw::VertexOut out ) { - FOR( writer, sdw::Int, ctrlVar, 0_i, ctrlVar < 20_i, ctrlVar += 10_i ) + sdwFOR( writer, sdw::Int, ctrlVar, 0_i, ctrlVar < 20_i, ctrlVar += 10_i ) { auto i = writer.declLocale( "i", ctrlVar ); } - ROF; - FOR( writer, sdw::Int, ctrlVar, 0_i, ctrlVar < 20_i, ++ctrlVar ) + sdwROF; + sdwFOR( writer, sdw::Int, ctrlVar, 0_i, ctrlVar < 20_i, ++ctrlVar ) { auto i = writer.declLocale( "i", ctrlVar ); } - ROF; - FOR( writer, sdw::Int, ctrlVar, 0_i, ctrlVar < 20_i, ctrlVar++ ) + sdwROF; + sdwFOR( writer, sdw::Int, ctrlVar, 0_i, ctrlVar < 20_i, ctrlVar++ ) { auto i = writer.declLocale( "i", ctrlVar ); } - ROF; - FOR( writer, sdw::Int, ctrlVar, 20_i, ctrlVar > 0_i, --ctrlVar ) + sdwROF; + sdwFOR( writer, sdw::Int, ctrlVar, 20_i, ctrlVar > 0_i, --ctrlVar ) { auto i = writer.declLocale( "i", ctrlVar ); } - ROF; - FOR( writer, sdw::Int, ctrlVar, 20_i, ctrlVar > 0_i, ctrlVar-- ) + sdwROF; + sdwFOR( writer, sdw::Int, ctrlVar, 20_i, ctrlVar > 0_i, ctrlVar-- ) { auto i = writer.declLocale( "i", ctrlVar ); } - ROF; + sdwROF; } ); test::writeShader( writer , testCounts, CurrentCompilers ); @@ -259,11 +259,11 @@ namespace writer.implementMain( [&]( sdw::VertexIn in, sdw::VertexOut out ) { auto ctrlVar = writer.declLocale< sdw::Int >( "ctrlVar", 20_i ); - WHILE( writer, ctrlVar != 0_i ) + sdwWHILE( writer, ctrlVar != 0_i ) { ctrlVar = ctrlVar - 1_i; } - ELIHW; + sdwELIHW; } ); test::writeShader( writer , testCounts, CurrentCompilers ); @@ -277,11 +277,11 @@ namespace writer.implementMain( [&]( sdw::VertexIn in, sdw::VertexOut out ) { auto ctrlVar = writer.declLocale< sdw::Int >( "ctrlVar", 20_i ); - DOWHILE( writer, ctrlVar != 0_i ) + sdwDOWHILE( writer, ctrlVar != 0_i ) { ctrlVar = ctrlVar - 1_i; } - ELIHWOD; + sdwELIHWOD; } ); test::writeShader( writer , testCounts, CurrentCompilers ); @@ -295,16 +295,16 @@ namespace writer.implementMain( [&]( sdw::VertexIn in, sdw::VertexOut out ) { auto ctrlVar1 = writer.declLocale< sdw::Int >( "ctrlVar1", 1_i ); - IF( writer, ctrlVar1 != 0_i ) + sdwIF( writer, ctrlVar1 != 0_i ) { auto ctrlVar2 = writer.declLocale< sdw::Int >( "ctrlVar2", 1_i ); - IF( writer, ctrlVar2 != 0_i ) + sdwIF( writer, ctrlVar2 != 0_i ) { auto i = writer.declLocale< sdw::Int >( "i" ); } - FI; + sdwFI; } - FI; + sdwFI; } ); test::writeShader( writer , testCounts, CurrentCompilers ); @@ -318,33 +318,33 @@ namespace writer.implementMain( [&]( sdw::VertexIn in, sdw::VertexOut out ) { auto ctrlVar1 = writer.declLocale< sdw::Int >( "ctrlVar1", 1_i ); - IF( writer, ctrlVar1 != 0_i ) + sdwIF( writer, ctrlVar1 != 0_i ) { auto ctrlVar2 = writer.declLocale< sdw::Int >( "ctrlVar2", 1_i ); - IF( writer, ctrlVar2 != 0_i ) + sdwIF( writer, ctrlVar2 != 0_i ) { auto i = writer.declLocale< sdw::Int >( "i" ); } - ELSE + sdwELSE { auto j = writer.declLocale< sdw::Int >( "j" ); } - FI; + sdwFI; } - ELSE + sdwELSE { auto ctrlVar2 = writer.declLocale< sdw::Int >( "ctrlVar2", 1_i ); - IF( writer, ctrlVar2 != 0_i ) + sdwIF( writer, ctrlVar2 != 0_i ) { auto i = writer.declLocale< sdw::Int >( "j" ); } - ELSE + sdwELSE { auto j = writer.declLocale< sdw::Int >( "k" ); } - FI; + sdwFI; } - FI; + sdwFI; } ); test::writeShader( writer , testCounts, CurrentCompilers ); @@ -359,35 +359,35 @@ namespace { auto ctrlVar1 = writer.declLocale< sdw::Int >( "ctrlVar1", 1_i ); auto ctrlVar2 = writer.declLocale< sdw::Int >( "ctrlVar2", 0_i ); - IF( writer, ctrlVar1 != 0_i ) + sdwIF( writer, ctrlVar1 != 0_i ) { auto ctrlVar3 = writer.declLocale< sdw::Int >( "ctrlVar3", 1_i ); auto ctrlVar4 = writer.declLocale< sdw::Int >( "ctrlVar4", 1_i ); - IF( writer, ctrlVar3 != 0_i ) + sdwIF( writer, ctrlVar3 != 0_i ) { auto i = writer.declLocale< sdw::Int >( "i" ); } - ELSEIF( ctrlVar4 != 0_i ) + sdwELSEIF( ctrlVar4 != 0_i ) { auto j = writer.declLocale< sdw::Int >( "j" ); } - FI; + sdwFI; } - ELSEIF( ctrlVar2 != 0_i ) + sdwELSEIF( ctrlVar2 != 0_i ) { auto ctrlVar3 = writer.declLocale< sdw::Int >( "ctrlVar3", 1_i ); auto ctrlVar4 = writer.declLocale< sdw::Int >( "ctrlVar4", 1_i ); - IF( writer, ctrlVar3 != 0_i ) + sdwIF( writer, ctrlVar3 != 0_i ) { auto k = writer.declLocale< sdw::Int >( "k" ); } - ELSEIF( ctrlVar4 != 0_i ) + sdwELSEIF( ctrlVar4 != 0_i ) { auto l = writer.declLocale< sdw::Int >( "l" ); } - FI; + sdwFI; } - FI; + sdwFI; } ); test::writeShader( writer , testCounts, CurrentCompilers ); @@ -402,61 +402,61 @@ namespace { auto ctrlVar1 = writer.declLocale< sdw::Int >( "ctrlVar1", 1_i ); auto ctrlVar2 = writer.declLocale< sdw::Int >( "ctrlVar2", 0_i ); - IF( writer, ctrlVar1 != 0_i ) + sdwIF( writer, ctrlVar1 != 0_i ) { auto ctrlVar3 = writer.declLocale< sdw::Int >( "ctrlVar3", 1_i ); auto ctrlVar4 = writer.declLocale< sdw::Int >( "ctrlVar4", 1_i ); - IF( writer, ctrlVar3 != 0_i ) + sdwIF( writer, ctrlVar3 != 0_i ) { auto i = writer.declLocale< sdw::Int >( "i" ); } - ELSEIF( ctrlVar4 != 0_i ) + sdwELSEIF( ctrlVar4 != 0_i ) { auto j = writer.declLocale< sdw::Int >( "j" ); } - ELSE + sdwELSE { auto k = writer.declLocale< sdw::Int >( "k" ); } - FI; + sdwFI; } - ELSEIF( ctrlVar2 != 0_i ) + sdwELSEIF( ctrlVar2 != 0_i ) { auto ctrlVar3 = writer.declLocale< sdw::Int >( "ctrlVar3", 1_i ); auto ctrlVar4 = writer.declLocale< sdw::Int >( "ctrlVar4", 1_i ); - IF( writer, ctrlVar3 != 0_i ) + sdwIF( writer, ctrlVar3 != 0_i ) { auto l = writer.declLocale< sdw::Int >( "l" ); } - ELSEIF( ctrlVar4 != 0_i ) + sdwELSEIF( ctrlVar4 != 0_i ) { auto m = writer.declLocale< sdw::Int >( "m" ); } - ELSE + sdwELSE { auto n = writer.declLocale< sdw::Int >( "n" ); } - FI; + sdwFI; } - ELSE + sdwELSE { auto ctrlVar3 = writer.declLocale< sdw::Int >( "ctrlVar3", 1_i ); auto ctrlVar4 = writer.declLocale< sdw::Int >( "ctrlVar4", 1_i ); - IF( writer, ctrlVar3 != 0_i ) + sdwIF( writer, ctrlVar3 != 0_i ) { auto o = writer.declLocale< sdw::Int >( "o" ); } - ELSEIF( ctrlVar4 != 0_i ) + sdwELSEIF( ctrlVar4 != 0_i ) { auto p = writer.declLocale< sdw::Int >( "p" ); } - ELSE + sdwELSE { auto q = writer.declLocale< sdw::Int >( "q" ); } - FI; + sdwFI; } - FI; + sdwFI; } ); test::writeShader( writer , testCounts, CurrentCompilers ); @@ -469,15 +469,15 @@ namespace sdw::VertexWriter writer{ &testCounts.allocator }; writer.implementMain( [&]( sdw::VertexIn in, sdw::VertexOut out ) { - FOR( writer, sdw::Int, ctrlVar, 0_i, ctrlVar < 20_i, ++ctrlVar ) + sdwFOR( writer, sdw::Int, ctrlVar, 0_i, ctrlVar < 20_i, ++ctrlVar ) { - FOR( writer, sdw::Int, ctrlVar2, 0_i, ctrlVar2 < 20_i, ++ctrlVar2 ) + sdwFOR( writer, sdw::Int, ctrlVar2, 0_i, ctrlVar2 < 20_i, ++ctrlVar2 ) { auto i = writer.declLocale( "i", ctrlVar2 ); } - ROF; + sdwROF; } - ROF; + sdwROF; } ); test::writeShader( writer , testCounts, CurrentCompilers ); @@ -491,17 +491,17 @@ namespace writer.implementMain( [&]( sdw::VertexIn in, sdw::VertexOut out ) { auto ctrlVar1 = writer.declLocale< sdw::Int >( "ctrlVar1", 20_i ); - WHILE( writer, ctrlVar1 != 0_i ) + sdwWHILE( writer, ctrlVar1 != 0_i ) { auto ctrlVar2 = writer.declLocale< sdw::Int >( "ctrlVar2", 20_i ); - WHILE( writer, ctrlVar2 != 0_i ) + sdwWHILE( writer, ctrlVar2 != 0_i ) { ctrlVar2 = ctrlVar2 - 1_i; } - ELIHW; + sdwELIHW; ctrlVar1 = ctrlVar1 - 1_i; } - ELIHW; + sdwELIHW; } ); test::writeShader( writer , testCounts, CurrentCompilers ); @@ -515,17 +515,17 @@ namespace writer.implementMain( [&]( sdw::VertexIn in, sdw::VertexOut out ) { auto ctrlVar1 = writer.declLocale< sdw::Int >( "ctrlVar1", 20_i ); - DOWHILE( writer, ctrlVar1 != 0_i ) + sdwDOWHILE( writer, ctrlVar1 != 0_i ) { auto ctrlVar2 = writer.declLocale< sdw::Int >( "ctrlVar2", 20_i ); - DOWHILE( writer, ctrlVar2 != 0_i ) + sdwDOWHILE( writer, ctrlVar2 != 0_i ) { ctrlVar2 = ctrlVar2 - 1_i; } - ELIHWOD; + sdwELIHWOD; ctrlVar1 = ctrlVar1 - 1_i; } - ELIHWOD; + sdwELIHWOD; } ); test::writeShader( writer , testCounts, CurrentCompilers ); @@ -557,15 +557,15 @@ namespace writer.implementMain( 32u, [&]( sdw::ComputeIn in ) { auto ctrlVar = writer.declConstant< sdw::Int >( "ctrlVar", 1_i ); - IF( writer, ctrlVar != 0_i ) + sdwIF( writer, ctrlVar != 0_i ) { auto i = writer.declLocale< sdw::Int >( "i", 24_i ); } - ELSE + sdwELSE { auto j = writer.declLocale< sdw::Int >( "j", 12_i ); } - FI; + sdwFI; } ); test::writeShader( writer , testCounts, CurrentCompilers ); @@ -585,15 +585,15 @@ namespace writer.implementMain( 32u, [&]( sdw::ComputeIn in ) { auto ctrlVar = writer.declConstant< sdw::Int >( "ctrlVar", 1_i ); - IF( writer, ctrlVar == 0_i ) + sdwIF( writer, ctrlVar == 0_i ) { auto i = writer.declLocale< sdw::Int >( "i", 24_i ); } - ELSE + sdwELSE { auto j = writer.declLocale< sdw::Int >( "j", 12_i ); } - FI; + sdwFI; } ); test::writeShader( writer , testCounts, CurrentCompilers ); @@ -614,19 +614,19 @@ namespace { auto ctrlVar1 = writer.declConstant< sdw::Int >( "ctrlVar1", 1_i ); auto ctrlVar2 = writer.declConstant< sdw::Int >( "ctrlVar2", 0_i ); - IF( writer, ctrlVar1 != 0_i ) + sdwIF( writer, ctrlVar1 != 0_i ) { auto i = writer.declLocale< sdw::Int >( "i", 24_i ); } - ELSEIF( ctrlVar2 == 0_i ) + sdwELSEIF( ctrlVar2 == 0_i ) { auto j = writer.declLocale< sdw::Int >( "j", 12_i ); } - ELSE + sdwELSE { auto k = writer.declLocale< sdw::Int >( "k", 6_i ); } - FI; + sdwFI; } ); test::writeShader( writer , testCounts, CurrentCompilers ); @@ -647,19 +647,19 @@ namespace { auto ctrlVar1 = writer.declConstant< sdw::Int >( "ctrlVar1", 1_i ); auto ctrlVar2 = writer.declConstant< sdw::Int >( "ctrlVar2", 0_i ); - IF( writer, ctrlVar1 != 0_i ) + sdwIF( writer, ctrlVar1 != 0_i ) { auto i = writer.declLocale< sdw::Int >( "i", 24_i ); } - ELSEIF( ctrlVar2 != 0_i ) + sdwELSEIF( ctrlVar2 != 0_i ) { auto j = writer.declLocale< sdw::Int >( "j", 12_i ); } - ELSE + sdwELSE { auto k = writer.declLocale< sdw::Int >( "k", 6_i ); } - FI; + sdwFI; } ); test::writeShader( writer , testCounts, CurrentCompilers ); @@ -680,19 +680,19 @@ namespace { auto ctrlVar1 = writer.declConstant< sdw::Int >( "ctrlVar1", 1_i ); auto ctrlVar2 = writer.declConstant< sdw::Int >( "ctrlVar2", 0_i ); - IF( writer, ctrlVar1 == 0_i ) + sdwIF( writer, ctrlVar1 == 0_i ) { auto i = writer.declLocale< sdw::Int >( "i", 24_i ); } - ELSEIF( ctrlVar2 == 0_i ) + sdwELSEIF( ctrlVar2 == 0_i ) { auto j = writer.declLocale< sdw::Int >( "j", 12_i ); } - ELSE + sdwELSE { auto k = writer.declLocale< sdw::Int >( "k", 6_i ); } - FI; + sdwFI; } ); test::writeShader( writer , testCounts, CurrentCompilers ); @@ -713,19 +713,19 @@ namespace { auto ctrlVar1 = writer.declConstant< sdw::Int >( "ctrlVar1", 1_i ); auto ctrlVar2 = writer.declConstant< sdw::Int >( "ctrlVar2", 0_i ); - IF( writer, ctrlVar1 == 0_i ) + sdwIF( writer, ctrlVar1 == 0_i ) { auto i = writer.declLocale< sdw::Int >( "i", 24_i ); } - ELSEIF( ctrlVar2 != 0_i ) + sdwELSEIF( ctrlVar2 != 0_i ) { auto j = writer.declLocale< sdw::Int >( "j", 12_i ); } - ELSE + sdwELSE { auto k = writer.declLocale< sdw::Int >( "k", 6_i ); } - FI; + sdwFI; } ); test::writeShader( writer , testCounts, CurrentCompilers ); @@ -745,25 +745,25 @@ namespace writer.implementMain( 32u, [&]( sdw::ComputeIn in ) { auto ctrl = writer.declConstant< sdw::Int >( "ctrl", 0_i ); - SWITCH( writer, ctrl ) + sdwSWITCH( writer, ctrl ) { - CASE( 0 ) + sdwCASE( 0 ) { auto i = writer.declLocale< sdw::Int >( "i", 24_i ); } - ESAC; - CASE( 1 ) + sdwESAC; + sdwCASE( 1 ) { auto j = writer.declLocale< sdw::Int >( "j", 12_i ); } - ESAC; - DEFAULT + sdwESAC; + sdwDEFAULT { auto k = writer.declLocale< sdw::Int >( "k", 6_i ); } - TLUAFED; + sdwTLUAFED; } - HCTIWS; + sdwHCTIWS; } ); test::writeShader( writer , testCounts, CurrentCompilers ); @@ -783,25 +783,25 @@ namespace writer.implementMain( 32u, [&]( sdw::ComputeIn in ) { auto ctrl = writer.declConstant< sdw::Int >( "ctrl", 1_i ); - SWITCH( writer, ctrl ) + sdwSWITCH( writer, ctrl ) { - CASE( 0 ) + sdwCASE( 0 ) { auto i = writer.declLocale< sdw::Int >( "i", 24_i ); } - ESAC; - CASE( 1 ) + sdwESAC; + sdwCASE( 1 ) { auto j = writer.declLocale< sdw::Int >( "j", 12_i ); } - ESAC; - DEFAULT + sdwESAC; + sdwDEFAULT { auto k = writer.declLocale< sdw::Int >( "k", 6_i ); } - TLUAFED; + sdwTLUAFED; } - HCTIWS; + sdwHCTIWS; } ); test::writeShader( writer , testCounts, CurrentCompilers ); @@ -821,25 +821,25 @@ namespace writer.implementMain( 32u, [&]( sdw::ComputeIn in ) { auto ctrl = writer.declConstant< sdw::Int >( "ctrl", 2_i ); - SWITCH( writer, ctrl ) + sdwSWITCH( writer, ctrl ) { - CASE( 0 ) + sdwCASE( 0 ) { auto i = writer.declLocale< sdw::Int >( "i", 24_i ); } - ESAC; - CASE( 1 ) + sdwESAC; + sdwCASE( 1 ) { auto j = writer.declLocale< sdw::Int >( "j", 12_i ); } - ESAC; - DEFAULT + sdwESAC; + sdwDEFAULT { auto k = writer.declLocale< sdw::Int >( "k", 6_i ); } - TLUAFED; + sdwTLUAFED; } - HCTIWS; + sdwHCTIWS; } ); test::writeShader( writer , testCounts, CurrentCompilers ); diff --git a/test/ShaderWriter/TestWriterFragmentShader.cpp b/test/ShaderWriter/TestWriterFragmentShader.cpp index 34b9da87..3b603939 100644 --- a/test/ShaderWriter/TestWriterFragmentShader.cpp +++ b/test/ShaderWriter/TestWriterFragmentShader.cpp @@ -588,9 +588,9 @@ namespace auto nrSamples = writer.declLocale( "nrSamples" , 0_i ); - FOR( writer, Float, phi, 0.0_f, phi < 6.283185482025146484375_f, phi += sampleDelta ) + sdwFOR( writer, Float, phi, 0.0_f, phi < 6.283185482025146484375_f, phi += sampleDelta ) { - FOR( writer, Float, theta, 0.0_f, theta < 1.57079637050628662109375_f, theta += sampleDelta ) + sdwFOR( writer, Float, theta, 0.0_f, theta < 1.57079637050628662109375_f, theta += sampleDelta ) { // spherical to cartesian (in tangent space) auto tangentSample = writer.declLocale( "tangentSample" @@ -602,9 +602,9 @@ namespace irradiance += c3d_mapEnvironment.sample( sampleVec ).rgb() * cos( theta ) * sin( theta ); nrSamples = nrSamples + 1; } - ROF; + sdwROF; } - ROF; + sdwROF; irradiance = irradiance * 3.1415927410125732421875_f *( 1.0_f / writer.cast< Float >( nrSamples ) ); out.colour = vec4( irradiance, 1.0_f ); @@ -707,21 +707,21 @@ namespace , vec4( 1.0_f, 1.0_f, 2.0_f, 1.0_f ) ); auto sv = s.getMemberArray< Vec4 >( "v" ); - IF( writer, cond != 0_i ) + sdwIF( writer, cond != 0_i ) { color = color1 + sv[2]; } - ELSE + sdwELSE { color = sqrt( color2 ) * scale; } - FI; + sdwFI; - FOR( writer, Int, i, 0_i, i < 4_i, ++i ) + sdwFOR( writer, Int, i, 0_i, i < 4_i, ++i ) { color *= multiplier; } - ROF; + sdwROF; } ); test::writeShader( writer @@ -740,11 +740,11 @@ namespace writer.implementMainT< PositionT, ColourT >( [&]( FragmentInT< PositionT > in , FragmentOutT< ColourT > out ) { - IF( writer, offpos.x() > 0.0_f ) + sdwIF( writer, offpos.x() > 0.0_f ) { writer.terminate(); } - FI; + sdwFI; out.colour = vec4( in.position, 1.0_f ); } ); @@ -764,11 +764,11 @@ namespace writer.implementMainT< PositionT, ColourT >( [&]( FragmentInT< PositionT > in , FragmentOutT< ColourT > out ) { - IF( writer, offpos.x() > 0.0_f ) + sdwIF( writer, offpos.x() > 0.0_f ) { writer.demote(); } - FI; + sdwFI; out.colour = vec4( in.position, 1.0_f ); } ); diff --git a/test/ShaderWriter/TestWriterFunction.cpp b/test/ShaderWriter/TestWriterFunction.cpp index 55cf0dd2..77d0b056 100644 --- a/test/ShaderWriter/TestWriterFunction.cpp +++ b/test/ShaderWriter/TestWriterFunction.cpp @@ -1247,11 +1247,11 @@ namespace , [&]( St const & m , Vec4 const & p ) { - FOR( writer, UInt, i, 0_u, i < 4_u, ++i ) + sdwFOR( writer, UInt, i, 0_u, i < 4_u, ++i ) { m.b[i] *= p; } - ROF; + sdwROF; writer.returnStmt( m.a * p ); } , InSt{ writer, "m" } @@ -1362,11 +1362,11 @@ namespace , [&]( St const & str , Vec4 const & pos ) { - FOR( writer, UInt, i, 0_u, i < 4_u, ++i ) + sdwFOR( writer, UInt, i, 0_u, i < 4_u, ++i ) { str.b[i] *= pos; } - ROF; + sdwROF; writer.returnStmt( str.a * pos ); } , InSt{ writer, "str" } @@ -1651,11 +1651,11 @@ namespace , [&]( Float test , Float const & end ) { - WHILE( writer, test > end ) + sdwWHILE( writer, test > end ) { test -= end; } - ELIHW; + sdwELIHW; writer.returnStmt( test ); } @@ -1696,11 +1696,11 @@ namespace , Float ptest , Float const & pend ) { - WHILE( writer, ptest > pend ) + sdwWHILE( writer, ptest > pend ) { ptest = foo01( pst.a.x(), pend ); } - ELIHW; + sdwELIHW; writer.returnStmt( pst.a.x() ); } @@ -1731,11 +1731,11 @@ namespace , [&]( Float const & gamma , Vec3 const & srgb ) { - IF( writer, gamma < 0.0_f ) + sdwIF( writer, gamma < 0.0_f ) { writer.returnStmt( srgb ); } - FI; + sdwFI; writer.returnStmt( pow( srgb, vec3( gamma ) ) ); } @@ -1787,15 +1787,15 @@ namespace auto foo03 = writer.implementFunction< Float >( "foo03" , [&]( Vec4 const & p ) { - IF( writer, p.x() ) + sdwIF( writer, p.x() ) { writer.returnStmt( p.y() ); } - ELSE + sdwELSE { writer.returnStmt( p.z() ); } - FI; + sdwFI; } , InVec4{ writer, "p" } ); @@ -1830,13 +1830,13 @@ namespace auto t = writer.declLocale( "t" , vec3( 0.5_f, 1.2_f, 1.0_f ) ); - WHILE( writer, coord.z() < 15.0_f && coord.w() > 0.9_f ) + sdwWHILE( writer, coord.z() < 15.0_f && coord.w() > 0.9_f ) { coord.xyz() = fma( t, vec3( dir, 1.0_f ), coord.xyz() ); e = normalize( coord.xy() ); coord.w() = dot( e, vec2( 0.5_f, 0.5_f ) ); } - ELIHW; + sdwELIHW; writer.returnStmt( coord.zw() ); } @@ -1870,15 +1870,15 @@ namespace auto bgColour = writer.declLocale( "bgColour", colour ); auto result = writer.declLocale( "result", colour ); - IF( writer, type == 0_u ) + sdwIF( writer, type == 0_u ) { result = vec4( mix( bgColour, colour, vec4( factor ) ).rgb(), colour.a() ); } - ELSEIF( type == 1_u ) + sdwELSEIF( type == 1_u ) { result = vec4( mix( bgColour, colour, vec4( factor ) ).rgb(), colour.a() ); } - FI; + sdwFI; writer.returnStmt( result ); } @@ -1911,11 +1911,11 @@ namespace , [&]( Float const & gamma , Vec3 const & srgb ) { - IF( writer, gamma < 0.0_f ) + sdwIF( writer, gamma < 0.0_f ) { writer.returnStmt( srgb ); } - FI; + sdwFI; writer.returnStmt( pow( srgb, vec3( gamma ) ) ); } diff --git a/test/ShaderWriter/TestWriterIncrement.cpp b/test/ShaderWriter/TestWriterIncrement.cpp index a2be2cb6..31da6e01 100644 --- a/test/ShaderWriter/TestWriterIncrement.cpp +++ b/test/ShaderWriter/TestWriterIncrement.cpp @@ -109,11 +109,11 @@ namespace writer.implementMainT< VoidT >( 16u, [&]( ComputeIn in ) { auto i = writer.declLocale( "i", 0_u ); - IF( writer, ++i ) + sdwIF( writer, ++i ) { auto j = writer.declLocale( "j", i ); } - FI; + sdwFI; astCheckEqual( writer.getBuilder().getContainer()->size(), 2u ); } ); test::writeShader( writer @@ -163,11 +163,11 @@ namespace writer.implementMainT< VoidT >( 16u, [&]( ComputeIn in ) { - FOR( writer, Int, i, 0_i, i < 12_i, ++i ) + sdwFOR( writer, Int, i, 0_i, i < 12_i, ++i ) { auto j = writer.declLocale( "j", i ); } - ROF; + sdwROF; astCheckEqual( writer.getBuilder().getContainer()->size(), 1u ); astBeginRequire( writer.getBuilder().getContainer()->back()->getKind() == stmt::Kind::eCompound ); astCheckEqual( static_cast< stmt::Container const & >( *writer.getBuilder().getContainer()->back() ).size(), 1u ); diff --git a/test/ShaderWriter/TestWriterMeshShaderEXT.cpp b/test/ShaderWriter/TestWriterMeshShaderEXT.cpp index 57c6fb56..a309fb72 100644 --- a/test/ShaderWriter/TestWriterMeshShaderEXT.cpp +++ b/test/ShaderWriter/TestWriterMeshShaderEXT.cpp @@ -1072,11 +1072,11 @@ namespace { localIndex = m.vertOffset + localIndex; - IF( writer, meshInfo.indexBytes == 4_u ) // 32-bit Vertex Indices + sdwIF( writer, meshInfo.indexBytes == 4_u ) // 32-bit Vertex Indices { writer.returnStmt( uniqueVertexIndices[localIndex].index ); } - ELSE // 16-bit Vertex Indices + sdwELSE // 16-bit Vertex Indices { // Byte address must be 4-byte aligned. auto wordOffset = writer.declLocale( "wordOffset", ( localIndex & 0x1_u ) ); @@ -1088,7 +1088,7 @@ namespace writer.returnStmt( index ); } - FI; + sdwFI; } , InParam< Meshlet >{ writer, "m" } , InUInt{ writer, "localIndex" } ); @@ -1125,13 +1125,13 @@ namespace primOut.setMeshOutputCounts( m.vertCount, m.primCount ); - IF( writer, gtid < m.primCount ) + sdwIF( writer, gtid < m.primCount ) { primOut[gtid].primitiveIndex = getPrimitive( m, gtid ); } - FI; + sdwFI; - IF( writer, gtid < m.vertCount ) + sdwIF( writer, gtid < m.vertCount ) { auto vertexIndex = writer.declLocale( "vertexIndex", getVertexIndex( m, gtid ) ); auto vertex = writer.declLocale( "vertex", getVertexAttributes( gtid, vertexIndex ) ); @@ -1140,7 +1140,7 @@ namespace vtxOut[gtid].normal = vertex.normal; vtxOut[gtid].meshletIndex = vertex.meshletIndex; } - FI; + sdwFI; } ); test::expectError( "Invalid capability operand: 5" , testCounts ); @@ -1193,11 +1193,11 @@ namespace { localIndex = m.vertOffset + localIndex; - IF( writer, meshInfos.indexBytes == 4_u ) // 32-bit Vertex Indices + sdwIF( writer, meshInfos.indexBytes == 4_u ) // 32-bit Vertex Indices { writer.returnStmt( uniqueVertexIndices[localIndex].index ); } - ELSE // 16-bit Vertex Indices + sdwELSE // 16-bit Vertex Indices { // Byte address must be 4-byte aligned. auto wordOffset = writer.declLocale( "wordOffset", ( localIndex & 0x1_u ) ); @@ -1209,7 +1209,7 @@ namespace writer.returnStmt( index ); } - FI; + sdwFI; } , InParam< Meshlet >{ writer, "m" } , InUInt{ writer, "localIndex" } ); @@ -1258,7 +1258,7 @@ namespace auto instanceCount = writer.declLocale( "instanceCount", 1_u ); // Last meshlet in mesh may be be packed - multiple instances submitted by a single threadgroup. - IF( writer, meshletIndex == meshInfos.meshletCount - 1_u ) + sdwIF( writer, meshletIndex == meshInfos.meshletCount - 1_u ) { auto instancesPerGroup = writer.declLocale( "instancesPerGroup", min( MaxVerts / m.vertCount, MaxPrims / m.primCount ) ); @@ -1269,7 +1269,7 @@ namespace startInstance = packedIndex * instancesPerGroup; instanceCount = min( drawParams.instanceCount - startInstance, instancesPerGroup ); } - FI; + sdwFI; // Compute our total vertex & primitive counts auto vertCount = writer.declLocale( "vertCount", m.vertCount * instanceCount ); @@ -1277,7 +1277,7 @@ namespace primOut.setMeshOutputCounts( vertCount, primCount ); - IF( writer, gtid < vertCount ) + sdwIF( writer, gtid < vertCount ) { auto readIndex = writer.declLocale( "readIndex", gtid % m.vertCount ); // Wrap our reads for packed instancing. auto instanceId = writer.declLocale( "instanceId", gtid / m.vertCount ); // Instance index into this threadgroup's instances (only non-zero for packed threadgroups.) @@ -1291,9 +1291,9 @@ namespace vtxOut[gtid].normal = vertex.normal; vtxOut[gtid].meshletIndex = vertex.meshletIndex; } - FI; + sdwFI; - IF( writer, gtid < primCount ) + sdwIF( writer, gtid < primCount ) { auto readIndex = writer.declLocale( "readIndex", gtid % m.primCount ); // Wrap our reads for packed instancing. auto instanceId = writer.declLocale( "instanceId", gtid / m.primCount ); // Instance index within this threadgroup (only non-zero in last meshlet threadgroups.) @@ -1301,7 +1301,7 @@ namespace // Must offset the vertex indices to this thread's instanced verts primOut[gtid].primitiveIndex = getPrimitive( m, readIndex ) + ( m.vertCount * instanceId ); } - FI; + sdwFI; } ); test::expectError( "Invalid capability operand: 5" , testCounts ); @@ -1385,11 +1385,11 @@ namespace { localIndex = m.vertOffset + localIndex; - IF( writer, meshInfos.indexSize == 4_u ) // 32-bit Vertex Indices + sdwIF( writer, meshInfos.indexSize == 4_u ) // 32-bit Vertex Indices { writer.returnStmt( uniqueVertexIndices[localIndex].index ); } - ELSE // 16-bit Vertex Indices + sdwELSE // 16-bit Vertex Indices { // Byte address must be 4-byte aligned. auto wordOffset = writer.declLocale( "wordOffset", ( localIndex & 0x1_u ) ); @@ -1401,7 +1401,7 @@ namespace writer.returnStmt( index ); } - FI; + sdwFI; } , InParam< Meshlet >{ writer, "m" } , InUInt{ writer, "localIndex" } ); @@ -1444,11 +1444,11 @@ namespace auto meshletIndex = writer.declLocale( "meshletIndex", payload.meshletIndices[gid] ); // Catch any out-of-range indices (in case too many MS threadgroups were dispatched from AS) - IF( writer, meshletIndex >= meshInfos.meshletCount ) + sdwIF( writer, meshletIndex >= meshInfos.meshletCount ) { writer.returnStmt(); } - FI; + sdwFI; // Load the meshlet auto m = writer.declLocale( "m", meshlets[meshletIndex] ); @@ -1459,7 +1459,7 @@ namespace //-------------------------------------------------------------------- // Export Primitive & Vertex Data - IF( writer, gtid < m.vertCount ) + sdwIF( writer, gtid < m.vertCount ) { auto vertexIndex = writer.declLocale( "vertexIndex", getVertexIndex( m, gtid ) ); auto vertex = writer.declLocale( "vertex", getVertexAttributes( meshletIndex, vertexIndex ) ); @@ -1468,13 +1468,13 @@ namespace vtxOut[gtid].normal = vertex.normal; vtxOut[gtid].meshletIndex = vertex.meshletIndex; } - FI; + sdwFI; - IF( writer, gtid < m.primCount ) + sdwIF( writer, gtid < m.primCount ) { primOut[gtid].primitiveIndex = getPrimitive( m, gtid ); } - FI; + sdwFI; } ); test::expectError( "Invalid capability operand: 5" , testCounts ); @@ -1517,11 +1517,11 @@ namespace { localIndex = m.vertOffset + localIndex; - IF( writer, meshInfos.indexSize == 4_u ) // 32-bit Vertex Indices + sdwIF( writer, meshInfos.indexSize == 4_u ) // 32-bit Vertex Indices { writer.returnStmt( uniqueVertexIndices[localIndex].index ); } - ELSE // 16-bit Vertex Indices + sdwELSE // 16-bit Vertex Indices { // Byte address must be 4-byte aligned. auto wordOffset = writer.declLocale( "wordOffset", ( localIndex & 0x1_u ) ); @@ -1533,7 +1533,7 @@ namespace writer.returnStmt( index ); } - FI; + sdwFI; } , InParam< Meshlet >{ writer, "m" } , InUInt{ writer, "localIndex" } ); @@ -1576,11 +1576,11 @@ namespace auto meshletIndex = writer.declLocale( "meshletIndex", payload.meshletIndices[gid] ); // Catch any out-of-range indices (in case too many MS threadgroups were dispatched from AS) - IF( writer, meshletIndex >= meshInfos.meshletCount ) + sdwIF( writer, meshletIndex >= meshInfos.meshletCount ) { writer.returnStmt(); } - FI; + sdwFI; // Load the meshlet auto m = writer.declLocale( "m", meshlets[meshletIndex] ); @@ -1591,7 +1591,7 @@ namespace //-------------------------------------------------------------------- // Export Primitive & Vertex Data - IF( writer, gtid < m.vertCount ) + sdwIF( writer, gtid < m.vertCount ) { auto vertexIndex = writer.declLocale( "vertexIndex", getVertexIndex( m, gtid ) ); auto vertex = writer.declLocale( "vertex", getVertexAttributes( meshletIndex, vertexIndex ) ); @@ -1600,14 +1600,14 @@ namespace vtxOut[gtid].normal = vertex.normal; vtxOut[gtid].meshletIndex = vertex.meshletIndex; } - FI; + sdwFI; - IF( writer, gtid < m.primCount ) + sdwIF( writer, gtid < m.primCount ) { auto primIndices = writer.declLocale( "primIndices", primitiveIndices[m.primOffset + gtid].index ); primOut[gtid].primitiveIndex = uvec3( primIndices ); } - FI; + sdwFI; } ); test::expectError( "Invalid capability operand: 5" , testCounts ); diff --git a/test/ShaderWriter/TestWriterMeshShaderNV.cpp b/test/ShaderWriter/TestWriterMeshShaderNV.cpp index 0ea73523..523f6160 100644 --- a/test/ShaderWriter/TestWriterMeshShaderNV.cpp +++ b/test/ShaderWriter/TestWriterMeshShaderNV.cpp @@ -1034,11 +1034,11 @@ namespace { localIndex = m.vertOffset + localIndex; - IF( writer, meshInfo.indexBytes == 4_u ) // 32-bit Vertex Indices + sdwIF( writer, meshInfo.indexBytes == 4_u ) // 32-bit Vertex Indices { writer.returnStmt( uniqueVertexIndices[localIndex].index ); } - ELSE // 16-bit Vertex Indices + sdwELSE // 16-bit Vertex Indices { // Byte address must be 4-byte aligned. auto wordOffset = writer.declLocale( "wordOffset", ( localIndex & 0x1_u ) ); @@ -1050,7 +1050,7 @@ namespace writer.returnStmt( index ); } - FI; + sdwFI; } , InParam< Meshlet >{ writer, "m" } , InUInt{ writer, "localIndex" } ); @@ -1087,13 +1087,13 @@ namespace primOut.setMeshOutputCounts( m.vertCount, m.primCount ); - IF( writer, gtid < m.primCount ) + sdwIF( writer, gtid < m.primCount ) { primOut[gtid].primitiveIndex = getPrimitive( m, gtid ); } - FI; + sdwFI; - IF( writer, gtid < m.vertCount ) + sdwIF( writer, gtid < m.vertCount ) { auto vertexIndex = writer.declLocale( "vertexIndex", getVertexIndex( m, gtid ) ); auto vertex = writer.declLocale( "vertex", getVertexAttributes( gtid, vertexIndex ) ); @@ -1102,7 +1102,7 @@ namespace vtxOut[gtid].normal = vertex.normal; vtxOut[gtid].meshletIndex = vertex.meshletIndex; } - FI; + sdwFI; } ); test::writeShader( writer , testCounts @@ -1162,11 +1162,11 @@ namespace { localIndex = m.vertOffset + localIndex; - IF( writer, meshInfos.indexBytes == 4_u ) // 32-bit Vertex Indices + sdwIF( writer, meshInfos.indexBytes == 4_u ) // 32-bit Vertex Indices { writer.returnStmt( uniqueVertexIndices[localIndex].index ); } - ELSE // 16-bit Vertex Indices + sdwELSE // 16-bit Vertex Indices { // Byte address must be 4-byte aligned. auto wordOffset = writer.declLocale( "wordOffset", ( localIndex & 0x1_u ) ); @@ -1178,7 +1178,7 @@ namespace writer.returnStmt( index ); } - FI; + sdwFI; } , InParam< Meshlet >{ writer, "m" } , InUInt{ writer, "localIndex" } ); @@ -1227,7 +1227,7 @@ namespace auto instanceCount = writer.declLocale( "instanceCount", 1_u ); // Last meshlet in mesh may be be packed - multiple instances submitted by a single threadgroup. - IF( writer, meshletIndex == meshInfos.meshletCount - 1_u ) + sdwIF( writer, meshletIndex == meshInfos.meshletCount - 1_u ) { auto instancesPerGroup = writer.declLocale( "instancesPerGroup", min( MaxVerts / m.vertCount, MaxPrims / m.primCount ) ); @@ -1238,7 +1238,7 @@ namespace startInstance = packedIndex * instancesPerGroup; instanceCount = min( drawParams.instanceCount - startInstance, instancesPerGroup ); } - FI; + sdwFI; // Compute our total vertex & primitive counts auto vertCount = writer.declLocale( "vertCount", m.vertCount * instanceCount ); @@ -1246,7 +1246,7 @@ namespace primOut.setMeshOutputCounts( vertCount, primCount ); - IF( writer, gtid < vertCount ) + sdwIF( writer, gtid < vertCount ) { auto readIndex = writer.declLocale( "readIndex", gtid % m.vertCount ); // Wrap our reads for packed instancing. auto instanceId = writer.declLocale( "instanceId", gtid / m.vertCount ); // Instance index into this threadgroup's instances (only non-zero for packed threadgroups.) @@ -1260,9 +1260,9 @@ namespace vtxOut[gtid].normal = vertex.normal; vtxOut[gtid].meshletIndex = vertex.meshletIndex; } - FI; + sdwFI; - IF( writer, gtid < primCount ) + sdwIF( writer, gtid < primCount ) { auto readIndex = writer.declLocale( "readIndex", gtid % m.primCount ); // Wrap our reads for packed instancing. auto instanceId = writer.declLocale( "instanceId", gtid / m.primCount ); // Instance index within this threadgroup (only non-zero in last meshlet threadgroups.) @@ -1270,7 +1270,7 @@ namespace // Must offset the vertex indices to this thread's instanced verts primOut[gtid].primitiveIndex = getPrimitive( m, readIndex ) + ( m.vertCount * instanceId ); } - FI; + sdwFI; } ); test::writeShader( writer , testCounts @@ -1359,11 +1359,11 @@ namespace { localIndex = m.vertOffset + localIndex; - IF( writer, meshInfos.indexSize == 4_u ) // 32-bit Vertex Indices + sdwIF( writer, meshInfos.indexSize == 4_u ) // 32-bit Vertex Indices { writer.returnStmt( uniqueVertexIndices[localIndex].index ); } - ELSE // 16-bit Vertex Indices + sdwELSE // 16-bit Vertex Indices { // Byte address must be 4-byte aligned. auto wordOffset = writer.declLocale( "wordOffset", ( localIndex & 0x1_u ) ); @@ -1375,7 +1375,7 @@ namespace writer.returnStmt( index ); } - FI; + sdwFI; } , InParam< Meshlet >{ writer, "m" } , InUInt{ writer, "localIndex" } ); @@ -1418,11 +1418,11 @@ namespace auto meshletIndex = writer.declLocale( "meshletIndex", payload.meshletIndices[gid] ); // Catch any out-of-range indices (in case too many MS threadgroups were dispatched from AS) - IF( writer, meshletIndex >= meshInfos.meshletCount ) + sdwIF( writer, meshletIndex >= meshInfos.meshletCount ) { writer.returnStmt(); } - FI; + sdwFI; // Load the meshlet auto m = writer.declLocale( "m", meshlets[meshletIndex] ); @@ -1433,7 +1433,7 @@ namespace //-------------------------------------------------------------------- // Export Primitive & Vertex Data - IF( writer, gtid < m.vertCount ) + sdwIF( writer, gtid < m.vertCount ) { auto vertexIndex = writer.declLocale( "vertexIndex", getVertexIndex( m, gtid ) ); auto vertex = writer.declLocale( "vertex", getVertexAttributes( meshletIndex, vertexIndex ) ); @@ -1442,13 +1442,13 @@ namespace vtxOut[gtid].normal = vertex.normal; vtxOut[gtid].meshletIndex = vertex.meshletIndex; } - FI; + sdwFI; - IF( writer, gtid < m.primCount ) + sdwIF( writer, gtid < m.primCount ) { primOut[gtid].primitiveIndex = getPrimitive( m, gtid ); } - FI; + sdwFI; } ); test::writeShader( writer , testCounts @@ -1489,11 +1489,11 @@ namespace { localIndex = m.vertOffset + localIndex; - IF( writer, meshInfos.indexSize == 4_u ) // 32-bit Vertex Indices + sdwIF( writer, meshInfos.indexSize == 4_u ) // 32-bit Vertex Indices { writer.returnStmt( uniqueVertexIndices[localIndex].index ); } - ELSE // 16-bit Vertex Indices + sdwELSE // 16-bit Vertex Indices { // Byte address must be 4-byte aligned. auto wordOffset = writer.declLocale( "wordOffset", ( localIndex & 0x1_u ) ); @@ -1505,7 +1505,7 @@ namespace writer.returnStmt( index ); } - FI; + sdwFI; } , InParam< Meshlet >{ writer, "m" } , InUInt{ writer, "localIndex" } ); @@ -1548,11 +1548,11 @@ namespace auto meshletIndex = writer.declLocale( "meshletIndex", payload.meshletIndices[gid] ); // Catch any out-of-range indices (in case too many MS threadgroups were dispatched from AS) - IF( writer, meshletIndex >= meshInfos.meshletCount ) + sdwIF( writer, meshletIndex >= meshInfos.meshletCount ) { writer.returnStmt(); } - FI; + sdwFI; // Load the meshlet auto m = writer.declLocale( "m", meshlets[meshletIndex] ); @@ -1563,7 +1563,7 @@ namespace //-------------------------------------------------------------------- // Export Primitive & Vertex Data - IF( writer, gtid < m.vertCount ) + sdwIF( writer, gtid < m.vertCount ) { auto vertexIndex = writer.declLocale( "vertexIndex", getVertexIndex( m, gtid ) ); auto vertex = writer.declLocale( "vertex", getVertexAttributes( meshletIndex, vertexIndex ) ); @@ -1572,13 +1572,13 @@ namespace vtxOut[gtid].normal = vertex.normal; vtxOut[gtid].meshletIndex = vertex.meshletIndex; } - FI; + sdwFI; - IF( writer, gtid < m.primCount ) + sdwIF( writer, gtid < m.primCount ) { writePackedPrimitiveIndices4x8NV( gtid, primitiveIndices[m.primOffset + gtid].index ); } - FI; + sdwFI; } ); test::writeShader( writer , testCounts diff --git a/test/ShaderWriter/TestWriterMeshShader_EXT.cpp b/test/ShaderWriter/TestWriterMeshShader_EXT.cpp index e38b85bd..0a0f2196 100644 --- a/test/ShaderWriter/TestWriterMeshShader_EXT.cpp +++ b/test/ShaderWriter/TestWriterMeshShader_EXT.cpp @@ -1076,11 +1076,11 @@ namespace { localIndex = m.vertOffset + localIndex; - IF( writer, meshInfo.indexBytes == 4_u ) // 32-bit Vertex Indices + sdwIF( writer, meshInfo.indexBytes == 4_u ) // 32-bit Vertex Indices { writer.returnStmt( uniqueVertexIndices[localIndex].index ); } - ELSE // 16-bit Vertex Indices + sdwELSE // 16-bit Vertex Indices { // Byte address must be 4-byte aligned. auto wordOffset = writer.declLocale( "wordOffset", ( localIndex & 0x1_u ) ); @@ -1092,7 +1092,7 @@ namespace writer.returnStmt( index ); } - FI; + sdwFI; } , InParam< Meshlet >{ writer, "m" } , InUInt{ writer, "localIndex" } ); @@ -1129,14 +1129,14 @@ namespace primOut.setMeshOutputCounts( m.vertCount, m.primCount ); - IF( writer, gtid < m.primCount ) + sdwIF( writer, gtid < m.primCount ) { primOut[gtid].primitiveIndex = getPrimitive( m, gtid ); primOut[gtid].primitiveID = gtid; } - FI; + sdwFI; - IF( writer, gtid < m.vertCount ) + sdwIF( writer, gtid < m.vertCount ) { auto vertexIndex = writer.declLocale( "vertexIndex", getVertexIndex( m, gtid ) ); auto vertex = writer.declLocale( "vertex", getVertexAttributes( gtid, vertexIndex ) ); @@ -1145,7 +1145,7 @@ namespace vtxOut[gtid].normal = vertex.normal; vtxOut[gtid].meshletIndex = vertex.meshletIndex; } - FI; + sdwFI; } ); test::expectError( "Invalid capability operand: 5" , testCounts ); @@ -1198,11 +1198,11 @@ namespace { localIndex = m.vertOffset + localIndex; - IF( writer, meshInfos.indexBytes == 4_u ) // 32-bit Vertex Indices + sdwIF( writer, meshInfos.indexBytes == 4_u ) // 32-bit Vertex Indices { writer.returnStmt( uniqueVertexIndices[localIndex].index ); } - ELSE // 16-bit Vertex Indices + sdwELSE // 16-bit Vertex Indices { // Byte address must be 4-byte aligned. auto wordOffset = writer.declLocale( "wordOffset", ( localIndex & 0x1_u ) ); @@ -1214,7 +1214,7 @@ namespace writer.returnStmt( index ); } - FI; + sdwFI; } , InParam< Meshlet >{ writer, "m" } , InUInt{ writer, "localIndex" } ); @@ -1263,7 +1263,7 @@ namespace auto instanceCount = writer.declLocale( "instanceCount", 1_u ); // Last meshlet in mesh may be be packed - multiple instances submitted by a single threadgroup. - IF( writer, meshletIndex == meshInfos.meshletCount - 1_u ) + sdwIF( writer, meshletIndex == meshInfos.meshletCount - 1_u ) { auto instancesPerGroup = writer.declLocale( "instancesPerGroup", min( MaxVerts / m.vertCount, MaxPrims / m.primCount ) ); @@ -1274,7 +1274,7 @@ namespace startInstance = packedIndex * instancesPerGroup; instanceCount = min( drawParams.instanceCount - startInstance, instancesPerGroup ); } - FI; + sdwFI; // Compute our total vertex & primitive counts auto vertCount = writer.declLocale( "vertCount", m.vertCount * instanceCount ); @@ -1282,7 +1282,7 @@ namespace primOut.setMeshOutputCounts( vertCount, primCount ); - IF( writer, gtid < vertCount ) + sdwIF( writer, gtid < vertCount ) { auto readIndex = writer.declLocale( "readIndex", gtid % m.vertCount ); // Wrap our reads for packed instancing. auto instanceId = writer.declLocale( "instanceId", gtid / m.vertCount ); // Instance index into this threadgroup's instances (only non-zero for packed threadgroups.) @@ -1296,9 +1296,9 @@ namespace vtxOut[gtid].normal = vertex.normal; vtxOut[gtid].meshletIndex = vertex.meshletIndex; } - FI; + sdwFI; - IF( writer, gtid < primCount ) + sdwIF( writer, gtid < primCount ) { auto readIndex = writer.declLocale( "readIndex", gtid % m.primCount ); // Wrap our reads for packed instancing. auto instanceId = writer.declLocale( "instanceId", gtid / m.primCount ); // Instance index within this threadgroup (only non-zero in last meshlet threadgroups.) @@ -1306,7 +1306,7 @@ namespace // Must offset the vertex indices to this thread's instanced verts primOut[gtid].primitiveIndex = getPrimitive( m, readIndex ) + ( m.vertCount * instanceId ); } - FI; + sdwFI; } ); test::expectError( "Invalid capability operand: 5" , testCounts ); @@ -1390,11 +1390,11 @@ namespace { localIndex = m.vertOffset + localIndex; - IF( writer, meshInfos.indexSize == 4_u ) // 32-bit Vertex Indices + sdwIF( writer, meshInfos.indexSize == 4_u ) // 32-bit Vertex Indices { writer.returnStmt( uniqueVertexIndices[localIndex].index ); } - ELSE // 16-bit Vertex Indices + sdwELSE // 16-bit Vertex Indices { // Byte address must be 4-byte aligned. auto wordOffset = writer.declLocale( "wordOffset", ( localIndex & 0x1_u ) ); @@ -1406,7 +1406,7 @@ namespace writer.returnStmt( index ); } - FI; + sdwFI; } , InParam< Meshlet >{ writer, "m" } , InUInt{ writer, "localIndex" } ); @@ -1449,11 +1449,11 @@ namespace auto meshletIndex = writer.declLocale( "meshletIndex", payload.meshletIndices[gid] ); // Catch any out-of-range indices (in case too many MS threadgroups were dispatched from AS) - IF( writer, meshletIndex >= meshInfos.meshletCount ) + sdwIF( writer, meshletIndex >= meshInfos.meshletCount ) { writer.returnStmt(); } - FI; + sdwFI; // Load the meshlet auto m = writer.declLocale( "m", meshlets[meshletIndex] ); @@ -1464,7 +1464,7 @@ namespace //-------------------------------------------------------------------- // Export Primitive & Vertex Data - IF( writer, gtid < m.vertCount ) + sdwIF( writer, gtid < m.vertCount ) { auto vertexIndex = writer.declLocale( "vertexIndex", getVertexIndex( m, gtid ) ); auto vertex = writer.declLocale( "vertex", getVertexAttributes( meshletIndex, vertexIndex ) ); @@ -1473,13 +1473,13 @@ namespace vtxOut[gtid].normal = vertex.normal; vtxOut[gtid].meshletIndex = vertex.meshletIndex; } - FI; + sdwFI; - IF( writer, gtid < m.primCount ) + sdwIF( writer, gtid < m.primCount ) { primOut[gtid].primitiveIndex = getPrimitive( m, gtid ); } - FI; + sdwFI; } ); test::expectError( "Invalid capability operand: 5" , testCounts ); @@ -1522,11 +1522,11 @@ namespace { localIndex = m.vertOffset + localIndex; - IF( writer, meshInfos.indexSize == 4_u ) // 32-bit Vertex Indices + sdwIF( writer, meshInfos.indexSize == 4_u ) // 32-bit Vertex Indices { writer.returnStmt( uniqueVertexIndices[localIndex].index ); } - ELSE // 16-bit Vertex Indices + sdwELSE // 16-bit Vertex Indices { // Byte address must be 4-byte aligned. auto wordOffset = writer.declLocale( "wordOffset", ( localIndex & 0x1_u ) ); @@ -1538,7 +1538,7 @@ namespace writer.returnStmt( index ); } - FI; + sdwFI; } , InParam< Meshlet >{ writer, "m" } , InUInt{ writer, "localIndex" } ); @@ -1581,11 +1581,11 @@ namespace auto meshletIndex = writer.declLocale( "meshletIndex", payload.meshletIndices[gid] ); // Catch any out-of-range indices (in case too many MS threadgroups were dispatched from AS) - IF( writer, meshletIndex >= meshInfos.meshletCount ) + sdwIF( writer, meshletIndex >= meshInfos.meshletCount ) { writer.returnStmt(); } - FI; + sdwFI; // Load the meshlet auto m = writer.declLocale( "m", meshlets[meshletIndex] ); @@ -1596,7 +1596,7 @@ namespace //-------------------------------------------------------------------- // Export Primitive & Vertex Data - IF( writer, gtid < m.vertCount ) + sdwIF( writer, gtid < m.vertCount ) { auto vertexIndex = writer.declLocale( "vertexIndex", getVertexIndex( m, gtid ) ); auto vertex = writer.declLocale( "vertex", getVertexAttributes( meshletIndex, vertexIndex ) ); @@ -1605,15 +1605,15 @@ namespace vtxOut[gtid].normal = vertex.normal; vtxOut[gtid].meshletIndex = vertex.meshletIndex; } - FI; + sdwFI; - IF( writer, gtid < m.primCount ) + sdwIF( writer, gtid < m.primCount ) { auto primIndices = writer.declLocale( "primIndices", primitiveIndices[m.primOffset + gtid].index ); primOut[gtid].primitiveIndex = uvec3( primIndices ); primOut[gtid].primitiveID = gtid; } - FI; + sdwFI; } ); test::expectError( "Invalid capability operand: 5" , testCounts ); diff --git a/test/ShaderWriter/TestWriterMeshShader_NV.cpp b/test/ShaderWriter/TestWriterMeshShader_NV.cpp index 4d17aca1..6874bb0c 100644 --- a/test/ShaderWriter/TestWriterMeshShader_NV.cpp +++ b/test/ShaderWriter/TestWriterMeshShader_NV.cpp @@ -1076,11 +1076,11 @@ namespace { localIndex = m.vertOffset + localIndex; - IF( writer, meshInfo.indexBytes == 4_u ) // 32-bit Vertex Indices + sdwIF( writer, meshInfo.indexBytes == 4_u ) // 32-bit Vertex Indices { writer.returnStmt( uniqueVertexIndices[localIndex].index ); } - ELSE // 16-bit Vertex Indices + sdwELSE // 16-bit Vertex Indices { // Byte address must be 4-byte aligned. auto wordOffset = writer.declLocale( "wordOffset", ( localIndex & 0x1_u ) ); @@ -1092,7 +1092,7 @@ namespace writer.returnStmt( index ); } - FI; + sdwFI; } , InParam< Meshlet >{ writer, "m" } , InUInt{ writer, "localIndex" } ); @@ -1129,13 +1129,13 @@ namespace primOut.setMeshOutputCounts( m.vertCount, m.primCount ); - IF( writer, gtid < m.primCount ) + sdwIF( writer, gtid < m.primCount ) { primOut[gtid].primitiveIndex = getPrimitive( m, gtid ); } - FI; + sdwFI; - IF( writer, gtid < m.vertCount ) + sdwIF( writer, gtid < m.vertCount ) { auto vertexIndex = writer.declLocale( "vertexIndex", getVertexIndex( m, gtid ) ); auto vertex = writer.declLocale( "vertex", getVertexAttributes( gtid, vertexIndex ) ); @@ -1144,7 +1144,7 @@ namespace vtxOut[gtid].normal = vertex.normal; vtxOut[gtid].meshletIndex = vertex.meshletIndex; } - FI; + sdwFI; } ); test::expectError( "Invalid capability operand: 5" , testCounts ); @@ -1197,11 +1197,11 @@ namespace { localIndex = m.vertOffset + localIndex; - IF( writer, meshInfos.indexBytes == 4_u ) // 32-bit Vertex Indices + sdwIF( writer, meshInfos.indexBytes == 4_u ) // 32-bit Vertex Indices { writer.returnStmt( uniqueVertexIndices[localIndex].index ); } - ELSE // 16-bit Vertex Indices + sdwELSE // 16-bit Vertex Indices { // Byte address must be 4-byte aligned. auto wordOffset = writer.declLocale( "wordOffset", ( localIndex & 0x1_u ) ); @@ -1213,7 +1213,7 @@ namespace writer.returnStmt( index ); } - FI; + sdwFI; } , InParam< Meshlet >{ writer, "m" } , InUInt{ writer, "localIndex" } ); @@ -1262,7 +1262,7 @@ namespace auto instanceCount = writer.declLocale( "instanceCount", 1_u ); // Last meshlet in mesh may be be packed - multiple instances submitted by a single threadgroup. - IF( writer, meshletIndex == meshInfos.meshletCount - 1_u ) + sdwIF( writer, meshletIndex == meshInfos.meshletCount - 1_u ) { auto instancesPerGroup = writer.declLocale( "instancesPerGroup", min( MaxVerts / m.vertCount, MaxPrims / m.primCount ) ); @@ -1273,7 +1273,7 @@ namespace startInstance = packedIndex * instancesPerGroup; instanceCount = min( drawParams.instanceCount - startInstance, instancesPerGroup ); } - FI; + sdwFI; // Compute our total vertex & primitive counts auto vertCount = writer.declLocale( "vertCount", m.vertCount * instanceCount ); @@ -1281,7 +1281,7 @@ namespace primOut.setMeshOutputCounts( vertCount, primCount ); - IF( writer, gtid < vertCount ) + sdwIF( writer, gtid < vertCount ) { auto readIndex = writer.declLocale( "readIndex", gtid % m.vertCount ); // Wrap our reads for packed instancing. auto instanceId = writer.declLocale( "instanceId", gtid / m.vertCount ); // Instance index into this threadgroup's instances (only non-zero for packed threadgroups.) @@ -1295,9 +1295,9 @@ namespace vtxOut[gtid].normal = vertex.normal; vtxOut[gtid].meshletIndex = vertex.meshletIndex; } - FI; + sdwFI; - IF( writer, gtid < primCount ) + sdwIF( writer, gtid < primCount ) { auto readIndex = writer.declLocale( "readIndex", gtid % m.primCount ); // Wrap our reads for packed instancing. auto instanceId = writer.declLocale( "instanceId", gtid / m.primCount ); // Instance index within this threadgroup (only non-zero in last meshlet threadgroups.) @@ -1305,7 +1305,7 @@ namespace // Must offset the vertex indices to this thread's instanced verts primOut[gtid].primitiveIndex = getPrimitive( m, readIndex ) + ( m.vertCount * instanceId ); } - FI; + sdwFI; } ); test::expectError( "Invalid capability operand: 5" , testCounts ); @@ -1389,11 +1389,11 @@ namespace { localIndex = m.vertOffset + localIndex; - IF( writer, meshInfos.indexSize == 4_u ) // 32-bit Vertex Indices + sdwIF( writer, meshInfos.indexSize == 4_u ) // 32-bit Vertex Indices { writer.returnStmt( uniqueVertexIndices[localIndex].index ); } - ELSE // 16-bit Vertex Indices + sdwELSE // 16-bit Vertex Indices { // Byte address must be 4-byte aligned. auto wordOffset = writer.declLocale( "wordOffset", ( localIndex & 0x1_u ) ); @@ -1405,7 +1405,7 @@ namespace writer.returnStmt( index ); } - FI; + sdwFI; } , InParam< Meshlet >{ writer, "m" } , InUInt{ writer, "localIndex" } ); @@ -1448,11 +1448,11 @@ namespace auto meshletIndex = writer.declLocale( "meshletIndex", payload.meshletIndices[gid] ); // Catch any out-of-range indices (in case too many MS threadgroups were dispatched from AS) - IF( writer, meshletIndex >= meshInfos.meshletCount ) + sdwIF( writer, meshletIndex >= meshInfos.meshletCount ) { writer.returnStmt(); } - FI; + sdwFI; // Load the meshlet auto m = writer.declLocale( "m", meshlets[meshletIndex] ); @@ -1463,7 +1463,7 @@ namespace //-------------------------------------------------------------------- // Export Primitive & Vertex Data - IF( writer, gtid < m.vertCount ) + sdwIF( writer, gtid < m.vertCount ) { auto vertexIndex = writer.declLocale( "vertexIndex", getVertexIndex( m, gtid ) ); auto vertex = writer.declLocale( "vertex", getVertexAttributes( meshletIndex, vertexIndex ) ); @@ -1472,13 +1472,13 @@ namespace vtxOut[gtid].normal = vertex.normal; vtxOut[gtid].meshletIndex = vertex.meshletIndex; } - FI; + sdwFI; - IF( writer, gtid < m.primCount ) + sdwIF( writer, gtid < m.primCount ) { primOut[gtid].primitiveIndex = getPrimitive( m, gtid ); } - FI; + sdwFI; } ); test::expectError( "Invalid capability operand: 5" , testCounts ); @@ -1521,11 +1521,11 @@ namespace { localIndex = m.vertOffset + localIndex; - IF( writer, meshInfos.indexSize == 4_u ) // 32-bit Vertex Indices + sdwIF( writer, meshInfos.indexSize == 4_u ) // 32-bit Vertex Indices { writer.returnStmt( uniqueVertexIndices[localIndex].index ); } - ELSE // 16-bit Vertex Indices + sdwELSE // 16-bit Vertex Indices { // Byte address must be 4-byte aligned. auto wordOffset = writer.declLocale( "wordOffset", ( localIndex & 0x1_u ) ); @@ -1537,7 +1537,7 @@ namespace writer.returnStmt( index ); } - FI; + sdwFI; } , InParam< Meshlet >{ writer, "m" } , InUInt{ writer, "localIndex" } ); @@ -1580,11 +1580,11 @@ namespace auto meshletIndex = writer.declLocale( "meshletIndex", payload.meshletIndices[gid] ); // Catch any out-of-range indices (in case too many MS threadgroups were dispatched from AS) - IF( writer, meshletIndex >= meshInfos.meshletCount ) + sdwIF( writer, meshletIndex >= meshInfos.meshletCount ) { writer.returnStmt(); } - FI; + sdwFI; // Load the meshlet auto m = writer.declLocale( "m", meshlets[meshletIndex] ); @@ -1595,7 +1595,7 @@ namespace //-------------------------------------------------------------------- // Export Primitive & Vertex Data - IF( writer, gtid < m.vertCount ) + sdwIF( writer, gtid < m.vertCount ) { auto vertexIndex = writer.declLocale( "vertexIndex", getVertexIndex( m, gtid ) ); auto vertex = writer.declLocale( "vertex", getVertexAttributes( meshletIndex, vertexIndex ) ); @@ -1604,14 +1604,14 @@ namespace vtxOut[gtid].normal = vertex.normal; vtxOut[gtid].meshletIndex = vertex.meshletIndex; } - FI; + sdwFI; - IF( writer, gtid < m.primCount ) + sdwIF( writer, gtid < m.primCount ) { auto primIndices = writer.declLocale( "primIndices", primitiveIndices[m.primOffset + gtid].index ); primOut[gtid].primitiveIndex = uvec3( primIndices ); } - FI; + sdwFI; } ); test::expectError( "Invalid capability operand: 5" , testCounts ); diff --git a/test/ShaderWriter/TestWriterProgram.cpp b/test/ShaderWriter/TestWriterProgram.cpp index e33b12ce..b5224b97 100644 --- a/test/ShaderWriter/TestWriterProgram.cpp +++ b/test/ShaderWriter/TestWriterProgram.cpp @@ -237,19 +237,19 @@ namespace auto avgDistance = writer.declLocale( "avgDistance" , ( a + b ) / 2.0_f ); - IF( writer, avgDistance <= 20.0_f ) + sdwIF( writer, avgDistance <= 20.0_f ) { writer.returnStmt( 256.0_f ); } - ELSEIF( avgDistance <= 50.0_f ) + sdwELSEIF( avgDistance <= 50.0_f ) { writer.returnStmt( 128.0_f ); } - ELSEIF( avgDistance <= 100.0_f ) + sdwELSEIF( avgDistance <= 100.0_f ) { writer.returnStmt( 64.0_f ); } - FI; + sdwFI; writer.returnStmt( 16.0_f ); } @@ -720,11 +720,11 @@ namespace for ( int i = 0; i < 6; ++i ) { - IF( writer, dot( center, cullPlanes[i] ) < -radius ) + sdwIF( writer, dot( center, cullPlanes[i] ) < -radius ) { writer.returnStmt( sdw::Boolean{ false } ); } - FI; + sdwFI; } writer.returnStmt( sdw::Boolean{ true } ); @@ -747,11 +747,11 @@ namespace auto idxOffset = writer.declLocale( "idxOffset", subgroupBallotExclusiveBitCount( vote ) ); // Compact visible meshlets into the export payload array - IF( writer, visible ) + sdwIF( writer, visible ) { payload.meshletIndices()[idxOffset] = meshletId; } - FI; + sdwFI; payload.dispatchMesh( tasks, 1_u, 1_u ); } ); @@ -772,13 +772,13 @@ namespace primOut.setMeshOutputCounts( meshlet.vertCount(), meshlet.primCount() ); - IF( writer, laneId < meshlet.primCount() ) + sdwIF( writer, laneId < meshlet.primCount() ) { primOut[laneId].primitiveIndex = primitiveIndices[meshlet.primOffset() + laneId].index(); } - FI; + sdwFI; - IF( writer, laneId < meshlet.vertCount() ) + sdwIF( writer, laneId < meshlet.vertCount() ) { auto vertexIndex = writer.declLocale( "vertexIndex", vertexIndices[meshlet.vertOffset() + laneId].index() ); auto vertex = writer.declLocale( "vertex", vertices[vertexIndex] ); @@ -786,7 +786,7 @@ namespace vtxOut[laneId].position = mvp * vertex.position(); vtxOut[laneId].colour() = vertex.colour(); } - FI; + sdwFI; } ); // Fragment Shader @@ -829,11 +829,11 @@ namespace for ( int i = 0; i < 6; ++i ) { - IF( writer, dot( center, cullPlanes[i] ) < -radius ) + sdwIF( writer, dot( center, cullPlanes[i] ) < -radius ) { writer.returnStmt( sdw::Boolean{ false } ); } - FI; + sdwFI; } writer.returnStmt( sdw::Boolean{ true } ); @@ -856,11 +856,11 @@ namespace auto idxOffset = writer.declLocale( "idxOffset", subgroupBallotExclusiveBitCount( vote ) ); // Compact visible meshlets into the export payload array - IF( writer, visible ) + sdwIF( writer, visible ) { payload.meshletIndices()[idxOffset] = meshletId; } - FI; + sdwFI; payload.dispatchMesh( tasks ); } ); @@ -881,13 +881,13 @@ namespace primOut.setMeshOutputCounts( meshlet.vertCount(), meshlet.primCount() ); - IF( writer, laneId < meshlet.primCount() ) + sdwIF( writer, laneId < meshlet.primCount() ) { primOut[laneId].primitiveIndex = primitiveIndices[meshlet.primOffset() + laneId].index(); } - FI; + sdwFI; - IF( writer, laneId < meshlet.vertCount() ) + sdwIF( writer, laneId < meshlet.vertCount() ) { auto vertexIndex = writer.declLocale( "vertexIndex", vertexIndices[meshlet.vertOffset() + laneId].index() ); auto vertex = writer.declLocale( "vertex", vertices[vertexIndex] ); @@ -895,7 +895,7 @@ namespace vtxOut[laneId].position = mvp * vertex.position(); vtxOut[laneId].colour() = vertex.colour(); } - FI; + sdwFI; } ); // Fragment Shader @@ -938,11 +938,11 @@ namespace for ( int i = 0; i < 6; ++i ) { - IF( writer, dot( center, cullPlanes[i] ) < -radius ) + sdwIF( writer, dot( center, cullPlanes[i] ) < -radius ) { writer.returnStmt( sdw::Boolean{ false } ); } - FI; + sdwFI; } writer.returnStmt( sdw::Boolean{ true } ); @@ -965,11 +965,11 @@ namespace auto idxOffset = writer.declLocale( "idxOffset", subgroupBallotExclusiveBitCount( vote ) ); // Compact visible meshlets into the export payload array - IF( writer, visible ) + sdwIF( writer, visible ) { payload.meshletIndices()[idxOffset] = meshletId; } - FI; + sdwFI; payload.dispatchMesh( SDW_MeshLocalSize( tasks, 1_u, 1_u ) ); } ); @@ -990,13 +990,13 @@ namespace primOut.setMeshOutputCounts( meshlet.vertCount(), meshlet.primCount() ); - IF( writer, laneId < meshlet.primCount() ) + sdwIF( writer, laneId < meshlet.primCount() ) { primOut[laneId].primitiveIndex = primitiveIndices[meshlet.primOffset() + laneId].index(); } - FI; + sdwFI; - IF( writer, laneId < meshlet.vertCount() ) + sdwIF( writer, laneId < meshlet.vertCount() ) { auto vertexIndex = writer.declLocale( "vertexIndex", vertexIndices[meshlet.vertOffset() + laneId].index() ); auto vertex = writer.declLocale( "vertex", vertices[vertexIndex] ); @@ -1004,7 +1004,7 @@ namespace vtxOut[laneId].position = mvp * vertex.position(); vtxOut[laneId].colour() = vertex.colour(); } - FI; + sdwFI; } ); // Fragment Shader diff --git a/test/ShaderWriter/TestWriterRayAnyHitShader.cpp b/test/ShaderWriter/TestWriterRayAnyHitShader.cpp index 57f3042c..fe1eda1a 100644 --- a/test/ShaderWriter/TestWriterRayAnyHitShader.cpp +++ b/test/ShaderWriter/TestWriterRayAnyHitShader.cpp @@ -296,23 +296,23 @@ namespace auto matIdx = writer.declLocale( "matIdx", matIndices[writer.cast< UInt >( in.primitiveID )] ); auto mat = writer.declLocale( "mat", materials[writer.cast< UInt >( matIdx )] ); - IF( writer, mat.illum == 4_i ) + sdwIF( writer, mat.illum == 4_i ) { writer.returnStmt(); } - FI; + sdwFI; auto seed = writer.declLocale( "seed", prd.seed ); // We don't want to modify the PRD - IF( writer, mat.dissolve == 0.0_f ) + sdwIF( writer, mat.dissolve == 0.0_f ) { writer.ignoreIntersection(); } - ELSEIF( rnd( seed ) > mat.dissolve ) + sdwELSEIF( rnd( seed ) > mat.dissolve ) { writer.ignoreIntersection(); } - FI; + sdwFI; } ); test::writeShader( writer diff --git a/test/ShaderWriter/TestWriterRayClosestHitShader.cpp b/test/ShaderWriter/TestWriterRayClosestHitShader.cpp index b18067f4..f7504c3e 100644 --- a/test/ShaderWriter/TestWriterRayClosestHitShader.cpp +++ b/test/ShaderWriter/TestWriterRayClosestHitShader.cpp @@ -282,11 +282,11 @@ namespace // Lambertian auto dotNL = writer.declLocale( "dotNL", max( dot( normal, lightDir ), 0.0_f ) ); auto c = writer.declLocale( "c", mat.diffuse * dotNL ); - IF( writer, mat.illum >= 1_i ) + sdwIF( writer, mat.illum >= 1_i ) { c += mat.ambient; } - FI + sdwFI writer.returnStmt( c ); } , sdw::InParam< WaveFrontMaterialT< LayoutT > >{ writer, "mat" } @@ -309,11 +309,11 @@ namespace , sdw::Vec3 lightDir , sdw::Vec3 normal ) { - IF( writer, mat.illum < 2_i ) + sdwIF( writer, mat.illum < 2_i ) { writer.returnStmt( vec3( 0.0_f ) ); } - FI; + sdwFI; // Compute specular only if not in shadow auto const kPi = writer.declLocale( "kPi", 3.14159265_f ); @@ -601,18 +601,18 @@ namespace auto lightDistance = writer.declLocale( "lightDistance", 100000.0_f ); // Point light - IF( writer, pcLightType == 0_i ) + sdwIF( writer, pcLightType == 0_i ) { auto lDir = writer.declLocale( "lDir", pcLightPosition - worldPos ); lightDistance = length( lDir ); lightIntensity = pcLightIntensity / ( lightDistance * lightDistance ); L = normalize( lDir ); } - ELSE // Directional light + sdwELSE // Directional light { L = normalize( pcLightPosition ); } - FI; + sdwFI; // Material of the object auto matIdx = writer.declLocale( "matIdx", matIndices[writer.cast< UInt >( in.primitiveID )] ); @@ -620,19 +620,19 @@ namespace // Diffuse auto diffuse = writer.declLocale( "diffuse", mat.computeDiffuse( L, worldNrm ) ); - IF( writer, mat.textureId >= 0_i ) + sdwIF( writer, mat.textureId >= 0_i ) { auto txtId = writer.declLocale( "txtId", writer.cast< UInt >( mat.textureId + objDescs[writer.cast< UInt >( in.instanceCustomIndex )].txtOffset ) ); auto texCoord = writer.declLocale( "texCoord", v0.texCoord * barycentrics.x() + v1.texCoord * barycentrics.y() + v2.texCoord * barycentrics.z() ); diffuse *= textureSamplers[nonuniform( txtId )].lod( texCoord, 0.0_f ).xyz(); } - FI; + sdwFI; auto specular = writer.declLocale( "specular", vec3( 0.0_f ) ); auto attenuation = writer.declLocale( "attenuation", 1.0_f ); // Tracing shadow ray only if the light is visible from the surface - IF( writer, dot( worldNrm, L ) > 0.0_f ) + sdwIF( writer, dot( worldNrm, L ) > 0.0_f ) { auto flags = writer.declLocale( "flags", RayFlags::TerminateOnFirstHit() | RayFlags::Opaque() | RayFlags::SkipClosestHitShader() ); auto ray = writer.declLocale< RayDesc >( "ray" ); @@ -650,18 +650,18 @@ namespace , 1_u // missIndex , ray ); - IF( writer, isShadowed ) + sdwIF( writer, isShadowed ) { attenuation = 0.3_f; } - ELSE + sdwELSE { // Specular specular = mat.computeSpecular( in.worldRayDirection, L, worldNrm ); } - FI; + sdwFI; } - FI; + sdwFI; prd.hitValue = vec3( lightIntensity * attenuation * ( diffuse + specular ) ); } ); @@ -736,19 +736,19 @@ namespace // Diffuse auto diffuse = writer.declLocale( "diffuse", mat.computeDiffuse( cLight.outLightDir, worldNrm ) ); - IF( writer, mat.textureId >= 0_i ) + sdwIF( writer, mat.textureId >= 0_i ) { auto txtId = writer.declLocale( "txtId", writer.cast< UInt >( mat.textureId + objDescs[writer.cast< UInt >( in.instanceCustomIndex )].txtOffset ) ); auto texCoord = writer.declLocale( "texCoord", v0.texCoord * barycentrics.x() + v1.texCoord * barycentrics.y() + v2.texCoord * barycentrics.z() ); diffuse *= textureSamplers[nonuniform( txtId )].lod( texCoord, 0.0_f ).xyz(); } - FI; + sdwFI; auto specular = writer.declLocale( "specular", vec3( 0.0_f ) ); auto attenuation = writer.declLocale( "attenuation", 1.0_f ); // Tracing shadow ray only if the light is visible from the surface - IF( writer, dot( worldNrm, cLight.outLightDir ) > 0.0_f ) + sdwIF( writer, dot( worldNrm, cLight.outLightDir ) > 0.0_f ) { auto flags = writer.declLocale( "flags", RayFlags::TerminateOnFirstHit() | RayFlags::Opaque() | RayFlags::SkipClosestHitShader() ); auto ray = writer.declLocale< RayDesc >( "ray" ); @@ -766,18 +766,18 @@ namespace , 1_u // missIndex , ray ); - IF( writer, isShadowed ) + sdwIF( writer, isShadowed ) { attenuation = 0.3_f; } - ELSE + sdwELSE { // Specular specular = mat.computeSpecular( in.worldRayDirection, cLight.outLightDir, worldNrm ); } - FI; + sdwFI; } - FI; + sdwFI; prd.hitValue = vec3( cLight.outIntensity * attenuation * ( diffuse + specular ) ); } ); @@ -857,19 +857,19 @@ namespace // Diffuse auto diffuse = writer.declLocale( "diffuse", mat.computeDiffuse( cLight.outLightDir, worldNrm ) ); - IF( writer, mat.textureId >= 0_i ) + sdwIF( writer, mat.textureId >= 0_i ) { auto txtId = writer.declLocale( "txtId", writer.cast< UInt >( mat.textureId + objDescs[writer.cast< UInt >( in.instanceCustomIndex )].txtOffset ) ); auto texCoord = writer.declLocale( "texCoord", v0.texCoord * barycentrics.x() + v1.texCoord * barycentrics.y() + v2.texCoord * barycentrics.z() ); diffuse *= textureSamplers[nonuniform( txtId )].lod( texCoord, 0.0_f ).xyz(); } - FI; + sdwFI; auto specular = writer.declLocale( "specular", vec3( 0.0_f ) ); auto attenuation = writer.declLocale( "attenuation", 1.0_f ); // Tracing shadow ray only if the light is visible from the surface - IF( writer, dot( worldNrm, cLight.outLightDir ) > 0.0_f ) + sdwIF( writer, dot( worldNrm, cLight.outLightDir ) > 0.0_f ) { auto flags = writer.declLocale( "flags", RayFlags::TerminateOnFirstHit() | RayFlags::Opaque() | RayFlags::SkipClosestHitShader() ); auto ray = writer.declLocale< RayDesc >( "ray" ); @@ -887,18 +887,18 @@ namespace , 1_u // missIndex , ray ); - IF( writer, isShadowed ) + sdwIF( writer, isShadowed ) { attenuation = 0.3_f; } - ELSE + sdwELSE { // Specular specular = mat.computeSpecular( in.worldRayDirection, cLight.outLightDir, worldNrm ); } - FI; + sdwFI; } - FI; + sdwFI; prd.hitValue = vec3( cLight.outIntensity * attenuation * ( diffuse + specular ) ); } ); diff --git a/test/ShaderWriter/TestWriterRayIntersectionShader.cpp b/test/ShaderWriter/TestWriterRayIntersectionShader.cpp index 3284ae47..a8ab38f0 100644 --- a/test/ShaderWriter/TestWriterRayIntersectionShader.cpp +++ b/test/ShaderWriter/TestWriterRayIntersectionShader.cpp @@ -125,15 +125,15 @@ namespace auto b = m_writer->declLocale( "b", 2.0_f * dot( oc, r.direction ) ); auto c = m_writer->declLocale( "c", dot( oc, oc ) - s.radius * s.radius ); auto discriminant = m_writer->declLocale( "discriminant", b * b - 4.0_f * a * c ); - IF( *m_writer, discriminant < 0.0_f ) + sdwIF( *m_writer, discriminant < 0.0_f ) { m_writer->returnStmt( -1.0_f ); } - ELSE + sdwELSE { m_writer->returnStmt( ( -b - sqrt( discriminant ) ) / ( 2.0_f * a ) ); } - FI; + sdwFI } , sdw::InParam< Sphere >{ *m_writer, "s" } , sdw::InParam< Ray >{ *m_writer, "r" } ); @@ -201,12 +201,12 @@ namespace auto tHit = writer.declLocale( "tHit", -1.0_f ); auto hitKind = writer.declLocale( "hitKind", writer.ternary( in.primitiveID % 2_i == 0_i, KIND_SPHERE, KIND_CUBE ) ); - IF( writer, hitKind == KIND_SPHERE ) + sdwIF( writer, hitKind == KIND_SPHERE ) { // Sphere intersection tHit = ray.hitSphere( sphere ); } - ELSE + sdwELSE { // AABB intersection auto aabb = writer.declLocale< Aabb >( "aabb" ); @@ -214,15 +214,15 @@ namespace aabb.maximum = sphere.center + vec3( sphere.radius ); tHit = ray.hitAabb( aabb ); } - FI; + sdwFI // Report hit point - IF( writer, tHit > 0.0_f ) + sdwIF( writer, tHit > 0.0_f ) { auto attribs = writer.declHitAttribute< sdw::Vec2 >( "attribs" ); attribs.reportIntersection( tHit, writer.cast< UInt >( hitKind ) ); } - FI; + sdwFI } ); test::writeShader( writer , testCounts diff --git a/test/ShaderWriter/TestWriterShader.cpp b/test/ShaderWriter/TestWriterShader.cpp index bfbf28d2..924a1e28 100644 --- a/test/ShaderWriter/TestWriterShader.cpp +++ b/test/ShaderWriter/TestWriterShader.cpp @@ -310,11 +310,11 @@ namespace writer.implementMainT< PosColT, ColourT >( [&writer]( FragmentInT< PosColT > const & in , FragmentOutT< ColourT > const & out ) { - IF( writer, in.position().x() < 0.0_f ) + sdwIF( writer, in.position().x() < 0.0_f ) { writer.demote(); } - FI + sdwFI out.colour() = in.colour(); } ); @@ -1018,22 +1018,22 @@ namespace auto axis = writer.declLocale( "axis", 0_u ); //Find the axis the maximize the projected area of this triangle - IF( writer, NdotXAxis > NdotYAxis && NdotXAxis > NdotZAxis ) + sdwIF( writer, NdotXAxis > NdotYAxis && NdotXAxis > NdotZAxis ) { proj = c3d_vpX; axis = 1_u; } - ELSEIF( NdotYAxis > NdotXAxis && NdotYAxis > NdotZAxis ) + sdwELSEIF( NdotYAxis > NdotXAxis && NdotYAxis > NdotZAxis ) { proj = c3d_vpY; axis = 2_u; } - ELSE + sdwELSE { proj = c3d_vpZ; axis = 3_u; } - FI + sdwFI auto pos = writer.declLocaleArray< Vec4 >( "pos", 3u ); @@ -1122,7 +1122,7 @@ namespace writer.implementMainT< IOVoxelGeomT, ColourT >( [&writer, c3d_size, &pxl_voxelVisibility]( FragmentInT< IOVoxelGeomT > const & in , FragmentOutT< ColourT > const & out ) { - IF( writer + sdwIF( writer , in.position().x() < in.aabb().x() || in.position().y() < in.aabb().y() || in.position().x() > in.aabb().z() @@ -1130,7 +1130,7 @@ namespace { writer.terminate(); } - FI + sdwFI auto width = writer.declLocale( "width" , writer.cast< Int >( c3d_size.x() ) ); @@ -1140,23 +1140,23 @@ namespace , width * writer.cast< Int >( in.fragCoord.z() ) ) ); auto texcoord = writer.declLocale< IVec3 >( "texcoord" ); - IF( writer, in.axis() == 1_u ) + sdwIF( writer, in.axis() == 1_u ) { texcoord.x() = width - temp.z(); texcoord.z() = temp.x(); texcoord.y() = temp.y(); } - ELSEIF( in.axis() == 2_u ) + sdwELSEIF( in.axis() == 2_u ) { texcoord.z() = temp.y(); texcoord.y() = width - temp.z(); texcoord.x() = temp.x(); } - ELSE + sdwELSE { texcoord = temp; } - FI + sdwFI pxl_voxelVisibility.store( texcoord, 1_u ); out.colour() = vec4( vec3( texcoord ), 1.0_f ); @@ -1208,19 +1208,19 @@ namespace auto avgDistance = writer.declLocale( "avgDistance" , ( a + b ) / 2.0_f ); - IF( writer, avgDistance <= 20.0_f ) + sdwIF( writer, avgDistance <= 20.0_f ) { writer.returnStmt( 256.0_f ); } - ELSEIF( avgDistance <= 50.0_f ) + sdwELSEIF( avgDistance <= 50.0_f ) { writer.returnStmt( 128.0_f ); } - ELSEIF( avgDistance <= 100.0_f ) + sdwELSEIF( avgDistance <= 100.0_f ) { writer.returnStmt( 64.0_f ); } - FI + sdwFI writer.returnStmt( 16.0_f ); } @@ -1541,9 +1541,9 @@ namespace auto nrSamples = writer.declLocale( "nrSamples" , 0_i ); - FOR( writer, Float, phi, 0.0_f, phi < 6.253184_f, phi += sampleDelta ) + sdwFOR( writer, Float, phi, 0.0_f, phi < 6.253184_f, phi += sampleDelta ) { - FOR( writer, Float, theta, 0.0_f, theta < 1.570796_f, theta += sampleDelta ) + sdwFOR( writer, Float, theta, 0.0_f, theta < 1.570796_f, theta += sampleDelta ) { // spherical to cartesian (in tangent space) auto tangentSample = writer.declLocale( "tangentSample" @@ -1555,9 +1555,9 @@ namespace irradiance += c3d_mapEnvironment.lod( sampleVec, 0.0_f ).rgb() * cos( theta ) * sin( theta ); nrSamples = nrSamples + 1; } - ROF; + sdwROF; } - ROF; + sdwROF; irradiance = irradiance * 3.141592_f *( 1.0_f / writer.cast< Float >( nrSamples ) ); outColour = vec4( irradiance, 1.0_f ); diff --git a/test/ShaderWriter/TestWriterSpecConstantDeclarations.cpp b/test/ShaderWriter/TestWriterSpecConstantDeclarations.cpp index f724e280..f43f8739 100644 --- a/test/ShaderWriter/TestWriterSpecConstantDeclarations.cpp +++ b/test/ShaderWriter/TestWriterSpecConstantDeclarations.cpp @@ -22,10 +22,10 @@ namespace astCheck( static_cast< sdw::stmt::SpecialisationConstantDecl const & >( stmt ).getLocation() == 0u ); writer.implementMain( [&]( sdw::FragmentIn in, sdw::FragmentOut out ) { - IF( writer, value ) + sdwIF( writer, value ) { } - FI; + sdwFI; } ); test::writeShader( writer, testCounts, CurrentCompilers ); } @@ -62,10 +62,10 @@ namespace astCheck( static_cast< sdw::stmt::SpecialisationConstantDecl const & >( stmt ).getLocation() == 2u ); writer.implementMain( [&]( sdw::FragmentIn in, sdw::FragmentOut out ) { - IF( writer, value ) + sdwIF( writer, value ) { } - FI; + sdwFI; } ); test::writeShader( writer, testCounts, CurrentCompilers ); } diff --git a/test/ShaderWriter/TestWriterTaskShaderEXT.cpp b/test/ShaderWriter/TestWriterTaskShaderEXT.cpp index 2b677ad8..3d6e3b46 100644 --- a/test/ShaderWriter/TestWriterTaskShaderEXT.cpp +++ b/test/ShaderWriter/TestWriterTaskShaderEXT.cpp @@ -523,11 +523,11 @@ namespace , Float scale , Vec3 viewPos ) { - IF( writer, ( instance.flags & CullFlag ) == 0_u ) + sdwIF( writer, ( instance.flags & CullFlag ) == 0_u ) { writer.returnStmt( Boolean{ true } ); } - FI; + sdwFI; // Do a cull test of the bounding sphere against the view frustum planes. auto center = writer.declLocale( "center", vec4( c.boundingSphere.xyz(), 1.0_f ) * world ); @@ -535,19 +535,19 @@ namespace for ( int i = 0; i < 6; ++i ) { - IF( writer, dot( center, constants.planes[i] ) < -radius ) + sdwIF( writer, dot( center, constants.planes[i] ) < -radius ) { writer.returnStmt( Boolean{ false } ); } - FI; + sdwFI; } // Do normal cone culling - IF( writer, isConeDegenerate( c ) ) + sdwIF( writer, isConeDegenerate( c ) ) { writer.returnStmt( Boolean{ true } ); // Cone is degenerate - spread is wider than a hemisphere. } - FI; + sdwFI; // Unpack the normal cone from its 8-bit uint compression auto normalCone = writer.declLocale( "normalCone", unpackCone( c.normalCone ) ); @@ -561,11 +561,11 @@ namespace // The normal cone w-component stores -cos(angle + 90 deg) // This is the min dot product along the inverted axis from which all the meshlet's triangles are backface - IF( writer, dot( view, -axis ) > normalCone.w() ) + sdwIF( writer, dot( view, -axis ) > normalCone.w() ) { writer.returnStmt( Boolean{ false } ); } - FI; + sdwFI; // All tests passed - it will merit pixels writer.returnStmt( Boolean{ true } ); @@ -587,22 +587,22 @@ namespace auto visible = writer.declLocale( "visible", Boolean{ false } ); // Check bounds of meshlet cull data resource - IF( writer, dtid < meshInfos.meshletCount ) + sdwIF( writer, dtid < meshInfos.meshletCount ) { // Do visibility testing for this thread visible = isVisible( meshletCullData[dtid] , instance.world , instance.scale, constants.cullViewPosition ); } - FI; + sdwFI; // Compact visible meshlets into the export payload array - IF( writer, visible ) + sdwIF( writer, visible ) { //auto index = writer.declLocale( "index", WavePrefixCountBits( visible ) ); payload.meshletIndices[7_u/*index*/] = dtid; } - FI; + sdwFI; // Dispatch the required number of MS threadgroups to render the visible meshlets //auto visibleCount = writer.declLocale( "visibleCount", WaveActiveCountBits( visible ) ); diff --git a/test/ShaderWriter/TestWriterTaskShaderNV.cpp b/test/ShaderWriter/TestWriterTaskShaderNV.cpp index 7fc76cc8..cba6a5a7 100644 --- a/test/ShaderWriter/TestWriterTaskShaderNV.cpp +++ b/test/ShaderWriter/TestWriterTaskShaderNV.cpp @@ -521,11 +521,11 @@ namespace , Float scale , Vec3 viewPos ) { - IF( writer, ( instance.flags & CullFlag ) == 0_u ) + sdwIF( writer, ( instance.flags & CullFlag ) == 0_u ) { writer.returnStmt( Boolean{ true } ); } - FI; + sdwFI; // Do a cull test of the bounding sphere against the view frustum planes. auto center = writer.declLocale( "center", vec4( c.boundingSphere.xyz(), 1.0_f ) * world ); @@ -533,19 +533,19 @@ namespace for ( int i = 0; i < 6; ++i ) { - IF( writer, dot( center, constants.planes[i] ) < -radius ) + sdwIF( writer, dot( center, constants.planes[i] ) < -radius ) { writer.returnStmt( Boolean{ false } ); } - FI; + sdwFI; } // Do normal cone culling - IF( writer, isConeDegenerate( c ) ) + sdwIF( writer, isConeDegenerate( c ) ) { writer.returnStmt( Boolean{ true } ); // Cone is degenerate - spread is wider than a hemisphere. } - FI; + sdwFI; // Unpack the normal cone from its 8-bit uint compression auto normalCone = writer.declLocale( "normalCone", unpackCone( c.normalCone ) ); @@ -559,11 +559,11 @@ namespace // The normal cone w-component stores -cos(angle + 90 deg) // This is the min dot product along the inverted axis from which all the meshlet's triangles are backface - IF( writer, dot( view, -axis ) > normalCone.w() ) + sdwIF( writer, dot( view, -axis ) > normalCone.w() ) { writer.returnStmt( Boolean{ false } ); } - FI; + sdwFI; // All tests passed - it will merit pixels writer.returnStmt( Boolean{ true } ); @@ -583,22 +583,22 @@ namespace auto visible = writer.declLocale( "visible", Boolean{ false } ); // Check bounds of meshlet cull data resource - IF( writer, dtid < meshInfos.meshletCount ) + sdwIF( writer, dtid < meshInfos.meshletCount ) { // Do visibility testing for this thread visible = isVisible( meshletCullData[dtid] , instance.world , instance.scale, constants.cullViewPosition ); } - FI; + sdwFI; // Compact visible meshlets into the export payload array - IF( writer, visible ) + sdwIF( writer, visible ) { //auto index = writer.declLocale( "index", WavePrefixCountBits( visible ) ); payload.meshletIndices[7_u/*index*/] = dtid; } - FI; + sdwFI; // Dispatch the required number of MS threadgroups to render the visible meshlets //auto visibleCount = writer.declLocale( "visibleCount", WaveActiveCountBits( visible ) ); diff --git a/test/ShaderWriter/TestWriterTaskShader_EXT.cpp b/test/ShaderWriter/TestWriterTaskShader_EXT.cpp index 1a34bcbd..8818459c 100644 --- a/test/ShaderWriter/TestWriterTaskShader_EXT.cpp +++ b/test/ShaderWriter/TestWriterTaskShader_EXT.cpp @@ -526,11 +526,11 @@ namespace , Float scale , Vec3 viewPos ) { - IF( writer, ( instance.flags & CullFlag ) == 0_u ) + sdwIF( writer, ( instance.flags & CullFlag ) == 0_u ) { writer.returnStmt( Boolean{ true } ); } - FI; + sdwFI // Do a cull test of the bounding sphere against the view frustum planes. auto center = writer.declLocale( "center", vec4( c.boundingSphere.xyz(), 1.0_f ) * world ); @@ -538,19 +538,19 @@ namespace for ( int i = 0; i < 6; ++i ) { - IF( writer, dot( center, constants.planes[i] ) < -radius ) + sdwIF( writer, dot( center, constants.planes[i] ) < -radius ) { writer.returnStmt( Boolean{ false } ); } - FI; + sdwFI } // Do normal cone culling - IF( writer, isConeDegenerate( c ) ) + sdwIF( writer, isConeDegenerate( c ) ) { writer.returnStmt( Boolean{ true } ); // Cone is degenerate - spread is wider than a hemisphere. } - FI; + sdwFI // Unpack the normal cone from its 8-bit uint compression auto normalCone = writer.declLocale( "normalCone", unpackCone( c.normalCone ) ); @@ -564,11 +564,11 @@ namespace // The normal cone w-component stores -cos(angle + 90 deg) // This is the min dot product along the inverted axis from which all the meshlet's triangles are backface - IF( writer, dot( view, -axis ) > normalCone.w() ) + sdwIF( writer, dot( view, -axis ) > normalCone.w() ) { writer.returnStmt( Boolean{ false } ); } - FI; + sdwFI // All tests passed - it will merit pixels writer.returnStmt( Boolean{ true } ); @@ -590,22 +590,22 @@ namespace auto visible = writer.declLocale( "visible", Boolean{ false } ); // Check bounds of meshlet cull data resource - IF( writer, dtid < meshInfos.meshletCount ) + sdwIF( writer, dtid < meshInfos.meshletCount ) { // Do visibility testing for this thread visible = isVisible( meshletCullData[dtid] , instance.world , instance.scale, constants.cullViewPosition ); } - FI; + sdwFI // Compact visible meshlets into the export payload array - IF( writer, visible ) + sdwIF( writer, visible ) { //auto index = writer.declLocale( "index", WavePrefixCountBits( visible ) ); payload.meshletIndices[7_u/*index*/] = dtid; } - FI; + sdwFI // Dispatch the required number of MS threadgroups to render the visible meshlets //auto visibleCount = writer.declLocale( "visibleCount", WaveActiveCountBits( visible ) ); diff --git a/test/ShaderWriter/TestWriterTaskShader_NV.cpp b/test/ShaderWriter/TestWriterTaskShader_NV.cpp index f5583977..005f8749 100644 --- a/test/ShaderWriter/TestWriterTaskShader_NV.cpp +++ b/test/ShaderWriter/TestWriterTaskShader_NV.cpp @@ -526,11 +526,11 @@ namespace , Float scale , Vec3 viewPos ) { - IF( writer, ( instance.flags & CullFlag ) == 0_u ) + sdwIF( writer, ( instance.flags & CullFlag ) == 0_u ) { writer.returnStmt( Boolean{ true } ); } - FI; + sdwFI // Do a cull test of the bounding sphere against the view frustum planes. auto center = writer.declLocale( "center", vec4( c.boundingSphere.xyz(), 1.0_f ) * world ); @@ -538,19 +538,19 @@ namespace for ( int i = 0; i < 6; ++i ) { - IF( writer, dot( center, constants.planes[i] ) < -radius ) + sdwIF( writer, dot( center, constants.planes[i] ) < -radius ) { writer.returnStmt( Boolean{ false } ); } - FI; + sdwFI } // Do normal cone culling - IF( writer, isConeDegenerate( c ) ) + sdwIF( writer, isConeDegenerate( c ) ) { writer.returnStmt( Boolean{ true } ); // Cone is degenerate - spread is wider than a hemisphere. } - FI; + sdwFI // Unpack the normal cone from its 8-bit uint compression auto normalCone = writer.declLocale( "normalCone", unpackCone( c.normalCone ) ); @@ -564,11 +564,11 @@ namespace // The normal cone w-component stores -cos(angle + 90 deg) // This is the min dot product along the inverted axis from which all the meshlet's triangles are backface - IF( writer, dot( view, -axis ) > normalCone.w() ) + sdwIF( writer, dot( view, -axis ) > normalCone.w() ) { writer.returnStmt( Boolean{ false } ); } - FI; + sdwFI // All tests passed - it will merit pixels writer.returnStmt( Boolean{ true } ); @@ -588,22 +588,22 @@ namespace auto visible = writer.declLocale( "visible", Boolean{ false } ); // Check bounds of meshlet cull data resource - IF( writer, dtid < meshInfos.meshletCount ) + sdwIF( writer, dtid < meshInfos.meshletCount ) { // Do visibility testing for this thread visible = isVisible( meshletCullData[dtid] , instance.world , instance.scale, constants.cullViewPosition ); } - FI; + sdwFI // Compact visible meshlets into the export payload array - IF( writer, visible ) + sdwIF( writer, visible ) { //auto index = writer.declLocale( "index", WavePrefixCountBits( visible ) ); payload.meshletIndices[7_u/*index*/] = dtid; } - FI; + sdwFI // Dispatch the required number of MS threadgroups to render the visible meshlets //auto visibleCount = writer.declLocale( "visibleCount", WaveActiveCountBits( visible ) ); diff --git a/test/ShaderWriter/TestWriterTessellationControlShader.cpp b/test/ShaderWriter/TestWriterTessellationControlShader.cpp index 0e733646..6ee04429 100644 --- a/test/ShaderWriter/TestWriterTessellationControlShader.cpp +++ b/test/ShaderWriter/TestWriterTessellationControlShader.cpp @@ -1103,19 +1103,19 @@ namespace auto avgDistance = writer.declLocale( "avgDistance" , ( a + b ) / 2.0_f ); - IF( writer, avgDistance <= 20.0_f ) + sdwIF( writer, avgDistance <= 20.0_f ) { writer.returnStmt( 256.0_f ); } - ELSEIF( avgDistance <= 50.0_f ) + sdwELSEIF( avgDistance <= 50.0_f ) { writer.returnStmt( 128.0_f ); } - ELSEIF( avgDistance <= 100.0_f ) + sdwELSEIF( avgDistance <= 100.0_f ) { writer.returnStmt( 64.0_f ); } - FI; + sdwFI writer.returnStmt( 16.0_f ); } From 89624e86f16bf061b74760efe60bc5af99f00c04 Mon Sep 17 00:00:00 2001 From: Sylvain Doremus Date: Mon, 19 May 2025 19:27:49 +0200 Subject: [PATCH 3/3] Tentative fix for clang compilation error. --- include/ShaderWriter/CompositeTypes/StructHelper.hpp | 2 ++ source/CompilerGlsl/compileGlsl.cpp | 2 ++ source/CompilerHlsl/HlslGenerateStatements.cpp | 1 + source/CompilerHlsl/HlslHelpers.cpp | 1 + source/CompilerHlsl/HlslHelpers.hpp | 1 + source/CompilerHlsl/compileHlsl.cpp | 2 ++ source/CompilerSpirV/SpirVHelpers.cpp | 1 + source/CompilerSpirV/SpirVModuleLiterals.cpp | 2 ++ source/CompilerSpirV/SpirVModuleTypes.cpp | 2 ++ source/CompilerSpirV/compileSpirV.cpp | 1 + source/GlslCommon/GenerateGlslStatements.cpp | 1 + source/ShaderAST/ShaderAllocator.cpp | 1 + source/ShaderAST/Visitors/ResolveConstants.cpp | 1 + source/ShaderAST/Visitors/TransformSSA.cpp | 2 ++ source/VulkanLayer/ProgramPipeline.cpp | 1 + source/VulkanLayer/ShaderDataPtr.cpp | 1 + test/Common.cpp | 1 + 17 files changed, 23 insertions(+) diff --git a/include/ShaderWriter/CompositeTypes/StructHelper.hpp b/include/ShaderWriter/CompositeTypes/StructHelper.hpp index 0e750f90..6552c722 100644 --- a/include/ShaderWriter/CompositeTypes/StructHelper.hpp +++ b/include/ShaderWriter/CompositeTypes/StructHelper.hpp @@ -10,6 +10,8 @@ See LICENSE file in root folder #include "ShaderWriter/BaseTypes/Void.hpp" +#include + namespace sdw { template< size_t N > diff --git a/source/CompilerGlsl/compileGlsl.cpp b/source/CompilerGlsl/compileGlsl.cpp index 31e5b0f3..09f10747 100644 --- a/source/CompilerGlsl/compileGlsl.cpp +++ b/source/CompilerGlsl/compileGlsl.cpp @@ -15,6 +15,8 @@ See LICENSE file in root folder #include #include +#include + namespace glsl { std::string compileGlsl( ast::ShaderAllocatorBlock & allocator diff --git a/source/CompilerHlsl/HlslGenerateStatements.cpp b/source/CompilerHlsl/HlslGenerateStatements.cpp index b872b713..2649404e 100644 --- a/source/CompilerHlsl/HlslGenerateStatements.cpp +++ b/source/CompilerHlsl/HlslGenerateStatements.cpp @@ -13,6 +13,7 @@ See LICENSE file in root folder #pragma warning( disable:4365 ) #pragma warning( disable:5262 ) +#include #include #include #include diff --git a/source/CompilerHlsl/HlslHelpers.cpp b/source/CompilerHlsl/HlslHelpers.cpp index a923102b..ffba8563 100644 --- a/source/CompilerHlsl/HlslHelpers.cpp +++ b/source/CompilerHlsl/HlslHelpers.cpp @@ -20,6 +20,7 @@ See LICENSE file in root folder #include #include +#include #include namespace hlsl diff --git a/source/CompilerHlsl/HlslHelpers.hpp b/source/CompilerHlsl/HlslHelpers.hpp index 627cb979..92a203cd 100644 --- a/source/CompilerHlsl/HlslHelpers.hpp +++ b/source/CompilerHlsl/HlslHelpers.hpp @@ -15,6 +15,7 @@ See LICENSE file in root folder #include #include +#include #include #include diff --git a/source/CompilerHlsl/compileHlsl.cpp b/source/CompilerHlsl/compileHlsl.cpp index 78fdee30..c23608b3 100644 --- a/source/CompilerHlsl/compileHlsl.cpp +++ b/source/CompilerHlsl/compileHlsl.cpp @@ -13,6 +13,8 @@ See LICENSE file in root folder #include #include +#include + namespace hlsl { namespace diff --git a/source/CompilerSpirV/SpirVHelpers.cpp b/source/CompilerSpirV/SpirVHelpers.cpp index ed039084..331f6d1b 100644 --- a/source/CompilerSpirV/SpirVHelpers.cpp +++ b/source/CompilerSpirV/SpirVHelpers.cpp @@ -20,6 +20,7 @@ See LICENSE file in root folder #include #include +#include #include namespace spirv diff --git a/source/CompilerSpirV/SpirVModuleLiterals.cpp b/source/CompilerSpirV/SpirVModuleLiterals.cpp index 036a13ec..f52ac73b 100644 --- a/source/CompilerSpirV/SpirVModuleLiterals.cpp +++ b/source/CompilerSpirV/SpirVModuleLiterals.cpp @@ -5,6 +5,8 @@ See LICENSE file in root folder #include "CompilerSpirV/SpirVModule.hpp" +#include + namespace spirv { //************************************************************************* diff --git a/source/CompilerSpirV/SpirVModuleTypes.cpp b/source/CompilerSpirV/SpirVModuleTypes.cpp index 47b8c56d..728c51b6 100644 --- a/source/CompilerSpirV/SpirVModuleTypes.cpp +++ b/source/CompilerSpirV/SpirVModuleTypes.cpp @@ -8,6 +8,8 @@ See LICENSE file in root folder #include +#include + namespace spirv { //************************************************************************* diff --git a/source/CompilerSpirV/compileSpirV.cpp b/source/CompilerSpirV/compileSpirV.cpp index 7f93ab06..9d14232c 100644 --- a/source/CompilerSpirV/compileSpirV.cpp +++ b/source/CompilerSpirV/compileSpirV.cpp @@ -18,6 +18,7 @@ See LICENSE file in root folder #include #include +#include #include namespace spirv diff --git a/source/GlslCommon/GenerateGlslStatements.cpp b/source/GlslCommon/GenerateGlslStatements.cpp index 5faeebc6..70f0e4ae 100644 --- a/source/GlslCommon/GenerateGlslStatements.cpp +++ b/source/GlslCommon/GenerateGlslStatements.cpp @@ -16,6 +16,7 @@ See LICENSE file in root folder #include #include +#include #include #include #pragma warning( push ) diff --git a/source/ShaderAST/ShaderAllocator.cpp b/source/ShaderAST/ShaderAllocator.cpp index 3cced1cb..c3deca93 100644 --- a/source/ShaderAST/ShaderAllocator.cpp +++ b/source/ShaderAST/ShaderAllocator.cpp @@ -4,6 +4,7 @@ See LICENSE file in root folder #include "ShaderAST/ShaderAllocator.hpp" #include "ShaderAST/ShaderLog.hpp" +#include #pragma warning( push ) #pragma warning( disable: 4365 ) #pragma warning( disable: 5262 ) diff --git a/source/ShaderAST/Visitors/ResolveConstants.cpp b/source/ShaderAST/Visitors/ResolveConstants.cpp index 466972c8..a354ef88 100644 --- a/source/ShaderAST/Visitors/ResolveConstants.cpp +++ b/source/ShaderAST/Visitors/ResolveConstants.cpp @@ -13,6 +13,7 @@ See LICENSE file in root folder #include "ShaderAST/Visitors/GetExprName.hpp" #include "ShaderAST/Visitors/SimplifyStatements.hpp" +#include #include #include #include diff --git a/source/ShaderAST/Visitors/TransformSSA.cpp b/source/ShaderAST/Visitors/TransformSSA.cpp index c417dabb..9ecaee53 100644 --- a/source/ShaderAST/Visitors/TransformSSA.cpp +++ b/source/ShaderAST/Visitors/TransformSSA.cpp @@ -11,6 +11,8 @@ See LICENSE file in root folder #include "ShaderAST/Visitors/GetExprName.hpp" #include "ShaderAST/Visitors/SimplifyStatements.hpp" +#include + namespace ast { namespace ssa diff --git a/source/VulkanLayer/ProgramPipeline.cpp b/source/VulkanLayer/ProgramPipeline.cpp index f2198e3e..dfd15aeb 100644 --- a/source/VulkanLayer/ProgramPipeline.cpp +++ b/source/VulkanLayer/ProgramPipeline.cpp @@ -7,6 +7,7 @@ See LICENSE file in root folder #include +#include #pragma warning( push ) #pragma warning( disable: 4365 ) #pragma warning( disable: 5262 ) diff --git a/source/VulkanLayer/ShaderDataPtr.cpp b/source/VulkanLayer/ShaderDataPtr.cpp index b5327d85..231ac4f0 100644 --- a/source/VulkanLayer/ShaderDataPtr.cpp +++ b/source/VulkanLayer/ShaderDataPtr.cpp @@ -3,6 +3,7 @@ See LICENSE file in root folder */ #include "VulkanLayer/ShaderDataPtr.hpp" +#include #pragma warning( push ) #pragma warning( disable: 4365 ) #pragma warning( disable: 5262 ) diff --git a/test/Common.cpp b/test/Common.cpp index 9a330730..780dc0ea 100644 --- a/test/Common.cpp +++ b/test/Common.cpp @@ -14,6 +14,7 @@ # include #endif +#include #include namespace test