GPU: Better handle the NDSDisplayInfo flags for applying the master brightness.

This commit is contained in:
rogerman 2017-02-16 00:31:02 -08:00
parent 60ae4c8de3
commit fb2cfc4e9c
2 changed files with 20 additions and 11 deletions

View File

@ -4033,6 +4033,7 @@ void GPUEngineBase::ApplyMasterBrightness()
if (this->_willApplyMasterBrightnessPerScanline) if (this->_willApplyMasterBrightnessPerScanline)
{ {
const bool isNativeSize = (this->nativeLineOutputCount == GPU_FRAMEBUFFER_NATIVE_HEIGHT); const bool isNativeSize = (this->nativeLineOutputCount == GPU_FRAMEBUFFER_NATIVE_HEIGHT);
bool needsApply = false;
for (size_t line = 0; line < GPU_FRAMEBUFFER_NATIVE_HEIGHT; line++) for (size_t line = 0; line < GPU_FRAMEBUFFER_NATIVE_HEIGHT; line++)
{ {
@ -4047,16 +4048,20 @@ void GPUEngineBase::ApplyMasterBrightness()
pixCount, pixCount,
compInfo.renderState.masterBrightnessMode, compInfo.renderState.masterBrightnessMode,
compInfo.renderState.masterBrightnessIntensity); compInfo.renderState.masterBrightnessIntensity);
}
else
{
if ( (compInfo.renderState.masterBrightnessIntensity != 0) && ((compInfo.renderState.masterBrightnessMode == GPUMasterBrightMode_Up) || (compInfo.renderState.masterBrightnessMode == GPUMasterBrightMode_Down)) ) if ( (compInfo.renderState.masterBrightnessIntensity != 0) && ((compInfo.renderState.masterBrightnessMode == GPUMasterBrightMode_Up) || (compInfo.renderState.masterBrightnessMode == GPUMasterBrightMode_Down)) )
{ {
dispInfoMutable.isMasterBrightnessApplied[this->_targetDisplayID] = true; needsApply = true;
} }
} }
dispInfoMutable.masterBrightnessMode[this->_targetDisplayID][line] = compInfo.renderState.masterBrightnessMode; dispInfoMutable.masterBrightnessMode[this->_targetDisplayID][line] = compInfo.renderState.masterBrightnessMode;
dispInfoMutable.masterBrightnessIntensity[this->_targetDisplayID][line] = compInfo.renderState.masterBrightnessIntensity; dispInfoMutable.masterBrightnessIntensity[this->_targetDisplayID][line] = compInfo.renderState.masterBrightnessIntensity;
} }
dispInfoMutable.needApplyMasterBrightness[this->_targetDisplayID] = dispInfoMutable.needApplyMasterBrightness[this->_targetDisplayID] && needsApply;
} }
else else
{ {
@ -4068,8 +4073,10 @@ void GPUEngineBase::ApplyMasterBrightness()
this->renderedWidth * this->renderedHeight, this->renderedWidth * this->renderedHeight,
compInfo.renderState.masterBrightnessMode, compInfo.renderState.masterBrightnessMode,
compInfo.renderState.masterBrightnessIntensity); compInfo.renderState.masterBrightnessIntensity);
}
dispInfoMutable.isMasterBrightnessApplied[this->_targetDisplayID] = (compInfo.renderState.masterBrightnessIntensity != 0) && ((compInfo.renderState.masterBrightnessMode == GPUMasterBrightMode_Up) || (compInfo.renderState.masterBrightnessMode == GPUMasterBrightMode_Down)); else
{
dispInfoMutable.needApplyMasterBrightness[this->_targetDisplayID] = (compInfo.renderState.masterBrightnessIntensity != 0) && ((compInfo.renderState.masterBrightnessMode == GPUMasterBrightMode_Up) || (compInfo.renderState.masterBrightnessMode == GPUMasterBrightMode_Down));
} }
for (size_t line = 0; line < GPU_FRAMEBUFFER_NATIVE_HEIGHT; line++) for (size_t line = 0; line < GPU_FRAMEBUFFER_NATIVE_HEIGHT; line++)
@ -6799,6 +6806,7 @@ GPUSubsystem::GPUSubsystem()
_displayInfo.isCustomSizeRequested = false; _displayInfo.isCustomSizeRequested = false;
_displayInfo.customWidth = GPU_FRAMEBUFFER_NATIVE_WIDTH; _displayInfo.customWidth = GPU_FRAMEBUFFER_NATIVE_WIDTH;
_displayInfo.customHeight = GPU_FRAMEBUFFER_NATIVE_HEIGHT; _displayInfo.customHeight = GPU_FRAMEBUFFER_NATIVE_HEIGHT;
_displayInfo.isMasterBrightnessAutoApplyRequested = true;
_customVRAM = NULL; _customVRAM = NULL;
_customVRAMBlank = NULL; _customVRAMBlank = NULL;
@ -7344,6 +7352,7 @@ bool GPUSubsystem::GetWillAutoApplyMasterBrightness() const
void GPUSubsystem::SetWillAutoApplyMasterBrightness(const bool willAutoApply) void GPUSubsystem::SetWillAutoApplyMasterBrightness(const bool willAutoApply)
{ {
this->_willAutoApplyMasterBrightness = willAutoApply; this->_willAutoApplyMasterBrightness = willAutoApply;
this->_displayInfo.isMasterBrightnessAutoApplyRequested = willAutoApply;
} }
bool GPUSubsystem::GetWillAutoConvertRGB666ToRGB888() const bool GPUSubsystem::GetWillAutoConvertRGB666ToRGB888() const
@ -7466,8 +7475,8 @@ void GPUSubsystem::RenderLine(const size_t l)
this->_displayInfo.isDisplayEnabled[NDSDisplayID_Main] = CommonSettings.showGpu.main; this->_displayInfo.isDisplayEnabled[NDSDisplayID_Main] = CommonSettings.showGpu.main;
this->_displayInfo.isDisplayEnabled[NDSDisplayID_Touch] = CommonSettings.showGpu.sub; this->_displayInfo.isDisplayEnabled[NDSDisplayID_Touch] = CommonSettings.showGpu.sub;
this->_displayInfo.isMasterBrightnessApplied[NDSDisplayID_Main] = false; this->_displayInfo.needApplyMasterBrightness[NDSDisplayID_Main] = !this->_displayInfo.isMasterBrightnessAutoApplyRequested;
this->_displayInfo.isMasterBrightnessApplied[NDSDisplayID_Touch] = false; this->_displayInfo.needApplyMasterBrightness[NDSDisplayID_Touch] = !this->_displayInfo.isMasterBrightnessAutoApplyRequested;
if (CommonSettings.showGpu.main) if (CommonSettings.showGpu.main)
{ {

View File

@ -1078,7 +1078,7 @@ typedef struct
// true - The emulator itself will apply the master brightness. This is the default option. // true - The emulator itself will apply the master brightness. This is the default option.
// false - The output framebuffer will not have master brightness applied. Clients will need to // false - The output framebuffer will not have master brightness applied. Clients will need to
// apply the master brightness themselves in a post-processing pass. Clients should use // apply the master brightness themselves in a post-processing pass. Clients should use
// the isMasterBrightnessApplied, masterBrightnessMode, masterBrightnessIntensity and // the needApplyMasterBrightness, masterBrightnessMode, masterBrightnessIntensity and
// isDisplayEnabled properties to determine how to apply the master brightness on their // isDisplayEnabled properties to determine how to apply the master brightness on their
// end. // end.
@ -1107,10 +1107,10 @@ typedef struct
// true - The display performed a custom-sized render. // true - The display performed a custom-sized render.
// false - The display performed a native-sized render. // false - The display performed a native-sized render.
bool isMasterBrightnessApplied[2]; // Reports if a display has master brightness applied. This will be false if the user requested to bool needApplyMasterBrightness[2]; // Reports if a display still needs to apply the master brightness. This will be true if the
// turn off auto-apply via GPUSubsystem::SetWillAutoApplyMasterBrightness(), or if the NDS applied // isMasterBrightnessAutoApplyRequested flag is false and if the NDS has a master brightness
// a master brightness intensity of 0 for all lines. // intensity of non-zero for at least one line.
GPUMasterBrightMode masterBrightnessMode[2][GPU_FRAMEBUFFER_NATIVE_HEIGHT]; // The master brightness mode of each display line. u8 masterBrightnessMode[2][GPU_FRAMEBUFFER_NATIVE_HEIGHT]; // The master brightness mode of each display line.
u8 masterBrightnessIntensity[2][GPU_FRAMEBUFFER_NATIVE_HEIGHT]; // The master brightness intensity of each display line. u8 masterBrightnessIntensity[2][GPU_FRAMEBUFFER_NATIVE_HEIGHT]; // The master brightness intensity of each display line.
} NDSDisplayInfo; } NDSDisplayInfo;