x64: Refactor to remove fake interfaces and general cleanups.

This commit is contained in:
bunnei 2015-08-12 00:00:44 -04:00
parent cfb354f11f
commit bd7e691f78
16 changed files with 52 additions and 666 deletions

View file

@ -13,7 +13,6 @@ set(SRCS
rasterizer.cpp
shader/shader.cpp
shader/shader_interpreter.cpp
shader/shader_jit.cpp
utils.cpp
video_core.cpp
)
@ -39,17 +38,16 @@ set(HEADERS
renderer_base.h
shader/shader.h
shader/shader_interpreter.h
shader/shader_jit.h
utils.h
video_core.h
)
if(_M_X86_64)
if(ARCHITECTURE_X64)
set(SRCS ${SRCS}
shader/shader_jit_x64.cpp)
else()
set(SRCS ${SRCS}
shader/shader_jit_fake.cpp)
set(HEADERS ${HEADERS}
shader/shader_jit_x64.h)
endif()
create_directory_groups(${SRCS} ${HEADERS})

View file

@ -15,7 +15,10 @@
#include "shader.h"
#include "shader_interpreter.h"
#include "shader_jit.h"
#ifdef ARCHITECTURE_X64
#include "shader_jit_x64.h"
#endif // ARCHITECTURE_X64
namespace Pica {
@ -43,7 +46,7 @@ void Setup(UnitState& state) {
jit_shader = jit.Compile();
shader_map.emplace(cache_key, jit_shader);
}
}
#endif // ARCHITECTURE_X64
}
void Shutdown() {
@ -92,7 +95,7 @@ OutputVertex Run(UnitState& state, const InputVertex& input, int num_attributes)
RunInterpreter(state);
#else
RunInterpreter(state);
#endif
#endif // ARCHITECTURE_X64
#if PICA_DUMP_SHADERS
DebugUtils::DumpShader(setup.program_code.data(), state.debug.max_offset, setup.swizzle_data.data(),

View file

@ -1,36 +0,0 @@
// Copyright 2015 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "video_core/pica.h"
#include "shader.h"
#include "shader_jit.h"
namespace Pica {
namespace Shader {
JitShader::JitShader() : jitted(nullptr) {
}
void JitShader::DoJit(JitCompiler& jit) {
jitted = jit.Compile();
}
void JitShader::Run(UnitState& state) {
if (jitted)
jitted(&state);
}
JitCompiler::JitCompiler() {
AllocCodeSpace(1024 * 1024 * 4);
}
void JitCompiler::Clear() {
ClearCodeSpace();
}
} // namespace Shader
} // namespace Pica

View file

@ -1,91 +0,0 @@
// Copyright 2015 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "common/fake_emitter.h"
#include "video_core/shader/shader.h"
#include "video_core/shader/shader_jit.h"
namespace Pica {
namespace Shader {
using namespace FakeGen;
void Jit::Comp_ADD(Instruction instr) {
}
void Jit::Comp_DP3(Instruction instr) {
}
void Jit::Comp_DP4(Instruction instr) {
}
void Jit::Comp_MUL(Instruction instr) {
}
void Jit::Comp_FLR(Instruction instr) {
}
void Jit::Comp_MAX(Instruction instr) {
}
void Jit::Comp_MIN(Instruction instr) {
}
void Jit::Comp_MOVA(Instruction instr) {
}
void Jit::Comp_MOV(Instruction instr) {
}
void Jit::Comp_SLTI(Instruction instr) {
}
void Jit::Comp_RCP(Instruction instr) {
}
void Jit::Comp_RSQ(Instruction instr) {
}
void Jit::Comp_NOP(Instruction instr) {
}
void Jit::Comp_END(Instruction instr) {
}
void Jit::Comp_CALL(Instruction instr) {
}
void Jit::Comp_CALLC(Instruction instr) {
}
void Jit::Comp_CALLU(Instruction instr) {
}
void Jit::Comp_CMP(Instruction instr) {
}
void Jit::Comp_MAD(Instruction instr) {
}
void Jit::Comp_IF(Instruction instr) {
}
void Jit::Comp_LOOP(Instruction instr) {
}
void Jit::Comp_JMP(Instruction instr) {
}
void Jit::Comp_NextInstr(unsigned* offset) {
}
CompiledShader Jit::Compile() {
return nullptr;
}
} // namespace Shader
} // namespace Pica

View file

@ -4,12 +4,13 @@
#include <smmintrin.h>
#include "common/abi.h"
#include "common/cpu_detect.h"
#include "common/x64_emitter.h"
#include "common/x64/abi.h"
#include "common/x64/emitter.h"
#include "shader.h"
#include "shader_jit.h"
#include "shader_jit_x64.h"
namespace Pica {
@ -134,7 +135,7 @@ static const u8 NO_DEST_REG_MASK = 0xf;
*/
void JitCompiler::Compile_SwizzleSrc(Instruction instr, unsigned src_num, SourceRegister src_reg, X64Reg dest) {
X64Reg src_ptr;
std::size_t src_offset;
int src_offset;
if (src_reg.GetRegisterType() == RegisterType::FloatUniform) {
src_ptr = UNIFORMS;
@ -451,7 +452,6 @@ void JitCompiler::Compile_NOP(Instruction instr) {
void JitCompiler::Compile_END(Instruction instr) {
ABI_PopAllCalleeSavedRegsAndAdjustStack();
RET();
done = true;
}
void JitCompiler::Compile_CALL(Instruction instr) {
@ -655,7 +655,7 @@ CompiledShader* JitCompiler::Compile() {
MOVAPS(NEGBIT, MDisp(RAX, 0));
looping = false;
done = false;
while (offset < g_state.vs.program_code.size()) {
Compile_NextInstr(&offset);
}
@ -663,6 +663,14 @@ CompiledShader* JitCompiler::Compile() {
return (CompiledShader*)start;
}
JitCompiler::JitCompiler() {
AllocCodeSpace(1024 * 1024 * 4);
}
void JitCompiler::Clear() {
ClearCodeSpace();
}
} // namespace Shader
} // namespace Pica

View file

@ -6,11 +6,7 @@
#include <nihstro/shader_bytecode.h>
#if defined(_M_X86_64)
#include "common/x64_emitter.h"
#else
#include "common/fake_emitter.h"
#endif
#include "common/x64/emitter.h"
#include "video_core/pica.h"
@ -65,18 +61,16 @@ private:
void Compile_Block(unsigned stop);
void Compile_NextInstr(unsigned* offset);
#if defined(_M_X86_64)
void Compile_SwizzleSrc(Instruction instr, unsigned src_num, SourceRegister src_reg, Gen::X64Reg dest);
void Compile_DestEnable(Instruction instr, Gen::X64Reg dest);
void Compile_EvaluateCondition(Instruction instr);
void Compile_UniformCondition(Instruction instr);
#endif
/// Pointer to the variable that stores the current Pica code offset. Used to handle nested code blocks.
unsigned* offset_ptr = nullptr;
bool done = false;
/// Set to true if currently in a loop, used to check for the existence of nested loops
bool looping = false;
};