early-access version 1955

This commit is contained in:
pineappleEA 2021-08-01 14:23:27 +02:00
parent 57da374c03
commit 489aa4bae1
8 changed files with 114 additions and 38 deletions

View file

@ -1,7 +1,7 @@
yuzu emulator early access yuzu emulator early access
============= =============
This is the source code for early-access 1954. This is the source code for early-access 1955.
## Legal Notice ## Legal Notice

View file

@ -18,9 +18,9 @@
namespace Tegra::Texture { namespace Tegra::Texture {
namespace { namespace {
template <bool TO_LINEAR> template <bool TO_LINEAR, u32 BYTES_PER_PIXEL>
void Swizzle(std::span<u8> output, std::span<const u8> input, u32 bytes_per_pixel, u32 width, void SwizzleImpl(std::span<u8> output, std::span<const u8> input, u32 width, u32 height, u32 depth,
u32 height, u32 depth, u32 block_height, u32 block_depth, u32 stride_alignment) { u32 block_height, u32 block_depth, u32 stride_alignment) {
// The origin of the transformation can be configured here, leave it as zero as the current API // The origin of the transformation can be configured here, leave it as zero as the current API
// doesn't expose it. // doesn't expose it.
static constexpr u32 origin_x = 0; static constexpr u32 origin_x = 0;
@ -28,9 +28,9 @@ void Swizzle(std::span<u8> output, std::span<const u8> input, u32 bytes_per_pixe
static constexpr u32 origin_z = 0; static constexpr u32 origin_z = 0;
// We can configure here a custom pitch // We can configure here a custom pitch
// As it's not exposed 'width * bpp' will be the expected pitch. // As it's not exposed 'width * BYTES_PER_PIXEL' will be the expected pitch.
const u32 pitch = width * bytes_per_pixel; const u32 pitch = width * BYTES_PER_PIXEL;
const u32 stride = Common::AlignUpLog2(width, stride_alignment) * bytes_per_pixel; const u32 stride = Common::AlignUpLog2(width, stride_alignment) * BYTES_PER_PIXEL;
const u32 gobs_in_x = Common::DivCeilLog2(stride, GOB_SIZE_X_SHIFT); const u32 gobs_in_x = Common::DivCeilLog2(stride, GOB_SIZE_X_SHIFT);
const u32 block_size = gobs_in_x << (GOB_SIZE_SHIFT + block_height + block_depth); const u32 block_size = gobs_in_x << (GOB_SIZE_SHIFT + block_height + block_depth);
@ -54,14 +54,14 @@ void Swizzle(std::span<u8> output, std::span<const u8> input, u32 bytes_per_pixe
((block_y & block_height_mask) << GOB_SIZE_SHIFT); ((block_y & block_height_mask) << GOB_SIZE_SHIFT);
for (u32 column = 0; column < width; ++column) { for (u32 column = 0; column < width; ++column) {
const u32 x = (column + origin_x) * bytes_per_pixel; const u32 x = (column + origin_x) * BYTES_PER_PIXEL;
const u32 offset_x = (x >> GOB_SIZE_X_SHIFT) << x_shift; const u32 offset_x = (x >> GOB_SIZE_X_SHIFT) << x_shift;
const u32 base_swizzled_offset = offset_z + offset_y + offset_x; const u32 base_swizzled_offset = offset_z + offset_y + offset_x;
const u32 swizzled_offset = base_swizzled_offset + table[x % GOB_SIZE_X]; const u32 swizzled_offset = base_swizzled_offset + table[x % GOB_SIZE_X];
const u32 unswizzled_offset = const u32 unswizzled_offset =
slice * pitch * height + line * pitch + column * bytes_per_pixel; slice * pitch * height + line * pitch + column * BYTES_PER_PIXEL;
if (const auto offset = (TO_LINEAR ? unswizzled_offset : swizzled_offset); if (const auto offset = (TO_LINEAR ? unswizzled_offset : swizzled_offset);
offset >= input.size()) { offset >= input.size()) {
@ -73,11 +73,45 @@ void Swizzle(std::span<u8> output, std::span<const u8> input, u32 bytes_per_pixe
u8* const dst = &output[TO_LINEAR ? swizzled_offset : unswizzled_offset]; u8* const dst = &output[TO_LINEAR ? swizzled_offset : unswizzled_offset];
const u8* const src = &input[TO_LINEAR ? unswizzled_offset : swizzled_offset]; const u8* const src = &input[TO_LINEAR ? unswizzled_offset : swizzled_offset];
std::memcpy(dst, src, bytes_per_pixel);
std::memcpy(dst, src, BYTES_PER_PIXEL);
} }
} }
} }
} }
template <bool TO_LINEAR>
void Swizzle(std::span<u8> output, std::span<const u8> input, u32 bytes_per_pixel, u32 width,
u32 height, u32 depth, u32 block_height, u32 block_depth, u32 stride_alignment) {
switch (bytes_per_pixel) {
case 1:
return SwizzleImpl<TO_LINEAR, 1>(output, input, width, height, depth, block_height,
block_depth, stride_alignment);
case 2:
return SwizzleImpl<TO_LINEAR, 2>(output, input, width, height, depth, block_height,
block_depth, stride_alignment);
case 3:
return SwizzleImpl<TO_LINEAR, 3>(output, input, width, height, depth, block_height,
block_depth, stride_alignment);
case 4:
return SwizzleImpl<TO_LINEAR, 4>(output, input, width, height, depth, block_height,
block_depth, stride_alignment);
case 6:
return SwizzleImpl<TO_LINEAR, 6>(output, input, width, height, depth, block_height,
block_depth, stride_alignment);
case 8:
return SwizzleImpl<TO_LINEAR, 8>(output, input, width, height, depth, block_height,
block_depth, stride_alignment);
case 12:
return SwizzleImpl<TO_LINEAR, 12>(output, input, width, height, depth, block_height,
block_depth, stride_alignment);
case 16:
return SwizzleImpl<TO_LINEAR, 16>(output, input, width, height, depth, block_height,
block_depth, stride_alignment);
default:
UNREACHABLE_MSG("Invalid bytes_per_pixel={}", bytes_per_pixel);
}
}
} // Anonymous namespace } // Anonymous namespace
void UnswizzleTexture(std::span<u8> output, std::span<const u8> input, u32 bytes_per_pixel, void UnswizzleTexture(std::span<u8> output, std::span<const u8> input, u32 bytes_per_pixel,

View file

@ -961,7 +961,8 @@ void Config::ReadUIGamelistValues() {
qt_config->beginGroup(QStringLiteral("UIGameList")); qt_config->beginGroup(QStringLiteral("UIGameList"));
ReadBasicSetting(UISettings::values.show_add_ons); ReadBasicSetting(UISettings::values.show_add_ons);
ReadBasicSetting(UISettings::values.icon_size); ReadBasicSetting(UISettings::values.game_icon_size);
ReadBasicSetting(UISettings::values.folder_icon_size);
ReadBasicSetting(UISettings::values.row_1_text_id); ReadBasicSetting(UISettings::values.row_1_text_id);
ReadBasicSetting(UISettings::values.row_2_text_id); ReadBasicSetting(UISettings::values.row_2_text_id);
ReadBasicSetting(UISettings::values.cache_game_list); ReadBasicSetting(UISettings::values.cache_game_list);
@ -1487,7 +1488,8 @@ void Config::SaveUIGamelistValues() {
qt_config->beginGroup(QStringLiteral("UIGameList")); qt_config->beginGroup(QStringLiteral("UIGameList"));
WriteBasicSetting(UISettings::values.show_add_ons); WriteBasicSetting(UISettings::values.show_add_ons);
WriteBasicSetting(UISettings::values.icon_size); WriteBasicSetting(UISettings::values.game_icon_size);
WriteBasicSetting(UISettings::values.folder_icon_size);
WriteBasicSetting(UISettings::values.row_1_text_id); WriteBasicSetting(UISettings::values.row_1_text_id);
WriteBasicSetting(UISettings::values.row_2_text_id); WriteBasicSetting(UISettings::values.row_2_text_id);
WriteBasicSetting(UISettings::values.cache_game_list); WriteBasicSetting(UISettings::values.cache_game_list);

View file

@ -16,7 +16,7 @@
#include "yuzu/uisettings.h" #include "yuzu/uisettings.h"
namespace { namespace {
constexpr std::array default_icon_sizes{ constexpr std::array default_game_icon_sizes{
std::make_pair(0, QT_TRANSLATE_NOOP("ConfigureUI", "None")), std::make_pair(0, QT_TRANSLATE_NOOP("ConfigureUI", "None")),
std::make_pair(32, QT_TRANSLATE_NOOP("ConfigureUI", "Small (32x32)")), std::make_pair(32, QT_TRANSLATE_NOOP("ConfigureUI", "Small (32x32)")),
std::make_pair(64, QT_TRANSLATE_NOOP("ConfigureUI", "Standard (64x64)")), std::make_pair(64, QT_TRANSLATE_NOOP("ConfigureUI", "Standard (64x64)")),
@ -24,6 +24,13 @@ constexpr std::array default_icon_sizes{
std::make_pair(256, QT_TRANSLATE_NOOP("ConfigureUI", "Full Size (256x256)")), std::make_pair(256, QT_TRANSLATE_NOOP("ConfigureUI", "Full Size (256x256)")),
}; };
constexpr std::array default_folder_icon_sizes{
std::make_pair(0, QT_TRANSLATE_NOOP("ConfigureUI", "None")),
std::make_pair(24, QT_TRANSLATE_NOOP("ConfigureUI", "Small (24x24)")),
std::make_pair(48, QT_TRANSLATE_NOOP("ConfigureUI", "Standard (48x48)")),
std::make_pair(72, QT_TRANSLATE_NOOP("ConfigureUI", "Large (72x72)")),
};
// clang-format off // clang-format off
constexpr std::array row_text_names{ constexpr std::array row_text_names{
QT_TRANSLATE_NOOP("ConfigureUI", "Filename"), QT_TRANSLATE_NOOP("ConfigureUI", "Filename"),
@ -34,8 +41,12 @@ constexpr std::array row_text_names{
}; };
// clang-format on // clang-format on
QString GetTranslatedIconSize(size_t index) { QString GetTranslatedGameIconSize(size_t index) {
return QCoreApplication::translate("ConfigureUI", default_icon_sizes[index].second); return QCoreApplication::translate("ConfigureUI", default_game_icon_sizes[index].second);
}
QString GetTranslatedFolderIconSize(size_t index) {
return QCoreApplication::translate("ConfigureUI", default_folder_icon_sizes[index].second);
} }
QString GetTranslatedRowTextName(size_t index) { QString GetTranslatedRowTextName(size_t index) {
@ -60,8 +71,10 @@ ConfigureUi::ConfigureUi(QWidget* parent) : QWidget(parent), ui(new Ui::Configur
// Force game list reload if any of the relevant settings are changed. // Force game list reload if any of the relevant settings are changed.
connect(ui->show_add_ons, &QCheckBox::stateChanged, this, &ConfigureUi::RequestGameListUpdate); connect(ui->show_add_ons, &QCheckBox::stateChanged, this, &ConfigureUi::RequestGameListUpdate);
connect(ui->icon_size_combobox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, connect(ui->game_icon_size_combobox, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&ConfigureUi::RequestGameListUpdate); &ConfigureUi::RequestGameListUpdate);
connect(ui->folder_icon_size_combobox, QOverload<int>::of(&QComboBox::currentIndexChanged),
this, &ConfigureUi::RequestGameListUpdate);
connect(ui->row_1_text_combobox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, connect(ui->row_1_text_combobox, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&ConfigureUi::RequestGameListUpdate); &ConfigureUi::RequestGameListUpdate);
connect(ui->row_2_text_combobox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, connect(ui->row_2_text_combobox, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
@ -95,7 +108,8 @@ void ConfigureUi::ApplyConfiguration() {
UISettings::values.theme = UISettings::values.theme =
ui->theme_combobox->itemData(ui->theme_combobox->currentIndex()).toString(); ui->theme_combobox->itemData(ui->theme_combobox->currentIndex()).toString();
UISettings::values.show_add_ons = ui->show_add_ons->isChecked(); UISettings::values.show_add_ons = ui->show_add_ons->isChecked();
UISettings::values.icon_size = ui->icon_size_combobox->currentData().toUInt(); UISettings::values.game_icon_size = ui->game_icon_size_combobox->currentData().toUInt();
UISettings::values.folder_icon_size = ui->folder_icon_size_combobox->currentData().toUInt();
UISettings::values.row_1_text_id = ui->row_1_text_combobox->currentData().toUInt(); UISettings::values.row_1_text_id = ui->row_1_text_combobox->currentData().toUInt();
UISettings::values.row_2_text_id = ui->row_2_text_combobox->currentData().toUInt(); UISettings::values.row_2_text_id = ui->row_2_text_combobox->currentData().toUInt();
@ -114,8 +128,10 @@ void ConfigureUi::SetConfiguration() {
ui->language_combobox->setCurrentIndex( ui->language_combobox->setCurrentIndex(
ui->language_combobox->findData(UISettings::values.language)); ui->language_combobox->findData(UISettings::values.language));
ui->show_add_ons->setChecked(UISettings::values.show_add_ons.GetValue()); ui->show_add_ons->setChecked(UISettings::values.show_add_ons.GetValue());
ui->icon_size_combobox->setCurrentIndex( ui->game_icon_size_combobox->setCurrentIndex(
ui->icon_size_combobox->findData(UISettings::values.icon_size.GetValue())); ui->game_icon_size_combobox->findData(UISettings::values.game_icon_size.GetValue()));
ui->folder_icon_size_combobox->setCurrentIndex(
ui->folder_icon_size_combobox->findData(UISettings::values.folder_icon_size.GetValue()));
ui->enable_screenshot_save_as->setChecked( ui->enable_screenshot_save_as->setChecked(
UISettings::values.enable_screenshot_save_as.GetValue()); UISettings::values.enable_screenshot_save_as.GetValue());
@ -134,8 +150,14 @@ void ConfigureUi::changeEvent(QEvent* event) {
void ConfigureUi::RetranslateUI() { void ConfigureUi::RetranslateUI() {
ui->retranslateUi(this); ui->retranslateUi(this);
for (int i = 0; i < ui->icon_size_combobox->count(); i++) { for (int i = 0; i < ui->game_icon_size_combobox->count(); i++) {
ui->icon_size_combobox->setItemText(i, GetTranslatedIconSize(static_cast<size_t>(i))); ui->game_icon_size_combobox->setItemText(i,
GetTranslatedGameIconSize(static_cast<size_t>(i)));
}
for (int i = 0; i < ui->folder_icon_size_combobox->count(); i++) {
ui->folder_icon_size_combobox->setItemText(
i, GetTranslatedFolderIconSize(static_cast<size_t>(i)));
} }
for (int i = 0; i < ui->row_1_text_combobox->count(); i++) { for (int i = 0; i < ui->row_1_text_combobox->count(); i++) {
@ -166,9 +188,13 @@ void ConfigureUi::InitializeLanguageComboBox() {
} }
void ConfigureUi::InitializeIconSizeComboBox() { void ConfigureUi::InitializeIconSizeComboBox() {
for (size_t i = 0; i < default_icon_sizes.size(); i++) { for (size_t i = 0; i < default_game_icon_sizes.size(); i++) {
const auto size = default_icon_sizes[i].first; const auto size = default_game_icon_sizes[i].first;
ui->icon_size_combobox->addItem(GetTranslatedIconSize(i), size); ui->game_icon_size_combobox->addItem(GetTranslatedGameIconSize(i), size);
}
for (size_t i = 0; i < default_folder_icon_sizes.size(); i++) {
const auto size = default_folder_icon_sizes[i].first;
ui->folder_icon_size_combobox->addItem(GetTranslatedFolderIconSize(i), size);
} }
} }

View file

@ -81,16 +81,30 @@
</widget> </widget>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="icon_size_qhbox_layout_2"> <layout class="QHBoxLayout" name="game_icon_size_qhbox_layout_2">
<item> <item>
<widget class="QLabel" name="icon_size_label"> <widget class="QLabel" name="game_icon_size_label">
<property name="text"> <property name="text">
<string>Icon Size:</string> <string>Game Icon Size:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QComboBox" name="icon_size_combobox"/> <widget class="QComboBox" name="game_icon_size_combobox"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="folder_icon_size_qhbox_layout_2">
<item>
<widget class="QLabel" name="folder_icon_size_label">
<property name="text">
<string>Folder Icon Size:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="folder_icon_size_combobox"/>
</item> </item>
</layout> </layout>
</item> </item>

View file

@ -244,8 +244,8 @@ void GameList::OnUpdateThemedIcons() {
for (int i = 0; i < item_model->invisibleRootItem()->rowCount(); i++) { for (int i = 0; i < item_model->invisibleRootItem()->rowCount(); i++) {
QStandardItem* child = item_model->invisibleRootItem()->child(i); QStandardItem* child = item_model->invisibleRootItem()->child(i);
const int icon_size = const int icon_size = UISettings::values.folder_icon_size.GetValue();
std::min(static_cast<int>(UISettings::values.icon_size.GetValue()), 64);
switch (child->data(GameListItem::TypeRole).value<GameListItemType>()) { switch (child->data(GameListItem::TypeRole).value<GameListItemType>()) {
case GameListItemType::SdmcDir: case GameListItemType::SdmcDir:
child->setData( child->setData(

View file

@ -80,7 +80,7 @@ public:
setData(qulonglong(program_id), ProgramIdRole); setData(qulonglong(program_id), ProgramIdRole);
setData(game_type, FileTypeRole); setData(game_type, FileTypeRole);
const u32 size = UISettings::values.icon_size.GetValue(); const u32 size = UISettings::values.game_icon_size.GetValue();
QPixmap picture; QPixmap picture;
if (!picture.loadFromData(picture_data.data(), static_cast<u32>(picture_data.size()))) { if (!picture.loadFromData(picture_data.data(), static_cast<u32>(picture_data.size()))) {
@ -233,8 +233,7 @@ public:
UISettings::GameDir* game_dir = &directory; UISettings::GameDir* game_dir = &directory;
setData(QVariant(UISettings::values.game_dirs.indexOf(directory)), GameDirRole); setData(QVariant(UISettings::values.game_dirs.indexOf(directory)), GameDirRole);
const int icon_size = const int icon_size = UISettings::values.folder_icon_size.GetValue();
std::min(static_cast<int>(UISettings::values.icon_size.GetValue()), 64);
switch (dir_type) { switch (dir_type) {
case GameListItemType::SdmcDir: case GameListItemType::SdmcDir:
setData( setData(
@ -295,8 +294,8 @@ public:
explicit GameListAddDir() { explicit GameListAddDir() {
setData(type(), TypeRole); setData(type(), TypeRole);
const int icon_size = const int icon_size = UISettings::values.folder_icon_size.GetValue();
std::min(static_cast<int>(UISettings::values.icon_size.GetValue()), 64);
setData(QIcon::fromTheme(QStringLiteral("plus")) setData(QIcon::fromTheme(QStringLiteral("plus"))
.pixmap(icon_size) .pixmap(icon_size)
.scaled(icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), .scaled(icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation),
@ -318,8 +317,8 @@ public:
explicit GameListFavorites() { explicit GameListFavorites() {
setData(type(), TypeRole); setData(type(), TypeRole);
const int icon_size = const int icon_size = UISettings::values.folder_icon_size.GetValue();
std::min(static_cast<int>(UISettings::values.icon_size.GetValue()), 64);
setData(QIcon::fromTheme(QStringLiteral("star")) setData(QIcon::fromTheme(QStringLiteral("star"))
.pixmap(icon_size) .pixmap(icon_size)
.scaled(icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), .scaled(icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation),

View file

@ -91,7 +91,8 @@ struct Values {
// Game List // Game List
Settings::BasicSetting<bool> show_add_ons{true, "show_add_ons"}; Settings::BasicSetting<bool> show_add_ons{true, "show_add_ons"};
Settings::BasicSetting<uint32_t> icon_size{64, "icon_size"}; Settings::BasicSetting<uint32_t> game_icon_size{64, "game_icon_size"};
Settings::BasicSetting<uint32_t> folder_icon_size{48, "folder_icon_size"};
Settings::BasicSetting<uint8_t> row_1_text_id{3, "row_1_text_id"}; Settings::BasicSetting<uint8_t> row_1_text_id{3, "row_1_text_id"};
Settings::BasicSetting<uint8_t> row_2_text_id{2, "row_2_text_id"}; Settings::BasicSetting<uint8_t> row_2_text_id{2, "row_2_text_id"};
std::atomic_bool is_game_list_reload_pending{false}; std::atomic_bool is_game_list_reload_pending{false};