Browse Source

Adreno workaround: Replace all scalar layouts with std140

Panagiotis Christopoulos Charitos 3 years ago
parent
commit
c8b6ab4552
63 changed files with 381 additions and 462 deletions
  1. 21 15
      AnKi/Renderer/ClusterBinning.cpp
  2. 1 1
      AnKi/Renderer/Common.h
  3. 2 10
      AnKi/Renderer/DepthDownscale.cpp
  4. 5 8
      AnKi/Renderer/Drawer.cpp
  5. 2 3
      AnKi/Renderer/FinalComposite.cpp
  6. 6 6
      AnKi/Renderer/GBuffer.h
  7. 0 1
      AnKi/Renderer/IndirectDiffuse.cpp
  8. 0 1
      AnKi/Renderer/IndirectSpecular.cpp
  9. 0 1
      AnKi/Renderer/LensFlare.cpp
  10. 0 1
      AnKi/Renderer/Renderer.cpp
  11. 0 1
      AnKi/Renderer/RtShadows.h
  12. 3 4
      AnKi/Renderer/ShadowMapping.cpp
  13. 1 11
      AnKi/Renderer/VolumetricFog.cpp
  14. 1 8
      AnKi/Renderer/VolumetricLightingAccumulation.cpp
  15. 0 1
      AnKi/Scene/Components/RenderComponent.cpp
  16. 1 1
      AnKi/Shaders/Blit.glsl
  17. 22 22
      AnKi/Shaders/ClusterBinning.ankiprog
  18. 12 12
      AnKi/Shaders/ClusteredShadingCommon.glsl
  19. 8 11
      AnKi/Shaders/DepthDownscaleCompute.ankiprog
  20. 2 2
      AnKi/Shaders/DepthDownscaleRaster.ankiprog
  21. 1 1
      AnKi/Shaders/DownscaleBlur.glsl
  22. 6 6
      AnKi/Shaders/Evsm.glsl
  23. 4 3
      AnKi/Shaders/FinalComposite.ankiprog
  24. 1 1
      AnKi/Shaders/ForwardShadingCommon.glsl
  25. 3 5
      AnKi/Shaders/ForwardShadingFog.ankiprog
  26. 4 6
      AnKi/Shaders/ForwardShadingParticles.ankiprog
  27. 9 9
      AnKi/Shaders/GBufferGeneric.ankiprog
  28. 7 9
      AnKi/Shaders/GBufferGpuParticles.ankiprog
  29. 3 2
      AnKi/Shaders/GpuParticlesSimulation.ankiprog
  30. 71 36
      AnKi/Shaders/Include/ClusteredShadingTypes.h
  31. 0 19
      AnKi/Shaders/Include/Evsm.h
  32. 2 3
      AnKi/Shaders/Include/GpuSceneTypes.h
  33. 0 34
      AnKi/Shaders/Include/IndirectDiffuseTypes.h
  34. 0 20
      AnKi/Shaders/Include/LensFlareTypes.h
  35. 4 5
      AnKi/Shaders/Include/MaterialTypes.h
  36. 137 0
      AnKi/Shaders/Include/MiscRendererTypes.h
  37. 1 10
      AnKi/Shaders/Include/ParticleTypes.h
  38. 0 26
      AnKi/Shaders/Include/RtShadows.h
  39. 0 26
      AnKi/Shaders/Include/ShadowMappingTypes.h
  40. 0 31
      AnKi/Shaders/Include/SsgiTypes.h
  41. 0 33
      AnKi/Shaders/Include/SsrTypes.h
  42. 3 0
      AnKi/Shaders/Include/TraditionalDeferredShadingTypes.h
  43. 3 7
      AnKi/Shaders/IndirectDiffuse.glsl
  44. 1 1
      AnKi/Shaders/IndirectDiffuseDenoise.glsl
  45. 3 3
      AnKi/Shaders/IndirectSpecular.glsl
  46. 3 3
      AnKi/Shaders/IrradianceDice.ankiprog
  47. 1 1
      AnKi/Shaders/LensFlareSprite.ankiprog
  48. 1 1
      AnKi/Shaders/LensFlareUpdateIndirectInfo.ankiprog
  49. 2 2
      AnKi/Shaders/LightFunctions.glsl
  50. 1 1
      AnKi/Shaders/LightShading.ankiprog
  51. 3 2
      AnKi/Shaders/LightShadingApplyIndirect.ankiprog
  52. 2 2
      AnKi/Shaders/LightShadingSkybox.ankiprog
  53. 1 1
      AnKi/Shaders/RtShadows.glsl
  54. 1 1
      AnKi/Shaders/RtShadowsDenoise.ankiprog
  55. 1 1
      AnKi/Shaders/RtShadowsRayGen.ankiprog
  56. 1 1
      AnKi/Shaders/RtShadowsSvgfAtrous.ankiprog
  57. 1 1
      AnKi/Shaders/RtShadowsSvgfVariance.ankiprog
  58. 1 1
      AnKi/Shaders/ShadowmapsResolve.glsl
  59. 1 1
      AnKi/Shaders/TraditionalDeferredShadingSkybox.ankiprog
  60. 3 12
      AnKi/Shaders/VolumetricFogAccumulation.ankiprog
  61. 6 13
      AnKi/Shaders/VolumetricLightingAccumulation.ankiprog
  62. 1 1
      Samples/Common/SampleApp.cpp
  63. 1 1
      Samples/PhysicsPlayground/Main.cpp

+ 21 - 15
AnKi/Renderer/ClusterBinning.cpp

@@ -261,9 +261,10 @@ void ClusterBinning::writeClustererBuffersTask()
 			{
 				out.m_shadowLayer = in.m_shadowLayer;
 				out.m_shadowAtlasTileScale = in.m_shadowAtlasTileSize;
-				static_assert(sizeof(out.m_shadowAtlasTileOffsets) == sizeof(in.m_shadowAtlasTileOffsets), "See file");
-				memcpy(&out.m_shadowAtlasTileOffsets[0], &in.m_shadowAtlasTileOffsets[0],
-					   sizeof(in.m_shadowAtlasTileOffsets));
+				for(U32 f = 0; f < 6; ++f)
+				{
+					out.m_shadowAtlasTileOffsets[f] = Vec4(in.m_shadowAtlasTileOffsets[f], 0.0f, 0.0f);
+				}
 			}
 		}
 	}
@@ -279,7 +280,10 @@ void ClusterBinning::writeClustererBuffersTask()
 			SpotLight& out = lights[i];
 
 			out.m_position = in.m_worldTransform.getTranslationPart().xyz();
-			memcpy(&out.m_edgePoints[0][0], &in.m_edgePoints[0][0], sizeof(out.m_edgePoints));
+			for(U32 j = 0; j < 4; ++j)
+			{
+				out.m_edgePoints[j] = in.m_edgePoints[j].xyz0();
+			}
 			out.m_diffuseColor = in.m_diffuseColor;
 			out.m_radius = in.m_distance;
 			out.m_squareRadiusOverOne = 1.0f / (in.m_distance * in.m_distance);
@@ -431,17 +435,19 @@ void ClusterBinning::writeClustererBuffersTask()
 		unis.m_tileSize = m_r->getTileSize();
 		unis.m_lightVolumeLastZSplit = m_r->getVolumetricLightingAccumulation().getFinalZSplit();
 
-		unis.m_objectCountsUpTo[CLUSTER_OBJECT_TYPE_POINT_LIGHT] = rqueue.m_pointLights.getSize();
-		unis.m_objectCountsUpTo[CLUSTER_OBJECT_TYPE_SPOT_LIGHT] =
-			unis.m_objectCountsUpTo[CLUSTER_OBJECT_TYPE_SPOT_LIGHT - 1] + rqueue.m_spotLights.getSize();
-		unis.m_objectCountsUpTo[CLUSTER_OBJECT_TYPE_DECAL] =
-			unis.m_objectCountsUpTo[CLUSTER_OBJECT_TYPE_DECAL - 1] + rqueue.m_decals.getSize();
-		unis.m_objectCountsUpTo[CLUSTER_OBJECT_TYPE_FOG_DENSITY_VOLUME] =
-			unis.m_objectCountsUpTo[CLUSTER_OBJECT_TYPE_FOG_DENSITY_VOLUME - 1] + rqueue.m_fogDensityVolumes.getSize();
-		unis.m_objectCountsUpTo[CLUSTER_OBJECT_TYPE_REFLECTION_PROBE] =
-			unis.m_objectCountsUpTo[CLUSTER_OBJECT_TYPE_REFLECTION_PROBE - 1] + rqueue.m_reflectionProbes.getSize();
-		unis.m_objectCountsUpTo[CLUSTER_OBJECT_TYPE_GLOBAL_ILLUMINATION_PROBE] =
-			unis.m_objectCountsUpTo[CLUSTER_OBJECT_TYPE_GLOBAL_ILLUMINATION_PROBE - 1] + rqueue.m_giProbes.getSize();
+		unis.m_objectCountsUpTo[CLUSTER_OBJECT_TYPE_POINT_LIGHT].x() = rqueue.m_pointLights.getSize();
+		unis.m_objectCountsUpTo[CLUSTER_OBJECT_TYPE_SPOT_LIGHT].x() =
+			unis.m_objectCountsUpTo[CLUSTER_OBJECT_TYPE_SPOT_LIGHT - 1].x() + rqueue.m_spotLights.getSize();
+		unis.m_objectCountsUpTo[CLUSTER_OBJECT_TYPE_DECAL].x() =
+			unis.m_objectCountsUpTo[CLUSTER_OBJECT_TYPE_DECAL - 1].x() + rqueue.m_decals.getSize();
+		unis.m_objectCountsUpTo[CLUSTER_OBJECT_TYPE_FOG_DENSITY_VOLUME].x() =
+			unis.m_objectCountsUpTo[CLUSTER_OBJECT_TYPE_FOG_DENSITY_VOLUME - 1].x()
+			+ rqueue.m_fogDensityVolumes.getSize();
+		unis.m_objectCountsUpTo[CLUSTER_OBJECT_TYPE_REFLECTION_PROBE].x() =
+			unis.m_objectCountsUpTo[CLUSTER_OBJECT_TYPE_REFLECTION_PROBE - 1].x() + rqueue.m_reflectionProbes.getSize();
+		unis.m_objectCountsUpTo[CLUSTER_OBJECT_TYPE_GLOBAL_ILLUMINATION_PROBE].x() =
+			unis.m_objectCountsUpTo[CLUSTER_OBJECT_TYPE_GLOBAL_ILLUMINATION_PROBE - 1].x()
+			+ rqueue.m_giProbes.getSize();
 
 		unis.m_reflectionProbesMipCount = F32(m_r->getProbeReflections().getReflectionTextureMipmapCount());
 

+ 1 - 1
AnKi/Renderer/Common.h

@@ -8,7 +8,7 @@
 #include <AnKi/Gr.h>
 #include <AnKi/Core/GpuMemoryPools.h>
 #include <AnKi/Util/Ptr.h>
-#include <AnKi/Shaders/Include/Evsm.h>
+#include <AnKi/Shaders/Include/MiscRendererTypes.h>
 #include <AnKi/Shaders/Include/ClusteredShadingTypes.h>
 
 namespace anki {

+ 2 - 10
AnKi/Renderer/DepthDownscale.cpp

@@ -259,15 +259,7 @@ void DepthDownscale::runCompute(RenderPassWorkContext& rgraphCtx)
 	SpdSetup(dispatchThreadGroupCountXY, workGroupOffset, numWorkGroupsAndMips, rectInfo);
 	SpdSetup(dispatchThreadGroupCountXY, workGroupOffset, numWorkGroupsAndMips, rectInfo, m_mipCount);
 
-	class PC
-	{
-	public:
-		U32 m_workgroupCount;
-		U32 m_mipmapCount;
-		Vec2 m_srcTexSizeOverOne;
-		U32 m_lastMipWidth;
-		U32 m_padding[3u];
-	} pc;
+	DepthDownscaleUniforms pc;
 	pc.m_workgroupCount = numWorkGroupsAndMips[0];
 	pc.m_mipmapCount = numWorkGroupsAndMips[1];
 	pc.m_srcTexSizeOverOne = 1.0f / Vec2(m_r->getInternalResolution());
@@ -347,7 +339,7 @@ void DepthDownscale::runGraphics(U32 mip, RenderPassWorkContext& rgraphCtx)
 
 	cmdb->bindStorageBuffer(0, 2, m_clientBuffer, 0, MAX_PTR_SIZE);
 
-	UVec4 pc((mip != m_mipCount - 1) ? 0 : m_lastMipSize.x());
+	const UVec4 pc((mip != m_mipCount - 1) ? 0 : m_lastMipSize.x());
 	cmdb->setPushConstants(&pc, sizeof(pc));
 
 	const UVec2 size = (m_r->getInternalResolution() / 2) >> mip;

+ 5 - 8
AnKi/Renderer/Drawer.cpp

@@ -49,16 +49,13 @@ void RenderableDrawer::drawRange(RenderingTechnique technique, const Mat4& viewM
 	// Allocate, set and bind global uniforms
 	{
 		StagingGpuMemoryToken globalUniformsToken;
-		MaterialGlobalUniforms* globalIniforms =
+		MaterialGlobalUniforms* globalUniforms =
 			static_cast<MaterialGlobalUniforms*>(m_r->getStagingGpuMemory().allocateFrame(
 				sizeof(MaterialGlobalUniforms), StagingGpuMemoryType::UNIFORM, globalUniformsToken));
-		memcpy(&globalIniforms->m_viewProjectionMatrix[0], &viewProjMat, sizeof(viewProjMat));
-		const Mat3x4 viewMat3x4(viewMat);
-		memcpy(&globalIniforms->m_viewMatrix[0], &viewMat3x4, sizeof(viewMat3x4));
-		globalIniforms->m_viewRotationMatrix = viewMat.getRotationPart();
-		const Mat3 camRotationMatrix = viewMat.getInverse().getRotationPart();
-		globalIniforms->m_cameraRotationMatrix = camRotationMatrix;
-		globalIniforms->m_cameraPosition = viewMat.getInverse().getTranslationPart().xyz();
+		globalUniforms->m_viewProjectionMatrix = viewProjMat;
+
+		globalUniforms->m_viewMatrix = Mat3x4(viewMat);
+		globalUniforms->m_cameraTransform = Mat3x4(viewMat.getInverse());
 
 		cmdb->bindUniformBuffer(MATERIAL_SET_GLOBAL, MATERIAL_BINDING_GLOBAL_UNIFORMS, globalUniformsToken.m_buffer,
 								globalUniformsToken.m_offset, globalUniformsToken.m_range);

+ 2 - 3
AnKi/Renderer/FinalComposite.cpp

@@ -167,9 +167,8 @@ void FinalComposite::run(RenderingContext& ctx, RenderPassWorkContext& rgraphCtx
 			rgraphCtx.bindColorTexture(0, 9, m_r->getDbg().getRt());
 		}
 
-		UVec4 frameCountPad3;
-		frameCountPad3.x() = m_r->getFrameCount() & MAX_U32;
-		cmdb->setPushConstants(&frameCountPad3, sizeof(frameCountPad3));
+		const UVec4 frameCount(m_r->getFrameCount() & MAX_U32);
+		cmdb->setPushConstants(&frameCount, sizeof(frameCount));
 	}
 	else
 	{

+ 6 - 6
AnKi/Renderer/GBuffer.h

@@ -20,9 +20,9 @@ public:
 	GBuffer(Renderer* r)
 		: RendererObject(r)
 	{
-		registerDebugRenderTarget("GBuffer_normals");
-		registerDebugRenderTarget("GBuffer_albedo");
-		registerDebugRenderTarget("GBuffer_velocity");
+		registerDebugRenderTarget("GBufferNormals");
+		registerDebugRenderTarget("GBufferAlbedo");
+		registerDebugRenderTarget("GBufferVelocity");
 	}
 
 	~GBuffer();
@@ -50,15 +50,15 @@ public:
 	void getDebugRenderTarget(CString rtName, RenderTargetHandle& handle,
 							  ShaderProgramPtr& optionalShaderProgram) const override
 	{
-		if(rtName == "GBuffer_albedo")
+		if(rtName == "GBufferAlbedo")
 		{
 			handle = m_runCtx.m_colorRts[0];
 		}
-		else if(rtName == "GBuffer_normals")
+		else if(rtName == "GBufferNormals")
 		{
 			handle = m_runCtx.m_colorRts[2];
 		}
-		else if(rtName == "GBuffer_velocity")
+		else if(rtName == "GBufferVelocity")
 		{
 			handle = m_runCtx.m_colorRts[3];
 		}

+ 0 - 1
AnKi/Renderer/IndirectDiffuse.cpp

@@ -11,7 +11,6 @@
 #include <AnKi/Renderer/MotionVectors.h>
 #include <AnKi/Renderer/IndirectDiffuseProbes.h>
 #include <AnKi/Core/ConfigSet.h>
-#include <AnKi/Shaders/Include/IndirectDiffuseTypes.h>
 
 namespace anki {
 

+ 0 - 1
AnKi/Renderer/IndirectSpecular.cpp

@@ -11,7 +11,6 @@
 #include <AnKi/Renderer/RenderQueue.h>
 #include <AnKi/Renderer/ProbeReflections.h>
 #include <AnKi/Core/ConfigSet.h>
-#include <AnKi/Shaders/Include/SsrTypes.h>
 
 namespace anki {
 

+ 0 - 1
AnKi/Renderer/LensFlare.cpp

@@ -9,7 +9,6 @@
 #include <AnKi/Renderer/Renderer.h>
 #include <AnKi/Core/ConfigSet.h>
 #include <AnKi/Util/Functions.h>
-#include <AnKi/Shaders/Include/LensFlareTypes.h>
 
 namespace anki {
 

+ 0 - 1
AnKi/Renderer/Renderer.cpp

@@ -301,7 +301,6 @@ Error Renderer::populateRenderGraph(RenderingContext& ctx)
 	ctx.m_matrices.m_view = ctx.m_renderQueue->m_viewMatrix;
 	ctx.m_matrices.m_projection = ctx.m_renderQueue->m_projectionMatrix;
 	ctx.m_matrices.m_viewProjection = ctx.m_renderQueue->m_viewProjectionMatrix;
-	ctx.m_matrices.m_viewRotation = ctx.m_renderQueue->m_viewMatrix.getRotationPart();
 
 	ctx.m_matrices.m_jitter = m_jitteredMats8x[m_frameCount & (m_jitteredMats8x.getSize() - 1)];
 	ctx.m_matrices.m_projectionJitter = ctx.m_matrices.m_jitter * ctx.m_matrices.m_projection;

+ 0 - 1
AnKi/Renderer/RtShadows.h

@@ -9,7 +9,6 @@
 #include <AnKi/Renderer/RendererObject.h>
 #include <AnKi/Resource/ImageResource.h>
 #include <AnKi/Util/BitSet.h>
-#include <AnKi/Shaders/Include/RtShadows.h>
 
 namespace anki {
 

+ 3 - 4
AnKi/Renderer/ShadowMapping.cpp

@@ -9,7 +9,6 @@
 #include <AnKi/Core/ConfigSet.h>
 #include <AnKi/Util/ThreadHive.h>
 #include <AnKi/Util/Tracer.h>
-#include <AnKi/Shaders/Include/ShadowMappingTypes.h>
 
 namespace anki {
 
@@ -159,11 +158,11 @@ void ShadowMapping::runAtlas(RenderPassWorkContext& rgraphCtx)
 	CommandBufferPtr& cmdb = rgraphCtx.m_commandBuffer;
 
 	// Allocate and populate uniforms
-	ShadowMappingUniforms* uniforms = allocateAndBindStorage<ShadowMappingUniforms*>(
-		m_atlas.m_resolveWorkItems.getSize() * sizeof(ShadowMappingUniforms), cmdb, 0, 0);
+	EvsmResolveUniforms* uniforms = allocateAndBindStorage<EvsmResolveUniforms*>(
+		m_atlas.m_resolveWorkItems.getSize() * sizeof(EvsmResolveUniforms), cmdb, 0, 0);
 	for(U32 i = 0; i < m_atlas.m_resolveWorkItems.getSize(); ++i)
 	{
-		ShadowMappingUniforms& uni = uniforms[i];
+		EvsmResolveUniforms& uni = uniforms[i];
 		const Atlas::ResolveWorkItem& workItem = m_atlas.m_resolveWorkItems[i];
 
 		uni.m_viewportXY = IVec2(workItem.m_viewportOut.xy());

+ 1 - 11
AnKi/Renderer/VolumetricFog.cpp

@@ -72,17 +72,7 @@ void VolumetricFog::populateRenderGraph(RenderingContext& ctx)
 
 		rgraphCtx.bindImage(0, 2, m_runCtx.m_rt, TextureSubresourceInfo());
 
-		class PushConsts
-		{
-		public:
-			Vec3 m_fogDiffuse;
-			F32 m_fogScatteringCoeff;
-			F32 m_fogAbsorptionCoeff;
-			F32 m_near;
-			F32 m_far;
-			F32 m_padding;
-		} regs;
-
+		VolumetricFogUniforms regs;
 		const SkyboxQueueElement& el = ctx.m_renderQueue->m_skybox;
 		regs.m_fogDiffuse = el.m_fog.m_diffuseColor;
 		regs.m_fogScatteringCoeff = el.m_fog.m_scatteringCoeff;

+ 1 - 8
AnKi/Renderer/VolumetricLightingAccumulation.cpp

@@ -126,14 +126,7 @@ void VolumetricLightingAccumulation::run(const RenderingContext& ctx, RenderPass
 	bindUniforms(cmdb, 0, 11, rsrc.m_fogDensityVolumesToken);
 	bindStorage(cmdb, 0, 12, rsrc.m_clustersToken);
 
-	class FogUniforms
-	{
-	public:
-		F32 m_densityAtMinHeight;
-		F32 m_densityAtMaxHeight;
-		F32 m_minHeight;
-		F32 m_oneOverMaxMinusMinHeight; // 1 / (maxHeight / minHeight)
-	} unis;
+	VolumetricLightingUniforms unis;
 	const SkyboxQueueElement& queueEl = ctx.m_renderQueue->m_skybox;
 	if(queueEl.m_fog.m_heightOfMaxDensity > queueEl.m_fog.m_heightOfMinDensity)
 	{

+ 0 - 1
AnKi/Scene/Components/RenderComponent.cpp

@@ -42,7 +42,6 @@ void RenderComponent::allocateAndSetupUniforms(const MaterialResourcePtr& mtl, c
 			memcpy(&renderableGpuViews->m_worldTransform, &transforms[i], sizeof(renderableGpuViews->m_worldTransform));
 			memcpy(&renderableGpuViews->m_previousWorldTransform, &prevTransforms[i],
 				   sizeof(renderableGpuViews->m_previousWorldTransform));
-			renderableGpuViews->m_worldRotation = transforms[i].getRotationPart();
 
 			++renderableGpuViews;
 		}

+ 1 - 1
AnKi/Shaders/Blit.glsl

@@ -17,7 +17,7 @@ layout(set = 0, binding = 1) uniform texture2D u_tex;
 #if USE_COMPUTE
 layout(set = 0, binding = 2) uniform writeonly image2D u_outImage;
 
-layout(push_constant, std430) uniform b_pc
+layout(push_constant, std140) uniform b_pc
 {
 	Vec2 u_viewportSize;
 	UVec2 u_viewportSizeU;

+ 22 - 22
AnKi/Shaders/ClusterBinning.ankiprog

@@ -18,42 +18,42 @@ ANKI_SPECIALIZATION_CONSTANT_UVEC2(RENDERING_SIZE, 4u);
 const U32 WORKGROUP_SIZE = 64u;
 layout(local_size_x = WORKGROUP_SIZE) in;
 
-layout(set = 0, binding = 0, scalar) uniform b_unis
+layout(set = 0, binding = 0) uniform b_unis
 {
 	ClusteredShadingUniforms u_unis;
 };
 
-layout(set = 0, binding = 1, scalar) writeonly buffer b_clusters
+layout(set = 0, binding = 1) writeonly buffer b_clusters
 {
 	Cluster u_clusters[];
 };
 
-layout(set = 0, binding = 2, scalar) uniform b_pointLights
+layout(set = 0, binding = 2) uniform b_pointLights
 {
 	PointLight u_pointLights[MAX_VISIBLE_POINT_LIGHTS];
 };
 
-layout(set = 0, binding = 3, scalar) uniform b_spotLights
+layout(set = 0, binding = 3) uniform b_spotLights
 {
 	SpotLightBinning u_spotLights[MAX_VISIBLE_SPOT_LIGHTS];
 };
 
-layout(set = 0, binding = 4, scalar) uniform b_reflectionProbes
+layout(set = 0, binding = 4) uniform b_reflectionProbes
 {
 	ReflectionProbe u_reflectionProbes[MAX_VISIBLE_REFLECTION_PROBES];
 };
 
-layout(set = 0, binding = 5, scalar) uniform b_giProbes
+layout(set = 0, binding = 5) uniform b_giProbes
 {
 	GlobalIlluminationProbe u_giProbes[MAX_VISIBLE_GLOBAL_ILLUMINATION_PROBES];
 };
 
-layout(set = 0, binding = 6, scalar) uniform b_fogVolumes
+layout(set = 0, binding = 6) uniform b_fogVolumes
 {
 	FogDensityVolume u_fogVolumes[MAX_VISIBLE_FOG_DENSITY_VOLUMES];
 };
 
-layout(set = 0, binding = 7, scalar) uniform b_decals
+layout(set = 0, binding = 7) uniform b_decals
 {
 	Decal u_decals[MAX_VISIBLE_DECALS];
 };
@@ -75,32 +75,32 @@ shared ExtendedClusterObjectMask s_zSplitMasks[Z_SPLIT_COUNT];
 
 Bool isPointLight()
 {
-	return gl_GlobalInvocationID.y < u_unis.m_objectCountsUpTo[CLUSTER_OBJECT_TYPE_POINT_LIGHT];
+	return gl_GlobalInvocationID.y < u_unis.m_objectCountsUpTo[CLUSTER_OBJECT_TYPE_POINT_LIGHT].x;
 }
 
 Bool isSpotLight()
 {
-	return gl_GlobalInvocationID.y < u_unis.m_objectCountsUpTo[CLUSTER_OBJECT_TYPE_SPOT_LIGHT];
+	return gl_GlobalInvocationID.y < u_unis.m_objectCountsUpTo[CLUSTER_OBJECT_TYPE_SPOT_LIGHT].x;
 }
 
 Bool isDecal()
 {
-	return gl_GlobalInvocationID.y < u_unis.m_objectCountsUpTo[CLUSTER_OBJECT_TYPE_DECAL];
+	return gl_GlobalInvocationID.y < u_unis.m_objectCountsUpTo[CLUSTER_OBJECT_TYPE_DECAL].x;
 }
 
 Bool isFogVolume()
 {
-	return gl_GlobalInvocationID.y < u_unis.m_objectCountsUpTo[CLUSTER_OBJECT_TYPE_FOG_DENSITY_VOLUME];
+	return gl_GlobalInvocationID.y < u_unis.m_objectCountsUpTo[CLUSTER_OBJECT_TYPE_FOG_DENSITY_VOLUME].x;
 }
 
 Bool isReflectionProbe()
 {
-	return gl_GlobalInvocationID.y < u_unis.m_objectCountsUpTo[CLUSTER_OBJECT_TYPE_REFLECTION_PROBE];
+	return gl_GlobalInvocationID.y < u_unis.m_objectCountsUpTo[CLUSTER_OBJECT_TYPE_REFLECTION_PROBE].x;
 }
 
 Bool isGiProbe()
 {
-	return gl_GlobalInvocationID.y < u_unis.m_objectCountsUpTo[CLUSTER_OBJECT_TYPE_GLOBAL_ILLUMINATION_PROBE];
+	return gl_GlobalInvocationID.y < u_unis.m_objectCountsUpTo[CLUSTER_OBJECT_TYPE_GLOBAL_ILLUMINATION_PROBE].x;
 }
 
 void main()
@@ -152,7 +152,7 @@ void main()
 	// Spot light
 	else if(isSpotLight())
 	{
-		objectArrayIdx = clustererObjectIdx - u_unis.m_objectCountsUpTo[CLUSTER_OBJECT_TYPE_SPOT_LIGHT - 1u];
+		objectArrayIdx = clustererObjectIdx - u_unis.m_objectCountsUpTo[CLUSTER_OBJECT_TYPE_SPOT_LIGHT - 1u].x;
 		const SpotLightBinning light = u_spotLights[objectArrayIdx];
 
 		t0 = 10000.0;
@@ -164,9 +164,9 @@ void main()
 		U32 idx = 0u;
 		do
 		{
-			const Vec3 v0 = light.m_edgePoints[indices[idx + 0u]];
-			const Vec3 v1 = light.m_edgePoints[indices[idx + 1u]];
-			const Vec3 v2 = light.m_edgePoints[indices[idx + 2u]];
+			const Vec3 v0 = light.m_edgePoints[indices[idx + 0u]].xyz;
+			const Vec3 v1 = light.m_edgePoints[indices[idx + 1u]].xyz;
+			const Vec3 v2 = light.m_edgePoints[indices[idx + 2u]].xyz;
 
 			F32 t, u, v;
 			const Bool localCollides = testRayTriangle(rayOrigin, rayDir, v0, v1, v2, false, t, u, v);
@@ -190,7 +190,7 @@ void main()
 	// Decal
 	else if(isDecal())
 	{
-		objectArrayIdx = clustererObjectIdx - u_unis.m_objectCountsUpTo[CLUSTER_OBJECT_TYPE_DECAL - 1u];
+		objectArrayIdx = clustererObjectIdx - u_unis.m_objectCountsUpTo[CLUSTER_OBJECT_TYPE_DECAL - 1u].x;
 		const Decal decal = u_decals[objectArrayIdx];
 
 		collides = testRayObb(rayOrigin, rayDir, decal.m_obbExtend, decal.m_invertedTransform, t0, t1);
@@ -198,7 +198,7 @@ void main()
 	// Fog volume
 	else if(isFogVolume())
 	{
-		objectArrayIdx = clustererObjectIdx - u_unis.m_objectCountsUpTo[CLUSTER_OBJECT_TYPE_FOG_DENSITY_VOLUME - 1u];
+		objectArrayIdx = clustererObjectIdx - u_unis.m_objectCountsUpTo[CLUSTER_OBJECT_TYPE_FOG_DENSITY_VOLUME - 1u].x;
 		const FogDensityVolume vol = u_fogVolumes[objectArrayIdx];
 
 		if(vol.m_isBox != 0u)
@@ -215,7 +215,7 @@ void main()
 	// Reflection probe
 	else if(isReflectionProbe())
 	{
-		objectArrayIdx = clustererObjectIdx - u_unis.m_objectCountsUpTo[CLUSTER_OBJECT_TYPE_REFLECTION_PROBE - 1u];
+		objectArrayIdx = clustererObjectIdx - u_unis.m_objectCountsUpTo[CLUSTER_OBJECT_TYPE_REFLECTION_PROBE - 1u].x;
 		const ReflectionProbe probe = u_reflectionProbes[objectArrayIdx];
 
 		collides = testRayAabb(rayOrigin, rayDir, probe.m_aabbMin, probe.m_aabbMax, t0, t1);
@@ -224,7 +224,7 @@ void main()
 	else
 	{
 		objectArrayIdx =
-			clustererObjectIdx - u_unis.m_objectCountsUpTo[CLUSTER_OBJECT_TYPE_GLOBAL_ILLUMINATION_PROBE - 1u];
+			clustererObjectIdx - u_unis.m_objectCountsUpTo[CLUSTER_OBJECT_TYPE_GLOBAL_ILLUMINATION_PROBE - 1u].x;
 		const GlobalIlluminationProbe probe = u_giProbes[objectArrayIdx];
 
 		collides = testRayAabb(rayOrigin, rayDir, probe.m_aabbMin, probe.m_aabbMax, t0, t1);

+ 12 - 12
AnKi/Shaders/ClusteredShadingCommon.glsl

@@ -11,7 +11,7 @@
 // Common uniforms
 //
 #if defined(CLUSTERED_SHADING_UNIFORMS_BINDING)
-layout(set = CLUSTERED_SHADING_SET, binding = CLUSTERED_SHADING_UNIFORMS_BINDING, scalar) uniform b_clusteredShading
+layout(set = CLUSTERED_SHADING_SET, binding = CLUSTERED_SHADING_UNIFORMS_BINDING) uniform b_clusteredShading
 {
 	ClusteredShadingUniforms u_clusteredShading;
 };
@@ -21,14 +21,14 @@ layout(set = CLUSTERED_SHADING_SET, binding = CLUSTERED_SHADING_UNIFORMS_BINDING
 // Light uniforms (3)
 //
 #if defined(CLUSTERED_SHADING_LIGHTS_BINDING)
-layout(set = CLUSTERED_SHADING_SET, binding = CLUSTERED_SHADING_LIGHTS_BINDING, scalar) uniform b_pointLights
+layout(set = CLUSTERED_SHADING_SET, binding = CLUSTERED_SHADING_LIGHTS_BINDING) uniform b_pointLights
 {
 	PointLight u_pointLights2[MAX_VISIBLE_POINT_LIGHTS];
 };
 
-layout(set = CLUSTERED_SHADING_SET, binding = CLUSTERED_SHADING_LIGHTS_BINDING + 1u, scalar) uniform b_spotLights
+layout(set = CLUSTERED_SHADING_SET, binding = CLUSTERED_SHADING_LIGHTS_BINDING + 1u) uniform b_spotLights
 {
-	SpotLight u_spotLights2[MAX_VISIBLE_SPOT_LIGHTS];
+	SpotLight u_spotLights[MAX_VISIBLE_SPOT_LIGHTS];
 };
 
 layout(set = CLUSTERED_SHADING_SET, binding = CLUSTERED_SHADING_LIGHTS_BINDING + 2u) uniform texture2D u_shadowAtlasTex;
@@ -38,7 +38,7 @@ layout(set = CLUSTERED_SHADING_SET, binding = CLUSTERED_SHADING_LIGHTS_BINDING +
 // Reflection probes (3)
 //
 #if defined(CLUSTERED_SHADING_REFLECTIONS_BINDING)
-layout(set = CLUSTERED_SHADING_SET, binding = CLUSTERED_SHADING_REFLECTIONS_BINDING, scalar) uniform b_reflectionProbes
+layout(set = CLUSTERED_SHADING_SET, binding = CLUSTERED_SHADING_REFLECTIONS_BINDING) uniform b_reflectionProbes
 {
 	ReflectionProbe u_reflectionProbes[MAX_VISIBLE_REFLECTION_PROBES];
 };
@@ -51,7 +51,7 @@ layout(set = CLUSTERED_SHADING_SET,
 // Decal uniforms (3)
 //
 #if defined(CLUSTERED_SHADING_DECALS_BINDING)
-layout(set = CLUSTERED_SHADING_SET, binding = CLUSTERED_SHADING_DECALS_BINDING, scalar) uniform b_decals
+layout(set = CLUSTERED_SHADING_SET, binding = CLUSTERED_SHADING_DECALS_BINDING) uniform b_decals
 {
 	Decal u_decals2[MAX_VISIBLE_DECALS];
 };
@@ -66,7 +66,7 @@ layout(set = CLUSTERED_SHADING_SET,
 // Fog density uniforms (1)
 //
 #if defined(CLUSTERED_SHADING_FOG_BINDING)
-layout(set = CLUSTERED_SHADING_SET, binding = CLUSTERED_SHADING_FOG_BINDING, scalar) uniform b_fogDensityVolumes
+layout(set = CLUSTERED_SHADING_SET, binding = CLUSTERED_SHADING_FOG_BINDING) uniform b_fogDensityVolumes
 {
 	FogDensityVolume u_fogDensityVolumes[MAX_VISIBLE_FOG_DENSITY_VOLUMES];
 };
@@ -79,7 +79,7 @@ layout(set = CLUSTERED_SHADING_SET, binding = CLUSTERED_SHADING_FOG_BINDING, sca
 layout(set = CLUSTERED_SHADING_SET, binding = CLUSTERED_SHADING_GI_BINDING) uniform ANKI_RP texture3D
 	u_globalIlluminationTextures[MAX_VISIBLE_GLOBAL_ILLUMINATION_PROBES];
 
-layout(set = CLUSTERED_SHADING_SET, binding = CLUSTERED_SHADING_GI_BINDING + 1u, scalar) uniform b_giProbes
+layout(set = CLUSTERED_SHADING_SET, binding = CLUSTERED_SHADING_GI_BINDING + 1u) uniform b_giProbes
 {
 	GlobalIlluminationProbe u_giProbes[MAX_VISIBLE_GLOBAL_ILLUMINATION_PROBES];
 };
@@ -89,9 +89,9 @@ layout(set = CLUSTERED_SHADING_SET, binding = CLUSTERED_SHADING_GI_BINDING + 1u,
 // Cluster uniforms
 //
 #if defined(CLUSTERED_SHADING_CLUSTERS_BINDING)
-layout(set = CLUSTERED_SHADING_SET, binding = CLUSTERED_SHADING_CLUSTERS_BINDING, scalar) readonly buffer b_clusters
+layout(set = CLUSTERED_SHADING_SET, binding = CLUSTERED_SHADING_CLUSTERS_BINDING) readonly buffer b_clusters
 {
-	Cluster u_clusters2[];
+	Cluster u_clusters[];
 };
 #endif
 
@@ -181,9 +181,9 @@ Cluster mergeClusters(Cluster tileCluster, Cluster zCluster)
 /// Get the final cluster after ORing and ANDing the masks.
 Cluster getClusterFragCoord(Vec3 fragCoord, U32 tileSize, UVec2 tileCounts, U32 zSplitCount, F32 a, F32 b)
 {
-	const Cluster tileCluster = u_clusters2[computeTileClusterIndexFragCoord(fragCoord.xy, tileSize, tileCounts.x)];
+	const Cluster tileCluster = u_clusters[computeTileClusterIndexFragCoord(fragCoord.xy, tileSize, tileCounts.x)];
 	const Cluster zCluster =
-		u_clusters2[computeZSplitClusterIndex(fragCoord.z, zSplitCount, a, b) + tileCounts.x * tileCounts.y];
+		u_clusters[computeZSplitClusterIndex(fragCoord.z, zSplitCount, a, b) + tileCounts.x * tileCounts.y];
 	return mergeClusters(tileCluster, zCluster);
 }
 

+ 8 - 11
AnKi/Shaders/DepthDownscaleCompute.ankiprog

@@ -9,16 +9,13 @@
 
 #pragma anki start comp
 #include <AnKi/Shaders/Common.glsl>
+#include <AnKi/Shaders/Include/MiscRendererTypes.h>
 
 layout(local_size_x = 256) in;
 
-layout(push_constant, std430) uniform b_pc
+layout(push_constant, std140) uniform b_pc
 {
-	U32 u_workgroupCount;
-	U32 u_mipmapCount;
-	Vec2 u_srcTexSizeOverOne;
-	U32 u_lastMipWidth;
-	U32 u_padding[3u];
+	DepthDownscaleUniforms u_unis;
 };
 
 layout(set = 0, binding = 0) uniform image2D u_dstImages[12u];
@@ -47,7 +44,7 @@ shared AF1 s_spdIntermediateR[16][16];
 
 AF4 SpdLoadSourceImage(AU2 p, AU1 slice)
 {
-	const AF2 textureCoord = Vec2(p) * u_srcTexSizeOverOne + u_srcTexSizeOverOne;
+	const AF2 textureCoord = Vec2(p) * u_unis.m_srcTexSizeOverOne + u_unis.m_srcTexSizeOverOne;
 	return AF4(textureLod(u_srcTex, u_linearAnyClampSampler, textureCoord, 0.0).r, 0.0, 0.0, 0.0);
 }
 
@@ -68,9 +65,9 @@ void SpdStore(AU2 p, AF4 value, AU1 mip, AU1 slice)
 	}
 
 	// Store the last mip to the buffer as well
-	if(mip == u_mipmapCount - 1u)
+	if(mip == u_unis.m_mipmapCount - 1u)
 	{
-		const U32 idx = p.y * u_lastMipWidth + p.x;
+		const U32 idx = p.y * u_unis.m_lastMipWidth + p.x;
 		u_clientBuf[idx] = value.x;
 	}
 }
@@ -118,8 +115,8 @@ void main()
 {
 	const U32 slice = 0u;
 	const UVec2 offset = UVec2(0u);
-	SpdDownsample(AU2(gl_WorkGroupID.xy), AU1(gl_LocalInvocationIndex), AU1(u_mipmapCount), AU1(u_workgroupCount),
-				  slice, offset);
+	SpdDownsample(AU2(gl_WorkGroupID.xy), AU1(gl_LocalInvocationIndex), AU1(u_unis.m_mipmapCount),
+				  AU1(u_unis.m_workgroupCount), slice, offset);
 }
 
 #pragma anki end

+ 2 - 2
AnKi/Shaders/DepthDownscaleRaster.ankiprog

@@ -23,10 +23,10 @@ layout(std430, set = 0, binding = 2) writeonly buffer b_cb
 	F32 u_clientBuf[];
 };
 
-layout(push_constant, scalar) uniform b_pc
+layout(push_constant, std140) uniform b_pc
 {
+	Vec3 u_padding;
 	U32 u_lastMipWidth;
-	UVec3 u_padding;
 };
 
 void main()

+ 1 - 1
AnKi/Shaders/DownscaleBlur.glsl

@@ -15,7 +15,7 @@ const UVec2 WORKGROUP_SIZE = UVec2(16, 16);
 layout(local_size_x = WORKGROUP_SIZE.x, local_size_y = WORKGROUP_SIZE.y, local_size_z = 1) in;
 
 // Push constants hold the size of the output image
-layout(push_constant, row_major, std430) uniform pc_
+layout(push_constant, row_major, std140) uniform b_pc
 {
 	UVec2 u_fbSize;
 	UVec2 u_padding;

+ 6 - 6
AnKi/Shaders/Evsm.glsl

@@ -6,11 +6,11 @@
 ANKI_SPECIALIZATION_CONSTANT_UVEC2(INPUT_TEXTURE_SIZE, 0u);
 ANKI_SPECIALIZATION_CONSTANT_UVEC2(FB_SIZE, 2u);
 
-#include <AnKi/Shaders/Include/ShadowMappingTypes.h>
+#include <AnKi/Shaders/Include/MiscRendererTypes.h>
 
-layout(set = 0, binding = 0, std430) readonly buffer b_unis
+layout(set = 0, binding = 0) readonly buffer b_unis
 {
-	ShadowMappingUniforms u_uniforms[];
+	EvsmResolveUniforms u_uniforms[];
 };
 
 #if defined(ANKI_VERTEX_SHADER)
@@ -21,7 +21,7 @@ layout(location = 1) flat out I32 out_instanceIndex;
 
 void main()
 {
-	const ShadowMappingUniforms uni = u_uniforms[gl_InstanceIndex];
+	const EvsmResolveUniforms uni = u_uniforms[gl_InstanceIndex];
 
 	const Vec2 uv = Vec2(((gl_VertexID + 2) / 3) % 2, ((gl_VertexID + 1) / 3) % 2);
 
@@ -63,12 +63,12 @@ Vec4 computeMoments(Vec2 uv)
 void main()
 {
 #	if defined(ANKI_COMPUTE_SHADER)
-	const ShadowMappingUniforms uni = u_uniforms[gl_GlobalInvocationID.z];
+	const EvsmResolveUniforms uni = u_uniforms[gl_GlobalInvocationID.z];
 
 	Vec2 uv = (Vec2(gl_GlobalInvocationID.xy) + 0.5) / uni.m_viewportZW; // in [0, 1]
 	uv = uv * uni.m_uvScale + uni.m_uvTranslation;
 #	else
-	const ShadowMappingUniforms uni = u_uniforms[in_instanceIndex];
+	const EvsmResolveUniforms uni = u_uniforms[in_instanceIndex];
 
 	Vec2 uv = in_uv;
 #	endif

+ 4 - 3
AnKi/Shaders/FinalComposite.ankiprog

@@ -34,9 +34,10 @@ layout(set = 0, binding = 8) uniform texture2D u_depthRt;
 layout(set = 0, binding = 9) uniform ANKI_RP texture2D u_dbgOutlineRt;
 #endif
 
-layout(push_constant, row_major, std430) uniform b_pc
+layout(push_constant, std140) uniform b_pc
 {
-	UVec4 u_frameCountPad3;
+	Vec3 u_padding0;
+	U32 u_frameCount;
 };
 
 layout(location = 0) in Vec2 in_uv;
@@ -76,7 +77,7 @@ void main()
 #if BLUE_NOISE
 	const Vec2 bnUvw = Vec2(FB_SIZE) / Vec2(64.0) * uv;
 	ANKI_RP Vec3 blueNoise = textureLod(u_blueNoise, u_trilinearRepeatSampler, bnUvw, 0.0).rgb;
-	blueNoise = animateBlueNoise(blueNoise, u_frameCountPad3.x);
+	blueNoise = animateBlueNoise(blueNoise, u_frameCount);
 	blueNoise = blueNoise * 2.0 - 1.0;
 	blueNoise = sign(blueNoise) * (1.0 - sqrt(1.0 - abs(blueNoise)));
 

+ 1 - 1
AnKi/Shaders/ForwardShadingCommon.glsl

@@ -86,7 +86,7 @@ Vec3 computeLightColorHigh(Vec3 diffCol, Vec3 worldPos)
 	{
 		const I32 idx = findLSB2(cluster.m_spotLightsMask);
 		cluster.m_spotLightsMask &= ~(ExtendedClusterObjectMask(1) << ExtendedClusterObjectMask(idx));
-		const SpotLight light = u_spotLights2[idx];
+		const SpotLight light = u_spotLights[idx];
 
 		const Vec3 diffC = diffCol * light.m_diffuseColor;
 

+ 3 - 5
AnKi/Shaders/ForwardShadingFog.ankiprog

@@ -22,19 +22,17 @@ struct PerDraw
 #pragma anki member ANKI_RP F32 m_fogDistanceOfMaxThikness
 #pragma anki struct end
 
-layout(set = MATERIAL_SET_GLOBAL, binding = MATERIAL_BINDING_GLOBAL_UNIFORMS, row_major,
-	   scalar) uniform b_ankiGlobalUniforms
+layout(set = MATERIAL_SET_GLOBAL, binding = MATERIAL_BINDING_GLOBAL_UNIFORMS) uniform b_ankiGlobalUniforms
 {
 	MaterialGlobalUniforms u_global;
 };
 
-layout(set = MATERIAL_SET_LOCAL, binding = MATERIAL_BINDING_RENDERABLE_GPU_VIEW, row_major,
-	   scalar) uniform b_renderableGpuViews
+layout(set = MATERIAL_SET_LOCAL, binding = MATERIAL_BINDING_RENDERABLE_GPU_VIEW) uniform b_renderableGpuViews
 {
 	RenderableGpuView u_renderableGpuViews[1];
 };
 
-layout(set = MATERIAL_SET_LOCAL, binding = MATERIAL_BINDING_LOCAL_UNIFORMS, row_major, scalar) buffer b_localUniforms
+layout(set = MATERIAL_SET_LOCAL, binding = MATERIAL_BINDING_LOCAL_UNIFORMS, std430) buffer b_localUniforms
 {
 	U32 u_localUniforms[];
 };

+ 4 - 6
AnKi/Shaders/ForwardShadingParticles.ankiprog

@@ -16,21 +16,19 @@
 #pragma anki member ANKI_RP Vec4 m_colorBias
 #pragma anki struct end
 
-layout(set = MATERIAL_SET_GLOBAL, binding = MATERIAL_BINDING_GLOBAL_UNIFORMS, row_major,
-	   scalar) uniform b_ankiGlobalUniforms
+layout(set = MATERIAL_SET_GLOBAL, binding = MATERIAL_BINDING_GLOBAL_UNIFORMS) uniform b_ankiGlobalUniforms
 {
 	MaterialGlobalUniforms u_ankiGlobals;
 };
 
 layout(set = MATERIAL_SET_GLOBAL, binding = MATERIAL_BINDING_TRILINEAR_REPEAT_SAMPLER) uniform sampler u_globalSampler;
 
-layout(set = MATERIAL_SET_LOCAL, binding = MATERIAL_BINDING_LOCAL_UNIFORMS, row_major, scalar) buffer b_localUniforms
+layout(set = MATERIAL_SET_LOCAL, binding = MATERIAL_BINDING_LOCAL_UNIFORMS, std430) buffer b_localUniforms
 {
 	U32 u_localUniforms[];
 };
 
-layout(set = MATERIAL_SET_LOCAL, binding = MATERIAL_BINDING_RENDERABLE_GPU_VIEW, row_major,
-	   scalar) uniform b_renderableGpuViews
+layout(set = MATERIAL_SET_LOCAL, binding = MATERIAL_BINDING_RENDERABLE_GPU_VIEW) uniform b_renderableGpuViews
 {
 	RenderableGpuView u_renderableGpuViews[1];
 };
@@ -59,7 +57,7 @@ void main()
 {
 	out_uv = Vec2(gl_VertexID & 1, gl_VertexID >> 1);
 
-	out_worldPos = u_ankiGlobals.m_cameraRotationMatrix * Vec3((out_uv - 0.5) * in_scale, 0.0) + in_position;
+	out_worldPos = u_ankiGlobals.m_cameraTransform * Vec4((out_uv - 0.5) * in_scale, 0.0, 0.0) + in_position;
 	gl_Position = u_ankiGlobals.m_viewProjectionMatrix
 				  * Vec4(u_renderableGpuViews[0].m_worldTransform * Vec4(out_worldPos, 1.0), 1.0);
 

+ 9 - 9
AnKi/Shaders/GBufferGeneric.ankiprog

@@ -68,19 +68,17 @@ layout(set = MATERIAL_SET_GLOBAL, binding = MATERIAL_BINDING_TRILINEAR_REPEAT_SA
 #pragma anki member ANKI_RP F32 m_subsurface
 #pragma anki struct end
 
-layout(set = MATERIAL_SET_LOCAL, binding = MATERIAL_BINDING_LOCAL_UNIFORMS, row_major, scalar) buffer b_localUniforms
+layout(set = MATERIAL_SET_LOCAL, binding = MATERIAL_BINDING_LOCAL_UNIFORMS, std430) buffer b_localUniforms
 {
 	U32 u_localUniforms[];
 };
 
-layout(set = MATERIAL_SET_LOCAL, binding = MATERIAL_BINDING_RENDERABLE_GPU_VIEW, row_major,
-	   scalar) uniform b_renderableGpuView
+layout(set = MATERIAL_SET_LOCAL, binding = MATERIAL_BINDING_RENDERABLE_GPU_VIEW) uniform b_renderableGpuView
 {
 	RenderableGpuView u_renderableGpuViews[MAX_INSTANCE_COUNT];
 };
 
-layout(set = MATERIAL_SET_GLOBAL, binding = MATERIAL_BINDING_GLOBAL_UNIFORMS, row_major,
-	   scalar) uniform b_globalUniforms
+layout(set = MATERIAL_SET_GLOBAL, binding = MATERIAL_BINDING_GLOBAL_UNIFORMS) uniform b_globalUniforms
 {
 	MaterialGlobalUniforms u_globalUniforms;
 };
@@ -143,8 +141,8 @@ void positionUvNormalTangent()
 {
 	gl_Position = u_globalUniforms.m_viewProjectionMatrix
 				  * Vec4(u_renderableGpuViews[gl_InstanceIndex].m_worldTransform * Vec4(g_position, 1.0), 1.0);
-	out_normal = u_renderableGpuViews[gl_InstanceIndex].m_worldRotation * g_normal;
-	out_tangent = u_renderableGpuViews[gl_InstanceIndex].m_worldRotation * g_tangent.xyz;
+	out_normal = u_renderableGpuViews[gl_InstanceIndex].m_worldTransform * Vec4(g_normal, 0.0);
+	out_tangent = u_renderableGpuViews[gl_InstanceIndex].m_worldTransform * Vec4(g_tangent.xyz, 0.0);
 	out_bitangent = cross(out_normal, out_tangent) * g_tangent.w;
 	out_uv = g_uv;
 }
@@ -158,8 +156,10 @@ void parallax()
 	const Vec3 t = in_tangent.xyz;
 	const Vec3 b = cross(n, t) * in_tangent.w;
 
-	const Mat3 invTbn = transpose(u_globalUniforms.m_viewRotationMatrix
-								  * u_renderableGpuViews[gl_InstanceIndex].m_worldRotation * Mat3(t, b, n));
+	// TODO
+	const Mat3 invTbn = Mat3(1.0);
+	// const Mat3 invTbn = transpose(u_globalUniforms.m_viewRotationMatrix
+	//							  * u_renderableGpuViews[gl_InstanceIndex].m_worldRotation * Mat3(t, b, n));
 
 	const Vec3 viewPos = (u_globalUniforms.m_viewMatrix
 						  * Vec4(u_renderableGpuViews[gl_InstanceIndex].m_worldTransform * Vec4(g_position, 1.0), 1.0))

+ 7 - 9
AnKi/Shaders/GBufferGpuParticles.ankiprog

@@ -20,19 +20,17 @@
 #pragma anki member ANKI_RP Vec3 m_finalEmission
 #pragma anki struct end
 
-layout(set = MATERIAL_SET_LOCAL, binding = MATERIAL_BINDING_LOCAL_UNIFORMS, row_major, scalar) buffer b_localUniforms
+layout(set = MATERIAL_SET_LOCAL, binding = MATERIAL_BINDING_LOCAL_UNIFORMS, std430) buffer b_localUniforms
 {
 	U32 u_localUniforms[];
 };
 
-layout(set = MATERIAL_SET_LOCAL, binding = MATERIAL_BINDING_RENDERABLE_GPU_VIEW, row_major,
-	   scalar) uniform b_renderableGpuView
+layout(set = MATERIAL_SET_LOCAL, binding = MATERIAL_BINDING_RENDERABLE_GPU_VIEW) uniform b_renderableGpuView
 {
 	RenderableGpuView u_renderableGpuViews[1];
 };
 
-layout(set = MATERIAL_SET_GLOBAL, binding = MATERIAL_BINDING_GLOBAL_UNIFORMS, row_major,
-	   scalar) uniform b_globalUniforms
+layout(set = MATERIAL_SET_GLOBAL, binding = MATERIAL_BINDING_GLOBAL_UNIFORMS) uniform b_globalUniforms
 {
 	MaterialGlobalUniforms u_globalUniforms;
 };
@@ -46,7 +44,7 @@ layout(set = MATERIAL_SET_LOCAL, binding = MATERIAL_BINDING_FIRST_NON_STANDARD_L
 
 layout(location = 0) out Vec2 out_velocity;
 layout(location = 1) flat out ANKI_RP F32 out_lifeFactor;
-layout(location = 2) out ANKI_RP Vec3 out_eyeToPosDir;
+layout(location = 2) out flat ANKI_RP Vec3 out_normal;
 
 void main()
 {
@@ -67,7 +65,7 @@ void main()
 
 	out_lifeFactor = saturate(1.0 - (part.m_life / part.m_startingLife));
 
-	out_eyeToPosDir = normalize(part.m_newWorldPosition - u_globalUniforms.m_cameraPosition);
+	out_normal = normalize(u_globalUniforms.m_cameraTransform[3]);
 }
 #pragma anki end
 
@@ -82,7 +80,7 @@ layout(location = 3) out Vec2 out_gbuffer3;
 
 layout(location = 0) in Vec2 in_velocity;
 layout(location = 1) flat in ANKI_RP F32 in_lifeFactor;
-layout(location = 2) in ANKI_RP Vec3 in_eyeToPosDir;
+layout(location = 2) in flat ANKI_RP Vec3 in_normal;
 
 void main()
 {
@@ -90,7 +88,7 @@ void main()
 
 	GbufferInfo g;
 	g.m_diffuse = localUniforms.m_diffColor;
-	g.m_normal = in_eyeToPosDir;
+	g.m_normal = in_normal;
 	g.m_f0 = localUniforms.m_specColor;
 	g.m_roughness = localUniforms.m_roughness;
 	g.m_subsurface = 0.0;

+ 3 - 2
AnKi/Shaders/GpuParticlesSimulation.ankiprog

@@ -73,7 +73,7 @@ Vec3 computeNormal(const Vec2 uv, const F32 depth)
 	Vec3 normalVSpace = cross(origin - top, right - origin);
 	normalVSpace = normalize(normalVSpace);
 
-	return u_state.m_invViewRotation * normalVSpace;
+	return u_state.m_invViewRotation * Vec4(normalVSpace, 0.0);
 }
 
 void initParticle(out GpuParticle p)
@@ -90,7 +90,8 @@ void initParticle(out GpuParticle p)
 	p.m_acceleration = mix(u_props.m_minGravity, u_props.m_maxGravity, randFactor);
 
 	// Calculate the initial velocity
-	const Vec3 initialForce = u_state.m_emitterRotation * mix(u_props.m_minForce, u_props.m_maxForce, randFactor);
+	const Vec3 initialForce =
+		u_state.m_emitterRotation * Vec4(mix(u_props.m_minForce, u_props.m_maxForce, randFactor), 0.0);
 	const Vec3 totalForce = (p.m_acceleration * p.m_mass) + initialForce;
 	const Vec3 acceleration = totalForce / p.m_mass;
 	p.m_velocity = acceleration * u_state.m_dt;

+ 71 - 36
AnKi/Shaders/Include/ClusteredShadingTypes.h

@@ -43,66 +43,83 @@ const ANKI_RP F32 SUBSURFACE_MIN = 0.01f;
 struct PointLight
 {
 	Vec3 m_position; ///< Position in world space.
-	ANKI_RP Vec3 m_diffuseColor;
 	ANKI_RP F32 m_radius; ///< Radius
+
+	ANKI_RP Vec3 m_diffuseColor;
 	ANKI_RP F32 m_squareRadiusOverOne; ///< 1/(radius^2).
+
+	Vec2 m_padding0;
 	U32 m_shadowLayer; ///< Shadow layer used in RT shadows. Also used to show that it doesn't cast shadow.
 	F32 m_shadowAtlasTileScale; ///< UV scale for all tiles.
-	Vec2 m_shadowAtlasTileOffsets[6u];
+
+	Vec4 m_shadowAtlasTileOffsets[6u]; ///< It's a array of Vec2 but because of padding round it up.
 };
-const U32 _ANKI_SIZEOF_PointLight = 22u * ANKI_SIZEOF(U32);
+const U32 _ANKI_SIZEOF_PointLight = 9u * ANKI_SIZEOF(Vec4);
 ANKI_SHADER_STATIC_ASSERT(sizeof(PointLight) == _ANKI_SIZEOF_PointLight);
 
 /// Spot light.
 struct SpotLight
 {
-	Vec3 m_position; ///< Position in world space.
-	Vec3 m_edgePoints[4u]; ///< Edge points in world space.
+	Vec3 m_position;
+	F32 m_padding0;
+
+	Vec4 m_edgePoints[4u]; ///< Edge points in world space.
+
 	ANKI_RP Vec3 m_diffuseColor;
 	ANKI_RP F32 m_radius; ///< Max distance.
+
+	ANKI_RP Vec3 m_direction; ///< Light direction.
 	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.
-	ANKI_RP Vec3 m_direction; ///< Light direction.
 	ANKI_RP F32 m_outerCos;
 	ANKI_RP F32 m_innerCos;
-	Vec2 m_padding;
+	U32 m_padding1;
+
 	Mat4 m_textureMatrix;
 };
-const U32 _ANKI_SIZEOF_SpotLight = 28u * ANKI_SIZEOF(U32) + ANKI_SIZEOF(Mat4);
+const U32 _ANKI_SIZEOF_SpotLight = 12u * ANKI_SIZEOF(Vec4);
 ANKI_SHADER_STATIC_ASSERT(sizeof(SpotLight) == _ANKI_SIZEOF_SpotLight);
 
-/// Spot light different view. This is the same structure as SpotLight but it's designed for binning.
+/// Spot light for binning. This is the same structure as SpotLight (same signature) but it's used for binning.
 struct SpotLightBinning
 {
-	Vec3 m_edgePoints[5u]; ///< Edge points in world space.
+	Vec4 m_edgePoints[5u]; ///< Edge points in world space. Point 0 is the eye pos.
+
 	ANKI_RP Vec3 m_diffuseColor;
 	ANKI_RP F32 m_radius; ///< Max distance.
+
+	ANKI_RP Vec3 m_direction; ///< Light direction.
 	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.
-	ANKI_RP Vec3 m_direction; ///< Light direction.
 	ANKI_RP F32 m_outerCos;
 	ANKI_RP F32 m_innerCos;
-	Vec2 m_padding;
+	U32 m_padding0;
+
 	Mat4 m_textureMatrix;
 };
 const U32 _ANKI_SIZEOF_SpotLightBinning = _ANKI_SIZEOF_SpotLight;
 ANKI_SHADER_STATIC_ASSERT(sizeof(SpotLightBinning) == _ANKI_SIZEOF_SpotLightBinning);
-ANKI_SHADER_STATIC_ASSERT(alignof(SpotLightBinning) == alignof(SpotLight));
+ANKI_SHADER_STATIC_ASSERT(sizeof(SpotLight) == sizeof(SpotLightBinning));
 
 /// Directional light (sun).
 struct DirectionalLight
 {
 	ANKI_RP Vec3 m_diffuseColor;
 	U32 m_cascadeCount; ///< If it's zero then it doesn't cast shadow.
+
 	ANKI_RP Vec3 m_direction;
 	U32 m_active;
+
 	ANKI_RP F32 m_effectiveShadowDistance;
 	ANKI_RP F32 m_shadowCascadesDistancePower;
 	U32 m_shadowLayer; ///< Shadow layer used in RT shadows. Also used to show that it doesn't cast shadow.
-	U32 m_padding;
+	U32 m_padding0;
+
 	Mat4 m_textureMatrices[MAX_SHADOW_CASCADES2];
 };
-const U32 _ANKI_SIZEOF_DirectionalLight = 12u * ANKI_SIZEOF(U32) + MAX_SHADOW_CASCADES2 * ANKI_SIZEOF(Mat4);
+const U32 _ANKI_SIZEOF_DirectionalLight = 3u * ANKI_SIZEOF(Vec4) + MAX_SHADOW_CASCADES2 * ANKI_SIZEOF(Mat4);
 ANKI_SHADER_STATIC_ASSERT(sizeof(DirectionalLight) == _ANKI_SIZEOF_DirectionalLight);
 
 /// Representation of a reflection probe.
@@ -110,22 +127,31 @@ struct ReflectionProbe
 {
 	Vec3 m_position; ///< Position of the probe in world space.
 	F32 m_cubemapIndex; ///< Index in the cubemap array texture.
+
 	Vec3 m_aabbMin;
+	F32 m_padding0;
+
 	Vec3 m_aabbMax;
+	F32 m_padding1;
 };
-const U32 _ANKI_SIZEOF_ReflectionProbe = 10u * ANKI_SIZEOF(U32);
+const U32 _ANKI_SIZEOF_ReflectionProbe = 3u * ANKI_SIZEOF(Vec4);
 ANKI_SHADER_STATIC_ASSERT(sizeof(ReflectionProbe) == _ANKI_SIZEOF_ReflectionProbe);
 
 /// Decal.
 struct Decal
 {
 	Vec4 m_diffuseUv;
+
 	Vec4 m_normRoughnessUv;
+
 	ANKI_RP Vec4 m_blendFactors;
+
 	Mat4 m_textureMatrix;
+
 	Mat4 m_invertedTransform;
+
 	Vec3 m_obbExtend;
-	F32 m_padding;
+	F32 m_padding0;
 };
 const U32 _ANKI_SIZEOF_Decal = 4u * ANKI_SIZEOF(Vec4) + 2u * ANKI_SIZEOF(Mat4);
 ANKI_SHADER_STATIC_ASSERT(sizeof(Decal) == _ANKI_SIZEOF_Decal);
@@ -135,6 +161,7 @@ struct FogDensityVolume
 {
 	Vec3 m_aabbMinOrSphereCenter;
 	U32 m_isBox;
+
 	Vec3 m_aabbMaxOrSphereRadiusSquared;
 	ANKI_RP F32 m_density;
 };
@@ -145,15 +172,18 @@ ANKI_SHADER_STATIC_ASSERT(sizeof(FogDensityVolume) == _ANKI_SIZEOF_FogDensityVol
 struct GlobalIlluminationProbe
 {
 	Vec3 m_aabbMin;
+	F32 m_padding0;
+
 	Vec3 m_aabbMax;
+	F32 m_padding1;
 
 	U32 m_textureIndex; ///< Index to the array of volume textures.
 	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.
 	ANKI_RP F32 m_fadeDistance;
+	F32 m_padding2;
 };
-const U32 _ANKI_SIZEOF_GlobalIlluminationProbe = 9u * ANKI_SIZEOF(U32);
+const U32 _ANKI_SIZEOF_GlobalIlluminationProbe = 3u * ANKI_SIZEOF(Vec4);
 ANKI_SHADER_STATIC_ASSERT(sizeof(GlobalIlluminationProbe) == _ANKI_SIZEOF_GlobalIlluminationProbe);
 
 /// Common matrices.
@@ -163,9 +193,6 @@ struct CommonMatrices
 	Mat4 m_view ANKI_CPP_CODE(= Mat4::getIdentity());
 	Mat4 m_projection ANKI_CPP_CODE(= Mat4::getIdentity());
 	Mat4 m_viewProjection ANKI_CPP_CODE(= Mat4::getIdentity());
-	Mat3 m_viewRotation ANKI_CPP_CODE(= Mat3::getIdentity());
-
-	F32 m_padding[3u]; // Because of the alignment requirements of some of the following members (in C++)
 
 	Mat4 m_jitter ANKI_CPP_CODE(= Mat4::getIdentity());
 	Mat4 m_projectionJitter ANKI_CPP_CODE(= Mat4::getIdentity());
@@ -190,42 +217,43 @@ struct CommonMatrices
 	/// @endcode
 	Vec4 m_unprojectionParameters ANKI_CPP_CODE(= Vec4(0.0f));
 };
-const U32 _ANKI_SIZEOF_CommonMatrices =
-	12u * ANKI_SIZEOF(Mat4) + ANKI_SIZEOF(Vec4) + ANKI_SIZEOF(Mat3) + ANKI_SIZEOF(F32) * 3u;
+const U32 _ANKI_SIZEOF_CommonMatrices = 12u * ANKI_SIZEOF(Mat4) + 1u * ANKI_SIZEOF(Vec4);
 ANKI_SHADER_STATIC_ASSERT(sizeof(CommonMatrices) == _ANKI_SIZEOF_CommonMatrices);
 
 /// Common uniforms for light shading passes.
 struct ClusteredShadingUniforms
 {
 	Vec2 m_renderingSize;
-
 	F32 m_time;
 	U32 m_frame;
 
 	Vec4 m_nearPlaneWSpace;
-	F32 m_near;
-	F32 m_far;
+
 	Vec3 m_cameraPosition;
+	F32 m_reflectionProbesMipCount;
 
 	UVec2 m_tileCounts;
 	U32 m_zSplitCount;
 	F32 m_zSplitCountOverFrustumLength; ///< m_zSplitCount/(far-near)
+
 	Vec2 m_zSplitMagic; ///< It's the "a" and "b" of computeZSplitClusterIndex(). See there for details.
 	U32 m_tileSize;
 	U32 m_lightVolumeLastZSplit;
 
-	/// This are some additive counts used to map a flat index to the index of the specific object.
-	U32 m_objectCountsUpTo[CLUSTER_OBJECT_TYPE_COUNT];
+	Vec2 m_padding0;
+	F32 m_near;
+	F32 m_far;
 
-	F32 m_reflectionProbesMipCount;
+	DirectionalLight m_directionalLight;
 
 	CommonMatrices m_matrices;
 	CommonMatrices m_previousMatrices;
 
-	DirectionalLight m_directionalLight;
+	/// This are some additive counts used to map a flat index to the index of the specific object.
+	UVec4 m_objectCountsUpTo[CLUSTER_OBJECT_TYPE_COUNT];
 };
-const U32 _ANKI_SIZEOF_ClusteredShadingUniforms =
-	28u * ANKI_SIZEOF(U32) + 2u * ANKI_SIZEOF(CommonMatrices) + ANKI_SIZEOF(DirectionalLight);
+const U32 _ANKI_SIZEOF_ClusteredShadingUniforms = (6u + CLUSTER_OBJECT_TYPE_COUNT) * ANKI_SIZEOF(Vec4)
+												  + 2u * ANKI_SIZEOF(CommonMatrices) + ANKI_SIZEOF(DirectionalLight);
 ANKI_SHADER_STATIC_ASSERT(sizeof(ClusteredShadingUniforms) == _ANKI_SIZEOF_ClusteredShadingUniforms);
 
 // Define the type of some cluster object masks
@@ -252,16 +280,23 @@ struct Cluster
 	U32 m_fogDensityVolumesMask;
 	U32 m_reflectionProbesMask;
 	U32 m_giProbesMask;
+
+	// Pad to 16byte
 #if ANKI_CLUSTERED_SHADING_USE_64BIT
-	U32 m_padding; ///< Add some padding to be 100% sure nothing will break.
+	U32 m_padding0;
+	U32 m_padding1;
+	U32 m_padding2;
+#else
+	U32 m_padding0;
+	U32 m_padding1;
 #endif
 };
 
 #if ANKI_CLUSTERED_SHADING_USE_64BIT
-const U32 _ANKI_SIZEOF_Cluster = 5u * ANKI_SIZEOF(U64);
+const U32 _ANKI_SIZEOF_Cluster = 3u * ANKI_SIZEOF(Vec4);
 ANKI_SHADER_STATIC_ASSERT(sizeof(Cluster) == _ANKI_SIZEOF_Cluster);
 #else
-const U32 _ANKI_SIZEOF_Cluster = 6u * ANKI_SIZEOF(U32);
+const U32 _ANKI_SIZEOF_Cluster = 2u * ANKI_SIZEOF(Vec4);
 ANKI_SHADER_STATIC_ASSERT(sizeof(Cluster) == _ANKI_SIZEOF_Cluster);
 #endif
 

+ 0 - 19
AnKi/Shaders/Include/Evsm.h

@@ -1,19 +0,0 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-#pragma once
-
-#include <AnKi/Shaders/Include/Common.h>
-
-ANKI_BEGIN_NAMESPACE
-
-#define ANKI_EVSM4 0 // 2 component EVSM or 4 component EVSM
-
-const F32 EVSM_POSITIVE_CONSTANT = 40.0f; // EVSM positive constant
-const F32 EVSM_NEGATIVE_CONSTANT = 5.0f; // EVSM negative constant
-const F32 EVSM_BIAS = 0.01f;
-const F32 EVSM_LIGHT_BLEEDING_REDUCTION = 0.05f;
-
-ANKI_END_NAMESPACE

+ 2 - 3
AnKi/Shaders/Include/GpuSceneTypes.h

@@ -11,9 +11,8 @@ ANKI_BEGIN_NAMESPACE
 
 struct RenderableGpuView
 {
-	ScalarMat3x4 m_worldTransform;
-	ScalarMat3x4 m_previousWorldTransform;
-	Mat3 m_worldRotation; ///< The roration part of m_worldTransform.
+	Mat3x4 m_worldTransform;
+	Mat3x4 m_previousWorldTransform;
 };
 
 struct SkinGpuView

+ 0 - 34
AnKi/Shaders/Include/IndirectDiffuseTypes.h

@@ -1,34 +0,0 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-#pragma once
-
-#include <AnKi/Shaders/Include/Common.h>
-
-ANKI_BEGIN_NAMESPACE
-
-struct IndirectDiffuseUniforms
-{
-	UVec2 m_viewportSize;
-	Vec2 m_viewportSizef;
-	Vec4 m_projectionMat;
-	ANKI_RP F32 m_radius; ///< In meters.
-	U32 m_sampleCount;
-	ANKI_RP F32 m_sampleCountf;
-	ANKI_RP F32 m_ssaoBias;
-	ANKI_RP F32 m_ssaoStrength;
-	F32 m_padding[3u];
-};
-
-struct IndirectDiffuseDenoiseUniforms
-{
-	Mat4 m_invertedViewProjectionJitterMat;
-	UVec2 m_viewportSize;
-	Vec2 m_viewportSizef;
-	F32 m_sampleCountDiv2;
-	F32 m_padding[3u];
-};
-
-ANKI_END_NAMESPACE

+ 0 - 20
AnKi/Shaders/Include/LensFlareTypes.h

@@ -1,20 +0,0 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-#pragma once
-
-#include <AnKi/Shaders/Include/Common.h>
-
-ANKI_BEGIN_NAMESPACE
-
-// Per flare information
-struct LensFlareSprite
-{
-	Vec4 m_posScale; // xy: Position, zw: Scale
-	ANKI_RP Vec4 m_color;
-	Vec4 m_depthPad3;
-};
-
-ANKI_END_NAMESPACE

+ 4 - 5
AnKi/Shaders/Include/MaterialTypes.h

@@ -12,12 +12,11 @@ ANKI_BEGIN_NAMESPACE
 /// Common data for all materials.
 struct MaterialGlobalUniforms
 {
-	ScalarMat4 m_viewProjectionMatrix;
-	ScalarMat3x4 m_viewMatrix;
-	Mat3 m_viewRotationMatrix; ///< Essentially the rotation part of the view matrix.
-	Mat3 m_cameraRotationMatrix;
-	Vec3 m_cameraPosition; ///< In world space of course.
+	Mat4 m_viewProjectionMatrix;
+	Mat3x4 m_viewMatrix;
+	Mat3x4 m_cameraTransform;
 };
+ANKI_SHADER_STATIC_ASSERT(sizeof(MaterialGlobalUniforms) == 10 * sizeof(Vec4));
 
 const U32 MATERIAL_SET_BINDLESS = 0u;
 const U32 MATERIAL_SET_GLOBAL = 1u;

+ 137 - 0
AnKi/Shaders/Include/MiscRendererTypes.h

@@ -9,4 +9,141 @@
 
 ANKI_BEGIN_NAMESPACE
 
+// EVSM
+#define ANKI_EVSM4 0 // 2 component EVSM or 4 component EVSM
+
+const F32 EVSM_POSITIVE_CONSTANT = 40.0f; // EVSM positive constant
+const F32 EVSM_NEGATIVE_CONSTANT = 5.0f; // EVSM negative constant
+const F32 EVSM_BIAS = 0.01f;
+const F32 EVSM_LIGHT_BLEEDING_REDUCTION = 0.05f;
+
+struct EvsmResolveUniforms
+{
+	IVec2 m_viewportXY;
+	Vec2 m_viewportZW;
+
+	Vec2 m_uvScale;
+	Vec2 m_uvTranslation;
+
+	Vec2 m_uvMin;
+	Vec2 m_uvMax;
+
+	U32 m_blur;
+	U32 m_padding0;
+	U32 m_padding1;
+	U32 m_padding2;
+};
+
+// RT shadows
+const U32 MAX_RT_SHADOW_LAYERS = 8u;
+
+struct RtShadowsUniforms
+{
+	F32 historyRejectFactor[MAX_RT_SHADOW_LAYERS]; // 1.0 means reject, 0.0 not reject
+};
+
+struct RtShadowsDenoiseUniforms
+{
+	Mat4 invViewProjMat;
+
+	F32 time;
+	F32 padding0;
+	F32 padding1;
+	F32 padding2;
+};
+
+// Indirect diffuse
+struct IndirectDiffuseUniforms
+{
+	UVec2 m_viewportSize;
+	Vec2 m_viewportSizef;
+
+	Vec4 m_projectionMat;
+
+	ANKI_RP F32 m_radius; ///< In meters.
+	U32 m_sampleCount;
+	ANKI_RP F32 m_sampleCountf;
+	ANKI_RP F32 m_ssaoBias;
+
+	ANKI_RP F32 m_ssaoStrength;
+	F32 m_padding0;
+	F32 m_padding1;
+	F32 m_padding2;
+};
+
+struct IndirectDiffuseDenoiseUniforms
+{
+	Mat4 m_invertedViewProjectionJitterMat;
+
+	UVec2 m_viewportSize;
+	Vec2 m_viewportSizef;
+
+	F32 m_sampleCountDiv2;
+	F32 m_padding0;
+	F32 m_padding1;
+	F32 m_padding2;
+};
+
+// Lens flare
+struct LensFlareSprite
+{
+	Vec4 m_posScale; // xy: Position, zw: Scale
+	ANKI_RP Vec4 m_color;
+	Vec4 m_depthPad3;
+};
+
+// Depth downscale
+struct DepthDownscaleUniforms
+{
+	Vec2 m_srcTexSizeOverOne;
+	U32 m_workgroupCount;
+	U32 m_mipmapCount;
+
+	U32 m_lastMipWidth;
+	F32 m_padding0;
+	F32 m_padding1;
+	F32 m_padding2;
+};
+
+// Screen space reflections uniforms
+struct SsrUniforms
+{
+	UVec2 m_depthBufferSize;
+	UVec2 m_framebufferSize;
+
+	U32 m_frameCount;
+	U32 m_depthMipCount;
+	U32 m_maxSteps;
+	U32 m_lightBufferMipCount;
+
+	UVec3 m_padding0;
+	U32 m_firstStepPixels;
+
+	Mat4 m_prevViewProjMatMulInvViewProjMat;
+	Mat4 m_projMat;
+	Mat4 m_invProjMat;
+	Mat3x4 m_normalMat;
+};
+
+// Vol fog
+struct VolumetricFogUniforms
+{
+	ANKI_RP Vec3 m_fogDiffuse;
+	ANKI_RP F32 m_fogScatteringCoeff;
+
+	ANKI_RP F32 m_fogAbsorptionCoeff;
+	ANKI_RP F32 m_near;
+	ANKI_RP F32 m_far;
+	F32 m_padding;
+};
+
+// Vol lighting
+struct VolumetricLightingUniforms
+{
+	ANKI_RP F32 m_densityAtMinHeight;
+	ANKI_RP F32 m_densityAtMaxHeight;
+	F32 m_minHeight;
+	F32 m_oneOverMaxMinusMinHeight; // 1 / (maxHeight / minHeight)
+};
+
 ANKI_END_NAMESPACE

+ 1 - 10
AnKi/Shaders/Include/ParticleTypes.h

@@ -44,7 +44,7 @@ struct GpuParticle
 	F32 m_startingLife; // The original max life
 
 	Vec3 m_velocity;
-	F32 m_padding1;
+	F32 m_padding0;
 };
 
 struct GpuParticleSimulationState
@@ -60,17 +60,8 @@ struct GpuParticleSimulationState
 	Vec3 m_emitterPosition;
 	F32 m_padding1;
 
-#if defined(__cplusplus)
 	Mat3x4 m_emitterRotation;
-#else
-	Mat3 m_emitterRotation;
-#endif
-
-#if defined(__cplusplus)
 	Mat3x4 m_invViewRotation;
-#else
-	Mat3 m_invViewRotation;
-#endif
 };
 
 ANKI_END_NAMESPACE

+ 0 - 26
AnKi/Shaders/Include/RtShadows.h

@@ -1,26 +0,0 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-#pragma once
-
-#include <AnKi/Shaders/Include/Common.h>
-
-ANKI_BEGIN_NAMESPACE
-
-const U32 MAX_RT_SHADOW_LAYERS = 8u;
-
-struct RtShadowsUniforms
-{
-	F32 historyRejectFactor[MAX_RT_SHADOW_LAYERS]; // 1.0 means reject, 0.0 not reject
-};
-
-struct RtShadowsDenoiseUniforms
-{
-	Mat4 invViewProjMat;
-	F32 time;
-	U32 padding[3];
-};
-
-ANKI_END_NAMESPACE

+ 0 - 26
AnKi/Shaders/Include/ShadowMappingTypes.h

@@ -1,26 +0,0 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-#pragma once
-
-#include <AnKi/Shaders/Include/Common.h>
-
-ANKI_BEGIN_NAMESPACE
-
-struct ShadowMappingUniforms
-{
-	IVec2 m_viewportXY;
-	Vec2 m_viewportZW;
-	Vec2 m_uvScale;
-	Vec2 m_uvTranslation;
-	Vec2 m_uvMin;
-	Vec2 m_uvMax;
-	U32 m_blur;
-	U32 m_padding0;
-	U32 m_padding1;
-	U32 m_padding2;
-};
-
-ANKI_END_NAMESPACE

+ 0 - 31
AnKi/Shaders/Include/SsgiTypes.h

@@ -1,31 +0,0 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-#pragma once
-
-#include <AnKi/Shaders/Include/Common.h>
-
-ANKI_BEGIN_NAMESPACE
-
-// Screen space reflections uniforms
-struct SsgiUniforms
-{
-	UVec2 m_depthBufferSize;
-	UVec2 m_framebufferSize;
-	U32 m_frameCount;
-	U32 m_maxSteps;
-	U32 m_firstStepPixels;
-	U32 m_padding0;
-	Mat4 m_invProjMat;
-	Mat4 m_projMat;
-	Mat4 m_prevViewProjMatMulInvViewProjMat;
-#ifdef __cplusplus
-	Mat3x4 m_normalMat;
-#else
-	Mat3 m_normalMat;
-#endif
-};
-
-ANKI_END_NAMESPACE

+ 0 - 33
AnKi/Shaders/Include/SsrTypes.h

@@ -1,33 +0,0 @@
-// Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
-// All rights reserved.
-// Code licensed under the BSD License.
-// http://www.anki3d.org/LICENSE
-
-#pragma once
-
-#include <AnKi/Shaders/Include/Common.h>
-
-ANKI_BEGIN_NAMESPACE
-
-// Screen space reflections uniforms
-struct SsrUniforms
-{
-	UVec2 m_depthBufferSize;
-	UVec2 m_framebufferSize;
-	U32 m_frameCount;
-	U32 m_depthMipCount;
-	U32 m_maxSteps;
-	U32 m_lightBufferMipCount;
-	UVec3 m_padding0;
-	U32 m_firstStepPixels;
-	Mat4 m_prevViewProjMatMulInvViewProjMat;
-	Mat4 m_projMat;
-	Mat4 m_invProjMat;
-#ifdef __cplusplus
-	Mat3x4 m_normalMat;
-#else
-	Mat3 m_normalMat;
-#endif
-};
-
-ANKI_END_NAMESPACE

+ 3 - 0
AnKi/Shaders/Include/TraditionalDeferredShadingTypes.h

@@ -89,9 +89,12 @@ struct DeferredSkyboxUniforms
 {
 	ANKI_RP Vec3 m_solidColor;
 	F32 m_padding1;
+
 	Vec2 m_inputTexUvScale;
 	Vec2 m_inputTexUvBias;
+
 	Mat4 m_invertedViewProjectionMat;
+
 	Vec3 m_cameraPos;
 	F32 m_padding2;
 };

+ 3 - 7
AnKi/Shaders/IndirectDiffuse.glsl

@@ -17,7 +17,7 @@ ANKI_SPECIALIZATION_CONSTANT_U32(SAMPLE_COUNT, 6u);
 #include <AnKi/Shaders/PackFunctions.glsl>
 #include <AnKi/Shaders/ImportanceSampling.glsl>
 #include <AnKi/Shaders/TonemappingFunctions.glsl>
-#include <AnKi/Shaders/Include/IndirectDiffuseTypes.h>
+#include <AnKi/Shaders/Include/MiscRendererTypes.h>
 
 #define CLUSTERED_SHADING_SET 0u
 #define CLUSTERED_SHADING_UNIFORMS_BINDING 0u
@@ -43,7 +43,7 @@ layout(location = 0) in Vec2 in_uv;
 layout(location = 0) out Vec3 out_color;
 #endif
 
-layout(push_constant, std430) uniform b_pc
+layout(push_constant, std140) uniform b_pc
 {
 	IndirectDiffuseUniforms u_unis;
 };
@@ -73,7 +73,7 @@ void main()
 
 	// Get normal
 	const Vec3 worldNormal = unpackNormalFromGBuffer(textureLod(u_gbufferRt2, u_linearAnyClampSampler, uv, 0.0));
-	const Vec3 viewNormal = u_clusteredShading.m_matrices.m_viewRotation * worldNormal;
+	const Vec3 viewNormal = (u_clusteredShading.m_matrices.m_view * Vec4(worldNormal, 0.0)).xyz;
 
 	// Get origin
 	const F32 depth = textureLod(u_depthRt, u_linearAnyClampSampler, uv, 0.0).r;
@@ -159,10 +159,6 @@ void main()
 		// Get the cluster
 		Cluster cluster = getClusterFragCoord(Vec3(fragCoord * 2.0, depth));
 
-		// Get world position
-		const Vec4 worldPos4 = u_clusteredShading.m_matrices.m_invertedViewProjectionJitter * Vec4(ndc, depth, 1.0);
-		const Vec3 worldPos = worldPos4.xyz / worldPos4.w;
-
 		if(bitCount(cluster.m_giProbesMask) == 1)
 		{
 			// All subgroups point to the same probe and there is only one probe, do a fast path without blend weight

+ 1 - 1
AnKi/Shaders/IndirectDiffuseDenoise.glsl

@@ -5,7 +5,7 @@
 
 #pragma anki mutator BLUR_ORIENTATION 0 1 // 0: in X axis, 1: in Y axis
 
-#include <AnKi/Shaders/Include/IndirectDiffuseTypes.h>
+#include <AnKi/Shaders/Include/MiscRendererTypes.h>
 #include <AnKi/Shaders/PackFunctions.glsl>
 #include <AnKi/Shaders/Functions.glsl>
 #include <AnKi/Shaders/BilateralFilter.glsl>

+ 3 - 3
AnKi/Shaders/IndirectSpecular.glsl

@@ -8,7 +8,7 @@
 
 #include <AnKi/Shaders/LightFunctions.glsl>
 #include <AnKi/Shaders/PackFunctions.glsl>
-#include <AnKi/Shaders/Include/SsrTypes.h>
+#include <AnKi/Shaders/Include/MiscRendererTypes.h>
 #include <AnKi/Shaders/TonemappingFunctions.glsl>
 #include <AnKi/Shaders/SsRaymarching.glsl>
 
@@ -73,7 +73,7 @@ void main()
 
 	// Compute refl vector
 	const Vec3 viewDir = -normalize(viewPos);
-	const Vec3 viewNormal = u_unis.m_normalMat * worldNormal;
+	const Vec3 viewNormal = u_unis.m_normalMat * Vec4(worldNormal, 0.0);
 #if STOCHASTIC
 	const Vec3 reflDir = sampleReflectionVector(viewDir, viewNormal, roughness, noise.xy);
 #else
@@ -97,7 +97,7 @@ void main()
 	{
 		const Vec3 hitNormal =
 			u_unis.m_normalMat
-			* unpackNormalFromGBuffer(textureLod(u_gbufferRt2, u_trilinearClampSampler, hitPoint.xy, 0.0));
+			* Vec4(unpackNormalFromGBuffer(textureLod(u_gbufferRt2, u_trilinearClampSampler, hitPoint.xy, 0.0)), 0.0);
 		F32 backFaceAttenuation;
 		rejectBackFaces(reflDir, hitNormal, backFaceAttenuation);
 

+ 3 - 3
AnKi/Shaders/IrradianceDice.ankiprog

@@ -34,7 +34,7 @@ layout(set = 0, binding = 2) uniform texture2D u_gbufferTex[3u];
 #endif
 
 // This is a temporary buffer used instead of shared memory because we can't fit it into shared memory
-layout(set = 0, binding = 3, std430) buffer ssbo_
+layout(set = 0, binding = 3) buffer b_ssbo
 {
 	Vec4 u_integrationResults[6u * WORKGROUP_SIZE];
 };
@@ -42,13 +42,13 @@ layout(set = 0, binding = 3, std430) buffer ssbo_
 #if STORE_LOCATION == 0
 layout(set = 0, binding = 4) uniform writeonly image3D u_irradianceVolume;
 
-layout(push_constant, std430) uniform pc_
+layout(push_constant, std140) uniform b_pc
 {
 	IVec3 u_volumeTexel;
 	I32 u_nextTexelOffsetInU;
 };
 #else
-layout(set = 0, binding = 4, std430) writeonly buffer ssbo1_
+layout(set = 0, binding = 4) writeonly buffer b_ssbo1
 {
 	ANKI_RP Vec4 u_irradianceDisceResults[6u];
 };

+ 1 - 1
AnKi/Shaders/LensFlareSprite.ankiprog

@@ -5,7 +5,7 @@
 
 #pragma anki start vert
 #include <AnKi/Shaders/Common.glsl>
-#include <AnKi/Shaders/Include/LensFlareTypes.h>
+#include <AnKi/Shaders/Include/MiscRendererTypes.h>
 
 // The block contains data for all flares
 layout(std140, set = 0, binding = 0) readonly buffer ssbo00

+ 1 - 1
AnKi/Shaders/LensFlareUpdateIndirectInfo.ankiprog

@@ -19,7 +19,7 @@ struct DrawArraysIndirectInfo
 	U32 baseInstance;
 };
 
-layout(set = 0, binding = 0, std430, row_major) readonly buffer ss0_
+layout(set = 0, binding = 0, std430, row_major) readonly buffer b_lf
 {
 	Mat4 u_mvp;
 	Vec4 u_flarePositions[];

+ 2 - 2
AnKi/Shaders/LightFunctions.glsl

@@ -11,7 +11,7 @@
 #include <AnKi/Shaders/CollisionFunctions.glsl>
 #include <AnKi/Shaders/PackFunctions.glsl>
 #include <AnKi/Shaders/Include/ClusteredShadingTypes.h>
-#include <AnKi/Shaders/Include/Evsm.h>
+#include <AnKi/Shaders/Include/MiscRendererTypes.h>
 
 // Do some EVSM magic with depth
 Vec2 evsmProcessDepth(F32 depth)
@@ -212,7 +212,7 @@ ANKI_RP F32 computeShadowFactorPointLight(PointLight light, Vec3 frag2Light, tex
 	Vec2 uv = convertCubeUvsu(dir, faceIdxu);
 
 	// Get the atlas offset
-	const Vec2 atlasOffset = light.m_shadowAtlasTileOffsets[faceIdxu];
+	const Vec2 atlasOffset = light.m_shadowAtlasTileOffsets[faceIdxu].xy;
 
 	// Compute UV
 	uv *= Vec2(light.m_shadowAtlasTileScale);

+ 1 - 1
AnKi/Shaders/LightShading.ankiprog

@@ -147,7 +147,7 @@ void main()
 	{
 		const I32 idx = findLSB2(cluster.m_spotLightsMask);
 		cluster.m_spotLightsMask &= ~(ExtendedClusterObjectMask(1) << ExtendedClusterObjectMask(idx));
-		const SpotLight light = u_spotLights2[idx];
+		const SpotLight light = u_spotLights[idx];
 
 		LIGHTING_COMMON_BRDF();
 

+ 3 - 2
AnKi/Shaders/LightShadingApplyIndirect.ankiprog

@@ -26,11 +26,12 @@ layout(set = 0, binding = 9) uniform ANKI_RP texture2D u_integrationLut;
 #define CLUSTERED_SHADING_UNIFORMS_BINDING 10u
 #include <AnKi/Shaders/ClusteredShadingCommon.glsl>
 
-layout(push_constant, std430) uniform b_pc
+layout(push_constant, std140) uniform b_pc
 {
 	F32 u_near;
 	F32 u_far;
-	Vec2 u_padding;
+	F32 u_padding0;
+	F32 u_padding1;
 };
 
 layout(location = 0) in Vec2 in_uv;

+ 2 - 2
AnKi/Shaders/LightShadingSkybox.ankiprog

@@ -27,7 +27,7 @@ layout(location = 0) in Vec2 in_uv;
 layout(location = 0) out ANKI_RP Vec3 out_color;
 
 #if METHOD == 0
-layout(push_constant, scalar) uniform b_pc
+layout(push_constant) uniform b_pc
 {
 	ANKI_RP Vec3 u_solidColor;
 	F32 u_padding;
@@ -36,7 +36,7 @@ layout(push_constant, scalar) uniform b_pc
 layout(binding = 0) uniform sampler u_trilinearAnySampler;
 layout(binding = 1) uniform ANKI_RP texture2D u_envMapTex;
 
-layout(push_constant, scalar, row_major) uniform b_pc
+layout(push_constant, row_major) uniform b_pc
 {
 	Mat4 u_invertedViewProjectionJitterMat;
 	Vec3 u_cameraPos;

+ 1 - 1
AnKi/Shaders/RtShadows.glsl

@@ -5,7 +5,7 @@
 
 #pragma once
 
-#include <AnKi/Shaders/Include/RtShadows.h>
+#include <AnKi/Shaders/Include/MiscRendererTypes.h>
 #include <AnKi/Shaders/PackFunctions.glsl>
 
 const F32 RT_SHADOWS_MAX_HISTORY_LENGTH = 16.0;

+ 1 - 1
AnKi/Shaders/RtShadowsDenoise.ankiprog

@@ -28,7 +28,7 @@ layout(set = 0, binding = 5) uniform texture2D u_momentsTex;
 layout(set = 0, binding = 6) uniform texture2D u_historyLengthTex;
 layout(set = 0, binding = 7) writeonly uniform uimage2D u_outImg;
 
-layout(std430, push_constant, row_major) uniform b_pc
+layout(push_constant, row_major, std140) uniform b_pc
 {
 	RtShadowsDenoiseUniforms u_unis;
 };

+ 1 - 1
AnKi/Shaders/RtShadowsRayGen.ankiprog

@@ -150,7 +150,7 @@ void main()
 	{
 		const I32 idx = findLSB2(cluster.m_spotLightsMask);
 		cluster.m_spotLightsMask &= ~(ExtendedClusterObjectMask(1) << ExtendedClusterObjectMask(idx));
-		const SpotLight light = u_spotLights2[idx];
+		const SpotLight light = u_spotLights[idx];
 
 		ANKI_BRANCH if(light.m_shadowLayer != MAX_U32)
 		{

+ 1 - 1
AnKi/Shaders/RtShadowsSvgfAtrous.ankiprog

@@ -27,7 +27,7 @@ layout(set = 0, binding = 5) uniform uimage2D u_shadowsImage;
 layout(set = 0, binding = 6) uniform image2D u_varianceImage;
 #endif
 
-layout(std430, push_constant, row_major) uniform b_pc
+layout(push_constant, row_major, std140) uniform b_pc
 {
 	Mat4 u_invProjMat;
 };

+ 1 - 1
AnKi/Shaders/RtShadowsSvgfVariance.ankiprog

@@ -24,7 +24,7 @@ layout(set = 0, binding = 5) uniform texture2D u_depthTex;
 layout(set = 0, binding = 6) uniform uimage2D u_shadowsImage;
 layout(set = 0, binding = 7) uniform image2D u_varianceImage;
 
-layout(std430, push_constant, row_major) uniform b_pc
+layout(push_constant, row_major, std140) uniform b_pc
 {
 	Mat4 u_invProjMat;
 };

+ 1 - 1
AnKi/Shaders/ShadowmapsResolve.glsl

@@ -122,7 +122,7 @@ void main()
 	{
 		const I32 idx = findLSB2(cluster.m_spotLightsMask);
 		cluster.m_spotLightsMask &= ~(ExtendedClusterObjectMask(1) << ExtendedClusterObjectMask(idx));
-		const SpotLight light = u_spotLights2[idx];
+		const SpotLight light = u_spotLights[idx];
 
 		ANKI_BRANCH if(light.m_shadowLayer != MAX_U32)
 		{

+ 1 - 1
AnKi/Shaders/TraditionalDeferredShadingSkybox.ankiprog

@@ -17,7 +17,7 @@
 layout(location = 0) in Vec2 in_uv;
 layout(location = 0) out ANKI_RP Vec3 out_color;
 
-layout(push_constant, scalar, row_major) uniform b_pc
+layout(push_constant, row_major, std140) uniform b_pc
 {
 	DeferredSkyboxUniforms u_unis;
 };

+ 3 - 12
AnKi/Shaders/VolumetricFogAccumulation.ankiprog

@@ -10,6 +10,7 @@ ANKI_SPECIALIZATION_CONSTANT_U32(Z_SPLIT_COUNT, 4u);
 #pragma anki start comp
 
 #include <AnKi/Shaders/Include/ClusteredShadingFunctions.h>
+#include <AnKi/Shaders/Include/MiscRendererTypes.h>
 #include <AnKi/Shaders/Common.glsl>
 
 const UVec2 WORKGROUP_SIZE = UVec2(8, 8);
@@ -19,19 +20,9 @@ layout(set = 0, binding = 0) uniform sampler u_linearAnyClampSampler;
 layout(set = 0, binding = 1) uniform ANKI_RP texture3D u_lightVolume;
 layout(set = 0, binding = 2) writeonly uniform ANKI_RP image3D u_fogVolume;
 
-struct Uniforms
+layout(push_constant, std140) uniform b_pc
 {
-	ANKI_RP Vec3 m_fogDiffuse;
-	ANKI_RP F32 m_fogScatteringCoeff;
-	ANKI_RP F32 m_fogAbsorptionCoeff;
-	ANKI_RP F32 m_near;
-	ANKI_RP F32 m_far;
-	F32 m_padding;
-};
-
-layout(push_constant, scalar) uniform b_pc
-{
-	Uniforms u_unis;
+	VolumetricFogUniforms u_unis;
 };
 
 void main()

+ 6 - 13
AnKi/Shaders/VolumetricLightingAccumulation.ankiprog

@@ -33,18 +33,11 @@ layout(set = 0, binding = 4) uniform texture3D u_prevVolume;
 #define CLUSTERED_SHADING_FOG_BINDING 11u
 #define CLUSTERED_SHADING_CLUSTERS_BINDING 12u
 #include <AnKi/Shaders/ClusteredShadingCommon.glsl>
+#include <AnKi/Shaders/Include/MiscRendererTypes.h>
 
-struct FogUniforms
+layout(push_constant, std140) uniform b_pc
 {
-	ANKI_RP F32 m_densityAtMinHeight;
-	ANKI_RP F32 m_densityAtMaxHeight;
-	F32 m_minHeight;
-	F32 m_oneOverMaxMinusMinHeight; // 1 / (maxHeight / minHeight)
-};
-
-layout(push_constant, scalar) uniform b_pc
-{
-	FogUniforms u_fogUnis;
+	VolumetricLightingUniforms u_fogUnis;
 };
 
 Vec3 g_globalInvocationID = Vec3(gl_GlobalInvocationID);
@@ -157,7 +150,7 @@ Vec4 accumulateLightsAndFog(Cluster cluster, Vec3 worldPos, F32 negativeZViewSpa
 	{
 		const I32 idx = findLSB2(cluster.m_spotLightsMask);
 		cluster.m_spotLightsMask &= ~(ExtendedClusterObjectMask(1) << ExtendedClusterObjectMask(idx));
-		const SpotLight light = u_spotLights2[idx];
+		const SpotLight light = u_spotLights[idx];
 
 		const Vec3 frag2Light = light.m_position - worldPos;
 		F32 factor = computeAttenuationFactor(light.m_squareRadiusOverOne, frag2Light);
@@ -275,10 +268,10 @@ void main()
 	// Get the cluster
 	const UVec2 tileIdxXY = UVec2(uvw.xy * Vec2(TILE_COUNT));
 	const U32 tileIdx = tileIdxXY.y * TILE_COUNT.x + tileIdxXY.x;
-	Cluster cluster = u_clusters2[tileIdx];
+	Cluster cluster = u_clusters[tileIdx];
 
 	const U32 zSplitIdx = U32(uvw.z * F32(Z_SPLIT_COUNT));
-	const Cluster split = u_clusters2[TILE_COUNT.x * TILE_COUNT.y + zSplitIdx];
+	const Cluster split = u_clusters[TILE_COUNT.x * TILE_COUNT.y + zSplitIdx];
 
 	cluster.m_pointLightsMask |= split.m_pointLightsMask;
 	cluster.m_spotLightsMask |= split.m_spotLightsMask;

+ 1 - 1
Samples/Common/SampleApp.cpp

@@ -64,7 +64,7 @@ Error SampleApp::userMainLoop(Bool& quit, Second elapsedTime)
 	if(in.getKey(KeyCode::Y) == 1)
 	{
 		renderer.setCurrentDebugRenderTarget(
-			(renderer.getCurrentDebugRenderTarget() == "GBuffer_normals") ? "" : "GBuffer_normals");
+			(renderer.getCurrentDebugRenderTarget() == "GBufferNormals") ? "" : "GBufferNormals");
 	}
 
 	if(in.getKey(KeyCode::U) == 1)

+ 1 - 1
Samples/PhysicsPlayground/Main.cpp

@@ -227,7 +227,7 @@ Error MyApp::userMainLoop(Bool& quit, Second elapsedTime)
 	if(getInput().getKey(KeyCode::U) == 1)
 	{
 		renderer.setCurrentDebugRenderTarget(
-			(renderer.getCurrentDebugRenderTarget() == "IndirectDiffuse") ? "" : "IndirectDiffuse");
+			(renderer.getCurrentDebugRenderTarget() == "GBufferNormals") ? "" : "GBufferNormals");
 	}
 
 	if(getInput().getKey(KeyCode::F1) == 1)