Fix upload bug and skip upload when RT cores are available

This commit is contained in:
Magnus Norddahl 2024-10-21 20:50:25 +02:00
commit c866937262
3 changed files with 8 additions and 5 deletions

View file

@ -22,6 +22,7 @@
#include "hw_collision.h"
#include "hw_levelmesh.h"
#include "v_video.h"
#include <algorithm>
#include <functional>
#include <cfloat>
@ -128,7 +129,8 @@ static FVector3 SwapYZ(const FVector3& v)
void CPUAccelStruct::Upload()
{
// To do: don't bother with this if rayquery is available as it won't be used
if (screen->IsRayQueryEnabled())
return;
unsigned int count = (unsigned int)TLAS.Nodes.size();
for (auto& blas : DynamicBLAS)
@ -165,9 +167,9 @@ void CPUAccelStruct::Upload()
CollisionNode& info = destnodes[offset];
info.center = SwapYZ(node.aabb.Center);
info.extents = SwapYZ(node.aabb.Extents);
info.left = blasStart + node.left;
info.right = blasStart + node.right;
info.element_index = indexStart + node.element_index;
info.left = node.left != -1 ? blasStart + node.left : -1;
info.right = node.right != -1 ? blasStart + node.right : -1;
info.element_index = node.element_index != -1 ? indexStart + node.element_index : -1;
offset++;
}
instance++;

View file

@ -136,6 +136,7 @@ public:
virtual void InitializeState() = 0; // For stuff that needs 'screen' set.
virtual bool IsVulkan() { return false; }
virtual bool IsPoly() { return false; }
virtual bool IsRayQueryEnabled() const { return false; }
virtual bool CompileNextShader() { return true; }
virtual void SetLevelMesh(LevelMesh *mesh) { }
virtual void UpdateLightmaps(const TArray<LightmapTile*>& tiles) {}

View file

@ -47,7 +47,7 @@ public:
VkRenderBuffers *GetBuffers() { return mActiveRenderBuffers; }
FRenderState* RenderState() override;
bool IsRayQueryEnabled() const { return mUseRayQuery; }
bool IsRayQueryEnabled() const override { return mUseRayQuery; }
bool IsVulkan() override { return true; }
void Update() override;