Add automatic fallback to CPU ray tracing if no vulkan device supports the ray tracing extension

This commit is contained in:
Magnus Norddahl 2021-11-12 16:17:44 +01:00
parent 9b6cd720dd
commit 04b01426e6

View file

@ -694,16 +694,30 @@ void FProcessor::BuildLightmaps()
Level.SetupLights();
LightmapMesh = std::make_unique<LevelMesh>(Level, Level.Samples, LMDims);
if (CPURaytrace)
std::unique_ptr<GPURaytracer> gpuraytracer;
if (!CPURaytrace)
{
try
{
gpuraytracer = std::make_unique<GPURaytracer>();
}
catch (std::exception msg)
{
printf("%s\n", msg.what());
printf("Falling back to CPU ray tracing\n");
}
}
if (gpuraytracer)
{
gpuraytracer->Raytrace(LightmapMesh.get());
}
else
{
CPURaytracer raytracer;
raytracer.Raytrace(LightmapMesh.get());
}
else
{
GPURaytracer raytracer;
raytracer.Raytrace(LightmapMesh.get());
}
LightmapMesh->CreateTextures();
}