From 29feece4b849bd40cc6dcef6c60f4bc58707557a Mon Sep 17 00:00:00 2001 From: Subv Date: Fri, 16 Mar 2018 20:32:44 -0500 Subject: GPU: Process command mode 5 (IncreaseOnce) differently from other commands. Accumulate all arguments before calling the desired method. Note: Maybe we should do the same for the NonIncreasing mode? --- src/video_core/engines/fermi_2d.cpp | 1 + src/video_core/engines/fermi_2d.h | 8 ++++++++ src/video_core/engines/maxwell_3d.cpp | 17 +++++++++++++++++ src/video_core/engines/maxwell_3d.h | 22 +++++++++++++++++++++- src/video_core/engines/maxwell_compute.cpp | 1 + src/video_core/engines/maxwell_compute.h | 8 ++++++++ 6 files changed, 56 insertions(+), 1 deletion(-) (limited to 'src/video_core/engines') 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 { namespace Engines { void Fermi2D::WriteReg(u32 method, u32 value) {} +void Fermi2D::CallMethod(u32 method, const std::vector& parameters) {} } // namespace Engines } // 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 @@ #pragma once +#include #include "common/common_types.h" namespace Tegra { @@ -16,6 +17,13 @@ public: /// Write the value to the register identified by method. void WriteReg(u32 method, u32 value); + + /** + * Handles a method call to this engine. + * @param method Method to call + * @param parameters Arguments to the method call + */ + void CallMethod(u32 method, const std::vector& parameters); }; } // namespace Engines diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp index 842c5a014..ef32180dd 100644 --- a/src/video_core/engines/maxwell_3d.cpp +++ b/src/video_core/engines/maxwell_3d.cpp @@ -8,8 +8,23 @@ namespace Tegra { namespace Engines { +const std::unordered_map Maxwell3D::method_handlers = { + {0xE24, {"PrepareShader", 5, &Maxwell3D::PrepareShader}}, +}; + Maxwell3D::Maxwell3D(MemoryManager& memory_manager) : memory_manager(memory_manager) {} +void Maxwell3D::CallMethod(u32 method, const std::vector& parameters) { + auto itr = method_handlers.find(method); + if (itr == method_handlers.end()) { + LOG_ERROR(HW_GPU, "Unhandled method call %08X", method); + return; + } + + ASSERT(itr->second.arguments == parameters.size()); + (this->*itr->second.handler)(parameters); +} + void Maxwell3D::WriteReg(u32 method, u32 value) { ASSERT_MSG(method < Regs::NUM_REGS, "Invalid Maxwell3D register, increase the size of the Regs structure"); @@ -56,5 +71,7 @@ void Maxwell3D::DrawArrays() { LOG_WARNING(HW_GPU, "Game requested a DrawArrays, ignoring"); } +void Maxwell3D::PrepareShader(const std::vector& parameters) {} + } // namespace Engines } // namespace Tegra diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h index 93f7698a0..954369cf5 100644 --- a/src/video_core/engines/maxwell_3d.h +++ b/src/video_core/engines/maxwell_3d.h @@ -4,6 +4,8 @@ #pragma once +#include +#include #include "common/bit_field.h" #include "common/common_funcs.h" #include "common/common_types.h" @@ -20,6 +22,13 @@ public: /// Write the value to the register identified by method. void WriteReg(u32 method, u32 value); + /** + * Handles a method call to this engine. + * @param method Method to call + * @param parameters Arguments to the method call + */ + void CallMethod(u32 method, const std::vector& parameters); + /// Register structure of the Maxwell3D engine. /// TODO(Subv): This structure will need to be made bigger as more registers are discovered. struct Regs { @@ -63,13 +72,24 @@ public: static_assert(sizeof(Regs) == Regs::NUM_REGS * sizeof(u32), "Maxwell3D Regs has wrong size"); private: + MemoryManager& memory_manager; + /// Handles a write to the QUERY_GET register. void ProcessQueryGet(); /// Handles a write to the VERTEX_END_GL register, triggering a draw. void DrawArrays(); - MemoryManager& memory_manager; + /// Method call handlers + void PrepareShader(const std::vector& parameters); + + struct MethodInfo { + const char* name; + u32 arguments; + void (Maxwell3D::*handler)(const std::vector& parameters); + }; + + static const std::unordered_map method_handlers; }; #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 { namespace Engines { void MaxwellCompute::WriteReg(u32 method, u32 value) {} +void MaxwellCompute::CallMethod(u32 method, const std::vector& parameters) {} } // namespace Engines } // 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 @@ #pragma once +#include #include "common/common_types.h" namespace Tegra { @@ -16,6 +17,13 @@ public: /// Write the value to the register identified by method. void WriteReg(u32 method, u32 value); + + /** + * Handles a method call to this engine. + * @param method Method to call + * @param parameters Arguments to the method call + */ + void CallMethod(u32 method, const std::vector& parameters); }; } // namespace Engines -- cgit v1.2.3