You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed that in void MeshSorter::RenderMeshes, the function context.SetConstantBuffer is used instead of SetDynamicConstantBufferView. From the code, I see that it directly passes a GPU handle, which is obtained via ModelInstance::Update(), where gfxContext.GetCommandList()->CopyBufferRegion(...) copies data from a CPU UploadBuffer (m_MeshConstantsCPU) to a GPU buffer (m_MeshConstantsGPU).
My concern is that m_MeshConstantsCPU is an UploadBuffer, but it does not use LinearAllocator for resource allocation. How can we ensure that m_MeshConstantsCPU is not being written to while CopyBufferRegion is executing? There doesn’t seem to be any explicit synchronization mechanism like a fence to manage this.
I understand that EngineProfiling::Update(); includes a WaitForFence, which ensures GPU completion every frame, but this is primarily for performance profiling. If we remove EngineProfiling::Update(), how do we guarantee that m_MeshConstantsCPU is not modified while CopyBufferRegion is in progress?
Would it be more appropriate to allocate the UploadBuffer using LinearAllocator to ensure proper synchronization and avoid potential data corruption?
Looking forward to your thoughts!
The text was updated successfully, but these errors were encountered:
Hi,
I noticed that in void MeshSorter::RenderMeshes, the function context.SetConstantBuffer is used instead of SetDynamicConstantBufferView. From the code, I see that it directly passes a GPU handle, which is obtained via ModelInstance::Update(), where gfxContext.GetCommandList()->CopyBufferRegion(...) copies data from a CPU UploadBuffer (m_MeshConstantsCPU) to a GPU buffer (m_MeshConstantsGPU).
My concern is that m_MeshConstantsCPU is an UploadBuffer, but it does not use LinearAllocator for resource allocation. How can we ensure that m_MeshConstantsCPU is not being written to while CopyBufferRegion is executing? There doesn’t seem to be any explicit synchronization mechanism like a fence to manage this.
I understand that EngineProfiling::Update(); includes a WaitForFence, which ensures GPU completion every frame, but this is primarily for performance profiling. If we remove EngineProfiling::Update(), how do we guarantee that m_MeshConstantsCPU is not modified while CopyBufferRegion is in progress?
Would it be more appropriate to allocate the UploadBuffer using LinearAllocator to ensure proper synchronization and avoid potential data corruption?
Looking forward to your thoughts!
The text was updated successfully, but these errors were encountered: