yuzu-emu
/
yuzu-android
Archived
1
0
Fork 0

Merge pull request #6464 from ameerj/disable-astc

textures: Add a toggle for GPU Accelerated ASTC decoder
This commit is contained in:
bunnei 2021-06-16 11:29:10 -07:00 committed by GitHub
commit 973bf306ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 1637 additions and 7 deletions

View File

@ -55,6 +55,7 @@ void LogSettings() {
log_setting("Renderer_UseAsynchronousGpuEmulation", log_setting("Renderer_UseAsynchronousGpuEmulation",
values.use_asynchronous_gpu_emulation.GetValue()); values.use_asynchronous_gpu_emulation.GetValue());
log_setting("Renderer_UseNvdecEmulation", values.use_nvdec_emulation.GetValue()); log_setting("Renderer_UseNvdecEmulation", values.use_nvdec_emulation.GetValue());
log_setting("Renderer_AccelerateASTC", values.accelerate_astc.GetValue());
log_setting("Renderer_UseVsync", values.use_vsync.GetValue()); log_setting("Renderer_UseVsync", values.use_vsync.GetValue());
log_setting("Renderer_UseAssemblyShaders", values.use_assembly_shaders.GetValue()); log_setting("Renderer_UseAssemblyShaders", values.use_assembly_shaders.GetValue());
log_setting("Renderer_UseAsynchronousShaders", values.use_asynchronous_shaders.GetValue()); log_setting("Renderer_UseAsynchronousShaders", values.use_asynchronous_shaders.GetValue());
@ -135,6 +136,7 @@ void RestoreGlobalState(bool is_powered_on) {
values.gpu_accuracy.SetGlobal(true); values.gpu_accuracy.SetGlobal(true);
values.use_asynchronous_gpu_emulation.SetGlobal(true); values.use_asynchronous_gpu_emulation.SetGlobal(true);
values.use_nvdec_emulation.SetGlobal(true); values.use_nvdec_emulation.SetGlobal(true);
values.accelerate_astc.SetGlobal(true);
values.use_vsync.SetGlobal(true); values.use_vsync.SetGlobal(true);
values.use_assembly_shaders.SetGlobal(true); values.use_assembly_shaders.SetGlobal(true);
values.use_asynchronous_shaders.SetGlobal(true); values.use_asynchronous_shaders.SetGlobal(true);

View File

@ -147,6 +147,7 @@ struct Values {
Setting<GPUAccuracy> gpu_accuracy; Setting<GPUAccuracy> gpu_accuracy;
Setting<bool> use_asynchronous_gpu_emulation; Setting<bool> use_asynchronous_gpu_emulation;
Setting<bool> use_nvdec_emulation; Setting<bool> use_nvdec_emulation;
Setting<bool> accelerate_astc;
Setting<bool> use_vsync; Setting<bool> use_vsync;
Setting<bool> use_assembly_shaders; Setting<bool> use_assembly_shaders;
Setting<bool> use_asynchronous_shaders; Setting<bool> use_asynchronous_shaders;

View File

@ -230,6 +230,7 @@ void TelemetrySession::AddInitialInfo(Loader::AppLoader& app_loader,
Settings::values.use_asynchronous_gpu_emulation.GetValue()); Settings::values.use_asynchronous_gpu_emulation.GetValue());
AddField(field_type, "Renderer_UseNvdecEmulation", AddField(field_type, "Renderer_UseNvdecEmulation",
Settings::values.use_nvdec_emulation.GetValue()); Settings::values.use_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_UseVsync", Settings::values.use_vsync.GetValue());
AddField(field_type, "Renderer_UseAssemblyShaders", AddField(field_type, "Renderer_UseAssemblyShaders",
Settings::values.use_assembly_shaders.GetValue()); Settings::values.use_assembly_shaders.GetValue());

View File

@ -237,6 +237,7 @@ add_library(video_core STATIC
texture_cache/util.cpp texture_cache/util.cpp
texture_cache/util.h texture_cache/util.h
textures/astc.h textures/astc.h
textures/astc.cpp
textures/decoders.cpp textures/decoders.cpp
textures/decoders.h textures/decoders.h
textures/texture.cpp textures/texture.cpp

View File

@ -763,7 +763,7 @@ void ComputeEndpoints(out uvec4 ep1, out uvec4 ep2, uint color_endpoint_mode) {
case 1: { case 1: {
READ_UINT_VALUES(2) READ_UINT_VALUES(2)
uint L0 = (v[0] >> 2) | (v[1] & 0xC0); uint L0 = (v[0] >> 2) | (v[1] & 0xC0);
uint L1 = max(L0 + (v[1] & 0x3F), 0xFFU); uint L1 = min(L0 + (v[1] & 0x3F), 0xFFU);
ep1 = uvec4(0xFF, L0, L0, L0); ep1 = uvec4(0xFF, L0, L0, L0);
ep2 = uvec4(0xFF, L1, L1, L1); ep2 = uvec4(0xFF, L1, L1, L1);
break; break;

View File

@ -9,6 +9,8 @@
#include <glad/glad.h> #include <glad/glad.h>
#include "common/settings.h"
#include "video_core/renderer_opengl/gl_device.h" #include "video_core/renderer_opengl/gl_device.h"
#include "video_core/renderer_opengl/gl_shader_manager.h" #include "video_core/renderer_opengl/gl_shader_manager.h"
#include "video_core/renderer_opengl/gl_state_tracker.h" #include "video_core/renderer_opengl/gl_state_tracker.h"
@ -307,7 +309,9 @@ void ApplySwizzle(GLuint handle, PixelFormat format, std::array<SwizzleSource, 4
[[nodiscard]] bool CanBeAccelerated(const TextureCacheRuntime& runtime, [[nodiscard]] bool CanBeAccelerated(const TextureCacheRuntime& runtime,
const VideoCommon::ImageInfo& info) { const VideoCommon::ImageInfo& info) {
return !runtime.HasNativeASTC() && IsPixelFormatASTC(info.format); if (IsPixelFormatASTC(info.format)) {
return !runtime.HasNativeASTC() && Settings::values.accelerate_astc.GetValue();
}
// Disable other accelerated uploads for now as they don't implement swizzled uploads // Disable other accelerated uploads for now as they don't implement swizzled uploads
return false; return false;
switch (info.type) { switch (info.type) {

View File

@ -8,6 +8,7 @@
#include <vector> #include <vector>
#include "common/bit_cast.h" #include "common/bit_cast.h"
#include "common/settings.h"
#include "video_core/engines/fermi_2d.h" #include "video_core/engines/fermi_2d.h"
#include "video_core/renderer_vulkan/blit_image.h" #include "video_core/renderer_vulkan/blit_image.h"
@ -828,7 +829,11 @@ Image::Image(TextureCacheRuntime& runtime, const ImageInfo& info_, GPUVAddr gpu_
commit = runtime.memory_allocator.Commit(buffer, MemoryUsage::DeviceLocal); commit = runtime.memory_allocator.Commit(buffer, MemoryUsage::DeviceLocal);
} }
if (IsPixelFormatASTC(info.format) && !runtime.device.IsOptimalAstcSupported()) { if (IsPixelFormatASTC(info.format) && !runtime.device.IsOptimalAstcSupported()) {
if (Settings::values.accelerate_astc.GetValue()) {
flags |= VideoCommon::ImageFlagBits::AcceleratedUpload; flags |= VideoCommon::ImageFlagBits::AcceleratedUpload;
} else {
flags |= VideoCommon::ImageFlagBits::Converted;
}
} }
if (runtime.device.HasDebuggingToolAttached()) { if (runtime.device.HasDebuggingToolAttached()) {
if (image) { if (image) {

View File

@ -47,6 +47,7 @@
#include "video_core/texture_cache/formatter.h" #include "video_core/texture_cache/formatter.h"
#include "video_core/texture_cache/samples_helper.h" #include "video_core/texture_cache/samples_helper.h"
#include "video_core/texture_cache/util.h" #include "video_core/texture_cache/util.h"
#include "video_core/textures/astc.h"
#include "video_core/textures/decoders.h" #include "video_core/textures/decoders.h"
namespace VideoCommon { namespace VideoCommon {
@ -884,8 +885,16 @@ void ConvertImage(std::span<const u8> input, const ImageInfo& info, std::span<u8
ASSERT(copy.image_extent == mip_size); ASSERT(copy.image_extent == mip_size);
ASSERT(copy.buffer_row_length == Common::AlignUp(mip_size.width, tile_size.width)); ASSERT(copy.buffer_row_length == Common::AlignUp(mip_size.width, tile_size.width));
ASSERT(copy.buffer_image_height == Common::AlignUp(mip_size.height, tile_size.height)); ASSERT(copy.buffer_image_height == Common::AlignUp(mip_size.height, tile_size.height));
if (IsPixelFormatASTC(info.format)) {
ASSERT(copy.image_extent.depth == 1);
Tegra::Texture::ASTC::Decompress(input.subspan(copy.buffer_offset),
copy.image_extent.width, copy.image_extent.height,
copy.image_subresource.num_layers, tile_size.width,
tile_size.height, output.subspan(output_offset));
} else {
DecompressBC4(input.subspan(copy.buffer_offset), copy.image_extent, DecompressBC4(input.subspan(copy.buffer_offset), copy.image_extent,
output.subspan(output_offset)); output.subspan(output_offset));
}
copy.buffer_offset = output_offset; copy.buffer_offset = output_offset;
copy.buffer_row_length = mip_size.width; copy.buffer_row_length = mip_size.width;
copy.buffer_image_height = mip_size.height; copy.buffer_image_height = mip_size.height;

File diff suppressed because it is too large Load Diff

View File

@ -129,4 +129,7 @@ struct AstcBufferData {
decltype(REPLICATE_BYTE_TO_16_TABLE) replicate_byte_to_16 = REPLICATE_BYTE_TO_16_TABLE; decltype(REPLICATE_BYTE_TO_16_TABLE) replicate_byte_to_16 = REPLICATE_BYTE_TO_16_TABLE;
} constexpr ASTC_BUFFER_DATA; } constexpr ASTC_BUFFER_DATA;
void Decompress(std::span<const uint8_t> data, uint32_t width, uint32_t height, uint32_t depth,
uint32_t block_width, uint32_t block_height, std::span<uint8_t> output);
} // namespace Tegra::Texture::ASTC } // namespace Tegra::Texture::ASTC

View File

@ -809,6 +809,7 @@ void Config::ReadRendererValues() {
QStringLiteral("use_asynchronous_gpu_emulation"), true); QStringLiteral("use_asynchronous_gpu_emulation"), true);
ReadSettingGlobal(Settings::values.use_nvdec_emulation, QStringLiteral("use_nvdec_emulation"), ReadSettingGlobal(Settings::values.use_nvdec_emulation, QStringLiteral("use_nvdec_emulation"),
true); true);
ReadSettingGlobal(Settings::values.accelerate_astc, QStringLiteral("accelerate_astc"), true);
ReadSettingGlobal(Settings::values.use_vsync, QStringLiteral("use_vsync"), true); ReadSettingGlobal(Settings::values.use_vsync, QStringLiteral("use_vsync"), true);
ReadSettingGlobal(Settings::values.use_assembly_shaders, QStringLiteral("use_assembly_shaders"), ReadSettingGlobal(Settings::values.use_assembly_shaders, QStringLiteral("use_assembly_shaders"),
false); false);
@ -1392,6 +1393,7 @@ void Config::SaveRendererValues() {
Settings::values.use_asynchronous_gpu_emulation, true); Settings::values.use_asynchronous_gpu_emulation, true);
WriteSettingGlobal(QStringLiteral("use_nvdec_emulation"), Settings::values.use_nvdec_emulation, WriteSettingGlobal(QStringLiteral("use_nvdec_emulation"), Settings::values.use_nvdec_emulation,
true); true);
WriteSettingGlobal(QStringLiteral("accelerate_astc"), Settings::values.accelerate_astc, true);
WriteSettingGlobal(QStringLiteral("use_vsync"), Settings::values.use_vsync, true); WriteSettingGlobal(QStringLiteral("use_vsync"), Settings::values.use_vsync, true);
WriteSettingGlobal(QStringLiteral("use_assembly_shaders"), WriteSettingGlobal(QStringLiteral("use_assembly_shaders"),
Settings::values.use_assembly_shaders, false); Settings::values.use_assembly_shaders, false);

View File

@ -70,10 +70,12 @@ void ConfigureGraphics::SetConfiguration() {
ui->use_asynchronous_gpu_emulation->setEnabled(runtime_lock); ui->use_asynchronous_gpu_emulation->setEnabled(runtime_lock);
ui->use_disk_shader_cache->setEnabled(runtime_lock); ui->use_disk_shader_cache->setEnabled(runtime_lock);
ui->use_nvdec_emulation->setEnabled(runtime_lock); ui->use_nvdec_emulation->setEnabled(runtime_lock);
ui->accelerate_astc->setEnabled(runtime_lock);
ui->use_disk_shader_cache->setChecked(Settings::values.use_disk_shader_cache.GetValue()); ui->use_disk_shader_cache->setChecked(Settings::values.use_disk_shader_cache.GetValue());
ui->use_asynchronous_gpu_emulation->setChecked( ui->use_asynchronous_gpu_emulation->setChecked(
Settings::values.use_asynchronous_gpu_emulation.GetValue()); Settings::values.use_asynchronous_gpu_emulation.GetValue());
ui->use_nvdec_emulation->setChecked(Settings::values.use_nvdec_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()) { if (Settings::IsConfiguringGlobal()) {
ui->api->setCurrentIndex(static_cast<int>(Settings::values.renderer_backend.GetValue())); ui->api->setCurrentIndex(static_cast<int>(Settings::values.renderer_backend.GetValue()));
@ -118,6 +120,8 @@ void ConfigureGraphics::ApplyConfiguration() {
use_asynchronous_gpu_emulation); use_asynchronous_gpu_emulation);
ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_nvdec_emulation, ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_nvdec_emulation,
ui->use_nvdec_emulation, use_nvdec_emulation); ui->use_nvdec_emulation, use_nvdec_emulation);
ConfigurationShared::ApplyPerGameSetting(&Settings::values.accelerate_astc, ui->accelerate_astc,
accelerate_astc);
if (Settings::IsConfiguringGlobal()) { if (Settings::IsConfiguringGlobal()) {
// Guard if during game and set to game-specific value // Guard if during game and set to game-specific value
@ -254,6 +258,7 @@ void ConfigureGraphics::SetupPerGameUI() {
ui->use_asynchronous_gpu_emulation->setEnabled( ui->use_asynchronous_gpu_emulation->setEnabled(
Settings::values.use_asynchronous_gpu_emulation.UsingGlobal()); Settings::values.use_asynchronous_gpu_emulation.UsingGlobal());
ui->use_nvdec_emulation->setEnabled(Settings::values.use_nvdec_emulation.UsingGlobal()); ui->use_nvdec_emulation->setEnabled(Settings::values.use_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->use_disk_shader_cache->setEnabled(Settings::values.use_disk_shader_cache.UsingGlobal());
ui->bg_button->setEnabled(Settings::values.bg_red.UsingGlobal()); ui->bg_button->setEnabled(Settings::values.bg_red.UsingGlobal());
@ -269,6 +274,8 @@ void ConfigureGraphics::SetupPerGameUI() {
ui->use_disk_shader_cache, Settings::values.use_disk_shader_cache, use_disk_shader_cache); ui->use_disk_shader_cache, Settings::values.use_disk_shader_cache, use_disk_shader_cache);
ConfigurationShared::SetColoredTristate( ConfigurationShared::SetColoredTristate(
ui->use_nvdec_emulation, Settings::values.use_nvdec_emulation, use_nvdec_emulation); 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, ConfigurationShared::SetColoredTristate(ui->use_asynchronous_gpu_emulation,
Settings::values.use_asynchronous_gpu_emulation, Settings::values.use_asynchronous_gpu_emulation,
use_asynchronous_gpu_emulation); use_asynchronous_gpu_emulation);

View File

@ -47,6 +47,7 @@ private:
QColor bg_color; QColor bg_color;
ConfigurationShared::CheckState use_nvdec_emulation; ConfigurationShared::CheckState use_nvdec_emulation;
ConfigurationShared::CheckState accelerate_astc;
ConfigurationShared::CheckState use_disk_shader_cache; ConfigurationShared::CheckState use_disk_shader_cache;
ConfigurationShared::CheckState use_asynchronous_gpu_emulation; ConfigurationShared::CheckState use_asynchronous_gpu_emulation;

View File

@ -104,6 +104,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="accelerate_astc">
<property name="text">
<string>Accelerate ASTC texture decoding</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QWidget" name="fullscreen_mode_layout" native="true"> <widget class="QWidget" name="fullscreen_mode_layout" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_1"> <layout class="QHBoxLayout" name="horizontalLayout_1">

View File

@ -447,8 +447,10 @@ void Config::ReadValues() {
sdl2_config->GetBoolean("Renderer", "use_assembly_shaders", true)); sdl2_config->GetBoolean("Renderer", "use_assembly_shaders", true));
Settings::values.use_asynchronous_shaders.SetValue( Settings::values.use_asynchronous_shaders.SetValue(
sdl2_config->GetBoolean("Renderer", "use_asynchronous_shaders", false)); sdl2_config->GetBoolean("Renderer", "use_asynchronous_shaders", false));
Settings::values.use_asynchronous_shaders.SetValue( Settings::values.use_nvdec_emulation.SetValue(
sdl2_config->GetBoolean("Renderer", "use_asynchronous_shaders", false)); sdl2_config->GetBoolean("Renderer", "use_nvdec_emulation", true));
Settings::values.accelerate_astc.SetValue(
sdl2_config->GetBoolean("Renderer", "accelerate_astc", true));
Settings::values.use_fast_gpu_time.SetValue( Settings::values.use_fast_gpu_time.SetValue(
sdl2_config->GetBoolean("Renderer", "use_fast_gpu_time", true)); sdl2_config->GetBoolean("Renderer", "use_fast_gpu_time", true));

View File

@ -194,6 +194,14 @@ use_assembly_shaders =
# 0 (default): Off, 1: On # 0 (default): Off, 1: On
use_asynchronous_shaders = use_asynchronous_shaders =
# Enable NVDEC emulation.
# 0: Off, 1 (default): On
use_nvdec_emulation =
# Accelerate ASTC texture decoding.
# 0: Off, 1 (default): On
accelerate_astc =
# Turns on the frame limiter, which will limit frames output to the target game speed # Turns on the frame limiter, which will limit frames output to the target game speed
# 0: Off, 1: On (default) # 0: Off, 1: On (default)
use_frame_limit = use_frame_limit =