diff --git a/trinity/Eve/SpaceObject/EveSpaceObject2.cpp b/trinity/Eve/SpaceObject/EveSpaceObject2.cpp index 0dac34cba..79e82f1da 100644 --- a/trinity/Eve/SpaceObject/EveSpaceObject2.cpp +++ b/trinity/Eve/SpaceObject/EveSpaceObject2.cpp @@ -2149,13 +2149,13 @@ void EveSpaceObject2::RefreshDamageLocatorMask( const LocatorStructureList* dama void EveSpaceObject2::UpdateDamageLocatorFilter() { - TRINITY_STATS_ZONE( __FUNCTION__ ); - if( m_damageFilterState == DamageFilterState::Idle ) { return; } + TRINITY_STATS_ZONE( __FUNCTION__ ); + if( !m_damageLocatorAutoFilterEnabled && !m_damageLocatorFilterRequested ) { m_damageLocatorEnabled.clear(); diff --git a/trinity/PostProcess/Tr2PostProcessRenderer.cpp b/trinity/PostProcess/Tr2PostProcessRenderer.cpp index 60fdf3726..65406f48e 100644 --- a/trinity/PostProcess/Tr2PostProcessRenderer.cpp +++ b/trinity/PostProcess/Tr2PostProcessRenderer.cpp @@ -6,6 +6,7 @@ #include "Shader/Parameter/TriTextureParameter.h" #include "include/TriMath.h" #include "TriSettingsRegistrar.h" +#include "Utilities/StringUtils.h" // FidelityFX headers #define A_CPU @@ -26,8 +27,6 @@ TRI_REGISTER_SETTING( "newBloom", g_newBloom ); int32_t g_dynamicExposureQualityRequirement = PostProcess::Quality::MEDIUM; TRI_REGISTER_SETTING( "dynamicExposureQualityRequirement", g_dynamicExposureQualityRequirement ); -#define MEMOIZED_STRING( x ) ( []( const char* str ) { static BlueSharedString s( str ); return s; }( x "" ) ) - namespace { const uint32_t HISTOGRAM_TILE_SIZE_X = 16; diff --git a/trinity/Tr2VolumetricsRenderer.cpp b/trinity/Tr2VolumetricsRenderer.cpp index 454ec2ee3..1a1f40f21 100644 --- a/trinity/Tr2VolumetricsRenderer.cpp +++ b/trinity/Tr2VolumetricsRenderer.cpp @@ -15,6 +15,7 @@ #include "Tr2LightManager.h" #include "Tr2TextureArray.h" #include "include/TriMath.h" +#include "Utilities/StringUtils.h" #include "Utilities/Vector4d.h" @@ -692,7 +693,7 @@ Tr2GpuResourcePool::Texture Tr2VolumetricsRenderer::RenderFog( if( shadowType == SHADOWS_RAYTRACED ) { uint32_t techniqueIndex; - if( !resources.rtCalculateFroxels->GetShaderStateInterface()->GetTechniqueIndex( BlueSharedString( "RtShadow" ), techniqueIndex ) ) + if( !resources.rtCalculateFroxels->GetShaderStateInterface()->GetTechniqueIndex( MEMOIZED_STRING( "RtShadow" ), techniqueIndex ) ) { CCP_LOGERR( "Failed to get technique index for raytraced froxel fog shadows!" ); return {}; @@ -700,7 +701,7 @@ Tr2GpuResourcePool::Texture Tr2VolumetricsRenderer::RenderFog( BlueSharedStringW rayGenName; BlueSharedStringW missName; - m_pipelineManager.AddLibrary( rayGenName, missName, resources.rtCalculateFroxels, BlueSharedString( "RtShadow" ) ); + m_pipelineManager.AddLibrary( rayGenName, missName, resources.rtCalculateFroxels, MEMOIZED_STRING( "RtShadow" ) ); Tr2RtPipelineStateAL pipelineState = m_pipelineManager.GetPipelineState( renderContext ); @@ -713,20 +714,27 @@ Tr2GpuResourcePool::Texture Tr2VolumetricsRenderer::RenderFog( Tr2RtLocalMaterialDescriptionAL material; material.SetConstants( Tr2Renderer::GetPerObjectVSStartRegister(), m_fogConstantBuffer ); - TRINITY_STATS_ZONE( "Create shader table" ); - m_shaderTableDesc.AddRayGenShader( rayGenName.c_str(), material ); - m_shaderTableDesc.AddMissShader( missName.c_str(), material ); - - Tr2RtShaderTableAL shadowShaderTable; - shadowShaderTable.Create( m_shaderTableDesc, pipelineState, renderContext.GetPrimaryRenderContext() ); + { + TRINITY_STATS_ZONE( "Create shader table" ); + m_shaderTableDesc.AddRayGenShader( rayGenName.c_str(), material ); + m_shaderTableDesc.AddMissShader( missName.c_str(), material ); + if( !m_rtShadowShaderTable.IsValid() || FAILED( m_rtShadowShaderTable.Update( m_shaderTableDesc, pipelineState, renderContext.GetPrimaryRenderContext() ) ) ) + { + m_rtShadowShaderTable.Create( m_shaderTableDesc, pipelineState, renderContext.GetPrimaryRenderContext() ); + } + if( !m_rtShadowShaderTable.IsValid() ) + { + return {}; + } + } - resources.rtCalculateFroxels->SetOption( BlueSharedString( "GOD_RAY_NOISE" ), BlueSharedString( m_froxelFogSettings.godRayNoiseIntensity.value > 0.0f ? "GOD_RAY_NOISE_ENABLED" : "GOD_RAY_NOISE_DISABLED" ) ); - resources.rtCalculateFroxels->SetOption( BlueSharedString( "FOG_NOISE" ), BlueSharedString( m_froxelFogSettings.fogNoiseIntensity.value > 0.0f ? "FOG_NOISE_ENABLED" : "FOG_NOISE_DISABLED" ) ); + resources.rtCalculateFroxels->SetOption( MEMOIZED_STRING( "GOD_RAY_NOISE" ), m_froxelFogSettings.godRayNoiseIntensity.value > 0.0f ? MEMOIZED_STRING( "GOD_RAY_NOISE_ENABLED" ) : MEMOIZED_STRING( "GOD_RAY_NOISE_DISABLED" ) ); + resources.rtCalculateFroxels->SetOption( MEMOIZED_STRING( "FOG_NOISE" ), m_froxelFogSettings.fogNoiseIntensity.value > 0.0f ? MEMOIZED_STRING( "FOG_NOISE_ENABLED" ) : MEMOIZED_STRING( "FOG_NOISE_DISABLED" ) ); - resources.rtCalculateFroxels->SetParameter( BlueSharedString( "Noise3DTexture" ), m_froxel3DNoise ); - resources.rtCalculateFroxels->SetParameter( BlueSharedString( "RtFroxelOutputTexture" ), fogFroxels ); + resources.rtCalculateFroxels->SetParameter( MEMOIZED_STRING( "Noise3DTexture" ), m_froxel3DNoise ); + resources.rtCalculateFroxels->SetParameter( MEMOIZED_STRING( "RtFroxelOutputTexture" ), fogFroxels ); - resources.rtCalculateFroxels->SetParameter( BlueSharedString( "RtShadowScene" ), raytracingGeometry ); + resources.rtCalculateFroxels->SetParameter( MEMOIZED_STRING( "RtShadowScene" ), raytracingGeometry ); renderContext.SetRtPipelineState( pipelineState, rayGenName.c_str() ); resources.rtCalculateFroxels->ApplyMaterialDataForRtState( techniqueIndex, renderContext ); renderContext.UseAccelerationStructure( raytracingGeometry->GetTLAS() ); @@ -736,17 +744,17 @@ Tr2GpuResourcePool::Texture Tr2VolumetricsRenderer::RenderFog( renderContext.UseResources( Tr2UseResourceDestination::COMPUTE, Tr2GpuUsage::SHADER_RESOURCE, raytracingGeometry->GetBindlessResources() ); } - renderContext.DispatchRays( pipelineState, shadowShaderTable, rayGenName.c_str(), width, height, depth ); + renderContext.DispatchRays( pipelineState, m_rtShadowShaderTable, rayGenName.c_str(), width, height, depth ); } else { //Otherwise, just use a plain compute shader. - resources.calculateFroxels->SetOption( BlueSharedString( "SHADOWS" ), BlueSharedString( shadowType == SHADOWS_CASCADED ? "SHADOWS_ENABLED" : "SHADOWS_DISABLED" ) ); - resources.calculateFroxels->SetOption( BlueSharedString( "GOD_RAY_NOISE" ), BlueSharedString( m_froxelFogSettings.godRayNoiseIntensity.value > 0.0f ? "GOD_RAY_NOISE_ENABLED" : "GOD_RAY_NOISE_DISABLED" ) ); - resources.calculateFroxels->SetOption( BlueSharedString( "FOG_NOISE" ), BlueSharedString( m_froxelFogSettings.fogNoiseIntensity.value > 0.0f ? "FOG_NOISE_ENABLED" : "FOG_NOISE_DISABLED" ) ); + resources.calculateFroxels->SetOption( MEMOIZED_STRING( "SHADOWS" ), shadowType == SHADOWS_CASCADED ? MEMOIZED_STRING( "SHADOWS_ENABLED" ) : MEMOIZED_STRING( "SHADOWS_DISABLED" ) ); + resources.calculateFroxels->SetOption( MEMOIZED_STRING( "GOD_RAY_NOISE" ), m_froxelFogSettings.godRayNoiseIntensity.value > 0.0f ? MEMOIZED_STRING( "GOD_RAY_NOISE_ENABLED" ) : MEMOIZED_STRING( "GOD_RAY_NOISE_DISABLED" ) ); + resources.calculateFroxels->SetOption( MEMOIZED_STRING( "FOG_NOISE" ), m_froxelFogSettings.fogNoiseIntensity.value > 0.0f ? MEMOIZED_STRING( "FOG_NOISE_ENABLED" ) : MEMOIZED_STRING( "FOG_NOISE_DISABLED" ) ); - resources.calculateFroxels->SetParameter( BlueSharedString( "Noise3DTexture" ), m_froxel3DNoise ); - resources.calculateFroxels->SetParameter( BlueSharedString( "RtFroxelOutputTexture" ), fogFroxels ); + resources.calculateFroxels->SetParameter( MEMOIZED_STRING( "Noise3DTexture" ), m_froxel3DNoise ); + resources.calculateFroxels->SetParameter( MEMOIZED_STRING( "RtFroxelOutputTexture" ), fogFroxels ); Tr2Renderer::RunComputeShader( resources.calculateFroxels, wgX, wgY, wgZ, renderContext ); } diff --git a/trinity/Tr2VolumetricsRenderer.h b/trinity/Tr2VolumetricsRenderer.h index e78d0737b..23f5410a7 100644 --- a/trinity/Tr2VolumetricsRenderer.h +++ b/trinity/Tr2VolumetricsRenderer.h @@ -150,6 +150,7 @@ BLUE_CLASS( Tr2VolumetricsRenderer ) : Tr2RaytracingPipelineStateManager m_pipelineManager; Tr2RtShaderTableDescriptionAL m_shaderTableDesc; + Tr2RtShaderTableAL m_rtShadowShaderTable; private: struct FogViewDependentResources diff --git a/trinity/Utilities/StringUtils.h b/trinity/Utilities/StringUtils.h index 9086ca715..a05e79c26 100644 --- a/trinity/Utilities/StringUtils.h +++ b/trinity/Utilities/StringUtils.h @@ -121,6 +121,12 @@ inline bool StringReplace( std::string& baseString, const char* oldString, const return false; } +// -------------------------------------------------------------------------------- +// Description: +// Static BlueSharedString for a string literal, created once at first use +// -------------------------------------------------------------------------------- +#define MEMOIZED_STRING( x ) ( []( const char* str ) { static BlueSharedString s( str ); return s; }( x "" ) ) +