R_TestVideo_f command fixes and Cinematics startup fix for NVRHI (BinkDec green frame)

(cherry picked from commit 846fcf14c723391c6e6b311eaaeb31926b1e65d1)
This commit is contained in:
Stephen Saunders 2022-12-20 02:06:07 -05:00
parent 600f4de937
commit f1b0f2ec00
6 changed files with 36 additions and 79 deletions

View file

@ -1246,6 +1246,20 @@ idCinematicLocal::ImageForTime
*/
cinData_t idCinematicLocal::ImageForTime( int thisTime, nvrhi::ICommandList* commandList )
{
cinData_t cinData;
if( thisTime <= 0 )
{
thisTime = Sys_Milliseconds();
}
memset( &cinData, 0, sizeof( cinData ) );
// SRS - also return if commandList is null, typically when called from within InitFromFile()
if( r_skipDynamicTextures.GetBool() || status == FMV_EOF || status == FMV_IDLE || !commandList )
{
return cinData;
}
#if defined(USE_FFMPEG)
// Carl: Handle BFG format BINK videos separately
if( !isRoQ )
@ -1259,39 +1273,12 @@ cinData_t idCinematicLocal::ImageForTime( int thisTime, nvrhi::ICommandList* com
}
#endif
// Carl: Handle original Doom 3 RoQ video files
cinData_t cinData;
// SRS - Changed from == 0 to <= 0 to match behaviour of FFMPEG and BinkDec decoders
if( thisTime <= 0 )
{
thisTime = Sys_Milliseconds();
}
//if( thisTime < 0 )
//{
// thisTime = 0;
//}
memset( &cinData, 0, sizeof( cinData ) );
// if ( r_skipROQ.GetBool() ) {
if( r_skipDynamicTextures.GetBool() )
{
return cinData;
}
if( !iFile )
{
// RB: neither .bik or .roq found
return cinData;
}
if( status == FMV_EOF || status == FMV_IDLE )
{
return cinData;
}
if( buf == NULL || startTime == -1 )
{
if( startTime == -1 )
@ -1333,17 +1320,6 @@ cinData_t idCinematicLocal::ImageForTime( int thisTime, nvrhi::ICommandList* com
}
}
// SRS - This is redundant code, virtually identical logic correctly handles looping below
//if( status == FMV_LOOPED )
//{
// status = FMV_PLAY;
// while( buf == NULL && status == FMV_PLAY )
// {
// RoQInterrupt();
// }
// startTime = thisTime;
//}
if( status == FMV_LOOPED || status == FMV_EOF )
{
if( looping )
@ -1388,17 +1364,7 @@ cinData_t idCinematicLocal::ImageForTimeFFMPEG( int thisTime, nvrhi::ICommandLis
uint8_t* audioBuffer = NULL;
int num_bytes = 0;
if( thisTime <= 0 )
{
thisTime = Sys_Milliseconds();
}
memset( &cinData, 0, sizeof( cinData ) );
if( r_skipDynamicTextures.GetBool() || status == FMV_EOF || status == FMV_IDLE )
{
return cinData;
}
if( !fmt_ctx )
{
// RB: .bik requested but not found
@ -1597,17 +1563,7 @@ cinData_t idCinematicLocal::ImageForTimeBinkDec( int thisTime, nvrhi::ICommandLi
int16_t* audioBuffer = NULL;
uint32_t num_bytes = 0;
if( thisTime <= 0 )
{
thisTime = Sys_Milliseconds();
}
memset( &cinData, 0, sizeof( cinData ) );
if( r_skipDynamicTextures.GetBool() || status == FMV_EOF || status == FMV_IDLE )
{
return cinData;
}
if( !binkHandle.isValid )
{
// RB: .bik requested but not found

View file

@ -365,6 +365,9 @@ public:
// Adds the image to the list of images to load on the main thread to the gpu.
void DeferredLoadImage();
// Removes the image from the list of images to load on the main thread to the gpu.
void DeferredPurgeImage();
//---------------------------------------------
// Platform specific implementations
//---------------------------------------------
@ -792,4 +795,4 @@ IMAGEPROGRAM
void R_LoadImageProgram( const char* name, byte** pic, int* width, int* height, ID_TIME_T* timestamp, textureUsage_t* usage = NULL );
const char* R_ParsePastImageProgram( idLexer& src );
#endif
#endif

View file

@ -743,6 +743,11 @@ void idImage::DeferredLoadImage()
globalImages->imagesToLoad.AddUnique( this );
}
void idImage::DeferredPurgeImage()
{
globalImages->imagesToLoad.Remove( this );
}
/*
==================
StorageSize
@ -1293,4 +1298,4 @@ void idImage::UploadScratch( const byte* data, int cols, int rows, nvrhi::IComma
}
isLoaded = true;
}
}

View file

@ -76,6 +76,9 @@ idImage::~idImage
idImage::~idImage()
{
PurgeImage();
// SRS - if image found in deferred load list, remove it now to avoid problems later
DeferredPurgeImage();
}
/*

View file

@ -2238,7 +2238,7 @@ Display a single image over most of the screen
*/
void idRenderBackend::DBG_TestImage()
{
idImage* image = NULL;
idImage* image = NULL;
idImage* imageCr = NULL;
idImage* imageCb = NULL;
int max;
@ -2254,9 +2254,9 @@ void idRenderBackend::DBG_TestImage()
{
cinData_t cin;
// SRS - Don't need calibrated time for testing cinematics, so just call ImageForTime( 0 ) for current system time
// SRS - Don't need calibrated time for testing cinematics, so just call ImageForTime( ) with current system time
// This simplification allows cinematic test playback to work over both 2D and 3D background scenes
cin = tr.testVideo->ImageForTime( 0 /*viewDef->renderView.time[1] - tr.testVideoStartTime*/, commandList );
cin = tr.testVideo->ImageForTime( Sys_Milliseconds() /*viewDef->renderView.time[1] - tr.testVideoStartTime*/, commandList );
if( cin.imageY != NULL )
{
image = cin.imageY;
@ -2308,9 +2308,10 @@ void idRenderBackend::DBG_TestImage()
float scale[16] = { 0 };
scale[0] = w; // scale
scale[5] = h; // scale
scale[12] = halfScreenWidth - ( halfScreenWidth * w ); // translate
scale[13] = halfScreenHeight - ( halfScreenHeight * h ); // translate
scale[10] = 1.0f;
scale[12] = halfScreenWidth - ( halfScreenWidth * w ); // translate to center x
scale[13] = halfScreenHeight / 2 - ( halfScreenHeight * h ); // translate to center y of console dropdown
scale[14] = -0.5f; // translate to center z
scale[15] = 1.0f;
float ortho[16] = { 0 };

View file

@ -704,14 +704,9 @@ void R_TestVideo_f( const idCmdArgs& args )
tr.testImage = globalImages->ImageFromFile( "_scratch", TF_DEFAULT, TR_REPEAT, TD_DEFAULT );
tr.testVideo = idCinematic::Alloc();
tr.testVideo->InitFromFile( args.Argv( 1 ), true, NULL );
cinData_t cin;
// FIXME commandList
cin = tr.testVideo->ImageForTime( 0, NULL );
// SRS - Also handle ffmpeg and original RoQ decoders for test videos (using cin.image)
if( cin.imageY == NULL && cin.image == NULL )
// SRS - make sure we have a valid bink, ffmpeg, or RoQ video file, otherwise delete testVideo and return
// SRS - no need to call ImageForTime() here, playback is handled within idRenderBackend::DBG_TestImage()
if( !tr.testVideo->InitFromFile( args.Argv( 1 ), true, NULL ) )
{
delete tr.testVideo;
tr.testVideo = NULL;
@ -719,12 +714,6 @@ void R_TestVideo_f( const idCmdArgs& args )
return;
}
// SRS - video info prinout is redundant, already handled by InitFromFile()
//common->Printf( "%i x %i images\n", cin.imageWidth, cin.imageHeight );
//int len = tr.testVideo->AnimationLength();
//common->Printf( "%5.1f seconds of video\n", len * 0.001 );
// try to play the matching wav file
idStr wavString = args.Argv( ( args.Argc() == 2 ) ? 1 : 2 );
wavString.StripFileExtension();