Move the visible surface list to HWDrawInfo
This commit is contained in:
parent
651b2ef9e3
commit
d9b066ad37
9 changed files with 58 additions and 75 deletions
|
|
@ -53,8 +53,8 @@ struct LevelMeshSurface
|
|||
int texWidth = 0;
|
||||
int texHeight = 0;
|
||||
|
||||
// True if the surface needs to be rendered into the lightmap texture before it can be used
|
||||
bool needsUpdate = true;
|
||||
bool alreadyInVisibleList = false;
|
||||
|
||||
//
|
||||
// Required for internal lightmapper:
|
||||
|
|
|
|||
|
|
@ -262,17 +262,12 @@ protected:
|
|||
|
||||
EPassType mPassType = NORMAL_PASS;
|
||||
|
||||
std::atomic<unsigned> mActiveLightmapSurfaceBufferIndex;
|
||||
TArray<LevelMeshSurface*> mActiveLightmapSurfacesBuffer;
|
||||
public:
|
||||
|
||||
uint64_t firstFrame = 0;
|
||||
|
||||
void Reset()
|
||||
{
|
||||
mActiveLightmapSurfaceBufferIndex = { 0 };
|
||||
mActiveLightmapSurfacesBuffer.Resize(lm_max_updates);
|
||||
|
||||
mTextureEnabled = true;
|
||||
mBrightmapEnabled = mGradientEnabled = mFogEnabled = mGlowEnabled = false;
|
||||
mFogColor = 0xffffffff;
|
||||
|
|
@ -739,35 +734,6 @@ public:
|
|||
return SetViewpoint(matrices);
|
||||
}
|
||||
|
||||
inline void PushVisibleSurface(LevelMeshSurface* surface)
|
||||
{
|
||||
if (surface->needsUpdate && !surface->portalIndex && !surface->bSky) // TODO atomic?
|
||||
{
|
||||
auto index = mActiveLightmapSurfaceBufferIndex.fetch_add(1);
|
||||
if (index < mActiveLightmapSurfacesBuffer.Size())
|
||||
{
|
||||
mActiveLightmapSurfacesBuffer[index] = surface;
|
||||
surface->needsUpdate = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline auto& GetVisibleSurfaceList()
|
||||
{
|
||||
return mActiveLightmapSurfacesBuffer;
|
||||
}
|
||||
|
||||
inline unsigned GetVisibleSurfaceListCount() const
|
||||
{
|
||||
return mActiveLightmapSurfaceBufferIndex;
|
||||
}
|
||||
|
||||
inline void ClearVisibleSurfaceList()
|
||||
{
|
||||
mActiveLightmapSurfacesBuffer.Resize(lm_max_updates);
|
||||
mActiveLightmapSurfaceBufferIndex = 0;
|
||||
}
|
||||
|
||||
// API-dependent render interface
|
||||
|
||||
// Worker threads
|
||||
|
|
|
|||
|
|
@ -99,8 +99,8 @@ void VkLightmap::SelectSurfaces(const TArray<LevelMeshSurface*>& surfaces)
|
|||
{
|
||||
LevelMeshSurface* surface = surfaces[i];
|
||||
|
||||
// All surfaces needs to be updated until we rendered them.
|
||||
surface->needsUpdate = true;
|
||||
if (!surface->needsUpdate)
|
||||
continue;
|
||||
|
||||
// Only grab surfaces until our bake texture is full
|
||||
auto result = packer.insert(surface->texWidth + 2, surface->texHeight + 2);
|
||||
|
|
@ -114,6 +114,8 @@ void VkLightmap::SelectSurfaces(const TArray<LevelMeshSurface*>& surfaces)
|
|||
|
||||
bakeImage.maxX = std::max<uint16_t>(bakeImage.maxX, uint16_t(selected.X + surface->texWidth + spacing));
|
||||
bakeImage.maxY = std::max<uint16_t>(bakeImage.maxY, uint16_t(selected.Y + surface->texHeight + spacing));
|
||||
|
||||
surface->needsUpdate = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -226,7 +228,14 @@ void VkLightmap::RenderBakeImage()
|
|||
}
|
||||
|
||||
if (buffersFull)
|
||||
{
|
||||
while (i < count)
|
||||
{
|
||||
selectedSurfaces[i].Surface->needsUpdate = true;
|
||||
i++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
selectedSurface.Rendered = true;
|
||||
}
|
||||
|
|
@ -422,9 +431,6 @@ void VkLightmap::CopyBakeImageResult()
|
|||
regions.push_back(region);
|
||||
seenPages.insert(surface->atlasPageIndex);
|
||||
|
||||
// We rendered this surface. Does not need an update anymore.
|
||||
surface->needsUpdate = false;
|
||||
|
||||
pixels += surface->Area();
|
||||
lastSurfaceCount++;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue