diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/common/uuid.h | 5 | ||||
| -rw-r--r-- | src/input_common/sdl/sdl_impl.cpp | 59 | ||||
| -rw-r--r-- | src/video_core/buffer_cache/buffer_cache.h | 78 | ||||
| -rw-r--r-- | src/video_core/engines/maxwell_dma.cpp | 20 | ||||
| -rw-r--r-- | src/video_core/engines/maxwell_dma.h | 2 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_buffer_cache.cpp | 6 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_buffer_cache.h | 2 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.cpp | 5 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.h | 2 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_texture_cache.h | 2 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_buffer_cache.cpp | 31 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_buffer_cache.h | 2 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_rasterizer.cpp | 5 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_rasterizer.h | 2 | ||||
| -rw-r--r-- | src/yuzu/bootmanager.cpp | 6 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_input_player.cpp | 3 |
16 files changed, 207 insertions, 23 deletions
diff --git a/src/common/uuid.h b/src/common/uuid.h index 2e7a18405..0ffa37e7c 100644 --- a/src/common/uuid.h +++ b/src/common/uuid.h | |||
| @@ -20,12 +20,11 @@ struct UUID { | |||
| 20 | constexpr explicit UUID(const u64 lo, const u64 hi) : uuid{{lo, hi}} {} | 20 | constexpr explicit UUID(const u64 lo, const u64 hi) : uuid{{lo, hi}} {} |
| 21 | 21 | ||
| 22 | [[nodiscard]] constexpr explicit operator bool() const { | 22 | [[nodiscard]] constexpr explicit operator bool() const { |
| 23 | return uuid[0] != INVALID_UUID[0] && uuid[1] != INVALID_UUID[1]; | 23 | return uuid != INVALID_UUID; |
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | [[nodiscard]] constexpr bool operator==(const UUID& rhs) const { | 26 | [[nodiscard]] constexpr bool operator==(const UUID& rhs) const { |
| 27 | // TODO(DarkLordZach): Replace with uuid == rhs.uuid with C++20 | 27 | return uuid == rhs.uuid; |
| 28 | return uuid[0] == rhs.uuid[0] && uuid[1] == rhs.uuid[1]; | ||
| 29 | } | 28 | } |
| 30 | 29 | ||
| 31 | [[nodiscard]] constexpr bool operator!=(const UUID& rhs) const { | 30 | [[nodiscard]] constexpr bool operator!=(const UUID& rhs) const { |
diff --git a/src/input_common/sdl/sdl_impl.cpp b/src/input_common/sdl/sdl_impl.cpp index 68672a92b..7778b3562 100644 --- a/src/input_common/sdl/sdl_impl.cpp +++ b/src/input_common/sdl/sdl_impl.cpp | |||
| @@ -115,6 +115,41 @@ public: | |||
| 115 | return state.buttons.at(button); | 115 | return state.buttons.at(button); |
| 116 | } | 116 | } |
| 117 | 117 | ||
| 118 | bool ToggleButton(int button) { | ||
| 119 | std::lock_guard lock{mutex}; | ||
| 120 | |||
| 121 | if (!state.toggle_buttons.contains(button) || !state.lock_buttons.contains(button)) { | ||
| 122 | state.toggle_buttons.insert_or_assign(button, false); | ||
| 123 | state.lock_buttons.insert_or_assign(button, false); | ||
| 124 | } | ||
| 125 | |||
| 126 | const bool button_state = state.toggle_buttons.at(button); | ||
| 127 | const bool button_lock = state.lock_buttons.at(button); | ||
| 128 | |||
| 129 | if (button_lock) { | ||
| 130 | return button_state; | ||
| 131 | } | ||
| 132 | |||
| 133 | state.lock_buttons.insert_or_assign(button, true); | ||
| 134 | |||
| 135 | if (button_state) { | ||
| 136 | state.toggle_buttons.insert_or_assign(button, false); | ||
| 137 | } else { | ||
| 138 | state.toggle_buttons.insert_or_assign(button, true); | ||
| 139 | } | ||
| 140 | |||
| 141 | return !button_state; | ||
| 142 | } | ||
| 143 | |||
| 144 | bool UnlockButton(int button) { | ||
| 145 | std::lock_guard lock{mutex}; | ||
| 146 | if (!state.toggle_buttons.contains(button)) { | ||
| 147 | return false; | ||
| 148 | } | ||
| 149 | state.lock_buttons.insert_or_assign(button, false); | ||
| 150 | return state.toggle_buttons.at(button); | ||
| 151 | } | ||
| 152 | |||
| 118 | void SetAxis(int axis, Sint16 value) { | 153 | void SetAxis(int axis, Sint16 value) { |
| 119 | std::lock_guard lock{mutex}; | 154 | std::lock_guard lock{mutex}; |
| 120 | state.axes.insert_or_assign(axis, value); | 155 | state.axes.insert_or_assign(axis, value); |
| @@ -130,10 +165,10 @@ public: | |||
| 130 | 165 | ||
| 131 | if (sdl_controller) { | 166 | if (sdl_controller) { |
| 132 | return SDL_GameControllerRumble(sdl_controller.get(), amp_low, amp_high, | 167 | return SDL_GameControllerRumble(sdl_controller.get(), amp_low, amp_high, |
| 133 | rumble_max_duration_ms) == 0; | 168 | rumble_max_duration_ms) != -1; |
| 134 | } else if (sdl_joystick) { | 169 | } else if (sdl_joystick) { |
| 135 | return SDL_JoystickRumble(sdl_joystick.get(), amp_low, amp_high, | 170 | return SDL_JoystickRumble(sdl_joystick.get(), amp_low, amp_high, |
| 136 | rumble_max_duration_ms) == 0; | 171 | rumble_max_duration_ms) != -1; |
| 137 | } | 172 | } |
| 138 | 173 | ||
| 139 | return false; | 174 | return false; |
| @@ -241,6 +276,8 @@ public: | |||
| 241 | private: | 276 | private: |
| 242 | struct State { | 277 | struct State { |
| 243 | std::unordered_map<int, bool> buttons; | 278 | std::unordered_map<int, bool> buttons; |
| 279 | std::unordered_map<int, bool> toggle_buttons{}; | ||
| 280 | std::unordered_map<int, bool> lock_buttons{}; | ||
| 244 | std::unordered_map<int, Sint16> axes; | 281 | std::unordered_map<int, Sint16> axes; |
| 245 | std::unordered_map<int, Uint8> hats; | 282 | std::unordered_map<int, Uint8> hats; |
| 246 | } state; | 283 | } state; |
| @@ -402,16 +439,25 @@ void SDLState::CloseJoysticks() { | |||
| 402 | 439 | ||
| 403 | class SDLButton final : public Input::ButtonDevice { | 440 | class SDLButton final : public Input::ButtonDevice { |
| 404 | public: | 441 | public: |
| 405 | explicit SDLButton(std::shared_ptr<SDLJoystick> joystick_, int button_) | 442 | explicit SDLButton(std::shared_ptr<SDLJoystick> joystick_, int button_, bool toggle_) |
| 406 | : joystick(std::move(joystick_)), button(button_) {} | 443 | : joystick(std::move(joystick_)), button(button_), toggle(toggle_) {} |
| 407 | 444 | ||
| 408 | bool GetStatus() const override { | 445 | bool GetStatus() const override { |
| 409 | return joystick->GetButton(button); | 446 | const bool button_state = joystick->GetButton(button); |
| 447 | if (!toggle) { | ||
| 448 | return button_state; | ||
| 449 | } | ||
| 450 | |||
| 451 | if (button_state) { | ||
| 452 | return joystick->ToggleButton(button); | ||
| 453 | } | ||
| 454 | return joystick->UnlockButton(button); | ||
| 410 | } | 455 | } |
| 411 | 456 | ||
| 412 | private: | 457 | private: |
| 413 | std::shared_ptr<SDLJoystick> joystick; | 458 | std::shared_ptr<SDLJoystick> joystick; |
| 414 | int button; | 459 | int button; |
| 460 | bool toggle; | ||
| 415 | }; | 461 | }; |
| 416 | 462 | ||
| 417 | class SDLDirectionButton final : public Input::ButtonDevice { | 463 | class SDLDirectionButton final : public Input::ButtonDevice { |
| @@ -635,6 +681,7 @@ public: | |||
| 635 | std::unique_ptr<Input::ButtonDevice> Create(const Common::ParamPackage& params) override { | 681 | std::unique_ptr<Input::ButtonDevice> Create(const Common::ParamPackage& params) override { |
| 636 | const std::string guid = params.Get("guid", "0"); | 682 | const std::string guid = params.Get("guid", "0"); |
| 637 | const int port = params.Get("port", 0); | 683 | const int port = params.Get("port", 0); |
| 684 | const auto toggle = params.Get("toggle", false); | ||
| 638 | 685 | ||
| 639 | auto joystick = state.GetSDLJoystickByGUID(guid, port); | 686 | auto joystick = state.GetSDLJoystickByGUID(guid, port); |
| 640 | 687 | ||
| @@ -679,7 +726,7 @@ public: | |||
| 679 | const int button = params.Get("button", 0); | 726 | const int button = params.Get("button", 0); |
| 680 | // This is necessary so accessing GetButton with button won't crash | 727 | // This is necessary so accessing GetButton with button won't crash |
| 681 | joystick->SetButton(button, false); | 728 | joystick->SetButton(button, false); |
| 682 | return std::make_unique<SDLButton>(joystick, button); | 729 | return std::make_unique<SDLButton>(joystick, button, toggle); |
| 683 | } | 730 | } |
| 684 | 731 | ||
| 685 | private: | 732 | private: |
diff --git a/src/video_core/buffer_cache/buffer_cache.h b/src/video_core/buffer_cache/buffer_cache.h index 2871682f6..7373cb62d 100644 --- a/src/video_core/buffer_cache/buffer_cache.h +++ b/src/video_core/buffer_cache/buffer_cache.h | |||
| @@ -164,11 +164,16 @@ public: | |||
| 164 | /// Pop asynchronous downloads | 164 | /// Pop asynchronous downloads |
| 165 | void PopAsyncFlushes(); | 165 | void PopAsyncFlushes(); |
| 166 | 166 | ||
| 167 | [[nodiscard]] bool DMACopy(GPUVAddr src_address, GPUVAddr dest_address, u64 amount); | 167 | bool DMACopy(GPUVAddr src_address, GPUVAddr dest_address, u64 amount); |
| 168 | |||
| 169 | bool DMAClear(GPUVAddr src_address, u64 amount, u32 value); | ||
| 168 | 170 | ||
| 169 | /// Return true when a CPU region is modified from the GPU | 171 | /// Return true when a CPU region is modified from the GPU |
| 170 | [[nodiscard]] bool IsRegionGpuModified(VAddr addr, size_t size); | 172 | [[nodiscard]] bool IsRegionGpuModified(VAddr addr, size_t size); |
| 171 | 173 | ||
| 174 | /// Return true when a region is registered on the cache | ||
| 175 | [[nodiscard]] bool IsRegionRegistered(VAddr addr, size_t size); | ||
| 176 | |||
| 172 | /// Return true when a CPU region is modified from the CPU | 177 | /// Return true when a CPU region is modified from the CPU |
| 173 | [[nodiscard]] bool IsRegionCpuModified(VAddr addr, size_t size); | 178 | [[nodiscard]] bool IsRegionCpuModified(VAddr addr, size_t size); |
| 174 | 179 | ||
| @@ -324,6 +329,8 @@ private: | |||
| 324 | 329 | ||
| 325 | [[nodiscard]] bool HasFastUniformBufferBound(size_t stage, u32 binding_index) const noexcept; | 330 | [[nodiscard]] bool HasFastUniformBufferBound(size_t stage, u32 binding_index) const noexcept; |
| 326 | 331 | ||
| 332 | void ClearDownload(IntervalType subtract_interval); | ||
| 333 | |||
| 327 | VideoCore::RasterizerInterface& rasterizer; | 334 | VideoCore::RasterizerInterface& rasterizer; |
| 328 | Tegra::Engines::Maxwell3D& maxwell3d; | 335 | Tegra::Engines::Maxwell3D& maxwell3d; |
| 329 | Tegra::Engines::KeplerCompute& kepler_compute; | 336 | Tegra::Engines::KeplerCompute& kepler_compute; |
| @@ -463,23 +470,28 @@ void BufferCache<P>::DownloadMemory(VAddr cpu_addr, u64 size) { | |||
| 463 | } | 470 | } |
| 464 | 471 | ||
| 465 | template <class P> | 472 | template <class P> |
| 473 | void BufferCache<P>::ClearDownload(IntervalType subtract_interval) { | ||
| 474 | uncommitted_ranges.subtract(subtract_interval); | ||
| 475 | for (auto& interval_set : committed_ranges) { | ||
| 476 | interval_set.subtract(subtract_interval); | ||
| 477 | } | ||
| 478 | } | ||
| 479 | |||
| 480 | template <class P> | ||
| 466 | bool BufferCache<P>::DMACopy(GPUVAddr src_address, GPUVAddr dest_address, u64 amount) { | 481 | bool BufferCache<P>::DMACopy(GPUVAddr src_address, GPUVAddr dest_address, u64 amount) { |
| 467 | const std::optional<VAddr> cpu_src_address = gpu_memory.GpuToCpuAddress(src_address); | 482 | const std::optional<VAddr> cpu_src_address = gpu_memory.GpuToCpuAddress(src_address); |
| 468 | const std::optional<VAddr> cpu_dest_address = gpu_memory.GpuToCpuAddress(dest_address); | 483 | const std::optional<VAddr> cpu_dest_address = gpu_memory.GpuToCpuAddress(dest_address); |
| 469 | if (!cpu_src_address || !cpu_dest_address) { | 484 | if (!cpu_src_address || !cpu_dest_address) { |
| 470 | return false; | 485 | return false; |
| 471 | } | 486 | } |
| 472 | const bool source_dirty = IsRegionGpuModified(*cpu_src_address, amount); | 487 | const bool source_dirty = IsRegionRegistered(*cpu_src_address, amount); |
| 473 | const bool dest_dirty = IsRegionGpuModified(*cpu_dest_address, amount); | 488 | const bool dest_dirty = IsRegionRegistered(*cpu_dest_address, amount); |
| 474 | if (!source_dirty && !dest_dirty) { | 489 | if (!source_dirty && !dest_dirty) { |
| 475 | return false; | 490 | return false; |
| 476 | } | 491 | } |
| 477 | 492 | ||
| 478 | const IntervalType subtract_interval{*cpu_dest_address, *cpu_dest_address + amount}; | 493 | const IntervalType subtract_interval{*cpu_dest_address, *cpu_dest_address + amount}; |
| 479 | uncommitted_ranges.subtract(subtract_interval); | 494 | ClearDownload(subtract_interval); |
| 480 | for (auto& interval_set : committed_ranges) { | ||
| 481 | interval_set.subtract(subtract_interval); | ||
| 482 | } | ||
| 483 | 495 | ||
| 484 | BufferId buffer_a; | 496 | BufferId buffer_a; |
| 485 | BufferId buffer_b; | 497 | BufferId buffer_b; |
| @@ -510,12 +522,13 @@ bool BufferCache<P>::DMACopy(GPUVAddr src_address, GPUVAddr dest_address, u64 am | |||
| 510 | ForEachWrittenRange(*cpu_src_address, amount, mirror); | 522 | ForEachWrittenRange(*cpu_src_address, amount, mirror); |
| 511 | // This subtraction in this order is important for overlapping copies. | 523 | // This subtraction in this order is important for overlapping copies. |
| 512 | common_ranges.subtract(subtract_interval); | 524 | common_ranges.subtract(subtract_interval); |
| 525 | bool atleast_1_download = tmp_intervals.size() != 0; | ||
| 513 | for (const IntervalType add_interval : tmp_intervals) { | 526 | for (const IntervalType add_interval : tmp_intervals) { |
| 514 | common_ranges.add(add_interval); | 527 | common_ranges.add(add_interval); |
| 515 | } | 528 | } |
| 516 | 529 | ||
| 517 | runtime.CopyBuffer(dest_buffer, src_buffer, copies); | 530 | runtime.CopyBuffer(dest_buffer, src_buffer, copies); |
| 518 | if (source_dirty) { | 531 | if (atleast_1_download) { |
| 519 | dest_buffer.MarkRegionAsGpuModified(*cpu_dest_address, amount); | 532 | dest_buffer.MarkRegionAsGpuModified(*cpu_dest_address, amount); |
| 520 | } | 533 | } |
| 521 | std::vector<u8> tmp_buffer(amount); | 534 | std::vector<u8> tmp_buffer(amount); |
| @@ -525,6 +538,33 @@ bool BufferCache<P>::DMACopy(GPUVAddr src_address, GPUVAddr dest_address, u64 am | |||
| 525 | } | 538 | } |
| 526 | 539 | ||
| 527 | template <class P> | 540 | template <class P> |
| 541 | bool BufferCache<P>::DMAClear(GPUVAddr dst_address, u64 amount, u32 value) { | ||
| 542 | const std::optional<VAddr> cpu_dst_address = gpu_memory.GpuToCpuAddress(dst_address); | ||
| 543 | if (!cpu_dst_address) { | ||
| 544 | return false; | ||
| 545 | } | ||
| 546 | const bool dest_dirty = IsRegionRegistered(*cpu_dst_address, amount); | ||
| 547 | if (!dest_dirty) { | ||
| 548 | return false; | ||
| 549 | } | ||
| 550 | |||
| 551 | const size_t size = amount * sizeof(u32); | ||
| 552 | const IntervalType subtract_interval{*cpu_dst_address, *cpu_dst_address + size}; | ||
| 553 | ClearDownload(subtract_interval); | ||
| 554 | common_ranges.subtract(subtract_interval); | ||
| 555 | |||
| 556 | BufferId buffer; | ||
| 557 | do { | ||
| 558 | has_deleted_buffers = false; | ||
| 559 | buffer = FindBuffer(*cpu_dst_address, static_cast<u32>(size)); | ||
| 560 | } while (has_deleted_buffers); | ||
| 561 | auto& dest_buffer = slot_buffers[buffer]; | ||
| 562 | const u32 offset = static_cast<u32>(*cpu_dst_address - dest_buffer.CpuAddr()); | ||
| 563 | runtime.ClearBuffer(dest_buffer, offset, size, value); | ||
| 564 | return true; | ||
| 565 | } | ||
| 566 | |||
| 567 | template <class P> | ||
| 528 | void BufferCache<P>::BindGraphicsUniformBuffer(size_t stage, u32 index, GPUVAddr gpu_addr, | 568 | void BufferCache<P>::BindGraphicsUniformBuffer(size_t stage, u32 index, GPUVAddr gpu_addr, |
| 529 | u32 size) { | 569 | u32 size) { |
| 530 | const std::optional<VAddr> cpu_addr = gpu_memory.GpuToCpuAddress(gpu_addr); | 570 | const std::optional<VAddr> cpu_addr = gpu_memory.GpuToCpuAddress(gpu_addr); |
| @@ -782,6 +822,27 @@ bool BufferCache<P>::IsRegionGpuModified(VAddr addr, size_t size) { | |||
| 782 | } | 822 | } |
| 783 | 823 | ||
| 784 | template <class P> | 824 | template <class P> |
| 825 | bool BufferCache<P>::IsRegionRegistered(VAddr addr, size_t size) { | ||
| 826 | const VAddr end_addr = addr + size; | ||
| 827 | const u64 page_end = Common::DivCeil(end_addr, PAGE_SIZE); | ||
| 828 | for (u64 page = addr >> PAGE_BITS; page < page_end;) { | ||
| 829 | const BufferId buffer_id = page_table[page]; | ||
| 830 | if (!buffer_id) { | ||
| 831 | ++page; | ||
| 832 | continue; | ||
| 833 | } | ||
| 834 | Buffer& buffer = slot_buffers[buffer_id]; | ||
| 835 | const VAddr buf_start_addr = buffer.CpuAddr(); | ||
| 836 | const VAddr buf_end_addr = buf_start_addr + buffer.SizeBytes(); | ||
| 837 | if (buf_start_addr < end_addr && addr < buf_end_addr) { | ||
| 838 | return true; | ||
| 839 | } | ||
| 840 | page = Common::DivCeil(end_addr, PAGE_SIZE); | ||
| 841 | } | ||
| 842 | return false; | ||
| 843 | } | ||
| 844 | |||
| 845 | template <class P> | ||
| 785 | bool BufferCache<P>::IsRegionCpuModified(VAddr addr, size_t size) { | 846 | bool BufferCache<P>::IsRegionCpuModified(VAddr addr, size_t size) { |
| 786 | const u64 page_end = Common::DivCeil(addr + size, PAGE_SIZE); | 847 | const u64 page_end = Common::DivCeil(addr + size, PAGE_SIZE); |
| 787 | for (u64 page = addr >> PAGE_BITS; page < page_end;) { | 848 | for (u64 page = addr >> PAGE_BITS; page < page_end;) { |
| @@ -1425,6 +1486,7 @@ void BufferCache<P>::DownloadBufferMemory(Buffer& buffer, VAddr cpu_addr, u64 si | |||
| 1425 | const VAddr end_address = start_address + range_size; | 1486 | const VAddr end_address = start_address + range_size; |
| 1426 | ForEachWrittenRange(start_address, range_size, add_download); | 1487 | ForEachWrittenRange(start_address, range_size, add_download); |
| 1427 | const IntervalType subtract_interval{start_address, end_address}; | 1488 | const IntervalType subtract_interval{start_address, end_address}; |
| 1489 | ClearDownload(subtract_interval); | ||
| 1428 | common_ranges.subtract(subtract_interval); | 1490 | common_ranges.subtract(subtract_interval); |
| 1429 | }); | 1491 | }); |
| 1430 | if (total_size_bytes == 0) { | 1492 | if (total_size_bytes == 0) { |
diff --git a/src/video_core/engines/maxwell_dma.cpp b/src/video_core/engines/maxwell_dma.cpp index 24481952b..c51776466 100644 --- a/src/video_core/engines/maxwell_dma.cpp +++ b/src/video_core/engines/maxwell_dma.cpp | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | #include "common/assert.h" | 5 | #include "common/assert.h" |
| 6 | #include "common/logging/log.h" | 6 | #include "common/logging/log.h" |
| 7 | #include "common/microprofile.h" | ||
| 7 | #include "common/settings.h" | 8 | #include "common/settings.h" |
| 8 | #include "core/core.h" | 9 | #include "core/core.h" |
| 9 | #include "video_core/engines/maxwell_3d.h" | 10 | #include "video_core/engines/maxwell_3d.h" |
| @@ -12,6 +13,9 @@ | |||
| 12 | #include "video_core/renderer_base.h" | 13 | #include "video_core/renderer_base.h" |
| 13 | #include "video_core/textures/decoders.h" | 14 | #include "video_core/textures/decoders.h" |
| 14 | 15 | ||
| 16 | MICROPROFILE_DECLARE(GPU_DMAEngine); | ||
| 17 | MICROPROFILE_DEFINE(GPU_DMAEngine, "GPU", "DMA Engine", MP_RGB(224, 224, 128)); | ||
| 18 | |||
| 15 | namespace Tegra::Engines { | 19 | namespace Tegra::Engines { |
| 16 | 20 | ||
| 17 | using namespace Texture; | 21 | using namespace Texture; |
| @@ -43,6 +47,7 @@ void MaxwellDMA::CallMultiMethod(u32 method, const u32* base_start, u32 amount, | |||
| 43 | } | 47 | } |
| 44 | 48 | ||
| 45 | void MaxwellDMA::Launch() { | 49 | void MaxwellDMA::Launch() { |
| 50 | MICROPROFILE_SCOPE(GPU_DMAEngine); | ||
| 46 | LOG_TRACE(Render_OpenGL, "DMA copy 0x{:x} -> 0x{:x}", static_cast<GPUVAddr>(regs.offset_in), | 51 | LOG_TRACE(Render_OpenGL, "DMA copy 0x{:x} -> 0x{:x}", static_cast<GPUVAddr>(regs.offset_in), |
| 47 | static_cast<GPUVAddr>(regs.offset_out)); | 52 | static_cast<GPUVAddr>(regs.offset_out)); |
| 48 | 53 | ||
| @@ -87,9 +92,11 @@ void MaxwellDMA::CopyPitchToPitch() { | |||
| 87 | // TODO: allow multisized components. | 92 | // TODO: allow multisized components. |
| 88 | if (is_buffer_clear) { | 93 | if (is_buffer_clear) { |
| 89 | ASSERT(regs.remap_const.component_size_minus_one == 3); | 94 | ASSERT(regs.remap_const.component_size_minus_one == 3); |
| 95 | accelerate.BufferClear(regs.offset_out, regs.line_length_in, regs.remap_consta_value); | ||
| 90 | std::vector<u32> tmp_buffer(regs.line_length_in, regs.remap_consta_value); | 96 | std::vector<u32> tmp_buffer(regs.line_length_in, regs.remap_consta_value); |
| 91 | memory_manager.WriteBlock(regs.offset_out, reinterpret_cast<u8*>(tmp_buffer.data()), | 97 | memory_manager.WriteBlockUnsafe(regs.offset_out, |
| 92 | regs.line_length_in * sizeof(u32)); | 98 | reinterpret_cast<u8*>(tmp_buffer.data()), |
| 99 | regs.line_length_in * sizeof(u32)); | ||
| 93 | return; | 100 | return; |
| 94 | } | 101 | } |
| 95 | UNIMPLEMENTED_IF(regs.launch_dma.remap_enable != 0); | 102 | UNIMPLEMENTED_IF(regs.launch_dma.remap_enable != 0); |
| @@ -179,8 +186,13 @@ void MaxwellDMA::CopyPitchToBlockLinear() { | |||
| 179 | write_buffer.resize(dst_size); | 186 | write_buffer.resize(dst_size); |
| 180 | } | 187 | } |
| 181 | 188 | ||
| 182 | memory_manager.ReadBlock(regs.offset_in, read_buffer.data(), src_size); | 189 | if (Settings::IsGPULevelExtreme()) { |
| 183 | memory_manager.ReadBlock(regs.offset_out, write_buffer.data(), dst_size); | 190 | memory_manager.ReadBlock(regs.offset_in, read_buffer.data(), src_size); |
| 191 | memory_manager.ReadBlock(regs.offset_out, write_buffer.data(), dst_size); | ||
| 192 | } else { | ||
| 193 | memory_manager.ReadBlockUnsafe(regs.offset_in, read_buffer.data(), src_size); | ||
| 194 | memory_manager.ReadBlockUnsafe(regs.offset_out, write_buffer.data(), dst_size); | ||
| 195 | } | ||
| 184 | 196 | ||
| 185 | // If the input is linear and the output is tiled, swizzle the input and copy it over. | 197 | // If the input is linear and the output is tiled, swizzle the input and copy it over. |
| 186 | if (regs.dst_params.block_size.depth > 0) { | 198 | if (regs.dst_params.block_size.depth > 0) { |
diff --git a/src/video_core/engines/maxwell_dma.h b/src/video_core/engines/maxwell_dma.h index 4ed0d0996..d3329b0f8 100644 --- a/src/video_core/engines/maxwell_dma.h +++ b/src/video_core/engines/maxwell_dma.h | |||
| @@ -31,6 +31,8 @@ class AccelerateDMAInterface { | |||
| 31 | public: | 31 | public: |
| 32 | /// Write the value to the register identified by method. | 32 | /// Write the value to the register identified by method. |
| 33 | virtual bool BufferCopy(GPUVAddr src_address, GPUVAddr dest_address, u64 amount) = 0; | 33 | virtual bool BufferCopy(GPUVAddr src_address, GPUVAddr dest_address, u64 amount) = 0; |
| 34 | |||
| 35 | virtual bool BufferClear(GPUVAddr src_address, u64 amount, u32 value) = 0; | ||
| 34 | }; | 36 | }; |
| 35 | 37 | ||
| 36 | /** | 38 | /** |
diff --git a/src/video_core/renderer_opengl/gl_buffer_cache.cpp b/src/video_core/renderer_opengl/gl_buffer_cache.cpp index c225d1fc9..c4189fb60 100644 --- a/src/video_core/renderer_opengl/gl_buffer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_buffer_cache.cpp | |||
| @@ -98,6 +98,12 @@ void BufferCacheRuntime::CopyBuffer(Buffer& dst_buffer, Buffer& src_buffer, | |||
| 98 | } | 98 | } |
| 99 | } | 99 | } |
| 100 | 100 | ||
| 101 | void BufferCacheRuntime::ClearBuffer(Buffer& dest_buffer, u32 offset, size_t size, u32 value) { | ||
| 102 | glClearNamedBufferSubData(dest_buffer.Handle(), GL_R32UI, static_cast<GLintptr>(offset), | ||
| 103 | static_cast<GLsizeiptr>(size / sizeof(u32)), GL_RGBA, GL_UNSIGNED_INT, | ||
| 104 | &value); | ||
| 105 | } | ||
| 106 | |||
| 101 | void BufferCacheRuntime::BindIndexBuffer(Buffer& buffer, u32 offset, u32 size) { | 107 | void BufferCacheRuntime::BindIndexBuffer(Buffer& buffer, u32 offset, u32 size) { |
| 102 | if (has_unified_vertex_buffers) { | 108 | if (has_unified_vertex_buffers) { |
| 103 | buffer.MakeResident(GL_READ_ONLY); | 109 | buffer.MakeResident(GL_READ_ONLY); |
diff --git a/src/video_core/renderer_opengl/gl_buffer_cache.h b/src/video_core/renderer_opengl/gl_buffer_cache.h index d8b20a9af..fe91aa452 100644 --- a/src/video_core/renderer_opengl/gl_buffer_cache.h +++ b/src/video_core/renderer_opengl/gl_buffer_cache.h | |||
| @@ -57,6 +57,8 @@ public: | |||
| 57 | void CopyBuffer(Buffer& dst_buffer, Buffer& src_buffer, | 57 | void CopyBuffer(Buffer& dst_buffer, Buffer& src_buffer, |
| 58 | std::span<const VideoCommon::BufferCopy> copies); | 58 | std::span<const VideoCommon::BufferCopy> copies); |
| 59 | 59 | ||
| 60 | void ClearBuffer(Buffer& dest_buffer, u32 offset, size_t size, u32 value); | ||
| 61 | |||
| 60 | void BindIndexBuffer(Buffer& buffer, u32 offset, u32 size); | 62 | void BindIndexBuffer(Buffer& buffer, u32 offset, u32 size); |
| 61 | 63 | ||
| 62 | void BindVertexBuffer(u32 index, Buffer& buffer, u32 offset, u32 size, u32 stride); | 64 | void BindVertexBuffer(u32 index, Buffer& buffer, u32 offset, u32 size, u32 stride); |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index 82c84127a..ceb3abcb2 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp | |||
| @@ -1407,4 +1407,9 @@ bool AccelerateDMA::BufferCopy(GPUVAddr src_address, GPUVAddr dest_address, u64 | |||
| 1407 | return buffer_cache.DMACopy(src_address, dest_address, amount); | 1407 | return buffer_cache.DMACopy(src_address, dest_address, amount); |
| 1408 | } | 1408 | } |
| 1409 | 1409 | ||
| 1410 | bool AccelerateDMA::BufferClear(GPUVAddr src_address, u64 amount, u32 value) { | ||
| 1411 | std::scoped_lock lock{buffer_cache.mutex}; | ||
| 1412 | return buffer_cache.DMAClear(src_address, amount, value); | ||
| 1413 | } | ||
| 1414 | |||
| 1410 | } // namespace OpenGL | 1415 | } // namespace OpenGL |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h index ccee9ba33..d30ad698f 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.h +++ b/src/video_core/renderer_opengl/gl_rasterizer.h | |||
| @@ -65,6 +65,8 @@ public: | |||
| 65 | 65 | ||
| 66 | bool BufferCopy(GPUVAddr src_address, GPUVAddr dest_address, u64 amount) override; | 66 | bool BufferCopy(GPUVAddr src_address, GPUVAddr dest_address, u64 amount) override; |
| 67 | 67 | ||
| 68 | bool BufferClear(GPUVAddr src_address, u64 amount, u32 value) override; | ||
| 69 | |||
| 68 | private: | 70 | private: |
| 69 | BufferCache& buffer_cache; | 71 | BufferCache& buffer_cache; |
| 70 | }; | 72 | }; |
diff --git a/src/video_core/renderer_opengl/gl_texture_cache.h b/src/video_core/renderer_opengl/gl_texture_cache.h index 25fe61566..cf3b789e3 100644 --- a/src/video_core/renderer_opengl/gl_texture_cache.h +++ b/src/video_core/renderer_opengl/gl_texture_cache.h | |||
| @@ -122,7 +122,7 @@ private: | |||
| 122 | bool has_broken_texture_view_formats = false; | 122 | bool has_broken_texture_view_formats = false; |
| 123 | 123 | ||
| 124 | StagingBuffers upload_buffers{GL_MAP_WRITE_BIT, GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT}; | 124 | StagingBuffers upload_buffers{GL_MAP_WRITE_BIT, GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT}; |
| 125 | StagingBuffers download_buffers{GL_MAP_READ_BIT, GL_MAP_READ_BIT}; | 125 | StagingBuffers download_buffers{GL_MAP_READ_BIT | GL_CLIENT_STORAGE_BIT, GL_MAP_READ_BIT}; |
| 126 | 126 | ||
| 127 | OGLTexture null_image_1d_array; | 127 | OGLTexture null_image_1d_array; |
| 128 | OGLTexture null_image_cube_array; | 128 | OGLTexture null_image_cube_array; |
diff --git a/src/video_core/renderer_vulkan/vk_buffer_cache.cpp b/src/video_core/renderer_vulkan/vk_buffer_cache.cpp index 79876dfd0..0def1e769 100644 --- a/src/video_core/renderer_vulkan/vk_buffer_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_buffer_cache.cpp | |||
| @@ -136,6 +136,30 @@ void BufferCacheRuntime::CopyBuffer(VkBuffer dst_buffer, VkBuffer src_buffer, | |||
| 136 | }); | 136 | }); |
| 137 | } | 137 | } |
| 138 | 138 | ||
| 139 | void BufferCacheRuntime::ClearBuffer(VkBuffer dest_buffer, u32 offset, size_t size, u32 value) { | ||
| 140 | static constexpr VkMemoryBarrier READ_BARRIER{ | ||
| 141 | .sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER, | ||
| 142 | .pNext = nullptr, | ||
| 143 | .srcAccessMask = VK_ACCESS_MEMORY_WRITE_BIT, | ||
| 144 | .dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT | VK_ACCESS_TRANSFER_WRITE_BIT, | ||
| 145 | }; | ||
| 146 | static constexpr VkMemoryBarrier WRITE_BARRIER{ | ||
| 147 | .sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER, | ||
| 148 | .pNext = nullptr, | ||
| 149 | .srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT, | ||
| 150 | .dstAccessMask = VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT, | ||
| 151 | }; | ||
| 152 | |||
| 153 | scheduler.RequestOutsideRenderPassOperationContext(); | ||
| 154 | scheduler.Record([dest_buffer, offset, size, value](vk::CommandBuffer cmdbuf) { | ||
| 155 | cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, | ||
| 156 | 0, READ_BARRIER); | ||
| 157 | cmdbuf.FillBuffer(dest_buffer, offset, size, value); | ||
| 158 | cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, | ||
| 159 | 0, WRITE_BARRIER); | ||
| 160 | }); | ||
| 161 | } | ||
| 162 | |||
| 139 | void BufferCacheRuntime::BindIndexBuffer(PrimitiveTopology topology, IndexFormat index_format, | 163 | void BufferCacheRuntime::BindIndexBuffer(PrimitiveTopology topology, IndexFormat index_format, |
| 140 | u32 base_vertex, u32 num_indices, VkBuffer buffer, | 164 | u32 base_vertex, u32 num_indices, VkBuffer buffer, |
| 141 | u32 offset, [[maybe_unused]] u32 size) { | 165 | u32 offset, [[maybe_unused]] u32 size) { |
| @@ -161,6 +185,13 @@ void BufferCacheRuntime::BindIndexBuffer(PrimitiveTopology topology, IndexFormat | |||
| 161 | } | 185 | } |
| 162 | 186 | ||
| 163 | void BufferCacheRuntime::BindQuadArrayIndexBuffer(u32 first, u32 count) { | 187 | void BufferCacheRuntime::BindQuadArrayIndexBuffer(u32 first, u32 count) { |
| 188 | if (count == 0) { | ||
| 189 | ReserveNullBuffer(); | ||
| 190 | scheduler.Record([this](vk::CommandBuffer cmdbuf) { | ||
| 191 | cmdbuf.BindIndexBuffer(*null_buffer, 0, VK_INDEX_TYPE_UINT32); | ||
| 192 | }); | ||
| 193 | return; | ||
| 194 | } | ||
| 164 | ReserveQuadArrayLUT(first + count, true); | 195 | ReserveQuadArrayLUT(first + count, true); |
| 165 | 196 | ||
| 166 | // The LUT has the indices 0, 1, 2, and 3 copied as an array | 197 | // The LUT has the indices 0, 1, 2, and 3 copied as an array |
diff --git a/src/video_core/renderer_vulkan/vk_buffer_cache.h b/src/video_core/renderer_vulkan/vk_buffer_cache.h index 6ea8448d7..3bb81d5b3 100644 --- a/src/video_core/renderer_vulkan/vk_buffer_cache.h +++ b/src/video_core/renderer_vulkan/vk_buffer_cache.h | |||
| @@ -60,6 +60,8 @@ public: | |||
| 60 | void CopyBuffer(VkBuffer src_buffer, VkBuffer dst_buffer, | 60 | void CopyBuffer(VkBuffer src_buffer, VkBuffer dst_buffer, |
| 61 | std::span<const VideoCommon::BufferCopy> copies); | 61 | std::span<const VideoCommon::BufferCopy> copies); |
| 62 | 62 | ||
| 63 | void ClearBuffer(VkBuffer dest_buffer, u32 offset, size_t size, u32 value); | ||
| 64 | |||
| 63 | void BindIndexBuffer(PrimitiveTopology topology, IndexFormat index_format, u32 num_indices, | 65 | void BindIndexBuffer(PrimitiveTopology topology, IndexFormat index_format, u32 num_indices, |
| 64 | u32 base_vertex, VkBuffer buffer, u32 offset, u32 size); | 66 | u32 base_vertex, VkBuffer buffer, u32 offset, u32 size); |
| 65 | 67 | ||
diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp index a8ffbe6ba..f57c15b37 100644 --- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp +++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp | |||
| @@ -706,6 +706,11 @@ void RasterizerVulkan::FlushWork() { | |||
| 706 | 706 | ||
| 707 | AccelerateDMA::AccelerateDMA(BufferCache& buffer_cache_) : buffer_cache{buffer_cache_} {} | 707 | AccelerateDMA::AccelerateDMA(BufferCache& buffer_cache_) : buffer_cache{buffer_cache_} {} |
| 708 | 708 | ||
| 709 | bool AccelerateDMA::BufferClear(GPUVAddr src_address, u64 amount, u32 value) { | ||
| 710 | std::scoped_lock lock{buffer_cache.mutex}; | ||
| 711 | return buffer_cache.DMAClear(src_address, amount, value); | ||
| 712 | } | ||
| 713 | |||
| 709 | bool AccelerateDMA::BufferCopy(GPUVAddr src_address, GPUVAddr dest_address, u64 amount) { | 714 | bool AccelerateDMA::BufferCopy(GPUVAddr src_address, GPUVAddr dest_address, u64 amount) { |
| 710 | std::scoped_lock lock{buffer_cache.mutex}; | 715 | std::scoped_lock lock{buffer_cache.mutex}; |
| 711 | return buffer_cache.DMACopy(src_address, dest_address, amount); | 716 | return buffer_cache.DMACopy(src_address, dest_address, amount); |
diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.h b/src/video_core/renderer_vulkan/vk_rasterizer.h index 3a78de258..2065209be 100644 --- a/src/video_core/renderer_vulkan/vk_rasterizer.h +++ b/src/video_core/renderer_vulkan/vk_rasterizer.h | |||
| @@ -56,6 +56,8 @@ public: | |||
| 56 | 56 | ||
| 57 | bool BufferCopy(GPUVAddr start_address, GPUVAddr end_address, u64 amount) override; | 57 | bool BufferCopy(GPUVAddr start_address, GPUVAddr end_address, u64 amount) override; |
| 58 | 58 | ||
| 59 | bool BufferClear(GPUVAddr src_address, u64 amount, u32 value) override; | ||
| 60 | |||
| 59 | private: | 61 | private: |
| 60 | BufferCache& buffer_cache; | 62 | BufferCache& buffer_cache; |
| 61 | }; | 63 | }; |
diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp index bfae73b60..d72ca5acc 100644 --- a/src/yuzu/bootmanager.cpp +++ b/src/yuzu/bootmanager.cpp | |||
| @@ -567,6 +567,12 @@ std::unique_ptr<Core::Frontend::GraphicsContext> GRenderWindow::CreateSharedCont | |||
| 567 | bool GRenderWindow::InitRenderTarget() { | 567 | bool GRenderWindow::InitRenderTarget() { |
| 568 | ReleaseRenderTarget(); | 568 | ReleaseRenderTarget(); |
| 569 | 569 | ||
| 570 | { | ||
| 571 | // Create a dummy render widget so that Qt | ||
| 572 | // places the render window at the correct position. | ||
| 573 | const RenderWidget dummy_widget{this}; | ||
| 574 | } | ||
| 575 | |||
| 570 | first_frame = false; | 576 | first_frame = false; |
| 571 | 577 | ||
| 572 | switch (Settings::values.renderer_backend.GetValue()) { | 578 | switch (Settings::values.renderer_backend.GetValue()) { |
diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp index d5d624b96..14579c220 100644 --- a/src/yuzu/configuration/configure_input_player.cpp +++ b/src/yuzu/configuration/configure_input_player.cpp | |||
| @@ -149,8 +149,9 @@ QString ButtonToText(const Common::ParamPackage& param) { | |||
| 149 | 149 | ||
| 150 | if (param.Has("button")) { | 150 | if (param.Has("button")) { |
| 151 | const QString button_str = QString::fromStdString(param.Get("button", "")); | 151 | const QString button_str = QString::fromStdString(param.Get("button", "")); |
| 152 | const QString toggle = QString::fromStdString(param.Get("toggle", false) ? "~" : ""); | ||
| 152 | 153 | ||
| 153 | return QObject::tr("Button %1").arg(button_str); | 154 | return QObject::tr("%1Button %2").arg(toggle, button_str); |
| 154 | } | 155 | } |
| 155 | 156 | ||
| 156 | if (param.Has("motion")) { | 157 | if (param.Has("motion")) { |