Change surfaceIndices to surfaces

This commit is contained in:
RaveYard 2023-09-10 20:16:35 +02:00 committed by Christoph Oelckers
parent 8e3b29de33
commit f9580f081e
7 changed files with 25 additions and 32 deletions

View file

@ -263,7 +263,7 @@ protected:
EPassType mPassType = NORMAL_PASS;
std::atomic<unsigned> mActiveLightmapSurfaceBufferIndex;
TArray<int> mActiveLightmapSurfacesBuffer;
TArray<LevelMeshSurface*> mActiveLightmapSurfacesBuffer;
public:
uint64_t firstFrame = 0;
@ -746,7 +746,7 @@ public:
int index = mActiveLightmapSurfaceBufferIndex.fetch_add(1);
if (index < mActiveLightmapSurfacesBuffer.Size())
{
mActiveLightmapSurfacesBuffer[index] = surfaceIndex;
mActiveLightmapSurfacesBuffer[index] = surface;
surface->needsUpdate = false;
}
}

View file

@ -156,7 +156,7 @@ public:
virtual bool IsPoly() { return false; }
virtual bool CompileNextShader() { return true; }
virtual void SetLevelMesh(LevelMesh *mesh) { }
virtual void UpdateLightmaps(const TArray<int>& surfaceIndices) {}
virtual void UpdateLightmaps(const TArray<LevelMeshSurface*>& surfaces) {}
bool allowSSBO() const
{
#ifndef HW_BLOCK_SSBO

View file

@ -50,7 +50,7 @@ VkLightmap::~VkLightmap()
#include <set>
#endif
void VkLightmap::Raytrace(LevelMesh* level, const TArray<int>& surfaceIndices)
void VkLightmap::Raytrace(LevelMesh* level, const TArray<LevelMeshSurface*>& surfaces)
{
bool newLevel = (mesh != level);
mesh = level;
@ -69,9 +69,9 @@ void VkLightmap::Raytrace(LevelMesh* level, const TArray<int>& surfaceIndices)
lightmapRaytrace.Clock();
lightmapRaytraceLast.ResetAndClock();
CreateAtlasImages(surfaceIndices);
CreateAtlasImages(surfaces);
#if 0
#if 0 // SmoothGroups
TArray<int> allSurfaces;
std::set<int> s;
@ -92,12 +92,7 @@ void VkLightmap::Raytrace(LevelMesh* level, const TArray<int>& surfaceIndices)
}
}
#else
for (auto& surface : surfaceIndices)
{
mesh->GetSurface(surface)->needsUpdate = false;
}
const auto& allSurfaces = surfaceIndices;
const auto& allSurfaces = surfaces;
#endif
UploadUniforms();
@ -126,7 +121,7 @@ void VkLightmap::Raytrace(LevelMesh* level, const TArray<int>& surfaceIndices)
lightmapRaytraceLast.Unclock();
}
void VkLightmap::RenderAtlasImage(size_t pageIndex, const TArray<int>& surfaceIndices)
void VkLightmap::RenderAtlasImage(size_t pageIndex, const TArray<LevelMeshSurface*>& surfaces)
{
LightmapImage& img = atlasImages[pageIndex];
@ -148,9 +143,9 @@ void VkLightmap::RenderAtlasImage(size_t pageIndex, const TArray<int>& surfaceIn
cmdbuffer->bindDescriptorSet(VK_PIPELINE_BIND_POINT_GRAPHICS, raytrace.pipelineLayout.get(), 1, raytrace.descriptorSet1.get());
}
for (int i = 0, count = surfaceIndices.Size(); i < count; i++)
for (int i = 0, count = surfaces.Size(); i < count; i++)
{
LevelMeshSurface* targetSurface = mesh->GetSurface(surfaceIndices[i]);
LevelMeshSurface* targetSurface = surfaces[i];
if (targetSurface->lightmapperAtlasPage != pageIndex)
continue;
@ -259,7 +254,7 @@ void VkLightmap::RenderAtlasImage(size_t pageIndex, const TArray<int>& surfaceIn
fb->GetCommands()->GetTransferCommands()->endRenderPass();
}
void VkLightmap::CreateAtlasImages(const TArray<int>& surfaceIndices)
void VkLightmap::CreateAtlasImages(const TArray<LevelMeshSurface*>& surfaces)
{
for (auto& page : atlasImages)
{
@ -272,9 +267,9 @@ void VkLightmap::CreateAtlasImages(const TArray<int>& surfaceIndices)
size_t pageIndex = atlasImages.size();
for (int i = 0, count = surfaceIndices.Size(); i < count; i++)
for (int i = 0, count = surfaces.Size(); i < count; i++)
{
LevelMeshSurface* surface = mesh->GetSurface(surfaceIndices[i]);
LevelMeshSurface* surface = surfaces[i];
//for (int i = 0, count = mesh->GetSurfaceCount(); i < count; i++)
//{
//LevelMeshSurface* surface = mesh->GetSurface(i);
@ -459,14 +454,14 @@ void VkLightmap::BlurAtlasImage(size_t pageIndex)
}
}
void VkLightmap::CopyAtlasImageResult(size_t pageIndex, const TArray<int>& surfaceIndices)
void VkLightmap::CopyAtlasImageResult(size_t pageIndex, const TArray<LevelMeshSurface*>& surfaces)
{
LightmapImage& img = atlasImages[pageIndex];
std::vector<VkImageCopy> regions;
for (int i = 0, count = surfaceIndices.Size(); i < count; i++)
for (int i = 0, count = surfaces.Size(); i < count; i++)
{
LevelMeshSurface* surface = mesh->GetSurface(surfaceIndices[i]);
LevelMeshSurface* surface = surfaces[i];
if (surface->lightmapperAtlasPage != pageIndex)
continue;

View file

@ -90,17 +90,17 @@ public:
VkLightmap(VulkanRenderDevice* fb);
~VkLightmap();
void Raytrace(LevelMesh* level, const TArray<int>& surfaceIndices);
void Raytrace(LevelMesh* level, const TArray<LevelMeshSurface*>& surfaces);
private:
void UpdateAccelStructDescriptors();
void UploadUniforms();
void CreateAtlasImages(const TArray<int>& surfaceIndices);
void RenderAtlasImage(size_t pageIndex, const TArray<int>& surfaceIndices);
void CreateAtlasImages(const TArray<LevelMeshSurface*>& surfaces);
void RenderAtlasImage(size_t pageIndex, const TArray<LevelMeshSurface*>& surfaces);
void ResolveAtlasImage(size_t pageIndex);
void BlurAtlasImage(size_t pageIndex);
void CopyAtlasImageResult(size_t pageIndex, const TArray<int>& surfaceIndices);
void CopyAtlasImageResult(size_t pageIndex, const TArray<LevelMeshSurface*>& surfaces);
LightmapImage CreateImage(int width, int height);

View file

@ -559,15 +559,15 @@ void VulkanRenderDevice::SetLevelMesh(LevelMesh* mesh)
}
}
void VulkanRenderDevice::UpdateLightmaps(const TArray<int>& surfaceIndices)
void VulkanRenderDevice::UpdateLightmaps(const TArray<LevelMeshSurface*>& surfaces)
{
if (surfaceIndices.Size() > 0)
if (surfaces.Size() > 0)
{
auto levelMesh = lastMesh; // There's nothing more permanent than a temporary solution
if (levelMesh)
{
GetLightmap()->Raytrace(levelMesh, surfaceIndices);
GetLightmap()->Raytrace(levelMesh, surfaces);
}
}
}

View file

@ -63,7 +63,7 @@ public:
void AmbientOccludeScene(float m5) override;
void SetSceneRenderTarget(bool useSSAO) override;
void SetLevelMesh(LevelMesh* mesh) override;
void UpdateLightmaps(const TArray<int>& surfaceIndices) override;
void UpdateLightmaps(const TArray<LevelMeshSurface*>& surfaces) override;
void SetShadowMaps(const TArray<float>& lights, hwrenderer::LevelAABBTree* tree, bool newTree) override;
void SetSaveBuffers(bool yes) override;
void ImageTransitionScene(bool unknown) override;

View file

@ -867,17 +867,15 @@ void UpdateLightmaps(DFrameBuffer* screen, FRenderState& RenderState)
if (size < lm_background_updates)
{
int index = 0;
for (auto& e : level.levelMesh->Surfaces)
{
if (e.needsUpdate)
{
list.Push(index);
list.Push(&e);
if (list.Size() >= lm_background_updates)
break;
}
++index;
}
}