Some code to debug the NVRHI swapchain problem

This commit is contained in:
Robert Beckebans 2022-09-17 20:01:06 +02:00
parent 44d65a6377
commit 9307983475
7 changed files with 40 additions and 12 deletions

2
neo/extern/nvrhi vendored

@ -1 +1 @@
Subproject commit 2caca768dc9598cd8e46f3d2257270a1db1981ce
Subproject commit 6cd068816ca7b6348196129285c76008960eb93f

View file

@ -1434,6 +1434,10 @@ idRenderBackend::GL_EndFrame
*/
void idRenderBackend::GL_EndFrame()
{
#if defined( USE_VK )
tr.SetReadyToPresent();
#endif
renderLog.CloseMainBlock( MRB_GPU_TIME );
commandList->close();
@ -1442,6 +1446,10 @@ void idRenderBackend::GL_EndFrame()
// update jitter for perspective matrix
taaPass->AdvanceFrame();
#if defined( USE_VK )
//GL_BlockingSwapBuffers();
#endif
}
/*

View file

@ -6599,7 +6599,13 @@ void idRenderBackend::ExecuteBackEndCommands( const emptyCommand_t* cmds )
{
delete hiZGenPass;
}
#if defined( USE_VK )
// FIXME
hiZGenPass = NULL;
#else
hiZGenPass = new MipMapGenPass( deviceManager->GetDevice(), globalImages->hierarchicalZbufferImage->GetTextureHandle() );
#endif
}

View file

@ -994,6 +994,11 @@ public:
bInitialized = true;
}
void SetReadyToPresent()
{
omitSwapBuffers = false;
}
public:
// internal functions
idRenderSystemLocal();
@ -1095,6 +1100,7 @@ public:
private:
bool bInitialized;
bool omitSwapBuffers;
};
extern idRenderSystemLocal tr;

View file

@ -257,7 +257,8 @@ idRenderSystemLocal::idRenderSystemLocal() :
zeroOneCubeTriangles( NULL ),
zeroOneSphereTriangles( NULL ),
testImageTriangles( NULL ),
bInitialized( false )
bInitialized( false ),
omitSwapBuffers( false )
{
Clear();
}
@ -676,10 +677,13 @@ void idRenderSystemLocal::SwapCommandBuffers_FinishRendering(
// keep capturing envprobes completely in the background
// and only update the screen when we update the progress bar in the console
#if !defined( USE_NVRHI )
#if defined( USE_NVRHI )
if( !omitSwapBuffers )
#else
if( !takingEnvprobe )
#endif
{
#if !IMGUI_BFGUI
ImGuiHook::Render();
#endif

View file

@ -67,7 +67,7 @@ idCVar r_requestStereoPixelFormat( "r_requestStereoPixelFormat", "1", CVAR_RENDE
idCVar r_debugContext( "r_debugContext", "0", CVAR_RENDERER, "Enable various levels of context debug." );
#if defined( USE_NVRHI )
#if defined( _WIN32 )
idCVar r_graphicsAPI( "r_graphicsAPI", "dx12", CVAR_RENDERER, "Specifies the graphics api to use (dx12, vulkan)" );
idCVar r_graphicsAPI( "r_graphicsAPI", "vulkan", CVAR_RENDERER, "Specifies the graphics api to use (dx12, vulkan)" );
#else
idCVar r_graphicsAPI( "r_graphicsAPI", "vulkan", CVAR_RENDERER, "Specifies the graphics api to use (vulkan)" );
#endif
@ -2225,7 +2225,10 @@ void idRenderSystemLocal::Init()
frontEndJobList = parallelJobManager->AllocJobList( JOBLIST_RENDERER_FRONTEND, JOBLIST_PRIORITY_MEDIUM, 2048, 0, NULL );
envprobeJobList = parallelJobManager->AllocJobList( JOBLIST_UTILITY, JOBLIST_PRIORITY_MEDIUM, 2048, 0, NULL ); // RB
bInitialized = true;
#if defined( USE_VK )
// avoid GL_BlockingSwapBuffers
omitSwapBuffers = true;
#endif
// make sure the command buffers are ready to accept the first screen update
SwapCommandBuffers( NULL, NULL, NULL, NULL, NULL, NULL );

View file

@ -163,7 +163,7 @@ private:
// device
{
VK_KHR_SWAPCHAIN_EXTENSION_NAME,
VK_KHR_MAINTENANCE1_EXTENSION_NAME
VK_KHR_MAINTENANCE1_EXTENSION_NAME,
},
};
@ -397,10 +397,10 @@ bool DeviceManager_VK::createInstance()
return false;
}
common->Printf( "Enabled Vulkan instance extensions:" );
common->Printf( "Enabled Vulkan instance extensions:\n" );
for( const auto& ext : enabledExtensions.instance )
{
common->Printf( " %s", ext.c_str() );
common->Printf( " %s\n", ext.c_str() );
}
std::unordered_set<std::string> requiredLayers = enabledExtensions.layers;
@ -429,10 +429,10 @@ bool DeviceManager_VK::createInstance()
return false;
}
common->Printf( "Enabled Vulkan layers:" );
common->Printf( "Enabled Vulkan layers:\n" );
for( const auto& layer : enabledExtensions.layers )
{
common->Printf( " %s", layer.c_str() );
common->Printf( " %s\n", layer.c_str() );
}
auto instanceExtVec = stringSetToVector( enabledExtensions.instance );
@ -705,7 +705,7 @@ bool DeviceManager_VK::createDevice()
common->Printf( "Enabled Vulkan device extensions:" );
for( const auto& ext : enabledExtensions.device )
{
common->Printf( " %s", ext.c_str() );
common->Printf( " %s\n", ext.c_str() );
if( ext == VK_KHR_ACCELERATION_STRUCTURE_EXTENSION_NAME )
{
@ -713,6 +713,7 @@ bool DeviceManager_VK::createDevice()
}
else if( ext == VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME )
{
// RB: only makes problems at the moment
bufferAddressSupported = true;
}
else if( ext == VK_KHR_RAY_TRACING_PIPELINE_EXTENSION_NAME )
@ -946,7 +947,7 @@ bool DeviceManager_VK::createSwapChain()
m_SwapChainFormat =
{
vk::Format( nvrhi::vulkan::convertFormat( deviceParms.swapChainFormat ) ),
vk::ColorSpaceKHR::eSrgbNonlinear // SP: Does this matter this is non-linear srgb?
vk::ColorSpaceKHR::eSrgbNonlinear
};
vk::Extent2D extent = vk::Extent2D( deviceParms.backBufferWidth, deviceParms.backBufferHeight );