summaryrefslogtreecommitdiffstats
path: root/src/video_core/shader
diff options
context:
space:
mode:
authorYuri Kunde Schlesner <yuriks@yuriks.net>2016-12-18 01:16:02 +0100
committerYuri Kunde Schlesner <yuriks@yuriks.net>2017-01-26 03:53:25 +0100
commit0e9081b97348c65029c96697443acb0dbbc58756 (patch)
tree58091caadcd6a11a96b48713c41ebf54716e1cc3 /src/video_core/shader
parentVideoCore/Shader: Move per-batch ShaderEngine state into ShaderSetup (diff)
downloadyuzu-0e9081b97348c65029c96697443acb0dbbc58756.tar
yuzu-0e9081b97348c65029c96697443acb0dbbc58756.tar.gz
yuzu-0e9081b97348c65029c96697443acb0dbbc58756.tar.bz2
yuzu-0e9081b97348c65029c96697443acb0dbbc58756.tar.lz
yuzu-0e9081b97348c65029c96697443acb0dbbc58756.tar.xz
yuzu-0e9081b97348c65029c96697443acb0dbbc58756.tar.zst
yuzu-0e9081b97348c65029c96697443acb0dbbc58756.zip
Diffstat (limited to 'src/video_core/shader')
-rw-r--r--src/video_core/shader/shader.h6
-rw-r--r--src/video_core/shader/shader_interpreter.cpp19
-rw-r--r--src/video_core/shader/shader_interpreter.h6
-rw-r--r--src/video_core/shader/shader_jit_x64.cpp10
-rw-r--r--src/video_core/shader/shader_jit_x64.h4
5 files changed, 23 insertions, 22 deletions
diff --git a/src/video_core/shader/shader.h b/src/video_core/shader/shader.h
index f26d2ba4f..44d9f76c3 100644
--- a/src/video_core/shader/shader.h
+++ b/src/video_core/shader/shader.h
@@ -170,6 +170,7 @@ struct ShaderSetup {
/// Data private to ShaderEngines
struct EngineData {
+ unsigned int entry_point;
/// Used by the JIT, points to a compiled shader object.
const void* cached_shader = nullptr;
} engine_data;
@@ -183,7 +184,7 @@ public:
* Performs any shader unit setup that only needs to happen once per shader (as opposed to once
* per vertex, which would happen within the `Run` function).
*/
- virtual void SetupBatch(ShaderSetup& setup) = 0;
+ virtual void SetupBatch(ShaderSetup& setup, unsigned int entry_point) = 0;
/**
* Runs the currently setup shader.
@@ -191,8 +192,7 @@ public:
* @param setup Shader engine state, must be setup with SetupBatch on each shader change.
* @param state Shader unit state, must be setup with input data before each shader invocation.
*/
- virtual void Run(const ShaderSetup& setup, UnitState& state,
- unsigned int entry_point) const = 0;
+ virtual void Run(const ShaderSetup& setup, UnitState& state) const = 0;
};
// TODO(yuriks): Remove and make it non-global state somewhere
diff --git a/src/video_core/shader/shader_interpreter.cpp b/src/video_core/shader/shader_interpreter.cpp
index e44abbf1d..c0c89b857 100644
--- a/src/video_core/shader/shader_interpreter.cpp
+++ b/src/video_core/shader/shader_interpreter.cpp
@@ -652,32 +652,31 @@ static void RunInterpreter(const ShaderSetup& setup, UnitState& state, DebugData
}
}
-void InterpreterEngine::SetupBatch(ShaderSetup& setup) {}
+void InterpreterEngine::SetupBatch(ShaderSetup& setup, unsigned int entry_point) {
+ ASSERT(entry_point < 1024);
+ setup.engine_data.entry_point = entry_point;
+}
MICROPROFILE_DECLARE(GPU_Shader);
-void InterpreterEngine::Run(const ShaderSetup& setup, UnitState& state,
- unsigned int entry_point) const {
- ASSERT(entry_point < 1024);
+void InterpreterEngine::Run(const ShaderSetup& setup, UnitState& state) const {
MICROPROFILE_SCOPE(GPU_Shader);
DebugData<false> dummy_debug_data;
- RunInterpreter(setup, state, dummy_debug_data, entry_point);
+ RunInterpreter(setup, state, dummy_debug_data, setup.engine_data.entry_point);
}
DebugData<true> InterpreterEngine::ProduceDebugInfo(const ShaderSetup& setup,
- const InputVertex& input, int num_attributes,
- unsigned int entry_point) const {
- ASSERT(entry_point < 1024);
-
+ const InputVertex& input,
+ int num_attributes) const {
UnitState state;
DebugData<true> debug_data;
// Setup input register table
boost::fill(state.registers.input, Math::Vec4<float24>::AssignToAll(float24::Zero()));
state.LoadInputVertex(input, num_attributes);
- RunInterpreter(setup, state, debug_data, entry_point);
+ RunInterpreter(setup, state, debug_data, setup.engine_data.entry_point);
return debug_data;
}
diff --git a/src/video_core/shader/shader_interpreter.h b/src/video_core/shader/shader_interpreter.h
index 7f94d405f..d6c0e2d8c 100644
--- a/src/video_core/shader/shader_interpreter.h
+++ b/src/video_core/shader/shader_interpreter.h
@@ -13,8 +13,8 @@ namespace Shader {
class InterpreterEngine final : public ShaderEngine {
public:
- void SetupBatch(ShaderSetup& setup) override;
- void Run(const ShaderSetup& setup, UnitState& state, unsigned int entry_point) const override;
+ void SetupBatch(ShaderSetup& setup, unsigned int entry_point) override;
+ void Run(const ShaderSetup& setup, UnitState& state) const override;
/**
* Produce debug information based on the given shader and input vertex
@@ -24,7 +24,7 @@ public:
* @return Debug information for this shader with regards to the given vertex
*/
DebugData<true> ProduceDebugInfo(const ShaderSetup& setup, const InputVertex& input,
- int num_attributes, unsigned int entry_point) const;
+ int num_attributes) const;
};
} // namespace
diff --git a/src/video_core/shader/shader_jit_x64.cpp b/src/video_core/shader/shader_jit_x64.cpp
index 15c1d60b5..0ee0dd9ef 100644
--- a/src/video_core/shader/shader_jit_x64.cpp
+++ b/src/video_core/shader/shader_jit_x64.cpp
@@ -14,7 +14,10 @@ namespace Shader {
JitX64Engine::JitX64Engine() = default;
JitX64Engine::~JitX64Engine() = default;
-void JitX64Engine::SetupBatch(ShaderSetup& setup) {
+void JitX64Engine::SetupBatch(ShaderSetup& setup, unsigned int entry_point) {
+ ASSERT(entry_point < 1024);
+ setup.engine_data.entry_point = entry_point;
+
u64 code_hash = Common::ComputeHash64(&setup.program_code, sizeof(setup.program_code));
u64 swizzle_hash = Common::ComputeHash64(&setup.swizzle_data, sizeof(setup.swizzle_data));
@@ -32,14 +35,13 @@ void JitX64Engine::SetupBatch(ShaderSetup& setup) {
MICROPROFILE_DECLARE(GPU_Shader);
-void JitX64Engine::Run(const ShaderSetup& setup, UnitState& state, unsigned int entry_point) const {
+void JitX64Engine::Run(const ShaderSetup& setup, UnitState& state) const {
ASSERT(setup.engine_data.cached_shader != nullptr);
- ASSERT(entry_point < 1024);
MICROPROFILE_SCOPE(GPU_Shader);
const JitShader* shader = static_cast<const JitShader*>(setup.engine_data.cached_shader);
- shader->Run(setup, state, entry_point);
+ shader->Run(setup, state, setup.engine_data.entry_point);
}
} // namespace Shader
diff --git a/src/video_core/shader/shader_jit_x64.h b/src/video_core/shader/shader_jit_x64.h
index bd30f51e2..078b2cba5 100644
--- a/src/video_core/shader/shader_jit_x64.h
+++ b/src/video_core/shader/shader_jit_x64.h
@@ -19,8 +19,8 @@ public:
JitX64Engine();
~JitX64Engine() override;
- void SetupBatch(ShaderSetup& setup) override;
- void Run(const ShaderSetup& setup, UnitState& state, unsigned int entry_point) const override;
+ void SetupBatch(ShaderSetup& setup, unsigned int entry_point) override;
+ void Run(const ShaderSetup& setup, UnitState& state) const override;
private:
std::unordered_map<u64, std::unique_ptr<JitShader>> cache;