PostProcessing: Get rid of Timer global
This commit is contained in:
parent
ba15a76d7b
commit
87e367076d
|
@ -11,8 +11,8 @@
|
|||
#include "shadergen.h"
|
||||
|
||||
// TODO: Remove me
|
||||
#include "core/host.h"
|
||||
#include "core/fullscreen_ui.h"
|
||||
#include "core/host.h"
|
||||
#include "core/settings.h"
|
||||
|
||||
#include "IconsFontAwesome5.h"
|
||||
|
@ -51,7 +51,7 @@ ALWAYS_INLINE void ForAllChains(const T& F)
|
|||
Chain DisplayChain(Config::DISPLAY_CHAIN_SECTION);
|
||||
Chain InternalChain(Config::INTERNAL_CHAIN_SECTION);
|
||||
|
||||
static Timer s_timer;
|
||||
static Timer::Value s_start_time;
|
||||
|
||||
static std::unordered_map<u64, std::unique_ptr<GPUSampler>> s_samplers;
|
||||
static std::unique_ptr<GPUTexture> s_dummy_texture;
|
||||
|
@ -525,7 +525,7 @@ void PostProcessing::Chain::UpdateSettings(std::unique_lock<std::mutex>& setting
|
|||
|
||||
if (stage_count > 0)
|
||||
{
|
||||
s_timer.Reset();
|
||||
s_start_time = Timer::GetCurrentValue();
|
||||
DEV_LOG("Loaded {} post-processing stages.", stage_count);
|
||||
}
|
||||
|
||||
|
@ -555,7 +555,7 @@ void PostProcessing::Chain::Toggle()
|
|||
m_enabled = new_enabled;
|
||||
m_needs_depth_buffer = new_enabled && m_wants_depth_buffer;
|
||||
if (m_enabled)
|
||||
s_timer.Reset();
|
||||
s_start_time = Timer::GetCurrentValue();
|
||||
}
|
||||
|
||||
bool PostProcessing::Chain::CheckTargets(GPUTexture::Format target_format, u32 target_width, u32 target_height,
|
||||
|
@ -693,13 +693,14 @@ GPUDevice::PresentResult PostProcessing::Chain::Apply(GPUTexture* input_color, G
|
|||
draw_final_target = GetTextureUnusedAtEndOfChain();
|
||||
}
|
||||
|
||||
const float time = Timer::ConvertValueToSeconds(Timer::GetCurrentValue() - s_start_time);
|
||||
for (const std::unique_ptr<Shader>& stage : m_stages)
|
||||
{
|
||||
const bool is_final = (stage.get() == m_stages.back().get());
|
||||
|
||||
if (const GPUDevice::PresentResult pres =
|
||||
stage->Apply(input_color, input_depth, is_final ? draw_final_target : output, final_rect, orig_width,
|
||||
orig_height, native_width, native_height, m_target_width, m_target_height);
|
||||
orig_height, native_width, native_height, m_target_width, m_target_height, time);
|
||||
pres != GPUDevice::PresentResult::OK)
|
||||
{
|
||||
return pres;
|
||||
|
@ -744,7 +745,7 @@ void PostProcessing::Initialize()
|
|||
{
|
||||
DisplayChain.LoadStages();
|
||||
InternalChain.LoadStages();
|
||||
s_timer.Reset();
|
||||
s_start_time = Timer::GetCurrentValue();
|
||||
}
|
||||
|
||||
void PostProcessing::UpdateSettings()
|
||||
|
@ -780,7 +781,7 @@ bool PostProcessing::ReloadShaders()
|
|||
chain.DestroyTextures();
|
||||
chain.LoadStages();
|
||||
});
|
||||
s_timer.Reset();
|
||||
s_start_time = Timer::GetCurrentValue();
|
||||
|
||||
Host::AddIconOSDMessage("PostProcessing", ICON_FA_PAINT_ROLLER,
|
||||
TRANSLATE_STR("OSDMessage", "Post-processing shaders reloaded."), Host::OSD_QUICK_DURATION);
|
||||
|
@ -869,11 +870,6 @@ SettingsInterface& PostProcessing::GetLoadSettingsInterface(const char* section)
|
|||
return *Host::Internal::GetBaseSettingsLayer();
|
||||
}
|
||||
|
||||
const Timer& PostProcessing::GetTimer()
|
||||
{
|
||||
return s_timer;
|
||||
}
|
||||
|
||||
GPUSampler* PostProcessing::GetSampler(const GPUSampler::Config& config)
|
||||
{
|
||||
auto it = s_samplers.find(config.key);
|
||||
|
|
|
@ -175,8 +175,6 @@ void Shutdown();
|
|||
GPUSampler* GetSampler(const GPUSampler::Config& config);
|
||||
GPUTexture* GetDummyTexture();
|
||||
|
||||
const Timer& GetTimer();
|
||||
|
||||
extern Chain DisplayChain;
|
||||
extern Chain InternalChain;
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ public:
|
|||
|
||||
virtual GPUDevice::PresentResult Apply(GPUTexture* input_color, GPUTexture* input_depth, GPUTexture* final_target,
|
||||
GSVector4i final_rect, s32 orig_width, s32 orig_height, s32 native_width,
|
||||
s32 native_height, u32 target_width, u32 target_height) = 0;
|
||||
s32 native_height, u32 target_width, u32 target_height, float time) = 0;
|
||||
|
||||
protected:
|
||||
using OptionList = std::vector<ShaderOption>;
|
||||
|
|
|
@ -1469,7 +1469,8 @@ bool PostProcessing::ReShadeFXShader::ResizeOutput(GPUTexture::Format format, u3
|
|||
GPUDevice::PresentResult PostProcessing::ReShadeFXShader::Apply(GPUTexture* input_color, GPUTexture* input_depth,
|
||||
GPUTexture* final_target, GSVector4i final_rect,
|
||||
s32 orig_width, s32 orig_height, s32 native_width,
|
||||
s32 native_height, u32 target_width, u32 target_height)
|
||||
s32 native_height, u32 target_width, u32 target_height,
|
||||
float time)
|
||||
{
|
||||
GL_PUSH_FMT("PostProcessingShaderFX {}", m_name);
|
||||
|
||||
|
@ -1478,6 +1479,9 @@ GPUDevice::PresentResult PostProcessing::ReShadeFXShader::Apply(GPUTexture* inpu
|
|||
// Reshade always draws at full size.
|
||||
g_gpu_device->SetViewportAndScissor(GSVector4i(0, 0, target_width, target_height));
|
||||
|
||||
// Reshade timer variable is in milliseconds.
|
||||
time *= 1000.0f;
|
||||
|
||||
if (m_uniforms_size > 0)
|
||||
{
|
||||
GL_SCOPE_FMT("Uniforms: {} bytes", m_uniforms_size);
|
||||
|
@ -1509,8 +1513,7 @@ GPUDevice::PresentResult PostProcessing::ReShadeFXShader::Apply(GPUTexture* inpu
|
|||
|
||||
case SourceOptionType::Timer:
|
||||
{
|
||||
const float value = static_cast<float>(PostProcessing::GetTimer().GetTimeMilliseconds());
|
||||
std::memcpy(dst, &value, sizeof(value));
|
||||
std::memcpy(dst, &time, sizeof(time));
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ public:
|
|||
ProgressCallback* progress) override;
|
||||
GPUDevice::PresentResult Apply(GPUTexture* input_color, GPUTexture* input_depth, GPUTexture* final_target,
|
||||
GSVector4i final_rect, s32 orig_width, s32 orig_height, s32 native_width,
|
||||
s32 native_height, u32 target_width, u32 target_height) override;
|
||||
s32 native_height, u32 target_width, u32 target_height, float time) override;
|
||||
|
||||
private:
|
||||
using TextureID = s32;
|
||||
|
|
|
@ -170,7 +170,8 @@ bool PostProcessing::GLSLShader::CompilePipeline(GPUTexture::Format format, u32
|
|||
GPUDevice::PresentResult PostProcessing::GLSLShader::Apply(GPUTexture* input_color, GPUTexture* input_depth,
|
||||
GPUTexture* final_target, GSVector4i final_rect,
|
||||
s32 orig_width, s32 orig_height, s32 native_width,
|
||||
s32 native_height, u32 target_width, u32 target_height)
|
||||
s32 native_height, u32 target_width, u32 target_height,
|
||||
float time)
|
||||
{
|
||||
GL_SCOPE_FMT("GLSL Shader {}", m_name);
|
||||
|
||||
|
@ -194,8 +195,7 @@ GPUDevice::PresentResult PostProcessing::GLSLShader::Apply(GPUTexture* input_col
|
|||
const u32 uniforms_size = GetUniformsSize();
|
||||
void* uniforms = g_gpu_device->MapUniformBuffer(uniforms_size);
|
||||
FillUniformBuffer(uniforms, final_rect.left, final_rect.top, final_rect.width(), final_rect.height(), target_width,
|
||||
target_height, orig_width, orig_height, native_width, native_height,
|
||||
static_cast<float>(PostProcessing::GetTimer().GetTimeSeconds()));
|
||||
target_height, orig_width, orig_height, native_width, native_height, time);
|
||||
g_gpu_device->UnmapUniformBuffer(uniforms_size);
|
||||
g_gpu_device->Draw(3, 0);
|
||||
return GPUDevice::PresentResult::OK;
|
||||
|
|
|
@ -27,7 +27,7 @@ public:
|
|||
ProgressCallback* progress) override;
|
||||
GPUDevice::PresentResult Apply(GPUTexture* input_color, GPUTexture* input_depth, GPUTexture* final_target,
|
||||
GSVector4i final_rect, s32 orig_width, s32 orig_height, s32 native_width,
|
||||
s32 native_height, u32 target_width, u32 target_height) override;
|
||||
s32 native_height, u32 target_width, u32 target_height, float time) override;
|
||||
|
||||
private:
|
||||
struct CommonUniforms
|
||||
|
|
Loading…
Reference in New Issue