Panagiotis Christopoulos Charitos 4 years ago
parent
commit
c0c254b933

+ 9 - 9
AnKi/Shaders/ApplyIrradianceToReflection.ankiprog

@@ -12,12 +12,12 @@ layout(local_size_x = 8, local_size_y = 8, local_size_z = 6) in;
 layout(set = 0, binding = 0) uniform sampler u_nearestAnyClampSampler;
 layout(set = 0, binding = 1) uniform texture2D u_gbufferTex[3u];
 
-layout(set = 0, binding = 2) buffer readonly ssbo_
+layout(set = 0, binding = 2) buffer readonly b_ssbo
 {
-	Vec4 u_irradianceDice[6u];
+	ANKI_RP Vec4 u_irradianceDice[6u];
 };
 
-layout(set = 0, binding = 3, r11f_g11f_b10f) uniform imageCube u_cubeTex;
+layout(set = 0, binding = 3, r11f_g11f_b10f) uniform ANKI_RP imageCube u_cubeTex;
 
 void main()
 {
@@ -39,17 +39,17 @@ void main()
 							textureLod(u_gbufferTex[2u], u_nearestAnyClampSampler, sampleUv, 0.0), gbuffer);
 
 	// Sample
-	const Vec3 irradiance = sampleAmbientDice(u_irradianceDice[0u].xyz, u_irradianceDice[1u].xyz,
-											  u_irradianceDice[2u].xyz, u_irradianceDice[3u].xyz,
-											  u_irradianceDice[4u].xyz, u_irradianceDice[5u].xyz, gbuffer.m_normal);
+	const ANKI_RP Vec3 irradiance = sampleAmbientDice(
+		u_irradianceDice[0u].xyz, u_irradianceDice[1u].xyz, u_irradianceDice[2u].xyz, u_irradianceDice[3u].xyz,
+		u_irradianceDice[4u].xyz, u_irradianceDice[5u].xyz, gbuffer.m_normal);
 
 	// Compute the indirect term
-	const Vec3 indirect = gbuffer.m_diffuse * irradiance;
+	const ANKI_RP Vec3 indirect = gbuffer.m_diffuse * irradiance;
 
 	// Read the prev color and apply indirect
 	const IVec3 coords = IVec3(globalInvocationID, faceIdx);
-	const Vec3 prevColor = imageLoad(u_cubeTex, coords).xyz;
-	const Vec3 prevColorWithIndirectDiffuse = prevColor + gbuffer.m_diffuse * indirect;
+	const ANKI_RP Vec3 prevColor = imageLoad(u_cubeTex, coords).xyz;
+	const ANKI_RP Vec3 prevColorWithIndirectDiffuse = prevColor + gbuffer.m_diffuse * indirect;
 
 	// Barrier just in case
 	memoryBarrierImage();

+ 6 - 9
AnKi/Shaders/BloomUpscale.ankiprog

@@ -8,7 +8,7 @@ ANKI_SPECIALIZATION_CONSTANT_UVEC2(INPUT_TEX_SIZE, 2u);
 const UVec2 WORKGROUP_SIZE = UVec2(16u, 16u);
 
 #pragma anki start comp
-#include <AnKi/Shaders/Common.glsl>
+#include <AnKi/Shaders/Functions.glsl>
 
 layout(local_size_x = WORKGROUP_SIZE.x, local_size_y = WORKGROUP_SIZE.y, local_size_z = 1) in;
 
@@ -53,12 +53,12 @@ ANKI_RP Vec3 ssLensFlare(Vec2 uv)
 	const Vec2 direction = normalize(ghostVec);
 	ANKI_RP Vec3 result = Vec3(0.0);
 
-	// sample ghosts:
+	// Sample ghosts
 	ANKI_UNROLL for(U32 i = 0u; i < MAX_GHOSTS; ++i)
 	{
 		const Vec2 offset = fract(flipUv + ghostVec * F32(i));
 
-		F32 weight = length(Vec2(0.5) - offset) / LEN_OF_HALF;
+		ANKI_RP F32 weight = length(Vec2(0.5) - offset) / LEN_OF_HALF;
 		weight = pow(1.0 - weight, 10.0);
 
 		result += textureDistorted(u_tex, u_linearAnyClampSampler, offset, direction, DISTORTION) * weight;
@@ -67,7 +67,7 @@ ANKI_RP Vec3 ssLensFlare(Vec2 uv)
 	// Sample halo
 #if ENABLE_HALO
 	const Vec2 haloVec = normalize(ghostVec) * HALO_WIDTH;
-	F32 weight = length(Vec2(0.5) - fract(flipUv + haloVec)) / LEN_OF_HALF;
+	ANKI_RP F32 weight = length(Vec2(0.5) - fract(flipUv + haloVec)) / LEN_OF_HALF;
 	weight = pow(1.0 - weight, 20.0);
 	result += textureDistorted(u_tex, u_linearAnyClampSampler, flipUv + haloVec, direction, DISTORTION)
 			  * (weight * HALO_OPACITY);
@@ -93,12 +93,9 @@ ANKI_RP Vec3 upscale(Vec2 uv)
 
 void main()
 {
-	if((FB_SIZE.x % WORKGROUP_SIZE.x) != 0u || (FB_SIZE.y % WORKGROUP_SIZE.y) != 0u) // This check is free
+	if(skipOutOfBoundsInvocations(WORKGROUP_SIZE, FB_SIZE))
 	{
-		if(gl_GlobalInvocationID.x >= FB_SIZE.x || gl_GlobalInvocationID.y >= FB_SIZE.y)
-		{
-			return;
-		}
+		return;
 	}
 
 	const Vec2 uv = (Vec2(gl_GlobalInvocationID.xy) + 0.5) / Vec2(FB_SIZE);

+ 3 - 2
AnKi/Shaders/ClusteredShadingCommon.glsl

@@ -58,9 +58,10 @@ layout(set = CLUSTERED_SHADING_SET, binding = CLUSTERED_SHADING_DECALS_BINDING,
 	Decal u_decals2[MAX_VISIBLE_DECALS];
 };
 
-layout(set = CLUSTERED_SHADING_SET, binding = CLUSTERED_SHADING_DECALS_BINDING + 1) uniform texture2D u_diffuseDecalTex;
 layout(set = CLUSTERED_SHADING_SET,
-	   binding = CLUSTERED_SHADING_DECALS_BINDING + 2) uniform texture2D u_specularRoughnessDecalTex;
+	   binding = CLUSTERED_SHADING_DECALS_BINDING + 1) uniform ANKI_RP texture2D u_diffuseDecalTex;
+layout(set = CLUSTERED_SHADING_SET,
+	   binding = CLUSTERED_SHADING_DECALS_BINDING + 2) uniform ANKI_RP texture2D u_specularRoughnessDecalTex;
 #endif
 
 //

+ 1 - 1
AnKi/Shaders/FinalComposite.ankiprog

@@ -54,7 +54,7 @@ ANKI_RP Vec3 colorGrading(ANKI_RP Vec3 color)
 
 void main()
 {
-	const Vec2 uv = in_uv.xy;
+	const Vec2 uv = in_uv;
 
 	if(MOTION_BLUR_SAMPLES > 0u)
 	{

+ 6 - 6
AnKi/Shaders/ForwardShadingCommonFrag.glsl

@@ -13,7 +13,7 @@
 // Global resources
 layout(set = 0, binding = 0) uniform sampler u_linearAnyClampSampler;
 layout(set = 0, binding = 1) uniform texture2D u_gbufferDepthRt;
-layout(set = 0, binding = 2) uniform texture3D u_lightVol;
+layout(set = 0, binding = 2) uniform ANKI_RP texture3D u_lightVol;
 #define CLUSTERED_SHADING_SET 0
 #define CLUSTERED_SHADING_UNIFORMS_BINDING 3
 #define CLUSTERED_SHADING_LIGHTS_BINDING 4
@@ -27,7 +27,7 @@ void packGBuffer(Vec4 color)
 	out_color = Vec4(color.rgb, color.a);
 }
 
-Vec4 readAnimatedTextureRgba(texture2DArray tex, sampler sampl, F32 period, Vec2 uv, F32 time)
+ANKI_RP Vec4 readAnimatedTextureRgba(ANKI_RP texture2DArray tex, sampler sampl, F32 period, Vec2 uv, F32 time)
 {
 	const F32 layerCount = F32(textureSize(tex, 0).z);
 	const F32 layer = mod(time * layerCount / period, layerCount);
@@ -101,7 +101,7 @@ Vec3 computeLightColorHigh(Vec3 diffCol, Vec3 worldPos)
 }
 
 // Just read the light color from the vol texture
-Vec3 computeLightColorLow(Vec3 diffCol, Vec3 worldPos)
+ANKI_RP Vec3 computeLightColorLow(ANKI_RP Vec3 diffCol, ANKI_RP Vec3 worldPos)
 {
 	const Vec2 uv = gl_FragCoord.xy / u_clusteredShading.m_renderingSize;
 	const F32 linearDepth = linearizeDepth(gl_FragCoord.z, u_clusteredShading.m_near, u_clusteredShading.m_far);
@@ -109,16 +109,16 @@ Vec3 computeLightColorLow(Vec3 diffCol, Vec3 worldPos)
 		Vec3(uv, linearDepth
 					 * (F32(u_clusteredShading.m_zSplitCount) / F32(u_clusteredShading.m_lightVolumeLastZSplit + 1u)));
 
-	const Vec3 light = textureLod(u_lightVol, u_linearAnyClampSampler, uvw, 0.0).rgb;
+	const ANKI_RP Vec3 light = textureLod(u_lightVol, u_linearAnyClampSampler, uvw, 0.0).rgb;
 	return diffuseLobe(diffCol) * light;
 }
 
-void particleAlpha(Vec4 color, Vec4 scaleColor, Vec4 biasColor)
+void particleAlpha(ANKI_RP Vec4 color, ANKI_RP Vec4 scaleColor, ANKI_RP Vec4 biasColor)
 {
 	packGBuffer(color * scaleColor + biasColor);
 }
 
-void fog(Vec3 color, F32 fogAlphaScale, F32 fogDistanceOfMaxThikness, F32 zVSpace)
+void fog(ANKI_RP Vec3 color, ANKI_RP F32 fogAlphaScale, ANKI_RP F32 fogDistanceOfMaxThikness, F32 zVSpace)
 {
 	const Vec2 screenSize = 1.0 / u_clusteredShading.m_renderingSize;
 

+ 0 - 5
AnKi/Shaders/ForwardShadingCommonVert.glsl

@@ -11,8 +11,3 @@
 
 // In/out
 layout(location = VERTEX_ATTRIBUTE_ID_POSITION) in Vec3 in_position;
-
-out gl_PerVertex
-{
-	Vec4 gl_Position;
-};

+ 3 - 3
AnKi/Shaders/ForwardShadingFog.ankiprog

@@ -7,9 +7,9 @@ struct PerDraw
 {
 	Mat4 m_ankiMvp;
 	Mat4 m_ankiModelViewMatrix;
-	Vec3 m_fogColor;
-	F32 m_fogAlphaScale;
-	F32 m_fogDistanceOfMaxThikness;
+	ANKI_RP Vec3 m_fogColor;
+	ANKI_RP F32 m_fogAlphaScale;
+	ANKI_RP F32 m_fogDistanceOfMaxThikness;
 };
 
 #pragma anki reflect b_ankiPerDraw

+ 10 - 10
AnKi/Shaders/ForwardShadingParticles.ankiprog

@@ -13,8 +13,8 @@ struct PerDraw
 #if ANIMATED_TEXTURE == 1
 	F32 m_animationPeriod;
 #endif
-	Vec4 m_colorScale;
-	Vec4 m_colorBias;
+	ANKI_RP Vec4 m_colorScale;
+	ANKI_RP Vec4 m_colorBias;
 };
 
 #pragma anki reflect b_ankiPerDraw
@@ -27,11 +27,11 @@ layout(set = 1, binding = 0, row_major) uniform b_ankiPerDraw
 layout(set = 1, binding = 1) uniform sampler u_ankiGlobalSampler;
 #if ANIMATED_TEXTURE == 0
 #	pragma anki reflect u_diffuseMap
-layout(set = 1, binding = 2) uniform texture2D u_diffuseMap;
+layout(set = 1, binding = 2) uniform ANKI_RP texture2D u_diffuseMap;
 #endif
 #if ANIMATED_TEXTURE == 1
 #	pragma anki reflect u_diffuseMapArr
-layout(set = 1, binding = 2) uniform texture2DArray u_diffuseMapArr;
+layout(set = 1, binding = 2) uniform ANKI_RP texture2DArray u_diffuseMapArr;
 #endif
 
 #pragma anki start vert
@@ -40,7 +40,7 @@ layout(set = 1, binding = 2) uniform texture2DArray u_diffuseMapArr;
 layout(location = VERTEX_ATTRIBUTE_ID_SCALE) in F32 in_scale;
 layout(location = VERTEX_ATTRIBUTE_ID_ALPHA) in F32 in_alpha;
 
-layout(location = 0) flat out F32 out_alpha;
+layout(location = 0) flat out ANKI_RP F32 out_alpha;
 layout(location = 1) out Vec2 out_uv;
 layout(location = 2) out Vec3 out_worldPos;
 
@@ -58,24 +58,24 @@ void main()
 #pragma anki start frag
 #include <AnKi/Shaders/ForwardShadingCommonFrag.glsl>
 
-layout(location = 0) flat in F32 in_alpha;
+layout(location = 0) flat in ANKI_RP F32 in_alpha;
 layout(location = 1) in Vec2 in_uv;
 layout(location = 2) in Vec3 in_worldPos;
 
 void main()
 {
 #if ANIMATED_TEXTURE == 1
-	Vec4 texCol = readAnimatedTextureRgba(u_diffuseMapArr, u_ankiGlobalSampler, u_ankiPerDraw.m_animationPeriod, in_uv,
-										  u_clusteredShading.m_time);
+	ANKI_RP Vec4 texCol = readAnimatedTextureRgba(u_diffuseMapArr, u_ankiGlobalSampler, u_ankiPerDraw.m_animationPeriod,
+												  in_uv, u_clusteredShading.m_time);
 #else
-	Vec4 texCol = texture(u_diffuseMap, u_ankiGlobalSampler, in_uv);
+	ANKI_RP Vec4 texCol = texture(u_diffuseMap, u_ankiGlobalSampler, in_uv);
 #endif
 
 #if LIGHT
 	texCol.rgb = computeLightColorLow(texCol.rgb, in_worldPos);
 #endif
 
-	Vec4 colScale = u_ankiPerDraw.m_colorScale;
+	ANKI_RP Vec4 colScale = u_ankiPerDraw.m_colorScale;
 	colScale.a *= in_alpha;
 	particleAlpha(texCol, colScale, u_ankiPerDraw.m_colorBias);
 }

+ 7 - 7
AnKi/Shaders/GBufferGpuParticles.ankiprog

@@ -11,12 +11,12 @@
 struct PerDraw
 {
 	Mat4 m_ankiMvp;
-	Vec3 m_diffColor;
-	F32 m_roughness;
-	Vec3 m_specColor;
-	F32 m_metallic;
-	Vec3 m_initialEmission;
-	Vec3 m_finalEmission;
+	ANKI_RP Vec3 m_diffColor;
+	ANKI_RP F32 m_roughness;
+	ANKI_RP Vec3 m_specColor;
+	ANKI_RP F32 m_metallic;
+	ANKI_RP Vec3 m_initialEmission;
+	ANKI_RP Vec3 m_finalEmission;
 };
 
 #pragma anki reflect b_ankiPerDraw
@@ -81,7 +81,7 @@ void main()
 	g.m_f0 = u_ankiPerDraw.m_specColor;
 	g.m_roughness = u_ankiPerDraw.m_roughness;
 	g.m_subsurface = 0.0;
-	const Vec3 emission = mix(u_ankiPerDraw.m_initialEmission, u_ankiPerDraw.m_finalEmission, in_lifeFactor);
+	const ANKI_RP Vec3 emission = mix(u_ankiPerDraw.m_initialEmission, u_ankiPerDraw.m_finalEmission, in_lifeFactor);
 	g.m_emission = (emission.r + emission.g + emission.b) / 3.0;
 	g.m_metallic = u_ankiPerDraw.m_metallic;
 	g.m_velocity = in_velocity;

+ 15 - 15
AnKi/Shaders/GBufferPost.ankiprog

@@ -16,7 +16,7 @@ ANKI_SPECIALIZATION_CONSTANT_U32(TILE_SIZE, 3u);
 #include <AnKi/Shaders/Functions.glsl>
 
 layout(set = 0, binding = 0) uniform sampler u_nearestAnyClampSampler;
-layout(set = 0, binding = 1) uniform texture2D u_msDepthRt;
+layout(set = 0, binding = 1) uniform texture2D u_depthTex;
 layout(set = 0, binding = 2) uniform sampler u_trilinearRepeatSampler;
 
 #define CLUSTERED_SHADING_SET 0
@@ -27,8 +27,8 @@ layout(set = 0, binding = 2) uniform sampler u_trilinearRepeatSampler;
 
 layout(location = 0) in Vec2 in_uv;
 
-layout(location = 0) out Vec4 out_color0;
-layout(location = 1) out Vec4 out_color1;
+layout(location = 0) out ANKI_RP Vec4 out_diffuse;
+layout(location = 1) out ANKI_RP Vec4 out_roughnessMetallicF0;
 
 void main()
 {
@@ -39,11 +39,11 @@ void main()
 	// 2nd decal: d''=d'*(1-f')+D'*f' <=> d''=d*(1-f)*(1-f')+D*f*(1-f')+D'*f'
 	// By looking at the trend we will have to multiply the gbuffer.diff with: (1-f)*(1-f') ... (1-f'''')
 
-	Vec4 outDiffuse = Vec4(0.0, 0.0, 0.0, 1.0);
-	Vec4 outSpecular = Vec4(0.0, 0.0, 0.0, 1.0);
+	ANKI_RP Vec4 diffuse = Vec4(0.0, 0.0, 0.0, 1.0);
+	ANKI_RP Vec4 roughnessMetallicF0 = Vec4(0.0, 0.0, 0.0, 1.0);
 
 	// Get worldPos
-	const F32 depth = textureLod(u_msDepthRt, u_nearestAnyClampSampler, in_uv, 0.0).r;
+	const F32 depth = textureLod(u_depthTex, u_nearestAnyClampSampler, in_uv, 0.0).r;
 	const Vec2 ndc = UV_TO_NDC(in_uv);
 	const Vec4 worldPos4 = u_clusteredShading.m_matrices.m_invertedViewProjectionJitter * Vec4(ndc, depth, 1.0);
 	const Vec3 worldPos = worldPos4.xyz / worldPos4.w;
@@ -79,24 +79,24 @@ void main()
 
 		// Read diffuse
 		const Vec2 diffUv = mad(texCoords2, decal.m_diffuseUv.zw, decal.m_diffuseUv.xy);
-		const Vec4 decalDiff = texture(u_diffuseDecalTex, u_trilinearRepeatSampler, diffUv);
+		const ANKI_RP Vec4 decalDiff = texture(u_diffuseDecalTex, u_trilinearRepeatSampler, diffUv);
 
 		// Read roughness
 		const Vec2 specUv = mad(texCoords2, decal.m_normRoughnessUv.zw, decal.m_normRoughnessUv.xy);
-		const Vec3 spec = texture(u_specularRoughnessDecalTex, u_trilinearRepeatSampler, specUv).rgb;
+		const ANKI_RP Vec3 spec = texture(u_specularRoughnessDecalTex, u_trilinearRepeatSampler, specUv).rgb;
 
 		// Update diffuse
-		F32 f = decalDiff.a * decal.m_blendFactors[0];
-		outDiffuse.rgb = outDiffuse.rgb * (1.0 - f) + decalDiff.rgb * f;
-		outDiffuse.a *= (1.0 - f);
+		ANKI_RP F32 f = decalDiff.a * decal.m_blendFactors[0];
+		diffuse.rgb = diffuse.rgb * (1.0 - f) + decalDiff.rgb * f;
+		diffuse.a *= (1.0 - f);
 
 		// Update specular
 		f = decalDiff.a * decal.m_blendFactors[1];
-		outSpecular.rgb = outSpecular.rgb * (1.0 - f) + spec.rgb * f;
-		outSpecular.a *= (1.0 - f);
+		roughnessMetallicF0.rgb = roughnessMetallicF0.rgb * (1.0 - f) + spec.rgb * f;
+		roughnessMetallicF0.a *= (1.0 - f);
 	}
 
-	out_color0 = outDiffuse;
-	out_color1 = outSpecular;
+	out_diffuse = diffuse;
+	out_roughnessMetallicF0 = roughnessMetallicF0;
 }
 #pragma anki end

+ 9 - 9
AnKi/Shaders/Include/ClusteredShadingTypes.h

@@ -75,13 +75,13 @@ ANKI_SHADER_STATIC_ASSERT(sizeof(SpotLight) == _ANKI_SIZEOF_SpotLight);
 struct SpotLightBinning
 {
 	Vec3 m_edgePoints[5u]; ///< Edge points in world space.
-	Vec3 m_diffuseColor;
-	F32 m_radius; ///< Max distance.
-	F32 m_squareRadiusOverOne; ///< 1/(radius^2).
+	ANKI_RP Vec3 m_diffuseColor;
+	ANKI_RP F32 m_radius; ///< Max distance.
+	ANKI_RP F32 m_squareRadiusOverOne; ///< 1/(radius^2).
 	U32 m_shadowLayer; ///< Shadow layer used in RT shadows. Also used to show that it doesn't cast shadow.
-	Vec3 m_direction; ///< Light direction.
-	F32 m_outerCos;
-	F32 m_innerCos;
+	ANKI_RP Vec3 m_direction; ///< Light direction.
+	ANKI_RP F32 m_outerCos;
+	ANKI_RP F32 m_innerCos;
 	Vec2 m_padding;
 	Mat4 m_textureMatrix;
 };
@@ -121,7 +121,7 @@ struct Decal
 {
 	Vec4 m_diffuseUv;
 	Vec4 m_normRoughnessUv;
-	Vec4 m_blendFactors;
+	ANKI_RP Vec4 m_blendFactors;
 	Mat4 m_textureMatrix;
 	Mat4 m_invertedTransform;
 	Vec3 m_obbExtend;
@@ -136,7 +136,7 @@ struct FogDensityVolume
 	Vec3 m_aabbMinOrSphereCenter;
 	U32 m_isBox;
 	Vec3 m_aabbMaxOrSphereRadiusSquared;
-	F32 m_density;
+	ANKI_RP F32 m_density;
 };
 const U32 _ANKI_SIZEOF_FogDensityVolume = 2u * ANKI_SIZEOF(Vec4);
 ANKI_SHADER_STATIC_ASSERT(sizeof(FogDensityVolume) == _ANKI_SIZEOF_FogDensityVolume);
@@ -151,7 +151,7 @@ struct GlobalIlluminationProbe
 	F32 m_halfTexelSizeU; ///< (1.0 / textureSize(texArr[textureIndex]).x) / 2.0
 
 	/// Used to calculate a factor that is zero when fragPos is close to AABB bounds and 1.0 at fadeDistance and less.
-	F32 m_fadeDistance;
+	ANKI_RP F32 m_fadeDistance;
 };
 const U32 _ANKI_SIZEOF_GlobalIlluminationProbe = 9u * ANKI_SIZEOF(U32);
 ANKI_SHADER_STATIC_ASSERT(sizeof(GlobalIlluminationProbe) == _ANKI_SIZEOF_GlobalIlluminationProbe);

+ 1 - 1
AnKi/Shaders/Include/LensFlareTypes.h

@@ -13,7 +13,7 @@ ANKI_BEGIN_NAMESPACE
 struct LensFlareSprite
 {
 	Vec4 m_posScale; // xy: Position, zw: Scale
-	Vec4 m_color;
+	ANKI_RP Vec4 m_color;
 	Vec4 m_depthPad3;
 };
 

+ 17 - 17
AnKi/Shaders/IrradianceDice.ankiprog

@@ -26,7 +26,7 @@ layout(set = 0, binding = 0) uniform sampler u_nearestAnyClampSampler;
 #if LIGHT_SHADING_TEX == 0
 layout(set = 0, binding = 1) uniform texture2D u_lightShadingTex2d;
 #else
-layout(set = 0, binding = 1) uniform textureCube u_lightShadingTexCube;
+layout(set = 0, binding = 1) uniform ANKI_RP textureCube u_lightShadingTexCube;
 #endif
 
 #if SECOND_BOUNCE == 1
@@ -50,13 +50,13 @@ layout(push_constant, std430) uniform pc_
 #else
 layout(set = 0, binding = 4, std430) writeonly buffer ssbo1_
 {
-	Vec4 u_irradianceDisceResults[6u];
+	ANKI_RP Vec4 u_irradianceDisceResults[6u];
 };
 #endif
 
-shared Vec3 s_diceIrradiance[6u];
+shared ANKI_RP Vec3 s_diceIrradiance[6u];
 
-Vec3 sampleLightShadingTexture(const U32 face)
+ANKI_RP Vec3 sampleLightShadingTexture(const U32 face)
 {
 #if LIGHT_SHADING_TEX == 0
 	const Vec2 INPUT_TEXTURES_SIZE = Vec2(U32(WORKGROUP_SIZE_XY) * 6u, U32(WORKGROUP_SIZE_XY));
@@ -90,9 +90,9 @@ void main()
 		const Vec3 r = getCubemapDirection(ndc, f);
 
 		// Compute integral part
-		const F32 lambert = max(0.0, dot(r, diceDir));
-		const Vec3 lightShading = sampleLightShadingTexture(f);
-		const Vec3 irradiance = lightShading * lambert * cubeCoordSolidAngle(ndc, WORKGROUP_SIZE_XY_F);
+		const ANKI_RP F32 lambert = max(0.0, dot(r, diceDir));
+		const ANKI_RP Vec3 lightShading = sampleLightShadingTexture(f);
+		const ANKI_RP Vec3 irradiance = lightShading * lambert * cubeCoordSolidAngle(ndc, WORKGROUP_SIZE_XY_F);
 
 		// Store
 		u_integrationResults[f * WORKGROUP_SIZE + gl_LocalInvocationID.y * U32(WORKGROUP_SIZE_XY)
@@ -137,7 +137,7 @@ void main()
 		const Vec3 r = getCubemapDirection(ndc, f);
 
 		// Compute integral part
-		const F32 lambert = max(0.0, dot(r, diceDir));
+		const ANKI_RP F32 lambert = max(0.0, dot(r, diceDir));
 
 		// Read the gbuffer
 		Vec2 gbufferUv = (Vec2(gl_LocalInvocationID.xy) + 0.5) / WORKGROUP_SIZE_XY_F;
@@ -149,14 +149,14 @@ void main()
 								textureLod(u_gbufferTex[2u], u_nearestAnyClampSampler, gbufferUv, 0.0), gbuffer);
 
 		// Sample irradiance
-		Vec3 firstBounceIrradiance =
+		ANKI_RP Vec3 firstBounceIrradiance =
 			sampleAmbientDice(s_diceIrradiance[0], s_diceIrradiance[1], s_diceIrradiance[2], s_diceIrradiance[3],
 							  s_diceIrradiance[4], s_diceIrradiance[5], gbuffer.m_normal);
 		firstBounceIrradiance = gbuffer.m_diffuse * firstBounceIrradiance;
 
 		// Compute 2nd bounce
-		const Vec3 lightShading = sampleLightShadingTexture(f);
-		const Vec3 irradiance =
+		const ANKI_RP Vec3 lightShading = sampleLightShadingTexture(f);
+		const ANKI_RP Vec3 irradiance =
 			(firstBounceIrradiance + lightShading * lambert) * cubeCoordSolidAngle(ndc, WORKGROUP_SIZE_XY_F);
 
 		// Store
@@ -191,20 +191,20 @@ void main()
 
 #if DEBUG_MODE == 0
 #	if SECOND_BOUNCE == 1
-		Vec3 irradiance = u_integrationResults[f * WORKGROUP_SIZE + 0u].xyz;
+		ANKI_RP Vec3 irradiance = u_integrationResults[f * WORKGROUP_SIZE + 0u].xyz;
 #	else
-		Vec3 irradiance = s_diceIrradiance[f];
+		ANKI_RP Vec3 irradiance = s_diceIrradiance[f];
 #	endif
-		const Vec3 toStoreValue = irradiance * PI;
+		const ANKI_RP Vec3 toStoreValue = irradiance * PI;
 #elif DEBUG_MODE == 1
-		const Vec3 toStoreValue = colorPerCubeFace(f);
+		const ANKI_RP Vec3 toStoreValue = colorPerCubeFace(f);
 #else
 		const UVec3 volumeSize = UVec3(imageSize(u_irradianceVolume));
 		const UVec3 subvolumeSize = UVec3(volumeSize.x / 6u, volumeSize.y, volumeSize.z);
 		const U32 cellIdx =
 			u_volumeTexel.z * subvolumeSize.x * subvolumeSize.y + u_volumeTexel.y * subvolumeSize.x + u_volumeTexel.x;
-		const F32 headmapFactor = F32(cellIdx) / F32(subvolumeSize.x * subvolumeSize.y * subvolumeSize.z);
-		const Vec3 toStoreValue = heatmap(headmapFactor);
+		const ANKI_RP F32 headmapFactor = F32(cellIdx) / F32(subvolumeSize.x * subvolumeSize.y * subvolumeSize.z);
+		const ANKI_RP Vec3 toStoreValue = heatmap(headmapFactor);
 #endif
 
 #if STORE_LOCATION == 0

+ 5 - 10
AnKi/Shaders/LensFlareSprite.ankiprog

@@ -14,12 +14,7 @@ layout(std140, set = 0, binding = 0) readonly buffer ssbo00
 };
 
 layout(location = 0) out Vec3 out_uv;
-layout(location = 1) flat out Vec4 out_color;
-
-out gl_PerVertex
-{
-	Vec4 gl_Position;
-};
+layout(location = 1) flat out ANKI_RP Vec4 out_color;
 
 void main()
 {
@@ -41,16 +36,16 @@ void main()
 #include <AnKi/Shaders/Common.glsl>
 
 layout(set = 0, binding = 1) uniform sampler u_trilinearRepeatSampler;
-layout(set = 0, binding = 2) uniform texture2DArray u_tex;
+layout(set = 0, binding = 2) uniform ANKI_RP texture2DArray u_tex;
 
 layout(location = 0) in Vec3 in_uv;
-layout(location = 1) flat in Vec4 in_color;
+layout(location = 1) flat in ANKI_RP Vec4 in_color;
 
-layout(location = 0) out Vec4 out_color;
+layout(location = 0) out ANKI_RP Vec4 out_color;
 
 void main()
 {
-	const Vec4 col = texture(u_tex, u_trilinearRepeatSampler, in_uv);
+	const ANKI_RP Vec4 col = texture(u_tex, u_trilinearRepeatSampler, in_uv);
 	out_color = col * in_color;
 }
 #pragma anki end

+ 24 - 24
AnKi/Shaders/TonemappingFunctions.glsl

@@ -8,41 +8,41 @@
 #include <AnKi/Shaders/Common.glsl>
 
 // A tick to compute log of base 10
-F32 log10(F32 x)
+ANKI_RP F32 log10(ANKI_RP F32 x)
 {
 	return log(x) / log(10.0);
 }
 
-F32 computeLuminance(Vec3 color)
+ANKI_RP F32 computeLuminance(ANKI_RP Vec3 color)
 {
-	return max(dot(Vec3(0.30, 0.59, 0.11), color), EPSILON);
+	return max(dot(Vec3(0.30, 0.59, 0.11), color), EPSILON_RP);
 }
 
-F32 computeExposure(F32 avgLum, F32 threshold)
+ANKI_RP F32 computeExposure(ANKI_RP F32 avgLum, ANKI_RP F32 threshold)
 {
-	const F32 keyValue = 1.03 - (2.0 / (2.0 + log10(avgLum + 1.0)));
-	const F32 linearExposure = (keyValue / avgLum);
-	F32 exposure = log2(linearExposure);
+	const ANKI_RP F32 keyValue = 1.03 - (2.0 / (2.0 + log10(avgLum + 1.0)));
+	const ANKI_RP F32 linearExposure = (keyValue / avgLum);
+	ANKI_RP F32 exposure = log2(linearExposure);
 
 	exposure -= threshold;
 	return exp2(exposure);
 }
 
-Vec3 computeExposedColor(Vec3 color, F32 avgLum, F32 threshold)
+ANKI_RP Vec3 computeExposedColor(ANKI_RP Vec3 color, ANKI_RP F32 avgLum, ANKI_RP F32 threshold)
 {
 	return computeExposure(avgLum, threshold) * color;
 }
 
 // Reinhard operator
-Vec3 tonemapReinhard(Vec3 color, F32 saturation)
+ANKI_RP Vec3 tonemapReinhard(ANKI_RP Vec3 color, ANKI_RP F32 saturation)
 {
-	const F32 lum = computeLuminance(color);
-	const F32 toneMappedLuminance = lum / (lum + 1.0);
+	const ANKI_RP F32 lum = computeLuminance(color);
+	const ANKI_RP F32 toneMappedLuminance = lum / (lum + 1.0);
 	return toneMappedLuminance * pow(color / lum, Vec3(saturation));
 }
 
 // Uncharted 2 operator
-Vec3 tonemapUncharted2(Vec3 color)
+ANKI_RP Vec3 tonemapUncharted2(ANKI_RP Vec3 color)
 {
 	const F32 A = 0.15;
 	const F32 B = 0.50;
@@ -54,42 +54,42 @@ Vec3 tonemapUncharted2(Vec3 color)
 	return ((color * (A * color + C * B) + D * E) / (color * (A * color + B) + D * F)) - E / F;
 }
 
-Vec3 tonemapACESFilm(Vec3 x)
+ANKI_RP Vec3 tonemapACESFilm(ANKI_RP Vec3 x)
 {
-	const F32 a = 2.51;
-	const F32 b = 0.03;
-	const F32 c = 2.43;
-	const F32 d = 0.59;
-	const F32 e = 0.14;
+	const ANKI_RP F32 a = 2.51;
+	const ANKI_RP F32 b = 0.03;
+	const ANKI_RP F32 c = 2.43;
+	const ANKI_RP F32 d = 0.59;
+	const ANKI_RP F32 e = 0.14;
 
 	return saturate((x * (a * x + b)) / (x * (c * x + d) + e));
 }
 
-Vec3 tonemap(Vec3 color, F32 exposure)
+ANKI_RP Vec3 tonemap(ANKI_RP Vec3 color, ANKI_RP F32 exposure)
 {
 	color *= exposure;
 #if 0
-	const F32 saturation = 1.0;
+	const ANKI_RP F32 saturation = 1.0;
 	return tonemapReinhard(color, saturation);
 #else
 	return tonemapACESFilm(color);
 #endif
 }
 
-Vec3 tonemap(Vec3 color, F32 avgLum, F32 threshold)
+ANKI_RP Vec3 tonemap(ANKI_RP Vec3 color, ANKI_RP F32 avgLum, ANKI_RP F32 threshold)
 {
-	const F32 exposure = computeExposure(avgLum, threshold);
+	const ANKI_RP F32 exposure = computeExposure(avgLum, threshold);
 	return tonemap(color, exposure);
 }
 
 // https://graphicrants.blogspot.com/2013/12/tone-mapping.html
-Vec3 invertibleTonemap(Vec3 colour)
+ANKI_RP Vec3 invertibleTonemap(ANKI_RP Vec3 colour)
 {
 	// 1 / (1 + max(rgb))
 	return colour / (1.0 + max(max(colour.r, colour.g), colour.b));
 }
 
-Vec3 invertInvertibleTonemap(Vec3 colour)
+ANKI_RP Vec3 invertInvertibleTonemap(ANKI_RP Vec3 colour)
 {
 	// 1 / (1 - max(rgb))
 	return colour / (1.0 - max(max(colour.r, colour.g), colour.b));