From 74ea90de433f0952a9c91b25f8e15fdf9cf8d6bc Mon Sep 17 00:00:00 2001 From: Colin Cornaby Date: Sat, 1 Jun 2024 22:20:05 -0700 Subject: [PATCH] Readability improvements to tiler gamma path --- .../FeatureLib/pfMetalPipeline/plMetalDevice.cpp | 11 ++++------- .../Plasma/FeatureLib/pfMetalPipeline/plMetalDevice.h | 5 ++--- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/Sources/Plasma/FeatureLib/pfMetalPipeline/plMetalDevice.cpp b/Sources/Plasma/FeatureLib/pfMetalPipeline/plMetalDevice.cpp index f9b7c999f7..b117fcd5c5 100644 --- a/Sources/Plasma/FeatureLib/pfMetalPipeline/plMetalDevice.cpp +++ b/Sources/Plasma/FeatureLib/pfMetalPipeline/plMetalDevice.cpp @@ -344,7 +344,7 @@ void plMetalDevice::BeginNewRenderPass() } else { renderPassDescriptor->colorAttachments()->object(0)->setTexture(fCurrentFragmentMSAAOutputTexture); - // if we need postprocessing, output to the main pass texture + // if we need postprocessing, output to the intermediate main pass texture // otherwise we can go straight to the drawable // We only need the intermediate texture for post processing on @@ -1257,17 +1257,14 @@ void plMetalDevice::CreateGammaAdjustState() gammaDescriptor->setVertexFunction(fShaderLibrary->newFunction(MTLSTR("gammaCorrectVertex"))->autorelease()); if (SupportsTileMemory()) { // Tiler GPU version does an in place transform - gammaDescriptor->setFragmentFunction(fShaderLibrary->newFunction(MTLSTR("gammaCorrectFragmentInPlace"))->autorelease()); - } else { - gammaDescriptor->setFragmentFunction(fShaderLibrary->newFunction(MTLSTR("gammaCorrectFragment"))->autorelease()); - } - - if (SupportsTileMemory()) { + // Because it's in place we need to describe all main pass buffers including depth and MSAA gammaDescriptor->colorAttachments()->object(0)->setPixelFormat(fCurrentFragmentOutputTexture->pixelFormat()); gammaDescriptor->setDepthAttachmentPixelFormat(fCurrentDepthFormat); gammaDescriptor->setSampleCount(CurrentTargetSampleCount()); + gammaDescriptor->setFragmentFunction(fShaderLibrary->newFunction(MTLSTR("gammaCorrectFragmentInPlace"))->autorelease()); } else { gammaDescriptor->colorAttachments()->object(0)->setPixelFormat(fFramebufferFormat); + gammaDescriptor->setFragmentFunction(fShaderLibrary->newFunction(MTLSTR("gammaCorrectFragment"))->autorelease()); } NS::Error* error; diff --git a/Sources/Plasma/FeatureLib/pfMetalPipeline/plMetalDevice.h b/Sources/Plasma/FeatureLib/pfMetalPipeline/plMetalDevice.h index 2a2da2e0e0..f84abfc405 100644 --- a/Sources/Plasma/FeatureLib/pfMetalPipeline/plMetalDevice.h +++ b/Sources/Plasma/FeatureLib/pfMetalPipeline/plMetalDevice.h @@ -279,10 +279,9 @@ class plMetalDevice MTL::RenderPipelineState* fGammaAdjustState; // MARK: - Device capabilities -public: - /// Returns true if the device supports title memory features such as directly writable render buffers. - BOOL SupportsTileMemory() { return fSupportsTileMemory; } private: + /// Returns true if the device supports tile memory features such as directly writable render buffers. + inline BOOL SupportsTileMemory() const { return fSupportsTileMemory; } BOOL fSupportsTileMemory; };