From 114d6b2f97eb62c7d8c958ebb391b70b026130f9 Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Sat, 17 Dec 2016 01:21:16 -0800 Subject: VideoCore/Shader: Split interpreter and JIT into separate ShaderEngines --- src/video_core/shader/shader_interpreter.cpp | 39 ++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 5 deletions(-) (limited to 'src/video_core/shader/shader_interpreter.cpp') diff --git a/src/video_core/shader/shader_interpreter.cpp b/src/video_core/shader/shader_interpreter.cpp index 20fb9754b..8e2b8c548 100644 --- a/src/video_core/shader/shader_interpreter.cpp +++ b/src/video_core/shader/shader_interpreter.cpp @@ -7,10 +7,12 @@ #include #include #include +#include #include #include "common/assert.h" #include "common/common_types.h" #include "common/logging/log.h" +#include "common/microprofile.h" #include "common/vector_math.h" #include "video_core/pica_state.h" #include "video_core/pica_types.h" @@ -37,8 +39,8 @@ struct CallStackElement { }; template -void RunInterpreter(const ShaderSetup& setup, UnitState& state, DebugData& debug_data, - unsigned offset) { +static void RunInterpreter(const ShaderSetup& setup, UnitState& state, DebugData& debug_data, + unsigned offset) { // TODO: Is there a maximal size for this? boost::container::static_vector call_stack; u32 program_counter = offset; @@ -647,9 +649,36 @@ void RunInterpreter(const ShaderSetup& setup, UnitState& state, DebugData } } -// Explicit instantiation -template void RunInterpreter(const ShaderSetup&, UnitState&, DebugData&, unsigned offset); -template void RunInterpreter(const ShaderSetup&, UnitState&, DebugData&, unsigned offset); +void InterpreterEngine::SetupBatch(const ShaderSetup* setup_) { + setup = setup_; +} + +MICROPROFILE_DECLARE(GPU_Shader); + +void InterpreterEngine::Run(UnitState& state, unsigned int entry_point) const { + ASSERT(setup != nullptr); + ASSERT(entry_point < 1024); + + MICROPROFILE_SCOPE(GPU_Shader); + + DebugData dummy_debug_data; + RunInterpreter(*setup, state, dummy_debug_data, entry_point); +} + +DebugData InterpreterEngine::ProduceDebugInfo(const InputVertex& input, int num_attributes, + unsigned int entry_point) const { + ASSERT(setup != nullptr); + ASSERT(entry_point < 1024); + + UnitState state; + DebugData debug_data; + + // Setup input register table + boost::fill(state.registers.input, Math::Vec4::AssignToAll(float24::Zero())); + state.LoadInputVertex(input, num_attributes); + RunInterpreter(*setup, state, debug_data, entry_point); + return debug_data; +} } // namespace -- cgit v1.2.3