From 34332dbeebe04b933e0cf26764356dc5048dfac2 Mon Sep 17 00:00:00 2001 From: Stephen Saunders Date: Tue, 23 May 2023 08:48:56 -0400 Subject: [PATCH 01/71] Implement m_frameLatencyWaitableObject sync for reduced DX12 frame latency --- neo/sys/DeviceManager_DX12.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/neo/sys/DeviceManager_DX12.cpp b/neo/sys/DeviceManager_DX12.cpp index f6c228f8da..34d137023f 100644 --- a/neo/sys/DeviceManager_DX12.cpp +++ b/neo/sys/DeviceManager_DX12.cpp @@ -47,6 +47,7 @@ using nvrhi::RefCountPtr; #define HR_RETURN(hr) if(FAILED(hr)) return false idCVar r_graphicsAdapter( "r_graphicsAdapter", "", CVAR_RENDERER | CVAR_INIT | CVAR_ARCHIVE, "Substring in the name the DXGI graphics adapter to select a certain GPU" ); +idCVar r_dx12FrameLatency( "r_dx12FrameLatency", "0", CVAR_INTEGER | CVAR_RENDERER | CVAR_INIT, "DX12 maximum frame latency using DXGI swap chain waitable object" ); class DeviceManager_DX12 : public DeviceManager { @@ -58,6 +59,7 @@ class DeviceManager_DX12 : public DeviceManager DXGI_SWAP_CHAIN_DESC1 m_SwapChainDesc{}; DXGI_SWAP_CHAIN_FULLSCREEN_DESC m_FullScreenDesc{}; RefCountPtr m_DxgiAdapter; + HANDLE m_frameLatencyWaitableObject = nullptr; bool m_TearingSupported = false; std::vector> m_SwapChainBuffers; @@ -310,7 +312,8 @@ bool DeviceManager_DX12::CreateDeviceAndSwapChain() m_SwapChainDesc.BufferUsage = m_DeviceParams.swapChainUsage; m_SwapChainDesc.BufferCount = m_DeviceParams.swapChainBufferCount; m_SwapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD; - m_SwapChainDesc.Flags = m_DeviceParams.allowModeSwitch ? DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH : 0; + m_SwapChainDesc.Flags = ( m_DeviceParams.allowModeSwitch ? DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH : 0 ) | + ( r_dx12FrameLatency.GetInteger() > 0 ? DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT : 0 ); // Special processing for sRGB swap chain formats. // DXGI will not create a swap chain with an sRGB format, but its contents will be interpreted as sRGB. @@ -429,6 +432,14 @@ bool DeviceManager_DX12::CreateDeviceAndSwapChain() hr = pSwapChain1->QueryInterface( IID_PPV_ARGS( &m_SwapChain ) ); HR_RETURN( hr ); + if( r_dx12FrameLatency.GetInteger() > 0 ) + { + hr = m_SwapChain->SetMaximumFrameLatency( r_dx12FrameLatency.GetInteger() ); + HR_RETURN( hr ); + + m_frameLatencyWaitableObject = m_SwapChain->GetFrameLatencyWaitableObject(); + } + nvrhi::d3d12::DeviceDesc deviceDesc; deviceDesc.errorCB = &DefaultMessageCallback::GetInstance(); deviceDesc.pDevice = m_Device12; @@ -616,6 +627,14 @@ void DeviceManager_DX12::Present() // 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 ); + if( m_frameLatencyWaitableObject ) + { + OPTICK_CATEGORY("DX12_Sync1", Optick::Category::Wait); + + // SRS - When m_frameLatencyWaitableObject active, sync first on earlier present + DWORD result = WaitForSingleObjectEx( m_frameLatencyWaitableObject, INFINITE, true ); + } + if constexpr( NUM_FRAME_DATA > 2 ) { OPTICK_CATEGORY( "DX12_Sync3", Optick::Category::Wait ); From 85e980421af857c2f67a8d0e403313d80a42a327 Mon Sep 17 00:00:00 2001 From: Stephen Saunders Date: Sat, 27 May 2023 01:40:40 -0400 Subject: [PATCH 02/71] Change r_maxFrameLatency cvar name and set to default value of 2 frames --- neo/sys/DeviceManager_DX12.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/neo/sys/DeviceManager_DX12.cpp b/neo/sys/DeviceManager_DX12.cpp index 34d137023f..021c713160 100644 --- a/neo/sys/DeviceManager_DX12.cpp +++ b/neo/sys/DeviceManager_DX12.cpp @@ -47,7 +47,7 @@ using nvrhi::RefCountPtr; #define HR_RETURN(hr) if(FAILED(hr)) return false idCVar r_graphicsAdapter( "r_graphicsAdapter", "", CVAR_RENDERER | CVAR_INIT | CVAR_ARCHIVE, "Substring in the name the DXGI graphics adapter to select a certain GPU" ); -idCVar r_dx12FrameLatency( "r_dx12FrameLatency", "0", CVAR_INTEGER | CVAR_RENDERER | CVAR_INIT, "DX12 maximum frame latency using DXGI swap chain waitable object" ); +idCVar r_maxFrameLatency( "r_maxFrameLatency", "2", CVAR_RENDERER | CVAR_INIT | CVAR_ARCHIVE | CVAR_INTEGER, "Maximum frame latency for DXGI swap chains (DX12 only)", 0, 3 ); class DeviceManager_DX12 : public DeviceManager { @@ -59,7 +59,7 @@ class DeviceManager_DX12 : public DeviceManager DXGI_SWAP_CHAIN_DESC1 m_SwapChainDesc{}; DXGI_SWAP_CHAIN_FULLSCREEN_DESC m_FullScreenDesc{}; RefCountPtr m_DxgiAdapter; - HANDLE m_frameLatencyWaitableObject = nullptr; + HANDLE m_frameLatencyWaitableObject = NULL; bool m_TearingSupported = false; std::vector> m_SwapChainBuffers; @@ -313,7 +313,7 @@ bool DeviceManager_DX12::CreateDeviceAndSwapChain() m_SwapChainDesc.BufferCount = m_DeviceParams.swapChainBufferCount; m_SwapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD; m_SwapChainDesc.Flags = ( m_DeviceParams.allowModeSwitch ? DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH : 0 ) | - ( r_dx12FrameLatency.GetInteger() > 0 ? DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT : 0 ); + ( r_maxFrameLatency.GetInteger() > 0 ? DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT : 0 ); // Special processing for sRGB swap chain formats. // DXGI will not create a swap chain with an sRGB format, but its contents will be interpreted as sRGB. @@ -432,9 +432,9 @@ bool DeviceManager_DX12::CreateDeviceAndSwapChain() hr = pSwapChain1->QueryInterface( IID_PPV_ARGS( &m_SwapChain ) ); HR_RETURN( hr ); - if( r_dx12FrameLatency.GetInteger() > 0 ) + if( r_maxFrameLatency.GetInteger() > 0 ) { - hr = m_SwapChain->SetMaximumFrameLatency( r_dx12FrameLatency.GetInteger() ); + hr = m_SwapChain->SetMaximumFrameLatency( r_maxFrameLatency.GetInteger() ); HR_RETURN( hr ); m_frameLatencyWaitableObject = m_SwapChain->GetFrameLatencyWaitableObject(); @@ -479,6 +479,12 @@ void DeviceManager_DX12::DestroyDeviceAndSwapChain() m_FrameWaitQuery = nullptr; + if( m_frameLatencyWaitableObject ) + { + CloseHandle( m_frameLatencyWaitableObject ); + m_frameLatencyWaitableObject = NULL; + } + if( m_SwapChain ) { m_SwapChain->SetFullscreenState( false, nullptr ); @@ -629,10 +635,11 @@ void DeviceManager_DX12::Present() if( m_frameLatencyWaitableObject ) { - OPTICK_CATEGORY("DX12_Sync1", Optick::Category::Wait); + OPTICK_CATEGORY( "DX12_Sync1", Optick::Category::Wait ); // SRS - When m_frameLatencyWaitableObject active, sync first on earlier present DWORD result = WaitForSingleObjectEx( m_frameLatencyWaitableObject, INFINITE, true ); + assert( result == WAIT_OBJECT_0 ); } if constexpr( NUM_FRAME_DATA > 2 ) From 89ad088ef36c53dac1f1f5c61342e65a577d166d Mon Sep 17 00:00:00 2001 From: Stephen Saunders Date: Thu, 1 Jun 2023 01:01:53 -0400 Subject: [PATCH 03/71] Set r_maxFrameLatency max value constraint to NUM_FRAME_DATA --- neo/sys/DeviceManager_DX12.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neo/sys/DeviceManager_DX12.cpp b/neo/sys/DeviceManager_DX12.cpp index 021c713160..fd558b166c 100644 --- a/neo/sys/DeviceManager_DX12.cpp +++ b/neo/sys/DeviceManager_DX12.cpp @@ -47,7 +47,7 @@ using nvrhi::RefCountPtr; #define HR_RETURN(hr) if(FAILED(hr)) return false idCVar r_graphicsAdapter( "r_graphicsAdapter", "", CVAR_RENDERER | CVAR_INIT | CVAR_ARCHIVE, "Substring in the name the DXGI graphics adapter to select a certain GPU" ); -idCVar r_maxFrameLatency( "r_maxFrameLatency", "2", CVAR_RENDERER | CVAR_INIT | CVAR_ARCHIVE | CVAR_INTEGER, "Maximum frame latency for DXGI swap chains (DX12 only)", 0, 3 ); +idCVar r_maxFrameLatency( "r_maxFrameLatency", "2", CVAR_RENDERER | CVAR_INIT | CVAR_ARCHIVE | CVAR_INTEGER, "Maximum frame latency for DXGI swap chains (DX12 only)", 0, NUM_FRAME_DATA ); class DeviceManager_DX12 : public DeviceManager { From f7751f64282b40a7d4c5f37a2360bd87323ee286 Mon Sep 17 00:00:00 2001 From: Stephen Saunders Date: Wed, 1 Nov 2023 19:13:47 -0400 Subject: [PATCH 04/71] Fix for cinematic audio when playing Bink video files with ffmpeg decoder, improve ffmpeg a/v resync --- neo/renderer/Cinematic.cpp | 81 ++++++++++++++++++++++---------------- 1 file changed, 47 insertions(+), 34 deletions(-) diff --git a/neo/renderer/Cinematic.cpp b/neo/renderer/Cinematic.cpp index 891d739ea3..3d7a5baf24 100644 --- a/neo/renderer/Cinematic.cpp +++ b/neo/renderer/Cinematic.cpp @@ -130,9 +130,8 @@ class idCinematicLocal : public idCinematic cinData_t ImageForTimeFFMPEG( int milliseconds, nvrhi::ICommandList* commandList ); bool InitFromFFMPEGFile( const char* qpath, bool looping, nvrhi::ICommandList* commandList ); void FFMPEGReset(); - uint8_t* lagBuffer[NUM_LAG_FRAMES] = {}; - int lagBufSize[NUM_LAG_FRAMES] = {}; - int lagIndex; + std::queue lagBuffer; + std::queue lagBufSize; bool skipLag; #endif #ifdef USE_BINKDEC @@ -469,7 +468,6 @@ idCinematicLocal::idCinematicLocal() img_convert_ctx = NULL; hasFrame = false; framePos = -1; - lagIndex = 0; skipLag = false; #endif @@ -842,14 +840,11 @@ void idCinematicLocal::FFMPEGReset() { cinematicAudio->ResetAudio(); - lagIndex = 0; - for( int i = 0; i < NUM_LAG_FRAMES; i++ ) + while( !lagBuffer.empty() ) { - lagBufSize[ i ] = 0; - if( lagBuffer[ i ] ) - { - av_freep( &lagBuffer[ i ] ); - } + av_freep( &lagBuffer.front() ); + lagBuffer.pop(); + lagBufSize.pop(); } } @@ -910,7 +905,7 @@ bool idCinematicLocal::InitFromBinkDecFile( const char* qpath, bool amilooping, } else { - common->Warning( "idCinematic: Cannot open BinkDec video file: '%s', %d\n", qpath, looping ); + common->Warning( "idCinematic: Cannot open Bink video file: '%s', %d\n", qpath, looping ); return false; } } @@ -918,7 +913,7 @@ bool idCinematicLocal::InitFromBinkDecFile( const char* qpath, bool amilooping, binkHandle = Bink_Open( fullpath ); if( !binkHandle.isValid ) { - common->Warning( "idCinematic: Cannot open BinkDec video file: '%s', %d\n", qpath, looping ); + common->Warning( "idCinematic: Cannot open Bink video file: '%s', %d\n", qpath, looping ); return false; } @@ -948,7 +943,7 @@ bool idCinematicLocal::InitFromBinkDecFile( const char* qpath, bool amilooping, numFrames = Bink_GetNumFrames( binkHandle ); float durationSec = numFrames / frameRate; // SRS - fixed Bink durationSec calculation animationLength = durationSec * 1000; // SRS - animationLength is in milliseconds - common->Printf( "Loaded BinkDec file: '%s', looping=%d, %dx%d, %3.2f FPS, %4.1f sec\n", qpath, looping, CIN_WIDTH, CIN_HEIGHT, frameRate, durationSec ); + common->Printf( "Loaded Bink file: '%s', looping=%d, %dx%d, %3.2f FPS, %4.1f sec\n", qpath, looping, CIN_WIDTH, CIN_HEIGHT, frameRate, durationSec ); memset( yuvBuffer, 0, sizeof( yuvBuffer ) ); @@ -1174,14 +1169,11 @@ void idCinematicLocal::Close() swr_free( &swr_ctx ); } - lagIndex = 0; - for( int i = 0; i < NUM_LAG_FRAMES; i++ ) + while( !lagBuffer.empty() ) { - lagBufSize[ i ] = 0; - if( lagBuffer[ i ] ) - { - av_freep( &lagBuffer[ i ] ); - } + av_freep( &lagBuffer.front() ); + lagBuffer.pop(); + lagBufSize.pop(); } } @@ -1378,6 +1370,7 @@ cinData_t idCinematicLocal::ImageForTimeFFMPEG( int thisTime, nvrhi::ICommandLis char error[64]; uint8_t* audioBuffer = NULL; int num_bytes = 0; + bool syncLost = false; memset( &cinData, 0, sizeof( cinData ) ); if( !fmt_ctx ) @@ -1491,8 +1484,8 @@ cinData_t idCinematicLocal::ImageForTimeFFMPEG( int thisTime, nvrhi::ICommandLis common->Warning( "idCinematic: Failed to receive audio frame from decoding with error: %s\n", error ); } } - // SRS - For the final (desired) frame only: allocate audio buffers, convert to packed format, and play the synced audio frames - else if( framePos + 1 == desiredFrame ) + // SRS - Allocate audio buffer, convert to packed format, save in queue, and play synced audio for desired frame + else { // SRS - Since destination sample format is packed (non-planar), returned bufflinesize equals num_bytes #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(59,37,100) @@ -1521,28 +1514,48 @@ cinData_t idCinematicLocal::ImageForTimeFFMPEG( int thisTime, nvrhi::ICommandLis memcpy( audioBuffer, frame3->extended_data[0], num_bytes ); } } - // SRS - If we have cinematic audio data, play a lagged frame (for bik video sync) and save the current frame + + // SRS - If we have cinematic audio data, save the current frame onto the back of the queue if( num_bytes > 0 ) { - // SRS - If we have a lagged cinematic audio frame, then play it now - if( lagBufSize[ lagIndex ] > 0 ) + // SRS - If queue is at max size we have lost a/v sync: drop frame and set syncLost flag + if( lagBuffer.size() == ( skipLag ? 1 : NUM_LAG_FRAMES ) ) { - // SRS - Note that PlayAudio() is responsible for releasing any audio buffers sent to it - cinematicAudio->PlayAudio( lagBuffer[ lagIndex ], lagBufSize[ lagIndex ] ); - } + av_freep( &lagBuffer.front() ); + lagBuffer.pop(); + lagBufSize.pop(); - // SRS - Save the current (new) audio buffer and its size to play in the future - lagBuffer[ lagIndex ] = audioBuffer; - lagBufSize[ lagIndex ] = num_bytes; + syncLost = true; + } - // SRS - If skipLag is true (e.g. RoQ, mp4, webm), reduce lag to 1 frame since AV playback is already synced - lagIndex = ( lagIndex + 1 ) % ( skipLag ? 1 : NUM_LAG_FRAMES ); + // SRS - Save the current (new) audio buffer and its size to play during the desired frame + lagBuffer.push( audioBuffer ); + lagBufSize.push( num_bytes ); } // SRS - Not sure if an audioBuffer can ever be allocated on failure, but check and free just in case else if( audioBuffer ) { av_freep( &audioBuffer ); } + + // SRS - If we have any synced audio frames available for the desired frame, play now and drain queue + if( framePos + 1 == desiredFrame ) + { + if( syncLost ) + { + // SRS - If we have lost sync, reset / resync audio stream before starting to play again + cinematicAudio->ResetAudio(); + syncLost = false; + } + + while( !lagBuffer.empty() ) + { + // SRS - Note that PlayAudio() is responsible for releasing any audio buffers sent to it + cinematicAudio->PlayAudio( lagBuffer.front(), lagBufSize.front() ); + lagBuffer.pop(); + lagBufSize.pop(); + } + } //common->Printf( "idCinematic: video pts = %7.3f, audio pts = %7.3f, samples = %4d, num_bytes = %5d\n", static_cast( frame->pts ) * av_q2d( dec_ctx->pkt_timebase ), static_cast( frame3->pts ) * av_q2d( dec_ctx2->pkt_timebase ), frame3->nb_samples, num_bytes ); } } From 19fab395eb96d7ea3a8e8a3d0006a75a669f816e Mon Sep 17 00:00:00 2001 From: Stephen Saunders Date: Thu, 2 Nov 2023 00:47:52 -0400 Subject: [PATCH 05/71] Add #include for std::queue support when USE_FFMPEG enabled --- neo/renderer/Cinematic.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/neo/renderer/Cinematic.cpp b/neo/renderer/Cinematic.cpp index 3d7a5baf24..dabeadd2f9 100644 --- a/neo/renderer/Cinematic.cpp +++ b/neo/renderer/Cinematic.cpp @@ -71,6 +71,7 @@ extern "C" #include #include } +#include #define NUM_LAG_FRAMES 15 // SRS - Lag audio by 15 frames (~1/2 sec at 30 fps) for ffmpeg bik decoder AV sync #endif From fc87f604409cfe5a8d17bf16cbdccc083724bfec Mon Sep 17 00:00:00 2001 From: SRSaunders <82544213+SRSaunders@users.noreply.github.com> Date: Wed, 28 Feb 2024 11:59:41 -0500 Subject: [PATCH 06/71] Complete Optick instrumentation and align with HUD GPU timers --- neo/framework/Common_local.h | 45 +++++ neo/framework/Console.cpp | 14 +- neo/renderer/NVRHI/RenderBackend_NVRHI.cpp | 12 ++ neo/renderer/NVRHI/RenderDebug_NVRHI.cpp | 13 +- neo/renderer/RenderBackend.cpp | 216 +++++++++++++++++---- neo/renderer/RenderLog.cpp | 120 ++++++++---- neo/renderer/RenderLog.h | 3 + neo/renderer/RenderSystem.h | 9 + neo/sys/DeviceManager_DX12.cpp | 2 +- neo/sys/DeviceManager_VK.cpp | 2 + 10 files changed, 349 insertions(+), 87 deletions(-) diff --git a/neo/framework/Common_local.h b/neo/framework/Common_local.h index 911c197b33..5dad78b248 100644 --- a/neo/framework/Common_local.h +++ b/neo/framework/Common_local.h @@ -333,11 +333,21 @@ class idCommonLocal : public idCommon } // RB begin + uint64 GetRendererGpuBeginDrawingMicroseconds() const + { + return stats_backend.gpuBeginDrawingMicroSec; + } + uint64 GetRendererGpuEarlyZMicroseconds() const { return stats_backend.gpuDepthMicroSec; } + uint64 GetRendererGpuGeometryMicroseconds() const + { + return stats_backend.gpuGeometryMicroSec; + } + uint64 GetRendererGpuSSAOMicroseconds() const { return stats_backend.gpuScreenSpaceAmbientOcclusionMicroSec; @@ -368,15 +378,50 @@ class idCommonLocal : public idCommon return stats_backend.gpuShaderPassMicroSec; } + uint64 GetRendererGpuFogAllLightsMicroseconds() const + { + return stats_backend.gpuFogAllLightsMicroSec; + } + + uint64 GetRendererGpuBloomMicroseconds() const + { + return stats_backend.gpuBloomMicroSec; + } + + uint64 GetRendererGpuShaderPassPostMicroseconds() const + { + return stats_backend.gpuShaderPassPostMicroSec; + } + + uint64 GetRendererGpuMotionVectorsMicroseconds() const + { + return stats_backend.gpuMotionVectorsMicroSec; + } + uint64 GetRendererGpuTAAMicroseconds() const { return stats_backend.gpuTemporalAntiAliasingMicroSec; } + uint64 GetRendererGpuToneMapPassMicroseconds() const + { + return stats_backend.gpuToneMapPassMicroSec; + } + uint64 GetRendererGpuPostProcessingMicroseconds() const { return stats_backend.gpuPostProcessingMicroSec; } + + uint64 GetRendererGpuDrawGuiMicroseconds() const + { + return stats_backend.gpuDrawGuiMicroSec; + } + + uint64 GetRendererGpuCrtPostProcessingMicroseconds() const + { + return stats_backend.gpuCrtPostProcessingMicroSec; + } // RB end // SRS start diff --git a/neo/framework/Console.cpp b/neo/framework/Console.cpp index 573e8db2b6..6d1072361e 100644 --- a/neo/framework/Console.cpp +++ b/neo/framework/Console.cpp @@ -299,15 +299,16 @@ float idConsoleLocal::DrawFPS( float y ) const uint64 rendererBackEndTime = commonLocal.GetRendererBackEndMicroseconds(); const uint64 rendererShadowsTime = commonLocal.GetRendererShadowsMicroseconds(); const uint64 rendererGPUTime = commonLocal.GetRendererGPUMicroseconds(); - const uint64 rendererGPUEarlyZTime = commonLocal.GetRendererGpuEarlyZMicroseconds(); + const uint64 rendererGPUEarlyZTime = commonLocal.GetRendererGpuBeginDrawingMicroseconds() + commonLocal.GetRendererGpuEarlyZMicroseconds() + commonLocal.GetRendererGpuGeometryMicroseconds(); const uint64 rendererGPU_SSAOTime = commonLocal.GetRendererGpuSSAOMicroseconds(); const uint64 rendererGPU_SSRTime = commonLocal.GetRendererGpuSSRMicroseconds(); const uint64 rendererGPUAmbientPassTime = commonLocal.GetRendererGpuAmbientPassMicroseconds(); const uint64 rendererGPUShadowAtlasTime = commonLocal.GetRendererGpuShadowAtlasPassMicroseconds(); const uint64 rendererGPUInteractionsTime = commonLocal.GetRendererGpuInteractionsMicroseconds(); - const uint64 rendererGPUShaderPassesTime = commonLocal.GetRendererGpuShaderPassMicroseconds(); - const uint64 rendererGPU_TAATime = commonLocal.GetRendererGpuTAAMicroseconds(); - const uint64 rendererGPUPostProcessingTime = commonLocal.GetRendererGpuPostProcessingMicroseconds(); + const uint64 rendererGPUShaderPassesTime = commonLocal.GetRendererGpuShaderPassMicroseconds() + commonLocal.GetRendererGpuFogAllLightsMicroseconds() + commonLocal.GetRendererGpuShaderPassPostMicroseconds() + commonLocal.GetRendererGpuDrawGuiMicroseconds(); + const uint64 rendererGPU_TAATime = commonLocal.GetRendererGpuMotionVectorsMicroseconds() + commonLocal.GetRendererGpuTAAMicroseconds(); + const uint64 rendererGPUToneMapPassTime = commonLocal.GetRendererGpuToneMapPassMicroseconds(); + const uint64 rendererGPUPostProcessingTime = commonLocal.GetRendererGpuPostProcessingMicroseconds() + commonLocal.GetRendererGpuCrtPostProcessingMicroseconds(); // SRS - Calculate max fps and max frame time based on glConfig.displayFrequency if vsync enabled and lower than engine Hz, otherwise use com_engineHz_latched const int maxFPS = ( r_swapInterval.GetInteger() > 0 && glConfig.displayFrequency > 0 ? std::min( glConfig.displayFrequency, int( com_engineHz_latched ) ) : com_engineHz_latched ); @@ -344,7 +345,7 @@ float idConsoleLocal::DrawFPS( float y ) { // start smaller int32 statsWindowWidth = 320; - int32 statsWindowHeight = 315; + int32 statsWindowHeight = 330; if( com_showFPS.GetInteger() > 2 ) { @@ -525,11 +526,12 @@ float idConsoleLocal::DrawFPS( float y ) ImGui::TextColored( rendererGPUShaderPassesTime > maxTime ? colorRed : colorWhite, " Shader Pass: %5llu us", rendererGPUShaderPassesTime ); #endif ImGui::TextColored( rendererGPU_TAATime > maxTime ? colorRed : colorWhite, " TAA: %5llu us", rendererGPU_TAATime ); + ImGui::TextColored( rendererGPUToneMapPassTime > maxTime ? colorRed : colorWhite, " ToneMap: %5llu us", rendererGPUToneMapPassTime ); ImGui::TextColored( rendererGPUPostProcessingTime > maxTime ? colorRed : colorWhite, " PostFX: %5llu us", rendererGPUPostProcessingTime ); ImGui::TextColored( frameBusyTime > maxTime || rendererGPUTime > maxTime ? colorRed : colorWhite, "Total: %5lld us Total: %5lld us", frameBusyTime, rendererGPUTime ); ImGui::TextColored( colorWhite, "Idle: %5lld us Idle: %5lld us", frameIdleTime, rendererGPUIdleTime ); // SRS - Show CPU and GPU overall usage statistics - //ImGui::TextColored( colorWhite, "Usage: %3.0f %% Usage: %3.0f %%", cpuUsage, gpuUsage ); + //ImGui::TextColored( colorWhite, "Frame: %3.0f %% Frame: %3.0f %%", cpuUsage, gpuUsage ); ImGui::End(); } diff --git a/neo/renderer/NVRHI/RenderBackend_NVRHI.cpp b/neo/renderer/NVRHI/RenderBackend_NVRHI.cpp index 09364d06c3..4cbed29fa6 100644 --- a/neo/renderer/NVRHI/RenderBackend_NVRHI.cpp +++ b/neo/renderer/NVRHI/RenderBackend_NVRHI.cpp @@ -2138,6 +2138,15 @@ void idRenderBackend::SetBuffer( const void* data ) const setBufferCommand_t* cmd = ( const setBufferCommand_t* )data; + nvrhi::ObjectType commandObject = nvrhi::ObjectTypes::D3D12_GraphicsCommandList; + if( deviceManager->GetGraphicsAPI() == nvrhi::GraphicsAPI::VULKAN ) + { + commandObject = nvrhi::ObjectTypes::VK_CommandBuffer; + } + OPTICK_GPU_CONTEXT( ( void* ) commandList->getNativeObject( commandObject ) ); + OPTICK_GPU_EVENT( "SetBuffer" ); + + renderLog.OpenMainBlock( MRB_BEGIN_DRAWING_VIEW ); renderLog.OpenBlock( "Render_SetBuffer" ); currentScissor.Clear(); @@ -2149,6 +2158,8 @@ void idRenderBackend::SetBuffer( const void* data ) // that might leave unrendered portions of the screen if( r_clear.GetFloat() || idStr::Length( r_clear.GetString() ) != 1 || r_singleArea.GetBool() || r_showOverDraw.GetBool() ) { + OPTICK_GPU_EVENT( "Render_ClearBuffer" ); + float c[3]; if( sscanf( r_clear.GetString(), "%f %f %f", &c[0], &c[1], &c[2] ) == 3 ) { @@ -2169,6 +2180,7 @@ void idRenderBackend::SetBuffer( const void* data ) } renderLog.CloseBlock(); + renderLog.CloseMainBlock(); } diff --git a/neo/renderer/NVRHI/RenderDebug_NVRHI.cpp b/neo/renderer/NVRHI/RenderDebug_NVRHI.cpp index aeb68914e7..0b7c60b1ac 100644 --- a/neo/renderer/NVRHI/RenderDebug_NVRHI.cpp +++ b/neo/renderer/NVRHI/RenderDebug_NVRHI.cpp @@ -36,6 +36,9 @@ If you have questions concerning this license or the applicable additional terms #include "../simplex.h" // line font definition #include "../ImmediateMode.h" +#include +extern DeviceManager* deviceManager; + idCVar r_showCenterOfProjection( "r_showCenterOfProjection", "0", CVAR_RENDERER | CVAR_BOOL, "Draw a cross to show the center of projection" ); idCVar r_showLines( "r_showLines", "0", CVAR_RENDERER | CVAR_INTEGER, "1 = draw alternate horizontal lines, 2 = draw alternate vertical lines" ); @@ -2432,6 +2435,14 @@ void idRenderBackend::DBG_RenderDebugTools( drawSurf_t** drawSurfs, int numDrawS return; } + nvrhi::ObjectType commandObject = nvrhi::ObjectTypes::D3D12_GraphicsCommandList; + if( deviceManager->GetGraphicsAPI() == nvrhi::GraphicsAPI::VULKAN ) + { + commandObject = nvrhi::ObjectTypes::VK_CommandBuffer; + } + OPTICK_GPU_CONTEXT( ( void* ) commandList->getNativeObject( commandObject ) ); + OPTICK_GPU_EVENT( "Render_DebugTools" ); + // don't do much if this was a 2D rendering if( !viewDef->viewEntitys ) { @@ -2440,7 +2451,7 @@ void idRenderBackend::DBG_RenderDebugTools( drawSurf_t** drawSurfs, int numDrawS return; } - OPTICK_EVENT( "Render_DebugTools" ); + //OPTICK_EVENT( "Render_DebugTools" ); renderLog.OpenMainBlock( MRB_DRAW_DEBUG_TOOLS ); renderLog.OpenBlock( "Render_DebugTools", colorGreen ); diff --git a/neo/renderer/RenderBackend.cpp b/neo/renderer/RenderBackend.cpp index 1124d00df8..a3e5492dac 100644 --- a/neo/renderer/RenderBackend.cpp +++ b/neo/renderer/RenderBackend.cpp @@ -793,16 +793,6 @@ on the 360. */ void idRenderBackend::FillDepthBufferFast( drawSurf_t** drawSurfs, int numDrawSurfs ) { - OPTICK_EVENT( "Render_FillDepthBufferFast" ); - - nvrhi::ObjectType commandObject = nvrhi::ObjectTypes::D3D12_GraphicsCommandList; - if( deviceManager->GetGraphicsAPI() == nvrhi::GraphicsAPI::VULKAN ) - { - commandObject = nvrhi::ObjectTypes::VK_CommandBuffer; - } - OPTICK_GPU_CONTEXT( ( void* ) commandList->getNativeObject( commandObject ) ); - OPTICK_GPU_EVENT( "Render_FillDepthBufferFast" ); - if( numDrawSurfs == 0 ) { return; @@ -814,6 +804,16 @@ void idRenderBackend::FillDepthBufferFast( drawSurf_t** drawSurfs, int numDrawSu return; } + //OPTICK_EVENT( "Render_FillDepthBufferFast" ); + + nvrhi::ObjectType commandObject = nvrhi::ObjectTypes::D3D12_GraphicsCommandList; + if( deviceManager->GetGraphicsAPI() == nvrhi::GraphicsAPI::VULKAN ) + { + commandObject = nvrhi::ObjectTypes::VK_CommandBuffer; + } + OPTICK_GPU_CONTEXT( ( void* ) commandList->getNativeObject( commandObject ) ); + OPTICK_GPU_EVENT( "Render_FillDepthBufferFast" ); + renderLog.OpenMainBlock( MRB_FILL_DEPTH_BUFFER ); renderLog.OpenBlock( "Render_FillDepthBufferFast", colorBlue ); @@ -3365,7 +3365,7 @@ void idRenderBackend::ShadowAtlasPass( const viewDef_t* _viewDef ) return; } - OPTICK_EVENT( "Render_ShadowAtlas" ); + //OPTICK_EVENT( "Render_ShadowAtlas" ); nvrhi::ObjectType commandObject = nvrhi::ObjectTypes::D3D12_GraphicsCommandList; if( deviceManager->GetGraphicsAPI() == nvrhi::GraphicsAPI::VULKAN ) @@ -3681,7 +3681,7 @@ void idRenderBackend::DrawInteractions( const viewDef_t* _viewDef ) return; } - OPTICK_EVENT( "Render_Interactions" ); + //OPTICK_EVENT( "Render_Interactions" ); nvrhi::ObjectType commandObject = nvrhi::ObjectTypes::D3D12_GraphicsCommandList; if( deviceManager->GetGraphicsAPI() == nvrhi::GraphicsAPI::VULKAN ) @@ -3871,7 +3871,7 @@ int idRenderBackend::DrawShaderPasses( const drawSurf_t* const* const drawSurfs, return numDrawSurfs; } - OPTICK_EVENT( "Render_GenericShaderPasses" ); + //OPTICK_EVENT( "Render_GenericShaderPasses" ); renderLog.OpenBlock( "Render_GenericShaderPasses", colorBlue ); if( viewDef->targetRender ) @@ -4624,7 +4624,7 @@ idRenderBackend::FogAllLights */ void idRenderBackend::FogAllLights() { - if( r_skipFogLights.GetBool() || r_showOverDraw.GetInteger() != 0 + if( r_skipFogLights.GetBool() || r_showOverDraw.GetInteger() != 0 || viewDef->viewLights == NULL || viewDef->isXraySubview /* don't fog in xray mode*/ ) { return; @@ -4632,6 +4632,14 @@ void idRenderBackend::FogAllLights() //OPTICK_EVENT( "Render_FogAllLights" ); + nvrhi::ObjectType commandObject = nvrhi::ObjectTypes::D3D12_GraphicsCommandList; + if( deviceManager->GetGraphicsAPI() == nvrhi::GraphicsAPI::VULKAN ) + { + commandObject = nvrhi::ObjectTypes::VK_CommandBuffer; + } + OPTICK_GPU_CONTEXT( ( void* ) commandList->getNativeObject( commandObject ) ); + OPTICK_GPU_EVENT( "Render_FogAllLights" ); + renderLog.OpenMainBlock( MRB_FOG_ALL_LIGHTS ); renderLog.OpenBlock( "Render_FogAllLights", colorBlue ); @@ -4679,6 +4687,15 @@ void idRenderBackend::DrawMotionVectors() //OPTICK_EVENT( "Render_MotionVectors" ); + nvrhi::ObjectType commandObject = nvrhi::ObjectTypes::D3D12_GraphicsCommandList; + if( deviceManager->GetGraphicsAPI() == nvrhi::GraphicsAPI::VULKAN ) + { + commandObject = nvrhi::ObjectTypes::VK_CommandBuffer; + } + OPTICK_GPU_CONTEXT( ( void* ) commandList->getNativeObject( commandObject ) ); + OPTICK_GPU_EVENT( "Render_MotionVectors" ); + + renderLog.OpenMainBlock( MRB_MOTION_VECTORS ); renderLog.OpenBlock( "Render_MotionVectors" ); // clear the alpha buffer and draw only the hands + weapon into it so @@ -4794,6 +4811,7 @@ void idRenderBackend::DrawMotionVectors() } renderLog.CloseBlock(); + renderLog.CloseMainBlock(); } void idRenderBackend::TemporalAAPass( const viewDef_t* _viewDef ) @@ -4821,6 +4839,14 @@ void idRenderBackend::TemporalAAPass( const viewDef_t* _viewDef ) //OPTICK_EVENT( "Render_TemporalAA" ); + nvrhi::ObjectType commandObject = nvrhi::ObjectTypes::D3D12_GraphicsCommandList; + if( deviceManager->GetGraphicsAPI() == nvrhi::GraphicsAPI::VULKAN ) + { + commandObject = nvrhi::ObjectTypes::VK_CommandBuffer; + } + OPTICK_GPU_CONTEXT( ( void* ) commandList->getNativeObject( commandObject ) ); + OPTICK_GPU_EVENT( "Render_TemporalAA" ); + renderLog.OpenMainBlock( MRB_TAA ); renderLog.OpenBlock( "Render_TemporalAA" ); @@ -4856,6 +4882,16 @@ void idRenderBackend::Bloom( const viewDef_t* _viewDef ) return; } + //OPTICK_EVENT( "Render_Bloom" ); + + nvrhi::ObjectType commandObject = nvrhi::ObjectTypes::D3D12_GraphicsCommandList; + if( deviceManager->GetGraphicsAPI() == nvrhi::GraphicsAPI::VULKAN ) + { + commandObject = nvrhi::ObjectTypes::VK_CommandBuffer; + } + OPTICK_GPU_CONTEXT( ( void* ) commandList->getNativeObject( commandObject ) ); + OPTICK_GPU_EVENT( "Render_Bloom" ); + renderLog.OpenMainBlock( MRB_BLOOM ); renderLog.OpenBlock( "Render_Bloom", colorBlue ); @@ -4979,6 +5015,14 @@ void idRenderBackend::DrawScreenSpaceAmbientOcclusion( const viewDef_t* _viewDef //OPTICK_EVENT( "Render_SSAO" ); + nvrhi::ObjectType commandObject = nvrhi::ObjectTypes::D3D12_GraphicsCommandList; + if( deviceManager->GetGraphicsAPI() == nvrhi::GraphicsAPI::VULKAN ) + { + commandObject = nvrhi::ObjectTypes::VK_CommandBuffer; + } + OPTICK_GPU_CONTEXT( ( void* ) commandList->getNativeObject( commandObject ) ); + OPTICK_GPU_EVENT( "Render_SSAO" ); + renderLog.OpenMainBlock( MRB_SSAO_PASS ); renderLog.OpenBlock( "Render_SSAO", colorBlue ); @@ -5212,6 +5256,14 @@ void idRenderBackend::DrawScreenSpaceAmbientOcclusion2( const viewDef_t* _viewDe //OPTICK_EVENT( "Render_SSAO2" ); + nvrhi::ObjectType commandObject = nvrhi::ObjectTypes::D3D12_GraphicsCommandList; + if( deviceManager->GetGraphicsAPI() == nvrhi::GraphicsAPI::VULKAN ) + { + commandObject = nvrhi::ObjectTypes::VK_CommandBuffer; + } + OPTICK_GPU_CONTEXT( ( void* ) commandList->getNativeObject( commandObject ) ); + OPTICK_GPU_EVENT( "Render_SSAO2" ); + renderLog.OpenMainBlock( MRB_SSAO_PASS ); renderLog.OpenBlock( "Render_SSAO2", colorBlue ); @@ -5410,8 +5462,8 @@ idRenderBackend::DrawViewInternal */ void idRenderBackend::DrawViewInternal( const viewDef_t* _viewDef, const int stereoEye ) { - OPTICK_EVENT( "Backend_DrawViewInternal" ); - OPTICK_TAG( "stereoEye", stereoEye ); + //OPTICK_EVENT( "Backend_DrawViewInternal" ); + //OPTICK_TAG( "stereoEye", stereoEye ); nvrhi::ObjectType commandObject = nvrhi::ObjectTypes::D3D12_GraphicsCommandList; if( deviceManager->GetGraphicsAPI() == nvrhi::GraphicsAPI::VULKAN ) @@ -5419,7 +5471,7 @@ void idRenderBackend::DrawViewInternal( const viewDef_t* _viewDef, const int ste commandObject = nvrhi::ObjectTypes::VK_CommandBuffer; } OPTICK_GPU_CONTEXT( ( void* ) commandList->getNativeObject( commandObject ) ); - OPTICK_GPU_EVENT( "DrawView" ); + //OPTICK_GPU_EVENT( "DrawView" ); // SRS - now in DrawView() for 3D vs. GUI renderLog.OpenBlock( "Render_DrawViewInternal", colorRed ); @@ -5483,7 +5535,11 @@ void idRenderBackend::DrawViewInternal( const viewDef_t* _viewDef, const int ste } // Clear the depth buffer and clear the stencil to 128 for stencil shadows as well as gui masking - GL_Clear( clearColor, true, true, STENCIL_SHADOW_TEST_VALUE, 0.0f, 0.0f, 0.0f, 0.0f, false ); + { + OPTICK_GPU_EVENT( "Render_ClearDepthStencil" ); + + GL_Clear( clearColor, true, true, STENCIL_SHADOW_TEST_VALUE, 0.0f, 0.0f, 0.0f, 0.0f, false ); + } // RB end @@ -5530,8 +5586,10 @@ void idRenderBackend::DrawViewInternal( const viewDef_t* _viewDef, const int ste // // fill the geometric buffer with normals and roughness //------------------------------------------------- + if( viewDef->viewEntitys ) // 3D views only { - OPTICK_EVENT( "Render_GeometryBuffer" ); + //OPTICK_EVENT( "Render_GeometryBuffer" ); + OPTICK_GPU_EVENT( "Render_GeometryBuffer" ); AmbientPass( drawSurfs, numDrawSurfs, true ); } @@ -5551,8 +5609,10 @@ void idRenderBackend::DrawViewInternal( const viewDef_t* _viewDef, const int ste //------------------------------------------------- // render static lighting and consider SSAO results //------------------------------------------------- + if( viewDef->viewEntitys ) // 3D views only { - OPTICK_EVENT( "Render_AmbientPass" ); + //OPTICK_EVENT( "Render_AmbientPass" ); + OPTICK_GPU_EVENT( "Render_AmbientPass" ); AmbientPass( drawSurfs, numDrawSurfs, false ); } @@ -5573,6 +5633,8 @@ void idRenderBackend::DrawViewInternal( const viewDef_t* _viewDef, const int ste int processed = 0; if( !r_skipShaderPasses.GetBool() ) { + OPTICK_GPU_EVENT( "Render_GenericShaderPasses" ); + renderLog.OpenMainBlock( MRB_DRAW_SHADER_PASSES ); float guiScreenOffset; if( _viewDef->viewEntitys != NULL ) @@ -5604,6 +5666,9 @@ void idRenderBackend::DrawViewInternal( const viewDef_t* _viewDef, const int ste //------------------------------------------------- if( processed < numDrawSurfs && !r_skipPostProcess.GetBool() ) { + OPTICK_GPU_EVENT( "Render_ShaderPassesPost" ); + + renderLog.OpenMainBlock( MRB_DRAW_SHADER_PASSES_POST ); int x = viewDef->viewport.x1; int y = viewDef->viewport.y1; int w = viewDef->viewport.x2 - viewDef->viewport.x1 + 1; @@ -5654,7 +5719,6 @@ void idRenderBackend::DrawViewInternal( const viewDef_t* _viewDef, const int ste SetFragmentParm( RENDERPARM_WINDOWCOORD, windowCoordParm ); // rpWindowCoord // render the remaining surfaces - renderLog.OpenMainBlock( MRB_DRAW_SHADER_PASSES_POST ); DrawShaderPasses( drawSurfs + processed, numDrawSurfs - processed, 0.0f /* definitely not a gui */, stereoEye ); renderLog.CloseMainBlock(); } @@ -5683,6 +5747,11 @@ void idRenderBackend::DrawViewInternal( const viewDef_t* _viewDef, const int ste if( useHDR && !( _viewDef->renderView.rdflags & RDF_IRRADIANCE ) && !_viewDef->targetRender ) { + OPTICK_GPU_EVENT( "Render_ToneMapPass" ); + + renderLog.OpenMainBlock( MRB_TONE_MAP_PASS ); + renderLog.OpenBlock( "Render_ToneMapPass", colorBlue ); + ToneMappingParameters parms; if( R_UseTemporalAA() ) { @@ -5701,6 +5770,9 @@ void idRenderBackend::DrawViewInternal( const viewDef_t* _viewDef, const int ste toneMapPass->SimpleRender( commandList, parms, viewDef, globalImages->currentRenderHDRImage->GetTextureHandle(), globalFramebuffers.ldrFBO->GetApiObject() ); } } + + renderLog.CloseBlock(); + renderLog.CloseMainBlock(); } //------------------------------------------------- @@ -5712,6 +5784,8 @@ void idRenderBackend::DrawViewInternal( const viewDef_t* _viewDef, const int ste if( _viewDef->renderView.rdflags & RDF_IRRADIANCE ) { + OPTICK_GPU_EVENT( "Blit_EnvProbeRendered" ); + // copy LDR result to DX12 / Vulkan swapchain image // we haven't changed ldrImage so it's basically the previewsRenderLDR @@ -5730,6 +5804,8 @@ void idRenderBackend::DrawViewInternal( const viewDef_t* _viewDef, const int ste } else { + OPTICK_GPU_EVENT( "Blit_Rendered" ); + // copy LDR result to DX12 / Vulkan swapchain image BlitParameters blitParms; @@ -5864,6 +5940,13 @@ void idRenderBackend::DrawView( const void* data, const int stereoEye ) { //OPTICK_EVENT( "Backend_DrawView" ); + nvrhi::ObjectType commandObject = nvrhi::ObjectTypes::D3D12_GraphicsCommandList; + if( deviceManager->GetGraphicsAPI() == nvrhi::GraphicsAPI::VULKAN ) + { + commandObject = nvrhi::ObjectTypes::VK_CommandBuffer; + } + OPTICK_GPU_CONTEXT( ( void* ) commandList->getNativeObject( commandObject ) ); + const drawSurfsCommand_t* cmd = ( const drawSurfsCommand_t* )data; viewDef = cmd->viewDef; @@ -5895,7 +5978,20 @@ void idRenderBackend::DrawView( const void* data, const int stereoEye ) DBG_ShowOverdraw(); // render the scene - DrawViewInternal( cmd->viewDef, stereoEye ); + if( viewDef->viewEntitys ) + { + OPTICK_GPU_EVENT( "DrawView_3D" ); + OPTICK_TAG( "stereoEye", stereoEye ); + + DrawViewInternal( cmd->viewDef, stereoEye ); + } + else + { + OPTICK_GPU_EVENT( "DrawView_GUI" ); + OPTICK_TAG( "stereoEye", stereoEye ); + + DrawViewInternal( cmd->viewDef, stereoEye ); + } // RB: Support motion blur in the future again? // It is the worst thing next to depth of field @@ -5937,6 +6033,14 @@ void idRenderBackend::CopyRender( const void* data ) return; } + nvrhi::ObjectType commandObject = nvrhi::ObjectTypes::D3D12_GraphicsCommandList; + if( deviceManager->GetGraphicsAPI() == nvrhi::GraphicsAPI::VULKAN ) + { + commandObject = nvrhi::ObjectTypes::VK_CommandBuffer; + } + OPTICK_GPU_CONTEXT( ( void* ) commandList->getNativeObject( commandObject ) ); + OPTICK_GPU_EVENT( "CopyRender" ); + renderLog.OpenBlock( "***************** RB_CopyRender *****************" ); if( cmd->image ) @@ -5981,9 +6085,19 @@ idRenderBackend::PostProcess extern idCVar rs_enable; void idRenderBackend::PostProcess( const void* data ) { + nvrhi::ObjectType commandObject = nvrhi::ObjectTypes::D3D12_GraphicsCommandList; + if( deviceManager->GetGraphicsAPI() == nvrhi::GraphicsAPI::VULKAN ) + { + commandObject = nvrhi::ObjectTypes::VK_CommandBuffer; + } + OPTICK_GPU_CONTEXT( ( void* ) commandList->getNativeObject( commandObject ) ); + OPTICK_GPU_EVENT( "PostProcess" ); + if( viewDef->renderView.rdflags & RDF_IRRADIANCE ) { #if defined( USE_NVRHI ) + OPTICK_GPU_EVENT( "Blit_EnvProbePostFX" ); + // we haven't changed ldrImage so it's basically the previewsRenderLDR BlitParameters blitParms; blitParms.sourceTexture = ( nvrhi::ITexture* )globalImages->ldrImage->GetTextureID(); @@ -6100,6 +6214,8 @@ void idRenderBackend::PostProcess( const void* data ) if( r_useFilmicPostFX.GetBool() || r_renderMode.GetInteger() > 0 ) { + OPTICK_GPU_EVENT( "Render_FilmicPostFX" ); + BlitParameters blitParms; blitParms.sourceTexture = ( nvrhi::ITexture* )globalImages->ldrImage->GetTextureID(); blitParms.targetFramebuffer = globalFramebuffers.smaaBlendFBO->GetApiObject(); @@ -6171,18 +6287,22 @@ void idRenderBackend::PostProcess( const void* data ) GL_SelectTexture( 0 ); renderProgManager.Unbind(); - // copy LDR result to DX12 / Vulkan swapchain image - 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 ); + { + OPTICK_GPU_EVENT( "Blit_FilmicPostFX" ); - // copy LDR result to postProcFBO which is HDR but also used by postFX - blitParms.sourceTexture = ( nvrhi::ITexture* )globalImages->ldrImage->GetTextureID(); - blitParms.targetFramebuffer = globalFramebuffers.postProcFBO->GetApiObject(); - blitParms.targetViewport = nvrhi::Viewport( viewport.x1, viewport.x2, viewport.y1, viewport.y2, viewport.zmin, viewport.zmax ); - commonPasses.BlitTexture( commandList, blitParms, &bindingCache ); + // copy LDR result to DX12 / Vulkan swapchain image + 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 ); + + // copy LDR result to postProcFBO which is HDR but also used by postFX + blitParms.sourceTexture = ( nvrhi::ITexture* )globalImages->ldrImage->GetTextureID(); + blitParms.targetFramebuffer = globalFramebuffers.postProcFBO->GetApiObject(); + blitParms.targetViewport = nvrhi::Viewport( viewport.x1, viewport.x2, viewport.y1, viewport.y2, viewport.zmin, viewport.zmax ); + commonPasses.BlitTexture( commandList, blitParms, &bindingCache ); + } GL_SelectTexture( 0 ); globalImages->currentRenderImage->Bind(); @@ -6194,7 +6314,15 @@ void idRenderBackend::PostProcess( const void* data ) void idRenderBackend::CRTPostProcess() { #if 1 - //renderLog.OpenMainBlock( MRB_POSTPROCESS ); + nvrhi::ObjectType commandObject = nvrhi::ObjectTypes::D3D12_GraphicsCommandList; + if( deviceManager->GetGraphicsAPI() == nvrhi::GraphicsAPI::VULKAN ) + { + commandObject = nvrhi::ObjectTypes::VK_CommandBuffer; + } + OPTICK_GPU_CONTEXT( ( void* ) commandList->getNativeObject( commandObject ) ); + OPTICK_GPU_EVENT( "CRTPostProcess" ); + + renderLog.OpenMainBlock( MRB_CRT_POSTPROCESS ); renderLog.OpenBlock( "Render_CRTPostFX", colorBlue ); GL_State( GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO | GLS_DEPTHMASK | GLS_DEPTHFUNC_ALWAYS | GLS_CULL_TWOSIDED ); @@ -6208,6 +6336,8 @@ void idRenderBackend::CRTPostProcess() if( r_useCRTPostFX.GetInteger() > 0 ) { + OPTICK_GPU_EVENT( "Render_CRTPostFX" ); + BlitParameters blitParms; blitParms.sourceTexture = ( nvrhi::ITexture* )globalImages->ldrImage->GetTextureID(); blitParms.targetFramebuffer = globalFramebuffers.smaaBlendFBO->GetApiObject(); @@ -6263,17 +6393,21 @@ void idRenderBackend::CRTPostProcess() //GL_SelectTexture( 0 ); //renderProgManager.Unbind(); - // copy LDR result to DX12 / Vulkan swapchain image - 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 ); + { + OPTICK_GPU_EVENT( "Blit_CRTPostFX" ); + + // copy LDR result to DX12 / Vulkan swapchain image + 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 ); + } GL_SelectTexture( 0 ); globalImages->currentRenderImage->Bind(); renderLog.CloseBlock(); - //renderLog.CloseMainBlock(); + renderLog.CloseMainBlock(); #endif } diff --git a/neo/renderer/RenderLog.cpp b/neo/renderer/RenderLog.cpp index 034d9dbc19..c679a3d802 100644 --- a/neo/renderer/RenderLog.cpp +++ b/neo/renderer/RenderLog.cpp @@ -53,10 +53,13 @@ const char* renderLogMainBlockLabels[] = ASSERT_ENUM_STRING( MRB_DRAW_SHADER_PASSES_POST, 11 ), ASSERT_ENUM_STRING( MRB_DRAW_DEBUG_TOOLS, 12 ), ASSERT_ENUM_STRING( MRB_CAPTURE_COLORBUFFER, 13 ), - ASSERT_ENUM_STRING( MRB_TAA, 14 ), - ASSERT_ENUM_STRING( MRB_POSTPROCESS, 15 ), - ASSERT_ENUM_STRING( MRB_DRAW_GUI, 16 ), - ASSERT_ENUM_STRING( MRB_TOTAL, 17 ) + ASSERT_ENUM_STRING( MRB_MOTION_VECTORS, 14 ), + ASSERT_ENUM_STRING( MRB_TAA, 15 ), + ASSERT_ENUM_STRING( MRB_TONE_MAP_PASS, 16 ), + ASSERT_ENUM_STRING( MRB_POSTPROCESS, 17 ), + ASSERT_ENUM_STRING( MRB_DRAW_GUI, 18 ), + ASSERT_ENUM_STRING( MRB_CRT_POSTPROCESS, 19 ), + ASSERT_ENUM_STRING( MRB_TOTAL, 20 ) }; extern uint64 Sys_Microseconds(); @@ -216,41 +219,82 @@ void idRenderLog::FetchGPUTimers( backEndCounters_t& pc ) double time = deviceManager->GetDevice()->getTimerQueryTime( timerQueries[ timerIndex ] ); time *= 1000000.0; // seconds -> microseconds - if( i == MRB_GPU_TIME ) + switch( i ) { - pc.gpuMicroSec = time; - } - else if( i == MRB_FILL_DEPTH_BUFFER ) - { - pc.gpuDepthMicroSec = time; - } - else if( i == MRB_SSAO_PASS ) - { - pc.gpuScreenSpaceAmbientOcclusionMicroSec = time; - } - else if( i == MRB_AMBIENT_PASS ) - { - pc.gpuAmbientPassMicroSec = time; - } - else if( i == MRB_SHADOW_ATLAS_PASS ) - { - pc.gpuShadowAtlasPassMicroSec = time; - } - else if( i == MRB_DRAW_INTERACTIONS ) - { - pc.gpuInteractionsMicroSec = time; - } - else if( i == MRB_DRAW_SHADER_PASSES ) - { - pc.gpuShaderPassMicroSec = time; - } - else if( i == MRB_TAA ) - { - pc.gpuTemporalAntiAliasingMicroSec = time; - } - else if( i == MRB_POSTPROCESS ) - { - pc.gpuPostProcessingMicroSec = time; + case MRB_GPU_TIME: + pc.gpuMicroSec = time; + break; + + case MRB_BEGIN_DRAWING_VIEW: + pc.gpuBeginDrawingMicroSec = time; + break; + + case MRB_FILL_DEPTH_BUFFER: + pc.gpuDepthMicroSec = time; + break; + + case MRB_FILL_GEOMETRY_BUFFER: + pc.gpuGeometryMicroSec = time; + break; + + case MRB_SSAO_PASS: + pc.gpuScreenSpaceAmbientOcclusionMicroSec = time; + break; + + case MRB_AMBIENT_PASS: + pc.gpuAmbientPassMicroSec = time; + break; + + case MRB_SHADOW_ATLAS_PASS: + pc.gpuShadowAtlasPassMicroSec = time; + break; + + case MRB_DRAW_INTERACTIONS: + pc.gpuInteractionsMicroSec = time; + break; + + case MRB_DRAW_SHADER_PASSES: + pc.gpuShaderPassMicroSec = time; + break; + + case MRB_FOG_ALL_LIGHTS: + pc.gpuFogAllLightsMicroSec = time; + break; + + case MRB_BLOOM: + pc.gpuBloomMicroSec = time; + break; + + case MRB_DRAW_SHADER_PASSES_POST: + pc.gpuShaderPassPostMicroSec = time; + break; + + case MRB_MOTION_VECTORS: + pc.gpuMotionVectorsMicroSec = time; + break; + + case MRB_TAA: + pc.gpuTemporalAntiAliasingMicroSec = time; + break; + + case MRB_TONE_MAP_PASS: + pc.gpuToneMapPassMicroSec = time; + break; + + case MRB_POSTPROCESS: + pc.gpuPostProcessingMicroSec = time; + break; + + case MRB_DRAW_GUI: + pc.gpuDrawGuiMicroSec = time; + break; + + case MRB_CRT_POSTPROCESS: + pc.gpuCrtPostProcessingMicroSec = time; + break; + + default: + break; } } diff --git a/neo/renderer/RenderLog.h b/neo/renderer/RenderLog.h index 73b2307564..77ac0a3d9b 100644 --- a/neo/renderer/RenderLog.h +++ b/neo/renderer/RenderLog.h @@ -53,9 +53,12 @@ enum renderLogMainBlock_t MRB_DRAW_SHADER_PASSES_POST, MRB_DRAW_DEBUG_TOOLS, MRB_CAPTURE_COLORBUFFER, + MRB_MOTION_VECTORS, MRB_TAA, + MRB_TONE_MAP_PASS, MRB_POSTPROCESS, MRB_DRAW_GUI, + MRB_CRT_POSTPROCESS, MRB_TOTAL, MRB_TOTAL_QUERIES = MRB_TOTAL * 2, diff --git a/neo/renderer/RenderSystem.h b/neo/renderer/RenderSystem.h index 62b02a4ebb..c52f2d1698 100644 --- a/neo/renderer/RenderSystem.h +++ b/neo/renderer/RenderSystem.h @@ -149,15 +149,24 @@ struct backEndCounters_t uint64 cpuTotalMicroSec; // total microseconds for backend run uint64 cpuShadowMicroSec; + uint64 gpuBeginDrawingMicroSec; uint64 gpuDepthMicroSec; + uint64 gpuGeometryMicroSec; uint64 gpuScreenSpaceAmbientOcclusionMicroSec; uint64 gpuScreenSpaceReflectionsMicroSec; uint64 gpuAmbientPassMicroSec; uint64 gpuShadowAtlasPassMicroSec; uint64 gpuInteractionsMicroSec; uint64 gpuShaderPassMicroSec; + uint64 gpuFogAllLightsMicroSec; + uint64 gpuBloomMicroSec; + uint64 gpuShaderPassPostMicroSec; + uint64 gpuMotionVectorsMicroSec; uint64 gpuTemporalAntiAliasingMicroSec; + uint64 gpuToneMapPassMicroSec; uint64 gpuPostProcessingMicroSec; + uint64 gpuDrawGuiMicroSec; + uint64 gpuCrtPostProcessingMicroSec; uint64 gpuMicroSec; }; // RB end diff --git a/neo/sys/DeviceManager_DX12.cpp b/neo/sys/DeviceManager_DX12.cpp index 7ef47746e1..8a62ac552f 100644 --- a/neo/sys/DeviceManager_DX12.cpp +++ b/neo/sys/DeviceManager_DX12.cpp @@ -601,7 +601,7 @@ uint32_t DeviceManager_DX12::GetBackBufferCount() void DeviceManager_DX12::EndFrame() { - + OPTICK_CATEGORY( "DX12_EndFrame", Optick::Category::Wait ); } void DeviceManager_DX12::Present() diff --git a/neo/sys/DeviceManager_VK.cpp b/neo/sys/DeviceManager_VK.cpp index 5c8043eb54..375f42d4de 100644 --- a/neo/sys/DeviceManager_VK.cpp +++ b/neo/sys/DeviceManager_VK.cpp @@ -1497,6 +1497,8 @@ void DeviceManager_VK::BeginFrame() void DeviceManager_VK::EndFrame() { + OPTICK_CATEGORY( "Vulkan_EndFrame", Optick::Category::Wait ); + m_NvrhiDevice->queueSignalSemaphore( nvrhi::CommandQueue::Graphics, m_PresentSemaphore, 0 ); // SRS - Don't need barrier commandlist if EndFrame() is called before executeCommandList() in idRenderBackend::GL_EndFrame() From 1e8899ca86b71a1f0e126dc4d0fcc58806fdb490 Mon Sep 17 00:00:00 2001 From: SRSaunders <82544213+SRSaunders@users.noreply.github.com> Date: Tue, 5 Mar 2024 09:47:35 -0500 Subject: [PATCH 07/71] Optick: Remove blocking sleep wait at start of Vulkan clock synchronization --- neo/libs/optick/optick_gpu.vulkan.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/neo/libs/optick/optick_gpu.vulkan.cpp b/neo/libs/optick/optick_gpu.vulkan.cpp index 0ee637fd8c..9efecb9576 100644 --- a/neo/libs/optick/optick_gpu.vulkan.cpp +++ b/neo/libs/optick/optick_gpu.vulkan.cpp @@ -500,7 +500,6 @@ namespace Optick // SRS - Improve GPU to CPU clock offset calibration by using Vulkan events // thanks to cdwfs for concept at https://gist.github.com/cdwfs/4222ca09cb259f8dd50f7f2cf7d09179 - std::this_thread::sleep_for(std::chrono::seconds(1)); (*vulkanFunctions.vkSetEvent)(Device, nodePayloads[nodeIndex]->event); clock.timestampCPU = GetHighPrecisionTime(); (*vulkanFunctions.vkWaitForFences)(Device, 1, &Fence, 1, (uint64_t)-1); From bcbc734d9413278306eb89d64d7bd01c0a596fac Mon Sep 17 00:00:00 2001 From: Stephen Saunders Date: Tue, 5 Mar 2024 14:44:29 -0500 Subject: [PATCH 08/71] Revert "Optick: Remove blocking sleep wait at start of Vulkan clock synchronization" This reverts commit 1e8899ca86b71a1f0e126dc4d0fcc58806fdb490. --- neo/libs/optick/optick_gpu.vulkan.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/neo/libs/optick/optick_gpu.vulkan.cpp b/neo/libs/optick/optick_gpu.vulkan.cpp index 9efecb9576..0ee637fd8c 100644 --- a/neo/libs/optick/optick_gpu.vulkan.cpp +++ b/neo/libs/optick/optick_gpu.vulkan.cpp @@ -500,6 +500,7 @@ namespace Optick // SRS - Improve GPU to CPU clock offset calibration by using Vulkan events // thanks to cdwfs for concept at https://gist.github.com/cdwfs/4222ca09cb259f8dd50f7f2cf7d09179 + std::this_thread::sleep_for(std::chrono::seconds(1)); (*vulkanFunctions.vkSetEvent)(Device, nodePayloads[nodeIndex]->event); clock.timestampCPU = GetHighPrecisionTime(); (*vulkanFunctions.vkWaitForFences)(Device, 1, &Fence, 1, (uint64_t)-1); From 75011c4eea955919dbb09b7ae570dfc878c6cc07 Mon Sep 17 00:00:00 2001 From: Stephen Saunders Date: Thu, 7 Mar 2024 13:54:35 -0500 Subject: [PATCH 09/71] Optick: Eliminate need for blocking sleep wait at start of Vulkan clock sync --- neo/libs/optick/optick_gpu.vulkan.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/neo/libs/optick/optick_gpu.vulkan.cpp b/neo/libs/optick/optick_gpu.vulkan.cpp index 0ee637fd8c..5e0d97d44e 100644 --- a/neo/libs/optick/optick_gpu.vulkan.cpp +++ b/neo/libs/optick/optick_gpu.vulkan.cpp @@ -477,14 +477,11 @@ namespace Optick VkDevice Device = node.device; VkFence Fence = currentFrame.fence; + // SRS - Prepare and submit an empty command buffer to wait on app buffer completion (*vulkanFunctions.vkWaitForFences)(Device, 1, &Fence, 1, (uint64_t)-1); (*vulkanFunctions.vkResetFences)(Device, 1, &Fence); - (*vulkanFunctions.vkResetEvent)(Device, nodePayloads[nodeIndex]->event); (*vulkanFunctions.vkResetCommandBuffer)(CB, VK_COMMAND_BUFFER_RESET_RELEASE_RESOURCES_BIT); (*vulkanFunctions.vkBeginCommandBuffer)(CB, &commandBufferBeginInfo); - (*vulkanFunctions.vkCmdResetQueryPool)(CB, nodePayloads[nodeIndex]->queryPool, 0, 1); - (*vulkanFunctions.vkCmdWaitEvents)(CB, 1, &nodePayloads[nodeIndex]->event, VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_HOST_BIT | VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, 0, nullptr, 0, nullptr, 0, nullptr); - (*vulkanFunctions.vkCmdWriteTimestamp)(CB, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, nodePayloads[nodeIndex]->queryPool, 0); (*vulkanFunctions.vkEndCommandBuffer)(CB); VkSubmitInfo submitInfo = {}; @@ -498,9 +495,19 @@ namespace Optick submitInfo.pSignalSemaphores = nullptr; (*vulkanFunctions.vkQueueSubmit)(nodePayloads[nodeIndex]->queue, 1, &submitInfo, Fence); + // SRS - Prepare and submit the actual command buffer used for clock synchronization + (*vulkanFunctions.vkWaitForFences)(Device, 1, &Fence, 1, (uint64_t)-1); + (*vulkanFunctions.vkResetFences)(Device, 1, &Fence); + (*vulkanFunctions.vkResetEvent)(Device, nodePayloads[nodeIndex]->event); + (*vulkanFunctions.vkBeginCommandBuffer)(CB, &commandBufferBeginInfo); + (*vulkanFunctions.vkCmdResetQueryPool)(CB, nodePayloads[nodeIndex]->queryPool, 0, 1); + (*vulkanFunctions.vkCmdWaitEvents)(CB, 1, &nodePayloads[nodeIndex]->event, VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_HOST_BIT | VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, 0, nullptr, 0, nullptr, 0, nullptr); + (*vulkanFunctions.vkCmdWriteTimestamp)(CB, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, nodePayloads[nodeIndex]->queryPool, 0); + (*vulkanFunctions.vkEndCommandBuffer)(CB); + (*vulkanFunctions.vkQueueSubmit)(nodePayloads[nodeIndex]->queue, 1, &submitInfo, Fence); + // SRS - Improve GPU to CPU clock offset calibration by using Vulkan events // thanks to cdwfs for concept at https://gist.github.com/cdwfs/4222ca09cb259f8dd50f7f2cf7d09179 - std::this_thread::sleep_for(std::chrono::seconds(1)); (*vulkanFunctions.vkSetEvent)(Device, nodePayloads[nodeIndex]->event); clock.timestampCPU = GetHighPrecisionTime(); (*vulkanFunctions.vkWaitForFences)(Device, 1, &Fence, 1, (uint64_t)-1); From 2e2a9106e1f429fced0d8497308a0c12af458a16 Mon Sep 17 00:00:00 2001 From: SRSaunders <82544213+SRSaunders@users.noreply.github.com> Date: Thu, 7 Mar 2024 15:55:00 -0500 Subject: [PATCH 10/71] Correct some uint64 types and add Optick frame tag for DX12 / Vulkan Present() --- neo/framework/Common_local.h | 6 +++--- neo/framework/Console.cpp | 2 +- neo/renderer/ImmediateMode.cpp | 2 +- neo/sys/DeviceManager_DX12.cpp | 3 ++- neo/sys/DeviceManager_VK.cpp | 36 ++++++++++++++++------------------ 5 files changed, 24 insertions(+), 25 deletions(-) diff --git a/neo/framework/Common_local.h b/neo/framework/Common_local.h index 5dad78b248..1084461e79 100644 --- a/neo/framework/Common_local.h +++ b/neo/framework/Common_local.h @@ -436,13 +436,13 @@ class idCommonLocal : public idCommon 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 @@ class idCommonLocal : public idCommon // 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; diff --git a/neo/framework/Console.cpp b/neo/framework/Console.cpp index 6d1072361e..9a910a6f7e 100644 --- a/neo/framework/Console.cpp +++ b/neo/framework/Console.cpp @@ -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, diff --git a/neo/renderer/ImmediateMode.cpp b/neo/renderer/ImmediateMode.cpp index aa0d8cc828..ab211996da 100644 --- a/neo/renderer/ImmediateMode.cpp +++ b/neo/renderer/ImmediateMode.cpp @@ -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( tr.backend.depthBias ), tr.backend.slopeScaleBias, tr.backend.currentFrameBuffer }; diff --git a/neo/sys/DeviceManager_DX12.cpp b/neo/sys/DeviceManager_DX12.cpp index 8a62ac552f..ce9e8bfecd 100644 --- a/neo/sys/DeviceManager_DX12.cpp +++ b/neo/sys/DeviceManager_DX12.cpp @@ -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 ); diff --git a/neo/sys/DeviceManager_VK.cpp b/neo/sys/DeviceManager_VK.cpp index 375f42d4de..18a92d220d 100644 --- a/neo/sys/DeviceManager_VK.cpp +++ b/neo/sys/DeviceManager_VK.cpp @@ -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::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 From 0a3b7c93269fa9a6e1df83cc930592730285884c Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Sun, 17 Mar 2024 11:25:21 +0100 Subject: [PATCH 11/71] Show VRAM memory usage with com_showFPS > 2 in separate line --- neo/framework/Console.cpp | 6 ++++-- neo/renderer/RenderBackend.cpp | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/neo/framework/Console.cpp b/neo/framework/Console.cpp index 9a910a6f7e..6043cbddc9 100644 --- a/neo/framework/Console.cpp +++ b/neo/framework/Console.cpp @@ -376,6 +376,7 @@ float idConsoleLocal::DrawFPS( float y ) static ImVec4 colorMdGrey = ImVec4( 0.50f, 0.50f, 0.50f, 1.00f ); static ImVec4 colorDkGrey = ImVec4( 0.25f, 0.25f, 0.25f, 1.00f ); static ImVec4 colorGold = ImVec4( 0.68f, 0.63f, 0.36f, 1.00f ); + static ImVec4 colorPastelMagenta = ImVec4( 1.0f, 0.5f, 1.0f, 1.00f ); ImGui::Begin( "Performance Stats" ); @@ -450,7 +451,8 @@ 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: %llu MB", deviceManager->GetRendererString(), commonLocal.GetRendererGpuMemoryMB() ); + ImGui::TextColored( colorGold, "Device: %s", deviceManager->GetRendererString() ); + ImGui::TextColored( colorPastelMagenta, "VRAM Usage: %llu MB", commonLocal.GetRendererGpuMemoryMB() ); ImGui::TextColored( colorLtGrey, "GENERAL: views:%i draws:%i tris:%i", commonLocal.stats_frontend.c_numViews, @@ -526,7 +528,7 @@ float idConsoleLocal::DrawFPS( float y ) ImGui::TextColored( rendererGPUShaderPassesTime > maxTime ? colorRed : colorWhite, " Shader Pass: %5llu us", rendererGPUShaderPassesTime ); #endif ImGui::TextColored( rendererGPU_TAATime > maxTime ? colorRed : colorWhite, " TAA: %5llu us", rendererGPU_TAATime ); - ImGui::TextColored( rendererGPUToneMapPassTime > maxTime ? colorRed : colorWhite, " ToneMap: %5llu us", rendererGPUToneMapPassTime ); + //ImGui::TextColored( rendererGPUToneMapPassTime > maxTime ? colorRed : colorWhite, " ToneMap: %5llu us", rendererGPUToneMapPassTime ); ImGui::TextColored( rendererGPUPostProcessingTime > maxTime ? colorRed : colorWhite, " PostFX: %5llu us", rendererGPUPostProcessingTime ); ImGui::TextColored( frameBusyTime > maxTime || rendererGPUTime > maxTime ? colorRed : colorWhite, "Total: %5lld us Total: %5lld us", frameBusyTime, rendererGPUTime ); ImGui::TextColored( colorWhite, "Idle: %5lld us Idle: %5lld us", frameIdleTime, rendererGPUIdleTime ); diff --git a/neo/renderer/RenderBackend.cpp b/neo/renderer/RenderBackend.cpp index a3e5492dac..3ac00ca5d3 100644 --- a/neo/renderer/RenderBackend.cpp +++ b/neo/renderer/RenderBackend.cpp @@ -6296,7 +6296,7 @@ void idRenderBackend::PostProcess( const void* data ) blitParms.targetFramebuffer = deviceManager->GetCurrentFramebuffer(); blitParms.targetViewport = nvrhi::Viewport( renderSystem->GetWidth(), renderSystem->GetHeight() ); commonPasses.BlitTexture( commandList, blitParms, &bindingCache ); - + // copy LDR result to postProcFBO which is HDR but also used by postFX blitParms.sourceTexture = ( nvrhi::ITexture* )globalImages->ldrImage->GetTextureID(); blitParms.targetFramebuffer = globalFramebuffers.postProcFBO->GetApiObject(); From 3ac61ce5d6115ab305d51a1f772ea0abfa5ab1bf Mon Sep 17 00:00:00 2001 From: SRSaunders <82544213+SRSaunders@users.noreply.github.com> Date: Wed, 20 Mar 2024 13:49:19 -0400 Subject: [PATCH 12/71] CMakeLists: Remove redundant code for finding dxc, now handled by ShaderMake --- neo/CMakeLists.txt | 22 +++++++++++++--------- neo/compileshaders.cmake | 18 +++++++++--------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/neo/CMakeLists.txt b/neo/CMakeLists.txt index 83e8fab7fe..af813c3ad0 100644 --- a/neo/CMakeLists.txt +++ b/neo/CMakeLists.txt @@ -396,8 +396,9 @@ if(USE_VULKAN) else() include_directories(${Vulkan_INCLUDE_DIRS}) - if(Vulkan_dxc_exe_FOUND AND NOT DEFINED DXC_SPIRV_EXECUTABLE) - set(DXC_SPIRV_EXECUTABLE ${Vulkan_dxc_EXECUTABLE}) + # SRS - ShaderMake uses DXC_CUSTOM_PATH as fallback if dxc for SPIRV not found by other means + if(Vulkan_dxc_exe_FOUND AND NOT DEFINED DXC_CUSTOM_PATH) + set(DXC_CUSTOM_PATH ${Vulkan_dxc_EXECUTABLE}) endif() if(APPLE) @@ -446,18 +447,21 @@ add_definitions(-DUSE_NVRHI) set(SHADERMAKE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/extern/ShaderMake) add_subdirectory(${SHADERMAKE_DIR}) -if(USE_DX11) - find_package(FXC REQUIRED) -endif() +# SRS - ShaderMake now finds fxc when required +#if(USE_DX11) +# find_package(FXC REQUIRED) +#endif() if(USE_DX12) - find_package(DXCdxil REQUIRED) + # SRS - ShaderMake now finds dxc for DXIL when required + # find_package(DXCdxil REQUIRED) set(USE_DXIL_ON_DX12 TRUE CACHE BOOL "Use DXC to compile DXIL shaders on DX12 - otherwise FXC and DXBC") endif() -if(USE_VULKAN) - find_package(DXCspirv REQUIRED) -endif() +# SRS - ShaderMake now finds dxc for SPIRV when required +#if(USE_VULKAN) +# find_package(DXCspirv REQUIRED) +#endif() include_directories(${NVRHI_DIR}/include) include_directories(${SHADERMAKE_DIR}/include) diff --git a/neo/compileshaders.cmake b/neo/compileshaders.cmake index fcc78d3f4f..c2d10d6979 100644 --- a/neo/compileshaders.cmake +++ b/neo/compileshaders.cmake @@ -57,8 +57,8 @@ function(compile_shaders) SOURCES ${params_SOURCES}) if (params_DXIL AND (USE_DX12 AND USE_DXIL_ON_DX12)) - if (NOT DXC_DXIL_EXECUTABLE) - message(FATAL_ERROR "compile_shaders: DXC not found --- please set DXC_DXIL_EXECUTABLE to the full path to the DXC binary") + if (NOT DXC_PATH) + message(FATAL_ERROR "compile_shaders: DXC not found --- please set DXC_PATH to the full path to the DXC binary") endif() if (NOT params_CFLAGS) @@ -76,12 +76,12 @@ function(compile_shaders) --outputExt=.bin -I ${SHADER_INCLUDE_DIR} ${CFLAGS} - --compiler=${DXC_DXIL_EXECUTABLE}) + --compiler=${DXC_PATH}) endif() if (params_DXBC AND (USE_DX11 OR (USE_DX12 AND NOT USE_DXIL_ON_DX12))) - if (NOT FXC_EXECUTABLE) - message(FATAL_ERROR "compile_shaders: FXC not found --- please set FXC_EXECUTABLE to the full path to the FXC binary") + if (NOT FXC_PATH) + message(FATAL_ERROR "compile_shaders: FXC not found --- please set FXC_PATH to the full path to the FXC binary") endif() if (NOT params_CFLAGS) @@ -99,12 +99,12 @@ function(compile_shaders) --outputExt=.bin -I ${SHADER_INCLUDE_DIR} ${CFLAGS} - --compiler=${FXC_EXECUTABLE}) + --compiler=${FXC_PATH}) endif() if (params_SPIRV_DXC AND USE_VULKAN) - if (NOT DXC_SPIRV_EXECUTABLE) - message(FATAL_ERROR "compile_shaders: DXC for SPIR-V not found --- please set DXC_SPIRV_EXECUTABLE to the full path to the DXC binary") + if (NOT DXC_SPIRV_PATH) + message(FATAL_ERROR "compile_shaders: DXC for SPIR-V not found --- please set DXC_SPIRV_PATH to the full path to the DXC binary") endif() if (NOT params_CFLAGS) @@ -123,7 +123,7 @@ function(compile_shaders) -I ${SHADER_INCLUDE_DIR} -D SPIRV ${CFLAGS} - --compiler=${DXC_SPIRV_EXECUTABLE}) + --compiler=${DXC_SPIRV_PATH}) endif() if(params_FOLDER) From 5b5b6165e6eac5260a88d48770df6fe33408df11 Mon Sep 17 00:00:00 2001 From: SRSaunders <82544213+SRSaunders@users.noreply.github.com> Date: Thu, 21 Mar 2024 22:07:47 -0400 Subject: [PATCH 13/71] Extend Optick to support data tags on custom storage events --- neo/libs/optick/optick.h | 26 +++++++++++++++++++- neo/libs/optick/optick_core.cpp | 42 +++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 1 deletion(-) diff --git a/neo/libs/optick/optick.h b/neo/libs/optick/optick.h index 5042dd2094..ca5ea52ad4 100644 --- a/neo/libs/optick/optick.h +++ b/neo/libs/optick/optick.h @@ -739,11 +739,22 @@ struct OPTICK_API Tag static void Attach(const EventDescription& description, const char* val); static void Attach(const EventDescription& description, const char* val, uint16_t length); + static void Attach(EventStorage* storage, int64_t timestamp, const EventDescription& description, float val); + static void Attach(EventStorage* storage, int64_t timestamp, const EventDescription& description, int32_t val); + static void Attach(EventStorage* storage, int64_t timestamp, const EventDescription& description, uint32_t val); + static void Attach(EventStorage* storage, int64_t timestamp, const EventDescription& description, uint64_t val); + static void Attach(EventStorage* storage, int64_t timestamp, const EventDescription& description, float val[3]); + static void Attach(EventStorage* storage, int64_t timestamp, const EventDescription& description, const char* val); + // Derived static void Attach(const EventDescription& description, float x, float y, float z) { float p[3] = { x, y, z }; Attach(description, p); } + static void Attach(EventStorage* storage, int64_t timestamp, const EventDescription& description, float x, float y, float z) + { + float p[3] = { x, y, z }; Attach(storage, timestamp, description, p); + } }; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -951,7 +962,7 @@ struct OptickApp #define OPTICK_STOP_THREAD() ::Optick::UnRegisterThread(false); // Attaches a custom data-tag. -// Supported types: int32, uint32, uint64, vec3, string (cut to 32 characters) +// Supported types: float, int32, uint32, uint64, vec3, string (cut to 32 characters) // Example: // OPTICK_TAG("PlayerName", name[index]); // OPTICK_TAG("Health", 100); @@ -1028,6 +1039,18 @@ struct OptickApp #define OPTICK_STORAGE_PUSH(STORAGE, DESCRIPTION, CPU_TIMESTAMP_START) if (::Optick::IsActive()) { ::Optick::Event::Push(STORAGE, DESCRIPTION, CPU_TIMESTAMP_START); } #define OPTICK_STORAGE_POP(STORAGE, CPU_TIMESTAMP_FINISH) if (::Optick::IsActive()) { ::Optick::Event::Pop(STORAGE, CPU_TIMESTAMP_FINISH); } +// Attaches a custom data-tag to the custom storage. +// Supported types: float, int32, uint32, uint64, vec3, string (cut to 32 characters) +// Example: +// OPTICK_STORAGE_TAG(IOStorage, cpuTimestamp, "PlayerName", name[index]); +// OPTICK_STORAGE_TAG(IOStorage, cpuTimestamp, "Health", 100); +// OPTICK_STORAGE_TAG(IOStorage, cpuTimestamp, "Score", 0x80000000u); +// OPTICK_STORAGE_TAG(IOStorage, cpuTimestamp, "Height(cm)", 176.3f); +// OPTICK_STORAGE_TAG(IOStorage, cpuTimestamp, "Address", (uint64)*this); +// OPTICK_STORAGE_TAG(IOStorage, cpuTimestamp, "Position", 123.0f, 456.0f, 789.0f); +#define OPTICK_STORAGE_TAG(STORAGE, CPU_TIMESTAMP, NAME, ...) static ::Optick::EventDescription* OPTICK_CONCAT(autogen_tag_, __LINE__) = nullptr; \ + if (OPTICK_CONCAT(autogen_tag_, __LINE__) == nullptr) OPTICK_CONCAT(autogen_tag_, __LINE__) = ::Optick::EventDescription::Create( NAME, __FILE__, __LINE__ ); \ + ::Optick::Tag::Attach(STORAGE, CPU_TIMESTAMP, *OPTICK_CONCAT(autogen_tag_, __LINE__), __VA_ARGS__); \ // Registers state change callback // If callback returns false - the call is repeated the next frame @@ -1123,6 +1146,7 @@ struct OptickApp #define OPTICK_STORAGE_EVENT(STORAGE, DESCRIPTION, CPU_TIMESTAMP_START, CPU_TIMESTAMP_FINISH) #define OPTICK_STORAGE_PUSH(STORAGE, DESCRIPTION, CPU_TIMESTAMP_START) #define OPTICK_STORAGE_POP(STORAGE, CPU_TIMESTAMP_FINISH) +#define OPTICK_STORAGE_TAG(STORAGE, CPU_TIMESTAMP, NAME, ...) #define OPTICK_SET_STATE_CHANGED_CALLBACK(CALLBACK) #define OPTICK_SET_MEMORY_ALLOCATOR(ALLOCATE_FUNCTION, DEALLOCATE_FUNCTION, INIT_THREAD_CALLBACK) #define OPTICK_SHUTDOWN() diff --git a/neo/libs/optick/optick_core.cpp b/neo/libs/optick/optick_core.cpp index 3103f11aad..95acce0848 100644 --- a/neo/libs/optick/optick_core.cpp +++ b/neo/libs/optick/optick_core.cpp @@ -411,6 +411,48 @@ void Tag::Attach(const EventDescription& description, const char* val, uint16_t storage->tagStringBuffer.Add(TagString(description, val, length)); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +void Tag::Attach(EventStorage* storage, int64_t timestamp, const EventDescription& description, float val) +{ + if (EventStorage* coreStorage = Core::storage) + if (storage && (coreStorage->currentMode & Mode::TAGS)) + storage->tagFloatBuffer.Add(TagFloat(description, val, timestamp)); +} +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +void Tag::Attach(EventStorage* storage, int64_t timestamp, const EventDescription& description, int32_t val) +{ + if (EventStorage* coreStorage = Core::storage) + if (storage && (coreStorage->currentMode & Mode::TAGS)) + storage->tagS32Buffer.Add(TagS32(description, val, timestamp)); +} +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +void Tag::Attach(EventStorage* storage, int64_t timestamp, const EventDescription& description, uint32_t val) +{ + if (EventStorage* coreStorage = Core::storage) + if (storage && (coreStorage->currentMode & Mode::TAGS)) + storage->tagU32Buffer.Add(TagU32(description, val, timestamp)); +} +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +void Tag::Attach(EventStorage* storage, int64_t timestamp, const EventDescription& description, uint64_t val) +{ + if (EventStorage* coreStorage = Core::storage) + if (storage && (coreStorage->currentMode & Mode::TAGS)) + storage->tagU64Buffer.Add(TagU64(description, val, timestamp)); +} +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +void Tag::Attach(EventStorage* storage, int64_t timestamp, const EventDescription& description, float val[3]) +{ + if (EventStorage* coreStorage = Core::storage) + if (storage && (coreStorage->currentMode & Mode::TAGS)) + storage->tagPointBuffer.Add(TagPoint(description, val, timestamp)); +} +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +void Tag::Attach(EventStorage* storage, int64_t timestamp, const EventDescription& description, const char* val) +{ + if (EventStorage* coreStorage = Core::storage) + if (storage && (coreStorage->currentMode & Mode::TAGS)) + storage->tagStringBuffer.Add(TagString(description, val, timestamp)); +} +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// OutputDataStream & operator<<(OutputDataStream &stream, const EventDescription &ob) { return stream << ob.name << ob.file << ob.line << ob.filter << ob.color << (float)0.0f << ob.flags; From 997b7b5b997878f3fcd3b6149407ccd4d1cdd602 Mon Sep 17 00:00:00 2001 From: SRSaunders <82544213+SRSaunders@users.noreply.github.com> Date: Thu, 21 Mar 2024 22:19:12 -0400 Subject: [PATCH 14/71] Add Optick traces for MoltenVK command buffer submit, image acquire, and metal encoding on macOS --- neo/sys/DeviceManager_VK.cpp | 127 +++++++++++++++++++++++++++++++---- 1 file changed, 114 insertions(+), 13 deletions(-) diff --git a/neo/sys/DeviceManager_VK.cpp b/neo/sys/DeviceManager_VK.cpp index 18a92d220d..5dc078ca14 100644 --- a/neo/sys/DeviceManager_VK.cpp +++ b/neo/sys/DeviceManager_VK.cpp @@ -73,6 +73,33 @@ idCVar r_preferFastSync( "r_preferFastSync", "1", CVAR_RENDERER | CVAR_ARCHIVE | // Define the Vulkan dynamic dispatcher - this needs to occur in exactly one cpp file in the program. VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE +#if defined(__APPLE__) && defined( USE_MoltenVK ) +#if MVK_VERSION >= MVK_MAKE_VERSION( 1, 2, 9 ) && USE_OPTICK + static bool optickCapturing = false; + + // SRS - Optick callback function for notification of state changes + static bool optickStateChangedCallback( Optick::State::Type state ) + { + switch( state ) + { + case Optick::State::START_CAPTURE: + optickCapturing = true; + break; + + case Optick::State::STOP_CAPTURE: + case Optick::State::CANCEL_CAPTURE: + optickCapturing = false; + break; + + default: + break; + } + + return true; + } +#endif +#endif + class DeviceManager_VK : public DeviceManager { public: @@ -316,6 +343,20 @@ class DeviceManager_VK : public DeviceManager // SRS - function pointer for retrieving MoltenVK advanced performance statistics PFN_vkGetPerformanceStatisticsMVK vkGetPerformanceStatisticsMVK = nullptr; #endif + +#if MVK_VERSION >= MVK_MAKE_VERSION( 1, 2, 9 ) && USE_OPTICK + // SRS - Optick event storage for MoltenVK's Vulkan-to-Metal encoding thread + Optick::EventStorage* mvkAcquireEventStorage; + Optick::EventStorage* mvkSubmitEventStorage; + Optick::EventStorage* mvkEncodeEventStorage; + Optick::EventDescription* mvkAcquireEventDesc; + Optick::EventDescription* mvkSubmitEventDesc; + Optick::EventDescription* mvkEncodeEventDesc; + int64_t mvkLatestSubmitTime = 0; + int64_t mvkPreviousSubmitTime = 0; + int64_t mvkPreviousSubmitWaitTime = 0; + double mvkPreviousAcquireHash = 0.0; +#endif #endif private: @@ -1317,6 +1358,17 @@ bool DeviceManager_VK::CreateDeviceAndSwapChain() // SRS - Get function pointer for retrieving MoltenVK advanced performance statistics in DeviceManager_VK::BeginFrame() vkGetPerformanceStatisticsMVK = ( PFN_vkGetPerformanceStatisticsMVK )vkGetInstanceProcAddr( m_VulkanInstance, "vkGetPerformanceStatisticsMVK" ); #endif + +#if MVK_VERSION >= MVK_MAKE_VERSION( 1, 2, 9 ) && USE_OPTICK + // SRS - Initialize Optick event storage and descriptions for MoltenVK events + mvkAcquireEventStorage = Optick::RegisterStorage( "Mvk_ImageAcquire", uint64_t( -1 ), Optick::ThreadMask::Main ); + mvkSubmitEventStorage = Optick::RegisterStorage( "Mvk_CmdBufSubmit", uint64_t( -1 ), Optick::ThreadMask::Main ); + mvkEncodeEventStorage = Optick::RegisterStorage( "Mvk_EncodeThread", uint64_t( -1 ), Optick::ThreadMask::GPU ); + mvkAcquireEventDesc = Optick::EventDescription::CreateShared( "Acquire_Wait" ); + mvkSubmitEventDesc = Optick::EventDescription::CreateShared( "Submit_Wait" ); + mvkEncodeEventDesc = Optick::EventDescription::CreateShared( "Metal_Encode" ); + Optick::SetStateChangedCallback( ( Optick::StateCallback )optickStateChangedCallback ); +#endif #endif CHECK( createDevice() ); @@ -1447,19 +1499,6 @@ void DeviceManager_VK::BeginFrame() { OPTICK_CATEGORY( "Vulkan_BeginFrame", Optick::Category::Wait ); -#if defined(__APPLE__) && defined( USE_MoltenVK ) -#if MVK_VERSION >= MVK_MAKE_VERSION( 1, 2, 6 ) - if( vkGetPerformanceStatisticsMVK && m_DeviceApiVersion >= VK_MAKE_API_VERSION( 0, 1, 2, 268 ) ) - { - // SRS - get MoltenVK's Metal encoding time and GPU memory usage for display in statistics overlay HUD - MVKPerformanceStatistics mvkPerfStats; - 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 ) ); - } -#endif -#endif - // SRS - get Vulkan GPU memory usage for display in statistics overlay HUD vk::PhysicalDeviceMemoryProperties2 memoryProperties2; vk::PhysicalDeviceMemoryBudgetPropertiesEXT memoryBudget; @@ -1502,6 +1541,14 @@ void DeviceManager_VK::EndFrame() //m_BarrierCommandList->open(); // umm... //m_BarrierCommandList->close(); //m_NvrhiDevice->executeCommandList( m_BarrierCommandList ); + +#if defined(__APPLE__) && defined( USE_MoltenVK ) +#if MVK_VERSION >= MVK_MAKE_VERSION( 1, 2, 9 ) && USE_OPTICK + // SRS - Capture MoltenVK command buffer submit time just before executeCommandList() in idRenderBackend::GL_EndFrame() + mvkPreviousSubmitTime = mvkLatestSubmitTime; + mvkLatestSubmitTime = Optick::GetHighPrecisionTime(); +#endif +#endif } void DeviceManager_VK::Present() @@ -1570,6 +1617,60 @@ void DeviceManager_VK::Present() m_NvrhiDevice->waitEventQuery( m_FrameWaitQuery ); } } + +#if defined(__APPLE__) && defined( USE_MoltenVK ) +#if MVK_VERSION >= MVK_MAKE_VERSION( 1, 2, 6 ) + if( vkGetPerformanceStatisticsMVK ) + { + // SRS - get MoltenVK's Metal encoding time for display in statistics overlay HUD + MVKPerformanceStatistics mvkPerfStats; + size_t mvkPerfStatsSize = sizeof( mvkPerfStats ); + if( vkGetPerformanceStatisticsMVK( m_VulkanDevice, &mvkPerfStats, &mvkPerfStatsSize ) == VK_SUCCESS ) + { + uint64 mvkEncodeTime = Max( 0.0, mvkPerfStats.queue.commandBufferEncoding.latest - mvkPerfStats.queue.retrieveCAMetalDrawable.latest ) * 1000000.0; + +#if MVK_VERSION >= MVK_MAKE_VERSION( 1, 2, 9 ) && USE_OPTICK + if( optickCapturing ) + { + // SRS - create custom Optick event that displays MoltenVK's command buffer submit waiting time + OPTICK_STORAGE_EVENT( mvkSubmitEventStorage, mvkSubmitEventDesc, mvkPreviousSubmitTime, mvkPreviousSubmitTime + mvkPreviousSubmitWaitTime ); + OPTICK_STORAGE_TAG( mvkSubmitEventStorage, mvkPreviousSubmitTime + mvkPreviousSubmitWaitTime / 2, "Frame", idLib::frameNumber - 2 ); + + // SRS - select latest acquire time if hashes match and we didn't retrieve a new image, otherwise select previous acquire time + double mvkLatestAcquireHash = mvkPerfStats.queue.retrieveCAMetalDrawable.latest + mvkPerfStats.queue.retrieveCAMetalDrawable.previous; + int64_t mvkAcquireWaitTime = mvkLatestAcquireHash == mvkPreviousAcquireHash ? mvkPerfStats.queue.retrieveCAMetalDrawable.latest * 1000000.0 : mvkPerfStats.queue.retrieveCAMetalDrawable.previous * 1000000.0; + + // SRS - select latest presented frame if we are running synchronous, otherwise select previous presented frame as reference + int64_t mvkAcquireStartTime = mvkPreviousSubmitTime + mvkPreviousSubmitWaitTime; + int32_t frameNumberTag = idLib::frameNumber - 2; + if( r_mvkSynchronousQueueSubmits.GetBool() ) + { + mvkAcquireStartTime = mvkLatestSubmitTime + int64_t( mvkPerfStats.queue.waitSubmitCommandBuffers.latest * 1000000.0 ); + mvkAcquireWaitTime = mvkPerfStats.queue.retrieveCAMetalDrawable.latest * 1000000.0; + frameNumberTag = idLib::frameNumber - 1; + } + + // SRS - create custom Optick event that displays MoltenVK's image acquire waiting time + OPTICK_STORAGE_EVENT( mvkAcquireEventStorage, mvkAcquireEventDesc, mvkAcquireStartTime, mvkAcquireStartTime + mvkAcquireWaitTime ); + OPTICK_STORAGE_TAG( mvkAcquireEventStorage, mvkAcquireStartTime + mvkAcquireWaitTime / 2, "Frame", frameNumberTag ); + + // SRS - when Optick is active, use MoltenVK's previous encoding time to select game command buffer vs. Optick's command buffer + int64_t mvkEncodeStartTime = mvkAcquireStartTime + mvkAcquireWaitTime; + mvkEncodeTime = Max( int64_t( 0 ), int64_t( mvkPerfStats.queue.commandBufferEncoding.previous * 1000000.0 ) - mvkAcquireWaitTime ); + + // SRS - create custom Optick event that displays MoltenVK's Vulkan-to-Metal encoding time + OPTICK_STORAGE_EVENT( mvkEncodeEventStorage, mvkEncodeEventDesc, mvkEncodeStartTime, mvkEncodeStartTime + mvkEncodeTime ); + OPTICK_STORAGE_TAG( mvkEncodeEventStorage, mvkEncodeStartTime + mvkEncodeTime / 2, "Frame", frameNumberTag ); + + mvkPreviousSubmitWaitTime = mvkPerfStats.queue.waitSubmitCommandBuffers.latest * 1000000.0; + mvkPreviousAcquireHash = mvkLatestAcquireHash; + } +#endif + commonLocal.SetRendererMvkEncodeMicroseconds( mvkEncodeTime / 1000 ); + } + } +#endif +#endif } DeviceManager* DeviceManager::CreateVK() From 4c9c242808cc7aef7d494b7a1d261b466f24e713 Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Thu, 21 Mar 2024 22:01:31 +0100 Subject: [PATCH 15/71] Killed hard to maintain renderdemo code --- neo/d3xp/Game.h | 5 - neo/d3xp/Game_local.cpp | 73 -- neo/d3xp/Game_local.h | 5 - neo/d3xp/Game_network.cpp | 2 - neo/framework/Common.cpp | 15 +- neo/framework/Common.h | 4 - neo/framework/Common_demos.cpp | 558 -------------- neo/framework/Common_load.cpp | 8 - neo/framework/Common_local.h | 24 - neo/framework/Common_menu.cpp | 6 - neo/framework/DemoFile.cpp | 371 --------- neo/framework/DemoFile.h | 99 --- neo/framework/common_frame.cpp | 37 +- neo/idlib/precompiled.h | 1 - neo/renderer/GuiModel.cpp | 18 - neo/renderer/GuiModel.h | 3 - neo/renderer/Model.cpp | 96 --- neo/renderer/Model.h | 4 - neo/renderer/ModelDecal.cpp | 144 ---- neo/renderer/ModelDecal.h | 3 - neo/renderer/ModelOverlay.cpp | 102 --- neo/renderer/ModelOverlay.h | 3 - neo/renderer/Model_local.h | 2 - neo/renderer/RenderCommon.h | 34 - neo/renderer/RenderEntity.cpp | 197 ----- neo/renderer/RenderSystem.cpp | 66 -- neo/renderer/RenderSystem.h | 7 - neo/renderer/RenderSystem_init.cpp | 1 - neo/renderer/RenderWorld.cpp | 37 +- neo/renderer/RenderWorld.h | 13 - neo/renderer/RenderWorld_defs.cpp | 24 - neo/renderer/RenderWorld_demo.cpp | 1033 -------------------------- neo/renderer/RenderWorld_load.cpp | 6 - neo/renderer/RenderWorld_local.h | 24 - neo/renderer/RenderWorld_portals.cpp | 8 - neo/renderer/tr_frontend_main.cpp | 6 - neo/sound/snd_emitter.cpp | 76 +- neo/sound/snd_local.h | 10 - neo/sound/snd_shader.cpp | 5 - neo/sound/snd_world.cpp | 203 ----- neo/sound/sound.h | 7 - neo/ui/GuiScript.h | 2 - neo/ui/RegExp.cpp | 69 -- neo/ui/RegExp.h | 4 - neo/ui/RegExp_old.h | 92 --- neo/ui/UserInterface.cpp | 52 -- neo/ui/UserInterface.h | 4 - neo/ui/UserInterfaceLocal.h | 2 - neo/ui/Window.cpp | 275 ------- neo/ui/Window.h | 2 - 50 files changed, 7 insertions(+), 3835 deletions(-) delete mode 100644 neo/framework/Common_demos.cpp delete mode 100644 neo/framework/DemoFile.cpp delete mode 100644 neo/framework/DemoFile.h delete mode 100644 neo/renderer/RenderWorld_demo.cpp delete mode 100644 neo/ui/RegExp_old.h diff --git a/neo/d3xp/Game.h b/neo/d3xp/Game.h index e7bcc832d7..9b0abb7a14 100644 --- a/neo/d3xp/Game.h +++ b/neo/d3xp/Game.h @@ -188,11 +188,6 @@ class idGame virtual void Shell_SetGameComplete() = 0; virtual bool SkipCinematicScene() = 0; virtual bool CheckInCinematic() = 0; - - // Demo helper functions - virtual void StartDemoPlayback( idRenderWorld* renderworld ) = 0; - - virtual bool ProcessDemoCommand( idDemoFile* readDemo ) = 0; }; extern idGame* game; diff --git a/neo/d3xp/Game_local.cpp b/neo/d3xp/Game_local.cpp index 320f7c7870..f28c8afa00 100644 --- a/neo/d3xp/Game_local.cpp +++ b/neo/d3xp/Game_local.cpp @@ -2684,8 +2684,6 @@ void idGameLocal::RunFrame( idUserCmdMgr& cmdMgr, gameReturn_t& ret ) SelectTimeGroup( false ); - DemoWriteGameInfo(); - #ifdef GAME_DLL // allow changing SIMD usage on the fly if( com_forceGenericSIMD.IsModified() ) @@ -6053,17 +6051,6 @@ void idGameLocal::Shell_UpdateLeaderboard( const idLeaderboardCallback* callback } } -/* -======================== -idGameLocal::StartDemoPlayback -======================== -*/ -void idGameLocal::StartDemoPlayback( idRenderWorld* renderworld ) -{ - gameRenderWorld = renderworld; - smokeParticles->Init(); -} - /* ======================== idGameLocal::SimulateProjectiles @@ -6104,64 +6091,4 @@ bool idGameLocal::SimulateProjectiles() return moreProjectiles; } -/* -=============== -idGameLocal::DemoWriteGameInfo -=============== -*/ -void idGameLocal::DemoWriteGameInfo() -{ - if( common->WriteDemo() != NULL ) - { - common->WriteDemo()->WriteInt( DS_GAME ); - common->WriteDemo()->WriteInt( GCMD_GAMETIME ); - - common->WriteDemo()->WriteInt( previousTime ); - common->WriteDemo()->WriteInt( time ); - common->WriteDemo()->WriteInt( framenum ); - - common->WriteDemo()->WriteInt( fast.previousTime ); - common->WriteDemo()->WriteInt( fast.time ); - common->WriteDemo()->WriteInt( fast.realClientTime ); - - common->WriteDemo()->WriteInt( slow.previousTime ); - common->WriteDemo()->WriteInt( slow.time ); - common->WriteDemo()->WriteInt( slow.realClientTime ); - } -} -bool idGameLocal::ProcessDemoCommand( idDemoFile* readDemo ) -{ - gameDemoCommand_t cmd = GCMD_UNKNOWN; - - if( !readDemo->ReadInt( ( int& )cmd ) ) - { - return false; - } - - switch( cmd ) - { - case GCMD_GAMETIME: - { - readDemo->ReadInt( previousTime ); - readDemo->ReadInt( time ); - readDemo->ReadInt( framenum ); - - readDemo->ReadInt( fast.previousTime ); - readDemo->ReadInt( fast.time ); - readDemo->ReadInt( fast.realClientTime ); - - readDemo->ReadInt( slow.previousTime ); - readDemo->ReadInt( slow.time ); - readDemo->ReadInt( slow.realClientTime ); - break; - } - default: - { - common->Error( "Bad demo game command '%d' in demo stream", cmd ); - break; - } - } - - return true; -} diff --git a/neo/d3xp/Game_local.h b/neo/d3xp/Game_local.h index 68985d23ce..1b06f8d515 100644 --- a/neo/d3xp/Game_local.h +++ b/neo/d3xp/Game_local.h @@ -610,16 +610,11 @@ class idGameLocal : public idGame virtual bool SkipCinematicScene(); virtual bool CheckInCinematic(); - virtual void StartDemoPlayback( idRenderWorld* renderworld ); - - void DemoWriteGameInfo(); - enum gameDemoCommand_t { GCMD_UNKNOWN, GCMD_GAMETIME, }; - virtual bool ProcessDemoCommand( idDemoFile* readDemo ); void Shell_ClearRepeater(); diff --git a/neo/d3xp/Game_network.cpp b/neo/d3xp/Game_network.cpp index 81b42a0a14..18f23bf458 100644 --- a/neo/d3xp/Game_network.cpp +++ b/neo/d3xp/Game_network.cpp @@ -1233,8 +1233,6 @@ void idGameLocal::ClientRunFrame( idUserCmdMgr& cmdMgr, bool lastPredictFrame, g slow.Set( time, previousTime, realClientTime ); fast.Set( time, previousTime, realClientTime ); - DemoWriteGameInfo(); - // run prediction on all active entities for( ent = activeEntities.Next(); ent != NULL; ent = ent->activeNode.Next() ) { diff --git a/neo/framework/Common.cpp b/neo/framework/Common.cpp index 0c3f950f31..c6dea55e3d 100644 --- a/neo/framework/Common.cpp +++ b/neo/framework/Common.cpp @@ -194,8 +194,6 @@ idCommonLocal::idCommonLocal() : renderWorld = NULL; soundWorld = NULL; menuSoundWorld = NULL; - readDemo = NULL; - writeDemo = NULL; gameFrame = 0; gameTimeResidual = 0; @@ -1789,8 +1787,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 - if( game && ( game->IsInGame() || readDemo ) ) + if( game && game->IsInGame() ) { if( event->evType == SE_KEY && event->evValue2 == 1 && ( event->evValue == K_ESCAPE || event->evValue == K_JOY9 ) ) { @@ -1810,15 +1807,7 @@ bool idCommonLocal::ProcessEvent( const sysEvent_t* event ) console->Close(); - // SRS - cancel demo playback and return to the main menu - if( readDemo ) - { - LeaveGame(); - } - else - { - StartMenu(); - } + StartMenu(); return true; } else diff --git a/neo/framework/Common.h b/neo/framework/Common.h index dc1427586d..503f447683 100644 --- a/neo/framework/Common.h +++ b/neo/framework/Common.h @@ -71,7 +71,6 @@ class idRenderWorld; class idSoundWorld; class idSession; class idCommonDialog; -class idDemoFile; class idUserInterface; class idSaveLoadParms; class idMatchParameters; @@ -315,9 +314,6 @@ class idCommon virtual bool LoadGame( const char* saveName ) = 0; virtual bool SaveGame( const char* saveName ) = 0; - virtual idDemoFile* ReadDemo() = 0; - virtual idDemoFile* WriteDemo() = 0; - virtual idGame* Game() = 0; virtual idRenderWorld* RW() = 0; virtual idSoundWorld* SW() = 0; diff --git a/neo/framework/Common_demos.cpp b/neo/framework/Common_demos.cpp deleted file mode 100644 index 0b6ade63ad..0000000000 --- a/neo/framework/Common_demos.cpp +++ /dev/null @@ -1,558 +0,0 @@ -/* -=========================================================================== - -Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -Copyright (C) 2014-2016 Robert Beckebans -Copyright (C) 2014-2016 Kot in Action Creative Artel - -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). - -Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Doom 3 BFG Edition Source Code. If not, see . - -In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below. - -If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA. - -=========================================================================== -*/ - -#include "precompiled.h" -#pragma hdrstop - -#include "Common_local.h" - -/* -================ -FindUnusedFileName -================ -*/ -static idStr FindUnusedFileName( const char* format ) -{ - idStr filename; - - for( int i = 0 ; i < 999 ; i++ ) - { - filename.Format( format, i ); - int len = fileSystem->ReadFile( filename, NULL, NULL ); - if( len <= 0 ) - { - return filename; // file doesn't exist - } - } - - return filename; -} - -void WriteDeclCache( idDemoFile* f, int demoCategory, int demoCode, declType_t declType ) -{ - f->WriteInt( demoCategory ); - f->WriteInt( demoCode ); - - int numDecls = 0; - - for( int i = 0; i < declManager->GetNumDecls( declType ); i++ ) - { - const idDecl* decl = declManager->DeclByIndex( declType, i, false ); - if( decl && decl->IsValid() ) - { - ++numDecls; - } - } - - f->WriteInt( numDecls ); - for( int i = 0; i < declManager->GetNumDecls( declType ); i++ ) - { - const idDecl* decl = declManager->DeclByIndex( declType, i, false ); - if( decl && decl->IsValid() ) - { - f->WriteHashString( decl->GetName() ); - } - } -} - -/* -================ -idCommonLocal::StartRecordingRenderDemo -================ -*/ -void idCommonLocal::StartRecordingRenderDemo( const char* demoName ) -{ - if( writeDemo ) - { - // allow it to act like a toggle - StopRecordingRenderDemo(); - return; - } - - if( !demoName[0] ) - { - common->Printf( "idCommonLocal::StartRecordingRenderDemo: no name specified\n" ); - return; - } - - console->Close(); - - writeDemo = new( TAG_SYSTEM ) idDemoFile; - if( !writeDemo->OpenForWriting( demoName ) ) - { - common->Printf( "error opening %s\n", demoName ); - delete writeDemo; - writeDemo = NULL; - return; - } - - common->Printf( "recording to %s\n", writeDemo->GetName() ); - - writeDemo->WriteInt( DS_VERSION ); - writeDemo->WriteInt( RENDERDEMO_VERSION ); - - // if we are in a map already, dump the current state - soundWorld->StartWritingDemo( writeDemo ); - renderWorld->StartWritingDemo( writeDemo ); -} - -/* -================ -idCommonLocal::StopRecordingRenderDemo -================ -*/ -void idCommonLocal::StopRecordingRenderDemo() -{ - if( !writeDemo ) - { - common->Printf( "idCommonLocal::StopRecordingRenderDemo: not recording\n" ); - return; - } - soundWorld->StopWritingDemo(); - renderWorld->StopWritingDemo(); - - writeDemo->Close(); - common->Printf( "stopped recording %s.\n", writeDemo->GetName() ); - delete writeDemo; - writeDemo = NULL; -} - -/* -================ -idCommonLocal::StopPlayingRenderDemo - -Reports timeDemo numbers and finishes any avi recording -================ -*/ -void idCommonLocal::StopPlayingRenderDemo() -{ - if( !readDemo ) - { - timeDemo = TD_NO; - return; - } - - // Record the stop time before doing anything that could be time consuming - int timeDemoStopTime = Sys_Milliseconds(); - - readDemo->Close(); - - // SRS - free entity joints allocated by demo playback, otherwise will leak - R_FreeDerivedData(); - - soundWorld->StopAllSounds(); - soundSystem->SetPlayingSoundWorld( menuSoundWorld ); - - common->Printf( "stopped playing %s.\n", readDemo->GetName() ); - delete readDemo; - readDemo = NULL; - - if( timeDemo ) - { - // report the stats - float demoSeconds = ( timeDemoStopTime - timeDemoStartTime ) * 0.001f; - float demoFPS = numDemoFrames / demoSeconds; - idStr message = va( "%i frames rendered in %3.1f seconds = %3.1f fps\n", numDemoFrames, demoSeconds, demoFPS ); - - common->Printf( message ); - if( timeDemo == TD_YES_THEN_QUIT ) - { - cmdSystem->BufferCommandText( CMD_EXEC_APPEND, "quit\n" ); - } - timeDemo = TD_NO; - } -} - -/* -================ -idCommonLocal::DemoShot - -A demoShot is a single frame demo -================ -*/ -void idCommonLocal::DemoShot( const char* demoName ) -{ - StartRecordingRenderDemo( demoName ); - - // force draw one frame - const bool captureToImage = false; - UpdateScreen( captureToImage ); - - StopRecordingRenderDemo(); -} - -/* -================ -idCommonLocal::StartPlayingRenderDemo -================ -*/ -void idCommonLocal::StartPlayingRenderDemo( idStr demoName ) -{ - if( !demoName[0] ) - { - common->Printf( "idCommonLocal::StartPlayingRenderDemo: no name specified\n" ); - return; - } - - // make sure localSound / GUI intro music shuts up - soundWorld->StopAllSounds(); - soundWorld->PlayShaderDirectly( "", 0 ); - menuSoundWorld->StopAllSounds(); - menuSoundWorld->PlayShaderDirectly( "", 0 ); - - // exit any current game - Stop(); - - // automatically put the console away - console->Close(); - - readDemo = new( TAG_SYSTEM ) idDemoFile; - demoName.DefaultFileExtension( ".demo" ); - if( !readDemo->OpenForReading( 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 - StartMenu(); - return; - } - - int opcode = -1, demoVersion = -1; - readDemo->ReadInt( opcode ); - 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 - StartMenu(); - return; - } - - readDemo->ReadInt( demoVersion ); - if( demoVersion != RENDERDEMO_VERSION ) - { - common->Printf( "StartPlayingRenderDemo got version %d, expected version %d\n", demoVersion, RENDERDEMO_VERSION ); - readDemo->Close(); - delete readDemo; - readDemo = NULL; - - 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 - - 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 ); - - timeDemoStartTime = Sys_Milliseconds(); -} - -/* -================ -idCommonLocal::TimeRenderDemo -================ -*/ -void idCommonLocal::TimeRenderDemo( const char* demoName, bool twice, bool quit ) -{ - idStr demo = demoName; - - StartPlayingRenderDemo( demo ); - - 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 ) - { - BusyWait(); // SRS - BusyWait() calls UpdateScreen() which draws and renders out-of-sequence but still supports frame timing - commonLocal.frameTiming.finishSyncTime_EndFrame = Sys_Microseconds(); - commonLocal.mainFrameTiming = commonLocal.frameTiming; - // ** End of current logical frame ** - - // ** Start of next logical frame ** - commonLocal.frameTiming.finishSyncTime = Sys_Microseconds(); - commonLocal.frameTiming.startGameTime = commonLocal.frameTiming.finishSyncTime; - - AdvanceRenderDemo( true ); // SRS - Advance demo commands to manually run the next game frame during first pass of the timedemo - commonLocal.frameTiming.finishGameTime = Sys_Microseconds(); - - eventLoop->RunEventLoop( false ); // SRS - Run event loop (with no commands) to allow keyboard escape to cancel first pass of the timedemo - } - - StartPlayingRenderDemo( demo ); - } - - - if( !readDemo ) - { - timeDemo = TD_NO; // SRS - Make sure timeDemo flag is off if readDemo is NULL - return; - } - - if( quit ) - { - // this allows hardware vendors to automate some testing - timeDemo = TD_YES_THEN_QUIT; - } - else - { - timeDemo = TD_YES; - } -} - -/* -================ -idCommonLocal::CompressDemoFile -================ -*/ -void idCommonLocal::CompressDemoFile( const char* scheme, const char* demoName ) -{ - idStr fullDemoName = "demos/"; - fullDemoName += demoName; - fullDemoName.DefaultFileExtension( ".demo" ); - idStr compressedName = fullDemoName; - compressedName.StripFileExtension(); - compressedName.Append( "_compressed.demo" ); - - int savedCompression = cvarSystem->GetCVarInteger( "com_compressDemos" ); - bool savedPreload = cvarSystem->GetCVarBool( "com_preloadDemos" ); - cvarSystem->SetCVarBool( "com_preloadDemos", false ); - cvarSystem->SetCVarInteger( "com_compressDemos", atoi( scheme ) ); - - idDemoFile demoread, demowrite; - if( !demoread.OpenForReading( fullDemoName ) ) - { - common->Printf( "Could not open %s for reading\n", fullDemoName.c_str() ); - return; - } - if( !demowrite.OpenForWriting( compressedName ) ) - { - common->Printf( "Could not open %s for writing\n", compressedName.c_str() ); - demoread.Close(); - cvarSystem->SetCVarBool( "com_preloadDemos", savedPreload ); - cvarSystem->SetCVarInteger( "com_compressDemos", savedCompression ); - return; - } - common->SetRefreshOnPrint( true ); - common->Printf( "Compressing %s to %s...\n", fullDemoName.c_str(), compressedName.c_str() ); - - static const int bufferSize = 65535; - char buffer[bufferSize]; - int bytesRead; - while( 0 != ( bytesRead = demoread.Read( buffer, bufferSize ) ) ) - { - demowrite.Write( buffer, bytesRead ); - common->Printf( "." ); - } - - demoread.Close(); - demowrite.Close(); - - cvarSystem->SetCVarBool( "com_preloadDemos", savedPreload ); - cvarSystem->SetCVarInteger( "com_compressDemos", savedCompression ); - - common->Printf( "Done\n" ); - common->SetRefreshOnPrint( false ); - -} - -/* -=============== -idCommonLocal::AdvanceRenderDemo -=============== -*/ -void idCommonLocal::AdvanceRenderDemo( bool singleFrameOnly ) -{ - while( true ) - { - int ds = DS_FINISHED; - readDemo->ReadInt( ds ); - - switch( ds ) - { - 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; - case DS_RENDER: - if( renderWorld->ProcessDemoCommand( readDemo, ¤tDemoRenderView, &demoTimeOffset ) ) - { - // a view is ready to render - numDemoFrames++; - return; - } - break; - case DS_SOUND: - soundWorld->ProcessDemoCommand( readDemo ); - break; - case DS_GAME: - Game()->ProcessDemoCommand( readDemo ); - break; - default: - common->Error( "Bad render demo token %d", ds ); - } - } -} - -// SRS - Changed macro from CONSOLE_COMMAND to CONSOLE_COMMAND_SHIP for demo-related commands - i.e. include in release builds - -/* -================ -Common_DemoShot_f -================ -*/ -CONSOLE_COMMAND_SHIP( demoShot, "writes a screenshot as a demo", NULL ) -{ - if( args.Argc() != 2 ) - { - idStr filename = FindUnusedFileName( "demos/shot%03i.demo" ); - commonLocal.DemoShot( filename ); - } - else - { - commonLocal.DemoShot( va( "demos/shot_%s.demo", args.Argv( 1 ) ) ); - } -} - -/* -================ -Common_RecordDemo_f -================ -*/ -CONSOLE_COMMAND_SHIP( recordDemo, "records a demo", NULL ) -{ - if( args.Argc() != 2 ) - { - idStr filename = FindUnusedFileName( "demos/demo%03i.demo" ); - commonLocal.StartRecordingRenderDemo( filename ); - } - else - { - commonLocal.StartRecordingRenderDemo( va( "demos/%s.demo", args.Argv( 1 ) ) ); - } -} - -/* -================ -Common_CompressDemo_f -================ -*/ -CONSOLE_COMMAND_SHIP( compressDemo, "compresses a demo file", idCmdSystem::ArgCompletion_DemoName ) -{ - if( args.Argc() == 2 ) - { - commonLocal.CompressDemoFile( "2", args.Argv( 1 ) ); - } - else if( args.Argc() == 3 ) - { - commonLocal.CompressDemoFile( args.Argv( 2 ), args.Argv( 1 ) ); - } - else - { - common->Printf( "use: CompressDemo [scheme]\nscheme is the same as com_compressDemo, defaults to 2" ); - } -} - -/* -================ -Common_StopRecordingDemo_f -================ -*/ -CONSOLE_COMMAND_SHIP( stopRecording, "stops demo recording", NULL ) -{ - commonLocal.StopRecordingRenderDemo(); -} - -/* -================ -Common_PlayDemo_f -================ -*/ -CONSOLE_COMMAND_SHIP( playDemo, "plays back a demo", idCmdSystem::ArgCompletion_DemoName ) -{ - if( args.Argc() >= 2 ) - { - commonLocal.StartPlayingRenderDemo( va( "demos/%s", args.Argv( 1 ) ) ); - } -} - -/* -================ -Common_TimeDemo_f -================ -*/ -CONSOLE_COMMAND_SHIP( timeDemo, "times a demo", idCmdSystem::ArgCompletion_DemoName ) -{ - if( args.Argc() >= 2 ) - { - commonLocal.TimeRenderDemo( va( "demos/%s", args.Argv( 1 ) ), ( args.Argc() > 2 ), false ); - } -} - -/* -================ -Common_TimeDemoQuit_f -================ -*/ -CONSOLE_COMMAND_SHIP( timeDemoQuit, "times a demo and quits", idCmdSystem::ArgCompletion_DemoName ) -{ - commonLocal.TimeRenderDemo( va( "demos/%s", args.Argv( 1 ) ), ( args.Argc() > 2 ), true ); // SRS - fixed missing "twice" argument -} diff --git a/neo/framework/Common_load.cpp b/neo/framework/Common_load.cpp index 20304e3eb5..76c00a77de 100644 --- a/neo/framework/Common_load.cpp +++ b/neo/framework/Common_load.cpp @@ -224,19 +224,12 @@ Exits with mapSpawned = false */ void idCommonLocal::UnloadMap() { - StopPlayingRenderDemo(); - // end the current map in the game if( game ) { game->MapShutdown(); } - if( writeDemo ) - { - StopRecordingRenderDemo(); - } - mapSpawned = false; } @@ -247,7 +240,6 @@ idCommonLocal::LoadLoadingGui */ void idCommonLocal::LoadLoadingGui( const char* mapName, bool& hellMap ) { - defaultLoadscreen = false; loadGUI = new idSWF( "loading/default", NULL ); diff --git a/neo/framework/Common_local.h b/neo/framework/Common_local.h index 1084461e79..f164858910 100644 --- a/neo/framework/Common_local.h +++ b/neo/framework/Common_local.h @@ -207,15 +207,6 @@ class idCommonLocal : public idCommon virtual int ButtonState( int key ); virtual int KeyState( int key ); - virtual idDemoFile* ReadDemo() - { - return readDemo; - } - virtual idDemoFile* WriteDemo() - { - return writeDemo; - } - virtual idGame* Game() { return game; @@ -475,14 +466,6 @@ class idCommonLocal : public idCommon void StartNewGame( const char* mapName, bool devmap, int gameMode ); void LeaveGame(); - void DemoShot( const char* name ); - void StartRecordingRenderDemo( const char* name ); - void StopRecordingRenderDemo(); - void StartPlayingRenderDemo( idStr name ); - void StopPlayingRenderDemo(); - void CompressDemoFile( const char* scheme, const char* name ); - void TimeRenderDemo( const char* name, bool twice = false, bool quit = false ); - // localization void InitLanguageDict(); void LocalizeGui( const char* fileName, idLangDict& langDict ); @@ -525,11 +508,6 @@ class idCommonLocal : public idCommon idRenderWorld* renderWorld; idSoundWorld* soundWorld; - // The renderer and sound system will write changes to writeDemo. - // Demos can be recorded and played at the same time when splicing. - idDemoFile* readDemo; - idDemoFile* writeDemo; - bool menuActive; idSoundWorld* menuSoundWorld; // so the game soundWorld can be muted @@ -723,8 +701,6 @@ class idCommonLocal : public idCommon void StartMenu( bool playIntro = false ); void GuiFrameEvents(); - void AdvanceRenderDemo( bool singleFrameOnly ); - void ProcessGameReturn( const gameReturn_t& ret ); void RunNetworkSnapshotFrame(); diff --git a/neo/framework/Common_menu.cpp b/neo/framework/Common_menu.cpp index 625f22a017..d25158b615 100644 --- a/neo/framework/Common_menu.cpp +++ b/neo/framework/Common_menu.cpp @@ -150,12 +150,6 @@ void idCommonLocal::StartMenu( bool playIntro ) return; } - if( readDemo ) - { - // if we're playing a demo, esc kills it - UnloadMap(); - } - if( game ) { game->Shell_Show( true ); diff --git a/neo/framework/DemoFile.cpp b/neo/framework/DemoFile.cpp deleted file mode 100644 index 53703a54a5..0000000000 --- a/neo/framework/DemoFile.cpp +++ /dev/null @@ -1,371 +0,0 @@ -/* -=========================================================================== - -Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. - -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). - -Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Doom 3 BFG Edition Source Code. If not, see . - -In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below. - -If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA. - -=========================================================================== -*/ - -#include "precompiled.h" -#pragma hdrstop - -idCVar idDemoFile::com_logDemos( "com_logDemos", "0", CVAR_SYSTEM | CVAR_BOOL, "Write demo.log with debug information in it" ); -idCVar idDemoFile::com_compressDemos( "com_compressDemos", "1", CVAR_SYSTEM | CVAR_INTEGER | CVAR_ARCHIVE, "Compression scheme for demo files\n0: None (Fast, large files)\n1: LZW (Fast to compress, Fast to decompress, medium/small files)\n2: LZSS (Slow to compress, Fast to decompress, small files)\n3: Huffman (Fast to compress, Slow to decompress, medium files)\nSee also: The 'CompressDemo' command" ); -idCVar idDemoFile::com_preloadDemos( "com_preloadDemos", "0", CVAR_SYSTEM | CVAR_BOOL | CVAR_ARCHIVE, "Load the whole demo in to RAM before running it" ); - -#define DEMO_MAGIC GAME_NAME " RDEMO" - -/* -================ -idDemoFile::idDemoFile -================ -*/ -idDemoFile::idDemoFile() -{ - f = NULL; - fLog = NULL; - log = false; - fileImage = NULL; - compressor = NULL; - writing = false; -} - -/* -================ -idDemoFile::~idDemoFile -================ -*/ -idDemoFile::~idDemoFile() -{ - Close(); -} - -/* -================ -idDemoFile::AllocCompressor -================ -*/ -idCompressor* idDemoFile::AllocCompressor( int type ) -{ - switch( type ) - { - case 0: - return idCompressor::AllocNoCompression(); - default: - case 1: - return idCompressor::AllocLZW(); - case 2: - return idCompressor::AllocLZSS(); - case 3: - return idCompressor::AllocHuffman(); - } -} - -/* -================ -idDemoFile::OpenForReading -================ -*/ -bool idDemoFile::OpenForReading( const char* fileName ) -{ - static const int magicLen = sizeof( DEMO_MAGIC ) / sizeof( DEMO_MAGIC[0] ); - char magicBuffer[magicLen]; - int compression; - int fileLength; - - Close(); - - f = fileSystem->OpenFileRead( fileName ); - if( !f ) - { - return false; - } - - fileLength = f->Length(); - - if( com_preloadDemos.GetBool() ) - { - fileImage = ( byte* )Mem_Alloc( fileLength, TAG_CRAP ); - f->Read( fileImage, fileLength ); - fileSystem->CloseFile( f ); - f = new( TAG_SYSTEM ) idFile_Memory( va( "preloaded(%s)", fileName ), ( const char* )fileImage, fileLength ); - } - - if( com_logDemos.GetBool() ) - { - fLog = fileSystem->OpenFileWrite( "demoread.log" ); - } - - writing = false; - - f->Read( magicBuffer, magicLen ); - if( memcmp( magicBuffer, DEMO_MAGIC, magicLen ) == 0 ) - { - f->ReadInt( compression ); - } - else - { - // Ideally we would error out if the magic string isn't there, - // but for backwards compatibility we are going to assume it's just an uncompressed demo file - compression = 0; - f->Rewind(); - } - - compressor = AllocCompressor( compression ); - compressor->Init( f, false, 8 ); - - return true; -} - -/* -================ -idDemoFile::SetLog -================ -*/ -void idDemoFile::SetLog( bool b, const char* p ) -{ - log = b; - if( p ) - { - logStr = p; - } -} - -/* -================ -idDemoFile::Log -================ -*/ -void idDemoFile::Log( const char* p ) -{ - if( fLog && p && *p ) - { - fLog->Write( p, strlen( p ) ); - } -} - -/* -================ -idDemoFile::OpenForWriting -================ -*/ -bool idDemoFile::OpenForWriting( const char* fileName ) -{ - Close(); - - f = fileSystem->OpenFileWrite( fileName ); - if( f == NULL ) - { - return false; - } - - if( com_logDemos.GetBool() ) - { - fLog = fileSystem->OpenFileWrite( "demowrite.log" ); - } - - writing = true; - - f->Write( DEMO_MAGIC, sizeof( DEMO_MAGIC ) ); - f->WriteInt( com_compressDemos.GetInteger() ); - f->Flush(); - - compressor = AllocCompressor( com_compressDemos.GetInteger() ); - compressor->Init( f, true, 8 ); - - return true; -} - -/* -================ -idDemoFile::Close -================ -*/ -void idDemoFile::Close() -{ - if( writing && compressor ) - { - compressor->FinishCompress(); - } - - if( f ) - { - fileSystem->CloseFile( f ); - f = NULL; - } - if( fLog ) - { - fileSystem->CloseFile( fLog ); - fLog = NULL; - } - if( fileImage ) - { - Mem_Free( fileImage ); - fileImage = NULL; - } - if( compressor ) - { - delete compressor; - compressor = NULL; - } - - demoStrings.DeleteContents( true ); -} - -/* -================ -idDemoFile::ReadHashString -================ -*/ -const char* idDemoFile::ReadHashString() -{ - int index; - - if( log && fLog ) - { - const char* text = va( "%s > Reading hash string\n", logStr.c_str() ); - fLog->Write( text, strlen( text ) ); - } - - ReadInt( index ); - - if( index == -1 ) - { - // read a new string for the table - idStr* str = new( TAG_SYSTEM ) idStr; - - idStr data; - ReadString( data ); - *str = data; - - demoStrings.Append( str ); - - return *str; - } - - if( index < -1 || index >= demoStrings.Num() ) - { - Close(); - common->Error( "demo hash index out of range" ); - } - - return demoStrings[index]->c_str(); -} - -/* -================ -idDemoFile::WriteHashString -================ -*/ -void idDemoFile::WriteHashString( const char* str ) -{ - if( log && fLog ) - { - const char* text = va( "%s > Writing hash string\n", logStr.c_str() ); - fLog->Write( text, strlen( text ) ); - } - // see if it is already in the has table - for( int i = 0 ; i < demoStrings.Num() ; i++ ) - { - if( !strcmp( demoStrings[i]->c_str(), str ) ) - { - WriteInt( i ); - return; - } - } - - // add it to our table and the demo table - idStr* copy = new( TAG_SYSTEM ) idStr( str ); -//common->Printf( "hash:%i = %s\n", demoStrings.Num(), str ); - demoStrings.Append( copy ); - int cmd = -1; - WriteInt( cmd ); - WriteString( str ); -} - -/* -================ -idDemoFile::ReadDict -================ -*/ -void idDemoFile::ReadDict( idDict& dict ) -{ - int i, c; - idStr key, val; - - dict.Clear(); - ReadInt( c ); - for( i = 0; i < c; i++ ) - { - key = ReadHashString(); - val = ReadHashString(); - dict.Set( key, val ); - } -} - -/* -================ -idDemoFile::WriteDict -================ -*/ -void idDemoFile::WriteDict( const idDict& dict ) -{ - int i, c; - - c = dict.GetNumKeyVals(); - WriteInt( c ); - for( i = 0; i < c; i++ ) - { - WriteHashString( dict.GetKeyVal( i )->GetKey() ); - WriteHashString( dict.GetKeyVal( i )->GetValue() ); - } -} - -/* - ================ - idDemoFile::Read - ================ - */ -int idDemoFile::Read( void* buffer, int len ) -{ - int read = compressor->Read( buffer, len ); - if( read == 0 && len >= 4 ) - { - *( demoSystem_t* )buffer = DS_FINISHED; - } - return read; -} - -/* - ================ - idDemoFile::Write - ================ - */ -int idDemoFile::Write( const void* buffer, int len ) -{ - return compressor->Write( buffer, len ); -} - - - - diff --git a/neo/framework/DemoFile.h b/neo/framework/DemoFile.h deleted file mode 100644 index 443eba3cbe..0000000000 --- a/neo/framework/DemoFile.h +++ /dev/null @@ -1,99 +0,0 @@ -/* -=========================================================================== - -Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -Copyright (C) 2014-2016 Robert Beckebans -Copyright (C) 2014-2016 Kot in Action Creative Artel - -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). - -Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Doom 3 BFG Edition Source Code. If not, see . - -In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below. - -If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA. - -=========================================================================== -*/ - -#ifndef __DEMOFILE_H__ -#define __DEMOFILE_H__ - -/* -=============================================================================== - - Demo file - -=============================================================================== -*/ - -typedef enum -{ - DS_FINISHED, - DS_RENDER, - DS_SOUND, - DS_GAME, - DS_VERSION -} demoSystem_t; - -class idDemoFile : public idFile -{ -public: - idDemoFile(); - ~idDemoFile(); - - const char* GetName() - { - return ( f ? f->GetName() : "" ); - } - const char* GetFullPath() - { - return ( f ? f->GetFullPath() : "" ); - } - - void SetLog( bool b, const char* p ); - void Log( const char* p ); - bool OpenForReading( const char* fileName ); - bool OpenForWriting( const char* fileName ); - void Close(); - - const char* ReadHashString(); - void WriteHashString( const char* str ); - - void ReadDict( idDict& dict ); - void WriteDict( const idDict& dict ); - - int Read( void* buffer, int len ); - int Write( const void* buffer, int len ); - -private: - static idCompressor* AllocCompressor( int type ); - - bool writing; - byte* fileImage; - idFile* f; - idCompressor* compressor; - - idList demoStrings; - idFile* fLog; - bool log; - idStr logStr; - - static idCVar com_logDemos; - static idCVar com_compressDemos; - static idCVar com_preloadDemos; -}; - -#endif /* !__DEMOFILE_H__ */ diff --git a/neo/framework/common_frame.cpp b/neo/framework/common_frame.cpp index 16d1165f49..aa087ea5c2 100644 --- a/neo/framework/common_frame.cpp +++ b/neo/framework/common_frame.cpp @@ -344,13 +344,8 @@ void idCommonLocal::Draw() } game->Shell_Render(); } - else if( readDemo ) - { // SRS - Advance demo inside Frame() instead of Draw() to support smp mode playback // AdvanceRenderDemo( true ); - renderWorld->RenderScene( ¤tDemoRenderView ); - renderSystem->DrawDemoPics(); - } else if( mapSpawned ) { bool gameDraw = false; @@ -371,13 +366,6 @@ void idCommonLocal::Draw() renderSystem->SetColor( colorBlack ); renderSystem->DrawStretchPic( 0, 0, renderSystem->GetVirtualWidth(), renderSystem->GetVirtualHeight(), 0, 0, 1, 1, whiteMaterial ); } - - // save off the 2D drawing from the game - if( writeDemo ) - { - renderSystem->WriteDemoPics(); - renderSystem->WriteEndFrame(); - } } else { @@ -674,9 +662,7 @@ void idCommonLocal::Frame() gameTimeResidual += clampedDeltaMilliseconds * timescale.GetFloat(); // 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 - if( pauseGame && ( !( readDemo && !timeDemo ) || session->IsSystemUIShowing() || com_pause.GetInteger() ) ) + if( pauseGame ) { gameFrame++; gameTimeResidual = 0; @@ -741,12 +727,6 @@ void idCommonLocal::Frame() } } - // jpcy: playDemo uses the game frame wait logic, but shouldn't run any game frames - if( readDemo && !timeDemo ) - { - numGameFrames = 0; - } - //-------------------------------------------- // It would be better to push as much of this as possible // either before or after the renderSystem->SwapCommandBuffers(), @@ -787,18 +767,6 @@ 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; - } - } - //-------------------------------------------- // Prepare usercmds and kick off the game processing // in a background thread @@ -898,8 +866,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 - if( pauseGame && !( readDemo && !timeDemo ) ) + if( pauseGame ) { soundWorld->Pause(); soundSystem->SetPlayingSoundWorld( menuSoundWorld ); diff --git a/neo/idlib/precompiled.h b/neo/idlib/precompiled.h index 583e4a6dd3..f90ff22488 100644 --- a/neo/idlib/precompiled.h +++ b/neo/idlib/precompiled.h @@ -175,7 +175,6 @@ constexpr uint32 NUM_FRAME_DATA = 3; #include "../framework/EditField.h" #include "../framework/DebugGraph.h" #include "../framework/Console.h" - #include "../framework/DemoFile.h" #include "../framework/Common_dialog.h" #endif /* !GAME_DLL */ diff --git a/neo/renderer/GuiModel.cpp b/neo/renderer/GuiModel.cpp index fc83ca3fba..1a7e5a276e 100644 --- a/neo/renderer/GuiModel.cpp +++ b/neo/renderer/GuiModel.cpp @@ -65,24 +65,6 @@ void idGuiModel::Clear() AdvanceSurf(); } -/* -================ -idGuiModel::WriteToDemo -================ -*/ -void idGuiModel::WriteToDemo( idDemoFile* demo ) -{ -} - -/* -================ -idGuiModel::ReadFromDemo -================ -*/ -void idGuiModel::ReadFromDemo( idDemoFile* demo ) -{ -} - /* ================ idGuiModel::BeginFrame diff --git a/neo/renderer/GuiModel.h b/neo/renderer/GuiModel.h index d3a9b22991..8fe5f03bd9 100644 --- a/neo/renderer/GuiModel.h +++ b/neo/renderer/GuiModel.h @@ -52,9 +52,6 @@ class idGuiModel void Clear(); - void WriteToDemo( idDemoFile* demo ); - void ReadFromDemo( idDemoFile* demo ); - // allocates memory for verts and indexes in frame-temporary buffer memory void BeginFrame(); diff --git a/neo/renderer/Model.cpp b/neo/renderer/Model.cpp index 8842419929..9b3aa05d51 100644 --- a/neo/renderer/Model.cpp +++ b/neo/renderer/Model.cpp @@ -3713,102 +3713,6 @@ void idRenderModelStatic::FreeVertexCache() } } -/* -================ -idRenderModelStatic::ReadFromDemoFile -================ -*/ -void idRenderModelStatic::ReadFromDemoFile( class idDemoFile* f ) -{ - PurgeModel(); - - InitEmpty( f->ReadHashString() ); - - int i, j, numSurfaces; - f->ReadInt( numSurfaces ); - - for( i = 0; i < numSurfaces; i++ ) - { - modelSurface_t surf; - - surf.shader = declManager->FindMaterial( f->ReadHashString() ); - - srfTriangles_t* tri = R_AllocStaticTriSurf(); - - f->ReadInt( tri->numIndexes ); - R_AllocStaticTriSurfIndexes( tri, tri->numIndexes ); - for( j = 0; j < tri->numIndexes; ++j ) - { - f->ReadInt( ( int& )tri->indexes[j] ); - } - - f->ReadInt( tri->numVerts ); - R_AllocStaticTriSurfVerts( tri, tri->numVerts ); - - idVec3 tNormal, tTangent, tBiTangent; - for( j = 0; j < tri->numVerts; ++j ) - { - f->ReadVec3( tri->verts[j].xyz ); - f->ReadBigArray( tri->verts[j].st, 2 ); - f->ReadBigArray( tri->verts[j].normal, 4 ); - f->ReadBigArray( tri->verts[j].tangent, 4 ); - f->ReadUnsignedChar( tri->verts[j].color[0] ); - f->ReadUnsignedChar( tri->verts[j].color[1] ); - f->ReadUnsignedChar( tri->verts[j].color[2] ); - f->ReadUnsignedChar( tri->verts[j].color[3] ); - } - - surf.geometry = tri; - - this->AddSurface( surf ); - } - - // RB: don't use mikktspace here because it is slower - this->FinishSurfaces( false ); -} - -/* -================ -idRenderModelStatic::WriteToDemoFile -================ -*/ -void idRenderModelStatic::WriteToDemoFile( class idDemoFile* f ) -{ - // note that it has been updated - lastArchivedFrame = tr.frameCount; - - f->WriteHashString( this->Name() ); - - int i, j, iData = surfaces.Num(); - f->WriteInt( iData ); - - for( i = 0; i < surfaces.Num(); i++ ) - { - const modelSurface_t* surf = &surfaces[i]; - - f->WriteHashString( surf->shader->GetName() ); - - srfTriangles_t* tri = surf->geometry; - f->WriteInt( tri->numIndexes ); - for( j = 0; j < tri->numIndexes; ++j ) - { - f->WriteInt( ( int& )tri->indexes[j] ); - } - f->WriteInt( tri->numVerts ); - for( j = 0; j < tri->numVerts; ++j ) - { - f->WriteVec3( tri->verts[j].xyz ); - f->WriteBigArray( tri->verts[j].st, 2 ); - f->WriteBigArray( tri->verts[j].normal, 4 ); - f->WriteBigArray( tri->verts[j].tangent, 4 ); - f->WriteUnsignedChar( tri->verts[j].color[0] ); - f->WriteUnsignedChar( tri->verts[j].color[1] ); - f->WriteUnsignedChar( tri->verts[j].color[2] ); - f->WriteUnsignedChar( tri->verts[j].color[3] ); - } - } -} - /* ================ idRenderModelStatic::IsLoaded diff --git a/neo/renderer/Model.h b/neo/renderer/Model.h index 4a51a05d81..76c81431fa 100644 --- a/neo/renderer/Model.h +++ b/neo/renderer/Model.h @@ -291,10 +291,6 @@ class idRenderModel // Returns number of the joint nearest to the given triangle. virtual int NearestJoint( int surfaceNum, int a, int c, int b ) const = 0; - // Writing to and reading from a demo file. - virtual void ReadFromDemoFile( class idDemoFile* f ) = 0; - virtual void WriteToDemoFile( class idDemoFile* f ) = 0; - // if false, the model doesn't need to be linked into the world, because it // can't contribute visually -- triggers, etc virtual bool ModelHasDrawingSurfaces() const diff --git a/neo/renderer/ModelDecal.cpp b/neo/renderer/ModelDecal.cpp index 12bdcb342e..ad1244a29e 100644 --- a/neo/renderer/ModelDecal.cpp +++ b/neo/renderer/ModelDecal.cpp @@ -885,148 +885,4 @@ drawSurf_t* idRenderModelDecal::CreateDecalDrawSurf( const viewEntity_t* space, return drawSurf; } -/* -==================== -idRenderModelDecal::ReadFromDemoFile -==================== -*/ -void idRenderModelDecal::ReadFromDemoFile( idDemoFile* f ) -{ - f->ReadUnsignedInt( firstDecal ); - f->ReadUnsignedInt( nextDecal ); - - for( unsigned int i = firstDecal; i < nextDecal; i++ ) - { - decal_t& decal = decals[ i & ( MAX_DECALS - 1 ) ]; - - bool decalWritten = false; - f->ReadBool( decalWritten ); - if( !decalWritten ) - { - continue; - } - - f->ReadInt( decal.startTime ); // TODO: Figure out what this needs to be. - - const char* matName = f->ReadHashString(); - decal.material = matName[ 0 ] ? declManager->FindMaterial( matName ) : NULL; - - f->ReadInt( decal.numVerts ); - for( int j = 0; j < decal.numVerts; j++ ) - { - f->Read( &decal.verts[ j ], sizeof( idDrawVert ) ); - } - f->ReadInt( decal.numIndexes ); - for( int j = 0; j < decal.numIndexes; j++ ) - { - f->Read( &decal.indexes[ j ], sizeof( triIndex_t ) ); - } - - f->Read( decal.vertDepthFade, sizeof( float )*MAX_DECAL_VERTS ); - } - - f->ReadUnsignedInt( firstDeferredDecal ); - f->ReadUnsignedInt( nextDeferredDecal ); - for( unsigned int i = firstDeferredDecal; i < nextDeferredDecal; i++ ) - { - decalProjectionParms_t& deferredDecal = deferredDecals[ i & ( MAX_DEFERRED_DECALS - 1 ) ]; - f->ReadInt( deferredDecal.startTime ); - f->ReadBool( deferredDecal.parallel ); - f->ReadBool( deferredDecal.force ); - f->Read( deferredDecal.boundingPlanes, sizeof( idPlane )*NUM_DECAL_BOUNDING_PLANES ); - f->ReadVec4( deferredDecal.fadePlanes[ 0 ].ToVec4() ); - f->ReadVec4( deferredDecal.fadePlanes[ 1 ].ToVec4() ); - f->ReadVec4( deferredDecal.textureAxis[ 0 ].ToVec4() ); - f->ReadVec4( deferredDecal.textureAxis[ 1 ].ToVec4() ); - f->ReadVec3( deferredDecal.projectionOrigin ); - f->ReadFloat( deferredDecal.fadeDepth ); - - const char* matName = f->ReadHashString(); - deferredDecal.material = matName[ 0 ] ? declManager->FindMaterial( matName ) : NULL; - } - - f->ReadUnsignedInt( numDecalMaterials ); - for( unsigned int i = 0; i < numDecalMaterials; i++ ) - { - const char* matName = f->ReadHashString(); - decalMaterials[ i ] = matName[ 0 ] ? declManager->FindMaterial( matName ) : NULL; - } -} - -/* -==================== -idRenderModelDecal::WriteToDemoFile -==================== -*/ -void idRenderModelDecal::WriteToDemoFile( idDemoFile* f ) const -{ - unsigned int i = 0; - int j = 0; - int nDecal = nextDecal; - if( nextDecal - firstDecal > MAX_DECALS ) - { - nDecal = nextDecal - MAX_DECALS; - } - f->WriteUnsignedInt( firstDecal ); - f->WriteUnsignedInt( nextDecal ); - - for( unsigned int i = firstDecal; i < nextDecal; i++ ) - { - const decal_t& decal = decals[ i & ( MAX_DECALS - 1 ) ]; - - if( decal.writtenToDemo ) - { - f->WriteBool( false ); - continue; - } - - f->WriteBool( true ); - f->WriteInt( decal.startTime ); - f->WriteHashString( decal.material ? decal.material->GetName() : "" ); - - f->WriteInt( decal.numVerts ); - if( decal.numVerts ) - { - for( j = 0; j < decal.numVerts; j++ ) - { - f->Write( &decal.verts[ j ], sizeof( idDrawVert ) ); - } - } - f->WriteInt( decal.numIndexes ); - if( decal.numIndexes ) - { - for( j = 0; j < decal.numIndexes; j++ ) - { - f->Write( &decal.indexes[ j ], sizeof( triIndex_t ) ); - } - } - f->Write( decal.vertDepthFade, sizeof( float )*MAX_DECAL_VERTS ); - - decal.writtenToDemo = true; - } - - f->WriteUnsignedInt( firstDeferredDecal ); - f->WriteUnsignedInt( nextDeferredDecal ); - for( i = firstDeferredDecal; i < nextDeferredDecal; i++ ) - { - const decalProjectionParms_t& deferredDecal = deferredDecals[ i & ( MAX_DEFERRED_DECALS - 1 ) ]; - f->WriteInt( deferredDecal.startTime ); - f->WriteBool( deferredDecal.parallel ); - f->WriteBool( deferredDecal.force ); - f->Write( deferredDecal.boundingPlanes, sizeof( idPlane )*NUM_DECAL_BOUNDING_PLANES ); - f->WriteVec4( deferredDecal.fadePlanes[ 0 ].ToVec4() ); - f->WriteVec4( deferredDecal.fadePlanes[ 1 ].ToVec4() ); - f->WriteVec4( deferredDecal.textureAxis[ 0 ].ToVec4() ); - f->WriteVec4( deferredDecal.textureAxis[ 1 ].ToVec4() ); - f->WriteVec3( deferredDecal.projectionOrigin ); - f->WriteFloat( deferredDecal.fadeDepth ); - f->WriteHashString( deferredDecal.material ? deferredDecal.material->GetName() : "" ); - } - - f->WriteUnsignedInt( numDecalMaterials ); - for( i = 0; i < numDecalMaterials; i++ ) - { - f->WriteHashString( decalMaterials[ i ] ? decalMaterials[ i ]->GetName() : "" ); - } -} diff --git a/neo/renderer/ModelDecal.h b/neo/renderer/ModelDecal.h index 27f92b0961..61ab56a62b 100644 --- a/neo/renderer/ModelDecal.h +++ b/neo/renderer/ModelDecal.h @@ -126,9 +126,6 @@ class idRenderModelDecal unsigned int GetNumDecalDrawSurfs(); struct drawSurf_t* CreateDecalDrawSurf( const struct viewEntity_t* space, unsigned int index ); - void ReadFromDemoFile( class idDemoFile* f ); - void WriteToDemoFile( class idDemoFile* f ) const; - qhandle_t index; // Used for Demo files. int demoSerialWrite; int demoSerialCurrent; diff --git a/neo/renderer/ModelOverlay.cpp b/neo/renderer/ModelOverlay.cpp index 4cfdd1e0a7..54d17c63a6 100644 --- a/neo/renderer/ModelOverlay.cpp +++ b/neo/renderer/ModelOverlay.cpp @@ -796,106 +796,4 @@ drawSurf_t* idRenderModelOverlay::CreateOverlayDrawSurf( const viewEntity_t* spa return drawSurf; } -/* -==================== -idRenderModelOverlay::ReadFromDemoFile -==================== -*/ -void idRenderModelOverlay::ReadFromDemoFile( idDemoFile* f ) -{ - f->ReadUnsignedInt( firstOverlay ); - f->ReadUnsignedInt( nextOverlay ); - - for( unsigned int i = firstOverlay; i < nextOverlay; i++ ) - { - overlay_t& overlay = overlays[ i & ( MAX_OVERLAYS - 1 ) ]; - - bool overlayWritten = false; - f->ReadBool( overlayWritten ); - if( !overlayWritten ) - { - continue; - } - - f->ReadInt( overlay.surfaceNum ); - f->ReadInt( overlay.surfaceId ); - f->ReadInt( overlay.maxReferencedVertex ); - - const char* matName = f->ReadHashString(); - overlay.material = matName[ 0 ] ? declManager->FindMaterial( matName ) : NULL; - - int numVerts = 0; - int numIndices = 0; - - f->ReadInt( numVerts ); - - if( numVerts > 0 ) - { - if( overlay.numVerts != numVerts ) - { - Mem_Free( overlay.verts ); - overlay.numVerts = numVerts; - overlay.verts = ( overlayVertex_t* )Mem_Alloc( overlay.numVerts * sizeof( overlayVertex_t ), TAG_MODEL ); - } - - f->Read( overlay.verts, sizeof( overlayVertex_t ) * overlay.numVerts ); - } - - f->ReadInt( numIndices ); - - if( numIndices > 0 ) - { - if( overlay.numIndexes != numIndices ) - { - Mem_Free( overlay.indexes ); - overlay.numIndexes = numIndices; - overlay.indexes = ( triIndex_t* )Mem_Alloc( overlay.numIndexes * sizeof( triIndex_t ), TAG_MODEL ); - } - - f->Read( overlay.indexes, sizeof( triIndex_t ) * overlay.numIndexes ); - } - } -} - -/* -==================== -idRenderModelOverlay::WriteToDemoFile -==================== -*/ -void idRenderModelOverlay::WriteToDemoFile( idDemoFile* f ) const -{ - f->WriteUnsignedInt( firstOverlay ); - f->WriteUnsignedInt( nextOverlay ); - - for( unsigned int i = firstOverlay; i < nextOverlay; i++ ) - { - const overlay_t& overlay = overlays[ i & ( MAX_OVERLAYS - 1 ) ]; - if( overlay.writtenToDemo ) - { - f->WriteBool( false ); - continue; - } - - f->WriteBool( true ); - f->WriteInt( overlay.surfaceNum ); - f->WriteInt( overlay.surfaceId ); - f->WriteInt( overlay.maxReferencedVertex ); - f->WriteHashString( overlay.material ? overlay.material->GetName() : "" ); - - f->WriteInt( overlay.numVerts ); - for( int j = 0; j < overlay.numVerts; j++ ) - { - f->Write( &overlay.verts[ j ], sizeof( overlayVertex_t ) ); - } - - f->WriteInt( overlay.numIndexes ); - for( int j = 0; j < overlay.numIndexes; j++ ) - { - f->Write( &overlay.indexes[ j ], sizeof( triIndex_t ) ); - } - - // so it won't be written again - overlay.writtenToDemo = true; - } -} diff --git a/neo/renderer/ModelOverlay.h b/neo/renderer/ModelOverlay.h index 1b2bdc13a4..89cda50663 100644 --- a/neo/renderer/ModelOverlay.h +++ b/neo/renderer/ModelOverlay.h @@ -95,9 +95,6 @@ class idRenderModelOverlay unsigned int GetNumOverlayDrawSurfs(); struct drawSurf_t* CreateOverlayDrawSurf( const struct viewEntity_t* space, const idRenderModel* baseModel, unsigned int index ); - void ReadFromDemoFile( class idDemoFile* f ); - void WriteToDemoFile( class idDemoFile* f ) const; - int index; int demoSerialWrite; int demoSerialCurrent; diff --git a/neo/renderer/Model_local.h b/neo/renderer/Model_local.h index cb5eead01e..a2cb9e9406 100644 --- a/neo/renderer/Model_local.h +++ b/neo/renderer/Model_local.h @@ -100,8 +100,6 @@ class idRenderModelStatic : public idRenderModel virtual const idJointQuat* GetDefaultPose() const; virtual int NearestJoint( int surfaceNum, int a, int b, int c ) const; virtual idBounds Bounds( const struct renderEntity_s* ent ) const; - virtual void ReadFromDemoFile( class idDemoFile* f ); - virtual void WriteToDemoFile( class idDemoFile* f ); virtual float DepthHack() const; virtual bool ModelHasDrawingSurfaces() const diff --git a/neo/renderer/RenderCommon.h b/neo/renderer/RenderCommon.h index 0775d0a3aa..f45f845c1b 100644 --- a/neo/renderer/RenderCommon.h +++ b/neo/renderer/RenderCommon.h @@ -52,34 +52,6 @@ const int FOG_ENTER_SIZE = 64; const float FOG_ENTER = ( FOG_ENTER_SIZE + 1.0f ) / ( FOG_ENTER_SIZE * 2 ); -enum demoCommand_t -{ - DC_BAD, - DC_RENDERVIEW, - DC_UPDATE_ENTITYDEF, - DC_DELETE_ENTITYDEF, - DC_UPDATE_LIGHTDEF, - DC_DELETE_LIGHTDEF, - DC_LOADMAP, - DC_CROP_RENDER, - DC_UNCROP_RENDER, - DC_CAPTURE_RENDER, - DC_END_FRAME, - DC_DEFINE_MODEL, - DC_SET_PORTAL_STATE, - DC_UPDATE_SOUNDOCCLUSION, - DC_GUI_MODEL, - DC_UPDATE_ENVPROBEDEF, - DC_DELETE_ENVPROBEDEF, - DC_UPDATE_DECAL, - DC_DELETE_DECAL, - DC_UPDATE_OVERLAY, - DC_DELETE_OVERLAY, - DC_CACHE_SKINS, - DC_CACHE_PARTICLES, - DC_CACHE_MATERIALS, -}; - /* ============================================================================== @@ -300,8 +272,6 @@ class idRenderEntityLocal : public idRenderEntity virtual void RemoveDecals(); bool IsDirectlyVisible() const; - void ReadFromDemoFile( class idDemoFile* f ); - void WriteToDemoFile( class idDemoFile* f ) const; renderEntity_t parms; float modelMatrix[16]; // this is just a rearrangement of parms.axis and parms.origin @@ -942,9 +912,6 @@ class idRenderSystemLocal : public idRenderSystem virtual void DrawCRTPostFX(); // RB - virtual void WriteDemoPics(); - virtual void WriteEndFrame(); - virtual void DrawDemoPics(); virtual const emptyCommand_t* SwapCommandBuffers( uint64* frontEndMicroSec, uint64* backEndMicroSec, uint64* shadowMicroSec, uint64* gpuMicroSec, backEndCounters_t* bc, performanceCounters_t* pc ); virtual void SwapCommandBuffers_FinishRendering( uint64* frontEndMicroSec, uint64* backEndMicroSec, uint64* shadowMicroSec, uint64* gpuMicroSec, backEndCounters_t* bc, performanceCounters_t* pc ); @@ -1175,7 +1142,6 @@ extern idCVar r_showUnsmoothedTangents; // highlight geometry rendered with uns extern idCVar r_showSilhouette; // highlight edges that are casting shadow planes extern idCVar r_showVertexColor; // draws all triangles with the solid vertex color extern idCVar r_showUpdates; // report entity and light updates and ref counts -extern idCVar r_showDemo; // report reads and writes to the demo file extern idCVar r_showDynamic; // report stats on dynamic surface generation extern idCVar r_showIntensity; // draw the screen colors based on intensity, red = 0, green = 128, blue = 255 extern idCVar r_showTrace; // show the intersection of an eye trace with the world diff --git a/neo/renderer/RenderEntity.cpp b/neo/renderer/RenderEntity.cpp index e878568dc0..d1ac4b0ad1 100644 --- a/neo/renderer/RenderEntity.cpp +++ b/neo/renderer/RenderEntity.cpp @@ -162,203 +162,6 @@ int RenderEnvprobeLocal::GetIndex() } -void idRenderEntityLocal::ReadFromDemoFile( class idDemoFile* f ) -{ - int i; - renderEntity_t ent; // SRS - fully initialize ent so that memcmp() in UpdateEntityDef() works properly memset( &ent, 0, sizeof( renderEntity_t ) ); - /* Initialize Pointers */ - decals = NULL; - overlays = NULL; - dynamicModel = NULL; - ent.referenceShader = NULL; - ent.referenceSound = NULL; - ent.hModel = NULL; - ent.customSkin = NULL; - ent.customShader = NULL; - ent.joints = NULL; - ent.callback = NULL; - ent.callbackData = NULL; - ent.remoteRenderView = NULL; - - f->ReadInt( index ); - f->ReadInt( dynamicModelFrameCount ); - f->ReadInt( ent.entityNum ); - f->ReadInt( ent.bodyId ); - f->ReadVec3( ent.bounds[ 0 ] ); - f->ReadVec3( ent.bounds[ 1 ] ); - f->ReadInt( ent.suppressSurfaceInViewID ); - f->ReadInt( ent.suppressShadowInViewID ); - f->ReadInt( ent.suppressShadowInLightID ); - f->ReadInt( ent.allowSurfaceInViewID ); - f->ReadVec3( ent.origin ); - f->ReadMat3( ent.axis ); - for( i = 0; i < MAX_ENTITY_SHADER_PARMS; i++ ) - { - f->ReadFloat( ent.shaderParms[ i ] ); - } - for( i = 0; i < MAX_RENDERENTITY_GUI; i++ ) - { - f->ReadInt( ( int& )ent.gui[ i ] ); - ent.gui[ i ] = NULL; - } - f->ReadInt( i ); //( int& )ent.remoteRenderView - f->ReadInt( ent.numJoints ); - f->ReadFloat( ent.modelDepthHack ); - f->ReadBool( ent.noSelfShadow ); - f->ReadBool( ent.noShadow ); - f->ReadBool( ent.noOverlays ); - f->ReadBool( ent.noDynamicInteractions ); - f->ReadBool( ent.weaponDepthHack ); - f->ReadInt( ent.forceUpdate ); - - const char* declName = NULL; - - declName = f->ReadHashString(); - ent.customShader = ( declName[ 0 ] != 0 ) ? declManager->FindMaterial( declName ) : NULL; - - declName = f->ReadHashString(); - ent.referenceShader = ( declName[ 0 ] != 0 ) ? declManager->FindMaterial( declName ) : NULL; - - declName = f->ReadHashString(); - ent.customSkin = ( declName[ 0 ] != 0 ) ? declManager->FindSkin( declName ) : NULL; - - int soundIndex = -1; - f->ReadInt( soundIndex ); - ent.referenceSound = soundIndex != -1 ? common->SW()->EmitterForIndex( soundIndex ) : NULL; - - const char* mdlName = f->ReadHashString(); - ent.hModel = ( mdlName[ 0 ] != 0 ) ? renderModelManager->FindModel( mdlName ) : NULL; - - /*if( ent.hModel != NULL ) - { - bool dynamicModel = false; - f->ReadBool( dynamicModel ); - if( dynamicModel ) - { - ent.hModel->ReadFromDemoFile( f ); - } - }*/ - - if( ent.numJoints > 0 ) - { - ent.joints = ( idJointMat* )Mem_Alloc16( SIMD_ROUND_JOINTS( ent.numJoints ) * sizeof( ent.joints[ 0 ] ), TAG_JOINTMAT ); - for( int i = 0; i < ent.numJoints; i++ ) - { - float* data = ent.joints[ i ].ToFloatPtr(); - for( int j = 0; j < 12; ++j ) - { - f->ReadFloat( data[ j ] ); - } - } - SIMD_INIT_LAST_JOINT( ent.joints, ent.numJoints ); - } - - f->ReadInt( ent.timeGroup ); - f->ReadInt( ent.xrayIndex ); - /* - f->ReadInt( i ); - if( i ) { - ent.overlays = idRenderModelOverlay::Alloc(); - ent.overlays->ReadFromDemoFile( f->Read ); - } - */ - - world->UpdateEntityDef( index, &ent ); - for( i = 0; i < MAX_RENDERENTITY_GUI; i++ ) - { - if( parms.gui[ i ] ) - { - parms.gui[ i ] = uiManager->Alloc(); -#ifdef WRITE_GUIS - parms.gui[ i ]->ReadFromDemoFile( f->Read ); -#endif - } - } - if( r_showDemo.GetBool() ) - { - common->Printf( "DC_UPDATE_ENTITYDEF: %i = %s\n", index, parms.hModel ? parms.hModel->Name() : "NULL" ); - } -} -void idRenderEntityLocal::WriteToDemoFile( class idDemoFile* f ) const -{ - f->WriteInt( index ); - f->WriteInt( dynamicModelFrameCount ); - f->WriteInt( parms.entityNum ); - f->WriteInt( parms.bodyId ); - f->WriteVec3( parms.bounds[ 0 ] ); - f->WriteVec3( parms.bounds[ 1 ] ); - f->WriteInt( parms.suppressSurfaceInViewID ); - f->WriteInt( parms.suppressShadowInViewID ); - f->WriteInt( parms.suppressShadowInLightID ); - f->WriteInt( parms.allowSurfaceInViewID ); - f->WriteVec3( parms.origin ); - f->WriteMat3( parms.axis ); - for( int i = 0; i < MAX_ENTITY_SHADER_PARMS; i++ ) - { - f->WriteFloat( parms.shaderParms[ i ] ); - } - for( int i = 0; i < MAX_RENDERENTITY_GUI; i++ ) - { - f->WriteInt( ( int& )parms.gui[ i ] ); - } - f->WriteInt( ( int& )parms.remoteRenderView ); - f->WriteInt( parms.numJoints ); - f->WriteFloat( parms.modelDepthHack ); - f->WriteBool( parms.noSelfShadow ); - f->WriteBool( parms.noShadow ); - f->WriteBool( parms.noOverlays ); - f->WriteBool( parms.noDynamicInteractions ); - f->WriteBool( parms.weaponDepthHack ); - f->WriteInt( parms.forceUpdate ); - - f->WriteHashString( parms.customShader ? parms.customShader->GetName() : "" ); - f->WriteHashString( parms.referenceShader ? parms.referenceShader->GetName() : "" ); - f->WriteHashString( parms.customSkin ? parms.customSkin->GetName() : "" ); - f->WriteInt( parms.referenceSound ? parms.referenceSound->Index() : -1 ); - - f->WriteHashString( parms.hModel ? parms.hModel->Name() : "" ); - /*if( parms.hModel ) - { - f->WriteBool( parms.hModel->ModelDynamicallyGenerated() ? true : false ); - if( parms.hModel->ModelDynamicallyGenerated() ) - { - parms.hModel->WriteToDemoFile( f ); - } - }*/ - - for( int i = 0; i < parms.numJoints; i++ ) - { - float* data = parms.joints[ i ].ToFloatPtr(); - for( int j = 0; j < 12; ++j ) - { - f->WriteFloat( data[ j ] ); - } - } - - // RENDERDEMO_VERSION >= 2 ( Doom3 1.2 ) - f->WriteInt( parms.timeGroup ); - f->WriteInt( parms.xrayIndex ); - -#ifdef WRITE_GUIS - for( i = 0; i < MAX_RENDERENTITY_GUI; i++ ) - { - if( parms.gui[ i ] ) - { - f->WriteInt( 1 ); - parms.gui[ i ]->WriteToDemoFile( f ); - } - else - { - f->WriteInt( 0 ); - } - } -#endif - - if( r_showDemo.GetBool() ) - { - common->Printf( "write DC_UPDATE_ENTITYDEF: %i = %s\n", index, parms.hModel ? parms.hModel->Name() : "NULL" ); - } -} diff --git a/neo/renderer/RenderSystem.cpp b/neo/renderer/RenderSystem.cpp index fb8e24bba0..ec11bd8f51 100644 --- a/neo/renderer/RenderSystem.cpp +++ b/neo/renderer/RenderSystem.cpp @@ -791,37 +791,6 @@ const emptyCommand_t* idRenderSystemLocal::SwapCommandBuffers_FinishCommandBuffe return commandBufferHead; } -/* -===================== -idRenderSystemLocal::WriteDemoPics -===================== -*/ -void idRenderSystemLocal::WriteDemoPics() -{ - common->WriteDemo()->WriteInt( DS_RENDER ); - common->WriteDemo()->WriteInt( DC_GUI_MODEL ); -} - -/* -===================== -idRenderSystemLocal::WriteEndFrame -===================== -*/ -void idRenderSystemLocal::WriteEndFrame() -{ - common->WriteDemo()->WriteInt( DS_RENDER ); - common->WriteDemo()->WriteInt( DC_END_FRAME ); -} - -/* -===================== -idRenderSystemLocal::DrawDemoPics -===================== -*/ -void idRenderSystemLocal::DrawDemoPics() -{ -} - /* ===================== idRenderSystemLocal::GetCroppedViewport @@ -875,19 +844,6 @@ void idRenderSystemLocal::CropRenderSize( int width, int height ) common->Error( "CropRenderSize: bad sizes" ); } - if( common->WriteDemo() ) - { - common->WriteDemo()->WriteInt( DS_RENDER ); - common->WriteDemo()->WriteInt( DC_CROP_RENDER ); - common->WriteDemo()->WriteInt( width ); - common->WriteDemo()->WriteInt( height ); - - if( r_showDemo.GetBool() ) - { - common->Printf( "write DC_CROP_RENDER\n" ); - } - } - idScreenRect& previous = renderCrops[currentRenderCrop]; currentRenderCrop++; @@ -979,17 +935,6 @@ void idRenderSystemLocal::UnCrop() guiModel->Clear(); currentRenderCrop--; - - if( common->WriteDemo() ) - { - common->WriteDemo()->WriteInt( DS_RENDER ); - common->WriteDemo()->WriteInt( DC_UNCROP_RENDER ); - - if( r_showDemo.GetBool() ) - { - common->Printf( "write DC_UNCROP\n" ); - } - } } /* @@ -1006,17 +951,6 @@ void idRenderSystemLocal::CaptureRenderToImage( const char* imageName, bool clea guiModel->EmitFullScreen(); guiModel->Clear(); - if( common->WriteDemo() ) - { - common->WriteDemo()->WriteInt( DS_RENDER ); - common->WriteDemo()->WriteInt( DC_CAPTURE_RENDER ); - common->WriteDemo()->WriteHashString( imageName ); - - if( r_showDemo.GetBool() ) - { - common->Printf( "write DC_CAPTURE_RENDER: %s\n", imageName ); - } - } idImage* image = globalImages->GetImage( imageName ); if( image == NULL ) { diff --git a/neo/renderer/RenderSystem.h b/neo/renderer/RenderSystem.h index c52f2d1698..d8637007c6 100644 --- a/neo/renderer/RenderSystem.h +++ b/neo/renderer/RenderSystem.h @@ -317,13 +317,6 @@ class idRenderSystem virtual void DrawCRTPostFX() = 0; // RB - // dump all 2D drawing so far this frame to the demo file - virtual void WriteDemoPics() = 0; - virtual void WriteEndFrame() = 0; - - // draw the 2D pics that were saved out with the current demo frame - virtual void DrawDemoPics() = 0; - // Performs final closeout of any gui models being defined. // // Waits for the previous GPU rendering to complete and vsync. diff --git a/neo/renderer/RenderSystem_init.cpp b/neo/renderer/RenderSystem_init.cpp index 1b3cb2e41d..04bdc06483 100644 --- a/neo/renderer/RenderSystem_init.cpp +++ b/neo/renderer/RenderSystem_init.cpp @@ -188,7 +188,6 @@ idCVar r_showUnsmoothedTangents( "r_showUnsmoothedTangents", "0", CVAR_RENDERER idCVar r_showSilhouette( "r_showSilhouette", "0", CVAR_RENDERER | CVAR_BOOL, "highlight edges that are casting shadow planes" ); idCVar r_showVertexColor( "r_showVertexColor", "0", CVAR_RENDERER | CVAR_BOOL, "draws all triangles with the solid vertex color" ); idCVar r_showUpdates( "r_showUpdates", "0", CVAR_RENDERER | CVAR_BOOL, "report entity and light updates and ref counts" ); -idCVar r_showDemo( "r_showDemo", "0", CVAR_RENDERER | CVAR_BOOL, "report reads and writes to the demo file" ); idCVar r_showDynamic( "r_showDynamic", "0", CVAR_RENDERER | CVAR_BOOL, "report stats on dynamic surface generation" ); idCVar r_showTrace( "r_showTrace", "0", CVAR_RENDERER | CVAR_INTEGER, "show the intersection of an eye trace with the world", idCmdSystem::ArgCompletion_Integer<0, 2> ); idCVar r_showIntensity( "r_showIntensity", "0", CVAR_RENDERER | CVAR_BOOL, "draw the screen colors based on intensity, red = 0, green = 128, blue = 255" ); diff --git a/neo/renderer/RenderWorld.cpp b/neo/renderer/RenderWorld.cpp index da64604d84..0ff43a78bf 100644 --- a/neo/renderer/RenderWorld.cpp +++ b/neo/renderer/RenderWorld.cpp @@ -400,11 +400,6 @@ void idRenderWorldLocal::FreeEntityDef( qhandle_t entityHandle ) R_FreeEntityDefDerivedData( def, false, false ); - if( common->WriteDemo() && def->archived ) - { - WriteFreeEntity( entityHandle ); - } - // if we are playing a demo, these will have been freed // in R_FreeEntityDefDerivedData(), otherwise the gui // object still exists in the game @@ -529,11 +524,6 @@ void idRenderWorldLocal::UpdateLightDef( qhandle_t lightHandle, const renderLigh light->parms = *rlight; light->lastModifiedFrameNum = tr.frameCount; - if( common->WriteDemo() && light->archived ) - { - WriteFreeLight( lightHandle ); - light->archived = false; - } // new for BFG edition: force noShadows on spectrum lights so teleport spawns // don't cause such a slowdown. Hell writing shouldn't be shadowed anyway... @@ -580,11 +570,6 @@ void idRenderWorldLocal::FreeLightDef( qhandle_t lightHandle ) R_FreeLightDefDerivedData( light ); - if( common->WriteDemo() && light->archived ) - { - WriteFreeLight( lightHandle ); - } - delete light; lightDefs[lightHandle] = NULL; } @@ -695,11 +680,6 @@ void idRenderWorldLocal::UpdateEnvprobeDef( qhandle_t envprobeHandle, const rend probe->parms = *ep; probe->lastModifiedFrameNum = tr.frameCount; - if( common->WriteDemo() && probe->archived ) - { - WriteFreeEnvprobe( envprobeHandle ); - probe->archived = false; - } if( !justUpdate ) { @@ -734,11 +714,6 @@ void idRenderWorldLocal::FreeEnvprobeDef( qhandle_t envprobeHandle ) R_FreeEnvprobeDefDerivedData( probe ); - if( common->WriteDemo() && probe->archived ) - { - WriteFreeEnvprobe( envprobeHandle ); - } - delete probe; envprobeDefs[envprobeHandle] = NULL; } @@ -958,10 +933,7 @@ idRenderModelDecal* idRenderWorldLocal::AllocDecal( qhandle_t newEntityHandle, i decals[oldest].entityHandle = newEntityHandle; decals[oldest].lastStartTime = startTime; decals[oldest].decals->ReUse(); - if( common->WriteDemo() ) - { - WriteFreeDecal( common->WriteDemo(), oldest ); - } + return decals[oldest].decals; } @@ -1150,13 +1122,6 @@ void idRenderWorldLocal::RenderScene( const renderView_t* renderView ) // render any post processing after the view and all its subviews has been draw R_RenderPostProcess( parms ); - // now write delete commands for any modified-but-not-visible entities, and - // add the renderView command to the demo - if( common->WriteDemo() ) - { - WriteRenderView( renderView ); - } - #if 0 for( int i = 0; i < entityDefs.Num(); i++ ) { diff --git a/neo/renderer/RenderWorld.h b/neo/renderer/RenderWorld.h index 3b213d001d..4ee0966abb 100644 --- a/neo/renderer/RenderWorld.h +++ b/neo/renderer/RenderWorld.h @@ -454,19 +454,6 @@ class idRenderWorld //-------------- Demo Control ----------------- - // Writes a loadmap command to the demo, and clears archive counters. - virtual void StartWritingDemo( idDemoFile* demo ) = 0; - virtual void StopWritingDemo() = 0; - - // Returns true when demoRenderView has been filled in. - // adds/updates/frees entityDefs and lightDefs based on the current demo file - // and returns the renderView to be used to render this frame. - // a demo file may need to be advanced multiple times if the framerate - // is less than 30hz - // demoTimeOffset will be set if a new map load command was processed before - // the next renderScene - virtual bool ProcessDemoCommand( idDemoFile* readDemo, renderView_t* demoRenderView, int* demoTimeOffset ) = 0; - // this is used to regenerate all interactions ( which is currently only done during influences ), there may be a less // expensive way to do it virtual void RegenerateWorld() = 0; diff --git a/neo/renderer/RenderWorld_defs.cpp b/neo/renderer/RenderWorld_defs.cpp index e90b9d2270..477b332218 100644 --- a/neo/renderer/RenderWorld_defs.cpp +++ b/neo/renderer/RenderWorld_defs.cpp @@ -68,30 +68,6 @@ Does not actually free the entityDef. */ void R_FreeEntityDefDerivedData( idRenderEntityLocal* def, bool keepDecals, bool keepCachedDynamicModel ) { - // demo playback needs to free the joints, while normal play - // leaves them in the control of the game - if( common->ReadDemo() ) - { - if( def->parms.joints ) - { - Mem_Free16( def->parms.joints ); - def->parms.joints = NULL; - } - if( def->parms.callbackData ) - { - Mem_Free( def->parms.callbackData ); - def->parms.callbackData = NULL; - } - for( int i = 0; i < MAX_RENDERENTITY_GUI; i++ ) - { - if( def->parms.gui[ i ] ) - { - delete def->parms.gui[ i ]; - def->parms.gui[ i ] = NULL; - } - } - } - // free all the interactions while( def->firstInteraction != NULL ) { diff --git a/neo/renderer/RenderWorld_demo.cpp b/neo/renderer/RenderWorld_demo.cpp deleted file mode 100644 index 2e9ca0a55d..0000000000 --- a/neo/renderer/RenderWorld_demo.cpp +++ /dev/null @@ -1,1033 +0,0 @@ -/* -=========================================================================== - -Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -Copyright (C) 2014-2016 Robert Beckebans -Copyright (C) 2014-2016 Kot in Action Creative Artel - -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). - -Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Doom 3 BFG Edition Source Code. If not, see . - -In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below. - -If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA. - -=========================================================================== -*/ - -#include "precompiled.h" -#pragma hdrstop - -#include "RenderCommon.h" - -idCVar r_writeDemoDecals( "r_writeDemoDecals", "1", CVAR_BOOL | CVAR_SYSTEM, "enable Writing of entity decals to demo files." ); -idCVar r_writeDemoOverlays( "r_writeDemoOverlays", "1", CVAR_BOOL | CVAR_SYSTEM, "enable Writing of entity Overlays to demo files." ); - -//idCVar r_writeDemoGUI( "r_writeDemoGUI", "0", CVAR_BOOL | CVAR_SYSTEM, "enable Writing of GUI elements to demo files." ); -//#define WRITE_GUIS - -extern void WriteDeclCache( idDemoFile* f, int demoCategory, int demoCode, declType_t declType ); - -typedef struct -{ - int version; - int sizeofRenderEntity; - int sizeofRenderLight; - char mapname[256]; -} demoHeader_t; - - -/* -============== -StartWritingDemo -============== -*/ -void idRenderWorldLocal::StartWritingDemo( idDemoFile* demo ) -{ - int i; - - // FIXME: we should track the idDemoFile locally, instead of snooping into session for it - - WriteLoadMap(); - - // write the door portal state - for( i = 0 ; i < numInterAreaPortals ; i++ ) - { - if( doublePortals[i].blockingBits ) - { - SetPortalState( i + 1, doublePortals[i].blockingBits ); - } - } - - // clear the archive counter on all defs - for( i = 0 ; i < lightDefs.Num() ; i++ ) - { - if( lightDefs[i] ) - { - lightDefs[i]->archived = false; - } - } - for( i = 0 ; i < entityDefs.Num() ; i++ ) - { - if( entityDefs[i] ) - { - entityDefs[i]->archived = false; - } - } -} - -void idRenderWorldLocal::StopWritingDemo() -{ -// writeDemo = NULL; -} - -/* -============== -ProcessDemoCommand -============== -*/ -bool idRenderWorldLocal::ProcessDemoCommand( idDemoFile* readDemo, renderView_t* renderView, int* demoTimeOffset ) -{ - bool newMap = false; - - if( !readDemo ) - { - return false; - } - - demoCommand_t dc; - qhandle_t h; - - if( !readDemo->ReadInt( ( int& )dc ) ) - { - // a demoShot may not have an endFrame, but it is still valid - return false; - } - - switch( dc ) - { - case DC_LOADMAP: - { - // read the initial data - demoHeader_t header; - - readDemo->ReadInt( header.version ); - readDemo->ReadInt( header.sizeofRenderEntity ); - readDemo->ReadInt( header.sizeofRenderLight ); - for( int i = 0; i < 256; i++ ) - { - readDemo->ReadChar( header.mapname[i] ); - } - // the internal version value got replaced by DS_VERSION at toplevel - if( header.version != 4 ) - { - common->Error( "Demo version mismatch.\n" ); - } - - if( r_showDemo.GetBool() ) - { - common->Printf( "DC_LOADMAP: %s\n", header.mapname ); - } - // Clean up existing Renderer before loading the new map. - FreeWorld(); - // Load up the new map. - InitFromMap( header.mapname ); - - newMap = true; // we will need to set demoTimeOffset - - break; - } - case DC_CACHE_SKINS: - { - int numSkins = 0; - readDemo->ReadInt( numSkins ); - - for( int i = 0; i < numSkins; ++i ) - { - const char* declName = readDemo->ReadHashString(); - declManager->FindSkin( declName, true ); - } - - if( r_showDemo.GetBool() ) - { - common->Printf( "DC_CACHESKINS: %d\n", numSkins ); - } - break; - } - case DC_CACHE_PARTICLES: - { - int numDecls = 0; - readDemo->ReadInt( numDecls ); - - for( int i = 0; i < numDecls; ++i ) - { - const char* declName = readDemo->ReadHashString(); - declManager->FindType( DECL_PARTICLE, declName, true ); - } - - if( r_showDemo.GetBool() ) - { - common->Printf( "DC_CACHE_PARTICLES: %d\n", numDecls ); - } - break; - } - case DC_CACHE_MATERIALS: - { - int numDecls = 0; - readDemo->ReadInt( numDecls ); - - for( int i = 0; i < numDecls; ++i ) - { - const char* declName = readDemo->ReadHashString(); - declManager->FindMaterial( declName, true ); - } - - if( r_showDemo.GetBool() ) - { - common->Printf( "DC_CACHE_MATERIALS: %d\n", numDecls ); - } - break; - } - case DC_RENDERVIEW: - { - readDemo->ReadInt( renderView->viewID ); - readDemo->ReadFloat( renderView->fov_x ); - readDemo->ReadFloat( renderView->fov_y ); - readDemo->ReadVec3( renderView->vieworg ); - readDemo->ReadMat3( renderView->viewaxis ); - readDemo->ReadBool( renderView->cramZNear ); - readDemo->ReadBool( renderView->forceUpdate ); - // binary compatibility with win32 padded structures - char tmp; - readDemo->ReadChar( tmp ); - readDemo->ReadChar( tmp ); - readDemo->ReadInt( renderView->time[0] ); - readDemo->ReadInt( renderView->time[1] ); - for( int i = 0; i < MAX_GLOBAL_SHADER_PARMS; i++ ) - { - readDemo->ReadFloat( renderView->shaderParms[i] ); - } - - if( !readDemo->ReadInt( ( int& )renderView->globalMaterial ) ) - { - return false; - } - - if( r_showDemo.GetBool() ) - { - // foresthale 2014-05-19: /analyze fix - was time, changed to time[0] - common->Printf( "DC_RENDERVIEW: %i\n", renderView->time[ 0 ] ); - } - - // possibly change the time offset if this is from a new map - if( newMap && demoTimeOffset ) - { - *demoTimeOffset = renderView->time[1] - eventLoop->Milliseconds(); - } - return false; - } - case DC_UPDATE_ENTITYDEF: - { - ReadRenderEntity(); - break; - } - case DC_DELETE_ENTITYDEF: - { - if( !readDemo->ReadInt( h ) ) - { - return false; - } - if( r_showDemo.GetBool() ) - { - common->Printf( "DC_DELETE_ENTITYDEF: %i\n", h ); - } - FreeEntityDef( h ); - break; - } - case DC_UPDATE_LIGHTDEF: - { - ReadRenderLight(); - break; - } - case DC_DELETE_LIGHTDEF: - { - if( !readDemo->ReadInt( h ) ) - { - return false; - } - if( r_showDemo.GetBool() ) - { - common->Printf( "DC_DELETE_LIGHTDEF: %i\n", h ); - } - FreeLightDef( h ); - break; - } - case DC_CAPTURE_RENDER: - { - if( r_showDemo.GetBool() ) - { - common->Printf( "DC_CAPTURE_RENDER\n" ); - } - renderSystem->CaptureRenderToImage( readDemo->ReadHashString() ); - break; - } - case DC_CROP_RENDER: - { - if( r_showDemo.GetBool() ) - { - common->Printf( "DC_CROP_RENDER\n" ); - } - int width, height; - readDemo->ReadInt( width ); - readDemo->ReadInt( height ); - renderSystem->CropRenderSize( width, height ); - break; - } - case DC_UNCROP_RENDER: - { - if( r_showDemo.GetBool() ) - { - common->Printf( "DC_UNCROP\n" ); - } - renderSystem->UnCrop(); - break; - } - case DC_GUI_MODEL: - { - if( r_showDemo.GetBool() ) - { - common->Printf( "DC_GUI_MODEL\n" ); - } - break; - } - case DC_DEFINE_MODEL: - { - idRenderModel* model = renderModelManager->AllocModel(); - model->ReadFromDemoFile( common->ReadDemo() ); - // add to model manager, so we can find it - renderModelManager->AddModel( model ); - - // save it in the list to free when clearing this map - localModels.Append( model ); - - if( r_showDemo.GetBool() ) - { - common->Printf( "DC_DEFINE_MODEL\n" ); - } - break; - } - case DC_UPDATE_DECAL: - { - if( !readDemo->ReadInt( h ) ) - { - return false; - } - int data[ 2 ]; - readDemo->ReadInt( data[ 0 ] ); - readDemo->ReadInt( data[ 1 ] ); - decals[ h ].entityHandle = data[ 0 ]; - decals[ h ].lastStartTime = data[ 1 ]; - decals[ h ].decals->ReadFromDemoFile( readDemo ); - break; - } - case DC_DELETE_DECAL: - { - if( !readDemo->ReadInt( h ) ) - { - return false; - } - - int data[ 2 ]; - readDemo->ReadInt( data[ 0 ] ); - readDemo->ReadInt( data[ 1 ] ); - decals[ h ].entityHandle = data[ 0 ]; - decals[ h ].lastStartTime = data[ 1 ]; - decals[ h ].decals->ReUse(); - break; - } - case DC_UPDATE_OVERLAY: - { - if( !readDemo->ReadInt( h ) ) - { - return false; - } - int data[ 2 ]; - readDemo->ReadInt( data[ 0 ] ); - readDemo->ReadInt( data[ 1 ] ); - overlays[ h ].entityHandle = data[ 0 ]; - overlays[ h ].lastStartTime = data[ 1 ]; - overlays[ h ].overlays->ReadFromDemoFile( readDemo ); - break; - } - case DC_DELETE_OVERLAY: - { - if( !readDemo->ReadInt( h ) ) - { - return false; - } - int data[ 2 ]; - readDemo->ReadInt( data[ 0 ] ); - readDemo->ReadInt( data[ 1 ] ); - overlays[ h ].entityHandle = data[ 0 ]; - overlays[ h ].lastStartTime = data[ 1 ]; - overlays[ h ].overlays->ReUse(); - break; - } - case DC_SET_PORTAL_STATE: - { - int data[2]; - readDemo->ReadInt( data[0] ); - readDemo->ReadInt( data[1] ); - SetPortalState( data[0], data[1] ); - if( r_showDemo.GetBool() ) - { - common->Printf( "DC_SET_PORTAL_STATE: %i %i\n", data[0], data[1] ); - } - break; - } - case DC_END_FRAME: - { - if( r_showDemo.GetBool() ) - { - common->Printf( "DC_END_FRAME\n" ); - } - return true; - } - default: - common->Error( "Bad demo render command '%d' in demo stream", dc ); - break; - } - - return false; -} - -/* -================ -WriteLoadMap -================ -*/ -void idRenderWorldLocal::WriteLoadMap() -{ - - // only the main renderWorld writes stuff to demos, not the wipes or - // menu renders - if( this != common->RW() ) - { - return; - } - idDemoFile* f = common->WriteDemo(); - f->WriteInt( DS_RENDER ); - f->WriteInt( DC_LOADMAP ); - - demoHeader_t header; - strncpy( header.mapname, mapName.c_str(), sizeof( header.mapname ) - 1 ); - header.version = 4; - header.sizeofRenderEntity = sizeof( renderEntity_t ); - header.sizeofRenderLight = sizeof( renderLight_t ); - f->WriteInt( header.version ); - f->WriteInt( header.sizeofRenderEntity ); - f->WriteInt( header.sizeofRenderLight ); - for( int i = 0; i < 256; i++ ) - { - f->WriteChar( header.mapname[ i ] ); - } - - if( r_showDemo.GetBool() ) - { - common->Printf( "write DC_LOADMAP: %s\n", mapName.c_str() ); - } - - ////////////////////////////////////////////////////////////////////////// - - WriteDeclCache( f, DS_RENDER, DC_CACHE_SKINS, DECL_SKIN ); - - if( r_showDemo.GetBool() ) - { - common->Printf( "write DC_CACHESKINS: %s\n", mapName.c_str() ); - } - - WriteDeclCache( f, DS_RENDER, DC_CACHE_PARTICLES, DECL_PARTICLE ); - - if( r_showDemo.GetBool() ) - { - common->Printf( "write DC_CACHEPARTICLES: %s\n", mapName.c_str() ); - } - - WriteDeclCache( f, DS_RENDER, DC_CACHE_MATERIALS, DECL_MATERIAL ); - - if( r_showDemo.GetBool() ) - { - common->Printf( "write DC_CACHEPARTICLES: %s\n", mapName.c_str() ); - } - - for( int i = 0; i < lightDefs.Num(); i++ ) - { - idRenderLightLocal* light = lightDefs[ i ]; - if( light ) - { - WriteRenderLight( f, light->index, &light->parms ); - } - } - - for( int i = 0; i < entityDefs.Num(); i++ ) - { - if( entityDefs[ i ] ) - { - WriteRenderEntity( f, entityDefs[ i ] ); - } - } - - if( r_showDemo.GetBool() ) - { - common->Printf( "write DC_CACHESKIN: %s\n", mapName.c_str() ); - } -} - -/* -================ -WriteVisibleDefs - -================ -*/ -void idRenderWorldLocal::WriteVisibleDefs( const viewDef_t* viewDef ) -{ - // only the main renderWorld writes stuff to demos, not the wipes or - // menu renders - if( this != common->RW() ) - { - return; - } - - // make sure all necessary entities and lights are updated - for( viewEntity_t* viewEnt = viewDef->viewEntitys ; viewEnt ; viewEnt = viewEnt->next ) - { - idRenderEntityLocal* ent = viewEnt->entityDef; - - if( !ent || ent->archived ) - { - // still up to date - continue; - } - // write it out - WriteRenderEntity( common->WriteDemo(), ent ); - ent->archived = true; - } - - for( viewLight_t* viewLight = viewDef->viewLights ; viewLight ; viewLight = viewLight->next ) - { - idRenderLightLocal* light = viewLight->lightDef; - - if( light->archived ) - { - // still up to date - continue; - } - // write it out - WriteRenderLight( common->WriteDemo(), light->index, &light->parms ); - light->archived = true; - } -} - - -/* -================ -WriteRenderView -================ -*/ -void idRenderWorldLocal::WriteRenderView( const renderView_t* renderView ) -{ - int i; - - // only the main renderWorld writes stuff to demos, not the wipes or - // menu renders - if( this != common->RW() ) - { - return; - } - - // write the actual view command - common->WriteDemo()->WriteInt( DS_RENDER ); - common->WriteDemo()->WriteInt( DC_RENDERVIEW ); - common->WriteDemo()->WriteInt( renderView->viewID ); - common->WriteDemo()->WriteFloat( renderView->fov_x ); - common->WriteDemo()->WriteFloat( renderView->fov_y ); - common->WriteDemo()->WriteVec3( renderView->vieworg ); - common->WriteDemo()->WriteMat3( renderView->viewaxis ); - common->WriteDemo()->WriteBool( renderView->cramZNear ); - common->WriteDemo()->WriteBool( renderView->forceUpdate ); - // binary compatibility with old win32 version writing padded structures directly to disk - common->WriteDemo()->WriteUnsignedChar( 0 ); - common->WriteDemo()->WriteUnsignedChar( 0 ); - common->WriteDemo()->WriteInt( renderView->time[0] ); - common->WriteDemo()->WriteInt( renderView->time[1] ); - for( i = 0; i < MAX_GLOBAL_SHADER_PARMS; i++ ) - { - common->WriteDemo()->WriteFloat( renderView->shaderParms[i] ); - } - common->WriteDemo()->WriteInt( ( int& )renderView->globalMaterial ); - - if( r_showDemo.GetBool() ) - { - // foresthale 2014-05-19: /analyze fix - was time, changed to time[0] - common->Printf( "write DC_RENDERVIEW: %i\n", renderView->time[0] ); - } -} - -/* -================ -WriteFreeEntity -================ -*/ -void idRenderWorldLocal::WriteFreeEntity( qhandle_t handle ) -{ - - // only the main renderWorld writes stuff to demos, not the wipes or - // menu renders - if( this != common->RW() ) - { - return; - } - - common->WriteDemo()->WriteInt( DS_RENDER ); - common->WriteDemo()->WriteInt( DC_DELETE_ENTITYDEF ); - common->WriteDemo()->WriteInt( handle ); - - if( r_showDemo.GetBool() ) - { - common->Printf( "write DC_DELETE_ENTITYDEF: %i\n", handle ); - } -} - -/* -================ -WriteFreeLightEntity -================ -*/ -void idRenderWorldLocal::WriteFreeLight( qhandle_t handle ) -{ - - // only the main renderWorld writes stuff to demos, not the wipes or - // menu renders - if( this != common->RW() ) - { - return; - } - - common->WriteDemo()->WriteInt( DS_RENDER ); - common->WriteDemo()->WriteInt( DC_DELETE_LIGHTDEF ); - common->WriteDemo()->WriteInt( handle ); - - if( r_showDemo.GetBool() ) - { - common->Printf( "write DC_DELETE_LIGHTDEF: %i\n", handle ); - } -} - -/* -================ -WriteRenderLight -================ -*/ -void idRenderWorldLocal::WriteRenderLight( idDemoFile* f, qhandle_t handle, const renderLight_t* light ) -{ - - // only the main renderWorld writes stuff to demos, not the wipes or - // menu renders - if( this != common->RW() ) - { - return; - } - - f->WriteInt( DS_RENDER ); - f->WriteInt( DC_UPDATE_LIGHTDEF ); - f->WriteInt( handle ); - - f->WriteMat3( light->axis ); - f->WriteVec3( light->origin ); - f->WriteInt( light->suppressLightInViewID ); - f->WriteInt( light->allowLightInViewID ); - f->WriteBool( light->noShadows ); - f->WriteBool( light->noSpecular ); - f->WriteBool( light->pointLight ); - f->WriteBool( light->parallel ); - f->WriteVec3( light->lightRadius ); - f->WriteVec3( light->lightCenter ); - f->WriteVec3( light->target ); - f->WriteVec3( light->right ); - f->WriteVec3( light->up ); - f->WriteVec3( light->start ); - f->WriteVec3( light->end ); - f->WriteInt( light->lightId ); - f->WriteInt( ( int& )light->prelightModel ); - f->WriteInt( ( int& )light->shader ); - for( int i = 0; i < MAX_ENTITY_SHADER_PARMS; i++ ) - { - f->WriteFloat( light->shaderParms[ i ] ); - } - f->WriteInt( ( int& )light->referenceSound ); - - if( light->prelightModel ) - { - f->WriteInt( 1 ); - f->WriteHashString( light->prelightModel->Name() ); - } - else - { - f->WriteInt( 0 ); - } - if( light->shader ) - { - f->WriteInt( 1 ); - f->WriteHashString( light->shader->GetName() ); - } - else - { - f->WriteInt( 0 ); - } - if( light->referenceSound ) - { - int index = light->referenceSound->Index(); - f->WriteInt( 1 ); - f->WriteInt( index ); - } - else - { - f->WriteInt( 0 ); - } - - if( r_showDemo.GetBool() ) - { - common->Printf( "write DC_UPDATE_LIGHTDEF: %i\n", handle ); - } -} - -/* -================ -ReadRenderLight -================ -*/ -void idRenderWorldLocal::ReadRenderLight() -{ - renderLight_t light = {}; - int index, i; - - common->ReadDemo()->ReadInt( index ); - if( index < 0 ) - { - common->Error( "ReadRenderLight: index < 0 " ); - } - - if( r_showDemo.GetBool() ) - { - common->Printf( "DC_UPDATE_LIGHTDEF: init %i\n", index ); - } - /* Initialize Pointers */ - light.prelightModel = NULL; - light.shader = NULL; - light.referenceSound = NULL; - - common->ReadDemo()->ReadMat3( light.axis ); - common->ReadDemo()->ReadVec3( light.origin ); - common->ReadDemo()->ReadInt( light.suppressLightInViewID ); - common->ReadDemo()->ReadInt( light.allowLightInViewID ); - common->ReadDemo()->ReadBool( light.noShadows ); - common->ReadDemo()->ReadBool( light.noSpecular ); - common->ReadDemo()->ReadBool( light.pointLight ); - common->ReadDemo()->ReadBool( light.parallel ); - common->ReadDemo()->ReadVec3( light.lightRadius ); - common->ReadDemo()->ReadVec3( light.lightCenter ); - common->ReadDemo()->ReadVec3( light.target ); - common->ReadDemo()->ReadVec3( light.right ); - common->ReadDemo()->ReadVec3( light.up ); - common->ReadDemo()->ReadVec3( light.start ); - common->ReadDemo()->ReadVec3( light.end ); - common->ReadDemo()->ReadInt( light.lightId ); - common->ReadDemo()->ReadInt( ( int& )light.prelightModel ); - common->ReadDemo()->ReadInt( ( int& )light.shader ); - for( int i = 0; i < MAX_ENTITY_SHADER_PARMS; i++ ) - { - common->ReadDemo()->ReadFloat( light.shaderParms[ i ] ); - } - common->ReadDemo()->ReadInt( ( int& )light.referenceSound ); - - common->ReadDemo()->ReadInt( i ); - if( i ) - { - light.prelightModel = renderModelManager->FindModel( common->ReadDemo()->ReadHashString() ); - } - common->ReadDemo()->ReadInt( i ); - if( i ) - { - light.shader = declManager->FindMaterial( common->ReadDemo()->ReadHashString() ); - } - - common->ReadDemo()->ReadInt( i ); - if( i ) - { - int index; - common->ReadDemo()->ReadInt( index ); - light.referenceSound = common->SW()->EmitterForIndex( index ); - } - - UpdateLightDef( index, &light ); - - if( r_showDemo.GetBool() ) - { - common->Printf( "DC_UPDATE_LIGHTDEF: %i\n", index ); - } -} - -/* -================ -WriteRenderEntity -================ -*/ -void idRenderWorldLocal::WriteRenderEntity( idDemoFile* f, idRenderEntityLocal* entity ) -{ - // only the main renderWorld writes stuff to demos, not the wipes or - // menu renders - if( this != common->RW() ) - { - return; - } - - if( entity->decals && entity->decals->demoSerialCurrent != entity->decals->demoSerialWrite ) - { - entity->decals->demoSerialWrite = entity->decals->demoSerialCurrent; - WriteRenderDecal( f, entity->decals->index ); - } - - if( entity->overlays && entity->overlays->demoSerialCurrent != entity->overlays->demoSerialWrite ) - { - entity->overlays->demoSerialWrite = entity->overlays->demoSerialCurrent; - WriteRenderOverlay( f, entity->overlays->index ); - } - - f->WriteInt( DS_RENDER ); - f->WriteInt( DC_UPDATE_ENTITYDEF ); - f->WriteInt( entity->index ); - entity->WriteToDemoFile( f ); - - // write decal ref - if( entity->decals ) - { - f->WriteBool( true ); - f->WriteInt( entity->decals->index ); - } - else - { - f->WriteBool( false ); - } - - // write overlay ref - if( entity->overlays ) - { - f->WriteBool( true ); - f->WriteInt( entity->overlays->index ); - } - else - { - f->WriteBool( false ); - } -} - - -/* -================ -ReadRenderEntity -================ -*/ -void idRenderWorldLocal::ReadRenderEntity() -{ - renderEntity_t ent; - int index; - - common->ReadDemo()->ReadInt( index ); - //tr.pc.c_entityUpdates++; - while( index >= entityDefs.Num() ) - { - entityDefs.Append( NULL ); - } - - idRenderEntityLocal* def = entityDefs[ index ]; - if( def == NULL ) - { - def = new( TAG_RENDER_ENTITY )idRenderEntityLocal; - def->world = this; - def->index = index; - entityDefs[ index ] = def; - } - def->ReadFromDemoFile( common->ReadDemo() ); - - // decals - bool hasDecal = false, hasOverlay = false; - - common->ReadDemo()->ReadBool( hasDecal ); - if( hasDecal ) - { - int index = 0; - common->ReadDemo()->ReadInt( index ); - - if( r_writeDemoDecals.GetBool() ) - { - def->decals = decals[ index ].decals; - } - } - - common->ReadDemo()->ReadBool( hasOverlay ); - if( hasOverlay ) - { - int index = 0; - common->ReadDemo()->ReadInt( index ); - - if( r_writeDemoOverlays.GetBool() ) - { - def->overlays = overlays[ index ].overlays; - } - } -} - -void idRenderWorldLocal::WriteRenderDecal( idDemoFile* f, qhandle_t handle ) -{ - // only the main renderWorld writes stuff to demos, not the wipes or - // menu renders - if( this != common->RW() ) - { - return; - } - - if( handle < 0 || !f ) - { - return; - } - if( !r_writeDemoDecals.GetBool() ) - { - return; - } - - // actually update the decal. - f->WriteInt( DS_RENDER ); - f->WriteInt( DC_UPDATE_DECAL ); - f->WriteInt( handle ); - f->WriteInt( decals[ handle ].entityHandle ); - f->WriteInt( decals[ handle ].lastStartTime ); - decals[ handle ].decals->WriteToDemoFile( f ); -} - -void idRenderWorldLocal::WriteFreeDecal( idDemoFile* f, qhandle_t handle ) -{ - // only the main renderWorld writes stuff to demos, not the wipes or - // menu renders - if( this != common->RW() ) - { - return; - } - - if( !r_writeDemoDecals.GetBool() ) - { - return; - } - - // When Decals are Freed, all that really happens is they get reallocated. - f->WriteInt( DS_RENDER ); - f->WriteInt( DC_DELETE_DECAL ); - f->WriteInt( handle ); - f->WriteInt( decals[ handle ].entityHandle ); - f->WriteInt( decals[ handle ].lastStartTime ); - - if( r_showDemo.GetBool() ) - { - common->Printf( "write DC_DELETE_DECAL: %i\n", handle ); - } -} - -void idRenderWorldLocal::WriteRenderOverlay( idDemoFile* f, qhandle_t handle ) -{ - // only the main renderWorld writes stuff to demos, not the wipes or - // menu renders - if( this != common->RW() ) - { - return; - } - - if( handle < 0 || !f || !r_writeDemoOverlays.GetBool() ) - { - return; - } - - // actually update the decal. - f->WriteInt( DS_RENDER ); - f->WriteInt( DC_UPDATE_OVERLAY ); - f->WriteInt( handle ); - f->WriteInt( overlays[ handle ].entityHandle ); - f->WriteInt( overlays[ handle ].lastStartTime ); - overlays[ handle ].overlays->WriteToDemoFile( f ); - - if( r_showDemo.GetBool() ) - { - common->Printf( "write DC_UPDATE_OVERLAY: %i\n", handle ); - } -} - -void idRenderWorldLocal::WriteFreeOverlay( idDemoFile* f, qhandle_t handle ) -{ - // only the main renderWorld writes stuff to demos, not the wipes or - // menu renders - if( this != common->RW() ) - { - return; - } - - if( !r_writeDemoOverlays.GetBool() ) - { - return; - } - - // When Decals are Freed, all that really happens is they get reallocated. - f->WriteInt( DS_RENDER ); - f->WriteInt( DC_DELETE_OVERLAY ); - f->WriteInt( handle ); - f->WriteInt( overlays[ handle ].entityHandle ); - f->WriteInt( overlays[ handle ].lastStartTime ); - - if( r_showDemo.GetBool() ) - { - common->Printf( "write DC_DELETE_OVERLAY: %i\n", handle ); - } -} - - -// RB begin -void idRenderWorldLocal::WriteFreeEnvprobe( qhandle_t handle ) -{ - - // only the main renderWorld writes stuff to demos, not the wipes or - // menu renders - if( this != common->RW() ) - { - return; - } - - common->WriteDemo()->WriteInt( DS_RENDER ); - common->WriteDemo()->WriteInt( DC_DELETE_ENVPROBEDEF ); - common->WriteDemo()->WriteInt( handle ); - - if( r_showDemo.GetBool() ) - { - common->Printf( "write DC_DELETE_ENVPROBEDEF: %i\n", handle ); - } -} -// RB end \ No newline at end of file diff --git a/neo/renderer/RenderWorld_load.cpp b/neo/renderer/RenderWorld_load.cpp index ead8860b15..5f4d6aee11 100644 --- a/neo/renderer/RenderWorld_load.cpp +++ b/neo/renderer/RenderWorld_load.cpp @@ -947,12 +947,6 @@ bool idRenderWorldLocal::InitFromMap( const char* name ) mapName = name; mapTimeStamp = currentTimeStamp; - // if we are writing a demo, archive the load command - if( common->WriteDemo() ) - { - WriteLoadMap(); - } - if( !src->ReadToken( &token ) || token.Icmp( PROC_FILE_ID ) ) { common->Printf( "idRenderWorldLocal::InitFromMap: bad id '%s' instead of '%s'\n", token.c_str(), PROC_FILE_ID ); diff --git a/neo/renderer/RenderWorld_local.h b/neo/renderer/RenderWorld_local.h index 9277066e46..05b8dbc1d5 100644 --- a/neo/renderer/RenderWorld_local.h +++ b/neo/renderer/RenderWorld_local.h @@ -339,30 +339,6 @@ class idRenderWorldLocal : public idRenderWorld return areaScreenRect[areaNum]; } - //-------------------------- - // RenderWorld_demo.cpp - - void StartWritingDemo( idDemoFile* demo ); - void StopWritingDemo(); - bool ProcessDemoCommand( idDemoFile* readDemo, renderView_t* demoRenderView, int* demoTimeOffset ); - - void WriteLoadMap(); - void WriteRenderView( const renderView_t* renderView ); - void WriteVisibleDefs( const viewDef_t* viewDef ); - void WriteFreeDecal( idDemoFile* f, qhandle_t handle ); - void WriteFreeOverlay( idDemoFile* f, qhandle_t handle ); - void WriteFreeLight( qhandle_t handle ); - void WriteFreeEntity( qhandle_t handle ); - void WriteFreeEnvprobe( qhandle_t handle ); // RB - void WriteRenderDecal( idDemoFile* f, qhandle_t handle ); - void WriteRenderOverlay( idDemoFile* f, qhandle_t handle ); - void WriteRenderLight( idDemoFile* f, qhandle_t handle, const renderLight_t* light ); - void WriteRenderEntity( idDemoFile* f, idRenderEntityLocal* entity ); - void WriteRenderEnvprobe( qhandle_t handle, const renderEnvironmentProbe_t* probe ); // RB - void ReadRenderEntity(); - void ReadRenderLight(); - void ReadRenderEnvprobe(); // RB - //-------------------------- // RenderWorld.cpp diff --git a/neo/renderer/RenderWorld_portals.cpp b/neo/renderer/RenderWorld_portals.cpp index c9d49def93..d386e2642a 100644 --- a/neo/renderer/RenderWorld_portals.cpp +++ b/neo/renderer/RenderWorld_portals.cpp @@ -1132,14 +1132,6 @@ void idRenderWorldLocal::SetPortalState( qhandle_t portal, int blockTypes ) FloodConnectedAreas( &portalAreas[doublePortals[portal - 1].portals[1]->intoArea], i ); } } - - if( common->WriteDemo() ) - { - common->WriteDemo()->WriteInt( DS_RENDER ); - common->WriteDemo()->WriteInt( DC_SET_PORTAL_STATE ); - common->WriteDemo()->WriteInt( portal ); - common->WriteDemo()->WriteInt( blockTypes ); - } } /* diff --git a/neo/renderer/tr_frontend_main.cpp b/neo/renderer/tr_frontend_main.cpp index 81fafb34de..4c63975b14 100644 --- a/neo/renderer/tr_frontend_main.cpp +++ b/neo/renderer/tr_frontend_main.cpp @@ -674,12 +674,6 @@ void R_RenderView( viewDef_t* parms ) // RB: find closest environment probes so we can interpolate between them in the ambient shaders R_FindClosestEnvironmentProbes(); - // write everything needed to the demo file - if( common->WriteDemo() ) - { - static_cast( parms->renderWorld )->WriteVisibleDefs( tr.viewDef ); - } - // add the rendering commands for this viewDef R_AddDrawViewCmd( parms, false ); diff --git a/neo/sound/snd_emitter.cpp b/neo/sound/snd_emitter.cpp index c95ae9e9c5..b12b98705f 100644 --- a/neo/sound/snd_emitter.cpp +++ b/neo/sound/snd_emitter.cpp @@ -467,13 +467,6 @@ void idSoundEmitterLocal::Init( int i, idSoundWorldLocal* sw ) spatializedOrigin.Zero(); memset( &parms, 0, sizeof( parms ) ); - - if( soundWorld && soundWorld->writeDemo ) - { - soundWorld->writeDemo->WriteInt( DS_SOUND ); - soundWorld->writeDemo->WriteInt( SCMD_ALLOC_EMITTER ); - soundWorld->writeDemo->WriteInt( index ); - } } /* @@ -695,13 +688,6 @@ void idSoundEmitterLocal::Free( bool immediate ) // Double free return; } - if( soundWorld && soundWorld->writeDemo ) - { - soundWorld->writeDemo->WriteInt( DS_SOUND ); - soundWorld->writeDemo->WriteInt( SCMD_FREE ); - soundWorld->writeDemo->WriteInt( index ); - soundWorld->writeDemo->WriteInt( immediate ); - } if( immediate ) { @@ -721,21 +707,6 @@ void idSoundEmitterLocal::UpdateEmitter( const idVec3& origin, int listenerId, c assert( soundWorld != NULL ); assert( soundWorld->emitters[this->index] == this ); - if( soundWorld && soundWorld->writeDemo ) - { - soundWorld->writeDemo->WriteInt( DS_SOUND ); - soundWorld->writeDemo->WriteInt( SCMD_UPDATE ); - soundWorld->writeDemo->WriteInt( index ); - soundWorld->writeDemo->WriteVec3( origin ); - soundWorld->writeDemo->WriteInt( listenerId ); - soundWorld->writeDemo->WriteFloat( parms->minDistance ); - soundWorld->writeDemo->WriteFloat( parms->maxDistance ); - soundWorld->writeDemo->WriteFloat( parms->volume ); - soundWorld->writeDemo->WriteFloat( parms->shakes ); - soundWorld->writeDemo->WriteInt( parms->soundShaderFlags ); - soundWorld->writeDemo->WriteInt( parms->soundClass ); - } - this->origin = origin; this->emitterId = listenerId; this->parms = *parms; @@ -762,19 +733,6 @@ int idSoundEmitterLocal::StartSound( const idSoundShader* shader, const s_channe return 0; } - if( soundWorld && soundWorld->writeDemo ) - { - soundWorld->writeDemo->WriteInt( DS_SOUND ); - soundWorld->writeDemo->WriteInt( SCMD_START ); - soundWorld->writeDemo->WriteInt( index ); - - soundWorld->writeDemo->WriteHashString( shader->GetName() ); - - soundWorld->writeDemo->WriteInt( channel ); - soundWorld->writeDemo->WriteFloat( diversity ); - soundWorld->writeDemo->WriteInt( shaderFlags ); - } - if( s_noSound.GetBool() ) { return 0; @@ -1003,14 +961,6 @@ void idSoundEmitterLocal::StopSound( const s_channelType channel ) assert( soundWorld != NULL ); assert( soundWorld->emitters[this->index] == this ); - if( soundWorld && soundWorld->writeDemo ) - { - soundWorld->writeDemo->WriteInt( DS_SOUND ); - soundWorld->writeDemo->WriteInt( SCMD_STOP ); - soundWorld->writeDemo->WriteInt( index ); - soundWorld->writeDemo->WriteInt( channel ); - } - for( int i = 0; i < channels.Num(); i++ ) { idSoundChannel* chan = channels[i]; @@ -1039,20 +989,6 @@ void idSoundEmitterLocal::ModifySound( const s_channelType channel, const soundS assert( soundWorld != NULL ); assert( soundWorld->emitters[this->index] == this ); - if( soundWorld && soundWorld->writeDemo ) - { - soundWorld->writeDemo->WriteInt( DS_SOUND ); - soundWorld->writeDemo->WriteInt( SCMD_MODIFY ); - soundWorld->writeDemo->WriteInt( index ); - soundWorld->writeDemo->WriteInt( channel ); - soundWorld->writeDemo->WriteFloat( parms->minDistance ); - soundWorld->writeDemo->WriteFloat( parms->maxDistance ); - soundWorld->writeDemo->WriteFloat( parms->volume ); - soundWorld->writeDemo->WriteFloat( parms->shakes ); - soundWorld->writeDemo->WriteInt( parms->soundShaderFlags ); - soundWorld->writeDemo->WriteInt( parms->soundClass ); - } - for( int i = channels.Num() - 1; i >= 0; i-- ) { idSoundChannel* chan = channels[i]; @@ -1060,10 +996,12 @@ void idSoundEmitterLocal::ModifySound( const s_channelType channel, const soundS { continue; } + if( s_showStartSound.GetBool() ) { idLib::Printf( "%dms: ModifySound(%d:%d): %s\n", soundWorld->GetSoundTime(), index, channel, chan->soundShader->GetName() ); } + OverrideParms( &chan->parms, parms, &chan->parms ); } } @@ -1078,16 +1016,6 @@ void idSoundEmitterLocal::FadeSound( const s_channelType channel, float to, floa assert( soundWorld != NULL ); assert( soundWorld->emitters[this->index] == this ); - if( soundWorld->writeDemo ) - { - soundWorld->writeDemo->WriteInt( DS_SOUND ); - soundWorld->writeDemo->WriteInt( SCMD_FADE ); - soundWorld->writeDemo->WriteInt( index ); - soundWorld->writeDemo->WriteInt( channel ); - soundWorld->writeDemo->WriteFloat( to ); - soundWorld->writeDemo->WriteFloat( over ); - } - int overMSec = SEC2MS( over ); for( int i = 0; i < channels.Num(); i++ ) diff --git a/neo/sound/snd_local.h b/neo/sound/snd_local.h index aa29151f25..1b4f16fe93 100644 --- a/neo/sound/snd_local.h +++ b/neo/sound/snd_local.h @@ -324,19 +324,10 @@ class idSoundWorldLocal : public idSoundWorld // where is the camera virtual void PlaceListener( const idVec3& origin, const idMat3& axis, const int listenerId ); - virtual void WriteSoundShaderLoad( const idSoundShader* snd ); - // fade all sounds in the world with a given shader soundClass // to is in Db, over is in seconds virtual void FadeSoundClasses( const int soundClass, const float to, const float over ); - // dumps the current state and begins archiving commands - virtual void StartWritingDemo( idDemoFile* demo ); - virtual void StopWritingDemo(); - - // read a sound command from a demo file - virtual void ProcessDemoCommand( idDemoFile* readDemo ); - // menu sounds virtual int PlayShaderDirectly( const char* name, int channel = -1 ); @@ -377,7 +368,6 @@ class idSoundWorldLocal : public idSoundWorld idSoundFade soundClassFade[SOUND_MAX_CLASSES]; idRenderWorld* renderWorld; // for debug visualization and light amplitude sampling - idDemoFile* writeDemo; // if not NULL, archive commands here float currentCushionDB; // channels at or below this level will be faded to 0 float shakeAmp; // last calculated shake amplitude diff --git a/neo/sound/snd_shader.cpp b/neo/sound/snd_shader.cpp index 6b3fa8c86a..dd5e5ca234 100644 --- a/neo/sound/snd_shader.cpp +++ b/neo/sound/snd_shader.cpp @@ -163,11 +163,6 @@ idSoundShader::Parse */ bool idSoundShader::Parse( const char* text, const int textLength, bool allowBinaryVersion ) { - if( soundSystemLocal.currentSoundWorld ) - { - soundSystemLocal.currentSoundWorld->WriteSoundShaderLoad( this ); - } - idLexer src; src.LoadMemory( text, textLength, GetFileName(), GetLineNum() ); diff --git a/neo/sound/snd_world.cpp b/neo/sound/snd_world.cpp index dc16469bb0..850ea95909 100644 --- a/neo/sound/snd_world.cpp +++ b/neo/sound/snd_world.cpp @@ -46,8 +46,6 @@ idCVar s_showVoices( "s_showVoices", "0", CVAR_BOOL, "show active voices" ); idCVar s_volume_dB( "s_volume_dB", "0", CVAR_ARCHIVE | CVAR_FLOAT, "volume in dB" ); extern idCVar s_noSound; -extern void WriteDeclCache( idDemoFile* f, int demoCategory, int demoCode, declType_t declType ); - /* ======================== idSoundWorldLocal::idSoundWorldLocal @@ -61,7 +59,6 @@ idSoundWorldLocal::idSoundWorldLocal() soundClassFade[i].Clear(); } renderWorld = NULL; - writeDemo = NULL; listener.axis.Identity(); listener.pos.Zero(); @@ -168,15 +165,6 @@ idSoundWorldLocal::PlaceListener */ void idSoundWorldLocal::PlaceListener( const idVec3& origin, const idMat3& axis, const int id ) { - if( writeDemo ) - { - writeDemo->WriteInt( DS_SOUND ); - writeDemo->WriteInt( SCMD_PLACE_LISTENER ); - writeDemo->WriteVec3( origin ); - writeDemo->WriteMat3( axis ); - writeDemo->WriteInt( id ); - } - if( s_lockListener.GetBool() ) { return; @@ -196,22 +184,6 @@ void idSoundWorldLocal::PlaceListener( const idVec3& origin, const idMat3& axis, } } -/* -======================== -idSoundWorldLocal::WriteSoundShaderLoad -======================== -*/ -void idSoundWorldLocal::WriteSoundShaderLoad( const idSoundShader* snd ) -{ - if( writeDemo ) - { - writeDemo->WriteInt( DS_SOUND ); - writeDemo->WriteInt( SCMD_CACHESOUNDSHADER ); - writeDemo->WriteInt( 1 ); - writeDemo->WriteHashString( snd->GetName() ); - } -} - /* ======================== idActiveChannel @@ -873,181 +845,6 @@ void idSoundWorldLocal::ResolveOrigin( const int stackDepth, const soundPortalTr } /* -======================== -idSoundWorldLocal::StartWritingDemo -======================== -*/ -void idSoundWorldLocal::StartWritingDemo( idDemoFile* demo ) -{ - writeDemo = demo; - - WriteDeclCache( writeDemo, DS_SOUND, SCMD_CACHESOUNDSHADER, DECL_SOUND ); - - writeDemo->WriteInt( DS_SOUND ); - writeDemo->WriteInt( SCMD_STATE ); - - // use the normal save game code to archive all the emitters - WriteToSaveGame( writeDemo ); -} - -/* -======================== -idSoundWorldLocal::StopWritingDemo -======================== -*/ -void idSoundWorldLocal::StopWritingDemo() -{ - writeDemo = NULL; -} - -/* -======================== -idSoundWorldLocal::ProcessDemoCommand -======================== -*/ -void idSoundWorldLocal::ProcessDemoCommand( idDemoFile* readDemo ) -{ - - if( !readDemo ) - { - return; - } - - int index; - soundDemoCommand_t dc; - - if( !readDemo->ReadInt( ( int& )dc ) ) - { - return; - } - - switch( dc ) - { - case SCMD_CACHESOUNDSHADER: - { - int numCaches = 0; - readDemo->ReadInt( numCaches ); - for( int i = 0; i < numCaches; ++i ) - { - const char* declName = readDemo->ReadHashString(); - declManager->FindSound( declName ); - } - break; - } - case SCMD_STATE: - { - ReadFromSaveGame( readDemo ); - UnPause(); - break; - } - case SCMD_PLACE_LISTENER: - { - idVec3 origin; - idMat3 axis; - int listenerId; - - readDemo->ReadVec3( origin ); - readDemo->ReadMat3( axis ); - readDemo->ReadInt( listenerId ); - - PlaceListener( origin, axis, listenerId ); - }; - break; - case SCMD_ALLOC_EMITTER: - { - readDemo->ReadInt( index ); - - while( emitters.Num() <= index ) - { - // append a brand new one - AllocSoundEmitter(); - } - } - break; - case SCMD_FREE: - { - int immediate; - - readDemo->ReadInt( index ); - readDemo->ReadInt( immediate ); - EmitterForIndex( index )->Free( immediate != 0 ); - } - break; - case SCMD_UPDATE: - { - idVec3 origin; - int listenerId; - soundShaderParms_t parms; - - readDemo->ReadInt( index ); - readDemo->ReadVec3( origin ); - readDemo->ReadInt( listenerId ); - readDemo->ReadFloat( parms.minDistance ); - readDemo->ReadFloat( parms.maxDistance ); - readDemo->ReadFloat( parms.volume ); - readDemo->ReadFloat( parms.shakes ); - readDemo->ReadInt( parms.soundShaderFlags ); - readDemo->ReadInt( parms.soundClass ); - EmitterForIndex( index )->UpdateEmitter( origin, listenerId, &parms ); - } - break; - case SCMD_START: - { - const idSoundShader* shader; - int channel; - float diversity; - int shaderFlags; - - readDemo->ReadInt( index ); - shader = declManager->FindSound( readDemo->ReadHashString() ); - readDemo->ReadInt( channel ); - readDemo->ReadFloat( diversity ); - readDemo->ReadInt( shaderFlags ); - EmitterForIndex( index )->StartSound( shader, ( s_channelType )channel, diversity, shaderFlags ); - } - break; - case SCMD_MODIFY: - { - int channel; - soundShaderParms_t parms; - - readDemo->ReadInt( index ); - readDemo->ReadInt( channel ); - readDemo->ReadFloat( parms.minDistance ); - readDemo->ReadFloat( parms.maxDistance ); - readDemo->ReadFloat( parms.volume ); - readDemo->ReadFloat( parms.shakes ); - readDemo->ReadInt( parms.soundShaderFlags ); - readDemo->ReadInt( parms.soundClass ); - EmitterForIndex( index )->ModifySound( ( s_channelType )channel, &parms ); - } - break; - case SCMD_STOP: - { - int channel; - - readDemo->ReadInt( index ); - readDemo->ReadInt( channel ); - EmitterForIndex( index )->StopSound( ( s_channelType )channel ); - } - break; - case SCMD_FADE: - { - int channel; - float to, over; - - readDemo->ReadInt( index ); - readDemo->ReadInt( channel ); - readDemo->ReadFloat( to ); - readDemo->ReadFloat( over ); - EmitterForIndex( index )->FadeSound( ( s_channelType )channel, to, over ); - } - break; - } -} - -/* -================= idSoundWorldLocal::WriteToSaveGame ================= */ diff --git a/neo/sound/sound.h b/neo/sound/sound.h index ba931e5339..4f507f4560 100644 --- a/neo/sound/sound.h +++ b/neo/sound/sound.h @@ -218,13 +218,6 @@ class idSoundWorld // menu sounds virtual int PlayShaderDirectly( const char* name, int channel = -1 ) = 0; - // dumps the current state and begins archiving commands - virtual void StartWritingDemo( idDemoFile* demo ) = 0; - virtual void StopWritingDemo() = 0; - - // read a sound command from a demo file - virtual void ProcessDemoCommand( idDemoFile* demo ) = 0; - // when cinematics are skipped, we need to advance sound time this much virtual void Skip( int time ) = 0; diff --git a/neo/ui/GuiScript.h b/neo/ui/GuiScript.h index 953cd47c1e..a39c126d49 100644 --- a/neo/ui/GuiScript.h +++ b/neo/ui/GuiScript.h @@ -112,8 +112,6 @@ class idGuiScriptList return sz; } void FixupParms( idWindow* win ); - void ReadFromDemoFile( class idDemoFile* f ) {}; - void WriteToDemoFile( class idDemoFile* f ) {}; void WriteToSaveGame( idFile* savefile ); void ReadFromSaveGame( idFile* savefile ); diff --git a/neo/ui/RegExp.cpp b/neo/ui/RegExp.cpp index 7b1384a2c1..a3ea0adfbf 100644 --- a/neo/ui/RegExp.cpp +++ b/neo/ui/RegExp.cpp @@ -178,40 +178,6 @@ void idRegister::GetFromRegs( float* registers ) } } -/* -================= -idRegister::ReadFromDemoFile -================= -*/ -void idRegister::ReadFromDemoFile( idDemoFile* f ) -{ - f->ReadBool( enabled ); - f->ReadShort( type ); - f->ReadInt( regCount ); - for( int i = 0; i < 4; i++ ) - { - f->ReadUnsignedShort( regs[i] ); - } - name = f->ReadHashString(); -} - -/* -================= -idRegister::WriteToDemoFile -================= -*/ -void idRegister::WriteToDemoFile( idDemoFile* f ) -{ - f->WriteBool( enabled ); - f->WriteShort( type ); - f->WriteInt( regCount ); - for( int i = 0; i < 4; i++ ) - { - f->WriteUnsignedShort( regs[i] ); - } - f->WriteHashString( name ); -} - /* ================= idRegister::WriteToSaveGame @@ -399,41 +365,6 @@ void idRegisterList::Reset() regHash.Clear(); } -/* -==================== -idRegisterList::ReadFromSaveGame -==================== -*/ -void idRegisterList::ReadFromDemoFile( idDemoFile* f ) -{ - int c; - - f->ReadInt( c ); - regs.DeleteContents( true ); - for( int i = 0; i < c; i++ ) - { - idRegister* reg = new( TAG_OLD_UI ) idRegister; - reg->ReadFromDemoFile( f ); - regs.Append( reg ); - } -} - -/* -==================== -idRegisterList::ReadFromSaveGame -==================== -*/ -void idRegisterList::WriteToDemoFile( idDemoFile* f ) -{ - int c = regs.Num(); - - f->WriteInt( c ); - for( int i = 0 ; i < c; i++ ) - { - regs[i]->WriteToDemoFile( f ); - } -} - /* ===================== idRegisterList::WriteToSaveGame diff --git a/neo/ui/RegExp.h b/neo/ui/RegExp.h index 23e3bcb8d0..875dd30e14 100644 --- a/neo/ui/RegExp.h +++ b/neo/ui/RegExp.h @@ -56,8 +56,6 @@ class idRegister { enabled = b; } - void ReadFromDemoFile( idDemoFile* f ); - void WriteToDemoFile( idDemoFile* f ); void WriteToSaveGame( idFile* savefile ); void ReadFromSaveGame( idFile* savefile ); }; @@ -98,8 +96,6 @@ class idRegisterList void SetToRegs( float* registers ); void GetFromRegs( float* registers ); void Reset(); - void ReadFromDemoFile( idDemoFile* f ); - void WriteToDemoFile( idDemoFile* f ); void WriteToSaveGame( idFile* savefile ); void ReadFromSaveGame( idFile* savefile ); diff --git a/neo/ui/RegExp_old.h b/neo/ui/RegExp_old.h deleted file mode 100644 index a5fcdd2a10..0000000000 --- a/neo/ui/RegExp_old.h +++ /dev/null @@ -1,92 +0,0 @@ -/* -=========================================================================== - -Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. - -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). - -Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Doom 3 BFG Edition Source Code. If not, see . - -In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below. - -If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA. - -=========================================================================== -*/ -#ifndef REGEXP_H_ -#define REGEXP_H_ - -class idWindow; - -class idRegister -{ -public: - idRegister() {}; - idRegister( const char* p, int t ) - { - name = p; - type = t; - assert( t >= 0 && t < NUMTYPES ); - regCount = REGCOUNT[t]; - enabled = ( type == STRING ) ? false : true; - }; - bool enabled; - int type; - int regCount; - enum REGTYPE { VEC4 = 0, FLOAT, BOOL, INT, STRING, VEC2, VEC3, NUMTYPES } ; - static int REGCOUNT[NUMTYPES]; - idStr name; - int regs[4]; - void SetToRegs( float* registers, idTypedDict* state ); - void SetToRegList( idList* registers, idTypedDict* state ); - void GetFromRegs( float* registers, idTypedDict* state ); - void CopyRegs( idRegister* src ) - { - regs[0] = src->regs[0]; - regs[1] = src->regs[1]; - regs[2] = src->regs[2]; - regs[3] = src->regs[3]; - } - void Enable( bool b ) - { - enabled = b; - } - void ReadFromDemoFile( idDemoFile* f ); - void WriteToDemoFile( idDemoFile* f ); - -}; - -class idRegisterList -{ - idList regs; -public: - - // - void RemoveReg( const char* name ); - // - - void AddReg( const char* name, int type, idTokenParser* src, idWindow* win ); - void AddReg( const char* name, int type, idVec4 data, idWindow* win ); - idRegister* FindReg( const char* name ); - int FindRegIndex( const char* name ); - void SetToRegs( float* registers, idTypedDict* state ); - void GetFromRegs( float* registers, idTypedDict* state ); - void Reset(); - void ReadFromDemoFile( idDemoFile* f ); - void WriteToDemoFile( idDemoFile* f ); - -}; - -#endif \ No newline at end of file diff --git a/neo/ui/UserInterface.cpp b/neo/ui/UserInterface.cpp index eb4eb179ec..5022793cde 100644 --- a/neo/ui/UserInterface.cpp +++ b/neo/ui/UserInterface.cpp @@ -630,58 +630,6 @@ void idUserInterfaceLocal::Trigger( int _time ) } } -void idUserInterfaceLocal::ReadFromDemoFile( class idDemoFile* f ) -{ - idStr work; - f->ReadDict( state ); - source = state.GetString( "name" ); - - if( desktop == NULL ) - { - f->Log( "creating new gui\n" ); - desktop = new( TAG_OLD_UI ) idWindow( this ); - desktop->SetFlag( WIN_DESKTOP ); - desktop->ReadFromDemoFile( f ); - } - else - { - f->Log( "re-using gui\n" ); - desktop->ReadFromDemoFile( f, false ); - } - - f->ReadFloat( cursorX ); - f->ReadFloat( cursorY ); - - bool add = true; - int c = uiManagerLocal.demoGuis.Num(); - for( int i = 0; i < c; i++ ) - { - if( uiManagerLocal.demoGuis[i] == this ) - { - add = false; - break; - } - } - - if( add ) - { - uiManagerLocal.demoGuis.Append( this ); - } -} - -void idUserInterfaceLocal::WriteToDemoFile( class idDemoFile* f ) -{ - idStr work; - f->WriteDict( state ); - if( desktop ) - { - desktop->WriteToDemoFile( f ); - } - - f->WriteFloat( cursorX ); - f->WriteFloat( cursorY ); -} - bool idUserInterfaceLocal::WriteToSaveGame( idFile* savefile ) const { int len; diff --git a/neo/ui/UserInterface.h b/neo/ui/UserInterface.h index 854d7efbd9..3f518d57a4 100644 --- a/neo/ui/UserInterface.h +++ b/neo/ui/UserInterface.h @@ -39,7 +39,6 @@ If you have questions concerning this license or the applicable additional terms */ class idFile; -class idDemoFile; class idUserInterface @@ -102,9 +101,6 @@ class idUserInterface // Triggers the gui and runs the onTrigger scripts. virtual void Trigger( int time ) = 0; - virtual void ReadFromDemoFile( class idDemoFile* f ) = 0; - virtual void WriteToDemoFile( class idDemoFile* f ) = 0; - virtual bool WriteToSaveGame( idFile* savefile ) const = 0; virtual bool ReadFromSaveGame( idFile* savefile ) = 0; virtual void SetKeyBindingNames() = 0; diff --git a/neo/ui/UserInterfaceLocal.h b/neo/ui/UserInterfaceLocal.h index d9054afcec..9032dfcfa7 100644 --- a/neo/ui/UserInterfaceLocal.h +++ b/neo/ui/UserInterfaceLocal.h @@ -59,8 +59,6 @@ class idUserInterfaceLocal : public idUserInterface virtual void StateChanged( int time, bool redraw ); virtual const char* Activate( bool activate, int time ); virtual void Trigger( int time ); - virtual void ReadFromDemoFile( class idDemoFile* f ); - virtual void WriteToDemoFile( class idDemoFile* f ); virtual bool WriteToSaveGame( idFile* savefile ) const; virtual bool ReadFromSaveGame( idFile* savefile ); virtual void SetKeyBindingNames(); diff --git a/neo/ui/Window.cpp b/neo/ui/Window.cpp index c81df07713..50cf8d49aa 100644 --- a/neo/ui/Window.cpp +++ b/neo/ui/Window.cpp @@ -3607,281 +3607,6 @@ void idWindow::EvaluateRegisters( float* registers ) } -/* -================ -idWindow::ReadFromDemoFile -================ -*/ -void idWindow::ReadFromDemoFile( class idDemoFile* f, bool rebuild ) -{ - - // should never hit unless we re-enable WRITE_GUIS -#ifndef WRITE_GUIS - assert( false ); -#else - - if( rebuild ) - { - CommonInit(); - } - - f->SetLog( true, "window1" ); - backGroundName = f->ReadHashString(); - f->SetLog( true, backGroundName ); - if( backGroundName[0] ) - { - background = declManager->FindMaterial( backGroundName ); - } - else - { - background = NULL; - } - f->ReadUnsignedChar( cursor ); - f->ReadUnsignedInt( flags ); - f->ReadInt( timeLine ); - f->ReadInt( lastTimeRun ); - idRectangle rct = rect; - f->ReadFloat( rct.x ); - f->ReadFloat( rct.y ); - f->ReadFloat( rct.w ); - f->ReadFloat( rct.h ); - f->ReadFloat( drawRect.x ); - f->ReadFloat( drawRect.y ); - f->ReadFloat( drawRect.w ); - f->ReadFloat( drawRect.h ); - f->ReadFloat( clientRect.x ); - f->ReadFloat( clientRect.y ); - f->ReadFloat( clientRect.w ); - f->ReadFloat( clientRect.h ); - f->ReadFloat( textRect.x ); - f->ReadFloat( textRect.y ); - f->ReadFloat( textRect.w ); - f->ReadFloat( textRect.h ); - f->ReadFloat( xOffset ); - f->ReadFloat( yOffset ); - int i, c; - - idStr work; - if( rebuild ) - { - f->SetLog( true, ( work + "-scripts" ) ); - for( i = 0; i < SCRIPT_COUNT; i++ ) - { - bool b; - f->ReadBool( b ); - if( b ) - { - delete scripts[i]; - scripts[i] = new( TAG_OLD_UI ) idGuiScriptList; - scripts[i]->ReadFromDemoFile( f ); - } - } - - f->SetLog( true, ( work + "-timelines" ) ); - f->ReadInt( c ); - for( i = 0; i < c; i++ ) - { - idTimeLineEvent* tl = new( TAG_OLD_UI ) idTimeLineEvent; - f->ReadInt( tl->time ); - f->ReadBool( tl->pending ); - tl->event->ReadFromDemoFile( f ); - if( rebuild ) - { - timeLineEvents.Append( tl ); - } - else - { - assert( i < timeLineEvents.Num() ); - timeLineEvents[i]->time = tl->time; - timeLineEvents[i]->pending = tl->pending; - } - } - } - - f->SetLog( true, ( work + "-transitions" ) ); - f->ReadInt( c ); - for( i = 0; i < c; i++ ) - { - idTransitionData td; - td.data = NULL; - f->ReadInt( td.offset ); - - float startTime, accelTime, linearTime, decelTime; - idVec4 startValue, endValue; - f->ReadFloat( startTime ); - f->ReadFloat( accelTime ); - f->ReadFloat( linearTime ); - f->ReadFloat( decelTime ); - f->ReadVec4( startValue ); - f->ReadVec4( endValue ); - td.interp.Init( startTime, accelTime, decelTime, accelTime + linearTime + decelTime, startValue, endValue ); - - // read this for correct data padding with the win32 savegames - // the extrapolate is correctly initialized through the above Init call - int extrapolationType; - float duration; - idVec4 baseSpeed, speed; - float currentTime; - idVec4 currentValue; - f->ReadInt( extrapolationType ); - f->ReadFloat( startTime ); - f->ReadFloat( duration ); - f->ReadVec4( startValue ); - f->ReadVec4( baseSpeed ); - f->ReadVec4( speed ); - f->ReadFloat( currentTime ); - f->ReadVec4( currentValue ); - - transitions.Append( td ); - } - - f->SetLog( true, ( work + "-regstuff" ) ); - if( rebuild ) - { - f->ReadInt( c ); - for( i = 0; i < c; i++ ) - { - wexpOp_t w; - f->ReadInt( ( int& )w.opType ); - f->ReadInt( w.a ); - f->ReadInt( w.b ); - f->ReadInt( w.c ); - f->ReadInt( w.d ); - ops.Append( w ); - } - - f->ReadInt( c ); - for( i = 0; i < c; i++ ) - { - float ff; - f->ReadFloat( ff ); - expressionRegisters.Append( ff ); - } - - regList.ReadFromDemoFile( f ); - - } - f->SetLog( true, ( work + "-children" ) ); - f->ReadInt( c ); - for( i = 0; i < c; i++ ) - { - if( rebuild ) - { - idWindow* win = new( TAG_OLD_UI ) idWindow( dc, gui ); - win->ReadFromDemoFile( f ); - AddChild( win ); - } - else - { - for( int j = 0; j < c; j++ ) - { - if( children[j]->childID == i ) - { - children[j]->ReadFromDemoFile( f, rebuild ); - break; - } - else - { - continue; - } - } - } - } -#endif /* WRITE_GUIS */ -} - -/* -================ -idWindow::WriteToDemoFile -================ -*/ -void idWindow::WriteToDemoFile( class idDemoFile* f ) -{ - // should never hit unless we re-enable WRITE_GUIS -#ifndef WRITE_GUIS - assert( false ); -#else - - f->SetLog( true, "window" ); - f->WriteHashString( backGroundName ); - f->SetLog( true, backGroundName ); - f->WriteUnsignedChar( cursor ); - f->WriteUnsignedInt( flags ); - f->WriteInt( timeLine ); - f->WriteInt( lastTimeRun ); - idRectangle rct = rect; - f->WriteFloat( rct.x ); - f->WriteFloat( rct.y ); - f->WriteFloat( rct.w ); - f->WriteFloat( rct.h ); - f->WriteFloat( drawRect.x ); - f->WriteFloat( drawRect.y ); - f->WriteFloat( drawRect.w ); - f->WriteFloat( drawRect.h ); - f->WriteFloat( clientRect.x ); - f->WriteFloat( clientRect.y ); - f->WriteFloat( clientRect.w ); - f->WriteFloat( clientRect.h ); - f->WriteFloat( textRect.x ); - f->WriteFloat( textRect.y ); - f->WriteFloat( textRect.w ); - f->WriteFloat( textRect.h ); - f->WriteFloat( xOffset ); - f->WriteFloat( yOffset ); - idStr work; - f->SetLog( true, work ); - - int i, c; - - f->SetLog( true, ( work + "-transitions" ) ); - c = transitions.Num(); - f->WriteInt( c ); - for( i = 0; i < c; i++ ) - { - f->WriteInt( 0 ); - f->WriteInt( transitions[i].offset ); - - f->WriteFloat( transitions[i].interp.GetStartTime() ); - f->WriteFloat( transitions[i].interp.GetAccelTime() ); - f->WriteFloat( transitions[i].interp.GetLinearTime() ); - f->WriteFloat( transitions[i].interp.GetDecelTime() ); - f->WriteVec4( transitions[i].interp.GetStartValue() ); - f->WriteVec4( transitions[i].interp.GetEndValue() ); - - // write to keep win32 render demo format compatiblity - we don't actually read them back anymore - f->WriteInt( transitions[i].interp.GetExtrapolate()->GetExtrapolationType() ); - f->WriteFloat( transitions[i].interp.GetExtrapolate()->GetStartTime() ); - f->WriteFloat( transitions[i].interp.GetExtrapolate()->GetDuration() ); - f->WriteVec4( transitions[i].interp.GetExtrapolate()->GetStartValue() ); - f->WriteVec4( transitions[i].interp.GetExtrapolate()->GetBaseSpeed() ); - f->WriteVec4( transitions[i].interp.GetExtrapolate()->GetSpeed() ); - f->WriteFloat( transitions[i].interp.GetExtrapolate()->GetCurrentTime() ); - f->WriteVec4( transitions[i].interp.GetExtrapolate()->GetCurrentValue() ); - } - - f->SetLog( true, ( work + "-regstuff" ) ); - - f->SetLog( true, ( work + "-children" ) ); - c = children.Num(); - f->WriteInt( c ); - for( i = 0; i < c; i++ ) - { - for( int j = 0; j < c; j++ ) - { - if( children[j]->childID == i ) - { - children[j]->WriteToDemoFile( f ); - break; - } - else - { - continue; - } - } - } -#endif /* WRITE_GUIS */ -} - /* =============== idWindow::WriteString diff --git a/neo/ui/Window.h b/neo/ui/Window.h index 4d1f789e10..67b830d172 100644 --- a/neo/ui/Window.h +++ b/neo/ui/Window.h @@ -294,8 +294,6 @@ class idWindow virtual void SetBuddy( idWindow* buddy ) {}; virtual void HandleBuddyUpdate( idWindow* buddy ) {}; virtual void StateChanged( bool redraw ); - virtual void ReadFromDemoFile( class idDemoFile* f, bool rebuild = true ); - virtual void WriteToDemoFile( class idDemoFile* f ); // SaveGame support void WriteSaveGameString( const char* string, idFile* savefile ); From d05a3db5e514c76f2ec9041f5406fb56d836a5d1 Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Thu, 21 Mar 2024 22:14:30 +0100 Subject: [PATCH 16/71] More renderdemo code removed --- neo/renderer/ModelDecal.cpp | 11 +---------- neo/renderer/ModelDecal.h | 4 ---- neo/renderer/ModelOverlay.cpp | 12 ++---------- neo/renderer/ModelOverlay.h | 6 ------ neo/renderer/RenderCommon.h | 2 -- neo/renderer/RenderEntity.cpp | 1 - neo/renderer/RenderWorld.cpp | 7 ------- neo/renderer/ResolutionScale.cpp | 7 +++++-- neo/renderer/tr_frontend_addmodels.cpp | 2 -- 9 files changed, 8 insertions(+), 44 deletions(-) diff --git a/neo/renderer/ModelDecal.cpp b/neo/renderer/ModelDecal.cpp index ad1244a29e..7fee6840f3 100644 --- a/neo/renderer/ModelDecal.cpp +++ b/neo/renderer/ModelDecal.cpp @@ -4,7 +4,6 @@ Doom 3 BFG Edition GPL Source Code Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 2014-2016 Robert Beckebans -Copyright (C) 2014-2016 Kot in Action Creative Artel This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). @@ -55,10 +54,7 @@ idRenderModelDecal::idRenderModelDecal() : nextDecal( 0 ), firstDeferredDecal( 0 ), nextDeferredDecal( 0 ), - numDecalMaterials( 0 ), - index( -1 ), - demoSerialWrite( 0 ), - demoSerialCurrent( 0 ) + numDecalMaterials( 0 ) { // SRS - initialize decals so members are defined for logical tests in CreateDecalFromWinding() memset( decals, 0, sizeof( decals ) ); @@ -218,7 +214,6 @@ void idRenderModelDecal::ReUse() firstDeferredDecal = 0; nextDeferredDecal = 0; numDecalMaterials = 0; - demoSerialCurrent++; } /* @@ -251,8 +246,6 @@ void idRenderModelDecal::CreateDecalFromWinding( const idWinding& w, const idMat } } - demoSerialCurrent++; - decal_t& decal = decals[decalIndex]; const float invFadeDepth = -1.0f / fadeDepth; @@ -300,8 +293,6 @@ void idRenderModelDecal::CreateDecalFromWinding( const idWinding& w, const idMat decal.indexes[decal.numIndexes + 1] = 0; decal.indexes[decal.numIndexes + 2] = 0; } - - decal.writtenToDemo = false; } /* diff --git a/neo/renderer/ModelDecal.h b/neo/renderer/ModelDecal.h index 61ab56a62b..0c7c7ef0d1 100644 --- a/neo/renderer/ModelDecal.h +++ b/neo/renderer/ModelDecal.h @@ -91,7 +91,6 @@ struct decalProjectionParms_t int numIndexes; int startTime; const idMaterial* material; - mutable bool writtenToDemo; } #if !defined(_WIN32) ALIGNTYPE16 @@ -126,9 +125,6 @@ class idRenderModelDecal unsigned int GetNumDecalDrawSurfs(); struct drawSurf_t* CreateDecalDrawSurf( const struct viewEntity_t* space, unsigned int index ); - qhandle_t index; // Used for Demo files. - int demoSerialWrite; - int demoSerialCurrent; private: decal_t decals[MAX_DECALS]; unsigned int firstDecal; diff --git a/neo/renderer/ModelOverlay.cpp b/neo/renderer/ModelOverlay.cpp index 54d17c63a6..175d073d50 100644 --- a/neo/renderer/ModelOverlay.cpp +++ b/neo/renderer/ModelOverlay.cpp @@ -3,8 +3,7 @@ Doom 3 BFG Edition GPL Source Code Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -Copyright (C) 2013-2016 Robert Beckebans -Copyright (C) 2014-2016 Kot in Action Creative Artel +Copyright (C) 2013 Robert Beckebans This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). @@ -46,10 +45,7 @@ idRenderModelOverlay::idRenderModelOverlay() : nextOverlay( 0 ), firstDeferredOverlay( 0 ), nextDeferredOverlay( 0 ), - numOverlayMaterials( 0 ), - index( -1 ), - demoSerialWrite( 0 ), - demoSerialCurrent( 0 ) + numOverlayMaterials( 0 ) { memset( overlays, 0, sizeof( overlays ) ); } @@ -79,7 +75,6 @@ void idRenderModelOverlay::ReUse() firstDeferredOverlay = 0; nextDeferredOverlay = 0; numOverlayMaterials = 0; - demoSerialCurrent++; for( unsigned int i = 0; i < MAX_OVERLAYS; i++ ) { @@ -496,8 +491,6 @@ void idRenderModelOverlay::CreateOverlay( const idRenderModel* model, const idPl overlayIndexes[numIndexes + 2] = 0; } - demoSerialCurrent++; - // allocate a new overlay overlay_t& overlay = overlays[nextOverlay++ & ( MAX_OVERLAYS - 1 )]; FreeOverlay( overlay ); @@ -511,7 +504,6 @@ void idRenderModelOverlay::CreateOverlay( const idRenderModel* model, const idPl overlay.verts = ( overlayVertex_t* )Mem_Alloc( numVerts * sizeof( overlay.verts[0] ), TAG_MODEL ); memcpy( overlay.verts, overlayVerts.Ptr(), numVerts * sizeof( overlay.verts[0] ) ); overlay.maxReferencedVertex = maxReferencedVertex; - overlay.writtenToDemo = false; if( nextOverlay - firstOverlay > MAX_OVERLAYS ) { diff --git a/neo/renderer/ModelOverlay.h b/neo/renderer/ModelOverlay.h index 89cda50663..a490b5833f 100644 --- a/neo/renderer/ModelOverlay.h +++ b/neo/renderer/ModelOverlay.h @@ -3,8 +3,6 @@ Doom 3 BFG Edition GPL Source Code Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -Copyright (C) 2014-2016 Robert Beckebans -Copyright (C) 2014-2016 Kot in Action Creative Artel This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). @@ -78,7 +76,6 @@ struct overlay_t int numVerts; overlayVertex_t* verts; const idMaterial* material; - mutable bool writtenToDemo; }; class idRenderModelOverlay @@ -95,9 +92,6 @@ class idRenderModelOverlay unsigned int GetNumOverlayDrawSurfs(); struct drawSurf_t* CreateOverlayDrawSurf( const struct viewEntity_t* space, const idRenderModel* baseModel, unsigned int index ); - int index; - int demoSerialWrite; - int demoSerialCurrent; private: overlay_t overlays[MAX_OVERLAYS]; unsigned int firstOverlay; diff --git a/neo/renderer/RenderCommon.h b/neo/renderer/RenderCommon.h index f45f845c1b..d797a631e3 100644 --- a/neo/renderer/RenderCommon.h +++ b/neo/renderer/RenderCommon.h @@ -284,14 +284,12 @@ class idRenderEntityLocal : public idRenderEntity int lastModifiedFrameNum; // to determine if it is constantly changing, // and should go in the dynamic frame memory, or kept // in the cached memory - bool archived; // for demo writing idRenderModel* dynamicModel; // if parms.model->IsDynamicModel(), this is the generated data int dynamicModelFrameCount; // continuously animating dynamic models will recreate // dynamicModel if this doesn't == tr.viewCount idRenderModel* cachedDynamicModel; - // the local bounds used to place entityRefs, either from parms for dynamic entities, or a model bounds idBounds localReferenceBounds; diff --git a/neo/renderer/RenderEntity.cpp b/neo/renderer/RenderEntity.cpp index d1ac4b0ad1..dc9d8bc738 100644 --- a/neo/renderer/RenderEntity.cpp +++ b/neo/renderer/RenderEntity.cpp @@ -41,7 +41,6 @@ idRenderEntityLocal::idRenderEntityLocal() world = NULL; index = 0; lastModifiedFrameNum = 0; - archived = false; dynamicModel = NULL; dynamicModelFrameCount = 0; cachedDynamicModel = NULL; diff --git a/neo/renderer/RenderWorld.cpp b/neo/renderer/RenderWorld.cpp index 0ff43a78bf..30844ce71f 100644 --- a/neo/renderer/RenderWorld.cpp +++ b/neo/renderer/RenderWorld.cpp @@ -4,7 +4,6 @@ Doom 3 BFG Edition GPL Source Code Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 2014-2016 Robert Beckebans -Copyright (C) 2014-2016 Kot in Action Creative Artel This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). @@ -166,7 +165,6 @@ idRenderWorldLocal::idRenderWorldLocal() decals[i].entityHandle = -1; decals[i].lastStartTime = 0; decals[i].decals = new( TAG_MODEL ) idRenderModelDecal(); - decals[i].decals->index = i; } for( int i = 0; i < overlays.Num(); i++ ) @@ -174,7 +172,6 @@ idRenderWorldLocal::idRenderWorldLocal() overlays[i].entityHandle = -1; overlays[i].lastStartTime = 0; overlays[i].overlays = new( TAG_MODEL ) idRenderModelOverlay(); - overlays[ i ].overlays->index = i; } } @@ -353,7 +350,6 @@ void idRenderWorldLocal::UpdateEntityDef( qhandle_t entityHandle, const renderEn def->parms = *re; def->lastModifiedFrameNum = tr.frameCount; - def->archived = false; // optionally immediately issue any callbacks if( !r_useEntityCallbacks.GetBool() && def->parms.callback != NULL ) @@ -804,7 +800,6 @@ void idRenderWorldLocal::ProjectDecalOntoWorld( const idFixedWinding& winding, c def->decals = AllocDecal( def->index, startTime ); } def->decals->AddDeferredDecal( localParms ); - def->archived = false; } } } @@ -860,7 +855,6 @@ void idRenderWorldLocal::ProjectDecal( qhandle_t entityHandle, const idFixedWind def->decals = AllocDecal( def->index, startTime ); } def->decals->AddDeferredDecal( localParms ); - def->archived = false; } /* @@ -899,7 +893,6 @@ void idRenderWorldLocal::ProjectOverlay( qhandle_t entityHandle, const idPlane l def->overlays = AllocOverlay( def->index, startTime ); } def->overlays->AddDeferredOverlay( localParms ); - def->archived = false; } /* diff --git a/neo/renderer/ResolutionScale.cpp b/neo/renderer/ResolutionScale.cpp index 22c26487aa..e0c80ffbff 100644 --- a/neo/renderer/ResolutionScale.cpp +++ b/neo/renderer/ResolutionScale.cpp @@ -207,8 +207,11 @@ void idResolutionScale::GetConsoleText( idStr& s ) GetCurrentResolutionScale( x, y ); if( rs_display.GetInteger() > 0 ) { - x *= 1280.0f; - y *= 720.0f; + // x *= 1280.0f; + // y *= 720.0f; + x *= renderSystem->GetWidth(); + y *= renderSystem->GetHeight(); + if( rs_enable.GetInteger() == 1 ) { y = 1.0f; diff --git a/neo/renderer/tr_frontend_addmodels.cpp b/neo/renderer/tr_frontend_addmodels.cpp index 64e9d68b1b..00d17fdafd 100644 --- a/neo/renderer/tr_frontend_addmodels.cpp +++ b/neo/renderer/tr_frontend_addmodels.cpp @@ -140,8 +140,6 @@ bool R_IssueEntityDefCallback( idRenderEntityLocal* def ) { idBounds oldBounds = def->localReferenceBounds; - def->archived = false; // will need to be written to the demo file - bool update; if( tr.viewDef != NULL ) { From f0b733f47a639fb66f2e78ebf5676fa3eeed00f3 Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Fri, 22 Mar 2024 09:24:23 +0100 Subject: [PATCH 17/71] Fixed democode removal merge problems --- neo/framework/Common.cpp | 1 - neo/framework/common_frame.cpp | 6 ++---- neo/renderer/RenderEntity.cpp | 4 ---- neo/renderer/RenderSystem.cpp | 13 ------------- 4 files changed, 2 insertions(+), 22 deletions(-) diff --git a/neo/framework/Common.cpp b/neo/framework/Common.cpp index c6dea55e3d..dc8da87b56 100644 --- a/neo/framework/Common.cpp +++ b/neo/framework/Common.cpp @@ -219,7 +219,6 @@ idCommonLocal::Quit */ void idCommonLocal::Quit() { - // don't try to shutdown if we are in a recursive error if( !com_errorEntered ) { diff --git a/neo/framework/common_frame.cpp b/neo/framework/common_frame.cpp index aa087ea5c2..d8002881a6 100644 --- a/neo/framework/common_frame.cpp +++ b/neo/framework/common_frame.cpp @@ -65,8 +65,6 @@ idCVar com_deltaTimeClamp( "com_deltaTimeClamp", "50", CVAR_INTEGER, "don't proc idCVar com_fixedTic( "com_fixedTic", DEFAULT_FIXED_TIC, CVAR_BOOL, "run a single game frame per render frame" ); idCVar com_noSleep( "com_noSleep", DEFAULT_NO_SLEEP, CVAR_BOOL, "don't sleep if the game is running too fast" ); idCVar com_smp( "com_smp", "1", CVAR_BOOL | CVAR_SYSTEM | CVAR_NOCHEAT, "run the game and draw code in a separate thread" ); -idCVar com_aviDemoWidth( "com_aviDemoWidth", "256", CVAR_SYSTEM, "" ); -idCVar com_aviDemoHeight( "com_aviDemoHeight", "256", CVAR_SYSTEM, "" ); idCVar com_skipGameDraw( "com_skipGameDraw", "0", CVAR_SYSTEM | CVAR_BOOL, "" ); idCVar com_sleepGame( "com_sleepGame", "0", CVAR_SYSTEM | CVAR_INTEGER, "intentionally add a sleep in the game time" ); @@ -344,11 +342,10 @@ void idCommonLocal::Draw() } game->Shell_Render(); } - // SRS - Advance demo inside Frame() instead of Draw() to support smp mode playback - // AdvanceRenderDemo( true ); else if( mapSpawned ) { bool gameDraw = false; + // normal drawing for both single and multi player if( !com_skipGameDraw.GetBool() && Game()->GetLocalClientNum() >= 0 ) { @@ -387,6 +384,7 @@ void idCommonLocal::Draw() // draw the half console / notify console on top of everything console->Draw( false ); + // old CRT TV simulation has to be last or it breaks the immersion renderSystem->DrawCRTPostFX(); } } diff --git a/neo/renderer/RenderEntity.cpp b/neo/renderer/RenderEntity.cpp index dc9d8bc738..b2f29a5de0 100644 --- a/neo/renderer/RenderEntity.cpp +++ b/neo/renderer/RenderEntity.cpp @@ -160,7 +160,3 @@ int RenderEnvprobeLocal::GetIndex() return index; } - - // SRS - fully initialize ent so that memcmp() in UpdateEntityDef() works properly - memset( &ent, 0, sizeof( renderEntity_t ) ); - diff --git a/neo/renderer/RenderSystem.cpp b/neo/renderer/RenderSystem.cpp index ec11bd8f51..36ae6cbbd1 100644 --- a/neo/renderer/RenderSystem.cpp +++ b/neo/renderer/RenderSystem.cpp @@ -878,19 +878,6 @@ void idRenderSystemLocal::CropRenderSize( int x, int y, int width, int height, b common->Error( "CropRenderSize: bad sizes" ); } - if( common->WriteDemo() ) - { - common->WriteDemo()->WriteInt( DS_RENDER ); - common->WriteDemo()->WriteInt( DC_CROP_RENDER ); - common->WriteDemo()->WriteInt( width ); - common->WriteDemo()->WriteInt( height ); - - if( r_showDemo.GetBool() ) - { - common->Printf( "write DC_CROP_RENDER\n" ); - } - } - idScreenRect& previous = renderCrops[currentRenderCrop]; currentRenderCrop++; From 9e155869a00ea94f4be6037f641b199897490a52 Mon Sep 17 00:00:00 2001 From: SRSaunders <82544213+SRSaunders@users.noreply.github.com> Date: Thu, 28 Mar 2024 01:08:58 -0400 Subject: [PATCH 18/71] macOS: Set CMAKE_FIND_FRAMEWORK to prefer dylibs over macOS frameworks and xcframeworks --- neo/CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/neo/CMakeLists.txt b/neo/CMakeLists.txt index 83e8fab7fe..64917d1171 100644 --- a/neo/CMakeLists.txt +++ b/neo/CMakeLists.txt @@ -314,6 +314,12 @@ if(STANDALONE) set(DOOM_CLASSIC OFF) endif() +# SRS - on Apple set find_package() to prefer dylibs over macOS frameworks and xcframeworks +# - required for cmake >= 3.29 and MoltenVK, also prefers openal-soft over Apple OpenAL +if(APPLE) + set(CMAKE_FIND_FRAMEWORK LAST) +endif() + # SRS - set libjpeg as first include path to prioritize bundled format_message() fix if (USE_SYSTEM_LIBJPEG) find_package(JPEG) From 2cb52c73dcc9182bdd95f4f40f8e5404364dac93 Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Tue, 2 Apr 2024 12:55:39 +0200 Subject: [PATCH 19/71] Skip startup if not compiled with Doom Classic support, closes #874 --- neo/CMakeLists.txt | 5 +- neo/d3xp/Game_local.cpp | 2 + neo/d3xp/menus/MenuHandler_Shell.cpp | 131 ++++++++++-------- neo/d3xp/menus/MenuScreen.h | 2 + .../menus/MenuScreen_Shell_PressStart.cpp | 5 + neo/d3xp/menus/MenuScreen_Shell_Root.cpp | 11 +- neo/sys/common/session_local.cpp | 4 + neo/sys/sys_session.h | 4 + neo/sys/sys_session_local.cpp | 75 +++++++++- neo/sys/sys_session_local.h | 6 + 10 files changed, 178 insertions(+), 67 deletions(-) diff --git a/neo/CMakeLists.txt b/neo/CMakeLists.txt index 83e8fab7fe..abfe61408c 100644 --- a/neo/CMakeLists.txt +++ b/neo/CMakeLists.txt @@ -35,9 +35,6 @@ option(FFMPEG option(BINKDEC "Use included libbinkdec to render Bink videos" OFF) -option(SPIRV_SHADERC - "Compile SPIR-V shader byte code using shaderc instead of using Glslang directly" OFF) - option(USE_MoltenVK "Link directly to MoltenVK library instead of Vulkan loader on macOS" OFF) @@ -66,7 +63,7 @@ option(USE_VULKAN "Use Vulkan" ON) option(USE_VMA - "Use VMA allocator instead of the NVRHI builtin one" ON) + "Use AMD's Vulkan Memory Allocator instead of the NVRHI builtin one" ON) option(OPTICK "Enable profiling with Optick" OFF) diff --git a/neo/d3xp/Game_local.cpp b/neo/d3xp/Game_local.cpp index f28c8afa00..7f6057cdd9 100644 --- a/neo/d3xp/Game_local.cpp +++ b/neo/d3xp/Game_local.cpp @@ -5960,9 +5960,11 @@ void idGameLocal::Shell_SyncWithSession() } switch( session->GetState() ) { +#if defined( USE_DOOMCLASSIC) case idSession::PRESS_START: shellHandler->SetShellState( SHELL_STATE_PRESS_START ); break; +#endif case idSession::INGAME: shellHandler->SetShellState( SHELL_STATE_PAUSED ); break; diff --git a/neo/d3xp/menus/MenuHandler_Shell.cpp b/neo/d3xp/menus/MenuHandler_Shell.cpp index eb733cb3ff..267288d036 100644 --- a/neo/d3xp/menus/MenuHandler_Shell.cpp +++ b/neo/d3xp/menus/MenuHandler_Shell.cpp @@ -71,6 +71,7 @@ void idMenuHandler_Shell::Update() PlaySound( GUI_SOUND_MUSIC ); } +#if defined( USE_DOOMCLASSIC ) if( nextState == SHELL_STATE_PRESS_START ) { HidePacifier(); @@ -82,75 +83,83 @@ void idMenuHandler_Shell::Update() menuBar->ClearSprite(); } } - else if( nextState == SHELL_STATE_IDLE ) - { - HidePacifier(); - if( nextScreen == SHELL_AREA_START || nextScreen == SHELL_AREA_PARTY_LOBBY || nextScreen == SHELL_AREA_GAME_LOBBY || nextScreen == SHELL_AREA_INVALID ) + else +#endif + if( nextState == SHELL_STATE_IDLE ) { - nextScreen = SHELL_AREA_ROOT; - } + HidePacifier(); + if( +#if defined( USE_DOOMCLASSIC ) + nextScreen == SHELL_AREA_START || +#endif + nextScreen == SHELL_AREA_PARTY_LOBBY || + nextScreen == SHELL_AREA_GAME_LOBBY || + nextScreen == SHELL_AREA_INVALID ) + { + nextScreen = SHELL_AREA_ROOT; + } - if( menuBar != NULL && gui != NULL ) + if( menuBar != NULL && gui != NULL ) + { + idSWFScriptObject& root = gui->GetRootObject(); + menuBar->BindSprite( root ); + SetupPCOptions(); + } + transition = MENU_TRANSITION_SIMPLE; + state = nextState; + } + else if( nextState == SHELL_STATE_PARTY_LOBBY ) { - idSWFScriptObject& root = gui->GetRootObject(); - menuBar->BindSprite( root ); - SetupPCOptions(); + HidePacifier(); + nextScreen = SHELL_AREA_PARTY_LOBBY; + transition = MENU_TRANSITION_SIMPLE; + state = nextState; } - transition = MENU_TRANSITION_SIMPLE; - state = nextState; - } - else if( nextState == SHELL_STATE_PARTY_LOBBY ) - { - HidePacifier(); - nextScreen = SHELL_AREA_PARTY_LOBBY; - transition = MENU_TRANSITION_SIMPLE; - state = nextState; - } - else if( nextState == SHELL_STATE_GAME_LOBBY ) - { - HidePacifier(); - if( state != SHELL_STATE_IN_GAME ) + else if( nextState == SHELL_STATE_GAME_LOBBY ) { - timeRemaining = WAIT_START_TIME_LONG; - idMatchParameters matchParameters = session->GetActivePlatformLobbyBase().GetMatchParms(); - /*if ( MatchTypeIsPrivate( matchParameters.matchFlags ) && ActiveScreen() == SHELL_AREA_PARTY_LOBBY ) { - timeRemaining = 0; - session->StartMatch(); - state = SHELL_STATE_IN_GAME; - } else {*/ - nextScreen = SHELL_AREA_GAME_LOBBY; + HidePacifier(); + if( state != SHELL_STATE_IN_GAME ) + { + timeRemaining = WAIT_START_TIME_LONG; + idMatchParameters matchParameters = session->GetActivePlatformLobbyBase().GetMatchParms(); + /*if ( MatchTypeIsPrivate( matchParameters.matchFlags ) && ActiveScreen() == SHELL_AREA_PARTY_LOBBY ) { + timeRemaining = 0; + session->StartMatch(); + state = SHELL_STATE_IN_GAME; + } else {*/ + nextScreen = SHELL_AREA_GAME_LOBBY; + transition = MENU_TRANSITION_SIMPLE; + //} + + state = nextState; + } + } + else if( nextState == SHELL_STATE_PAUSED ) + { + HidePacifier(); transition = MENU_TRANSITION_SIMPLE; - //} + + if( gameComplete ) + { + nextScreen = SHELL_AREA_CREDITS; + } + else + { + nextScreen = SHELL_AREA_ROOT; + } state = nextState; } - } - else if( nextState == SHELL_STATE_PAUSED ) - { - HidePacifier(); - transition = MENU_TRANSITION_SIMPLE; - - if( gameComplete ) + else if( nextState == SHELL_STATE_CONNECTING ) { - nextScreen = SHELL_AREA_CREDITS; + ShowPacifier( "#str_dlg_connecting" ); + state = nextState; } - else + else if( nextState == SHELL_STATE_SEARCHING ) { - nextScreen = SHELL_AREA_ROOT; + ShowPacifier( "#str_online_mpstatus_searching" ); + state = nextState; } - - state = nextState; - } - else if( nextState == SHELL_STATE_CONNECTING ) - { - ShowPacifier( "#str_dlg_connecting" ); - state = nextState; - } - else if( nextState == SHELL_STATE_SEARCHING ) - { - ShowPacifier( "#str_online_mpstatus_searching" ); - state = nextState; - } } if( activeScreen != nextScreen ) @@ -488,7 +497,9 @@ void idMenuHandler_Shell::Initialize( const char* swfFile, idSoundWorld* sw ) } else { +#if defined( USE_DOOMCLASSIC ) BIND_SHELL_SCREEN( SHELL_AREA_START, idMenuScreen_Shell_PressStart, this ); +#endif BIND_SHELL_SCREEN( SHELL_AREA_ROOT, idMenuScreen_Shell_Root, this ); BIND_SHELL_SCREEN( SHELL_AREA_CAMPAIGN, idMenuScreen_Shell_Singleplayer, this ); BIND_SHELL_SCREEN( SHELL_AREA_SETTINGS, idMenuScreen_Shell_Settings, this ); @@ -938,10 +949,12 @@ void idMenuHandler_Shell::HandleExitGameBtn() { common->Quit(); } +#if defined( USE_DOOMCLASSIC ) else if( accept == -1 ) { session->MoveToPressStart(); } +#endif return idSWFScriptVar(); } private: @@ -1291,7 +1304,11 @@ void idMenuHandler_Shell::UpdateBGState() } } - if( smallFrameShowing || largeFrameShowing || nextScreen == SHELL_AREA_START ) + if( smallFrameShowing || largeFrameShowing +#if defined( USE_DOOMCLASSIC ) + || nextScreen == SHELL_AREA_START +#endif + ) { ShowLogo( false ); } diff --git a/neo/d3xp/menus/MenuScreen.h b/neo/d3xp/menus/MenuScreen.h index 89536d31da..7e28246290 100755 --- a/neo/d3xp/menus/MenuScreen.h +++ b/neo/d3xp/menus/MenuScreen.h @@ -418,6 +418,7 @@ class idMenuScreen_Shell_Pause : public idMenuScreen bool isMpPause; }; +#if defined(USE_DOOMCLASSIC) //* //================================================ //idMenuScreen_Shell_PressStart @@ -479,6 +480,7 @@ class idMenuScreen_Shell_GameSelect : public idMenuScreen const idMaterial* doom2Cover; const idMaterial* doom3Cover; }; +#endif //* //================================================ diff --git a/neo/d3xp/menus/MenuScreen_Shell_PressStart.cpp b/neo/d3xp/menus/MenuScreen_Shell_PressStart.cpp index d69d06efbf..39423b8ff7 100644 --- a/neo/d3xp/menus/MenuScreen_Shell_PressStart.cpp +++ b/neo/d3xp/menus/MenuScreen_Shell_PressStart.cpp @@ -28,6 +28,9 @@ If you have questions concerning this license or the applicable additional terms */ #include "precompiled.h" #pragma hdrstop + +#if defined(USE_DOOMCLASSIC) + #include "../Game_local.h" #include "../../framework/Common_local.h" @@ -365,3 +368,5 @@ bool idMenuScreen_Shell_PressStart::HandleAction( idWidgetAction& action, const return idMenuWidget::HandleAction( action, event, widget, forceHandled ); } + +#endif \ No newline at end of file diff --git a/neo/d3xp/menus/MenuScreen_Shell_Root.cpp b/neo/d3xp/menus/MenuScreen_Shell_Root.cpp index 05c8335601..3de9c2c75f 100644 --- a/neo/d3xp/menus/MenuScreen_Shell_Root.cpp +++ b/neo/d3xp/menus/MenuScreen_Shell_Root.cpp @@ -342,10 +342,12 @@ void idMenuScreen_Shell_Root::HandleExitGameBtn() { common->Quit(); } +#if defined( USE_DOOMCLASSIC ) else if( accept == -1 ) { session->MoveToPressStart(); } +#endif return idSWFScriptVar(); } private: @@ -357,10 +359,14 @@ void idMenuScreen_Shell_Root::HandleExitGameBtn() idStaticList< idStrId, 4 > optionText; callbacks.Append( new( TAG_SWF ) idSWFScriptFunction_QuitDialog( GDM_QUIT_GAME, 1 ) ); callbacks.Append( new( TAG_SWF ) idSWFScriptFunction_QuitDialog( GDM_QUIT_GAME, 0 ) ); +#if defined( USE_DOOMCLASSIC ) callbacks.Append( new( TAG_SWF ) idSWFScriptFunction_QuitDialog( GDM_QUIT_GAME, -1 ) ); +#endif optionText.Append( idStrId( "#STR_SWF_ACCEPT" ) ); optionText.Append( idStrId( "#STR_SWF_CANCEL" ) ); +#if defined( USE_DOOMCLASSIC ) optionText.Append( idStrId( "#str_swf_change_game" ) ); +#endif common->Dialog().AddDynamicDialog( GDM_QUIT_GAME, callbacks, optionText, true, "" ); } @@ -400,7 +406,6 @@ idMenuScreen_Shell_Root::HandleAction */ bool idMenuScreen_Shell_Root::HandleAction( idWidgetAction& action, const idWidgetEvent& event, idMenuWidget* widget, bool forceHandled ) { - if( menuData == NULL ) { return true; @@ -416,16 +421,17 @@ bool idMenuScreen_Shell_Root::HandleAction( idWidgetAction& action, const idWidg switch( actionType ) { +#if defined( USE_DOOMCLASSIC ) case WIDGET_ACTION_GO_BACK: { session->MoveToPressStart(); return true; } +#endif case WIDGET_ACTION_PRESS_FOCUSED: { if( menuData->GetPlatform() == 2 ) { - idMenuHandler_Shell* shell = dynamic_cast< idMenuHandler_Shell* >( menuData ); if( !shell ) { @@ -453,7 +459,6 @@ bool idMenuScreen_Shell_Root::HandleAction( idWidgetAction& action, const idWidg } case WIDGET_ACTION_SCROLL_HORIZONTAL: { - if( menuData->GetPlatform() != 2 ) { return true; diff --git a/neo/sys/common/session_local.cpp b/neo/sys/common/session_local.cpp index 3344d5a350..2d40c1765b 100644 --- a/neo/sys/common/session_local.cpp +++ b/neo/sys/common/session_local.cpp @@ -248,7 +248,11 @@ void idSessionLocalWin::Shutdown() MoveToMainMenu(); // Wait until we fully shutdown +#if defined( USE_DOOMCLASSIC ) while( localState != STATE_IDLE && localState != STATE_PRESS_START ) +#else + while( localState != STATE_IDLE ) +#endif { Pump(); } diff --git a/neo/sys/sys_session.h b/neo/sys/sys_session.h index be57eea081..1614ee8c34 100644 --- a/neo/sys/sys_session.h +++ b/neo/sys/sys_session.h @@ -425,7 +425,9 @@ class idSession enum sessionState_t { +#if defined( USE_DOOMCLASSIC ) PRESS_START, +#endif IDLE, SEARCHING, CONNECTING, @@ -474,7 +476,9 @@ class idSession virtual void ClearSessionOption( sessionOption_t option ) = 0; virtual sessionState_t GetBackState() = 0; virtual void Cancel() = 0; +#if defined( USE_DOOMCLASSIC ) virtual void MoveToPressStart() = 0; +#endif virtual void FinishDisconnect() = 0; virtual void LoadingFinished() = 0; virtual bool IsCurrentLobbyMigrating() const = 0; diff --git a/neo/sys/sys_session_local.cpp b/neo/sys/sys_session_local.cpp index 345ff3b1e9..3e7433bcb4 100644 --- a/neo/sys/sys_session_local.cpp +++ b/neo/sys/sys_session_local.cpp @@ -65,6 +65,7 @@ idCVar net_headlessServer( "net_headlessServer", "0", CVAR_BOOL, "toggle to auto const char* idSessionLocal::stateToString[ NUM_STATES ] = { +#if defined( USE_DOOMCLASSIC ) ASSERT_ENUM_STRING( STATE_PRESS_START, 0 ), ASSERT_ENUM_STRING( STATE_IDLE, 1 ), ASSERT_ENUM_STRING( STATE_PARTY_LOBBY_HOST, 2 ), @@ -83,6 +84,25 @@ const char* idSessionLocal::stateToString[ NUM_STATES ] = ASSERT_ENUM_STRING( STATE_BUSY, 15 ), ASSERT_ENUM_STRING( STATE_LOADING, 16 ), ASSERT_ENUM_STRING( STATE_INGAME, 17 ), +#else + ASSERT_ENUM_STRING( STATE_IDLE, 0 ), + ASSERT_ENUM_STRING( STATE_PARTY_LOBBY_HOST, 1 ), + ASSERT_ENUM_STRING( STATE_PARTY_LOBBY_PEER, 2 ), + ASSERT_ENUM_STRING( STATE_GAME_LOBBY_HOST, 3 ), + ASSERT_ENUM_STRING( STATE_GAME_LOBBY_PEER, 4 ), + ASSERT_ENUM_STRING( STATE_GAME_STATE_LOBBY_HOST, 5 ), + ASSERT_ENUM_STRING( STATE_GAME_STATE_LOBBY_PEER, 6 ), + ASSERT_ENUM_STRING( STATE_CREATE_AND_MOVE_TO_PARTY_LOBBY, 7 ), + ASSERT_ENUM_STRING( STATE_CREATE_AND_MOVE_TO_GAME_LOBBY, 8 ), + ASSERT_ENUM_STRING( STATE_CREATE_AND_MOVE_TO_GAME_STATE_LOBBY, 9 ), + ASSERT_ENUM_STRING( STATE_FIND_OR_CREATE_MATCH, 10 ), + ASSERT_ENUM_STRING( STATE_CONNECT_AND_MOVE_TO_PARTY, 11 ), + ASSERT_ENUM_STRING( STATE_CONNECT_AND_MOVE_TO_GAME, 12 ), + ASSERT_ENUM_STRING( STATE_CONNECT_AND_MOVE_TO_GAME_STATE, 13 ), + ASSERT_ENUM_STRING( STATE_BUSY, 14 ), + ASSERT_ENUM_STRING( STATE_LOADING, 15 ), + ASSERT_ENUM_STRING( STATE_INGAME, 16 ), +#endif }; struct netVersion_s @@ -178,7 +198,11 @@ void idSessionLocal::InitBaseState() //assert( mem.IsGlobalHeap() ); +#if defined( USE_DOOMCLASSIC ) localState = STATE_PRESS_START; +#else + localState = STATE_IDLE; +#endif sessionOptions = 0; currentID = 0; @@ -478,7 +502,11 @@ idSessionLocal::sessionState_t idSessionLocal::GetBackState() return IDLE; // From here, go to idle if we aren't there yet } +#if defined( USE_DOOMCLASSIC ) return PRESS_START; // Otherwise, go back to press start +#else + return IDLE; // Otherwise, go to idle +#endif } /* @@ -490,7 +518,11 @@ void idSessionLocal::Cancel() { NET_VERBOSE_PRINT( "NET: Cancel\n" ); +#if defined( USE_DOOMCLASSIC ) if( localState == STATE_PRESS_START ) +#else + if( localState == STATE_IDLE ) +#endif { return; // We're as far back as we can go } @@ -544,6 +576,7 @@ void idSessionLocal::Cancel() SetState( STATE_IDLE ); break; +#if defined( USE_DOOMCLASSIC ) case PRESS_START: // Go back to press start/main GetGameLobby().Shutdown(); @@ -551,12 +584,14 @@ void idSessionLocal::Cancel() GetPartyLobby().Shutdown(); SetState( STATE_PRESS_START ); break; +#endif } // Validate the current lobby immediately ValidateLobbies(); } +#if defined( USE_DOOMCLASSIC ) /* ======================== idSessionLocal::MoveToPressStart @@ -574,6 +609,7 @@ void idSessionLocal::MoveToPressStart() SetState( STATE_PRESS_START ); } } +#endif /* ======================== @@ -1974,7 +2010,11 @@ Determines if any of the session instances need to become the host */ void idSessionLocal::ValidateLobbies() { +#if defined( USE_DOOMCLASSIC ) if( localState == STATE_PRESS_START || localState == STATE_IDLE ) +#else + if( localState == STATE_IDLE ) +#endif { // At press start or main menu, don't do anything return; @@ -2267,8 +2307,10 @@ bool idSessionLocal::HandleState() switch( localState ) { +#if defined( USE_DOOMCLASSIC ) case STATE_PRESS_START: return false; +#endif case STATE_IDLE: HandlePackets(); return false; // Call handle packets, since packets from old sessions could still be in flight, which need to be emptied @@ -2319,8 +2361,10 @@ idSessionLocal::sessionState_t idSessionLocal::GetState() const // Convert our internal state to one of the external states switch( localState ) { +#if defined( USE_DOOMCLASSIC ) case STATE_PRESS_START: return PRESS_START; +#endif case STATE_IDLE: return IDLE; case STATE_PARTY_LOBBY_HOST: @@ -2366,6 +2410,7 @@ const char* idSessionLocal::GetStateString() const { static const char* stateToString[] = { +#if defined( USE_DOOMCLASSIC ) ASSERT_ENUM_STRING( STATE_PRESS_START, 0 ), ASSERT_ENUM_STRING( STATE_IDLE, 1 ), ASSERT_ENUM_STRING( STATE_PARTY_LOBBY_HOST, 2 ), @@ -2384,6 +2429,25 @@ const char* idSessionLocal::GetStateString() const ASSERT_ENUM_STRING( STATE_BUSY, 15 ), ASSERT_ENUM_STRING( STATE_LOADING, 16 ), ASSERT_ENUM_STRING( STATE_INGAME, 17 ) +#else + ASSERT_ENUM_STRING( STATE_IDLE, 0 ), + ASSERT_ENUM_STRING( STATE_PARTY_LOBBY_HOST, 1 ), + ASSERT_ENUM_STRING( STATE_PARTY_LOBBY_PEER, 2 ), + ASSERT_ENUM_STRING( STATE_GAME_LOBBY_HOST, 3 ), + ASSERT_ENUM_STRING( STATE_GAME_LOBBY_PEER, 4 ), + ASSERT_ENUM_STRING( STATE_GAME_STATE_LOBBY_HOST, 5 ), + ASSERT_ENUM_STRING( STATE_GAME_STATE_LOBBY_PEER, 6 ), + ASSERT_ENUM_STRING( STATE_CREATE_AND_MOVE_TO_PARTY_LOBBY, 7 ), + ASSERT_ENUM_STRING( STATE_CREATE_AND_MOVE_TO_GAME_LOBBY, 8 ), + ASSERT_ENUM_STRING( STATE_CREATE_AND_MOVE_TO_GAME_STATE_LOBBY, 9 ), + ASSERT_ENUM_STRING( STATE_FIND_OR_CREATE_MATCH, 10 ), + ASSERT_ENUM_STRING( STATE_CONNECT_AND_MOVE_TO_PARTY, 11 ), + ASSERT_ENUM_STRING( STATE_CONNECT_AND_MOVE_TO_GAME, 12 ), + ASSERT_ENUM_STRING( STATE_CONNECT_AND_MOVE_TO_GAME_STATE, 13 ), + ASSERT_ENUM_STRING( STATE_BUSY, 14 ), + ASSERT_ENUM_STRING( STATE_LOADING, 15 ), + ASSERT_ENUM_STRING( STATE_INGAME, 16 ) +#endif }; return stateToString[ localState ]; } @@ -2609,24 +2673,27 @@ void idSessionLocal::UpdateSignInManager() if( masterUser == NULL ) { +#if defined( USE_DOOMCLASSIC ) // If we don't have a master user at all, then we need to be at "Press Start" MoveToPressStart( GDM_SP_SIGNIN_CHANGE_POST ); +#endif return; } +#if defined( USE_DOOMCLASSIC ) else if( localState == STATE_PRESS_START ) { - - // If we have a master user, and we are at press start, move to the menu area SetState( STATE_IDLE ); - } +#endif // See if the master user either isn't persistent (but needs to be), OR, if the owner changed // RequirePersistentMaster is poorly named, this really means RequireSignedInMaster if( masterUser->HasOwnerChanged() || ( RequirePersistentMaster() && !masterUser->IsProfileReady() ) ) { +#if defined( USE_DOOMCLASSIC ) MoveToPressStart( GDM_SP_SIGNIN_CHANGE_POST ); +#endif return; } @@ -2666,6 +2733,7 @@ idPlayerProfile* idSessionLocal::GetProfileFromMasterLocalUser() return profile; } +#if defined( USE_DOOMCLASSIC ) /* ======================== idSessionLocal::MoveToPressStart @@ -2680,6 +2748,7 @@ void idSessionLocal::MoveToPressStart( gameDialogMessages_t msg ) common->Dialog().AddDialog( msg, DIALOG_ACCEPT, NULL, NULL, false, "", 0, true ); } } +#endif /* ======================== diff --git a/neo/sys/sys_session_local.h b/neo/sys/sys_session_local.h index 93291ea685..52e0b12eab 100644 --- a/neo/sys/sys_session_local.h +++ b/neo/sys/sys_session_local.h @@ -259,7 +259,9 @@ class idSessionLocal : public idSession // Overall state of the session enum state_t { +#if defined( USE_DOOMCLASSIC ) STATE_PRESS_START, // We are at press start +#endif STATE_IDLE, // We are at the main menu STATE_PARTY_LOBBY_HOST, // We are in the party lobby menu as host STATE_PARTY_LOBBY_PEER, // We are in the party lobby menu as a peer @@ -347,7 +349,9 @@ class idSessionLocal : public idSession } virtual sessionState_t GetBackState(); virtual void Cancel(); +#if defined( USE_DOOMCLASSIC ) virtual void MoveToPressStart(); +#endif virtual void FinishDisconnect(); virtual bool ShouldShowMigratingDialog() const; // Note this is not in sys_session.h virtual bool IsCurrentLobbyMigrating() const; @@ -833,7 +837,9 @@ class idSessionLocal : public idSession void MatchFinishedInternal(); void EndMatchForMigration(); +#if defined( USE_DOOMCLASSIC ) void MoveToPressStart( gameDialogMessages_t msg ); +#endif // Voice chat void SendVoiceAudio(); From c01089f1139dbd2cf03e79cd54bb2b9273a062c6 Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Tue, 2 Apr 2024 14:32:20 +0200 Subject: [PATCH 20/71] Small cleanup in CMakeLists.txt --- neo/CMakeLists.txt | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/neo/CMakeLists.txt b/neo/CMakeLists.txt index 14b5337d4e..f871a0a170 100644 --- a/neo/CMakeLists.txt +++ b/neo/CMakeLists.txt @@ -444,22 +444,11 @@ add_definitions(-DUSE_NVRHI) set(SHADERMAKE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/extern/ShaderMake) add_subdirectory(${SHADERMAKE_DIR}) -# SRS - ShaderMake now finds fxc when required -#if(USE_DX11) -# find_package(FXC REQUIRED) -#endif() - if(USE_DX12) # SRS - ShaderMake now finds dxc for DXIL when required - # find_package(DXCdxil REQUIRED) set(USE_DXIL_ON_DX12 TRUE CACHE BOOL "Use DXC to compile DXIL shaders on DX12 - otherwise FXC and DXBC") endif() -# SRS - ShaderMake now finds dxc for SPIRV when required -#if(USE_VULKAN) -# find_package(DXCspirv REQUIRED) -#endif() - include_directories(${NVRHI_DIR}/include) include_directories(${SHADERMAKE_DIR}/include) @@ -1509,11 +1498,6 @@ if(MSVC) list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/renderer/DXT/DXTDecoder.cpp) list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/renderer/DXT/DXTEncoder.cpp) list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/renderer/DXT/DXTEncoder_SSE2.cpp) - - # SRS - Exclusion no longer needed with updated nvrhi CMakeLists.txt that makes Vulkan-Headers private - #if(USE_VULKAN) - # list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/sys/DeviceManager_VK.cpp) - #endif() #foreach( src_file ${RBDOOM3_PRECOMPILED_SOURCES} ) # message(STATUS "-include precompiled.h for ${src_file}") @@ -1564,7 +1548,6 @@ if(MSVC) winmm wsock32.lib ${Vulkan_LIBRARIES} - ${OpenGL_LIBRARIES} ${OpenAL_LIBRARIES} ${FFmpeg_LIBRARIES} ${ZLIB_LIBRARY} @@ -1657,11 +1640,6 @@ else() list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/renderer/DXT/DXTDecoder.cpp) list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/renderer/DXT/DXTEncoder.cpp) list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/renderer/DXT/DXTEncoder_SSE2.cpp) - - # SRS - Exclusion no longer needed with updated nvrhi CMakeLists.txt that makes Vulkan-Headers private - #if(USE_VULKAN) - # list(REMOVE_ITEM RBDOOM3_PRECOMPILED_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/sys/DeviceManager_VK.cpp) - #endif() foreach( src_file ${RBDOOM3_PRECOMPILED_SOURCES} ) #message(STATUS "-include precompiled.h for ${src_file}") @@ -1785,7 +1763,6 @@ else() target_link_libraries(RBDoom3BFG idlib ${Vulkan_LIBRARY} - #${OPENGL_LIBRARIES} pthread ${RT_LIBRARY} ${SDLx_LIBRARY} From 506250ad62703389e4781b06b8f2779b2942fb99 Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Tue, 2 Apr 2024 16:29:48 +0200 Subject: [PATCH 21/71] Added CMake -DRETAIL option for shipping builds on Github/ModDB --- neo/CMakeLists.txt | 88 ++++++++---------------- neo/cmake-vs2019-win64-retail.bat | 6 ++ neo/cmake-vs2022-win64-retail.bat | 6 ++ neo/d3xp/Achievements.cpp | 4 +- neo/d3xp/menus/MenuHandler_Shell.cpp | 4 +- neo/d3xp/menus/MenuScreen_Shell_Root.cpp | 2 +- neo/framework/CmdSystem.h | 2 +- neo/framework/Common.cpp | 9 ++- neo/framework/Licensee.h | 5 -- 9 files changed, 54 insertions(+), 72 deletions(-) create mode 100644 neo/cmake-vs2019-win64-retail.bat create mode 100644 neo/cmake-vs2022-win64-retail.bat diff --git a/neo/CMakeLists.txt b/neo/CMakeLists.txt index f871a0a170..d5937ae1e3 100644 --- a/neo/CMakeLists.txt +++ b/neo/CMakeLists.txt @@ -68,6 +68,9 @@ option(USE_VMA option(OPTICK "Enable profiling with Optick" OFF) +option(RETAIL + "Strip certain developer features and cheats from shipping builds" OFF) + set(NVRHI_INSTALL OFF) set(CPU_TYPE "" CACHE STRING "When set, passes this string as CPU-ID which will be embedded into the binary.") @@ -112,27 +115,14 @@ if(COMPILE_COMMANDS) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) endif() -if (FORCE_COLOR_OUTPUT) - if (CMAKE_COMPILER_IS_GNUCC) - add_compile_options(-fdiagnostics-color=always) - elseif(CMAKE_C_COMPILER_ID MATCHES "Clang") - add_compile_options(-fcolor-diagnostics) - endif () +# Enforced colored output +if (CMAKE_COMPILER_IS_GNUCC) + add_compile_options(-fdiagnostics-color=always) +elseif(CMAKE_C_COMPILER_ID MATCHES "Clang") + add_compile_options(-fcolor-diagnostics) endif () -if(MSVC) - #message(STATUS CMAKE_ROOT: ${CMAKE_ROOT}) - - #if(CMAKE_CL_64) - # SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/../bin/win64) - #else() - # SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/../bin/win32) - #endif() - - #message(STATUS EXECUTABLE_OUTPUT_PATH: ${EXECUTABLE_OUTPUT_PATH}) - #message(STATUS PROJECT_BINARY_DIR: ${PROJECT_BINARY_DIR}) - #message(STATUS CMAKE_BINARY_DIR: ${CMAKE_BINARY_DIR}) -else() +if(NOT MSVC) message(STATUS CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}) endif() @@ -176,7 +166,7 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang") #endif() add_compile_options(-Wno-pragmas -Wno-unused-variable -Wno-switch -Wno-unused-value -Winvalid-pch -Wno-multichar) - if(CMAKE_C_COMPILER_ID MATCHES "Clang") + if(CMAKE_C_COMPILER_ID MATCHES "Clang") # add clang-specific settings for warnings (the second one make sure clang doesn't complain # about unknown -W flags, like -Wno-unused-but-set-variable) # SRS - Add -Wno-expansion-to-defined, Wno-nullability-completeness and -Wno-shorten-64-to-32 to list of warning settings @@ -240,47 +230,23 @@ elseif(MSVC) # Omit Frame Pointers # "/Oy", - # if(MSVC_VERSION EQUAL 1700) - # #message(STATUS "$ENV{LIBPATH}") - - # find_path(Windows_winmd_DIR NAMES Windows.winmd - # HINTS - # C:/Program Files (x86)/Windows Kits/8.0/References/CommonConfiguration/Neutral - # PATH_SUFFIXES "Neutral") - - # message(STATUS "${Windows_winmd_DIR}") - - # #set(WINRT_OPTIONS "/ZW /D USE_WINRT /AI \"C:\Program Files (x86)\Windows Kits\8.0\References\CommonConfiguration\Neutral\"") - # #set(WINRT_OPTIONS "/ZW /D USE_WINRT /AI \"$ENV{LIBPATH}\" ") - # set(WINRT_OPTIONS "/ZW /D USE_WINRT") - # set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /D _DEBUG /MP ${WINRT_OPTIONS}") - # set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MP /Oi /Oy ${WINRT_OPTIONS}") - # set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /MP /Oi ${WINRT_OPTIONS}") - # set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} /MP /Oi /Oy ${WINRT_OPTIONS}") - - # set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MP ${WINRT_OPTIONS}") - # set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MP /Oi /Oy ${WINRT_OPTIONS}") - # set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MP ${WINRT_OPTIONS}") - # set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /MP /Oi /Oy ${WINRT_OPTIONS}") - # else() - set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /D _DEBUG /MP /MDd") - set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MP /Oi /Oy /MD") - set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /MP /Oi /MDd") - set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} /MP /Oi /Oy /MD") + set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /D _DEBUG /MP /MDd") + set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MP /Oi /Oy /MD") + set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /MP /Oi /MDd") + set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} /MP /Oi /Oy /MD") - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MP /MDd") - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MP /Oi /Oy /MD") - set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MP /MDd") - set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /MP /Oi /Oy /MD") + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MP /MDd") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MP /Oi /Oy /MD") + set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MP /MDd") + set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /MP /Oi /Oy /MD") - # RB: without /SAFESEH:NO we can't link against ffmpeg libs and VS2013 or we have to build our own - # libs for newer compilers - set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /SAFESEH:NO") - set(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL} /SAFESEH:NO") - set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /SAFESEH:NO") - set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /SAFESEH:NO") - # endif() + # RB: without /SAFESEH:NO we can't link against ffmpeg libs and VS2013 or we have to build our own + # libs for newer compilers + set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /SAFESEH:NO") + set(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL} /SAFESEH:NO") + set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /SAFESEH:NO") + set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /SAFESEH:NO") add_definitions(-DWIN32 -DNOMINMAX @@ -294,7 +260,7 @@ elseif(MSVC) if( WINDOWS10 ) # Windows RT add_definitions(-DUSE_WINRT) endif() - + if(NOT CMAKE_CL_64) add_definitions(-D_USE_32BIT_TIME_T) endif() @@ -311,6 +277,10 @@ if(STANDALONE) set(DOOM_CLASSIC OFF) endif() +if(RETAIL) + add_definitions(-DID_RETAIL) +endif() + # SRS - set libjpeg as first include path to prioritize bundled format_message() fix if (USE_SYSTEM_LIBJPEG) find_package(JPEG) diff --git a/neo/cmake-vs2019-win64-retail.bat b/neo/cmake-vs2019-win64-retail.bat new file mode 100644 index 0000000000..81dac706ab --- /dev/null +++ b/neo/cmake-vs2019-win64-retail.bat @@ -0,0 +1,6 @@ +cd .. +del /s /q build +mkdir build +cd build +cmake -G "Visual Studio 16" -A x64 -DFFMPEG=ON -DBINKDEC=OFF -DRETAIL=ON ../neo +pause \ No newline at end of file diff --git a/neo/cmake-vs2022-win64-retail.bat b/neo/cmake-vs2022-win64-retail.bat new file mode 100644 index 0000000000..b42ccb34be --- /dev/null +++ b/neo/cmake-vs2022-win64-retail.bat @@ -0,0 +1,6 @@ +cd .. +del /s /q build +mkdir build +cd build +cmake -G "Visual Studio 17" -A x64 -DFFMPEG=ON -DBINKDEC=OFF -DRETAIL=ON ../neo +pause \ No newline at end of file diff --git a/neo/d3xp/Achievements.cpp b/neo/d3xp/Achievements.cpp index 5baea1eaba..bc9c56ccd9 100644 --- a/neo/d3xp/Achievements.cpp +++ b/neo/d3xp/Achievements.cpp @@ -254,7 +254,7 @@ void idAchievementManager::EventCompletesAchievement( const achievement_t eventI return; } -#ifdef ID_RETAIL +#if 0 //def ID_RETAIL if( common->GetConsoleUsed() ) { if( !cheatingDialogShown ) @@ -338,7 +338,7 @@ void idAchievementManager::LocalUser_CompleteAchievement( achievement_t id ) return; } -#ifdef ID_RETAIL +#if 0 //def ID_RETAIL if( common->GetConsoleUsed() ) { if( !cheatingDialogShown ) diff --git a/neo/d3xp/menus/MenuHandler_Shell.cpp b/neo/d3xp/menus/MenuHandler_Shell.cpp index 267288d036..febcb3bbf5 100644 --- a/neo/d3xp/menus/MenuHandler_Shell.cpp +++ b/neo/d3xp/menus/MenuHandler_Shell.cpp @@ -842,7 +842,7 @@ void idMenuHandler_Shell::SetupPCOptions() } else { -#if !defined ( ID_RETAIL ) +#if !defined( ID_RETAIL ) navOptions.Append( "DEV" ); // DEV #endif navOptions.Append( "#str_swf_campaign" ); // singleplayer @@ -854,7 +854,7 @@ void idMenuHandler_Shell::SetupPCOptions() idMenuWidget_MenuButton* buttonWidget = NULL; int index = 0; -#if !defined ( ID_RETAIL ) +#if !defined( ID_RETAIL ) buttonWidget = dynamic_cast< idMenuWidget_MenuButton* >( &menuBar->GetChildByIndex( index ) ); if( buttonWidget != NULL ) { diff --git a/neo/d3xp/menus/MenuScreen_Shell_Root.cpp b/neo/d3xp/menus/MenuScreen_Shell_Root.cpp index 3de9c2c75f..387284b4c2 100644 --- a/neo/d3xp/menus/MenuScreen_Shell_Root.cpp +++ b/neo/d3xp/menus/MenuScreen_Shell_Root.cpp @@ -211,7 +211,7 @@ void idMenuScreen_Shell_Root::ShowScreen( const mainMenuTransition_t transitionT idMenuWidget_Button* buttonWidget = NULL; -#if !defined ( ID_RETAIL ) +#if !defined( ID_RETAIL ) option.Append( "DEV" ); // DEV menuOptions.Append( option ); options->GetChildByIndex( index ).ClearEventActions(); diff --git a/neo/framework/CmdSystem.h b/neo/framework/CmdSystem.h index bdd6ee3b1c..ee1b69d83c 100644 --- a/neo/framework/CmdSystem.h +++ b/neo/framework/CmdSystem.h @@ -112,7 +112,7 @@ created using the CONSOLE_COMMAND_SHIP macro. ================================================ */ -#if defined ( ID_RETAIL ) && !defined( ID_RETAIL_INTERNAL ) +#if defined( ID_RETAIL ) && !defined( ID_RETAIL_INTERNAL ) #define CONSOLE_COMMAND_SHIP CONSOLE_COMMAND_COMPILE #define CONSOLE_COMMAND CONSOLE_COMMAND_NO_COMPILE // We need to disable this warning to get commands that were made friends diff --git a/neo/framework/Common.cpp b/neo/framework/Common.cpp index dc8da87b56..b3e46a4361 100644 --- a/neo/framework/Common.cpp +++ b/neo/framework/Common.cpp @@ -71,7 +71,8 @@ struct version_s idCVar com_version( "si_version", version.string, CVAR_SYSTEM | CVAR_ROM | CVAR_SERVERINFO, "engine version" ); idCVar com_forceGenericSIMD( "com_forceGenericSIMD", "0", CVAR_BOOL | CVAR_SYSTEM | CVAR_NOCHEAT, "force generic platform independent SIMD" ); -#ifdef ID_RETAIL +// RB: not allowing the console is a bit harsh for shipping builds +#if 0 //def ID_RETAIL idCVar com_allowConsole( "com_allowConsole", "0", CVAR_BOOL | CVAR_SYSTEM | CVAR_INIT, "allow toggling console with the tilde key" ); #else idCVar com_allowConsole( "com_allowConsole", "1", CVAR_BOOL | CVAR_SYSTEM | CVAR_INIT, "allow toggling console with the tilde key" ); @@ -121,7 +122,11 @@ idCommonLocal commonLocal; idCommon* common = &commonLocal; // RB: defaulted this to 1 because we don't have a sound for the intro .bik video -idCVar com_skipIntroVideos( "com_skipIntroVideos", "1", CVAR_BOOL , "skips intro videos" ); +#if defined( ID_RETAIL ) + idCVar com_skipIntroVideos( "com_skipIntroVideos", "0", CVAR_BOOL , "skips intro videos" ); +#else + idCVar com_skipIntroVideos( "com_skipIntroVideos", "1", CVAR_BOOL , "skips intro videos" ); +#endif // For doom classic struct Globals; diff --git a/neo/framework/Licensee.h b/neo/framework/Licensee.h index 704f292b89..0ffc894a94 100644 --- a/neo/framework/Licensee.h +++ b/neo/framework/Licensee.h @@ -59,11 +59,6 @@ If you have questions concerning this license or the applicable additional terms // use a different major for each game #define ASYNC_PROTOCOL_MAJOR 1 -// <= Doom v1.1: 1. no DS_VERSION token ( default ) -// Doom v1.2: 2 -// Doom 3 BFG: 3 -#define RENDERDEMO_VERSION 3 - // win32 info #define WIN32_CONSOLE_CLASS "D3BFG_WinConsole" #define WIN32_WINDOW_CLASS_NAME "D3BFG" From 14bea1fea9544772dabbee40dd479e32432358d5 Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Tue, 2 Apr 2024 16:36:28 +0200 Subject: [PATCH 22/71] Added cmake-linux-retail.sh --- neo/cmake-linux-retail.sh | 5 +++++ neo/framework/Common.cpp | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 neo/cmake-linux-retail.sh diff --git a/neo/cmake-linux-retail.sh b/neo/cmake-linux-retail.sh new file mode 100644 index 0000000000..981c76492a --- /dev/null +++ b/neo/cmake-linux-retail.sh @@ -0,0 +1,5 @@ +cd .. +rm -rf build +mkdir build +cd build +cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DONATIVE=ON -DFFMPEG=OFF -DBINKDEC=ON -DRETAIL=ON ../neo diff --git a/neo/framework/Common.cpp b/neo/framework/Common.cpp index b3e46a4361..6ce616d403 100644 --- a/neo/framework/Common.cpp +++ b/neo/framework/Common.cpp @@ -121,7 +121,6 @@ int com_editors = 0; idCommonLocal commonLocal; idCommon* common = &commonLocal; -// RB: defaulted this to 1 because we don't have a sound for the intro .bik video #if defined( ID_RETAIL ) idCVar com_skipIntroVideos( "com_skipIntroVideos", "0", CVAR_BOOL , "skips intro videos" ); #else From 40408dda5e884c8c0757fdb17dba0a13e4a38394 Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Tue, 2 Apr 2024 16:46:08 +0200 Subject: [PATCH 23/71] Astyle --- neo/sys/DeviceManager_VK.cpp | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/neo/sys/DeviceManager_VK.cpp b/neo/sys/DeviceManager_VK.cpp index 5dc078ca14..c2e683f5d7 100644 --- a/neo/sys/DeviceManager_VK.cpp +++ b/neo/sys/DeviceManager_VK.cpp @@ -75,28 +75,28 @@ VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE #if defined(__APPLE__) && defined( USE_MoltenVK ) #if MVK_VERSION >= MVK_MAKE_VERSION( 1, 2, 9 ) && USE_OPTICK - static bool optickCapturing = false; - - // SRS - Optick callback function for notification of state changes - static bool optickStateChangedCallback( Optick::State::Type state ) - { - switch( state ) - { - case Optick::State::START_CAPTURE: - optickCapturing = true; - break; +static bool optickCapturing = false; - case Optick::State::STOP_CAPTURE: - case Optick::State::CANCEL_CAPTURE: - optickCapturing = false; - break; +// SRS - Optick callback function for notification of state changes +static bool optickStateChangedCallback( Optick::State::Type state ) +{ + switch( state ) + { + case Optick::State::START_CAPTURE: + optickCapturing = true; + break; - default: - break; - } + case Optick::State::STOP_CAPTURE: + case Optick::State::CANCEL_CAPTURE: + optickCapturing = false; + break; - return true; + default: + break; } + + return true; +} #endif #endif From 3fe0b2d5ee2cf8bdfa016d2fbbc6dcbbea92d014 Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Tue, 2 Apr 2024 17:17:47 +0200 Subject: [PATCH 24/71] Renamed DX12/Vulkan specific cvars with a r_vk/r_dx prefix --- neo/renderer/ImageManager.cpp | 6 +++--- neo/renderer/ModelManager.cpp | 4 ++-- neo/renderer/NVRHI/RenderBackend_NVRHI.cpp | 4 ++-- neo/sys/DeviceManager_DX12.cpp | 8 ++++---- neo/sys/DeviceManager_VK.cpp | 4 ++-- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/neo/renderer/ImageManager.cpp b/neo/renderer/ImageManager.cpp index 64d65a9748..fc39db36df 100644 --- a/neo/renderer/ImageManager.cpp +++ b/neo/renderer/ImageManager.cpp @@ -40,7 +40,7 @@ idImageManager imageManager; idImageManager* globalImages = &imageManager; extern DeviceManager* deviceManager; -extern idCVar r_uploadBufferSizeMB; +extern idCVar r_vkUploadBufferSizeMB; idCVar preLoad_Images( "preLoad_Images", "1", CVAR_SYSTEM | CVAR_BOOL, "preload images during beginlevelload" ); @@ -886,7 +886,7 @@ int idImageManager::LoadLevelImages( bool pacifier ) if( deviceManager->GetGraphicsAPI() == nvrhi::GraphicsAPI::VULKAN ) { // SRS - set upload buffer size to avoid Vulkan staging buffer fragmentation - size_t maxBufferSize = ( size_t )( r_uploadBufferSizeMB.GetInteger() * 1024 * 1024 ); + size_t maxBufferSize = ( size_t )( r_vkUploadBufferSizeMB.GetInteger() * 1024 * 1024 ); params.setUploadChunkSize( maxBufferSize ); } commandList = deviceManager->GetDevice()->createCommandList( params ); @@ -1009,7 +1009,7 @@ void idImageManager::LoadDeferredImages( nvrhi::ICommandList* _commandList ) if( deviceManager->GetGraphicsAPI() == nvrhi::GraphicsAPI::VULKAN ) { // SRS - set upload buffer size to avoid Vulkan staging buffer fragmentation - size_t maxBufferSize = ( size_t )( r_uploadBufferSizeMB.GetInteger() * 1024 * 1024 ); + size_t maxBufferSize = ( size_t )( r_vkUploadBufferSizeMB.GetInteger() * 1024 * 1024 ); params.setUploadChunkSize( maxBufferSize ); } commandList = deviceManager->GetDevice()->createCommandList( params ); diff --git a/neo/renderer/ModelManager.cpp b/neo/renderer/ModelManager.cpp index 85842ceb2e..5739f22add 100644 --- a/neo/renderer/ModelManager.cpp +++ b/neo/renderer/ModelManager.cpp @@ -37,7 +37,7 @@ If you have questions concerning this license or the applicable additional terms #include extern DeviceManager* deviceManager; -extern idCVar r_uploadBufferSizeMB; +extern idCVar r_vkUploadBufferSizeMB; idCVar binaryLoadRenderModels( "binaryLoadRenderModels", "1", 0, "enable binary load/write of render models" ); idCVar preload_MapModels( "preload_MapModels", "1", CVAR_SYSTEM | CVAR_BOOL, "preload models during begin or end levelload" ); @@ -248,7 +248,7 @@ void idRenderModelManagerLocal::Init() if( deviceManager->GetGraphicsAPI() == nvrhi::GraphicsAPI::VULKAN ) { // SRS - set upload buffer size to avoid Vulkan staging buffer fragmentation - size_t maxBufferSize = ( size_t )( r_uploadBufferSizeMB.GetInteger() * 1024 * 1024 ); + size_t maxBufferSize = ( size_t )( r_vkUploadBufferSizeMB.GetInteger() * 1024 * 1024 ); params.setUploadChunkSize( maxBufferSize ); } commandList = deviceManager->GetDevice()->createCommandList( params ); diff --git a/neo/renderer/NVRHI/RenderBackend_NVRHI.cpp b/neo/renderer/NVRHI/RenderBackend_NVRHI.cpp index 4cbed29fa6..59a793a333 100644 --- a/neo/renderer/NVRHI/RenderBackend_NVRHI.cpp +++ b/neo/renderer/NVRHI/RenderBackend_NVRHI.cpp @@ -56,7 +56,7 @@ idCVar stereoRender_warpTargetFraction( "stereoRender_warpTargetFraction", "1.0" idCVar r_showSwapBuffers( "r_showSwapBuffers", "0", CVAR_BOOL, "Show timings from GL_BlockingSwapBuffers" ); idCVar r_syncEveryFrame( "r_syncEveryFrame", "1", CVAR_BOOL, "Don't let the GPU buffer execution past swapbuffers" ); -idCVar r_uploadBufferSizeMB( "r_uploadBufferSizeMB", "64", CVAR_INTEGER | CVAR_INIT, "Size of gpu upload buffer (Vulkan only)" ); +idCVar r_vkUploadBufferSizeMB( "r_vkUploadBufferSizeMB", "64", CVAR_INTEGER | CVAR_INIT, "Size of gpu upload buffer (Vulkan only)" ); constexpr std::size_t MAX_IMAGE_PARMS = 16; @@ -222,7 +222,7 @@ void idRenderBackend::Init() if( deviceManager->GetGraphicsAPI() == nvrhi::GraphicsAPI::VULKAN ) { // SRS - set upload buffer size to avoid Vulkan staging buffer fragmentation - size_t maxBufferSize = ( size_t )( r_uploadBufferSizeMB.GetInteger() * 1024 * 1024 ); + size_t maxBufferSize = ( size_t )( r_vkUploadBufferSizeMB.GetInteger() * 1024 * 1024 ); params.setUploadChunkSize( maxBufferSize ); } commandList = deviceManager->GetDevice()->createCommandList( params ); diff --git a/neo/sys/DeviceManager_DX12.cpp b/neo/sys/DeviceManager_DX12.cpp index bf3badd908..4669a3af9d 100644 --- a/neo/sys/DeviceManager_DX12.cpp +++ b/neo/sys/DeviceManager_DX12.cpp @@ -48,7 +48,7 @@ using nvrhi::RefCountPtr; #define HR_RETURN(hr) if(FAILED(hr)) return false idCVar r_graphicsAdapter( "r_graphicsAdapter", "", CVAR_RENDERER | CVAR_INIT | CVAR_ARCHIVE, "Substring in the name the DXGI graphics adapter to select a certain GPU" ); -idCVar r_maxFrameLatency( "r_maxFrameLatency", "2", CVAR_RENDERER | CVAR_INIT | CVAR_ARCHIVE | CVAR_INTEGER, "Maximum frame latency for DXGI swap chains (DX12 only)", 0, NUM_FRAME_DATA ); +idCVar r_dxMaxFrameLatency( "r_dxMaxFrameLatency", "2", CVAR_RENDERER | CVAR_INIT | CVAR_ARCHIVE | CVAR_INTEGER, "Maximum frame latency for DXGI swap chains (DX12 only)", 0, NUM_FRAME_DATA ); class DeviceManager_DX12 : public DeviceManager { @@ -314,7 +314,7 @@ bool DeviceManager_DX12::CreateDeviceAndSwapChain() m_SwapChainDesc.BufferCount = m_DeviceParams.swapChainBufferCount; m_SwapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD; m_SwapChainDesc.Flags = ( m_DeviceParams.allowModeSwitch ? DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH : 0 ) | - ( r_maxFrameLatency.GetInteger() > 0 ? DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT : 0 ); + ( r_dxMaxFrameLatency.GetInteger() > 0 ? DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT : 0 ); // Special processing for sRGB swap chain formats. // DXGI will not create a swap chain with an sRGB format, but its contents will be interpreted as sRGB. @@ -433,9 +433,9 @@ bool DeviceManager_DX12::CreateDeviceAndSwapChain() hr = pSwapChain1->QueryInterface( IID_PPV_ARGS( &m_SwapChain ) ); HR_RETURN( hr ); - if( r_maxFrameLatency.GetInteger() > 0 ) + if( r_dxMaxFrameLatency.GetInteger() > 0 ) { - hr = m_SwapChain->SetMaximumFrameLatency( r_maxFrameLatency.GetInteger() ); + hr = m_SwapChain->SetMaximumFrameLatency( r_dxMaxFrameLatency.GetInteger() ); HR_RETURN( hr ); m_frameLatencyWaitableObject = m_SwapChain->GetFrameLatencyWaitableObject(); diff --git a/neo/sys/DeviceManager_VK.cpp b/neo/sys/DeviceManager_VK.cpp index c2e683f5d7..2dc0b6ef6e 100644 --- a/neo/sys/DeviceManager_VK.cpp +++ b/neo/sys/DeviceManager_VK.cpp @@ -68,7 +68,7 @@ idCVar r_vmaDeviceLocalMemoryMB( "r_vmaDeviceLocalMemoryMB", "256", CVAR_INTEGER | CVAR_INIT, "Size of VMA allocation block for gpu memory." ); #endif -idCVar r_preferFastSync( "r_preferFastSync", "1", CVAR_RENDERER | CVAR_ARCHIVE | CVAR_BOOL, "Prefer Fast Sync/no-tearing in place of VSync off/tearing (Vulkan only)" ); +idCVar r_vkPreferFastSync( "r_vkPreferFastSync", "1", CVAR_RENDERER | CVAR_ARCHIVE | CVAR_BOOL, "Prefer Fast Sync/no-tearing in place of VSync off/tearing" ); // Define the Vulkan dynamic dispatcher - this needs to occur in exactly one cpp file in the program. VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE @@ -1178,7 +1178,7 @@ bool DeviceManager_VK::createSwapChain() switch( m_DeviceParams.vsyncEnabled ) { case 0: - presentMode = enablePModeMailbox && r_preferFastSync.GetBool() ? vk::PresentModeKHR::eMailbox : + presentMode = enablePModeMailbox && r_vkPreferFastSync.GetBool() ? vk::PresentModeKHR::eMailbox : ( enablePModeImmediate ? vk::PresentModeKHR::eImmediate : vk::PresentModeKHR::eFifo ); break; case 1: From 11eb7e8bbaa70f4102698aee7e551fdd02d13031 Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Tue, 2 Apr 2024 17:23:27 +0200 Subject: [PATCH 25/71] Set execution flag on cmake-linux-retail.sh --- neo/cmake-linux-retail.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 neo/cmake-linux-retail.sh diff --git a/neo/cmake-linux-retail.sh b/neo/cmake-linux-retail.sh old mode 100644 new mode 100755 From ef2b39863fbe11b49f222680e373f0d266362e71 Mon Sep 17 00:00:00 2001 From: SRSaunders <82544213+SRSaunders@users.noreply.github.com> Date: Tue, 2 Apr 2024 12:41:50 -0400 Subject: [PATCH 26/71] Check for valid allocations before freeing Bink Decoder bundles --- neo/libs/libbinkdec/src/BinkDecoder.cpp | 4 ++++ neo/libs/libbinkdec/src/BinkVideo.cpp | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/neo/libs/libbinkdec/src/BinkDecoder.cpp b/neo/libs/libbinkdec/src/BinkDecoder.cpp index 49855ad4dc..d89d98646b 100644 --- a/neo/libs/libbinkdec/src/BinkDecoder.cpp +++ b/neo/libs/libbinkdec/src/BinkDecoder.cpp @@ -165,6 +165,10 @@ BinkDecoder::BinkDecoder() { nFrames = 0; currentFrame = 0; + for (int i = 0; i < BINK_NB_SRC; i++) + { + bundle[i].data = NULL; + } } BinkDecoder::~BinkDecoder() diff --git a/neo/libs/libbinkdec/src/BinkVideo.cpp b/neo/libs/libbinkdec/src/BinkVideo.cpp index 35acdc0721..f15b028356 100644 --- a/neo/libs/libbinkdec/src/BinkVideo.cpp +++ b/neo/libs/libbinkdec/src/BinkVideo.cpp @@ -105,7 +105,11 @@ void BinkDecoder::InitBundles() void BinkDecoder::FreeBundles() { for (int i = 0; i < BINK_NB_SRC; i++) - delete[] bundle[i].data; + if (bundle[i].data) + { + delete[] bundle[i].data; + bundle[i].data = NULL; + } } uint8_t BinkDecoder::GetHuffSymbol(BinkCommon::BitReader &bits, Tree &tree) From e7cd9bb2f72254af4fa3cfab938935263aabf8e3 Mon Sep 17 00:00:00 2001 From: SRSaunders <82544213+SRSaunders@users.noreply.github.com> Date: Tue, 2 Apr 2024 12:42:54 -0400 Subject: [PATCH 27/71] When playing testVideos, skip sRGB to linear conversion only when console active (i.e. 2D) --- neo/renderer/NVRHI/RenderDebug_NVRHI.cpp | 25 ++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/neo/renderer/NVRHI/RenderDebug_NVRHI.cpp b/neo/renderer/NVRHI/RenderDebug_NVRHI.cpp index 0b7c60b1ac..6d0c17831c 100644 --- a/neo/renderer/NVRHI/RenderDebug_NVRHI.cpp +++ b/neo/renderer/NVRHI/RenderDebug_NVRHI.cpp @@ -2318,6 +2318,7 @@ void idRenderBackend::DBG_TestImage() // Set State GL_State( GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO | GLS_DEPTHMASK | GLS_DEPTHFUNC_ALWAYS | GLS_CULL_TWOSIDED ); + renderProgManager.SetRenderParm( RENDERPARM_ALPHA_TEST, vec4_zero.ToFloatPtr() ); // Set Parms float texS[4] = { 1.0f, 0.0f, 0.0f, 0.0f }; @@ -2327,6 +2328,7 @@ void idRenderBackend::DBG_TestImage() float texGenEnabled[4] = { 0, 0, 0, 0 }; renderProgManager.SetRenderParm( RENDERPARM_TEXGEN_0_ENABLED, texGenEnabled ); + RB_SetVertexColorParms( SVC_IGNORE ); #if 1 // not really necessary but just for clarity @@ -2378,16 +2380,31 @@ void idRenderBackend::DBG_TestImage() GL_SelectTexture( 2 ); imageCb->Bind(); - // SRS - Use Bink shader without sRGB to linear conversion, otherwise cinematic colours may be wrong - // BindShader_BinkGUI() does not seem to work here - perhaps due to vertex shader input dependencies? - renderProgManager.BindShader_Bink_sRGB(); + + // SRS - When console is active (i.e. 2D) skip sRGB to linear conversion + if( console->Active() ) + { + renderProgManager.BindShader_Bink_sRGB(); + } + else + { + renderProgManager.BindShader_Bink(); + } } else { GL_SelectTexture( 0 ); image->Bind(); - renderProgManager.BindShader_Texture(); + // SRS - When console is active (i.e. 2D) skip sRGB to linear conversion + if( console->Active() ) + { + renderProgManager.BindShader_TextureVertexColor_sRGB(); + } + else + { + renderProgManager.BindShader_TextureVertexColor(); + } } // Draw! From 18755609de07ab87dea78b8cd2650435909651a1 Mon Sep 17 00:00:00 2001 From: SRSaunders <82544213+SRSaunders@users.noreply.github.com> Date: Tue, 2 Apr 2024 13:40:03 -0400 Subject: [PATCH 28/71] Fix testVideo to check for viewDef->viewEntitys (i.e. 3D/2D) not console state --- neo/renderer/NVRHI/RenderDebug_NVRHI.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/neo/renderer/NVRHI/RenderDebug_NVRHI.cpp b/neo/renderer/NVRHI/RenderDebug_NVRHI.cpp index 6d0c17831c..e850739375 100644 --- a/neo/renderer/NVRHI/RenderDebug_NVRHI.cpp +++ b/neo/renderer/NVRHI/RenderDebug_NVRHI.cpp @@ -2381,14 +2381,14 @@ void idRenderBackend::DBG_TestImage() GL_SelectTexture( 2 ); imageCb->Bind(); - // SRS - When console is active (i.e. 2D) skip sRGB to linear conversion - if( console->Active() ) + // SRS - When rendering in 2D skip sRGB to linear conversion + if( viewDef->viewEntitys ) { - renderProgManager.BindShader_Bink_sRGB(); + renderProgManager.BindShader_Bink(); } else { - renderProgManager.BindShader_Bink(); + renderProgManager.BindShader_Bink_sRGB(); } } else @@ -2396,14 +2396,14 @@ void idRenderBackend::DBG_TestImage() GL_SelectTexture( 0 ); image->Bind(); - // SRS - When console is active (i.e. 2D) skip sRGB to linear conversion - if( console->Active() ) + // SRS - When rendering in 2D skip sRGB to linear conversion + if( viewDef->viewEntitys ) { - renderProgManager.BindShader_TextureVertexColor_sRGB(); + renderProgManager.BindShader_TextureVertexColor(); } else { - renderProgManager.BindShader_TextureVertexColor(); + renderProgManager.BindShader_TextureVertexColor_sRGB(); } } From d716661d90134cce976b0b248eb6d20d2f1737ba Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Wed, 10 Apr 2024 10:48:26 +0200 Subject: [PATCH 29/71] Don't let VR options of other VR builds to break rendering of the non-VR master --- neo/d3xp/menus/MenuHandler.h | 2 ++ neo/d3xp/menus/MenuHandler_Shell.cpp | 24 ++++++++++++++++--- neo/d3xp/menus/MenuScreen.h | 4 ++++ neo/d3xp/menus/MenuScreen_Shell_Settings.cpp | 4 ++++ .../menus/MenuScreen_Shell_Stereoscopics.cpp | 4 ++++ neo/framework/Licensee.h | 2 ++ neo/renderer/RenderSystem_init.cpp | 9 +++++++ 7 files changed, 46 insertions(+), 3 deletions(-) diff --git a/neo/d3xp/menus/MenuHandler.h b/neo/d3xp/menus/MenuHandler.h index 0067aeba43..4d9e9cbd4e 100644 --- a/neo/d3xp/menus/MenuHandler.h +++ b/neo/d3xp/menus/MenuHandler.h @@ -42,7 +42,9 @@ enum shellAreas_t SHELL_AREA_SYSTEM_OPTIONS, SHELL_AREA_MULTIPLAYER, SHELL_AREA_GAME_LOBBY, +#if VR_OPTIONS SHELL_AREA_STEREOSCOPICS, +#endif SHELL_AREA_PARTY_LOBBY, SHELL_AREA_SETTINGS, SHELL_AREA_AUDIO, diff --git a/neo/d3xp/menus/MenuHandler_Shell.cpp b/neo/d3xp/menus/MenuHandler_Shell.cpp index febcb3bbf5..2349458cfd 100644 --- a/neo/d3xp/menus/MenuHandler_Shell.cpp +++ b/neo/d3xp/menus/MenuHandler_Shell.cpp @@ -485,7 +485,9 @@ void idMenuHandler_Shell::Initialize( const char* swfFile, idSoundWorld* sw ) BIND_SHELL_SCREEN( SHELL_AREA_SYSTEM_OPTIONS, idMenuScreen_Shell_SystemOptions, this ); BIND_SHELL_SCREEN( SHELL_AREA_GAME_OPTIONS, idMenuScreen_Shell_GameOptions, this ); BIND_SHELL_SCREEN( SHELL_AREA_SAVE, idMenuScreen_Shell_Save, this ); +#if VR_OPTIONS BIND_SHELL_SCREEN( SHELL_AREA_STEREOSCOPICS, idMenuScreen_Shell_Stereoscopics, this ); +#endif BIND_SHELL_SCREEN( SHELL_AREA_CONTROLS, idMenuScreen_Shell_Controls, this ); BIND_SHELL_SCREEN( SHELL_AREA_KEYBOARD, idMenuScreen_Shell_Bindings, this ); BIND_SHELL_SCREEN( SHELL_AREA_RESOLUTION, idMenuScreen_Shell_Resolution, this ); @@ -509,7 +511,9 @@ void idMenuHandler_Shell::Initialize( const char* swfFile, idSoundWorld* sw ) BIND_SHELL_SCREEN( SHELL_AREA_GAME_OPTIONS, idMenuScreen_Shell_GameOptions, this ); BIND_SHELL_SCREEN( SHELL_AREA_PARTY_LOBBY, idMenuScreen_Shell_PartyLobby, this ); BIND_SHELL_SCREEN( SHELL_AREA_GAME_LOBBY, idMenuScreen_Shell_GameLobby, this ); +#if VR_OPTIONS BIND_SHELL_SCREEN( SHELL_AREA_STEREOSCOPICS, idMenuScreen_Shell_Stereoscopics, this ); +#endif BIND_SHELL_SCREEN( SHELL_AREA_DIFFICULTY, idMenuScreen_Shell_Difficulty, this ); BIND_SHELL_SCREEN( SHELL_AREA_CONTROLS, idMenuScreen_Shell_Controls, this ); BIND_SHELL_SCREEN( SHELL_AREA_KEYBOARD, idMenuScreen_Shell_Bindings, this ); @@ -1036,8 +1040,14 @@ bool idMenuHandler_Shell::HandleAction( idWidgetAction& action, const idWidgetEv session->Cancel(); } - if( cmd != SHELL_CMD_QUIT && ( nextScreen == SHELL_AREA_STEREOSCOPICS || nextScreen == SHELL_AREA_SYSTEM_OPTIONS || nextScreen == SHELL_AREA_GAME_OPTIONS || - nextScreen == SHELL_AREA_GAMEPAD || nextScreen == SHELL_AREA_MATCH_SETTINGS ) ) + if( cmd != SHELL_CMD_QUIT && ( +#if VR_OPTIONS + nextScreen == SHELL_AREA_STEREOSCOPICS || +#endif + nextScreen == SHELL_AREA_SYSTEM_OPTIONS || + nextScreen == SHELL_AREA_GAME_OPTIONS || + nextScreen == SHELL_AREA_GAMEPAD || + nextScreen == SHELL_AREA_MATCH_SETTINGS ) ) { cvarSystem->SetModifiedFlags( CVAR_ARCHIVE ); @@ -1272,7 +1282,15 @@ void idMenuHandler_Shell::UpdateBGState() { if( nextScreen != SHELL_AREA_PLAYSTATION && nextScreen != SHELL_AREA_SETTINGS && nextScreen != SHELL_AREA_CAMPAIGN && nextScreen != SHELL_AREA_DEV ) { - if( nextScreen != SHELL_AREA_RESOLUTION && nextScreen != SHELL_AREA_GAMEPAD && nextScreen != SHELL_AREA_DIFFICULTY && nextScreen != SHELL_AREA_SYSTEM_OPTIONS && nextScreen != SHELL_AREA_GAME_OPTIONS && nextScreen != SHELL_AREA_NEW_GAME && nextScreen != SHELL_AREA_STEREOSCOPICS && + if( nextScreen != SHELL_AREA_RESOLUTION && + nextScreen != SHELL_AREA_GAMEPAD && + nextScreen != SHELL_AREA_DIFFICULTY && + nextScreen != SHELL_AREA_SYSTEM_OPTIONS && + nextScreen != SHELL_AREA_GAME_OPTIONS && + nextScreen != SHELL_AREA_NEW_GAME && +#if VR_OPTIONS + nextScreen != SHELL_AREA_STEREOSCOPICS && +#endif nextScreen != SHELL_AREA_CONTROLS ) { ShowSmallFrame( false ); diff --git a/neo/d3xp/menus/MenuScreen.h b/neo/d3xp/menus/MenuScreen.h index 7e28246290..f16b6a70be 100755 --- a/neo/d3xp/menus/MenuScreen.h +++ b/neo/d3xp/menus/MenuScreen.h @@ -1437,6 +1437,8 @@ class idMenuScreen_Shell_SystemOptions : public idMenuScreen }; +#if VR_OPTIONS + //* //================================================ //idMenuScreen_Shell_Stereoscopics @@ -1505,6 +1507,8 @@ class idMenuScreen_Shell_Stereoscopics : public idMenuScreen const idMaterial* rightEyeMat; }; +#endif + //* //================================================ //idMenuScreen_Shell_PartyLobby diff --git a/neo/d3xp/menus/MenuScreen_Shell_Settings.cpp b/neo/d3xp/menus/MenuScreen_Shell_Settings.cpp index ada6e23546..967c5c5a27 100644 --- a/neo/d3xp/menus/MenuScreen_Shell_Settings.cpp +++ b/neo/d3xp/menus/MenuScreen_Shell_Settings.cpp @@ -36,7 +36,9 @@ enum settingMenuCmds_t SETTING_CMD_CONTROLS, SETTING_CMD_GAMEPLAY, SETTING_CMD_SYSTEM, +#if VR_OPTIONS SETTING_CMD_3D, +#endif }; /* @@ -252,11 +254,13 @@ bool idMenuScreen_Shell_Settings::HandleAction( idWidgetAction& action, const id menuData->SetNextScreen( SHELL_AREA_SYSTEM_OPTIONS, MENU_TRANSITION_SIMPLE ); break; } +#if VR_OPTIONS case SETTING_CMD_3D: { menuData->SetNextScreen( SHELL_AREA_STEREOSCOPICS, MENU_TRANSITION_SIMPLE ); break; } +#endif } if( options != NULL ) diff --git a/neo/d3xp/menus/MenuScreen_Shell_Stereoscopics.cpp b/neo/d3xp/menus/MenuScreen_Shell_Stereoscopics.cpp index 3b074d6154..ecb5ee5321 100644 --- a/neo/d3xp/menus/MenuScreen_Shell_Stereoscopics.cpp +++ b/neo/d3xp/menus/MenuScreen_Shell_Stereoscopics.cpp @@ -29,6 +29,8 @@ If you have questions concerning this license or the applicable additional terms #pragma hdrstop #include "../Game_local.h" +#if VR_OPTIONS + const static int NUM_SYSTEM_OPTIONS_OPTIONS = 4; // TRC requires a maximum interoccular distance of 6.5cm even though human adults can easily have an interoccular distance of over 7.5cm @@ -475,3 +477,5 @@ bool idMenuScreen_Shell_Stereoscopics::idMenuDataSource_StereoSettings::IsRestar } return false; } + +#endif \ No newline at end of file diff --git a/neo/framework/Licensee.h b/neo/framework/Licensee.h index 0ffc894a94..633c16f1ac 100644 --- a/neo/framework/Licensee.h +++ b/neo/framework/Licensee.h @@ -79,3 +79,5 @@ If you have questions concerning this license or the applicable additional terms // raynorpat: GOG.com Galaxy Launcher Game ID for figuring out Steam base path #define GOGPATH_ID "1733124578" + +#define VR_OPTIONS 0 diff --git a/neo/renderer/RenderSystem_init.cpp b/neo/renderer/RenderSystem_init.cpp index 04bdc06483..843115438e 100644 --- a/neo/renderer/RenderSystem_init.cpp +++ b/neo/renderer/RenderSystem_init.cpp @@ -2504,7 +2504,11 @@ idRenderSystemLocal::IsStereoScopicRenderingSupported */ bool idRenderSystemLocal::IsStereoScopicRenderingSupported() const { +#if VR_OPTIONS return true; +#else + return false; +#endif } /* @@ -2541,7 +2545,12 @@ idRenderSystemLocal::GetStereoScopicRenderingMode */ stereo3DMode_t idRenderSystemLocal::GetStereoScopicRenderingMode() const { + // RB: only support in VR builds +#if VR_OPTIONS return ( !IsStereoScopicRenderingSupported() ) ? STEREO3D_OFF : ( stereo3DMode_t )stereoRender_enable.GetInteger(); +#else + return STEREO3D_OFF; +#endif } /* From 75bee8107b8f2d9d71ac1ab98853c019e688e273 Mon Sep 17 00:00:00 2001 From: CodeLikeCXK <44729188+CodeLikeCXK@users.noreply.github.com> Date: Tue, 23 Apr 2024 00:11:50 +0800 Subject: [PATCH 30/71] Create cmake-vs2022-arm64.bat --- neo/cmake-vs2022-arm64.bat | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 neo/cmake-vs2022-arm64.bat diff --git a/neo/cmake-vs2022-arm64.bat b/neo/cmake-vs2022-arm64.bat new file mode 100644 index 0000000000..e945b70ac1 --- /dev/null +++ b/neo/cmake-vs2022-arm64.bat @@ -0,0 +1,6 @@ +cd .. +del /s /q build +mkdir build +cd build +cmake -G "Visual Studio 17" -A arm64 -DUSE_INTRINSICS_SSE=OFF -DFFMPEG=OFF -DBINKDEC=ON -VULKAN=OFF ../neo +pause \ No newline at end of file From 99ff3656c128a578a4a8cb0e8080094f70578883 Mon Sep 17 00:00:00 2001 From: CodeLikeCXK <44729188+CodeLikeCXK@users.noreply.github.com> Date: Tue, 23 Apr 2024 00:22:51 +0800 Subject: [PATCH 31/71] Update cmake-vs2022-arm64.bat --- neo/cmake-vs2022-arm64.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neo/cmake-vs2022-arm64.bat b/neo/cmake-vs2022-arm64.bat index e945b70ac1..ba5b49d515 100644 --- a/neo/cmake-vs2022-arm64.bat +++ b/neo/cmake-vs2022-arm64.bat @@ -2,5 +2,5 @@ cd .. del /s /q build mkdir build cd build -cmake -G "Visual Studio 17" -A arm64 -DUSE_INTRINSICS_SSE=OFF -DFFMPEG=OFF -DBINKDEC=ON -VULKAN=OFF ../neo +cmake -G "Visual Studio 17" -A arm64 -DUSE_INTRINSICS_SSE=OFF VULKAN=OFF -DFFMPEG=OFF -DBINKDEC=ON ../neo pause \ No newline at end of file From f8a5329ea87f2b187cb5b8c114f40f7ddbe9c2a6 Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Wed, 24 Apr 2024 15:46:03 +0200 Subject: [PATCH 32/71] Read Blender lights directly through the KHR_lights_punctual glTF extension --- base/devtools.cfg | 2 +- neo/idlib/MapFile_gltf.cpp | 29 ++++++++++++++++++++++++----- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/base/devtools.cfg b/base/devtools.cfg index 20dc3373ab..4826fe7350 100644 --- a/base/devtools.cfg +++ b/base/devtools.cfg @@ -3,7 +3,7 @@ bind "I" "toggle r_showSurfaceInfo" bind "N" "noclip" bind "M" "spawn moveable_macbethchart" -bind "F1" "toggle editLights" +bind "F1" "editLights" bind "F2" "toggle r_showTris 1 2 0" bind "F3" "toggle r_forceAmbient 0.5 1.0 0" bind "F4" "toggle r_skipInteractions" diff --git a/neo/idlib/MapFile_gltf.cpp b/neo/idlib/MapFile_gltf.cpp index 554ca26967..1a99a951d5 100644 --- a/neo/idlib/MapFile_gltf.cpp +++ b/neo/idlib/MapFile_gltf.cpp @@ -433,6 +433,8 @@ void ResolveLight( gltfData* data, idMapEntity* newEntity, gltfNode* node ) assert( light ); + newEntity->epairs.Set( "classname", "light" ); + //newEntity->epairs.SetMatrix( "rotation", mat3_default ); newEntity->epairs.SetVector( "_color", light->color ); @@ -450,8 +452,19 @@ void ResolveLight( gltfData* data, idMapEntity* newEntity, gltfNode* node ) case gltfExt_KHR_lights_punctual::Point: { - newEntity->epairs.SetVector( "light_radius", idVec3( light->range ) ); - newEntity->epairs.Set( "texture", "lights/defaultpointlight" ); + float radius = 300; + if( light->range != -1 ) + { + radius = light->range; + } + + newEntity->epairs.SetVector( "light_radius", idVec3( radius ) ); + + idStr texture; + if( !newEntity->epairs.GetString( "texture", "", texture ) ) + { + newEntity->epairs.Set( "texture", "lights/biground1" ); + } break; } @@ -471,7 +484,12 @@ void ResolveLight( gltfData* data, idMapEntity* newEntity, gltfNode* node ) newEntity->epairs.SetVector( "light_up", axis[2] * fov ); newEntity->epairs.SetVector( "light_start", axis[0] * 16 ); newEntity->epairs.SetVector( "light_end", axis[0] * ( light->range - 16 ) ); - newEntity->epairs.Set( "texture", "lights/spot01" ); + + idStr texture; + if( !newEntity->epairs.GetString( "texture", "", texture ) ) + { + newEntity->epairs.Set( "texture", "lights/spot01" ); + } break; } @@ -638,8 +656,9 @@ int idMapEntity::GetEntities( gltfData* data, EntityListRef entities, int sceneI idStr classnameStr = node->extras.strPairs.GetString( "classname" ); bool skipInline = !node->extras.strPairs.GetBool( "inline", true ); idDict epairs; - // skip everything that is not an entity - if( !classnameStr.IsEmpty() ) + + // skip everything that is not an entity except lights + if( !classnameStr.IsEmpty() || node->extensions.KHR_lights_punctual ) { idMapEntity* newEntity = new( TAG_IDLIB_GLTF ) idMapEntity(); entities.Append( newEntity ); From 0a1a591c148f777c6860a007e2ac9c09ac88a54e Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Wed, 24 Apr 2024 16:05:32 +0200 Subject: [PATCH 33/71] Updated .plan --- RELEASE-NOTES.md | 55 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 2900a3c908..5c0d3c5af0 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -19,6 +19,61 @@ TBD - RBDOOM-3-BFG 1.6.0 _______________________________ +## .plan - April 24, 2024 + +Cudos to Stephen Saunders for most changes in this build. NVRHI was updated to the version on 25 February. +The shader compiling part was also split out of NVRHI into a new ShaderMake tool by Nvidia. + +You can get Blender lights to work with the glTF workflow without the need to place fake light entities in Blender. +VR options are stripped from the settings menu and com_showFPS > 2 show the VRAM memory usage. + +Optick has been improved for macOS and Vulkan and otherwise most changes are developer related. +The renderdemo code has been removed and if you compile the engine without Classic Doom support then you will bypass the startup screen and get into the main menu immediatly. + +Changelog: + +* Read Blender lights directly through the KHR_lights_punctual glTF extension + +* Don't let VR options of other VR builds to break rendering of the non-VR master + +* Fix testVideo to check for viewDef->viewEntitys (i.e. 3D/2D) not console state + +* When playing testVideos, skip sRGB to linear conversion only when console active (i.e. 2D) + +* Check for valid allocations before freeing Bink Decoder bundles + +* Renamed DX12/Vulkan specific cvars with a r_vk/r_dx prefix + +* Set r_maxFrameLatency max value constraint to NUM_FRAME_DATA + +* Change r_maxFrameLatency cvar name and set to default value of 2 frames + +* Implement m_frameLatencyWaitableObject sync for reduced DX12 frame latency + +* Extend Optick to support data tags on custom storage events + +* Added CMake -DRETAIL option for shipping builds on Github/ModDB + +* Skip startup if not compiled with Doom Classic support, closes #874 + +* More renderdemo code removed + +* Killed hard to maintain renderdemo code + +* Fix for cinematic audio when playing Bink video files with ffmpeg decoder, improve ffmpeg a/v resync + +* Show VRAM memory usage with com_showFPS > 2 in separate line + +* Correct some uint64 types and add Optick frame tag for DX12 / Vulkan Present() + +* Optick: Eliminate need for blocking sleep wait at start of Vulkan clock sync + +* Optick: Remove blocking sleep wait at start of Vulkan clock synchronization + +* Complete Optick instrumentation and align with HUD GPU timers + + + ## .plan - January 20, 2024 Cudos to Stephen Saunders for this build and to reeFridge for finding the issue. From 82455c188da3a63e31ff54fe9f6ad678341f6fa2 Mon Sep 17 00:00:00 2001 From: SRSaunders <82544213+SRSaunders@users.noreply.github.com> Date: Mon, 29 Apr 2024 00:36:58 -0400 Subject: [PATCH 34/71] macOS: Support non-system Vulkan SDK installs & enable cmake regen for xcode release builds --- neo/CMakeLists.txt | 15 ++++++++++++++- neo/cmake-xcode-debug.sh | 4 ++-- neo/cmake-xcode-release.sh | 6 ++---- neo/cmake-xcode-universal.sh | 8 +++----- 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/neo/CMakeLists.txt b/neo/CMakeLists.txt index 1ee7185332..1e76a192af 100644 --- a/neo/CMakeLists.txt +++ b/neo/CMakeLists.txt @@ -375,7 +375,7 @@ if(USE_VULKAN) endif() if(APPLE) - # SRS - Enable Beta extensions for VULKAN_SDK portability subset features on OSX + # SRS - Enable Beta extensions for Vulkan portability subset features on macOS add_definitions(-DVK_ENABLE_BETA_EXTENSIONS) # SRS - Optionally link directly to MoltenVK headers/library for runtime config functions on OSX if(USE_MoltenVK) @@ -386,6 +386,19 @@ if(USE_VULKAN) else() message(FATAL_ERROR "Must define VULKAN_SDK location if USE_MoltenVK option enabled!") endif() + else() + # If using Xcode and the Vulkan loader's environment variables are defined, make them available within Xcode scheme + if(CMAKE_GENERATOR MATCHES "Xcode") + if(DEFINED ENV{VK_ADD_LAYER_PATH}) + set(CMAKE_XCODE_SCHEME_ENVIRONMENT "${CMAKE_XCODE_SCHEME_ENVIRONMENT};VK_ADD_LAYER_PATH=$ENV{VK_ADD_LAYER_PATH}") + endif() + if(DEFINED ENV{VK_ICD_FILENAMES}) + set(CMAKE_XCODE_SCHEME_ENVIRONMENT "${CMAKE_XCODE_SCHEME_ENVIRONMENT};VK_ICD_FILENAMES=$ENV{VK_ICD_FILENAMES}") + endif() + if(DEFINED ENV{VK_DRIVER_FILES}) + set(CMAKE_XCODE_SCHEME_ENVIRONMENT "${CMAKE_XCODE_SCHEME_ENVIRONMENT};VK_DRIVER_FILES=$ENV{VK_DRIVER_FILES}") + endif() + endif() endif() endif() message(STATUS "Using Vulkan: " ${Vulkan_LIBRARY}) diff --git a/neo/cmake-xcode-debug.sh b/neo/cmake-xcode-debug.sh index 7b89593ab0..ab7dae12f0 100755 --- a/neo/cmake-xcode-debug.sh +++ b/neo/cmake-xcode-debug.sh @@ -13,8 +13,8 @@ if [ -z "$OPENAL_PREFIX" ]; then fi fi -# note 1: remove or set -DCMAKE_SUPPRESS_REGENERATION=OFF to reenable ZERO_CHECK target which checks for CMakeLists.txt changes and re-runs CMake before builds -# however, if ZERO_CHECK is reenabled **must** add VULKAN_SDK location to Xcode Custom Paths (under Prefs/Locations) otherwise build failures may occur +# note 1: remove or set -DCMAKE_SUPPRESS_REGENERATION=OFF to enable ZERO_CHECK target which checks for CMakeLists.txt changes and re-runs CMake before builds +# however, if ZERO_CHECK is enabled **must** add Vulkan's VK_ADD_LAYER_PATH, VK_ICD_FILENAMES, and VK_DRIVER_FILES locations to Xcode Custom Paths (under Settings/Locations) otherwise runtime failures may occur # note 2: policy CMAKE_POLICY_DEFAULT_CMP0142=NEW suppresses non-existant per-config suffixes on Xcode library search paths, works for cmake version 3.25 and later # note 3: env variable MVK_CONFIG_FULL_IMAGE_VIEW_SWIZZLE=1 enables MoltenVK's image view swizzle which may be required on older macOS versions or hardware (see vulkaninfo) - only used for VulkanSDK < 1.3.275 # note 4: env variable MVK_CONFIG_SYNCHRONOUS_QUEUE_SUBMITS=0 disables synchronous queue submits which is optimal for the synchronization method used by the game - only used for VulkanSDK < 1.3.275 diff --git a/neo/cmake-xcode-release.sh b/neo/cmake-xcode-release.sh index 538c1ed482..0d5c36fb20 100755 --- a/neo/cmake-xcode-release.sh +++ b/neo/cmake-xcode-release.sh @@ -13,7 +13,5 @@ if [ -z "$OPENAL_PREFIX" ]; then fi fi -# note 1: remove or set -DCMAKE_SUPPRESS_REGENERATION=OFF to reenable ZERO_CHECK target which checks for CMakeLists.txt changes and re-runs CMake before builds -# however, if ZERO_CHECK is reenabled **must** add VULKAN_SDK location to Xcode Custom Paths (under Prefs/Locations) otherwise build failures may occur -# note 2: policy CMAKE_POLICY_DEFAULT_CMP0142=NEW suppresses non-existant per-config suffixes on Xcode library search paths, works for cmake version 3.25 and later -cmake -G Xcode -DCMAKE_BUILD_TYPE=Release -DCMAKE_CONFIGURATION_TYPES="Release;MinSizeRel;RelWithDebInfo" -DMACOSX_BUNDLE=ON -DFFMPEG=OFF -DBINKDEC=ON -DUSE_MoltenVK=ON -DCMAKE_XCODE_GENERATE_SCHEME=ON -DCMAKE_XCODE_SCHEME_ENABLE_GPU_API_VALIDATION=OFF -DCMAKE_SUPPRESS_REGENERATION=ON -DOPENAL_LIBRARY=$OPENAL_PREFIX/lib/libopenal.dylib -DOPENAL_INCLUDE_DIR=$OPENAL_PREFIX/include ../neo -DCMAKE_POLICY_DEFAULT_CMP0142=NEW -Wno-dev +# note 1: policy CMAKE_POLICY_DEFAULT_CMP0142=NEW suppresses non-existant per-config suffixes on Xcode library search paths, works for cmake version 3.25 and later +cmake -G Xcode -DCMAKE_BUILD_TYPE=Release -DCMAKE_CONFIGURATION_TYPES="Release;MinSizeRel;RelWithDebInfo" -DMACOSX_BUNDLE=ON -DFFMPEG=OFF -DBINKDEC=ON -DUSE_MoltenVK=ON -DCMAKE_XCODE_GENERATE_SCHEME=ON -DCMAKE_XCODE_SCHEME_ENABLE_GPU_API_VALIDATION=OFF -DOPENAL_LIBRARY=$OPENAL_PREFIX/lib/libopenal.dylib -DOPENAL_INCLUDE_DIR=$OPENAL_PREFIX/include ../neo -DCMAKE_POLICY_DEFAULT_CMP0142=NEW -Wno-dev diff --git a/neo/cmake-xcode-universal.sh b/neo/cmake-xcode-universal.sh index 667c44fe01..517090d3f1 100755 --- a/neo/cmake-xcode-universal.sh +++ b/neo/cmake-xcode-universal.sh @@ -11,8 +11,6 @@ if [[ $OPENAL_VARIANTS != *universal* ]]; then exit 1 fi -# note 1: remove or set -DCMAKE_SUPPRESS_REGENERATION=OFF to reenable ZERO_CHECK target which checks for CMakeLists.txt changes and re-runs CMake before builds -# however, if ZERO_CHECK is reenabled **must** add VULKAN_SDK location to Xcode Custom Paths (under Prefs/Locations) otherwise build failures may occur -# note 2: policy CMAKE_POLICY_DEFAULT_CMP0142=NEW suppresses non-existant per-config suffixes on Xcode library search paths, works for cmake version 3.25 and later -# note 3: universal openal-soft library and include paths assume MacPorts install locations -cmake -G Xcode -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" -DCMAKE_CONFIGURATION_TYPES="Release;MinSizeRel;RelWithDebInfo" -DMACOSX_BUNDLE=ON -DFFMPEG=OFF -DBINKDEC=ON -DUSE_MoltenVK=ON -DCMAKE_XCODE_GENERATE_SCHEME=ON -DCMAKE_XCODE_SCHEME_ENABLE_GPU_API_VALIDATION=OFF -DCMAKE_SUPPRESS_REGENERATION=ON -DOPENAL_LIBRARY=/opt/local/lib/libopenal.dylib -DOPENAL_INCLUDE_DIR=/opt/local/include ../neo -DCMAKE_POLICY_DEFAULT_CMP0142=NEW -Wno-dev +# note 1: policy CMAKE_POLICY_DEFAULT_CMP0142=NEW suppresses non-existant per-config suffixes on Xcode library search paths, works for cmake version 3.25 and later +# note 2: universal openal-soft library and include paths assume MacPorts install locations +cmake -G Xcode -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" -DCMAKE_CONFIGURATION_TYPES="Release;MinSizeRel;RelWithDebInfo" -DMACOSX_BUNDLE=ON -DFFMPEG=OFF -DBINKDEC=ON -DUSE_MoltenVK=ON -DCMAKE_XCODE_GENERATE_SCHEME=ON -DCMAKE_XCODE_SCHEME_ENABLE_GPU_API_VALIDATION=OFF -DOPENAL_LIBRARY=/opt/local/lib/libopenal.dylib -DOPENAL_INCLUDE_DIR=/opt/local/include ../neo -DCMAKE_POLICY_DEFAULT_CMP0142=NEW -Wno-dev From c7f5dd7aa43249679aa601a636bea438a1fb242c Mon Sep 17 00:00:00 2001 From: SRSaunders <82544213+SRSaunders@users.noreply.github.com> Date: Mon, 29 Apr 2024 01:39:45 -0400 Subject: [PATCH 35/71] Update README to document DXC_CUSTOM_PATH as an alternative to modifying PATH for dxc --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 1071f85e27..e96dea8150 100644 --- a/README.md +++ b/README.md @@ -449,6 +449,8 @@ Recommended in this case is `cmake-vs2022-win64-no-ffmpeg.bat` > # DXC compiler > PATH="~/dxc-artifacts/bin:$PATH" + As an alternative to modifying your PATH, you can add -DDXC\_CUSTOM_PATH=\ to the CMake options. + 2. You need the following dependencies in order to compile RBDoom3BFG with all features: On Debian or Ubuntu: From 117b41c0a47b75e9439f1d022f5b11b9a5996861 Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Wed, 1 May 2024 11:11:03 +0200 Subject: [PATCH 36/71] Support linked group instances by TrenchBroom. close #700 --- neo/idlib/MapFile.cpp | 92 +++++++++++++++++++++++++++++++++++++++---- neo/idlib/MapFile.h | 1 + 2 files changed, 86 insertions(+), 7 deletions(-) diff --git a/neo/idlib/MapFile.cpp b/neo/idlib/MapFile.cpp index 44d21928d0..581516a52d 100644 --- a/neo/idlib/MapFile.cpp +++ b/neo/idlib/MapFile.cpp @@ -1785,6 +1785,13 @@ bool idMapFile::Parse( const char* filename, bool ignoreRegion, bool osPath ) } } + if( valve220Format ) + { + // it might be possible that the level designer missed to set the name/model keys to be protected + // so the game code would fail to load the map because entities have then the same name + FixDuplicatedNamesInGroupInstances(); + } + // RB: _extraents.map allows to add and override existing entities idMapFile extrasMap; fullName = name; @@ -3216,11 +3223,10 @@ void idMapFile::ClassifyEntitiesForTrenchBroom( idDict& classTypeOverview ) bool idMapFile::ConvertQuakeToDoom() { - idDict classTypeOverview; idStrList textureCollections; int count = GetNumEntities(); - for( int j = 0; j < count; j++ ) + for( int j = 1; j < count; j++ ) { idMapEntity* ent = GetEntity( j ); if( ent ) @@ -3296,11 +3302,7 @@ bool idMapFile::ConvertQuakeToDoom() if( ent->GetNumPrimitives() > 0 ) { - if( j > 0 ) - { - const idKeyValue* namePair = ent->epairs.FindKey( "name" ); - ent->epairs.Set( "model", namePair->GetValue() ); - } + ent->epairs.Set( "model", namePair->GetValue() ); // map Wad brushes names to proper Doom 3 compatible material names for( int i = 0; i < ent->GetNumPrimitives(); i++ ) @@ -3317,6 +3319,8 @@ bool idMapFile::ConvertQuakeToDoom() idStr matName; WadTextureToMaterial( side->GetMaterial(), matName ); side->SetMaterial( matName ); + + idMapFile::AddMaterialToCollection( side->GetMaterial(), textureCollections ); } } else if( mapPrim->GetType() == idMapPrimitive::TYPE_PATCH ) @@ -3356,6 +3360,80 @@ bool idMapFile::ConvertQuakeToDoom() return true; } +void idMapFile::FixDuplicatedNamesInGroupInstances() +{ + int count = GetNumEntities(); + for( int j = 1; j < count; j++ ) + { + idMapEntity* ent = GetEntity( j ); + if( ent ) + { + idStr classname = ent->epairs.GetString( "classname" ); + + // only fix names in linked group lists + const idKeyValue* groupPair = ent->epairs.FindKey( "_tb_group" ); + if( !groupPair ) + { + continue; + } + + const idKeyValue* namePair = ent->epairs.FindKey( "name" ); + if( !namePair ) + { + idStr uniqueName = GetUniqueEntityName( classname ); + + ent->epairs.Set( "name", uniqueName ); + } + else + { + // is there a name clash with another entity? + bool clash = false; + + for( int i = 1; i < count; i++ ) + { + if( i == j ) + { + continue; + } + + idMapEntity* otherEnt = GetEntity( i ); + + const idKeyValue* otherNamePair = otherEnt->epairs.FindKey( "name" ); + if( otherNamePair && !otherNamePair->GetValue().IsEmpty() && idStr::Cmp( namePair->GetValue(), otherNamePair->GetValue() ) == 0 ) + { + // both entities have the same name, give this one a new name + idStr uniqueName = GetUniqueEntityName( classname ); + + ent->epairs.Set( "name", uniqueName ); + + if( ent->GetNumPrimitives() > 0 ) + { + ent->epairs.Set( "model", uniqueName ); + } + break; + } + } + } + + // fix light color range + if( idStr::Icmp( classname, "light" ) == 0 ) + { + idVec3 color; + ent->epairs.GetVector( "_color", "1 1 1", color ); + + if( color.x > 1 || color.y > 1 || color.z > 1 ) + { + color.x *= 1.0f / 255; + color.y *= 1.0f / 255; + color.z *= 1.0f / 255; + + ent->epairs.SetVector( "_color", color ); + } + } + } + } +} + void idMapFile::AddMaterialToCollection( const char* material, idStrList& textureCollections ) { idStr withoutPath = material; diff --git a/neo/idlib/MapFile.h b/neo/idlib/MapFile.h index a1a492f84c..188af81a39 100644 --- a/neo/idlib/MapFile.h +++ b/neo/idlib/MapFile.h @@ -508,6 +508,7 @@ class idMapFile // converts Wad texture names to valid Doom 3 materials and gives every entity a unique name bool ConvertQuakeToDoom(); + void FixDuplicatedNamesInGroupInstances(); // RB end // get the number of entities in the map From 4357e0f7a3f445d46f465a175af257a9daab5517 Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Wed, 1 May 2024 11:37:34 +0200 Subject: [PATCH 37/71] Restored internal envprobe fallback if map has no envprobes. close #836 --- neo/renderer/Image_load.cpp | 3 +++ neo/renderer/tr_frontend_main.cpp | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/neo/renderer/Image_load.cpp b/neo/renderer/Image_load.cpp index 7bd3b55b5d..8080a80d2d 100644 --- a/neo/renderer/Image_load.cpp +++ b/neo/renderer/Image_load.cpp @@ -585,6 +585,9 @@ void idImage::FinalizeImage( bool fromBackEnd, nvrhi::ICommandList* commandList AllocImage(); + // default it again because it was unset by AllocImage().PurgeImage() + defaulted = true; + // clear the data so it's not left uninitialized idTempArray clear( opts.width * opts.height * 4 ); memset( clear.Ptr(), 0, clear.Size() ); diff --git a/neo/renderer/tr_frontend_main.cpp b/neo/renderer/tr_frontend_main.cpp index 4c63975b14..cc7e98afd1 100644 --- a/neo/renderer/tr_frontend_main.cpp +++ b/neo/renderer/tr_frontend_main.cpp @@ -532,7 +532,7 @@ static void R_FindClosestEnvironmentProbes() RenderEnvprobeLocal* nearest = viewEnvprobes[0]; tr.viewDef->globalProbeBounds = nearest->globalProbeBounds; - if( !nearest->irradianceImage->IsDefaulted() ) + if( nearest->irradianceImage->IsLoaded() && !nearest->irradianceImage->IsDefaulted() ) { tr.viewDef->irradianceImage = nearest->irradianceImage; } From 9933722d2b4798f52139165fca33b8c2b51dd23f Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Wed, 1 May 2024 12:55:18 +0200 Subject: [PATCH 38/71] Removed unused alternative idTarget_Level in EndLevel.cpp --- neo/CMakeLists.txt | 2 - neo/d3xp/EndLevel.cpp | 202 ------------------------------------------ neo/d3xp/EndLevel.h | 67 -------------- 3 files changed, 271 deletions(-) delete mode 100644 neo/d3xp/EndLevel.cpp delete mode 100644 neo/d3xp/EndLevel.h diff --git a/neo/CMakeLists.txt b/neo/CMakeLists.txt index 1e76a192af..b46ab1b2df 100644 --- a/neo/CMakeLists.txt +++ b/neo/CMakeLists.txt @@ -731,7 +731,6 @@ set(GAMED3XP_INCLUDES d3xp/AimAssist.h d3xp/BrittleFracture.h d3xp/Camera.h - #d3xp/EndLevel.h d3xp/Entity.h d3xp/EnvironmentProbe.h d3xp/Fx.h @@ -769,7 +768,6 @@ set(GAMED3XP_SOURCES d3xp/AimAssist.cpp d3xp/BrittleFracture.cpp d3xp/Camera.cpp - #d3xp/EndLevel.cpp d3xp/Entity.cpp d3xp/EnvironmentProbe.cpp d3xp/Fx.cpp diff --git a/neo/d3xp/EndLevel.cpp b/neo/d3xp/EndLevel.cpp deleted file mode 100644 index 2cfc0e6c84..0000000000 --- a/neo/d3xp/EndLevel.cpp +++ /dev/null @@ -1,202 +0,0 @@ -/* -=========================================================================== - -Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. - -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). - -Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Doom 3 BFG Edition Source Code. If not, see . - -In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below. - -If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA. - -=========================================================================== -*/ - -#include "../idlib/precompiled.h" -#pragma hdrstop - -#include "Game_local.h" - -/* - - game_endlevel.cpp - - This entity is targeted to complete a level, and it also handles - running the stats and moving the camera. - -*/ - - -CLASS_DECLARATION( idEntity, idTarget_EndLevel ) -EVENT( EV_Activate, idTarget_EndLevel::Event_Trigger ) -END_CLASS - -/* -================ -idTarget_EndLevel::Spawn -================ -*/ -void idTarget_EndLevel::Spawn() -{ - idStr guiName; - - gui = NULL; - noGui = spawnArgs.GetBool( "noGui" ); - if( !noGui ) - { - spawnArgs.GetString( "guiName", "guis/EndLevel.gui", guiName ); - - if( guiName.Length() ) - { - gui = idUserInterface::FindGui( guiName, true, false, true ); - } - } - - buttonsReleased = false; - readyToExit = false; - - exitCommand = ""; -} - -/* -================ -idTarget_EndLevel::~idTarget_EndLevel() -================ -*/ -idTarget_EndLevel::~idTarget_EndLevel() -{ - //FIXME: need to go to smart ptrs for gui allocs or the unique method - //delete gui; -} - -/* -================ -idTarget_EndLevel::Event_Trigger -================ -*/ -void idTarget_EndLevel::Event_Trigger( idEntity* activator ) -{ - if( gameLocal.endLevel ) - { - return; - } - - // mark the endLevel, which will modify some game actions - // and pass control to us for drawing the stats and camera position - gameLocal.endLevel = this; - - // grab the activating player view position - idPlayer* player = ( idPlayer* )( activator ); - - initialViewOrg = player->GetEyePosition(); - initialViewAngles = idVec3( player->viewAngles[0], player->viewAngles[1], player->viewAngles[2] ); - - // kill all the sounds - gameSoundWorld->StopAllSounds(); - - if( noGui ) - { - readyToExit = true; - } -} - -/* -================ -idTarget_EndLevel::Draw -================ -*/ -void idTarget_EndLevel::Draw() -{ - - if( noGui ) - { - return; - } - - renderView_t renderView; - - memset( &renderView, 0, sizeof( renderView ) ); - - renderView.width = SCREEN_WIDTH; - renderView.height = SCREEN_HEIGHT; - renderView.x = 0; - renderView.y = 0; - - renderView.fov_x = 90; - renderView.fov_y = gameLocal.CalcFovY( renderView.fov_x ); - renderView.time = gameLocal.time; - -#if 0 - renderView.vieworg = initialViewOrg; - renderView.viewaxis = idAngles( initialViewAngles ).toMat3(); -#else - renderView.vieworg = renderEntity.origin; - renderView.viewaxis = renderEntity.axis; -#endif - - gameRenderWorld->RenderScene( &renderView ); - - // draw the gui on top of the 3D view - gui->Redraw( gameLocal.time ); -} - -/* -================ -idTarget_EndLevel::PlayerCommand -================ -*/ -void idTarget_EndLevel::PlayerCommand( int buttons ) -{ - if( !( buttons & BUTTON_ATTACK ) ) - { - buttonsReleased = true; - return; - } - if( !buttonsReleased ) - { - return; - } - - // we will exit at the end of the next game frame - readyToExit = true; -} - -/* -================ -idTarget_EndLevel::ExitCommand -================ -*/ -const char* idTarget_EndLevel::ExitCommand() -{ - if( !readyToExit ) - { - return NULL; - } - - idStr nextMap; - - if( spawnArgs.GetString( "nextMap", "", nextMap ) ) - { - sprintf( exitCommand, "map %s", nextMap.c_str() ); - } - else - { - exitCommand = ""; - } - - return exitCommand; -} diff --git a/neo/d3xp/EndLevel.h b/neo/d3xp/EndLevel.h deleted file mode 100644 index 2c4c6989ff..0000000000 --- a/neo/d3xp/EndLevel.h +++ /dev/null @@ -1,67 +0,0 @@ -/* -=========================================================================== - -Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. - -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). - -Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Doom 3 BFG Edition Source Code. If not, see . - -In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below. - -If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA. - -=========================================================================== -*/ - -class idTarget_EndLevel : public idEntity -{ -public: - CLASS_PROTOTYPE( idTarget_EndLevel ); - - void Spawn(); - ~idTarget_EndLevel(); - - void Draw(); - // the endLevel will be responsible for drawing the entire screen - // when it is active - - void PlayerCommand( int buttons ); - // when an endlevel is active, plauer buttons get sent here instead - // of doing anything to the player, which will allow moving to - // the next level - - const char* ExitCommand(); - // the game will check this each frame, and return it to the - // session when there is something to give - -private: - idStr exitCommand; - - idVec3 initialViewOrg; - idVec3 initialViewAngles; - // set when the player triggers the exit - - idUserInterface* gui; - - bool buttonsReleased; - // don't skip out until buttons are released, then pressed - - bool readyToExit; - bool noGui; - - void Event_Trigger( idEntity* activator ); -}; - From bbaffcd75bc05c5f8590a3659499636b2015d812 Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Wed, 1 May 2024 13:49:13 +0200 Subject: [PATCH 39/71] Save .bcanim files under generated/cameraanim/. close #866 --- neo/d3xp/Camera.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/neo/d3xp/Camera.cpp b/neo/d3xp/Camera.cpp index 7036f0db79..1092afd1af 100644 --- a/neo/d3xp/Camera.cpp +++ b/neo/d3xp/Camera.cpp @@ -405,8 +405,8 @@ void idCameraAnim::LoadAnim() // check for generated file - idStrStatic< MAX_OSPATH > generatedFileName = key; - generatedFileName.Insert( "generated/", 0 ); + idStrStatic< MAX_OSPATH > generatedFileName = "generated/cameraanim/"; + generatedFileName.AppendPath( key ); generatedFileName.SetFileExtension( CAMERA_ANIM_BINARYFILE_EXT ); ID_TIME_T currentTimeStamp = FILE_NOT_FOUND_TIMESTAMP; @@ -491,8 +491,8 @@ void idCameraAnim::LoadAnim() cameraCuts.SetNum( numCuts ); for( i = 0; i < numCuts; i++ ) { - cameraCuts[i] = parser.ParseInt(); - if( ( cameraCuts[i] < 1 ) || ( cameraCuts[i] >= numFrames ) ) + cameraCuts[ i ] = parser.ParseInt(); + if( ( cameraCuts[ i ] < 1 ) || ( cameraCuts[ i ] >= numFrames ) ) { parser.Error( "Invalid camera cut" ); } @@ -505,9 +505,9 @@ void idCameraAnim::LoadAnim() camera.SetNum( numFrames ); for( i = 0; i < numFrames; i++ ) { - parser.Parse1DMatrix( 3, camera[i].t.ToFloatPtr() ); - parser.Parse1DMatrix( 3, camera[i].q.ToFloatPtr() ); - camera[i].fov = parser.ParseFloat(); + parser.Parse1DMatrix( 3, camera[ i ].t.ToFloatPtr() ); + parser.Parse1DMatrix( 3, camera[ i ].q.ToFloatPtr() ); + camera[ i ].fov = parser.ParseFloat(); } parser.ExpectTokenString( "}" ); } @@ -754,6 +754,7 @@ void idCameraAnim::Event_Activate( idEntity* _activator ) } } +// HarrievG begin void idCameraAnim::gltfLoadAnim( idStr gltfFileName, idStr animName ) { GLTF_Parser gltf; @@ -887,6 +888,7 @@ void idCameraAnim::gltfLoadAnim( idStr gltfFileName, idStr animName ) camera[i].fov = ( float )( *lensFrameValues )[i]; } } + //Dont forget to free! normally a gltfPropertyArray destructor frees the itemdata delete CameraLensFrames->item; } @@ -920,7 +922,6 @@ void idCameraAnim::WriteBinaryCamAnim( idFile* file, ID_TIME_T* _timeStamp /*= N file->WriteVec3( cam.t ); } } - } bool idCameraAnim::LoadBinaryCamAnim( idFile* file, const ID_TIME_T sourceTimeStamp ) @@ -960,8 +961,10 @@ bool idCameraAnim::LoadBinaryCamAnim( idFile* file, const ID_TIME_T sourceTimeSt assert( i == count ); return true; } + return false; } +// HarrievG end /* =============== From 4fe3823733badda67fe72a6fbf5dca9b017538a6 Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Wed, 1 May 2024 15:00:54 +0200 Subject: [PATCH 40/71] Added filter option all to extractResourceFile cmd #166 --- base/extract_resources.cfg | 128 ++++++++++++++++---------------- neo/framework/FileSystem.cpp | 23 +++++- neo/framework/File_Resource.cpp | 24 +++++- neo/framework/File_Resource.h | 2 +- 4 files changed, 108 insertions(+), 69 deletions(-) diff --git a/base/extract_resources.cfg b/base/extract_resources.cfg index 7c3e035376..3ff3fc5934 100644 --- a/base/extract_resources.cfg +++ b/base/extract_resources.cfg @@ -1,65 +1,65 @@ -extractResourceFile _common.resources basedev 1 -extractResourceFile _ordered.resources basedev 1 -extractResourceFile _sound_pc.resources basedev 1 -extractResourceFile _sound_pc_en.resources basedev 1 +extractResourceFile _common.resources baseref 1 +extractResourceFile _ordered.resources baseref 1 +extractResourceFile _sound_pc.resources baseref 1 +extractResourceFile _sound_pc_en.resources baseref 1 -extractResourceFile maps/admin.resources basedev 1 -extractResourceFile maps/alphalabs1.resources basedev 1 -extractResourceFile maps/alphalabs2.resources basedev 1 -extractResourceFile maps/alphalabs3.resources basedev 1 -extractResourceFile maps/alphalabs4.resources basedev 1 -extractResourceFile maps/caverns1.resources basedev 1 1 -extractResourceFile maps/caverns2.resources basedev 1 -extractResourceFile maps/comm1.resources basedev 1 -extractResourceFile maps/commoutside.resources basedev 1 -extractResourceFile maps/cpu.resources basedev 1 -extractResourceFile maps/cpuboss.resources basedev 1 -extractResourceFile maps/d3ctf1.resources basedev 1 -extractResourceFile maps/d3ctf2.resources basedev 1 -extractResourceFile maps/d3ctf3.resources basedev 1 -extractResourceFile maps/d3ctf4.resources basedev 1 -extractResourceFile maps/d3dm1.resources basedev 1 -extractResourceFile maps/d3dm2.resources basedev 1 -extractResourceFile maps/d3dm3.resources basedev 1 -extractResourceFile maps/d3dm4.resources basedev 1 -extractResourceFile maps/d3dm5.resources basedev 1 -extractResourceFile maps/d3xpdm1.resources basedev 1 -extractResourceFile maps/d3xpdm2.resources basedev 1 -extractResourceFile maps/d3xpdm3.resources basedev 1 -extractResourceFile maps/d3xpdm4.resources basedev 1 -extractResourceFile maps/delta1.resources basedev 1 -extractResourceFile maps/delta2a.resources basedev 1 -extractResourceFile maps/delta2b.resources basedev 1 -extractResourceFile maps/delta3.resources basedev 1 -extractResourceFile maps/delta4.resources basedev 1 -extractResourceFile maps/delta5.resources basedev 1 -extractResourceFile maps/deltax.resources basedev 1 -extractResourceFile maps/enpro.resources basedev 1 -extractResourceFile maps/erebus1.resources basedev 1 -extractResourceFile maps/erebus2.resources basedev 1 -extractResourceFile maps/erebus3.resources basedev 1 -extractResourceFile maps/erebus4.resources basedev 1 -extractResourceFile maps/erebus5.resources basedev 1 -extractResourceFile maps/erebus6.resources basedev 1 -extractResourceFile maps/hell.resources basedev 1 -extractResourceFile maps/hell1.resources basedev 1 -extractResourceFile maps/hellhole.resources basedev 1 -extractResourceFile maps/le_enpro1.resources basedev 1 -extractResourceFile maps/le_enpro2.resources basedev 1 -extractResourceFile maps/le_exis1.resources basedev 1 -extractResourceFile maps/le_exis2.resources basedev 1 -extractResourceFile maps/le_hell.resources basedev 1 -extractResourceFile maps/le_hell_post.resources basedev 1 -extractResourceFile maps/le_underground.resources basedev 1 -extractResourceFile maps/le_underground2.resources basedev 1 -extractResourceFile maps/mars_city1.resources basedev 1 -extractResourceFile maps/mars_city2.resources basedev 1 -extractResourceFile maps/mc_underground.resources basedev 1 -extractResourceFile maps/monorail.resources basedev 1 -extractResourceFile maps/phobos1.resources basedev 1 -extractResourceFile maps/phobos2.resources basedev 1 -extractResourceFile maps/phobos3.resources basedev 1 -extractResourceFile maps/phobos4.resources basedev 1 -extractResourceFile maps/recycling1.resources basedev 1 -extractResourceFile maps/recycling2.resources basedev 1 -extractResourceFile maps/site3.resources basedev 1 +extractResourceFile maps/admin.resources baseref 1 +extractResourceFile maps/alphalabs1.resources baseref 1 +extractResourceFile maps/alphalabs2.resources baseref 1 +extractResourceFile maps/alphalabs3.resources baseref 1 +extractResourceFile maps/alphalabs4.resources baseref 1 +extractResourceFile maps/caverns1.resources baseref 1 1 +extractResourceFile maps/caverns2.resources baseref 1 +extractResourceFile maps/comm1.resources baseref 1 +extractResourceFile maps/commoutside.resources baseref 1 +extractResourceFile maps/cpu.resources baseref 1 +extractResourceFile maps/cpuboss.resources baseref 1 +extractResourceFile maps/d3ctf1.resources baseref 1 +extractResourceFile maps/d3ctf2.resources baseref 1 +extractResourceFile maps/d3ctf3.resources baseref 1 +extractResourceFile maps/d3ctf4.resources baseref 1 +extractResourceFile maps/d3dm1.resources baseref 1 +extractResourceFile maps/d3dm2.resources baseref 1 +extractResourceFile maps/d3dm3.resources baseref 1 +extractResourceFile maps/d3dm4.resources baseref 1 +extractResourceFile maps/d3dm5.resources baseref 1 +extractResourceFile maps/d3xpdm1.resources baseref 1 +extractResourceFile maps/d3xpdm2.resources baseref 1 +extractResourceFile maps/d3xpdm3.resources baseref 1 +extractResourceFile maps/d3xpdm4.resources baseref 1 +extractResourceFile maps/delta1.resources baseref 1 +extractResourceFile maps/delta2a.resources baseref 1 +extractResourceFile maps/delta2b.resources baseref 1 +extractResourceFile maps/delta3.resources baseref 1 +extractResourceFile maps/delta4.resources baseref 1 +extractResourceFile maps/delta5.resources baseref 1 +extractResourceFile maps/deltax.resources baseref 1 +extractResourceFile maps/enpro.resources baseref 1 +extractResourceFile maps/erebus1.resources baseref 1 +extractResourceFile maps/erebus2.resources baseref 1 +extractResourceFile maps/erebus3.resources baseref 1 +extractResourceFile maps/erebus4.resources baseref 1 +extractResourceFile maps/erebus5.resources baseref 1 +extractResourceFile maps/erebus6.resources baseref 1 +extractResourceFile maps/hell.resources baseref 1 +extractResourceFile maps/hell1.resources baseref 1 +extractResourceFile maps/hellhole.resources baseref 1 +extractResourceFile maps/le_enpro1.resources baseref 1 +extractResourceFile maps/le_enpro2.resources baseref 1 +extractResourceFile maps/le_exis1.resources baseref 1 +extractResourceFile maps/le_exis2.resources baseref 1 +extractResourceFile maps/le_hell.resources baseref 1 +extractResourceFile maps/le_hell_post.resources baseref 1 +extractResourceFile maps/le_underground.resources baseref 1 +extractResourceFile maps/le_underground2.resources baseref 1 +extractResourceFile maps/mars_city1.resources baseref 1 +extractResourceFile maps/mars_city2.resources baseref 1 +extractResourceFile maps/mc_underground.resources baseref 1 +extractResourceFile maps/monorail.resources baseref 1 +extractResourceFile maps/phobos1.resources baseref 1 +extractResourceFile maps/phobos2.resources baseref 1 +extractResourceFile maps/phobos3.resources baseref 1 +extractResourceFile maps/phobos4.resources baseref 1 +extractResourceFile maps/recycling1.resources baseref 1 +extractResourceFile maps/recycling2.resources baseref 1 +extractResourceFile maps/site3.resources baseref 1 diff --git a/neo/framework/FileSystem.cpp b/neo/framework/FileSystem.cpp index 51d074b63a..2acacc362f 100644 --- a/neo/framework/FileSystem.cpp +++ b/neo/framework/FileSystem.cpp @@ -2656,14 +2656,31 @@ void idFileSystemLocal::ExtractResourceFile_f( const idCmdArgs& args ) { if( args.Argc() < 3 ) { - common->Printf( "Usage: extractResourceFile \n" ); + common->Printf( "Usage: extractResourceFile \n" ); return; } idStr filename = args.Argv( 1 ); idStr outPath = args.Argv( 2 ); - bool copyWaves = ( args.Argc() > 3 ); - idResourceContainer::ExtractResourceFile( filename, outPath, copyWaves ); + bool copyWaves = false; + bool allFileTypes = false; + + for( int i = 1; i < args.Argc(); i++ ) + { + idStr option = args.Argv( i ); + option.StripLeading( '-' ); + + if( option.Icmp( "copysound" ) == 0 ) + { + copyWaves = true; + } + else if( option.Icmp( "all" ) == 0 ) + { + allFileTypes = true; + } + } + + idResourceContainer::ExtractResourceFile( filename, outPath, copyWaves, allFileTypes ); } /* diff --git a/neo/framework/File_Resource.cpp b/neo/framework/File_Resource.cpp index 6d2dace649..243864c1b4 100644 --- a/neo/framework/File_Resource.cpp +++ b/neo/framework/File_Resource.cpp @@ -330,7 +330,7 @@ void idResourceContainer::SetContainerIndex( const int& _idx ) idResourceContainer::ExtractResourceFile ======================== */ -void idResourceContainer::ExtractResourceFile( const char* _fileName, const char* _outPath, bool _copyWavs ) +void idResourceContainer::ExtractResourceFile( const char* _fileName, const char* _outPath, bool _copyWavs, bool _all ) { idFile* inFile = fileSystem->OpenFileRead( _fileName ); @@ -368,8 +368,11 @@ void idResourceContainer::ExtractResourceFile( const char* _fileName, const char rt.filename.BackSlashesToSlashes(); rt.filename.ToLower(); byte* fbuf = NULL; + if( _copyWavs && ( rt.filename.Find( ".idwav" ) >= 0 || rt.filename.Find( ".idxma" ) >= 0 || rt.filename.Find( ".idmsf" ) >= 0 ) ) { + // TODO make this work #166 + rt.filename.SetFileExtension( "wav" ); rt.filename.Replace( "generated/", "" ); int len = fileSystem->GetFileLength( rt.filename ); @@ -378,10 +381,29 @@ void idResourceContainer::ExtractResourceFile( const char* _fileName, const char } else { + // RB: filter out all unwanted binary files + if( !_all && ( + rt.filename.IcmpPrefix( "renderprogs") == 0 || + rt.filename.IcmpPrefix( "generated") == 0 ) + /* + rt.filename.Find( ".bcmodel") >= 0 || + rt.filename.Find( ".bcanim") >= 0 || + rt.filename.Find( ".bmd5mesh") >= 0 || + rt.filename.Find( ".bmd5anim") >= 0 || + rt.filename.Find( ".bimage") >= 0 || + rt.filename.Find( ".base") >= 0 || + rt.filename.Find( ".blwo") >= 0 || + rt.filename.Find( ".bprt") >= 0 || + rt.filename.Find( ".bswf") >= 0 )*/ ) + { + continue; + } + inFile->Seek( rt.offset, FS_SEEK_SET ); fbuf = ( byte* )Mem_Alloc( rt.length, TAG_RESOURCE ); inFile->Read( fbuf, rt.length ); } + idStr outName = _outPath; outName.AppendPath( rt.filename ); idFile* outFile = fileSystem->OpenExplicitFileWrite( outName ); diff --git a/neo/framework/File_Resource.h b/neo/framework/File_Resource.h index d45b47bbc2..b85ce9a24c 100644 --- a/neo/framework/File_Resource.h +++ b/neo/framework/File_Resource.h @@ -95,7 +95,7 @@ class idResourceContainer static void WriteResourceFile( const char* fileName, const idStrList& manifest, const bool& _writeManifest ); static void WriteManifestFile( const char* name, const idStrList& list ); static int ReadManifestFile( const char* filename, idStrList& list ); - static void ExtractResourceFile( const char* fileName, const char* outPath, bool copyWavs ); + static void ExtractResourceFile( const char* fileName, const char* outPath, bool copyWavs, bool all ); static void UpdateResourceFile( const char* filename, const idStrList& filesToAdd ); idFile* OpenFile( const char* fileName ); const char* GetFileName() const From 6966fda77606c05a1c06f95926867d4cf40a2815 Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Wed, 1 May 2024 22:26:31 +0200 Subject: [PATCH 41/71] WIP .idwav -> .wav export code --- base/extract_resources.cfg | 128 ++++++++++++------------ neo/framework/File_Resource.cpp | 138 +++++++++++++++++++++----- neo/sound/WaveFile.cpp | 13 ++- neo/sound/WaveFile.h | 2 +- neo/sound/XAudio2/XA2_SoundSample.cpp | 2 +- 5 files changed, 188 insertions(+), 95 deletions(-) diff --git a/base/extract_resources.cfg b/base/extract_resources.cfg index 3ff3fc5934..dd0578387e 100644 --- a/base/extract_resources.cfg +++ b/base/extract_resources.cfg @@ -1,65 +1,65 @@ -extractResourceFile _common.resources baseref 1 -extractResourceFile _ordered.resources baseref 1 -extractResourceFile _sound_pc.resources baseref 1 -extractResourceFile _sound_pc_en.resources baseref 1 +extractResourceFile _common.resources baseref +extractResourceFile _ordered.resources baseref +extractResourceFile _sound_pc.resources baseref copysound +extractResourceFile _sound_pc_en.resources baseref copysound -extractResourceFile maps/admin.resources baseref 1 -extractResourceFile maps/alphalabs1.resources baseref 1 -extractResourceFile maps/alphalabs2.resources baseref 1 -extractResourceFile maps/alphalabs3.resources baseref 1 -extractResourceFile maps/alphalabs4.resources baseref 1 -extractResourceFile maps/caverns1.resources baseref 1 1 -extractResourceFile maps/caverns2.resources baseref 1 -extractResourceFile maps/comm1.resources baseref 1 -extractResourceFile maps/commoutside.resources baseref 1 -extractResourceFile maps/cpu.resources baseref 1 -extractResourceFile maps/cpuboss.resources baseref 1 -extractResourceFile maps/d3ctf1.resources baseref 1 -extractResourceFile maps/d3ctf2.resources baseref 1 -extractResourceFile maps/d3ctf3.resources baseref 1 -extractResourceFile maps/d3ctf4.resources baseref 1 -extractResourceFile maps/d3dm1.resources baseref 1 -extractResourceFile maps/d3dm2.resources baseref 1 -extractResourceFile maps/d3dm3.resources baseref 1 -extractResourceFile maps/d3dm4.resources baseref 1 -extractResourceFile maps/d3dm5.resources baseref 1 -extractResourceFile maps/d3xpdm1.resources baseref 1 -extractResourceFile maps/d3xpdm2.resources baseref 1 -extractResourceFile maps/d3xpdm3.resources baseref 1 -extractResourceFile maps/d3xpdm4.resources baseref 1 -extractResourceFile maps/delta1.resources baseref 1 -extractResourceFile maps/delta2a.resources baseref 1 -extractResourceFile maps/delta2b.resources baseref 1 -extractResourceFile maps/delta3.resources baseref 1 -extractResourceFile maps/delta4.resources baseref 1 -extractResourceFile maps/delta5.resources baseref 1 -extractResourceFile maps/deltax.resources baseref 1 -extractResourceFile maps/enpro.resources baseref 1 -extractResourceFile maps/erebus1.resources baseref 1 -extractResourceFile maps/erebus2.resources baseref 1 -extractResourceFile maps/erebus3.resources baseref 1 -extractResourceFile maps/erebus4.resources baseref 1 -extractResourceFile maps/erebus5.resources baseref 1 -extractResourceFile maps/erebus6.resources baseref 1 -extractResourceFile maps/hell.resources baseref 1 -extractResourceFile maps/hell1.resources baseref 1 -extractResourceFile maps/hellhole.resources baseref 1 -extractResourceFile maps/le_enpro1.resources baseref 1 -extractResourceFile maps/le_enpro2.resources baseref 1 -extractResourceFile maps/le_exis1.resources baseref 1 -extractResourceFile maps/le_exis2.resources baseref 1 -extractResourceFile maps/le_hell.resources baseref 1 -extractResourceFile maps/le_hell_post.resources baseref 1 -extractResourceFile maps/le_underground.resources baseref 1 -extractResourceFile maps/le_underground2.resources baseref 1 -extractResourceFile maps/mars_city1.resources baseref 1 -extractResourceFile maps/mars_city2.resources baseref 1 -extractResourceFile maps/mc_underground.resources baseref 1 -extractResourceFile maps/monorail.resources baseref 1 -extractResourceFile maps/phobos1.resources baseref 1 -extractResourceFile maps/phobos2.resources baseref 1 -extractResourceFile maps/phobos3.resources baseref 1 -extractResourceFile maps/phobos4.resources baseref 1 -extractResourceFile maps/recycling1.resources baseref 1 -extractResourceFile maps/recycling2.resources baseref 1 -extractResourceFile maps/site3.resources baseref 1 +extractResourceFile maps/admin.resources baseref +extractResourceFile maps/alphalabs1.resources baseref +extractResourceFile maps/alphalabs2.resources baseref +extractResourceFile maps/alphalabs3.resources baseref +extractResourceFile maps/alphalabs4.resources baseref +extractResourceFile maps/caverns1.resources baseref 1 +extractResourceFile maps/caverns2.resources baseref +extractResourceFile maps/comm1.resources baseref +extractResourceFile maps/commoutside.resources baseref +extractResourceFile maps/cpu.resources baseref +extractResourceFile maps/cpuboss.resources baseref +extractResourceFile maps/d3ctf1.resources baseref +extractResourceFile maps/d3ctf2.resources baseref +extractResourceFile maps/d3ctf3.resources baseref +extractResourceFile maps/d3ctf4.resources baseref +extractResourceFile maps/d3dm1.resources baseref +extractResourceFile maps/d3dm2.resources baseref +extractResourceFile maps/d3dm3.resources baseref +extractResourceFile maps/d3dm4.resources baseref +extractResourceFile maps/d3dm5.resources baseref +extractResourceFile maps/d3xpdm1.resources baseref +extractResourceFile maps/d3xpdm2.resources baseref +extractResourceFile maps/d3xpdm3.resources baseref +extractResourceFile maps/d3xpdm4.resources baseref +extractResourceFile maps/delta1.resources baseref +extractResourceFile maps/delta2a.resources baseref +extractResourceFile maps/delta2b.resources baseref +extractResourceFile maps/delta3.resources baseref +extractResourceFile maps/delta4.resources baseref +extractResourceFile maps/delta5.resources baseref +extractResourceFile maps/deltax.resources baseref +extractResourceFile maps/enpro.resources baseref +extractResourceFile maps/erebus1.resources baseref +extractResourceFile maps/erebus2.resources baseref +extractResourceFile maps/erebus3.resources baseref +extractResourceFile maps/erebus4.resources baseref +extractResourceFile maps/erebus5.resources baseref +extractResourceFile maps/erebus6.resources baseref +extractResourceFile maps/hell.resources baseref +extractResourceFile maps/hell1.resources baseref +extractResourceFile maps/hellhole.resources baseref +extractResourceFile maps/le_enpro1.resources baseref +extractResourceFile maps/le_enpro2.resources baseref +extractResourceFile maps/le_exis1.resources baseref +extractResourceFile maps/le_exis2.resources baseref +extractResourceFile maps/le_hell.resources baseref +extractResourceFile maps/le_hell_post.resources baseref +extractResourceFile maps/le_underground.resources baseref +extractResourceFile maps/le_underground2.resources baseref +extractResourceFile maps/mars_city1.resources baseref +extractResourceFile maps/mars_city2.resources baseref +extractResourceFile maps/mc_underground.resources baseref +extractResourceFile maps/monorail.resources baseref +extractResourceFile maps/phobos1.resources baseref +extractResourceFile maps/phobos2.resources baseref +extractResourceFile maps/phobos3.resources baseref +extractResourceFile maps/phobos4.resources baseref +extractResourceFile maps/recycling1.resources baseref +extractResourceFile maps/recycling2.resources baseref +extractResourceFile maps/site3.resources baseref diff --git a/neo/framework/File_Resource.cpp b/neo/framework/File_Resource.cpp index 243864c1b4..48fbe0d70a 100644 --- a/neo/framework/File_Resource.cpp +++ b/neo/framework/File_Resource.cpp @@ -330,6 +330,8 @@ void idResourceContainer::SetContainerIndex( const int& _idx ) idResourceContainer::ExtractResourceFile ======================== */ +#include "../sound/WaveFile.h" + void idResourceContainer::ExtractResourceFile( const char* _fileName, const char* _outPath, bool _copyWavs, bool _all ) { idFile* inFile = fileSystem->OpenFileRead( _fileName ); @@ -368,33 +370,113 @@ void idResourceContainer::ExtractResourceFile( const char* _fileName, const char rt.filename.BackSlashesToSlashes(); rt.filename.ToLower(); byte* fbuf = NULL; - + if( _copyWavs && ( rt.filename.Find( ".idwav" ) >= 0 || rt.filename.Find( ".idxma" ) >= 0 || rt.filename.Find( ".idmsf" ) >= 0 ) ) { // TODO make this work #166 - rt.filename.SetFileExtension( "wav" ); - rt.filename.Replace( "generated/", "" ); + //rt.filename.SetFileExtension( "wav" ); + //rt.filename.Replace( "generated/", "" ); int len = fileSystem->GetFileLength( rt.filename ); - fbuf = ( byte* )Mem_Alloc( len, TAG_RESOURCE ); - fileSystem->ReadFile( rt.filename, ( void** )&fbuf, NULL ); + //fbuf = ( byte* )Mem_Alloc( len, TAG_RESOURCE ); + //fileSystem->ReadFile( rt.filename, ( void** )&fbuf, NULL ); + + idFileLocal fileIn( fileSystem->OpenFileReadMemory( rt.filename ) ); + if( fileIn != NULL ) + { + struct sampleBuffer_t + { + void* buffer; + int bufferSize; + int numSamples; + }; + + ID_TIME_T timestamp; + bool loaded; + int playBegin; + int playLength; + idWaveFile::waveFmt_t format; + idList amplitude; + int totalBufferSize; + idList buffers; + + uint32 magic; + fileIn->ReadBig( magic ); + fileIn->ReadBig( timestamp ); + fileIn->ReadBig( loaded ); + fileIn->ReadBig( playBegin ); + fileIn->ReadBig( playLength ); + idWaveFile::ReadWaveFormatDirect( format, fileIn ); + + int num; + fileIn->ReadBig( num ); + amplitude.Clear(); + amplitude.SetNum( num ); + + fileIn->Read( amplitude.Ptr(), amplitude.Num() ); + + fileIn->ReadBig( totalBufferSize ); + fileIn->ReadBig( num ); + buffers.SetNum( num ); + + for( int i = 0; i < num; i++ ) + { + fileIn->ReadBig( buffers[ i ].numSamples ); + fileIn->ReadBig( buffers[ i ].bufferSize ); + buffers[ i ].buffer = Mem_Alloc( buffers[ i ].bufferSize, TAG_AUDIO ); + fileIn->Read( buffers[ i ].buffer, buffers[ i ].bufferSize ); + //buffers[ i ].buffer = GPU_CONVERT_CPU_TO_CPU_CACHED_READONLY_ADDRESS( buffers[ i ].buffer ); + } + + // write it as .wav file + if( format.basic.formatTag == idWaveFile::FORMAT_ADPCM ) + { + rt.filename.SetFileExtension( "wav" ); + rt.filename.Replace( "generated/", "" ); + + idStr outName = _outPath; + outName.AppendPath( rt.filename ); + idFileLocal fileOut( fileSystem->OpenExplicitFileWrite( outName ) ); + if( fileOut != NULL ) + { + common->Printf( "writing %s\n", outName.c_str() ); + + uint32 fileSize = 12 + 24 + format.extraSize + 4 + totalBufferSize; + fileSize -= 8; + + idWaveFile::WriteHeaderDirect( fileSize, fileOut ); + idWaveFile::WriteWaveFormatDirect( format, fileOut, true ); + idWaveFile::WriteDataDirect( ( char* ) buffers[ 0 ].buffer, totalBufferSize, fileOut ); + } + } + + for( int i = 0; i < num; i++ ) + { + Mem_Free( buffers[ i ].buffer ); + } + + // just export the first file for testing + delete inFile; + Mem_Free( buf ); + return; + } } else { // RB: filter out all unwanted binary files if( !_all && ( - rt.filename.IcmpPrefix( "renderprogs") == 0 || - rt.filename.IcmpPrefix( "generated") == 0 ) - /* - rt.filename.Find( ".bcmodel") >= 0 || - rt.filename.Find( ".bcanim") >= 0 || - rt.filename.Find( ".bmd5mesh") >= 0 || - rt.filename.Find( ".bmd5anim") >= 0 || - rt.filename.Find( ".bimage") >= 0 || - rt.filename.Find( ".base") >= 0 || - rt.filename.Find( ".blwo") >= 0 || - rt.filename.Find( ".bprt") >= 0 || - rt.filename.Find( ".bswf") >= 0 )*/ ) + rt.filename.IcmpPrefix( "renderprogs" ) == 0 || + rt.filename.IcmpPrefix( "generated" ) == 0 ) + /* + rt.filename.Find( ".bcmodel") >= 0 || + rt.filename.Find( ".bcanim") >= 0 || + rt.filename.Find( ".bmd5mesh") >= 0 || + rt.filename.Find( ".bmd5anim") >= 0 || + rt.filename.Find( ".bimage") >= 0 || + rt.filename.Find( ".base") >= 0 || + rt.filename.Find( ".blwo") >= 0 || + rt.filename.Find( ".bprt") >= 0 || + rt.filename.Find( ".bswf") >= 0 )*/ ) { continue; } @@ -402,17 +484,19 @@ void idResourceContainer::ExtractResourceFile( const char* _fileName, const char inFile->Seek( rt.offset, FS_SEEK_SET ); fbuf = ( byte* )Mem_Alloc( rt.length, TAG_RESOURCE ); inFile->Read( fbuf, rt.length ); + + idStr outName = _outPath; + outName.AppendPath( rt.filename ); + idFile* outFile = fileSystem->OpenExplicitFileWrite( outName ); + if( outFile != NULL ) + { + outFile->Write( ( byte* )fbuf, rt.length ); + delete outFile; + } + Mem_Free( fbuf ); } - - idStr outName = _outPath; - outName.AppendPath( rt.filename ); - idFile* outFile = fileSystem->OpenExplicitFileWrite( outName ); - if( outFile != NULL ) - { - outFile->Write( ( byte* )fbuf, rt.length ); - delete outFile; - } - Mem_Free( fbuf ); + + } delete inFile; Mem_Free( buf ); diff --git a/neo/sound/WaveFile.cpp b/neo/sound/WaveFile.cpp index 1225e70231..bd1402c2b2 100644 --- a/neo/sound/WaveFile.cpp +++ b/neo/sound/WaveFile.cpp @@ -417,7 +417,7 @@ idWaveFile::WriteWaveFormatDirect Writes a wave format header to a file ptr, ======================== */ -bool idWaveFile::WriteWaveFormatDirect( waveFmt_t& format, idFile* file ) +bool idWaveFile::WriteWaveFormatDirect( waveFmt_t& format, idFile* file, bool wavFile ) { //idSwapClass swap; //swap.Little( format.basic.formatTag ); @@ -426,6 +426,15 @@ bool idWaveFile::WriteWaveFormatDirect( waveFmt_t& format, idFile* file ) //swap.Little( format.basic.avgBytesPerSec ); //swap.Little( format.basic.blockSize ); //swap.Little( format.basic.bitsPerSample ); + + // RB begin + if( wavFile ) + { + file->WriteBig( format.id ); + file->WriteUnsignedInt( sizeof( format.basic ) ); + } + // RB end + file->Write( &format.basic, sizeof( format.basic ) ); if( format.basic.formatTag == FORMAT_PCM ) { @@ -526,7 +535,7 @@ bool idWaveFile::WriteHeaderDirect( uint32 fileSize, idFile* file ) static const uint32 riff = 'RIFF'; static const uint32 wave = 'WAVE'; file->WriteBig( riff ); - file->WriteBig( fileSize ); + file->WriteUnsignedInt( fileSize ); file->WriteBig( wave ); return true; } diff --git a/neo/sound/WaveFile.h b/neo/sound/WaveFile.h index 6681ac0e3e..d99e482318 100644 --- a/neo/sound/WaveFile.h +++ b/neo/sound/WaveFile.h @@ -220,7 +220,7 @@ class idWaveFile const char* ReadWaveFormat( waveFmt_t& waveFmt ); static bool ReadWaveFormatDirect( waveFmt_t& format, idFile* file ); - static bool WriteWaveFormatDirect( waveFmt_t& format, idFile* file ); + static bool WriteWaveFormatDirect( waveFmt_t& format, idFile* file, bool wavFile ); static bool WriteSampleDataDirect( idList< sampleData_t >& sampleData, idFile* file ); static bool WriteDataDirect( char* _data, uint32 size, idFile* file ); static bool WriteHeaderDirect( uint32 fileSize, idFile* file ); diff --git a/neo/sound/XAudio2/XA2_SoundSample.cpp b/neo/sound/XAudio2/XA2_SoundSample.cpp index f63ef05cce..7390efdfc0 100644 --- a/neo/sound/XAudio2/XA2_SoundSample.cpp +++ b/neo/sound/XAudio2/XA2_SoundSample.cpp @@ -102,7 +102,7 @@ void idSoundSample_XAudio2::WriteGeneratedSample( idFile* fileOut ) fileOut->WriteBig( loaded ); fileOut->WriteBig( playBegin ); fileOut->WriteBig( playLength ); - idWaveFile::WriteWaveFormatDirect( format, fileOut ); + idWaveFile::WriteWaveFormatDirect( format, fileOut, false ); fileOut->WriteBig( ( int )amplitude.Num() ); fileOut->Write( amplitude.Ptr(), amplitude.Num() ); fileOut->WriteBig( totalBufferSize ); From 33b74a7b25542b2a66d69e1c63e69ec9a1986ae8 Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Thu, 2 May 2024 19:48:14 +0200 Subject: [PATCH 42/71] extractResourceFiles can export .wav files. closes #166 --- base/extract_resources.cfg | 1 + neo/cmake-vs2019-openal.bat | 2 +- neo/framework/File_Resource.cpp | 36 ++++++++++++++--------------- neo/sound/OpenAL/AL_SoundSample.cpp | 2 +- neo/sound/WaveFile.cpp | 16 ++++++++++--- 5 files changed, 34 insertions(+), 23 deletions(-) diff --git a/base/extract_resources.cfg b/base/extract_resources.cfg index dd0578387e..d50734390e 100644 --- a/base/extract_resources.cfg +++ b/base/extract_resources.cfg @@ -2,6 +2,7 @@ extractResourceFile _common.resources baseref extractResourceFile _ordered.resources baseref extractResourceFile _sound_pc.resources baseref copysound extractResourceFile _sound_pc_en.resources baseref copysound +extractResourceFile _sound_pc_gr.resources baseref copysound extractResourceFile maps/admin.resources baseref extractResourceFile maps/alphalabs1.resources baseref diff --git a/neo/cmake-vs2019-openal.bat b/neo/cmake-vs2019-openal.bat index 5af677a027..219191861f 100644 --- a/neo/cmake-vs2019-openal.bat +++ b/neo/cmake-vs2019-openal.bat @@ -2,5 +2,5 @@ cd .. del /s /q build mkdir build cd build -cmake -G "Visual Studio 16" -A x64 -DUSE_OPENAL=ON ../neo +cmake -G "Visual Studio 16" -A x64 -DOPENAL=ON ../neo pause \ No newline at end of file diff --git a/neo/framework/File_Resource.cpp b/neo/framework/File_Resource.cpp index 48fbe0d70a..d0e68339c8 100644 --- a/neo/framework/File_Resource.cpp +++ b/neo/framework/File_Resource.cpp @@ -3,6 +3,7 @@ Doom 3 BFG Edition GPL Source Code Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 2024 Robert Beckebans This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). @@ -29,6 +30,9 @@ If you have questions concerning this license or the applicable additional terms #include "precompiled.h" #pragma hdrstop +#include "../sound/WaveFile.h" +#include "../renderer/CmdlineProgressbar.h" + /* ================================================================================================ @@ -330,8 +334,6 @@ void idResourceContainer::SetContainerIndex( const int& _idx ) idResourceContainer::ExtractResourceFile ======================== */ -#include "../sound/WaveFile.h" - void idResourceContainer::ExtractResourceFile( const char* _fileName, const char* _outPath, bool _copyWavs, bool _all ) { idFile* inFile = fileSystem->OpenFileRead( _fileName ); @@ -350,6 +352,8 @@ void idResourceContainer::ExtractResourceFile( const char* _fileName, const char return; } + common->Printf( "extracting resource file %s\n", _fileName ); + int _tableOffset; int _tableLength; inFile->ReadBig( _tableOffset ); @@ -363,6 +367,12 @@ void idResourceContainer::ExtractResourceFile( const char* _fileName, const char int _numFileResources; memFile.ReadBig( _numFileResources ); + CommandlineProgressBar progressBar( _numFileResources, renderSystem->GetWidth(), renderSystem->GetHeight() ); + if( _copyWavs ) + { + progressBar.Start(); + } + for( int i = 0; i < _numFileResources; i++ ) { idResourceCacheEntry rt; @@ -373,14 +383,6 @@ void idResourceContainer::ExtractResourceFile( const char* _fileName, const char if( _copyWavs && ( rt.filename.Find( ".idwav" ) >= 0 || rt.filename.Find( ".idxma" ) >= 0 || rt.filename.Find( ".idmsf" ) >= 0 ) ) { - // TODO make this work #166 - - //rt.filename.SetFileExtension( "wav" ); - //rt.filename.Replace( "generated/", "" ); - int len = fileSystem->GetFileLength( rt.filename ); - //fbuf = ( byte* )Mem_Alloc( len, TAG_RESOURCE ); - //fileSystem->ReadFile( rt.filename, ( void** )&fbuf, NULL ); - idFileLocal fileIn( fileSystem->OpenFileReadMemory( rt.filename ) ); if( fileIn != NULL ) { @@ -439,9 +441,9 @@ void idResourceContainer::ExtractResourceFile( const char* _fileName, const char idFileLocal fileOut( fileSystem->OpenExplicitFileWrite( outName ) ); if( fileOut != NULL ) { - common->Printf( "writing %s\n", outName.c_str() ); + //common->Printf( "writing %s\n", outName.c_str() ); - uint32 fileSize = 12 + 24 + format.extraSize + 4 + totalBufferSize; + uint32 fileSize = 12 + 24 + 2 + format.extraSize + 8 + totalBufferSize; fileSize -= 8; idWaveFile::WriteHeaderDirect( fileSize, fileOut ); @@ -454,11 +456,6 @@ void idResourceContainer::ExtractResourceFile( const char* _fileName, const char { Mem_Free( buffers[ i ].buffer ); } - - // just export the first file for testing - delete inFile; - Mem_Free( buf ); - return; } } else @@ -496,7 +493,10 @@ void idResourceContainer::ExtractResourceFile( const char* _fileName, const char Mem_Free( fbuf ); } - + if( _copyWavs ) + { + progressBar.Increment( true ); + } } delete inFile; Mem_Free( buf ); diff --git a/neo/sound/OpenAL/AL_SoundSample.cpp b/neo/sound/OpenAL/AL_SoundSample.cpp index 369cbf0818..b4bbee227c 100644 --- a/neo/sound/OpenAL/AL_SoundSample.cpp +++ b/neo/sound/OpenAL/AL_SoundSample.cpp @@ -107,7 +107,7 @@ void idSoundSample_OpenAL::WriteGeneratedSample( idFile* fileOut ) fileOut->WriteBig( loaded ); fileOut->WriteBig( playBegin ); fileOut->WriteBig( playLength ); - idWaveFile::WriteWaveFormatDirect( format, fileOut ); + idWaveFile::WriteWaveFormatDirect( format, fileOut, false ); fileOut->WriteBig( ( int )amplitude.Num() ); fileOut->Write( amplitude.Ptr(), amplitude.Num() ); fileOut->WriteBig( totalBufferSize ); diff --git a/neo/sound/WaveFile.cpp b/neo/sound/WaveFile.cpp index bd1402c2b2..1e15cc3818 100644 --- a/neo/sound/WaveFile.cpp +++ b/neo/sound/WaveFile.cpp @@ -427,11 +427,19 @@ bool idWaveFile::WriteWaveFormatDirect( waveFmt_t& format, idFile* file, bool wa //swap.Little( format.basic.blockSize ); //swap.Little( format.basic.bitsPerSample ); - // RB begin + // RB: this is also called by .idwav saving code and it was missing if( wavFile ) { file->WriteBig( format.id ); - file->WriteUnsignedInt( sizeof( format.basic ) ); + + if( format.basic.formatTag != FORMAT_PCM ) + { + file->WriteUnsignedInt( sizeof( format.basic ) + 2 + format.extraSize ); + } + else + { + file->WriteUnsignedInt( sizeof( format.basic ) ); + } } // RB end @@ -462,6 +470,7 @@ bool idWaveFile::WriteWaveFormatDirect( waveFmt_t& format, idFile* file, bool wa { return false; } + return true; } @@ -518,7 +527,8 @@ bool idWaveFile::WriteDataDirect( char* _data, uint32 size, idFile* file ) static const uint32 data = 'data'; file->WriteBig( data ); file->Write( &size, sizeof( uint32 ) ); - file->WriteBigArray( _data, size ); + //file->WriteBigArray( _data, size ); // RB: this is super slow + file->Write( _data, size ); return true; } From 4a374f9091709716a54865fe58258b0115ebb55c Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Fri, 10 May 2024 09:52:32 +0200 Subject: [PATCH 43/71] Fixed clang, gcc compile errors with newer versions #885 --- neo/sound/WaveFile.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/neo/sound/WaveFile.cpp b/neo/sound/WaveFile.cpp index 1e15cc3818..666ee9159b 100644 --- a/neo/sound/WaveFile.cpp +++ b/neo/sound/WaveFile.cpp @@ -430,7 +430,8 @@ bool idWaveFile::WriteWaveFormatDirect( waveFmt_t& format, idFile* file, bool wa // RB: this is also called by .idwav saving code and it was missing if( wavFile ) { - file->WriteBig( format.id ); + static const uint32 id = 'fmt '; + file->WriteBig( id ); if( format.basic.formatTag != FORMAT_PCM ) { From 0a438ad614184de9de5ed0127a2c3ae072fb8acb Mon Sep 17 00:00:00 2001 From: SRSaunders <82544213+SRSaunders@users.noreply.github.com> Date: Wed, 8 May 2024 18:12:11 -0400 Subject: [PATCH 44/71] Remove unneeded VkPhysicalDeviceBufferAddressFeaturesEXT from CreateDevice() pNext chain --- neo/sys/DeviceManager_VK.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/neo/sys/DeviceManager_VK.cpp b/neo/sys/DeviceManager_VK.cpp index 2dc0b6ef6e..522fdaca0a 100644 --- a/neo/sys/DeviceManager_VK.cpp +++ b/neo/sys/DeviceManager_VK.cpp @@ -948,8 +948,6 @@ bool DeviceManager_VK::createDevice() auto accelStructFeatures = vk::PhysicalDeviceAccelerationStructureFeaturesKHR() .setAccelerationStructure( true ); - auto bufferAddressFeatures = vk::PhysicalDeviceBufferAddressFeaturesEXT() - .setBufferDeviceAddress( true ); auto rayPipelineFeatures = vk::PhysicalDeviceRayTracingPipelineFeaturesKHR() .setRayTracingPipeline( true ) .setRayTraversalPrimitiveCulling( true ); @@ -986,7 +984,6 @@ bool DeviceManager_VK::createDevice() #endif #define APPEND_EXTENSION(condition, desc) if (condition) { (desc).pNext = pNext; pNext = &(desc); } // NOLINT(cppcoreguidelines-macro-usage) APPEND_EXTENSION( accelStructSupported, accelStructFeatures ) - APPEND_EXTENSION( bufferAddressSupported, bufferAddressFeatures ) APPEND_EXTENSION( rayPipelineSupported, rayPipelineFeatures ) APPEND_EXTENSION( rayQuerySupported, rayQueryFeatures ) APPEND_EXTENSION( meshletsSupported, meshletFeatures ) From 01768625817a6b7326190751665baf1092fe632f Mon Sep 17 00:00:00 2001 From: SRSaunders <82544213+SRSaunders@users.noreply.github.com> Date: Wed, 8 May 2024 18:17:47 -0400 Subject: [PATCH 45/71] Remove VK_EXT_debug_utils and enable VK_EXT_debug_marker only when debugging --- neo/sys/DeviceManager_VK.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/neo/sys/DeviceManager_VK.cpp b/neo/sys/DeviceManager_VK.cpp index 522fdaca0a..5c76556592 100644 --- a/neo/sys/DeviceManager_VK.cpp +++ b/neo/sys/DeviceManager_VK.cpp @@ -252,14 +252,12 @@ class DeviceManager_VK : public DeviceManager VK_EXT_LAYER_SETTINGS_EXTENSION_NAME, #endif #endif - VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME, - VK_EXT_DEBUG_UTILS_EXTENSION_NAME + VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME }, // layers { }, // device { - VK_EXT_DEBUG_MARKER_EXTENSION_NAME, VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME, VK_NV_MESH_SHADER_EXTENSION_NAME, @@ -1244,6 +1242,7 @@ bool DeviceManager_VK::CreateDeviceAndSwapChain() if( m_DeviceParams.enableDebugRuntime ) { enabledExtensions.instance.insert( VK_EXT_DEBUG_REPORT_EXTENSION_NAME ); + optionalExtensions.device.insert( VK_EXT_DEBUG_MARKER_EXTENSION_NAME ); #if defined(__APPLE__) && defined( USE_MoltenVK ) } From 30f92b8103565b5187d073176028dc96e53192e5 Mon Sep 17 00:00:00 2001 From: Stephen Saunders Date: Fri, 10 May 2024 11:54:43 -0400 Subject: [PATCH 46/71] Suppress Vulkan [Shader-OutputNotConsumed] validation layer message since by design --- neo/sys/DeviceManager_VK.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/neo/sys/DeviceManager_VK.cpp b/neo/sys/DeviceManager_VK.cpp index 5c76556592..13ab8d7b8e 100644 --- a/neo/sys/DeviceManager_VK.cpp +++ b/neo/sys/DeviceManager_VK.cpp @@ -1250,6 +1250,13 @@ bool DeviceManager_VK::CreateDeviceAndSwapChain() static const vk::DynamicLoader dl( "libMoltenVK.dylib" ); #else enabledExtensions.layers.insert( "VK_LAYER_KHRONOS_validation" ); + + // SRS - Suppress WARNING-Shader-OutputNotConsumed: by design for vertex shader layouts + #ifdef _WIN32 + SetEnvironmentVariable( "VK_LAYER_MESSAGE_ID_FILTER", "0xc81ad50e" ); + #else + setenv( "VK_LAYER_MESSAGE_ID_FILTER", "0xc81ad50e", 1 ); + #endif } // SRS - make static so ~DynamicLoader() does not prematurely unload vulkan dynamic lib From 23adc49344530aea8e8738106916bd576b9224e6 Mon Sep 17 00:00:00 2001 From: Stephen Saunders Date: Fri, 10 May 2024 11:55:14 -0400 Subject: [PATCH 47/71] Suppress DX12 [RESOURCE_BARRIER_BEFORE_AFTER_MISMATCH] error caused by cinematics --- neo/sys/DeviceManager_DX12.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/neo/sys/DeviceManager_DX12.cpp b/neo/sys/DeviceManager_DX12.cpp index 4669a3af9d..ff15e67b56 100644 --- a/neo/sys/DeviceManager_DX12.cpp +++ b/neo/sys/DeviceManager_DX12.cpp @@ -382,7 +382,9 @@ bool DeviceManager_DX12::CreateDeviceAndSwapChain() D3D12_MESSAGE_ID disableMessageIDs[] = { D3D12_MESSAGE_ID_CLEARDEPTHSTENCILVIEW_MISMATCHINGCLEARVALUE, + D3D12_MESSAGE_ID_CLEARRENDERTARGETVIEW_MISMATCHINGCLEARVALUE, D3D12_MESSAGE_ID_COMMAND_LIST_STATIC_DESCRIPTOR_RESOURCE_DIMENSION_MISMATCH, // descriptor validation doesn't understand acceleration structures + D3D12_MESSAGE_ID_RESOURCE_BARRIER_BEFORE_AFTER_MISMATCH // barrier validation error caused by cinematics - not sure how to fix, suppress for now }; D3D12_INFO_QUEUE_FILTER filter = {}; From 41f8a22f2345b925fd21cd744cc681ee8608418f Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Fri, 10 May 2024 21:34:49 +0200 Subject: [PATCH 48/71] Split lights with brushes/patches into light groups for TrenchBroom #825 --- neo/d3xp/Game_local.cpp | 3 +- neo/idlib/MapFile.cpp | 150 ++++++++++++++++++++++++++++++++++++---- 2 files changed, 138 insertions(+), 15 deletions(-) diff --git a/neo/d3xp/Game_local.cpp b/neo/d3xp/Game_local.cpp index 7f6057cdd9..7dbe47135a 100644 --- a/neo/d3xp/Game_local.cpp +++ b/neo/d3xp/Game_local.cpp @@ -3979,7 +3979,6 @@ idGameLocal::InhibitEntitySpawn */ bool idGameLocal::InhibitEntitySpawn( idDict& spawnArgs ) { - bool result = false; if( common->IsMultiplayer() ) @@ -4024,7 +4023,7 @@ bool idGameLocal::InhibitEntitySpawn( idDict& spawnArgs ) } } - // RB: TrenchBroom interop skip func_group entities + // RB: TrenchBroom interop skip func_group helper entities { const char* name = spawnArgs.GetString( "classname" ); const char* groupType = spawnArgs.GetString( "_tb_type" ); diff --git a/neo/idlib/MapFile.cpp b/neo/idlib/MapFile.cpp index 581516a52d..e40605c199 100644 --- a/neo/idlib/MapFile.cpp +++ b/neo/idlib/MapFile.cpp @@ -1714,7 +1714,6 @@ bool idMapFile::Parse( const char* filename, bool ignoreRegion, bool osPath ) // if the map has a worldspawn if( entities.Num() ) { - // "removeEntities" "classname" can be set in the worldspawn to remove all entities with the given classname const idKeyValue* removeEntities = entities[0]->epairs.MatchPrefix( "removeEntities", NULL ); while( removeEntities ) @@ -2914,6 +2913,32 @@ bool idMapFile::ConvertToValve220Format() idDict classTypeOverview; idStrList textureCollections; + int tbGroupID = 7; + + // just an idea but we can assume that we have no TB groups in the file + // because we are calling this command for the original Doom 3 BFG .map files + /* + idList tbGroupIDs; + + // collect TrenchBroom group IDs + for( int j = 0; j < count; j++ ) + { + idMapEntity* ent = GetEntity( j ); + if( ent ) + { + //idStr classname = ent->epairs.GetString( "classname" ); + const char* name = ent->epairs.GetString( "classname" ); + const char* groupType = ent->epairs.GetString( "_tb_type" ); + + if( idStr::Icmp( name, "func_group" ) == 0 && ( idStr::Icmp( groupType, "_tb_group" ) == 0 || idStr::Icmp( groupType, "_tb_layer" ) == 0 ) ) + { + int id = ent->epairs.GetInt( "_tb_id", -1 ); + tbGroupIDs.AddUnique( id ); + } + } + } + */ + int count = GetNumEntities(); for( int j = 0; j < count; j++ ) { @@ -2967,8 +2992,9 @@ bool idMapFile::ConvertToValve220Format() const idKeyValue* modelPair = ent->epairs.FindKey( "model" ); idStr model = ent->epairs.GetString( "model" ); -#if 1 + // HACK: convert every old .lwo, .ase model to an .obj proxy model so it can be displayed properly in TrenchBroom + // this wouldn't be necessary for Doom 3 but it is for the BFG edition idStr ext; model.ExtractFileExtension( ext ); @@ -2979,17 +3005,122 @@ bool idMapFile::ConvertToValve220Format() ent->epairs.Set( "proxymodel", model ); } -#endif bool isBrushModel = ( ent->GetNumPrimitives() > 0 ) && ( idStr::Icmp( model.c_str(), name.c_str() ) == 0 ); + bool isLight = idStr::Icmp( classname, "light" ) == 0; // is this oldschool brushes & patches? if( isBrushModel ) { + if( isLight ) + { + // we need to split this up into several entities + // turn this entity into a func_static and create a separate light and func_group entity + + auto lightEnt = new( TAG_SYSTEM ) idMapEntity(); + entities.Append( lightEnt ); + + // don't grab brushes or polys + lightEnt->epairs.Copy( ent->epairs ); + + // we can expect "light_origin" and "light_rotation" at this point from DoomEdit + // replace them with "origin" and "angles" + { + idAngles angles; + idMat3 mat; + if( !ent->epairs.GetMatrix( "light_rotation", "1 0 0 0 1 0 0 0 1", mat ) ) + { + if( !ent->epairs.GetMatrix( "rotation", "1 0 0 0 1 0 0 0 1", mat ) ) + { + // RB: light_angles is specific for lights that have been modified by the editLights command + // these lights have a static model and are not proper grouped using func_group + if( ent->epairs.GetAngles( "light_angles", "0 0 0", angles ) ) + { + angles[ 0 ] = idMath::AngleNormalize360( angles[ 0 ] ); + angles[ 1 ] = idMath::AngleNormalize360( angles[ 1 ] ); + angles[ 2 ] = idMath::AngleNormalize360( angles[ 2 ] ); + + mat = angles.ToMat3(); + } + // RB: TrenchBroom interop + // support "angles" like in Quake 3 + else if( ent->epairs.GetAngles( "angles", "0 0 0", angles ) ) + { + angles[ 0 ] = idMath::AngleNormalize360( angles[ 0 ] ); + angles[ 1 ] = idMath::AngleNormalize360( angles[ 1 ] ); + angles[ 2 ] = idMath::AngleNormalize360( angles[ 2 ] ); + + mat = angles.ToMat3(); + } + else + { + ent->epairs.GetFloat( "angle", "0", angles[ 1 ] ); + angles[ 0 ] = 0; + angles[ 1 ] = idMath::AngleNormalize360( angles[ 1 ] ); + angles[ 2 ] = 0; + mat = angles.ToMat3(); + } + } + } + + // fix degenerate identity matrices + mat[0].FixDegenerateNormal(); + mat[1].FixDegenerateNormal(); + mat[2].FixDegenerateNormal(); + + lightEnt->epairs.Delete( "light_rotation" ); + lightEnt->epairs.Delete( "light_angles" ); + lightEnt->epairs.Delete( "angles" ); + lightEnt->epairs.Delete( "angle" ); + lightEnt->epairs.Delete( "model" ); + + angles = mat.ToAngles(); + lightEnt->epairs.SetAngles( "angles", angles ); + + idVec3 lightOrigin = ent->epairs.GetVector( "light_origin", "0 0 0" ); + lightEnt->epairs.SetVector( "origin", lightOrigin ); + lightEnt->epairs.Delete( "light_origin" ); + + lightEnt->epairs.SetInt( "_tb_group", tbGroupID ); + } + + // turn this entity into a func_static and give it a new unique name + ent->epairs.Set( "classname", "func_static" ); + idStr uniqueName = GetUniqueEntityName( "light_model" ); + + ent->epairs.Set( "name", uniqueName ); + ent->epairs.Set( "model", uniqueName ); + ent->epairs.SetInt( "_tb_group", tbGroupID ); + + // strip any light specific data + ent->epairs.Delete( "light_origin" ); + ent->epairs.Delete( "light_rotation" ); + ent->epairs.Delete( "light_radius" ); + ent->epairs.Delete( "light_center" ); + ent->epairs.Delete( "angles" ); + ent->epairs.Delete( "angle" ); + ent->epairs.Delete( "noshadows" ); + ent->epairs.Delete( "nodiffuse" ); + ent->epairs.Delete( "nospecular" ); + ent->epairs.Delete( "falloff" ); + ent->epairs.Delete( "texture" ); + + // add group entity + auto groupEnt = new( TAG_SYSTEM ) idMapEntity(); + entities.Append( groupEnt ); + + groupEnt->epairs.Set( "classname", "func_group" ); + uniqueName = GetUniqueEntityName( "light_group" ); + groupEnt->epairs.Set( "name", uniqueName ); + groupEnt->epairs.Set( "_tb_name", uniqueName ); + groupEnt->epairs.Set( "_tb_type", "_tb_group" ); + groupEnt->epairs.SetInt( "_tb_id", tbGroupID ); + + tbGroupID++; + } + bool removedOrigin = false; - if( !transform.IsIdentity() && - //idStr::Icmp( classname, "func_static" ) != 0 && - idStr::Icmp( classname, "light" ) != 0 ) + if( !transform.IsIdentity() ) //&& !isLight ) { ent->epairs.Delete( "origin" ); ent->epairs.Delete( "rotation" ); @@ -2999,13 +3130,6 @@ bool idMapFile::ConvertToValve220Format() removedOrigin = true; } - // purge flare patches from lights because we can't select lights in TrenchBroom - // that still have primitives - if( idStr::Icmp( classname, "light" ) == 0 ) - { - ent->RemovePrimitiveData(); - } - // convert brushes for( int i = 0; i < ent->GetNumPrimitives(); i++ ) { From d16c13057b810c3c8d2ffc46e4ca920568e8a8b0 Mon Sep 17 00:00:00 2001 From: SRSaunders <82544213+SRSaunders@users.noreply.github.com> Date: Fri, 10 May 2024 19:05:52 -0400 Subject: [PATCH 49/71] Fix Vulkan & D3D12 pipeline validation warnings if no color attachments (e.g. atlas) --- neo/renderer/PipelineCache.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/neo/renderer/PipelineCache.cpp b/neo/renderer/PipelineCache.cpp index 7e12caf1e9..53323e0aca 100644 --- a/neo/renderer/PipelineCache.cpp +++ b/neo/renderer/PipelineCache.cpp @@ -88,6 +88,12 @@ nvrhi::GraphicsPipelineHandle PipelineCache::GetOrCreatePipeline( const Pipeline // Specialize the state with the state key. GetRenderState( key.state, key, pipelineDesc.renderState ); + // SRS - if no color attachments (e.g. atlas), disable fragment shader to avoid validation warnings + if( key.framebuffer->GetApiObject()->getDesc().colorAttachments.size() == 0 ) + { + pipelineDesc.PS = nvrhi::ShaderHandle( NULL ); + } + auto pipeline = device->createGraphicsPipeline( pipelineDesc, key.framebuffer->GetApiObject() ); pipelineHash.Add( h, pipelines.Append( { key, pipeline } ) ); From 9ee8f9439026052e707d3b4fbb4ed59a0a6bc0a4 Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Sat, 11 May 2024 14:17:18 +0200 Subject: [PATCH 50/71] Fixed leaking problems when converting a map to valve 220 format --- neo/idlib/MapFile.cpp | 90 +++++++++++++++++++++++++++++++++++++++++++ neo/idlib/MapFile.h | 2 + 2 files changed, 92 insertions(+) diff --git a/neo/idlib/MapFile.cpp b/neo/idlib/MapFile.cpp index e40605c199..1947fb42f1 100644 --- a/neo/idlib/MapFile.cpp +++ b/neo/idlib/MapFile.cpp @@ -145,6 +145,7 @@ void idMapBrushSide::ConvertToValve220Format( const idMat4& entityTransform, idS return; } +#if 0 // create p1, p2, p3 idVec3 forward = plane.Normal(); idVec3 p1 = forward * plane.Dist(); @@ -170,6 +171,25 @@ void idMapBrushSide::ConvertToValve220Format( const idMat4& entityTransform, idS planepts[1] = entityTransform * p2; planepts[2] = entityTransform * p3; +#else + // from DoomEdit's void BrushPrimit_Parse( brush_t* b, bool newFormat, const idVec3 origin ) + + idVec3 origin = entityTransform.GetTranslation(); + + idPlane fixedPlane = plane; + fixedPlane.FixDegeneracies( DEGENERATE_DIST_EPSILON ); + + idWinding w; + w.BaseForPlane( fixedPlane ); + + for( int j = 0; j < 3; j++ ) + { + planepts[j].x = w[j].x + origin.x; + planepts[j].y = w[j].y + origin.y; + planepts[j].z = w[j].z + origin.z; + } +#endif + idVec3 texX, texY; ComputeAxisBase( plane.Normal(), texX, texY ); @@ -943,7 +963,75 @@ bool idMapBrush::WriteValve220( idFile* fp, int primitiveNum, const idVec3& orig return true; } +/* +============ +RB idMapBrush::SetPlanePointsFromWindings +============ +*/ +void idMapBrush::SetPlanePointsFromWindings( const idVec3& origin, int entityNum, int primitiveNum ) +{ + // fix degenerate planes + idPlane* planes = ( idPlane* ) _alloca16( GetNumSides() * sizeof( planes[0] ) ); + for( int i = 0; i < GetNumSides(); i++ ) + { + planes[i] = GetSide( i )->GetPlane(); + planes[i].FixDegeneracies( DEGENERATE_DIST_EPSILON ); + } + + idBounds bounds; + bounds.Clear(); + + idFixedWinding w; + + for( int i = 0; i < GetNumSides(); i++ ) + { + idMapBrushSide* mapSide = GetSide( i ); + + //const idMaterial* material = declManager->FindMaterial( mapSide->GetMaterial() ); + + // chop base plane by other brush sides + w.BaseForPlane( -planes[i] ); + + if( !w.GetNumPoints() ) + { + common->Printf( "Entity %i, Brush %i: base winding has no points\n", entityNum, primitiveNum ); + break; + } + + for( int j = 0; j < GetNumSides() && w.GetNumPoints(); j++ ) + { + if( i == j ) + { + continue; + } + if( !w.ClipInPlace( -planes[j], 0 ) ) + { + // no intersection + //badBrush = true; + common->Printf( "Entity %i, Brush %i: no intersection with other brush plane\n", entityNum, primitiveNum ); + break; + } + } + + if( w.GetNumPoints() >= 3 ) + { + for( int j = 0; j < 3; j++ ) + { + mapSide->planepts[j].x = w[j].x + origin.x; + mapSide->planepts[j].y = w[j].y + origin.y; + mapSide->planepts[j].z = w[j].z + origin.z; + } + } + + // only used for debugging + for( int j = 0; j < w.GetNumPoints(); j++ ) + { + const idVec3& v = w[j].ToVec3(); + bounds.AddPoint( v ); + } + } +} /* =============== @@ -3144,6 +3232,8 @@ bool idMapFile::ConvertToValve220Format() idMapBrushSide* side = brushPrim->GetSide( s ); side->ConvertToValve220Format( transform, textureCollections ); } + + //brushPrim->SetPlanePointsFromWindings( transform.GetTranslation(), j, i ); } else if( mapPrim->GetType() == idMapPrimitive::TYPE_PATCH ) { diff --git a/neo/idlib/MapFile.h b/neo/idlib/MapFile.h index 188af81a39..cdfdc9cf4f 100644 --- a/neo/idlib/MapFile.h +++ b/neo/idlib/MapFile.h @@ -192,6 +192,8 @@ class idMapBrush : public idMapPrimitive // so we can center the brush on a grid size of 1 in TrenchBroom static idMapBrush* MakeOriginBrush( const idVec3& origin, const idVec3& scale = vec3_one ); + void SetPlanePointsFromWindings( const idVec3& origin, int entityNum, int primitiveNum ); + int GetNumSides() const { return sides.Num(); From a4558ff5b85305824e99a386ef00e51c8a9eef94 Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Sat, 11 May 2024 18:13:26 +0200 Subject: [PATCH 51/71] Optimized convertMapToValve220 output with sane 3 point plane definitions --- neo/idlib/MapFile.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/neo/idlib/MapFile.cpp b/neo/idlib/MapFile.cpp index 1947fb42f1..8a83a521d5 100644 --- a/neo/idlib/MapFile.cpp +++ b/neo/idlib/MapFile.cpp @@ -987,9 +987,6 @@ void idMapBrush::SetPlanePointsFromWindings( const idVec3& origin, int entityNum { idMapBrushSide* mapSide = GetSide( i ); - //const idMaterial* material = declManager->FindMaterial( mapSide->GetMaterial() ); - - // chop base plane by other brush sides w.BaseForPlane( -planes[i] ); if( !w.GetNumPoints() ) @@ -998,6 +995,7 @@ void idMapBrush::SetPlanePointsFromWindings( const idVec3& origin, int entityNum break; } + // chop base plane by other brush planes for( int j = 0; j < GetNumSides() && w.GetNumPoints(); j++ ) { if( i == j ) @@ -1007,8 +1005,6 @@ void idMapBrush::SetPlanePointsFromWindings( const idVec3& origin, int entityNum if( !w.ClipInPlace( -planes[j], 0 ) ) { - // no intersection - //badBrush = true; common->Printf( "Entity %i, Brush %i: no intersection with other brush plane\n", entityNum, primitiveNum ); break; } @@ -1016,12 +1012,10 @@ void idMapBrush::SetPlanePointsFromWindings( const idVec3& origin, int entityNum if( w.GetNumPoints() >= 3 ) { - for( int j = 0; j < 3; j++ ) - { - mapSide->planepts[j].x = w[j].x + origin.x; - mapSide->planepts[j].y = w[j].y + origin.y; - mapSide->planepts[j].z = w[j].z + origin.z; - } + // reverse order to invert normal + mapSide->planepts[0] = w[2].ToVec3() + origin; + mapSide->planepts[1] = w[1].ToVec3() + origin; + mapSide->planepts[2] = w[0].ToVec3() + origin; } // only used for debugging @@ -3178,6 +3172,7 @@ bool idMapFile::ConvertToValve220Format() ent->epairs.Set( "name", uniqueName ); ent->epairs.Set( "model", uniqueName ); + lightEnt->epairs.Set( "model", uniqueName ); ent->epairs.SetInt( "_tb_group", tbGroupID ); // strip any light specific data @@ -3233,7 +3228,9 @@ bool idMapFile::ConvertToValve220Format() side->ConvertToValve220Format( transform, textureCollections ); } - //brushPrim->SetPlanePointsFromWindings( transform.GetTranslation(), j, i ); + // RB: this is not necessary but the initial plane definitions are at the border of the max world size + // so with this function we get sane values that are within the brush boundaries + brushPrim->SetPlanePointsFromWindings( transform.GetTranslation(), j, i ); } else if( mapPrim->GetType() == idMapPrimitive::TYPE_PATCH ) { From ca012ce8435377e76c2c34726a88da6305280024 Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Sat, 11 May 2024 20:42:22 +0200 Subject: [PATCH 52/71] Changed important console cmds to CONSOLE_COMMAND_SHIP for new ModDB builds --- neo/framework/Common.cpp | 2 +- neo/framework/Common_load.cpp | 6 +++++- neo/framework/Common_mapconvert.cpp | 4 ++-- neo/idlib/gltfParser.cpp | 2 +- neo/renderer/RenderWorld_envprobes.cpp | 2 +- neo/renderer/RenderWorld_lightgrid.cpp | 2 +- 6 files changed, 11 insertions(+), 7 deletions(-) diff --git a/neo/framework/Common.cpp b/neo/framework/Common.cpp index 6ce616d403..855cb01b29 100644 --- a/neo/framework/Common.cpp +++ b/neo/framework/Common.cpp @@ -647,7 +647,7 @@ Com_WriteConfig_f Write the config file to a specific name =============== */ -CONSOLE_COMMAND( writeConfig, "writes a config file", NULL ) +CONSOLE_COMMAND_SHIP( writeConfig, "writes a config file", NULL ) { idStr filename; diff --git a/neo/framework/Common_load.cpp b/neo/framework/Common_load.cpp index 76c00a77de..873a99e5c1 100644 --- a/neo/framework/Common_load.cpp +++ b/neo/framework/Common_load.cpp @@ -1420,8 +1420,11 @@ CONSOLE_COMMAND( testmap, "tests a map", idCmdSystem::ArgCompletion_MapName ) /* ================== Common_TestMap_f + +// TODO finish this ================== */ +#if 0 CONSOLE_COMMAND( bakemap, "loads a map and bakes environment probes", idCmdSystem::ArgCompletion_MapName ) { idStr map, string; @@ -1440,4 +1443,5 @@ CONSOLE_COMMAND( bakemap, "loads a map and bakes environment probes", idCmdSyste sprintf( string, "bakeEnvironmentProbes" ); cmdSystem->BufferCommandText( CMD_EXEC_NOW, string ); -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/neo/framework/Common_mapconvert.cpp b/neo/framework/Common_mapconvert.cpp index a1701e586b..ab7eaf67c7 100644 --- a/neo/framework/Common_mapconvert.cpp +++ b/neo/framework/Common_mapconvert.cpp @@ -692,7 +692,7 @@ CONSOLE_COMMAND( convertMapToJSON, "Convert .map file to new .json map format wi common->SetRefreshOnPrint( false ); } -CONSOLE_COMMAND( convertMapToValve220, "Convert .map file to the Valve 220 map format for TrenchBroom", idCmdSystem::ArgCompletion_MapNameNoJson ) +CONSOLE_COMMAND_SHIP( convertMapToValve220, "Convert .map file to the Valve 220 map format for TrenchBroom", idCmdSystem::ArgCompletion_MapNameNoJson ) { common->SetRefreshOnPrint( true ); @@ -799,7 +799,7 @@ CONSOLE_COMMAND( checkMapsForBrushEntities, "List all brush entities in all .map } -CONSOLE_COMMAND( convertMapQuakeToDoom, "Convert Quake .map in Valve 220 map format for Doom 3 BFG", idCmdSystem::ArgCompletion_MapNameNoJson ) +CONSOLE_COMMAND_SHIP( convertMapQuakeToDoom, "Convert Quake .map in Valve 220 map format for Doom 3 BFG", idCmdSystem::ArgCompletion_MapNameNoJson ) { common->SetRefreshOnPrint( true ); diff --git a/neo/idlib/gltfParser.cpp b/neo/idlib/gltfParser.cpp index 4a691ab6c5..0d2befd760 100644 --- a/neo/idlib/gltfParser.cpp +++ b/neo/idlib/gltfParser.cpp @@ -2362,7 +2362,7 @@ void gltfData::ClearData( idStr& fileName ) #undef GLTFARRAYITEM #undef GLTFARRAYITEMREF -CONSOLE_COMMAND_COMPILE( LoadGLTF, "Loads an .gltf or .glb file", idCmdSystem::ArgCompletion_MapName ) +CONSOLE_COMMAND( LoadGLTF, "Loads an .gltf or .glb file", idCmdSystem::ArgCompletion_MapName ) { if( args.Argc() > 1 ) diff --git a/neo/renderer/RenderWorld_envprobes.cpp b/neo/renderer/RenderWorld_envprobes.cpp index 32bda966f5..c49b473356 100644 --- a/neo/renderer/RenderWorld_envprobes.cpp +++ b/neo/renderer/RenderWorld_envprobes.cpp @@ -921,7 +921,7 @@ void R_MakeAmbientMap( const char* baseName, byte* buffers[6], const char* suffi } } -CONSOLE_COMMAND( bakeEnvironmentProbes, "Bake environment probes", NULL ) +CONSOLE_COMMAND_SHIP( bakeEnvironmentProbes, "Bake environment probes", NULL ) { idStr fullname; idStr baseName; diff --git a/neo/renderer/RenderWorld_lightgrid.cpp b/neo/renderer/RenderWorld_lightgrid.cpp index 619b3b1d86..fa3c81d519 100644 --- a/neo/renderer/RenderWorld_lightgrid.cpp +++ b/neo/renderer/RenderWorld_lightgrid.cpp @@ -1035,7 +1035,7 @@ REGISTER_PARALLEL_JOB( CalculateLightGridPointJob, "CalculateLightGridPointJob" -CONSOLE_COMMAND( bakeLightGrids, "Bake irradiance/vis light grid data", NULL ) +CONSOLE_COMMAND_SHIP( bakeLightGrids, "Bake irradiance/vis light grid data", NULL ) { idStr baseName; idStr filename; From 985d73697a55f851db9b39b7726a9c9304041053 Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Sat, 11 May 2024 21:29:43 +0200 Subject: [PATCH 53/71] Don't mess up material names when loading patches from valve 220 format --- neo/idlib/MapFile.cpp | 21 +++++++++++++-------- neo/idlib/MapFile.h | 8 ++++---- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/neo/idlib/MapFile.cpp b/neo/idlib/MapFile.cpp index 8a83a521d5..352b2aab57 100644 --- a/neo/idlib/MapFile.cpp +++ b/neo/idlib/MapFile.cpp @@ -278,7 +278,7 @@ void idMapBrushSide::ConvertToValve220Format( const idMat4& entityTransform, idS idMapPatch::Parse ================= */ -idMapPatch* idMapPatch::Parse( idLexer& src, const idVec3& origin, bool patchDef3, float version ) +idMapPatch* idMapPatch::Parse( idLexer& src, const idVec3& origin, bool patchDef3, int version ) { float info[7]; idDrawVert* vert; @@ -318,7 +318,11 @@ idMapPatch* idMapPatch::Parse( idLexer& src, const idVec3& origin, bool patchDef idMapPatch* patch = new( TAG_IDLIB ) idMapPatch( info[0], info[1] ); patch->SetSize( info[0], info[1] ); - if( version < 2.0f ) + + idStr matName = token; + + // version 220 might be missing textures/ if saved by TrenchBroom + if( version < 2 || ( version == 220 && matName.IcmpPrefix( "textures/" ) != 0 ) ) { patch->SetMaterial( "textures/" + token ); } @@ -480,7 +484,7 @@ unsigned int idMapPatch::GetGeometryCRC() const idMapBrush::Parse ================= */ -idMapBrush* idMapBrush::Parse( idLexer& src, const idVec3& origin, bool newFormat, float version ) +idMapBrush* idMapBrush::Parse( idLexer& src, const idVec3& origin, bool newFormat, int version ) { int i; idVec3 planepts[3]; @@ -596,7 +600,7 @@ idMapBrush* idMapBrush::Parse( idLexer& src, const idVec3& origin, bool newForma } // we had an implicit 'textures/' in the old format... - if( version < 2.0f ) + if( version < 2 ) { side->material = "textures/" + token; } @@ -1076,7 +1080,7 @@ bool idMapBrush::IsOriginBrush() const idMapEntity::Parse ================ */ -idMapEntity* idMapEntity::Parse( idLexer& src, bool worldSpawn, float version ) +idMapEntity* idMapEntity::Parse( idLexer& src, bool worldSpawn, int version ) { idToken token; idMapEntity* mapEnt; @@ -1771,13 +1775,14 @@ bool idMapFile::Parse( const char* filename, bool ignoreRegion, bool osPath ) if( token == "Version" ) { src.ReadTokenOnLine( &token ); - version = token.GetFloatValue(); + version = token.GetIntValue(); } else { // Valve 220 format and idMapEntity::Parse will expect { src.UnreadToken( &token ); valve220Format = true; + version = 220; } while( 1 ) @@ -1963,7 +1968,7 @@ bool idMapFile::Write( const char* fileName, const char* ext, bool fromBasePath } else { - fp->WriteFloatString( "Version %f\n", ( float ) CURRENT_MAP_VERSION ); + fp->WriteFloatString( "Version %d\n", CURRENT_MAP_VERSION ); } for( i = 0; i < entities.Num(); i++ ) @@ -2004,7 +2009,7 @@ bool idMapFile::WriteJSON( const char* fileName, const char* ext, bool fromBaseP } fp->Printf( "{\n" ); - fp->WriteFloatString( "\t\"version\": \"%f\",\n", ( float ) CURRENT_MAP_VERSION ); + fp->WriteFloatString( "\t\"version\": \"%d\",\n", CURRENT_MAP_VERSION ); fp->Printf( "\t\"entities\": \n\t[\n" ); for( i = 0; i < entities.Num(); i++ ) diff --git a/neo/idlib/MapFile.h b/neo/idlib/MapFile.h index cdfdc9cf4f..db90bfccaf 100644 --- a/neo/idlib/MapFile.h +++ b/neo/idlib/MapFile.h @@ -182,7 +182,7 @@ class idMapBrush : public idMapPrimitive { sides.DeleteContents( true ); } - static idMapBrush* Parse( idLexer& src, const idVec3& origin, bool newFormat = true, float version = CURRENT_MAP_VERSION ); + static idMapBrush* Parse( idLexer& src, const idVec3& origin, bool newFormat = true, int version = CURRENT_MAP_VERSION ); static idMapBrush* ParseQ3( idLexer& src, const idVec3& origin ); static idMapBrush* ParseValve220( idLexer& src, const idVec3& origin ); // RB bool Write( idFile* fp, int primitiveNum, const idVec3& origin ) const; @@ -222,7 +222,7 @@ class idMapPatch : public idMapPrimitive, public idSurface_Patch idMapPatch(); idMapPatch( int maxPatchWidth, int maxPatchHeight ); ~idMapPatch() { } - static idMapPatch* Parse( idLexer& src, const idVec3& origin, bool patchDef3 = true, float version = CURRENT_MAP_VERSION ); + static idMapPatch* Parse( idLexer& src, const idVec3& origin, bool patchDef3, int version ); bool Write( idFile* fp, int primitiveNum, const idVec3& origin ) const; const char* GetMaterial() const { @@ -455,7 +455,7 @@ class idMapEntity } // HVG check gltf scene for entities static int GetEntities( gltfData* data, EntityListRef entities, int scene = 0 ); - static idMapEntity* Parse( idLexer& src, bool worldSpawn = false, float version = CURRENT_MAP_VERSION ); + static idMapEntity* Parse( idLexer& src, bool worldSpawn = false, int version = CURRENT_MAP_VERSION ); bool Write( idFile* fp, int entityNum, bool valve220 ) const; // HVG NOTE: this is not compatible with gltf (extra) json! @@ -558,7 +558,7 @@ class idMapFile static void WadTextureToMaterial( const char* material, idStr& matName ); protected: - float version; + int version; ID_TIME_T fileTime; unsigned int geometryCRC; idMapEntity::EntityList entities; From 0efc9e24f36c1f6191ed542cbabf806b8df21fd8 Mon Sep 17 00:00:00 2001 From: SRSaunders <82544213+SRSaunders@users.noreply.github.com> Date: Sat, 11 May 2024 17:45:07 -0400 Subject: [PATCH 54/71] Revert VK_EXT_debug_marker change and enable VK_EXT_Debug_Report as parent dependency --- neo/sys/DeviceManager_VK.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/neo/sys/DeviceManager_VK.cpp b/neo/sys/DeviceManager_VK.cpp index 13ab8d7b8e..eafe596723 100644 --- a/neo/sys/DeviceManager_VK.cpp +++ b/neo/sys/DeviceManager_VK.cpp @@ -252,12 +252,14 @@ class DeviceManager_VK : public DeviceManager VK_EXT_LAYER_SETTINGS_EXTENSION_NAME, #endif #endif + VK_EXT_DEBUG_REPORT_EXTENSION_NAME, VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME }, // layers { }, // device { + VK_EXT_DEBUG_MARKER_EXTENSION_NAME, VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME, VK_NV_MESH_SHADER_EXTENSION_NAME, @@ -1241,8 +1243,6 @@ bool DeviceManager_VK::CreateDeviceAndSwapChain() if( m_DeviceParams.enableDebugRuntime ) { - enabledExtensions.instance.insert( VK_EXT_DEBUG_REPORT_EXTENSION_NAME ); - optionalExtensions.device.insert( VK_EXT_DEBUG_MARKER_EXTENSION_NAME ); #if defined(__APPLE__) && defined( USE_MoltenVK ) } From 70a616e6eb93234f8d50096ec9bf85d5253d4cb4 Mon Sep 17 00:00:00 2001 From: SRSaunders <82544213+SRSaunders@users.noreply.github.com> Date: Sat, 11 May 2024 17:47:42 -0400 Subject: [PATCH 55/71] Enable VK_KHR_maintenance4 for relaxed interface matching between input and output vectors --- neo/sys/DeviceManager_VK.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/neo/sys/DeviceManager_VK.cpp b/neo/sys/DeviceManager_VK.cpp index eafe596723..f5fd167cd2 100644 --- a/neo/sys/DeviceManager_VK.cpp +++ b/neo/sys/DeviceManager_VK.cpp @@ -269,6 +269,9 @@ class DeviceManager_VK : public DeviceManager #endif #if defined( VK_KHR_format_feature_flags2 ) VK_KHR_FORMAT_FEATURE_FLAGS_2_EXTENSION_NAME, +#endif +#if defined( VK_KHR_maintenance4 ) + VK_KHR_MAINTENANCE_4_EXTENSION_NAME, #endif VK_KHR_SYNCHRONIZATION_2_EXTENSION_NAME, VK_EXT_MEMORY_BUDGET_EXTENSION_NAME From 37927c94a304cfb8debc4ab5097ed66a728014ac Mon Sep 17 00:00:00 2001 From: SRSaunders <82544213+SRSaunders@users.noreply.github.com> Date: Sat, 11 May 2024 18:32:01 -0400 Subject: [PATCH 56/71] Revert no-color attachment change, instead suppress DX12 & Vulkan validation layer messages --- neo/renderer/PipelineCache.cpp | 6 ------ neo/sys/DeviceManager_DX12.cpp | 1 + neo/sys/DeviceManager_VK.cpp | 8 +++++--- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/neo/renderer/PipelineCache.cpp b/neo/renderer/PipelineCache.cpp index 53323e0aca..7e12caf1e9 100644 --- a/neo/renderer/PipelineCache.cpp +++ b/neo/renderer/PipelineCache.cpp @@ -88,12 +88,6 @@ nvrhi::GraphicsPipelineHandle PipelineCache::GetOrCreatePipeline( const Pipeline // Specialize the state with the state key. GetRenderState( key.state, key, pipelineDesc.renderState ); - // SRS - if no color attachments (e.g. atlas), disable fragment shader to avoid validation warnings - if( key.framebuffer->GetApiObject()->getDesc().colorAttachments.size() == 0 ) - { - pipelineDesc.PS = nvrhi::ShaderHandle( NULL ); - } - auto pipeline = device->createGraphicsPipeline( pipelineDesc, key.framebuffer->GetApiObject() ); pipelineHash.Add( h, pipelines.Append( { key, pipeline } ) ); diff --git a/neo/sys/DeviceManager_DX12.cpp b/neo/sys/DeviceManager_DX12.cpp index ff15e67b56..f8669342a2 100644 --- a/neo/sys/DeviceManager_DX12.cpp +++ b/neo/sys/DeviceManager_DX12.cpp @@ -384,6 +384,7 @@ bool DeviceManager_DX12::CreateDeviceAndSwapChain() D3D12_MESSAGE_ID_CLEARDEPTHSTENCILVIEW_MISMATCHINGCLEARVALUE, D3D12_MESSAGE_ID_CLEARRENDERTARGETVIEW_MISMATCHINGCLEARVALUE, D3D12_MESSAGE_ID_COMMAND_LIST_STATIC_DESCRIPTOR_RESOURCE_DIMENSION_MISMATCH, // descriptor validation doesn't understand acceleration structures + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_RENDERTARGETVIEW_NOT_SET, // disable warning when there is no color attachment (e.g. shadow atlas) D3D12_MESSAGE_ID_RESOURCE_BARRIER_BEFORE_AFTER_MISMATCH // barrier validation error caused by cinematics - not sure how to fix, suppress for now }; diff --git a/neo/sys/DeviceManager_VK.cpp b/neo/sys/DeviceManager_VK.cpp index f5fd167cd2..050e1adba2 100644 --- a/neo/sys/DeviceManager_VK.cpp +++ b/neo/sys/DeviceManager_VK.cpp @@ -1254,11 +1254,13 @@ bool DeviceManager_VK::CreateDeviceAndSwapChain() #else enabledExtensions.layers.insert( "VK_LAYER_KHRONOS_validation" ); - // SRS - Suppress WARNING-Shader-OutputNotConsumed: by design for vertex shader layouts + // SRS - Suppress specific [ WARNING-Shader-OutputNotConsumed ] false positive validation warnings which are by design: + // 0xc81ad50e: vkCreateGraphicsPipelines(): pCreateInfos[0].pVertexInputState Vertex attribute at location X not consumed by vertex shader. + // 0x9805298c: vkCreateGraphicsPipelines(): pCreateInfos[0] fragment shader writes to output location 0 with no matching attachment. #ifdef _WIN32 - SetEnvironmentVariable( "VK_LAYER_MESSAGE_ID_FILTER", "0xc81ad50e" ); + SetEnvironmentVariable( "VK_LAYER_MESSAGE_ID_FILTER", "0xc81ad50e;0x9805298c" ); #else - setenv( "VK_LAYER_MESSAGE_ID_FILTER", "0xc81ad50e", 1 ); + setenv( "VK_LAYER_MESSAGE_ID_FILTER", "0xc81ad50e:0x9805298c", 1 ); #endif } From d5920c0b6a6df4c0f37cc09552888ff283323b95 Mon Sep 17 00:00:00 2001 From: SRSaunders <82544213+SRSaunders@users.noreply.github.com> Date: Sat, 11 May 2024 18:36:43 -0400 Subject: [PATCH 57/71] Minor tweak to Vulkan extension order --- neo/sys/DeviceManager_VK.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/neo/sys/DeviceManager_VK.cpp b/neo/sys/DeviceManager_VK.cpp index 050e1adba2..11a7479287 100644 --- a/neo/sys/DeviceManager_VK.cpp +++ b/neo/sys/DeviceManager_VK.cpp @@ -252,8 +252,8 @@ class DeviceManager_VK : public DeviceManager VK_EXT_LAYER_SETTINGS_EXTENSION_NAME, #endif #endif - VK_EXT_DEBUG_REPORT_EXTENSION_NAME, - VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME + VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME, + VK_EXT_DEBUG_REPORT_EXTENSION_NAME }, // layers { }, From 729013311d0829fc5f3b7876a835b11407b6e48b Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Mon, 13 May 2024 23:11:02 +0200 Subject: [PATCH 58/71] Killed remnants of renderLight precalculated shadowvolume models --- neo/d3xp/Light.cpp | 33 ++----------------------------- neo/d3xp/Light.h | 4 ++++ neo/d3xp/gamesys/SaveGame.cpp | 4 ---- neo/idlib/MapFile.cpp | 3 ++- neo/renderer/RenderWorld.cpp | 7 +------ neo/renderer/RenderWorld.h | 5 ----- neo/renderer/RenderWorld_defs.cpp | 2 ++ 7 files changed, 11 insertions(+), 47 deletions(-) diff --git a/neo/d3xp/Light.cpp b/neo/d3xp/Light.cpp index cd864a0bd1..1ccd1202c5 100644 --- a/neo/d3xp/Light.cpp +++ b/neo/d3xp/Light.cpp @@ -290,7 +290,8 @@ void idLight::Save( idSaveGame* savefile ) const { savefile->WriteRenderLight( renderLight ); - savefile->WriteBool( renderLight.prelightModel != NULL ); + // RB keep it for savegame compatibility but we have no support for dmap generated shadow models + savefile->WriteBool( false ); savefile->WriteVec3( localLightOrigin ); savefile->WriteMat3( localLightAxis ); @@ -326,21 +327,6 @@ void idLight::Restore( idRestoreGame* savefile ) savefile->ReadRenderLight( renderLight ); savefile->ReadBool( hadPrelightModel ); - renderLight.prelightModel = renderModelManager->CheckModel( va( "_prelight_%s", name.c_str() ) ); - if( ( renderLight.prelightModel == NULL ) && hadPrelightModel ) - { - assert( 0 ); - if( developer.GetBool() ) - { - // we really want to know if this happens - gameLocal.Error( "idLight::Restore: prelightModel '_prelight_%s' not found", name.c_str() ); - } - else - { - // but let it slide after release - gameLocal.Warning( "idLight::Restore: prelightModel '_prelight_%s' not found", name.c_str() ); - } - } savefile->ReadVec3( localLightOrigin ); savefile->ReadMat3( localLightAxis ); @@ -415,17 +401,6 @@ void idLight::Spawn() lightDefHandle = -1; // no static version yet - // see if an optimized shadow volume exists - // the renderer will ignore this value after a light has been moved, - // but there may still be a chance to get it wrong if the game moves - // a light before the first present, and doesn't clear the prelight - renderLight.prelightModel = 0; - if( name[ 0 ] ) - { - // this will return 0 if not found - renderLight.prelightModel = renderModelManager->CheckModel( va( "_prelight_%s", name.c_str() ) ); - } - spawnArgs.GetBool( "start_off", "0", start_off ); if( start_off ) { @@ -803,7 +778,6 @@ void idLight::BecomeBroken( idEntity* activator ) if( common->IsServer() ) { - ServerSendEvent( EVENT_BECOMEBROKEN, NULL, true ); if( spawnArgs.GetString( "def_damage", "", &damageDefName ) ) @@ -811,7 +785,6 @@ void idLight::BecomeBroken( idEntity* activator ) idVec3 origin = renderEntity.origin + renderEntity.bounds.GetCenter() * renderEntity.axis; gameLocal.RadiusDamage( origin, activator, activator, this, this, damageDefName ); } - } ActivateTargets( activator ); @@ -871,7 +844,6 @@ idLight::PresentModelDefChange */ void idLight::PresentModelDefChange() { - if( !renderEntity.hModel || IsHidden() ) { return; @@ -1366,7 +1338,6 @@ idLight::WriteToSnapshot */ void idLight::WriteToSnapshot( idBitMsg& msg ) const { - GetPhysics()->WriteToSnapshot( msg ); WriteBindToSnapshot( msg ); diff --git a/neo/d3xp/Light.h b/neo/d3xp/Light.h index bfb5259a06..5bd0f45720 100644 --- a/neo/d3xp/Light.h +++ b/neo/d3xp/Light.h @@ -71,6 +71,7 @@ ID_INLINE void rvmLightStyleState_t::Reset() // jmarshall end +//class idStaticEntity; class idLight : public idEntity { @@ -174,6 +175,9 @@ class idLight : public idEntity int fadeEnd; bool soundWasPlaying; + // RB: pointing to static model because this light entity was split into 2 entities by convertMapToValve220 + //idEntityPtr staticModel; + private: void PresentLightDefChange(); void PresentModelDefChange(); diff --git a/neo/d3xp/gamesys/SaveGame.cpp b/neo/d3xp/gamesys/SaveGame.cpp index 9590e54aaa..d651ccf6f5 100644 --- a/neo/d3xp/gamesys/SaveGame.cpp +++ b/neo/d3xp/gamesys/SaveGame.cpp @@ -1627,10 +1627,6 @@ void idRestoreGame::ReadRenderLight( renderLight_t& renderLight ) ReadVec3( renderLight.start ); ReadVec3( renderLight.end ); - // only idLight has a prelightModel and it's always based on the entityname, so we'll restore it there - // ReadModel( renderLight.prelightModel ); - renderLight.prelightModel = NULL; - ReadInt( renderLight.lightId ); ReadMaterial( renderLight.shader ); diff --git a/neo/idlib/MapFile.cpp b/neo/idlib/MapFile.cpp index 352b2aab57..7dbf1fa663 100644 --- a/neo/idlib/MapFile.cpp +++ b/neo/idlib/MapFile.cpp @@ -3157,7 +3157,6 @@ bool idMapFile::ConvertToValve220Format() lightEnt->epairs.Delete( "light_rotation" ); lightEnt->epairs.Delete( "light_angles" ); - lightEnt->epairs.Delete( "angles" ); lightEnt->epairs.Delete( "angle" ); lightEnt->epairs.Delete( "model" ); @@ -3177,6 +3176,8 @@ bool idMapFile::ConvertToValve220Format() ent->epairs.Set( "name", uniqueName ); ent->epairs.Set( "model", uniqueName ); + + // TODO replace this with other key that links idLight to func_static entity for syncing color/broken model lightEnt->epairs.Set( "model", uniqueName ); ent->epairs.SetInt( "_tb_group", tbGroupID ); diff --git a/neo/renderer/RenderWorld.cpp b/neo/renderer/RenderWorld.cpp index 30844ce71f..ced5533250 100644 --- a/neo/renderer/RenderWorld.cpp +++ b/neo/renderer/RenderWorld.cpp @@ -497,7 +497,7 @@ void idRenderWorldLocal::UpdateLightDef( qhandle_t lightHandle, const renderLigh rlight->parallel == light->parms.parallel && rlight->pointLight == light->parms.pointLight && rlight->right == light->parms.right && rlight->start == light->parms.start && rlight->target == light->parms.target && rlight->up == light->parms.up && - rlight->shader == light->lightShader && rlight->prelightModel == light->parms.prelightModel ) + rlight->shader == light->lightShader ) { justUpdate = true; } @@ -528,11 +528,6 @@ void idRenderWorldLocal::UpdateLightDef( qhandle_t lightHandle, const renderLigh light->parms.noShadows = true; } - if( light->lightHasMoved ) - { - light->parms.prelightModel = NULL; - } - if( !justUpdate ) { R_CreateLightRefs( light ); diff --git a/neo/renderer/RenderWorld.h b/neo/renderer/RenderWorld.h index 4ee0966abb..8c3ca01c52 100644 --- a/neo/renderer/RenderWorld.h +++ b/neo/renderer/RenderWorld.h @@ -203,11 +203,6 @@ typedef struct renderLight_s idVec3 start; idVec3 end; - // Dmap will generate an optimized shadow volume named _prelight_ - // for the light against all the _area* models in the map. The renderer will - // ignore this value if the light has been moved after initial creation - idRenderModel* prelightModel; - // muzzle flash lights will not cast shadows from player and weapon world models int lightId; diff --git a/neo/renderer/RenderWorld_defs.cpp b/neo/renderer/RenderWorld_defs.cpp index 477b332218..f084198985 100644 --- a/neo/renderer/RenderWorld_defs.cpp +++ b/neo/renderer/RenderWorld_defs.cpp @@ -713,11 +713,13 @@ void R_CreateLightRefs( idRenderLightLocal* light ) // we can limit the area references to those visible through the portals from the light center. // We can't do this in the normal case, because shadows are cast from back facing triangles, which // may be in areas not directly visible to the light projection center. + /* if( light->parms.prelightModel != NULL && r_useLightPortalFlow.GetBool() && light->lightShader->LightCastsShadows() ) { light->world->FlowLightThroughPortals( light ); } else + */ { // push the light frustum down the BSP tree into areas light->world->PushFrustumIntoTree( NULL, light, light->inverseBaseLightProject, bounds_zeroOneCube ); From f2acbbabde37e4a7b111334db51dfb7ba2894b4e Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Thu, 16 May 2024 21:00:44 +0200 Subject: [PATCH 59/71] Introduced idLight::modelTarget key for TrenchBroom light group setup --- base/def/misc.def | 6 +- neo/d3xp/Light.cpp | 130 +++++++++++++++++++++++++++++++++++++----- neo/d3xp/Light.h | 5 +- neo/idlib/MapFile.cpp | 4 +- 4 files changed, 127 insertions(+), 18 deletions(-) diff --git a/base/def/misc.def b/base/def/misc.def index 33cdb0bedf..2b268f87d2 100644 --- a/base/def/misc.def +++ b/base/def/misc.def @@ -38,8 +38,10 @@ entityDef light { "editor_var shaderParm7" "shaderParm 7" "editor_var count" "how many times light must be triggered to toggle." "editor_var break" "break when triggered." - "editor_model model" "model to use." - "editor_model broken" "model to use when the light is broken (defaults to model name with '_broken' appended to name)" + // RB: modelTarget key to support light groups of lights and func_static models in TrenchBroom + "editor_var modelTarget" "name of func_static entity as a replacement for model on this entity" + "editor_model model" "model to use." + "editor_model broken" "model to use when the light is broken (defaults to model name with '_broken' appended to name)" "editor_var hideModelOnBreak" "hides the model when broken" "editor_var health" "amount of damage to recieve before becoming broken. 0 is nonbreakable." "editor_var target" "entities to trigger if shot." diff --git a/neo/d3xp/Light.cpp b/neo/d3xp/Light.cpp index 1ccd1202c5..ea52951df4 100644 --- a/neo/d3xp/Light.cpp +++ b/neo/d3xp/Light.cpp @@ -3,6 +3,8 @@ Doom 3 BFG Edition GPL Source Code Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 2021 Justin Marshall +Copyright (C) 2021-2024 Robert Beckebans This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). @@ -49,6 +51,7 @@ const idEventDef EV_Light_On( "On", NULL ); const idEventDef EV_Light_Off( "Off", NULL ); const idEventDef EV_Light_FadeOut( "fadeOutLight", "f" ); const idEventDef EV_Light_FadeIn( "fadeInLight", "f" ); +const idEventDef EV_Light_UpdateModelTarget( "", NULL ); // RB CLASS_DECLARATION( idEntity, idLight ) EVENT( EV_Light_SetShader, idLight::Event_SetShader ) @@ -65,6 +68,8 @@ EVENT( EV_Activate, idLight::Event_ToggleOnOff ) EVENT( EV_PostSpawn, idLight::Event_SetSoundHandles ) EVENT( EV_Light_FadeOut, idLight::Event_FadeOut ) EVENT( EV_Light_FadeIn, idLight::Event_FadeIn ) +EVENT( EV_Light_FadeIn, idLight::Event_FadeIn ) +EVENT( EV_Light_UpdateModelTarget, idLight::Event_UpdateModelTarget ) END_CLASS @@ -226,6 +231,14 @@ void idLight::UpdateChangeableSpawnArgs( const idDict* source ) // RB: allow the ingame light editor to move the light GetPhysics()->SetOrigin( renderLight.origin ); GetPhysics()->SetAxis( renderLight.axis ); + + // link func_static modelTarget + modelTarget = NULL; + const char* target = source->GetString( "modelTarget" ); + if( target != NULL && target[0] != '\0' ) + { + PostEventMS( &EV_Light_UpdateModelTarget, 0 ); + } // RB end UpdateVisuals(); @@ -455,7 +468,11 @@ void idLight::Spawn() idStr model = spawnArgs.GetString( "model" ); // get the visual model if( !model.Length() ) { - gameLocal.Error( "Breakable light without a model set on entity #%d(%s)", entityNumber, name.c_str() ); + model = spawnArgs.GetString( "modelTarget" ); + if( !model.Length() ) + { + gameLocal.Error( "Breakable light without a model set on entity #%d(%s)", entityNumber, name.c_str() ); + } } fl.takedamage = true; @@ -523,9 +540,22 @@ void idLight::SetLightLevel() renderLight.shaderParms[ SHADERPARM_RED ] = color[ 0 ]; renderLight.shaderParms[ SHADERPARM_GREEN ] = color[ 1 ]; renderLight.shaderParms[ SHADERPARM_BLUE ] = color[ 2 ]; - renderEntity.shaderParms[ SHADERPARM_RED ] = color[ 0 ]; - renderEntity.shaderParms[ SHADERPARM_GREEN ] = color[ 1 ]; - renderEntity.shaderParms[ SHADERPARM_BLUE ] = color[ 2 ]; + + if( modelTarget ) + { + renderEntity_t* rent = modelTarget->GetRenderEntity(); + + rent->shaderParms[ SHADERPARM_RED ] = color[ 0 ]; + rent->shaderParms[ SHADERPARM_GREEN ] = color[ 1 ]; + rent->shaderParms[ SHADERPARM_BLUE ] = color[ 2 ]; + } + else + { + renderEntity.shaderParms[ SHADERPARM_RED ] = color[ 0 ]; + renderEntity.shaderParms[ SHADERPARM_GREEN ] = color[ 1 ]; + renderEntity.shaderParms[ SHADERPARM_BLUE ] = color[ 2 ]; + } + PresentLightDefChange(); PresentModelDefChange(); } @@ -630,10 +660,23 @@ void idLight::SetLightParms( float parm0, float parm1, float parm2, float parm3 renderLight.shaderParms[ SHADERPARM_GREEN ] = parm1; renderLight.shaderParms[ SHADERPARM_BLUE ] = parm2; renderLight.shaderParms[ SHADERPARM_ALPHA ] = parm3; - renderEntity.shaderParms[ SHADERPARM_RED ] = parm0; - renderEntity.shaderParms[ SHADERPARM_GREEN ] = parm1; - renderEntity.shaderParms[ SHADERPARM_BLUE ] = parm2; - renderEntity.shaderParms[ SHADERPARM_ALPHA ] = parm3; + + if( modelTarget ) + { + renderEntity_t* rent = modelTarget->GetRenderEntity(); + + rent->shaderParms[ SHADERPARM_RED ] = parm0; + rent->shaderParms[ SHADERPARM_GREEN ] = parm1; + rent->shaderParms[ SHADERPARM_BLUE ] = parm2; + rent->shaderParms[ SHADERPARM_ALPHA ] = parm3; + } + else + { + renderEntity.shaderParms[ SHADERPARM_RED ] = parm0; + renderEntity.shaderParms[ SHADERPARM_GREEN ] = parm1; + renderEntity.shaderParms[ SHADERPARM_BLUE ] = parm2; + renderEntity.shaderParms[ SHADERPARM_ALPHA ] = parm3; + } PresentLightDefChange(); PresentModelDefChange(); } @@ -670,6 +713,7 @@ idLight::On void idLight::On() { currentLevel = levels; + // offset the start time of the shader to sync it to the game time renderLight.shaderParms[ SHADERPARM_TIMEOFFSET ] = -MS2SEC( gameLocal.time ); if( ( soundWasPlaying || refSound.waitfortrigger ) && refSound.shader ) @@ -689,6 +733,7 @@ idLight::Off void idLight::Off() { currentLevel = 0; + // kill any sound it was making if( refSound.referenceSound && refSound.referenceSound->CurrentlyPlaying() ) { @@ -844,6 +889,14 @@ idLight::PresentModelDefChange */ void idLight::PresentModelDefChange() { + if( modelTarget ) + { + modelTarget->BecomeActive( TH_UPDATEVISUALS ); + modelTarget->Present(); + + return; + } + if( !renderEntity.hModel || IsHidden() ) { return; @@ -884,12 +937,30 @@ void idLight::Present() if( lightParent ) { renderLight.referenceSound = lightParent->GetSoundEmitter(); - renderEntity.referenceSound = lightParent->GetSoundEmitter(); + + if( modelTarget ) + { + renderEntity_t* rent = modelTarget->GetRenderEntity(); + rent->referenceSound = lightParent->GetSoundEmitter(); + } + else + { + renderEntity.referenceSound = lightParent->GetSoundEmitter(); + } } else { renderLight.referenceSound = refSound.referenceSound; - renderEntity.referenceSound = refSound.referenceSound; + + if( modelTarget ) + { + renderEntity_t* rent = modelTarget->GetRenderEntity(); + rent->referenceSound = refSound.referenceSound; + } + else + { + renderEntity.referenceSound = refSound.referenceSound; + } } // update the renderLight and renderEntity to render the light and flare @@ -1186,7 +1257,14 @@ idLight::Event_Hide */ void idLight::Event_Hide() { - Hide(); + if( modelTarget ) + { + modelTarget->Hide(); + } + else + { + Hide(); + } PresentModelDefChange(); Off(); } @@ -1198,7 +1276,14 @@ idLight::Event_Show */ void idLight::Event_Show() { - Show(); + if( modelTarget ) + { + modelTarget->Show(); + } + else + { + Show(); + } PresentModelDefChange(); On(); } @@ -1452,7 +1537,6 @@ idLight::ClientReceiveEvent */ bool idLight::ClientReceiveEvent( int event, int time, const idBitMsg& msg ) { - switch( event ) { case EVENT_BECOMEBROKEN: @@ -1466,3 +1550,23 @@ bool idLight::ClientReceiveEvent( int event, int time, const idBitMsg& msg ) } } } + +/* +================ +RB idLight::Event_UpdateModelTarget + +connects this light to its original and separate brush/patch model +================ +*/ +void idLight::Event_UpdateModelTarget() +{ + const char* target = spawnArgs.GetString( "modelTarget" ); + + idEntity* ent = gameLocal.FindEntity( target ); + if( ent->IsType( idStaticEntity::Type ) ) + { + modelTarget = static_cast( ent ); + + //ent->UpdateVisuals(); + } +} diff --git a/neo/d3xp/Light.h b/neo/d3xp/Light.h index 5bd0f45720..46531187f7 100644 --- a/neo/d3xp/Light.h +++ b/neo/d3xp/Light.h @@ -3,6 +3,8 @@ Doom 3 BFG Edition GPL Source Code Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 2021 Justin Marshall +Copyright (C) 2021-2024 Robert Beckebans This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). @@ -176,7 +178,7 @@ class idLight : public idEntity bool soundWasPlaying; // RB: pointing to static model because this light entity was split into 2 entities by convertMapToValve220 - //idEntityPtr staticModel; + idEntityPtr modelTarget; private: void PresentLightDefChange(); @@ -196,6 +198,7 @@ class idLight : public idEntity void Event_SetSoundHandles(); void Event_FadeOut( float time ); void Event_FadeIn( float time ); + void Event_UpdateModelTarget(); // jmarshall idList light_styles; diff --git a/neo/idlib/MapFile.cpp b/neo/idlib/MapFile.cpp index 7dbf1fa663..0b1d73f33c 100644 --- a/neo/idlib/MapFile.cpp +++ b/neo/idlib/MapFile.cpp @@ -3177,8 +3177,8 @@ bool idMapFile::ConvertToValve220Format() ent->epairs.Set( "name", uniqueName ); ent->epairs.Set( "model", uniqueName ); - // TODO replace this with other key that links idLight to func_static entity for syncing color/broken model - lightEnt->epairs.Set( "model", uniqueName ); + // link idLight to func_static entity for syncing color/broken model using new modelTarget key + lightEnt->epairs.Set( "modelTarget", uniqueName ); ent->epairs.SetInt( "_tb_group", tbGroupID ); // strip any light specific data From 1d5750569dfb42c4ce2bd35060e2d2cfce2f04d5 Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Thu, 16 May 2024 21:02:46 +0200 Subject: [PATCH 60/71] rvmLightStyleState_t -> iceLightStyleState_t --- neo/d3xp/Light.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/neo/d3xp/Light.h b/neo/d3xp/Light.h index 46531187f7..d029761455 100644 --- a/neo/d3xp/Light.h +++ b/neo/d3xp/Light.h @@ -44,9 +44,9 @@ extern const idEventDef EV_Light_SetLightParm; extern const idEventDef EV_Light_SetLightParms; // jmarshall -struct rvmLightStyleState_t +struct iceLightStyleState_t { - rvmLightStyleState_t(); + iceLightStyleState_t(); int dl_frame; float dl_framef; @@ -57,12 +57,12 @@ struct rvmLightStyleState_t void Reset(); }; -ID_INLINE rvmLightStyleState_t::rvmLightStyleState_t() +ID_INLINE iceLightStyleState_t::iceLightStyleState_t() { Reset(); } -ID_INLINE void rvmLightStyleState_t::Reset() +ID_INLINE void iceLightStyleState_t::Reset() { dl_frame = 0; dl_framef = 0; @@ -202,7 +202,7 @@ class idLight : public idEntity // jmarshall idList light_styles; - rvmLightStyleState_t lightStyleState; + iceLightStyleState_t lightStyleState; // jmarshall end }; From 2398670349ff8eb09bce8a2e09d6e86ad96a2470 Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Thu, 16 May 2024 21:41:29 +0200 Subject: [PATCH 61/71] Bumped savegame version for idLight::modelTarget --- neo/d3xp/Light.cpp | 19 +++++++++++++++++++ neo/framework/BuildVersion.h | 9 +++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/neo/d3xp/Light.cpp b/neo/d3xp/Light.cpp index ea52951df4..e9c5627167 100644 --- a/neo/d3xp/Light.cpp +++ b/neo/d3xp/Light.cpp @@ -276,6 +276,8 @@ idLight::idLight(): lightStyleBase.Set( 300, 300, 300 ); lightStyleState.Reset(); + + modelTarget = NULL; // RB end } @@ -324,6 +326,9 @@ void idLight::Save( idSaveGame* savefile ) const savefile->WriteInt( fadeStart ); savefile->WriteInt( fadeEnd ); savefile->WriteBool( soundWasPlaying ); + + // RB: TODO light styles + modelTarget.Save( savefile ); } /* @@ -360,6 +365,11 @@ void idLight::Restore( idRestoreGame* savefile ) savefile->ReadInt( fadeEnd ); savefile->ReadBool( soundWasPlaying ); + if( savefile->GetBuildNumber() >= BUILD_NUMBER_SAVE_VERSION_LIGHT_MODELTARGET_CHANGE ) + { + modelTarget.Restore( savefile ); + } + lightDefHandle = -1; SetLightLevel(); @@ -520,6 +530,15 @@ void idLight::Spawn() idClipModel::CheckModel( brokenModel ); } + // RB: link func_static modelTarget + //modelTarget = NULL; + const char* target = spawnArgs.GetString( "modelTarget" ); + if( target != NULL && target[0] != '\0' ) + { + PostEventMS( &EV_Light_UpdateModelTarget, 0 ); + } + // RB end + PostEventMS( &EV_PostSpawn, 0 ); UpdateVisuals(); diff --git a/neo/framework/BuildVersion.h b/neo/framework/BuildVersion.h index de76a91af6..edd4488486 100644 --- a/neo/framework/BuildVersion.h +++ b/neo/framework/BuildVersion.h @@ -26,9 +26,10 @@ If you have questions concerning this license or the applicable additional terms =========================================================================== */ -const int BUILD_NUMBER_SAVE_VERSION_BEFORE_SKIP_CINEMATIC = 1400; -const int BUILD_NUMBER_SAVE_VERSION_CHANGE = 1401; // Altering saves so that the version goes in the Details file that we read in during the enumeration phase -const int BUILD_NUMBER_SAVE_VERSION_SCRIPT_CHANGES1 = 1402; // RB: Merged script compiler changes from Dhewm3 so functions don't need declarations before used +const int BUILD_NUMBER_SAVE_VERSION_BEFORE_SKIP_CINEMATIC = 1400; +const int BUILD_NUMBER_SAVE_VERSION_CHANGE = 1401; // Altering saves so that the version goes in the Details file that we read in during the enumeration phase +const int BUILD_NUMBER_SAVE_VERSION_SCRIPT_CHANGES1 = 1402; // RB: Merged script compiler changes from Dhewm3 so functions don't need declarations before used +const int BUILD_NUMBER_SAVE_VERSION_LIGHT_MODELTARGET_CHANGE = 1403; // RB: added idLight::modelTarget entity pointer -const int BUILD_NUMBER = BUILD_NUMBER_SAVE_VERSION_SCRIPT_CHANGES1; +const int BUILD_NUMBER = BUILD_NUMBER_SAVE_VERSION_LIGHT_MODELTARGET_CHANGE; const int BUILD_NUMBER_MINOR = 0; From f91342634871564dfade41a8d629c0f9046107d4 Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Fri, 17 May 2024 16:28:32 +0200 Subject: [PATCH 62/71] Allow scalable models like in Quake 3. Close #668 --- neo/d3xp/Entity.cpp | 39 ++++++++++++++++++++++++++++++--------- neo/d3xp/Light.cpp | 11 ++++++++++- 2 files changed, 40 insertions(+), 10 deletions(-) diff --git a/neo/d3xp/Entity.cpp b/neo/d3xp/Entity.cpp index 3d66009600..046d32da97 100644 --- a/neo/d3xp/Entity.cpp +++ b/neo/d3xp/Entity.cpp @@ -320,18 +320,19 @@ void idGameEdit::ParseSpawnArgsToRenderEntity( const idDict* args, renderEntity_ if( !args->GetMatrix( "rotation", "1 0 0 0 1 0 0 0 1", renderEntity->axis ) ) { // RB: TrenchBroom interop - // support "angles" like in Quake 3 + // support "angles", "modelscale" and "modelscale_vec" like in Quake 3 idAngles angles; + idMat3 rotMat; + idMat3 scaleMat; + + rotMat.Identity(); + scaleMat.Identity(); if( args->GetAngles( "angles", "0 0 0", angles ) ) { if( angles.pitch != 0.0f || angles.yaw != 0.0f || angles.roll != 0.0f ) { - renderEntity->axis = angles.ToMat3(); - } - else - { - renderEntity->axis.Identity(); + rotMat = angles.ToMat3(); } } else @@ -339,13 +340,33 @@ void idGameEdit::ParseSpawnArgsToRenderEntity( const idDict* args, renderEntity_ angle = args->GetFloat( "angle" ); if( angle != 0.0f ) { - renderEntity->axis = idAngles( 0.0f, angle, 0.0f ).ToMat3(); + rotMat = idAngles( 0.0f, angle, 0.0f ).ToMat3(); } - else + } + + idVec3 scaleVec; + if( args->GetVector( "modelscale_vec", "1 1 1", scaleVec ) ) + { + // don't allow very small and negative values + if( ( scaleVec.x != 1.0f || scaleVec.y != 1.0f || scaleVec.z != 1.0f ) && ( scaleVec.x > 0.01f && scaleVec.y > 0.01f && scaleVec.z > 0.01f ) ) { - renderEntity->axis.Identity(); + scaleMat[0][0] = scaleVec.x; + scaleMat[1][1] = scaleVec.y; + scaleMat[2][2] = scaleVec.z; } } + else + { + float scale = args->GetFloat( "modelscale", 1.0f ); + if( scale != 1.0f && scale > 0.01f ) + { + scaleMat[0][0] = scale; + scaleMat[1][1] = scale; + scaleMat[2][2] = scale; + } + } + + renderEntity->axis = scaleMat * rotMat; // RB end } diff --git a/neo/d3xp/Light.cpp b/neo/d3xp/Light.cpp index e9c5627167..34f419f08f 100644 --- a/neo/d3xp/Light.cpp +++ b/neo/d3xp/Light.cpp @@ -234,7 +234,16 @@ void idLight::UpdateChangeableSpawnArgs( const idDict* source ) // link func_static modelTarget modelTarget = NULL; - const char* target = source->GetString( "modelTarget" ); + const char* target = NULL; + if( source ) + { + target = source->GetString( "modelTarget" ); + } + else + { + target = spawnArgs.GetString( "modelTarget" ); + } + if( target != NULL && target[0] != '\0' ) { PostEventMS( &EV_Light_UpdateModelTarget, 0 ); From 0657a59c69edc0dce00566d23269183b1b4f03ca Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Fri, 17 May 2024 21:21:03 +0200 Subject: [PATCH 63/71] Don't try to cache models by the new model* keywords --- neo/d3xp/Game_local.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/neo/d3xp/Game_local.cpp b/neo/d3xp/Game_local.cpp index 7dbe47135a..cdf05d86e5 100644 --- a/neo/d3xp/Game_local.cpp +++ b/neo/d3xp/Game_local.cpp @@ -1883,7 +1883,9 @@ void idGameLocal::CacheDictionaryMedia( const idDict* dict ) kv = dict->MatchPrefix( "model" ); while( kv ) { - if( kv->GetValue().Length() ) + const char* modelKey = kv->GetKey().c_str(); + + if( kv->GetValue().Length() && idStr::Icmp( modelKey, "modelTarget" ) != 0 && idStr::Icmpn( modelKey, "modelscale", 10 ) != 0 ) { declManager->MediaPrint( "Precaching model %s\n", kv->GetValue().c_str() ); From 5561411f6534f31691b4a934ede06e99a8bf0907 Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Fri, 17 May 2024 21:35:27 +0200 Subject: [PATCH 64/71] Sync non-SSE bounding box calcuation in idRenderModelGLTF::UpdateSurface --- neo/renderer/Model_gltf.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/neo/renderer/Model_gltf.cpp b/neo/renderer/Model_gltf.cpp index ab401f0cc7..c9addf099c 100644 --- a/neo/renderer/Model_gltf.cpp +++ b/neo/renderer/Model_gltf.cpp @@ -1942,13 +1942,13 @@ void idRenderModelGLTF::UpdateSurface( const struct renderEntity_s* ent, const i _mm_store_ss( tri->bounds.ToFloatPtr() + 5, _mm_splat_ps( maxZ, 3 ) ); #else - bounds.Clear(); - for( int i = 0; i < jointIds.Num(); i++ ) + tri->bounds.Clear(); + for( int i = 0; i < md5joints.Num(); i++ ) { const idJointMat& joint = entJoints[i]; - bounds.AddPoint( joint.GetTranslation() ); + tri->bounds.AddPoint( joint.GetTranslation() ); } - bounds.ExpandSelf( maxJointVertDist ); + tri->bounds.ExpandSelf( maxJointVertDist ); #endif From f548ee56dede486424180a995a940a26ef2da466 Mon Sep 17 00:00:00 2001 From: SRSaunders <82544213+SRSaunders@users.noreply.github.com> Date: Sat, 18 May 2024 11:42:05 -0400 Subject: [PATCH 65/71] Revert VK_KHR_maintenance4 and suppress messageID=0x609a13b for older Vulkan SDKs --- neo/sys/DeviceManager_VK.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/neo/sys/DeviceManager_VK.cpp b/neo/sys/DeviceManager_VK.cpp index 11a7479287..86599b71a2 100644 --- a/neo/sys/DeviceManager_VK.cpp +++ b/neo/sys/DeviceManager_VK.cpp @@ -269,9 +269,6 @@ class DeviceManager_VK : public DeviceManager #endif #if defined( VK_KHR_format_feature_flags2 ) VK_KHR_FORMAT_FEATURE_FLAGS_2_EXTENSION_NAME, -#endif -#if defined( VK_KHR_maintenance4 ) - VK_KHR_MAINTENANCE_4_EXTENSION_NAME, #endif VK_KHR_SYNCHRONIZATION_2_EXTENSION_NAME, VK_EXT_MEMORY_BUDGET_EXTENSION_NAME @@ -1254,13 +1251,17 @@ bool DeviceManager_VK::CreateDeviceAndSwapChain() #else enabledExtensions.layers.insert( "VK_LAYER_KHRONOS_validation" ); - // SRS - Suppress specific [ WARNING-Shader-OutputNotConsumed ] false positive validation warnings which are by design: + // SRS - Suppress specific [ WARNING-Shader-OutputNotConsumed ] validation warnings which are by design: // 0xc81ad50e: vkCreateGraphicsPipelines(): pCreateInfos[0].pVertexInputState Vertex attribute at location X not consumed by vertex shader. - // 0x9805298c: vkCreateGraphicsPipelines(): pCreateInfos[0] fragment shader writes to output location 0 with no matching attachment. + // 0x9805298c: vkCreateGraphicsPipelines(): pCreateInfos[0] fragment shader writes to output location X with no matching attachment. + // SRS - Suppress similar [ UNASSIGNED-CoreValidation-Shader-OutputNotConsumed ] warnings for older Vulkan SDKs: + // 0x609a13b: vertex shader writes to output location X.0 which is not consumed by fragment shader... + // 0x609a13b: Vertex attribute at location X not consumed by vertex shader. + // 0x609a13b: fragment shader writes to output location X with no matching attachment. #ifdef _WIN32 - SetEnvironmentVariable( "VK_LAYER_MESSAGE_ID_FILTER", "0xc81ad50e;0x9805298c" ); + SetEnvironmentVariable( "VK_LAYER_MESSAGE_ID_FILTER", "0xc81ad50e;0x9805298c;0x609a13b" ); #else - setenv( "VK_LAYER_MESSAGE_ID_FILTER", "0xc81ad50e:0x9805298c", 1 ); + setenv( "VK_LAYER_MESSAGE_ID_FILTER", "0xc81ad50e:0x9805298c:0x609a13b", 1 ); #endif } From 8613b2bc695f1f384177dc9d09a7f3163a9c9de5 Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Tue, 21 May 2024 20:12:03 +0200 Subject: [PATCH 66/71] Fixed crash with Vulkan when using the colorProcess shader. Close #891 --- neo/shaders/colorProcess.ps.hlsl | 2 +- neo/shaders/colorProcess.vs.hlsl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/neo/shaders/colorProcess.ps.hlsl b/neo/shaders/colorProcess.ps.hlsl index fb3dcf43a9..6b674b3ed6 100644 --- a/neo/shaders/colorProcess.ps.hlsl +++ b/neo/shaders/colorProcess.ps.hlsl @@ -32,7 +32,7 @@ If you have questions concerning this license or the applicable additional terms // *INDENT-OFF* Texture2D t_CurrentRender : register( t0 VK_DESCRIPTOR_SET( 0 ) ); -SamplerState LinearSampler : register( s0 VK_DESCRIPTOR_SET( 2 ) ); +SamplerState LinearSampler : register( s0 VK_DESCRIPTOR_SET( 1 ) ); struct PS_IN { diff --git a/neo/shaders/colorProcess.vs.hlsl b/neo/shaders/colorProcess.vs.hlsl index c625acba78..c2546ce8a2 100644 --- a/neo/shaders/colorProcess.vs.hlsl +++ b/neo/shaders/colorProcess.vs.hlsl @@ -59,7 +59,7 @@ void main( VS_IN vertex, out VS_OUT result ) result.color = rpUser1; // targetHue result.texcoord0.x = vertex.texcoord.x; - result.texcoord0.y = 1.0f - vertex.texcoord.y; + result.texcoord0.y = /*1.0f -*/ vertex.texcoord.y; result.texcoord0.z = rpUser0.x; // fraction } From c4d951443b8fa70c5df9cbad988e29f1083d175b Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Tue, 21 May 2024 21:05:52 +0200 Subject: [PATCH 67/71] Automatically sign in master user if compiled without DOOM_CLASSIC. close #892 --- neo/sys/DeviceManager_VK.cpp | 6 +++--- neo/sys/sys_session_local.cpp | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/neo/sys/DeviceManager_VK.cpp b/neo/sys/DeviceManager_VK.cpp index 86599b71a2..a43fd4b03c 100644 --- a/neo/sys/DeviceManager_VK.cpp +++ b/neo/sys/DeviceManager_VK.cpp @@ -1258,11 +1258,11 @@ bool DeviceManager_VK::CreateDeviceAndSwapChain() // 0x609a13b: vertex shader writes to output location X.0 which is not consumed by fragment shader... // 0x609a13b: Vertex attribute at location X not consumed by vertex shader. // 0x609a13b: fragment shader writes to output location X with no matching attachment. - #ifdef _WIN32 +#ifdef _WIN32 SetEnvironmentVariable( "VK_LAYER_MESSAGE_ID_FILTER", "0xc81ad50e;0x9805298c;0x609a13b" ); - #else +#else setenv( "VK_LAYER_MESSAGE_ID_FILTER", "0xc81ad50e:0x9805298c:0x609a13b", 1 ); - #endif +#endif } // SRS - make static so ~DynamicLoader() does not prematurely unload vulkan dynamic lib diff --git a/neo/sys/sys_session_local.cpp b/neo/sys/sys_session_local.cpp index 3e7433bcb4..e9addce02a 100644 --- a/neo/sys/sys_session_local.cpp +++ b/neo/sys/sys_session_local.cpp @@ -2676,6 +2676,9 @@ void idSessionLocal::UpdateSignInManager() #if defined( USE_DOOMCLASSIC ) // If we don't have a master user at all, then we need to be at "Press Start" MoveToPressStart( GDM_SP_SIGNIN_CHANGE_POST ); +#else + // RB: automatically sign in the first user. This enumerates the savegames #892 + session->GetSignInManager().RegisterLocalUser( 0 ); #endif return; } From 2c9d4e0b1487cbca9605abef025ce7d6388000ba Mon Sep 17 00:00:00 2001 From: Karin Date: Thu, 30 May 2024 20:19:26 +0800 Subject: [PATCH 68/71] Explicit font's position's type is signed char idFont::fontInfo_t::ascii should be not effect it. --- neo/renderer/Font.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/neo/renderer/Font.h b/neo/renderer/Font.h index 56cae30739..acd255dd49 100644 --- a/neo/renderer/Font.h +++ b/neo/renderer/Font.h @@ -68,8 +68,8 @@ class idFont { byte width; // width of glyph in pixels byte height; // height of glyph in pixels - char top; // distance in pixels from the base line to the top of the glyph - char left; // distance in pixels from the pen to the left edge of the glyph + signed char top; // distance in pixels from the base line to the top of the glyph + signed char left; // distance in pixels from the pen to the left edge of the glyph byte xSkip; // x adjustment after rendering this glyph uint16 s; // x offset in image where glyph starts (in pixels) uint16 t; // y offset in image where glyph starts (in pixels) From bef28ab428ff3ec613275f5ed8c964247ace584f Mon Sep 17 00:00:00 2001 From: Karin Date: Thu, 30 May 2024 20:25:11 +0800 Subject: [PATCH 69/71] Make move type is signed char If as unsigned char, always move forward and right, and speed is faster. --- doomclassic/doom/d_ticcmd.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doomclassic/doom/d_ticcmd.h b/doomclassic/doom/d_ticcmd.h index 609c08ec86..50b261d063 100644 --- a/doomclassic/doom/d_ticcmd.h +++ b/doomclassic/doom/d_ticcmd.h @@ -41,8 +41,8 @@ If you have questions concerning this license or the applicable additional terms // plus a checksum for internal state consistency. typedef struct { - char forwardmove; // *2048 for move - char sidemove; // *2048 for move + signed char forwardmove; // *2048 for move + signed char sidemove; // *2048 for move short angleturn; // <<16 for angle delta short consistancy; // checks for net game byte buttons; From d1c63f8821e5dad5aa1305adeb78edf3788ed3af Mon Sep 17 00:00:00 2001 From: Karin Date: Thu, 30 May 2024 20:27:52 +0800 Subject: [PATCH 70/71] Linux arm 32bits compile --- neo/idlib/sys/sys_defines.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/neo/idlib/sys/sys_defines.h b/neo/idlib/sys/sys_defines.h index f053d9aea0..03569f800f 100644 --- a/neo/idlib/sys/sys_defines.h +++ b/neo/idlib/sys/sys_defines.h @@ -130,6 +130,8 @@ If you have questions concerning this license or the applicable additional terms #define CPUSTRING "sparc" #elif defined(__loongarch64) #define CPUSTRING "loongarch64" + #elif defined(__arm__) + #define CPUSTRING "arm" #else #error unknown CPU #endif From 3a944086078453c75360d05eff721ad3fe6c947a Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Sun, 2 Jun 2024 16:11:19 +0200 Subject: [PATCH 71/71] Fixed typo in cmake-vs2022-arm64.bat --- neo/cmake-vs2019-arm64.bat | 6 ------ neo/cmake-vs2022-arm64.bat | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) delete mode 100644 neo/cmake-vs2019-arm64.bat diff --git a/neo/cmake-vs2019-arm64.bat b/neo/cmake-vs2019-arm64.bat deleted file mode 100644 index 31c11fc6f7..0000000000 --- a/neo/cmake-vs2019-arm64.bat +++ /dev/null @@ -1,6 +0,0 @@ -cd .. -del /s /q build -mkdir build -cd build -cmake -G "Visual Studio 16" -A arm64 -DUSE_INTRINSICS_SSE=OFF -DFFMPEG=OFF -DBINKDEC=ON ../neo -pause \ No newline at end of file diff --git a/neo/cmake-vs2022-arm64.bat b/neo/cmake-vs2022-arm64.bat index ba5b49d515..5bb3bb1659 100644 --- a/neo/cmake-vs2022-arm64.bat +++ b/neo/cmake-vs2022-arm64.bat @@ -2,5 +2,5 @@ cd .. del /s /q build mkdir build cd build -cmake -G "Visual Studio 17" -A arm64 -DUSE_INTRINSICS_SSE=OFF VULKAN=OFF -DFFMPEG=OFF -DBINKDEC=ON ../neo +cmake -G "Visual Studio 17" -A arm64 -DUSE_INTRINSICS_SSE=OFF -DVULKAN=OFF -DFFMPEG=OFF -DBINKDEC=ON ../neo pause \ No newline at end of file