Correct some uint64 types and add Optick frame tag for DX12 / Vulkan Present()

This commit is contained in:
SRSaunders 2024-03-07 15:55:00 -05:00
parent 75011c4eea
commit 2e2a9106e1
5 changed files with 24 additions and 25 deletions

View file

@ -436,13 +436,13 @@ public:
return metal_encode;
}
void SetRendererGpuMemoryMB( int gpuMemoryMB )
void SetRendererGpuMemoryMB( uint64 gpuMemoryMB )
{
gpu_memory = gpuMemoryMB;
return;
}
int GetRendererGpuMemoryMB() const
uint64 GetRendererGpuMemoryMB() const
{
return gpu_memory;
}
@ -664,7 +664,7 @@ private:
// SRS - MoltenVK's Vulkan to Metal command buffer encoding time, set default to 0 for non-macOS platforms (Windows and Linux)
uint64 metal_encode = 0;
// SRS - Cross-platform GPU Memory usage counter, set default to 0 in case platform or graphics API does not support queries
int gpu_memory = 0;
uint64 gpu_memory = 0;
// Used during loading screens
int lastPacifierSessionTime;

View file

@ -450,7 +450,7 @@ float idConsoleLocal::DrawFPS( float y )
ImGui::TextColored( colorCyan, "API: %s, AA[%i, %i]: %s, %s", API, width, height, aaMode, resolutionText.c_str() );
ImGui::TextColored( colorGold, "Device: %s, Memory: %i MB", deviceManager->GetRendererString(), commonLocal.GetRendererGpuMemoryMB() );
ImGui::TextColored( colorGold, "Device: %s, Memory: %llu MB", deviceManager->GetRendererString(), commonLocal.GetRendererGpuMemoryMB() );
ImGui::TextColored( colorLtGrey, "GENERAL: views:%i draws:%i tris:%i",
commonLocal.stats_frontend.c_numViews,

View file

@ -153,7 +153,7 @@ void fhImmediateMode::End()
}
}
uint64_t stateBits = tr.backend.glStateBits;
uint64 stateBits = tr.backend.glStateBits;
int program = renderProgManager.CurrentProgram();
PipelineKey key{ stateBits, program, static_cast<int>( tr.backend.depthBias ), tr.backend.slopeScaleBias, tr.backend.currentFrameBuffer };

View file

@ -572,7 +572,7 @@ void DeviceManager_DX12::BeginFrame()
DXGI_QUERY_VIDEO_MEMORY_INFO memoryInfoLocal = {}, memoryInfoNonLocal = {};
m_DxgiAdapter->QueryVideoMemoryInfo( 0, DXGI_MEMORY_SEGMENT_GROUP_LOCAL, &memoryInfoLocal );
m_DxgiAdapter->QueryVideoMemoryInfo( 0, DXGI_MEMORY_SEGMENT_GROUP_NON_LOCAL, &memoryInfoNonLocal );
commonLocal.SetRendererGpuMemoryMB( int( ( memoryInfoLocal.CurrentUsage + memoryInfoNonLocal.CurrentUsage ) / 1024 / 1024 ) );
commonLocal.SetRendererGpuMemoryMB( ( memoryInfoLocal.CurrentUsage + memoryInfoNonLocal.CurrentUsage ) / 1024 / 1024 );
}
nvrhi::ITexture* DeviceManager_DX12::GetCurrentBackBuffer()
@ -621,6 +621,7 @@ void DeviceManager_DX12::Present()
OPTICK_GPU_FLIP( m_SwapChain.Get(), idLib::frameNumber - 1 );
OPTICK_CATEGORY( "DX12_Present", Optick::Category::Wait );
OPTICK_TAG( "Frame", idLib::frameNumber - 1 );
// SRS - Don't change m_DeviceParams.vsyncEnabled here, simply test for vsync mode 2 to set DXGI SyncInterval
m_SwapChain->Present( m_DeviceParams.vsyncEnabled == 2 ? 1 : 0, presentFlags );

View file

@ -1456,33 +1456,30 @@ void DeviceManager_VK::BeginFrame()
size_t mvkPerfStatsSize = sizeof( mvkPerfStats );
vkGetPerformanceStatisticsMVK( m_VulkanDevice, &mvkPerfStats, &mvkPerfStatsSize );
commonLocal.SetRendererMvkEncodeMicroseconds( uint64( Max( 0.0, mvkPerfStats.queue.submitCommandBuffers.latest - mvkPerfStats.queue.retrieveCAMetalDrawable.latest ) * 1000.0 ) );
commonLocal.SetRendererGpuMemoryMB( int( mvkPerfStats.device.gpuMemoryAllocated.latest / 1024.0 ) );
}
else
#endif
#endif
{
// SRS - get Vulkan GPU memory usage for display in statistics overlay HUD
vk::PhysicalDeviceMemoryProperties2 memoryProperties2;
vk::PhysicalDeviceMemoryBudgetPropertiesEXT memoryBudget;
memoryProperties2.pNext = &memoryBudget;
m_VulkanPhysicalDevice.getMemoryProperties2( &memoryProperties2 );
VkDeviceSize gpuMemoryAllocated = 0;
for( uint32_t i = 0; i < memoryProperties2.memoryProperties.memoryHeapCount; i++ )
{
gpuMemoryAllocated += memoryBudget.heapUsage[i];
// SRS - get Vulkan GPU memory usage for display in statistics overlay HUD
vk::PhysicalDeviceMemoryProperties2 memoryProperties2;
vk::PhysicalDeviceMemoryBudgetPropertiesEXT memoryBudget;
memoryProperties2.pNext = &memoryBudget;
m_VulkanPhysicalDevice.getMemoryProperties2( &memoryProperties2 );
VkDeviceSize gpuMemoryAllocated = 0;
for( uint32_t i = 0; i < memoryProperties2.memoryProperties.memoryHeapCount; i++ )
{
gpuMemoryAllocated += memoryBudget.heapUsage[i];
#if defined(__APPLE__)
// SRS - macOS Vulkan API <= 1.2.268 has heap reporting defect, use heapUsage[0] only
if( m_DeviceApiVersion <= VK_MAKE_API_VERSION( 0, 1, 2, 268 ) )
{
break;
}
#endif
// SRS - macOS Vulkan API <= 1.2.268 has heap reporting defect, use heapUsage[0] only
if( m_DeviceApiVersion <= VK_MAKE_API_VERSION( 0, 1, 2, 268 ) )
{
break;
}
commonLocal.SetRendererGpuMemoryMB( int( gpuMemoryAllocated / 1024 / 1024 ) );
#endif
}
commonLocal.SetRendererGpuMemoryMB( gpuMemoryAllocated / 1024 / 1024 );
const vk::Result res = m_VulkanDevice.acquireNextImageKHR( m_SwapChain,
std::numeric_limits<uint64_t>::max(), // timeout
@ -1511,6 +1508,7 @@ void DeviceManager_VK::Present()
{
OPTICK_GPU_FLIP( m_SwapChain );
OPTICK_CATEGORY( "Vulkan_Present", Optick::Category::Wait );
OPTICK_TAG( "Frame", idLib::frameNumber - 1 );
void* pNext = nullptr;
#if USE_OPTICK