Mark parameters as const

This commit is contained in:
David Marcec 2020-06-03 16:33:38 +10:00
parent 3a20e74f40
commit 411f5527d4
8 changed files with 11 additions and 11 deletions

View File

@ -115,7 +115,7 @@ void Maxwell3D::InitializeRegisterDefaults() {
mme_inline[MAXWELL3D_REG_INDEX(index_array.count)] = true; mme_inline[MAXWELL3D_REG_INDEX(index_array.count)] = true;
} }
void Maxwell3D::CallMacroMethod(u32 method, std::vector<u32>& parameters) { void Maxwell3D::CallMacroMethod(u32 method, const std::vector<u32>& parameters) {
// Reset the current macro. // Reset the current macro.
executing_macro = 0; executing_macro = 0;

View File

@ -1466,7 +1466,6 @@ private:
/// Interpreter for the macro codes uploaded to the GPU. /// Interpreter for the macro codes uploaded to the GPU.
std::unique_ptr<MacroEngine> macro_engine; std::unique_ptr<MacroEngine> macro_engine;
// MacroInterpreter macro_interpreter;
static constexpr u32 null_cb_data = 0xFFFFFFFF; static constexpr u32 null_cb_data = 0xFFFFFFFF;
struct { struct {
@ -1495,7 +1494,7 @@ private:
* @param num_parameters Number of arguments * @param num_parameters Number of arguments
* @param parameters Arguments to the method call * @param parameters Arguments to the method call
*/ */
void CallMacroMethod(u32 method, std::vector<u32>& parameters); void CallMacroMethod(u32 method, const std::vector<u32>& parameters);
/// Handles writes to the macro uploading register. /// Handles writes to the macro uploading register.
void ProcessMacroUpload(u32 data); void ProcessMacroUpload(u32 data);

View File

@ -15,7 +15,7 @@ void MacroEngine::AddCode(u32 method, u32 data) {
uploaded_macro_code[method].push_back(data); uploaded_macro_code[method].push_back(data);
} }
void MacroEngine::Execute(u32 method, std::vector<u32>& parameters) { void MacroEngine::Execute(u32 method, const std::vector<u32>& parameters) {
auto compiled_macro = macro_cache.find(method); auto compiled_macro = macro_cache.find(method);
if (compiled_macro != macro_cache.end()) { if (compiled_macro != macro_cache.end()) {
compiled_macro->second->Execute(parameters, method); compiled_macro->second->Execute(parameters, method);

View File

@ -102,7 +102,7 @@ public:
* @param code The macro byte code to execute * @param code The macro byte code to execute
* @param parameters The parameters of the macro * @param parameters The parameters of the macro
*/ */
virtual void Execute(std::vector<u32>& parameters, u32 method) = 0; virtual void Execute(const std::vector<u32>& parameters, u32 method) = 0;
}; };
class MacroEngine { class MacroEngine {
@ -113,7 +113,7 @@ public:
void AddCode(u32 method, u32 data); void AddCode(u32 method, u32 data);
// Compiles the macro if its not in the cache, and executes the compiled macro // Compiles the macro if its not in the cache, and executes the compiled macro
void Execute(u32 method, std::vector<u32>& parameters); void Execute(u32 method, const std::vector<u32>& parameters);
protected: protected:
virtual std::unique_ptr<CachedMacro> Compile(const std::vector<u32>& code) = 0; virtual std::unique_ptr<CachedMacro> Compile(const std::vector<u32>& code) = 0;

View File

@ -21,7 +21,7 @@ MacroInterpreterImpl::MacroInterpreterImpl(Engines::Maxwell3D& maxwell3d,
const std::vector<u32>& code) const std::vector<u32>& code)
: maxwell3d(maxwell3d), code(code) {} : maxwell3d(maxwell3d), code(code) {}
void MacroInterpreterImpl::Execute(std::vector<u32>& parameters, u32 method) { void MacroInterpreterImpl::Execute(const std::vector<u32>& parameters, u32 method) {
MICROPROFILE_SCOPE(MacroInterp); MICROPROFILE_SCOPE(MacroInterp);
Reset(); Reset();

View File

@ -29,7 +29,7 @@ private:
class MacroInterpreterImpl : public CachedMacro { class MacroInterpreterImpl : public CachedMacro {
public: public:
MacroInterpreterImpl(Engines::Maxwell3D& maxwell3d, const std::vector<u32>& code); MacroInterpreterImpl(Engines::Maxwell3D& maxwell3d, const std::vector<u32>& code);
void Execute(std::vector<u32>& parameters, u32 method) override; void Execute(const std::vector<u32>& parameters, u32 method) override;
private: private:
/// Resets the execution engine state, zeroing registers, etc. /// Resets the execution engine state, zeroing registers, etc.

View File

@ -47,7 +47,7 @@ MacroJITx64Impl::MacroJITx64Impl(Engines::Maxwell3D& maxwell3d, const std::vecto
MacroJITx64Impl::~MacroJITx64Impl() = default; MacroJITx64Impl::~MacroJITx64Impl() = default;
void MacroJITx64Impl::Execute(std::vector<u32>& parameters, u32 method) { void MacroJITx64Impl::Execute(const std::vector<u32>& parameters, u32 method) {
MICROPROFILE_SCOPE(MacroJitExecute); MICROPROFILE_SCOPE(MacroJitExecute);
ASSERT_OR_EXECUTE(program != nullptr, { return; }); ASSERT_OR_EXECUTE(program != nullptr, { return; });
JITState state{}; JITState state{};

View File

@ -13,6 +13,7 @@
#include "video_core/macro/macro.h" #include "video_core/macro/macro.h"
namespace Tegra { namespace Tegra {
namespace Engines { namespace Engines {
class Maxwell3D; class Maxwell3D;
} }
@ -36,7 +37,7 @@ public:
MacroJITx64Impl(Engines::Maxwell3D& maxwell3d, const std::vector<u32>& code); MacroJITx64Impl(Engines::Maxwell3D& maxwell3d, const std::vector<u32>& code);
~MacroJITx64Impl(); ~MacroJITx64Impl();
void Execute(std::vector<u32>& parameters, u32 method) override; void Execute(const std::vector<u32>& parameters, u32 method) override;
void Compile_ALU(Macro::Opcode opcode); void Compile_ALU(Macro::Opcode opcode);
void Compile_AddImmediate(Macro::Opcode opcode); void Compile_AddImmediate(Macro::Opcode opcode);
@ -66,7 +67,7 @@ private:
struct JITState { struct JITState {
Engines::Maxwell3D* maxwell3d{}; Engines::Maxwell3D* maxwell3d{};
std::array<u32, Macro::NUM_MACRO_REGISTERS> registers{}; std::array<u32, Macro::NUM_MACRO_REGISTERS> registers{};
u32* parameters{}; const u32* parameters{};
u32 carry_flag{}; u32 carry_flag{};
}; };
static_assert(offsetof(JITState, maxwell3d) == 0, "Maxwell3D is not at 0x0"); static_assert(offsetof(JITState, maxwell3d) == 0, "Maxwell3D is not at 0x0");