nvdec: VA-API
This commit is contained in:
@@ -584,7 +584,17 @@ if (YUZU_USE_BUNDLED_FFMPEG)
|
||||
CACHE PATH "Path to FFmpeg headers" FORCE)
|
||||
|
||||
# `configure` parameters builds only exactly what yuzu needs from FFmpeg
|
||||
# `--disable-{vaapi,vdpau}` is needed to avoid linking issues
|
||||
# `--disable-vdpau` is needed to avoid linking issues
|
||||
|
||||
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
||||
pkg_check_modules(LIBVA REQUIRED)
|
||||
pkg_check_modules(LIBVA-DRM REQUIRED)
|
||||
pkg_check_modules(LIBVA-X11 REQUIRED)
|
||||
link_libraries(va va-drm va-x11)
|
||||
set(FFmpeg-hwaccel-flags --enable-hwaccel=h264_vaapi --enable-hwaccel=vp9_vaapi)
|
||||
else()
|
||||
set(FFmpeg-hwaccel-flags --disable-vaapi)
|
||||
endif()
|
||||
add_custom_command(
|
||||
OUTPUT
|
||||
${FFmpeg_MAKEFILE}
|
||||
@@ -595,18 +605,18 @@ if (YUZU_USE_BUNDLED_FFMPEG)
|
||||
--disable-avformat
|
||||
--disable-doc
|
||||
--disable-everything
|
||||
--disable-ffmpeg
|
||||
--disable-ffprobe
|
||||
--disable-network
|
||||
--disable-postproc
|
||||
--disable-swresample
|
||||
--disable-vaapi
|
||||
--disable-vdpau
|
||||
--enable-decoder=h264
|
||||
--enable-decoder=vp9
|
||||
${FFmpeg-hwaccel-flags}
|
||||
WORKING_DIRECTORY
|
||||
${FFmpeg_BUILD_DIR}
|
||||
)
|
||||
unset(FFmpeg-hwaccel-flags)
|
||||
|
||||
# Workaround for Ubuntu 18.04's older version of make not being able to call make as a child
|
||||
# with context of the jobserver. Also helps ninja users.
|
||||
|
||||
@@ -54,7 +54,7 @@ void LogSettings() {
|
||||
log_setting("Renderer_GPUAccuracyLevel", values.gpu_accuracy.GetValue());
|
||||
log_setting("Renderer_UseAsynchronousGpuEmulation",
|
||||
values.use_asynchronous_gpu_emulation.GetValue());
|
||||
log_setting("Renderer_UseNvdecEmulation", values.use_nvdec_emulation.GetValue());
|
||||
log_setting("Renderer_NvdecEmulation", values.nvdec_emulation.GetValue());
|
||||
log_setting("Renderer_AccelerateASTC", values.accelerate_astc.GetValue());
|
||||
log_setting("Renderer_UseVsync", values.use_vsync.GetValue());
|
||||
log_setting("Renderer_ShaderBackend", values.shader_backend.GetValue());
|
||||
@@ -137,7 +137,7 @@ void RestoreGlobalState(bool is_powered_on) {
|
||||
values.use_disk_shader_cache.SetGlobal(true);
|
||||
values.gpu_accuracy.SetGlobal(true);
|
||||
values.use_asynchronous_gpu_emulation.SetGlobal(true);
|
||||
values.use_nvdec_emulation.SetGlobal(true);
|
||||
values.nvdec_emulation.SetGlobal(true);
|
||||
values.accelerate_astc.SetGlobal(true);
|
||||
values.use_vsync.SetGlobal(true);
|
||||
values.shader_backend.SetGlobal(true);
|
||||
|
||||
@@ -42,6 +42,12 @@ enum class CPUAccuracy : u32 {
|
||||
Unsafe = 2,
|
||||
};
|
||||
|
||||
enum class NvdecEmulation : u32 {
|
||||
Off = 0,
|
||||
Software = 1,
|
||||
Vaapi = 2,
|
||||
};
|
||||
|
||||
/** The BasicSetting class is a simple resource manager. It defines a label and default value
|
||||
* alongside the actual value of the setting for simpler and less-error prone use with frontend
|
||||
* configurations. Setting a default value and label is required, though subclasses may deviate from
|
||||
@@ -336,7 +342,7 @@ struct Values {
|
||||
Setting<bool> use_disk_shader_cache{true, "use_disk_shader_cache"};
|
||||
Setting<GPUAccuracy> gpu_accuracy{GPUAccuracy::High, "gpu_accuracy"};
|
||||
Setting<bool> use_asynchronous_gpu_emulation{true, "use_asynchronous_gpu_emulation"};
|
||||
Setting<bool> use_nvdec_emulation{true, "use_nvdec_emulation"};
|
||||
Setting<NvdecEmulation> nvdec_emulation{NvdecEmulation::Software, "nvdec_emulation"};
|
||||
Setting<bool> accelerate_astc{true, "accelerate_astc"};
|
||||
Setting<bool> use_vsync{true, "use_vsync"};
|
||||
BasicSetting<u16> fps_cap{1000, "fps_cap"};
|
||||
|
||||
@@ -72,6 +72,18 @@ static const char* TranslateGPUAccuracyLevel(Settings::GPUAccuracy backend) {
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
static const char* TranslateNvdecEmulation(Settings::NvdecEmulation backend) {
|
||||
switch (backend) {
|
||||
case Settings::NvdecEmulation::Off:
|
||||
return "Off";
|
||||
case Settings::NvdecEmulation::Software:
|
||||
return "Software";
|
||||
case Settings::NvdecEmulation::Vaapi:
|
||||
return "VA-API";
|
||||
}
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
u64 GetTelemetryId() {
|
||||
u64 telemetry_id{};
|
||||
const auto filename = Common::FS::GetYuzuPath(Common::FS::YuzuPath::ConfigDir) / "telemetry_id";
|
||||
@@ -229,8 +241,8 @@ void TelemetrySession::AddInitialInfo(Loader::AppLoader& app_loader,
|
||||
TranslateGPUAccuracyLevel(Settings::values.gpu_accuracy.GetValue()));
|
||||
AddField(field_type, "Renderer_UseAsynchronousGpuEmulation",
|
||||
Settings::values.use_asynchronous_gpu_emulation.GetValue());
|
||||
AddField(field_type, "Renderer_UseNvdecEmulation",
|
||||
Settings::values.use_nvdec_emulation.GetValue());
|
||||
AddField(field_type, "Renderer_NvdecEmulation",
|
||||
TranslateNvdecEmulation(Settings::values.nvdec_emulation.GetValue()));
|
||||
AddField(field_type, "Renderer_AccelerateASTC", Settings::values.accelerate_astc.GetValue());
|
||||
AddField(field_type, "Renderer_UseVsync", Settings::values.use_vsync.GetValue());
|
||||
AddField(field_type, "Renderer_ShaderBackend",
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
#include "common/assert.h"
|
||||
#include "common/settings.h"
|
||||
#include "video_core/command_classes/codecs/codec.h"
|
||||
#include "video_core/command_classes/codecs/h264.h"
|
||||
#include "video_core/command_classes/codecs/vp9.h"
|
||||
@@ -41,6 +42,48 @@ Codec::~Codec() {
|
||||
av_frame_unref(av_frame);
|
||||
av_free(av_frame);
|
||||
avcodec_close(av_codec_ctx);
|
||||
av_buffer_unref(&av_hw_device);
|
||||
}
|
||||
|
||||
// Hardware acceleration code from FFmpeg/doc/examples/hw_decode.c
|
||||
// under MIT license
|
||||
#if defined(__linux__)
|
||||
static enum AVPixelFormat get_hw_format(AVCodecContext* ctx, const enum AVPixelFormat* pix_fmts) {
|
||||
for (const enum AVPixelFormat* p = pix_fmts; *p != AV_PIX_FMT_NONE; ++p) {
|
||||
if (*p == AV_PIX_FMT_VAAPI) {
|
||||
return AV_PIX_FMT_VAAPI;
|
||||
}
|
||||
}
|
||||
LOG_ERROR(Service_NVDRV, "Unable to decode this file using VA-API.");
|
||||
return AV_PIX_FMT_NONE;
|
||||
}
|
||||
#endif
|
||||
|
||||
void Codec::InitializeHwdec() {
|
||||
if (Settings::values.nvdec_emulation.GetValue() != Settings::NvdecEmulation::Vaapi) {
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined(__linux__)
|
||||
const int hwdevice_error =
|
||||
av_hwdevice_ctx_create(&av_hw_device, AV_HWDEVICE_TYPE_VAAPI, nullptr, nullptr, 0);
|
||||
if (hwdevice_error < 0) {
|
||||
LOG_ERROR(Service_NVDRV, "av_hwdevice_ctx_create failed {}", hwdevice_error);
|
||||
goto fail;
|
||||
}
|
||||
if (!(av_codec_ctx->hw_device_ctx = av_buffer_ref(av_hw_device))) {
|
||||
LOG_ERROR(Service_NVDRV, "av_buffer_ref failed");
|
||||
goto fail;
|
||||
}
|
||||
av_codec_ctx->get_format = get_hw_format;
|
||||
return;
|
||||
|
||||
fail:
|
||||
av_codec_ctx->hw_device_ctx = nullptr;
|
||||
av_hw_device = nullptr;
|
||||
#else
|
||||
UNIMPLEMENTED_MSG("Hardware acceleration without Linux")
|
||||
#endif
|
||||
}
|
||||
|
||||
void Codec::Initialize() {
|
||||
@@ -59,16 +102,16 @@ void Codec::Initialize() {
|
||||
av_codec_ctx = avcodec_alloc_context3(av_codec);
|
||||
av_opt_set(av_codec_ctx->priv_data, "tune", "zerolatency", 0);
|
||||
|
||||
// TODO(ameerj): libavcodec gpu hw acceleration
|
||||
InitializeHwdec();
|
||||
|
||||
const auto av_error = avcodec_open2(av_codec_ctx, av_codec, nullptr);
|
||||
if (av_error < 0) {
|
||||
LOG_ERROR(Service_NVDRV, "avcodec_open2() Failed.");
|
||||
avcodec_close(av_codec_ctx);
|
||||
av_buffer_unref(&av_hw_device);
|
||||
return;
|
||||
}
|
||||
initialized = true;
|
||||
return;
|
||||
}
|
||||
|
||||
void Codec::SetTargetCodec(NvdecCommon::VideoCodec codec) {
|
||||
@@ -99,12 +142,31 @@ void Codec::Decode() {
|
||||
packet.data = frame_data.data();
|
||||
packet.size = static_cast<s32>(frame_data.size());
|
||||
|
||||
avcodec_send_packet(av_codec_ctx, &packet);
|
||||
int ret = avcodec_send_packet(av_codec_ctx, &packet);
|
||||
ASSERT_MSG(!ret, "avcodec_send_packet error {}", ret);
|
||||
|
||||
if (!vp9_hidden_frame) {
|
||||
// Only receive/store visible frames
|
||||
AVFramePtr frame = AVFramePtr{av_frame_alloc(), AVFrameDeleter};
|
||||
avcodec_receive_frame(av_codec_ctx, frame.get());
|
||||
AVFrame* hw_frame = av_frame_alloc();
|
||||
AVFrame* sw_frame = hw_frame;
|
||||
ASSERT_MSG(hw_frame, "av_frame_alloc hw_frame failed");
|
||||
ret = avcodec_receive_frame(av_codec_ctx, hw_frame);
|
||||
ASSERT_MSG(ret, "avcodec_receive_frame error {}", ret);
|
||||
#if defined(__linux__)
|
||||
if (hw_frame->format == AV_PIX_FMT_VAAPI) {
|
||||
sw_frame = av_frame_alloc();
|
||||
ASSERT_MSG(sw_frame, "av_frame_alloc sw_frame failed");
|
||||
// Hardware rescale doesn't work because too many broken drivers :(
|
||||
sw_frame->format = AV_PIX_FMT_NV12;
|
||||
ret = av_hwframe_transfer_data(sw_frame, hw_frame, 0);
|
||||
ASSERT_MSG(!ret, "av_hwframe_transfer_data error {}", ret);
|
||||
av_frame_free(&hw_frame);
|
||||
ASSERT_MSG(sw_frame->format == AV_PIX_FMT_NV12,
|
||||
"av_hwframe_transfer_data overwrote AV_PIX_FMT_NV12 to {}",
|
||||
sw_frame->format);
|
||||
}
|
||||
#endif
|
||||
AVFramePtr frame = AVFramePtr{sw_frame, AVFrameDeleter};
|
||||
av_frames.push(std::move(frame));
|
||||
// Limit queue to 10 frames. Workaround for ZLA decode and queue spam
|
||||
if (av_frames.size() > 10) {
|
||||
|
||||
@@ -55,10 +55,13 @@ public:
|
||||
[[nodiscard]] std::string_view GetCurrentCodecName() const;
|
||||
|
||||
private:
|
||||
void InitializeHwdec();
|
||||
|
||||
bool initialized{};
|
||||
NvdecCommon::VideoCodec current_codec{NvdecCommon::VideoCodec::None};
|
||||
|
||||
AVCodec* av_codec{nullptr};
|
||||
AVBufferRef* av_hw_device{nullptr};
|
||||
AVCodecContext* av_codec_ctx{nullptr};
|
||||
|
||||
GPU& gpu;
|
||||
|
||||
@@ -68,6 +68,14 @@ void Vic::Execute() {
|
||||
if (!frame || frame->width == 0 || frame->height == 0) {
|
||||
return;
|
||||
}
|
||||
switch (frame->format) {
|
||||
case AV_PIX_FMT_YUV420P:
|
||||
case AV_PIX_FMT_NV12:
|
||||
break;
|
||||
default:
|
||||
UNIMPLEMENTED_MSG("Unknown video format from host graphics: {}", frame->format);
|
||||
return;
|
||||
}
|
||||
const VideoPixelFormat pixel_format =
|
||||
static_cast<VideoPixelFormat>(config.pixel_format.Value());
|
||||
switch (pixel_format) {
|
||||
@@ -83,10 +91,11 @@ void Vic::Execute() {
|
||||
sws_freeContext(scaler_ctx);
|
||||
scaler_ctx = nullptr;
|
||||
|
||||
// FFmpeg returns all frames in YUV420, convert it into expected format
|
||||
scaler_ctx =
|
||||
sws_getContext(frame->width, frame->height, AV_PIX_FMT_YUV420P, frame->width,
|
||||
frame->height, target_format, 0, nullptr, nullptr, nullptr);
|
||||
// Software return YUV420 and VA-API returns NV12
|
||||
// Convert it to RGB
|
||||
scaler_ctx = sws_getContext(frame->width, frame->height,
|
||||
static_cast<AVPixelFormat>(frame->format), frame->width,
|
||||
frame->height, target_format, 0, nullptr, nullptr, nullptr);
|
||||
|
||||
scaler_width = frame->width;
|
||||
scaler_height = frame->height;
|
||||
@@ -131,38 +140,61 @@ void Vic::Execute() {
|
||||
const std::size_t surface_height = config.surface_height_minus1 + 1;
|
||||
const auto frame_width = std::min(surface_width, static_cast<size_t>(frame->width));
|
||||
const auto frame_height = std::min(surface_height, static_cast<size_t>(frame->height));
|
||||
const std::size_t half_width = frame_width / 2;
|
||||
const std::size_t half_height = frame_height / 2;
|
||||
const std::size_t aligned_width = (surface_width + 0xff) & ~0xff;
|
||||
|
||||
const auto* luma_ptr = frame->data[0];
|
||||
const auto* chroma_b_ptr = frame->data[1];
|
||||
const auto* chroma_r_ptr = frame->data[2];
|
||||
const auto stride = static_cast<size_t>(frame->linesize[0]);
|
||||
const auto half_stride = static_cast<size_t>(frame->linesize[1]);
|
||||
|
||||
luma_buffer.resize(aligned_width * surface_height);
|
||||
chroma_buffer.resize(aligned_width * surface_height / 2);
|
||||
|
||||
// Populate luma buffer
|
||||
for (std::size_t y = 0; y < frame_height; ++y) {
|
||||
const std::size_t src = y * stride;
|
||||
const std::size_t dst = y * aligned_width;
|
||||
for (std::size_t x = 0; x < frame_width; ++x) {
|
||||
luma_buffer[dst + x] = luma_ptr[src + x];
|
||||
{
|
||||
const unsigned char* luma_ptr = frame->data[0];
|
||||
const unsigned char* src = &luma_ptr[frame_height * stride];
|
||||
unsigned char* dst = &luma_buffer[frame_height * aligned_width];
|
||||
for (std::size_t y = frame_height; y--;) {
|
||||
src -= stride;
|
||||
dst -= aligned_width;
|
||||
memcpy(dst, src, frame_width);
|
||||
}
|
||||
}
|
||||
gpu.MemoryManager().WriteBlock(output_surface_luma_address, luma_buffer.data(),
|
||||
luma_buffer.size());
|
||||
|
||||
// Populate chroma buffer from both channels with interleaving.
|
||||
for (std::size_t y = 0; y < half_height; ++y) {
|
||||
const std::size_t src = y * half_stride;
|
||||
const std::size_t dst = y * aligned_width;
|
||||
// Chroma
|
||||
{
|
||||
const std::size_t half_height = frame_height / 2;
|
||||
const auto half_stride = static_cast<size_t>(frame->linesize[1]);
|
||||
unsigned char* dst = &chroma_buffer[half_height * aligned_width];
|
||||
|
||||
for (std::size_t x = 0; x < half_width; ++x) {
|
||||
chroma_buffer[dst + x * 2] = chroma_b_ptr[src + x];
|
||||
chroma_buffer[dst + x * 2 + 1] = chroma_r_ptr[src + x];
|
||||
LOG_CRITICAL(Debug, "Target");
|
||||
if (frame->format == AV_PIX_FMT_YUV420P) {
|
||||
// Frame from FFmpeg software
|
||||
// Populate chroma buffer from both channels with interleaving.
|
||||
const std::size_t half_width = frame_width / 2;
|
||||
const unsigned char* chroma_r_ptr = frame->data[2];
|
||||
const unsigned char* chroma_b_ptr = frame->data[1];
|
||||
const unsigned char* src_r = &chroma_r_ptr[half_height * half_stride];
|
||||
const unsigned char* src_b = &chroma_b_ptr[half_height * half_stride];
|
||||
for (std::size_t y = half_height; y--;) {
|
||||
dst -= aligned_width;
|
||||
src_r -= half_stride;
|
||||
src_b -= half_stride;
|
||||
for (std::size_t x = half_width; x--;) {
|
||||
dst[x * 2 + 1] = src_r[x];
|
||||
dst[x * 2] = src_b[x];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Frame from VA-API hardware
|
||||
// This is already interleaved so just copy
|
||||
const unsigned char* chroma_ptr = frame->data[1];
|
||||
const unsigned char* src = &chroma_ptr[half_height * half_stride];
|
||||
for (std::size_t y = half_height; y--;) {
|
||||
src -= half_stride;
|
||||
dst -= aligned_width;
|
||||
memcpy(dst, src, frame_width);
|
||||
}
|
||||
}
|
||||
}
|
||||
gpu.MemoryManager().WriteBlock(output_surface_chroma_u_address, chroma_buffer.data(),
|
||||
|
||||
@@ -37,7 +37,8 @@ std::unique_ptr<VideoCore::RendererBase> CreateRenderer(
|
||||
namespace VideoCore {
|
||||
|
||||
std::unique_ptr<Tegra::GPU> CreateGPU(Core::Frontend::EmuWindow& emu_window, Core::System& system) {
|
||||
const bool use_nvdec = Settings::values.use_nvdec_emulation.GetValue();
|
||||
const bool use_nvdec =
|
||||
Settings::values.nvdec_emulation.GetValue() != Settings::NvdecEmulation::Off;
|
||||
const bool use_async = Settings::values.use_asynchronous_gpu_emulation.GetValue();
|
||||
auto gpu = std::make_unique<Tegra::GPU>(system, use_async, use_nvdec);
|
||||
auto context = emu_window.CreateSharedContext();
|
||||
|
||||
@@ -811,7 +811,7 @@ void Config::ReadRendererValues() {
|
||||
ReadGlobalSetting(Settings::values.use_disk_shader_cache);
|
||||
ReadGlobalSetting(Settings::values.gpu_accuracy);
|
||||
ReadGlobalSetting(Settings::values.use_asynchronous_gpu_emulation);
|
||||
ReadGlobalSetting(Settings::values.use_nvdec_emulation);
|
||||
ReadGlobalSetting(Settings::values.nvdec_emulation);
|
||||
ReadGlobalSetting(Settings::values.accelerate_astc);
|
||||
ReadGlobalSetting(Settings::values.use_vsync);
|
||||
ReadGlobalSetting(Settings::values.shader_backend);
|
||||
@@ -1343,7 +1343,10 @@ void Config::SaveRendererValues() {
|
||||
static_cast<u32>(Settings::values.gpu_accuracy.GetDefault()),
|
||||
Settings::values.gpu_accuracy.UsingGlobal());
|
||||
WriteGlobalSetting(Settings::values.use_asynchronous_gpu_emulation);
|
||||
WriteGlobalSetting(Settings::values.use_nvdec_emulation);
|
||||
WriteSetting(QString::fromStdString(Settings::values.nvdec_emulation.GetLabel()),
|
||||
static_cast<u32>(Settings::values.nvdec_emulation.GetValue(global)),
|
||||
static_cast<u32>(Settings::values.nvdec_emulation.GetDefault()),
|
||||
Settings::values.nvdec_emulation.UsingGlobal());
|
||||
WriteGlobalSetting(Settings::values.accelerate_astc);
|
||||
WriteGlobalSetting(Settings::values.use_vsync);
|
||||
WriteSetting(QString::fromStdString(Settings::values.shader_backend.GetLabel()),
|
||||
|
||||
@@ -181,5 +181,6 @@ private:
|
||||
// These metatype declarations cannot be in common/settings.h because core is devoid of QT
|
||||
Q_DECLARE_METATYPE(Settings::CPUAccuracy);
|
||||
Q_DECLARE_METATYPE(Settings::GPUAccuracy);
|
||||
Q_DECLARE_METATYPE(Settings::NvdecEmulation);
|
||||
Q_DECLARE_METATYPE(Settings::RendererBackend);
|
||||
Q_DECLARE_METATYPE(Settings::ShaderBackend);
|
||||
|
||||
@@ -88,16 +88,20 @@ void ConfigureGraphics::SetConfiguration() {
|
||||
ui->api_widget->setEnabled(runtime_lock);
|
||||
ui->use_asynchronous_gpu_emulation->setEnabled(runtime_lock);
|
||||
ui->use_disk_shader_cache->setEnabled(runtime_lock);
|
||||
ui->use_nvdec_emulation->setEnabled(runtime_lock);
|
||||
ui->nvdec_emulation_widget->setEnabled(runtime_lock);
|
||||
#if !defined(__linux__)
|
||||
ui->nvdec_emulation->removeItem(static_cast<int>(Settings::NvdecEmulation::Vaapi));
|
||||
#endif
|
||||
ui->accelerate_astc->setEnabled(runtime_lock);
|
||||
ui->use_disk_shader_cache->setChecked(Settings::values.use_disk_shader_cache.GetValue());
|
||||
ui->use_asynchronous_gpu_emulation->setChecked(
|
||||
Settings::values.use_asynchronous_gpu_emulation.GetValue());
|
||||
ui->use_nvdec_emulation->setChecked(Settings::values.use_nvdec_emulation.GetValue());
|
||||
ui->accelerate_astc->setChecked(Settings::values.accelerate_astc.GetValue());
|
||||
|
||||
if (Settings::IsConfiguringGlobal()) {
|
||||
ui->api->setCurrentIndex(static_cast<int>(Settings::values.renderer_backend.GetValue()));
|
||||
ui->nvdec_emulation->setCurrentIndex(
|
||||
static_cast<int>(Settings::values.nvdec_emulation.GetValue()));
|
||||
ui->fullscreen_mode_combobox->setCurrentIndex(Settings::values.fullscreen_mode.GetValue());
|
||||
ui->aspect_ratio_combobox->setCurrentIndex(Settings::values.aspect_ratio.GetValue());
|
||||
} else {
|
||||
@@ -105,7 +109,12 @@ void ConfigureGraphics::SetConfiguration() {
|
||||
ConfigurationShared::SetHighlight(ui->api_widget,
|
||||
!Settings::values.renderer_backend.UsingGlobal());
|
||||
|
||||
ConfigurationShared::SetPerGameSetting(ui->fullscreen_mode_combobox,
|
||||
ConfigurationShared::SetPerGameSetting(ui->nvdec_emulation,
|
||||
&Settings::values.nvdec_emulation);
|
||||
ConfigurationShared::SetHighlight(ui->nvdec_emulation_widget,
|
||||
!Settings::values.nvdec_emulation.UsingGlobal());
|
||||
|
||||
ConfigurationShared::SetPerGameSetting(ui->fullscreen_mode_combobox,
|
||||
&Settings::values.fullscreen_mode);
|
||||
ConfigurationShared::SetHighlight(ui->fullscreen_mode_label,
|
||||
!Settings::values.fullscreen_mode.UsingGlobal());
|
||||
@@ -136,8 +145,6 @@ void ConfigureGraphics::ApplyConfiguration() {
|
||||
ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_asynchronous_gpu_emulation,
|
||||
ui->use_asynchronous_gpu_emulation,
|
||||
use_asynchronous_gpu_emulation);
|
||||
ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_nvdec_emulation,
|
||||
ui->use_nvdec_emulation, use_nvdec_emulation);
|
||||
ConfigurationShared::ApplyPerGameSetting(&Settings::values.accelerate_astc, ui->accelerate_astc,
|
||||
accelerate_astc);
|
||||
|
||||
@@ -146,6 +153,9 @@ void ConfigureGraphics::ApplyConfiguration() {
|
||||
if (Settings::values.renderer_backend.UsingGlobal()) {
|
||||
Settings::values.renderer_backend.SetValue(GetCurrentGraphicsBackend());
|
||||
}
|
||||
if (Settings::values.nvdec_emulation.UsingGlobal()) {
|
||||
Settings::values.nvdec_emulation.SetValue(GetCurrentNvdecEmulation());
|
||||
}
|
||||
if (Settings::values.shader_backend.UsingGlobal()) {
|
||||
Settings::values.shader_backend.SetValue(shader_backend);
|
||||
}
|
||||
@@ -179,6 +189,13 @@ void ConfigureGraphics::ApplyConfiguration() {
|
||||
}
|
||||
}
|
||||
|
||||
if (ui->nvdec_emulation->currentIndex() == ConfigurationShared::USE_GLOBAL_INDEX) {
|
||||
Settings::values.nvdec_emulation.SetGlobal(true);
|
||||
} else {
|
||||
Settings::values.nvdec_emulation.SetGlobal(false);
|
||||
Settings::values.nvdec_emulation.SetValue(GetCurrentNvdecEmulation());
|
||||
}
|
||||
|
||||
if (ui->bg_combobox->currentIndex() == ConfigurationShared::USE_GLOBAL_INDEX) {
|
||||
Settings::values.bg_red.SetGlobal(true);
|
||||
Settings::values.bg_green.SetGlobal(true);
|
||||
@@ -277,6 +294,20 @@ Settings::RendererBackend ConfigureGraphics::GetCurrentGraphicsBackend() const {
|
||||
ConfigurationShared::USE_GLOBAL_OFFSET);
|
||||
}
|
||||
|
||||
Settings::NvdecEmulation ConfigureGraphics::GetCurrentNvdecEmulation() const {
|
||||
if (Settings::IsConfiguringGlobal()) {
|
||||
return static_cast<Settings::NvdecEmulation>(ui->nvdec_emulation->currentIndex());
|
||||
}
|
||||
|
||||
if (ui->nvdec_emulation->currentIndex() == ConfigurationShared::USE_GLOBAL_INDEX) {
|
||||
Settings::values.nvdec_emulation.SetGlobal(true);
|
||||
return Settings::values.nvdec_emulation.GetValue();
|
||||
}
|
||||
Settings::values.nvdec_emulation.SetGlobal(false);
|
||||
return static_cast<Settings::NvdecEmulation>(ui->nvdec_emulation->currentIndex() -
|
||||
ConfigurationShared::USE_GLOBAL_OFFSET);
|
||||
}
|
||||
|
||||
void ConfigureGraphics::SetupPerGameUI() {
|
||||
if (Settings::IsConfiguringGlobal()) {
|
||||
ui->api->setEnabled(Settings::values.renderer_backend.UsingGlobal());
|
||||
@@ -285,7 +316,7 @@ void ConfigureGraphics::SetupPerGameUI() {
|
||||
ui->aspect_ratio_combobox->setEnabled(Settings::values.aspect_ratio.UsingGlobal());
|
||||
ui->use_asynchronous_gpu_emulation->setEnabled(
|
||||
Settings::values.use_asynchronous_gpu_emulation.UsingGlobal());
|
||||
ui->use_nvdec_emulation->setEnabled(Settings::values.use_nvdec_emulation.UsingGlobal());
|
||||
ui->nvdec_emulation->setEnabled(Settings::values.nvdec_emulation.UsingGlobal());
|
||||
ui->accelerate_astc->setEnabled(Settings::values.accelerate_astc.UsingGlobal());
|
||||
ui->use_disk_shader_cache->setEnabled(Settings::values.use_disk_shader_cache.UsingGlobal());
|
||||
ui->bg_button->setEnabled(Settings::values.bg_red.UsingGlobal());
|
||||
@@ -300,8 +331,6 @@ void ConfigureGraphics::SetupPerGameUI() {
|
||||
|
||||
ConfigurationShared::SetColoredTristate(
|
||||
ui->use_disk_shader_cache, Settings::values.use_disk_shader_cache, use_disk_shader_cache);
|
||||
ConfigurationShared::SetColoredTristate(
|
||||
ui->use_nvdec_emulation, Settings::values.use_nvdec_emulation, use_nvdec_emulation);
|
||||
ConfigurationShared::SetColoredTristate(ui->accelerate_astc, Settings::values.accelerate_astc,
|
||||
accelerate_astc);
|
||||
ConfigurationShared::SetColoredTristate(ui->use_asynchronous_gpu_emulation,
|
||||
@@ -314,4 +343,7 @@ void ConfigureGraphics::SetupPerGameUI() {
|
||||
Settings::values.fullscreen_mode.GetValue(true));
|
||||
ConfigurationShared::InsertGlobalItem(
|
||||
ui->api, static_cast<int>(Settings::values.renderer_backend.GetValue(true)));
|
||||
ConfigurationShared::InsertGlobalItem(
|
||||
ui->nvdec_emulation, static_cast<int>(Settings::values.nvdec_emulation.GetValue(true)));
|
||||
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ private:
|
||||
void SetupPerGameUI();
|
||||
|
||||
Settings::RendererBackend GetCurrentGraphicsBackend() const;
|
||||
Settings::NvdecEmulation GetCurrentNvdecEmulation() const;
|
||||
|
||||
std::unique_ptr<Ui::ConfigureGraphics> ui;
|
||||
QColor bg_color;
|
||||
|
||||
@@ -167,13 +167,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="use_nvdec_emulation">
|
||||
<property name="text">
|
||||
<string>Use NVDEC emulation</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="accelerate_astc">
|
||||
<property name="text">
|
||||
@@ -181,6 +174,50 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="nvdec_emulation_widget" native="true">
|
||||
<layout class="QHBoxLayout" name="nvdec_emulation_layout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="nvdec_emulation_label">
|
||||
<property name="text">
|
||||
<string>Nvdec emulation:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="nvdec_emulation">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Off</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Software</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>VA-API</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="fullscreen_mode_layout" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_1">
|
||||
|
||||
@@ -461,7 +461,7 @@ void Config::ReadValues() {
|
||||
ReadSetting("Renderer", Settings::values.disable_fps_limit);
|
||||
ReadSetting("Renderer", Settings::values.shader_backend);
|
||||
ReadSetting("Renderer", Settings::values.use_asynchronous_shaders);
|
||||
ReadSetting("Renderer", Settings::values.use_nvdec_emulation);
|
||||
ReadSetting("Renderer", Settings::values.nvdec_emulation);
|
||||
ReadSetting("Renderer", Settings::values.accelerate_astc);
|
||||
ReadSetting("Renderer", Settings::values.use_fast_gpu_time);
|
||||
ReadSetting("Renderer", Settings::values.use_caches_gc);
|
||||
|
||||
@@ -257,9 +257,9 @@ shader_backend =
|
||||
# 0 (default): Off, 1: On
|
||||
use_asynchronous_shaders =
|
||||
|
||||
# Enable NVDEC emulation.
|
||||
# 0: Off, 1 (default): On
|
||||
use_nvdec_emulation =
|
||||
# NVDEC emulation.
|
||||
# 0: Off, 1 (default): Software, 2: VA-API
|
||||
nvdec_emulation =
|
||||
|
||||
# Accelerate ASTC texture decoding.
|
||||
# 0: Off, 1 (default): On
|
||||
|
||||
Reference in New Issue
Block a user