diff options
Diffstat (limited to 'src/video_core/cdma_pusher.cpp')
| -rw-r--r-- | src/video_core/cdma_pusher.cpp | 63 |
1 files changed, 23 insertions, 40 deletions
diff --git a/src/video_core/cdma_pusher.cpp b/src/video_core/cdma_pusher.cpp index 33b3c060b..a3fda1094 100644 --- a/src/video_core/cdma_pusher.cpp +++ b/src/video_core/cdma_pusher.cpp | |||
| @@ -37,59 +37,43 @@ CDmaPusher::CDmaPusher(GPU& gpu_) | |||
| 37 | 37 | ||
| 38 | CDmaPusher::~CDmaPusher() = default; | 38 | CDmaPusher::~CDmaPusher() = default; |
| 39 | 39 | ||
| 40 | void CDmaPusher::Push(ChCommandHeaderList&& entries) { | 40 | void CDmaPusher::ProcessEntries(ChCommandHeaderList&& entries) { |
| 41 | cdma_queue.push(std::move(entries)); | 41 | for (const auto& value : entries) { |
| 42 | } | ||
| 43 | |||
| 44 | void CDmaPusher::DispatchCalls() { | ||
| 45 | while (!cdma_queue.empty()) { | ||
| 46 | Step(); | ||
| 47 | } | ||
| 48 | } | ||
| 49 | |||
| 50 | void CDmaPusher::Step() { | ||
| 51 | const auto entries{cdma_queue.front()}; | ||
| 52 | cdma_queue.pop(); | ||
| 53 | |||
| 54 | std::vector<u32> values(entries.size()); | ||
| 55 | std::memcpy(values.data(), entries.data(), entries.size() * sizeof(u32)); | ||
| 56 | |||
| 57 | for (const u32 value : values) { | ||
| 58 | if (mask != 0) { | 42 | if (mask != 0) { |
| 59 | const auto lbs = static_cast<u32>(std::countr_zero(mask)); | 43 | const auto lbs = static_cast<u32>(std::countr_zero(mask)); |
| 60 | mask &= ~(1U << lbs); | 44 | mask &= ~(1U << lbs); |
| 61 | ExecuteCommand(static_cast<u32>(offset + lbs), value); | 45 | ExecuteCommand(offset + lbs, value.raw); |
| 62 | continue; | 46 | continue; |
| 63 | } else if (count != 0) { | 47 | } else if (count != 0) { |
| 64 | --count; | 48 | --count; |
| 65 | ExecuteCommand(static_cast<u32>(offset), value); | 49 | ExecuteCommand(offset, value.raw); |
| 66 | if (incrementing) { | 50 | if (incrementing) { |
| 67 | ++offset; | 51 | ++offset; |
| 68 | } | 52 | } |
| 69 | continue; | 53 | continue; |
| 70 | } | 54 | } |
| 71 | const auto mode = static_cast<ChSubmissionMode>((value >> 28) & 0xf); | 55 | const auto mode = value.submission_mode.Value(); |
| 72 | switch (mode) { | 56 | switch (mode) { |
| 73 | case ChSubmissionMode::SetClass: { | 57 | case ChSubmissionMode::SetClass: { |
| 74 | mask = value & 0x3f; | 58 | mask = value.value & 0x3f; |
| 75 | offset = (value >> 16) & 0xfff; | 59 | offset = value.method_offset; |
| 76 | current_class = static_cast<ChClassId>((value >> 6) & 0x3ff); | 60 | current_class = static_cast<ChClassId>((value.value >> 6) & 0x3ff); |
| 77 | break; | 61 | break; |
| 78 | } | 62 | } |
| 79 | case ChSubmissionMode::Incrementing: | 63 | case ChSubmissionMode::Incrementing: |
| 80 | case ChSubmissionMode::NonIncrementing: | 64 | case ChSubmissionMode::NonIncrementing: |
| 81 | count = value & 0xffff; | 65 | count = value.value; |
| 82 | offset = (value >> 16) & 0xfff; | 66 | offset = value.method_offset; |
| 83 | incrementing = mode == ChSubmissionMode::Incrementing; | 67 | incrementing = mode == ChSubmissionMode::Incrementing; |
| 84 | break; | 68 | break; |
| 85 | case ChSubmissionMode::Mask: | 69 | case ChSubmissionMode::Mask: |
| 86 | mask = value & 0xffff; | 70 | mask = value.value; |
| 87 | offset = (value >> 16) & 0xfff; | 71 | offset = value.method_offset; |
| 88 | break; | 72 | break; |
| 89 | case ChSubmissionMode::Immediate: { | 73 | case ChSubmissionMode::Immediate: { |
| 90 | const u32 data = value & 0xfff; | 74 | const u32 data = value.value & 0xfff; |
| 91 | offset = (value >> 16) & 0xfff; | 75 | offset = value.method_offset; |
| 92 | ExecuteCommand(static_cast<u32>(offset), data); | 76 | ExecuteCommand(offset, data); |
| 93 | break; | 77 | break; |
| 94 | } | 78 | } |
| 95 | default: | 79 | default: |
| @@ -102,8 +86,8 @@ void CDmaPusher::Step() { | |||
| 102 | void CDmaPusher::ExecuteCommand(u32 state_offset, u32 data) { | 86 | void CDmaPusher::ExecuteCommand(u32 state_offset, u32 data) { |
| 103 | switch (current_class) { | 87 | switch (current_class) { |
| 104 | case ChClassId::NvDec: | 88 | case ChClassId::NvDec: |
| 105 | ThiStateWrite(nvdec_thi_state, state_offset, {data}); | 89 | ThiStateWrite(nvdec_thi_state, offset, data); |
| 106 | switch (static_cast<ThiMethod>(state_offset)) { | 90 | switch (static_cast<ThiMethod>(offset)) { |
| 107 | case ThiMethod::IncSyncpt: { | 91 | case ThiMethod::IncSyncpt: { |
| 108 | LOG_DEBUG(Service_NVDRV, "NVDEC Class IncSyncpt Method"); | 92 | LOG_DEBUG(Service_NVDRV, "NVDEC Class IncSyncpt Method"); |
| 109 | const auto syncpoint_id = static_cast<u32>(data & 0xFF); | 93 | const auto syncpoint_id = static_cast<u32>(data & 0xFF); |
| @@ -120,7 +104,7 @@ void CDmaPusher::ExecuteCommand(u32 state_offset, u32 data) { | |||
| 120 | LOG_DEBUG(Service_NVDRV, "NVDEC method 0x{:X}", | 104 | LOG_DEBUG(Service_NVDRV, "NVDEC method 0x{:X}", |
| 121 | static_cast<u32>(nvdec_thi_state.method_0)); | 105 | static_cast<u32>(nvdec_thi_state.method_0)); |
| 122 | nvdec_processor->ProcessMethod(static_cast<Nvdec::Method>(nvdec_thi_state.method_0), | 106 | nvdec_processor->ProcessMethod(static_cast<Nvdec::Method>(nvdec_thi_state.method_0), |
| 123 | {data}); | 107 | data); |
| 124 | break; | 108 | break; |
| 125 | default: | 109 | default: |
| 126 | break; | 110 | break; |
| @@ -144,7 +128,7 @@ void CDmaPusher::ExecuteCommand(u32 state_offset, u32 data) { | |||
| 144 | case ThiMethod::SetMethod1: | 128 | case ThiMethod::SetMethod1: |
| 145 | LOG_DEBUG(Service_NVDRV, "VIC method 0x{:X}, Args=({})", | 129 | LOG_DEBUG(Service_NVDRV, "VIC method 0x{:X}, Args=({})", |
| 146 | static_cast<u32>(vic_thi_state.method_0), data); | 130 | static_cast<u32>(vic_thi_state.method_0), data); |
| 147 | vic_processor->ProcessMethod(static_cast<Vic::Method>(vic_thi_state.method_0), {data}); | 131 | vic_processor->ProcessMethod(static_cast<Vic::Method>(vic_thi_state.method_0), data); |
| 148 | break; | 132 | break; |
| 149 | default: | 133 | default: |
| 150 | break; | 134 | break; |
| @@ -153,7 +137,7 @@ void CDmaPusher::ExecuteCommand(u32 state_offset, u32 data) { | |||
| 153 | case ChClassId::Host1x: | 137 | case ChClassId::Host1x: |
| 154 | // This device is mainly for syncpoint synchronization | 138 | // This device is mainly for syncpoint synchronization |
| 155 | LOG_DEBUG(Service_NVDRV, "Host1X Class Method"); | 139 | LOG_DEBUG(Service_NVDRV, "Host1X Class Method"); |
| 156 | host1x_processor->ProcessMethod(static_cast<Host1x::Method>(state_offset), {data}); | 140 | host1x_processor->ProcessMethod(static_cast<Host1x::Method>(offset), data); |
| 157 | break; | 141 | break; |
| 158 | default: | 142 | default: |
| 159 | UNIMPLEMENTED_MSG("Current class not implemented {:X}", static_cast<u32>(current_class)); | 143 | UNIMPLEMENTED_MSG("Current class not implemented {:X}", static_cast<u32>(current_class)); |
| @@ -161,10 +145,9 @@ void CDmaPusher::ExecuteCommand(u32 state_offset, u32 data) { | |||
| 161 | } | 145 | } |
| 162 | } | 146 | } |
| 163 | 147 | ||
| 164 | void CDmaPusher::ThiStateWrite(ThiRegisters& state, u32 state_offset, | 148 | void CDmaPusher::ThiStateWrite(ThiRegisters& state, u32 state_offset, u32 argument) { |
| 165 | const std::vector<u32>& arguments) { | 149 | u8* const offset_ptr = reinterpret_cast<u8*>(&state) + sizeof(u32) * state_offset; |
| 166 | u8* const state_offset_ptr = reinterpret_cast<u8*>(&state) + sizeof(u32) * state_offset; | 150 | std::memcpy(offset_ptr, &argument, sizeof(u32)); |
| 167 | std::memcpy(state_offset_ptr, arguments.data(), sizeof(u32) * arguments.size()); | ||
| 168 | } | 151 | } |
| 169 | 152 | ||
| 170 | } // namespace Tegra | 153 | } // namespace Tegra |