Don't call ResizeFramebuffers() during bake commands!

This commit is contained in:
Robert Beckebans 2022-04-23 18:48:55 +02:00
parent 43b3375da7
commit ea296d884d
9 changed files with 73 additions and 58 deletions

View file

@ -35,36 +35,26 @@ If you have questions concerning this license or the applicable additional terms
void CommandlineProgressBar::Start()
{
#if !defined( USE_NVRHI )
// restore the original resolution, same as "vid_restart"
glConfig.nativeScreenWidth = sysWidth;
glConfig.nativeScreenHeight = sysHeight;
R_SetNewMode( false );
common->Printf( "0%% 10 20 30 40 50 60 70 80 90 100%%\n" );
common->Printf( "|----|----|----|----|----|----|----|----|----|----|\n" );
common->UpdateScreen( false );
#else
common->Printf( "0%% 10 20 30 40 50 60 70 80 90 100%%\n" );
common->Printf( "|----|----|----|----|----|----|----|----|----|----|\n" );
#endif
}
void CommandlineProgressBar::Increment( bool updateScreen )
{
if( ( count + 1 ) >= nextTicCount )
{
#if !defined( USE_NVRHI )
#if 1 //!defined( USE_NVRHI )
if( updateScreen )
{
// restore the original resolution, same as "vid_restart"
glConfig.nativeScreenWidth = sysWidth;
glConfig.nativeScreenHeight = sysHeight;
R_SetNewMode( false );
//glConfig.nativeScreenWidth = sysWidth;
//glConfig.nativeScreenHeight = sysHeight;
//R_SetNewMode( false );
// resize frame buffers (this triggers SwapBuffers)
tr.SwapCommandBuffers( NULL, NULL, NULL, NULL, NULL, NULL );
//tr.SwapCommandBuffers( NULL, NULL, NULL, NULL, NULL, NULL );
}
#endif
@ -86,7 +76,7 @@ void CommandlineProgressBar::Increment( bool updateScreen )
common->Printf( "\n" );
}
#if !defined( USE_NVRHI )
#if 1 //!defined( USE_NVRHI )
if( updateScreen )
{
common->UpdateScreen( false );

View file

@ -7058,7 +7058,21 @@ void idRenderBackend::DrawViewInternal( const viewDef_t* _viewDef, const int ste
//TODO(Stephen): Move somewhere else?
// RB: this needs to be done after next post processing steps later on
if( !( _viewDef->renderView.rdflags & RDF_IRRADIANCE ) )
if( _viewDef->renderView.rdflags & RDF_IRRADIANCE )
{
// we haven't changed ldrImage so it's basically the previewsRenderLDR
BlitParameters blitParms;
blitParms.sourceTexture = ( nvrhi::ITexture* )globalImages->ldrImage->GetTextureID();
blitParms.targetFramebuffer = deviceManager->GetCurrentFramebuffer();
blitParms.targetViewport = nvrhi::Viewport( renderSystem->GetWidth(), renderSystem->GetHeight() );
commonPasses.BlitTexture( commandList, blitParms, &bindingCache );
blitParms.sourceTexture = ( nvrhi::ITexture* )globalImages->envprobeHDRImage->GetTextureID();
blitParms.targetFramebuffer = deviceManager->GetCurrentFramebuffer();
blitParms.targetViewport = nvrhi::Viewport( ENVPROBE_CAPTURE_SIZE, ENVPROBE_CAPTURE_SIZE );
commonPasses.BlitTexture( commandList, blitParms, &bindingCache );
}
else
{
BlitParameters blitParms;
blitParms.sourceTexture = ( nvrhi::ITexture* )globalImages->ldrImage->GetTextureID();
@ -7316,6 +7330,11 @@ void idRenderBackend::PostProcess( const void* data )
return;
}
if( viewDef->renderView.rdflags & RDF_IRRADIANCE )
{
return;
}
renderLog.OpenMainBlock( MRB_POSTPROCESS );
renderLog.OpenBlock( "Render_PostProcessing", colorBlue );

View file

@ -956,7 +956,7 @@ public:
virtual void TakeScreenshot( int width, int height, const char* fileName, renderView_t* ref );
virtual byte* CaptureRenderToBuffer( int width, int height, renderView_t* ref );
virtual void CropRenderSize( int width, int height );
virtual void CropRenderSize( int x, int y, int width, int height );
virtual void CropRenderSize( int x, int y, int width, int height, bool topLeftAncor );
virtual void CaptureRenderToImage( const char* imageName, bool clearColorAfterCopy = false );
virtual void CaptureRenderToFile( const char* fileName, bool fixAlpha );
virtual void UnCrop();

View file

@ -1078,7 +1078,7 @@ void idRenderSystemLocal::CropRenderSize( int width, int height )
idRenderSystemLocal::CropRenderSize
================
*/
void idRenderSystemLocal::CropRenderSize( int x, int y, int width, int height )
void idRenderSystemLocal::CropRenderSize( int x, int y, int width, int height, bool topLeftAncor )
{
if( !IsInitialized() )
{
@ -1114,10 +1114,20 @@ void idRenderSystemLocal::CropRenderSize( int x, int y, int width, int height )
idScreenRect& current = renderCrops[currentRenderCrop];
current.x1 = x;
current.x2 = previous.x1 + width - 1;
current.y1 = y;
current.y2 = previous.y2;
if( topLeftAncor )
{
current.x1 = x;
current.x2 = width - 1;
current.y1 = y;
current.y2 = height - 1;
}
else
{
current.x1 = x;
current.x2 = previous.x1 + width - 1;
current.y1 = y;
current.y2 = previous.y2;
}
}
/*

View file

@ -421,7 +421,7 @@ public:
// then perform all desired rendering, then capture to an image
// if the specified physical dimensions are larger than the current cropped region, they will be cut down to fit
virtual void CropRenderSize( int width, int height ) = 0;
virtual void CropRenderSize( int x, int y, int width, int height ) = 0;
virtual void CropRenderSize( int x, int y, int width, int height, bool topLeftAncor ) = 0;
virtual void CaptureRenderToImage( const char* imageName, bool clearColorAfterCopy = false ) = 0;
// fixAlpha will set all the alpha channel values to 0xff, which allows screen captures
// to use the default tga loading code without having dimmed down areas in many places

View file

@ -1000,9 +1000,6 @@ void idRenderSystemLocal::TakeScreenshot( int widthIgnored, int heightIgnored, c
// make sure the game / draw thread has completed
commonLocal.WaitGameThread();
// discard anything currently on the list
//tr.SwapCommandBuffers( NULL, NULL, NULL, NULL, NULL, NULL );
// discard anything currently on the list
tr.SwapCommandBuffers( NULL, NULL, NULL, NULL, NULL, NULL );
if( ref )

View file

@ -1088,16 +1088,28 @@ void idRenderWorldLocal::RenderScene( const renderView_t* renderView )
int windowWidth = tr.GetWidth();
int windowHeight = tr.GetHeight();
tr.PerformResolutionScaling( windowWidth, windowHeight );
// screenFraction is just for quickly testing fill rate limitations
if( r_screenFraction.GetInteger() != 100 )
if( parms->renderView.rdflags & RDF_IRRADIANCE )
{
windowWidth = ( windowWidth * r_screenFraction.GetInteger() ) / 100;
windowHeight = ( windowHeight * r_screenFraction.GetInteger() ) / 100;
windowWidth = ENVPROBE_CAPTURE_SIZE;
windowHeight = ENVPROBE_CAPTURE_SIZE;
tr.CropRenderSize( 0, 0, windowWidth, windowHeight, true );
tr.GetCroppedViewport( &parms->viewport );
}
else
{
tr.PerformResolutionScaling( windowWidth, windowHeight );
// screenFraction is just for quickly testing fill rate limitations
if( r_screenFraction.GetInteger() != 100 )
{
windowWidth = ( windowWidth * r_screenFraction.GetInteger() ) / 100;
windowHeight = ( windowHeight * r_screenFraction.GetInteger() ) / 100;
}
tr.CropRenderSize( windowWidth, windowHeight );
tr.GetCroppedViewport( &parms->viewport );
}
tr.CropRenderSize( windowWidth, windowHeight );
tr.GetCroppedViewport( &parms->viewport );
// the scissor bounds may be shrunk in subviews even if
// the viewport stays the same

View file

@ -939,7 +939,7 @@ CONSOLE_COMMAND( bakeEnvironmentProbes, "Bake environment probes", NULL )
int sysWidth = renderSystem->GetWidth();
int sysHeight = renderSystem->GetHeight();
bool useThreads = false;
bool useThreads = true;
baseName = tr.primaryWorld->mapName;
baseName.StripFileExtension();
@ -961,8 +961,8 @@ CONSOLE_COMMAND( bakeEnvironmentProbes, "Bake environment probes", NULL )
// make sure the game / draw thread has completed
commonLocal.WaitGameThread();
glConfig.nativeScreenWidth = captureSize;
glConfig.nativeScreenHeight = captureSize;
//glConfig.nativeScreenWidth = captureSize;
//glConfig.nativeScreenHeight = captureSize;
// disable scissor, so we don't need to adjust all those rects
r_useScissor.SetBool( false );
@ -1034,11 +1034,8 @@ CONSOLE_COMMAND( bakeEnvironmentProbes, "Bake environment probes", NULL )
ref.vieworg = def->parms.origin;
ref.viewaxis = tr.cubeAxis[j];
glConfig.nativeScreenWidth = captureSize;
glConfig.nativeScreenHeight = captureSize;
// discard anything currently on the list
tr.SwapCommandBuffers( NULL, NULL, NULL, NULL, NULL, NULL );
//tr.SwapCommandBuffers( NULL, NULL, NULL, NULL, NULL, NULL );
// build commands to render the scene
tr.primaryWorld->RenderScene( &ref );
@ -1106,11 +1103,6 @@ CONSOLE_COMMAND( bakeEnvironmentProbes, "Bake environment probes", NULL )
tr.takingEnvprobe = false;
// restore the original resolution, same as "vid_restart"
glConfig.nativeScreenWidth = sysWidth;
glConfig.nativeScreenHeight = sysHeight;
R_SetNewMode( false );
r_useScissor.SetBool( true );
r_useParallelAddModels.SetBool( true );
r_useParallelAddShadows.SetBool( true );

View file

@ -1206,9 +1206,6 @@ CONSOLE_COMMAND( bakeLightGrids, "Bake irradiance/vis light grid data", NULL )
// make sure the game / draw thread has completed
commonLocal.WaitGameThread();
glConfig.nativeScreenWidth = captureSize;
glConfig.nativeScreenHeight = captureSize;
// disable scissor, so we don't need to adjust all those rects
r_useScissor.SetBool( false );
@ -1263,11 +1260,8 @@ CONSOLE_COMMAND( bakeLightGrids, "Bake irradiance/vis light grid data", NULL )
ref.vieworg = gridPoint->origin;
ref.viewaxis = tr.cubeAxis[ side ];
glConfig.nativeScreenWidth = captureSize;
glConfig.nativeScreenHeight = captureSize;
// discard anything currently on the list
tr.SwapCommandBuffers( NULL, NULL, NULL, NULL, NULL, NULL );
//tr.SwapCommandBuffers( NULL, NULL, NULL, NULL, NULL, NULL );
// build commands to render the scene
tr.primaryWorld->RenderScene( &ref );
@ -1289,8 +1283,14 @@ CONSOLE_COMMAND( bakeLightGrids, "Bake irradiance/vis light grid data", NULL )
#if defined( USE_VULKAN )
// TODO
#elif defined( USE_NVRHI )
// make sure that all frames have finished rendering
//deviceManager->GetDevice()->waitForIdle();
R_ReadPixelsRGB16F( deviceManager->GetDevice(), &tr.backend.GetCommonPasses(), globalImages->envprobeHDRImage->GetTextureHandle() , nvrhi::ResourceStates::RenderTarget, floatRGB16F, captureSize, captureSize );
// release all in-flight references to the render targets
//deviceManager->GetDevice()->runGarbageCollection();
#if 0
idStr testName;
testName.Format( "env/test/area%i_envprobe_%i_side_%i.exr", a, tr.lightGridJobs.Num(), side );
@ -1328,11 +1328,6 @@ CONSOLE_COMMAND( bakeLightGrids, "Bake irradiance/vis light grid data", NULL )
tr.takingEnvprobe = false;
// restore the original resolution, same as "vid_restart"
glConfig.nativeScreenWidth = sysWidth;
glConfig.nativeScreenHeight = sysHeight;
R_SetNewMode( false );
r_useScissor.SetBool( true );
r_useParallelAddModels.SetBool( true );
r_useParallelAddShadows.SetBool( true );