mirror of
https://github.com/hyprwm/Hyprland
synced 2026-05-08 14:18:02 +02:00
keep unmodified copy
This commit is contained in:
parent
de606eb9b7
commit
70037ff4d7
8 changed files with 59 additions and 30 deletions
|
|
@ -818,7 +818,8 @@ CConfigManager::CConfigManager() {
|
|||
registerConfigVar("render:commit_timing_enabled", Hyprlang::INT{1});
|
||||
registerConfigVar("render:icc_vcgt_enabled", Hyprlang::INT{1});
|
||||
registerConfigVar("render:use_shader_blur_blend", Hyprlang::INT{0});
|
||||
registerConfigVar("render:use_fp16", Hyprlang::INT{0});
|
||||
registerConfigVar("render:use_fp16", Hyprlang::INT{2});
|
||||
registerConfigVar("render:keep_unmodified_copy", Hyprlang::INT{2});
|
||||
|
||||
registerConfigVar("ecosystem:no_update_news", Hyprlang::INT{0});
|
||||
registerConfigVar("ecosystem:no_donation_nag", Hyprlang::INT{0});
|
||||
|
|
|
|||
|
|
@ -1679,9 +1679,15 @@ namespace Config::Supplementary {
|
|||
},
|
||||
{
|
||||
.value = "render:use_fp16",
|
||||
.description = "Use experimental internal FP16 buffer",
|
||||
.type = CONFIG_OPTION_BOOL,
|
||||
.data = SConfigOptionDescription::SBoolData{false},
|
||||
.description = "Use experimental internal FP16 buffer. 0 - disabled, 1 - on, 2 - auto (enabled in HDR mode)",
|
||||
.type = CONFIG_OPTION_INT,
|
||||
.data = SConfigOptionDescription::SRangeData{.value = 2, .min = 0, .max = 2},
|
||||
},
|
||||
{
|
||||
.value = "render:keep_unmodified_copy",
|
||||
.description = "Keep umodified SDR frame copy for sreensharing. 0 - disabled, 1 - on, 2 - auto (enabled in HDR with SDR modifiers)",
|
||||
.type = CONFIG_OPTION_INT,
|
||||
.data = SConfigOptionDescription::SRangeData{.value = 2, .min = 0, .max = 2},
|
||||
},
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -2412,12 +2412,37 @@ bool CMonitorState::updateSwapchain() {
|
|||
return m_owner->m_output->swapchain->reconfigure(options);
|
||||
}
|
||||
|
||||
bool CMonitor::needsACopyFB() {
|
||||
return !m_mirrors.empty() || Screenshare::mgr()->isOutputBeingSSd(m_self.lock());
|
||||
}
|
||||
|
||||
bool CMonitor::needsUnmodifiedCopy() {
|
||||
static const auto PKEEP = CConfigValue<Hyprlang::INT>("render:keep_unmodified_copy");
|
||||
if (*PKEEP == 1)
|
||||
return true;
|
||||
|
||||
const bool HAS_MODS = m_sdrMinLuminance != SDR_MIN_LUMINANCE || m_sdrMaxLuminance != SDR_MAX_LUMINANCE || (m_sdrBrightness > 0 && m_sdrBrightness != 1.0) ||
|
||||
(m_sdrSaturation > 0 && m_sdrSaturation != 1.0);
|
||||
|
||||
if (!HAS_MODS)
|
||||
return false;
|
||||
|
||||
if (m_imageDescription->value().transferFunction != CM_TRANSFER_FUNCTION_ST2084_PQ && m_imageDescription->value().transferFunction != CM_TRANSFER_FUNCTION_HLG)
|
||||
return false;
|
||||
|
||||
return *PKEEP == 2 ? true : needsACopyFB();
|
||||
}
|
||||
|
||||
bool CMonitor::useFP16() {
|
||||
static const auto PFP16 = CConfigValue<Hyprlang::INT>("render:use_fp16");
|
||||
return *PFP16 == 1 || (*PFP16 == 2 && m_imageDescription->value().transferFunction == CM_TRANSFER_FUNCTION_ST2084_PQ);
|
||||
}
|
||||
|
||||
WP<CMonitorResources> CMonitor::resources() {
|
||||
static const auto PFP16 = CConfigValue<Hyprlang::INT>("render:use_fp16");
|
||||
const auto DRM_FORMAT = *PFP16 ? DRM_FORMAT_ABGR16161616F : m_output->state->state().drmFormat;
|
||||
const auto DRM_FORMAT = useFP16() ? DRM_FORMAT_ABGR16161616F : m_output->state->state().drmFormat;
|
||||
|
||||
if (!m_resources || m_resources->m_drmFormat != DRM_FORMAT || m_resources->m_size != m_pixelSize)
|
||||
m_resources = makeUnique<CMonitorResources>(m_self, DRM_FORMAT, m_pixelSize, *PFP16 ? LINEAR_IMAGE_DESCRIPTION : m_imageDescription);
|
||||
m_resources = makeUnique<CMonitorResources>(m_self, DRM_FORMAT, m_pixelSize, useFP16() ? LINEAR_IMAGE_DESCRIPTION : m_imageDescription);
|
||||
|
||||
return m_resources;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -382,6 +382,9 @@ class CMonitor {
|
|||
return m_position == rhs.m_position && m_size == rhs.m_size && m_name == rhs.m_name;
|
||||
}
|
||||
|
||||
bool needsACopyFB();
|
||||
bool needsUnmodifiedCopy();
|
||||
bool useFP16();
|
||||
WP<Monitor::CMonitorResources> resources();
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -9,13 +9,13 @@
|
|||
#include <vector>
|
||||
#include <expected>
|
||||
|
||||
#define SDR_MIN_LUMINANCE 0.2
|
||||
#define SDR_MAX_LUMINANCE 80.0
|
||||
#define SDR_REF_LUMINANCE 80.0
|
||||
#define HDR_MIN_LUMINANCE 0.005
|
||||
#define HDR_MAX_LUMINANCE 10000.0
|
||||
#define HDR_REF_LUMINANCE 203.0
|
||||
#define HLG_MAX_LUMINANCE 1000.0
|
||||
#define SDR_MIN_LUMINANCE 0.2f
|
||||
#define SDR_MAX_LUMINANCE 80.0f
|
||||
#define SDR_REF_LUMINANCE 80.0f
|
||||
#define HDR_MIN_LUMINANCE 0.005f
|
||||
#define HDR_MAX_LUMINANCE 10000.0f
|
||||
#define HDR_REF_LUMINANCE 203.0f
|
||||
#define HLG_MAX_LUMINANCE 1000.0f
|
||||
|
||||
namespace Render {
|
||||
class ITexture;
|
||||
|
|
|
|||
|
|
@ -721,7 +721,7 @@ void CHyprOpenGLImpl::begin(PHLMONITOR pMonitor, const CRegion& damage_, SP<IFra
|
|||
initShaders();
|
||||
|
||||
const bool HAS_MIRROR_FB = g_pHyprRenderer->m_renderData.pMonitor->resources()->hasMirrorFB();
|
||||
const bool NEEDS_COPY_FB = g_pHyprRenderer->needsACopyFB(g_pHyprRenderer->m_renderData.pMonitor.lock());
|
||||
const bool NEEDS_COPY_FB = g_pHyprRenderer->m_renderData.pMonitor->needsACopyFB();
|
||||
|
||||
g_pHyprRenderer->m_renderData.transformDamage = true;
|
||||
if (HAS_MIRROR_FB != NEEDS_COPY_FB) {
|
||||
|
|
@ -747,7 +747,7 @@ void CHyprOpenGLImpl::begin(PHLMONITOR pMonitor, const CRegion& damage_, SP<IFra
|
|||
g_pHyprRenderer->m_renderData.mainFB = g_pHyprRenderer->m_renderData.currentFB;
|
||||
g_pHyprRenderer->m_renderData.outFB = fb ? fb : dc<CHyprGLRenderer*>(g_pHyprRenderer.get())->m_currentRenderbuffer->getFB();
|
||||
|
||||
if UNLIKELY (g_pHyprRenderer->needsACopyFB(g_pHyprRenderer->m_renderData.pMonitor.lock()) && !m_fakeFrame) {
|
||||
if UNLIKELY (g_pHyprRenderer->m_renderData.pMonitor->needsUnmodifiedCopy() && !m_fakeFrame) {
|
||||
if (!g_pHyprRenderer->m_renderData.pMonitor->resources()->m_mirrorTex) {
|
||||
GLenum buffers[] = {GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1};
|
||||
glDrawBuffers(2, buffers);
|
||||
|
|
@ -767,7 +767,6 @@ void CHyprOpenGLImpl::begin(PHLMONITOR pMonitor, const CRegion& damage_, SP<IFra
|
|||
}
|
||||
|
||||
void CHyprOpenGLImpl::end() {
|
||||
static auto PFP16 = CConfigValue<Hyprlang::INT>("render:use_fp16");
|
||||
static auto PZOOMDISABLEAA = CConfigValue<Hyprlang::INT>("cursor:zoom_disable_aa");
|
||||
auto& m_renderData = g_pHyprRenderer->m_renderData;
|
||||
TRACY_GPU_ZONE("RenderEnd");
|
||||
|
|
@ -793,7 +792,7 @@ void CHyprOpenGLImpl::end() {
|
|||
|
||||
// copy the damaged areas into the mirror buffer
|
||||
// we can't use the offloadFB for mirroring / ss, as it contains artifacts from blurring
|
||||
if UNLIKELY (g_pHyprRenderer->needsACopyFB(g_pHyprRenderer->m_renderData.pMonitor.lock()) && !m_fakeFrame)
|
||||
if UNLIKELY (g_pHyprRenderer->m_renderData.pMonitor->needsACopyFB() && !m_fakeFrame)
|
||||
saveBufferForMirror(monbox);
|
||||
|
||||
const auto TEX = g_pHyprRenderer->m_renderData.currentFB->getTexture();
|
||||
|
|
@ -825,7 +824,7 @@ void CHyprOpenGLImpl::end() {
|
|||
g_pHyprRenderer->popMonitorTransformEnabled();
|
||||
|
||||
// invalidate our render FBs to signal to the driver we don't need them anymore
|
||||
if (!*PFP16) { // FIXME wtf?
|
||||
if (!g_pHyprRenderer->m_renderData.pMonitor->useFP16()) { // FIXME wtf?
|
||||
g_pHyprRenderer->m_renderData.pMonitor->resources()->forEachUnusedFB(
|
||||
[](const auto& fb) {
|
||||
fb->bind();
|
||||
|
|
@ -2268,7 +2267,8 @@ void CHyprOpenGLImpl::renderRoundedShadow(const CBox& box, int round, float roun
|
|||
}
|
||||
|
||||
void CHyprOpenGLImpl::saveBufferForMirror(const CBox& box) {
|
||||
const auto TEX = g_pHyprRenderer->m_renderData.pMonitor->resources()->m_mirrorTex;
|
||||
const auto TEX = g_pHyprRenderer->m_renderData.pMonitor->resources()->m_mirrorTex ? g_pHyprRenderer->m_renderData.pMonitor->resources()->m_mirrorTex :
|
||||
g_pHyprRenderer->m_renderData.currentFB->getTexture();
|
||||
auto guard = g_pHyprRenderer->bindTempFB(g_pHyprRenderer->m_renderData.pMonitor->resources()->mirrorFB());
|
||||
|
||||
blend(false);
|
||||
|
|
|
|||
|
|
@ -1612,7 +1612,7 @@ bool IHyprRenderer::beginRender(PHLMONITOR pMonitor, CRegion& damage, eRenderMod
|
|||
setProjectionType(RPT_MONITOR);
|
||||
|
||||
const bool HAS_MIRROR_FB = g_pHyprRenderer->m_renderData.pMonitor->resources()->hasMirrorFB();
|
||||
const bool NEEDS_COPY_FB = needsACopyFB(g_pHyprRenderer->m_renderData.pMonitor.lock());
|
||||
const bool NEEDS_COPY_FB = g_pHyprRenderer->m_renderData.pMonitor->needsACopyFB();
|
||||
|
||||
if (HAS_MIRROR_FB && !NEEDS_COPY_FB)
|
||||
g_pHyprRenderer->m_renderData.pMonitor->resources()->mirrorFB()->release();
|
||||
|
|
@ -3158,14 +3158,14 @@ void IHyprRenderer::renderSnapshot(WP<Desktop::View::CPopup> popup) {
|
|||
}
|
||||
|
||||
NColorManagement::PImageDescription IHyprRenderer::workBufferImageDescription() {
|
||||
static const auto PFP16 = CConfigValue<Hyprlang::INT>("render:use_fp16");
|
||||
// TODO
|
||||
// const bool IS_MONITOR_ICC = m_renderData.pMonitor->m_imageDescription.valid() && m_renderData.pMonitor->m_imageDescription->value().icc.present;
|
||||
// const auto sdrEOTF = NTransferFunction::fromConfig(IS_MONITOR_ICC);
|
||||
// const auto CHOSEN_SDR_EOTF = sdrEOTF != NTransferFunction::TF_SRGB ? NColorManagement::CM_TRANSFER_FUNCTION_GAMMA22 : NColorManagement::CM_TRANSFER_FUNCTION_SRGB;
|
||||
|
||||
return *PFP16 ? LINEAR_IMAGE_DESCRIPTION :
|
||||
m_renderData.pMonitor->m_imageDescription; //CImageDescription::from(NColorManagement::SImageDescription{.transferFunction = CHOSEN_SDR_EOTF});
|
||||
return m_renderData.pMonitor->useFP16() ?
|
||||
LINEAR_IMAGE_DESCRIPTION :
|
||||
m_renderData.pMonitor->m_imageDescription; //CImageDescription::from(NColorManagement::SImageDescription{.transferFunction = CHOSEN_SDR_EOTF});
|
||||
}
|
||||
|
||||
bool IHyprRenderer::shouldBlur(PHLLS ls) {
|
||||
|
|
@ -3252,7 +3252,3 @@ SP<ITexture> IHyprRenderer::renderSplash(const std::function<SP<ITexture>(const
|
|||
cairo_destroy(CAIRO);
|
||||
return tex;
|
||||
}
|
||||
|
||||
bool IHyprRenderer::needsACopyFB(PHLMONITOR mon) {
|
||||
return !mon->m_mirrors.empty() || Screenshare::mgr()->isOutputBeingSSd(mon);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -193,8 +193,6 @@ namespace Render {
|
|||
SP<CWLSurfaceResource> surface = nullptr, bool modifySDR = false, float sdrMinLuminance = -1.0f, int sdrMaxLuminance = -1);
|
||||
virtual bool reloadShaders(const std::string& path = "") = 0;
|
||||
|
||||
bool needsACopyFB(PHLMONITOR mon);
|
||||
|
||||
protected:
|
||||
virtual void renderOffToMain(SP<IFramebuffer> off) = 0;
|
||||
virtual SP<IRenderbuffer> getOrCreateRenderbufferInternal(SP<Aquamarine::IBuffer> buffer, uint32_t fmt) = 0;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue