Project

General

Profile

Actions

Emulator Issues #6880

closed

LLVM JIT in the VertexLoader

Added by nodchip over 10 years ago.

Status:
Won't fix
Priority:
Normal
Assignee:
% Done:

0%

Operating system:
N/A
Issue type:
Other
Milestone:
Regression:
No
Relates to usability:
No
Relates to performance:
No
Easy:
No
Relates to maintainability:
No
Regression start:
Fixed in:

Description

Purpose of code changes on this branch:
The objective of this patch is a proof of concept to introduce LLVM into Dolphin.

When reviewing my code changes, please focus on:
Could you test if this patch works in environments other than Windows 64-bit platform?

After the review, I'll merge this branch into:
I don't have any ideas about this. Could you suggest a right branch?

About three years ago, I and other developers tried to implement a new CPU emulator with LLVM but we gave up. After that, I tried to optimize VertexLoader with LLVM because VertexLoader was one of performance bottle necks. Unfortunatelly, this patch decreases the fps (40 fps -> 33 fps in the first scene of "The Legend of Zelda: Twilight Princess"). But I think that we can optimize the code and improve the performance.

How to enable LLVM JIT in Vertexloader:

  1. Download and install CMake. (CMake - Cross Platform Make http://www.cmake.org/)
  2. Download LLVM source code. (The LLVM Compiler Infrastructure Project http://llvm.org/)
  3. Build LLVM in the Release mode with "Visual Studio 12 Win64" mode.
  4. Add the "include" directories both in the LLVM src folder and the LLVM build folder to the additional include folders of the VideoCommon.
  5. Add the "lib\Release" in the LLVM build folder to the additional library folder of the VideoCommon.
  6. Add the LLVM*.lib files in the "lib\Release" folder to the additional libraries of the VideoCommon.
  7. Apply this patch.
  8. Comment out "#define USE_JIT" in VertexLoader.cpp.
  9. Uncomment out "#define USE_LLVM_JIT" in VertexLoader.cpp.

About files:

  • VertexLoader.cpp: The USE_LLVM_JIT enables the LLVM JIT in Vertexloader. USE_LLVM_JIT_DEBUG enables to call the entry point of the JIT directly. This is useful to debug VertexLoader_LLVMEntryPoint.cpp.
  • VertexLoader_LLVMEntryPoint.cpp: This file contains almost all the code to convert the GC/Wii vertex data format into the DirectX/OpenGL vertex data format. We need to compile this source code into LLVM assembler by clang with -emit-llvm option, include the LLVM assembler into VertexLoader.cpp, partially evaluated with parameters which are passed to VertexLoader, optimize with Function/ModulePassManager and compile into x86.
  • VertexLoader_LLVMEntryPoint_s.cpp: This file contains a part of code to generate a string object which represents the LLVM assembler above. This file is included from VertexLoader.cpp.
  • to_cpp_string.py: This python script converts the LLVM assembler file into VertexLoader_LLVMEntryPoint_s.cpp.
  • llvm_compile.sh: This shell script compiles VertexLoader_LLVMEntryPoint.cpp and generates VertexLoader_LLVMEntryPoint_s.cpp. Please use this shell script once you update VertexLoader_LLVMEntryPoint.cpp.
Actions

Also available in: Atom PDF