Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ find_package(Threads REQUIRED)

set(GLES_VERSION "GLES3")
find_package(OpenGL REQUIRED COMPONENTS ${GLES_VERSION})
find_package(glslang CONFIG REQUIRED)

set(AQUAMARINE_MINIMUM_VERSION 0.9.3)
set(HYPRLANG_MINIMUM_VERSION 0.6.7)
Expand Down Expand Up @@ -479,9 +480,9 @@ function(protocolWayland)
endfunction()

if(TARGET OpenGL::GL)
target_link_libraries(hyprland_lib PUBLIC OpenGL::EGL OpenGL::GL Threads::Threads)
target_link_libraries(hyprland_lib PUBLIC OpenGL::EGL OpenGL::GL glslang::glslang glslang::glslang-default-resource-limits glslang::SPIRV Threads::Threads)
else()
target_link_libraries(hyprland_lib PUBLIC OpenGL::EGL OpenGL::GLES3 Threads::Threads)
target_link_libraries(hyprland_lib PUBLIC OpenGL::EGL OpenGL::GLES3 glslang::glslang glslang::glslang-default-resource-limits glslang::SPIRV Threads::Threads)
endif()

pkg_check_modules(hyprland_protocols_dep hyprland-protocols>=0.6.4)
Expand Down
2 changes: 2 additions & 0 deletions nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
epoll-shim,
git,
glaze-hyprland,
glslang,
gtest,
hyprcursor,
hyprgraphics,
Expand Down Expand Up @@ -173,6 +174,7 @@ customStdenv.mkDerivation (finalAttrs: {
cairo
git
glaze-hyprland
glslang
gtest
hyprcursor
hyprgraphics
Expand Down
2 changes: 1 addition & 1 deletion scripts/generateShaderIncludes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ echo 'static const std::map<std::string, std::string> SHADERS = {' >> ./src/rend
for filename in `ls ${SHADERS_SRC}`; do
echo "-- ${filename}"

{ echo 'R"#('; cat ${SHADERS_SRC}/${filename}; echo ')#"'; } > ./src/render/shaders/${filename}.inc
{ echo -n 'R"#('; cat ${SHADERS_SRC}/${filename}; echo ')#"'; } > ./src/render/shaders/${filename}.inc
echo "{\"${filename}\"," >> ./src/render/shaders/Shaders.hpp
echo "#include \"./${filename}.inc\"" >> ./src/render/shaders/Shaders.hpp
echo "}," >> ./src/render/shaders/Shaders.hpp
Expand Down
12 changes: 12 additions & 0 deletions src/config/ConfigDescriptions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1585,6 +1585,18 @@ inline static const std::vector<SConfigOptionDescription> CONFIG_OPTIONS = {
.type = CONFIG_OPTION_BOOL,
.data = SConfigOptionDescription::SBoolData{true},
},
{
.value = "render:use_shader_blur_blend",
.description = "Use experimental blurred bg blending",
.type = CONFIG_OPTION_BOOL,
.data = SConfigOptionDescription::SBoolData{false},
},
{
.value = "render:use_fp16",
.description = "Use experimental internal FP16 buffer",
.type = CONFIG_OPTION_BOOL,
.data = SConfigOptionDescription::SBoolData{false},
},

/*
* cursor:
Expand Down
2 changes: 2 additions & 0 deletions src/config/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,8 @@ CConfigManager::CConfigManager() {
registerConfigVar("render:cm_sdr_eotf", {"default"});
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("ecosystem:no_update_news", Hyprlang::INT{0});
registerConfigVar("ecosystem:no_donation_nag", Hyprlang::INT{0});
Expand Down
9 changes: 7 additions & 2 deletions src/debug/HyprCtl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2049,7 +2049,12 @@ static std::string submapRequest(eHyprCtlOutputFormat format, std::string reques
}

static std::string reloadShaders(eHyprCtlOutputFormat format, std::string request) {
if (g_pHyprOpenGL->initShaders())
CVarList vars(request, 0, ' ');

if (vars.size() > 2)
return "too many args";

if (g_pHyprOpenGL && g_pHyprRenderer->reloadShaders(vars.size() == 2 ? vars[1] : ""))
return format == FORMAT_JSON ? "{\"ok\": true}" : "ok";
else
return format == FORMAT_JSON ? "{\"ok\": false}" : "error";
Expand All @@ -2076,8 +2081,8 @@ CHyprCtl::CHyprCtl() {
registerCommand(SHyprCtlCommand{"locked", true, getIsLocked});
registerCommand(SHyprCtlCommand{"descriptions", true, getDescriptions});
registerCommand(SHyprCtlCommand{"submap", true, submapRequest});
registerCommand(SHyprCtlCommand{.name = "reloadshaders", .exact = true, .fn = reloadShaders});

registerCommand(SHyprCtlCommand{.name = "reloadshaders", .exact = false, .fn = reloadShaders});
registerCommand(SHyprCtlCommand{"monitors", false, monitorsRequest});
registerCommand(SHyprCtlCommand{"reload", false, reloadRequest});
registerCommand(SHyprCtlCommand{"plugin", false, dispatchPlugin});
Expand Down
16 changes: 0 additions & 16 deletions src/helpers/Format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,22 +297,6 @@ int NFormatUtils::minStride(const SPixelFormat* const fmt, int32_t width) {
return std::ceil((width * fmt->bytesPerBlock) / pixelsPerBlock(fmt));
}

uint32_t NFormatUtils::drmFormatToGL(DRMFormat drm) {
switch (drm) {
case DRM_FORMAT_XRGB8888:
case DRM_FORMAT_XBGR8888: return GL_RGBA; // doesn't matter, opengl is gucci in this case.
case DRM_FORMAT_XRGB2101010:
case DRM_FORMAT_XBGR2101010: return GL_RGB10_A2;
default: return GL_RGBA;
}
UNREACHABLE();
return GL_RGBA;
}

uint32_t NFormatUtils::glFormatToType(uint32_t gl) {
return gl != GL_RGBA ? GL_UNSIGNED_INT_2_10_10_10_REV : GL_UNSIGNED_BYTE;
}

std::string NFormatUtils::drmFormatName(DRMFormat drm) {
auto n = drmGetFormatName(drm);

Expand Down
2 changes: 0 additions & 2 deletions src/helpers/Format.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ namespace NFormatUtils {
bool isFormatOpaque(DRMFormat drm);
int pixelsPerBlock(const SPixelFormat* const fmt);
int minStride(const SPixelFormat* const fmt, int32_t width);
uint32_t drmFormatToGL(DRMFormat drm);
uint32_t glFormatToType(uint32_t gl);
std::string drmFormatName(DRMFormat drm);
std::string drmModifierName(uint64_t mod);
DRMFormat alphaFormat(DRMFormat prevFormat);
Expand Down
10 changes: 10 additions & 0 deletions src/helpers/Monitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1579,10 +1579,20 @@ Vector2D CMonitor::middle() {
return m_position + m_size / 2.f;
}

const Mat3x3& CMonitor::getTransformMatrix() {
return m_projMatrix;
}

const Mat3x3& CMonitor::getScaleMatrix() {
return m_projOutputMatrix;
}

void CMonitor::updateMatrix() {
m_projMatrix = Mat3x3::identity();
if (m_transform != WL_OUTPUT_TRANSFORM_NORMAL)
m_projMatrix.translate(m_pixelSize / 2.0).transform(Math::wlTransformToHyprutils(m_transform)).translate(-m_transformedSize / 2.0);

m_projOutputMatrix = Mat3x3::outputProjection(m_pixelSize, HYPRUTILS_TRANSFORM_NORMAL);
}

WORKSPACEID CMonitor::activeWorkspaceID() {
Expand Down
12 changes: 10 additions & 2 deletions src/helpers/Monitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class CMonitor {
bool m_scheduledRecalc = false;
wl_output_transform m_transform = WL_OUTPUT_TRANSFORM_NORMAL;
float m_xwaylandScale = 1.f;
Mat3x3 m_projMatrix;

std::optional<Vector2D> m_forceSize;
SP<Aquamarine::SOutputMode> m_currentMode;
SP<Aquamarine::CSwapchain> m_cursorSwapchain;
Expand Down Expand Up @@ -303,7 +303,6 @@ class CMonitor {
void setSpecialWorkspace(const WORKSPACEID& id);
void moveTo(const Vector2D& pos);
Vector2D middle();
void updateMatrix();
WORKSPACEID activeWorkspaceID();
WORKSPACEID activeSpecialWorkspaceID();
CBox logicalBox();
Expand Down Expand Up @@ -335,6 +334,10 @@ class CMonitor {
bool inHDR();
bool gammaRampsInUse();

//
const Mat3x3& getTransformMatrix();
const Mat3x3& getScaleMatrix();

/// Has an active workspace with a real fullscreen window (includes special workspace)
bool inFullscreenMode();
/// Get fullscreen window from active or special workspace
Expand Down Expand Up @@ -364,7 +367,12 @@ class CMonitor {
return m_position == rhs.m_position && m_size == rhs.m_size && m_name == rhs.m_name;
}

Mat3x3 m_projMatrix;

private:
void updateMatrix();
Mat3x3 m_projOutputMatrix;

void setupDefaultWS(const SMonitorRule&);
WORKSPACEID findAvailableDefaultWS();
void commitDPMSState(bool state);
Expand Down
5 changes: 4 additions & 1 deletion src/helpers/TransferFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ std::string NTransferFunction::toString(eTF tf) {
return "";
}

eTF NTransferFunction::fromConfig() {
eTF NTransferFunction::fromConfig(bool useICC) {
if (useICC)
return TF_SRGB;

static auto PSDREOTF = CConfigValue<Hyprlang::STRING>("render:cm_sdr_eotf");
static auto sdrEOTF = NTransferFunction::fromString(*PSDREOTF);
static auto P = Event::bus()->m_events.config.reloaded.listen([]() { sdrEOTF = NTransferFunction::fromString(*PSDREOTF); });
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/TransferFunction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ namespace NTransferFunction {
eTF fromString(const std::string tfName);
std::string toString(eTF tf);

eTF fromConfig();
eTF fromConfig(bool useICC = false);
}
32 changes: 18 additions & 14 deletions src/helpers/cm/ColorManagement.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,18 +322,22 @@ namespace NColorManagement {

using PImageDescription = WP<const CImageDescription>;

static const auto DEFAULT_IMAGE_DESCRIPTION = CImageDescription::from(SImageDescription{.transferFunction = NColorManagement::CM_TRANSFER_FUNCTION_GAMMA22,
.primariesNameSet = true,
.primariesNamed = NColorManagement::CM_PRIMARIES_SRGB,
.primaries = NColorManagement::getPrimaries(NColorManagement::CM_PRIMARIES_SRGB),
.luminances = {.min = SDR_MIN_LUMINANCE, .max = 80, .reference = 80}});

static const auto DEFAULT_HDR_IMAGE_DESCRIPTION = CImageDescription::from(SImageDescription{.transferFunction = NColorManagement::CM_TRANSFER_FUNCTION_ST2084_PQ,
.primariesNameSet = true,
.primariesNamed = NColorManagement::CM_PRIMARIES_BT2020,
.primaries = NColorManagement::getPrimaries(NColorManagement::CM_PRIMARIES_BT2020),
.luminances = {.min = HDR_MIN_LUMINANCE, .max = 10000, .reference = 203}});
;
static const auto DEFAULT_IMAGE_DESCRIPTION = CImageDescription::from(SImageDescription{
.transferFunction = NColorManagement::CM_TRANSFER_FUNCTION_GAMMA22,
.primariesNameSet = true,
.primariesNamed = NColorManagement::CM_PRIMARIES_SRGB,
.primaries = NColorManagement::getPrimaries(NColorManagement::CM_PRIMARIES_SRGB),
.luminances = {.min = SDR_MIN_LUMINANCE, .max = 80, .reference = 80},
});

static const auto DEFAULT_HDR_IMAGE_DESCRIPTION = CImageDescription::from(SImageDescription{
.transferFunction = NColorManagement::CM_TRANSFER_FUNCTION_ST2084_PQ,
.primariesNameSet = true,
.primariesNamed = NColorManagement::CM_PRIMARIES_BT2020,
.primaries = NColorManagement::getPrimaries(NColorManagement::CM_PRIMARIES_BT2020),
.luminances = {.min = HDR_MIN_LUMINANCE, .max = 10000, .reference = 203},
});

static const auto SCRGB_IMAGE_DESCRIPTION = CImageDescription::from(SImageDescription{
.transferFunction = NColorManagement::CM_TRANSFER_FUNCTION_EXT_LINEAR,
.windowsScRGB = true,
Expand All @@ -342,6 +346,6 @@ namespace NColorManagement {
.primaries = NColorPrimaries::BT709,
.luminances = {.reference = 203},
});
;

}
static const auto LINEAR_IMAGE_DESCRIPTION = SCRGB_IMAGE_DESCRIPTION; // TODO any reason to use something different?
}
Loading
Loading