Compare commits
15 Commits
__refs_pul
...
__refs_pul
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bb94beed15 | ||
|
|
6e10a0c130 | ||
|
|
182221b9ff | ||
|
|
2643ea80df | ||
|
|
f94186d3c3 | ||
|
|
bf08bc3c0f | ||
|
|
871e7cacf6 | ||
|
|
2fe922aae5 | ||
|
|
67fd1df762 | ||
|
|
b7f60e9123 | ||
|
|
3ec027400e | ||
|
|
42e1db4b0e | ||
|
|
1968cc7b10 | ||
|
|
b3691fc33c | ||
|
|
0a6bd8b236 |
@@ -83,5 +83,3 @@ If you wish to support us a different way, please join our [Discord](https://dis
|
||||
## License
|
||||
|
||||
yuzu is licensed under the GPLv3 (or any later version). Refer to the [LICENSE.txt](https://github.com/yuzu-emu/yuzu/blob/master/LICENSE.txt) file.
|
||||
|
||||
The [Skyline-Emulator Team](https://github.com/skyline-emu/skyline) may choose to use the code from these contributors under the GPL-3.0-or-later OR MPL-2.0: [FernandoS27](https://github.com/FernandoS27), [lioncash](https://github.com/lioncash), [bunnei](https://github.com/bunnei), [ReinUsesLisp](https://github.com/ReinUsesLisp), [Morph1984](https://github.com/Morph1984), [ogniK5377](https://github.com/ogniK5377), [german77](https://github.com/german77), [ameerj](https://github.com/ameerj), [Kelebek1](https://github.com/Kelebek1) and [lat9nq](https://github.com/lat9nq)
|
||||
|
||||
@@ -23,7 +23,10 @@ public:
|
||||
buffer{Common::make_unique_for_overwrite<T[]>(initial_capacity)} {}
|
||||
|
||||
~ScratchBuffer() = default;
|
||||
ScratchBuffer(const ScratchBuffer&) = delete;
|
||||
ScratchBuffer& operator=(const ScratchBuffer&) = delete;
|
||||
ScratchBuffer(ScratchBuffer&&) = default;
|
||||
ScratchBuffer& operator=(ScratchBuffer&&) = default;
|
||||
|
||||
/// This will only grow the buffer's capacity if size is greater than the current capacity.
|
||||
/// The previously held data will remain intact.
|
||||
@@ -87,6 +90,12 @@ public:
|
||||
return buffer_capacity;
|
||||
}
|
||||
|
||||
void swap(ScratchBuffer& other) noexcept {
|
||||
std::swap(last_requested_size, other.last_requested_size);
|
||||
std::swap(buffer_capacity, other.buffer_capacity);
|
||||
std::swap(buffer, other.buffer);
|
||||
}
|
||||
|
||||
private:
|
||||
size_t last_requested_size{};
|
||||
size_t buffer_capacity{};
|
||||
|
||||
@@ -535,6 +535,8 @@ struct Values {
|
||||
Setting<bool> enable_ir_sensor{false, "enable_ir_sensor"};
|
||||
Setting<std::string> ir_sensor_device{"auto", "ir_sensor_device"};
|
||||
|
||||
Setting<bool> random_amiibo_id{false, "random_amiibo_id"};
|
||||
|
||||
// Data Storage
|
||||
Setting<bool> use_virtual_sd{true, "use_virtual_sd"};
|
||||
Setting<bool> gamecard_inserted{false, "gamecard_inserted"};
|
||||
|
||||
@@ -48,9 +48,6 @@ NfcDevice::NfcDevice(Core::HID::NpadIdType npad_id_, Core::System& system_,
|
||||
};
|
||||
is_controller_set = true;
|
||||
callback_key = npad_device->SetCallback(engine_callback);
|
||||
|
||||
auto& standard_steady_clock{system.GetTimeManager().GetStandardSteadyClockCore()};
|
||||
current_posix_time = standard_steady_clock.GetCurrentTimePoint(system).time_point;
|
||||
}
|
||||
|
||||
NfcDevice::~NfcDevice() {
|
||||
@@ -227,11 +224,21 @@ Result NfcDevice::GetTagInfo(NFP::TagInfo& tag_info, bool is_mifare) const {
|
||||
return ResultWrongDeviceState;
|
||||
}
|
||||
|
||||
UniqueSerialNumber uuid = encrypted_tag_data.uuid.uid;
|
||||
|
||||
// Generate random UUID to bypass amiibo load limits
|
||||
if (Settings::values.random_amiibo_id) {
|
||||
Common::TinyMT rng{};
|
||||
rng.Initialize(static_cast<u32>(GetCurrentPosixTime()));
|
||||
rng.GenerateRandomBytes(uuid.data(), sizeof(UniqueSerialNumber));
|
||||
uuid[3] = 0x88 ^ uuid[0] ^ uuid[1] ^ uuid[2];
|
||||
}
|
||||
|
||||
if (is_mifare) {
|
||||
tag_info = {
|
||||
.uuid = encrypted_tag_data.uuid.uid,
|
||||
.uuid = uuid,
|
||||
.uuid_extension = {},
|
||||
.uuid_length = static_cast<u8>(encrypted_tag_data.uuid.uid.size()),
|
||||
.uuid_length = static_cast<u8>(uuid.size()),
|
||||
.protocol = NfcProtocol::TypeA,
|
||||
.tag_type = TagType::Type4,
|
||||
};
|
||||
@@ -240,9 +247,9 @@ Result NfcDevice::GetTagInfo(NFP::TagInfo& tag_info, bool is_mifare) const {
|
||||
|
||||
// Protocol and tag type may change here
|
||||
tag_info = {
|
||||
.uuid = encrypted_tag_data.uuid.uid,
|
||||
.uuid = uuid,
|
||||
.uuid_extension = {},
|
||||
.uuid_length = static_cast<u8>(encrypted_tag_data.uuid.uid.size()),
|
||||
.uuid_length = static_cast<u8>(uuid.size()),
|
||||
.protocol = NfcProtocol::TypeA,
|
||||
.tag_type = TagType::Type2,
|
||||
};
|
||||
@@ -406,7 +413,7 @@ Result NfcDevice::Flush() {
|
||||
|
||||
auto& settings = tag_data.settings;
|
||||
|
||||
const auto& current_date = GetAmiiboDate(current_posix_time);
|
||||
const auto& current_date = GetAmiiboDate(GetCurrentPosixTime());
|
||||
if (settings.write_date.raw_date != current_date.raw_date) {
|
||||
settings.write_date = current_date;
|
||||
UpdateSettingsCrc();
|
||||
@@ -525,6 +532,7 @@ Result NfcDevice::GetModelInfo(NFP::ModelInfo& model_info) const {
|
||||
}
|
||||
|
||||
const auto& model_info_data = encrypted_tag_data.user_memory.model_info;
|
||||
|
||||
model_info = {
|
||||
.character_id = model_info_data.character_id,
|
||||
.character_variant = model_info_data.character_variant,
|
||||
@@ -669,6 +677,7 @@ Result NfcDevice::DeleteRegisterInfo() {
|
||||
}
|
||||
|
||||
Common::TinyMT rng{};
|
||||
rng.Initialize(static_cast<u32>(GetCurrentPosixTime()));
|
||||
rng.GenerateRandomBytes(&tag_data.owner_mii, sizeof(tag_data.owner_mii));
|
||||
rng.GenerateRandomBytes(&tag_data.settings.amiibo_name, sizeof(tag_data.settings.amiibo_name));
|
||||
rng.GenerateRandomBytes(&tag_data.unknown, sizeof(u8));
|
||||
@@ -701,7 +710,7 @@ Result NfcDevice::SetRegisterInfoPrivate(const NFP::RegisterInfoPrivate& registe
|
||||
auto& settings = tag_data.settings;
|
||||
|
||||
if (tag_data.settings.settings.amiibo_initialized == 0) {
|
||||
settings.init_date = GetAmiiboDate(current_posix_time);
|
||||
settings.init_date = GetAmiiboDate(GetCurrentPosixTime());
|
||||
settings.write_date.raw_date = 0;
|
||||
}
|
||||
|
||||
@@ -868,6 +877,7 @@ Result NfcDevice::SetApplicationArea(std::span<const u8> data) {
|
||||
}
|
||||
|
||||
Common::TinyMT rng{};
|
||||
rng.Initialize(static_cast<u32>(GetCurrentPosixTime()));
|
||||
std::memcpy(tag_data.application_area.data(), data.data(), data.size());
|
||||
// Fill remaining data with random numbers
|
||||
rng.GenerateRandomBytes(tag_data.application_area.data() + data.size(),
|
||||
@@ -924,6 +934,7 @@ Result NfcDevice::RecreateApplicationArea(u32 access_id, std::span<const u8> dat
|
||||
}
|
||||
|
||||
Common::TinyMT rng{};
|
||||
rng.Initialize(static_cast<u32>(GetCurrentPosixTime()));
|
||||
std::memcpy(tag_data.application_area.data(), data.data(), data.size());
|
||||
// Fill remaining data with random numbers
|
||||
rng.GenerateRandomBytes(tag_data.application_area.data() + data.size(),
|
||||
@@ -973,6 +984,7 @@ Result NfcDevice::DeleteApplicationArea() {
|
||||
}
|
||||
|
||||
Common::TinyMT rng{};
|
||||
rng.Initialize(static_cast<u32>(GetCurrentPosixTime()));
|
||||
rng.GenerateRandomBytes(tag_data.application_area.data(), sizeof(NFP::ApplicationArea));
|
||||
rng.GenerateRandomBytes(&tag_data.application_id, sizeof(u64));
|
||||
rng.GenerateRandomBytes(&tag_data.application_area_id, sizeof(u32));
|
||||
@@ -1189,6 +1201,11 @@ NFP::AmiiboDate NfcDevice::GetAmiiboDate(s64 posix_time) const {
|
||||
return amiibo_date;
|
||||
}
|
||||
|
||||
u64 NfcDevice::GetCurrentPosixTime() const {
|
||||
auto& standard_steady_clock{system.GetTimeManager().GetStandardSteadyClockCore()};
|
||||
return standard_steady_clock.GetCurrentTimePoint(system).time_point;
|
||||
}
|
||||
|
||||
u64 NfcDevice::RemoveVersionByte(u64 application_id) const {
|
||||
return application_id & ~(0xfULL << NFP::application_id_version_offset);
|
||||
}
|
||||
|
||||
@@ -105,6 +105,7 @@ private:
|
||||
NFP::AmiiboName GetAmiiboName(const NFP::AmiiboSettings& settings) const;
|
||||
void SetAmiiboName(NFP::AmiiboSettings& settings, const NFP::AmiiboName& amiibo_name);
|
||||
NFP::AmiiboDate GetAmiiboDate(s64 posix_time) const;
|
||||
u64 GetCurrentPosixTime() const;
|
||||
u64 RemoveVersionByte(u64 application_id) const;
|
||||
void UpdateSettingsCrc();
|
||||
void UpdateRegisterInfoCrc();
|
||||
@@ -127,7 +128,6 @@ private:
|
||||
bool is_data_moddified{};
|
||||
bool is_app_area_open{};
|
||||
bool is_plain_amiibo{};
|
||||
s64 current_posix_time{};
|
||||
NFP::MountTarget mount_target{NFP::MountTarget::None};
|
||||
|
||||
NFP::NTAG215File tag_data{};
|
||||
|
||||
@@ -793,6 +793,7 @@ Status BufferQueueProducer::SetPreallocatedBuffer(s32 slot,
|
||||
std::scoped_lock lock{core->mutex};
|
||||
|
||||
slots[slot] = {};
|
||||
slots[slot].fence = Fence::NoFence();
|
||||
slots[slot].graphic_buffer = buffer;
|
||||
slots[slot].frame_number = 0;
|
||||
|
||||
@@ -854,7 +855,7 @@ void BufferQueueProducer::Transact(HLERequestContext& ctx, TransactionId code, u
|
||||
status = DequeueBuffer(&slot, &fence, is_async, width, height, pixel_format, usage);
|
||||
|
||||
parcel_out.Write(slot);
|
||||
parcel_out.WriteObject(&fence);
|
||||
parcel_out.WriteFlattenedObject(&fence);
|
||||
break;
|
||||
}
|
||||
case TransactionId::RequestBuffer: {
|
||||
@@ -864,7 +865,7 @@ void BufferQueueProducer::Transact(HLERequestContext& ctx, TransactionId code, u
|
||||
|
||||
status = RequestBuffer(slot, &buf);
|
||||
|
||||
parcel_out.WriteObject(buf);
|
||||
parcel_out.WriteFlattenedObject(buf);
|
||||
break;
|
||||
}
|
||||
case TransactionId::QueueBuffer: {
|
||||
|
||||
@@ -117,61 +117,67 @@ private:
|
||||
|
||||
class OutputParcel final {
|
||||
public:
|
||||
static constexpr std::size_t DefaultBufferSize = 0x40;
|
||||
|
||||
OutputParcel() : buffer(DefaultBufferSize) {}
|
||||
|
||||
template <typename T>
|
||||
explicit OutputParcel(const T& out_data) : buffer(DefaultBufferSize) {
|
||||
Write(out_data);
|
||||
}
|
||||
OutputParcel() = default;
|
||||
|
||||
template <typename T>
|
||||
void Write(const T& val) {
|
||||
static_assert(std::is_trivially_copyable_v<T>, "T must be trivially copyable.");
|
||||
|
||||
if (buffer.size() < write_index + sizeof(T)) {
|
||||
buffer.resize(buffer.size() + sizeof(T) + DefaultBufferSize);
|
||||
}
|
||||
|
||||
std::memcpy(buffer.data() + write_index, &val, sizeof(T));
|
||||
write_index += sizeof(T);
|
||||
write_index = Common::AlignUp(write_index, 4);
|
||||
this->WriteImpl(val, m_data_buffer);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void WriteObject(const T* ptr) {
|
||||
static_assert(std::is_trivially_copyable_v<T>, "T must be trivially copyable.");
|
||||
|
||||
void WriteFlattenedObject(const T* ptr) {
|
||||
if (!ptr) {
|
||||
Write<u32>(0);
|
||||
this->Write<u32>(0);
|
||||
return;
|
||||
}
|
||||
|
||||
Write<u32>(1);
|
||||
Write<s64>(sizeof(T));
|
||||
Write(*ptr);
|
||||
this->Write<u32>(1);
|
||||
this->Write<s64>(sizeof(T));
|
||||
this->Write(*ptr);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void WriteObject(const std::shared_ptr<T> ptr) {
|
||||
WriteObject(ptr.get());
|
||||
void WriteFlattenedObject(const std::shared_ptr<T> ptr) {
|
||||
this->WriteFlattenedObject(ptr.get());
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void WriteInterface(const T& val) {
|
||||
this->WriteImpl(val, m_data_buffer);
|
||||
this->WriteImpl(0U, m_object_buffer);
|
||||
}
|
||||
|
||||
std::vector<u8> Serialize() const {
|
||||
ParcelHeader header{};
|
||||
header.data_size = static_cast<u32>(write_index - sizeof(ParcelHeader));
|
||||
header.data_offset = sizeof(ParcelHeader);
|
||||
header.objects_size = 4;
|
||||
header.objects_offset = static_cast<u32>(sizeof(ParcelHeader) + header.data_size);
|
||||
std::memcpy(buffer.data(), &header, sizeof(ParcelHeader));
|
||||
std::vector<u8> output_buffer(sizeof(ParcelHeader) + m_data_buffer.size() +
|
||||
m_object_buffer.size());
|
||||
|
||||
return buffer;
|
||||
ParcelHeader header{};
|
||||
header.data_size = static_cast<u32>(m_data_buffer.size());
|
||||
header.data_offset = sizeof(ParcelHeader);
|
||||
header.objects_size = static_cast<u32>(m_object_buffer.size());
|
||||
header.objects_offset = header.data_offset + header.data_size;
|
||||
|
||||
std::memcpy(output_buffer.data(), &header, sizeof(header));
|
||||
std::ranges::copy(m_data_buffer, output_buffer.data() + header.data_offset);
|
||||
std::ranges::copy(m_object_buffer, output_buffer.data() + header.objects_offset);
|
||||
|
||||
return output_buffer;
|
||||
}
|
||||
|
||||
private:
|
||||
mutable std::vector<u8> buffer;
|
||||
std::size_t write_index = sizeof(ParcelHeader);
|
||||
template <typename T>
|
||||
requires(std::is_trivially_copyable_v<T>)
|
||||
void WriteImpl(const T& val, std::vector<u8>& buffer) {
|
||||
const size_t aligned_size = Common::AlignUp(sizeof(T), 4);
|
||||
const size_t old_size = buffer.size();
|
||||
buffer.resize(old_size + aligned_size);
|
||||
|
||||
std::memcpy(buffer.data() + old_size, &val, sizeof(T));
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<u8> m_data_buffer;
|
||||
std::vector<u8> m_object_buffer;
|
||||
};
|
||||
|
||||
} // namespace Service::android
|
||||
|
||||
@@ -64,8 +64,8 @@ public:
|
||||
private:
|
||||
const u32 magic = 2;
|
||||
const u32 process_id = 1;
|
||||
const u32 id;
|
||||
INSERT_PADDING_WORDS(3);
|
||||
const u64 id;
|
||||
INSERT_PADDING_WORDS(2);
|
||||
std::array<u8, 8> dispdrv = {'d', 'i', 's', 'p', 'd', 'r', 'v', '\0'};
|
||||
INSERT_PADDING_WORDS(2);
|
||||
};
|
||||
@@ -608,7 +608,9 @@ private:
|
||||
return;
|
||||
}
|
||||
|
||||
const auto parcel = android::OutputParcel{NativeWindow{*buffer_queue_id}};
|
||||
android::OutputParcel parcel;
|
||||
parcel.WriteInterface(NativeWindow{*buffer_queue_id});
|
||||
|
||||
const auto buffer_size = ctx.WriteBuffer(parcel.Serialize());
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 4};
|
||||
@@ -654,7 +656,9 @@ private:
|
||||
return;
|
||||
}
|
||||
|
||||
const auto parcel = android::OutputParcel{NativeWindow{*buffer_queue_id}};
|
||||
android::OutputParcel parcel;
|
||||
parcel.WriteInterface(NativeWindow{*buffer_queue_id});
|
||||
|
||||
const auto buffer_size = ctx.WriteBuffer(parcel.Serialize());
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 6};
|
||||
|
||||
@@ -109,14 +109,37 @@ public:
|
||||
}
|
||||
|
||||
bool RumblePlay(const Common::Input::VibrationStatus vibration) {
|
||||
constexpr u32 rumble_max_duration_ms = 1000;
|
||||
constexpr u32 rumble_max_duration_ms = 2000;
|
||||
constexpr f32 low_start_sensitivity_limit = 140.0;
|
||||
constexpr f32 low_width_sensitivity_limit = 400.0;
|
||||
constexpr f32 high_start_sensitivity_limit = 200.0;
|
||||
constexpr f32 high_width_sensitivity_limit = 700.0;
|
||||
// Try to provide some feeling of the frequency by reducing the amplitude depending on it.
|
||||
f32 low_frequency_scale = 1.0;
|
||||
if (vibration.low_frequency > low_start_sensitivity_limit) {
|
||||
low_frequency_scale =
|
||||
std::max(1.0f - (vibration.low_frequency - low_start_sensitivity_limit) /
|
||||
low_width_sensitivity_limit,
|
||||
0.3f);
|
||||
}
|
||||
f32 low_amplitude = vibration.low_amplitude * low_frequency_scale;
|
||||
|
||||
f32 high_frequency_scale = 1.0;
|
||||
if (vibration.high_frequency > high_start_sensitivity_limit) {
|
||||
high_frequency_scale =
|
||||
std::max(1.0f - (vibration.high_frequency - high_start_sensitivity_limit) /
|
||||
high_width_sensitivity_limit,
|
||||
0.3f);
|
||||
}
|
||||
f32 high_amplitude = vibration.high_amplitude * high_frequency_scale;
|
||||
|
||||
if (sdl_controller) {
|
||||
return SDL_GameControllerRumble(
|
||||
sdl_controller.get(), static_cast<u16>(vibration.low_amplitude),
|
||||
static_cast<u16>(vibration.high_amplitude), rumble_max_duration_ms) != -1;
|
||||
return SDL_GameControllerRumble(sdl_controller.get(), static_cast<u16>(low_amplitude),
|
||||
static_cast<u16>(high_amplitude),
|
||||
rumble_max_duration_ms) != -1;
|
||||
} else if (sdl_joystick) {
|
||||
return SDL_JoystickRumble(sdl_joystick.get(), static_cast<u16>(vibration.low_amplitude),
|
||||
static_cast<u16>(vibration.high_amplitude),
|
||||
return SDL_JoystickRumble(sdl_joystick.get(), static_cast<u16>(low_amplitude),
|
||||
static_cast<u16>(high_amplitude),
|
||||
rumble_max_duration_ms) != -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -96,12 +96,12 @@ void BufferCache<P>::TickFrame() {
|
||||
|
||||
template <class P>
|
||||
void BufferCache<P>::WriteMemory(VAddr cpu_addr, u64 size) {
|
||||
memory_tracker.MarkRegionAsCpuModified(cpu_addr, size);
|
||||
if (memory_tracker.IsRegionGpuModified(cpu_addr, size)) {
|
||||
const IntervalType subtract_interval{cpu_addr, cpu_addr + size};
|
||||
ClearDownload(subtract_interval);
|
||||
common_ranges.subtract(subtract_interval);
|
||||
}
|
||||
memory_tracker.MarkRegionAsCpuModified(cpu_addr, size);
|
||||
}
|
||||
|
||||
template <class P>
|
||||
@@ -122,9 +122,10 @@ std::optional<VideoCore::RasterizerDownloadArea> BufferCache<P>::GetFlushArea(VA
|
||||
area->preemtive = true;
|
||||
return area;
|
||||
};
|
||||
area->preemtive =
|
||||
!IsRegionGpuModified(cpu_addr_start_aligned, cpu_addr_end_aligned - cpu_addr_start_aligned);
|
||||
memory_tracker.MarkRegionAsPreflushable(cpu_addr_start_aligned,
|
||||
cpu_addr_end_aligned - cpu_addr_start_aligned);
|
||||
area->preemtive = !IsRegionGpuModified(cpu_addr, size);
|
||||
return area;
|
||||
}
|
||||
|
||||
@@ -1223,11 +1224,10 @@ void BufferCache<P>::UpdateComputeTextureBuffers() {
|
||||
|
||||
template <class P>
|
||||
void BufferCache<P>::MarkWrittenBuffer(BufferId buffer_id, VAddr cpu_addr, u32 size) {
|
||||
memory_tracker.MarkRegionAsGpuModified(cpu_addr, size);
|
||||
|
||||
if (memory_tracker.IsRegionCpuModified(cpu_addr, size)) {
|
||||
SynchronizeBuffer(slot_buffers[buffer_id], cpu_addr, size);
|
||||
}
|
||||
memory_tracker.MarkRegionAsGpuModified(cpu_addr, size);
|
||||
|
||||
const IntervalType base_interval{cpu_addr, cpu_addr + size};
|
||||
common_ranges.add(base_interval);
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <cmath>
|
||||
#include <vector>
|
||||
|
||||
#include "common/scratch_buffer.h"
|
||||
#include "video_core/engines/sw_blitter/blitter.h"
|
||||
#include "video_core/engines/sw_blitter/converter.h"
|
||||
#include "video_core/memory_manager.h"
|
||||
@@ -112,11 +113,11 @@ void Bilinear(std::span<const f32> input, std::span<f32> output, size_t src_widt
|
||||
} // namespace
|
||||
|
||||
struct SoftwareBlitEngine::BlitEngineImpl {
|
||||
std::vector<u8> tmp_buffer;
|
||||
std::vector<u8> src_buffer;
|
||||
std::vector<u8> dst_buffer;
|
||||
std::vector<f32> intermediate_src;
|
||||
std::vector<f32> intermediate_dst;
|
||||
Common::ScratchBuffer<u8> tmp_buffer;
|
||||
Common::ScratchBuffer<u8> src_buffer;
|
||||
Common::ScratchBuffer<u8> dst_buffer;
|
||||
Common::ScratchBuffer<f32> intermediate_src;
|
||||
Common::ScratchBuffer<f32> intermediate_dst;
|
||||
ConverterFactory converter_factory;
|
||||
};
|
||||
|
||||
@@ -158,14 +159,14 @@ bool SoftwareBlitEngine::Blit(Fermi2D::Surface& src, Fermi2D::Surface& dst,
|
||||
const auto src_bytes_per_pixel = BytesPerBlock(PixelFormatFromRenderTargetFormat(src.format));
|
||||
const auto dst_bytes_per_pixel = BytesPerBlock(PixelFormatFromRenderTargetFormat(dst.format));
|
||||
const size_t src_size = get_surface_size(src, src_bytes_per_pixel);
|
||||
impl->tmp_buffer.resize(src_size);
|
||||
impl->tmp_buffer.resize_destructive(src_size);
|
||||
memory_manager.ReadBlock(src.Address(), impl->tmp_buffer.data(), src_size);
|
||||
|
||||
const size_t src_copy_size = src_extent_x * src_extent_y * src_bytes_per_pixel;
|
||||
|
||||
const size_t dst_copy_size = dst_extent_x * dst_extent_y * dst_bytes_per_pixel;
|
||||
|
||||
impl->src_buffer.resize(src_copy_size);
|
||||
impl->src_buffer.resize_destructive(src_copy_size);
|
||||
|
||||
const bool no_passthrough =
|
||||
src.format != dst.format || src_extent_x != dst_extent_x || src_extent_y != dst_extent_y;
|
||||
@@ -177,8 +178,10 @@ bool SoftwareBlitEngine::Blit(Fermi2D::Surface& src, Fermi2D::Surface& dst,
|
||||
|
||||
const auto convertion_phase_ir = [&]() {
|
||||
auto* input_converter = impl->converter_factory.GetFormatConverter(src.format);
|
||||
impl->intermediate_src.resize((src_copy_size / src_bytes_per_pixel) * ir_components);
|
||||
impl->intermediate_dst.resize((dst_copy_size / dst_bytes_per_pixel) * ir_components);
|
||||
impl->intermediate_src.resize_destructive((src_copy_size / src_bytes_per_pixel) *
|
||||
ir_components);
|
||||
impl->intermediate_dst.resize_destructive((dst_copy_size / dst_bytes_per_pixel) *
|
||||
ir_components);
|
||||
input_converter->ConvertTo(impl->src_buffer, impl->intermediate_src);
|
||||
|
||||
if (config.filter != Fermi2D::Filter::Bilinear) {
|
||||
@@ -195,7 +198,7 @@ bool SoftwareBlitEngine::Blit(Fermi2D::Surface& src, Fermi2D::Surface& dst,
|
||||
|
||||
// Do actual Blit
|
||||
|
||||
impl->dst_buffer.resize(dst_copy_size);
|
||||
impl->dst_buffer.resize_destructive(dst_copy_size);
|
||||
if (src.linear == Fermi2D::MemoryLayout::BlockLinear) {
|
||||
UnswizzleSubrect(impl->src_buffer, impl->tmp_buffer, src_bytes_per_pixel, src.width,
|
||||
src.height, src.depth, config.src_x0, config.src_y0, src_extent_x,
|
||||
@@ -218,7 +221,7 @@ bool SoftwareBlitEngine::Blit(Fermi2D::Surface& src, Fermi2D::Surface& dst,
|
||||
}
|
||||
|
||||
const size_t dst_size = get_surface_size(dst, dst_bytes_per_pixel);
|
||||
impl->tmp_buffer.resize(dst_size);
|
||||
impl->tmp_buffer.resize_destructive(dst_size);
|
||||
memory_manager.ReadBlock(dst.Address(), impl->tmp_buffer.data(), dst_size);
|
||||
|
||||
if (dst.linear == Fermi2D::MemoryLayout::BlockLinear) {
|
||||
|
||||
@@ -176,7 +176,7 @@ public:
|
||||
};
|
||||
|
||||
inline void PushImageDescriptors(TextureCache& texture_cache,
|
||||
UpdateDescriptorQueue& update_descriptor_queue,
|
||||
GuestDescriptorQueue& guest_descriptor_queue,
|
||||
const Shader::Info& info, RescalingPushConstant& rescaling,
|
||||
const VkSampler*& samplers,
|
||||
const VideoCommon::ImageViewInOut*& views) {
|
||||
@@ -190,7 +190,7 @@ inline void PushImageDescriptors(TextureCache& texture_cache,
|
||||
const VkSampler sampler{*(samplers++)};
|
||||
ImageView& image_view{texture_cache.GetImageView(image_view_id)};
|
||||
const VkImageView vk_image_view{image_view.Handle(desc.type)};
|
||||
update_descriptor_queue.AddSampledImage(vk_image_view, sampler);
|
||||
guest_descriptor_queue.AddSampledImage(vk_image_view, sampler);
|
||||
rescaling.PushTexture(texture_cache.IsRescaling(image_view));
|
||||
}
|
||||
}
|
||||
@@ -201,7 +201,7 @@ inline void PushImageDescriptors(TextureCache& texture_cache,
|
||||
texture_cache.MarkModification(image_view.image_id);
|
||||
}
|
||||
const VkImageView vk_image_view{image_view.StorageView(desc.type, desc.format)};
|
||||
update_descriptor_queue.AddImage(vk_image_view);
|
||||
guest_descriptor_queue.AddImage(vk_image_view);
|
||||
rescaling.PushImage(texture_cache.IsRescaling(image_view));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -298,12 +298,14 @@ private:
|
||||
|
||||
BufferCacheRuntime::BufferCacheRuntime(const Device& device_, MemoryAllocator& memory_allocator_,
|
||||
Scheduler& scheduler_, StagingBufferPool& staging_pool_,
|
||||
UpdateDescriptorQueue& update_descriptor_queue_,
|
||||
GuestDescriptorQueue& guest_descriptor_queue_,
|
||||
ComputePassDescriptorQueue& compute_pass_descriptor_queue,
|
||||
DescriptorPool& descriptor_pool)
|
||||
: device{device_}, memory_allocator{memory_allocator_}, scheduler{scheduler_},
|
||||
staging_pool{staging_pool_}, update_descriptor_queue{update_descriptor_queue_},
|
||||
uint8_pass(device, scheduler, descriptor_pool, staging_pool, update_descriptor_queue),
|
||||
quad_index_pass(device, scheduler, descriptor_pool, staging_pool, update_descriptor_queue) {
|
||||
staging_pool{staging_pool_}, guest_descriptor_queue{guest_descriptor_queue_},
|
||||
uint8_pass(device, scheduler, descriptor_pool, staging_pool, compute_pass_descriptor_queue),
|
||||
quad_index_pass(device, scheduler, descriptor_pool, staging_pool,
|
||||
compute_pass_descriptor_queue) {
|
||||
quad_array_index_buffer = std::make_shared<QuadArrayIndexBuffer>(device_, memory_allocator_,
|
||||
scheduler_, staging_pool_);
|
||||
quad_strip_index_buffer = std::make_shared<QuadStripIndexBuffer>(device_, memory_allocator_,
|
||||
|
||||
@@ -63,7 +63,8 @@ class BufferCacheRuntime {
|
||||
public:
|
||||
explicit BufferCacheRuntime(const Device& device_, MemoryAllocator& memory_manager_,
|
||||
Scheduler& scheduler_, StagingBufferPool& staging_pool_,
|
||||
UpdateDescriptorQueue& update_descriptor_queue_,
|
||||
GuestDescriptorQueue& guest_descriptor_queue,
|
||||
ComputePassDescriptorQueue& compute_pass_descriptor_queue,
|
||||
DescriptorPool& descriptor_pool);
|
||||
|
||||
void Finish();
|
||||
@@ -116,12 +117,12 @@ public:
|
||||
|
||||
void BindTextureBuffer(Buffer& buffer, u32 offset, u32 size,
|
||||
VideoCore::Surface::PixelFormat format) {
|
||||
update_descriptor_queue.AddTexelBuffer(buffer.View(offset, size, format));
|
||||
guest_descriptor_queue.AddTexelBuffer(buffer.View(offset, size, format));
|
||||
}
|
||||
|
||||
private:
|
||||
void BindBuffer(VkBuffer buffer, u32 offset, u32 size) {
|
||||
update_descriptor_queue.AddBuffer(buffer, offset, size);
|
||||
guest_descriptor_queue.AddBuffer(buffer, offset, size);
|
||||
}
|
||||
|
||||
void ReserveNullBuffer();
|
||||
@@ -130,7 +131,7 @@ private:
|
||||
MemoryAllocator& memory_allocator;
|
||||
Scheduler& scheduler;
|
||||
StagingBufferPool& staging_pool;
|
||||
UpdateDescriptorQueue& update_descriptor_queue;
|
||||
GuestDescriptorQueue& guest_descriptor_queue;
|
||||
|
||||
std::shared_ptr<QuadArrayIndexBuffer> quad_array_index_buffer;
|
||||
std::shared_ptr<QuadStripIndexBuffer> quad_strip_index_buffer;
|
||||
|
||||
@@ -200,12 +200,12 @@ ComputePass::~ComputePass() = default;
|
||||
|
||||
Uint8Pass::Uint8Pass(const Device& device_, Scheduler& scheduler_, DescriptorPool& descriptor_pool,
|
||||
StagingBufferPool& staging_buffer_pool_,
|
||||
UpdateDescriptorQueue& update_descriptor_queue_)
|
||||
ComputePassDescriptorQueue& compute_pass_descriptor_queue_)
|
||||
: ComputePass(device_, descriptor_pool, INPUT_OUTPUT_DESCRIPTOR_SET_BINDINGS,
|
||||
INPUT_OUTPUT_DESCRIPTOR_UPDATE_TEMPLATE, INPUT_OUTPUT_BANK_INFO, {},
|
||||
VULKAN_UINT8_COMP_SPV),
|
||||
scheduler{scheduler_}, staging_buffer_pool{staging_buffer_pool_},
|
||||
update_descriptor_queue{update_descriptor_queue_} {}
|
||||
compute_pass_descriptor_queue{compute_pass_descriptor_queue_} {}
|
||||
|
||||
Uint8Pass::~Uint8Pass() = default;
|
||||
|
||||
@@ -214,10 +214,10 @@ std::pair<VkBuffer, VkDeviceSize> Uint8Pass::Assemble(u32 num_vertices, VkBuffer
|
||||
const u32 staging_size = static_cast<u32>(num_vertices * sizeof(u16));
|
||||
const auto staging = staging_buffer_pool.Request(staging_size, MemoryUsage::DeviceLocal);
|
||||
|
||||
update_descriptor_queue.Acquire();
|
||||
update_descriptor_queue.AddBuffer(src_buffer, src_offset, num_vertices);
|
||||
update_descriptor_queue.AddBuffer(staging.buffer, staging.offset, staging_size);
|
||||
const void* const descriptor_data{update_descriptor_queue.UpdateData()};
|
||||
compute_pass_descriptor_queue.Acquire();
|
||||
compute_pass_descriptor_queue.AddBuffer(src_buffer, src_offset, num_vertices);
|
||||
compute_pass_descriptor_queue.AddBuffer(staging.buffer, staging.offset, staging_size);
|
||||
const void* const descriptor_data{compute_pass_descriptor_queue.UpdateData()};
|
||||
|
||||
scheduler.RequestOutsideRenderPassOperationContext();
|
||||
scheduler.Record([this, descriptor_data, num_vertices](vk::CommandBuffer cmdbuf) {
|
||||
@@ -242,12 +242,12 @@ std::pair<VkBuffer, VkDeviceSize> Uint8Pass::Assemble(u32 num_vertices, VkBuffer
|
||||
QuadIndexedPass::QuadIndexedPass(const Device& device_, Scheduler& scheduler_,
|
||||
DescriptorPool& descriptor_pool_,
|
||||
StagingBufferPool& staging_buffer_pool_,
|
||||
UpdateDescriptorQueue& update_descriptor_queue_)
|
||||
ComputePassDescriptorQueue& compute_pass_descriptor_queue_)
|
||||
: ComputePass(device_, descriptor_pool_, INPUT_OUTPUT_DESCRIPTOR_SET_BINDINGS,
|
||||
INPUT_OUTPUT_DESCRIPTOR_UPDATE_TEMPLATE, INPUT_OUTPUT_BANK_INFO,
|
||||
COMPUTE_PUSH_CONSTANT_RANGE<sizeof(u32) * 3>, VULKAN_QUAD_INDEXED_COMP_SPV),
|
||||
scheduler{scheduler_}, staging_buffer_pool{staging_buffer_pool_},
|
||||
update_descriptor_queue{update_descriptor_queue_} {}
|
||||
compute_pass_descriptor_queue{compute_pass_descriptor_queue_} {}
|
||||
|
||||
QuadIndexedPass::~QuadIndexedPass() = default;
|
||||
|
||||
@@ -272,10 +272,10 @@ std::pair<VkBuffer, VkDeviceSize> QuadIndexedPass::Assemble(
|
||||
const std::size_t staging_size = num_tri_vertices * sizeof(u32);
|
||||
const auto staging = staging_buffer_pool.Request(staging_size, MemoryUsage::DeviceLocal);
|
||||
|
||||
update_descriptor_queue.Acquire();
|
||||
update_descriptor_queue.AddBuffer(src_buffer, src_offset, input_size);
|
||||
update_descriptor_queue.AddBuffer(staging.buffer, staging.offset, staging_size);
|
||||
const void* const descriptor_data{update_descriptor_queue.UpdateData()};
|
||||
compute_pass_descriptor_queue.Acquire();
|
||||
compute_pass_descriptor_queue.AddBuffer(src_buffer, src_offset, input_size);
|
||||
compute_pass_descriptor_queue.AddBuffer(staging.buffer, staging.offset, staging_size);
|
||||
const void* const descriptor_data{compute_pass_descriptor_queue.UpdateData()};
|
||||
|
||||
scheduler.RequestOutsideRenderPassOperationContext();
|
||||
scheduler.Record([this, descriptor_data, num_tri_vertices, base_vertex, index_shift,
|
||||
@@ -304,13 +304,14 @@ std::pair<VkBuffer, VkDeviceSize> QuadIndexedPass::Assemble(
|
||||
ASTCDecoderPass::ASTCDecoderPass(const Device& device_, Scheduler& scheduler_,
|
||||
DescriptorPool& descriptor_pool_,
|
||||
StagingBufferPool& staging_buffer_pool_,
|
||||
UpdateDescriptorQueue& update_descriptor_queue_,
|
||||
ComputePassDescriptorQueue& compute_pass_descriptor_queue_,
|
||||
MemoryAllocator& memory_allocator_)
|
||||
: ComputePass(device_, descriptor_pool_, ASTC_DESCRIPTOR_SET_BINDINGS,
|
||||
ASTC_PASS_DESCRIPTOR_UPDATE_TEMPLATE_ENTRY, ASTC_BANK_INFO,
|
||||
COMPUTE_PUSH_CONSTANT_RANGE<sizeof(AstcPushConstants)>, ASTC_DECODER_COMP_SPV),
|
||||
scheduler{scheduler_}, staging_buffer_pool{staging_buffer_pool_},
|
||||
update_descriptor_queue{update_descriptor_queue_}, memory_allocator{memory_allocator_} {}
|
||||
compute_pass_descriptor_queue{compute_pass_descriptor_queue_}, memory_allocator{
|
||||
memory_allocator_} {}
|
||||
|
||||
ASTCDecoderPass::~ASTCDecoderPass() = default;
|
||||
|
||||
@@ -358,11 +359,11 @@ void ASTCDecoderPass::Assemble(Image& image, const StagingBufferRef& map,
|
||||
const u32 num_dispatches_y = Common::DivCeil(swizzle.num_tiles.height, 8U);
|
||||
const u32 num_dispatches_z = image.info.resources.layers;
|
||||
|
||||
update_descriptor_queue.Acquire();
|
||||
update_descriptor_queue.AddBuffer(map.buffer, input_offset,
|
||||
image.guest_size_bytes - swizzle.buffer_offset);
|
||||
update_descriptor_queue.AddImage(image.StorageImageView(swizzle.level));
|
||||
const void* const descriptor_data{update_descriptor_queue.UpdateData()};
|
||||
compute_pass_descriptor_queue.Acquire();
|
||||
compute_pass_descriptor_queue.AddBuffer(map.buffer, input_offset,
|
||||
image.guest_size_bytes - swizzle.buffer_offset);
|
||||
compute_pass_descriptor_queue.AddImage(image.StorageImageView(swizzle.level));
|
||||
const void* const descriptor_data{compute_pass_descriptor_queue.UpdateData()};
|
||||
|
||||
// To unswizzle the ASTC data
|
||||
const auto params = MakeBlockLinearSwizzle2DParams(swizzle, image.info);
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "common/common_types.h"
|
||||
#include "video_core/engines/maxwell_3d.h"
|
||||
#include "video_core/renderer_vulkan/vk_descriptor_pool.h"
|
||||
#include "video_core/renderer_vulkan/vk_update_descriptor.h"
|
||||
#include "video_core/vulkan_common/vulkan_memory_allocator.h"
|
||||
#include "video_core/vulkan_common/vulkan_wrapper.h"
|
||||
|
||||
@@ -21,7 +22,6 @@ namespace Vulkan {
|
||||
class Device;
|
||||
class StagingBufferPool;
|
||||
class Scheduler;
|
||||
class UpdateDescriptorQueue;
|
||||
class Image;
|
||||
struct StagingBufferRef;
|
||||
|
||||
@@ -50,7 +50,7 @@ class Uint8Pass final : public ComputePass {
|
||||
public:
|
||||
explicit Uint8Pass(const Device& device_, Scheduler& scheduler_,
|
||||
DescriptorPool& descriptor_pool_, StagingBufferPool& staging_buffer_pool_,
|
||||
UpdateDescriptorQueue& update_descriptor_queue_);
|
||||
ComputePassDescriptorQueue& compute_pass_descriptor_queue_);
|
||||
~Uint8Pass();
|
||||
|
||||
/// Assemble uint8 indices into an uint16 index buffer
|
||||
@@ -61,7 +61,7 @@ public:
|
||||
private:
|
||||
Scheduler& scheduler;
|
||||
StagingBufferPool& staging_buffer_pool;
|
||||
UpdateDescriptorQueue& update_descriptor_queue;
|
||||
ComputePassDescriptorQueue& compute_pass_descriptor_queue;
|
||||
};
|
||||
|
||||
class QuadIndexedPass final : public ComputePass {
|
||||
@@ -69,7 +69,7 @@ public:
|
||||
explicit QuadIndexedPass(const Device& device_, Scheduler& scheduler_,
|
||||
DescriptorPool& descriptor_pool_,
|
||||
StagingBufferPool& staging_buffer_pool_,
|
||||
UpdateDescriptorQueue& update_descriptor_queue_);
|
||||
ComputePassDescriptorQueue& compute_pass_descriptor_queue_);
|
||||
~QuadIndexedPass();
|
||||
|
||||
std::pair<VkBuffer, VkDeviceSize> Assemble(
|
||||
@@ -79,7 +79,7 @@ public:
|
||||
private:
|
||||
Scheduler& scheduler;
|
||||
StagingBufferPool& staging_buffer_pool;
|
||||
UpdateDescriptorQueue& update_descriptor_queue;
|
||||
ComputePassDescriptorQueue& compute_pass_descriptor_queue;
|
||||
};
|
||||
|
||||
class ASTCDecoderPass final : public ComputePass {
|
||||
@@ -87,7 +87,7 @@ public:
|
||||
explicit ASTCDecoderPass(const Device& device_, Scheduler& scheduler_,
|
||||
DescriptorPool& descriptor_pool_,
|
||||
StagingBufferPool& staging_buffer_pool_,
|
||||
UpdateDescriptorQueue& update_descriptor_queue_,
|
||||
ComputePassDescriptorQueue& compute_pass_descriptor_queue_,
|
||||
MemoryAllocator& memory_allocator_);
|
||||
~ASTCDecoderPass();
|
||||
|
||||
@@ -97,7 +97,7 @@ public:
|
||||
private:
|
||||
Scheduler& scheduler;
|
||||
StagingBufferPool& staging_buffer_pool;
|
||||
UpdateDescriptorQueue& update_descriptor_queue;
|
||||
ComputePassDescriptorQueue& compute_pass_descriptor_queue;
|
||||
MemoryAllocator& memory_allocator;
|
||||
};
|
||||
|
||||
|
||||
@@ -26,13 +26,13 @@ using Tegra::Texture::TexturePair;
|
||||
|
||||
ComputePipeline::ComputePipeline(const Device& device_, vk::PipelineCache& pipeline_cache_,
|
||||
DescriptorPool& descriptor_pool,
|
||||
UpdateDescriptorQueue& update_descriptor_queue_,
|
||||
GuestDescriptorQueue& guest_descriptor_queue_,
|
||||
Common::ThreadWorker* thread_worker,
|
||||
PipelineStatistics* pipeline_statistics,
|
||||
VideoCore::ShaderNotify* shader_notify, const Shader::Info& info_,
|
||||
vk::ShaderModule spv_module_)
|
||||
: device{device_}, pipeline_cache(pipeline_cache_),
|
||||
update_descriptor_queue{update_descriptor_queue_}, info{info_},
|
||||
: device{device_},
|
||||
pipeline_cache(pipeline_cache_), guest_descriptor_queue{guest_descriptor_queue_}, info{info_},
|
||||
spv_module(std::move(spv_module_)) {
|
||||
if (shader_notify) {
|
||||
shader_notify->MarkShaderBuilding();
|
||||
@@ -99,7 +99,7 @@ ComputePipeline::ComputePipeline(const Device& device_, vk::PipelineCache& pipel
|
||||
void ComputePipeline::Configure(Tegra::Engines::KeplerCompute& kepler_compute,
|
||||
Tegra::MemoryManager& gpu_memory, Scheduler& scheduler,
|
||||
BufferCache& buffer_cache, TextureCache& texture_cache) {
|
||||
update_descriptor_queue.Acquire();
|
||||
guest_descriptor_queue.Acquire();
|
||||
|
||||
buffer_cache.SetComputeUniformBufferState(info.constant_buffer_mask, &uniform_buffer_sizes);
|
||||
buffer_cache.UnbindComputeStorageBuffers();
|
||||
@@ -194,7 +194,7 @@ void ComputePipeline::Configure(Tegra::Engines::KeplerCompute& kepler_compute,
|
||||
RescalingPushConstant rescaling;
|
||||
const VkSampler* samplers_it{samplers.data()};
|
||||
const VideoCommon::ImageViewInOut* views_it{views.data()};
|
||||
PushImageDescriptors(texture_cache, update_descriptor_queue, info, rescaling, samplers_it,
|
||||
PushImageDescriptors(texture_cache, guest_descriptor_queue, info, rescaling, samplers_it,
|
||||
views_it);
|
||||
|
||||
if (!is_built.load(std::memory_order::relaxed)) {
|
||||
@@ -204,7 +204,7 @@ void ComputePipeline::Configure(Tegra::Engines::KeplerCompute& kepler_compute,
|
||||
build_condvar.wait(lock, [this] { return is_built.load(std::memory_order::relaxed); });
|
||||
});
|
||||
}
|
||||
const void* const descriptor_data{update_descriptor_queue.UpdateData()};
|
||||
const void* const descriptor_data{guest_descriptor_queue.UpdateData()};
|
||||
const bool is_rescaling = !info.texture_descriptors.empty() || !info.image_descriptors.empty();
|
||||
scheduler.Record([this, descriptor_data, is_rescaling,
|
||||
rescaling_data = rescaling.Data()](vk::CommandBuffer cmdbuf) {
|
||||
|
||||
@@ -30,7 +30,7 @@ class ComputePipeline {
|
||||
public:
|
||||
explicit ComputePipeline(const Device& device, vk::PipelineCache& pipeline_cache,
|
||||
DescriptorPool& descriptor_pool,
|
||||
UpdateDescriptorQueue& update_descriptor_queue,
|
||||
GuestDescriptorQueue& guest_descriptor_queue,
|
||||
Common::ThreadWorker* thread_worker,
|
||||
PipelineStatistics* pipeline_statistics,
|
||||
VideoCore::ShaderNotify* shader_notify, const Shader::Info& info,
|
||||
@@ -48,7 +48,7 @@ public:
|
||||
private:
|
||||
const Device& device;
|
||||
vk::PipelineCache& pipeline_cache;
|
||||
UpdateDescriptorQueue& update_descriptor_queue;
|
||||
GuestDescriptorQueue& guest_descriptor_queue;
|
||||
Shader::Info info;
|
||||
|
||||
VideoCommon::ComputeUniformBufferSizes uniform_buffer_sizes{};
|
||||
|
||||
@@ -236,13 +236,13 @@ GraphicsPipeline::GraphicsPipeline(
|
||||
Scheduler& scheduler_, BufferCache& buffer_cache_, TextureCache& texture_cache_,
|
||||
vk::PipelineCache& pipeline_cache_, VideoCore::ShaderNotify* shader_notify,
|
||||
const Device& device_, DescriptorPool& descriptor_pool,
|
||||
UpdateDescriptorQueue& update_descriptor_queue_, Common::ThreadWorker* worker_thread,
|
||||
GuestDescriptorQueue& guest_descriptor_queue_, Common::ThreadWorker* worker_thread,
|
||||
PipelineStatistics* pipeline_statistics, RenderPassCache& render_pass_cache,
|
||||
const GraphicsPipelineCacheKey& key_, std::array<vk::ShaderModule, NUM_STAGES> stages,
|
||||
const std::array<const Shader::Info*, NUM_STAGES>& infos)
|
||||
: key{key_}, device{device_}, texture_cache{texture_cache_}, buffer_cache{buffer_cache_},
|
||||
pipeline_cache(pipeline_cache_), scheduler{scheduler_},
|
||||
update_descriptor_queue{update_descriptor_queue_}, spv_modules{std::move(stages)} {
|
||||
guest_descriptor_queue{guest_descriptor_queue_}, spv_modules{std::move(stages)} {
|
||||
if (shader_notify) {
|
||||
shader_notify->MarkShaderBuilding();
|
||||
}
|
||||
@@ -449,7 +449,7 @@ void GraphicsPipeline::ConfigureImpl(bool is_indexed) {
|
||||
buffer_cache.UpdateGraphicsBuffers(is_indexed);
|
||||
buffer_cache.BindHostGeometryBuffers(is_indexed);
|
||||
|
||||
update_descriptor_queue.Acquire();
|
||||
guest_descriptor_queue.Acquire();
|
||||
|
||||
RescalingPushConstant rescaling;
|
||||
RenderAreaPushConstant render_area;
|
||||
@@ -457,7 +457,7 @@ void GraphicsPipeline::ConfigureImpl(bool is_indexed) {
|
||||
const VideoCommon::ImageViewInOut* views_it{views.data()};
|
||||
const auto prepare_stage{[&](size_t stage) LAMBDA_FORCEINLINE {
|
||||
buffer_cache.BindHostStageBuffers(stage);
|
||||
PushImageDescriptors(texture_cache, update_descriptor_queue, stage_infos[stage], rescaling,
|
||||
PushImageDescriptors(texture_cache, guest_descriptor_queue, stage_infos[stage], rescaling,
|
||||
samplers_it, views_it);
|
||||
const auto& info{stage_infos[0]};
|
||||
if (info.uses_render_area) {
|
||||
@@ -499,7 +499,7 @@ void GraphicsPipeline::ConfigureDraw(const RescalingPushConstant& rescaling,
|
||||
const bool is_rescaling{texture_cache.IsRescaling()};
|
||||
const bool update_rescaling{scheduler.UpdateRescaling(is_rescaling)};
|
||||
const bool bind_pipeline{scheduler.UpdateGraphicsPipeline(this)};
|
||||
const void* const descriptor_data{update_descriptor_queue.UpdateData()};
|
||||
const void* const descriptor_data{guest_descriptor_queue.UpdateData()};
|
||||
scheduler.Record([this, descriptor_data, bind_pipeline, rescaling_data = rescaling.Data(),
|
||||
is_rescaling, update_rescaling,
|
||||
uses_render_area = render_area.uses_render_area,
|
||||
|
||||
@@ -64,7 +64,6 @@ class RenderPassCache;
|
||||
class RescalingPushConstant;
|
||||
class RenderAreaPushConstant;
|
||||
class Scheduler;
|
||||
class UpdateDescriptorQueue;
|
||||
|
||||
class GraphicsPipeline {
|
||||
static constexpr size_t NUM_STAGES = Tegra::Engines::Maxwell3D::Regs::MaxShaderStage;
|
||||
@@ -74,7 +73,7 @@ public:
|
||||
Scheduler& scheduler, BufferCache& buffer_cache, TextureCache& texture_cache,
|
||||
vk::PipelineCache& pipeline_cache, VideoCore::ShaderNotify* shader_notify,
|
||||
const Device& device, DescriptorPool& descriptor_pool,
|
||||
UpdateDescriptorQueue& update_descriptor_queue, Common::ThreadWorker* worker_thread,
|
||||
GuestDescriptorQueue& guest_descriptor_queue, Common::ThreadWorker* worker_thread,
|
||||
PipelineStatistics* pipeline_statistics, RenderPassCache& render_pass_cache,
|
||||
const GraphicsPipelineCacheKey& key, std::array<vk::ShaderModule, NUM_STAGES> stages,
|
||||
const std::array<const Shader::Info*, NUM_STAGES>& infos);
|
||||
@@ -133,7 +132,7 @@ private:
|
||||
BufferCache& buffer_cache;
|
||||
vk::PipelineCache& pipeline_cache;
|
||||
Scheduler& scheduler;
|
||||
UpdateDescriptorQueue& update_descriptor_queue;
|
||||
GuestDescriptorQueue& guest_descriptor_queue;
|
||||
|
||||
void (*configure_func)(GraphicsPipeline*, bool){};
|
||||
|
||||
|
||||
@@ -277,11 +277,11 @@ bool GraphicsPipelineCacheKey::operator==(const GraphicsPipelineCacheKey& rhs) c
|
||||
|
||||
PipelineCache::PipelineCache(RasterizerVulkan& rasterizer_, const Device& device_,
|
||||
Scheduler& scheduler_, DescriptorPool& descriptor_pool_,
|
||||
UpdateDescriptorQueue& update_descriptor_queue_,
|
||||
GuestDescriptorQueue& guest_descriptor_queue_,
|
||||
RenderPassCache& render_pass_cache_, BufferCache& buffer_cache_,
|
||||
TextureCache& texture_cache_, VideoCore::ShaderNotify& shader_notify_)
|
||||
: VideoCommon::ShaderCache{rasterizer_}, device{device_}, scheduler{scheduler_},
|
||||
descriptor_pool{descriptor_pool_}, update_descriptor_queue{update_descriptor_queue_},
|
||||
descriptor_pool{descriptor_pool_}, guest_descriptor_queue{guest_descriptor_queue_},
|
||||
render_pass_cache{render_pass_cache_}, buffer_cache{buffer_cache_},
|
||||
texture_cache{texture_cache_}, shader_notify{shader_notify_},
|
||||
use_asynchronous_shaders{Settings::values.use_asynchronous_shaders.GetValue()},
|
||||
@@ -643,7 +643,7 @@ std::unique_ptr<GraphicsPipeline> PipelineCache::CreateGraphicsPipeline(
|
||||
Common::ThreadWorker* const thread_worker{build_in_parallel ? &workers : nullptr};
|
||||
return std::make_unique<GraphicsPipeline>(
|
||||
scheduler, buffer_cache, texture_cache, vulkan_pipeline_cache, &shader_notify, device,
|
||||
descriptor_pool, update_descriptor_queue, thread_worker, statistics, render_pass_cache, key,
|
||||
descriptor_pool, guest_descriptor_queue, thread_worker, statistics, render_pass_cache, key,
|
||||
std::move(modules), infos);
|
||||
|
||||
} catch (const Shader::Exception& exception) {
|
||||
@@ -722,7 +722,7 @@ std::unique_ptr<ComputePipeline> PipelineCache::CreateComputePipeline(
|
||||
}
|
||||
Common::ThreadWorker* const thread_worker{build_in_parallel ? &workers : nullptr};
|
||||
return std::make_unique<ComputePipeline>(device, vulkan_pipeline_cache, descriptor_pool,
|
||||
update_descriptor_queue, thread_worker, statistics,
|
||||
guest_descriptor_queue, thread_worker, statistics,
|
||||
&shader_notify, program.info, std::move(spv_module));
|
||||
|
||||
} catch (const Shader::Exception& exception) {
|
||||
|
||||
@@ -82,7 +82,6 @@ class PipelineStatistics;
|
||||
class RasterizerVulkan;
|
||||
class RenderPassCache;
|
||||
class Scheduler;
|
||||
class UpdateDescriptorQueue;
|
||||
|
||||
using VideoCommon::ShaderInfo;
|
||||
|
||||
@@ -102,7 +101,7 @@ class PipelineCache : public VideoCommon::ShaderCache {
|
||||
public:
|
||||
explicit PipelineCache(RasterizerVulkan& rasterizer, const Device& device, Scheduler& scheduler,
|
||||
DescriptorPool& descriptor_pool,
|
||||
UpdateDescriptorQueue& update_descriptor_queue,
|
||||
GuestDescriptorQueue& guest_descriptor_queue,
|
||||
RenderPassCache& render_pass_cache, BufferCache& buffer_cache,
|
||||
TextureCache& texture_cache, VideoCore::ShaderNotify& shader_notify_);
|
||||
~PipelineCache();
|
||||
@@ -144,7 +143,7 @@ private:
|
||||
const Device& device;
|
||||
Scheduler& scheduler;
|
||||
DescriptorPool& descriptor_pool;
|
||||
UpdateDescriptorQueue& update_descriptor_queue;
|
||||
GuestDescriptorQueue& guest_descriptor_queue;
|
||||
RenderPassCache& render_pass_cache;
|
||||
BufferCache& buffer_cache;
|
||||
TextureCache& texture_cache;
|
||||
|
||||
@@ -160,17 +160,16 @@ RasterizerVulkan::RasterizerVulkan(Core::Frontend::EmuWindow& emu_window_, Tegra
|
||||
: RasterizerAccelerated{cpu_memory_}, gpu{gpu_}, screen_info{screen_info_}, device{device_},
|
||||
memory_allocator{memory_allocator_}, state_tracker{state_tracker_}, scheduler{scheduler_},
|
||||
staging_pool(device, memory_allocator, scheduler), descriptor_pool(device, scheduler),
|
||||
update_descriptor_queue(device, scheduler),
|
||||
blit_image(device, scheduler, state_tracker, descriptor_pool),
|
||||
render_pass_cache(device), texture_cache_runtime{device, scheduler,
|
||||
memory_allocator, staging_pool,
|
||||
blit_image, render_pass_cache,
|
||||
descriptor_pool, update_descriptor_queue},
|
||||
guest_descriptor_queue(device, scheduler), compute_pass_descriptor_queue(device, scheduler),
|
||||
blit_image(device, scheduler, state_tracker, descriptor_pool), render_pass_cache(device),
|
||||
texture_cache_runtime{
|
||||
device, scheduler, memory_allocator, staging_pool,
|
||||
blit_image, render_pass_cache, descriptor_pool, compute_pass_descriptor_queue},
|
||||
texture_cache(texture_cache_runtime, *this),
|
||||
buffer_cache_runtime(device, memory_allocator, scheduler, staging_pool,
|
||||
update_descriptor_queue, descriptor_pool),
|
||||
guest_descriptor_queue, compute_pass_descriptor_queue, descriptor_pool),
|
||||
buffer_cache(*this, cpu_memory_, buffer_cache_runtime),
|
||||
pipeline_cache(*this, device, scheduler, descriptor_pool, update_descriptor_queue,
|
||||
pipeline_cache(*this, device, scheduler, descriptor_pool, guest_descriptor_queue,
|
||||
render_pass_cache, buffer_cache, texture_cache, gpu.ShaderNotify()),
|
||||
query_cache{*this, cpu_memory_, device, scheduler},
|
||||
accelerate_dma(buffer_cache, texture_cache, scheduler),
|
||||
@@ -349,12 +348,25 @@ void RasterizerVulkan::Clear(u32 layer_count) {
|
||||
|
||||
const u32 color_attachment = regs.clear_surface.RT;
|
||||
if (use_color && framebuffer->HasAspectColorBit(color_attachment)) {
|
||||
const auto format =
|
||||
VideoCore::Surface::PixelFormatFromRenderTargetFormat(regs.rt[color_attachment].format);
|
||||
bool is_integer = IsPixelFormatInteger(format);
|
||||
bool is_signed = IsPixelFormatSignedInteger(format);
|
||||
size_t int_size = PixelComponentSizeBitsInteger(format);
|
||||
VkClearValue clear_value{};
|
||||
VkClearValue clear_value;
|
||||
bool is_integer = false;
|
||||
bool is_signed = false;
|
||||
size_t int_size = 8;
|
||||
for (std::size_t i = 0; i < Tegra::Engines::Maxwell3D::Regs::NumRenderTargets; ++i) {
|
||||
const auto& this_rt = regs.rt[i];
|
||||
if (this_rt.Address() == 0) {
|
||||
continue;
|
||||
}
|
||||
if (this_rt.format == Tegra::RenderTargetFormat::NONE) {
|
||||
continue;
|
||||
}
|
||||
const auto format =
|
||||
VideoCore::Surface::PixelFormatFromRenderTargetFormat(this_rt.format);
|
||||
is_integer = IsPixelFormatInteger(format);
|
||||
is_signed = IsPixelFormatSignedInteger(format);
|
||||
int_size = PixelComponentSizeBitsInteger(format);
|
||||
break;
|
||||
}
|
||||
if (!is_integer) {
|
||||
std::memcpy(clear_value.color.float32, regs.clear_color.data(),
|
||||
regs.clear_color.size() * sizeof(f32));
|
||||
@@ -656,7 +668,8 @@ void RasterizerVulkan::FlushCommands() {
|
||||
|
||||
void RasterizerVulkan::TickFrame() {
|
||||
draw_counter = 0;
|
||||
update_descriptor_queue.TickFrame();
|
||||
guest_descriptor_queue.TickFrame();
|
||||
compute_pass_descriptor_queue.TickFrame();
|
||||
fence_manager.TickFrame();
|
||||
staging_pool.TickFrame();
|
||||
{
|
||||
|
||||
@@ -184,7 +184,8 @@ private:
|
||||
|
||||
StagingBufferPool staging_pool;
|
||||
DescriptorPool descriptor_pool;
|
||||
UpdateDescriptorQueue update_descriptor_queue;
|
||||
GuestDescriptorQueue guest_descriptor_queue;
|
||||
ComputePassDescriptorQueue compute_pass_descriptor_queue;
|
||||
BlitImageHelper blit_image;
|
||||
RenderPassCache render_pass_cache;
|
||||
|
||||
|
||||
@@ -798,13 +798,13 @@ TextureCacheRuntime::TextureCacheRuntime(const Device& device_, Scheduler& sched
|
||||
BlitImageHelper& blit_image_helper_,
|
||||
RenderPassCache& render_pass_cache_,
|
||||
DescriptorPool& descriptor_pool,
|
||||
UpdateDescriptorQueue& update_descriptor_queue)
|
||||
ComputePassDescriptorQueue& compute_pass_descriptor_queue)
|
||||
: device{device_}, scheduler{scheduler_}, memory_allocator{memory_allocator_},
|
||||
staging_buffer_pool{staging_buffer_pool_}, blit_image_helper{blit_image_helper_},
|
||||
render_pass_cache{render_pass_cache_}, resolution{Settings::values.resolution_info} {
|
||||
if (Settings::values.accelerate_astc) {
|
||||
astc_decoder_pass.emplace(device, scheduler, descriptor_pool, staging_buffer_pool,
|
||||
update_descriptor_queue, memory_allocator);
|
||||
compute_pass_descriptor_queue, memory_allocator);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,6 @@ class ImageView;
|
||||
class Framebuffer;
|
||||
class RenderPassCache;
|
||||
class StagingBufferPool;
|
||||
class UpdateDescriptorQueue;
|
||||
class Scheduler;
|
||||
|
||||
class TextureCacheRuntime {
|
||||
@@ -45,7 +44,7 @@ public:
|
||||
BlitImageHelper& blit_image_helper_,
|
||||
RenderPassCache& render_pass_cache_,
|
||||
DescriptorPool& descriptor_pool,
|
||||
UpdateDescriptorQueue& update_descriptor_queue);
|
||||
ComputePassDescriptorQueue& compute_pass_descriptor_queue);
|
||||
|
||||
void Finish();
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ class UpdateDescriptorQueue final {
|
||||
// This should be plenty for the vast majority of cases. Most desktop platforms only
|
||||
// provide up to 3 swapchain images.
|
||||
static constexpr size_t FRAMES_IN_FLIGHT = 5;
|
||||
static constexpr size_t FRAME_PAYLOAD_SIZE = 0x10000;
|
||||
static constexpr size_t FRAME_PAYLOAD_SIZE = 0x20000;
|
||||
static constexpr size_t PAYLOAD_SIZE = FRAME_PAYLOAD_SIZE * FRAMES_IN_FLIGHT;
|
||||
|
||||
public:
|
||||
@@ -86,4 +86,8 @@ private:
|
||||
std::array<DescriptorUpdateEntry, PAYLOAD_SIZE> payload;
|
||||
};
|
||||
|
||||
// TODO: should these be separate classes instead?
|
||||
using GuestDescriptorQueue = UpdateDescriptorQueue;
|
||||
using ComputePassDescriptorQueue = UpdateDescriptorQueue;
|
||||
|
||||
} // namespace Vulkan
|
||||
|
||||
@@ -1469,7 +1469,7 @@ std::optional<typename TextureCache<P>::BlitImages> TextureCache<P>::GetBlitImag
|
||||
if (!copy.must_accelerate) {
|
||||
do {
|
||||
if (!src_id && !dst_id) {
|
||||
return std::nullopt;
|
||||
break;
|
||||
}
|
||||
if (src_id && True(slot_images[src_id].flags & ImageFlagBits::GpuModified)) {
|
||||
break;
|
||||
|
||||
@@ -443,6 +443,7 @@ void Config::ReadControlValues() {
|
||||
ReadBasicSetting(Settings::values.mouse_panning_sensitivity);
|
||||
ReadBasicSetting(Settings::values.enable_joycon_driver);
|
||||
ReadBasicSetting(Settings::values.enable_procon_driver);
|
||||
ReadBasicSetting(Settings::values.random_amiibo_id);
|
||||
|
||||
ReadBasicSetting(Settings::values.tas_enable);
|
||||
ReadBasicSetting(Settings::values.tas_loop);
|
||||
@@ -1150,6 +1151,7 @@ void Config::SaveControlValues() {
|
||||
WriteBasicSetting(Settings::values.enable_raw_input);
|
||||
WriteBasicSetting(Settings::values.enable_joycon_driver);
|
||||
WriteBasicSetting(Settings::values.enable_procon_driver);
|
||||
WriteBasicSetting(Settings::values.random_amiibo_id);
|
||||
WriteBasicSetting(Settings::values.keyboard_enabled);
|
||||
WriteBasicSetting(Settings::values.emulate_analog_keyboard);
|
||||
WriteBasicSetting(Settings::values.mouse_panning_sensitivity);
|
||||
|
||||
@@ -140,6 +140,7 @@ void ConfigureInputAdvanced::ApplyConfiguration() {
|
||||
Settings::values.enable_ir_sensor = ui->enable_ir_sensor->isChecked();
|
||||
Settings::values.enable_joycon_driver = ui->enable_joycon_driver->isChecked();
|
||||
Settings::values.enable_procon_driver = ui->enable_procon_driver->isChecked();
|
||||
Settings::values.random_amiibo_id = ui->random_amiibo_id->isChecked();
|
||||
}
|
||||
|
||||
void ConfigureInputAdvanced::LoadConfiguration() {
|
||||
@@ -176,6 +177,7 @@ void ConfigureInputAdvanced::LoadConfiguration() {
|
||||
ui->enable_ir_sensor->setChecked(Settings::values.enable_ir_sensor.GetValue());
|
||||
ui->enable_joycon_driver->setChecked(Settings::values.enable_joycon_driver.GetValue());
|
||||
ui->enable_procon_driver->setChecked(Settings::values.enable_procon_driver.GetValue());
|
||||
ui->random_amiibo_id->setChecked(Settings::values.random_amiibo_id.GetValue());
|
||||
|
||||
UpdateUIEnabled();
|
||||
}
|
||||
|
||||
@@ -2728,6 +2728,22 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QCheckBox" name="random_amiibo_id">
|
||||
<property name="toolTip">
|
||||
<string>Allows unlimited uses of the same Amiibo in games that would otherwise limit you to one use.</string>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>23</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Use random Amiibo ID</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="QCheckBox" name="mouse_panning">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
@@ -2740,7 +2756,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="2">
|
||||
<item row="8" column="2">
|
||||
<widget class="QSpinBox" name="mouse_panning_sensitivity">
|
||||
<property name="toolTip">
|
||||
<string>Mouse sensitivity</string>
|
||||
@@ -2762,14 +2778,14 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<item row="9" column="0">
|
||||
<widget class="QLabel" name="motion_touch">
|
||||
<property name="text">
|
||||
<string>Motion / Touch</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="2">
|
||||
<item row="9" column="2">
|
||||
<widget class="QPushButton" name="buttonMotionTouch">
|
||||
<property name="text">
|
||||
<string>Configure</string>
|
||||
|
||||
@@ -169,6 +169,7 @@ void Config::ReadValues() {
|
||||
ReadSetting("ControlsGeneral", Settings::values.enable_raw_input);
|
||||
ReadSetting("ControlsGeneral", Settings::values.enable_joycon_driver);
|
||||
ReadSetting("ControlsGeneral", Settings::values.enable_procon_driver);
|
||||
ReadSetting("ControlsGeneral", Settings::values.random_amiibo_id);
|
||||
ReadSetting("ControlsGeneral", Settings::values.emulate_analog_keyboard);
|
||||
ReadSetting("ControlsGeneral", Settings::values.vibration_enabled);
|
||||
ReadSetting("ControlsGeneral", Settings::values.enable_accurate_vibrations);
|
||||
|
||||
Reference in New Issue
Block a user