diff options
Diffstat (limited to 'src/video_core')
| -rw-r--r-- | src/video_core/command_processor.cpp | 56 | ||||
| -rw-r--r-- | src/video_core/engines/maxwell_3d.cpp | 23 | ||||
| -rw-r--r-- | src/video_core/engines/maxwell_3d.h | 12 | ||||
| -rw-r--r-- | src/video_core/gpu.h | 10 |
4 files changed, 74 insertions, 27 deletions
diff --git a/src/video_core/command_processor.cpp b/src/video_core/command_processor.cpp index 1d578582e..d4cdb4ab2 100644 --- a/src/video_core/command_processor.cpp +++ b/src/video_core/command_processor.cpp | |||
| @@ -24,12 +24,37 @@ namespace Tegra { | |||
| 24 | 24 | ||
| 25 | enum class BufferMethods { | 25 | enum class BufferMethods { |
| 26 | BindObject = 0, | 26 | BindObject = 0, |
| 27 | SetGraphMacroCode = 0x45, | ||
| 28 | SetGraphMacroCodeArg = 0x46, | ||
| 29 | SetGraphMacroEntry = 0x47, | ||
| 27 | CountBufferMethods = 0x100, | 30 | CountBufferMethods = 0x100, |
| 28 | }; | 31 | }; |
| 29 | 32 | ||
| 30 | void GPU::WriteReg(u32 method, u32 subchannel, u32 value) { | 33 | void GPU::WriteReg(u32 method, u32 subchannel, u32 value, u32 remaining_params) { |
| 31 | LOG_WARNING(HW_GPU, "Processing method %08X on subchannel %u value %08X", method, subchannel, | 34 | LOG_WARNING(HW_GPU, "Processing method %08X on subchannel %u value %08X remaining params %u", |
| 32 | value); | 35 | method, subchannel, value, remaining_params); |
| 36 | |||
| 37 | if (method == static_cast<u32>(BufferMethods::SetGraphMacroEntry)) { | ||
| 38 | // Prepare to upload a new macro, reset the upload counter. | ||
| 39 | LOG_DEBUG(HW_GPU, "Uploading GPU macro %08X", value); | ||
| 40 | current_macro_entry = value; | ||
| 41 | current_macro_code.clear(); | ||
| 42 | return; | ||
| 43 | } | ||
| 44 | |||
| 45 | if (method == static_cast<u32>(BufferMethods::SetGraphMacroCodeArg)) { | ||
| 46 | // Append a new code word to the current macro. | ||
| 47 | current_macro_code.push_back(value); | ||
| 48 | |||
| 49 | // There are no more params remaining, submit the code to the 3D engine. | ||
| 50 | if (remaining_params == 0) { | ||
| 51 | maxwell_3d->SubmitMacroCode(current_macro_entry, std::move(current_macro_code)); | ||
| 52 | current_macro_entry = InvalidGraphMacroEntry; | ||
| 53 | current_macro_code.clear(); | ||
| 54 | } | ||
| 55 | |||
| 56 | return; | ||
| 57 | } | ||
| 33 | 58 | ||
| 34 | if (method == static_cast<u32>(BufferMethods::BindObject)) { | 59 | if (method == static_cast<u32>(BufferMethods::BindObject)) { |
| 35 | // Bind the current subchannel to the desired engine id. | 60 | // Bind the current subchannel to the desired engine id. |
| @@ -54,7 +79,7 @@ void GPU::WriteReg(u32 method, u32 subchannel, u32 value) { | |||
| 54 | fermi_2d->WriteReg(method, value); | 79 | fermi_2d->WriteReg(method, value); |
| 55 | break; | 80 | break; |
| 56 | case EngineID::MAXWELL_B: | 81 | case EngineID::MAXWELL_B: |
| 57 | maxwell_3d->WriteReg(method, value); | 82 | maxwell_3d->WriteReg(method, value, remaining_params); |
| 58 | break; | 83 | break; |
| 59 | case EngineID::MAXWELL_COMPUTE_B: | 84 | case EngineID::MAXWELL_COMPUTE_B: |
| 60 | maxwell_compute->WriteReg(method, value); | 85 | maxwell_compute->WriteReg(method, value); |
| @@ -78,7 +103,8 @@ void GPU::ProcessCommandList(GPUVAddr address, u32 size) { | |||
| 78 | case SubmissionMode::Increasing: { | 103 | case SubmissionMode::Increasing: { |
| 79 | // Increase the method value with each argument. | 104 | // Increase the method value with each argument. |
| 80 | for (unsigned i = 0; i < header.arg_count; ++i) { | 105 | for (unsigned i = 0; i < header.arg_count; ++i) { |
| 81 | WriteReg(header.method + i, header.subchannel, Memory::Read32(current_addr)); | 106 | WriteReg(header.method + i, header.subchannel, Memory::Read32(current_addr), |
| 107 | header.arg_count - i - 1); | ||
| 82 | current_addr += sizeof(u32); | 108 | current_addr += sizeof(u32); |
| 83 | } | 109 | } |
| 84 | break; | 110 | break; |
| @@ -87,31 +113,31 @@ void GPU::ProcessCommandList(GPUVAddr address, u32 size) { | |||
| 87 | case SubmissionMode::NonIncreasing: { | 113 | case SubmissionMode::NonIncreasing: { |
| 88 | // Use the same method value for all arguments. | 114 | // Use the same method value for all arguments. |
| 89 | for (unsigned i = 0; i < header.arg_count; ++i) { | 115 | for (unsigned i = 0; i < header.arg_count; ++i) { |
| 90 | WriteReg(header.method, header.subchannel, Memory::Read32(current_addr)); | 116 | WriteReg(header.method, header.subchannel, Memory::Read32(current_addr), |
| 117 | header.arg_count - i - 1); | ||
| 91 | current_addr += sizeof(u32); | 118 | current_addr += sizeof(u32); |
| 92 | } | 119 | } |
| 93 | break; | 120 | break; |
| 94 | } | 121 | } |
| 95 | case SubmissionMode::IncreaseOnce: { | 122 | case SubmissionMode::IncreaseOnce: { |
| 96 | ASSERT(header.arg_count.Value() >= 1); | 123 | ASSERT(header.arg_count.Value() >= 1); |
| 124 | |||
| 97 | // Use the original method for the first argument and then the next method for all other | 125 | // Use the original method for the first argument and then the next method for all other |
| 98 | // arguments. | 126 | // arguments. |
| 127 | WriteReg(header.method, header.subchannel, Memory::Read32(current_addr), | ||
| 128 | header.arg_count - 1); | ||
| 129 | current_addr += sizeof(u32); | ||
| 99 | 130 | ||
| 100 | // Process this command as a method call instead of a register write. Gather | 131 | for (unsigned i = 1; i < header.arg_count; ++i) { |
| 101 | // all the parameters first and then pass them at once to the CallMethod function. | 132 | WriteReg(header.method + 1, header.subchannel, Memory::Read32(current_addr), |
| 102 | std::vector<u32> parameters(header.arg_count); | 133 | header.arg_count - i - 1); |
| 103 | |||
| 104 | for (unsigned i = 0; i < header.arg_count; ++i) { | ||
| 105 | parameters[i] = Memory::Read32(current_addr); | ||
| 106 | current_addr += sizeof(u32); | 134 | current_addr += sizeof(u32); |
| 107 | } | 135 | } |
| 108 | |||
| 109 | CallMethod(header.method, header.subchannel, parameters); | ||
| 110 | break; | 136 | break; |
| 111 | } | 137 | } |
| 112 | case SubmissionMode::Inline: { | 138 | case SubmissionMode::Inline: { |
| 113 | // The register value is stored in the bits 16-28 as an immediate | 139 | // The register value is stored in the bits 16-28 as an immediate |
| 114 | WriteReg(header.method, header.subchannel, header.inline_data); | 140 | WriteReg(header.method, header.subchannel, header.inline_data, 0); |
| 115 | break; | 141 | break; |
| 116 | } | 142 | } |
| 117 | default: | 143 | default: |
diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp index 67b1b4e7f..49a138c1d 100644 --- a/src/video_core/engines/maxwell_3d.cpp +++ b/src/video_core/engines/maxwell_3d.cpp | |||
| @@ -17,14 +17,21 @@ const std::unordered_map<u32, Maxwell3D::MethodInfo> Maxwell3D::method_handlers | |||
| 17 | 17 | ||
| 18 | Maxwell3D::Maxwell3D(MemoryManager& memory_manager) : memory_manager(memory_manager) {} | 18 | Maxwell3D::Maxwell3D(MemoryManager& memory_manager) : memory_manager(memory_manager) {} |
| 19 | 19 | ||
| 20 | void Maxwell3D::AttemptMethodCall(u32 method, const std::vector<u32>& parameters) { | 20 | void Maxwell3D::SubmitMacroCode(u32 entry, std::vector<u32> code) { |
| 21 | uploaded_macros[entry * 2 + MacroRegistersStart] = std::move(code); | ||
| 22 | } | ||
| 23 | |||
| 24 | void Maxwell3D::CallMacroMethod(u32 method, const std::vector<u32>& parameters) { | ||
| 21 | // TODO(Subv): Write an interpreter for the macros uploaded via registers 0x45 and 0x47 | 25 | // TODO(Subv): Write an interpreter for the macros uploaded via registers 0x45 and 0x47 |
| 26 | |||
| 27 | // The requested macro must have been uploaded already. | ||
| 28 | ASSERT_MSG(uploaded_macros.find(method) != uploaded_macros.end(), "Macro %08X was not uploaded", | ||
| 29 | method); | ||
| 30 | |||
| 22 | auto itr = method_handlers.find(method); | 31 | auto itr = method_handlers.find(method); |
| 23 | ASSERT_MSG(itr != method_handlers.end(), "Unhandled method call %08X", method); | 32 | ASSERT_MSG(itr != method_handlers.end(), "Unhandled method call %08X", method); |
| 24 | 33 | ||
| 25 | // Only execute the macro handler once we've been fed the expected number of parameters. | 34 | ASSERT(itr->second.arguments == parameters.size()); |
| 26 | if (itr->second.arguments != parameters.size()) | ||
| 27 | return; | ||
| 28 | 35 | ||
| 29 | (this->*itr->second.handler)(parameters); | 36 | (this->*itr->second.handler)(parameters); |
| 30 | 37 | ||
| @@ -33,7 +40,7 @@ void Maxwell3D::AttemptMethodCall(u32 method, const std::vector<u32>& parameters | |||
| 33 | macro_params.clear(); | 40 | macro_params.clear(); |
| 34 | } | 41 | } |
| 35 | 42 | ||
| 36 | void Maxwell3D::WriteReg(u32 method, u32 value) { | 43 | void Maxwell3D::WriteReg(u32 method, u32 value, u32 remaining_params) { |
| 37 | ASSERT_MSG(method < Regs::NUM_REGS, | 44 | ASSERT_MSG(method < Regs::NUM_REGS, |
| 38 | "Invalid Maxwell3D register, increase the size of the Regs structure"); | 45 | "Invalid Maxwell3D register, increase the size of the Regs structure"); |
| 39 | 46 | ||
| @@ -56,8 +63,10 @@ void Maxwell3D::WriteReg(u32 method, u32 value) { | |||
| 56 | 63 | ||
| 57 | macro_params.push_back(value); | 64 | macro_params.push_back(value); |
| 58 | 65 | ||
| 59 | // Try to call the macro with the current number of parameters. | 66 | // Call the macro when there are no more parameters in the command buffer |
| 60 | AttemptMethodCall(executing_macro, macro_params); | 67 | if (remaining_params == 0) { |
| 68 | CallMacroMethod(executing_macro, macro_params); | ||
| 69 | } | ||
| 61 | return; | 70 | return; |
| 62 | } | 71 | } |
| 63 | 72 | ||
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h index 75a1c05bc..05820a21e 100644 --- a/src/video_core/engines/maxwell_3d.h +++ b/src/video_core/engines/maxwell_3d.h | |||
| @@ -21,7 +21,10 @@ public: | |||
| 21 | ~Maxwell3D() = default; | 21 | ~Maxwell3D() = default; |
| 22 | 22 | ||
| 23 | /// Write the value to the register identified by method. | 23 | /// Write the value to the register identified by method. |
| 24 | void WriteReg(u32 method, u32 value); | 24 | void WriteReg(u32 method, u32 value, u32 remaining_params); |
| 25 | |||
| 26 | /// Uploads the code for a GPU macro program associated with the specified entry. | ||
| 27 | void SubmitMacroCode(u32 entry, std::vector<u32> code); | ||
| 25 | 28 | ||
| 26 | /// Register structure of the Maxwell3D engine. | 29 | /// Register structure of the Maxwell3D engine. |
| 27 | /// TODO(Subv): This structure will need to be made bigger as more registers are discovered. | 30 | /// TODO(Subv): This structure will need to be made bigger as more registers are discovered. |
| @@ -198,18 +201,19 @@ public: | |||
| 198 | private: | 201 | private: |
| 199 | MemoryManager& memory_manager; | 202 | MemoryManager& memory_manager; |
| 200 | 203 | ||
| 204 | std::unordered_map<u32, std::vector<u32>> uploaded_macros; | ||
| 205 | |||
| 201 | /// Macro method that is currently being executed / being fed parameters. | 206 | /// Macro method that is currently being executed / being fed parameters. |
| 202 | u32 executing_macro = 0; | 207 | u32 executing_macro = 0; |
| 203 | /// Parameters that have been submitted to the macro call so far. | 208 | /// Parameters that have been submitted to the macro call so far. |
| 204 | std::vector<u32> macro_params; | 209 | std::vector<u32> macro_params; |
| 205 | 210 | ||
| 206 | /** | 211 | /** |
| 207 | * Attempts a method call to this engine. Will return without doing anything if the number of | 212 | * Call a macro on this engine. |
| 208 | * parameters doesn't match what is expected for the method. | ||
| 209 | * @param method Method to call | 213 | * @param method Method to call |
| 210 | * @param parameters Arguments to the method call | 214 | * @param parameters Arguments to the method call |
| 211 | */ | 215 | */ |
| 212 | void AttemptMethodCall(u32 method, const std::vector<u32>& parameters); | 216 | void CallMacroMethod(u32 method, const std::vector<u32>& parameters); |
| 213 | 217 | ||
| 214 | /// Handles a write to the QUERY_GET register. | 218 | /// Handles a write to the QUERY_GET register. |
| 215 | void ProcessQueryGet(); | 219 | void ProcessQueryGet(); |
diff --git a/src/video_core/gpu.h b/src/video_core/gpu.h index ba7781756..d2e4ff52d 100644 --- a/src/video_core/gpu.h +++ b/src/video_core/gpu.h | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | 6 | ||
| 7 | #include <memory> | 7 | #include <memory> |
| 8 | #include <unordered_map> | 8 | #include <unordered_map> |
| 9 | #include <vector> | ||
| 9 | #include "common/common_types.h" | 10 | #include "common/common_types.h" |
| 10 | #include "video_core/engines/fermi_2d.h" | 11 | #include "video_core/engines/fermi_2d.h" |
| 11 | #include "video_core/engines/maxwell_3d.h" | 12 | #include "video_core/engines/maxwell_3d.h" |
| @@ -38,8 +39,10 @@ public: | |||
| 38 | std::unique_ptr<MemoryManager> memory_manager; | 39 | std::unique_ptr<MemoryManager> memory_manager; |
| 39 | 40 | ||
| 40 | private: | 41 | private: |
| 42 | static constexpr u32 InvalidGraphMacroEntry = 0xFFFFFFFF; | ||
| 43 | |||
| 41 | /// Writes a single register in the engine bound to the specified subchannel | 44 | /// Writes a single register in the engine bound to the specified subchannel |
| 42 | void WriteReg(u32 method, u32 subchannel, u32 value); | 45 | void WriteReg(u32 method, u32 subchannel, u32 value, u32 remaining_params); |
| 43 | 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; |
| @@ -50,6 +53,11 @@ private: | |||
| 50 | std::unique_ptr<Engines::Fermi2D> fermi_2d; | 53 | std::unique_ptr<Engines::Fermi2D> fermi_2d; |
| 51 | /// Compute engine | 54 | /// Compute engine |
| 52 | std::unique_ptr<Engines::MaxwellCompute> maxwell_compute; | 55 | std::unique_ptr<Engines::MaxwellCompute> maxwell_compute; |
| 56 | |||
| 57 | /// Entry of the macro that is currently being uploaded | ||
| 58 | u32 current_macro_entry = InvalidGraphMacroEntry; | ||
| 59 | /// Code being uploaded for the current macro | ||
| 60 | std::vector<u32> current_macro_code; | ||
| 53 | }; | 61 | }; |
| 54 | 62 | ||
| 55 | } // namespace Tegra | 63 | } // namespace Tegra |