Ran Astyle

This commit is contained in:
Robert Beckebans 2021-04-29 15:20:45 +02:00
parent d72ce4a2d5
commit 0964c02bcf
39 changed files with 517 additions and 507 deletions

View file

@ -268,7 +268,7 @@ bool idMenuWidget_ScrollBar::HandleAction( idWidgetAction& action, const idWidge
CalculatePosition( x, y );
return true;
}
case ( widgetAction_t ) WIDGET_ACTION_EVENT_DRAG_STOP: // SRS - Cast actionHandler_t to widgetAction_t
case( widgetAction_t ) WIDGET_ACTION_EVENT_DRAG_STOP: // SRS - Cast actionHandler_t to widgetAction_t
{
dragging = false;
return true;

View file

@ -75,9 +75,9 @@ public:
virtual void BufferCommandText( cmdExecution_t exec, const char* text );
virtual void ExecuteCommandBuffer();
virtual void ArgCompletion_FolderExtension( const idCmdArgs& args, void( *callback )( const char* s ), const char* folder, int stripFolder, ... );
// SRS - Changed stripFolder type from bool to int for compatibility with va_start()
// SRS - Changed stripFolder type from bool to int for compatibility with va_start()
virtual void ArgCompletion_DeclName( const idCmdArgs& args, void( *callback )( const char* s ), int type );
virtual void BufferCommandArgs( cmdExecution_t exec, const idCmdArgs& args );
@ -798,7 +798,7 @@ idCmdSystemLocal::ArgCompletion_FolderExtension
============
*/
void idCmdSystemLocal::ArgCompletion_FolderExtension( const idCmdArgs& args, void( *callback )( const char* s ), const char* folder, int stripFolder, ... )
// SRS - Changed stripFolder type from bool to int for compatibility with va_start()
// SRS - Changed stripFolder type from bool to int for compatibility with va_start()
{
int i;
idStr string;

View file

@ -171,7 +171,7 @@ public:
// Base for path/file auto-completion.
virtual void ArgCompletion_FolderExtension( const idCmdArgs& args, void( *callback )( const char* s ), const char* folder, int stripFolder, ... ) = 0;
// SRS - Changed stripFolder type from bool to int for compatibility with va_start()
// SRS - Changed stripFolder type from bool to int for compatibility with va_start()
// Base for decl name auto-completion.
virtual void ArgCompletion_DeclName( const idCmdArgs& args, void( *callback )( const char* s ), int type ) = 0;

View file

@ -1338,7 +1338,7 @@ void idCommonLocal::Init( int argc, const char* const* argv, const char* cmdline
// display the legal splash screen
// No clue why we have to render this twice to show up...
RenderSplash();
// SRS - OSX needs this for some OpenGL drivers, otherwise renders leftover image before splash
// SRS - OSX needs this for some OpenGL drivers, otherwise renders leftover image before splash
RenderSplash();
}
@ -1794,7 +1794,7 @@ idCommonLocal::ProcessEvent
bool idCommonLocal::ProcessEvent( const sysEvent_t* event )
{
// hitting escape anywhere brings up the menu
// SRS - allow escape during demo playback to cancel
// SRS - allow escape during demo playback to cancel
if( game && ( game->IsInGame() || readDemo ) )
{
if( event->evType == SE_KEY && event->evValue2 == 1 && ( event->evValue == K_ESCAPE || event->evValue == K_JOY9 ) )
@ -1815,16 +1815,16 @@ bool idCommonLocal::ProcessEvent( const sysEvent_t* event )
}
console->Close();
// SRS - cancel demo playback and return to the main menu
if ( readDemo )
{
LeaveGame();
}
else
{
StartMenu();
}
// SRS - cancel demo playback and return to the main menu
if( readDemo )
{
LeaveGame();
}
else
{
StartMenu();
}
return true;
}
else

View file

@ -248,8 +248,8 @@ void idCommonLocal::StartPlayingRenderDemo( idStr demoName )
common->Printf( "couldn't open %s\n", demoName.c_str() );
delete readDemo;
readDemo = NULL;
CreateMainMenu(); // SRS - drop back to main menu if demo playback fails
CreateMainMenu(); // SRS - drop back to main menu if demo playback fails
StartMenu();
return;
}
@ -259,11 +259,11 @@ void idCommonLocal::StartPlayingRenderDemo( idStr demoName )
if( opcode != DS_VERSION )
{
common->Printf( "StartPlayingRenderDemo invalid demo file\n" );
readDemo->Close();
delete readDemo;
readDemo = NULL;
CreateMainMenu(); // SRS - drop back to main menu if demo playback fails
readDemo->Close();
delete readDemo;
readDemo = NULL;
CreateMainMenu(); // SRS - drop back to main menu if demo playback fails
StartMenu();
return;
}
@ -272,35 +272,35 @@ void idCommonLocal::StartPlayingRenderDemo( idStr demoName )
if( demoVersion != RENDERDEMO_VERSION )
{
common->Printf( "StartPlayingRenderDemo got version %d, expected version %d\n", demoVersion, RENDERDEMO_VERSION );
readDemo->Close();
delete readDemo;
readDemo = NULL;
readDemo->Close();
delete readDemo;
readDemo = NULL;
CreateMainMenu(); // SRS - drop back to main menu if demo playback fails
CreateMainMenu(); // SRS - drop back to main menu if demo playback fails
StartMenu();
return;
}
numDemoFrames = 0; // SRS - Moved ahead of first call to AdvanceRenderDemo to properly handle demoshots
numShotFrames = 0; // SRS - Initialize count of demoShot frames to play before timeout to main menu
renderSystem->BeginLevelLoad(); // SRS - Free static data from previous level before loading demo assets
soundSystem->BeginLevelLoad(); // SRS - Free sound media from previous level before loading demo assets
declManager->BeginLevelLoad(); // SRS - Clear declaration manager data before loading demo assets
uiManager->BeginLevelLoad(); // SRS - Clear gui manager data before loading demo assets
numDemoFrames = 0; // SRS - Moved ahead of first call to AdvanceRenderDemo to properly handle demoshots
numShotFrames = 0; // SRS - Initialize count of demoShot frames to play before timeout to main menu
renderSystem->BeginLevelLoad(); // SRS - Free static data from previous level before loading demo assets
soundSystem->BeginLevelLoad(); // SRS - Free sound media from previous level before loading demo assets
declManager->BeginLevelLoad(); // SRS - Clear declaration manager data before loading demo assets
uiManager->BeginLevelLoad(); // SRS - Clear gui manager data before loading demo assets
AdvanceRenderDemo( true ); // SRS - Call AdvanceRenderDemo() once to load map and initial assets (like level load)
renderSystem->EndLevelLoad(); // SRS - Define static data for use by RB_StencilShadowPass if stencil shadows enabled
soundSystem->EndLevelLoad();
declManager->EndLevelLoad();
uiManager->EndLevelLoad( "" ); // SRS - FIXME: No gui assets are currently saved/reloaded in demo file, fix later?
Game()->StartDemoPlayback( renderWorld );
renderWorld->GenerateAllInteractions();
soundSystem->SetPlayingSoundWorld( soundWorld );
renderSystem->EndLevelLoad(); // SRS - Define static data for use by RB_StencilShadowPass if stencil shadows enabled
soundSystem->EndLevelLoad();
declManager->EndLevelLoad();
uiManager->EndLevelLoad( "" ); // SRS - FIXME: No gui assets are currently saved/reloaded in demo file, fix later?
Game()->StartDemoPlayback( renderWorld );
renderWorld->GenerateAllInteractions();
soundSystem->SetPlayingSoundWorld( soundWorld );
timeDemoStartTime = Sys_Milliseconds();
}
@ -318,15 +318,15 @@ void idCommonLocal::TimeRenderDemo( const char* demoName, bool twice, bool quit
if( twice && readDemo )
{
timeDemo = TD_YES; // SRS - Set timeDemo to TD_YES to disable time demo playback pause when window not in focus
while( readDemo )
timeDemo = TD_YES; // SRS - Set timeDemo to TD_YES to disable time demo playback pause when window not in focus
while( readDemo )
{
// const bool captureToImage = false;
// UpdateScreen( captureToImage );
BusyWait(); // SRS - Call BusyWait() vs. UpdateScreen() to avoid Pump() timeout messages in console
AdvanceRenderDemo( true );
eventLoop->RunEventLoop(); // SRS - Run event loop to allow keyboard escape to cancel first pass of the demo
BusyWait(); // SRS - Call BusyWait() vs. UpdateScreen() to avoid Pump() timeout messages in console
AdvanceRenderDemo( true );
eventLoop->RunEventLoop(); // SRS - Run event loop to allow keyboard escape to cancel first pass of the demo
}
StartPlayingRenderDemo( demo );
@ -335,7 +335,7 @@ void idCommonLocal::TimeRenderDemo( const char* demoName, bool twice, bool quit
if( !readDemo )
{
timeDemo = TD_NO; // SRS - Make sure timeDemo flag is off if readDemo is NULL
timeDemo = TD_NO; // SRS - Make sure timeDemo flag is off if readDemo is NULL
return;
}
@ -523,13 +523,15 @@ void idCommonLocal::AdvanceRenderDemo( bool singleFrameOnly )
case DS_FINISHED:
if( numDemoFrames == 1 )
{
// if the demo has a single frame (a demoShot), continuously replay
// the renderView that has already been read
if ( numShotFrames++ < com_engineHz_latched*10 ) // SRS - play demoShot for min 10 sec then timeout
return;
}
LeaveGame(); // SRS - drop back to main menu after demo playback is finished
return;
// if the demo has a single frame (a demoShot), continuously replay
// the renderView that has already been read
if( numShotFrames++ < com_engineHz_latched * 10 ) // SRS - play demoShot for min 10 sec then timeout
{
return;
}
}
LeaveGame(); // SRS - drop back to main menu after demo playback is finished
return;
case DS_RENDER:
if( renderWorld->ProcessDemoCommand( readDemo, &currentDemoRenderView, &demoTimeOffset ) )
{

View file

@ -547,7 +547,7 @@ private:
timeDemo_t timeDemo;
int timeDemoStartTime;
int numDemoFrames; // for timeDemo and demoShot
int numShotFrames; // SRS - for demoShot playback timeout
int numShotFrames; // SRS - for demoShot playback timeout
int demoTimeOffset;
renderView_t currentDemoRenderView;

View file

@ -347,8 +347,8 @@ void idCommonLocal::Draw()
}
else if( readDemo )
{
// SRS - Advance demo inside Frame() instead of Draw() to support smp mode playback
// AdvanceRenderDemo( true );
// SRS - Advance demo inside Frame() instead of Draw() to support smp mode playback
// AdvanceRenderDemo( true );
renderWorld->RenderScene( &currentDemoRenderView );
renderSystem->DrawDemoPics();
}
@ -564,7 +564,7 @@ void idCommonLocal::Frame()
// RB end, DG end
{
// RB: don't release the mouse when opening a PDA or menu
// SRS - don't release when console open in a game (otherwise may be out of frame on return) but always release at main menu
// SRS - don't release when console open in a game (otherwise may be out of frame on return) but always release at main menu
if( ( console->Active() && !game ) || !mapSpawned || ImGuiTools::ReleaseMouseForTools() )
{
Sys_GrabMouseCursor( false );
@ -681,7 +681,7 @@ void idCommonLocal::Frame()
// don't run any frames when paused
// jpcy: the game is paused when playing a demo, but playDemo should wait like the game does
// SRS - don't wait if window not in focus and playDemo itself paused
// SRS - don't wait if window not in focus and playDemo itself paused
if( pauseGame && ( !( readDemo && !timeDemo ) || session->IsSystemUIShowing() || com_pause.GetInteger() ) )
{
gameFrame++;
@ -769,11 +769,11 @@ void idCommonLocal::Frame()
ExecuteMapChange();
mapSpawnData.savegameFile = NULL;
mapSpawnData.persistentPlayerInfo.Clear();
// SRS - If in Doom 3 mode (com_smp = -1) on map change, must obey fence before returning to avoid command buffer sync issues
if( com_smp.GetInteger() < 0 )
{
renderSystem->SwapCommandBuffers_FinishRendering( &time_frontend, &time_backend, &time_shadows, &time_gpu, &stats_backend, &stats_frontend );
}
// SRS - If in Doom 3 mode (com_smp = -1) on map change, must obey fence before returning to avoid command buffer sync issues
if( com_smp.GetInteger() < 0 )
{
renderSystem->SwapCommandBuffers_FinishRendering( &time_frontend, &time_backend, &time_shadows, &time_gpu, &stats_backend, &stats_frontend );
}
return;
}
else if( session->GetState() != idSession::INGAME && mapSpawned )
@ -796,19 +796,19 @@ void idCommonLocal::Frame()
// send frame and mouse events to active guis
GuiFrameEvents();
// SRS - Advance demos inside Frame() vs. Draw() to support smp mode playback
// SRS - Pause playDemo (but not timeDemo) when window not in focus
if ( readDemo && ( !( session->IsSystemUIShowing() || com_pause.GetInteger() ) || timeDemo ) )
{
AdvanceRenderDemo( true );
if( !readDemo )
{
// SRS - Important to return after demo playback is finished to avoid command buffer sync issues
return;
}
}
// SRS - Advance demos inside Frame() vs. Draw() to support smp mode playback
// SRS - Pause playDemo (but not timeDemo) when window not in focus
if( readDemo && ( !( session->IsSystemUIShowing() || com_pause.GetInteger() ) || timeDemo ) )
{
AdvanceRenderDemo( true );
if( !readDemo )
{
// SRS - Important to return after demo playback is finished to avoid command buffer sync issues
return;
}
}
//--------------------------------------------
// Prepare usercmds and kick off the game processing
// in a background thread
@ -859,7 +859,7 @@ void idCommonLocal::Frame()
// RB begin
#if defined(USE_DOOMCLASSIC)
// If we're in Doom or Doom 2, run tics and upload the new texture.
// SRS - Add check for com_pause cvar to make sure window is in focus - if not classic game should be paused (FIXME: but classic music still plays in background)
// SRS - Add check for com_pause cvar to make sure window is in focus - if not classic game should be paused (FIXME: but classic music still plays in background)
if( ( GetCurrentGame() == DOOM_CLASSIC || GetCurrentGame() == DOOM2_CLASSIC ) && !( Dialog().IsDialogPausing() || session->IsSystemUIShowing() || com_pause.GetInteger() ) )
{
RunDoomClassicFrame();
@ -891,12 +891,12 @@ void idCommonLocal::Frame()
}
frameTiming.finishRenderTime = Sys_Microseconds();
// SRS - If in Doom 3 mode (com_smp = -1), must sync after RenderCommandBuffers() otherwise get artifacts due to improper command buffer swap timing
if( com_smp.GetInteger() < 0 )
{
// RB: this is the same as Doom 3 renderSystem->EndFrame()
renderSystem->SwapCommandBuffers_FinishRendering( &time_frontend, &time_backend, &time_shadows, &time_gpu, &stats_backend, &stats_frontend );
}
// SRS - If in Doom 3 mode (com_smp = -1), must sync after RenderCommandBuffers() otherwise get artifacts due to improper command buffer swap timing
if( com_smp.GetInteger() < 0 )
{
// RB: this is the same as Doom 3 renderSystem->EndFrame()
renderSystem->SwapCommandBuffers_FinishRendering( &time_frontend, &time_backend, &time_shadows, &time_gpu, &stats_backend, &stats_frontend );
}
// make sure the game / draw thread has completed
// This may block if the game is taking longer than the render back end
@ -911,7 +911,7 @@ void idCommonLocal::Frame()
SendSnapshots();
// Render the sound system using the latest commands from the game thread
// SRS - Enable sound during normal playDemo playback but not during timeDemo
// SRS - Enable sound during normal playDemo playback but not during timeDemo
if( pauseGame && !( readDemo && !timeDemo ) )
{
soundWorld->Pause();
@ -922,10 +922,12 @@ void idCommonLocal::Frame()
soundWorld->UnPause();
soundSystem->SetPlayingSoundWorld( soundWorld );
}
// SRS - Play silence when dialog waiting or window not in focus
if ( Dialog().IsDialogPausing() || session->IsSystemUIShowing() || com_pause.GetInteger() )
soundSystem->SetPlayingSoundWorld( NULL );
// SRS - Play silence when dialog waiting or window not in focus
if( Dialog().IsDialogPausing() || session->IsSystemUIShowing() || com_pause.GetInteger() )
{
soundSystem->SetPlayingSoundWorld( NULL );
}
soundSystem->Render();
// process the game return for map changes, etc

View file

@ -354,7 +354,7 @@ ID_INLINE _type_* idBlockAlloc<_type_, _blockSize_, memTag>::Alloc()
_type_ * t = ( _type_* ) element->buffer;
if( clearAllocs )
{
memset( (void*)t, 0, sizeof( _type_ ) ); // SRS - Added (void*) cast to silence build-time warning
memset( ( void* )t, 0, sizeof( _type_ ) ); // SRS - Added (void*) cast to silence build-time warning
}
new( t ) _type_;
return t;

View file

@ -197,8 +197,8 @@ void idLib::FatalError( const char* fmt, ... )
va_end( argptr );
common->FatalError( "%s", text );
exit(EXIT_FAILURE); // SRS - Added exit to silence build warning since FatalError has attribute noreturn
exit( EXIT_FAILURE ); // SRS - Added exit to silence build warning since FatalError has attribute noreturn
}
/*
@ -216,8 +216,8 @@ void idLib::Error( const char* fmt, ... )
va_end( argptr );
common->Error( "%s", text );
exit(EXIT_FAILURE); // SRS - Added exit to silence build warning since Error has attribute noreturn
exit( EXIT_FAILURE ); // SRS - Added exit to silence build warning since Error has attribute noreturn
}
/*

View file

@ -150,9 +150,9 @@ Note: The data is merely moved around the list, so any pointers to data within t
template< class type, int size >
ID_INLINE void idStaticList<type, size>::Sort( const idSort<type>& sort )
{
/* if( list == NULL ) */
if( Num() <= 0 ) // SRS - Instead of checking this->list for NULL, check this->Num() for empty list
{
/* if( list == NULL ) */
if( Num() <= 0 ) // SRS - Instead of checking this->list for NULL, check this->Num() for empty list
{
return;
}
sort.Sort( Ptr(), Num() );

View file

@ -181,20 +181,20 @@ ID_INLINE void idStrPool::FreeString( const idPoolStr* poolStr )
* we're shutting down (at this point) just get rid of the following assertion:
* assert( poolStr->numUsers >= 1 );
*/
//if( poolStr->numUsers < 1 ) // SRS - This test does not work if idStrPool is empty and poolStr->numUsers is undefined
//if( poolStr->numUsers < 1 ) // SRS - This test does not work if idStrPool is empty and poolStr->numUsers is undefined
//{
// return;
//}
// DG end
if( pool.Num() <= 0 ) // SRS - Instead, check for empty idStrPool and return to prevent segfaulting on shutdown
{
return;
}
if( pool.Num() <= 0 ) // SRS - Instead, check for empty idStrPool and return to prevent segfaulting on shutdown
{
return;
}
assert( poolStr->pool == this );
assert( poolStr->numUsers >= 1 ); // SRS - Reestablish assertion
assert( poolStr->numUsers >= 1 ); // SRS - Reestablish assertion
poolStr->numUsers--;
if( poolStr->numUsers <= 0 )
{

View file

@ -963,8 +963,8 @@ idMath::ATan
*/
ID_INLINE float idMath::ATan( float y, float x )
{
// SRS - Don't need this assertion since atan2f(y,x) handles x=0, y=0 and x=0, y>0 or y<0 cases properly
// SRS - This assertion can cause game to stop prematurely when _DEBUG is defined and asserts are enabled
// SRS - Don't need this assertion since atan2f(y,x) handles x=0, y=0 and x=0, y>0 or y<0 cases properly
// SRS - This assertion can cause game to stop prematurely when _DEBUG is defined and asserts are enabled
//assert( fabs( y ) > idMath::FLT_SMALLEST_NON_DENORMAL || fabs( x ) > idMath::FLT_SMALLEST_NON_DENORMAL );
return atan2f( y, x );
}

View file

@ -93,9 +93,9 @@ public:
}
cpuid_t cpuid;
virtual ~idSIMDProcessor() {} // SRS - Added virtual destructor
virtual ~idSIMDProcessor() {} // SRS - Added virtual destructor
virtual const char* VPCALL GetName() const = 0;
virtual void VPCALL MinMax( float& min, float& max, const float* src, const int count ) = 0;

View file

@ -88,10 +88,10 @@ const int MAX_EXPRESSION_REGISTERS = 4096;
// to be double buffered to allow it to run in
// parallel on a dual cpu machine
#if defined(__APPLE__) && defined(USE_VULKAN)
// SRS - macOS MoltenVK/Metal needs triple buffering for full screen to work properly
const uint32 NUM_FRAME_DATA = 3;
// SRS - macOS MoltenVK/Metal needs triple buffering for full screen to work properly
const uint32 NUM_FRAME_DATA = 3;
#else
const uint32 NUM_FRAME_DATA = 2;
const uint32 NUM_FRAME_DATA = 2;
#endif
#if defined(USE_VULKAN)

View file

@ -897,62 +897,62 @@ bool idBinaryImage::LoadFromGeneratedFile( idFile* bFile, ID_TIME_T sourceTimeSt
// just the multiplication of dimensions
assert( img.dataSize >= img.width * img.height * BitsForFormat( ( textureFormat_t )fileData.format ) / 8 );
#if defined(__APPLE__) && defined(USE_VULKAN)
int imgfile_dataSize = img.dataSize;
// SRS - Allocate 2x memory to prepare for in-place conversion from FMT_RGB565 to FMT_RGBA8
if( ( textureFormat_t )fileData.format == FMT_RGB565 )
{
img.Alloc( img.dataSize * 2 );
}
else
{
img.Alloc( img.dataSize );
}
int imgfile_dataSize = img.dataSize;
// SRS - Allocate 2x memory to prepare for in-place conversion from FMT_RGB565 to FMT_RGBA8
if( ( textureFormat_t )fileData.format == FMT_RGB565 )
{
img.Alloc( img.dataSize * 2 );
}
else
{
img.Alloc( img.dataSize );
}
if( img.data == NULL )
{
return false;
}
// SRS - Read image data using actual on-disk data size
// SRS - Read image data using actual on-disk data size
if( bFile->Read( img.data, imgfile_dataSize ) <= 0 )
{
return false;
}
// SRS - Convert FMT_RGB565 16-bits to FMT_RGBA8 32-bits in place using pre-allocated space
if( ( textureFormat_t )fileData.format == FMT_RGB565 )
{
//SRS - Make sure we have an integer number of RGBA8 storage slots
assert( img.dataSize % 4 == 0 );
for( int pixelIndex = img.dataSize/2 - 2; pixelIndex >= 0; pixelIndex -= 2 )
{
// SRS - Convert FMT_RGB565 16-bits to FMT_RGBA8 32-bits in place using pre-allocated space
if( ( textureFormat_t )fileData.format == FMT_RGB565 )
{
//SRS - Make sure we have an integer number of RGBA8 storage slots
assert( img.dataSize % 4 == 0 );
for( int pixelIndex = img.dataSize / 2 - 2; pixelIndex >= 0; pixelIndex -= 2 )
{
#if 1
// SRS - Option 1: Scale and shift algorithm
uint16 pixelValue_rgb565 = img.data[pixelIndex + 0] << 8 | img.data[pixelIndex + 1];
img.data[pixelIndex*2 + 0] = ( ( ( pixelValue_rgb565 ) >> 11 ) * 527 + 23 ) >> 6;
img.data[pixelIndex*2 + 1] = ( ( ( pixelValue_rgb565 & 0x07E0 ) >> 5 ) * 259 + 33 ) >> 6;
img.data[pixelIndex*2 + 2] = ( ( ( pixelValue_rgb565 & 0x001F ) ) * 527 + 23 ) >> 6;
// SRS - Option 1: Scale and shift algorithm
uint16 pixelValue_rgb565 = img.data[pixelIndex + 0] << 8 | img.data[pixelIndex + 1];
img.data[pixelIndex * 2 + 0] = ( ( ( pixelValue_rgb565 ) >> 11 ) * 527 + 23 ) >> 6;
img.data[pixelIndex * 2 + 1] = ( ( ( pixelValue_rgb565 & 0x07E0 ) >> 5 ) * 259 + 33 ) >> 6;
img.data[pixelIndex * 2 + 2] = ( ( ( pixelValue_rgb565 & 0x001F ) ) * 527 + 23 ) >> 6;
#else
// SRS - Option 2: Shift and combine algorithm - is this faster?
uint8 pixelValue_rgb565_hi = img.data[pixelIndex + 0];
uint8 pixelValue_rgb565_lo = img.data[pixelIndex + 1];
img.data[pixelIndex*2 + 0] = ( pixelValue_rgb565_hi & 0xF8 ) | ( pixelValue_rgb565_hi >> 5 );
img.data[pixelIndex*2 + 1] = ( pixelValue_rgb565_hi << 5 ) | ( ( pixelValue_rgb565_lo & 0xE0 ) >> 3 ) | ( ( pixelValue_rgb565_hi & 0x07 ) >> 1 );
img.data[pixelIndex*2 + 2] = ( pixelValue_rgb565_lo << 3 ) | ( ( pixelValue_rgb565_lo & 0x1F ) >> 2 );
// SRS - Option 2: Shift and combine algorithm - is this faster?
uint8 pixelValue_rgb565_hi = img.data[pixelIndex + 0];
uint8 pixelValue_rgb565_lo = img.data[pixelIndex + 1];
img.data[pixelIndex * 2 + 0] = ( pixelValue_rgb565_hi & 0xF8 ) | ( pixelValue_rgb565_hi >> 5 );
img.data[pixelIndex * 2 + 1] = ( pixelValue_rgb565_hi << 5 ) | ( ( pixelValue_rgb565_lo & 0xE0 ) >> 3 ) | ( ( pixelValue_rgb565_hi & 0x07 ) >> 1 );
img.data[pixelIndex * 2 + 2] = ( pixelValue_rgb565_lo << 3 ) | ( ( pixelValue_rgb565_lo & 0x1F ) >> 2 );
#endif
img.data[pixelIndex*2 + 3] = 0xFF;
}
}
img.data[pixelIndex * 2 + 3] = 0xFF;
}
}
#else
img.Alloc( img.dataSize );
if( img.data == NULL )
{
return false;
}
img.Alloc( img.dataSize );
if( img.data == NULL )
{
return false;
}
if( bFile->Read( img.data, img.dataSize ) <= 0 )
{
return false;
}
if( bFile->Read( img.data, img.dataSize ) <= 0 )
{
return false;
}
#endif
}

View file

@ -455,9 +455,9 @@ private:
#if defined( USE_VULKAN )
void CreateSampler();
// SRS - added method to set image layout
void SetImageLayout( VkImage image, VkImageSubresourceRange subresourceRange, VkImageLayout oldImageLayout, VkImageLayout newImageLayout );
// SRS End
// SRS - added method to set image layout
void SetImageLayout( VkImage image, VkImageSubresourceRange subresourceRange, VkImageLayout oldImageLayout, VkImageLayout newImageLayout );
// SRS End
bool bIsSwapChainImage;
VkFormat internalFormat;

View file

@ -400,8 +400,8 @@ void idImage::ActuallyLoadImage( bool fromBackEnd )
if( ( fileSystem->InProductionMode() && binaryFileTime != FILE_NOT_FOUND_TIMESTAMP ) || ( ( binaryFileTime != FILE_NOT_FOUND_TIMESTAMP )
&& ( header.colorFormat == opts.colorFormat )
#if defined(__APPLE__) && defined(USE_VULKAN)
// SRS - Handle case when image read is cached and RGB565 format conversion is already done
&& ( header.format == opts.format || ( header.format == FMT_RGB565 && opts.format == FMT_RGBA8 ) )
// SRS - Handle case when image read is cached and RGB565 format conversion is already done
&& ( header.format == opts.format || ( header.format == FMT_RGB565 && opts.format == FMT_RGBA8 ) )
#else
&& ( header.format == opts.format )
#endif
@ -413,16 +413,16 @@ void idImage::ActuallyLoadImage( bool fromBackEnd )
opts.numLevels = header.numLevels;
opts.colorFormat = ( textureColor_t )header.colorFormat;
#if defined(__APPLE__) && defined(USE_VULKAN)
// SRS - Set in-memory format to FMT_RGBA8 for converted FMT_RGB565 image
if( header.format == FMT_RGB565 )
{
opts.format = FMT_RGBA8;
}
else
// SRS - Set in-memory format to FMT_RGBA8 for converted FMT_RGB565 image
if( header.format == FMT_RGB565 )
{
opts.format = FMT_RGBA8;
}
else
#endif
{
opts.format = ( textureFormat_t )header.format;
}
{
opts.format = ( textureFormat_t )header.format;
}
opts.textureType = ( textureType_t )header.textureType;
if( cvarSystem->GetCVarBool( "fs_buildresources" ) )
{
@ -806,27 +806,27 @@ void idImage::GenerateImage( const byte* pic, int width, int height, textureFilt
if( pic == NULL || opts.textureType == TT_2D_MULTISAMPLE )
{
AllocImage();
#if defined(USE_VULKAN)
// SRS - update layout of Ambient Occlusion image otherwise get Vulkan validation layer errors with SSAO enabled
if( imgName == "_ao0" || imgName == "_ao1" )
{
VkImageSubresourceRange subresourceRange;
if( internalFormat == VK_FORMAT_D32_SFLOAT_S8_UINT || opts.format == FMT_DEPTH )
{
subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT;
}
else
{
subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
}
subresourceRange.baseMipLevel = 0;
subresourceRange.levelCount = opts.numLevels;
subresourceRange.baseArrayLayer = 0;
subresourceRange.layerCount = 1;
SetImageLayout( image, subresourceRange, VK_IMAGE_LAYOUT_UNDEFINED, layout );
}
#if defined(USE_VULKAN)
// SRS - update layout of Ambient Occlusion image otherwise get Vulkan validation layer errors with SSAO enabled
if( imgName == "_ao0" || imgName == "_ao1" )
{
VkImageSubresourceRange subresourceRange;
if( internalFormat == VK_FORMAT_D32_SFLOAT_S8_UINT || opts.format == FMT_DEPTH )
{
subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT;
}
else
{
subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
}
subresourceRange.baseMipLevel = 0;
subresourceRange.levelCount = opts.numLevels;
subresourceRange.baseArrayLayer = 0;
subresourceRange.layerCount = 1;
SetImageLayout( image, subresourceRange, VK_IMAGE_LAYOUT_UNDEFINED, layout );
}
#endif
}
else

View file

@ -557,7 +557,7 @@ void idImage::SetTexParameters()
// use a blurring LOD bias in combination with high anisotropy to fix our aliasing grate textures...
glTexParameterf( target, GL_TEXTURE_LOD_BIAS_EXT, /*0.5*/ r_lodBias.GetFloat() );
}
// RB end
// set the wrap/clamp modes

View file

@ -33,14 +33,14 @@ If you have questions concerning this license or the applicable additional terms
// SRS - Include SDL headers to enable vsync changes without restart for UNIX-like OSs
#if defined(__linux__) || defined(__FreeBSD__) || defined(__APPLE__)
// SRS - Don't seem to need these #undefs (at least on macOS), are they needed for Linux, etc?
// DG: SDL.h somehow needs the following functions, so #undef those silly
// "don't use" #defines from Str.h
//#undef strncmp
//#undef strcasecmp
//#undef vsnprintf
// DG end
#include <SDL.h>
// SRS - Don't seem to need these #undefs (at least on macOS), are they needed for Linux, etc?
// DG: SDL.h somehow needs the following functions, so #undef those silly
// "don't use" #defines from Str.h
//#undef strncmp
//#undef strcasecmp
//#undef vsnprintf
// DG end
#include <SDL.h>
#endif
// SRS end
@ -353,10 +353,10 @@ static void R_CheckPortableExtensions()
glConfig.occlusionQueryAvailable = GLEW_ARB_occlusion_query != 0;
#if defined(__APPLE__)
// SRS - DSA not available in Apple OpenGL 4.1, but enable for OSX anyways since elapsed time query will be used to get timing info instead
// SRS - DSA not available in Apple OpenGL 4.1, but enable for OSX anyways since elapsed time query will be used to get timing info instead
glConfig.timerQueryAvailable = ( GLEW_ARB_timer_query != 0 || GLEW_EXT_timer_query != 0 ) && ( glConfig.vendor != VENDOR_INTEL || r_skipIntelWorkarounds.GetBool() ) && glConfig.driverType != GLDRV_OPENGL_MESA;
#else
// GL_ARB_timer_query using the DSA interface
// GL_ARB_timer_query using the DSA interface
glConfig.timerQueryAvailable = ( GLEW_ARB_direct_state_access != 0 && GLEW_ARB_timer_query != 0 );
#endif
@ -1550,23 +1550,27 @@ void idRenderBackend::CheckCVars()
}
}
// SRS - Enable SDL-driven vync changes without restart for UNIX-like OSs
// SRS - Enable SDL-driven vync changes without restart for UNIX-like OSs
#if defined(__linux__) || defined(__FreeBSD__) || defined(__APPLE__)
extern idCVar r_swapInterval;
if( r_swapInterval.IsModified() )
{
r_swapInterval.ClearModified();
extern idCVar r_swapInterval;
if( r_swapInterval.IsModified() )
{
r_swapInterval.ClearModified();
#if SDL_VERSION_ATLEAST(2, 0, 0)
if( SDL_GL_SetSwapInterval( r_swapInterval.GetInteger() ) < 0 )
common->Warning( "Vsync changes not supported without restart" );
if( SDL_GL_SetSwapInterval( r_swapInterval.GetInteger() ) < 0 )
{
common->Warning( "Vsync changes not supported without restart" );
}
#else
if( SDL_GL_SetAttribute( SDL_GL_SWAP_CONTROL, r_swapInterval.GetInteger() ) < 0 )
common->Warning( "Vsync changes not supported without restart" );
if( SDL_GL_SetAttribute( SDL_GL_SWAP_CONTROL, r_swapInterval.GetInteger() ) < 0 )
{
common->Warning( "Vsync changes not supported without restart" );
}
#endif
}
}
#endif
// SRS end
// SRS end
if( r_antiAliasing.IsModified() )
{
switch( r_antiAliasing.GetInteger() )

View file

@ -785,7 +785,7 @@ void idRenderBackend::DBG_ShowTris( drawSurf_t** drawSurfs, int numDrawSurfs )
if( r_showTris.GetInteger() == 3 )
{
GL_State( (glStateBits & ~( GLS_CULL_MASK )) | GLS_CULL_TWOSIDED ); // SRS - Added parens to silence build warnings
GL_State( ( glStateBits & ~( GLS_CULL_MASK ) ) | GLS_CULL_TWOSIDED ); // SRS - Added parens to silence build warnings
}
GL_Color( color );
@ -794,7 +794,7 @@ void idRenderBackend::DBG_ShowTris( drawSurf_t** drawSurfs, int numDrawSurfs )
if( r_showTris.GetInteger() == 3 )
{
GL_State( (glStateBits & ~( GLS_CULL_MASK )) | GLS_CULL_FRONTSIDED ); // SRS - Added parens to silence build warnings
GL_State( ( glStateBits & ~( GLS_CULL_MASK ) ) | GLS_CULL_FRONTSIDED ); // SRS - Added parens to silence build warnings
}
}

View file

@ -128,14 +128,14 @@ void idRenderProgManager::LoadShader( shader_t& shader )
default:
{
//SRS - OSX supports only up to GLSL 4.1
#if defined(__APPLE__)
//SRS - OSX supports only up to GLSL 4.1
#if defined(__APPLE__)
outFileGLSL.Format( "renderprogs/glsl-4_10/%s%s", shader.name.c_str(), shader.nameOutSuffix.c_str() );
outFileUniforms.Format( "renderprogs/glsl-4_10/%s%s", shader.name.c_str(), shader.nameOutSuffix.c_str() );
#else
outFileGLSL.Format( "renderprogs/glsl-4_50/%s%s", shader.name.c_str(), shader.nameOutSuffix.c_str() );
outFileUniforms.Format( "renderprogs/glsl-4_50/%s%s", shader.name.c_str(), shader.nameOutSuffix.c_str() );
#endif
#else
outFileGLSL.Format( "renderprogs/glsl-4_50/%s%s", shader.name.c_str(), shader.nameOutSuffix.c_str() );
outFileUniforms.Format( "renderprogs/glsl-4_50/%s%s", shader.name.c_str(), shader.nameOutSuffix.c_str() );
#endif
}
}

View file

@ -134,7 +134,7 @@ struct gpuInfo_t
struct vulkanContext_t
{
// Eric: If on linux, use this to pass SDL_Window pointer to the SDL_Vulkan_* methods not in sdl_vkimp.cpp file.
// SRS - Add OSX case
// SRS - Add OSX case
#if defined(__linux__) || defined(__APPLE__)
SDL_Window* sdlWindow = nullptr;
#endif

View file

@ -619,18 +619,18 @@ void idRenderLog::OpenMainBlock( renderLogMainBlock_t block )
// SRS - For OSX use elapsed time query for Apple OpenGL 4.1 using GL_TIME_ELAPSED vs GL_TIMESTAMP (which is not implemented on OSX)
#elif defined(__APPLE__)
// SRS - OSX AMD drivers have a rendering bug (flashing colours) with an elasped time query when Shadow Mapping is on - turn off query for that case unless r_skipAMDWorkarounds is set
if( glConfig.timerQueryAvailable && ( !r_useShadowMapping.GetBool() || glConfig.vendor != VENDOR_AMD || r_skipAMDWorkarounds.GetBool() ) )
{
if( glcontext.renderLogMainBlockTimeQueryIds[ glcontext.frameParity ][ mainBlock * 2 + 1 ] == 0 )
{
glGenQueries( 1, &glcontext.renderLogMainBlockTimeQueryIds[ glcontext.frameParity ][ mainBlock * 2 + 1 ] );
}
glBeginQuery( GL_TIME_ELAPSED_EXT, glcontext.renderLogMainBlockTimeQueryIds[ glcontext.frameParity ][ mainBlock * 2 + 1 ] );
}
// SRS - OSX AMD drivers have a rendering bug (flashing colours) with an elasped time query when Shadow Mapping is on - turn off query for that case unless r_skipAMDWorkarounds is set
if( glConfig.timerQueryAvailable && ( !r_useShadowMapping.GetBool() || glConfig.vendor != VENDOR_AMD || r_skipAMDWorkarounds.GetBool() ) )
{
if( glcontext.renderLogMainBlockTimeQueryIds[ glcontext.frameParity ][ mainBlock * 2 + 1 ] == 0 )
{
glGenQueries( 1, &glcontext.renderLogMainBlockTimeQueryIds[ glcontext.frameParity ][ mainBlock * 2 + 1 ] );
}
glBeginQuery( GL_TIME_ELAPSED_EXT, glcontext.renderLogMainBlockTimeQueryIds[ glcontext.frameParity ][ mainBlock * 2 + 1 ] );
}
#else
if( glConfig.timerQueryAvailable )
@ -665,17 +665,17 @@ void idRenderLog::CloseMainBlock()
uint32 queryIndex = vkcontext.queryAssignedIndex[ vkcontext.frameParity ][ mainBlock * 2 + 1 ] = vkcontext.queryIndex[ vkcontext.frameParity ]++;
vkCmdWriteTimestamp( commandBuffer, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, queryPool, queryIndex );
// SRS - For OSX use elapsed time query for Apple OpenGL 4.1 using GL_TIME_ELAPSED vs GL_TIMESTAMP (which is not implemented on OSX)
#elif defined(__APPLE__)
// SRS - OSX AMD drivers have a rendering bug (flashing colours) with an elasped time query when Shadow Mapping is on - turn off query for that case unless r_skipAMDWorkarounds is set
if( glConfig.timerQueryAvailable && ( !r_useShadowMapping.GetBool() || glConfig.vendor != VENDOR_AMD || r_skipAMDWorkarounds.GetBool() ) )
{
glEndQuery( GL_TIME_ELAPSED_EXT );
glcontext.renderLogMainBlockTimeQueryIssued[ glcontext.frameParity ][ mainBlock * 2 + 1 ]++;
}
// SRS - OSX AMD drivers have a rendering bug (flashing colours) with an elasped time query when Shadow Mapping is on - turn off query for that case unless r_skipAMDWorkarounds is set
if( glConfig.timerQueryAvailable && ( !r_useShadowMapping.GetBool() || glConfig.vendor != VENDOR_AMD || r_skipAMDWorkarounds.GetBool() ) )
{
glEndQuery( GL_TIME_ELAPSED_EXT );
glcontext.renderLogMainBlockTimeQueryIssued[ glcontext.frameParity ][ mainBlock * 2 + 1 ]++;
}
#else
if( glConfig.timerQueryAvailable )

View file

@ -793,9 +793,9 @@ const char* fragmentInsert =
{
// SRS - OSX OpenGL only supports up to GLSL 4.1, but current RenderProgs shaders seem to work as-is on OSX OpenGL drivers
#if defined(__APPLE__) && !defined(USE_VULKAN)
"#version 410\n"
"#version 410\n"
#else
"#version 450\n"
"#version 450\n"
#endif
"#pragma shader_stage( fragment )\n"
"#extension GL_ARB_separate_shader_objects : enable\n"
@ -1512,7 +1512,7 @@ idStr idRenderProgManager::ConvertCG2GLSL( const idStr& in, const char* name, rp
idStr filenameHint = "// filename " + idStr( name ) + "\n";
// RB: changed to allow multiple versions of GLSL
if( stage == SHADER_STAGE_VERTEX ) // SRS - Remove extra parens
if( stage == SHADER_STAGE_VERTEX ) // SRS - Remove extra parens
{
switch( glConfig.driverType )
{
@ -1561,7 +1561,7 @@ idStr idRenderProgManager::ConvertCG2GLSL( const idStr& in, const char* name, rp
if( vkGLSL )
{
out += "\n";
if( stage == SHADER_STAGE_VERTEX ) // SRS - Remove extra parens
if( stage == SHADER_STAGE_VERTEX ) // SRS - Remove extra parens
{
out += "layout( binding = 0 ) uniform UBOV {\n";
}

View file

@ -742,15 +742,15 @@ void idRenderSystemLocal::SwapCommandBuffers_FinishRendering(
backend.pc.gpuPostProcessingMicroSec = ( gpuEndNanoseconds - gpuStartNanoseconds ) / 1000;
}
// SRS - For OSX OpenGL calculate total rendering time vs direct measurement due to missing GL_TIMESTAMP support in Apple OpenGL 4.1
#if defined(__APPLE__)
backend.pc.gpuMicroSec = backend.pc.gpuDepthMicroSec + backend.pc.gpuScreenSpaceAmbientOcclusionMicroSec + backend.pc.gpuAmbientPassMicroSec + backend.pc.gpuInteractionsMicroSec + backend.pc.gpuShaderPassMicroSec + backend.pc.gpuPostProcessingMicroSec + commonLocal.GetRendererIdleMicroseconds();
if( gpuMicroSec != NULL )
{
*gpuMicroSec = backend.pc.gpuMicroSec;
}
backend.pc.gpuMicroSec = backend.pc.gpuDepthMicroSec + backend.pc.gpuScreenSpaceAmbientOcclusionMicroSec + backend.pc.gpuAmbientPassMicroSec + backend.pc.gpuInteractionsMicroSec + backend.pc.gpuShaderPassMicroSec + backend.pc.gpuPostProcessingMicroSec + commonLocal.GetRendererIdleMicroseconds();
if( gpuMicroSec != NULL )
{
*gpuMicroSec = backend.pc.gpuMicroSec;
}
#endif
for( int i = 0; i < MRB_TOTAL_QUERIES; i++ )

View file

@ -58,11 +58,11 @@ idCVar r_debugContext( "r_debugContext", "0", CVAR_RENDERER, "Enable various lev
idCVar r_glDriver( "r_glDriver", "", CVAR_RENDERER, "\"opengl32\", etc." );
// SRS - Added workaround for AMD OSX driver bugs caused by GL_EXT_timer_query when shadow mapping enabled; Intel bugs not present on OSX
#if defined(__APPLE__)
idCVar r_skipIntelWorkarounds( "r_skipIntelWorkarounds", "1", CVAR_RENDERER | CVAR_BOOL, "skip workarounds for Intel driver bugs" );
idCVar r_skipAMDWorkarounds( "r_skipAMDWorkarounds", "0", CVAR_RENDERER | CVAR_BOOL, "skip workarounds for AMD driver bugs" );
idCVar r_skipIntelWorkarounds( "r_skipIntelWorkarounds", "1", CVAR_RENDERER | CVAR_BOOL, "skip workarounds for Intel driver bugs" );
idCVar r_skipAMDWorkarounds( "r_skipAMDWorkarounds", "0", CVAR_RENDERER | CVAR_BOOL, "skip workarounds for AMD driver bugs" );
#else
idCVar r_skipIntelWorkarounds( "r_skipIntelWorkarounds", "0", CVAR_RENDERER | CVAR_BOOL, "skip workarounds for Intel driver bugs" );
idCVar r_skipAMDWorkarounds( "r_skipAMDWorkarounds", "1", CVAR_RENDERER | CVAR_BOOL, "skip workarounds for AMD driver bugs" );
idCVar r_skipIntelWorkarounds( "r_skipIntelWorkarounds", "0", CVAR_RENDERER | CVAR_BOOL, "skip workarounds for Intel driver bugs" );
idCVar r_skipAMDWorkarounds( "r_skipAMDWorkarounds", "1", CVAR_RENDERER | CVAR_BOOL, "skip workarounds for AMD driver bugs" );
#endif
// SRS end
// RB: disabled 16x MSAA
@ -2117,9 +2117,9 @@ void idRenderSystemLocal::Shutdown()
R_ShutdownFrameData();
UnbindBufferObjects();
// SRS - wait for fence to hit before freeing any resources the GPU may be using, otherwise get Vulkan validation layer errors on shutdown
backend.GL_BlockingSwapBuffers();
// SRS - wait for fence to hit before freeing any resources the GPU may be using, otherwise get Vulkan validation layer errors on shutdown
backend.GL_BlockingSwapBuffers();
// free the vertex cache, which should have nothing allocated now
vertexCache.Shutdown();

View file

@ -157,10 +157,10 @@ void idVertexCache::Shutdown()
frameData[i].jointBuffer.FreeBufferObject();
}
// SRS - free static buffers to avoid Vulkan validation layer errors on shutdown
staticData.vertexBuffer.FreeBufferObject();
staticData.indexBuffer.FreeBufferObject();
staticData.jointBuffer.FreeBufferObject();
// SRS - free static buffers to avoid Vulkan validation layer errors on shutdown
staticData.vertexBuffer.FreeBufferObject();
staticData.indexBuffer.FreeBufferObject();
staticData.jointBuffer.FreeBufferObject();
}
/*

View file

@ -167,7 +167,7 @@ idVulkanBlock::Init
*/
bool idVulkanBlock::Init()
{
//SRS - Changed UINT64_MAX to UINT32_MAX for type consistency, otherwise test is always false
//SRS - Changed UINT64_MAX to UINT32_MAX for type consistency, otherwise test is always false
if( memoryTypeIndex == UINT32_MAX )
{
return false;
@ -496,7 +496,7 @@ void idVulkanBlock::Print()
idLib::Printf( "Type Index: %u\n", memoryTypeIndex );
idLib::Printf( "Usage: %s\n", memoryUsageStrings[ usage ] );
idLib::Printf( "Count: %d\n", count );
//SRS - Changed %lu to %llu
//SRS - Changed %lu to %llu
idLib::Printf( "Size: %llu\n", size );
idLib::Printf( "Allocated: %llu\n", allocated );
idLib::Printf( "Next Block: %u\n", nextBlockId );
@ -507,8 +507,8 @@ void idVulkanBlock::Print()
idLib::Printf( "{\n" );
idLib::Printf( "\tId: %u\n", current->id );
//SRS - Changed %lu to %llu
idLib::Printf( "\tSize: %llu\n", current->size );
//SRS - Changed %lu to %llu
idLib::Printf( "\tSize: %llu\n", current->size );
idLib::Printf( "\tOffset: %llu\n", current->offset );
idLib::Printf( "\tType: %s\n", allocationTypeStrings[ current->type ] );
@ -682,7 +682,7 @@ void idVulkanAllocator::Print()
{
idLib::Printf( "Device Local MB: %d\n", int( deviceLocalMemoryBytes / 1024 * 1024 ) );
idLib::Printf( "Host Visible MB: %d\n", int( hostVisibleMemoryBytes / 1024 * 1024 ) );
//SRS - Changed %lu to %llu
//SRS - Changed %lu to %llu
idLib::Printf( "Buffer Granularity: %llu\n", bufferImageGranularity );
idLib::Printf( "\n" );
@ -706,7 +706,7 @@ CONSOLE_COMMAND( Vulkan_PrintHeapInfo, "Print out the heap information for this
for( uint32 i = 0; i < props.memoryHeapCount; ++i )
{
VkMemoryHeap heap = props.memoryHeaps[ i ];
//SRS - Changed %lu to %llu
//SRS - Changed %lu to %llu
idLib::Printf( "id=%d, size=%llu, flags=", i, heap.size );
if( heap.flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT )
{

View file

@ -105,14 +105,14 @@ bool idVertexBuffer::AllocBufferObject( const void* data, int allocSize, bufferU
}
else if( usage == BU_DYNAMIC )
{
// SRS - needed to ensure host coherency for MoltenVK on OSX < 10.15.6, otherwise black screen
// SRS - needed to ensure host coherency for MoltenVK on OSX < 10.15.6, otherwise black screen
#if defined(__APPLE__)
vmaReq.usage = VMA_MEMORY_USAGE_UNKNOWN;
vmaReq.requiredFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
vmaReq.usage = VMA_MEMORY_USAGE_UNKNOWN;
vmaReq.requiredFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
#else
vmaReq.usage = VMA_MEMORY_USAGE_CPU_TO_GPU;
#endif
vmaReq.flags = VMA_MEMORY_REQUIREMENT_PERSISTENT_MAP_BIT;
vmaReq.flags = VMA_MEMORY_REQUIREMENT_PERSISTENT_MAP_BIT;
}
ID_VK_CHECK( vmaCreateBuffer( vmaAllocator, &bufferCreateInfo, &vmaReq, &apiObject, &vmaAllocation, &allocation ) );
@ -363,12 +363,12 @@ bool idIndexBuffer::AllocBufferObject( const void* data, int allocSize, bufferUs
}
else if( usage == BU_DYNAMIC )
{
// SRS - needed to ensure host coherency for MoltenVK on OSX < 10.15.6, otherwise black screen
// SRS - needed to ensure host coherency for MoltenVK on OSX < 10.15.6, otherwise black screen
#if defined(__APPLE__)
vmaReq.usage = VMA_MEMORY_USAGE_UNKNOWN;
vmaReq.requiredFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
vmaReq.usage = VMA_MEMORY_USAGE_UNKNOWN;
vmaReq.requiredFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
#else
vmaReq.usage = VMA_MEMORY_USAGE_CPU_TO_GPU;
vmaReq.usage = VMA_MEMORY_USAGE_CPU_TO_GPU;
#endif
vmaReq.flags = VMA_MEMORY_REQUIREMENT_PERSISTENT_MAP_BIT;
}
@ -622,14 +622,14 @@ bool idUniformBuffer::AllocBufferObject( const void* data, int allocSize, buffer
}
else if( usage == BU_DYNAMIC )
{
// SRS - needed to ensure host coherency for MoltenVK on OSX < 10.15.6, otherwise black screen
// SRS - needed to ensure host coherency for MoltenVK on OSX < 10.15.6, otherwise black screen
#if defined(__APPLE__)
vmaReq.usage = VMA_MEMORY_USAGE_UNKNOWN;
vmaReq.requiredFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
vmaReq.usage = VMA_MEMORY_USAGE_UNKNOWN;
vmaReq.requiredFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
#else
vmaReq.usage = VMA_MEMORY_USAGE_CPU_TO_GPU;
vmaReq.usage = VMA_MEMORY_USAGE_CPU_TO_GPU;
#endif
vmaReq.flags = VMA_MEMORY_REQUIREMENT_PERSISTENT_MAP_BIT;
vmaReq.flags = VMA_MEMORY_REQUIREMENT_PERSISTENT_MAP_BIT;
}
ID_VK_CHECK( vmaCreateBuffer( vmaAllocator, &bufferCreateInfo, &vmaReq, &apiObject, &vmaAllocation, &allocation ) );

View file

@ -657,10 +657,10 @@ void idImage::SubImageUpload( int mipLevel, int x, int y, int z, int width, int
{
assert( x >= 0 && y >= 0 && mipLevel >= 0 && width >= 0 && height >= 0 && mipLevel < opts.numLevels );
// SRS - Calculate buffer size without changing original width and height dimensions for compressed images
int bufferW = width;
int bufferH = height;
// SRS - Calculate buffer size without changing original width and height dimensions for compressed images
int bufferW = width;
int bufferH = height;
if( IsCompressed() )
{
bufferW = ( width + 3 ) & ~3;
@ -668,7 +668,7 @@ void idImage::SubImageUpload( int mipLevel, int x, int y, int z, int width, int
}
int size = bufferW * bufferH * BitsForFormat( opts.format ) / 8;
// SRS end
// SRS end
VkBuffer buffer;
VkCommandBuffer commandBuffer;
@ -776,117 +776,117 @@ idImage::SetImageLayout
void idImage::SetImageLayout( VkImage image, VkImageSubresourceRange subresourceRange, VkImageLayout oldImageLayout, VkImageLayout newImageLayout )
{
VkBuffer buffer;
VkCommandBuffer commandBuffer;
int size = 0;
int offset = 0;
byte* data = stagingManager.Stage( size, 16, commandBuffer, buffer, offset );
VkBuffer buffer;
VkCommandBuffer commandBuffer;
int size = 0;
int offset = 0;
byte* data = stagingManager.Stage( size, 16, commandBuffer, buffer, offset );
VkImageMemoryBarrier barrier = {};
barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
barrier.image = image;
barrier.subresourceRange = subresourceRange;
barrier.oldLayout = oldImageLayout;
barrier.newLayout = newImageLayout;
// Source layouts (old)
// Source access mask controls actions that have to be finished on the old layout before it will be transitioned to the new layout
switch ( oldImageLayout )
{
case VK_IMAGE_LAYOUT_UNDEFINED:
// Image layout is undefined (or does not matter)
// Only valid as initial layout
// No flags required, listed only for completeness
barrier.srcAccessMask = 0;
break;
VkImageMemoryBarrier barrier = {};
barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
barrier.image = image;
barrier.subresourceRange = subresourceRange;
barrier.oldLayout = oldImageLayout;
barrier.newLayout = newImageLayout;
case VK_IMAGE_LAYOUT_PREINITIALIZED:
// Image is preinitialized
// Only valid as initial layout for linear images, preserves memory contents
// Make sure host writes have been finished
barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT;
break;
// Source layouts (old)
// Source access mask controls actions that have to be finished on the old layout before it will be transitioned to the new layout
switch( oldImageLayout )
{
case VK_IMAGE_LAYOUT_UNDEFINED:
// Image layout is undefined (or does not matter)
// Only valid as initial layout
// No flags required, listed only for completeness
barrier.srcAccessMask = 0;
break;
case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL:
// Image is a color attachment
// Make sure any writes to the color buffer have been finished
barrier.srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
break;
case VK_IMAGE_LAYOUT_PREINITIALIZED:
// Image is preinitialized
// Only valid as initial layout for linear images, preserves memory contents
// Make sure host writes have been finished
barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT;
break;
case VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL:
// Image is a depth/stencil attachment
// Make sure any writes to the depth/stencil buffer have been finished
barrier.srcAccessMask = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
break;
case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL:
// Image is a color attachment
// Make sure any writes to the color buffer have been finished
barrier.srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
break;
case VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL:
// Image is a transfer source
// Make sure any reads from the image have been finished
barrier.srcAccessMask = VK_ACCESS_TRANSFER_READ_BIT;
break;
case VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL:
// Image is a depth/stencil attachment
// Make sure any writes to the depth/stencil buffer have been finished
barrier.srcAccessMask = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
break;
case VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL:
// Image is a transfer destination
// Make sure any writes to the image have been finished
barrier.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
break;
case VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL:
// Image is a transfer source
// Make sure any reads from the image have been finished
barrier.srcAccessMask = VK_ACCESS_TRANSFER_READ_BIT;
break;
case VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL:
// Image is read by a shader
// Make sure any shader reads from the image have been finished
barrier.srcAccessMask = VK_ACCESS_SHADER_READ_BIT;
break;
default:
// Other source layouts aren't handled (yet)
break;
}
case VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL:
// Image is a transfer destination
// Make sure any writes to the image have been finished
barrier.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
break;
// Target layouts (new)
// Destination access mask controls the dependency for the new image layout
switch ( newImageLayout )
{
case VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL:
// Image will be used as a transfer destination
// Make sure any writes to the image have been finished
barrier.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
break;
case VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL:
// Image is read by a shader
// Make sure any shader reads from the image have been finished
barrier.srcAccessMask = VK_ACCESS_SHADER_READ_BIT;
break;
case VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL:
// Image will be used as a transfer source
// Make sure any reads from the image have been finished
barrier.dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT;
break;
default:
// Other source layouts aren't handled (yet)
break;
}
case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL:
// Image will be used as a color attachment
// Make sure any writes to the color buffer have been finished
barrier.dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
break;
// Target layouts (new)
// Destination access mask controls the dependency for the new image layout
switch( newImageLayout )
{
case VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL:
// Image will be used as a transfer destination
// Make sure any writes to the image have been finished
barrier.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
break;
case VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL:
// Image layout will be used as a depth/stencil attachment
// Make sure any writes to depth/stencil buffer have been finished
barrier.dstAccessMask = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
break;
case VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL:
// Image will be used as a transfer source
// Make sure any reads from the image have been finished
barrier.dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT;
break;
case VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL:
// Image will be read in a shader (sampler, input attachment)
// Make sure any writes to the image have been finished
if ( barrier.srcAccessMask == 0 )
{
barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT | VK_ACCESS_TRANSFER_WRITE_BIT;
}
barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT;
break;
default:
// Other destination layouts aren't handled (yet)
break;
}
case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL:
// Image will be used as a color attachment
// Make sure any writes to the color buffer have been finished
barrier.dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
break;
vkCmdPipelineBarrier( commandBuffer, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT, 0, 0, NULL, 0, NULL, 1, &barrier );
case VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL:
// Image layout will be used as a depth/stencil attachment
// Make sure any writes to depth/stencil buffer have been finished
barrier.dstAccessMask = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
break;
case VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL:
// Image will be read in a shader (sampler, input attachment)
// Make sure any writes to the image have been finished
if( barrier.srcAccessMask == 0 )
{
barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT | VK_ACCESS_TRANSFER_WRITE_BIT;
}
barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT;
break;
default:
// Other destination layouts aren't handled (yet)
break;
}
vkCmdPipelineBarrier( commandBuffer, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT, 0, 0, NULL, 0, NULL, 1, &barrier );
}
// SRS End

View file

@ -76,12 +76,12 @@ static const char* g_instanceExtensions[ g_numInstanceExtensions ] =
// SRS - needed for MoltenVK portability implementation on OSX
#if defined(__APPLE__)
// required for VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME visibility (as of SDK 1.2.170.0)
#include <vulkan/vulkan_beta.h>
#if defined(USE_MoltenVK)
// optionally needed for runtime access to fullImageViewSwizzle (instead of env var MVK_CONFIG_FULL_IMAGE_VIEW_SWIZZLE = 1)
#include <MoltenVK/vk_mvk_moltenvk.h>
#endif
// required for VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME visibility (as of SDK 1.2.170.0)
#include <vulkan/vulkan_beta.h>
#if defined(USE_MoltenVK)
// optionally needed for runtime access to fullImageViewSwizzle (instead of env var MVK_CONFIG_FULL_IMAGE_VIEW_SWIZZLE = 1)
#include <MoltenVK/vk_mvk_moltenvk.h>
#endif
#endif
static const int g_numDebugInstanceExtensions = 1;
@ -95,7 +95,7 @@ static const char* g_validationLayers[ g_numValidationLayers ] =
{
// SRS - use MoltenVK validation layer on macOS when using libMoltenVK in place of libvulkan
#if defined(__APPLE__) && defined(USE_MoltenVK)
"MoltenVK"
"MoltenVK"
#else
"VK_LAYER_KHRONOS_validation"
#endif
@ -303,7 +303,7 @@ static void CreateVulkanInstance()
ValidateValidationLayers();
}
// SRS - Add OSX case
// SRS - Add OSX case
#if defined(__linux__) || defined(__APPLE__)
auto extensions = get_required_extensions( sdlInstanceExtensions, enableLayers );
createInfo.enabledExtensionCount = static_cast<uint32_t>( extensions.size() );
@ -458,7 +458,7 @@ static void CreateSurface()
ID_VK_CHECK( vkCreateWaylandSurfaceKHR( info.inst, &createInfo, NULL, &info.surface ) );
#else
// SRS - Add OSX case
// SRS - Add OSX case
#if defined(__linux__) || defined(__APPLE__)
if( !SDL_Vulkan_CreateSurface( vkcontext.sdlWindow, vkcontext.instance, &vkcontext.surface ) )
{
@ -523,15 +523,15 @@ static void PopulateDeviceExtensions( const idList< VkExtensionProperties >& ext
{
//idLib::Printf( "Checking Vulkan device extension [%s]\n", extensionProps[ i ].extensionName );
// SRS - needed for MoltenVK portability implementation on OSX
// SRS - needed for MoltenVK portability implementation on OSX
#if defined(__APPLE__)
if( idStr::Icmp( extensionProps[ i ].extensionName, VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME ) == 0 )
{
extensions.AddUnique( VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME );
continue;
}
if( idStr::Icmp( extensionProps[ i ].extensionName, VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME ) == 0 )
{
extensions.AddUnique( VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME );
continue;
}
#endif
if( idStr::Icmp( extensionProps[ i ].extensionName, VK_EXT_DEBUG_MARKER_EXTENSION_NAME ) == 0 && enableLayers )
{
extensions.AddUnique( VK_EXT_DEBUG_MARKER_EXTENSION_NAME );
@ -737,16 +737,16 @@ static void CreateLogicalDeviceAndQueues()
devqInfo.Append( qinfo );
}
// SRS - needed for MoltenVK portability implementation on OSX
// SRS - needed for MoltenVK portability implementation on OSX
#if defined(__APPLE__)
VkPhysicalDeviceFeatures2 deviceFeatures2 = {};
VkPhysicalDevicePortabilitySubsetFeaturesKHR portabilityFeatures = {};
VkPhysicalDeviceFeatures2 deviceFeatures2 = {};
VkPhysicalDevicePortabilitySubsetFeaturesKHR portabilityFeatures = {};
deviceFeatures2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
deviceFeatures2.pNext = &portabilityFeatures;
portabilityFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PORTABILITY_SUBSET_FEATURES_KHR;
vkGetPhysicalDeviceFeatures2( vkcontext.physicalDevice, &deviceFeatures2 );
deviceFeatures2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
deviceFeatures2.pNext = &portabilityFeatures;
portabilityFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PORTABILITY_SUBSET_FEATURES_KHR;
vkGetPhysicalDeviceFeatures2( vkcontext.physicalDevice, &deviceFeatures2 );
#else
VkPhysicalDeviceFeatures deviceFeatures = {};
deviceFeatures.textureCompressionBC = VK_TRUE;
@ -760,11 +760,11 @@ static void CreateLogicalDeviceAndQueues()
VkDeviceCreateInfo info = {};
info.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
// SRS - needed for MoltenVK portability implementation on OSX
// SRS - needed for MoltenVK portability implementation on OSX
#if defined(__APPLE__)
info.pNext = &deviceFeatures2;
info.pNext = &deviceFeatures2;
#else
info.pEnabledFeatures = &deviceFeatures;
info.pEnabledFeatures = &deviceFeatures;
#endif
info.queueCreateInfoCount = devqInfo.Num();
info.pQueueCreateInfos = devqInfo.Ptr();
@ -886,7 +886,7 @@ static VkExtent2D ChooseSurfaceExtent( VkSurfaceCapabilitiesKHR& caps )
int width = glConfig.nativeScreenWidth;
int height = glConfig.nativeScreenHeight;
// SRS - Add OSX case
// SRS - Add OSX case
#if defined(__linux__) || defined(__APPLE__)
SDL_Vulkan_GetDrawableSize( vkcontext.sdlWindow, &width, &height );
@ -1154,13 +1154,13 @@ static void CreateRenderTargets()
{
vkcontext.sampleCount = VK_SAMPLE_COUNT_2_BIT;
}
#if defined(__APPLE__)
// SRS - Disable MSAA for OSX since shaderStorageImageMultisample is disabled on MoltenVK for now
if( samples >= 2 )
{
vkcontext.sampleCount = VK_SAMPLE_COUNT_1_BIT;
}
// SRS - Disable MSAA for OSX since shaderStorageImageMultisample is disabled on MoltenVK for now
if( samples >= 2 )
{
vkcontext.sampleCount = VK_SAMPLE_COUNT_1_BIT;
}
#endif
// Select Depth Format
@ -1179,7 +1179,7 @@ static void CreateRenderTargets()
depthOptions.format = FMT_DEPTH;
// Eric: See if this fixes resizing
// SRS - Add OSX case
// SRS - Add OSX case
#if defined(__linux__) || defined(__APPLE__)
gpuInfo_t& gpu = *vkcontext.gpu;
VkExtent2D extent = ChooseSurfaceExtent( gpu.surfaceCaps );
@ -1300,7 +1300,7 @@ static void CreateRenderPass()
depthAttachment.storeOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
// RB
// SRS - reenable, otherwise get Vulkan validation layer warnings
// SRS - reenable, otherwise get Vulkan validation layer warnings
depthAttachment.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
depthAttachment.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
@ -1507,7 +1507,7 @@ void idRenderBackend::Init()
// DG: make sure SDL has setup video so getting supported modes in R_SetNewMode() works
// SRS - Add OSX case
// SRS - Add OSX case
#if ( defined(__linux__) || defined(__APPLE__) ) && defined(USE_VULKAN)
VKimp_PreInit();
#else
@ -1529,14 +1529,14 @@ void idRenderBackend::Init()
idLib::Printf( "Creating Vulkan Instance...\n" );
CreateVulkanInstance();
// SRS - On macOS optionally set fullImageViewSwizzle to TRUE (instead of env var MVK_CONFIG_FULL_IMAGE_VIEW_SWIZZLE = 1)
// SRS - On macOS optionally set fullImageViewSwizzle to TRUE (instead of env var MVK_CONFIG_FULL_IMAGE_VIEW_SWIZZLE = 1)
#if defined(__APPLE__) && defined(USE_MoltenVK)
MVKConfiguration pConfig;
size_t pConfigSize = sizeof( pConfig );
vkGetMoltenVKConfigurationMVK( vkcontext.instance, &pConfig, &pConfigSize );
pConfig.fullImageViewSwizzle = VK_TRUE;
vkSetMoltenVKConfigurationMVK( vkcontext.instance, &pConfig, &pConfigSize );
MVKConfiguration pConfig;
size_t pConfigSize = sizeof( pConfig );
vkGetMoltenVKConfigurationMVK( vkcontext.instance, &pConfig, &pConfigSize );
pConfig.fullImageViewSwizzle = VK_TRUE;
vkSetMoltenVKConfigurationMVK( vkcontext.instance, &pConfig, &pConfigSize );
#endif
// create the windowing interface
@ -1703,7 +1703,7 @@ void idRenderBackend::Shutdown()
ClearContext();
// destroy main window
// SRS - Add OSX case
// SRS - Add OSX case
#if ( defined(__linux__) || defined(__APPLE__) ) && defined(USE_VULKAN)
VKimp_Shutdown();
#else

View file

@ -146,9 +146,9 @@ idVulkanStagingManager::Shutdown
*/
void idVulkanStagingManager::Shutdown()
{
// SRS - use vkFreeMemory (with implicit unmap) vs. vkUnmapMemory to avoid validation layer errors on shutdown
// SRS - use vkFreeMemory (with implicit unmap) vs. vkUnmapMemory to avoid validation layer errors on shutdown
//vkUnmapMemory( vkcontext.device, memory );
vkFreeMemory( vkcontext.device, memory, NULL );
vkFreeMemory( vkcontext.device, memory, NULL );
memory = VK_NULL_HANDLE;
mappedData = NULL;
@ -163,9 +163,9 @@ void idVulkanStagingManager::Shutdown()
maxBufferSize = 0;
currentBuffer = 0;
// SRS - destroy command pool to avoid validation layer errors on shutdown
vkDestroyCommandPool( vkcontext.device, commandPool, NULL );
commandPool = VK_NULL_HANDLE;
// SRS - destroy command pool to avoid validation layer errors on shutdown
vkDestroyCommandPool( vkcontext.device, commandPool, NULL );
commandPool = VK_NULL_HANDLE;
}
/*

View file

@ -776,20 +776,22 @@ remove them if not needed.
// For C++17 aligned_alloc is available with the 10.15 SDK already.
void* aligned_alloc( size_t alignment, size_t size )
{
// alignment must be >= sizeof(void*)
if(alignment < sizeof(void*))
{
alignment = sizeof(void*);
}
void *pointer;
if(posix_memalign(&pointer, alignment, size) == 0)
return pointer;
return NULL;
// alignment must be >= sizeof(void*)
if( alignment < sizeof( void* ) )
{
alignment = sizeof( void* );
}
void* pointer;
if( posix_memalign( &pointer, alignment, size ) == 0 )
{
return pointer;
}
return NULL;
}
#endif
#elif !defined(_WIN32)
#include <malloc.h> // for aligned_alloc()
#include <malloc.h> // for aligned_alloc()
#endif
// Normal assert to check for programmer's errors, especially in Debug configuration.
@ -3488,7 +3490,7 @@ void VmaBlock::PrintDetailedMap( class VmaStringBuilder& sb ) const
sb.Add( ",\n\t\t\t\"FreeBytes\": " );
sb.AddNumber( m_SumFreeSize );
sb.Add( ",\n\t\t\t\"Suballocations\": " );
//SRS - cast to uint32_t to avoid type ambiguity
//SRS - cast to uint32_t to avoid type ambiguity
sb.AddNumber( ( uint32_t )m_Suballocations.size() );
sb.Add( ",\n\t\t\t\"FreeSuballocations\": " );
sb.AddNumber( m_FreeCount );
@ -4954,7 +4956,7 @@ void VmaAllocator_T::PrintDetailedMap( VmaStringBuilder& sb )
sb.Add( ",\n\"OwnAllocations\": {\n\t\"Type " );
ownAllocationsStarted = true;
}
//SRS - cast to uint32_t to avoid type ambiguity, memTypeIndex is an unsigned int
//SRS - cast to uint32_t to avoid type ambiguity, memTypeIndex is an unsigned int
sb.AddNumber( ( uint32_t )memTypeIndex );
if( blockVectorType == VMA_BLOCK_VECTOR_TYPE_MAPPED )
{
@ -5006,7 +5008,7 @@ void VmaAllocator_T::PrintDetailedMap( VmaStringBuilder& sb )
sb.Add( ",\n\"Allocations\": {\n\t\"Type " );
allocationsStarted = true;
}
//SRS - cast to uint32_t to avoid type ambiguity, memTypeIndex is an unsigned int
//SRS - cast to uint32_t to avoid type ambiguity, memTypeIndex is an unsigned int
sb.AddNumber( ( uint32_t )memTypeIndex );
if( blockVectorType == VMA_BLOCK_VECTOR_TYPE_MAPPED )
{

View file

@ -435,20 +435,20 @@ const char* Sys_DefaultBasePath()
{
common->Printf( "no '%s' directory in exe path %s, skipping\n", BASE_GAMEDIR, basepath.c_str() );
}
#if defined(__APPLE__) // SRS - - Added check for MacOS app bundle resources path
basepath += "/../Resources";
testbase = basepath;
testbase += "/";
testbase += BASE_GAMEDIR;
if( stat( testbase.c_str(), &st ) != -1 && S_ISDIR( st.st_mode ) )
{
return basepath.c_str();
}
else
{
common->Printf( "no '%s' directory in MacOS app bundle resources path %s, skipping\n", BASE_GAMEDIR, basepath.c_str() );
}
#endif
#if defined(__APPLE__) // SRS - - Added check for MacOS app bundle resources path
basepath += "/../Resources";
testbase = basepath;
testbase += "/";
testbase += BASE_GAMEDIR;
if( stat( testbase.c_str(), &st ) != -1 && S_ISDIR( st.st_mode ) )
{
return basepath.c_str();
}
else
{
common->Printf( "no '%s' directory in MacOS app bundle resources path %s, skipping\n", BASE_GAMEDIR, basepath.c_str() );
}
#endif
}
if( basepath != Posix_Cwd() )
{

View file

@ -43,7 +43,7 @@ If you have questions concerning this license or the applicable additional terms
#include <vulkan/vulkan.h>
// SRS - optinally needed for VK_MVK_MOLTENVK_EXTENSION_NAME visibility
#if defined(__APPLE__) && defined(USE_MoltenVK)
#include <MoltenVK/vk_mvk_moltenvk.h>
#include <MoltenVK/vk_mvk_moltenvk.h>
#endif
#include <vector>
@ -94,14 +94,14 @@ std::vector<const char*> get_required_extensions( const std::vector<const char*>
}
}
// SRS - needed for MoltenVK portability implementation and optionally for MoltenVK configuration on OSX
// SRS - needed for MoltenVK portability implementation and optionally for MoltenVK configuration on OSX
#if defined(__APPLE__)
sdlInstanceExtensions.push_back( VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME );
sdlInstanceExtensions.push_back( VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME );
#if defined(USE_MoltenVK)
sdlInstanceExtensions.push_back( VK_MVK_MOLTENVK_EXTENSION_NAME );
sdlInstanceExtensions.push_back( VK_MVK_MOLTENVK_EXTENSION_NAME );
#endif
#endif
if( enableValidationLayers )
{
sdlInstanceExtensions.push_back( "VK_EXT_debug_report" );
@ -317,11 +317,11 @@ bool VKimp_Init( glimpParms_t parms )
common->Printf( "No usable VK mode found: %s", SDL_GetError() );
return false;
}
/* SRS - This must be leftover code from OpenGL, disable it
#ifdef __APPLE__
glewExperimental = GL_TRUE;
#endif
*/
/* SRS - This must be leftover code from OpenGL, disable it
#ifdef __APPLE__
glewExperimental = GL_TRUE;
#endif
*/
// DG: disable cursor, we have two cursors in menu (because mouse isn't grabbed in menu)
SDL_ShowCursor( SDL_DISABLE );
// DG end

View file

@ -947,8 +947,8 @@ idSessionCallbacks
class idSessionCallbacks
{
public:
virtual ~idSessionCallbacks() {} // SRS - Added virtual destructor
virtual ~idSessionCallbacks() {} // SRS - Added virtual destructor
virtual idLobby& GetPartyLobby() = 0;
virtual idLobby& GetGameLobby() = 0;
virtual idLobby& GetActingGameStateLobby() = 0;

View file

@ -236,8 +236,8 @@ public:
idLobbyBackend() : type( TYPE_INVALID ), isLocal( false ), isHost( false ) {}
idLobbyBackend( lobbyBackendType_t lobbyType ) : type( lobbyType ), isLocal( false ), isHost( false ) {}
virtual ~idLobbyBackend() {} // SRS - Added virtual destructor
virtual ~idLobbyBackend() {} // SRS - Added virtual destructor
virtual void StartHosting( const idMatchParameters& p, float skillLevel, lobbyBackendType_t type ) = 0;
virtual void StartFinding( const idMatchParameters& p, int numPartyUsers, float skillLevel ) = 0;
virtual void JoinFromConnectInfo( const lobbyConnectInfo_t& connectInfo ) = 0;

View file

@ -356,7 +356,7 @@ saveGameHandle_t idSessionLocal::LoadGameSync( const char* name, saveFileEntryLi
{
idSaveLoadParms& parms = processorLoadFiles->GetParmsNonConst();
saveGameHandle_t handle = 0;
bool checkDetailsFile = true;
bool checkDetailsFile = true;
{
// Put in a local block so everything will go in the global heap before the map change, but the heap is
@ -415,28 +415,28 @@ saveGameHandle_t idSessionLocal::LoadGameSync( const char* name, saveFileEntryLi
parms.errorCode = SAVEGAME_E_UNKNOWN;
}
// SRS - check details file for compatibility before removing it from parms.files list
if( parms.GetError() == SAVEGAME_E_NONE )
// SRS - check details file for compatibility before removing it from parms.files list
if( parms.GetError() == SAVEGAME_E_NONE )
{
// Checks the details file to see if corrupted or if it's from a newer savegame
checkDetailsFile = LoadGameCheckDescriptionFile( parms );
}
// tomgreen66 - remove details file we added via auto_ptr to parms.files in InitLoadFiles above
for ( int i = 0; i < parms.files.Num(); ++i )
{
if ( parms.files[i] == gameDetailsFile.get() )
{
// details file reference will be deleted by auto_ptr so remove it from list and update file count
parms.files.RemoveIndexFast( i );
}
}
// SRS - return if savegame error or description file corrupt or not compatible
if( parms.GetError() != SAVEGAME_E_NONE || !checkDetailsFile )
{
return 0;
}
// Checks the details file to see if corrupted or if it's from a newer savegame
checkDetailsFile = LoadGameCheckDescriptionFile( parms );
}
// tomgreen66 - remove details file we added via auto_ptr to parms.files in InitLoadFiles above
for( int i = 0; i < parms.files.Num(); ++i )
{
if( parms.files[i] == gameDetailsFile.get() )
{
// details file reference will be deleted by auto_ptr so remove it from list and update file count
parms.files.RemoveIndexFast( i );
}
}
// SRS - return if savegame error or description file corrupt or not compatible
if( parms.GetError() != SAVEGAME_E_NONE || !checkDetailsFile )
{
return 0;
}
// Checks to see if loaded map is from a DLC map and if that DLC is active
if( !IsDLCAvailable( parms.description.GetMapName() ) )

View file

@ -39,9 +39,9 @@ class idVoiceChatMgr
{
public:
idVoiceChatMgr() : activeLobbyType( -1 ), activeGroupIndex( 0 ), sendFrame( 0 ), disableVoiceReasons( 0 ), sendGlobal( false ) {}
virtual ~idVoiceChatMgr() {} // SRS - Added virtual destructor
virtual ~idVoiceChatMgr() {} // SRS - Added virtual destructor
virtual void Init( void* pXAudio2 );
virtual void Shutdown();