diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/command_processor.cpp | 43 | ||||
| -rw-r--r-- | src/video_core/command_processor.h | 2 | ||||
| -rw-r--r-- | src/video_core/engines/fermi_2d.cpp | 1 | ||||
| -rw-r--r-- | src/video_core/engines/fermi_2d.h | 8 | ||||
| -rw-r--r-- | src/video_core/engines/maxwell_3d.cpp | 17 | ||||
| -rw-r--r-- | src/video_core/engines/maxwell_3d.h | 22 | ||||
| -rw-r--r-- | src/video_core/engines/maxwell_compute.cpp | 1 | ||||
| -rw-r--r-- | src/video_core/engines/maxwell_compute.h | 8 | ||||
| -rw-r--r-- | src/video_core/gpu.h | 3 |
9 files changed, 97 insertions, 8 deletions
diff --git a/src/video_core/command_processor.cpp b/src/video_core/command_processor.cpp index 21d672085..26ba8c40b 100644 --- a/src/video_core/command_processor.cpp +++ b/src/video_core/command_processor.cpp | |||
| @@ -64,6 +64,35 @@ void GPU::WriteReg(u32 method, u32 subchannel, u32 value) { | |||
| 64 | } | 64 | } |
| 65 | } | 65 | } |
| 66 | 66 | ||
| 67 | void GPU::CallMethod(u32 method, u32 subchannel, const std::vector<u32>& parameters) { | ||
| 68 | LOG_WARNING(HW_GPU, "Processing method %08X on subchannel %u num params %zu", method, | ||
| 69 | subchannel, parameters.size()); | ||
| 70 | |||
| 71 | if (method < static_cast<u32>(BufferMethods::CountBufferMethods)) { | ||
| 72 | // TODO(Subv): Research and implement these methods. | ||
| 73 | LOG_ERROR(HW_GPU, "Special buffer methods other than Bind are not implemented"); | ||
| 74 | return; | ||
| 75 | } | ||
| 76 | |||
| 77 | ASSERT(bound_engines.find(subchannel) != bound_engines.end()); | ||
| 78 | |||
| 79 | const EngineID engine = bound_engines[subchannel]; | ||
| 80 | |||
| 81 | switch (engine) { | ||
| 82 | case EngineID::FERMI_TWOD_A: | ||
| 83 | fermi_2d->CallMethod(method, parameters); | ||
| 84 | break; | ||
| 85 | case EngineID::MAXWELL_B: | ||
| 86 | maxwell_3d->CallMethod(method, parameters); | ||
| 87 | break; | ||
| 88 | case EngineID::MAXWELL_COMPUTE_B: | ||
| 89 | maxwell_compute->CallMethod(method, parameters); | ||
| 90 | break; | ||
| 91 | default: | ||
| 92 | UNIMPLEMENTED(); | ||
| 93 | } | ||
| 94 | } | ||
| 95 | |||
| 67 | void GPU::ProcessCommandList(GPUVAddr address, u32 size) { | 96 | void GPU::ProcessCommandList(GPUVAddr address, u32 size) { |
| 68 | // TODO(Subv): PhysicalToVirtualAddress is a misnomer, it converts a GPU VAddr into an | 97 | // TODO(Subv): PhysicalToVirtualAddress is a misnomer, it converts a GPU VAddr into an |
| 69 | // application VAddr. | 98 | // application VAddr. |
| @@ -96,13 +125,17 @@ void GPU::ProcessCommandList(GPUVAddr address, u32 size) { | |||
| 96 | ASSERT(header.arg_count.Value() >= 1); | 125 | ASSERT(header.arg_count.Value() >= 1); |
| 97 | // Use the original method for the first argument and then the next method for all other | 126 | // Use the original method for the first argument and then the next method for all other |
| 98 | // arguments. | 127 | // arguments. |
| 99 | WriteReg(header.method, header.subchannel, Memory::Read32(current_addr)); | 128 | |
| 100 | current_addr += sizeof(u32); | 129 | // Process this command as a method call instead of a register write. Gather |
| 101 | // Use the same method value for all arguments. | 130 | // all the parameters first and then pass them at once to the CallMethod function. |
| 102 | for (unsigned i = 1; i < header.arg_count; ++i) { | 131 | std::vector<u32> parameters(header.arg_count); |
| 103 | WriteReg(header.method + 1, header.subchannel, Memory::Read32(current_addr)); | 132 | |
| 133 | for (unsigned i = 0; i < header.arg_count; ++i) { | ||
| 134 | parameters[i] = Memory::Read32(current_addr); | ||
| 104 | current_addr += sizeof(u32); | 135 | current_addr += sizeof(u32); |
| 105 | } | 136 | } |
| 137 | |||
| 138 | CallMethod(header.method, header.subchannel, parameters); | ||
| 106 | break; | 139 | break; |
| 107 | } | 140 | } |
| 108 | case SubmissionMode::Inline: { | 141 | case SubmissionMode::Inline: { |
diff --git a/src/video_core/command_processor.h b/src/video_core/command_processor.h index b511bfcf7..f7214ffec 100644 --- a/src/video_core/command_processor.h +++ b/src/video_core/command_processor.h | |||
| @@ -34,6 +34,4 @@ static_assert(std::is_standard_layout<CommandHeader>::value == true, | |||
| 34 | "CommandHeader does not use standard layout"); | 34 | "CommandHeader does not use standard layout"); |
| 35 | static_assert(sizeof(CommandHeader) == sizeof(u32), "CommandHeader has incorrect size!"); | 35 | static_assert(sizeof(CommandHeader) == sizeof(u32), "CommandHeader has incorrect size!"); |
| 36 | 36 | ||
| 37 | void ProcessCommandList(VAddr address, u32 size); | ||
| 38 | |||
| 39 | } // namespace Tegra | 37 | } // namespace Tegra |
diff --git a/src/video_core/engines/fermi_2d.cpp b/src/video_core/engines/fermi_2d.cpp index 7aab163dc..6c6162cf3 100644 --- a/src/video_core/engines/fermi_2d.cpp +++ b/src/video_core/engines/fermi_2d.cpp | |||
| @@ -8,6 +8,7 @@ namespace Tegra { | |||
| 8 | namespace Engines { | 8 | namespace Engines { |
| 9 | 9 | ||
| 10 | void Fermi2D::WriteReg(u32 method, u32 value) {} | 10 | void Fermi2D::WriteReg(u32 method, u32 value) {} |
| 11 | void Fermi2D::CallMethod(u32 method, const std::vector<u32>& parameters) {} | ||
| 11 | 12 | ||
| 12 | } // namespace Engines | 13 | } // namespace Engines |
| 13 | } // namespace Tegra | 14 | } // namespace Tegra |
diff --git a/src/video_core/engines/fermi_2d.h b/src/video_core/engines/fermi_2d.h index 8967ddede..ce8920cee 100644 --- a/src/video_core/engines/fermi_2d.h +++ b/src/video_core/engines/fermi_2d.h | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <vector> | ||
| 7 | #include "common/common_types.h" | 8 | #include "common/common_types.h" |
| 8 | 9 | ||
| 9 | namespace Tegra { | 10 | namespace Tegra { |
| @@ -16,6 +17,13 @@ public: | |||
| 16 | 17 | ||
| 17 | /// Write the value to the register identified by method. | 18 | /// Write the value to the register identified by method. |
| 18 | void WriteReg(u32 method, u32 value); | 19 | void WriteReg(u32 method, u32 value); |
| 20 | |||
| 21 | /** | ||
| 22 | * Handles a method call to this engine. | ||
| 23 | * @param method Method to call | ||
| 24 | * @param parameters Arguments to the method call | ||
| 25 | */ | ||
| 26 | void CallMethod(u32 method, const std::vector<u32>& parameters); | ||
| 19 | }; | 27 | }; |
| 20 | 28 | ||
| 21 | } // namespace Engines | 29 | } // namespace Engines |
diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp index 8c6d1172c..1b963e87e 100644 --- a/src/video_core/engines/maxwell_3d.cpp +++ b/src/video_core/engines/maxwell_3d.cpp | |||
| @@ -8,8 +8,23 @@ | |||
| 8 | namespace Tegra { | 8 | namespace Tegra { |
| 9 | namespace Engines { | 9 | namespace Engines { |
| 10 | 10 | ||
| 11 | const std::unordered_map<u32, Maxwell3D::MethodInfo> Maxwell3D::method_handlers = { | ||
| 12 | {0xE24, {"PrepareShader", 5, &Maxwell3D::PrepareShader}}, | ||
| 13 | }; | ||
| 14 | |||
| 11 | Maxwell3D::Maxwell3D(MemoryManager& memory_manager) : memory_manager(memory_manager) {} | 15 | Maxwell3D::Maxwell3D(MemoryManager& memory_manager) : memory_manager(memory_manager) {} |
| 12 | 16 | ||
| 17 | void Maxwell3D::CallMethod(u32 method, const std::vector<u32>& parameters) { | ||
| 18 | auto itr = method_handlers.find(method); | ||
| 19 | if (itr == method_handlers.end()) { | ||
| 20 | LOG_ERROR(HW_GPU, "Unhandled method call %08X", method); | ||
| 21 | return; | ||
| 22 | } | ||
| 23 | |||
| 24 | ASSERT(itr->second.arguments == parameters.size()); | ||
| 25 | (this->*itr->second.handler)(parameters); | ||
| 26 | } | ||
| 27 | |||
| 13 | void Maxwell3D::WriteReg(u32 method, u32 value) { | 28 | void Maxwell3D::WriteReg(u32 method, u32 value) { |
| 14 | ASSERT_MSG(method < Regs::NUM_REGS, | 29 | ASSERT_MSG(method < Regs::NUM_REGS, |
| 15 | "Invalid Maxwell3D register, increase the size of the Regs structure"); | 30 | "Invalid Maxwell3D register, increase the size of the Regs structure"); |
| @@ -64,5 +79,7 @@ void Maxwell3D::DrawArrays() { | |||
| 64 | LOG_WARNING(HW_GPU, "Game requested a DrawArrays, ignoring"); | 79 | LOG_WARNING(HW_GPU, "Game requested a DrawArrays, ignoring"); |
| 65 | } | 80 | } |
| 66 | 81 | ||
| 82 | void Maxwell3D::PrepareShader(const std::vector<u32>& parameters) {} | ||
| 83 | |||
| 67 | } // namespace Engines | 84 | } // namespace Engines |
| 68 | } // namespace Tegra | 85 | } // namespace Tegra |
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h index a2ad28732..8870ef119 100644 --- a/src/video_core/engines/maxwell_3d.h +++ b/src/video_core/engines/maxwell_3d.h | |||
| @@ -4,6 +4,8 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <unordered_map> | ||
| 8 | #include <vector> | ||
| 7 | #include "common/bit_field.h" | 9 | #include "common/bit_field.h" |
| 8 | #include "common/common_funcs.h" | 10 | #include "common/common_funcs.h" |
| 9 | #include "common/common_types.h" | 11 | #include "common/common_types.h" |
| @@ -20,6 +22,13 @@ public: | |||
| 20 | /// Write the value to the register identified by method. | 22 | /// Write the value to the register identified by method. |
| 21 | void WriteReg(u32 method, u32 value); | 23 | void WriteReg(u32 method, u32 value); |
| 22 | 24 | ||
| 25 | /** | ||
| 26 | * Handles a method call to this engine. | ||
| 27 | * @param method Method to call | ||
| 28 | * @param parameters Arguments to the method call | ||
| 29 | */ | ||
| 30 | void CallMethod(u32 method, const std::vector<u32>& parameters); | ||
| 31 | |||
| 23 | /// Register structure of the Maxwell3D engine. | 32 | /// Register structure of the Maxwell3D engine. |
| 24 | /// TODO(Subv): This structure will need to be made bigger as more registers are discovered. | 33 | /// TODO(Subv): This structure will need to be made bigger as more registers are discovered. |
| 25 | struct Regs { | 34 | struct Regs { |
| @@ -112,13 +121,24 @@ public: | |||
| 112 | static_assert(sizeof(Regs) == Regs::NUM_REGS * sizeof(u32), "Maxwell3D Regs has wrong size"); | 121 | static_assert(sizeof(Regs) == Regs::NUM_REGS * sizeof(u32), "Maxwell3D Regs has wrong size"); |
| 113 | 122 | ||
| 114 | private: | 123 | private: |
| 124 | MemoryManager& memory_manager; | ||
| 125 | |||
| 115 | /// Handles a write to the QUERY_GET register. | 126 | /// Handles a write to the QUERY_GET register. |
| 116 | void ProcessQueryGet(); | 127 | void ProcessQueryGet(); |
| 117 | 128 | ||
| 118 | /// Handles a write to the VERTEX_END_GL register, triggering a draw. | 129 | /// Handles a write to the VERTEX_END_GL register, triggering a draw. |
| 119 | void DrawArrays(); | 130 | void DrawArrays(); |
| 120 | 131 | ||
| 121 | MemoryManager& memory_manager; | 132 | /// Method call handlers |
| 133 | void PrepareShader(const std::vector<u32>& parameters); | ||
| 134 | |||
| 135 | struct MethodInfo { | ||
| 136 | const char* name; | ||
| 137 | u32 arguments; | ||
| 138 | void (Maxwell3D::*handler)(const std::vector<u32>& parameters); | ||
| 139 | }; | ||
| 140 | |||
| 141 | static const std::unordered_map<u32, MethodInfo> method_handlers; | ||
| 122 | }; | 142 | }; |
| 123 | 143 | ||
| 124 | #define ASSERT_REG_POSITION(field_name, position) \ | 144 | #define ASSERT_REG_POSITION(field_name, position) \ |
diff --git a/src/video_core/engines/maxwell_compute.cpp b/src/video_core/engines/maxwell_compute.cpp index e4e5f9e5e..3bef7fe86 100644 --- a/src/video_core/engines/maxwell_compute.cpp +++ b/src/video_core/engines/maxwell_compute.cpp | |||
| @@ -8,6 +8,7 @@ namespace Tegra { | |||
| 8 | namespace Engines { | 8 | namespace Engines { |
| 9 | 9 | ||
| 10 | void MaxwellCompute::WriteReg(u32 method, u32 value) {} | 10 | void MaxwellCompute::WriteReg(u32 method, u32 value) {} |
| 11 | void MaxwellCompute::CallMethod(u32 method, const std::vector<u32>& parameters) {} | ||
| 11 | 12 | ||
| 12 | } // namespace Engines | 13 | } // namespace Engines |
| 13 | } // namespace Tegra | 14 | } // namespace Tegra |
diff --git a/src/video_core/engines/maxwell_compute.h b/src/video_core/engines/maxwell_compute.h index 7262e1bcb..5fc7ed635 100644 --- a/src/video_core/engines/maxwell_compute.h +++ b/src/video_core/engines/maxwell_compute.h | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <vector> | ||
| 7 | #include "common/common_types.h" | 8 | #include "common/common_types.h" |
| 8 | 9 | ||
| 9 | namespace Tegra { | 10 | namespace Tegra { |
| @@ -16,6 +17,13 @@ public: | |||
| 16 | 17 | ||
| 17 | /// Write the value to the register identified by method. | 18 | /// Write the value to the register identified by method. |
| 18 | void WriteReg(u32 method, u32 value); | 19 | void WriteReg(u32 method, u32 value); |
| 20 | |||
| 21 | /** | ||
| 22 | * Handles a method call to this engine. | ||
| 23 | * @param method Method to call | ||
| 24 | * @param parameters Arguments to the method call | ||
| 25 | */ | ||
| 26 | void CallMethod(u32 method, const std::vector<u32>& parameters); | ||
| 19 | }; | 27 | }; |
| 20 | 28 | ||
| 21 | } // namespace Engines | 29 | } // namespace Engines |
diff --git a/src/video_core/gpu.h b/src/video_core/gpu.h index ba7781756..c5ec6fdef 100644 --- a/src/video_core/gpu.h +++ b/src/video_core/gpu.h | |||
| @@ -41,6 +41,9 @@ private: | |||
| 41 | /// Writes a single register in the engine bound to the specified subchannel | 41 | /// Writes a single register in the engine bound to the specified subchannel |
| 42 | void WriteReg(u32 method, u32 subchannel, u32 value); | 42 | void WriteReg(u32 method, u32 subchannel, u32 value); |
| 43 | 43 | ||
| 44 | /// Calls a method in the engine bound to the specified subchannel with the input parameters. | ||
| 45 | void CallMethod(u32 method, u32 subchannel, const std::vector<u32>& parameters); | ||
| 46 | |||
| 44 | /// Mapping of command subchannels to their bound engine ids. | 47 | /// Mapping of command subchannels to their bound engine ids. |
| 45 | std::unordered_map<u32, EngineID> bound_engines; | 48 | std::unordered_map<u32, EngineID> bound_engines; |
| 46 | 49 | ||