Skip to content

Commit

Permalink
Fix up comments and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
wheremyfoodat committed Jul 16, 2023
1 parent 786c3e8 commit 826f0ac
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ Panda3DS also supports controller input using the SDL2 GameController API.
- [Corgi3DS](https://github.com/PSI-Rockin/Corgi3DS), an LLE 3DS emulator which both served as an inspiration, as well as a nice source of documentation for some PICA200-related things

# Sister Projects
- [Dynarmic](https://github.com/merryhime/dynarmic): An arm32/arm64 to x86-64/ARMv8 recompiler
- [PCSX-Redux](https://github.com/grumpycoders/pcsx-redux): A PlayStation 1 emulator targetting developers, reverse engineers and regular PS1 fans alike
- [SkyEmu](https://github.com/skylersaleh/SkyEmu): A seagull-themed low-level GameBoy, GameBoy Color, GameBoy Advance and Nintendo DS emulator that is designed to be easy to use, cross platform and accurate.
- [NanoBoyAdvance](https://github.com/nba-emu/NanoBoyAdvance): A Game Boy Advance emulator focusing on hardware research and cycle-accurate emulation
Expand Down
8 changes: 7 additions & 1 deletion src/core/PICA/dynapica/shader_rec_emitter_x64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -945,14 +945,19 @@ void ShaderEmitter::printLog(const PICAShader& shaderUnit) {
Xbyak::Label ShaderEmitter::emitLog2Func() {
Xbyak::Label subroutine;

// This code uses the fact that log2(float) = log2(2^exponent * mantissa)
// = log2(2^exponent) + log2(mantissa) = exponent + log2(mantissa) where mantissa has a limited range of values
// https://stackoverflow.com/a/45787548

// SSE does not have a log instruction, thus we must approximate.
// We perform this approximation first performaing a range reduction into the range [1.0, 2.0).
// We perform this approximation first performing a range reduction into the range [1.0, 2.0).
// A minimax polynomial which was fit for the function log2(x) / (x - 1) is then evaluated.
// We multiply the result by (x - 1) then restore the result into the appropriate range.

// Coefficients for the minimax polynomial.
// f(x) computes approximately log2(x) / (x - 1).
// f(x) = c4 + x * (c3 + x * (c2 + x * (c1 + x * c0)).
// We align the table of coefficients to 64 bytes, so that the whole thing will fit in 1 cache line
align(64);
const void* c0 = getCurr();
dd(0x3d74552f);
Expand Down Expand Up @@ -1055,6 +1060,7 @@ Xbyak::Label ShaderEmitter::emitExp2Func() {
// A minimax polynomial which was fit for the function exp2(x) is then evaluated.
// We then restore the result into the appropriate range.

// Similarly to log2, we align our literal pool to 64 bytes to make sure the whole thing fits in 1 cache line
align(64);
const void* input_max = getCurr();
dd(0x43010000);
Expand Down

0 comments on commit 826f0ac

Please sign in to comment.