Skip to content

Commit

Permalink
reshade: Add gamescope_always_paint flag
Browse files Browse the repository at this point in the history
  • Loading branch information
misyltoad committed Jan 2, 2025
1 parent 22b0ec8 commit f873ec7
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/rendervulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3856,12 +3856,15 @@ std::optional<uint64_t> vulkan_screenshot( const struct FrameInfo_t *frameInfo,
extern std::string g_reshade_effect;
extern uint32_t g_reshade_technique_idx;

ReshadeEffectPipeline *g_pLastReshadeEffect = nullptr;

std::optional<uint64_t> vulkan_composite( struct FrameInfo_t *frameInfo, gamescope::Rc<CVulkanTexture> pPipewireTexture, bool partial, gamescope::Rc<CVulkanTexture> pOutputOverride, bool increment, std::unique_ptr<CVulkanCmdBuffer> pInCommandBuffer )
{
EOTF outputTF = frameInfo->outputEncodingEOTF;
if (!frameInfo->applyOutputColorMgmt)
outputTF = EOTF_Count; //Disable blending stuff.

g_pLastReshadeEffect = nullptr;
if (!g_reshade_effect.empty())
{
if (frameInfo->layers[0].tex)
Expand All @@ -3877,6 +3880,8 @@ std::optional<uint64_t> vulkan_composite( struct FrameInfo_t *frameInfo, gamesco
};

ReshadeEffectPipeline* pipeline = g_reshadeManager.pipeline(key);
g_pLastReshadeEffect = pipeline;

if (pipeline != nullptr)
{
uint64_t seq = pipeline->execute(frameInfo->layers[0].tex, &frameInfo->layers[0].tex);
Expand Down
8 changes: 6 additions & 2 deletions src/reshade_effect_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ DataUniform::~DataUniform()
{
}

static std::vector<std::shared_ptr<ReshadeUniform>> createReshadeUniforms(const reshadefx::module& module)
static std::vector<std::shared_ptr<ReshadeUniform>> createReshadeUniforms(const reshadefx::module& module, uint32_t *pFlags)
{
std::vector<std::shared_ptr<ReshadeUniform>> uniforms;
for (auto& uniform : module.uniforms)
Expand Down Expand Up @@ -703,6 +703,10 @@ static std::vector<std::shared_ptr<ReshadeUniform>> createReshadeUniforms(const
{
uniforms.push_back(std::make_shared<DepthUniform>(uniform));
}
else if (source == "gamescope_always_paint")
{
( *pFlags ) |= ReshadeEffectFlag::AlwaysScanout;
}
else if (!source.empty())
{
uniforms.push_back(std::make_shared<RuntimeUniform>(uniform));
Expand Down Expand Up @@ -1089,7 +1093,7 @@ bool ReshadeEffectPipeline::init(CVulkanDevice *device, const ReshadeEffectKey &
}

// Create Uniforms
m_uniforms = createReshadeUniforms(*m_module);
m_uniforms = createReshadeUniforms(*m_module, &m_flags);

// Create Textures
{
Expand Down
10 changes: 10 additions & 0 deletions src/reshade_effect_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ enum ReshadeDescriptorSets
GAMESCOPE_RESHADE_DESCRIPTOR_SET_COUNT,
};

namespace ReshadeEffectFlag
{
static constexpr uint32_t AlwaysScanout = 1u << 0;
}
using ReshadeEffectFlags = uint32_t;

class ReshadeEffectPipeline
{
public:
Expand All @@ -53,6 +59,8 @@ class ReshadeEffectPipeline
const ReshadeEffectKey& key() const { return m_key; }
reshadefx::module *module() { return m_module.get(); }

ReshadeEffectFlags flags() const { return m_flags; }

gamescope::Rc<CVulkanTexture> findTexture(std::string_view name);

private:
Expand All @@ -76,6 +84,8 @@ class ReshadeEffectPipeline

VkDescriptorSetLayout m_descriptorSetLayouts[GAMESCOPE_RESHADE_DESCRIPTOR_SET_COUNT] = {};
VkDescriptorSet m_descriptorSets[GAMESCOPE_RESHADE_DESCRIPTOR_SET_COUNT] = {};

ReshadeEffectFlags m_flags = 0;
};

class ReshadeEffectManager
Expand Down
12 changes: 12 additions & 0 deletions src/steamcompmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
#include "convar.h"
#include "refresh_rate.h"
#include "commit.h"
#include "reshade_effect_manager.hpp"
#include "BufferMemo.h"
#include "Utils/Process.h"
#include "Utils/Algorithm.h"
Expand Down Expand Up @@ -159,6 +160,7 @@ std::string clipboard;
std::string primarySelection;

std::string g_reshade_effect{};
extern ReshadeEffectPipeline *g_pLastReshadeEffect;
uint32_t g_reshade_technique_idx = 0;

bool g_bSteamIsActiveWindow = false;
Expand Down Expand Up @@ -7936,6 +7938,11 @@ steamcompmgr_main(int argc, char **argv)
else
eFlipType = FlipType::Normal;

if ( g_pLastReshadeEffect && ( g_pLastReshadeEffect->flags() & ReshadeEffectFlag::AlwaysScanout ) )
{
eFlipType = FlipType::Normal;
}

bool bShouldPaint = false;

if ( GetBackend()->IsVisible() )
Expand Down Expand Up @@ -7996,6 +8003,11 @@ steamcompmgr_main(int argc, char **argv)
bShouldPaint = false;
}

if ( g_pLastReshadeEffect && ( g_pLastReshadeEffect->flags() & ReshadeEffectFlag::AlwaysScanout ) )
{
bShouldPaint = true;
}

if ( bShouldPaint )
{
paint_all( eFlipType == FlipType::Async );
Expand Down

0 comments on commit f873ec7

Please sign in to comment.