From 826f0ac039cdb0e6641972b7cdf29553b4395b92 Mon Sep 17 00:00:00 2001 From: wheremyfoodat <44909372+wheremyfoodat@users.noreply.github.com> Date: Sun, 16 Jul 2023 19:23:42 +0300 Subject: [PATCH] Fix up comments and readme --- readme.md | 1 + src/core/PICA/dynapica/shader_rec_emitter_x64.cpp | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 9c98178d..854267b6 100644 --- a/readme.md +++ b/readme.md @@ -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 diff --git a/src/core/PICA/dynapica/shader_rec_emitter_x64.cpp b/src/core/PICA/dynapica/shader_rec_emitter_x64.cpp index 7f4eb00c..13eb630e 100644 --- a/src/core/PICA/dynapica/shader_rec_emitter_x64.cpp +++ b/src/core/PICA/dynapica/shader_rec_emitter_x64.cpp @@ -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); @@ -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);