summaryrefslogtreecommitdiffstats
path: root/src/video_core/shader
diff options
context:
space:
mode:
Diffstat (limited to 'src/video_core/shader')
-rw-r--r--src/video_core/shader/shader.cpp30
-rw-r--r--src/video_core/shader/shader.h12
2 files changed, 22 insertions, 20 deletions
diff --git a/src/video_core/shader/shader.cpp b/src/video_core/shader/shader.cpp
index 7ae57e619..8dca9d0cb 100644
--- a/src/video_core/shader/shader.cpp
+++ b/src/video_core/shader/shader.cpp
@@ -76,6 +76,17 @@ OutputVertex OutputRegisters::ToVertex(const Regs::ShaderConfig& config) const {
return ret;
}
+void UnitState::LoadInputVertex(const InputVertex& input, int num_attributes) {
+ // Setup input register table
+ const auto& attribute_register_map = g_state.regs.vs.input_register_map;
+
+ for (int i = 0; i < num_attributes; i++)
+ registers.input[attribute_register_map.GetRegisterForAttribute(i)] = input.attr[i];
+
+ conditional_code[0] = false;
+ conditional_code[1] = false;
+}
+
#ifdef ARCHITECTURE_x86_64
static std::unordered_map<u64, std::unique_ptr<JitShader>> shader_map;
static const JitShader* jit_shader;
@@ -109,21 +120,12 @@ void ShaderSetup::Setup() {
MICROPROFILE_DEFINE(GPU_Shader, "GPU", "Shader", MP_RGB(50, 50, 240));
-void ShaderSetup::Run(UnitState& state, const InputVertex& input, int num_attributes) {
+void ShaderSetup::Run(UnitState& state) {
auto& config = g_state.regs.vs;
auto& setup = g_state.vs;
MICROPROFILE_SCOPE(GPU_Shader);
- // Setup input register table
- const auto& attribute_register_map = config.input_register_map;
-
- for (int i = 0; i < num_attributes; i++)
- state.registers.input[attribute_register_map.GetRegisterForAttribute(i)] = input.attr[i];
-
- state.conditional_code[0] = false;
- state.conditional_code[1] = false;
-
#ifdef ARCHITECTURE_x86_64
if (VideoCore::g_shader_jit_enabled) {
jit_shader->Run(setup, state, config.main_offset);
@@ -145,13 +147,7 @@ DebugData<true> ShaderSetup::ProduceDebugInfo(const InputVertex& input, int num_
// Setup input register table
boost::fill(state.registers.input, Math::Vec4<float24>::AssignToAll(float24::Zero()));
- const auto& attribute_register_map = config.input_register_map;
- for (int i = 0; i < num_attributes; i++)
- state.registers.input[attribute_register_map.GetRegisterForAttribute(i)] = input.attr[i];
-
- state.conditional_code[0] = false;
- state.conditional_code[1] = false;
-
+ state.LoadInputVertex(input, num_attributes);
RunInterpreter(setup, state, debug_data, config.main_offset);
return debug_data;
}
diff --git a/src/video_core/shader/shader.h b/src/video_core/shader/shader.h
index 2b07759b9..c5d23e0ea 100644
--- a/src/video_core/shader/shader.h
+++ b/src/video_core/shader/shader.h
@@ -142,6 +142,14 @@ struct UnitState {
return 0;
}
}
+
+ /**
+ * Loads the unit state with an input vertex.
+ *
+ * @param input Input vertex into the shader
+ * @param num_attributes The number of vertex shader attributes to load
+ */
+ void LoadInputVertex(const InputVertex& input, int num_attributes);
};
/// Clears the shader cache
@@ -182,10 +190,8 @@ struct ShaderSetup {
/**
* Runs the currently setup shader
* @param state Shader unit state, must be setup per shader and per shader unit
- * @param input Input vertex into the shader
- * @param num_attributes The number of vertex shader attributes
*/
- void Run(UnitState& state, const InputVertex& input, int num_attributes);
+ void Run(UnitState& state);
/**
* Produce debug information based on the given shader and input vertex