Panagiotis Christopoulos Charitos 11 months ago
parent
commit
0c2b0a5d16

+ 1 - 1
AnKi/Gr/D3D/D3DGrManager.cpp

@@ -445,7 +445,7 @@ Error GrManagerImpl::initInternal(const GrManagerInitInfo& init)
 		m_capabilities.m_maxDrawIndirectCount = kMaxU32;
 		m_capabilities.m_maxDrawIndirectCount = kMaxU32;
 		m_capabilities.m_discreteGpu = !architecture.UMA;
 		m_capabilities.m_discreteGpu = !architecture.UMA;
 		m_capabilities.m_majorApiVersion = 12;
 		m_capabilities.m_majorApiVersion = 12;
-		m_capabilities.m_rayTracingEnabled = g_rayTracingCVar;
+		m_capabilities.m_rayTracingEnabled = g_rayTracingCVar && false; // TODO: Support RT
 		m_capabilities.m_vrs = g_vrsCVar;
 		m_capabilities.m_vrs = g_vrsCVar;
 		m_capabilities.m_unalignedBbpTextureFormats = false;
 		m_capabilities.m_unalignedBbpTextureFormats = false;
 		m_capabilities.m_dlss = false;
 		m_capabilities.m_dlss = false;

+ 13 - 2
AnKi/Renderer/Reflections.cpp

@@ -372,7 +372,11 @@ void Reflections::populateRenderGraph(RenderingContext& ctx)
 				rgraphCtx.bindSrv(4, 2, getRenderer().getGeneratedSky().getEnvironmentMapRt());
 				rgraphCtx.bindSrv(4, 2, getRenderer().getGeneratedSky().getEnvironmentMapRt());
 			}
 			}
 
 
-			cmdb.bindSrv(5, 2, GpuSceneArrays::GlobalIlluminationProbe::getSingleton().getBufferView());
+			cmdb.bindSrv(
+				5, 2,
+				(GpuSceneArrays::GlobalIlluminationProbe::getSingleton().getElementCount())
+					? GpuSceneArrays::GlobalIlluminationProbe::getSingleton().getBufferView()
+					: BufferView(&getRenderer().getDummyBuffer(), 0, GpuSceneArrays::GlobalIlluminationProbe::getSingleton().getElementSize()));
 			cmdb.bindSrv(6, 2, pixelsFailedSsrBuff);
 			cmdb.bindSrv(6, 2, pixelsFailedSsrBuff);
 			rgraphCtx.bindSrv(7, 2, getRenderer().getShadowMapping().getShadowmapRt());
 			rgraphCtx.bindSrv(7, 2, getRenderer().getShadowMapping().getShadowmapRt());
 
 
@@ -382,7 +386,14 @@ void Reflections::populateRenderGraph(RenderingContext& ctx)
 			cmdb.bindSampler(0, 2, getRenderer().getSamplers().m_trilinearClamp.get());
 			cmdb.bindSampler(0, 2, getRenderer().getSamplers().m_trilinearClamp.get());
 			cmdb.bindSampler(1, 2, getRenderer().getSamplers().m_trilinearClampShadow.get());
 			cmdb.bindSampler(1, 2, getRenderer().getSamplers().m_trilinearClampShadow.get());
 
 
-			const Vec4 consts(g_rtReflectionsMaxRayDistanceCVar);
+			struct Consts
+			{
+				F32 m_maxRayT;
+				U32 m_giProbeCount;
+				F32 m_padding1;
+				F32 m_padding2;
+			} consts = {g_rtReflectionsMaxRayDistanceCVar, GpuSceneArrays::GlobalIlluminationProbe::getSingleton().getElementCount(), 0, 0};
+
 			cmdb.setFastConstants(&consts, sizeof(consts));
 			cmdb.setFastConstants(&consts, sizeof(consts));
 
 
 			cmdb.traceRaysIndirect(sbtBuffer, m_sbtRecordSize, GpuSceneArrays::RenderableBoundingVolumeRt::getSingleton().getElementCount(), 1,
 			cmdb.traceRaysIndirect(sbtBuffer, m_sbtRecordSize, GpuSceneArrays::RenderableBoundingVolumeRt::getSingleton().getElementCount(), 1,

+ 1 - 1
AnKi/Shaders/ClusteredShadingFunctions.hlsl

@@ -215,7 +215,7 @@ vector<T, 3> sampleGiProbes(Cluster cluster, StructuredBuffer<GlobalIllumination
 
 
 	if(probeCount == 0)
 	if(probeCount == 0)
 	{
 	{
-		probeColor = -1.0;
+		probeColor = 0.0;
 	}
 	}
 	else if(WaveActiveAllTrue(probeCount == 1))
 	else if(WaveActiveAllTrue(probeCount == 1))
 	{
 	{

+ 4 - 4
AnKi/Shaders/Reflections.ankiprog

@@ -412,9 +412,9 @@ void bestCandidateToHallucinate(IVec2 svGroupThreadId, IVec2 offset, F32 depth,
 
 
 		Vec3 worldHitPos = worldPos + reflDir * 1.0;
 		Vec3 worldHitPos = worldPos + reflDir * 1.0;
 		worldHitPos -= g_globalRendererConstants.m_cameraPosition;
 		worldHitPos -= g_globalRendererConstants.m_cameraPosition;
-
-		g_colorAndPdfTex[realCoord] = Vec4(col, kPdfForVeryRough);
 		g_hitPosAndDepthTex[realCoord] = Vec4(worldHitPos, 1.0 - depth);
 		g_hitPosAndDepthTex[realCoord] = Vec4(worldHitPos, 1.0 - depth);
+		g_colorAndPdfTex[realCoord] = Vec4(col, kPdfForVeryRough);
+
 		return;
 		return;
 	}
 	}
 
 
@@ -650,7 +650,7 @@ RWTexture2D<Vec4> g_hitPosAndDepthTex : register(u1);
 struct Consts
 struct Consts
 {
 {
 	F32 m_maxRayT;
 	F32 m_maxRayT;
-	F32 m_padding0;
+	U32 m_giProbeCount;
 	F32 m_padding1;
 	F32 m_padding1;
 	F32 m_padding2;
 	F32 m_padding2;
 };
 };
@@ -756,7 +756,7 @@ ANKI_FAST_CONSTANTS(Consts, g_consts)
 	// Do simple light shading
 	// Do simple light shading
 	Vec3 outColor = payload.m_emission;
 	Vec3 outColor = payload.m_emission;
 	Vec3 indirectDiffuse = 0.0;
 	Vec3 indirectDiffuse = 0.0;
-	if(!hasHitSky)
+	if(!hasHitSky && g_consts.m_giProbeCount > 0)
 	{
 	{
 		indirectDiffuse = getDiffuseIndirect(g_giProbes, hitPos, payload.m_worldNormal, g_linearClampAnySampler);
 		indirectDiffuse = getDiffuseIndirect(g_giProbes, hitPos, payload.m_worldNormal, g_linearClampAnySampler);
 	}
 	}