early-access version 3725

This commit is contained in:
pineappleEA 2023-06-30 01:36:31 +02:00
parent 2c5e184f44
commit 8657c4c5eb
13 changed files with 112 additions and 103 deletions

View file

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

View file

@ -15,3 +15,6 @@ android.useAndroidX=true
kotlin.code.style=official
kotlin.parallel.tasks.in.project=true
android.defaults.buildfeatures.buildconfig=true
# Android Gradle plugin 8.0.2
android.suppressUnsupportedCompileSdk=34

View file

@ -527,12 +527,10 @@ struct Values {
Setting<bool> mouse_panning{false, "mouse_panning"};
Setting<u8, true> mouse_panning_x_sensitivity{50, 1, 100, "mouse_panning_x_sensitivity"};
Setting<u8, true> mouse_panning_y_sensitivity{50, 1, 100, "mouse_panning_y_sensitivity"};
Setting<u8, true> mouse_panning_deadzone_x_counterweight{
0, 0, 100, "mouse_panning_deadzone_x_counterweight"};
Setting<u8, true> mouse_panning_deadzone_y_counterweight{
0, 0, 100, "mouse_panning_deadzone_y_counterweight"};
Setting<u8, true> mouse_panning_decay_strength{22, 0, 100, "mouse_panning_decay_strength"};
Setting<u8, true> mouse_panning_min_decay{5, 0, 100, "mouse_panning_min_decay"};
Setting<u8, true> mouse_panning_deadzone_counterweight{20, 0, 100,
"mouse_panning_deadzone_counterweight"};
Setting<u8, true> mouse_panning_decay_strength{18, 0, 100, "mouse_panning_decay_strength"};
Setting<u8, true> mouse_panning_min_decay{6, 0, 100, "mouse_panning_min_decay"};
Setting<bool> mouse_enabled{false, "mouse_enabled"};
Setting<bool> emulate_analog_keyboard{false, "emulate_analog_keyboard"};

View file

@ -12,9 +12,13 @@
namespace InputCommon {
constexpr int update_time = 10;
constexpr float default_stick_sensitivity = 0.0044f;
constexpr float default_motion_sensitivity = 0.0003f;
constexpr float default_panning_sensitivity = 0.0010f;
constexpr float default_stick_sensitivity = 0.0006f;
constexpr float default_deadzone_counterweight = 0.01f;
constexpr float default_motion_panning_sensitivity = 2.5f;
constexpr float default_motion_sensitivity = 0.416f;
constexpr float maximum_rotation_speed = 2.0f;
constexpr float maximum_stick_range = 1.5f;
constexpr int mouse_axis_x = 0;
constexpr int mouse_axis_y = 1;
constexpr int wheel_axis_x = 2;
@ -89,26 +93,13 @@ void Mouse::UpdateStickInput() {
// Prevent input from exceeding the max range (1.0f) too much,
// but allow some room to make it easier to sustain
if (length > 1.2f) {
if (length > maximum_stick_range) {
last_mouse_change /= length;
last_mouse_change *= 1.2f;
last_mouse_change *= maximum_stick_range;
}
auto mouse_change = last_mouse_change;
// Bind the mouse change to [0 <= deadzone_counterweight <= 1,1]
if (length < 1.0f) {
const float deadzone_h_counterweight =
Settings::values.mouse_panning_deadzone_x_counterweight.GetValue();
const float deadzone_v_counterweight =
Settings::values.mouse_panning_deadzone_y_counterweight.GetValue();
mouse_change /= length;
mouse_change.x *= length + (1 - length) * deadzone_h_counterweight * 0.01f;
mouse_change.y *= length + (1 - length) * deadzone_v_counterweight * 0.01f;
}
SetAxis(identifier, mouse_axis_x, mouse_change.x);
SetAxis(identifier, mouse_axis_y, -mouse_change.y);
SetAxis(identifier, mouse_axis_x, last_mouse_change.x);
SetAxis(identifier, mouse_axis_y, -last_mouse_change.y);
// Decay input over time
const float clamped_length = std::min(1.0f, length);
@ -120,14 +111,13 @@ void Mouse::UpdateStickInput() {
}
void Mouse::UpdateMotionInput() {
// This may need its own sensitivity instead of using the average
const float sensitivity = (Settings::values.mouse_panning_x_sensitivity.GetValue() +
Settings::values.mouse_panning_y_sensitivity.GetValue()) /
2.0f * default_motion_sensitivity;
const float sensitivity = Settings::values.mouse_panning ? default_motion_panning_sensitivity
: default_motion_sensitivity;
const float rotation_velocity = std::sqrt(last_motion_change.x * last_motion_change.x +
last_motion_change.y * last_motion_change.y);
// Clamp rotation speed
if (rotation_velocity > maximum_rotation_speed / sensitivity) {
const float multiplier = maximum_rotation_speed / rotation_velocity / sensitivity;
last_motion_change.x = last_motion_change.x * multiplier;
@ -158,29 +148,38 @@ void Mouse::Move(int x, int y, int center_x, int center_y) {
const auto mouse_change =
(Common::MakeVec(x, y) - Common::MakeVec(center_x, center_y)).Cast<float>();
const float x_sensitivity =
Settings::values.mouse_panning_x_sensitivity.GetValue() * default_stick_sensitivity;
Settings::values.mouse_panning_x_sensitivity.GetValue() * default_panning_sensitivity;
const float y_sensitivity =
Settings::values.mouse_panning_y_sensitivity.GetValue() * default_stick_sensitivity;
Settings::values.mouse_panning_y_sensitivity.GetValue() * default_panning_sensitivity;
const float deadzone_counterweight =
Settings::values.mouse_panning_deadzone_counterweight.GetValue() *
default_deadzone_counterweight;
last_motion_change += {-mouse_change.y, -mouse_change.x, 0};
last_mouse_change.x += mouse_change.x * x_sensitivity * 0.09f;
last_mouse_change.y += mouse_change.y * y_sensitivity * 0.09f;
last_motion_change += {-mouse_change.y * x_sensitivity, -mouse_change.x * y_sensitivity, 0};
last_mouse_change.x += mouse_change.x * x_sensitivity;
last_mouse_change.y += mouse_change.y * y_sensitivity;
// Bind the mouse change to [0 <= deadzone_counterweight <= 1.0]
if (last_mouse_change.Length() < deadzone_counterweight) {
last_mouse_change /= last_mouse_change.Length();
last_mouse_change *= deadzone_counterweight;
}
return;
}
if (button_pressed) {
const auto mouse_move = Common::MakeVec<int>(x, y) - mouse_origin;
const float x_sensitivity = Settings::values.mouse_panning_x_sensitivity.GetValue();
const float y_sensitivity = Settings::values.mouse_panning_y_sensitivity.GetValue();
SetAxis(identifier, mouse_axis_x,
static_cast<float>(mouse_move.x) * x_sensitivity * 0.0012f);
SetAxis(identifier, mouse_axis_y,
static_cast<float>(-mouse_move.y) * y_sensitivity * 0.0012f);
const float x_sensitivity =
Settings::values.mouse_panning_x_sensitivity.GetValue() * default_stick_sensitivity;
const float y_sensitivity =
Settings::values.mouse_panning_y_sensitivity.GetValue() * default_stick_sensitivity;
SetAxis(identifier, mouse_axis_x, static_cast<float>(mouse_move.x) * x_sensitivity);
SetAxis(identifier, mouse_axis_y, static_cast<float>(-mouse_move.y) * y_sensitivity);
last_motion_change = {
static_cast<float>(-mouse_move.y) / 50.0f,
static_cast<float>(-mouse_move.x) / 50.0f,
static_cast<float>(-mouse_move.y) * x_sensitivity,
static_cast<float>(-mouse_move.x) * y_sensitivity,
last_motion_change.z,
};
}
@ -234,7 +233,7 @@ void Mouse::ReleaseButton(MouseButton button) {
void Mouse::MouseWheelChange(int x, int y) {
wheel_position.x += x;
wheel_position.y += y;
last_motion_change.z += static_cast<f32>(y) / 100.0f;
last_motion_change.z += static_cast<f32>(y);
SetAxis(identifier, wheel_axis_x, static_cast<f32>(wheel_position.x));
SetAxis(identifier, wheel_axis_y, static_cast<f32>(wheel_position.y));
}

View file

@ -36,8 +36,10 @@ using VideoCommon::ImageFlagBits;
using VideoCommon::ImageInfo;
using VideoCommon::ImageType;
using VideoCommon::SubresourceRange;
using VideoCore::Surface::BytesPerBlock;
using VideoCore::Surface::IsPixelFormatASTC;
using VideoCore::Surface::IsPixelFormatInteger;
using VideoCore::Surface::SurfaceType;
namespace {
constexpr VkBorderColor ConvertBorderColor(const std::array<float, 4>& color) {
@ -130,7 +132,7 @@ constexpr VkBorderColor ConvertBorderColor(const std::array<float, 4>& color) {
[[nodiscard]] VkImageCreateInfo MakeImageCreateInfo(const Device& device, const ImageInfo& info) {
const PixelFormat format = StorageFormat(info.format);
const auto format_info = MaxwellToVK::SurfaceFormat(device, FormatType::Optimal, false, format);
VkImageCreateFlags flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT;
VkImageCreateFlags flags{};
if (info.type == ImageType::e2D && info.resources.layers >= 6 &&
info.size.width == info.size.height && !device.HasBrokenCubeImageCompability()) {
flags |= VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT;
@ -163,11 +165,24 @@ constexpr VkBorderColor ConvertBorderColor(const std::array<float, 4>& color) {
}
[[nodiscard]] vk::Image MakeImage(const Device& device, const MemoryAllocator& allocator,
const ImageInfo& info) {
const ImageInfo& info, std::span<const VkFormat> view_formats) {
if (info.type == ImageType::Buffer) {
return vk::Image{};
}
return allocator.CreateImage(MakeImageCreateInfo(device, info));
VkImageCreateInfo image_ci = MakeImageCreateInfo(device, info);
const VkImageFormatListCreateInfo image_format_list = {
.sType = VK_STRUCTURE_TYPE_IMAGE_FORMAT_LIST_CREATE_INFO,
.pNext = nullptr,
.viewFormatCount = static_cast<u32>(view_formats.size()),
.pViewFormats = view_formats.data(),
};
if (view_formats.size() > 1) {
image_ci.flags |= VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT;
if (device.IsKhrImageFormatListSupported()) {
image_ci.pNext = &image_format_list;
}
}
return allocator.CreateImage(image_ci);
}
[[nodiscard]] VkImageAspectFlags ImageAspectMask(PixelFormat format) {
@ -806,6 +821,24 @@ TextureCacheRuntime::TextureCacheRuntime(const Device& device_, Scheduler& sched
astc_decoder_pass.emplace(device, scheduler, descriptor_pool, staging_buffer_pool,
compute_pass_descriptor_queue, memory_allocator);
}
if (!device.IsKhrImageFormatListSupported()) {
return;
}
for (size_t index_a = 0; index_a < VideoCore::Surface::MaxPixelFormat; index_a++) {
const auto image_format = static_cast<PixelFormat>(index_a);
const auto type_a = VideoCore::Surface::GetFormatType(image_format);
if (type_a != SurfaceType::ColorTexture) {
continue;
}
for (size_t index_b = 0; index_b < VideoCore::Surface::MaxPixelFormat; index_b++) {
const auto view_format = static_cast<PixelFormat>(index_b);
if (VideoCore::Surface::IsViewCompatible(image_format, view_format, false, true)) {
const auto view_info =
MaxwellToVK::SurfaceFormat(device, FormatType::Optimal, true, view_format);
view_formats[index_a].push_back(view_info.format);
}
}
}
}
void TextureCacheRuntime::Finish() {
@ -1265,8 +1298,8 @@ void TextureCacheRuntime::TickFrame() {}
Image::Image(TextureCacheRuntime& runtime_, const ImageInfo& info_, GPUVAddr gpu_addr_,
VAddr cpu_addr_)
: VideoCommon::ImageBase(info_, gpu_addr_, cpu_addr_), scheduler{&runtime_.scheduler},
runtime{&runtime_},
original_image(MakeImage(runtime_.device, runtime_.memory_allocator, info)),
runtime{&runtime_}, original_image(MakeImage(runtime_.device, runtime_.memory_allocator, info,
runtime->ViewFormats(info.format))),
aspect_mask(ImageAspectMask(info.format)) {
if (IsPixelFormatASTC(info.format) && !runtime->device.IsOptimalAstcSupported()) {
if (Settings::values.async_astc.GetValue()) {
@ -1471,7 +1504,8 @@ bool Image::ScaleUp(bool ignore) {
auto scaled_info = info;
scaled_info.size.width = scaled_width;
scaled_info.size.height = scaled_height;
scaled_image = MakeImage(runtime->device, runtime->memory_allocator, scaled_info);
scaled_image = MakeImage(runtime->device, runtime->memory_allocator, scaled_info,
runtime->ViewFormats(info.format));
ignore = false;
}
current_image = *scaled_image;

View file

@ -103,6 +103,10 @@ public:
[[nodiscard]] VkBuffer GetTemporaryBuffer(size_t needed_size);
std::span<const VkFormat> ViewFormats(PixelFormat format) {
return view_formats[static_cast<std::size_t>(format)];
}
void BarrierFeedbackLoop();
const Device& device;
@ -113,6 +117,7 @@ public:
RenderPassCache& render_pass_cache;
std::optional<ASTCDecoderPass> astc_decoder_pass;
const Settings::ResolutionScalingInfo& resolution;
std::array<std::vector<VkFormat>, VideoCore::Surface::MaxPixelFormat> view_formats;
static constexpr size_t indexing_slots = 8 * sizeof(size_t);
std::array<vk::Buffer, indexing_slots> buffers{};

View file

@ -870,6 +870,10 @@ ImageId TextureCache<P>::DmaImageId(const Tegra::DMA::ImageOperand& operand, boo
return NULL_IMAGE_ID;
}
auto& image = slot_images[image_id];
if (image.info.type == ImageType::e3D) {
// Don't accelerate 3D images.
return NULL_IMAGE_ID;
}
if (!is_upload && !image.info.dma_downloaded) {
// Force a full sync.
image.info.dma_downloaded = true;

View file

@ -54,7 +54,6 @@ enum class RelaxedOptions : u32 {
Format = 1 << 1,
Samples = 1 << 2,
ForceBrokenViews = 1 << 3,
FormatBpp = 1 << 4,
};
DECLARE_ENUM_FLAG_OPERATORS(RelaxedOptions)

View file

@ -1201,8 +1201,7 @@ std::optional<SubresourceBase> FindSubresource(const ImageInfo& candidate, const
// Format checking is relaxed, but we still have to check for matching bytes per block.
// This avoids creating a view for blits on UE4 titles where formats with different bytes
// per block are aliased.
if (BytesPerBlock(existing.format) != BytesPerBlock(candidate.format) &&
False(options & RelaxedOptions::FormatBpp)) {
if (BytesPerBlock(existing.format) != BytesPerBlock(candidate.format)) {
return std::nullopt;
}
} else {
@ -1233,11 +1232,7 @@ std::optional<SubresourceBase> FindSubresource(const ImageInfo& candidate, const
}
const bool strict_size = False(options & RelaxedOptions::Size);
if (!IsBlockLinearSizeCompatible(existing, candidate, base->level, 0, strict_size)) {
if (False(options & RelaxedOptions::FormatBpp)) {
return std::nullopt;
} else if (!IsBlockLinearSizeCompatibleBPPRelaxed(existing, candidate, base->level, 0)) {
return std::nullopt;
}
return std::nullopt;
}
// TODO: compare block sizes
return base;

View file

@ -77,6 +77,7 @@ VK_DEFINE_HANDLE(VmaAllocator)
EXTENSION(KHR, SPIRV_1_4, spirv_1_4) \
EXTENSION(KHR, SWAPCHAIN, swapchain) \
EXTENSION(KHR, SWAPCHAIN_MUTABLE_FORMAT, swapchain_mutable_format) \
EXTENSION(KHR, IMAGE_FORMAT_LIST, image_format_list) \
EXTENSION(NV, DEVICE_DIAGNOSTICS_CONFIG, device_diagnostics_config) \
EXTENSION(NV, GEOMETRY_SHADER_PASSTHROUGH, geometry_shader_passthrough) \
EXTENSION(NV, VIEWPORT_ARRAY2, viewport_array2) \
@ -408,6 +409,11 @@ public:
return extensions.workgroup_memory_explicit_layout;
}
/// Returns true if the device supports VK_KHR_image_format_list.
bool IsKhrImageFormatListSupported() const {
return extensions.image_format_list || instance_version >= VK_API_VERSION_1_2;
}
/// Returns true if the device supports VK_EXT_primitive_topology_list_restart.
bool IsTopologyListPrimitiveRestartSupported() const {
return features.primitive_topology_list_restart.primitiveTopologyListRestart;

View file

@ -503,8 +503,7 @@ void Config::ReadMousePanningValues() {
ReadBasicSetting(Settings::values.mouse_panning);
ReadBasicSetting(Settings::values.mouse_panning_x_sensitivity);
ReadBasicSetting(Settings::values.mouse_panning_y_sensitivity);
ReadBasicSetting(Settings::values.mouse_panning_deadzone_x_counterweight);
ReadBasicSetting(Settings::values.mouse_panning_deadzone_y_counterweight);
ReadBasicSetting(Settings::values.mouse_panning_deadzone_counterweight);
ReadBasicSetting(Settings::values.mouse_panning_decay_strength);
ReadBasicSetting(Settings::values.mouse_panning_min_decay);
}
@ -1122,8 +1121,7 @@ void Config::SaveMousePanningValues() {
// Don't overwrite values.mouse_panning
WriteBasicSetting(Settings::values.mouse_panning_x_sensitivity);
WriteBasicSetting(Settings::values.mouse_panning_y_sensitivity);
WriteBasicSetting(Settings::values.mouse_panning_deadzone_x_counterweight);
WriteBasicSetting(Settings::values.mouse_panning_deadzone_y_counterweight);
WriteBasicSetting(Settings::values.mouse_panning_deadzone_counterweight);
WriteBasicSetting(Settings::values.mouse_panning_decay_strength);
WriteBasicSetting(Settings::values.mouse_panning_min_decay);
}

View file

@ -27,10 +27,8 @@ void ConfigureMousePanning::SetConfiguration(float right_stick_deadzone, float r
ui->enable->setChecked(Settings::values.mouse_panning.GetValue());
ui->x_sensitivity->setValue(Settings::values.mouse_panning_x_sensitivity.GetValue());
ui->y_sensitivity->setValue(Settings::values.mouse_panning_y_sensitivity.GetValue());
ui->deadzone_x_counterweight->setValue(
Settings::values.mouse_panning_deadzone_x_counterweight.GetValue());
ui->deadzone_y_counterweight->setValue(
Settings::values.mouse_panning_deadzone_y_counterweight.GetValue());
ui->deadzone_counterweight->setValue(
Settings::values.mouse_panning_deadzone_counterweight.GetValue());
ui->decay_strength->setValue(Settings::values.mouse_panning_decay_strength.GetValue());
ui->min_decay->setValue(Settings::values.mouse_panning_min_decay.GetValue());
@ -48,10 +46,8 @@ void ConfigureMousePanning::SetConfiguration(float right_stick_deadzone, float r
void ConfigureMousePanning::SetDefaultConfiguration() {
ui->x_sensitivity->setValue(Settings::values.mouse_panning_x_sensitivity.GetDefault());
ui->y_sensitivity->setValue(Settings::values.mouse_panning_y_sensitivity.GetDefault());
ui->deadzone_x_counterweight->setValue(
Settings::values.mouse_panning_deadzone_x_counterweight.GetDefault());
ui->deadzone_y_counterweight->setValue(
Settings::values.mouse_panning_deadzone_y_counterweight.GetDefault());
ui->deadzone_counterweight->setValue(
Settings::values.mouse_panning_deadzone_counterweight.GetDefault());
ui->decay_strength->setValue(Settings::values.mouse_panning_decay_strength.GetDefault());
ui->min_decay->setValue(Settings::values.mouse_panning_min_decay.GetDefault());
}
@ -68,10 +64,8 @@ void ConfigureMousePanning::ApplyConfiguration() {
Settings::values.mouse_panning = ui->enable->isChecked();
Settings::values.mouse_panning_x_sensitivity = static_cast<float>(ui->x_sensitivity->value());
Settings::values.mouse_panning_y_sensitivity = static_cast<float>(ui->y_sensitivity->value());
Settings::values.mouse_panning_deadzone_x_counterweight =
static_cast<float>(ui->deadzone_x_counterweight->value());
Settings::values.mouse_panning_deadzone_y_counterweight =
static_cast<float>(ui->deadzone_y_counterweight->value());
Settings::values.mouse_panning_deadzone_counterweight =
static_cast<float>(ui->deadzone_counterweight->value());
Settings::values.mouse_panning_decay_strength = static_cast<float>(ui->decay_strength->value());
Settings::values.mouse_panning_min_decay = static_cast<float>(ui->min_decay->value());

View file

@ -89,40 +89,14 @@
</property>
<layout class="QGridLayout">
<item row="0" column="0">
<widget class="QLabel" name="deadzone_x_counterweight_label">
<widget class="QLabel" name="deadzone_counterweight_label">
<property name="text">
<string>Horizontal</string>
<string>Deadzone</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="deadzone_x_counterweight">
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="suffix">
<string>%</string>
</property>
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="deadzone_y_counterweight_label">
<property name="text">
<string>Vertical</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="deadzone_y_counterweight">
<widget class="QSpinBox" name="deadzone_counterweight">
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>