Browse Source

Minor opts

Panagiotis Christopoulos Charitos 2 years ago
parent
commit
a820fe7a0f
2 changed files with 6 additions and 14 deletions
  1. 2 5
      AnKi/Renderer/Utils/HzbGenerator.cpp
  2. 4 9
      AnKi/Shaders/HzbMaxDepthProject.ankiprog

+ 2 - 5
AnKi/Renderer/Utils/HzbGenerator.cpp

@@ -248,8 +248,8 @@ void HzbGenerator::populateRenderGraphDirectionalLight(RenderTargetHandle srcDep
 		pass.newTextureDependency(maxDepthRt, TextureUsageBit::kSampledFragment);
 		pass.newTextureDependency(maxDepthRt, TextureUsageBit::kSampledFragment);
 		pass.newTextureDependency(depthRts[i], TextureUsageBit::kFramebufferWrite, DepthStencilAspectBit::kDepth);
 		pass.newTextureDependency(depthRts[i], TextureUsageBit::kFramebufferWrite, DepthStencilAspectBit::kDepth);
 
 
-		pass.setWork([this, maxDepthRt, invViewProjMat, lightViewProjMat = dstViewProjectionMats[i], viewport = dstHzbSizes[i] * 2, maxDepthRtSize,
-					  srcDepthRtSize](RenderPassWorkContext& rgraphCtx) {
+		pass.setWork([this, maxDepthRt, invViewProjMat, lightViewProjMat = dstViewProjectionMats[i], viewport = dstHzbSizes[i] * 2,
+					  maxDepthRtSize](RenderPassWorkContext& rgraphCtx) {
 			CommandBuffer& cmdb = *rgraphCtx.m_commandBuffer;
 			CommandBuffer& cmdb = *rgraphCtx.m_commandBuffer;
 
 
 			cmdb.setDepthCompareOperation(CompareOperation::kGreater);
 			cmdb.setDepthCompareOperation(CompareOperation::kGreater);
@@ -263,12 +263,9 @@ void HzbGenerator::populateRenderGraphDirectionalLight(RenderTargetHandle srcDep
 			struct Uniforms
 			struct Uniforms
 			{
 			{
 				Mat4 m_reprojectionMat;
 				Mat4 m_reprojectionMat;
-				UVec2 m_mainCameraDepthBufferSize;
-				UVec2 m_padding;
 			} unis;
 			} unis;
 
 
 			unis.m_reprojectionMat = lightViewProjMat * invViewProjMat;
 			unis.m_reprojectionMat = lightViewProjMat * invViewProjMat;
-			unis.m_mainCameraDepthBufferSize = srcDepthRtSize;
 
 
 			cmdb.setPushConstants(&unis, sizeof(unis));
 			cmdb.setPushConstants(&unis, sizeof(unis));
 
 

+ 4 - 9
AnKi/Shaders/HzbMaxDepthProject.ankiprog

@@ -9,15 +9,11 @@
 
 
 #pragma anki start vert
 #pragma anki start vert
 
 
-constexpr U32 kTileSize = 64;
-
 [[vk::binding(0)]] Texture2D<Vec4> g_maxDepthRt;
 [[vk::binding(0)]] Texture2D<Vec4> g_maxDepthRt;
 
 
 struct Uniforms
 struct Uniforms
 {
 {
 	Mat4 m_reprojectionMat;
 	Mat4 m_reprojectionMat;
-	UVec2 m_mainCameraDepthBufferSize;
-	UVec2 m_padding;
 };
 };
 
 
 [[vk::push_constant]] ConstantBuffer<Uniforms> g_unis;
 [[vk::push_constant]] ConstantBuffer<Uniforms> g_unis;
@@ -37,17 +33,16 @@ Vec4 main(U32 svVertexId : SV_VERTEXID, U32 svInstanceId : SV_INSTANCEID) : SV_P
 	ndc.z = (svVertexId <= 1) ? 0.0 : maxDepth;
 	ndc.z = (svVertexId <= 1) ? 0.0 : maxDepth;
 
 
 	// X
 	// X
-	ndc.x = F32(tileX * kTileSize);
+	ndc.x = F32(tileX);
 	if(svVertexId == 1 || svVertexId == 2)
 	if(svVertexId == 1 || svVertexId == 2)
 	{
 	{
 		// Right side, move the point
 		// Right side, move the point
-		ndc.x += kTileSize;
+		ndc.x += 1.0f;
 	}
 	}
-	ndc.x /= F32(g_unis.m_mainCameraDepthBufferSize.x);
+	ndc.x /= F32(maxDepthRtSize.x);
 
 
 	// Y
 	// Y
-	ndc.y = F32(tileY * kTileSize);
-	ndc.y /= F32(g_unis.m_mainCameraDepthBufferSize.y);
+	ndc.y = F32(tileY) / F32(maxDepthRtSize.y);
 
 
 	ndc.xy = uvToNdc(saturate(ndc.xy));
 	ndc.xy = uvToNdc(saturate(ndc.xy));