- Fix VkRaytrace::Raytrace not working properly if called multiple times per frame.

- Only call VkRaytrace::Raytrace once per scene
This commit is contained in:
Magnus Norddahl 2023-09-16 05:12:31 +02:00
commit 2178de0c6c
4 changed files with 10 additions and 7 deletions

View file

@ -61,6 +61,12 @@ void VkLightmap::SetLevelMesh(LevelMesh* level)
lastSurfaceCount = 0;
}
void VkLightmap::BeginFrame()
{
lights.Pos = 0;
vertices.Pos = 0;
}
void VkLightmap::Raytrace(const TArray<LevelMeshSurface*>& surfaces)
{
if (surfaces.Size())
@ -137,9 +143,6 @@ void VkLightmap::RenderBakeImage()
cmdbuffer->bindDescriptorSet(VK_PIPELINE_BIND_POINT_GRAPHICS, raytrace.pipelineLayout.get(), 0, raytrace.descriptorSet0.get());
cmdbuffer->bindDescriptorSet(VK_PIPELINE_BIND_POINT_GRAPHICS, raytrace.pipelineLayout.get(), 1, raytrace.descriptorSet1.get());
lights.Pos = 0;
vertices.Pos = 0;
for (int i = 0, count = selectedSurfaces.Size(); i < count; i++)
{
auto& selectedSurface = selectedSurfaces[i];
@ -406,7 +409,6 @@ void VkLightmap::BlurBakeImage()
void VkLightmap::CopyBakeImageResult()
{
uint32_t pixels = 0;
uint32_t surfacesRenderer = 0;
std::set<int> seenPages;
std::vector<VkImageCopy> regions;
@ -433,11 +435,10 @@ void VkLightmap::CopyBakeImageResult()
seenPages.insert(surface->atlasPageIndex);
pixels += surface->Area();
surfacesRenderer++;
lastSurfaceCount++;
}
}
lastSurfaceCount = surfacesRenderer;
lastPixelCount = pixels;
totalPixelCount += pixels;