From bfa57b3fe9561dd88b5623071c4dfdef357aa468 Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Wed, 30 Nov 2022 02:37:58 +0100 Subject: [PATCH] early-access version 3167 --- README.md | 2 +- src/video_core/engines/engine_upload.cpp | 7 +- src/video_core/engines/engine_upload.h | 2 +- src/video_core/engines/fermi_2d.h | 2 +- src/video_core/engines/kepler_compute.cpp | 6 +- src/video_core/engines/kepler_compute.h | 14 ++-- src/video_core/engines/kepler_memory.cpp | 6 +- src/video_core/engines/maxwell_3d.cpp | 12 ++-- src/video_core/engines/maxwell_3d.h | 79 ++++++++------------- src/video_core/engines/maxwell_dma.cpp | 14 ++-- src/video_core/engines/puller.cpp | 6 +- src/video_core/host1x/syncpoint_manager.cpp | 6 +- src/video_core/host1x/syncpoint_manager.h | 12 ++-- 13 files changed, 69 insertions(+), 99 deletions(-) diff --git a/README.md b/README.md index 83373d2e8..1101a2b3a 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 3166. +This is the source code for early-access 3167. ## Legal Notice diff --git a/src/video_core/engines/engine_upload.cpp b/src/video_core/engines/engine_upload.cpp index cf87e3fbb..f1d01b38c 100755 --- a/src/video_core/engines/engine_upload.cpp +++ b/src/video_core/engines/engine_upload.cpp @@ -49,10 +49,9 @@ void State::ProcessData(std::span read_buffer) { if (regs.line_count == 1) { rasterizer->AccelerateInlineToMemory(address, copy_size, read_buffer); } else { - for (u32 line = 0; line < regs.line_count; ++line) { - const GPUVAddr dest_line = address + static_cast(line) * regs.dest.pitch; - std::span buffer(read_buffer.data() + - static_cast(line) * regs.line_length_in, + for (size_t line = 0; line < regs.line_count; ++line) { + const GPUVAddr dest_line = address + line * regs.dest.pitch; + std::span buffer(read_buffer.data() + line * regs.line_length_in, regs.line_length_in); rasterizer->AccelerateInlineToMemory(dest_line, regs.line_length_in, buffer); } diff --git a/src/video_core/engines/engine_upload.h b/src/video_core/engines/engine_upload.h index 79d92e8b4..ae814b743 100755 --- a/src/video_core/engines/engine_upload.h +++ b/src/video_core/engines/engine_upload.h @@ -39,7 +39,7 @@ struct Registers { u32 y; GPUVAddr Address() const { - return static_cast((static_cast(address_high) << 32) | address_low); + return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low}; } u32 BlockWidth() const { diff --git a/src/video_core/engines/fermi_2d.h b/src/video_core/engines/fermi_2d.h index 4240df819..634d0bc99 100755 --- a/src/video_core/engines/fermi_2d.h +++ b/src/video_core/engines/fermi_2d.h @@ -97,7 +97,7 @@ public: u32 addr_lower; [[nodiscard]] constexpr GPUVAddr Address() const noexcept { - return (static_cast(addr_upper) << 32) | static_cast(addr_lower); + return (GPUVAddr{addr_upper} << 32) | GPUVAddr{addr_lower}; } }; static_assert(sizeof(Surface) == 0x28, "Surface has incorrect size"); diff --git a/src/video_core/engines/kepler_compute.cpp b/src/video_core/engines/kepler_compute.cpp index 3dc87fc51..4f5361556 100755 --- a/src/video_core/engines/kepler_compute.cpp +++ b/src/video_core/engines/kepler_compute.cpp @@ -50,11 +50,11 @@ void KeplerCompute::CallMultiMethod(u32 method, const u32* base_start, u32 amoun u32 methods_pending) { switch (method) { case KEPLER_COMPUTE_REG_INDEX(data_upload): - upload_state.ProcessData(base_start, static_cast(amount)); + upload_state.ProcessData(base_start, amount); return; default: - for (std::size_t i = 0; i < amount; i++) { - CallMethod(method, base_start[i], methods_pending - static_cast(i) <= 1); + for (u32 i = 0; i < amount; i++) { + CallMethod(method, base_start[i], methods_pending - i <= 1); } break; } diff --git a/src/video_core/engines/kepler_compute.h b/src/video_core/engines/kepler_compute.h index 48005b2da..267180ba1 100755 --- a/src/video_core/engines/kepler_compute.h +++ b/src/video_core/engines/kepler_compute.h @@ -68,7 +68,7 @@ public: struct { u32 address; GPUVAddr Address() const { - return static_cast((static_cast(address) << 8)); + return GPUVAddr{address} << 8; } } launch_desc_loc; @@ -83,8 +83,7 @@ public: u32 address_low; u32 limit; GPUVAddr Address() const { - return static_cast((static_cast(address_high) << 32) | - address_low); + return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low}; } } tsc; @@ -95,8 +94,7 @@ public: u32 address_low; u32 limit; GPUVAddr Address() const { - return static_cast((static_cast(address_high) << 32) | - address_low); + return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low}; } } tic; @@ -106,8 +104,7 @@ public: u32 address_high; u32 address_low; GPUVAddr Address() const { - return static_cast((static_cast(address_high) << 32) | - address_low); + return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low}; } } code_loc; @@ -162,8 +159,7 @@ public: BitField<15, 17, u32> size; }; GPUVAddr Address() const { - return static_cast((static_cast(address_high.Value()) << 32) | - address_low); + return (GPUVAddr{address_high.Value()} << 32) | GPUVAddr{address_low}; } }; std::array const_buffer_config; diff --git a/src/video_core/engines/kepler_memory.cpp b/src/video_core/engines/kepler_memory.cpp index cd5e3a773..4afd7a0ec 100755 --- a/src/video_core/engines/kepler_memory.cpp +++ b/src/video_core/engines/kepler_memory.cpp @@ -42,11 +42,11 @@ void KeplerMemory::CallMultiMethod(u32 method, const u32* base_start, u32 amount u32 methods_pending) { switch (method) { case KEPLERMEMORY_REG_INDEX(data): - upload_state.ProcessData(base_start, static_cast(amount)); + upload_state.ProcessData(base_start, amount); return; default: - for (std::size_t i = 0; i < amount; i++) { - CallMethod(method, base_start[i], methods_pending - static_cast(i) <= 1); + for (u32 i = 0; i < amount; i++) { + CallMethod(method, base_start[i], methods_pending - i <= 1); } break; } diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp index 6fe957b9a..7504aa338 100755 --- a/src/video_core/engines/maxwell_3d.cpp +++ b/src/video_core/engines/maxwell_3d.cpp @@ -370,11 +370,11 @@ void Maxwell3D::CallMultiMethod(u32 method, const u32* base_start, u32 amount, ProcessCBMultiData(base_start, amount); break; case MAXWELL3D_REG_INDEX(inline_data): - upload_state.ProcessData(base_start, static_cast(amount)); + upload_state.ProcessData(base_start, amount); return; default: - for (std::size_t i = 0; i < amount; i++) { - CallMethod(method, base_start[i], methods_pending - static_cast(i) <= 1); + for (u32 i = 0; i < amount; i++) { + CallMethod(method, base_start[i], methods_pending - i <= 1); } break; } @@ -652,12 +652,12 @@ void Maxwell3D::ProcessDeferredDraw() { return; } - u32 method_count = static_cast(deferred_draw_method.size()); + const auto method_count = deferred_draw_method.size(); u32 instance_count = 1; u32 vertex_buffer_count = 0; u32 index_buffer_count = 0; - for (u32 index = 0; index < method_count; ++index) { - u32 method = deferred_draw_method[index]; + for (size_t index = 0; index < method_count; ++index) { + const u32 method = deferred_draw_method[index]; if (method == MAXWELL3D_REG_INDEX(vertex_buffer.count)) { instance_count = ++vertex_buffer_count; } else if (method == MAXWELL3D_REG_INDEX(index_buffer.count)) { diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h index ffb9f275f..29de88df9 100755 --- a/src/video_core/engines/maxwell_3d.h +++ b/src/video_core/engines/maxwell_3d.h @@ -96,8 +96,7 @@ public: u32 type; GPUVAddr Address() const { - return static_cast((static_cast(address_high) << 32) | - address_low); + return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low}; } }; @@ -106,8 +105,7 @@ public: u32 address_low; GPUVAddr Address() const { - return static_cast((static_cast(address_high) << 32) | - address_low); + return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low}; } }; @@ -124,8 +122,7 @@ public: Mode mode; GPUVAddr Address() const { - return static_cast((static_cast(offset_high) << 32) | - offset_low); + return (GPUVAddr{offset_high} << 32) | GPUVAddr{offset_low}; } }; @@ -187,7 +184,7 @@ public: default: // Thresholds begin at 0x10 (1 << 4) // Threshold is in the range 0x1 to 0x13 - return 1 << (4 + threshold.Value() - 1); + return 1U << (4 + threshold.Value() - 1); } } }; @@ -468,8 +465,7 @@ public: INSERT_PADDING_BYTES_NOINIT(0xC); GPUVAddr Address() const { - return static_cast((static_cast(address_high) << 32) | - address_low); + return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low}; } }; static_assert(sizeof(Buffer) == 0x20); @@ -511,12 +507,11 @@ public: u32 default_size_per_warp; GPUVAddr Address() const { - return static_cast((static_cast(address_high) << 32) | - address_low); + return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low}; } u64 Size() const { - return (static_cast(size_high) << 32) | size_low; + return (u64{size_high} << 32) | u64{size_low}; } }; @@ -538,13 +533,11 @@ public: u32 storage_limit_address_low; GPUVAddr StorageAddress() const { - return static_cast((static_cast(storage_address_high) << 32) | - storage_address_low); + return (GPUVAddr{storage_address_high} << 32) | GPUVAddr{storage_address_low}; } GPUVAddr StorageLimitAddress() const { - return static_cast( - (static_cast(storage_limit_address_high) << 32) | - storage_limit_address_low); + return (GPUVAddr{storage_limit_address_high} << 32) | + GPUVAddr{storage_limit_address_low}; } }; @@ -829,11 +822,11 @@ public: struct CompressionThresholdSamples { u32 samples; - u32 Samples() { + u32 Samples() const { if (samples == 0) { return 0; } - return 1 << (samples - 1); + return 1U << (samples - 1); } }; @@ -1138,8 +1131,7 @@ public: INSERT_PADDING_BYTES_NOINIT(0x18); GPUVAddr Address() const { - return static_cast((static_cast(address_high) << 32) | - address_low); + return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low}; } }; static_assert(sizeof(RenderTargetConfig) == 0x40); @@ -1482,8 +1474,7 @@ public: u32 address_low; GPUVAddr Address() const { - return static_cast((static_cast(address_high) << 32) | - address_low); + return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low}; } }; @@ -1533,8 +1524,7 @@ public: u32 address_low; GPUVAddr Address() const { - return static_cast((static_cast(address_high) << 32) | - address_low); + return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low}; } }; @@ -1561,8 +1551,7 @@ public: u32 array_pitch; GPUVAddr Address() const { - return static_cast((static_cast(address_high) << 32) | - address_low); + return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low}; } }; @@ -1910,8 +1899,7 @@ public: Mode mode; GPUVAddr Address() const { - return static_cast((static_cast(address_high) << 32) | - address_low); + return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low}; } }; @@ -1921,8 +1909,7 @@ public: u32 limit; GPUVAddr Address() const { - return static_cast((static_cast(address_high) << 32) | - address_low); + return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low}; } }; @@ -1932,8 +1919,7 @@ public: u32 limit; GPUVAddr Address() const { - return static_cast((static_cast(address_high) << 32) | - address_low); + return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low}; } }; @@ -1981,8 +1967,7 @@ public: u32 address_low; GPUVAddr Address() const { - return static_cast((static_cast(address_high) << 32) | - address_low); + return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low}; } }; @@ -2027,8 +2012,7 @@ public: u32 address_low; GPUVAddr Address() const { - return static_cast((static_cast(address_high) << 32) | - address_low); + return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low}; } }; @@ -2224,19 +2208,16 @@ public: } GPUVAddr StartAddress() const { - return static_cast((static_cast(start_addr_high) << 32) | - start_addr_low); + return (GPUVAddr{start_addr_high} << 32) | GPUVAddr{start_addr_low}; } GPUVAddr EndAddress() const { - return static_cast((static_cast(limit_addr_high) << 32) | - limit_addr_low); + return (GPUVAddr{limit_addr_high} << 32) | GPUVAddr{limit_addr_low}; } /// Adjust the index buffer offset so it points to the first desired index. GPUVAddr IndexStart() const { - return StartAddress() + - static_cast(first) * static_cast(FormatSizeInBytes()); + return StartAddress() + size_t{first} * size_t{FormatSizeInBytes()}; } }; @@ -2464,8 +2445,7 @@ public: } query; GPUVAddr Address() const { - return static_cast((static_cast(address_high) << 32) | - address_low); + return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low}; } }; @@ -2479,8 +2459,7 @@ public: u32 frequency; GPUVAddr Address() const { - return static_cast((static_cast(address_high) << 32) | - address_low); + return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low}; } bool IsEnabled() const { @@ -2494,8 +2473,7 @@ public: u32 address_low; GPUVAddr Address() const { - return static_cast((static_cast(address_high) << 32) | - address_low); + return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low}; } }; static_assert(sizeof(VertexStreamLimit) == 0x8); @@ -2543,8 +2521,7 @@ public: std::array buffer; GPUVAddr Address() const { - return static_cast((static_cast(address_high) << 32) | - address_low); + return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low}; } }; diff --git a/src/video_core/engines/maxwell_dma.cpp b/src/video_core/engines/maxwell_dma.cpp index 72eb9cd2b..f6cd0d166 100755 --- a/src/video_core/engines/maxwell_dma.cpp +++ b/src/video_core/engines/maxwell_dma.cpp @@ -41,8 +41,8 @@ void MaxwellDMA::CallMethod(u32 method, u32 method_argument, bool is_last_call) void MaxwellDMA::CallMultiMethod(u32 method, const u32* base_start, u32 amount, u32 methods_pending) { - for (size_t i = 0; i < amount; ++i) { - CallMethod(method, base_start[i], methods_pending - static_cast(i) <= 1); + for (u32 i = 0; i < amount; ++i) { + CallMethod(method, base_start[i], methods_pending - i <= 1); } } @@ -94,14 +94,14 @@ void MaxwellDMA::Launch() { reinterpret_cast(tmp_buffer.data()), regs.line_length_in * sizeof(u32)); } else { - auto convert_linear_2_blocklinear_addr = [](u64 address) { + const auto convert_linear_2_blocklinear_addr = [](u64 address) { return (address & ~0x1f0ULL) | ((address & 0x40) >> 2) | ((address & 0x10) << 1) | ((address & 0x180) >> 1) | ((address & 0x20) << 3); }; - auto src_kind = memory_manager.GetPageKind(regs.offset_in); - auto dst_kind = memory_manager.GetPageKind(regs.offset_out); - const bool is_src_pitch = IsPitchKind(static_cast(src_kind)); - const bool is_dst_pitch = IsPitchKind(static_cast(dst_kind)); + const auto src_kind = memory_manager.GetPageKind(regs.offset_in); + const auto dst_kind = memory_manager.GetPageKind(regs.offset_out); + const bool is_src_pitch = IsPitchKind(src_kind); + const bool is_dst_pitch = IsPitchKind(dst_kind); if (!is_src_pitch && is_dst_pitch) { UNIMPLEMENTED_IF(regs.line_length_in % 16 != 0); UNIMPLEMENTED_IF(regs.offset_in % 16 != 0); diff --git a/src/video_core/engines/puller.cpp b/src/video_core/engines/puller.cpp index 89bf47272..8a989b4cb 100755 --- a/src/video_core/engines/puller.cpp +++ b/src/video_core/engines/puller.cpp @@ -31,7 +31,7 @@ void Puller::ProcessBindMethod(const MethodCall& method_call) { LOG_DEBUG(HW_GPU, "Binding subchannel {} to engine {}", method_call.subchannel, method_call.argument); const auto engine_id = static_cast(method_call.argument); - bound_engines[method_call.subchannel] = static_cast(engine_id); + bound_engines[method_call.subchannel] = engine_id; switch (engine_id) { case EngineID::FERMI_TWOD_A: dma_pusher.BindSubchannel(channel_state.fermi_2d.get(), method_call.subchannel); @@ -285,12 +285,12 @@ void Puller::CallMultiMethod(u32 method, u32 subchannel, const u32* base_start, if (ExecuteMethodOnEngine(method)) { CallEngineMultiMethod(method, subchannel, base_start, amount, methods_pending); } else { - for (std::size_t i = 0; i < amount; i++) { + for (u32 i = 0; i < amount; i++) { CallPullerMethod(MethodCall{ method, base_start[i], subchannel, - methods_pending - static_cast(i), + methods_pending - i, }); } } diff --git a/src/video_core/host1x/syncpoint_manager.cpp b/src/video_core/host1x/syncpoint_manager.cpp index 7aaaee24b..eb5dd8d70 100755 --- a/src/video_core/host1x/syncpoint_manager.cpp +++ b/src/video_core/host1x/syncpoint_manager.cpp @@ -34,7 +34,7 @@ SyncpointManager::ActionHandle SyncpointManager::RegisterAction( } void SyncpointManager::DeregisterAction(std::list& action_storage, - ActionHandle& handle) { + const ActionHandle& handle) { std::unique_lock lk(guard); // We want to ensure the iterator still exists prior to erasing it @@ -49,11 +49,11 @@ void SyncpointManager::DeregisterAction(std::list& action_stor } } -void SyncpointManager::DeregisterGuestAction(u32 syncpoint_id, ActionHandle& handle) { +void SyncpointManager::DeregisterGuestAction(u32 syncpoint_id, const ActionHandle& handle) { DeregisterAction(guest_action_storage[syncpoint_id], handle); } -void SyncpointManager::DeregisterHostAction(u32 syncpoint_id, ActionHandle& handle) { +void SyncpointManager::DeregisterHostAction(u32 syncpoint_id, const ActionHandle& handle) { DeregisterAction(host_action_storage[syncpoint_id], handle); } diff --git a/src/video_core/host1x/syncpoint_manager.h b/src/video_core/host1x/syncpoint_manager.h index d31f703de..8fb5d603c 100755 --- a/src/video_core/host1x/syncpoint_manager.h +++ b/src/video_core/host1x/syncpoint_manager.h @@ -36,21 +36,19 @@ public: template ActionHandle RegisterGuestAction(u32 syncpoint_id, u32 expected_value, Func&& action) { - std::function func(action); return RegisterAction(syncpoints_guest[syncpoint_id], guest_action_storage[syncpoint_id], - expected_value, std::move(func)); + expected_value, std::move(action)); } template ActionHandle RegisterHostAction(u32 syncpoint_id, u32 expected_value, Func&& action) { - std::function func(action); return RegisterAction(syncpoints_host[syncpoint_id], host_action_storage[syncpoint_id], - expected_value, std::move(func)); + expected_value, std::move(action)); } - void DeregisterGuestAction(u32 syncpoint_id, ActionHandle& handle); + void DeregisterGuestAction(u32 syncpoint_id, const ActionHandle& handle); - void DeregisterHostAction(u32 syncpoint_id, ActionHandle& handle); + void DeregisterHostAction(u32 syncpoint_id, const ActionHandle& handle); void IncrementGuest(u32 syncpoint_id); @@ -76,7 +74,7 @@ private: std::list& action_storage, u32 expected_value, std::function&& action); - void DeregisterAction(std::list& action_storage, ActionHandle& handle); + void DeregisterAction(std::list& action_storage, const ActionHandle& handle); void Wait(std::atomic& syncpoint, std::condition_variable& wait_cv, u32 expected_value);