4040#include < magic_enum/magic_enum.hpp>
4141#endif
4242
43+ #define MARATHON_RECOMP
4344#include " ../../tools/XenosRecomp/XenosRecomp/shader_common.h"
4445
4546#ifdef MARATHON_RECOMP_D3D12
4647#include " shader/hlsl/blend_color_alpha_ps.hlsl.dxil.h"
48+ #include " shader/hlsl/conditional_survey_ps.hlsl.dxil.h"
4749#include " shader/hlsl/copy_vs.hlsl.dxil.h"
4850#include " shader/hlsl/copy_color_ps.hlsl.dxil.h"
4951#include " shader/hlsl/copy_depth_ps.hlsl.dxil.h"
6971
7072#ifdef MARATHON_RECOMP_METAL
7173#include " shader/msl/blend_color_alpha_ps.metal.metallib.h"
74+ #include " shader/msl/conditional_survey_ps.metal.metallib.h"
7275#include " shader/msl/copy_vs.metal.metallib.h"
7376#include " shader/msl/copy_color_ps.metal.metallib.h"
7477#include " shader/msl/copy_depth_ps.metal.metallib.h"
9396#endif
9497
9598#include " shader/hlsl/blend_color_alpha_ps.hlsl.spirv.h"
99+ #include " shader/hlsl/conditional_survey_ps.hlsl.spirv.h"
96100#include " shader/hlsl/copy_vs.hlsl.spirv.h"
97101#include " shader/hlsl/copy_color_ps.hlsl.spirv.h"
98102#include " shader/hlsl/copy_depth_ps.hlsl.spirv.h"
@@ -188,6 +192,7 @@ struct PipelineState
188192 RenderFormat depthStencilFormat{};
189193 RenderSampleCounts sampleCount = RenderSampleCount::COUNT_1 ;
190194 bool enableAlphaToCoverage = false ;
195+ bool enableConditionalSurvey = false ;
191196 uint32_t specConstants = 0 ;
192197};
193198#pragma pack(pop)
@@ -1488,6 +1493,8 @@ static GuestShader* g_csdShader;
14881493static std::unique_ptr<GuestShader> g_enhancedBurnoutBlurVSShader;
14891494static std::unique_ptr<GuestShader> g_enhancedBurnoutBlurPSShader;
14901495
1496+ static std::unique_ptr<GuestShader> g_conditionalSurveyPSShader;
1497+
14911498#if defined(MARATHON_RECOMP_D3D12)
14921499
14931500#define CREATE_SHADER (NAME ) \
@@ -2245,6 +2252,9 @@ bool Video::CreateHostDevice(const char *sdlVideoDriver, bool graphicsApiRetry)
22452252 g_enhancedBurnoutBlurPSShader = std::make_unique<GuestShader>(ResourceType::PixelShader);
22462253 g_enhancedBurnoutBlurPSShader->shader = CREATE_SHADER (enhanced_burnout_blur_ps);
22472254
2255+ g_conditionalSurveyPSShader = std::make_unique<GuestShader>(ResourceType::PixelShader);
2256+ g_conditionalSurveyPSShader->shader = CREATE_SHADER (conditional_survey_ps);
2257+
22482258 CreateImGuiBackend ();
22492259
22502260 auto gammaCorrectionShader = CREATE_SHADER (gamma_correction_ps);
@@ -4518,7 +4528,12 @@ static std::unique_ptr<RenderPipeline> CreateGraphicsPipeline(const PipelineStat
45184528 RenderGraphicsPipelineDesc desc;
45194529 desc.pipelineLayout = g_pipelineLayout.get ();
45204530 desc.vertexShader = GetOrLinkShader (pipelineState.vertexShader , pipelineState.specConstants );
4521- desc.pixelShader = pipelineState.pixelShader != nullptr ? GetOrLinkShader (pipelineState.pixelShader , pipelineState.specConstants ) : nullptr ;
4531+ if (pipelineState.enableConditionalSurvey )
4532+ desc.pixelShader = GetOrLinkShader (g_conditionalSurveyPSShader.get (), pipelineState.specConstants );
4533+ else if (pipelineState.pixelShader != nullptr )
4534+ desc.pixelShader = GetOrLinkShader (pipelineState.pixelShader , pipelineState.specConstants );
4535+ else
4536+ desc.pixelShader = nullptr ;
45224537 desc.depthFunction = pipelineState.zFunc ;
45234538 desc.depthEnabled = pipelineState.zEnable ;
45244539 desc.depthWriteEnabled = pipelineState.zWriteEnable ;
@@ -4666,6 +4681,7 @@ static RenderPipeline* CreateGraphicsPipelineInRenderThread(PipelineState pipeli
46664681 " depthStencilFormat: {}\n "
46674682 " sampleCount: {}\n "
46684683 " enableAlphaToCoverage: {}\n "
4684+ " enableConditionalSurvey: {}\n "
46694685 " specConstants: {:X}\n " ,
46704686 hash,
46714687 pipelineState.vertexShader ->name ,
@@ -4708,6 +4724,7 @@ static RenderPipeline* CreateGraphicsPipelineInRenderThread(PipelineState pipeli
47084724 magic_enum::enum_name (pipelineState.depthStencilFormat ),
47094725 pipelineState.sampleCount ,
47104726 pipelineState.enableAlphaToCoverage ,
4727+ pipelineState.enableConditionalSurvey ,
47114728 pipelineState.specConstants )
47124729 + g_pipelineDebugText;
47134730 }
@@ -5720,7 +5737,6 @@ static void EndConditionalSurvey(GuestDevice* device)
57205737
57215738static void ProcSetConditionalSurvey (const RenderCommand& cmd)
57225739{
5723- uint32_t specConstants = g_pipelineState.specConstants ;
57245740 if (cmd.setConditionalSurvey .enabled )
57255741 {
57265742 // Clear previous survey result first.
@@ -5734,13 +5750,9 @@ static void ProcSetConditionalSurvey(const RenderCommand& cmd)
57345750 commandList->barriers (RenderBarrierStage::GRAPHICS , RenderBufferBarrier (g_conditionalSurveyBuffer.get (), RenderBufferAccess::READ | RenderBufferAccess::WRITE ));
57355751
57365752 g_tempBuffers[g_frame].emplace_back (std::move (uploadBuffer));
5737-
5738- specConstants |= SPEC_CONSTANT_CONDITIONAL_SURVEY ;
57395753 }
5740- else
5741- specConstants &= ~SPEC_CONSTANT_CONDITIONAL_SURVEY ;
57425754
5743- SetDirtyValue (g_dirtyStates.pipelineState , g_pipelineState.specConstants , specConstants );
5755+ SetDirtyValue (g_dirtyStates.pipelineState , g_pipelineState.enableConditionalSurvey , cmd. setConditionalSurvey . enabled );
57445756 SetDirtyValue (g_dirtyStates.sharedConstants , g_sharedConstants.conditionalSurveyIndex , cmd.setConditionalSurvey .index );
57455757}
57465758
@@ -7694,6 +7706,7 @@ class SDLEventListenerForPSOCaching : public SDLEventListener
76947706 " RenderFormat::{},"
76957707 " {},"
76967708 " {},"
7709+ " {},"
76977710 " 0x{:X} }}," ,
76987711 pipelineState.vertexShader ->shaderCacheEntry ->hash ,
76997712 pipelineState.pixelShader != nullptr ? pipelineState.pixelShader ->shaderCacheEntry ->hash : 0 ,
@@ -7747,6 +7760,7 @@ class SDLEventListenerForPSOCaching : public SDLEventListener
77477760 magic_enum::enum_name (pipelineState.depthStencilFormat ),
77487761 pipelineState.sampleCount ,
77497762 pipelineState.enableAlphaToCoverage ,
7763+ pipelineState.enableConditionalSurvey ,
77507764 pipelineState.specConstants );
77517765 }
77527766
0 commit comments