diff options
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/hle/service/gsp.cpp | 64 | ||||
| -rw-r--r-- | src/core/hle/service/gsp.h | 52 |
2 files changed, 79 insertions, 37 deletions
diff --git a/src/core/hle/service/gsp.cpp b/src/core/hle/service/gsp.cpp index 053c7dd2c..05753fa2c 100644 --- a/src/core/hle/service/gsp.cpp +++ b/src/core/hle/service/gsp.cpp | |||
| @@ -160,60 +160,72 @@ void TriggerCmdReqQueue(Service::Interface* self) { | |||
| 160 | }; | 160 | }; |
| 161 | 161 | ||
| 162 | GX_CmdBufferHeader* header = (GX_CmdBufferHeader*)GX_GetCmdBufferPointer(g_thread_id); | 162 | GX_CmdBufferHeader* header = (GX_CmdBufferHeader*)GX_GetCmdBufferPointer(g_thread_id); |
| 163 | u32* cmd_buff = (u32*)GX_GetCmdBufferPointer(g_thread_id, 0x20 + (header->index * 0x20)); | 163 | auto& command = *(const GXCommand*)GX_GetCmdBufferPointer(g_thread_id, 0x20 + (header->index * 0x20)); |
| 164 | 164 | ||
| 165 | switch (static_cast<GXCommandId>(cmd_buff[0])) { | 165 | switch (command.id) { |
| 166 | 166 | ||
| 167 | // GX request DMA - typically used for copying memory from GSP heap to VRAM | 167 | // GX request DMA - typically used for copying memory from GSP heap to VRAM |
| 168 | case GXCommandId::REQUEST_DMA: | 168 | case GXCommandId::REQUEST_DMA: |
| 169 | memcpy(Memory::GetPointer(cmd_buff[2]), Memory::GetPointer(cmd_buff[1]), cmd_buff[3]); | 169 | memcpy(Memory::GetPointer(command.dma_request.dest_address), |
| 170 | Memory::GetPointer(command.dma_request.source_address), | ||
| 171 | command.dma_request.size); | ||
| 170 | break; | 172 | break; |
| 171 | 173 | ||
| 172 | case GXCommandId::SET_COMMAND_LIST_LAST: | 174 | case GXCommandId::SET_COMMAND_LIST_LAST: |
| 173 | WriteGPURegister(GPU::Regs::CommandProcessor + 2, cmd_buff[1] >> 3); // command list data address | 175 | { |
| 174 | WriteGPURegister(GPU::Regs::CommandProcessor, cmd_buff[2] >> 3); // command list address | 176 | auto& params = command.set_command_list_last; |
| 175 | WriteGPURegister(GPU::Regs::CommandProcessor + 4, 1); // TODO: Not sure if we are supposed to always write this .. seems to trigger processing though | 177 | WriteGPURegister(GPU::Regs::CommandProcessor + 2, params.address >> 3); |
| 178 | WriteGPURegister(GPU::Regs::CommandProcessor, params.size >> 3); | ||
| 179 | WriteGPURegister(GPU::Regs::CommandProcessor + 4, 1); // TODO: Not sure if we are supposed to always write this .. seems to trigger processing though | ||
| 176 | 180 | ||
| 177 | // TODO: Move this to GPU | 181 | // TODO: Move this to GPU |
| 178 | // TODO: Not sure what units the size is measured in | 182 | // TODO: Not sure what units the size is measured in |
| 179 | g_debugger.CommandListCalled(cmd_buff[1], (u32*)Memory::GetPointer(cmd_buff[1]), cmd_buff[2]); | 183 | g_debugger.CommandListCalled(params.address, |
| 184 | (u32*)Memory::GetPointer(params.address), | ||
| 185 | params.size); | ||
| 180 | break; | 186 | break; |
| 187 | } | ||
| 181 | 188 | ||
| 182 | case GXCommandId::SET_MEMORY_FILL: | 189 | case GXCommandId::SET_MEMORY_FILL: |
| 183 | WriteGPURegister(GPU::Regs::MemoryFill, cmd_buff[1] >> 3); // Start 1 | 190 | { |
| 184 | WriteGPURegister(GPU::Regs::MemoryFill + 1, cmd_buff[3] >> 3); // End 1 | 191 | auto& params = command.memory_fill; |
| 185 | WriteGPURegister(GPU::Regs::MemoryFill + 2, cmd_buff[3] - cmd_buff[1]); // Size 1 | 192 | WriteGPURegister(GPU::Regs::MemoryFill, params.start1 >> 3); |
| 186 | WriteGPURegister(GPU::Regs::MemoryFill + 3, cmd_buff[2]); // Value 1 | 193 | WriteGPURegister(GPU::Regs::MemoryFill + 1, params.end1 >> 3); |
| 187 | 194 | WriteGPURegister(GPU::Regs::MemoryFill + 2, params.end1 - params.start1); | |
| 188 | WriteGPURegister(GPU::Regs::MemoryFill + 4, cmd_buff[4] >> 3); // Start 2 | 195 | WriteGPURegister(GPU::Regs::MemoryFill + 3, params.value1); |
| 189 | WriteGPURegister(GPU::Regs::MemoryFill + 5, cmd_buff[6] >> 3); // End 2 | 196 | |
| 190 | WriteGPURegister(GPU::Regs::MemoryFill + 6, cmd_buff[6] - cmd_buff[4]); // Size 2 | 197 | WriteGPURegister(GPU::Regs::MemoryFill + 4, params.start2 >> 3); |
| 191 | WriteGPURegister(GPU::Regs::MemoryFill + 7, cmd_buff[5]); // Value 2 | 198 | WriteGPURegister(GPU::Regs::MemoryFill + 5, params.end2 >> 3); |
| 199 | WriteGPURegister(GPU::Regs::MemoryFill + 6, params.end2 - params.start2); | ||
| 200 | WriteGPURegister(GPU::Regs::MemoryFill + 7, params.value2); | ||
| 192 | break; | 201 | break; |
| 202 | } | ||
| 193 | 203 | ||
| 194 | // TODO: Check if texture copies are implemented correctly.. | 204 | // TODO: Check if texture copies are implemented correctly.. |
| 195 | case GXCommandId::SET_DISPLAY_TRANSFER: | 205 | case GXCommandId::SET_DISPLAY_TRANSFER: |
| 196 | case GXCommandId::SET_TEXTURE_COPY: | 206 | case GXCommandId::SET_TEXTURE_COPY: |
| 197 | WriteGPURegister(GPU::Regs::DisplayTransfer, cmd_buff[1] >> 3); // input buffer address | 207 | { |
| 198 | WriteGPURegister(GPU::Regs::DisplayTransfer + 1, cmd_buff[2] >> 3); // output buffer address | 208 | auto& params = command.image_copy; |
| 199 | WriteGPURegister(GPU::Regs::DisplayTransfer + 3, cmd_buff[3]); // input buffer size | 209 | WriteGPURegister(GPU::Regs::DisplayTransfer, params.in_buffer_address >> 3); |
| 200 | WriteGPURegister(GPU::Regs::DisplayTransfer + 2, cmd_buff[4]); // output buffer size | 210 | WriteGPURegister(GPU::Regs::DisplayTransfer + 1, params.out_buffer_address >> 3); |
| 201 | WriteGPURegister(GPU::Regs::DisplayTransfer + 4, cmd_buff[5]); // transfer flags | 211 | WriteGPURegister(GPU::Regs::DisplayTransfer + 3, params.in_buffer_size); |
| 212 | WriteGPURegister(GPU::Regs::DisplayTransfer + 2, params.out_buffer_size); | ||
| 213 | WriteGPURegister(GPU::Regs::DisplayTransfer + 4, params.flags); | ||
| 202 | 214 | ||
| 203 | // TODO: Should this only be ORed with 1 for texture copies? | 215 | // TODO: Should this only be ORed with 1 for texture copies? |
| 204 | WriteGPURegister(GPU::Regs::DisplayTransfer + 6, 1); // trigger transfer | 216 | // trigger transfer |
| 217 | WriteGPURegister(GPU::Regs::DisplayTransfer + 6, 1); | ||
| 205 | break; | 218 | break; |
| 219 | } | ||
| 206 | 220 | ||
| 207 | case GXCommandId::SET_COMMAND_LIST_FIRST: | 221 | case GXCommandId::SET_COMMAND_LIST_FIRST: |
| 208 | { | 222 | { |
| 209 | //u32* buf0_data = (u32*)Memory::GetPointer(cmd_buff[1]); | 223 | // TODO |
| 210 | //u32* buf1_data = (u32*)Memory::GetPointer(cmd_buff[3]); | ||
| 211 | //u32* buf2_data = (u32*)Memory::GetPointer(cmd_buff[5]); | ||
| 212 | break; | 224 | break; |
| 213 | } | 225 | } |
| 214 | 226 | ||
| 215 | default: | 227 | default: |
| 216 | ERROR_LOG(GSP, "unknown command 0x%08X", cmd_buff[0]); | 228 | ERROR_LOG(GSP, "unknown command 0x%08X", (int)command.id.Value()); |
| 217 | } | 229 | } |
| 218 | 230 | ||
| 219 | GX_FinishCommand(g_thread_id); | 231 | GX_FinishCommand(g_thread_id); |
diff --git a/src/core/hle/service/gsp.h b/src/core/hle/service/gsp.h index fb50a928a..f36afb697 100644 --- a/src/core/hle/service/gsp.h +++ b/src/core/hle/service/gsp.h | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include "common/bit_field.h" | ||
| 7 | #include "core/hle/service/service.h" | 8 | #include "core/hle/service/service.h" |
| 8 | 9 | ||
| 9 | //////////////////////////////////////////////////////////////////////////////////////////////////// | 10 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| @@ -12,21 +13,50 @@ | |||
| 12 | namespace GSP_GPU { | 13 | namespace GSP_GPU { |
| 13 | 14 | ||
| 14 | enum class GXCommandId : u32 { | 15 | enum class GXCommandId : u32 { |
| 15 | REQUEST_DMA = 0x00000000, | 16 | REQUEST_DMA = 0x00, |
| 16 | SET_COMMAND_LIST_LAST = 0x00000001, | 17 | SET_COMMAND_LIST_LAST = 0x01, |
| 17 | SET_MEMORY_FILL = 0x01000102, // TODO: Confirm? | 18 | SET_MEMORY_FILL = 0x02, |
| 18 | SET_DISPLAY_TRANSFER = 0x00000003, | 19 | SET_DISPLAY_TRANSFER = 0x03, |
| 19 | SET_TEXTURE_COPY = 0x00000004, | 20 | SET_TEXTURE_COPY = 0x04, |
| 20 | SET_COMMAND_LIST_FIRST = 0x00000005, | 21 | SET_COMMAND_LIST_FIRST = 0x05, |
| 21 | }; | 22 | }; |
| 22 | 23 | ||
| 23 | union GXCommand { | 24 | struct GXCommand { |
| 24 | struct { | 25 | BitField<0, 8, GXCommandId> id; |
| 25 | GXCommandId id; | 26 | |
| 26 | }; | 27 | union { |
| 28 | struct { | ||
| 29 | u32 source_address; | ||
| 30 | u32 dest_address; | ||
| 31 | u32 size; | ||
| 32 | } dma_request; | ||
| 33 | |||
| 34 | struct { | ||
| 35 | u32 address; | ||
| 36 | u32 size; | ||
| 37 | } set_command_list_last; | ||
| 27 | 38 | ||
| 28 | u32 data[0x20]; | 39 | struct { |
| 40 | u32 start1; | ||
| 41 | u32 value1; | ||
| 42 | u32 end1; | ||
| 43 | u32 start2; | ||
| 44 | u32 value2; | ||
| 45 | u32 end2; | ||
| 46 | } memory_fill; | ||
| 47 | |||
| 48 | struct { | ||
| 49 | u32 in_buffer_address; | ||
| 50 | u32 out_buffer_address; | ||
| 51 | u32 in_buffer_size; | ||
| 52 | u32 out_buffer_size; | ||
| 53 | u32 flags; | ||
| 54 | } image_copy; | ||
| 55 | |||
| 56 | u8 raw_data[0x1C]; | ||
| 57 | }; | ||
| 29 | }; | 58 | }; |
| 59 | static_assert(sizeof(GXCommand) == 0x20, "GXCommand struct has incorrect size"); | ||
| 30 | 60 | ||
| 31 | /// Interface to "srv:" service | 61 | /// Interface to "srv:" service |
| 32 | class Interface : public Service::Interface { | 62 | class Interface : public Service::Interface { |