This commit is contained in:
1 2017-10-04 14:25:02 +01:00 committed by citra
parent e000d756d7
commit 9dd09cb60d
4 changed files with 27 additions and 0 deletions

View File

@ -45,6 +45,7 @@ set(SRCS
set(HEADERS set(HEADERS
alignment.h alignment.h
assert.h assert.h
avx_utils.h
bit_field.h bit_field.h
bit_set.h bit_set.h
break_points.h break_points.h

22
src/common/avx_utils.h Normal file
View File

@ -0,0 +1,22 @@
#pragma once
#if defined(_MSC_VER)
/* Microsoft C/C++-compatible compiler */
#include <intrin.h>
#elif defined(__GNUC__) && (defined(__x86_64__) || defined(__i386__))
/* GCC-compatible compiler, targeting x86/x86-64 */
#include <x86intrin.h>
#endif
// It seems a lot of folks out there compile citra with avx. This lil function
// fixes the penalty by mixing SSE instructions with AVX. For further info:
// https://software.intel.com/en-us/articles/avoiding-avx-sse-transition-penalties
// call this function before running dynamicly generated code.
inline void ZeroUpperAVX() {
#ifdef __AVX__
_mm256_zeroupper();
#else
// Do Nothing
#endif
}

View File

@ -5,6 +5,7 @@
#include <cstring> #include <cstring>
#include <dynarmic/dynarmic.h> #include <dynarmic/dynarmic.h>
#include "common/assert.h" #include "common/assert.h"
#include "common/avx_utils.h"
#include "common/microprofile.h" #include "common/microprofile.h"
#include "core/arm/dynarmic/arm_dynarmic.h" #include "core/arm/dynarmic/arm_dynarmic.h"
#include "core/arm/dynarmic/arm_dynarmic_cp15.h" #include "core/arm/dynarmic/arm_dynarmic_cp15.h"
@ -130,6 +131,7 @@ void ARM_Dynarmic::ExecuteInstructions(int num_instructions) {
ASSERT(Memory::GetCurrentPageTable() == current_page_table); ASSERT(Memory::GetCurrentPageTable() == current_page_table);
MICROPROFILE_SCOPE(ARM_Jit); MICROPROFILE_SCOPE(ARM_Jit);
ZeroUpperAVX();
std::size_t ticks_executed = jit->Run(static_cast<unsigned>(num_instructions)); std::size_t ticks_executed = jit->Run(static_cast<unsigned>(num_instructions));
CoreTiming::AddTicks(4000); CoreTiming::AddTicks(4000);

View File

@ -2,6 +2,7 @@
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include "common/avx_utils.h"
#include "common/hash.h" #include "common/hash.h"
#include "common/microprofile.h" #include "common/microprofile.h"
#include "video_core/shader/shader.h" #include "video_core/shader/shader.h"
@ -41,6 +42,7 @@ void JitX64Engine::Run(const ShaderSetup& setup, UnitState& state) const {
MICROPROFILE_SCOPE(GPU_Shader); MICROPROFILE_SCOPE(GPU_Shader);
const JitShader* shader = static_cast<const JitShader*>(setup.engine_data.cached_shader); const JitShader* shader = static_cast<const JitShader*>(setup.engine_data.cached_shader);
ZeroUpperAVX();
shader->Run(setup, state, setup.engine_data.entry_point); shader->Run(setup, state, setup.engine_data.entry_point);
} }