GPU: Consolidate applying the master brightness into one place.

This commit is contained in:
rogerman 2016-12-22 22:16:56 -08:00
parent dfd23f6ba3
commit 922a7ac6f6
2 changed files with 35 additions and 49 deletions

View File

@ -4054,20 +4054,6 @@ void GPUEngineBase::_RenderLine_LayerOBJ(GPUEngineCompositorInfo &compInfo, item
} }
} }
template <NDSColorFormat OUTPUTFORMAT>
void GPUEngineBase::_RenderLine_MasterBrightness(const size_t l)
{
const NDSDisplayInfo &dispInfo = GPU->GetDisplayInfo();
const GPUEngineCompositorInfo &compInfo = this->_currentCompositorInfo[l];
void *dstColorLine = (this->isLineOutputNative[l]) ? ((u8 *)this->nativeBuffer + (compInfo.line.blockOffsetNative * dispInfo.pixelBytes)) : ((u8 *)this->customBuffer + (compInfo.line.blockOffsetCustom * dispInfo.pixelBytes));
const size_t pixCount = (this->isLineOutputNative[l]) ? GPU_FRAMEBUFFER_NATIVE_WIDTH : compInfo.line.pixelCount;
this->ApplyMasterBrightness<OUTPUTFORMAT, false>(dstColorLine,
pixCount,
compInfo.renderState.masterBrightnessMode,
compInfo.renderState.masterBrightnessIntensity);
}
bool GPUEngineBase::WillApplyMasterBrightnessPerScanline() const bool GPUEngineBase::WillApplyMasterBrightnessPerScanline() const
{ {
return this->_willApplyMasterBrightnessPerScanline; return this->_willApplyMasterBrightnessPerScanline;
@ -4078,6 +4064,37 @@ void GPUEngineBase::SetWillApplyMasterBrightnessPerScanline(bool willApply)
this->_willApplyMasterBrightnessPerScanline = willApply; this->_willApplyMasterBrightnessPerScanline = willApply;
} }
template <NDSColorFormat OUTPUTFORMAT>
void GPUEngineBase::ApplyMasterBrightness()
{
if (this->_willApplyMasterBrightnessPerScanline)
{
const bool isNativeSize = (this->nativeLineOutputCount == GPU_FRAMEBUFFER_NATIVE_HEIGHT);
for (size_t line = 0; line < GPU_FRAMEBUFFER_NATIVE_HEIGHT; line++)
{
const NDSDisplayInfo &dispInfo = GPU->GetDisplayInfo();
const GPUEngineCompositorInfo &compInfo = this->_currentCompositorInfo[line];
void *dstColorLine = (isNativeSize) ? ((u8 *)this->nativeBuffer + (compInfo.line.blockOffsetNative * dispInfo.pixelBytes)) : ((u8 *)this->customBuffer + (compInfo.line.blockOffsetCustom * dispInfo.pixelBytes));
const size_t pixCount = (isNativeSize) ? GPU_FRAMEBUFFER_NATIVE_WIDTH : compInfo.line.pixelCount;
this->ApplyMasterBrightness<OUTPUTFORMAT, false>(dstColorLine,
pixCount,
compInfo.renderState.masterBrightnessMode,
compInfo.renderState.masterBrightnessIntensity);
}
}
else
{
const GPUEngineCompositorInfo &compInfo = this->_currentCompositorInfo[0];
this->ApplyMasterBrightness<OUTPUTFORMAT, false>(this->renderedBuffer,
this->renderedWidth * this->renderedHeight,
compInfo.renderState.masterBrightnessMode,
compInfo.renderState.masterBrightnessIntensity);
}
}
template <NDSColorFormat OUTPUTFORMAT, bool ISFULLINTENSITYHINT> template <NDSColorFormat OUTPUTFORMAT, bool ISFULLINTENSITYHINT>
void GPUEngineBase::ApplyMasterBrightness(void *dst, const size_t pixCount, const GPUMasterBrightMode mode, const u8 intensity) void GPUEngineBase::ApplyMasterBrightness(void *dst, const size_t pixCount, const GPUMasterBrightMode mode, const u8 intensity)
{ {
@ -5317,11 +5334,6 @@ void GPUEngineA::RenderLine(const size_t l)
this->_RenderLine_DisplayCapture<OUTPUTFORMAT, GPU_FRAMEBUFFER_NATIVE_WIDTH>(l); this->_RenderLine_DisplayCapture<OUTPUTFORMAT, GPU_FRAMEBUFFER_NATIVE_WIDTH>(l);
} }
} }
if (this->_willApplyMasterBrightnessPerScanline)
{
this->_RenderLine_MasterBrightness<OUTPUTFORMAT>(l);
}
} }
template <NDSColorFormat OUTPUTFORMAT, bool WILLPERFORMWINDOWTEST> template <NDSColorFormat OUTPUTFORMAT, bool WILLPERFORMWINDOWTEST>
@ -6787,11 +6799,6 @@ void GPUEngineB::RenderLine(const size_t l)
default: default:
break; break;
} }
if (this->_willApplyMasterBrightnessPerScanline)
{
this->_RenderLine_MasterBrightness<OUTPUTFORMAT>(l);
}
} }
GPUSubsystem::GPUSubsystem() GPUSubsystem::GPUSubsystem()
@ -7494,17 +7501,7 @@ void GPUSubsystem::RenderLine(const size_t l, bool isFrameSkipRequested)
{ {
if (CommonSettings.showGpu.main) if (CommonSettings.showGpu.main)
{ {
if (!this->_engineMain->WillApplyMasterBrightnessPerScanline()) this->_engineMain->ApplyMasterBrightness<OUTPUTFORMAT>();
{
GPUMasterBrightMode mode;
u8 intensity;
this->_engineMain->GetMasterBrightnessAtLineZero(mode, intensity);
this->_engineMain->ApplyMasterBrightness<OUTPUTFORMAT, false>(this->_engineMain->renderedBuffer,
this->_engineMain->renderedWidth * this->_engineMain->renderedHeight,
mode,
intensity);
}
} }
else else
{ {
@ -7513,17 +7510,7 @@ void GPUSubsystem::RenderLine(const size_t l, bool isFrameSkipRequested)
if (CommonSettings.showGpu.sub) if (CommonSettings.showGpu.sub)
{ {
if (!this->_engineSub->WillApplyMasterBrightnessPerScanline()) this->_engineSub->ApplyMasterBrightness<OUTPUTFORMAT>();
{
GPUMasterBrightMode mode;
u8 intensity;
this->_engineSub->GetMasterBrightnessAtLineZero(mode, intensity);
this->_engineSub->ApplyMasterBrightness<OUTPUTFORMAT, false>(this->_engineSub->renderedBuffer,
this->_engineSub->renderedWidth * this->_engineSub->renderedHeight,
mode,
intensity);
}
} }
else else
{ {

View File

@ -1359,9 +1359,7 @@ protected:
template<NDSColorFormat OUTPUTFORMAT, bool ISDEBUGRENDER, bool WILLPERFORMWINDOWTEST, bool ISCUSTOMRENDERINGNEEDED> void _RenderLine_LayerBG(GPUEngineCompositorInfo &compInfo); template<NDSColorFormat OUTPUTFORMAT, bool ISDEBUGRENDER, bool WILLPERFORMWINDOWTEST, bool ISCUSTOMRENDERINGNEEDED> void _RenderLine_LayerBG(GPUEngineCompositorInfo &compInfo);
template<NDSColorFormat OUTPUTFORMAT, bool WILLPERFORMWINDOWTEST> void _RenderLine_LayerOBJ(GPUEngineCompositorInfo &compInfo, itemsForPriority_t *__restrict item); template<NDSColorFormat OUTPUTFORMAT, bool WILLPERFORMWINDOWTEST> void _RenderLine_LayerOBJ(GPUEngineCompositorInfo &compInfo, itemsForPriority_t *__restrict item);
template<NDSColorFormat OUTPUTFORMAT> void _RenderLine_MasterBrightness(const size_t l);
template<NDSColorFormat OUTPUTFORMAT, bool ISSRCLAYEROBJ, bool ISDEBUGRENDER, bool WILLPERFORMWINDOWTEST, bool COLOREFFECTDISABLEDHINT> FORCEINLINE void _RenderPixel(GPUEngineCompositorInfo &compInfo, const u16 srcColor16, const u8 srcAlpha); template<NDSColorFormat OUTPUTFORMAT, bool ISSRCLAYEROBJ, bool ISDEBUGRENDER, bool WILLPERFORMWINDOWTEST, bool COLOREFFECTDISABLEDHINT> FORCEINLINE void _RenderPixel(GPUEngineCompositorInfo &compInfo, const u16 srcColor16, const u8 srcAlpha);
template<NDSColorFormat OUTPUTFORMAT> FORCEINLINE void _RenderPixel3D(GPUEngineCompositorInfo &compInfo, const bool enableColorEffect, const FragmentColor srcColor32); template<NDSColorFormat OUTPUTFORMAT> FORCEINLINE void _RenderPixel3D(GPUEngineCompositorInfo &compInfo, const bool enableColorEffect, const FragmentColor srcColor32);
@ -1477,6 +1475,7 @@ public:
bool WillApplyMasterBrightnessPerScanline() const; bool WillApplyMasterBrightnessPerScanline() const;
void SetWillApplyMasterBrightnessPerScanline(bool willApply); void SetWillApplyMasterBrightnessPerScanline(bool willApply);
template<NDSColorFormat OUTPUTFORMAT> void ApplyMasterBrightness();
template<NDSColorFormat OUTPUTFORMAT, bool ISFULLINTENSITYHINT> void ApplyMasterBrightness(void *dst, const size_t pixCount, const GPUMasterBrightMode mode, const u8 intensity); template<NDSColorFormat OUTPUTFORMAT, bool ISFULLINTENSITYHINT> void ApplyMasterBrightness(void *dst, const size_t pixCount, const GPUMasterBrightMode mode, const u8 intensity);
const BGLayerInfo& GetBGLayerInfoByID(const GPULayerID layerID); const BGLayerInfo& GetBGLayerInfoByID(const GPULayerID layerID);