2018-01-13 13:22:39 -08:00
|
|
|
// Copyright 2018 yuzu emulator team
|
2018-01-07 18:27:58 -08:00
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2018-01-11 19:36:56 -08:00
|
|
|
#include <algorithm>
|
2018-02-11 16:03:31 -08:00
|
|
|
#include <array>
|
2018-09-13 13:43:31 -07:00
|
|
|
#include <cstring>
|
2018-03-21 03:09:40 -07:00
|
|
|
#include <memory>
|
2018-10-29 21:03:25 -07:00
|
|
|
#include <optional>
|
2018-07-23 11:52:32 -07:00
|
|
|
#include <type_traits>
|
2018-07-23 11:48:53 -07:00
|
|
|
#include <utility>
|
2018-10-29 21:03:25 -07:00
|
|
|
|
2018-01-07 18:27:58 -08:00
|
|
|
#include "common/alignment.h"
|
2018-09-13 13:43:31 -07:00
|
|
|
#include "common/assert.h"
|
|
|
|
#include "common/common_funcs.h"
|
|
|
|
#include "common/logging/log.h"
|
2018-07-17 17:11:41 -07:00
|
|
|
#include "common/math_util.h"
|
2018-09-13 13:43:31 -07:00
|
|
|
#include "common/swap.h"
|
2018-01-08 16:12:28 -08:00
|
|
|
#include "core/core_timing.h"
|
2018-01-07 18:27:58 -08:00
|
|
|
#include "core/hle/ipc_helpers.h"
|
2018-11-26 15:34:07 -08:00
|
|
|
#include "core/hle/kernel/readable_event.h"
|
2018-12-31 15:09:41 -08:00
|
|
|
#include "core/hle/kernel/thread.h"
|
2018-11-26 15:34:07 -08:00
|
|
|
#include "core/hle/kernel/writable_event.h"
|
2019-06-07 08:34:55 -07:00
|
|
|
#include "core/hle/service/nvdrv/nvdata.h"
|
2018-02-13 19:12:46 -08:00
|
|
|
#include "core/hle/service/nvdrv/nvdrv.h"
|
2018-01-22 08:54:58 -08:00
|
|
|
#include "core/hle/service/nvflinger/buffer_queue.h"
|
2018-09-13 13:43:31 -07:00
|
|
|
#include "core/hle/service/nvflinger/nvflinger.h"
|
2019-02-26 14:20:02 -08:00
|
|
|
#include "core/hle/service/service.h"
|
2018-01-07 18:27:58 -08:00
|
|
|
#include "core/hle/service/vi/vi.h"
|
|
|
|
#include "core/hle/service/vi/vi_m.h"
|
2018-02-02 01:59:50 -08:00
|
|
|
#include "core/hle/service/vi/vi_s.h"
|
|
|
|
#include "core/hle/service/vi/vi_u.h"
|
2018-04-02 20:28:45 -07:00
|
|
|
#include "core/settings.h"
|
2018-01-07 18:27:58 -08:00
|
|
|
|
2018-04-19 18:41:44 -07:00
|
|
|
namespace Service::VI {
|
2018-01-07 18:27:58 -08:00
|
|
|
|
2019-01-04 16:31:14 -08:00
|
|
|
constexpr ResultCode ERR_OPERATION_FAILED{ErrorModule::VI, 1};
|
2019-02-26 14:49:32 -08:00
|
|
|
constexpr ResultCode ERR_PERMISSION_DENIED{ErrorModule::VI, 5};
|
2019-01-04 16:31:14 -08:00
|
|
|
constexpr ResultCode ERR_UNSUPPORTED{ErrorModule::VI, 6};
|
2019-02-05 13:20:04 -08:00
|
|
|
constexpr ResultCode ERR_NOT_FOUND{ErrorModule::VI, 7};
|
2019-01-04 16:31:14 -08:00
|
|
|
|
2018-02-07 04:11:17 -08:00
|
|
|
struct DisplayInfo {
|
2019-01-02 12:26:41 -08:00
|
|
|
/// The name of this particular display.
|
2018-02-07 04:11:17 -08:00
|
|
|
char display_name[0x40]{"Default"};
|
2019-01-02 12:26:41 -08:00
|
|
|
|
|
|
|
/// Whether or not the display has a limited number of layers.
|
|
|
|
u8 has_limited_layers{1};
|
2019-11-03 15:54:03 -08:00
|
|
|
INSERT_PADDING_BYTES(7);
|
2019-01-02 12:26:41 -08:00
|
|
|
|
|
|
|
/// Indicates the total amount of layers supported by the display.
|
|
|
|
/// @note This is only valid if has_limited_layers is set.
|
|
|
|
u64 max_layers{1};
|
|
|
|
|
|
|
|
/// Maximum width in pixels.
|
2019-01-02 13:14:40 -08:00
|
|
|
u64 width{1920};
|
2019-01-02 12:26:41 -08:00
|
|
|
|
|
|
|
/// Maximum height in pixels.
|
2019-01-02 13:14:40 -08:00
|
|
|
u64 height{1080};
|
2018-02-07 04:11:17 -08:00
|
|
|
};
|
|
|
|
static_assert(sizeof(DisplayInfo) == 0x60, "DisplayInfo has wrong size");
|
|
|
|
|
2018-01-07 18:27:58 -08:00
|
|
|
class Parcel {
|
|
|
|
public:
|
|
|
|
// This default size was chosen arbitrarily.
|
2018-09-15 06:21:06 -07:00
|
|
|
static constexpr std::size_t DefaultBufferSize = 0x40;
|
2018-01-07 18:27:58 -08:00
|
|
|
Parcel() : buffer(DefaultBufferSize) {}
|
2018-01-17 17:21:14 -08:00
|
|
|
explicit Parcel(std::vector<u8> data) : buffer(std::move(data)) {}
|
2018-01-07 18:27:58 -08:00
|
|
|
virtual ~Parcel() = default;
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
T Read() {
|
2018-07-23 11:52:32 -07:00
|
|
|
static_assert(std::is_trivially_copyable_v<T>, "T must be trivially copyable.");
|
2018-02-17 10:54:59 -08:00
|
|
|
ASSERT(read_index + sizeof(T) <= buffer.size());
|
2018-07-23 11:52:32 -07:00
|
|
|
|
2018-01-07 18:27:58 -08:00
|
|
|
T val;
|
|
|
|
std::memcpy(&val, buffer.data() + read_index, sizeof(T));
|
|
|
|
read_index += sizeof(T);
|
|
|
|
read_index = Common::AlignUp(read_index, 4);
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
T ReadUnaligned() {
|
2018-07-23 11:52:32 -07:00
|
|
|
static_assert(std::is_trivially_copyable_v<T>, "T must be trivially copyable.");
|
2018-02-17 10:54:59 -08:00
|
|
|
ASSERT(read_index + sizeof(T) <= buffer.size());
|
2018-07-23 11:52:32 -07:00
|
|
|
|
2018-01-07 18:27:58 -08:00
|
|
|
T val;
|
|
|
|
std::memcpy(&val, buffer.data() + read_index, sizeof(T));
|
|
|
|
read_index += sizeof(T);
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
2018-09-15 06:21:06 -07:00
|
|
|
std::vector<u8> ReadBlock(std::size_t length) {
|
2018-02-17 10:54:59 -08:00
|
|
|
ASSERT(read_index + length <= buffer.size());
|
2018-01-17 17:08:02 -08:00
|
|
|
const u8* const begin = buffer.data() + read_index;
|
|
|
|
const u8* const end = begin + length;
|
|
|
|
std::vector<u8> data(begin, end);
|
2018-01-07 18:27:58 -08:00
|
|
|
read_index += length;
|
|
|
|
read_index = Common::AlignUp(read_index, 4);
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::u16string ReadInterfaceToken() {
|
2020-04-15 12:59:23 -07:00
|
|
|
[[maybe_unused]] const u32 unknown = Read<u32_le>();
|
|
|
|
const u32 length = Read<u32_le>();
|
2018-01-07 18:27:58 -08:00
|
|
|
|
|
|
|
std::u16string token{};
|
|
|
|
|
|
|
|
for (u32 ch = 0; ch < length + 1; ++ch) {
|
|
|
|
token.push_back(ReadUnaligned<u16_le>());
|
|
|
|
}
|
|
|
|
|
|
|
|
read_index = Common::AlignUp(read_index, 4);
|
|
|
|
|
|
|
|
return token;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
void Write(const T& val) {
|
2018-07-23 11:52:32 -07:00
|
|
|
static_assert(std::is_trivially_copyable_v<T>, "T must be trivially copyable.");
|
|
|
|
|
|
|
|
if (buffer.size() < write_index + sizeof(T)) {
|
2018-01-07 18:27:58 -08:00
|
|
|
buffer.resize(buffer.size() + sizeof(T) + DefaultBufferSize);
|
2018-07-23 11:52:32 -07:00
|
|
|
}
|
|
|
|
|
2018-01-07 18:27:58 -08:00
|
|
|
std::memcpy(buffer.data() + write_index, &val, sizeof(T));
|
|
|
|
write_index += sizeof(T);
|
|
|
|
write_index = Common::AlignUp(write_index, 4);
|
|
|
|
}
|
|
|
|
|
2018-02-13 19:12:46 -08:00
|
|
|
template <typename T>
|
|
|
|
void WriteObject(const T& val) {
|
2018-07-23 11:52:32 -07:00
|
|
|
static_assert(std::is_trivially_copyable_v<T>, "T must be trivially copyable.");
|
|
|
|
|
|
|
|
const u32_le size = static_cast<u32>(sizeof(val));
|
2018-02-13 19:12:46 -08:00
|
|
|
Write(size);
|
|
|
|
// TODO(Subv): Support file descriptors.
|
|
|
|
Write<u32_le>(0); // Fd count.
|
|
|
|
Write(val);
|
|
|
|
}
|
|
|
|
|
2018-01-07 18:27:58 -08:00
|
|
|
void Deserialize() {
|
2018-02-17 10:54:59 -08:00
|
|
|
ASSERT(buffer.size() > sizeof(Header));
|
|
|
|
|
2018-01-07 18:27:58 -08:00
|
|
|
Header header{};
|
|
|
|
std::memcpy(&header, buffer.data(), sizeof(Header));
|
|
|
|
|
|
|
|
read_index = header.data_offset;
|
|
|
|
DeserializeData();
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<u8> Serialize() {
|
|
|
|
ASSERT(read_index == 0);
|
|
|
|
write_index = sizeof(Header);
|
|
|
|
|
|
|
|
SerializeData();
|
|
|
|
|
|
|
|
Header header{};
|
2018-01-19 15:01:41 -08:00
|
|
|
header.data_size = static_cast<u32_le>(write_index - sizeof(Header));
|
2018-02-11 14:28:07 -08:00
|
|
|
header.data_offset = sizeof(Header);
|
|
|
|
header.objects_size = 4;
|
2020-10-13 05:10:50 -07:00
|
|
|
header.objects_offset = static_cast<u32>(sizeof(Header) + header.data_size);
|
2018-01-07 18:27:58 -08:00
|
|
|
std::memcpy(buffer.data(), &header, sizeof(Header));
|
|
|
|
|
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2018-01-17 17:16:48 -08:00
|
|
|
virtual void SerializeData() {}
|
2018-01-07 18:27:58 -08:00
|
|
|
|
2018-01-17 17:16:48 -08:00
|
|
|
virtual void DeserializeData() {}
|
2018-01-07 18:27:58 -08:00
|
|
|
|
|
|
|
private:
|
|
|
|
struct Header {
|
|
|
|
u32_le data_size;
|
|
|
|
u32_le data_offset;
|
|
|
|
u32_le objects_size;
|
|
|
|
u32_le objects_offset;
|
|
|
|
};
|
|
|
|
static_assert(sizeof(Header) == 16, "ParcelHeader has wrong size");
|
|
|
|
|
|
|
|
std::vector<u8> buffer;
|
2018-09-15 06:21:06 -07:00
|
|
|
std::size_t read_index = 0;
|
|
|
|
std::size_t write_index = 0;
|
2018-01-07 18:27:58 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
class NativeWindow : public Parcel {
|
|
|
|
public:
|
2018-04-19 18:34:36 -07:00
|
|
|
explicit NativeWindow(u32 id) {
|
2018-01-07 18:27:58 -08:00
|
|
|
data.id = id;
|
|
|
|
}
|
|
|
|
~NativeWindow() override = default;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void SerializeData() override {
|
|
|
|
Write(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
struct Data {
|
|
|
|
u32_le magic = 2;
|
2018-02-11 14:28:07 -08:00
|
|
|
u32_le process_id = 1;
|
2018-01-07 18:27:58 -08:00
|
|
|
u32_le id;
|
2018-02-11 14:28:07 -08:00
|
|
|
INSERT_PADDING_WORDS(3);
|
2018-01-18 18:21:26 -08:00
|
|
|
std::array<u8, 8> dispdrv = {'d', 'i', 's', 'p', 'd', 'r', 'v', '\0'};
|
2018-02-11 14:28:07 -08:00
|
|
|
INSERT_PADDING_WORDS(2);
|
2018-01-07 18:27:58 -08:00
|
|
|
};
|
|
|
|
static_assert(sizeof(Data) == 0x28, "ParcelData has wrong size");
|
|
|
|
|
|
|
|
Data data{};
|
|
|
|
};
|
|
|
|
|
|
|
|
class IGBPConnectRequestParcel : public Parcel {
|
|
|
|
public:
|
2018-07-23 11:48:53 -07:00
|
|
|
explicit IGBPConnectRequestParcel(std::vector<u8> buffer) : Parcel(std::move(buffer)) {
|
2018-01-07 18:27:58 -08:00
|
|
|
Deserialize();
|
|
|
|
}
|
|
|
|
|
2018-01-17 17:16:48 -08:00
|
|
|
void DeserializeData() override {
|
2020-10-12 17:35:34 -07:00
|
|
|
[[maybe_unused]] const std::u16string token = ReadInterfaceToken();
|
2018-01-07 18:27:58 -08:00
|
|
|
data = Read<Data>();
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Data {
|
|
|
|
u32_le unk;
|
|
|
|
u32_le api;
|
|
|
|
u32_le producer_controlled_by_app;
|
|
|
|
};
|
|
|
|
|
|
|
|
Data data;
|
|
|
|
};
|
|
|
|
|
|
|
|
class IGBPConnectResponseParcel : public Parcel {
|
|
|
|
public:
|
2018-04-19 18:34:36 -07:00
|
|
|
explicit IGBPConnectResponseParcel(u32 width, u32 height) {
|
2018-01-07 18:27:58 -08:00
|
|
|
data.width = width;
|
|
|
|
data.height = height;
|
|
|
|
}
|
|
|
|
~IGBPConnectResponseParcel() override = default;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void SerializeData() override {
|
|
|
|
Write(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
struct Data {
|
|
|
|
u32_le width;
|
|
|
|
u32_le height;
|
|
|
|
u32_le transform_hint;
|
|
|
|
u32_le num_pending_buffers;
|
|
|
|
u32_le status;
|
|
|
|
};
|
|
|
|
static_assert(sizeof(Data) == 20, "ParcelData has wrong size");
|
|
|
|
|
|
|
|
Data data{};
|
|
|
|
};
|
|
|
|
|
2018-11-17 14:10:10 -08:00
|
|
|
/// Represents a parcel containing one int '0' as its data
|
|
|
|
/// Used by DetachBuffer and Disconnect
|
|
|
|
class IGBPEmptyResponseParcel : public Parcel {
|
|
|
|
protected:
|
|
|
|
void SerializeData() override {
|
|
|
|
Write(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
struct Data {
|
2020-04-24 00:16:39 -07:00
|
|
|
u32_le unk_0{};
|
2018-11-17 14:10:10 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
Data data{};
|
|
|
|
};
|
|
|
|
|
2018-01-07 18:27:58 -08:00
|
|
|
class IGBPSetPreallocatedBufferRequestParcel : public Parcel {
|
|
|
|
public:
|
2018-07-23 11:48:53 -07:00
|
|
|
explicit IGBPSetPreallocatedBufferRequestParcel(std::vector<u8> buffer)
|
|
|
|
: Parcel(std::move(buffer)) {
|
2018-01-07 18:27:58 -08:00
|
|
|
Deserialize();
|
|
|
|
}
|
|
|
|
|
2018-01-17 17:16:48 -08:00
|
|
|
void DeserializeData() override {
|
2020-10-12 17:35:34 -07:00
|
|
|
[[maybe_unused]] const std::u16string token = ReadInterfaceToken();
|
2018-01-07 18:27:58 -08:00
|
|
|
data = Read<Data>();
|
2020-12-17 11:22:46 -08:00
|
|
|
if (data.contains_object != 0) {
|
|
|
|
buffer_container = Read<BufferContainer>();
|
|
|
|
}
|
2018-01-07 18:27:58 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
struct Data {
|
|
|
|
u32_le slot;
|
2020-12-17 11:22:46 -08:00
|
|
|
u32_le contains_object;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct BufferContainer {
|
2018-01-07 18:27:58 -08:00
|
|
|
u32_le graphic_buffer_length;
|
|
|
|
INSERT_PADDING_WORDS(1);
|
2020-12-17 11:22:46 -08:00
|
|
|
NVFlinger::IGBPBuffer buffer{};
|
2018-01-07 18:27:58 -08:00
|
|
|
};
|
|
|
|
|
2020-12-17 11:22:46 -08:00
|
|
|
Data data{};
|
|
|
|
BufferContainer buffer_container{};
|
2018-01-07 18:27:58 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
class IGBPSetPreallocatedBufferResponseParcel : public Parcel {
|
|
|
|
protected:
|
|
|
|
void SerializeData() override {
|
|
|
|
// TODO(Subv): Find out what this means
|
|
|
|
Write<u32>(0);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-10-12 17:35:34 -07:00
|
|
|
class IGBPCancelBufferRequestParcel : public Parcel {
|
|
|
|
public:
|
|
|
|
explicit IGBPCancelBufferRequestParcel(std::vector<u8> buffer) : Parcel(std::move(buffer)) {
|
|
|
|
Deserialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DeserializeData() override {
|
|
|
|
[[maybe_unused]] const std::u16string token = ReadInterfaceToken();
|
|
|
|
data = Read<Data>();
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Data {
|
|
|
|
u32_le slot;
|
|
|
|
Service::Nvidia::MultiFence multi_fence;
|
|
|
|
};
|
|
|
|
|
|
|
|
Data data;
|
|
|
|
};
|
|
|
|
|
|
|
|
class IGBPCancelBufferResponseParcel : public Parcel {
|
|
|
|
protected:
|
|
|
|
void SerializeData() override {
|
|
|
|
Write<u32>(0); // Success
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-01-07 18:27:58 -08:00
|
|
|
class IGBPDequeueBufferRequestParcel : public Parcel {
|
|
|
|
public:
|
2018-07-23 11:48:53 -07:00
|
|
|
explicit IGBPDequeueBufferRequestParcel(std::vector<u8> buffer) : Parcel(std::move(buffer)) {
|
2018-01-07 18:27:58 -08:00
|
|
|
Deserialize();
|
|
|
|
}
|
|
|
|
|
2018-01-17 17:16:48 -08:00
|
|
|
void DeserializeData() override {
|
2020-10-12 17:35:34 -07:00
|
|
|
[[maybe_unused]] const std::u16string token = ReadInterfaceToken();
|
2018-01-07 18:27:58 -08:00
|
|
|
data = Read<Data>();
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Data {
|
|
|
|
u32_le pixel_format;
|
|
|
|
u32_le width;
|
|
|
|
u32_le height;
|
|
|
|
u32_le get_frame_timestamps;
|
|
|
|
u32_le usage;
|
|
|
|
};
|
|
|
|
|
|
|
|
Data data;
|
|
|
|
};
|
|
|
|
|
|
|
|
class IGBPDequeueBufferResponseParcel : public Parcel {
|
|
|
|
public:
|
2019-06-07 08:34:55 -07:00
|
|
|
explicit IGBPDequeueBufferResponseParcel(u32 slot, Service::Nvidia::MultiFence& multi_fence)
|
|
|
|
: slot(slot), multi_fence(multi_fence) {}
|
2018-01-07 18:27:58 -08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void SerializeData() override {
|
2018-02-13 19:12:46 -08:00
|
|
|
Write(slot);
|
2018-02-13 19:51:24 -08:00
|
|
|
Write<u32_le>(1);
|
2019-06-07 08:34:55 -07:00
|
|
|
WriteObject(multi_fence);
|
2018-02-13 19:12:46 -08:00
|
|
|
Write<u32_le>(0);
|
2018-01-07 18:27:58 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
u32_le slot;
|
2019-06-07 08:34:55 -07:00
|
|
|
Service::Nvidia::MultiFence multi_fence;
|
2018-01-07 18:27:58 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
class IGBPRequestBufferRequestParcel : public Parcel {
|
|
|
|
public:
|
2018-07-23 11:48:53 -07:00
|
|
|
explicit IGBPRequestBufferRequestParcel(std::vector<u8> buffer) : Parcel(std::move(buffer)) {
|
2018-01-07 18:27:58 -08:00
|
|
|
Deserialize();
|
|
|
|
}
|
|
|
|
|
2018-01-17 17:16:48 -08:00
|
|
|
void DeserializeData() override {
|
2020-10-12 17:35:34 -07:00
|
|
|
[[maybe_unused]] const std::u16string token = ReadInterfaceToken();
|
2018-01-07 18:27:58 -08:00
|
|
|
slot = Read<u32_le>();
|
|
|
|
}
|
|
|
|
|
|
|
|
u32_le slot;
|
|
|
|
};
|
|
|
|
|
|
|
|
class IGBPRequestBufferResponseParcel : public Parcel {
|
|
|
|
public:
|
2018-07-23 11:48:53 -07:00
|
|
|
explicit IGBPRequestBufferResponseParcel(NVFlinger::IGBPBuffer buffer) : buffer(buffer) {}
|
2018-01-07 18:27:58 -08:00
|
|
|
~IGBPRequestBufferResponseParcel() override = default;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void SerializeData() override {
|
2018-07-17 17:11:41 -07:00
|
|
|
// TODO(Subv): Figure out what this value means, writing non-zero here will make libnx
|
|
|
|
// try to read an IGBPBuffer object from the parcel.
|
2018-02-17 10:59:45 -08:00
|
|
|
Write<u32_le>(1);
|
|
|
|
WriteObject(buffer);
|
2018-01-07 18:27:58 -08:00
|
|
|
Write<u32_le>(0);
|
|
|
|
}
|
|
|
|
|
2018-01-22 08:54:58 -08:00
|
|
|
NVFlinger::IGBPBuffer buffer;
|
2018-01-07 18:27:58 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
class IGBPQueueBufferRequestParcel : public Parcel {
|
|
|
|
public:
|
2018-07-23 11:48:53 -07:00
|
|
|
explicit IGBPQueueBufferRequestParcel(std::vector<u8> buffer) : Parcel(std::move(buffer)) {
|
2018-01-07 18:27:58 -08:00
|
|
|
Deserialize();
|
|
|
|
}
|
|
|
|
|
2018-01-17 17:16:48 -08:00
|
|
|
void DeserializeData() override {
|
2020-10-12 17:35:34 -07:00
|
|
|
[[maybe_unused]] const std::u16string token = ReadInterfaceToken();
|
2018-01-07 18:27:58 -08:00
|
|
|
data = Read<Data>();
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Data {
|
|
|
|
u32_le slot;
|
2018-02-11 16:03:31 -08:00
|
|
|
INSERT_PADDING_WORDS(3);
|
2018-01-07 18:27:58 -08:00
|
|
|
u32_le timestamp;
|
2018-02-11 16:03:31 -08:00
|
|
|
s32_le is_auto_timestamp;
|
|
|
|
s32_le crop_top;
|
2018-07-17 17:11:41 -07:00
|
|
|
s32_le crop_left;
|
2018-02-11 16:03:31 -08:00
|
|
|
s32_le crop_right;
|
|
|
|
s32_le crop_bottom;
|
|
|
|
s32_le scaling_mode;
|
|
|
|
NVFlinger::BufferQueue::BufferTransformFlags transform;
|
|
|
|
u32_le sticky_transform;
|
2019-06-04 13:10:07 -07:00
|
|
|
INSERT_PADDING_WORDS(1);
|
|
|
|
u32_le swap_interval;
|
2019-06-07 08:34:55 -07:00
|
|
|
Service::Nvidia::MultiFence multi_fence;
|
2018-07-17 17:11:41 -07:00
|
|
|
|
2019-02-26 19:47:49 -08:00
|
|
|
Common::Rectangle<int> GetCropRect() const {
|
2018-07-17 17:11:41 -07:00
|
|
|
return {crop_left, crop_top, crop_right, crop_bottom};
|
|
|
|
}
|
2018-01-07 18:27:58 -08:00
|
|
|
};
|
2019-06-07 08:34:55 -07:00
|
|
|
static_assert(sizeof(Data) == 96, "ParcelData has wrong size");
|
2018-01-07 18:27:58 -08:00
|
|
|
|
|
|
|
Data data;
|
|
|
|
};
|
|
|
|
|
|
|
|
class IGBPQueueBufferResponseParcel : public Parcel {
|
|
|
|
public:
|
2018-04-19 18:34:36 -07:00
|
|
|
explicit IGBPQueueBufferResponseParcel(u32 width, u32 height) {
|
2018-01-07 18:27:58 -08:00
|
|
|
data.width = width;
|
|
|
|
data.height = height;
|
|
|
|
}
|
|
|
|
~IGBPQueueBufferResponseParcel() override = default;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void SerializeData() override {
|
|
|
|
Write(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
struct Data {
|
|
|
|
u32_le width;
|
|
|
|
u32_le height;
|
|
|
|
u32_le transform_hint;
|
|
|
|
u32_le num_pending_buffers;
|
|
|
|
u32_le status;
|
|
|
|
};
|
|
|
|
static_assert(sizeof(Data) == 20, "ParcelData has wrong size");
|
|
|
|
|
|
|
|
Data data{};
|
|
|
|
};
|
|
|
|
|
2018-01-21 08:13:47 -08:00
|
|
|
class IGBPQueryRequestParcel : public Parcel {
|
|
|
|
public:
|
2018-07-23 11:48:53 -07:00
|
|
|
explicit IGBPQueryRequestParcel(std::vector<u8> buffer) : Parcel(std::move(buffer)) {
|
2018-01-21 08:13:47 -08:00
|
|
|
Deserialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DeserializeData() override {
|
2020-10-12 17:35:34 -07:00
|
|
|
[[maybe_unused]] const std::u16string token = ReadInterfaceToken();
|
2018-01-21 08:13:47 -08:00
|
|
|
type = Read<u32_le>();
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 type;
|
|
|
|
};
|
|
|
|
|
|
|
|
class IGBPQueryResponseParcel : public Parcel {
|
|
|
|
public:
|
2018-04-19 18:34:36 -07:00
|
|
|
explicit IGBPQueryResponseParcel(u32 value) : value(value) {}
|
2018-01-21 08:13:47 -08:00
|
|
|
~IGBPQueryResponseParcel() override = default;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void SerializeData() override {
|
|
|
|
Write(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
u32_le value;
|
|
|
|
};
|
|
|
|
|
2018-01-07 18:27:58 -08:00
|
|
|
class IHOSBinderDriver final : public ServiceFramework<IHOSBinderDriver> {
|
|
|
|
public:
|
2020-11-26 12:19:08 -08:00
|
|
|
explicit IHOSBinderDriver(Core::System& system_, NVFlinger::NVFlinger& nv_flinger_)
|
|
|
|
: ServiceFramework{system_, "IHOSBinderDriver"}, nv_flinger(nv_flinger_) {
|
2018-01-07 18:27:58 -08:00
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{0, &IHOSBinderDriver::TransactParcel, "TransactParcel"},
|
|
|
|
{1, &IHOSBinderDriver::AdjustRefcount, "AdjustRefcount"},
|
2018-01-15 14:20:08 -08:00
|
|
|
{2, &IHOSBinderDriver::GetNativeHandle, "GetNativeHandle"},
|
2018-02-13 18:39:58 -08:00
|
|
|
{3, &IHOSBinderDriver::TransactParcel, "TransactParcelAuto"},
|
2018-01-07 18:27:58 -08:00
|
|
|
};
|
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
enum class TransactionId {
|
|
|
|
RequestBuffer = 1,
|
|
|
|
SetBufferCount = 2,
|
|
|
|
DequeueBuffer = 3,
|
|
|
|
DetachBuffer = 4,
|
|
|
|
DetachNextBuffer = 5,
|
|
|
|
AttachBuffer = 6,
|
|
|
|
QueueBuffer = 7,
|
|
|
|
CancelBuffer = 8,
|
|
|
|
Query = 9,
|
|
|
|
Connect = 10,
|
|
|
|
Disconnect = 11,
|
|
|
|
|
|
|
|
AllocateBuffers = 13,
|
|
|
|
SetPreallocatedBuffer = 14
|
|
|
|
};
|
|
|
|
|
2018-02-13 18:54:12 -08:00
|
|
|
void TransactParcel(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp{ctx};
|
2019-01-02 16:42:08 -08:00
|
|
|
const u32 id = rp.Pop<u32>();
|
|
|
|
const auto transaction = static_cast<TransactionId>(rp.Pop<u32>());
|
|
|
|
const u32 flags = rp.Pop<u32>();
|
|
|
|
|
|
|
|
LOG_DEBUG(Service_VI, "called. id=0x{:08X} transaction={:X}, flags=0x{:08X}", id,
|
2020-12-07 19:00:34 -08:00
|
|
|
transaction, flags);
|
2018-02-13 18:54:12 -08:00
|
|
|
|
2020-04-04 19:29:56 -07:00
|
|
|
switch (transaction) {
|
|
|
|
case TransactionId::Connect: {
|
2018-02-13 18:54:12 -08:00
|
|
|
IGBPConnectRequestParcel request{ctx.ReadBuffer()};
|
2018-11-15 23:07:42 -08:00
|
|
|
IGBPConnectResponseParcel response{
|
2018-11-18 20:20:47 -08:00
|
|
|
static_cast<u32>(static_cast<u32>(DisplayResolution::UndockedWidth) *
|
configuration: implement per-game configurations (#4098)
* Switch game settings to use a pointer
In order to add full per-game settings, we need to be able to tell yuzu to switch
to using either the global or game configuration. Using a pointer makes it easier
to switch.
* configuration: add new UI without changing existing funcitonality
The new UI also adds General, System, Graphics, Advanced Graphics,
and Audio tabs, but as yet they do nothing. This commit keeps yuzu
to the same functionality as originally branched.
* configuration: Rename files
These weren't included in the last commit. Now they are.
* configuration: setup global configuration checkbox
Global config checkbox now enables/disables the appropriate tabs in the game
properties dialog. The use global configuration setting is now saved to the
config, defaulting to true. This also addresses some changes requested in the PR.
* configuration: swap to per-game config memory for properties dialog
Does not set memory going in-game. Swaps to game values when opening the
properties dialog, then swaps back when closing it. Uses a `memcpy` to swap.
Also implements saving config files, limited to certain groups of configurations
so as to not risk setting unsafe configurations.
* configuration: change config interfaces to use config-specific pointers
When a game is booted, we need to be able to open the configuration dialogs
without changing the settings pointer in the game's emualtion. A new pointer
specific to just the configuration dialogs can be used to separate changes
to just those config dialogs without affecting the emulation.
* configuration: boot a game using per-game settings
Swaps values where needed to boot a game.
* configuration: user correct config during emulation
Creates a new pointer specifically for modifying the configuration while
emulation is in progress. Both the regular configuration dialog and the game
properties dialog now use the pointer Settings::config_values to focus edits to
the correct struct.
* settings: split Settings::values into two different structs
By splitting the settings into two mutually exclusive structs, it becomes easier,
as a developer, to determine how to use the Settings structs after per-game
configurations is merged. Other benefits include only duplicating the required
settings in memory.
* settings: move use_docked_mode to Controls group
`use_docked_mode` is set in the input settings and cannot be accessed from the
system settings. Grouping it with system settings causes it to be saved with
per-game settings, which may make transferring configs more difficult later on,
especially since docked mode cannot be set from within the game properties
dialog.
* configuration: Fix the other yuzu executables and a regression
In main.cpp, we have to get the title ID before the ROM is loaded, else the
renderer will reflect only the global settings and now the user's game specific
settings.
* settings: use a template to duplicate memory for each setting
Replaces the type of each variable in the Settings::Values struct with a new
class that allows basic data reading and writing. The new struct
Settings::Setting duplicates the data in memory and can manage global overrides
per each setting.
* configuration: correct add-ons config and swap settings when apropriate
Any add-ons interaction happens directly through the global values struct.
Swapping bewteen structs now also includes copying the necessary global configs
that cannot be changed nor saved in per-game settings. General and System config
menus now update based on whether it is viewing the global or per-game settings.
* settings: restore old values struct
No longer needed with the Settings::Setting class template.
* configuration: implement hierarchical game properties dialog
This sets the apropriate global or local data in each setting.
* clang format
* clang format take 2
can the docker container save this?
* address comments and style issues
* config: read and write settings with global awareness
Adds new functions to read and write settings while keeping the global state in
focus. Files now generated per-game are much smaller since often they only need
address the global state.
* settings: restore global state when necessary
Upon closing a game or the game properties dialog, we need to restore all global
settings to the original global state so that we can properly open the
configuration dialog or boot a different game.
* configuration: guard setting values incorrectly
This disables setting values while a game is running if the setting is
overwritten by a per game setting.
* config: don't write local settings in the global config
Simple guards to prevent writing the wrong settings in the wrong files.
* configuration: add comments, assume less, and clang format
No longer assumes that a disabled UI element means the global state is turned
off, instead opting to directly answer that question. Still however assumes a
game is running if it is in that state.
* configuration: fix a logic error
Should not be negated
* restore settings' global state regardless of accept/cancel
Fixes loading a properties dialog and causing the global config dialog to show
local settings.
* fix more logic errors
Fixed the frame limit would set the global setting from the game properties
dialog. Also strengthened the Settings::Setting member variables and simplified
the logic in config reading (ReadSettingGlobal).
* fix another logic error
In my efforts to guard RestoreGlobalState, I accidentally negated the IsPowered
condition.
* configure_audio: set toggle_stretched_audio to tristate
* fixed custom rtc and rng seed overwriting the global value
* clang format
* rebased
* clang format take 4
* address my own review
Basically revert unintended changes
* settings: literal instead of casting
"No need to cast, use 1U instead"
Thanks, Morph!
Co-authored-by: Morph <39850852+Morph1984@users.noreply.github.com>
* Revert "settings: literal instead of casting
"
This reverts commit 95e992a87c898f3e882ffdb415bb0ef9f80f613f.
* main: fix status buttons reporting wrong settings after stop emulation
* settings: Log UseDockedMode in the Controls group
This should have happened when use_docked_mode was moved over to the controls group
internally. This just reflects this in the log.
* main: load settings if the file has a title id
In other words, don't exit if the loader has trouble getting a title id.
* use a zero
* settings: initalize resolution factor with constructor instead of casting
* Revert "settings: initalize resolution factor with constructor instead of casting"
This reverts commit 54c35ecb46a29953842614620f9b7de1aa9d5dc8.
* configure_graphics: guard device selector when Vulkan is global
Prevents the user from editing the device selector if Vulkan is the global
renderer backend. Also resets the vulkan_device variable when the users
switches back-and-forth between global and Vulkan.
* address reviewer concerns
Changes function variables to const wherever they don't need to be changed. Sets Settings::Setting to final as it should not be inherited from. Sets ConfigurationShared::use_global_text to static.
Co-Authored-By: VolcaEM <volcaem@users.noreply.github.com>
* main: load per-game settings after LoadROM
This prevents `Restart Emulation` from restoring the global settings *after* the per-game settings were applied. Thanks to BSoDGamingYT for finding this bug.
* Revert "main: load per-game settings after LoadROM"
This reverts commit 9d0d48c52d2dcf3bfb1806cc8fa7d5a271a8a804.
* main: only restore global settings when necessary
Loading the per-game settings cannot happen after the ROM is loaded, so we have to specify when to restore the global state. Again thanks to BSoD for finding the bug.
* configuration_shared: address reviewer concerns except operator overrides
Dropping operator override usage in next commit.
Co-Authored-By: LC <lioncash@users.noreply.github.com>
* settings: Drop operator overrides from Setting template
Requires using GetValue and SetValue explicitly. Also reverts a change that broke title ID formatting in the game properties dialog.
* complete rebase
* configuration_shared: translate "Use global configuration"
Uses ConfigurePerGame to do so, since its usage, at least as of now, corresponds with ConfigurationShared.
* configure_per_game: address reviewer concern
As far as I understand, it prevents the program from unnecessarily copying strings.
Co-Authored-By: LC <lioncash@users.noreply.github.com>
Co-authored-by: Morph <39850852+Morph1984@users.noreply.github.com>
Co-authored-by: VolcaEM <volcaem@users.noreply.github.com>
Co-authored-by: LC <lioncash@users.noreply.github.com>
2020-07-09 19:42:09 -07:00
|
|
|
Settings::values.resolution_factor.GetValue()),
|
2018-11-18 20:20:47 -08:00
|
|
|
static_cast<u32>(static_cast<u32>(DisplayResolution::UndockedHeight) *
|
configuration: implement per-game configurations (#4098)
* Switch game settings to use a pointer
In order to add full per-game settings, we need to be able to tell yuzu to switch
to using either the global or game configuration. Using a pointer makes it easier
to switch.
* configuration: add new UI without changing existing funcitonality
The new UI also adds General, System, Graphics, Advanced Graphics,
and Audio tabs, but as yet they do nothing. This commit keeps yuzu
to the same functionality as originally branched.
* configuration: Rename files
These weren't included in the last commit. Now they are.
* configuration: setup global configuration checkbox
Global config checkbox now enables/disables the appropriate tabs in the game
properties dialog. The use global configuration setting is now saved to the
config, defaulting to true. This also addresses some changes requested in the PR.
* configuration: swap to per-game config memory for properties dialog
Does not set memory going in-game. Swaps to game values when opening the
properties dialog, then swaps back when closing it. Uses a `memcpy` to swap.
Also implements saving config files, limited to certain groups of configurations
so as to not risk setting unsafe configurations.
* configuration: change config interfaces to use config-specific pointers
When a game is booted, we need to be able to open the configuration dialogs
without changing the settings pointer in the game's emualtion. A new pointer
specific to just the configuration dialogs can be used to separate changes
to just those config dialogs without affecting the emulation.
* configuration: boot a game using per-game settings
Swaps values where needed to boot a game.
* configuration: user correct config during emulation
Creates a new pointer specifically for modifying the configuration while
emulation is in progress. Both the regular configuration dialog and the game
properties dialog now use the pointer Settings::config_values to focus edits to
the correct struct.
* settings: split Settings::values into two different structs
By splitting the settings into two mutually exclusive structs, it becomes easier,
as a developer, to determine how to use the Settings structs after per-game
configurations is merged. Other benefits include only duplicating the required
settings in memory.
* settings: move use_docked_mode to Controls group
`use_docked_mode` is set in the input settings and cannot be accessed from the
system settings. Grouping it with system settings causes it to be saved with
per-game settings, which may make transferring configs more difficult later on,
especially since docked mode cannot be set from within the game properties
dialog.
* configuration: Fix the other yuzu executables and a regression
In main.cpp, we have to get the title ID before the ROM is loaded, else the
renderer will reflect only the global settings and now the user's game specific
settings.
* settings: use a template to duplicate memory for each setting
Replaces the type of each variable in the Settings::Values struct with a new
class that allows basic data reading and writing. The new struct
Settings::Setting duplicates the data in memory and can manage global overrides
per each setting.
* configuration: correct add-ons config and swap settings when apropriate
Any add-ons interaction happens directly through the global values struct.
Swapping bewteen structs now also includes copying the necessary global configs
that cannot be changed nor saved in per-game settings. General and System config
menus now update based on whether it is viewing the global or per-game settings.
* settings: restore old values struct
No longer needed with the Settings::Setting class template.
* configuration: implement hierarchical game properties dialog
This sets the apropriate global or local data in each setting.
* clang format
* clang format take 2
can the docker container save this?
* address comments and style issues
* config: read and write settings with global awareness
Adds new functions to read and write settings while keeping the global state in
focus. Files now generated per-game are much smaller since often they only need
address the global state.
* settings: restore global state when necessary
Upon closing a game or the game properties dialog, we need to restore all global
settings to the original global state so that we can properly open the
configuration dialog or boot a different game.
* configuration: guard setting values incorrectly
This disables setting values while a game is running if the setting is
overwritten by a per game setting.
* config: don't write local settings in the global config
Simple guards to prevent writing the wrong settings in the wrong files.
* configuration: add comments, assume less, and clang format
No longer assumes that a disabled UI element means the global state is turned
off, instead opting to directly answer that question. Still however assumes a
game is running if it is in that state.
* configuration: fix a logic error
Should not be negated
* restore settings' global state regardless of accept/cancel
Fixes loading a properties dialog and causing the global config dialog to show
local settings.
* fix more logic errors
Fixed the frame limit would set the global setting from the game properties
dialog. Also strengthened the Settings::Setting member variables and simplified
the logic in config reading (ReadSettingGlobal).
* fix another logic error
In my efforts to guard RestoreGlobalState, I accidentally negated the IsPowered
condition.
* configure_audio: set toggle_stretched_audio to tristate
* fixed custom rtc and rng seed overwriting the global value
* clang format
* rebased
* clang format take 4
* address my own review
Basically revert unintended changes
* settings: literal instead of casting
"No need to cast, use 1U instead"
Thanks, Morph!
Co-authored-by: Morph <39850852+Morph1984@users.noreply.github.com>
* Revert "settings: literal instead of casting
"
This reverts commit 95e992a87c898f3e882ffdb415bb0ef9f80f613f.
* main: fix status buttons reporting wrong settings after stop emulation
* settings: Log UseDockedMode in the Controls group
This should have happened when use_docked_mode was moved over to the controls group
internally. This just reflects this in the log.
* main: load settings if the file has a title id
In other words, don't exit if the loader has trouble getting a title id.
* use a zero
* settings: initalize resolution factor with constructor instead of casting
* Revert "settings: initalize resolution factor with constructor instead of casting"
This reverts commit 54c35ecb46a29953842614620f9b7de1aa9d5dc8.
* configure_graphics: guard device selector when Vulkan is global
Prevents the user from editing the device selector if Vulkan is the global
renderer backend. Also resets the vulkan_device variable when the users
switches back-and-forth between global and Vulkan.
* address reviewer concerns
Changes function variables to const wherever they don't need to be changed. Sets Settings::Setting to final as it should not be inherited from. Sets ConfigurationShared::use_global_text to static.
Co-Authored-By: VolcaEM <volcaem@users.noreply.github.com>
* main: load per-game settings after LoadROM
This prevents `Restart Emulation` from restoring the global settings *after* the per-game settings were applied. Thanks to BSoDGamingYT for finding this bug.
* Revert "main: load per-game settings after LoadROM"
This reverts commit 9d0d48c52d2dcf3bfb1806cc8fa7d5a271a8a804.
* main: only restore global settings when necessary
Loading the per-game settings cannot happen after the ROM is loaded, so we have to specify when to restore the global state. Again thanks to BSoD for finding the bug.
* configuration_shared: address reviewer concerns except operator overrides
Dropping operator override usage in next commit.
Co-Authored-By: LC <lioncash@users.noreply.github.com>
* settings: Drop operator overrides from Setting template
Requires using GetValue and SetValue explicitly. Also reverts a change that broke title ID formatting in the game properties dialog.
* complete rebase
* configuration_shared: translate "Use global configuration"
Uses ConfigurePerGame to do so, since its usage, at least as of now, corresponds with ConfigurationShared.
* configure_per_game: address reviewer concern
As far as I understand, it prevents the program from unnecessarily copying strings.
Co-Authored-By: LC <lioncash@users.noreply.github.com>
Co-authored-by: Morph <39850852+Morph1984@users.noreply.github.com>
Co-authored-by: VolcaEM <volcaem@users.noreply.github.com>
Co-authored-by: LC <lioncash@users.noreply.github.com>
2020-07-09 19:42:09 -07:00
|
|
|
Settings::values.resolution_factor.GetValue())};
|
2020-12-16 21:09:06 -08:00
|
|
|
|
|
|
|
{
|
|
|
|
auto& buffer_queue = *nv_flinger.FindBufferQueue(id);
|
|
|
|
buffer_queue.Connect();
|
|
|
|
}
|
|
|
|
|
2018-02-13 18:54:12 -08:00
|
|
|
ctx.WriteBuffer(response.Serialize());
|
2020-04-04 19:29:56 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TransactionId::SetPreallocatedBuffer: {
|
2018-02-13 18:54:12 -08:00
|
|
|
IGBPSetPreallocatedBufferRequestParcel request{ctx.ReadBuffer()};
|
2018-01-07 18:27:58 -08:00
|
|
|
|
2020-12-09 22:52:09 -08:00
|
|
|
{
|
2020-12-10 15:32:52 -08:00
|
|
|
auto& buffer_queue = *nv_flinger.FindBufferQueue(id);
|
|
|
|
buffer_queue.SetPreallocatedBuffer(request.data.slot,
|
|
|
|
request.buffer_container.buffer);
|
2020-12-09 22:52:09 -08:00
|
|
|
}
|
2018-01-07 18:27:58 -08:00
|
|
|
|
|
|
|
IGBPSetPreallocatedBufferResponseParcel response{};
|
2018-02-13 18:54:12 -08:00
|
|
|
ctx.WriteBuffer(response.Serialize());
|
2020-04-04 19:29:56 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TransactionId::DequeueBuffer: {
|
2018-02-13 18:54:12 -08:00
|
|
|
IGBPDequeueBufferRequestParcel request{ctx.ReadBuffer()};
|
2018-03-18 17:27:15 -07:00
|
|
|
const u32 width{request.data.width};
|
|
|
|
const u32 height{request.data.height};
|
2020-12-09 22:52:09 -08:00
|
|
|
|
2020-12-16 21:09:06 -08:00
|
|
|
auto& buffer_queue = *nv_flinger.FindBufferQueue(id);
|
|
|
|
do {
|
|
|
|
if (auto result = buffer_queue.DequeueBuffer(width, height); result) {
|
2020-12-09 22:52:09 -08:00
|
|
|
// Buffer is available
|
|
|
|
IGBPDequeueBufferResponseParcel response{result->first, *result->second};
|
|
|
|
ctx.WriteBuffer(response.Serialize());
|
2020-12-16 21:09:06 -08:00
|
|
|
break;
|
2020-12-09 22:52:09 -08:00
|
|
|
}
|
2020-12-16 21:09:06 -08:00
|
|
|
} while (buffer_queue.IsConnected());
|
2020-12-09 22:52:09 -08:00
|
|
|
|
2020-04-04 19:29:56 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TransactionId::RequestBuffer: {
|
2018-02-13 18:54:12 -08:00
|
|
|
IGBPRequestBufferRequestParcel request{ctx.ReadBuffer()};
|
2018-01-07 18:27:58 -08:00
|
|
|
|
2020-12-10 15:32:52 -08:00
|
|
|
auto& buffer_queue = *nv_flinger.FindBufferQueue(id);
|
2019-02-21 08:31:53 -08:00
|
|
|
auto& buffer = buffer_queue.RequestBuffer(request.slot);
|
2018-01-07 18:27:58 -08:00
|
|
|
IGBPRequestBufferResponseParcel response{buffer};
|
2018-02-13 18:54:12 -08:00
|
|
|
ctx.WriteBuffer(response.Serialize());
|
2020-12-09 22:52:09 -08:00
|
|
|
|
2020-04-04 19:29:56 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TransactionId::QueueBuffer: {
|
2018-02-13 18:54:12 -08:00
|
|
|
IGBPQueueBufferRequestParcel request{ctx.ReadBuffer()};
|
2018-01-07 18:27:58 -08:00
|
|
|
|
2020-12-10 15:32:52 -08:00
|
|
|
auto& buffer_queue = *nv_flinger.FindBufferQueue(id);
|
|
|
|
buffer_queue.QueueBuffer(request.data.slot, request.data.transform,
|
|
|
|
request.data.GetCropRect(), request.data.swap_interval,
|
|
|
|
request.data.multi_fence);
|
2018-01-08 15:18:50 -08:00
|
|
|
|
2018-01-07 18:27:58 -08:00
|
|
|
IGBPQueueBufferResponseParcel response{1280, 720};
|
2018-02-13 18:54:12 -08:00
|
|
|
ctx.WriteBuffer(response.Serialize());
|
2020-04-04 19:29:56 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TransactionId::Query: {
|
2018-02-13 18:54:12 -08:00
|
|
|
IGBPQueryRequestParcel request{ctx.ReadBuffer()};
|
2018-01-21 08:13:47 -08:00
|
|
|
|
2020-12-10 15:32:52 -08:00
|
|
|
auto& buffer_queue = *nv_flinger.FindBufferQueue(id);
|
2019-02-21 08:31:53 -08:00
|
|
|
const u32 value =
|
|
|
|
buffer_queue.Query(static_cast<NVFlinger::BufferQueue::QueryType>(request.type));
|
2018-01-21 08:13:47 -08:00
|
|
|
|
|
|
|
IGBPQueryResponseParcel response{value};
|
2018-02-13 18:54:12 -08:00
|
|
|
ctx.WriteBuffer(response.Serialize());
|
2020-04-04 19:29:56 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TransactionId::CancelBuffer: {
|
2020-10-12 17:35:34 -07:00
|
|
|
IGBPCancelBufferRequestParcel request{ctx.ReadBuffer()};
|
|
|
|
|
2020-12-10 15:32:52 -08:00
|
|
|
auto& buffer_queue = *nv_flinger.FindBufferQueue(id);
|
|
|
|
buffer_queue.CancelBuffer(request.data.slot, request.data.multi_fence);
|
2020-10-12 17:35:34 -07:00
|
|
|
|
|
|
|
IGBPCancelBufferResponseParcel response{};
|
|
|
|
ctx.WriteBuffer(response.Serialize());
|
2020-04-04 19:29:56 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TransactionId::Disconnect: {
|
|
|
|
LOG_WARNING(Service_VI, "(STUBBED) called, transaction=Disconnect");
|
2018-11-17 14:10:10 -08:00
|
|
|
const auto buffer = ctx.ReadBuffer();
|
|
|
|
|
2020-12-10 15:32:52 -08:00
|
|
|
auto& buffer_queue = *nv_flinger.FindBufferQueue(id);
|
|
|
|
buffer_queue.Disconnect();
|
2020-04-04 19:29:56 -07:00
|
|
|
|
2018-11-17 14:10:10 -08:00
|
|
|
IGBPEmptyResponseParcel response{};
|
|
|
|
ctx.WriteBuffer(response.Serialize());
|
2020-04-04 19:29:56 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TransactionId::DetachBuffer: {
|
|
|
|
const auto buffer = ctx.ReadBuffer();
|
|
|
|
|
|
|
|
IGBPEmptyResponseParcel response{};
|
|
|
|
ctx.WriteBuffer(response.Serialize());
|
|
|
|
break;
|
|
|
|
}
|
2020-04-24 00:16:39 -07:00
|
|
|
case TransactionId::SetBufferCount: {
|
|
|
|
LOG_WARNING(Service_VI, "(STUBBED) called, transaction=SetBufferCount");
|
|
|
|
[[maybe_unused]] const auto buffer = ctx.ReadBuffer();
|
|
|
|
|
|
|
|
IGBPEmptyResponseParcel response{};
|
|
|
|
ctx.WriteBuffer(response.Serialize());
|
|
|
|
break;
|
|
|
|
}
|
2020-04-04 19:29:56 -07:00
|
|
|
default:
|
2018-01-07 18:27:58 -08:00
|
|
|
ASSERT_MSG(false, "Unimplemented");
|
|
|
|
}
|
2018-02-09 19:50:29 -08:00
|
|
|
|
2018-01-23 16:52:18 -08:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
2018-01-07 18:27:58 -08:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AdjustRefcount(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp{ctx};
|
2019-01-02 16:42:08 -08:00
|
|
|
const u32 id = rp.Pop<u32>();
|
|
|
|
const s32 addval = rp.PopRaw<s32>();
|
|
|
|
const u32 type = rp.Pop<u32>();
|
|
|
|
|
2018-07-02 09:13:26 -07:00
|
|
|
LOG_WARNING(Service_VI, "(STUBBED) called id={}, addval={:08X}, type={:08X}", id, addval,
|
2018-07-02 09:20:50 -07:00
|
|
|
type);
|
2018-11-25 22:06:13 -08:00
|
|
|
|
2018-01-23 16:52:18 -08:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
2018-01-07 18:27:58 -08:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2018-01-15 14:20:08 -08:00
|
|
|
void GetNativeHandle(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp{ctx};
|
2019-01-02 16:42:08 -08:00
|
|
|
const u32 id = rp.Pop<u32>();
|
|
|
|
const u32 unknown = rp.Pop<u32>();
|
|
|
|
|
2018-11-25 22:06:13 -08:00
|
|
|
LOG_WARNING(Service_VI, "(STUBBED) called id={}, unknown={:08X}", id, unknown);
|
2018-01-15 14:20:08 -08:00
|
|
|
|
2020-12-10 15:32:52 -08:00
|
|
|
const auto& buffer_queue = *nv_flinger.FindBufferQueue(id);
|
2018-01-15 14:20:08 -08:00
|
|
|
|
|
|
|
// TODO(Subv): Find out what this actually is.
|
2018-01-23 16:52:18 -08:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 1};
|
2018-01-15 14:20:08 -08:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
2019-02-21 08:31:53 -08:00
|
|
|
rb.PushCopyObjects(buffer_queue.GetBufferWaitEvent());
|
2018-01-15 14:20:08 -08:00
|
|
|
}
|
|
|
|
|
2020-11-24 14:31:58 -08:00
|
|
|
NVFlinger::NVFlinger& nv_flinger;
|
|
|
|
};
|
2018-01-07 18:27:58 -08:00
|
|
|
|
|
|
|
class ISystemDisplayService final : public ServiceFramework<ISystemDisplayService> {
|
|
|
|
public:
|
2020-11-26 12:19:08 -08:00
|
|
|
explicit ISystemDisplayService(Core::System& system_)
|
|
|
|
: ServiceFramework{system_, "ISystemDisplayService"} {
|
2018-01-07 18:27:58 -08:00
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{1200, nullptr, "GetZOrderCountMin"},
|
2018-04-17 08:37:43 -07:00
|
|
|
{1202, nullptr, "GetZOrderCountMax"},
|
|
|
|
{1203, nullptr, "GetDisplayLogicalResolution"},
|
|
|
|
{1204, nullptr, "SetDisplayMagnification"},
|
|
|
|
{2201, nullptr, "SetLayerPosition"},
|
|
|
|
{2203, nullptr, "SetLayerSize"},
|
|
|
|
{2204, nullptr, "GetLayerZ"},
|
2018-01-07 18:27:58 -08:00
|
|
|
{2205, &ISystemDisplayService::SetLayerZ, "SetLayerZ"},
|
2018-04-16 02:04:34 -07:00
|
|
|
{2207, &ISystemDisplayService::SetLayerVisibility, "SetLayerVisibility"},
|
2018-04-17 08:37:43 -07:00
|
|
|
{2209, nullptr, "SetLayerAlpha"},
|
|
|
|
{2312, nullptr, "CreateStrayLayer"},
|
|
|
|
{2400, nullptr, "OpenIndirectLayer"},
|
|
|
|
{2401, nullptr, "CloseIndirectLayer"},
|
|
|
|
{2402, nullptr, "FlipIndirectLayer"},
|
|
|
|
{3000, nullptr, "ListDisplayModes"},
|
|
|
|
{3001, nullptr, "ListDisplayRgbRanges"},
|
|
|
|
{3002, nullptr, "ListDisplayContentTypes"},
|
2018-09-17 08:19:31 -07:00
|
|
|
{3200, &ISystemDisplayService::GetDisplayMode, "GetDisplayMode"},
|
2018-04-17 08:37:43 -07:00
|
|
|
{3201, nullptr, "SetDisplayMode"},
|
|
|
|
{3202, nullptr, "GetDisplayUnderscan"},
|
|
|
|
{3203, nullptr, "SetDisplayUnderscan"},
|
|
|
|
{3204, nullptr, "GetDisplayContentType"},
|
|
|
|
{3205, nullptr, "SetDisplayContentType"},
|
|
|
|
{3206, nullptr, "GetDisplayRgbRange"},
|
|
|
|
{3207, nullptr, "SetDisplayRgbRange"},
|
|
|
|
{3208, nullptr, "GetDisplayCmuMode"},
|
|
|
|
{3209, nullptr, "SetDisplayCmuMode"},
|
|
|
|
{3210, nullptr, "GetDisplayContrastRatio"},
|
|
|
|
{3211, nullptr, "SetDisplayContrastRatio"},
|
|
|
|
{3214, nullptr, "GetDisplayGamma"},
|
|
|
|
{3215, nullptr, "SetDisplayGamma"},
|
|
|
|
{3216, nullptr, "GetDisplayCmuLuma"},
|
|
|
|
{3217, nullptr, "SetDisplayCmuLuma"},
|
2020-06-28 19:01:34 -07:00
|
|
|
{6013, nullptr, "GetLayerPresentationSubmissionTimestamps"},
|
2018-04-17 08:37:43 -07:00
|
|
|
{8225, nullptr, "GetSharedBufferMemoryHandleId"},
|
|
|
|
{8250, nullptr, "OpenSharedLayer"},
|
|
|
|
{8251, nullptr, "CloseSharedLayer"},
|
|
|
|
{8252, nullptr, "ConnectSharedLayer"},
|
|
|
|
{8253, nullptr, "DisconnectSharedLayer"},
|
|
|
|
{8254, nullptr, "AcquireSharedFrameBuffer"},
|
|
|
|
{8255, nullptr, "PresentSharedFrameBuffer"},
|
|
|
|
{8256, nullptr, "GetSharedFrameBufferAcquirableEvent"},
|
|
|
|
{8257, nullptr, "FillSharedFrameBufferColor"},
|
|
|
|
{8258, nullptr, "CancelSharedFrameBuffer"},
|
2018-01-07 18:27:58 -08:00
|
|
|
};
|
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
void SetLayerZ(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp{ctx};
|
2019-01-02 16:42:08 -08:00
|
|
|
const u64 layer_id = rp.Pop<u64>();
|
|
|
|
const u64 z_value = rp.Pop<u64>();
|
|
|
|
|
|
|
|
LOG_WARNING(Service_VI, "(STUBBED) called. layer_id=0x{:016X}, z_value=0x{:016X}", layer_id,
|
|
|
|
z_value);
|
2018-01-07 18:27:58 -08:00
|
|
|
|
2018-09-18 22:09:59 -07:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
2018-01-07 18:27:58 -08:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
2018-04-16 02:04:34 -07:00
|
|
|
|
2019-01-28 05:21:34 -08:00
|
|
|
// This function currently does nothing but return a success error code in
|
|
|
|
// the vi library itself, so do the same thing, but log out the passed in values.
|
2018-04-16 02:04:34 -07:00
|
|
|
void SetLayerVisibility(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp{ctx};
|
2019-01-02 16:42:08 -08:00
|
|
|
const u64 layer_id = rp.Pop<u64>();
|
|
|
|
const bool visibility = rp.Pop<bool>();
|
|
|
|
|
2019-01-28 05:21:34 -08:00
|
|
|
LOG_DEBUG(Service_VI, "called, layer_id=0x{:08X}, visibility={}", layer_id, visibility);
|
2018-11-25 22:06:13 -08:00
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2018-04-16 02:04:34 -07:00
|
|
|
}
|
2018-09-17 08:19:31 -07:00
|
|
|
|
|
|
|
void GetDisplayMode(Kernel::HLERequestContext& ctx) {
|
2018-11-25 22:06:13 -08:00
|
|
|
LOG_WARNING(Service_VI, "(STUBBED) called");
|
|
|
|
|
2018-09-17 08:19:31 -07:00
|
|
|
IPC::ResponseBuilder rb{ctx, 6};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
|
2020-09-28 07:00:15 -07:00
|
|
|
if (Settings::values.use_docked_mode.GetValue()) {
|
2018-11-15 23:07:42 -08:00
|
|
|
rb.Push(static_cast<u32>(Service::VI::DisplayResolution::DockedWidth) *
|
configuration: implement per-game configurations (#4098)
* Switch game settings to use a pointer
In order to add full per-game settings, we need to be able to tell yuzu to switch
to using either the global or game configuration. Using a pointer makes it easier
to switch.
* configuration: add new UI without changing existing funcitonality
The new UI also adds General, System, Graphics, Advanced Graphics,
and Audio tabs, but as yet they do nothing. This commit keeps yuzu
to the same functionality as originally branched.
* configuration: Rename files
These weren't included in the last commit. Now they are.
* configuration: setup global configuration checkbox
Global config checkbox now enables/disables the appropriate tabs in the game
properties dialog. The use global configuration setting is now saved to the
config, defaulting to true. This also addresses some changes requested in the PR.
* configuration: swap to per-game config memory for properties dialog
Does not set memory going in-game. Swaps to game values when opening the
properties dialog, then swaps back when closing it. Uses a `memcpy` to swap.
Also implements saving config files, limited to certain groups of configurations
so as to not risk setting unsafe configurations.
* configuration: change config interfaces to use config-specific pointers
When a game is booted, we need to be able to open the configuration dialogs
without changing the settings pointer in the game's emualtion. A new pointer
specific to just the configuration dialogs can be used to separate changes
to just those config dialogs without affecting the emulation.
* configuration: boot a game using per-game settings
Swaps values where needed to boot a game.
* configuration: user correct config during emulation
Creates a new pointer specifically for modifying the configuration while
emulation is in progress. Both the regular configuration dialog and the game
properties dialog now use the pointer Settings::config_values to focus edits to
the correct struct.
* settings: split Settings::values into two different structs
By splitting the settings into two mutually exclusive structs, it becomes easier,
as a developer, to determine how to use the Settings structs after per-game
configurations is merged. Other benefits include only duplicating the required
settings in memory.
* settings: move use_docked_mode to Controls group
`use_docked_mode` is set in the input settings and cannot be accessed from the
system settings. Grouping it with system settings causes it to be saved with
per-game settings, which may make transferring configs more difficult later on,
especially since docked mode cannot be set from within the game properties
dialog.
* configuration: Fix the other yuzu executables and a regression
In main.cpp, we have to get the title ID before the ROM is loaded, else the
renderer will reflect only the global settings and now the user's game specific
settings.
* settings: use a template to duplicate memory for each setting
Replaces the type of each variable in the Settings::Values struct with a new
class that allows basic data reading and writing. The new struct
Settings::Setting duplicates the data in memory and can manage global overrides
per each setting.
* configuration: correct add-ons config and swap settings when apropriate
Any add-ons interaction happens directly through the global values struct.
Swapping bewteen structs now also includes copying the necessary global configs
that cannot be changed nor saved in per-game settings. General and System config
menus now update based on whether it is viewing the global or per-game settings.
* settings: restore old values struct
No longer needed with the Settings::Setting class template.
* configuration: implement hierarchical game properties dialog
This sets the apropriate global or local data in each setting.
* clang format
* clang format take 2
can the docker container save this?
* address comments and style issues
* config: read and write settings with global awareness
Adds new functions to read and write settings while keeping the global state in
focus. Files now generated per-game are much smaller since often they only need
address the global state.
* settings: restore global state when necessary
Upon closing a game or the game properties dialog, we need to restore all global
settings to the original global state so that we can properly open the
configuration dialog or boot a different game.
* configuration: guard setting values incorrectly
This disables setting values while a game is running if the setting is
overwritten by a per game setting.
* config: don't write local settings in the global config
Simple guards to prevent writing the wrong settings in the wrong files.
* configuration: add comments, assume less, and clang format
No longer assumes that a disabled UI element means the global state is turned
off, instead opting to directly answer that question. Still however assumes a
game is running if it is in that state.
* configuration: fix a logic error
Should not be negated
* restore settings' global state regardless of accept/cancel
Fixes loading a properties dialog and causing the global config dialog to show
local settings.
* fix more logic errors
Fixed the frame limit would set the global setting from the game properties
dialog. Also strengthened the Settings::Setting member variables and simplified
the logic in config reading (ReadSettingGlobal).
* fix another logic error
In my efforts to guard RestoreGlobalState, I accidentally negated the IsPowered
condition.
* configure_audio: set toggle_stretched_audio to tristate
* fixed custom rtc and rng seed overwriting the global value
* clang format
* rebased
* clang format take 4
* address my own review
Basically revert unintended changes
* settings: literal instead of casting
"No need to cast, use 1U instead"
Thanks, Morph!
Co-authored-by: Morph <39850852+Morph1984@users.noreply.github.com>
* Revert "settings: literal instead of casting
"
This reverts commit 95e992a87c898f3e882ffdb415bb0ef9f80f613f.
* main: fix status buttons reporting wrong settings after stop emulation
* settings: Log UseDockedMode in the Controls group
This should have happened when use_docked_mode was moved over to the controls group
internally. This just reflects this in the log.
* main: load settings if the file has a title id
In other words, don't exit if the loader has trouble getting a title id.
* use a zero
* settings: initalize resolution factor with constructor instead of casting
* Revert "settings: initalize resolution factor with constructor instead of casting"
This reverts commit 54c35ecb46a29953842614620f9b7de1aa9d5dc8.
* configure_graphics: guard device selector when Vulkan is global
Prevents the user from editing the device selector if Vulkan is the global
renderer backend. Also resets the vulkan_device variable when the users
switches back-and-forth between global and Vulkan.
* address reviewer concerns
Changes function variables to const wherever they don't need to be changed. Sets Settings::Setting to final as it should not be inherited from. Sets ConfigurationShared::use_global_text to static.
Co-Authored-By: VolcaEM <volcaem@users.noreply.github.com>
* main: load per-game settings after LoadROM
This prevents `Restart Emulation` from restoring the global settings *after* the per-game settings were applied. Thanks to BSoDGamingYT for finding this bug.
* Revert "main: load per-game settings after LoadROM"
This reverts commit 9d0d48c52d2dcf3bfb1806cc8fa7d5a271a8a804.
* main: only restore global settings when necessary
Loading the per-game settings cannot happen after the ROM is loaded, so we have to specify when to restore the global state. Again thanks to BSoD for finding the bug.
* configuration_shared: address reviewer concerns except operator overrides
Dropping operator override usage in next commit.
Co-Authored-By: LC <lioncash@users.noreply.github.com>
* settings: Drop operator overrides from Setting template
Requires using GetValue and SetValue explicitly. Also reverts a change that broke title ID formatting in the game properties dialog.
* complete rebase
* configuration_shared: translate "Use global configuration"
Uses ConfigurePerGame to do so, since its usage, at least as of now, corresponds with ConfigurationShared.
* configure_per_game: address reviewer concern
As far as I understand, it prevents the program from unnecessarily copying strings.
Co-Authored-By: LC <lioncash@users.noreply.github.com>
Co-authored-by: Morph <39850852+Morph1984@users.noreply.github.com>
Co-authored-by: VolcaEM <volcaem@users.noreply.github.com>
Co-authored-by: LC <lioncash@users.noreply.github.com>
2020-07-09 19:42:09 -07:00
|
|
|
static_cast<u32>(Settings::values.resolution_factor.GetValue()));
|
2018-11-15 23:07:42 -08:00
|
|
|
rb.Push(static_cast<u32>(Service::VI::DisplayResolution::DockedHeight) *
|
configuration: implement per-game configurations (#4098)
* Switch game settings to use a pointer
In order to add full per-game settings, we need to be able to tell yuzu to switch
to using either the global or game configuration. Using a pointer makes it easier
to switch.
* configuration: add new UI without changing existing funcitonality
The new UI also adds General, System, Graphics, Advanced Graphics,
and Audio tabs, but as yet they do nothing. This commit keeps yuzu
to the same functionality as originally branched.
* configuration: Rename files
These weren't included in the last commit. Now they are.
* configuration: setup global configuration checkbox
Global config checkbox now enables/disables the appropriate tabs in the game
properties dialog. The use global configuration setting is now saved to the
config, defaulting to true. This also addresses some changes requested in the PR.
* configuration: swap to per-game config memory for properties dialog
Does not set memory going in-game. Swaps to game values when opening the
properties dialog, then swaps back when closing it. Uses a `memcpy` to swap.
Also implements saving config files, limited to certain groups of configurations
so as to not risk setting unsafe configurations.
* configuration: change config interfaces to use config-specific pointers
When a game is booted, we need to be able to open the configuration dialogs
without changing the settings pointer in the game's emualtion. A new pointer
specific to just the configuration dialogs can be used to separate changes
to just those config dialogs without affecting the emulation.
* configuration: boot a game using per-game settings
Swaps values where needed to boot a game.
* configuration: user correct config during emulation
Creates a new pointer specifically for modifying the configuration while
emulation is in progress. Both the regular configuration dialog and the game
properties dialog now use the pointer Settings::config_values to focus edits to
the correct struct.
* settings: split Settings::values into two different structs
By splitting the settings into two mutually exclusive structs, it becomes easier,
as a developer, to determine how to use the Settings structs after per-game
configurations is merged. Other benefits include only duplicating the required
settings in memory.
* settings: move use_docked_mode to Controls group
`use_docked_mode` is set in the input settings and cannot be accessed from the
system settings. Grouping it with system settings causes it to be saved with
per-game settings, which may make transferring configs more difficult later on,
especially since docked mode cannot be set from within the game properties
dialog.
* configuration: Fix the other yuzu executables and a regression
In main.cpp, we have to get the title ID before the ROM is loaded, else the
renderer will reflect only the global settings and now the user's game specific
settings.
* settings: use a template to duplicate memory for each setting
Replaces the type of each variable in the Settings::Values struct with a new
class that allows basic data reading and writing. The new struct
Settings::Setting duplicates the data in memory and can manage global overrides
per each setting.
* configuration: correct add-ons config and swap settings when apropriate
Any add-ons interaction happens directly through the global values struct.
Swapping bewteen structs now also includes copying the necessary global configs
that cannot be changed nor saved in per-game settings. General and System config
menus now update based on whether it is viewing the global or per-game settings.
* settings: restore old values struct
No longer needed with the Settings::Setting class template.
* configuration: implement hierarchical game properties dialog
This sets the apropriate global or local data in each setting.
* clang format
* clang format take 2
can the docker container save this?
* address comments and style issues
* config: read and write settings with global awareness
Adds new functions to read and write settings while keeping the global state in
focus. Files now generated per-game are much smaller since often they only need
address the global state.
* settings: restore global state when necessary
Upon closing a game or the game properties dialog, we need to restore all global
settings to the original global state so that we can properly open the
configuration dialog or boot a different game.
* configuration: guard setting values incorrectly
This disables setting values while a game is running if the setting is
overwritten by a per game setting.
* config: don't write local settings in the global config
Simple guards to prevent writing the wrong settings in the wrong files.
* configuration: add comments, assume less, and clang format
No longer assumes that a disabled UI element means the global state is turned
off, instead opting to directly answer that question. Still however assumes a
game is running if it is in that state.
* configuration: fix a logic error
Should not be negated
* restore settings' global state regardless of accept/cancel
Fixes loading a properties dialog and causing the global config dialog to show
local settings.
* fix more logic errors
Fixed the frame limit would set the global setting from the game properties
dialog. Also strengthened the Settings::Setting member variables and simplified
the logic in config reading (ReadSettingGlobal).
* fix another logic error
In my efforts to guard RestoreGlobalState, I accidentally negated the IsPowered
condition.
* configure_audio: set toggle_stretched_audio to tristate
* fixed custom rtc and rng seed overwriting the global value
* clang format
* rebased
* clang format take 4
* address my own review
Basically revert unintended changes
* settings: literal instead of casting
"No need to cast, use 1U instead"
Thanks, Morph!
Co-authored-by: Morph <39850852+Morph1984@users.noreply.github.com>
* Revert "settings: literal instead of casting
"
This reverts commit 95e992a87c898f3e882ffdb415bb0ef9f80f613f.
* main: fix status buttons reporting wrong settings after stop emulation
* settings: Log UseDockedMode in the Controls group
This should have happened when use_docked_mode was moved over to the controls group
internally. This just reflects this in the log.
* main: load settings if the file has a title id
In other words, don't exit if the loader has trouble getting a title id.
* use a zero
* settings: initalize resolution factor with constructor instead of casting
* Revert "settings: initalize resolution factor with constructor instead of casting"
This reverts commit 54c35ecb46a29953842614620f9b7de1aa9d5dc8.
* configure_graphics: guard device selector when Vulkan is global
Prevents the user from editing the device selector if Vulkan is the global
renderer backend. Also resets the vulkan_device variable when the users
switches back-and-forth between global and Vulkan.
* address reviewer concerns
Changes function variables to const wherever they don't need to be changed. Sets Settings::Setting to final as it should not be inherited from. Sets ConfigurationShared::use_global_text to static.
Co-Authored-By: VolcaEM <volcaem@users.noreply.github.com>
* main: load per-game settings after LoadROM
This prevents `Restart Emulation` from restoring the global settings *after* the per-game settings were applied. Thanks to BSoDGamingYT for finding this bug.
* Revert "main: load per-game settings after LoadROM"
This reverts commit 9d0d48c52d2dcf3bfb1806cc8fa7d5a271a8a804.
* main: only restore global settings when necessary
Loading the per-game settings cannot happen after the ROM is loaded, so we have to specify when to restore the global state. Again thanks to BSoD for finding the bug.
* configuration_shared: address reviewer concerns except operator overrides
Dropping operator override usage in next commit.
Co-Authored-By: LC <lioncash@users.noreply.github.com>
* settings: Drop operator overrides from Setting template
Requires using GetValue and SetValue explicitly. Also reverts a change that broke title ID formatting in the game properties dialog.
* complete rebase
* configuration_shared: translate "Use global configuration"
Uses ConfigurePerGame to do so, since its usage, at least as of now, corresponds with ConfigurationShared.
* configure_per_game: address reviewer concern
As far as I understand, it prevents the program from unnecessarily copying strings.
Co-Authored-By: LC <lioncash@users.noreply.github.com>
Co-authored-by: Morph <39850852+Morph1984@users.noreply.github.com>
Co-authored-by: VolcaEM <volcaem@users.noreply.github.com>
Co-authored-by: LC <lioncash@users.noreply.github.com>
2020-07-09 19:42:09 -07:00
|
|
|
static_cast<u32>(Settings::values.resolution_factor.GetValue()));
|
2018-09-17 08:19:31 -07:00
|
|
|
} else {
|
2018-11-15 23:07:42 -08:00
|
|
|
rb.Push(static_cast<u32>(Service::VI::DisplayResolution::UndockedWidth) *
|
configuration: implement per-game configurations (#4098)
* Switch game settings to use a pointer
In order to add full per-game settings, we need to be able to tell yuzu to switch
to using either the global or game configuration. Using a pointer makes it easier
to switch.
* configuration: add new UI without changing existing funcitonality
The new UI also adds General, System, Graphics, Advanced Graphics,
and Audio tabs, but as yet they do nothing. This commit keeps yuzu
to the same functionality as originally branched.
* configuration: Rename files
These weren't included in the last commit. Now they are.
* configuration: setup global configuration checkbox
Global config checkbox now enables/disables the appropriate tabs in the game
properties dialog. The use global configuration setting is now saved to the
config, defaulting to true. This also addresses some changes requested in the PR.
* configuration: swap to per-game config memory for properties dialog
Does not set memory going in-game. Swaps to game values when opening the
properties dialog, then swaps back when closing it. Uses a `memcpy` to swap.
Also implements saving config files, limited to certain groups of configurations
so as to not risk setting unsafe configurations.
* configuration: change config interfaces to use config-specific pointers
When a game is booted, we need to be able to open the configuration dialogs
without changing the settings pointer in the game's emualtion. A new pointer
specific to just the configuration dialogs can be used to separate changes
to just those config dialogs without affecting the emulation.
* configuration: boot a game using per-game settings
Swaps values where needed to boot a game.
* configuration: user correct config during emulation
Creates a new pointer specifically for modifying the configuration while
emulation is in progress. Both the regular configuration dialog and the game
properties dialog now use the pointer Settings::config_values to focus edits to
the correct struct.
* settings: split Settings::values into two different structs
By splitting the settings into two mutually exclusive structs, it becomes easier,
as a developer, to determine how to use the Settings structs after per-game
configurations is merged. Other benefits include only duplicating the required
settings in memory.
* settings: move use_docked_mode to Controls group
`use_docked_mode` is set in the input settings and cannot be accessed from the
system settings. Grouping it with system settings causes it to be saved with
per-game settings, which may make transferring configs more difficult later on,
especially since docked mode cannot be set from within the game properties
dialog.
* configuration: Fix the other yuzu executables and a regression
In main.cpp, we have to get the title ID before the ROM is loaded, else the
renderer will reflect only the global settings and now the user's game specific
settings.
* settings: use a template to duplicate memory for each setting
Replaces the type of each variable in the Settings::Values struct with a new
class that allows basic data reading and writing. The new struct
Settings::Setting duplicates the data in memory and can manage global overrides
per each setting.
* configuration: correct add-ons config and swap settings when apropriate
Any add-ons interaction happens directly through the global values struct.
Swapping bewteen structs now also includes copying the necessary global configs
that cannot be changed nor saved in per-game settings. General and System config
menus now update based on whether it is viewing the global or per-game settings.
* settings: restore old values struct
No longer needed with the Settings::Setting class template.
* configuration: implement hierarchical game properties dialog
This sets the apropriate global or local data in each setting.
* clang format
* clang format take 2
can the docker container save this?
* address comments and style issues
* config: read and write settings with global awareness
Adds new functions to read and write settings while keeping the global state in
focus. Files now generated per-game are much smaller since often they only need
address the global state.
* settings: restore global state when necessary
Upon closing a game or the game properties dialog, we need to restore all global
settings to the original global state so that we can properly open the
configuration dialog or boot a different game.
* configuration: guard setting values incorrectly
This disables setting values while a game is running if the setting is
overwritten by a per game setting.
* config: don't write local settings in the global config
Simple guards to prevent writing the wrong settings in the wrong files.
* configuration: add comments, assume less, and clang format
No longer assumes that a disabled UI element means the global state is turned
off, instead opting to directly answer that question. Still however assumes a
game is running if it is in that state.
* configuration: fix a logic error
Should not be negated
* restore settings' global state regardless of accept/cancel
Fixes loading a properties dialog and causing the global config dialog to show
local settings.
* fix more logic errors
Fixed the frame limit would set the global setting from the game properties
dialog. Also strengthened the Settings::Setting member variables and simplified
the logic in config reading (ReadSettingGlobal).
* fix another logic error
In my efforts to guard RestoreGlobalState, I accidentally negated the IsPowered
condition.
* configure_audio: set toggle_stretched_audio to tristate
* fixed custom rtc and rng seed overwriting the global value
* clang format
* rebased
* clang format take 4
* address my own review
Basically revert unintended changes
* settings: literal instead of casting
"No need to cast, use 1U instead"
Thanks, Morph!
Co-authored-by: Morph <39850852+Morph1984@users.noreply.github.com>
* Revert "settings: literal instead of casting
"
This reverts commit 95e992a87c898f3e882ffdb415bb0ef9f80f613f.
* main: fix status buttons reporting wrong settings after stop emulation
* settings: Log UseDockedMode in the Controls group
This should have happened when use_docked_mode was moved over to the controls group
internally. This just reflects this in the log.
* main: load settings if the file has a title id
In other words, don't exit if the loader has trouble getting a title id.
* use a zero
* settings: initalize resolution factor with constructor instead of casting
* Revert "settings: initalize resolution factor with constructor instead of casting"
This reverts commit 54c35ecb46a29953842614620f9b7de1aa9d5dc8.
* configure_graphics: guard device selector when Vulkan is global
Prevents the user from editing the device selector if Vulkan is the global
renderer backend. Also resets the vulkan_device variable when the users
switches back-and-forth between global and Vulkan.
* address reviewer concerns
Changes function variables to const wherever they don't need to be changed. Sets Settings::Setting to final as it should not be inherited from. Sets ConfigurationShared::use_global_text to static.
Co-Authored-By: VolcaEM <volcaem@users.noreply.github.com>
* main: load per-game settings after LoadROM
This prevents `Restart Emulation` from restoring the global settings *after* the per-game settings were applied. Thanks to BSoDGamingYT for finding this bug.
* Revert "main: load per-game settings after LoadROM"
This reverts commit 9d0d48c52d2dcf3bfb1806cc8fa7d5a271a8a804.
* main: only restore global settings when necessary
Loading the per-game settings cannot happen after the ROM is loaded, so we have to specify when to restore the global state. Again thanks to BSoD for finding the bug.
* configuration_shared: address reviewer concerns except operator overrides
Dropping operator override usage in next commit.
Co-Authored-By: LC <lioncash@users.noreply.github.com>
* settings: Drop operator overrides from Setting template
Requires using GetValue and SetValue explicitly. Also reverts a change that broke title ID formatting in the game properties dialog.
* complete rebase
* configuration_shared: translate "Use global configuration"
Uses ConfigurePerGame to do so, since its usage, at least as of now, corresponds with ConfigurationShared.
* configure_per_game: address reviewer concern
As far as I understand, it prevents the program from unnecessarily copying strings.
Co-Authored-By: LC <lioncash@users.noreply.github.com>
Co-authored-by: Morph <39850852+Morph1984@users.noreply.github.com>
Co-authored-by: VolcaEM <volcaem@users.noreply.github.com>
Co-authored-by: LC <lioncash@users.noreply.github.com>
2020-07-09 19:42:09 -07:00
|
|
|
static_cast<u32>(Settings::values.resolution_factor.GetValue()));
|
2018-11-15 23:07:42 -08:00
|
|
|
rb.Push(static_cast<u32>(Service::VI::DisplayResolution::UndockedHeight) *
|
configuration: implement per-game configurations (#4098)
* Switch game settings to use a pointer
In order to add full per-game settings, we need to be able to tell yuzu to switch
to using either the global or game configuration. Using a pointer makes it easier
to switch.
* configuration: add new UI without changing existing funcitonality
The new UI also adds General, System, Graphics, Advanced Graphics,
and Audio tabs, but as yet they do nothing. This commit keeps yuzu
to the same functionality as originally branched.
* configuration: Rename files
These weren't included in the last commit. Now they are.
* configuration: setup global configuration checkbox
Global config checkbox now enables/disables the appropriate tabs in the game
properties dialog. The use global configuration setting is now saved to the
config, defaulting to true. This also addresses some changes requested in the PR.
* configuration: swap to per-game config memory for properties dialog
Does not set memory going in-game. Swaps to game values when opening the
properties dialog, then swaps back when closing it. Uses a `memcpy` to swap.
Also implements saving config files, limited to certain groups of configurations
so as to not risk setting unsafe configurations.
* configuration: change config interfaces to use config-specific pointers
When a game is booted, we need to be able to open the configuration dialogs
without changing the settings pointer in the game's emualtion. A new pointer
specific to just the configuration dialogs can be used to separate changes
to just those config dialogs without affecting the emulation.
* configuration: boot a game using per-game settings
Swaps values where needed to boot a game.
* configuration: user correct config during emulation
Creates a new pointer specifically for modifying the configuration while
emulation is in progress. Both the regular configuration dialog and the game
properties dialog now use the pointer Settings::config_values to focus edits to
the correct struct.
* settings: split Settings::values into two different structs
By splitting the settings into two mutually exclusive structs, it becomes easier,
as a developer, to determine how to use the Settings structs after per-game
configurations is merged. Other benefits include only duplicating the required
settings in memory.
* settings: move use_docked_mode to Controls group
`use_docked_mode` is set in the input settings and cannot be accessed from the
system settings. Grouping it with system settings causes it to be saved with
per-game settings, which may make transferring configs more difficult later on,
especially since docked mode cannot be set from within the game properties
dialog.
* configuration: Fix the other yuzu executables and a regression
In main.cpp, we have to get the title ID before the ROM is loaded, else the
renderer will reflect only the global settings and now the user's game specific
settings.
* settings: use a template to duplicate memory for each setting
Replaces the type of each variable in the Settings::Values struct with a new
class that allows basic data reading and writing. The new struct
Settings::Setting duplicates the data in memory and can manage global overrides
per each setting.
* configuration: correct add-ons config and swap settings when apropriate
Any add-ons interaction happens directly through the global values struct.
Swapping bewteen structs now also includes copying the necessary global configs
that cannot be changed nor saved in per-game settings. General and System config
menus now update based on whether it is viewing the global or per-game settings.
* settings: restore old values struct
No longer needed with the Settings::Setting class template.
* configuration: implement hierarchical game properties dialog
This sets the apropriate global or local data in each setting.
* clang format
* clang format take 2
can the docker container save this?
* address comments and style issues
* config: read and write settings with global awareness
Adds new functions to read and write settings while keeping the global state in
focus. Files now generated per-game are much smaller since often they only need
address the global state.
* settings: restore global state when necessary
Upon closing a game or the game properties dialog, we need to restore all global
settings to the original global state so that we can properly open the
configuration dialog or boot a different game.
* configuration: guard setting values incorrectly
This disables setting values while a game is running if the setting is
overwritten by a per game setting.
* config: don't write local settings in the global config
Simple guards to prevent writing the wrong settings in the wrong files.
* configuration: add comments, assume less, and clang format
No longer assumes that a disabled UI element means the global state is turned
off, instead opting to directly answer that question. Still however assumes a
game is running if it is in that state.
* configuration: fix a logic error
Should not be negated
* restore settings' global state regardless of accept/cancel
Fixes loading a properties dialog and causing the global config dialog to show
local settings.
* fix more logic errors
Fixed the frame limit would set the global setting from the game properties
dialog. Also strengthened the Settings::Setting member variables and simplified
the logic in config reading (ReadSettingGlobal).
* fix another logic error
In my efforts to guard RestoreGlobalState, I accidentally negated the IsPowered
condition.
* configure_audio: set toggle_stretched_audio to tristate
* fixed custom rtc and rng seed overwriting the global value
* clang format
* rebased
* clang format take 4
* address my own review
Basically revert unintended changes
* settings: literal instead of casting
"No need to cast, use 1U instead"
Thanks, Morph!
Co-authored-by: Morph <39850852+Morph1984@users.noreply.github.com>
* Revert "settings: literal instead of casting
"
This reverts commit 95e992a87c898f3e882ffdb415bb0ef9f80f613f.
* main: fix status buttons reporting wrong settings after stop emulation
* settings: Log UseDockedMode in the Controls group
This should have happened when use_docked_mode was moved over to the controls group
internally. This just reflects this in the log.
* main: load settings if the file has a title id
In other words, don't exit if the loader has trouble getting a title id.
* use a zero
* settings: initalize resolution factor with constructor instead of casting
* Revert "settings: initalize resolution factor with constructor instead of casting"
This reverts commit 54c35ecb46a29953842614620f9b7de1aa9d5dc8.
* configure_graphics: guard device selector when Vulkan is global
Prevents the user from editing the device selector if Vulkan is the global
renderer backend. Also resets the vulkan_device variable when the users
switches back-and-forth between global and Vulkan.
* address reviewer concerns
Changes function variables to const wherever they don't need to be changed. Sets Settings::Setting to final as it should not be inherited from. Sets ConfigurationShared::use_global_text to static.
Co-Authored-By: VolcaEM <volcaem@users.noreply.github.com>
* main: load per-game settings after LoadROM
This prevents `Restart Emulation` from restoring the global settings *after* the per-game settings were applied. Thanks to BSoDGamingYT for finding this bug.
* Revert "main: load per-game settings after LoadROM"
This reverts commit 9d0d48c52d2dcf3bfb1806cc8fa7d5a271a8a804.
* main: only restore global settings when necessary
Loading the per-game settings cannot happen after the ROM is loaded, so we have to specify when to restore the global state. Again thanks to BSoD for finding the bug.
* configuration_shared: address reviewer concerns except operator overrides
Dropping operator override usage in next commit.
Co-Authored-By: LC <lioncash@users.noreply.github.com>
* settings: Drop operator overrides from Setting template
Requires using GetValue and SetValue explicitly. Also reverts a change that broke title ID formatting in the game properties dialog.
* complete rebase
* configuration_shared: translate "Use global configuration"
Uses ConfigurePerGame to do so, since its usage, at least as of now, corresponds with ConfigurationShared.
* configure_per_game: address reviewer concern
As far as I understand, it prevents the program from unnecessarily copying strings.
Co-Authored-By: LC <lioncash@users.noreply.github.com>
Co-authored-by: Morph <39850852+Morph1984@users.noreply.github.com>
Co-authored-by: VolcaEM <volcaem@users.noreply.github.com>
Co-authored-by: LC <lioncash@users.noreply.github.com>
2020-07-09 19:42:09 -07:00
|
|
|
static_cast<u32>(Settings::values.resolution_factor.GetValue()));
|
2018-09-17 08:19:31 -07:00
|
|
|
}
|
|
|
|
|
2018-11-25 22:06:13 -08:00
|
|
|
rb.PushRaw<float>(60.0f); // This wouldn't seem to be correct for 30 fps games.
|
2018-09-17 08:19:31 -07:00
|
|
|
rb.Push<u32>(0);
|
|
|
|
}
|
2018-01-07 18:27:58 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
class IManagerDisplayService final : public ServiceFramework<IManagerDisplayService> {
|
|
|
|
public:
|
2020-11-26 12:19:08 -08:00
|
|
|
explicit IManagerDisplayService(Core::System& system_, NVFlinger::NVFlinger& nv_flinger_)
|
|
|
|
: ServiceFramework{system_, "IManagerDisplayService"}, nv_flinger{nv_flinger_} {
|
2019-11-12 05:54:58 -08:00
|
|
|
// clang-format off
|
2018-01-07 18:27:58 -08:00
|
|
|
static const FunctionInfo functions[] = {
|
2018-04-17 08:37:43 -07:00
|
|
|
{200, nullptr, "AllocateProcessHeapBlock"},
|
|
|
|
{201, nullptr, "FreeProcessHeapBlock"},
|
2018-01-14 22:29:00 -08:00
|
|
|
{1020, &IManagerDisplayService::CloseDisplay, "CloseDisplay"},
|
2018-01-07 18:27:58 -08:00
|
|
|
{1102, nullptr, "GetDisplayResolution"},
|
|
|
|
{2010, &IManagerDisplayService::CreateManagedLayer, "CreateManagedLayer"},
|
2018-04-17 08:37:43 -07:00
|
|
|
{2011, nullptr, "DestroyManagedLayer"},
|
2019-02-25 05:06:47 -08:00
|
|
|
{2012, nullptr, "CreateStrayLayer"},
|
2018-04-17 08:37:43 -07:00
|
|
|
{2050, nullptr, "CreateIndirectLayer"},
|
|
|
|
{2051, nullptr, "DestroyIndirectLayer"},
|
|
|
|
{2052, nullptr, "CreateIndirectProducerEndPoint"},
|
|
|
|
{2053, nullptr, "DestroyIndirectProducerEndPoint"},
|
|
|
|
{2054, nullptr, "CreateIndirectConsumerEndPoint"},
|
|
|
|
{2055, nullptr, "DestroyIndirectConsumerEndPoint"},
|
|
|
|
{2300, nullptr, "AcquireLayerTexturePresentingEvent"},
|
|
|
|
{2301, nullptr, "ReleaseLayerTexturePresentingEvent"},
|
|
|
|
{2302, nullptr, "GetDisplayHotplugEvent"},
|
2020-06-28 19:01:34 -07:00
|
|
|
{2303, nullptr, "GetDisplayModeChangedEvent"},
|
2018-04-17 08:37:43 -07:00
|
|
|
{2402, nullptr, "GetDisplayHotplugState"},
|
|
|
|
{2501, nullptr, "GetCompositorErrorInfo"},
|
|
|
|
{2601, nullptr, "GetDisplayErrorEvent"},
|
|
|
|
{4201, nullptr, "SetDisplayAlpha"},
|
|
|
|
{4203, nullptr, "SetDisplayLayerStack"},
|
|
|
|
{4205, nullptr, "SetDisplayPowerState"},
|
|
|
|
{4206, nullptr, "SetDefaultDisplay"},
|
2018-01-07 18:27:58 -08:00
|
|
|
{6000, &IManagerDisplayService::AddToLayerStack, "AddToLayerStack"},
|
2018-04-17 08:37:43 -07:00
|
|
|
{6001, nullptr, "RemoveFromLayerStack"},
|
2018-04-16 02:04:34 -07:00
|
|
|
{6002, &IManagerDisplayService::SetLayerVisibility, "SetLayerVisibility"},
|
2018-04-17 08:37:43 -07:00
|
|
|
{6003, nullptr, "SetLayerConfig"},
|
|
|
|
{6004, nullptr, "AttachLayerPresentationTracer"},
|
|
|
|
{6005, nullptr, "DetachLayerPresentationTracer"},
|
|
|
|
{6006, nullptr, "StartLayerPresentationRecording"},
|
|
|
|
{6007, nullptr, "StopLayerPresentationRecording"},
|
|
|
|
{6008, nullptr, "StartLayerPresentationFenceWait"},
|
|
|
|
{6009, nullptr, "StopLayerPresentationFenceWait"},
|
|
|
|
{6010, nullptr, "GetLayerPresentationAllFencesExpiredEvent"},
|
2019-11-12 05:54:58 -08:00
|
|
|
{6011, nullptr, "EnableLayerAutoClearTransitionBuffer"},
|
|
|
|
{6012, nullptr, "DisableLayerAutoClearTransitionBuffer"},
|
2018-04-17 08:37:43 -07:00
|
|
|
{7000, nullptr, "SetContentVisibility"},
|
|
|
|
{8000, nullptr, "SetConductorLayer"},
|
2019-11-12 05:54:58 -08:00
|
|
|
{8001, nullptr, "SetTimestampTracking"},
|
2018-04-17 08:37:43 -07:00
|
|
|
{8100, nullptr, "SetIndirectProducerFlipOffset"},
|
|
|
|
{8200, nullptr, "CreateSharedBufferStaticStorage"},
|
|
|
|
{8201, nullptr, "CreateSharedBufferTransferMemory"},
|
|
|
|
{8202, nullptr, "DestroySharedBuffer"},
|
|
|
|
{8203, nullptr, "BindSharedLowLevelLayerToManagedLayer"},
|
|
|
|
{8204, nullptr, "BindSharedLowLevelLayerToIndirectLayer"},
|
|
|
|
{8207, nullptr, "UnbindSharedLowLevelLayer"},
|
|
|
|
{8208, nullptr, "ConnectSharedLowLevelLayerToSharedBuffer"},
|
|
|
|
{8209, nullptr, "DisconnectSharedLowLevelLayerFromSharedBuffer"},
|
|
|
|
{8210, nullptr, "CreateSharedLayer"},
|
|
|
|
{8211, nullptr, "DestroySharedLayer"},
|
|
|
|
{8216, nullptr, "AttachSharedLayerToLowLevelLayer"},
|
|
|
|
{8217, nullptr, "ForceDetachSharedLayerFromLowLevelLayer"},
|
|
|
|
{8218, nullptr, "StartDetachSharedLayerFromLowLevelLayer"},
|
|
|
|
{8219, nullptr, "FinishDetachSharedLayerFromLowLevelLayer"},
|
|
|
|
{8220, nullptr, "GetSharedLayerDetachReadyEvent"},
|
|
|
|
{8221, nullptr, "GetSharedLowLevelLayerSynchronizedEvent"},
|
|
|
|
{8222, nullptr, "CheckSharedLowLevelLayerSynchronized"},
|
|
|
|
{8223, nullptr, "RegisterSharedBufferImporterAruid"},
|
|
|
|
{8224, nullptr, "UnregisterSharedBufferImporterAruid"},
|
|
|
|
{8227, nullptr, "CreateSharedBufferProcessHeap"},
|
|
|
|
{8228, nullptr, "GetSharedLayerLayerStacks"},
|
|
|
|
{8229, nullptr, "SetSharedLayerLayerStacks"},
|
|
|
|
{8291, nullptr, "PresentDetachedSharedFrameBufferToLowLevelLayer"},
|
|
|
|
{8292, nullptr, "FillDetachedSharedFrameBufferColor"},
|
|
|
|
{8293, nullptr, "GetDetachedSharedFrameBufferImage"},
|
|
|
|
{8294, nullptr, "SetDetachedSharedFrameBufferImage"},
|
|
|
|
{8295, nullptr, "CopyDetachedSharedFrameBufferImage"},
|
|
|
|
{8296, nullptr, "SetDetachedSharedFrameBufferSubImage"},
|
|
|
|
{8297, nullptr, "GetSharedFrameBufferContentParameter"},
|
|
|
|
{8298, nullptr, "ExpandStartupLogoOnSharedFrameBuffer"},
|
2018-01-07 18:27:58 -08:00
|
|
|
};
|
2019-11-12 05:54:58 -08:00
|
|
|
// clang-format on
|
|
|
|
|
2018-01-07 18:27:58 -08:00
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2018-01-14 22:29:00 -08:00
|
|
|
void CloseDisplay(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp{ctx};
|
2019-01-02 16:42:08 -08:00
|
|
|
const u64 display = rp.Pop<u64>();
|
|
|
|
|
|
|
|
LOG_WARNING(Service_VI, "(STUBBED) called. display=0x{:016X}", display);
|
2018-01-14 22:29:00 -08:00
|
|
|
|
2018-09-18 22:09:59 -07:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
2018-01-14 22:29:00 -08:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2018-01-07 18:27:58 -08:00
|
|
|
void CreateManagedLayer(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp{ctx};
|
2019-01-02 16:42:08 -08:00
|
|
|
const u32 unknown = rp.Pop<u32>();
|
2018-01-07 18:27:58 -08:00
|
|
|
rp.Skip(1, false);
|
2019-01-02 16:42:08 -08:00
|
|
|
const u64 display = rp.Pop<u64>();
|
|
|
|
const u64 aruid = rp.Pop<u64>();
|
2018-01-07 18:27:58 -08:00
|
|
|
|
2019-01-02 16:42:08 -08:00
|
|
|
LOG_WARNING(Service_VI,
|
|
|
|
"(STUBBED) called. unknown=0x{:08X}, display=0x{:016X}, aruid=0x{:016X}",
|
|
|
|
unknown, display, aruid);
|
|
|
|
|
2020-11-24 14:31:58 -08:00
|
|
|
const auto layer_id = nv_flinger.CreateLayer(display);
|
2019-02-05 13:20:04 -08:00
|
|
|
if (!layer_id) {
|
2020-04-28 18:15:21 -07:00
|
|
|
LOG_ERROR(Service_VI, "Layer not found! display=0x{:016X}", display);
|
2019-02-05 13:20:04 -08:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(ERR_NOT_FOUND);
|
|
|
|
return;
|
|
|
|
}
|
2018-01-08 15:18:50 -08:00
|
|
|
|
2018-09-18 22:09:59 -07:00
|
|
|
IPC::ResponseBuilder rb{ctx, 4};
|
2018-01-07 18:27:58 -08:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
2019-02-05 13:20:04 -08:00
|
|
|
rb.Push(*layer_id);
|
2018-01-07 18:27:58 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void AddToLayerStack(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp{ctx};
|
2019-01-02 16:42:08 -08:00
|
|
|
const u32 stack = rp.Pop<u32>();
|
|
|
|
const u64 layer_id = rp.Pop<u64>();
|
|
|
|
|
|
|
|
LOG_WARNING(Service_VI, "(STUBBED) called. stack=0x{:08X}, layer_id=0x{:016X}", stack,
|
|
|
|
layer_id);
|
2018-01-07 18:27:58 -08:00
|
|
|
|
2018-09-18 22:09:59 -07:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
2018-01-07 18:27:58 -08:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
2018-01-08 15:18:50 -08:00
|
|
|
|
2018-04-16 02:04:34 -07:00
|
|
|
void SetLayerVisibility(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp{ctx};
|
2019-01-02 16:42:08 -08:00
|
|
|
const u64 layer_id = rp.Pop<u64>();
|
|
|
|
const bool visibility = rp.Pop<bool>();
|
|
|
|
|
2018-07-02 09:13:26 -07:00
|
|
|
LOG_WARNING(Service_VI, "(STUBBED) called, layer_id=0x{:X}, visibility={}", layer_id,
|
2018-07-02 09:20:50 -07:00
|
|
|
visibility);
|
2018-11-25 22:06:13 -08:00
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2018-04-16 02:04:34 -07:00
|
|
|
}
|
|
|
|
|
2020-11-24 14:31:58 -08:00
|
|
|
NVFlinger::NVFlinger& nv_flinger;
|
2018-01-07 18:27:58 -08:00
|
|
|
};
|
|
|
|
|
2018-03-21 03:09:40 -07:00
|
|
|
class IApplicationDisplayService final : public ServiceFramework<IApplicationDisplayService> {
|
|
|
|
public:
|
2020-11-26 12:19:08 -08:00
|
|
|
explicit IApplicationDisplayService(Core::System& system_, NVFlinger::NVFlinger& nv_flinger_);
|
2018-01-07 18:27:58 -08:00
|
|
|
|
2018-03-21 03:09:40 -07:00
|
|
|
private:
|
2019-01-04 16:31:14 -08:00
|
|
|
enum class ConvertedScaleMode : u64 {
|
2019-01-04 17:32:29 -08:00
|
|
|
Freeze = 0,
|
|
|
|
ScaleToWindow = 1,
|
|
|
|
ScaleAndCrop = 2,
|
|
|
|
None = 3,
|
|
|
|
PreserveAspectRatio = 4,
|
2019-01-04 16:31:14 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
enum class NintendoScaleMode : u32 {
|
|
|
|
None = 0,
|
|
|
|
Freeze = 1,
|
|
|
|
ScaleToWindow = 2,
|
2019-01-04 17:32:29 -08:00
|
|
|
ScaleAndCrop = 3,
|
|
|
|
PreserveAspectRatio = 4,
|
2019-01-04 16:31:14 -08:00
|
|
|
};
|
|
|
|
|
2018-03-21 03:09:40 -07:00
|
|
|
void GetRelayService(Kernel::HLERequestContext& ctx) {
|
2018-07-02 09:13:26 -07:00
|
|
|
LOG_WARNING(Service_VI, "(STUBBED) called");
|
2018-01-07 18:27:58 -08:00
|
|
|
|
2018-03-21 03:09:40 -07:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2020-11-26 12:19:08 -08:00
|
|
|
rb.PushIpcInterface<IHOSBinderDriver>(system, nv_flinger);
|
2018-03-21 03:09:40 -07:00
|
|
|
}
|
2018-01-07 18:27:58 -08:00
|
|
|
|
2018-03-21 03:09:40 -07:00
|
|
|
void GetSystemDisplayService(Kernel::HLERequestContext& ctx) {
|
2018-07-02 09:13:26 -07:00
|
|
|
LOG_WARNING(Service_VI, "(STUBBED) called");
|
2018-01-07 18:27:58 -08:00
|
|
|
|
2018-03-21 03:09:40 -07:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2020-11-26 12:19:08 -08:00
|
|
|
rb.PushIpcInterface<ISystemDisplayService>(system);
|
2018-03-21 03:09:40 -07:00
|
|
|
}
|
2018-01-07 18:27:58 -08:00
|
|
|
|
2018-03-21 03:09:40 -07:00
|
|
|
void GetManagerDisplayService(Kernel::HLERequestContext& ctx) {
|
2018-07-02 09:13:26 -07:00
|
|
|
LOG_WARNING(Service_VI, "(STUBBED) called");
|
2018-01-07 18:27:58 -08:00
|
|
|
|
2018-03-21 03:09:40 -07:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2020-11-26 12:19:08 -08:00
|
|
|
rb.PushIpcInterface<IManagerDisplayService>(system, nv_flinger);
|
2018-03-21 03:09:40 -07:00
|
|
|
}
|
2018-01-15 14:20:08 -08:00
|
|
|
|
2018-03-21 03:09:40 -07:00
|
|
|
void GetIndirectDisplayTransactionService(Kernel::HLERequestContext& ctx) {
|
2018-07-02 09:13:26 -07:00
|
|
|
LOG_WARNING(Service_VI, "(STUBBED) called");
|
2018-01-15 14:20:08 -08:00
|
|
|
|
2018-03-21 03:09:40 -07:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2020-11-26 12:19:08 -08:00
|
|
|
rb.PushIpcInterface<IHOSBinderDriver>(system, nv_flinger);
|
2018-03-21 03:09:40 -07:00
|
|
|
}
|
2018-01-08 15:18:50 -08:00
|
|
|
|
2018-03-21 03:09:40 -07:00
|
|
|
void OpenDisplay(Kernel::HLERequestContext& ctx) {
|
2018-07-02 09:13:26 -07:00
|
|
|
LOG_WARNING(Service_VI, "(STUBBED) called");
|
2018-11-25 22:06:13 -08:00
|
|
|
|
2018-03-21 03:09:40 -07:00
|
|
|
IPC::RequestParser rp{ctx};
|
2019-01-02 15:05:15 -08:00
|
|
|
const auto name_buf = rp.PopRaw<std::array<char, 0x40>>();
|
2018-01-08 15:18:50 -08:00
|
|
|
|
2019-01-02 15:05:15 -08:00
|
|
|
OpenDisplayImpl(ctx, std::string_view{name_buf.data(), name_buf.size()});
|
|
|
|
}
|
|
|
|
|
|
|
|
void OpenDefaultDisplay(Kernel::HLERequestContext& ctx) {
|
|
|
|
LOG_DEBUG(Service_VI, "called");
|
|
|
|
|
|
|
|
OpenDisplayImpl(ctx, "Default");
|
|
|
|
}
|
2018-01-08 15:18:50 -08:00
|
|
|
|
2019-01-02 15:05:15 -08:00
|
|
|
void OpenDisplayImpl(Kernel::HLERequestContext& ctx, std::string_view name) {
|
|
|
|
const auto trim_pos = name.find('\0');
|
|
|
|
|
|
|
|
if (trim_pos != std::string_view::npos) {
|
|
|
|
name.remove_suffix(name.size() - trim_pos);
|
|
|
|
}
|
2018-01-07 18:27:58 -08:00
|
|
|
|
2018-03-21 03:09:40 -07:00
|
|
|
ASSERT_MSG(name == "Default", "Non-default displays aren't supported yet");
|
2018-01-07 18:27:58 -08:00
|
|
|
|
2020-11-24 14:31:58 -08:00
|
|
|
const auto display_id = nv_flinger.OpenDisplay(name);
|
2019-02-05 13:20:04 -08:00
|
|
|
if (!display_id) {
|
2020-04-28 18:15:21 -07:00
|
|
|
LOG_ERROR(Service_VI, "Display not found! display_name={}", name);
|
2019-02-05 13:20:04 -08:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(ERR_NOT_FOUND);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-09-18 22:09:59 -07:00
|
|
|
IPC::ResponseBuilder rb{ctx, 4};
|
2018-03-21 03:09:40 -07:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
2019-02-05 13:20:04 -08:00
|
|
|
rb.Push<u64>(*display_id);
|
2018-03-21 03:09:40 -07:00
|
|
|
}
|
2018-01-15 14:20:08 -08:00
|
|
|
|
2018-03-21 03:09:40 -07:00
|
|
|
void CloseDisplay(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp{ctx};
|
2019-01-02 16:42:08 -08:00
|
|
|
const u64 display_id = rp.Pop<u64>();
|
|
|
|
|
|
|
|
LOG_WARNING(Service_VI, "(STUBBED) called. display_id=0x{:016X}", display_id);
|
2018-01-15 14:20:08 -08:00
|
|
|
|
2018-09-18 22:09:59 -07:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
2018-03-21 03:09:40 -07:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
2018-01-08 15:18:50 -08:00
|
|
|
|
2019-01-02 17:45:40 -08:00
|
|
|
// This literally does nothing internally in the actual service itself,
|
|
|
|
// and just returns a successful result code regardless of the input.
|
|
|
|
void SetDisplayEnabled(Kernel::HLERequestContext& ctx) {
|
|
|
|
LOG_DEBUG(Service_VI, "called.");
|
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2018-04-02 20:28:45 -07:00
|
|
|
void GetDisplayResolution(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp{ctx};
|
2019-01-02 16:42:08 -08:00
|
|
|
const u64 display_id = rp.Pop<u64>();
|
|
|
|
|
2019-01-04 15:43:15 -08:00
|
|
|
LOG_DEBUG(Service_VI, "called. display_id=0x{:016X}", display_id);
|
2018-04-02 20:28:45 -07:00
|
|
|
|
2018-09-18 22:09:59 -07:00
|
|
|
IPC::ResponseBuilder rb{ctx, 6};
|
2018-04-02 20:28:45 -07:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
|
2019-01-04 15:43:15 -08:00
|
|
|
// This only returns the fixed values of 1280x720 and makes no distinguishing
|
|
|
|
// between docked and undocked dimensions. We take the liberty of applying
|
|
|
|
// the resolution scaling factor here.
|
|
|
|
rb.Push(static_cast<u64>(DisplayResolution::UndockedWidth) *
|
configuration: implement per-game configurations (#4098)
* Switch game settings to use a pointer
In order to add full per-game settings, we need to be able to tell yuzu to switch
to using either the global or game configuration. Using a pointer makes it easier
to switch.
* configuration: add new UI without changing existing funcitonality
The new UI also adds General, System, Graphics, Advanced Graphics,
and Audio tabs, but as yet they do nothing. This commit keeps yuzu
to the same functionality as originally branched.
* configuration: Rename files
These weren't included in the last commit. Now they are.
* configuration: setup global configuration checkbox
Global config checkbox now enables/disables the appropriate tabs in the game
properties dialog. The use global configuration setting is now saved to the
config, defaulting to true. This also addresses some changes requested in the PR.
* configuration: swap to per-game config memory for properties dialog
Does not set memory going in-game. Swaps to game values when opening the
properties dialog, then swaps back when closing it. Uses a `memcpy` to swap.
Also implements saving config files, limited to certain groups of configurations
so as to not risk setting unsafe configurations.
* configuration: change config interfaces to use config-specific pointers
When a game is booted, we need to be able to open the configuration dialogs
without changing the settings pointer in the game's emualtion. A new pointer
specific to just the configuration dialogs can be used to separate changes
to just those config dialogs without affecting the emulation.
* configuration: boot a game using per-game settings
Swaps values where needed to boot a game.
* configuration: user correct config during emulation
Creates a new pointer specifically for modifying the configuration while
emulation is in progress. Both the regular configuration dialog and the game
properties dialog now use the pointer Settings::config_values to focus edits to
the correct struct.
* settings: split Settings::values into two different structs
By splitting the settings into two mutually exclusive structs, it becomes easier,
as a developer, to determine how to use the Settings structs after per-game
configurations is merged. Other benefits include only duplicating the required
settings in memory.
* settings: move use_docked_mode to Controls group
`use_docked_mode` is set in the input settings and cannot be accessed from the
system settings. Grouping it with system settings causes it to be saved with
per-game settings, which may make transferring configs more difficult later on,
especially since docked mode cannot be set from within the game properties
dialog.
* configuration: Fix the other yuzu executables and a regression
In main.cpp, we have to get the title ID before the ROM is loaded, else the
renderer will reflect only the global settings and now the user's game specific
settings.
* settings: use a template to duplicate memory for each setting
Replaces the type of each variable in the Settings::Values struct with a new
class that allows basic data reading and writing. The new struct
Settings::Setting duplicates the data in memory and can manage global overrides
per each setting.
* configuration: correct add-ons config and swap settings when apropriate
Any add-ons interaction happens directly through the global values struct.
Swapping bewteen structs now also includes copying the necessary global configs
that cannot be changed nor saved in per-game settings. General and System config
menus now update based on whether it is viewing the global or per-game settings.
* settings: restore old values struct
No longer needed with the Settings::Setting class template.
* configuration: implement hierarchical game properties dialog
This sets the apropriate global or local data in each setting.
* clang format
* clang format take 2
can the docker container save this?
* address comments and style issues
* config: read and write settings with global awareness
Adds new functions to read and write settings while keeping the global state in
focus. Files now generated per-game are much smaller since often they only need
address the global state.
* settings: restore global state when necessary
Upon closing a game or the game properties dialog, we need to restore all global
settings to the original global state so that we can properly open the
configuration dialog or boot a different game.
* configuration: guard setting values incorrectly
This disables setting values while a game is running if the setting is
overwritten by a per game setting.
* config: don't write local settings in the global config
Simple guards to prevent writing the wrong settings in the wrong files.
* configuration: add comments, assume less, and clang format
No longer assumes that a disabled UI element means the global state is turned
off, instead opting to directly answer that question. Still however assumes a
game is running if it is in that state.
* configuration: fix a logic error
Should not be negated
* restore settings' global state regardless of accept/cancel
Fixes loading a properties dialog and causing the global config dialog to show
local settings.
* fix more logic errors
Fixed the frame limit would set the global setting from the game properties
dialog. Also strengthened the Settings::Setting member variables and simplified
the logic in config reading (ReadSettingGlobal).
* fix another logic error
In my efforts to guard RestoreGlobalState, I accidentally negated the IsPowered
condition.
* configure_audio: set toggle_stretched_audio to tristate
* fixed custom rtc and rng seed overwriting the global value
* clang format
* rebased
* clang format take 4
* address my own review
Basically revert unintended changes
* settings: literal instead of casting
"No need to cast, use 1U instead"
Thanks, Morph!
Co-authored-by: Morph <39850852+Morph1984@users.noreply.github.com>
* Revert "settings: literal instead of casting
"
This reverts commit 95e992a87c898f3e882ffdb415bb0ef9f80f613f.
* main: fix status buttons reporting wrong settings after stop emulation
* settings: Log UseDockedMode in the Controls group
This should have happened when use_docked_mode was moved over to the controls group
internally. This just reflects this in the log.
* main: load settings if the file has a title id
In other words, don't exit if the loader has trouble getting a title id.
* use a zero
* settings: initalize resolution factor with constructor instead of casting
* Revert "settings: initalize resolution factor with constructor instead of casting"
This reverts commit 54c35ecb46a29953842614620f9b7de1aa9d5dc8.
* configure_graphics: guard device selector when Vulkan is global
Prevents the user from editing the device selector if Vulkan is the global
renderer backend. Also resets the vulkan_device variable when the users
switches back-and-forth between global and Vulkan.
* address reviewer concerns
Changes function variables to const wherever they don't need to be changed. Sets Settings::Setting to final as it should not be inherited from. Sets ConfigurationShared::use_global_text to static.
Co-Authored-By: VolcaEM <volcaem@users.noreply.github.com>
* main: load per-game settings after LoadROM
This prevents `Restart Emulation` from restoring the global settings *after* the per-game settings were applied. Thanks to BSoDGamingYT for finding this bug.
* Revert "main: load per-game settings after LoadROM"
This reverts commit 9d0d48c52d2dcf3bfb1806cc8fa7d5a271a8a804.
* main: only restore global settings when necessary
Loading the per-game settings cannot happen after the ROM is loaded, so we have to specify when to restore the global state. Again thanks to BSoD for finding the bug.
* configuration_shared: address reviewer concerns except operator overrides
Dropping operator override usage in next commit.
Co-Authored-By: LC <lioncash@users.noreply.github.com>
* settings: Drop operator overrides from Setting template
Requires using GetValue and SetValue explicitly. Also reverts a change that broke title ID formatting in the game properties dialog.
* complete rebase
* configuration_shared: translate "Use global configuration"
Uses ConfigurePerGame to do so, since its usage, at least as of now, corresponds with ConfigurationShared.
* configure_per_game: address reviewer concern
As far as I understand, it prevents the program from unnecessarily copying strings.
Co-Authored-By: LC <lioncash@users.noreply.github.com>
Co-authored-by: Morph <39850852+Morph1984@users.noreply.github.com>
Co-authored-by: VolcaEM <volcaem@users.noreply.github.com>
Co-authored-by: LC <lioncash@users.noreply.github.com>
2020-07-09 19:42:09 -07:00
|
|
|
static_cast<u32>(Settings::values.resolution_factor.GetValue()));
|
2019-01-04 15:43:15 -08:00
|
|
|
rb.Push(static_cast<u64>(DisplayResolution::UndockedHeight) *
|
configuration: implement per-game configurations (#4098)
* Switch game settings to use a pointer
In order to add full per-game settings, we need to be able to tell yuzu to switch
to using either the global or game configuration. Using a pointer makes it easier
to switch.
* configuration: add new UI without changing existing funcitonality
The new UI also adds General, System, Graphics, Advanced Graphics,
and Audio tabs, but as yet they do nothing. This commit keeps yuzu
to the same functionality as originally branched.
* configuration: Rename files
These weren't included in the last commit. Now they are.
* configuration: setup global configuration checkbox
Global config checkbox now enables/disables the appropriate tabs in the game
properties dialog. The use global configuration setting is now saved to the
config, defaulting to true. This also addresses some changes requested in the PR.
* configuration: swap to per-game config memory for properties dialog
Does not set memory going in-game. Swaps to game values when opening the
properties dialog, then swaps back when closing it. Uses a `memcpy` to swap.
Also implements saving config files, limited to certain groups of configurations
so as to not risk setting unsafe configurations.
* configuration: change config interfaces to use config-specific pointers
When a game is booted, we need to be able to open the configuration dialogs
without changing the settings pointer in the game's emualtion. A new pointer
specific to just the configuration dialogs can be used to separate changes
to just those config dialogs without affecting the emulation.
* configuration: boot a game using per-game settings
Swaps values where needed to boot a game.
* configuration: user correct config during emulation
Creates a new pointer specifically for modifying the configuration while
emulation is in progress. Both the regular configuration dialog and the game
properties dialog now use the pointer Settings::config_values to focus edits to
the correct struct.
* settings: split Settings::values into two different structs
By splitting the settings into two mutually exclusive structs, it becomes easier,
as a developer, to determine how to use the Settings structs after per-game
configurations is merged. Other benefits include only duplicating the required
settings in memory.
* settings: move use_docked_mode to Controls group
`use_docked_mode` is set in the input settings and cannot be accessed from the
system settings. Grouping it with system settings causes it to be saved with
per-game settings, which may make transferring configs more difficult later on,
especially since docked mode cannot be set from within the game properties
dialog.
* configuration: Fix the other yuzu executables and a regression
In main.cpp, we have to get the title ID before the ROM is loaded, else the
renderer will reflect only the global settings and now the user's game specific
settings.
* settings: use a template to duplicate memory for each setting
Replaces the type of each variable in the Settings::Values struct with a new
class that allows basic data reading and writing. The new struct
Settings::Setting duplicates the data in memory and can manage global overrides
per each setting.
* configuration: correct add-ons config and swap settings when apropriate
Any add-ons interaction happens directly through the global values struct.
Swapping bewteen structs now also includes copying the necessary global configs
that cannot be changed nor saved in per-game settings. General and System config
menus now update based on whether it is viewing the global or per-game settings.
* settings: restore old values struct
No longer needed with the Settings::Setting class template.
* configuration: implement hierarchical game properties dialog
This sets the apropriate global or local data in each setting.
* clang format
* clang format take 2
can the docker container save this?
* address comments and style issues
* config: read and write settings with global awareness
Adds new functions to read and write settings while keeping the global state in
focus. Files now generated per-game are much smaller since often they only need
address the global state.
* settings: restore global state when necessary
Upon closing a game or the game properties dialog, we need to restore all global
settings to the original global state so that we can properly open the
configuration dialog or boot a different game.
* configuration: guard setting values incorrectly
This disables setting values while a game is running if the setting is
overwritten by a per game setting.
* config: don't write local settings in the global config
Simple guards to prevent writing the wrong settings in the wrong files.
* configuration: add comments, assume less, and clang format
No longer assumes that a disabled UI element means the global state is turned
off, instead opting to directly answer that question. Still however assumes a
game is running if it is in that state.
* configuration: fix a logic error
Should not be negated
* restore settings' global state regardless of accept/cancel
Fixes loading a properties dialog and causing the global config dialog to show
local settings.
* fix more logic errors
Fixed the frame limit would set the global setting from the game properties
dialog. Also strengthened the Settings::Setting member variables and simplified
the logic in config reading (ReadSettingGlobal).
* fix another logic error
In my efforts to guard RestoreGlobalState, I accidentally negated the IsPowered
condition.
* configure_audio: set toggle_stretched_audio to tristate
* fixed custom rtc and rng seed overwriting the global value
* clang format
* rebased
* clang format take 4
* address my own review
Basically revert unintended changes
* settings: literal instead of casting
"No need to cast, use 1U instead"
Thanks, Morph!
Co-authored-by: Morph <39850852+Morph1984@users.noreply.github.com>
* Revert "settings: literal instead of casting
"
This reverts commit 95e992a87c898f3e882ffdb415bb0ef9f80f613f.
* main: fix status buttons reporting wrong settings after stop emulation
* settings: Log UseDockedMode in the Controls group
This should have happened when use_docked_mode was moved over to the controls group
internally. This just reflects this in the log.
* main: load settings if the file has a title id
In other words, don't exit if the loader has trouble getting a title id.
* use a zero
* settings: initalize resolution factor with constructor instead of casting
* Revert "settings: initalize resolution factor with constructor instead of casting"
This reverts commit 54c35ecb46a29953842614620f9b7de1aa9d5dc8.
* configure_graphics: guard device selector when Vulkan is global
Prevents the user from editing the device selector if Vulkan is the global
renderer backend. Also resets the vulkan_device variable when the users
switches back-and-forth between global and Vulkan.
* address reviewer concerns
Changes function variables to const wherever they don't need to be changed. Sets Settings::Setting to final as it should not be inherited from. Sets ConfigurationShared::use_global_text to static.
Co-Authored-By: VolcaEM <volcaem@users.noreply.github.com>
* main: load per-game settings after LoadROM
This prevents `Restart Emulation` from restoring the global settings *after* the per-game settings were applied. Thanks to BSoDGamingYT for finding this bug.
* Revert "main: load per-game settings after LoadROM"
This reverts commit 9d0d48c52d2dcf3bfb1806cc8fa7d5a271a8a804.
* main: only restore global settings when necessary
Loading the per-game settings cannot happen after the ROM is loaded, so we have to specify when to restore the global state. Again thanks to BSoD for finding the bug.
* configuration_shared: address reviewer concerns except operator overrides
Dropping operator override usage in next commit.
Co-Authored-By: LC <lioncash@users.noreply.github.com>
* settings: Drop operator overrides from Setting template
Requires using GetValue and SetValue explicitly. Also reverts a change that broke title ID formatting in the game properties dialog.
* complete rebase
* configuration_shared: translate "Use global configuration"
Uses ConfigurePerGame to do so, since its usage, at least as of now, corresponds with ConfigurationShared.
* configure_per_game: address reviewer concern
As far as I understand, it prevents the program from unnecessarily copying strings.
Co-Authored-By: LC <lioncash@users.noreply.github.com>
Co-authored-by: Morph <39850852+Morph1984@users.noreply.github.com>
Co-authored-by: VolcaEM <volcaem@users.noreply.github.com>
Co-authored-by: LC <lioncash@users.noreply.github.com>
2020-07-09 19:42:09 -07:00
|
|
|
static_cast<u32>(Settings::values.resolution_factor.GetValue()));
|
2018-04-02 20:28:45 -07:00
|
|
|
}
|
|
|
|
|
2018-03-21 03:09:40 -07:00
|
|
|
void SetLayerScalingMode(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp{ctx};
|
2019-01-04 16:31:14 -08:00
|
|
|
const auto scaling_mode = rp.PopEnum<NintendoScaleMode>();
|
2019-01-02 16:42:08 -08:00
|
|
|
const u64 unknown = rp.Pop<u64>();
|
|
|
|
|
2020-12-07 19:00:34 -08:00
|
|
|
LOG_DEBUG(Service_VI, "called. scaling_mode=0x{:08X}, unknown=0x{:016X}", scaling_mode,
|
|
|
|
unknown);
|
2018-01-08 15:18:50 -08:00
|
|
|
|
2018-09-18 22:09:59 -07:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
2019-01-04 16:31:14 -08:00
|
|
|
|
2019-01-04 17:32:29 -08:00
|
|
|
if (scaling_mode > NintendoScaleMode::PreserveAspectRatio) {
|
2019-01-04 16:31:14 -08:00
|
|
|
LOG_ERROR(Service_VI, "Invalid scaling mode provided.");
|
|
|
|
rb.Push(ERR_OPERATION_FAILED);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (scaling_mode != NintendoScaleMode::ScaleToWindow &&
|
2019-01-04 17:32:29 -08:00
|
|
|
scaling_mode != NintendoScaleMode::PreserveAspectRatio) {
|
2019-01-04 16:31:14 -08:00
|
|
|
LOG_ERROR(Service_VI, "Unsupported scaling mode supplied.");
|
|
|
|
rb.Push(ERR_UNSUPPORTED);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-03-21 03:09:40 -07:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
2018-01-07 18:27:58 -08:00
|
|
|
|
2018-03-21 03:09:40 -07:00
|
|
|
void ListDisplays(Kernel::HLERequestContext& ctx) {
|
2018-11-25 22:06:13 -08:00
|
|
|
LOG_WARNING(Service_VI, "(STUBBED) called");
|
|
|
|
|
2018-03-21 03:09:40 -07:00
|
|
|
DisplayInfo display_info;
|
configuration: implement per-game configurations (#4098)
* Switch game settings to use a pointer
In order to add full per-game settings, we need to be able to tell yuzu to switch
to using either the global or game configuration. Using a pointer makes it easier
to switch.
* configuration: add new UI without changing existing funcitonality
The new UI also adds General, System, Graphics, Advanced Graphics,
and Audio tabs, but as yet they do nothing. This commit keeps yuzu
to the same functionality as originally branched.
* configuration: Rename files
These weren't included in the last commit. Now they are.
* configuration: setup global configuration checkbox
Global config checkbox now enables/disables the appropriate tabs in the game
properties dialog. The use global configuration setting is now saved to the
config, defaulting to true. This also addresses some changes requested in the PR.
* configuration: swap to per-game config memory for properties dialog
Does not set memory going in-game. Swaps to game values when opening the
properties dialog, then swaps back when closing it. Uses a `memcpy` to swap.
Also implements saving config files, limited to certain groups of configurations
so as to not risk setting unsafe configurations.
* configuration: change config interfaces to use config-specific pointers
When a game is booted, we need to be able to open the configuration dialogs
without changing the settings pointer in the game's emualtion. A new pointer
specific to just the configuration dialogs can be used to separate changes
to just those config dialogs without affecting the emulation.
* configuration: boot a game using per-game settings
Swaps values where needed to boot a game.
* configuration: user correct config during emulation
Creates a new pointer specifically for modifying the configuration while
emulation is in progress. Both the regular configuration dialog and the game
properties dialog now use the pointer Settings::config_values to focus edits to
the correct struct.
* settings: split Settings::values into two different structs
By splitting the settings into two mutually exclusive structs, it becomes easier,
as a developer, to determine how to use the Settings structs after per-game
configurations is merged. Other benefits include only duplicating the required
settings in memory.
* settings: move use_docked_mode to Controls group
`use_docked_mode` is set in the input settings and cannot be accessed from the
system settings. Grouping it with system settings causes it to be saved with
per-game settings, which may make transferring configs more difficult later on,
especially since docked mode cannot be set from within the game properties
dialog.
* configuration: Fix the other yuzu executables and a regression
In main.cpp, we have to get the title ID before the ROM is loaded, else the
renderer will reflect only the global settings and now the user's game specific
settings.
* settings: use a template to duplicate memory for each setting
Replaces the type of each variable in the Settings::Values struct with a new
class that allows basic data reading and writing. The new struct
Settings::Setting duplicates the data in memory and can manage global overrides
per each setting.
* configuration: correct add-ons config and swap settings when apropriate
Any add-ons interaction happens directly through the global values struct.
Swapping bewteen structs now also includes copying the necessary global configs
that cannot be changed nor saved in per-game settings. General and System config
menus now update based on whether it is viewing the global or per-game settings.
* settings: restore old values struct
No longer needed with the Settings::Setting class template.
* configuration: implement hierarchical game properties dialog
This sets the apropriate global or local data in each setting.
* clang format
* clang format take 2
can the docker container save this?
* address comments and style issues
* config: read and write settings with global awareness
Adds new functions to read and write settings while keeping the global state in
focus. Files now generated per-game are much smaller since often they only need
address the global state.
* settings: restore global state when necessary
Upon closing a game or the game properties dialog, we need to restore all global
settings to the original global state so that we can properly open the
configuration dialog or boot a different game.
* configuration: guard setting values incorrectly
This disables setting values while a game is running if the setting is
overwritten by a per game setting.
* config: don't write local settings in the global config
Simple guards to prevent writing the wrong settings in the wrong files.
* configuration: add comments, assume less, and clang format
No longer assumes that a disabled UI element means the global state is turned
off, instead opting to directly answer that question. Still however assumes a
game is running if it is in that state.
* configuration: fix a logic error
Should not be negated
* restore settings' global state regardless of accept/cancel
Fixes loading a properties dialog and causing the global config dialog to show
local settings.
* fix more logic errors
Fixed the frame limit would set the global setting from the game properties
dialog. Also strengthened the Settings::Setting member variables and simplified
the logic in config reading (ReadSettingGlobal).
* fix another logic error
In my efforts to guard RestoreGlobalState, I accidentally negated the IsPowered
condition.
* configure_audio: set toggle_stretched_audio to tristate
* fixed custom rtc and rng seed overwriting the global value
* clang format
* rebased
* clang format take 4
* address my own review
Basically revert unintended changes
* settings: literal instead of casting
"No need to cast, use 1U instead"
Thanks, Morph!
Co-authored-by: Morph <39850852+Morph1984@users.noreply.github.com>
* Revert "settings: literal instead of casting
"
This reverts commit 95e992a87c898f3e882ffdb415bb0ef9f80f613f.
* main: fix status buttons reporting wrong settings after stop emulation
* settings: Log UseDockedMode in the Controls group
This should have happened when use_docked_mode was moved over to the controls group
internally. This just reflects this in the log.
* main: load settings if the file has a title id
In other words, don't exit if the loader has trouble getting a title id.
* use a zero
* settings: initalize resolution factor with constructor instead of casting
* Revert "settings: initalize resolution factor with constructor instead of casting"
This reverts commit 54c35ecb46a29953842614620f9b7de1aa9d5dc8.
* configure_graphics: guard device selector when Vulkan is global
Prevents the user from editing the device selector if Vulkan is the global
renderer backend. Also resets the vulkan_device variable when the users
switches back-and-forth between global and Vulkan.
* address reviewer concerns
Changes function variables to const wherever they don't need to be changed. Sets Settings::Setting to final as it should not be inherited from. Sets ConfigurationShared::use_global_text to static.
Co-Authored-By: VolcaEM <volcaem@users.noreply.github.com>
* main: load per-game settings after LoadROM
This prevents `Restart Emulation` from restoring the global settings *after* the per-game settings were applied. Thanks to BSoDGamingYT for finding this bug.
* Revert "main: load per-game settings after LoadROM"
This reverts commit 9d0d48c52d2dcf3bfb1806cc8fa7d5a271a8a804.
* main: only restore global settings when necessary
Loading the per-game settings cannot happen after the ROM is loaded, so we have to specify when to restore the global state. Again thanks to BSoD for finding the bug.
* configuration_shared: address reviewer concerns except operator overrides
Dropping operator override usage in next commit.
Co-Authored-By: LC <lioncash@users.noreply.github.com>
* settings: Drop operator overrides from Setting template
Requires using GetValue and SetValue explicitly. Also reverts a change that broke title ID formatting in the game properties dialog.
* complete rebase
* configuration_shared: translate "Use global configuration"
Uses ConfigurePerGame to do so, since its usage, at least as of now, corresponds with ConfigurationShared.
* configure_per_game: address reviewer concern
As far as I understand, it prevents the program from unnecessarily copying strings.
Co-Authored-By: LC <lioncash@users.noreply.github.com>
Co-authored-by: Morph <39850852+Morph1984@users.noreply.github.com>
Co-authored-by: VolcaEM <volcaem@users.noreply.github.com>
Co-authored-by: LC <lioncash@users.noreply.github.com>
2020-07-09 19:42:09 -07:00
|
|
|
display_info.width *= static_cast<u64>(Settings::values.resolution_factor.GetValue());
|
|
|
|
display_info.height *= static_cast<u64>(Settings::values.resolution_factor.GetValue());
|
2018-03-21 03:09:40 -07:00
|
|
|
ctx.WriteBuffer(&display_info, sizeof(DisplayInfo));
|
2018-09-18 22:09:59 -07:00
|
|
|
IPC::ResponseBuilder rb{ctx, 4};
|
2018-03-21 03:09:40 -07:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.Push<u64>(1);
|
|
|
|
}
|
2018-01-08 15:18:50 -08:00
|
|
|
|
2018-03-21 03:09:40 -07:00
|
|
|
void OpenLayer(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp{ctx};
|
2019-01-02 16:42:08 -08:00
|
|
|
const auto name_buf = rp.PopRaw<std::array<u8, 0x40>>();
|
|
|
|
const auto end = std::find(name_buf.begin(), name_buf.end(), '\0');
|
2018-01-07 18:27:58 -08:00
|
|
|
|
2019-01-02 16:42:08 -08:00
|
|
|
const std::string display_name(name_buf.begin(), end);
|
2018-01-15 14:20:08 -08:00
|
|
|
|
2019-01-02 16:42:08 -08:00
|
|
|
const u64 layer_id = rp.Pop<u64>();
|
|
|
|
const u64 aruid = rp.Pop<u64>();
|
2018-01-15 14:20:08 -08:00
|
|
|
|
2019-01-02 16:42:08 -08:00
|
|
|
LOG_DEBUG(Service_VI, "called. layer_id=0x{:016X}, aruid=0x{:016X}", layer_id, aruid);
|
|
|
|
|
2020-11-24 14:31:58 -08:00
|
|
|
const auto display_id = nv_flinger.OpenDisplay(display_name);
|
2019-02-05 13:20:04 -08:00
|
|
|
if (!display_id) {
|
2020-04-28 18:15:21 -07:00
|
|
|
LOG_ERROR(Service_VI, "Layer not found! layer_id={}", layer_id);
|
2019-02-05 13:20:04 -08:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(ERR_NOT_FOUND);
|
|
|
|
return;
|
|
|
|
}
|
2018-01-15 14:20:08 -08:00
|
|
|
|
2020-11-24 14:31:58 -08:00
|
|
|
const auto buffer_queue_id = nv_flinger.FindBufferQueueId(*display_id, layer_id);
|
2019-02-05 13:20:04 -08:00
|
|
|
if (!buffer_queue_id) {
|
2020-04-28 18:15:21 -07:00
|
|
|
LOG_ERROR(Service_VI, "Buffer queue id not found! display_id={}", *display_id);
|
2019-02-05 13:20:04 -08:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(ERR_NOT_FOUND);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
NativeWindow native_window{*buffer_queue_id};
|
2018-09-18 22:09:59 -07:00
|
|
|
IPC::ResponseBuilder rb{ctx, 4};
|
2018-03-21 03:09:40 -07:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.Push<u64>(ctx.WriteBuffer(native_window.Serialize()));
|
|
|
|
}
|
2018-01-15 14:20:08 -08:00
|
|
|
|
2020-01-03 21:45:06 -08:00
|
|
|
void CloseLayer(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp{ctx};
|
|
|
|
const auto layer_id{rp.Pop<u64>()};
|
|
|
|
|
|
|
|
LOG_DEBUG(Service_VI, "called. layer_id=0x{:016X}", layer_id);
|
|
|
|
|
2020-11-24 14:31:58 -08:00
|
|
|
nv_flinger.CloseLayer(layer_id);
|
2020-01-03 21:45:06 -08:00
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2018-03-21 03:09:40 -07:00
|
|
|
void CreateStrayLayer(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp{ctx};
|
2019-01-02 16:42:08 -08:00
|
|
|
const u32 flags = rp.Pop<u32>();
|
2018-03-21 03:09:40 -07:00
|
|
|
rp.Pop<u32>(); // padding
|
2019-01-02 16:42:08 -08:00
|
|
|
const u64 display_id = rp.Pop<u64>();
|
|
|
|
|
|
|
|
LOG_DEBUG(Service_VI, "called. flags=0x{:08X}, display_id=0x{:016X}", flags, display_id);
|
2018-01-15 14:20:08 -08:00
|
|
|
|
2018-03-21 03:09:40 -07:00
|
|
|
// TODO(Subv): What's the difference between a Stray and a Managed layer?
|
2018-01-15 14:20:08 -08:00
|
|
|
|
2020-11-24 14:31:58 -08:00
|
|
|
const auto layer_id = nv_flinger.CreateLayer(display_id);
|
2019-02-05 13:20:04 -08:00
|
|
|
if (!layer_id) {
|
2020-04-28 18:15:21 -07:00
|
|
|
LOG_ERROR(Service_VI, "Layer not found! layer_id={}", *layer_id);
|
2019-02-05 13:20:04 -08:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(ERR_NOT_FOUND);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-11-24 14:31:58 -08:00
|
|
|
const auto buffer_queue_id = nv_flinger.FindBufferQueueId(display_id, *layer_id);
|
2019-02-05 13:20:04 -08:00
|
|
|
if (!buffer_queue_id) {
|
2020-04-28 18:15:21 -07:00
|
|
|
LOG_ERROR(Service_VI, "Buffer queue id not found! display_id={}", display_id);
|
2019-02-05 13:20:04 -08:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(ERR_NOT_FOUND);
|
|
|
|
return;
|
|
|
|
}
|
2018-01-15 14:20:08 -08:00
|
|
|
|
2019-02-05 13:20:04 -08:00
|
|
|
NativeWindow native_window{*buffer_queue_id};
|
2018-09-18 22:09:59 -07:00
|
|
|
IPC::ResponseBuilder rb{ctx, 6};
|
2018-03-21 03:09:40 -07:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
2019-02-05 13:20:04 -08:00
|
|
|
rb.Push(*layer_id);
|
2018-03-21 03:09:40 -07:00
|
|
|
rb.Push<u64>(ctx.WriteBuffer(native_window.Serialize()));
|
|
|
|
}
|
2018-01-07 18:27:58 -08:00
|
|
|
|
2018-03-21 03:09:40 -07:00
|
|
|
void DestroyStrayLayer(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp{ctx};
|
2019-01-02 16:42:08 -08:00
|
|
|
const u64 layer_id = rp.Pop<u64>();
|
|
|
|
|
|
|
|
LOG_WARNING(Service_VI, "(STUBBED) called. layer_id=0x{:016X}", layer_id);
|
2018-02-07 04:11:17 -08:00
|
|
|
|
2018-09-18 22:09:59 -07:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
2018-03-21 03:09:40 -07:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
2018-01-07 18:27:58 -08:00
|
|
|
|
2018-03-21 03:09:40 -07:00
|
|
|
void GetDisplayVsyncEvent(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp{ctx};
|
2019-01-02 16:42:08 -08:00
|
|
|
const u64 display_id = rp.Pop<u64>();
|
|
|
|
|
|
|
|
LOG_WARNING(Service_VI, "(STUBBED) called. display_id=0x{:016X}", display_id);
|
2018-01-08 15:29:43 -08:00
|
|
|
|
2020-11-24 14:31:58 -08:00
|
|
|
const auto vsync_event = nv_flinger.FindVsyncEvent(display_id);
|
2019-02-05 13:20:04 -08:00
|
|
|
if (!vsync_event) {
|
2020-04-28 18:15:21 -07:00
|
|
|
LOG_ERROR(Service_VI, "Vsync event was not found for display_id={}", display_id);
|
2019-02-05 13:20:04 -08:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(ERR_NOT_FOUND);
|
|
|
|
return;
|
|
|
|
}
|
2018-03-21 03:09:40 -07:00
|
|
|
|
2018-09-18 22:09:59 -07:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 1};
|
2018-03-21 03:09:40 -07:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.PushCopyObjects(vsync_event);
|
|
|
|
}
|
|
|
|
|
2018-10-16 08:25:42 -07:00
|
|
|
void ConvertScalingMode(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp{ctx};
|
2019-01-04 16:55:01 -08:00
|
|
|
const auto mode = rp.PopEnum<NintendoScaleMode>();
|
2020-12-07 19:00:34 -08:00
|
|
|
LOG_DEBUG(Service_VI, "called mode={}", mode);
|
2018-10-16 08:25:42 -07:00
|
|
|
|
2019-01-04 16:55:01 -08:00
|
|
|
const auto converted_mode = ConvertScalingModeImpl(mode);
|
|
|
|
|
|
|
|
if (converted_mode.Succeeded()) {
|
|
|
|
IPC::ResponseBuilder rb{ctx, 4};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.PushEnum(*converted_mode);
|
|
|
|
} else {
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(converted_mode.Code());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-21 06:06:18 -07:00
|
|
|
void GetIndirectLayerImageRequiredMemoryInfo(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp{ctx};
|
|
|
|
const auto width = rp.Pop<u64>();
|
|
|
|
const auto height = rp.Pop<u64>();
|
|
|
|
LOG_DEBUG(Service_VI, "called width={}, height={}", width, height);
|
|
|
|
|
2020-08-31 07:34:46 -07:00
|
|
|
constexpr u64 base_size = 0x20000;
|
|
|
|
constexpr u64 alignment = 0x1000;
|
2020-07-21 06:06:18 -07:00
|
|
|
const auto texture_size = width * height * 4;
|
|
|
|
const auto out_size = (texture_size + base_size - 1) / base_size * base_size;
|
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 6};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.Push(out_size);
|
|
|
|
rb.Push(alignment);
|
|
|
|
}
|
|
|
|
|
2019-01-04 16:55:01 -08:00
|
|
|
static ResultVal<ConvertedScaleMode> ConvertScalingModeImpl(NintendoScaleMode mode) {
|
2018-10-16 08:25:42 -07:00
|
|
|
switch (mode) {
|
|
|
|
case NintendoScaleMode::None:
|
2019-01-04 16:55:01 -08:00
|
|
|
return MakeResult(ConvertedScaleMode::None);
|
2018-10-16 08:25:42 -07:00
|
|
|
case NintendoScaleMode::Freeze:
|
2019-01-04 16:55:01 -08:00
|
|
|
return MakeResult(ConvertedScaleMode::Freeze);
|
2018-10-16 08:25:42 -07:00
|
|
|
case NintendoScaleMode::ScaleToWindow:
|
2019-01-04 16:55:01 -08:00
|
|
|
return MakeResult(ConvertedScaleMode::ScaleToWindow);
|
2019-01-04 17:32:29 -08:00
|
|
|
case NintendoScaleMode::ScaleAndCrop:
|
|
|
|
return MakeResult(ConvertedScaleMode::ScaleAndCrop);
|
|
|
|
case NintendoScaleMode::PreserveAspectRatio:
|
|
|
|
return MakeResult(ConvertedScaleMode::PreserveAspectRatio);
|
2018-10-16 08:25:42 -07:00
|
|
|
default:
|
2020-04-28 18:15:21 -07:00
|
|
|
LOG_ERROR(Service_VI, "Invalid scaling mode specified, mode={}", mode);
|
2019-01-04 16:55:01 -08:00
|
|
|
return ERR_OPERATION_FAILED;
|
2018-10-16 08:25:42 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-24 14:31:58 -08:00
|
|
|
NVFlinger::NVFlinger& nv_flinger;
|
2018-03-21 03:09:40 -07:00
|
|
|
};
|
2018-01-07 18:27:58 -08:00
|
|
|
|
2020-11-26 12:19:08 -08:00
|
|
|
IApplicationDisplayService::IApplicationDisplayService(Core::System& system_,
|
|
|
|
NVFlinger::NVFlinger& nv_flinger_)
|
|
|
|
: ServiceFramework{system_, "IApplicationDisplayService"}, nv_flinger{nv_flinger_} {
|
2018-01-07 18:27:58 -08:00
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{100, &IApplicationDisplayService::GetRelayService, "GetRelayService"},
|
|
|
|
{101, &IApplicationDisplayService::GetSystemDisplayService, "GetSystemDisplayService"},
|
|
|
|
{102, &IApplicationDisplayService::GetManagerDisplayService, "GetManagerDisplayService"},
|
2018-01-15 14:20:08 -08:00
|
|
|
{103, &IApplicationDisplayService::GetIndirectDisplayTransactionService,
|
|
|
|
"GetIndirectDisplayTransactionService"},
|
2018-02-07 04:11:17 -08:00
|
|
|
{1000, &IApplicationDisplayService::ListDisplays, "ListDisplays"},
|
2018-01-07 18:27:58 -08:00
|
|
|
{1010, &IApplicationDisplayService::OpenDisplay, "OpenDisplay"},
|
2019-01-02 15:05:15 -08:00
|
|
|
{1011, &IApplicationDisplayService::OpenDefaultDisplay, "OpenDefaultDisplay"},
|
2018-01-15 14:20:08 -08:00
|
|
|
{1020, &IApplicationDisplayService::CloseDisplay, "CloseDisplay"},
|
2019-01-02 17:45:40 -08:00
|
|
|
{1101, &IApplicationDisplayService::SetDisplayEnabled, "SetDisplayEnabled"},
|
2018-04-02 20:28:45 -07:00
|
|
|
{1102, &IApplicationDisplayService::GetDisplayResolution, "GetDisplayResolution"},
|
2018-01-07 18:27:58 -08:00
|
|
|
{2020, &IApplicationDisplayService::OpenLayer, "OpenLayer"},
|
2020-01-03 21:45:06 -08:00
|
|
|
{2021, &IApplicationDisplayService::CloseLayer, "CloseLayer"},
|
2018-01-15 14:20:08 -08:00
|
|
|
{2030, &IApplicationDisplayService::CreateStrayLayer, "CreateStrayLayer"},
|
|
|
|
{2031, &IApplicationDisplayService::DestroyStrayLayer, "DestroyStrayLayer"},
|
2018-04-17 08:37:43 -07:00
|
|
|
{2101, &IApplicationDisplayService::SetLayerScalingMode, "SetLayerScalingMode"},
|
2018-10-16 08:25:42 -07:00
|
|
|
{2102, &IApplicationDisplayService::ConvertScalingMode, "ConvertScalingMode"},
|
2018-04-17 08:37:43 -07:00
|
|
|
{2450, nullptr, "GetIndirectLayerImageMap"},
|
|
|
|
{2451, nullptr, "GetIndirectLayerImageCropMap"},
|
2020-07-21 06:06:18 -07:00
|
|
|
{2460, &IApplicationDisplayService::GetIndirectLayerImageRequiredMemoryInfo,
|
|
|
|
"GetIndirectLayerImageRequiredMemoryInfo"},
|
2018-01-07 18:27:58 -08:00
|
|
|
{5202, &IApplicationDisplayService::GetDisplayVsyncEvent, "GetDisplayVsyncEvent"},
|
2018-04-17 08:37:43 -07:00
|
|
|
{5203, nullptr, "GetDisplayVsyncEventForDebug"},
|
2018-01-07 18:27:58 -08:00
|
|
|
};
|
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
|
2019-02-26 14:49:32 -08:00
|
|
|
static bool IsValidServiceAccess(Permission permission, Policy policy) {
|
|
|
|
if (permission == Permission::User) {
|
|
|
|
return policy == Policy::User;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (permission == Permission::System || permission == Permission::Manager) {
|
|
|
|
return policy == Policy::User || policy == Policy::Compositor;
|
|
|
|
}
|
2018-03-21 03:09:40 -07:00
|
|
|
|
2019-02-26 14:49:32 -08:00
|
|
|
return false;
|
|
|
|
}
|
hle/service: Default constructors and destructors in the cpp file where applicable
When a destructor isn't defaulted into a cpp file, it can cause the use
of forward declarations to seemingly fail to compile for non-obvious
reasons. It also allows inlining of the construction/destruction logic
all over the place where a constructor or destructor is invoked, which
can lead to code bloat. This isn't so much a worry here, given the
services won't be created and destroyed frequently.
The cause of the above mentioned non-obvious errors can be demonstrated
as follows:
------- Demonstrative example, if you know how the described error happens, skip forwards -------
Assume we have the following in the header, which we'll call "thing.h":
\#include <memory>
// Forward declaration. For example purposes, assume the definition
// of Object is in some header named "object.h"
class Object;
class Thing {
public:
// assume no constructors or destructors are specified here,
// or the constructors/destructors are defined as:
//
// Thing() = default;
// ~Thing() = default;
//
// ... Some interface member functions would be defined here
private:
std::shared_ptr<Object> obj;
};
If this header is included in a cpp file, (which we'll call "main.cpp"),
this will result in a compilation error, because even though no
destructor is specified, the destructor will still need to be generated by
the compiler because std::shared_ptr's destructor is *not* trivial (in
other words, it does something other than nothing), as std::shared_ptr's
destructor needs to do two things:
1. Decrement the shared reference count of the object being pointed to,
and if the reference count decrements to zero,
2. Free the Object instance's memory (aka deallocate the memory it's
pointing to).
And so the compiler generates the code for the destructor doing this inside main.cpp.
Now, keep in mind, the Object forward declaration is not a complete type. All it
does is tell the compiler "a type named Object exists" and allows us to
use the name in certain situations to avoid a header dependency. So the
compiler needs to generate destruction code for Object, but the compiler
doesn't know *how* to destruct it. A forward declaration doesn't tell
the compiler anything about Object's constructor or destructor. So, the
compiler will issue an error in this case because it's undefined
behavior to try and deallocate (or construct) an incomplete type and
std::shared_ptr and std::unique_ptr make sure this isn't the case
internally.
Now, if we had defaulted the destructor in "thing.cpp", where we also
include "object.h", this would never be an issue, as the destructor
would only have its code generated in one place, and it would be in a
place where the full class definition of Object would be visible to the
compiler.
---------------------- End example ----------------------------
Given these service classes are more than certainly going to change in
the future, this defaults the constructors and destructors into the
relevant cpp files to make the construction and destruction of all of
the services consistent and unlikely to run into cases where forward
declarations are indirectly causing compilation errors. It also has the
plus of avoiding the need to rebuild several services if destruction
logic changes, since it would only be necessary to recompile the single
cpp file.
2018-09-10 18:20:52 -07:00
|
|
|
|
2020-11-26 12:19:08 -08:00
|
|
|
void detail::GetDisplayServiceImpl(Kernel::HLERequestContext& ctx, Core::System& system,
|
|
|
|
NVFlinger::NVFlinger& nv_flinger, Permission permission) {
|
2019-02-26 14:49:32 -08:00
|
|
|
IPC::RequestParser rp{ctx};
|
|
|
|
const auto policy = rp.PopEnum<Policy>();
|
|
|
|
|
|
|
|
if (!IsValidServiceAccess(permission, policy)) {
|
2020-12-07 19:00:34 -08:00
|
|
|
LOG_ERROR(Service_VI, "Permission denied for policy {}", policy);
|
2019-02-26 14:49:32 -08:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(ERR_PERMISSION_DENIED);
|
|
|
|
return;
|
|
|
|
}
|
2018-03-21 03:09:40 -07:00
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2020-11-26 12:19:08 -08:00
|
|
|
rb.PushIpcInterface<IApplicationDisplayService>(system, nv_flinger);
|
2018-03-21 03:09:40 -07:00
|
|
|
}
|
|
|
|
|
2020-11-26 12:19:08 -08:00
|
|
|
void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system,
|
|
|
|
NVFlinger::NVFlinger& nv_flinger) {
|
|
|
|
std::make_shared<VI_M>(system, nv_flinger)->InstallAsService(service_manager);
|
|
|
|
std::make_shared<VI_S>(system, nv_flinger)->InstallAsService(service_manager);
|
|
|
|
std::make_shared<VI_U>(system, nv_flinger)->InstallAsService(service_manager);
|
2018-01-07 18:27:58 -08:00
|
|
|
}
|
|
|
|
|
2018-04-19 18:41:44 -07:00
|
|
|
} // namespace Service::VI
|