[VK]: Rework frame interpolation toggle & implement support for PC #340
2 changed files with 64 additions and 109 deletions
|
@ -331,12 +331,8 @@ struct Values {
|
||||||
SwitchableSetting<int> vulkan_device{linkage, 0, "vulkan_device", Category::Renderer,
|
SwitchableSetting<int> vulkan_device{linkage, 0, "vulkan_device", Category::Renderer,
|
||||||
Specialization::RuntimeList};
|
Specialization::RuntimeList};
|
||||||
SwitchableSetting<bool> enable_raii{linkage, false, "enable_raii", Category::Renderer};
|
SwitchableSetting<bool> enable_raii{linkage, false, "enable_raii", Category::Renderer};
|
||||||
#ifdef __ANDROID__
|
|
||||||
SwitchableSetting<bool> frame_interpolation{linkage, true, "frame_interpolation", Category::Renderer,
|
SwitchableSetting<bool> frame_interpolation{linkage, true, "frame_interpolation", Category::Renderer,
|
||||||
Specialization::RuntimeList};
|
Specialization::RuntimeList};
|
||||||
SwitchableSetting<bool> frame_skipping{linkage, false, "frame_skipping", Category::Renderer,
|
|
||||||
Specialization::RuntimeList};
|
|
||||||
#endif
|
|
||||||
SwitchableSetting<bool> use_disk_shader_cache{linkage, true, "use_disk_shader_cache",
|
SwitchableSetting<bool> use_disk_shader_cache{linkage, true, "use_disk_shader_cache",
|
||||||
Category::Renderer};
|
Category::Renderer};
|
||||||
SwitchableSetting<SpirvOptimizeMode, true> optimize_spirv_output{linkage,
|
SwitchableSetting<SpirvOptimizeMode, true> optimize_spirv_output{linkage,
|
||||||
|
|
|
@ -38,9 +38,7 @@
|
||||||
#include "video_core/vulkan_common/vulkan_memory_allocator.h"
|
#include "video_core/vulkan_common/vulkan_memory_allocator.h"
|
||||||
#include "video_core/vulkan_common/vulkan_surface.h"
|
#include "video_core/vulkan_common/vulkan_surface.h"
|
||||||
#include "video_core/vulkan_common/vulkan_wrapper.h"
|
#include "video_core/vulkan_common/vulkan_wrapper.h"
|
||||||
#ifdef __ANDROID__
|
|
||||||
#include <jni.h>
|
|
||||||
#endif
|
|
||||||
namespace Vulkan {
|
namespace Vulkan {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -189,40 +187,7 @@ RendererVulkan::~RendererVulkan() {
|
||||||
void(device.GetLogical().WaitIdle());
|
void(device.GetLogical().WaitIdle());
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __ANDROID__
|
void RendererVulkan::InterpolateFrames(Frame* prev_frame, Frame* interpolated_frame) {
|
||||||
class BooleanSetting {
|
|
||||||
public:
|
|
||||||
// static BooleanSetting FRAME_SKIPPING;
|
|
||||||
static BooleanSetting FRAME_INTERPOLATION;
|
|
||||||
explicit BooleanSetting(bool initial_value = false) : value(initial_value) {}
|
|
||||||
|
|
||||||
[[nodiscard]] bool getBoolean() const {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setBoolean(bool new_value) {
|
|
||||||
value = new_value;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool value;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Initialize static members
|
|
||||||
// BooleanSetting BooleanSetting::FRAME_SKIPPING(false);
|
|
||||||
BooleanSetting BooleanSetting::FRAME_INTERPOLATION(false);
|
|
||||||
|
|
||||||
// extern "C" JNIEXPORT jboolean JNICALL
|
|
||||||
// Java_org_yuzu_yuzu_1emu_features_settings_model_BooleanSetting_isFrameSkippingEnabled(JNIEnv* env, jobject /* this */) {
|
|
||||||
// return static_cast<jboolean>(BooleanSetting::FRAME_SKIPPING.getBoolean());
|
|
||||||
// }
|
|
||||||
|
|
||||||
extern "C" JNIEXPORT jboolean JNICALL
|
|
||||||
Java_org_yuzu_yuzu_1emu_features_settings_model_BooleanSetting_isFrameInterpolationEnabled(JNIEnv* env, jobject /* this */) {
|
|
||||||
return static_cast<jboolean>(BooleanSetting::FRAME_INTERPOLATION.getBoolean());
|
|
||||||
}
|
|
||||||
|
|
||||||
void RendererVulkan::InterpolateFrames(Frame* prev_frame, Frame* interpolated_frame) {
|
|
||||||
if (!prev_frame || !interpolated_frame || !prev_frame->image || !interpolated_frame->image) {
|
if (!prev_frame || !interpolated_frame || !prev_frame->image || !interpolated_frame->image) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -291,31 +256,26 @@ class BooleanSetting {
|
||||||
TransitionImageLayout(cmdbuf, *prev_frame->image, VK_IMAGE_LAYOUT_GENERAL);
|
TransitionImageLayout(cmdbuf, *prev_frame->image, VK_IMAGE_LAYOUT_GENERAL);
|
||||||
TransitionImageLayout(cmdbuf, *interpolated_frame->image, VK_IMAGE_LAYOUT_GENERAL);
|
TransitionImageLayout(cmdbuf, *interpolated_frame->image, VK_IMAGE_LAYOUT_GENERAL);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
void RendererVulkan::Composite(std::span<const Tegra::FramebufferConfig> framebuffers) {
|
void RendererVulkan::Composite(std::span<const Tegra::FramebufferConfig> framebuffers) {
|
||||||
#ifdef __ANDROID__
|
|
||||||
static int frame_counter = 0;
|
static int frame_counter = 0;
|
||||||
static int target_fps = 60; // Target FPS (30 or 60)
|
static int target_fps = 60; // Target FPS (30 or 60)
|
||||||
int frame_skip_threshold = 1;
|
int frame_skip_threshold = 1;
|
||||||
|
|
||||||
bool frame_skipping = false; //BooleanSetting::FRAME_SKIPPING.getBoolean();
|
bool frame_skipping = true;
|
||||||
bool frame_interpolation = BooleanSetting::FRAME_INTERPOLATION.getBoolean();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (framebuffers.empty()) {
|
if (framebuffers.empty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __ANDROID__
|
|
||||||
if (frame_skipping) {
|
if (frame_skipping) {
|
||||||
frame_skip_threshold = (target_fps == 30) ? 2 : 2;
|
frame_skip_threshold = (target_fps == 30) ? 2 : 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
frame_counter++;
|
frame_counter++;
|
||||||
if (frame_counter % frame_skip_threshold != 0) {
|
if (frame_counter % frame_skip_threshold != 0) {
|
||||||
if (frame_interpolation && previous_frame) {
|
if (Settings::values.frame_interpolation.GetValue() && previous_frame) {
|
||||||
Frame* interpolated_frame = present_manager.GetRenderFrame();
|
Frame* interpolated_frame = present_manager.GetRenderFrame();
|
||||||
InterpolateFrames(previous_frame, interpolated_frame);
|
InterpolateFrames(previous_frame, interpolated_frame);
|
||||||
blit_swapchain.DrawToFrame(rasterizer, interpolated_frame, framebuffers,
|
blit_swapchain.DrawToFrame(rasterizer, interpolated_frame, framebuffers,
|
||||||
|
@ -326,7 +286,6 @@ void RendererVulkan::Composite(std::span<const Tegra::FramebufferConfig> framebu
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
SCOPE_EXIT {
|
SCOPE_EXIT {
|
||||||
render_window.OnFrameDisplayed();
|
render_window.OnFrameDisplayed();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue