Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Divide large constant buffer into subsets and implement push constants for Vulkan performance #818

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
5320c57
Divide large constant buffer into subsets and implement push constant…
SRSaunders Oct 4, 2023
9956923
Remove need for barrier command list on Vulkan, simplifies code and e…
SRSaunders Oct 4, 2023
5475976
Add CPU / GPU usage % to HUD overlay and display MoltenVK's Metal enc…
SRSaunders Oct 4, 2023
54f5ffb
Refactor renderParmSets to fit within D3D12 root constant limit and r…
SRSaunders Oct 9, 2023
e96321f
Fix ssao_compute.hlsl for compatibility with multiple HLSL versions (…
SRSaunders Oct 9, 2023
509b196
Clamp max push constant size to nvrhi::c_MaxPushConstantSize
SRSaunders Oct 10, 2023
5a76607
Define r_useDX12PushConstants cvar (default off) to control DX12 push…
SRSaunders Oct 10, 2023
0f9f4f6
CMakeLists: Add wildcards to remove tmp files from ZERO_CHECK regener…
SRSaunders Oct 12, 2023
ba2df1b
Merge latest changes from upstream master
SRSaunders Oct 12, 2023
86dc341
macOS: Disable GPU skinning on Apple Silicon to eliminate rendering a…
SRSaunders Oct 13, 2023
6707d42
macOS: Update cmake*.sh build scripts for openal-soft path portabilit…
SRSaunders Oct 15, 2023
83b97d0
Work around missing Vulkan shaderStorageImageReadWithoutFormat on Int…
SRSaunders Oct 17, 2023
638ae85
Vulkan: Detect and enable fragment shading rate features at individua…
SRSaunders Oct 19, 2023
2063c72
Fix uniforms change detection and add r_useVulkanPushConstants cvar (…
SRSaunders Oct 21, 2023
c1f712a
Simplify change detection logic that controls writing of constant buf…
SRSaunders Oct 24, 2023
18769ec
Add comments, remove redundant call to Vulkan getProperties, enable K…
SRSaunders Oct 27, 2023
ea6d698
Memory Optimization: allocate constant buffers only when push constan…
SRSaunders Nov 29, 2023
8a0c493
Statistics HUD: smooth CPU/GPU usage, add GPU Memory for mode 3; CMak…
SRSaunders Nov 30, 2023
ee3b6f9
Fix ImmediateMode so debug tools work properly with push constants
SRSaunders Dec 20, 2023
b3f627d
Merge branch 'master' into push-constants
SRSaunders Dec 26, 2023
f3c65ee
macOS: Support VK_EXT_layer_settings for MoltenVK >= 1.2.7 / Vulkan S…
SRSaunders Dec 28, 2023
3b6598b
Don't reset or lock r_useGPUSkinning cvar in multiplayer mode (not a …
SRSaunders Jan 2, 2024
96ddf7b
Merge branch 'RobertBeckebans:master' into push-constants
SRSaunders Jan 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ Recommended in this case is `cmake-vs2022-win64-no-ffmpeg.bat`

Xcode release and universal builds now automatically package the executable into a macOS app bundle, defining an Info.plist file and copying the base directory and custom icon into the application bundle's Contents/Resources folder. This is controlled by adding -DMACOSX_BUNDLE=ON to the CMake options.

Depending on which package manager you install (Homebrew or MacPorts) you may need to change the openal-soft library and include paths specified in the cmake shell scripts. For single architecture builds (debug, release, retail) the default openal-soft paths are set for Homebrew on x86, while for universal builds the default paths are set for MacPorts on x86 or Apple Silicon. If you want to build using the single architecture shell scripts (debug, release, retail) on Apple Silicon, you will need to change the openal-soft paths from `/usr/local/...` to either `/opt/homebrew/...` (Homebrew) or `/opt/local/...` (MacPorts).
For single architecture builds (debug, release, retail) the default openal-soft paths are set for Homebrew, while for universal builds the default paths are set for MacPorts. The single architecture build scripts are now portable and automatically detect Homebrew's openal-soft path prefix for x86 and Apple Silicon. The universal build script remains portable since MacPorts uses the same openal-soft installation path on x86 and Apple Silicon.

4. Compile RBDOOM-3-BFG targets:

Expand Down
6 changes: 5 additions & 1 deletion neo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,8 @@ if(USE_VULKAN)
if(USE_VMA)
add_definitions(-DUSE_AMD_ALLOCATOR)
include_directories("libs/vma/include")
file(GLOB VMA_INCLUDES libs/vma/include/*.h)
source_group("libs\\vma" FILES ${VMA_INCLUDES})
endif()

endif()
Expand Down Expand Up @@ -1304,6 +1306,7 @@ set(RBDOOM3_INCLUDES
#${FREETYPE_SOURCES}
${SOUND_INCLUDES}
${OGGVORBIS_INCLUDES}
${VMA_INCLUDES}
${OPTICK_INCLUDES}
${UI_INCLUDES}
${SWF_INCLUDES}
Expand Down Expand Up @@ -1776,7 +1779,8 @@ else()
# delete precompiled header file after executable is compiled: IDE build case (e.g. Xcode)
else()
add_custom_command(TARGET RBDoom3BFG POST_BUILD
COMMAND ${remove_command} "idlib/precompiled.h.gch"
# SRS - added wildcards to remove tmp files from cmake ZERO_CHECK regeneration
COMMAND ${remove_command} "idlib/precompiled.h*.gch*"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "remove idlib/precompiled.h.gch"
)
Expand Down
13 changes: 12 additions & 1 deletion neo/cmake-macos-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,16 @@ cd ..
rm -rf build
mkdir build
cd build

# asemarafa/SRS - Determine the Homebrew path prefix for openal-soft
if [ -z "$OPENAL_PREFIX" ]; then
OPENAL_PREFIX=$(brew --prefix openal-soft 2>/dev/null)
if [ -z "$OPENAL_PREFIX" ]; then
echo "Error: openal-soft is not installed via Homebrew."
echo "Either install it using 'brew install openal-soft' or define the path prefix via OPENAL_PREFIX."
exit 1
fi
fi

# change or remove -DCMAKE_OSX_DEPLOYMENT_TARGET=<version> to match supported runtime targets
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS_RELEASE="-DNDEBUG" -DCMAKE_OSX_DEPLOYMENT_TARGET=12.1 -DFFMPEG=OFF -DBINKDEC=ON -DUSE_MoltenVK=ON -DOPENAL_LIBRARY=/usr/local/opt/openal-soft/lib/libopenal.dylib -DOPENAL_INCLUDE_DIR=/usr/local/opt/openal-soft/include ../neo -Wno-dev
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS_RELEASE="-DNDEBUG" -DCMAKE_OSX_DEPLOYMENT_TARGET=12.1 -DFFMPEG=OFF -DBINKDEC=ON -DUSE_MoltenVK=ON -DOPENAL_LIBRARY=$OPENAL_PREFIX/lib/libopenal.dylib -DOPENAL_INCLUDE_DIR=$OPENAL_PREFIX/include ../neo -Wno-dev
13 changes: 12 additions & 1 deletion neo/cmake-macos-retail.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,16 @@ cd ..
rm -rf build
mkdir build
cd build

# asemarafa/SRS - Determine the Homebrew path prefix for openal-soft
if [ -z "$OPENAL_PREFIX" ]; then
OPENAL_PREFIX=$(brew --prefix openal-soft 2>/dev/null)
if [ -z "$OPENAL_PREFIX" ]; then
echo "Error: openal-soft is not installed via Homebrew."
echo "Either install it using 'brew install openal-soft' or define the path prefix via OPENAL_PREFIX."
exit 1
fi
fi

# change or remove -DCMAKE_OSX_DEPLOYMENT_TARGET=<version> to match supported runtime targets
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS_RELEASE="-DNDEBUG -DID_RETAIL" -DCMAKE_OSX_DEPLOYMENT_TARGET=12.1 -DFFMPEG=OFF -DBINKDEC=ON -DUSE_MoltenVK=ON -DOPENAL_LIBRARY=/usr/local/opt/openal-soft/lib/libopenal.dylib -DOPENAL_INCLUDE_DIR=/usr/local/opt/openal-soft/include ../neo -Wno-dev
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS_RELEASE="-DNDEBUG -DID_RETAIL" -DCMAKE_OSX_DEPLOYMENT_TARGET=12.1 -DFFMPEG=OFF -DBINKDEC=ON -DUSE_MoltenVK=ON -DOPENAL_LIBRARY=$OPENAL_PREFIX/lib/libopenal.dylib -DOPENAL_INCLUDE_DIR=$OPENAL_PREFIX/include ../neo -Wno-dev
14 changes: 13 additions & 1 deletion neo/cmake-xcode-debug.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,22 @@ cd ..
rm -rf xcode-debug
mkdir xcode-debug
cd xcode-debug

# asemarafa/SRS - Determine the Homebrew path prefix for openal-soft
if [ -z "$OPENAL_PREFIX" ]; then
OPENAL_PREFIX=$(brew --prefix openal-soft 2>/dev/null)
if [ -z "$OPENAL_PREFIX" ]; then
echo "Error: openal-soft is not installed via Homebrew."
echo "Either install it using 'brew install openal-soft' or define the path prefix via OPENAL_PREFIX."
exit 1
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
# 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)
# 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
# note 5: env variable MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS=2 enables MoltenVK's use of Metal argument buffers only if VK_EXT_descriptor_indexing is enabled
cmake -G Xcode -DCMAKE_BUILD_TYPE=Debug -DCMAKE_XCODE_GENERATE_SCHEME=ON -DCMAKE_XCODE_SCHEME_ENVIRONMENT="MVK_CONFIG_FULL_IMAGE_VIEW_SWIZZLE=1;MVK_CONFIG_SYNCHRONOUS_QUEUE_SUBMITS=0;MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS=2" -DCMAKE_XCODE_SCHEME_ENABLE_GPU_API_VALIDATION=OFF -DCMAKE_SUPPRESS_REGENERATION=ON -DOPENAL_LIBRARY=/usr/local/opt/openal-soft/lib/libopenal.dylib -DOPENAL_INCLUDE_DIR=/usr/local/opt/openal-soft/include ../neo -DCMAKE_POLICY_DEFAULT_CMP0142=NEW -Wno-dev
# note 6: env variable MVK_CONFIG_TIMESTAMP_PERIOD_LOWPASS_ALPHA=1.0 disables MoltenVK's timestampPeriod lowpass filter for non-Apple GPUs
cmake -G Xcode -DCMAKE_BUILD_TYPE=Debug -DCMAKE_XCODE_GENERATE_SCHEME=ON -DCMAKE_XCODE_SCHEME_ENVIRONMENT="MVK_CONFIG_FULL_IMAGE_VIEW_SWIZZLE=1;MVK_CONFIG_SYNCHRONOUS_QUEUE_SUBMITS=0;MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS=2;MVK_CONFIG_TIMESTAMP_PERIOD_LOWPASS_ALPHA=1.0" -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
13 changes: 12 additions & 1 deletion neo/cmake-xcode-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,18 @@ cd ..
rm -rf xcode-release
mkdir xcode-release
cd xcode-release

# asemarafa/SRS - Determine the Homebrew path prefix for openal-soft
if [ -z "$OPENAL_PREFIX" ]; then
OPENAL_PREFIX=$(brew --prefix openal-soft 2>/dev/null)
if [ -z "$OPENAL_PREFIX" ]; then
echo "Error: openal-soft is not installed via Homebrew."
echo "Either install it using 'brew install openal-soft' or define the path prefix via OPENAL_PREFIX."
exit 1
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=/usr/local/opt/openal-soft/lib/libopenal.dylib -DOPENAL_INCLUDE_DIR=/usr/local/opt/openal-soft/include ../neo -DCMAKE_POLICY_DEFAULT_CMP0142=NEW -Wno-dev
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
9 changes: 9 additions & 0 deletions neo/cmake-xcode-universal.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@ cd ..
rm -rf xcode-universal
mkdir xcode-universal
cd xcode-universal

# SRS - Determine if openal-soft universal variant is installed via MacPorts
OPENAL_VARIANTS=$(port info --variants openal-soft 2>/dev/null)
if [[ $OPENAL_VARIANTS != *universal* ]]; then
echo "Error: openal-soft universal variant is not installed via MacPorts."
echo "Please install it using 'sudo port install openal-soft +universal'"
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
Expand Down
25 changes: 21 additions & 4 deletions neo/framework/Common_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -380,14 +380,26 @@ class idCommonLocal : public idCommon
// RB end

// SRS start
uint64 GetRendererStartFrameSyncMicroseconds() const
void SetRendererMvkEncodeMicroseconds( uint64 mvkEncodeMicroSeconds )
{
return mainFrameTiming.finishSyncTime - mainFrameTiming.startSyncTime;
metal_encode = mvkEncodeMicroSeconds;
return;
}

uint64 GetRendererEndFrameSyncMicroseconds() const
uint64 GetRendererMvkEncodeMicroseconds() const
{
return mainFrameTiming.finishSyncTime_EndFrame - mainFrameTiming.startRenderTime;
return metal_encode;
}

void SetRendererGpuMemoryMB( int gpuMemoryMB )
{
gpu_memory = gpuMemoryMB;
return;
}

int GetRendererGpuMemoryMB() const
{
return gpu_memory;
}
// SRS end

Expand Down Expand Up @@ -604,6 +616,11 @@ class idCommonLocal : public idCommon
backEndCounters_t stats_backend;
performanceCounters_t stats_frontend;

// 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;

// Used during loading screens
int lastPacifierSessionTime;
int lastPacifierGuiTime;
Expand Down
29 changes: 25 additions & 4 deletions neo/framework/Console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,10 @@ float idConsoleLocal::DrawFPS( float y )
extern idCVar r_swapInterval;

static float previousTimes[FPS_FRAMES];
static float previousCpuUsage[FPS_FRAMES] = {};
static float previousGpuUsage[FPS_FRAMES] = {};
static float previousTimesNormalized[FPS_FRAMES_HISTORY];
static int index;
static int index = 0;
static int previous;
static int valuesOffset = 0;

Expand All @@ -239,6 +241,8 @@ float idConsoleLocal::DrawFPS( float y )
previous = t;

int fps = 0;
float cpuUsage = 0.0;
float gpuUsage = 0.0;

const float milliSecondsPerFrame = 1000.0f / com_engineHz_latched;

Expand All @@ -253,13 +257,17 @@ float idConsoleLocal::DrawFPS( float y )
for( int i = 0 ; i < FPS_FRAMES ; i++ )
{
total += previousTimes[i];
cpuUsage += previousCpuUsage[i];
gpuUsage += previousGpuUsage[i];
}
if( !total )
{
total = 1;
}
fps = 1000000 * FPS_FRAMES / total;
fps = ( fps + 500 ) / 1000;
cpuUsage /= FPS_FRAMES;
gpuUsage /= FPS_FRAMES;

const char* s = va( "%ifps", fps );
int w = strlen( s ) * BIGCHAR_WIDTH;
Expand Down Expand Up @@ -290,6 +298,7 @@ float idConsoleLocal::DrawFPS( float y )

const uint64 rendererBackEndTime = commonLocal.GetRendererBackEndMicroseconds();
const uint64 rendererShadowsTime = commonLocal.GetRendererShadowsMicroseconds();
const uint64 rendererMvkEncodeTime = commonLocal.GetRendererMvkEncodeMicroseconds();
const uint64 rendererGPUTime = commonLocal.GetRendererGPUMicroseconds();
const uint64 rendererGPUEarlyZTime = commonLocal.GetRendererGpuEarlyZMicroseconds();
const uint64 rendererGPU_SSAOTime = commonLocal.GetRendererGpuSSAOMicroseconds();
Expand All @@ -315,14 +324,18 @@ float idConsoleLocal::DrawFPS( float y )
// SRS - GPU idle time is simply the difference between measured frame-over-frame time and GPU busy time (directly from GPU timers)
const int64 rendererGPUIdleTime = frameBusyTime + frameIdleTime - rendererGPUTime;

// SRS - Save current CPU and GPU usage factors in ring buffer to calculate smoothed averages for future frames
previousCpuUsage[(index - 1) % FPS_FRAMES] = float( frameBusyTime - frameSyncTime ) / float( frameBusyTime + frameIdleTime ) * 100.0;
previousGpuUsage[(index - 1) % FPS_FRAMES] = float( rendererGPUTime ) / float( rendererGPUTime + rendererGPUIdleTime ) * 100.0;

#if 1

// RB: use ImGui to show more detailed stats about the scene loads
if( ImGuiHook::IsReadyToRender() )
{
// start smaller
int32 statsWindowWidth = 320;
int32 statsWindowHeight = 315;
int32 statsWindowHeight = 330;

if( com_showFPS.GetInteger() > 2 )
{
Expand Down Expand Up @@ -427,7 +440,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", deviceManager->GetRendererString() );
ImGui::TextColored( colorGold, "Device: %s, Memory: %i MB", deviceManager->GetRendererString(), commonLocal.GetRendererGpuMemoryMB() );

ImGui::TextColored( colorLtGrey, "GENERAL: views:%i draws:%i tris:%i",
commonLocal.stats_frontend.c_numViews,
Expand Down Expand Up @@ -477,7 +490,7 @@ float idConsoleLocal::DrawFPS( float y )

if( com_showFPS.GetInteger() > 2 )
{
const char* overlay = va( "Average FPS %i", fps );
const char* overlay = va( "Average FPS %-4i", fps );

ImGui::PlotLines( "Relative\nFrametime ms", previousTimesNormalized, FPS_FRAMES_HISTORY, valuesOffset, overlay, -10.0f, 10.0f, ImVec2( 0, 50 ) );
}
Expand All @@ -494,12 +507,20 @@ float idConsoleLocal::DrawFPS( float y )
ImGui::TextColored( gameThreadRenderTime > maxTime ? colorRed : colorWhite, "RF: %5llu us SSR: %5llu us", gameThreadRenderTime, rendererGPU_SSRTime );
ImGui::TextColored( rendererBackEndTime > maxTime ? colorRed : colorWhite, "RB: %5llu us Ambient Pass: %5llu us", rendererBackEndTime, rendererGPUAmbientPassTime );
ImGui::TextColored( rendererGPUShadowAtlasTime > maxTime ? colorRed : colorWhite, "Shadows: %5llu us Shadow Atlas: %5llu us", rendererShadowsTime, rendererGPUShadowAtlasTime );
#if defined(__APPLE__) && defined( USE_MoltenVK )
// SRS - For more recent versions of MoltenVK with enhanced performance statistics (v1.2.6 and later), display the Vulkan to Metal encoding thread time on macOS
ImGui::TextColored( rendererMvkEncodeTime > maxTime || rendererGPUInteractionsTime > maxTime ? colorRed : colorWhite, "Encode: %5lld us Interactions: %5llu us", rendererMvkEncodeTime, rendererGPUInteractionsTime );
ImGui::TextColored( rendererGPUShaderPassesTime > maxTime ? colorRed : colorWhite, "Sync: %5lld us Shader Pass: %5llu us", frameSyncTime, rendererGPUShaderPassesTime );
#else
ImGui::TextColored( rendererGPUInteractionsTime > maxTime ? colorRed : colorWhite, "Sync: %5lld us Interactions: %5llu us", frameSyncTime, rendererGPUInteractionsTime );
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( 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::End();
}
Expand Down
6 changes: 4 additions & 2 deletions neo/renderer/ImmediateMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ void fhImmediateMode::End()
vertexBuffer.Update( drawVerts, drawVertsUsed * sizeof( idDrawVert ), 0, false, commandList );
indexBuffer.Update( lineIndices, drawVertsUsed * sizeof( triIndex_t ), 0, false, commandList );

renderProgManager.CommitConstantBuffer( commandList, true );
renderProgManager.CommitConstantBuffer( commandList, false );

int bindingLayoutType = renderProgManager.BindingLayoutType();

Expand All @@ -147,7 +147,7 @@ void fhImmediateMode::End()

for( int i = 0; i < layouts->Num(); i++ )
{
if( !tr.backend.currentBindingSets[i] || *tr.backend.currentBindingSets[i]->getDesc() != tr.backend.pendingBindingSetDescs[bindingLayoutType][i] )
if( !tr.backend.currentBindingSets[i] || *tr.backend.currentBindingSets[i]->getDesc() != tr.backend.pendingBindingSetDescs[bindingLayoutType][i] || bindingLayoutType != tr.backend.prevBindingLayoutType )
{
tr.backend.currentBindingSets[i] = tr.backend.bindingCache.GetOrCreateBindingSet( tr.backend.pendingBindingSetDescs[bindingLayoutType][i], ( *layouts )[i] );
}
Expand Down Expand Up @@ -182,6 +182,8 @@ void fhImmediateMode::End()
state.viewport.addScissorRect( nvrhi::Rect( viewport ) );

commandList->setGraphicsState( state );

renderProgManager.CommitPushConstants( commandList, bindingLayoutType );
}

nvrhi::DrawArguments args;
Expand Down
9 changes: 6 additions & 3 deletions neo/renderer/Material.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2144,11 +2144,14 @@ void idMaterial::ParseStage( idLexer& src, const textureRepeat_t trpDefault )
ss->conditionRegister = ParseExpression( src );
continue;
}

auto usePushConstants = renderProgManager.layoutTypeAttributes[BINDING_LAYOUT_POST_PROCESS_INGAME].pcEnabled ? "1" : "0";

if( !token.Icmp( "program" ) )
{
if( src.ReadTokenOnLine( &token ) )
{
idList<shaderMacro_t> macros = { { "USE_GPU_SKINNING", "0" } };
idList<shaderMacro_t> macros = { { "USE_GPU_SKINNING", "0" }, { "USE_PUSH_CONSTANTS", usePushConstants } };
newStage.vertexProgram = renderProgManager.FindShader( token.c_str(), SHADER_STAGE_VERTEX, "", macros, false );
newStage.fragmentProgram = renderProgManager.FindShader( token.c_str(), SHADER_STAGE_FRAGMENT, "", macros, false );
}
Expand All @@ -2158,7 +2161,7 @@ void idMaterial::ParseStage( idLexer& src, const textureRepeat_t trpDefault )
{
if( src.ReadTokenOnLine( &token ) )
{
idList<shaderMacro_t> macros = { { "USE_GPU_SKINNING", "0" } };
idList<shaderMacro_t> macros = { { "USE_GPU_SKINNING", "0" }, { "USE_PUSH_CONSTANTS", usePushConstants } };
newStage.fragmentProgram = renderProgManager.FindShader( token.c_str(), SHADER_STAGE_FRAGMENT, "", macros, false );
}
continue;
Expand All @@ -2167,7 +2170,7 @@ void idMaterial::ParseStage( idLexer& src, const textureRepeat_t trpDefault )
{
if( src.ReadTokenOnLine( &token ) )
{
idList<shaderMacro_t> macros = { { "USE_GPU_SKINNING", "0" } };
idList<shaderMacro_t> macros = { { "USE_GPU_SKINNING", "0" }, { "USE_PUSH_CONSTANTS", usePushConstants } };
newStage.vertexProgram = renderProgManager.FindShader( token.c_str(), SHADER_STAGE_VERTEX, "", macros, false );
}
continue;
Expand Down
Loading