Skip to content

Fix building on linux - #3

Closed
phire wants to merge 30 commits into
iwubcode:post-enhance-shader-systemfrom
phire:pp_buildfixes
Closed

phire wants to merge 30 commits into
iwubcode:post-enhance-shader-systemfrom
phire:pp_buildfixes

Conversation

@phire

@phire phire commented Sep 27, 2021

Copy link
Copy Markdown

No description provided.

iwubcode and others added 30 commits September 25, 2021 23:32
…ge so that they can be used as read buffers in future calls
@iwubcode
iwubcode force-pushed the post-enhance-shader-system branch from aaac51f to ae5d113 Compare December 16, 2021 18:59
@iwubcode
iwubcode force-pushed the post-enhance-shader-system branch 2 times, most recently from d4ab3e3 to 46e6dcc Compare January 4, 2022 07:40
@iwubcode
iwubcode force-pushed the post-enhance-shader-system branch 8 times, most recently from 9e43b77 to 62ecc51 Compare January 9, 2022 07:55
@iwubcode
iwubcode force-pushed the post-enhance-shader-system branch 4 times, most recently from ba7b40b to bec8cb8 Compare January 29, 2022 19:47
@iwubcode
iwubcode force-pushed the post-enhance-shader-system branch from bec8cb8 to 35f5bde Compare February 7, 2022 05:56
@iwubcode
iwubcode force-pushed the post-enhance-shader-system branch from 35f5bde to 1f202ca Compare February 19, 2022 17:47
@iwubcode
iwubcode force-pushed the post-enhance-shader-system branch from 1f202ca to d24a247 Compare June 7, 2022 23:26
@iwubcode
iwubcode force-pushed the post-enhance-shader-system branch 2 times, most recently from a50fb76 to b4c44b2 Compare July 22, 2022 05:49
@iwubcode
iwubcode force-pushed the post-enhance-shader-system branch 2 times, most recently from 9d46872 to 09f2845 Compare August 28, 2022 05:36
@iwubcode
iwubcode force-pushed the post-enhance-shader-system branch from 09f2845 to 044f683 Compare October 24, 2022 00:12
@iwubcode
iwubcode force-pushed the post-enhance-shader-system branch from 044f683 to 8d9232d Compare January 16, 2023 01:20
@phire phire closed this Feb 2, 2023
@phire
phire deleted the pp_buildfixes branch February 2, 2023 14:53
iwubcode pushed a commit that referenced this pull request Jul 2, 2023
Qt: Fix some Post Process Configuration Widget issues #3-4
iwubcode pushed a commit that referenced this pull request May 2, 2025
There's no guarantee that directory initialization has completed by this
point, so we can't safely use NativeLibrary.

I'm making this change because of a crash being reported in Google Play
Console. The exact way it's crashing is mysterious to me, so I'm not
sure if this commit fixes the crash, but I think this commit is
a reasonable change to make even if it doesn't fix the crash. Backtrace
from Google Play Console:

  #00  pc 0x0000000000469074  /data/app/~~m0kqybFNfeqnDenQFc53XQ==/org.dolphinemu.dolphinemu-Mtaw0lU8DVUQbte2ZjBp3w==/lib/arm64/libmain.so (std::__ndk1::pair<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char>> const, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char>>>::pair[abi:nn180000]<char const* const&, char const* const&, 0>(char const* const&, char const* const&)) (BuildId: 64cfebf5b574b6729ebc51799aa94ccc3238cbcc)
  #1  pc 0x0000000000468e9c  /data/app/~~m0kqybFNfeqnDenQFc53XQ==/org.dolphinemu.dolphinemu-Mtaw0lU8DVUQbte2ZjBp3w==/lib/arm64/libmain.so (std::__ndk1::pair<std::__ndk1::__tree_iterator<std::__ndk1::__value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char>>, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char>>>, std::__ndk1::__tree_node<std::__ndk1::__value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char>>, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char>>>, void*>*, long>, bool> std::__ndk1::__tree<std::__ndk1::__value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char>>, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char>>>, std::__ndk1::__map_value_compare<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char>>, std::__ndk1::__value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char>>, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char>>>, std::__ndk1::less<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char>>>, true>, std::__ndk1::allocator<std::__ndk1::__value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char>>, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char>>>>>::__emplace_unique_impl<char const* const&, char const* const&>(char const* const&, char const* const&)) (BuildId: 64cfebf5b574b6729ebc51799aa94ccc3238cbcc)
  #2  pc 0x0000000000462f08  /data/app/~~m0kqybFNfeqnDenQFc53XQ==/org.dolphinemu.dolphinemu-Mtaw0lU8DVUQbte2ZjBp3w==/lib/arm64/libmain.so (Common::Log::LogManager::GetLogTypes()) (BuildId: 64cfebf5b574b6729ebc51799aa94ccc3238cbcc)
  #3  pc 0x000000000044339c  /data/app/~~m0kqybFNfeqnDenQFc53XQ==/org.dolphinemu.dolphinemu-Mtaw0lU8DVUQbte2ZjBp3w==/lib/arm64/libmain.so (Java_org_dolphinemu_dolphinemu_NativeLibrary_GetLogTypeNames+56) (BuildId: 64cfebf5b574b6729ebc51799aa94ccc3238cbcc)
  #4  pc 0x000000000031456c  /data/misc/apexdata/com.android.art/dalvik-cache/arm64/boot.oat (art_jni_trampoline+108)
  #5  pc 0x0000000000781508  /apex/com.android.art/lib64/libart.so (nterp_helper+152)
  dolphin-emu#6  pc 0x00000000002d94d4  /data/app/~~m0kqybFNfeqnDenQFc53XQ==/org.dolphinemu.dolphinemu-Mtaw0lU8DVUQbte2ZjBp3w==/base.apk (org.dolphinemu.dolphinemu.features.settings.ui.SettingsFragmentPresenter.<clinit>+16)
[...]
iwubcode pushed a commit that referenced this pull request Nov 2, 2026
This instruction effectively performs the following computation:

```
Xresult = SXTW(slice_length) - Xresult + global_timer;
```

ARM64 has a dedicated sign extension instruction, but also allows this
sign extension to happen as part of many arithmetic operations. By
reordering the computation, we can take advantage of this:

```
Xresult = global_timer + SXTW(slice_length) - Xresult;
```

Before:
```
ldr    w24, [x29, #0x2f0]
scvtf  s8, w24
ldr    s9, [x27, #0x20]
fmul   s8, s8, s9
fcvtzs x25, s8
ldp    x24, x23, [x27]
sxtw   x23, w23
sub    x25, x23, x25
add    x25, x25, x24
ldp    x24, x23, [x27, #0x10]
sub    x25, x25, x23
mov    x23, #-0x5555555555555556 ; =-6148914691236517206
add    x23, x23, #0x1
umulh  x25, x25, x23
add    x25, x24, x25, lsr #3
str    x25, [x29, #0x770]
```

After:
```
ldr    w24, [x29, #0x2f0]
scvtf  s8, w24
ldr    s9, [x27, #0x20]
fmul   s8, s8, s9
fcvtzs x25, s8
ldp    x24, x23, [x27]
add    x24, x24, w23, sxtw
sub    x25, x24, x25
ldp    x24, x23, [x27, #0x10]
sub    x25, x25, x23
mov    x23, #-0x5555555555555556 ; =-6148914691236517206
add    x23, x23, #0x1
umulh  x25, x25, x23
add    x25, x24, x25, lsr #3
str    x25, [x29, #0x770]
```
iwubcode pushed a commit that referenced this pull request Nov 2, 2026
This replaces the old instruction sequence with one that is considerably
shorter. Main ideas are as follows:

 - Use AND with constant mask to isolate the needed bits.
 - Use ORR + LSL/LSR to shift the bits into position and combine in one
   instruction where possible.
 - Red and blue are already sequential, so don't need to wait for the
   byteswap. This is especially handy for red, where the bits are
   already where they need to be.
 - Red and blue can be expanded from 5 to 8 bits together.

Before:

ldurh  w14, [x0, #0x1]
rev16  w14, w14
and    w15, w14, #0x1f
orr    w15, wzr, w15, lsl #3
orr    w15, w15, w15, lsr #5
orr    w16, wzr, w15, lsl dolphin-emu#16
ubfx   w15, w14, #5, dolphin-emu#6
orr    w15, wzr, w15, lsl #2
orr    w15, w15, w15, lsr dolphin-emu#6
orr    w16, w16, w15, lsl dolphin-emu#8
ubfx   w15, w14, dolphin-emu#11, #5
orr    w16, w16, w15, lsl #3
orr    w16, w16, w15, lsr #2
orr    w16, w16, #0xff000000
str    w16, [x1, #0xc]

After:

ldurh  w14, [x0, #0x1]
rev16  w15, w14
bfi    w14, w14, dolphin-emu#11, dolphin-emu#13
and    w16, w14, #0xf800f8
and    w14, w14, #0xe000e0
orr    w16, w16, #0xff000000
orr    w16, w16, w14, lsr #5
and    w14, w15, #0x7e0
and    w15, w15, #0x600
orr    w14, w14, w15, lsr dolphin-emu#6
orr    w16, w16, w14, lsl #5
str    w16, [x1, #0xc]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants