summaryrefslogtreecommitdiff
path: root/src/video_core
diff options
context:
space:
mode:
Diffstat (limited to 'src/video_core')
-rw-r--r--src/video_core/shader/shader_jit_x64.cpp9
-rw-r--r--src/video_core/shader/shader_jit_x64.h4
2 files changed, 8 insertions, 5 deletions
diff --git a/src/video_core/shader/shader_jit_x64.cpp b/src/video_core/shader/shader_jit_x64.cpp
index 503fad158..e32a4e720 100644
--- a/src/video_core/shader/shader_jit_x64.cpp
+++ b/src/video_core/shader/shader_jit_x64.cpp
@@ -2,6 +2,7 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <algorithm>
5#include <smmintrin.h> 6#include <smmintrin.h>
6 7
7#include "common/x64/abi.h" 8#include "common/x64/abi.h"
@@ -760,8 +761,7 @@ void JitCompiler::Compile_Return() {
760} 761}
761 762
762void JitCompiler::Compile_NextInstr() { 763void JitCompiler::Compile_NextInstr() {
763 auto search = return_offsets.find(program_counter); 764 if (std::binary_search(return_offsets.begin(), return_offsets.end(), program_counter)) {
764 if (search != return_offsets.end()) {
765 Compile_Return(); 765 Compile_Return();
766 } 766 }
767 767
@@ -793,10 +793,13 @@ void JitCompiler::FindReturnOffsets() {
793 case OpCode::Id::CALL: 793 case OpCode::Id::CALL:
794 case OpCode::Id::CALLC: 794 case OpCode::Id::CALLC:
795 case OpCode::Id::CALLU: 795 case OpCode::Id::CALLU:
796 return_offsets.insert(instr.flow_control.dest_offset + instr.flow_control.num_instructions); 796 return_offsets.push_back(instr.flow_control.dest_offset + instr.flow_control.num_instructions);
797 break; 797 break;
798 } 798 }
799 } 799 }
800
801 // Sort for efficient binary search later
802 std::sort(return_offsets.begin(), return_offsets.end());
800} 803}
801 804
802void JitCompiler::Compile() { 805void JitCompiler::Compile() {
diff --git a/src/video_core/shader/shader_jit_x64.h b/src/video_core/shader/shader_jit_x64.h
index 920a269e2..aa5060584 100644
--- a/src/video_core/shader/shader_jit_x64.h
+++ b/src/video_core/shader/shader_jit_x64.h
@@ -4,8 +4,8 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <set>
8#include <utility> 7#include <utility>
8#include <vector>
9 9
10#include <nihstro/shader_bytecode.h> 10#include <nihstro/shader_bytecode.h>
11 11
@@ -106,7 +106,7 @@ private:
106 std::array<const u8*, 1024> code_ptr; 106 std::array<const u8*, 1024> code_ptr;
107 107
108 /// Offsets in code where a return needs to be inserted 108 /// Offsets in code where a return needs to be inserted
109 std::set<unsigned> return_offsets; 109 std::vector<unsigned> return_offsets;
110 110
111 unsigned program_counter = 0; ///< Offset of the next instruction to decode 111 unsigned program_counter = 0; ///< Offset of the next instruction to decode
112 bool looping = false; ///< True if compiling a loop, used to check for nested loops 112 bool looping = false; ///< True if compiling a loop, used to check for nested loops