This is my new game engine. The main reason for this is that the renderer in the last one wasn't designed well from the start, and other elements such as the build system became cumbersome. In this new engine, I'm hoping to avoid this.
I'm doing my best to document how I'm designing things in design/. The renderer is going to be
designed around a render hardware interface, with more complex render passes on top of that, instead of implementing
a fixed function pipeline in each graphics API like before. Another notable feature of this iteration is that it uses
DLLs for each system, and the reason is so that the systems of the engine could be reused by tools that I might make,
and also because it makes it easier to separate functionality that shouldn't get tangled up.
The engine doesn't use the CRT or STL at all (where possible, meaning not at all on Windows and a little bit on other platforms),
which does improve portability, especially between Windows versions. Some performance-critical functions are written to use
SIMD if the current CPU supports it (on x86, it's all dynamically enabled based on cpuid instead of being done at compile
time). I also wrote my own allocator that works pretty well, but I'm sure I'll have to optimize it eventually. I have my own
containers too. I have limited experience with SIMD and writing an allocator, so I'm sure there's room for improvement.
First, clone the repo recursively:
git clone --recursive https://github.com/RandomcodeDev/chifir-engineor, if you already cloned it:
git submodule update --init --recursiveFor every platform, you need xmake and a C++17 compiler.
- For Windows, you need Visual Studio 2022 (or any version with C++17 support). You can also build with Clang, but you still need VS. You also (will, in the future) need the GDK to build the x64 version. There is support for cross compiling, using Clang and the Windows SDK/MSVC headers.
- For the original Xbox, you need the SDK or the source code, either is easy to find. To use the SDK, make sure the
XDKenvironment variable is set. If you're using the source code, you need<source tree>/public/xdksymlinked to<Chifir repo>/external/xbox. For Xbox 360, you need the SDK, it's on Internet Archive. You'll also need my LLVM fork when it's done.- For Switch, you need version 15.3.2 of the SDK, the private repo, and my private fork of xmake.
- For PS4, you need version 8.008 of the SDK, the private repo, and my private fork of xmake.
- For Linux, you need Clang and glibc. GCC isn't supported and isn't a priority, especially MinGW.
There are Rust bindings in progress, you need the nightly toolchain for them.
You can get a semi-accurate line count with this command if you have tokei installed:
tokei -t="C,C++,C Header,Python,Lua,Assembly,Rust" -e external -e public/xboxYou'll need xmake. First, you should copy config.default.lua to config.lua, and change any important stuff.
Next, run xmake config with these flags (you have to pass all of them or it will seem like it works and then not build):
-psets the platform (required):windowsWindows/PC GDKxboxOriginal Xbox (semi-private, code is public but requires xmake fork)linuxLinuxscarlettXbox One/Series X|S (private)nxNintendo Switch (private)orbisPlayStation 4 (private)
-asets the architecture (required):x64AMD64, supported onwindows,linux,scarlett,orbisx86IA-32, supported onwindows,xbox, andlinuxarm64ARM64, supported onlinuxandnxarm64-v8aARM64, supported onlinux
-msets the build mode (required):debuglots of logs, symbols, no optimization, debugging featuresreleasereasonable amount of logs, symbols, full optimization, debugging featuresretailreasonable amount of logs, no symbols, full optimization
-ksets whether to build static or dynamic libraries (required):staticeverything is statically linked, supported onwindows,linux,scarlett,nx,orbissharedeverything is dynamically linked (preferred), supported onwindows,linux,scarlett
--toolchainsets what compiler/linker to use (required)msvcMSVC is the most functional toolchain forwindows/scarlett/xboxclang-clClang usually works forwindows/scarlett/xbox, but it breaks sometimesclang/llvmClang is the only supported compiler onlinuxnx-clangNintendo Switch SDK version of Clang and LLVM (use this fornx)orbis-clangPS4 Clang (use this fororbis)windows-crossClang and LLVM tools, used for building forwindows/scarletton non-Windows hostsxbox-crossSame aswindows-cross, but forxbox. Currently non-functional because LLD crashes because of the Xbox libraries.
--vsSets the Visual Studio version to generate wrapper projects for (optional)
This isn't supported on Windows, only Linux.
To cross compile for Windows, make a folder in external called winsdk with symlinks like this (these instructions could be wrong):
external/winsdk
|- include
|\-- msvc -> <MSVC install path>/Include
| |- shared -> <Windows SDK install path>/Include/<version>/shared
| |- ucrt -> <Windows SDK install path>/Include/<version>/ucrt
| |- um -> <Windows SDK install path>/Include/<version>/um
| \- winrt -> <Windows SDK install path>/Include/<version>/winrt
|
|- lib
|\-- um -> <Windows SDK install path>/Lib/<version>/um
This tool lets you conveniently download the Windows SDK and MSVC headers. After that, just do this to configure:
xmake f -p <windows or scarlett> -a <x64 or x86> -m <mode> -k <static or shared> --toolchain=windows-cross
For Xbox, just symlink the public/xdk folder from the source tree as external/xbox and do this:
xmake f -p xbox -a x86 -m <mode> --toolchain=xbox-cross
Use scripts/genrelease.py.
If you want to make an XISO for the original Xbox, you need cxbe from nxdk and xdvdfs (can be installed with
cargo install xdvdfs-cli). Then you can run this after a build:
python scripts/makexiso.py -m <mode>
Use private/scripts/makensp.py.
For the Rust stuff, build the engine, then do cargo build.
- Windows
- Windows is the most actively developed platform
- Windows XP and later are supported
- I'm working on getting Windows 2000 to work
- UWP support seems to work
- Nothing is statically imported from system libraries, it's all done at runtime
- Most features are implemented with native functions in
ntdll.dllthat have been around since Windows 2000/XP, rather than usingkernel32.dll
- Linux
- Linux is usually mostly up to date with Windows
- glibc is the only libc I've tested with
- Uses SDL for windowing, because X11 and Wayland are annoying
- Only Clang is supported, GCC is a weird compiler and I don't like it
- Nintendo Switch
- Mostly works, crashes in Vulkan init code
- I might work on a version using libnx and deko3d eventually
- PlayStation 4
- Not done implementing the platform abstraction code yet
- I might make a homebrew version eventually
- My PS4 is on 11.02, so I'm stuck with shadPS4 for now
- Xbox One/Series X|S
- Once UWP support is done, it'll work in the retail dev mode
- I don't have a devkit or an OS version supported by the Collateral Damage exploit, so I can't make a version for GameOS yet
- Xbox 360
- I did write some code for it, but eventually I decided that C++03 sucks
- I'm working on targetting it with LLVM, but I have to learn how to implement its custom calling convention
- Will require DirectX 9, similar to Windows XP
- Original Xbox
- x86-based, so modern compilers work
- Uses DirectX 8 (so far basically copied and pasted from the D3D9 backend)
