diff options
| author | 2014-07-26 14:42:46 +0200 | |
|---|---|---|
| committer | 2014-08-12 13:47:30 +0200 | |
| commit | 76a586de4952df6d8dd9db9d97716c00690cebdd (patch) | |
| tree | ad6a954780faa4ab7908780e4ab605952b7e400b | |
| parent | Pica: Add float24 structure. (diff) | |
| download | yuzu-76a586de4952df6d8dd9db9d97716c00690cebdd.tar.gz yuzu-76a586de4952df6d8dd9db9d97716c00690cebdd.tar.xz yuzu-76a586de4952df6d8dd9db9d97716c00690cebdd.zip | |
Pica: Add command processor.
Diffstat (limited to '')
| -rw-r--r-- | src/citra_qt/debugger/graphics_cmdlists.cpp | 2 | ||||
| -rw-r--r-- | src/core/hw/gpu.cpp | 8 | ||||
| -rw-r--r-- | src/video_core/CMakeLists.txt | 7 | ||||
| -rw-r--r-- | src/video_core/command_processor.cpp | 60 | ||||
| -rw-r--r-- | src/video_core/command_processor.h | 31 | ||||
| -rw-r--r-- | src/video_core/gpu_debugger.h | 8 | ||||
| -rw-r--r-- | src/video_core/pica.h | 2 | ||||
| -rw-r--r-- | src/video_core/video_core.vcxproj | 2 | ||||
| -rw-r--r-- | src/video_core/video_core.vcxproj.filters | 2 |
9 files changed, 113 insertions, 9 deletions
diff --git a/src/citra_qt/debugger/graphics_cmdlists.cpp b/src/citra_qt/debugger/graphics_cmdlists.cpp index 30b8b5dae..e98560a19 100644 --- a/src/citra_qt/debugger/graphics_cmdlists.cpp +++ b/src/citra_qt/debugger/graphics_cmdlists.cpp | |||
| @@ -78,7 +78,7 @@ QVariant GPUCommandListModel::data(const QModelIndex& index, int role) const | |||
| 78 | // index refers to a specific command | 78 | // index refers to a specific command |
| 79 | const GraphicsDebugger::PicaCommandList& cmdlist = command_lists[item->parent->index].second; | 79 | const GraphicsDebugger::PicaCommandList& cmdlist = command_lists[item->parent->index].second; |
| 80 | const GraphicsDebugger::PicaCommand& cmd = cmdlist[item->index]; | 80 | const GraphicsDebugger::PicaCommand& cmd = cmdlist[item->index]; |
| 81 | const Pica::CommandHeader& header = cmd.GetHeader(); | 81 | const Pica::CommandProcessor::CommandHeader& header = cmd.GetHeader(); |
| 82 | 82 | ||
| 83 | if (role == Qt::DisplayRole) { | 83 | if (role == Qt::DisplayRole) { |
| 84 | QString content; | 84 | QString content; |
diff --git a/src/core/hw/gpu.cpp b/src/core/hw/gpu.cpp index 591997aa3..87cf93bac 100644 --- a/src/core/hw/gpu.cpp +++ b/src/core/hw/gpu.cpp | |||
| @@ -14,6 +14,7 @@ | |||
| 14 | 14 | ||
| 15 | #include "core/hw/gpu.h" | 15 | #include "core/hw/gpu.h" |
| 16 | 16 | ||
| 17 | #include "video_core/command_processor.h" | ||
| 17 | #include "video_core/video_core.h" | 18 | #include "video_core/video_core.h" |
| 18 | 19 | ||
| 19 | 20 | ||
| @@ -143,14 +144,15 @@ inline void Write(u32 addr, const T data) { | |||
| 143 | break; | 144 | break; |
| 144 | } | 145 | } |
| 145 | 146 | ||
| 147 | // Seems like writing to this register triggers processing | ||
| 146 | case GPU_REG_INDEX(command_processor_config.trigger): | 148 | case GPU_REG_INDEX(command_processor_config.trigger): |
| 147 | { | 149 | { |
| 148 | const auto& config = g_regs.command_processor_config; | 150 | const auto& config = g_regs.command_processor_config; |
| 149 | if (config.trigger & 1) | 151 | if (config.trigger & 1) |
| 150 | { | 152 | { |
| 151 | // u32* buffer = (u32*)Memory::GetPointer(config.GetPhysicalAddress()); | 153 | u32* buffer = (u32*)Memory::GetPointer(Memory::PhysicalToVirtualAddress(config.GetPhysicalAddress())); |
| 152 | ERROR_LOG(GPU, "Beginning 0x%08x bytes of commands from address 0x%08x", config.size, config.GetPhysicalAddress()); | 154 | u32 size = config.size << 3; |
| 153 | // TODO: Process command list! | 155 | Pica::CommandProcessor::ProcessCommandList(buffer, size); |
| 154 | } | 156 | } |
| 155 | break; | 157 | break; |
| 156 | } | 158 | } |
diff --git a/src/video_core/CMakeLists.txt b/src/video_core/CMakeLists.txt index 2503b9d18..8977c8dca 100644 --- a/src/video_core/CMakeLists.txt +++ b/src/video_core/CMakeLists.txt | |||
| @@ -1,11 +1,14 @@ | |||
| 1 | set(SRCS video_core.cpp | 1 | set(SRCS command_processor.cpp |
| 2 | utils.cpp | 2 | utils.cpp |
| 3 | video_core.cpp | ||
| 3 | renderer_opengl/renderer_opengl.cpp) | 4 | renderer_opengl/renderer_opengl.cpp) |
| 4 | 5 | ||
| 5 | set(HEADERS math.h | 6 | set(HEADERS command_processor.h |
| 7 | math.h | ||
| 6 | utils.h | 8 | utils.h |
| 7 | video_core.h | 9 | video_core.h |
| 8 | renderer_base.h | 10 | renderer_base.h |
| 11 | video_core.h | ||
| 9 | renderer_opengl/renderer_opengl.h) | 12 | renderer_opengl/renderer_opengl.h) |
| 10 | 13 | ||
| 11 | add_library(video_core STATIC ${SRCS} ${HEADERS}) | 14 | add_library(video_core STATIC ${SRCS} ${HEADERS}) |
diff --git a/src/video_core/command_processor.cpp b/src/video_core/command_processor.cpp new file mode 100644 index 000000000..515c407ea --- /dev/null +++ b/src/video_core/command_processor.cpp | |||
| @@ -0,0 +1,60 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include "pica.h" | ||
| 6 | #include "command_processor.h" | ||
| 7 | |||
| 8 | |||
| 9 | namespace Pica { | ||
| 10 | |||
| 11 | Regs registers; | ||
| 12 | |||
| 13 | namespace CommandProcessor { | ||
| 14 | |||
| 15 | static inline void WritePicaReg(u32 id, u32 value) { | ||
| 16 | u32 old_value = registers[id]; | ||
| 17 | registers[id] = value; | ||
| 18 | |||
| 19 | switch(id) { | ||
| 20 | // TODO: Perform actions for anything which requires special treatment here... | ||
| 21 | |||
| 22 | default: | ||
| 23 | break; | ||
| 24 | } | ||
| 25 | } | ||
| 26 | |||
| 27 | static std::ptrdiff_t ExecuteCommandBlock(const u32* first_command_word) { | ||
| 28 | const CommandHeader& header = *(const CommandHeader*)(&first_command_word[1]); | ||
| 29 | |||
| 30 | u32* read_pointer = (u32*)first_command_word; | ||
| 31 | |||
| 32 | // TODO: Take parameter mask into consideration! | ||
| 33 | |||
| 34 | WritePicaReg(header.cmd_id, *read_pointer); | ||
| 35 | read_pointer += 2; | ||
| 36 | |||
| 37 | for (int i = 1; i < 1+header.extra_data_length; ++i) { | ||
| 38 | u32 cmd = header.cmd_id + ((header.group_commands) ? i : 0); | ||
| 39 | WritePicaReg(cmd, *read_pointer); | ||
| 40 | ++read_pointer; | ||
| 41 | } | ||
| 42 | |||
| 43 | // align read pointer to 8 bytes | ||
| 44 | if ((first_command_word - read_pointer) % 2) | ||
| 45 | ++read_pointer; | ||
| 46 | |||
| 47 | return read_pointer - first_command_word; | ||
| 48 | } | ||
| 49 | |||
| 50 | void ProcessCommandList(const u32* list, u32 size) { | ||
| 51 | u32* read_pointer = (u32*)list; | ||
| 52 | |||
| 53 | while (read_pointer < list + size) { | ||
| 54 | read_pointer += ExecuteCommandBlock(read_pointer); | ||
| 55 | } | ||
| 56 | } | ||
| 57 | |||
| 58 | } // namespace | ||
| 59 | |||
| 60 | } // namespace | ||
diff --git a/src/video_core/command_processor.h b/src/video_core/command_processor.h new file mode 100644 index 000000000..6b6241a25 --- /dev/null +++ b/src/video_core/command_processor.h | |||
| @@ -0,0 +1,31 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include "common/bit_field.h" | ||
| 8 | #include "common/common_types.h" | ||
| 9 | |||
| 10 | #include "pica.h" | ||
| 11 | |||
| 12 | namespace Pica { | ||
| 13 | |||
| 14 | namespace CommandProcessor { | ||
| 15 | |||
| 16 | union CommandHeader { | ||
| 17 | u32 hex; | ||
| 18 | |||
| 19 | BitField< 0, 16, u32> cmd_id; | ||
| 20 | BitField<16, 4, u32> parameter_mask; | ||
| 21 | BitField<20, 11, u32> extra_data_length; | ||
| 22 | BitField<31, 1, u32> group_commands; | ||
| 23 | }; | ||
| 24 | static_assert(std::is_standard_layout<CommandHeader>::value == true, "CommandHeader does not use standard layout"); | ||
| 25 | static_assert(sizeof(CommandHeader) == sizeof(u32), "CommandHeader has incorrect size!"); | ||
| 26 | |||
| 27 | void ProcessCommandList(const u32* list, u32 size); | ||
| 28 | |||
| 29 | } // namespace | ||
| 30 | |||
| 31 | } // namespace | ||
diff --git a/src/video_core/gpu_debugger.h b/src/video_core/gpu_debugger.h index 5d85f90b9..2ba873457 100644 --- a/src/video_core/gpu_debugger.h +++ b/src/video_core/gpu_debugger.h | |||
| @@ -11,6 +11,8 @@ | |||
| 11 | #include "common/log.h" | 11 | #include "common/log.h" |
| 12 | 12 | ||
| 13 | #include "core/hle/service/gsp.h" | 13 | #include "core/hle/service/gsp.h" |
| 14 | |||
| 15 | #include "command_processor.h" | ||
| 14 | #include "pica.h" | 16 | #include "pica.h" |
| 15 | 17 | ||
| 16 | class GraphicsDebugger | 18 | class GraphicsDebugger |
| @@ -20,10 +22,10 @@ public: | |||
| 20 | // A vector of commands represented by their raw byte sequence | 22 | // A vector of commands represented by their raw byte sequence |
| 21 | struct PicaCommand : public std::vector<u32> | 23 | struct PicaCommand : public std::vector<u32> |
| 22 | { | 24 | { |
| 23 | const Pica::CommandHeader& GetHeader() const | 25 | const Pica::CommandProcessor::CommandHeader& GetHeader() const |
| 24 | { | 26 | { |
| 25 | const u32& val = at(1); | 27 | const u32& val = at(1); |
| 26 | return *(Pica::CommandHeader*)&val; | 28 | return *(Pica::CommandProcessor::CommandHeader*)&val; |
| 27 | } | 29 | } |
| 28 | }; | 30 | }; |
| 29 | 31 | ||
| @@ -99,7 +101,7 @@ public: | |||
| 99 | PicaCommandList cmdlist; | 101 | PicaCommandList cmdlist; |
| 100 | for (u32* parse_pointer = command_list; parse_pointer < command_list + size_in_words;) | 102 | for (u32* parse_pointer = command_list; parse_pointer < command_list + size_in_words;) |
| 101 | { | 103 | { |
| 102 | const Pica::CommandHeader header = static_cast<Pica::CommandHeader>(parse_pointer[1]); | 104 | const Pica::CommandProcessor::CommandHeader& header = *(Pica::CommandProcessor::CommandHeader*)(&parse_pointer[1]); |
| 103 | 105 | ||
| 104 | cmdlist.push_back(PicaCommand()); | 106 | cmdlist.push_back(PicaCommand()); |
| 105 | auto& cmd = cmdlist.back(); | 107 | auto& cmd = cmdlist.back(); |
diff --git a/src/video_core/pica.h b/src/video_core/pica.h index 24b39a3ad..0e231c6c9 100644 --- a/src/video_core/pica.h +++ b/src/video_core/pica.h | |||
| @@ -161,6 +161,8 @@ ASSERT_REG_POSITION(vertex_descriptor, 0x200); | |||
| 161 | // The total number of registers is chosen arbitrarily, but let's make sure it's not some odd value anyway. | 161 | // The total number of registers is chosen arbitrarily, but let's make sure it's not some odd value anyway. |
| 162 | static_assert(sizeof(Regs) == 0x300 * sizeof(u32), "Invalid total size of register set"); | 162 | static_assert(sizeof(Regs) == 0x300 * sizeof(u32), "Invalid total size of register set"); |
| 163 | 163 | ||
| 164 | extern Regs registers; // TODO: Not sure if we want to have one global instance for this | ||
| 165 | |||
| 164 | 166 | ||
| 165 | struct float24 { | 167 | struct float24 { |
| 166 | static float24 FromFloat32(float val) { | 168 | static float24 FromFloat32(float val) { |
diff --git a/src/video_core/video_core.vcxproj b/src/video_core/video_core.vcxproj index 2dbfc68dd..28eb21284 100644 --- a/src/video_core/video_core.vcxproj +++ b/src/video_core/video_core.vcxproj | |||
| @@ -20,10 +20,12 @@ | |||
| 20 | </ItemGroup> | 20 | </ItemGroup> |
| 21 | <ItemGroup> | 21 | <ItemGroup> |
| 22 | <ClCompile Include="renderer_opengl\renderer_opengl.cpp" /> | 22 | <ClCompile Include="renderer_opengl\renderer_opengl.cpp" /> |
| 23 | <ClCompile Include="command_processor.cpp" /> | ||
| 23 | <ClCompile Include="utils.cpp" /> | 24 | <ClCompile Include="utils.cpp" /> |
| 24 | <ClCompile Include="video_core.cpp" /> | 25 | <ClCompile Include="video_core.cpp" /> |
| 25 | </ItemGroup> | 26 | </ItemGroup> |
| 26 | <ItemGroup> | 27 | <ItemGroup> |
| 28 | <ClInclude Include="command_processor.h" /> | ||
| 27 | <ClInclude Include="gpu_debugger.h" /> | 29 | <ClInclude Include="gpu_debugger.h" /> |
| 28 | <ClInclude Include="math.h" /> | 30 | <ClInclude Include="math.h" /> |
| 29 | <ClInclude Include="pica.h" /> | 31 | <ClInclude Include="pica.h" /> |
diff --git a/src/video_core/video_core.vcxproj.filters b/src/video_core/video_core.vcxproj.filters index b42823d2a..713458fcf 100644 --- a/src/video_core/video_core.vcxproj.filters +++ b/src/video_core/video_core.vcxproj.filters | |||
| @@ -9,6 +9,7 @@ | |||
| 9 | <ClCompile Include="renderer_opengl\renderer_opengl.cpp"> | 9 | <ClCompile Include="renderer_opengl\renderer_opengl.cpp"> |
| 10 | <Filter>renderer_opengl</Filter> | 10 | <Filter>renderer_opengl</Filter> |
| 11 | </ClCompile> | 11 | </ClCompile> |
| 12 | <ClCompile Include="command_processor.cpp" /> | ||
| 12 | <ClCompile Include="utils.cpp" /> | 13 | <ClCompile Include="utils.cpp" /> |
| 13 | <ClCompile Include="video_core.cpp" /> | 14 | <ClCompile Include="video_core.cpp" /> |
| 14 | </ItemGroup> | 15 | </ItemGroup> |
| @@ -16,6 +17,7 @@ | |||
| 16 | <ClInclude Include="renderer_opengl\renderer_opengl.h"> | 17 | <ClInclude Include="renderer_opengl\renderer_opengl.h"> |
| 17 | <Filter>renderer_opengl</Filter> | 18 | <Filter>renderer_opengl</Filter> |
| 18 | </ClInclude> | 19 | </ClInclude> |
| 20 | <ClInclude Include="command_processor.h" /> | ||
| 19 | <ClInclude Include="gpu_debugger.h" /> | 21 | <ClInclude Include="gpu_debugger.h" /> |
| 20 | <ClInclude Include="math.h" /> | 22 | <ClInclude Include="math.h" /> |
| 21 | <ClInclude Include="pica.h" /> | 23 | <ClInclude Include="pica.h" /> |