8 changed files with 153 additions and 97 deletions
-
2src/video_core/CMakeLists.txt
-
2src/video_core/pica.cpp
-
92src/video_core/shader/shader.cpp
-
5src/video_core/shader/shader.h
-
39src/video_core/shader/shader_interpreter.cpp
-
19src/video_core/shader/shader_interpreter.h
-
56src/video_core/shader/shader_jit_x64.cpp
-
35src/video_core/shader/shader_jit_x64.h
@ -0,0 +1,56 @@ |
|||
// Copyright 2016 Citra Emulator Project
|
|||
// Licensed under GPLv2 or any later version
|
|||
// Refer to the license.txt file included.
|
|||
|
|||
#include "common/hash.h"
|
|||
#include "common/microprofile.h"
|
|||
#include "video_core/shader/shader.h"
|
|||
#include "video_core/shader/shader_jit_x64.h"
|
|||
#include "video_core/shader/shader_jit_x64_compiler.h"
|
|||
|
|||
namespace Pica { |
|||
namespace Shader { |
|||
|
|||
JitX64Engine::JitX64Engine() = default; |
|||
JitX64Engine::~JitX64Engine() = default; |
|||
|
|||
void JitX64Engine::SetupBatch(const ShaderSetup* setup_) { |
|||
cached_shader = nullptr; |
|||
setup = setup_; |
|||
if (setup == nullptr) |
|||
return; |
|||
|
|||
u64 code_hash = Common::ComputeHash64(&setup->program_code, sizeof(setup->program_code)); |
|||
u64 swizzle_hash = Common::ComputeHash64(&setup->swizzle_data, sizeof(setup->swizzle_data)); |
|||
|
|||
u64 cache_key = code_hash ^ swizzle_hash; |
|||
auto iter = cache.find(cache_key); |
|||
if (iter != cache.end()) { |
|||
cached_shader = iter->second.get(); |
|||
} else { |
|||
auto shader = std::make_unique<JitShader>(); |
|||
shader->Compile(); |
|||
cached_shader = shader.get(); |
|||
cache.emplace_hint(iter, cache_key, std::move(shader)); |
|||
} |
|||
} |
|||
|
|||
MICROPROFILE_DECLARE(GPU_Shader); |
|||
|
|||
void JitX64Engine::Run(UnitState& state, unsigned int entry_point) const { |
|||
ASSERT(setup != nullptr); |
|||
ASSERT(cached_shader != nullptr); |
|||
ASSERT(entry_point < 1024); |
|||
|
|||
MICROPROFILE_SCOPE(GPU_Shader); |
|||
|
|||
cached_shader->Run(*setup, state, entry_point); |
|||
} |
|||
|
|||
DebugData<true> JitX64Engine::ProduceDebugInfo(const InputVertex& input, int num_attributes, |
|||
unsigned int entry_point) const { |
|||
UNIMPLEMENTED_MSG("Shader tracing/debugging is not supported by the JIT."); |
|||
} |
|||
|
|||
} // namespace Shader
|
|||
} // namespace Pica
|
|||
@ -0,0 +1,35 @@ |
|||
// Copyright 2016 Citra Emulator Project |
|||
// Licensed under GPLv2 or any later version |
|||
// Refer to the license.txt file included. |
|||
|
|||
#pragma once |
|||
|
|||
#include <memory> |
|||
#include <unordered_map> |
|||
#include "common/common_types.h" |
|||
#include "video_core/shader/shader.h" |
|||
|
|||
namespace Pica { |
|||
namespace Shader { |
|||
|
|||
class JitShader; |
|||
|
|||
class JitX64Engine final : public ShaderEngine { |
|||
public: |
|||
JitX64Engine(); |
|||
~JitX64Engine() override; |
|||
|
|||
void SetupBatch(const ShaderSetup* setup) override; |
|||
void Run(UnitState& state, unsigned int entry_point) const override; |
|||
DebugData<true> ProduceDebugInfo(const InputVertex& input, int num_attributes, |
|||
unsigned int entry_point) const override; |
|||
|
|||
private: |
|||
const ShaderSetup* setup = nullptr; |
|||
|
|||
std::unordered_map<u64, std::unique_ptr<JitShader>> cache; |
|||
const JitShader* cached_shader = nullptr; |
|||
}; |
|||
|
|||
} // namespace Shader |
|||
} // namespace Pica |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue