Browse Source

Some HLSL refactoring

Panagiotis Christopoulos Charitos 3 years ago
parent
commit
42672ea599
40 changed files with 151 additions and 186 deletions
  1. 1 1
      .clang-format-hlsl
  2. 6 26
      AnKi/Shaders/Blit.hlsl
  3. 6 26
      AnKi/Shaders/Bloom.hlsl
  4. 7 28
      AnKi/Shaders/BloomUpscale.hlsl
  5. 1 1
      AnKi/Shaders/ClearTextureCompute.ankiprog
  6. 2 2
      AnKi/Shaders/ClusterBinning.ankiprog
  7. 1 1
      AnKi/Shaders/ClusteredShadingCommon.hlsl
  8. 4 5
      AnKi/Shaders/DepthAwareBlur.hlsl
  9. 1 1
      AnKi/Shaders/DepthDownscaleCompute.ankiprog
  10. 1 1
      AnKi/Shaders/DepthDownscaleRaster.ankiprog
  11. 2 2
      AnKi/Shaders/DownscaleBlur.hlsl
  12. 4 18
      AnKi/Shaders/FinalComposite.ankiprog
  13. 1 1
      AnKi/Shaders/ForwardShadingCommon.glsl
  14. 5 5
      AnKi/Shaders/ForwardShadingCommon.hlsl
  15. 1 1
      AnKi/Shaders/GBufferGeneric.ankiprog
  16. 1 1
      AnKi/Shaders/GBufferPost.ankiprog
  17. 2 2
      AnKi/Shaders/GaussianBlur.glsl
  18. 1 1
      AnKi/Shaders/GpuParticlesSimulation.ankiprog
  19. 1 1
      AnKi/Shaders/GpuSceneMicroPatching.ankiprog
  20. 3 4
      AnKi/Shaders/Include/Common.h
  21. 3 3
      AnKi/Shaders/IndirectDiffuse.hlsl
  22. 3 3
      AnKi/Shaders/IndirectDiffuseDenoise.hlsl
  23. 2 2
      AnKi/Shaders/IndirectDiffuseVrsSriGeneration.ankiprog
  24. 4 4
      AnKi/Shaders/IndirectSpecular.glsl
  25. 10 10
      AnKi/Shaders/IrradianceDice.ankiprog
  26. 4 4
      AnKi/Shaders/LightFunctions.glsl
  27. 4 4
      AnKi/Shaders/LightFunctions.hlsl
  28. 2 2
      AnKi/Shaders/LightShading.ankiprog
  29. 1 1
      AnKi/Shaders/MotionBlur.hlsl
  30. 1 1
      AnKi/Shaders/RtShadows.glsl
  31. 2 2
      AnKi/Shaders/RtShadowsDenoise.ankiprog
  32. 7 7
      AnKi/Shaders/RtShadowsRayGen.ankiprog
  33. 3 3
      AnKi/Shaders/RtShadowsSvgfAtrous.ankiprog
  34. 2 2
      AnKi/Shaders/RtShadowsSvgfVariance.ankiprog
  35. 2 2
      AnKi/Shaders/ShadowmapsResolve.glsl
  36. 1 1
      AnKi/Shaders/SsRaymarching.glsl
  37. 3 3
      AnKi/Shaders/TonemappingAverageLuminance.ankiprog
  38. 1 1
      AnKi/Shaders/VolumetricLightingAccumulation.ankiprog
  39. 2 2
      AnKi/Shaders/VrsSriGenerationCompute.ankiprog
  40. 43 1
      Tools/FormatSource.py

+ 1 - 1
.clang-format-hlsl

@@ -41,7 +41,7 @@ BraceWrapping:
   AfterExternBlock: false
   AfterExternBlock: false
   BeforeCatch:     true
   BeforeCatch:     true
   BeforeElse:      true
   BeforeElse:      true
-  BeforeLambdaBody: false
+  BeforeLambdaBody: true
   BeforeWhile:     false
   BeforeWhile:     false
   IndentBraces:    false
   IndentBraces:    false
   SplitEmptyFunction: true
   SplitEmptyFunction: true

+ 6 - 26
AnKi/Shaders/Blit.hlsl

@@ -24,48 +24,28 @@ struct Uniforms
 };
 };
 
 
 [[vk::push_constant]] ConstantBuffer<Uniforms> g_pc;
 [[vk::push_constant]] ConstantBuffer<Uniforms> g_pc;
-
-struct CompIn
-{
-	UVec3 m_svDispatchThreadId : SV_DISPATCHTHREADID;
-};
-#else
-struct VertOut
-{
-	[[vk::location(0)]] Vec2 m_uv : TEXCOORD;
-	Vec4 m_svPosition : SV_POSITION;
-};
-
-struct FragOut
-{
-	RVec3 m_svTarget : SV_TARGET0;
-};
 #endif
 #endif
 
 
 #if USE_COMPUTE
 #if USE_COMPUTE
-ANKI_NUMTHREADS(8, 8, 1) void main(CompIn input)
+[numthreads(8, 8, 1)] void main(UVec3 svDispatchThreadId : SV_DISPATCHTHREADID)
 #else
 #else
-FragOut main(VertOut input)
+RVec3 main([[vk::location(0)]] Vec2 uv : TEXCOORD) : SV_TARGET0
 #endif
 #endif
 {
 {
 #if USE_COMPUTE
 #if USE_COMPUTE
-	if(skipOutOfBoundsInvocations(UVec2(8, 8), g_pc.m_viewportSizeU, input.m_svDispatchThreadId.xy))
+	if(skipOutOfBoundsInvocations(UVec2(8, 8), g_pc.m_viewportSizeU, svDispatchThreadId.xy))
 	{
 	{
 		return;
 		return;
 	}
 	}
 
 
-	const Vec2 uv = (Vec2(input.m_svDispatchThreadId.xy) + 0.5) / g_pc.m_viewportSize;
-#else
-	const Vec2 uv = input.m_uv;
+	const Vec2 uv = (Vec2(svDispatchThreadId.xy) + 0.5) / g_pc.m_viewportSize;
 #endif
 #endif
 
 
 	const RVec3 color = g_inputTex.SampleLevel(g_linearAnyClampSampler, uv, 0.0).rgb;
 	const RVec3 color = g_inputTex.SampleLevel(g_linearAnyClampSampler, uv, 0.0).rgb;
 
 
 #if USE_COMPUTE
 #if USE_COMPUTE
-	g_outUav[input.m_svDispatchThreadId.xy] = RVec4(color, 0.0);
+	g_outUav[svDispatchThreadId.xy] = RVec4(color, 0.0);
 #else
 #else
-	FragOut output;
-	output.m_svTarget = color;
-	return output;
+	return color;
 #endif
 #endif
 }
 }

+ 6 - 26
AnKi/Shaders/Bloom.hlsl

@@ -20,22 +20,6 @@ struct Uniforms
 
 
 [[vk::push_constant]] ConstantBuffer<Uniforms> g_pc;
 [[vk::push_constant]] ConstantBuffer<Uniforms> g_pc;
 
 
-struct CompIn
-{
-	UVec3 m_svDispatchThreadId : SV_DISPATCHTHREADID;
-};
-
-struct VertOut
-{
-	Vec4 m_position : SV_POSITION;
-	[[vk::location(0)]] Vec2 m_uv : TEXCOORD;
-};
-
-struct FragOut
-{
-	RVec3 m_svTarget : SV_TARGET0;
-};
-
 #if defined(ANKI_COMPUTE_SHADER)
 #if defined(ANKI_COMPUTE_SHADER)
 #	define THREADGROUP_SIZE_X 8
 #	define THREADGROUP_SIZE_X 8
 #	define THREADGROUP_SIZE_Y 8
 #	define THREADGROUP_SIZE_Y 8
@@ -43,20 +27,18 @@ struct FragOut
 #endif
 #endif
 
 
 #if defined(ANKI_COMPUTE_SHADER)
 #if defined(ANKI_COMPUTE_SHADER)
-ANKI_NUMTHREADS(THREADGROUP_SIZE_X, THREADGROUP_SIZE_Y, 1) void main(CompIn input)
+[numthreads(THREADGROUP_SIZE_X, THREADGROUP_SIZE_Y, 1)] void main(UVec3 svDispatchThreadId : SV_DISPATCHTHREADID)
 #else
 #else
-FragOut main(VertOut input)
+RVec3 main([[vk::location(0)]] Vec2 uv : TEXCOORD) : SV_TARGET0
 #endif
 #endif
 {
 {
 #if defined(ANKI_COMPUTE_SHADER)
 #if defined(ANKI_COMPUTE_SHADER)
-	if(skipOutOfBoundsInvocations(UVec2(THREADGROUP_SIZE_X, THREADGROUP_SIZE_Y), kViewport, input.m_svDispatchThreadId))
+	if(skipOutOfBoundsInvocations(UVec2(THREADGROUP_SIZE_X, THREADGROUP_SIZE_Y), kViewport, svDispatchThreadId))
 	{
 	{
 		return;
 		return;
 	}
 	}
 
 
-	const Vec2 uv = (Vec2(input.m_svDispatchThreadId.xy) + 0.5) / Vec2(kViewport);
-#else
-	const Vec2 uv = input.m_uv;
+	const Vec2 uv = (Vec2(svDispatchThreadId.xy) + 0.5) / Vec2(kViewport);
 #endif
 #endif
 
 
 	RF32 weight = 1.0 / 5.0;
 	RF32 weight = 1.0 / 5.0;
@@ -70,10 +52,8 @@ FragOut main(VertOut input)
 		tonemap(color, readExposureAndAverageLuminance().y, g_pc.m_thresholdScalePad2.x) * g_pc.m_thresholdScalePad2.y;
 		tonemap(color, readExposureAndAverageLuminance().y, g_pc.m_thresholdScalePad2.x) * g_pc.m_thresholdScalePad2.y;
 
 
 #if defined(ANKI_COMPUTE_SHADER)
 #if defined(ANKI_COMPUTE_SHADER)
-	g_outUav[input.m_svDispatchThreadId.xy] = RVec4(color, 0.0);
+	g_outUav[svDispatchThreadId.xy] = RVec4(color, 0.0);
 #else
 #else
-	FragOut output;
-	output.m_svTarget = color;
-	return output;
+	return color;
 #endif
 #endif
 }
 }

+ 7 - 28
AnKi/Shaders/BloomUpscale.hlsl

@@ -21,22 +21,6 @@ constexpr F32 kHaloOpacity = 0.5;
 [[vk::binding(1)]] Texture2D<RVec4> g_inputTex;
 [[vk::binding(1)]] Texture2D<RVec4> g_inputTex;
 [[vk::binding(2)]] Texture2D<RVec3> g_lensDirtTex;
 [[vk::binding(2)]] Texture2D<RVec3> g_lensDirtTex;
 
 
-struct CompIn
-{
-	UVec3 m_svDispatchThreadId : SV_DISPATCHTHREADID;
-};
-
-struct VertOut
-{
-	Vec4 m_position : SV_POSITION;
-	[[vk::location(0)]] Vec2 m_uv : TEXCOORD;
-};
-
-struct FragOut
-{
-	RVec3 m_svTarget : SV_TARGET0;
-};
-
 #if defined(ANKI_COMPUTE_SHADER)
 #if defined(ANKI_COMPUTE_SHADER)
 #	define THREADGROUP_SIZE_XY 8
 #	define THREADGROUP_SIZE_XY 8
 [[vk::binding(3)]] RWTexture2D<RVec4> g_outUav;
 [[vk::binding(3)]] RWTexture2D<RVec4> g_outUav;
@@ -69,7 +53,7 @@ RVec3 ssLensFlare(Vec2 uv)
 	RVec3 result = Vec3(0.0, 0.0, 0.0);
 	RVec3 result = Vec3(0.0, 0.0, 0.0);
 
 
 	// Sample ghosts
 	// Sample ghosts
-	[[unroll]] for(U32 i = 0u; i < kMaxGhosts; ++i)
+	[unroll] for(U32 i = 0u; i < kMaxGhosts; ++i)
 	{
 	{
 		const Vec2 offset = frac(flipUv + ghostVec * F32(i));
 		const Vec2 offset = frac(flipUv + ghostVec * F32(i));
 
 
@@ -107,30 +91,25 @@ RVec3 upscale(Vec2 uv)
 }
 }
 
 
 #if defined(ANKI_COMPUTE_SHADER)
 #if defined(ANKI_COMPUTE_SHADER)
-ANKI_NUMTHREADS(THREADGROUP_SIZE_XY, THREADGROUP_SIZE_XY, 1) void main(CompIn input)
+[numthreads(THREADGROUP_SIZE_XY, THREADGROUP_SIZE_XY, 1)] void main(UVec3 svDispatchThreadId : SV_DISPATCHTHREADID)
 #else
 #else
-FragOut main(VertOut input)
+RVec3 main([[vk::location(0)]] Vec2 uv : TEXCOORD) : SV_TARGET0
 #endif
 #endif
 {
 {
 #if defined(ANKI_COMPUTE_SHADER)
 #if defined(ANKI_COMPUTE_SHADER)
-	if(skipOutOfBoundsInvocations(UVec2(THREADGROUP_SIZE_XY, THREADGROUP_SIZE_XY), kViewport,
-								  input.m_svDispatchThreadId))
+	if(skipOutOfBoundsInvocations(UVec2(THREADGROUP_SIZE_XY, THREADGROUP_SIZE_XY), kViewport, svDispatchThreadId))
 	{
 	{
 		return;
 		return;
 	}
 	}
 
 
-	const Vec2 uv = (Vec2(input.m_svDispatchThreadId.xy) + 0.5) / Vec2(kViewport);
-#else
-	const Vec2 uv = input.m_uv;
+	const Vec2 uv = (Vec2(svDispatchThreadId.xy) + 0.5) / Vec2(kViewport);
 #endif
 #endif
 
 
 	const RVec3 outColor = ssLensFlare(uv) + upscale(uv);
 	const RVec3 outColor = ssLensFlare(uv) + upscale(uv);
 
 
 #if defined(ANKI_COMPUTE_SHADER)
 #if defined(ANKI_COMPUTE_SHADER)
-	g_outUav[input.m_svDispatchThreadId.xy] = RVec4(outColor, 0.0);
+	g_outUav[svDispatchThreadId.xy] = RVec4(outColor, 0.0);
 #else
 #else
-	FragOut output;
-	output.m_svTarget = outColor;
-	return output;
+	return outColor;
 #endif
 #endif
 }
 }

+ 1 - 1
AnKi/Shaders/ClearTextureCompute.ankiprog

@@ -38,7 +38,7 @@ struct Uniforms
 #	endif
 #	endif
 #endif
 #endif
 
 
-ANKI_NUMTHREADS(8, 8, (TEXTURE_DIMENSIONS == 2) ? 1 : 8) void main(UVec3 svDispatchThreadId : SV_DISPATCHTHREADID)
+[numthreads(8, 8, (TEXTURE_DIMENSIONS == 2) ? 1 : 8)] void main(UVec3 svDispatchThreadId : SV_DISPATCHTHREADID)
 {
 {
 #if TEXTURE_DIMENSIONS == 2
 #if TEXTURE_DIMENSIONS == 2
 	UVec2 texSize;
 	UVec2 texSize;

+ 2 - 2
AnKi/Shaders/ClusterBinning.ankiprog

@@ -71,8 +71,8 @@ Bool isGiProbe(U32 objectIdx)
 	return objectIdx < g_unis.m_objectCountsUpTo[kClusterObjectTypeGlobalIlluminationProbe].x;
 	return objectIdx < g_unis.m_objectCountsUpTo[kClusterObjectTypeGlobalIlluminationProbe].x;
 }
 }
 
 
-ANKI_NUMTHREADS(THREADGROUP_SIZE, 1, 1)
-void main(UVec3 svDispatchThreadId : SV_DISPATCHTHREADID, U32 svGroupIdx : SV_GROUPINDEX)
+[numthreads(THREADGROUP_SIZE, 1, 1)] void main(UVec3 svDispatchThreadId : SV_DISPATCHTHREADID,
+											   U32 svGroupIdx : SV_GROUPINDEX)
 {
 {
 	const U32 dispatchThreadIdX = min(svDispatchThreadId.x, kTileCount * kSampleCount);
 	const U32 dispatchThreadIdX = min(svDispatchThreadId.x, kTileCount * kSampleCount);
 	const U32 tileIdx = dispatchThreadIdX / kSampleCount;
 	const U32 tileIdx = dispatchThreadIdX / kSampleCount;

+ 1 - 1
AnKi/Shaders/ClusteredShadingCommon.hlsl

@@ -146,7 +146,7 @@ U32 computeZSplitClusterIndex(F32 depth, U32 zSplitCount, F32 a, F32 b)
 /// Return the tile index.
 /// Return the tile index.
 U32 computeTileClusterIndexFragCoord(Vec2 fragCoord, U32 tileSize, U32 tileCountX)
 U32 computeTileClusterIndexFragCoord(Vec2 fragCoord, U32 tileSize, U32 tileCountX)
 {
 {
-	const UVec2 tileXY = UVec2(fragCoord / (F32)tileSize);
+	const UVec2 tileXY = UVec2(fragCoord / F32(tileSize));
 	return tileXY.y * tileCountX + tileXY.x;
 	return tileXY.y * tileCountX + tileXY.x;
 }
 }
 
 

+ 4 - 5
AnKi/Shaders/DepthAwareBlur.hlsl

@@ -58,10 +58,9 @@ void sampleTex(Vec2 uv, F32 refDepth, inout ColorType col, inout F32 weight)
 }
 }
 
 
 #if defined(ANKI_COMPUTE_SHADER)
 #if defined(ANKI_COMPUTE_SHADER)
-ANKI_NUMTHREADS(THREADGROUP_SQRT_SIZE, THREADGROUP_SQRT_SIZE, 1)
-void main(UVec3 svDispatchThreadId : SV_DISPATCHTHREADID)
+[numthreads(THREADGROUP_SQRT_SIZE, THREADGROUP_SQRT_SIZE, 1)] void main(UVec3 svDispatchThreadId : SV_DISPATCHTHREADID)
 #else
 #else
-ColorType main([[vk::location(0)]] Vec2 uv : TEXCOORD): SV_TARGET0
+ColorType main([[vk::location(0)]] Vec2 uv : TEXCOORD) : SV_TARGET0
 #endif
 #endif
 {
 {
 	UVec2 textureSize;
 	UVec2 textureSize;
@@ -70,7 +69,7 @@ ColorType main([[vk::location(0)]] Vec2 uv : TEXCOORD): SV_TARGET0
 
 
 	// Set UVs
 	// Set UVs
 #if defined(ANKI_COMPUTE_SHADER)
 #if defined(ANKI_COMPUTE_SHADER)
-	[[branch]] if(svDispatchThreadId.x >= textureSize.x || svDispatchThreadId.y >= textureSize.y)
+	[branch] if(svDispatchThreadId.x >= textureSize.x || svDispatchThreadId.y >= textureSize.y)
 	{
 	{
 		// Out of bounds
 		// Out of bounds
 		return;
 		return;
@@ -98,7 +97,7 @@ ColorType main([[vk::location(0)]] Vec2 uv : TEXCOORD): SV_TARGET0
 	Vec2 uvOffset = Vec2(0.0, 0.0);
 	Vec2 uvOffset = Vec2(0.0, 0.0);
 	uvOffset.X_OR_Y = 1.5 * texelSize.X_OR_Y;
 	uvOffset.X_OR_Y = 1.5 * texelSize.X_OR_Y;
 
 
-	[[unroll]] for(U32 i = 0u; i < (SAMPLE_COUNT - 1u) / 2u; ++i)
+	[unroll] for(U32 i = 0u; i < (SAMPLE_COUNT - 1u) / 2u; ++i)
 	{
 	{
 		sampleTex(uv + uvOffset, refDepth, color, weight);
 		sampleTex(uv + uvOffset, refDepth, color, weight);
 		sampleTex(uv - uvOffset, refDepth, color, weight);
 		sampleTex(uv - uvOffset, refDepth, color, weight);

+ 1 - 1
AnKi/Shaders/DepthDownscaleCompute.ankiprog

@@ -106,7 +106,7 @@ AF4 SpdReduce4(AF4 v0, AF4 v1, AF4 v2, AF4 v3)
 
 
 #include <ThirdParty/FidelityFX/ffx_spd.h>
 #include <ThirdParty/FidelityFX/ffx_spd.h>
 
 
-ANKI_NUMTHREADS(256, 1, 1) void main(UVec3 svGroupId : SV_GROUPID, U32 svGroupIndex : SV_GROUPINDEX)
+[numthreads(256, 1, 1)] void main(UVec3 svGroupId : SV_GROUPID, U32 svGroupIndex : SV_GROUPINDEX)
 {
 {
 	const U32 slice = 0u;
 	const U32 slice = 0u;
 	const UVec2 offset = UVec2(0, 0);
 	const UVec2 offset = UVec2(0, 0);

+ 1 - 1
AnKi/Shaders/DepthDownscaleRaster.ankiprog

@@ -25,7 +25,7 @@ struct Uniforms
 };
 };
 [[vk::push_constant]] ConstantBuffer<Uniforms> g_uniforms;
 [[vk::push_constant]] ConstantBuffer<Uniforms> g_uniforms;
 
 
-F32 main([[vk::location(0)]] Vec2 uv : TEXCOORD, Vec4 svPosition : SV_POSITION): SV_TARGET0
+F32 main([[vk::location(0)]] Vec2 uv : TEXCOORD, Vec4 svPosition : SV_POSITION) : SV_TARGET0
 {
 {
 	F32 output;
 	F32 output;
 #if REDUCTION_SAMPLER
 #if REDUCTION_SAMPLER

+ 2 - 2
AnKi/Shaders/DownscaleBlur.hlsl

@@ -27,9 +27,9 @@ struct Uniforms
 #endif
 #endif
 
 
 #if defined(ANKI_COMPUTE_SHADER)
 #if defined(ANKI_COMPUTE_SHADER)
-ANKI_NUMTHREADS(8, 8, 1) void main(UVec4 svDispatchThreadId : SV_DISPATCHTHREADID)
+[numthreads(8, 8, 1)] void main(UVec4 svDispatchThreadId : SV_DISPATCHTHREADID)
 #else
 #else
-RVec3 main([[vk::location(0)]] Vec2 uv : TEXCOORD): SV_TARGET0
+RVec3 main([[vk::location(0)]] Vec2 uv : TEXCOORD) : SV_TARGET0
 #endif
 #endif
 {
 {
 #if defined(ANKI_COMPUTE_SHADER)
 #if defined(ANKI_COMPUTE_SHADER)

+ 4 - 18
AnKi/Shaders/FinalComposite.ankiprog

@@ -24,7 +24,6 @@ ANKI_SPECIALIZATION_CONSTANT_U32(kMotionBlurSamples, 3u);
 [[vk::binding(0)]] SamplerState g_nearestAnyClampSampler;
 [[vk::binding(0)]] SamplerState g_nearestAnyClampSampler;
 [[vk::binding(1)]] SamplerState g_linearAnyClampSampler;
 [[vk::binding(1)]] SamplerState g_linearAnyClampSampler;
 [[vk::binding(2)]] SamplerState g_trilinearRepeatSampler;
 [[vk::binding(2)]] SamplerState g_trilinearRepeatSampler;
-
 [[vk::binding(3)]] Texture2D<RVec4> g_lightShadingRt;
 [[vk::binding(3)]] Texture2D<RVec4> g_lightShadingRt;
 [[vk::binding(4)]] Texture2D<RVec4> g_ppsBloomLfRt;
 [[vk::binding(4)]] Texture2D<RVec4> g_ppsBloomLfRt;
 [[vk::binding(5)]] Texture3D<RVec4> g_lut;
 [[vk::binding(5)]] Texture3D<RVec4> g_lut;
@@ -43,19 +42,9 @@ struct PushConstants
 
 
 [[vk::push_constant]] ConstantBuffer<PushConstants> g_pc;
 [[vk::push_constant]] ConstantBuffer<PushConstants> g_pc;
 
 
-struct VertOut
-{
-	[[vk::location(0)]] Vec2 m_uv : TEXCOORD;
-};
-
-struct FragOut
-{
-	RVec3 m_color : SV_TARGET0;
-};
-
 RVec3 colorGrading(RVec3 color)
 RVec3 colorGrading(RVec3 color)
 {
 {
-	constexpr RF32 kLutSizef = (RF32)kLutSize;
+	constexpr RF32 kLutSizef = RF32(kLutSize);
 	constexpr RVec3 kLutScale = ((kLutSizef - 1.0) / kLutSizef).xxx;
 	constexpr RVec3 kLutScale = ((kLutSizef - 1.0) / kLutSizef).xxx;
 	constexpr RVec3 kLutOffset = (1.0 / (2.0 * kLutSize)).xxx;
 	constexpr RVec3 kLutOffset = (1.0 / (2.0 * kLutSize)).xxx;
 
 
@@ -64,9 +53,8 @@ RVec3 colorGrading(RVec3 color)
 	return g_lut.SampleLevel(g_trilinearRepeatSampler, lutCoords, 0.0).rgb;
 	return g_lut.SampleLevel(g_trilinearRepeatSampler, lutCoords, 0.0).rgb;
 }
 }
 
 
-FragOut main(VertOut input)
+RVec3 main([[vk::location(0)]] Vec2 uv : TEXCOORD) : SV_TARGET0
 {
 {
-	const Vec2 uv = input.m_uv;
 	RVec3 outColor;
 	RVec3 outColor;
 
 
 	if(kMotionBlurSamples > 0u)
 	if(kMotionBlurSamples > 0u)
@@ -88,7 +76,7 @@ FragOut main(VertOut input)
 
 
 #if FILM_GRAIN
 #if FILM_GRAIN
 	const F32 dt = 1.0;
 	const F32 dt = 1.0;
-	outColor = filmGrain(outColor, uv, g_pc.m_filmGrainStrength, (F32)(g_pc.m_frameCount % 0xFFFFu) * dt);
+	outColor = filmGrain(outColor, uv, g_pc.m_filmGrainStrength, F32(g_pc.m_frameCount % 0xFFFFu) * dt);
 #endif
 #endif
 
 
 #if DBG_ENABLED
 #if DBG_ENABLED
@@ -96,9 +84,7 @@ FragOut main(VertOut input)
 	outColor = lerp(outColor, dbg.rgb, dbg.a);
 	outColor = lerp(outColor, dbg.rgb, dbg.a);
 #endif
 #endif
 
 
-	FragOut output;
-	output.m_color = outColor;
-	return output;
+	return outColor;
 }
 }
 
 
 #pragma anki end
 #pragma anki end

+ 1 - 1
AnKi/Shaders/ForwardShadingCommon.glsl

@@ -104,7 +104,7 @@ Vec3 computeLightColorHigh(Vec3 diffCol, Vec3 worldPos)
 		const F32 shadow = 1.0;
 		const F32 shadow = 1.0;
 #	else
 #	else
 		F32 shadow = 1.0;
 		F32 shadow = 1.0;
-		[[branch]] if(light.m_shadowLayer != kMaxU32)
+		[branch] if(light.m_shadowLayer != kMaxU32)
 		{
 		{
 			shadow = computeShadowFactorSpotLight(light, worldPos, u_shadowAtlasTex, u_shadowSampler);
 			shadow = computeShadowFactorSpotLight(light, worldPos, u_shadowAtlasTex, u_shadowSampler);
 		}
 		}

+ 5 - 5
AnKi/Shaders/ForwardShadingCommon.hlsl

@@ -58,10 +58,10 @@ Vec3 computeLightColorHigh(Vec3 diffCol, Vec3 worldPos, Vec4 svPosition)
 	Cluster cluster = getClusterFragCoord(svPosition.xyz);
 	Cluster cluster = getClusterFragCoord(svPosition.xyz);
 
 
 	// Point lights
 	// Point lights
-	[[loop]] while(cluster.m_pointLightsMask != (ExtendedClusterObjectMask)0)
+	[loop] while(cluster.m_pointLightsMask != 0)
 	{
 	{
 		const I32 idx = firstbitlow2(cluster.m_pointLightsMask);
 		const I32 idx = firstbitlow2(cluster.m_pointLightsMask);
-		cluster.m_pointLightsMask &= ~((ExtendedClusterObjectMask)1 << (ExtendedClusterObjectMask)idx);
+		cluster.m_pointLightsMask &= ~(ExtendedClusterObjectMask(1) << ExtendedClusterObjectMask(idx));
 		const PointLight light = g_pointLights[idx];
 		const PointLight light = g_pointLights[idx];
 
 
 		const Vec3 diffC = diffCol * light.m_diffuseColor;
 		const Vec3 diffC = diffCol * light.m_diffuseColor;
@@ -83,10 +83,10 @@ Vec3 computeLightColorHigh(Vec3 diffCol, Vec3 worldPos, Vec4 svPosition)
 	}
 	}
 
 
 	// Spot lights
 	// Spot lights
-	[[loop]] while(cluster.m_spotLightsMask != (ExtendedClusterObjectMask)0)
+	[loop] while(cluster.m_spotLightsMask != 0)
 	{
 	{
 		const I32 idx = firstbitlow2(cluster.m_spotLightsMask);
 		const I32 idx = firstbitlow2(cluster.m_spotLightsMask);
-		cluster.m_spotLightsMask &= ~((ExtendedClusterObjectMask)1 << (ExtendedClusterObjectMask)idx);
+		cluster.m_spotLightsMask &= ~(ExtendedClusterObjectMask(1) << ExtendedClusterObjectMask(idx));
 		const SpotLight light = g_spotLights[idx];
 		const SpotLight light = g_spotLights[idx];
 
 
 		const Vec3 diffC = diffCol * light.m_diffuseColor;
 		const Vec3 diffC = diffCol * light.m_diffuseColor;
@@ -102,7 +102,7 @@ Vec3 computeLightColorHigh(Vec3 diffCol, Vec3 worldPos, Vec4 svPosition)
 		const F32 shadow = 1.0;
 		const F32 shadow = 1.0;
 #	else
 #	else
 		F32 shadow = 1.0;
 		F32 shadow = 1.0;
-		[[branch]] if(light.m_shadowLayer != kMaxU32)
+		[branch] if(light.m_shadowLayer != kMaxU32)
 		{
 		{
 			shadow = computeShadowFactorSpotLight(light, worldPos, g_shadowAtlasTex, g_shadowSampler);
 			shadow = computeShadowFactorSpotLight(light, worldPos, g_shadowAtlasTex, g_shadowSampler);
 		}
 		}

+ 1 - 1
AnKi/Shaders/GBufferGeneric.ankiprog

@@ -135,7 +135,7 @@ void skinning(VertIn input, inout Vec3 pos, inout Vec3 prevPos, inout RVec3 norm
 {
 {
 	Mat4 skinMat = g_boneTransforms[input.m_boneIndices[0]] * input.m_boneWeights[0];
 	Mat4 skinMat = g_boneTransforms[input.m_boneIndices[0]] * input.m_boneWeights[0];
 	Mat4 prevSkinMat = g_prevFrameBoneTransforms[input.m_boneIndices[0]] * input.m_boneWeights[0];
 	Mat4 prevSkinMat = g_prevFrameBoneTransforms[input.m_boneIndices[0]] * input.m_boneWeights[0];
-	[[unroll]] for(U32 i = 1u; i < 4u; ++i)
+	[unroll] for(U32 i = 1u; i < 4u; ++i)
 	{
 	{
 		skinMat = skinMat + g_boneTransforms[input.m_boneIndices[i]] * input.m_boneWeights[i];
 		skinMat = skinMat + g_boneTransforms[input.m_boneIndices[i]] * input.m_boneWeights[i];
 		prevSkinMat = prevSkinMat + g_prevFrameBoneTransforms[input.m_boneIndices[i]] * input.m_boneWeights[i];
 		prevSkinMat = prevSkinMat + g_prevFrameBoneTransforms[input.m_boneIndices[i]] * input.m_boneWeights[i];

+ 1 - 1
AnKi/Shaders/GBufferPost.ankiprog

@@ -61,7 +61,7 @@ FragOut main([[vk::location(0)]] Vec2 uv : TEXCOORD, Vec4 svPosition : SV_POSITI
 		discard;
 		discard;
 	}
 	}
 
 
-	[[loop]] while(cluster.m_decalsMask != 0)
+	[loop] while(cluster.m_decalsMask != 0)
 	{
 	{
 		const I32 idx = firstbitlow2(cluster.m_decalsMask);
 		const I32 idx = firstbitlow2(cluster.m_decalsMask);
 		cluster.m_decalsMask &= ~((ExtendedClusterObjectMask)1 << (ExtendedClusterObjectMask)idx);
 		cluster.m_decalsMask &= ~((ExtendedClusterObjectMask)1 << (ExtendedClusterObjectMask)idx);

+ 2 - 2
AnKi/Shaders/GaussianBlur.glsl

@@ -60,7 +60,7 @@ void main()
 {
 {
 	// Set UVs
 	// Set UVs
 #if USE_COMPUTE
 #if USE_COMPUTE
-	[[branch]] if(gl_GlobalInvocationID.x >= kTextureSize.x || gl_GlobalInvocationID.y >= kTextureSize.y)
+	[branch] if(gl_GlobalInvocationID.x >= kTextureSize.x || gl_GlobalInvocationID.y >= kTextureSize.y)
 	{
 	{
 		// Out of bounds
 		// Out of bounds
 		return;
 		return;
@@ -87,7 +87,7 @@ void main()
 	Vec2 uvOffset = Vec2(0.0);
 	Vec2 uvOffset = Vec2(0.0);
 	uvOffset.X_OR_Y = 1.5 * TEXEL_SIZE.X_OR_Y;
 	uvOffset.X_OR_Y = 1.5 * TEXEL_SIZE.X_OR_Y;
 
 
-	[[unroll]] for(U32 i = 0u; i < kStepCount; ++i)
+	[unroll] for(U32 i = 0u; i < kStepCount; ++i)
 	{
 	{
 		COL_TYPE col = textureLod(u_tex, u_linearAnyClampSampler, uv + uvOffset, 0.0).TEX_FETCH;
 		COL_TYPE col = textureLod(u_tex, u_linearAnyClampSampler, uv + uvOffset, 0.0).TEX_FETCH;
 		col += textureLod(u_tex, u_linearAnyClampSampler, uv - uvOffset, 0.0).TEX_FETCH;
 		col += textureLod(u_tex, u_linearAnyClampSampler, uv - uvOffset, 0.0).TEX_FETCH;

+ 1 - 1
AnKi/Shaders/GpuParticlesSimulation.ankiprog

@@ -82,7 +82,7 @@ void initParticle(UVec3 svDispatchThreadId, out GpuParticle p)
 	p.m_velocity = acceleration * g_state.m_dt;
 	p.m_velocity = acceleration * g_state.m_dt;
 }
 }
 
 
-ANKI_NUMTHREADS(64, 1, 1) void main(UVec3 svDispatchThreadId : SV_DISPATCHTHREADID)
+[numthreads(64, 1, 1)] void main(UVec3 svDispatchThreadId : SV_DISPATCHTHREADID)
 {
 {
 	const U32 particleIdx = svDispatchThreadId.x;
 	const U32 particleIdx = svDispatchThreadId.x;
 	if(particleIdx >= g_props.m_particleCount)
 	if(particleIdx >= g_props.m_particleCount)

+ 1 - 1
AnKi/Shaders/GpuSceneMicroPatching.ankiprog

@@ -13,7 +13,7 @@
 [[vk::binding(1)]] StructuredBuffer<U32> g_srcBuffer;
 [[vk::binding(1)]] StructuredBuffer<U32> g_srcBuffer;
 [[vk::binding(2)]] RWStructuredBuffer<U32> g_dstBuffer;
 [[vk::binding(2)]] RWStructuredBuffer<U32> g_dstBuffer;
 
 
-ANKI_NUMTHREADS(64, 1, 1) void main(UVec3 svGroupId : SV_GROUPID, U32 svGroupIndex : SV_GROUPINDEX)
+[numthreads(64, 1, 1)] void main(UVec3 svGroupId : SV_GROUPID, U32 svGroupIndex : SV_GROUPINDEX)
 {
 {
 	const UVec2 header = g_patchHeaders[svGroupId.x];
 	const UVec2 header = g_patchHeaders[svGroupId.x];
 	const U32 dwordCount = (header.x >> 26u) + 1u;
 	const U32 dwordCount = (header.x >> 26u) + 1u;

+ 3 - 4
AnKi/Shaders/Include/Common.h

@@ -61,10 +61,6 @@ void maybeUnused(T a)
 }
 }
 #	define ANKI_MAYBE_UNUSED(x) maybeUnused(x)
 #	define ANKI_MAYBE_UNUSED(x) maybeUnused(x)
 
 
-// Use a define because the [] annoyes clang-format
-#	define _ANKI_NUMTHREADS
-#	define ANKI_NUMTHREADS(x, y, z) _ANKI_NUMTHREADS[numthreads(x, y, z)]
-
 #	define _ANKI_CONCATENATE(a, b) a##b
 #	define _ANKI_CONCATENATE(a, b) a##b
 #	define ANKI_CONCATENATE(a, b) _ANKI_CONCATENATE(a, b)
 #	define ANKI_CONCATENATE(a, b) _ANKI_CONCATENATE(a, b)
 
 
@@ -428,6 +424,9 @@ constexpr F32 kPi = 3.14159265358979323846f;
 #		extension GL_EXT_ray_tracing : enable
 #		extension GL_EXT_ray_tracing : enable
 #	endif
 #	endif
 
 
+#	define unroll [unroll]
+#	define branch [branch]
+
 #	define F32 float
 #	define F32 float
 const uint kSizeof_float = 4u;
 const uint kSizeof_float = 4u;
 #	define Vec2 vec2
 #	define Vec2 vec2

+ 3 - 3
AnKi/Shaders/IndirectDiffuse.hlsl

@@ -48,9 +48,9 @@ Vec4 cheapProject(Vec4 point_)
 }
 }
 
 
 #if defined(ANKI_COMPUTE_SHADER)
 #if defined(ANKI_COMPUTE_SHADER)
-ANKI_NUMTHREADS(8, 8, 1) void main(UVec3 svDispatchThreadId : SV_DISPATCHTHREADID)
+[numthreads(8, 8, 1)] void main(UVec3 svDispatchThreadId : SV_DISPATCHTHREADID)
 #else
 #else
-RVec3 main([[vk::location(0)]] Vec2 uv : TEXCOORD, Vec4 svPosition : SV_POSITION): SV_TARGET0
+RVec3 main([[vk::location(0)]] Vec2 uv : TEXCOORD, Vec4 svPosition : SV_POSITION) : SV_TARGET0
 #endif
 #endif
 {
 {
 #if defined(ANKI_COMPUTE_SHADER)
 #if defined(ANKI_COMPUTE_SHADER)
@@ -173,7 +173,7 @@ RVec3 main([[vk::location(0)]] Vec2 uv : TEXCOORD, Vec4 svPosition : SV_POSITION
 			F32 totalBlendWeight = kEpsilonF32;
 			F32 totalBlendWeight = kEpsilonF32;
 
 
 			// Loop probes
 			// Loop probes
-			[[loop]] while(cluster.m_giProbesMask != 0u)
+			[loop] while(cluster.m_giProbesMask != 0u)
 			{
 			{
 				const U32 idx = U32(firstbitlow2(cluster.m_giProbesMask));
 				const U32 idx = U32(firstbitlow2(cluster.m_giProbesMask));
 				cluster.m_giProbesMask &= ~(1u << idx);
 				cluster.m_giProbesMask &= ~(1u << idx);

+ 3 - 3
AnKi/Shaders/IndirectDiffuseDenoise.hlsl

@@ -31,10 +31,10 @@ Vec3 unproject(Vec2 ndc, F32 depth)
 }
 }
 
 
 #if defined(ANKI_COMPUTE_SHADER)
 #if defined(ANKI_COMPUTE_SHADER)
-ANKI_NUMTHREADS(THREAD_GROUP_SIZE_SQRT, THREAD_GROUP_SIZE_SQRT, 1)
-void main(UVec3 svDispatchThreadId : SV_DISPATCHTHREADID)
+[numthreads(THREAD_GROUP_SIZE_SQRT, THREAD_GROUP_SIZE_SQRT, 1)] void
+main(UVec3 svDispatchThreadId : SV_DISPATCHTHREADID)
 #else
 #else
-RVec3 main([[vk::location(0)]] Vec2 uv : TEXCOORD): SV_TARGET0
+RVec3 main([[vk::location(0)]] Vec2 uv : TEXCOORD) : SV_TARGET0
 #endif
 #endif
 {
 {
 #if defined(ANKI_COMPUTE_SHADER)
 #if defined(ANKI_COMPUTE_SHADER)

+ 2 - 2
AnKi/Shaders/IndirectDiffuseVrsSriGeneration.ankiprog

@@ -113,7 +113,7 @@ void main()
 
 
 #if SHARED_MEMORY
 #if SHARED_MEMORY
 	// Store results in shared memory.
 	// Store results in shared memory.
-	[[branch]] if(subgroupElect())
+	[branch] if(subgroupElect())
 	{
 	{
 		s_maxDerivative[gl_SubgroupID] = Vec2(maxDerivativeX, maxDerivativeY);
 		s_maxDerivative[gl_SubgroupID] = Vec2(maxDerivativeX, maxDerivativeY);
 	}
 	}
@@ -123,7 +123,7 @@ void main()
 #endif
 #endif
 
 
 	// Write the result
 	// Write the result
-	[[branch]] if(gl_LocalInvocationIndex == 0u)
+	[branch] if(gl_LocalInvocationIndex == 0u)
 	{
 	{
 		// Get max across all subgroups.
 		// Get max across all subgroups.
 #if SHARED_MEMORY
 #if SHARED_MEMORY

+ 4 - 4
AnKi/Shaders/IndirectSpecular.glsl

@@ -109,7 +109,7 @@ void main()
 
 
 #if EXTRA_REJECTION
 #if EXTRA_REJECTION
 	// Reject backfacing
 	// Reject backfacing
-	[[branch]] if(ssrAttenuation > 0.0)
+	[branch] if(ssrAttenuation > 0.0)
 	{
 	{
 		const Vec3 hitNormal =
 		const Vec3 hitNormal =
 			u_unis.m_normalMat
 			u_unis.m_normalMat
@@ -121,7 +121,7 @@ void main()
 	}
 	}
 
 
 	// Reject far from hit point
 	// Reject far from hit point
-	[[branch]] if(ssrAttenuation > 0.0)
+	[branch] if(ssrAttenuation > 0.0)
 	{
 	{
 		const F32 depth = textureLod(u_depthRt, u_trilinearClampSampler, hitPoint.xy, 0.0).r;
 		const F32 depth = textureLod(u_depthRt, u_trilinearClampSampler, hitPoint.xy, 0.0).r;
 		Vec4 viewPos4 = u_unis.m_invProjMat * Vec4(UV_TO_NDC(hitPoint.xy), depth, 1.0);
 		Vec4 viewPos4 = u_unis.m_invProjMat * Vec4(UV_TO_NDC(hitPoint.xy), depth, 1.0);
@@ -139,7 +139,7 @@ void main()
 
 
 	// Read the reflection
 	// Read the reflection
 	Vec3 outColor = Vec3(0.0);
 	Vec3 outColor = Vec3(0.0);
-	[[branch]] if(ssrAttenuation > 0.0)
+	[branch] if(ssrAttenuation > 0.0)
 	{
 	{
 		// Reproject the UV because you are reading the previous frame
 		// Reproject the UV because you are reading the previous frame
 		const Vec4 v4 = u_unis.m_prevViewProjMatMulInvViewProjMat * Vec4(UV_TO_NDC(hitPoint.xy), hitPoint.z, 1.0);
 		const Vec4 v4 = u_unis.m_prevViewProjMatMulInvViewProjMat * Vec4(UV_TO_NDC(hitPoint.xy), hitPoint.z, 1.0);
@@ -180,7 +180,7 @@ void main()
 	}
 	}
 
 
 	// Read probes
 	// Read probes
-	[[branch]] if(ssrAttenuation < 1.0)
+	[branch] if(ssrAttenuation < 1.0)
 	{
 	{
 #if defined(ANKI_COMPUTE_SHADER)
 #if defined(ANKI_COMPUTE_SHADER)
 		const Vec2 fragCoord = Vec2(gl_GlobalInvocationID.xy) + 0.5;
 		const Vec2 fragCoord = Vec2(gl_GlobalInvocationID.xy) + 0.5;

+ 10 - 10
AnKi/Shaders/IrradianceDice.ankiprog

@@ -94,14 +94,14 @@ void main()
 	}
 	}
 
 
 	// Subgroup reduce
 	// Subgroup reduce
-	[[unroll]] for(U32 f = 0u; f < 6u; ++f)
+	[unroll] for(U32 f = 0u; f < 6u; ++f)
 	{
 	{
 		resultFaces[f] = subgroupAdd(resultFaces[f]);
 		resultFaces[f] = subgroupAdd(resultFaces[f]);
 	}
 	}
 
 
-	[[branch]] if(subgroupElect())
+	[branch] if(subgroupElect())
 	{
 	{
-		[[unroll]] for(U32 f = 0u; f < 6u; ++f)
+		[unroll] for(U32 f = 0u; f < 6u; ++f)
 		{
 		{
 			s_integrationResults[f][gl_SubgroupID] = resultFaces[f];
 			s_integrationResults[f][gl_SubgroupID] = resultFaces[f];
 		}
 		}
@@ -111,9 +111,9 @@ void main()
 	barrier();
 	barrier();
 
 
 	// Worgroup reduce
 	// Worgroup reduce
-	[[branch]] if(gl_LocalInvocationIndex == 0u)
+	[branch] if(gl_LocalInvocationIndex == 0u)
 	{
 	{
-		[[unroll]] for(U32 f = 0u; f < 6u; ++f)
+		[unroll] for(U32 f = 0u; f < 6u; ++f)
 		{
 		{
 			for(U32 i = 1u; i < gl_NumSubgroups; ++i)
 			for(U32 i = 1u; i < gl_NumSubgroups; ++i)
 			{
 			{
@@ -162,14 +162,14 @@ void main()
 	}
 	}
 
 
 	// Subgroup reduce
 	// Subgroup reduce
-	[[unroll]] for(U32 f = 0u; f < 6u; ++f)
+	[unroll] for(U32 f = 0u; f < 6u; ++f)
 	{
 	{
 		resultFaces[f] = subgroupAdd(resultFaces[f]);
 		resultFaces[f] = subgroupAdd(resultFaces[f]);
 	}
 	}
 
 
-	[[branch]] if(subgroupElect())
+	[branch] if(subgroupElect())
 	{
 	{
-		[[unroll]] for(U32 f = 0u; f < 6u; ++f)
+		[unroll] for(U32 f = 0u; f < 6u; ++f)
 		{
 		{
 			s_integrationResults[f][gl_SubgroupID] = resultFaces[f];
 			s_integrationResults[f][gl_SubgroupID] = resultFaces[f];
 		}
 		}
@@ -179,9 +179,9 @@ void main()
 	barrier();
 	barrier();
 
 
 	// Worgroup reduce
 	// Worgroup reduce
-	[[branch]] if(gl_LocalInvocationIndex == 0u)
+	[branch] if(gl_LocalInvocationIndex == 0u)
 	{
 	{
-		[[unroll]] for(U32 f = 0u; f < 6u; ++f)
+		[unroll] for(U32 f = 0u; f < 6u; ++f)
 		{
 		{
 			for(U32 i = 1u; i < gl_NumSubgroups; ++i)
 			for(U32 i = 1u; i < gl_NumSubgroups; ++i)
 			{
 			{

+ 4 - 4
AnKi/Shaders/LightFunctions.glsl

@@ -123,7 +123,7 @@ ANKI_RP F32 computeShadowFactorSpotLightPcf(SpotLight light, Vec3 worldPos, text
 	const F32 cosTheta = cos(randFactor * 2.0 * kPi);
 	const F32 cosTheta = cos(randFactor * 2.0 * kPi);
 
 
 	ANKI_RP F32 shadow = 0.0;
 	ANKI_RP F32 shadow = 0.0;
-	[[unroll]] for(U32 i = 0u; i < 4u; ++i)
+	[unroll] for(U32 i = 0u; i < 4u; ++i)
 	{
 	{
 		const Vec2 diskPoint = kPoissonDisk[i] * kPcfScale;
 		const Vec2 diskPoint = kPoissonDisk[i] * kPcfScale;
 
 
@@ -194,7 +194,7 @@ ANKI_RP F32 computeShadowFactorPointLightGeneric(PointLight light, Vec3 frag2Lig
 		const F32 cosTheta = cos(randFactor * 2.0 * kPi);
 		const F32 cosTheta = cos(randFactor * 2.0 * kPi);
 
 
 		shadow = 0.0;
 		shadow = 0.0;
-		[[unroll]] for(U32 i = 0u; i < 4u; ++i)
+		[unroll] for(U32 i = 0u; i < 4u; ++i)
 		{
 		{
 			const Vec2 diskPoint = kPoissonDisk[i] * kPcfScale;
 			const Vec2 diskPoint = kPoissonDisk[i] * kPcfScale;
 
 
@@ -271,7 +271,7 @@ ANKI_RP F32 computeShadowFactorDirLightGeneric(DirectionalLight light, U32 casca
 		const F32 cosTheta = cos(randFactor * 2.0 * kPi);
 		const F32 cosTheta = cos(randFactor * 2.0 * kPi);
 
 
 		shadow = 0.0;
 		shadow = 0.0;
-		[[unroll]] for(U32 i = 0u; i < 4u; ++i)
+		[unroll] for(U32 i = 0u; i < 4u; ++i)
 		{
 		{
 			const Vec2 diskPoint = kPoissonDisk[i] * kPcfScale;
 			const Vec2 diskPoint = kPoissonDisk[i] * kPcfScale;
 
 
@@ -420,7 +420,7 @@ ANKI_RP Vec3 sampleGlobalIllumination(const Vec3 worldPos, const Vec3 normal, co
 
 
 	// Read the irradiance
 	// Read the irradiance
 	ANKI_RP Vec3 irradiancePerDir[6u];
 	ANKI_RP Vec3 irradiancePerDir[6u];
-	[[unroll]] for(U32 dir = 0u; dir < 6u; ++dir)
+	[unroll] for(U32 dir = 0u; dir < 6u; ++dir)
 	{
 	{
 		// Point to the correct UV
 		// Point to the correct UV
 		Vec3 shiftedUVw = uvw;
 		Vec3 shiftedUVw = uvw;

+ 4 - 4
AnKi/Shaders/LightFunctions.hlsl

@@ -128,7 +128,7 @@ RF32 computeShadowFactorSpotLightPcf(SpotLight light, Vec3 worldPos, Texture2D s
 	const F32 cosTheta = cos(randFactor * 2.0 * kPi);
 	const F32 cosTheta = cos(randFactor * 2.0 * kPi);
 
 
 	RF32 shadow = 0.0;
 	RF32 shadow = 0.0;
-	[[unroll]] for(U32 i = 0u; i < 4u; ++i)
+	[unroll] for(U32 i = 0u; i < 4u; ++i)
 	{
 	{
 		const Vec2 diskPoint = kPoissonDisk[i] * kPcfScale;
 		const Vec2 diskPoint = kPoissonDisk[i] * kPcfScale;
 
 
@@ -202,7 +202,7 @@ RF32 computeShadowFactorPointLightGeneric(PointLight light, Vec3 frag2Light, Tex
 		const F32 cosTheta = cos(randFactor * 2.0 * kPi);
 		const F32 cosTheta = cos(randFactor * 2.0 * kPi);
 
 
 		shadow = 0.0;
 		shadow = 0.0;
-		[[unroll]] for(U32 i = 0u; i < 4u; ++i)
+		[unroll] for(U32 i = 0u; i < 4u; ++i)
 		{
 		{
 			const Vec2 diskPoint = kPoissonDisk[i] * kPcfScale;
 			const Vec2 diskPoint = kPoissonDisk[i] * kPcfScale;
 
 
@@ -281,7 +281,7 @@ RF32 computeShadowFactorDirLightGeneric(DirectionalLight light, U32 cascadeIdx,
 		const F32 cosTheta = cos(randFactor * 2.0 * kPi);
 		const F32 cosTheta = cos(randFactor * 2.0 * kPi);
 
 
 		shadow = 0.0;
 		shadow = 0.0;
-		[[unroll]] for(U32 i = 0u; i < 4u; ++i)
+		[unroll] for(U32 i = 0u; i < 4u; ++i)
 		{
 		{
 			const Vec2 diskPoint = kPoissonDisk[i] * kPcfScale;
 			const Vec2 diskPoint = kPoissonDisk[i] * kPcfScale;
 
 
@@ -431,7 +431,7 @@ RVec3 sampleGlobalIllumination(const Vec3 worldPos, const Vec3 normal, const Glo
 
 
 	// Read the irradiance
 	// Read the irradiance
 	RVec3 irradiancePerDir[6u];
 	RVec3 irradiancePerDir[6u];
-	[[unroll]] for(U32 dir = 0u; dir < 6u; ++dir)
+	[unroll] for(U32 dir = 0u; dir < 6u; ++dir)
 	{
 	{
 		// Point to the correct UV
 		// Point to the correct UV
 		Vec3 shiftedUVw = uvw;
 		Vec3 shiftedUVw = uvw;

+ 2 - 2
AnKi/Shaders/LightShading.ankiprog

@@ -129,7 +129,7 @@ void main()
 
 
 		LIGHTING_COMMON_BRDF();
 		LIGHTING_COMMON_BRDF();
 
 
-		[[branch]] if(light.m_shadowAtlasTileScale >= 0.0)
+		[branch] if(light.m_shadowAtlasTileScale >= 0.0)
 		{
 		{
 #if USE_SHADOW_LAYERS
 #if USE_SHADOW_LAYERS
 			const ANKI_RP F32 shadow = resolvedSm[light.m_shadowLayer];
 			const ANKI_RP F32 shadow = resolvedSm[light.m_shadowLayer];
@@ -153,7 +153,7 @@ void main()
 
 
 		const F32 spot = computeSpotFactor(l, light.m_outerCos, light.m_innerCos, light.m_direction);
 		const F32 spot = computeSpotFactor(l, light.m_outerCos, light.m_innerCos, light.m_direction);
 
 
-		[[branch]] if(light.m_shadowLayer != kMaxU32)
+		[branch] if(light.m_shadowLayer != kMaxU32)
 		{
 		{
 #if USE_SHADOW_LAYERS
 #if USE_SHADOW_LAYERS
 			const ANKI_RP F32 shadow = resolvedSm[light.m_shadowLayer];
 			const ANKI_RP F32 shadow = resolvedSm[light.m_shadowLayer];

+ 1 - 1
AnKi/Shaders/MotionBlur.hlsl

@@ -46,7 +46,7 @@ RVec3 motionBlur(Texture2D motionVectorsRt, SamplerState motionVectorsRtSampler,
 	// Sample
 	// Sample
 	const RF32 weight = 1.0 / sampleCountf;
 	const RF32 weight = 1.0 / sampleCountf;
 	RVec3 outColor = toBlurRt.SampleLevel(toBlurRtSampler, uv, 0.0).rgb * weight;
 	RVec3 outColor = toBlurRt.SampleLevel(toBlurRtSampler, uv, 0.0).rgb * weight;
-	[[loop]] for(F32 s = 1.0; s < sampleCountf; s += 1.0)
+	[loop] for(F32 s = 1.0; s < sampleCountf; s += 1.0)
 	{
 	{
 		const F32 f = s / sampleCountf;
 		const F32 f = s / sampleCountf;
 		const Vec2 sampleUv = uv + velocity * f;
 		const Vec2 sampleUv = uv + velocity * f;

+ 1 - 1
AnKi/Shaders/RtShadows.glsl

@@ -33,7 +33,7 @@ void unpackRtShadows(UVec4 packed, out F32 shadowFactors[kMaxRtShadowLayers])
 
 
 void zeroRtShadowLayers(out F32 shadowFactors[kMaxRtShadowLayers])
 void zeroRtShadowLayers(out F32 shadowFactors[kMaxRtShadowLayers])
 {
 {
-	[[unroll]] for(U32 i = 0u; i < kMaxRtShadowLayers; ++i)
+	[unroll] for(U32 i = 0u; i < kMaxRtShadowLayers; ++i)
 	{
 	{
 		shadowFactors[i] = 0.0;
 		shadowFactors[i] = 0.0;
 	}
 	}

+ 2 - 2
AnKi/Shaders/RtShadowsDenoise.ankiprog

@@ -138,7 +138,7 @@ void main()
 
 
 		w *= gaussianWeight(0.4, abs(F32(i)) / F32(sampleCount + 1u));
 		w *= gaussianWeight(0.4, abs(F32(i)) / F32(sampleCount + 1u));
 
 
-		[[unroll]] for(U32 i = 0u; i < kMaxRtShadowLayers; ++i)
+		[unroll] for(U32 i = 0u; i < kMaxRtShadowLayers; ++i)
 		{
 		{
 			shadowFactors[i] += localShadowFactors[i] * w;
 			shadowFactors[i] += localShadowFactors[i] * w;
 		}
 		}
@@ -147,7 +147,7 @@ void main()
 	}
 	}
 
 
 	// Write value
 	// Write value
-	[[unroll]] for(U32 i = 0u; i < kMaxRtShadowLayers; ++i)
+	[unroll] for(U32 i = 0u; i < kMaxRtShadowLayers; ++i)
 	{
 	{
 		shadowFactors[i] /= weight;
 		shadowFactors[i] /= weight;
 	}
 	}

+ 7 - 7
AnKi/Shaders/RtShadowsRayGen.ankiprog

@@ -103,7 +103,7 @@ void main()
 
 
 	// Dir light
 	// Dir light
 	const DirectionalLight dirLight = u_clusteredShading.m_directionalLight;
 	const DirectionalLight dirLight = u_clusteredShading.m_directionalLight;
-	[[branch]] if(dirLight.m_active != 0u && dirLight.m_shadowCascadeCount > 0u)
+	[branch] if(dirLight.m_active != 0u && dirLight.m_shadowCascadeCount > 0u)
 	{
 	{
 		for(I32 i = 0; i < RAYS_PER_PIXEL; ++i)
 		for(I32 i = 0; i < RAYS_PER_PIXEL; ++i)
 		{
 		{
@@ -111,7 +111,7 @@ void main()
 			const Vec3 rayDir = normalize(dirLightPos - worldPos);
 			const Vec3 rayDir = normalize(dirLightPos - worldPos);
 
 
 			const F32 lambertTerm = dot(rayDir, normal);
 			const F32 lambertTerm = dot(rayDir, normal);
-			[[branch]] if(lambertTerm > 0.0)
+			[branch] if(lambertTerm > 0.0)
 			{
 			{
 				shadowFactors[dirLight.m_shadowLayer] += trace(worldPos, rayDir, 10000.0) / F32(RAYS_PER_PIXEL);
 				shadowFactors[dirLight.m_shadowLayer] += trace(worldPos, rayDir, 10000.0) / F32(RAYS_PER_PIXEL);
 			}
 			}
@@ -125,7 +125,7 @@ void main()
 		cluster.m_pointLightsMask &= ~(ExtendedClusterObjectMask(1) << ExtendedClusterObjectMask(idx));
 		cluster.m_pointLightsMask &= ~(ExtendedClusterObjectMask(1) << ExtendedClusterObjectMask(idx));
 		const PointLight light = u_pointLights2[idx];
 		const PointLight light = u_pointLights2[idx];
 
 
-		[[branch]] if(light.m_shadowAtlasTileScale >= 0.0)
+		[branch] if(light.m_shadowAtlasTileScale >= 0.0)
 		{
 		{
 			for(I32 i = 0; i < RAYS_PER_PIXEL; ++i)
 			for(I32 i = 0; i < RAYS_PER_PIXEL; ++i)
 			{
 			{
@@ -136,7 +136,7 @@ void main()
 
 
 				const Bool inside = distanceToLight < light.m_radius;
 				const Bool inside = distanceToLight < light.m_radius;
 				const F32 lambertTerm = dot(rayDir, normal);
 				const F32 lambertTerm = dot(rayDir, normal);
-				[[branch]] if(inside && lambertTerm > 0.0)
+				[branch] if(inside && lambertTerm > 0.0)
 				{
 				{
 					shadowFactors[light.m_shadowLayer] +=
 					shadowFactors[light.m_shadowLayer] +=
 						trace(worldPos, rayDir, distanceToLight) / F32(RAYS_PER_PIXEL);
 						trace(worldPos, rayDir, distanceToLight) / F32(RAYS_PER_PIXEL);
@@ -152,7 +152,7 @@ void main()
 		cluster.m_spotLightsMask &= ~(ExtendedClusterObjectMask(1) << ExtendedClusterObjectMask(idx));
 		cluster.m_spotLightsMask &= ~(ExtendedClusterObjectMask(1) << ExtendedClusterObjectMask(idx));
 		const SpotLight light = u_spotLights[idx];
 		const SpotLight light = u_spotLights[idx];
 
 
-		[[branch]] if(light.m_shadowLayer != kMaxU32)
+		[branch] if(light.m_shadowLayer != kMaxU32)
 		{
 		{
 			for(I32 i = 0; i < RAYS_PER_PIXEL; ++i)
 			for(I32 i = 0; i < RAYS_PER_PIXEL; ++i)
 			{
 			{
@@ -162,7 +162,7 @@ void main()
 				const Vec3 rayDir = toLight / distanceToLight; // normalize
 				const Vec3 rayDir = toLight / distanceToLight; // normalize
 
 
 				const F32 lambertTerm = dot(rayDir, normal);
 				const F32 lambertTerm = dot(rayDir, normal);
-				[[branch]] if(lambertTerm > 0.0)
+				[branch] if(lambertTerm > 0.0)
 				{
 				{
 					shadowFactors[light.m_shadowLayer] +=
 					shadowFactors[light.m_shadowLayer] +=
 						trace(worldPos, rayDir, distanceToLight) / F32(RAYS_PER_PIXEL);
 						trace(worldPos, rayDir, distanceToLight) / F32(RAYS_PER_PIXEL);
@@ -197,7 +197,7 @@ void main()
 
 
 	// Compute the moments that will give temporal variance
 	// Compute the moments that will give temporal variance
 	Vec2 moments = Vec2(0.0);
 	Vec2 moments = Vec2(0.0);
-	[[unroll]] for(U32 i = 0u; i < kMaxRtShadowLayers; ++i)
+	[unroll] for(U32 i = 0u; i < kMaxRtShadowLayers; ++i)
 	{
 	{
 		moments.x += shadowFactors[i];
 		moments.x += shadowFactors[i];
 	}
 	}

+ 3 - 3
AnKi/Shaders/RtShadowsSvgfAtrous.ankiprog

@@ -45,7 +45,7 @@ Vec3 toViewspace(Vec2 uv, F32 depth)
 F32 computeShadowsLuma(F32 shadowLayers[kMaxRtShadowLayers])
 F32 computeShadowsLuma(F32 shadowLayers[kMaxRtShadowLayers])
 {
 {
 	F32 l = 0.0;
 	F32 l = 0.0;
-	[[unroll]] for(U32 i = 0u; i < kMaxRtShadowLayers; ++i)
+	[unroll] for(U32 i = 0u; i < kMaxRtShadowLayers; ++i)
 	{
 	{
 		l += shadowLayers[i];
 		l += shadowLayers[i];
 	}
 	}
@@ -141,7 +141,7 @@ void main()
 			// w *= kKernelWeights[abs(offsetx)] * kKernelWeights[abs(offsety)];
 			// w *= kKernelWeights[abs(offsetx)] * kKernelWeights[abs(offsety)];
 
 
 			// Sum
 			// Sum
-			[[unroll]] for(U32 i = 0u; i < kMaxRtShadowLayers; ++i)
+			[unroll] for(U32 i = 0u; i < kMaxRtShadowLayers; ++i)
 			{
 			{
 				sumShadowLayers[i] += shadowLayers[i] * w;
 				sumShadowLayers[i] += shadowLayers[i] * w;
 			}
 			}
@@ -154,7 +154,7 @@ void main()
 	// Normalize
 	// Normalize
 	sumWeight += kEpsilonf;
 	sumWeight += kEpsilonf;
 
 
-	[[unroll]] for(U32 i = 0u; i < kMaxRtShadowLayers; ++i)
+	[unroll] for(U32 i = 0u; i < kMaxRtShadowLayers; ++i)
 	{
 	{
 		sumShadowLayers[i] /= sumWeight;
 		sumShadowLayers[i] /= sumWeight;
 	}
 	}

+ 2 - 2
AnKi/Shaders/RtShadowsSvgfVariance.ankiprog

@@ -97,7 +97,7 @@ void main()
 
 
 				F32 shadowLayers[kMaxRtShadowLayers];
 				F32 shadowLayers[kMaxRtShadowLayers];
 				unpackRtShadows(textureLod(u_shadowsTex, u_nearestAnyClampSampler, sampleUv, 0.0), shadowLayers);
 				unpackRtShadows(textureLod(u_shadowsTex, u_nearestAnyClampSampler, sampleUv, 0.0), shadowLayers);
-				[[unroll]] for(U32 i = 0u; i < kMaxRtShadowLayers; ++i)
+				[unroll] for(U32 i = 0u; i < kMaxRtShadowLayers; ++i)
 				{
 				{
 					sumShadowLayers[i] += shadowLayers[i] * w;
 					sumShadowLayers[i] += shadowLayers[i] * w;
 				}
 				}
@@ -108,7 +108,7 @@ void main()
 
 
 		sumWeight += kEpsilonf;
 		sumWeight += kEpsilonf;
 
 
-		[[unroll]] for(U32 i = 0u; i < kMaxRtShadowLayers; ++i)
+		[unroll] for(U32 i = 0u; i < kMaxRtShadowLayers; ++i)
 		{
 		{
 			sumShadowLayers[i] /= sumWeight;
 			sumShadowLayers[i] /= sumWeight;
 		}
 		}

+ 2 - 2
AnKi/Shaders/ShadowmapsResolve.glsl

@@ -171,7 +171,7 @@ void main()
 		cluster.m_pointLightsMask &= ~(ExtendedClusterObjectMask(1) << ExtendedClusterObjectMask(idx));
 		cluster.m_pointLightsMask &= ~(ExtendedClusterObjectMask(1) << ExtendedClusterObjectMask(idx));
 		const PointLight light = u_pointLights2[idx];
 		const PointLight light = u_pointLights2[idx];
 
 
-		[[branch]] if(light.m_shadowAtlasTileScale >= 0.0)
+		[branch] if(light.m_shadowAtlasTileScale >= 0.0)
 		{
 		{
 			const Vec3 frag2Light = light.m_position - worldPos;
 			const Vec3 frag2Light = light.m_position - worldPos;
 
 
@@ -193,7 +193,7 @@ void main()
 		cluster.m_spotLightsMask &= ~(ExtendedClusterObjectMask(1) << ExtendedClusterObjectMask(idx));
 		cluster.m_spotLightsMask &= ~(ExtendedClusterObjectMask(1) << ExtendedClusterObjectMask(idx));
 		const SpotLight light = u_spotLights[idx];
 		const SpotLight light = u_spotLights[idx];
 
 
-		[[branch]] if(light.m_shadowLayer != kMaxU32)
+		[branch] if(light.m_shadowLayer != kMaxU32)
 		{
 		{
 #if PCF
 #if PCF
 			const ANKI_RP F32 shadowFactor = computeShadowFactorSpotLightPcf(light, worldPos, u_shadowAtlasTex,
 			const ANKI_RP F32 shadowFactor = computeShadowFactorSpotLightPcf(light, worldPos, u_shadowAtlasTex,

+ 1 - 1
AnKi/Shaders/SsRaymarching.glsl

@@ -70,7 +70,7 @@ void raymarch(Vec3 rayOrigin, // Ray origin in view space
 	// Check for view facing reflections [sakibsaikia]
 	// Check for view facing reflections [sakibsaikia]
 	const Vec3 viewDir = normalize(rayOrigin);
 	const Vec3 viewDir = normalize(rayOrigin);
 	const F32 cameraContribution = 1.0 - smoothstep(0.25, 0.5, dot(-viewDir, rayDir));
 	const F32 cameraContribution = 1.0 - smoothstep(0.25, 0.5, dot(-viewDir, rayDir));
-	[[branch]] if(cameraContribution <= 0.0)
+	[branch] if(cameraContribution <= 0.0)
 	{
 	{
 		return;
 		return;
 	}
 	}

+ 3 - 3
AnKi/Shaders/TonemappingAverageLuminance.ankiprog

@@ -33,9 +33,9 @@ void main()
 	const U32 xStart = gl_LocalInvocationID.x * kPixelsPerTile.x;
 	const U32 xStart = gl_LocalInvocationID.x * kPixelsPerTile.x;
 
 
 	F32 avgLum = 0.0;
 	F32 avgLum = 0.0;
-	[[unroll]] for(U32 y = 0u; y < kPixelsPerTile.y; ++y)
+	[unroll] for(U32 y = 0u; y < kPixelsPerTile.y; ++y)
 	{
 	{
-		[[unroll]] for(U32 x = 0u; x < kPixelsPerTile.x; ++x)
+		[unroll] for(U32 x = 0u; x < kPixelsPerTile.x; ++x)
 		{
 		{
 			const UVec2 uv = UVec2(xStart, yStart) + UVec2(x, y);
 			const UVec2 uv = UVec2(xStart, yStart) + UVec2(x, y);
 			if(uv.x >= kInputTexSize.x || uv.y >= kInputTexSize.y)
 			if(uv.x >= kInputTexSize.x || uv.y >= kInputTexSize.y)
@@ -76,7 +76,7 @@ void main()
 	}
 	}
 
 
 	// Write the result
 	// Write the result
-	[[branch]] if(gl_LocalInvocationIndex == 0u)
+	[branch] if(gl_LocalInvocationIndex == 0u)
 	{
 	{
 #if LOG_AVG
 #if LOG_AVG
 		const F32 crntLum = exp(s_avgLum[0] * (1.0 / F32(kInputTexSize.x * kInputTexSize.y)));
 		const F32 crntLum = exp(s_avgLum[0] * (1.0 / F32(kInputTexSize.x * kInputTexSize.y)));

+ 1 - 1
AnKi/Shaders/VolumetricLightingAccumulation.ankiprog

@@ -234,7 +234,7 @@ Vec4 accumulateLightsAndFog(Cluster cluster, Vec3 worldPos, F32 negativeZViewSpa
 			const FogDensityVolume vol = u_fogDensityVolumes[idx];
 			const FogDensityVolume vol = u_fogDensityVolumes[idx];
 
 
 			F32 factor;
 			F32 factor;
-			[[branch]] if(vol.m_isBox == 1u)
+			[branch] if(vol.m_isBox == 1u)
 			{
 			{
 				factor = computeProbeBlendWeight(worldPos, vol.m_aabbMinOrSphereCenter,
 				factor = computeProbeBlendWeight(worldPos, vol.m_aabbMinOrSphereCenter,
 												 vol.m_aabbMaxOrSphereRadiusSquared, 0.2);
 												 vol.m_aabbMaxOrSphereRadiusSquared, 0.2);

+ 2 - 2
AnKi/Shaders/VrsSriGenerationCompute.ankiprog

@@ -135,7 +135,7 @@ void main()
 
 
 #if SHARED_MEMORY
 #if SHARED_MEMORY
 	// Store results in shared memory.
 	// Store results in shared memory.
-	[[branch]] if(subgroupElect())
+	[branch] if(subgroupElect())
 	{
 	{
 		s_averageLuma[gl_SubgroupID] = averageLuma;
 		s_averageLuma[gl_SubgroupID] = averageLuma;
 		s_maxDerivative[gl_SubgroupID] = Vec2(maxDerivativeX, maxDerivativeY);
 		s_maxDerivative[gl_SubgroupID] = Vec2(maxDerivativeX, maxDerivativeY);
@@ -146,7 +146,7 @@ void main()
 #endif
 #endif
 
 
 	// Write the result
 	// Write the result
-	[[branch]] if(gl_LocalInvocationIndex == 0u)
+	[branch] if(gl_LocalInvocationIndex == 0u)
 	{
 	{
 		// Get max across all subgroups.
 		// Get max across all subgroups.
 #if SHARED_MEMORY
 #if SHARED_MEMORY

+ 43 - 1
Tools/FormatSource.py

@@ -10,9 +10,13 @@ import subprocess
 import threading
 import threading
 import multiprocessing
 import multiprocessing
 import os
 import os
+import tempfile
+import shutil
 
 
 file_extensions = ["h", "hpp", "c", "cpp", "glsl", "hlsl", "ankiprog"]
 file_extensions = ["h", "hpp", "c", "cpp", "glsl", "hlsl", "ankiprog"]
 directories = ["AnKi", "Tests", "Sandbox", "Tools", "Samples"]
 directories = ["AnKi", "Tests", "Sandbox", "Tools", "Samples"]
+hlsl_semantics = ["TEXCOORD", "SV_POSITION", "SV_TARGET0",
+                  "SV_TARGET", "SV_DISPATCHTHREADID", "SV_GROUPINDEX", "SV_GROUPID"]
 
 
 
 
 def thread_callback(tid):
 def thread_callback(tid):
@@ -32,7 +36,27 @@ def thread_callback(tid):
             break
             break
 
 
         unused, file_extension = os.path.splitext(file_name)
         unused, file_extension = os.path.splitext(file_name)
-        if file_extension == ".hlsl" or file_extension == ".ankiprog":
+        is_shader = file_extension == ".hlsl" or file_extension == ".ankiprog"
+
+        if is_shader:
+            # Read all text
+            file = open(file_name, mode="r", newline="\n")
+            file_txt = file.read()
+            file.close()
+
+            # Replace all semantics
+            for semantic in hlsl_semantics:
+                file_txt = file_txt.replace(": " + semantic, "__" + semantic)
+
+            # Write the new file
+            tmp_filefd, tmp_filename = tempfile.mkstemp()
+            with open(tmp_filename, "w", newline="\n") as f:
+                f.write(file_txt)
+                os.close(tmp_filefd)
+
+            orig_filename = file_name
+            file_name = tmp_filename
+
             style_file = "--style=file:.clang-format-hlsl"
             style_file = "--style=file:.clang-format-hlsl"
         else:
         else:
             style_file = "--style=file:.clang-format"
             style_file = "--style=file:.clang-format"
@@ -40,6 +64,24 @@ def thread_callback(tid):
         subprocess.check_call(["./ThirdParty/Bin/Windows64/clang-format.exe",
         subprocess.check_call(["./ThirdParty/Bin/Windows64/clang-format.exe",
                               "-sort-includes=false", style_file, "-i", file_name])
                               "-sort-includes=false", style_file, "-i", file_name])
 
 
+        if is_shader:
+            shutil.move(tmp_filename, orig_filename)
+            file_name = orig_filename
+
+            # Read all text
+            file = open(file_name, mode="r", newline="\n")
+            file_txt = file.read()
+            file.close()
+
+            # Replace all semantics
+            for semantic in hlsl_semantics:
+                file_txt = file_txt.replace("__" + semantic, ": " + semantic)
+
+            # Write the new file
+            file = open(file_name, mode="w", newline="\n")
+            file.write(file_txt)
+            file.close()
+
 
 
 # Gather the filenames
 # Gather the filenames
 file_names = []
 file_names = []