diff options
Diffstat (limited to 'src/video_core/dma_pusher.cpp')
| -rw-r--r-- | src/video_core/dma_pusher.cpp | 65 |
1 files changed, 40 insertions, 25 deletions
diff --git a/src/video_core/dma_pusher.cpp b/src/video_core/dma_pusher.cpp index f2f96ac33..2c8b20024 100644 --- a/src/video_core/dma_pusher.cpp +++ b/src/video_core/dma_pusher.cpp | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include "common/cityhash.h" | ||
| 5 | #include "common/microprofile.h" | 6 | #include "common/microprofile.h" |
| 6 | #include "core/core.h" | 7 | #include "core/core.h" |
| 7 | #include "core/memory.h" | 8 | #include "core/memory.h" |
| @@ -12,7 +13,7 @@ | |||
| 12 | 13 | ||
| 13 | namespace Tegra { | 14 | namespace Tegra { |
| 14 | 15 | ||
| 15 | DmaPusher::DmaPusher(Core::System& system, GPU& gpu) : gpu{gpu}, system{system} {} | 16 | DmaPusher::DmaPusher(Core::System& system_, GPU& gpu_) : gpu{gpu_}, system{system_} {} |
| 16 | 17 | ||
| 17 | DmaPusher::~DmaPusher() = default; | 18 | DmaPusher::~DmaPusher() = default; |
| 18 | 19 | ||
| @@ -45,32 +46,41 @@ bool DmaPusher::Step() { | |||
| 45 | return false; | 46 | return false; |
| 46 | } | 47 | } |
| 47 | 48 | ||
| 48 | const CommandList& command_list{dma_pushbuffer.front()}; | 49 | CommandList& command_list{dma_pushbuffer.front()}; |
| 49 | ASSERT_OR_EXECUTE(!command_list.empty(), { | ||
| 50 | // Somehow the command_list is empty, in order to avoid a crash | ||
| 51 | // We ignore it and assume its size is 0. | ||
| 52 | dma_pushbuffer.pop(); | ||
| 53 | dma_pushbuffer_subindex = 0; | ||
| 54 | return true; | ||
| 55 | }); | ||
| 56 | const CommandListHeader command_list_header{command_list[dma_pushbuffer_subindex++]}; | ||
| 57 | const GPUVAddr dma_get = command_list_header.addr; | ||
| 58 | |||
| 59 | if (dma_pushbuffer_subindex >= command_list.size()) { | ||
| 60 | // We've gone through the current list, remove it from the queue | ||
| 61 | dma_pushbuffer.pop(); | ||
| 62 | dma_pushbuffer_subindex = 0; | ||
| 63 | } | ||
| 64 | 50 | ||
| 65 | if (command_list_header.size == 0) { | 51 | ASSERT_OR_EXECUTE( |
| 66 | return true; | 52 | command_list.command_lists.size() || command_list.prefetch_command_list.size(), { |
| 67 | } | 53 | // Somehow the command_list is empty, in order to avoid a crash |
| 54 | // We ignore it and assume its size is 0. | ||
| 55 | dma_pushbuffer.pop(); | ||
| 56 | dma_pushbuffer_subindex = 0; | ||
| 57 | return true; | ||
| 58 | }); | ||
| 59 | |||
| 60 | if (command_list.prefetch_command_list.size()) { | ||
| 61 | // Prefetched command list from nvdrv, used for things like synchronization | ||
| 62 | command_headers = std::move(command_list.prefetch_command_list); | ||
| 63 | dma_pushbuffer.pop(); | ||
| 64 | } else { | ||
| 65 | const CommandListHeader command_list_header{ | ||
| 66 | command_list.command_lists[dma_pushbuffer_subindex++]}; | ||
| 67 | const GPUVAddr dma_get = command_list_header.addr; | ||
| 68 | |||
| 69 | if (dma_pushbuffer_subindex >= command_list.command_lists.size()) { | ||
| 70 | // We've gone through the current list, remove it from the queue | ||
| 71 | dma_pushbuffer.pop(); | ||
| 72 | dma_pushbuffer_subindex = 0; | ||
| 73 | } | ||
| 68 | 74 | ||
| 69 | // Push buffer non-empty, read a word | 75 | if (command_list_header.size == 0) { |
| 70 | command_headers.resize(command_list_header.size); | 76 | return true; |
| 71 | gpu.MemoryManager().ReadBlockUnsafe(dma_get, command_headers.data(), | 77 | } |
| 72 | command_list_header.size * sizeof(u32)); | ||
| 73 | 78 | ||
| 79 | // Push buffer non-empty, read a word | ||
| 80 | command_headers.resize(command_list_header.size); | ||
| 81 | gpu.MemoryManager().ReadBlockUnsafe(dma_get, command_headers.data(), | ||
| 82 | command_list_header.size * sizeof(u32)); | ||
| 83 | } | ||
| 74 | for (std::size_t index = 0; index < command_headers.size();) { | 84 | for (std::size_t index = 0; index < command_headers.size();) { |
| 75 | const CommandHeader& command_header = command_headers[index]; | 85 | const CommandHeader& command_header = command_headers[index]; |
| 76 | 86 | ||
| @@ -142,7 +152,12 @@ void DmaPusher::SetState(const CommandHeader& command_header) { | |||
| 142 | 152 | ||
| 143 | void DmaPusher::CallMethod(u32 argument) const { | 153 | void DmaPusher::CallMethod(u32 argument) const { |
| 144 | if (dma_state.method < non_puller_methods) { | 154 | if (dma_state.method < non_puller_methods) { |
| 145 | gpu.CallMethod({dma_state.method, argument, dma_state.subchannel, dma_state.method_count}); | 155 | gpu.CallMethod(GPU::MethodCall{ |
| 156 | dma_state.method, | ||
| 157 | argument, | ||
| 158 | dma_state.subchannel, | ||
| 159 | dma_state.method_count, | ||
| 160 | }); | ||
| 146 | } else { | 161 | } else { |
| 147 | subchannels[dma_state.subchannel]->CallMethod(dma_state.method, argument, | 162 | subchannels[dma_state.subchannel]->CallMethod(dma_state.method, argument, |
| 148 | dma_state.is_last_call); | 163 | dma_state.is_last_call); |