Skip to content

Added upscalar swapping key binds (FSR sample) #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
21 changes: 19 additions & 2 deletions samples/fsr/fsrsample.cpp
Original file line number Diff line number Diff line change
@@ -27,6 +27,7 @@
#include "upscalerendermodule.h"

#include "rendermoduleregistry.h"
#include "core/inputmanager.h"
#include "taa/taarendermodule.h"
#include "translucency/translucencyrendermodule.h"

@@ -103,12 +104,12 @@ int32_t FSRSample::DoSampleInit()
uiSection.SectionType = UISectionType::Sample;

// Setup upscale method options
const char* upscalers[] = { "Native", "Point", "Bilinear", "Bicubic", "FSR1", "FSR2" };
const char* upscalers[] = { "Point", "Bilinear", "Bicubic", "FSR1", "FSR2", "Native" };
std::vector<std::string> comboOptions;
comboOptions.assign(upscalers, upscalers + _countof(upscalers));

// Add the section header
uiSection.AddCombo("Method", reinterpret_cast<int32_t*>(&m_UIMethod), &comboOptions);
uiSection.AddCombo("Method (1-6 to swap)", reinterpret_cast<int32_t*>(&m_UIMethod), &comboOptions);
GetUIManager()->RegisterUIElements(uiSection);

// Setup the default upscaler (FSR2 for now)
@@ -167,6 +168,22 @@ void FSRSample::SwitchUpscaler(UpscaleMethod newUpscaler)

void FSRSample::DoSampleUpdates(double deltaTime)
{
//To swap between upscaling modes more conveniently
const InputState& inputState = GetInputManager()->GetInputState();
if (inputState.GetKeyUpState(Key_1))
m_UIMethod = UpscaleMethod::Point;
if (inputState.GetKeyUpState(Key_2))
m_UIMethod = UpscaleMethod::Bilinear;
if (inputState.GetKeyUpState(Key_3))
m_UIMethod = UpscaleMethod::Bicubic;
if (inputState.GetKeyUpState(Key_4))
m_UIMethod = UpscaleMethod::FSR1;
if (inputState.GetKeyUpState(Key_5))
m_UIMethod = UpscaleMethod::FSR2;
if (inputState.GetKeyUpState(Key_6))
m_UIMethod = UpscaleMethod::Native;


// Upscaler changes need to be done before the rest of the frame starts executing
// as it relies on the upscale method being set for the frame and whatnot
if (m_UIMethod != m_Method)
5 changes: 2 additions & 3 deletions samples/fsr/fsrsample.h
Original file line number Diff line number Diff line change
@@ -70,13 +70,12 @@ class FSRSample : public cauldron::Framework

enum class UpscaleMethod : uint32_t
{
Native = 0,
Point,
Point = 0,
Bilinear,
Bicubic,
FSR1,
FSR2,

Native,
Count
};