Hook up the raytracing

This commit is contained in:
Magnus Norddahl 2023-10-16 17:03:40 +02:00
parent 7c1acb5075
commit 156ef319af
2 changed files with 25 additions and 3 deletions

View file

@ -49,8 +49,28 @@ void GPURaytracer::Raytrace(DoomLevelMesh* mesh)
raytrace->BeginFrame(); raytrace->BeginFrame();
lightmap->BeginFrame(); lightmap->BeginFrame();
printf("."); // Keep baking until all surfaces have been processed
//lightmap->Raytrace(surfaces); while (true)
{
printf(".");
TArray<LevelMeshSurface*> surfaces;
for (int i = 0, count = submesh->GetSurfaceCount(); i < count; i++)
{
LevelMeshSurface* surface = submesh->GetSurface(i);
if (surface->needsUpdate)
{
surfaces.Push(surface);
}
}
if (surfaces.Size() == 0)
break;
lightmap->Raytrace(surfaces);
mDevice->GetCommands()->SubmitAndWait();
}
printf("."); printf(".");

View file

@ -66,6 +66,8 @@ void VkCommandBufferManager::SubmitAndWait()
.AddCommandBuffer(mTransferCommands.get()) .AddCommandBuffer(mTransferCommands.get())
.Execute(fb->GetDevice(), fb->GetDevice()->GraphicsQueue); .Execute(fb->GetDevice(), fb->GetDevice()->GraphicsQueue);
TransferDeleteList->Add(std::move(mTransferCommands));
vkDeviceWaitIdle(fb->GetDevice()->device); vkDeviceWaitIdle(fb->GetDevice()->device);
} }
@ -113,7 +115,7 @@ void VkTextureManager::CreateLightmap(int newLMTextureSize, int newLMTextureCoun
PipelineBarrier() PipelineBarrier()
.AddImage(Lightmap.Image.get(), VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, 0, VK_ACCESS_SHADER_READ_BIT, VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, LMTextureCount) .AddImage(Lightmap.Image.get(), VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, 0, VK_ACCESS_SHADER_READ_BIT, VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, LMTextureCount)
.Execute(fb->GetCommands()->GetTransferCommands(), 0, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT); .Execute(fb->GetCommands()->GetTransferCommands(), VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
} }
void VkTextureManager::DownloadLightmap(int arrayIndex, uint16_t* buffer) void VkTextureManager::DownloadLightmap(int arrayIndex, uint16_t* buffer)