Skip to content

Commit

Permalink
Readability improvements to tiler gamma path
Browse files Browse the repository at this point in the history
  • Loading branch information
colincornaby committed Jun 2, 2024
1 parent e663fbf commit 74ea90d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
11 changes: 4 additions & 7 deletions Sources/Plasma/FeatureLib/pfMetalPipeline/plMetalDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 2 additions & 3 deletions Sources/Plasma/FeatureLib/pfMetalPipeline/plMetalDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down

0 comments on commit 74ea90d

Please sign in to comment.