Skip to content

Commit d222c2d

Browse files
authored
Merge branch 'main' into callstacks-imgui-fix
2 parents 67fd798 + 34ea4f1 commit d222c2d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1551
-371
lines changed

.github/filter-mips/filter.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ cd $CWD
1010

1111
# Need to delete submodules actively.
1212
# Done in two passes for speed.
13-
git filter-branch -f --tree-filter 'find third_party -depth -not -name uC-sdk -and -not -path third_party/EABase -and -not -path third_party/EABase/\* -and -not -path third_party/EASTL -and -not -path third_party/EASTL/\* -delete || true' --tag-name-filter cat --prune-empty
14-
git filter-branch -f --tree-filter 'find third_party -depth -not -name uC-sdk -and -not -path third_party/EABase -and -not -path third_party/EABase/\* -and -not -path third_party/EASTL -and -not -path third_party/EASTL/\* -exec git rm -f {} \; || true' --tag-name-filter cat --prune-empty
13+
git filter-branch -f --tree-filter 'find third_party -depth -not -name uC-sdk -and -not -path third_party/psxlua -and -not -path third_party/EABase -and -not -path third_party/EABase/\* -and -not -path third_party/EASTL -and -not -path third_party/EASTL/\* -delete || true' --tag-name-filter cat --prune-empty
14+
git filter-branch -f --tree-filter 'find third_party -depth -not -name uC-sdk -and -not -path third_party/psxlua -and -not -path third_party/EABase -and -not -path third_party/EABase/\* -and -not -path third_party/EASTL -and -not -path third_party/EASTL/\* -exec git rm -f {} \; || true' --tag-name-filter cat --prune-empty
1515

1616
# Shuffle files around.
1717
git filter-branch -f --tree-filter 'mkdir -p src/mips ; git mv third_party src/mips ; mv .gitmodules src/mips ; mv docker* src/mips || true' --tag-name-filter cat --prune-empty
@@ -26,12 +26,17 @@ git filter-branch -f --tree-filter "cp ${ROOT}/README-filtered.md README.md" --t
2626
git filter-branch -f --tree-filter "find . -name Makefile -exec sed 's|\.\./\.\./\.\./third_party/uC-sdk/|../third_party/uC-sdk/|' -i {} \;" --tag-name-filter cat --prune-empty
2727
git filter-branch -f --tree-filter "find . -name '*.mk' -exec sed 's|\.\./\.\./\.\./third_party/uC-sdk/|../third_party/uC-sdk/|' -i {} \;" --tag-name-filter cat --prune-empty
2828
git filter-branch -f --tree-filter "sed 's|src/mips/third_party/uC-sdk|third_party/uC-sdk|' -i .gitmodules" --tag-name-filter cat --prune-empty
29+
git filter-branch -f --tree-filter "sed 's|src/mips/third_party/psxlua|third_party/psxlua|' -i .gitmodules" --tag-name-filter cat --prune-empty
2930

3031
# Adjust paths for the EASTL
3132
git filter-branch -f --tree-filter "find . -name Makefile -exec sed 's|\.\./\.\./\.\./third_party/EABase/|../third_party/EABase/|' -i {} \;" --tag-name-filter cat --prune-empty
3233
git filter-branch -f --tree-filter "find . -name Makefile -exec sed 's|\.\./\.\./\.\./third_party/EASTL/|../third_party/EASTL/|' -i {} \;" --tag-name-filter cat --prune-empty
3334
git filter-branch -f --tree-filter "find . -name '*.mk' -exec sed 's|\.\./\.\./\.\./third_party/EABase/|../third_party/EABase/|' -i {} \;" --tag-name-filter cat --prune-empty
3435
git filter-branch -f --tree-filter "find . -name '*.mk' -exec sed 's|\.\./\.\./\.\./third_party/EASTL/|../third_party/EASTL/|' -i {} \;" --tag-name-filter cat --prune-empty
3536

37+
# Adjust paths for psxlua
38+
git filter-branch -f --tree-filter "find . -name Makefile -exec sed 's|\.\./\.\./\.\./third_party/psxlua/|../third_party/psxlua/|' -i {} \;" --tag-name-filter cat --prune-empty
39+
git filter-branch -f --tree-filter "find . -name '*.mk' -exec sed 's|\.\./\.\./\.\./third_party/psxlua/|../third_party/psxlua/|' -i {} \;" --tag-name-filter cat --prune-empty
40+
3641
# Delete unwanted files
3742
git filter-branch -f --tree-filter 'find . -name compile_flags.txt -or -name Doxyfile -delete || true' --tag-name-filter cat --prune-empty

.github/workflows/linux-toolchain.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ jobs:
2626
- name: Build OpenBIOS with it
2727
run: make -C src/mips/openbios -j 6 all
2828
- name: Build psyqo examples with it
29-
run: for d in src/mips/psyqo/examples/* ; do make -C $d -j 6 all TEST=true ; done
29+
run: for d in src/mips/psyqo/examples/* src/mips/psyqo-paths/examples/* src/mips/psyqo-lua/examples/* ; do make -C $d -j 6 all TEST=true ; done

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,6 @@
9797
[submodule "third_party/PEGTL"]
9898
path = third_party/PEGTL
9999
url = https://github.com/taocpp/PEGTL.git
100+
[submodule "third_party/psxlua"]
101+
path = third_party/psxlua
102+
url = https://github.com/grumpycoders/psxlua.git

flake.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,27 @@
2424
forGithubSystems = lib.genAttrs supportedSystems;
2525
in {
2626
packages = forAllSystems (system:
27-
let pkgs = import nixpkgs { inherit system; };
27+
let
28+
pkgs = nixpkgs.legacyPackages.${system};
29+
cross = import nixpkgs {
30+
inherit system;
31+
crossSystem = "mipsel-none-elf";
32+
};
2833
in {
34+
default = self.packages.${system}.pcsx-redux;
35+
2936
pcsx-redux = pkgs.callPackage ./pcsx-redux.nix {
3037
src = self;
3138
platforms = lib.systems.flakeExposed;
39+
gccMips = cross.buildPackages.gccWithoutTargetLibc;
3240
};
33-
# FIXME: default gets duplicated in githubActions
34-
# default = self.packages.${system}.pcsx-redux;
3541
});
3642

3743
githubActions = nix-github-actions.lib.mkGithubMatrix {
38-
checks = forGithubSystems (system: self.packages.${system});
44+
checks = forGithubSystems (system:
45+
# Prevent double build
46+
builtins.removeAttrs self.packages.${system} ["default"]
47+
);
3948
};
4049
};
4150
}

pcsx-redux.nix

Lines changed: 66 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -26,121 +26,104 @@
2626
uriparser,
2727
ucl,
2828
llhttp,
29+
zip,
2930

3031
src,
3132
debugBuild ? false,
3233
platforms,
34+
gccMips,
35+
withOpenbios ? true,
3336
}:
3437
let
35-
zep = fetchFromGitHub {
36-
owner = "grumpycoders";
37-
repo = "zep";
38-
rev = "86ea3c7019f45ccd4a13503bf7d98a396e8f0193";
39-
hash = "sha256-6NmUlOHkRQvCgbATcNxnFrfA2ZWROPYN8Vpd10k6Z2g=";
40-
};
41-
nanosvg = fetchFromGitHub {
42-
owner = "grumpycoders";
43-
repo = "nanosvg";
44-
rev = "f0a3e1034dd22e2e87e5db22401e44998383124e";
45-
hash = "sha256-af11kAga6Ru2rPgrfcYswXNy9etvH3J9FX2T0I0++ew=";
46-
};
47-
nanovg = fetchFromGitHub {
48-
owner = "grumpycoders";
49-
repo = "nanovg";
50-
rev = "7c021819bbd4843a1a3091fe47346d3fcb2a3e1a";
51-
hash = "sha256-gZHbNuDkLXlLlXZZpLBHcbwzTfeBBkLY7xl4L5yr2lY=";
52-
};
53-
vixl = fetchFromGitHub {
54-
owner = "grumpycoders";
55-
repo = "vixl";
56-
rev = "53ad192b26ddf6edd228a24ae1cffc363b442c01";
57-
hash = "sha256-p9Z2lFzhqnHnFWfqT6BIJBVw2ZpkVIxykhG3jUHXA84=";
58-
};
59-
imgui-md = fetchFromGitHub {
38+
# TODO: read the revs from elsewhere to avoid duplication
39+
submodules = [
40+
({
41+
owner = "grumpycoders";
42+
repo = "zep";
43+
rev = "86ea3c7019f45ccd4a13503bf7d98a396e8f0193";
44+
hash = "sha256-6NmUlOHkRQvCgbATcNxnFrfA2ZWROPYN8Vpd10k6Z2g=";
45+
})
46+
({
47+
owner = "grumpycoders";
48+
repo = "nanosvg";
49+
rev = "f0a3e1034dd22e2e87e5db22401e44998383124e";
50+
hash = "sha256-af11kAga6Ru2rPgrfcYswXNy9etvH3J9FX2T0I0++ew=";
51+
})
52+
({
53+
owner = "grumpycoders";
54+
repo = "nanovg";
55+
rev = "7c021819bbd4843a1a3091fe47346d3fcb2a3e1a";
56+
hash = "sha256-gZHbNuDkLXlLlXZZpLBHcbwzTfeBBkLY7xl4L5yr2lY=";
57+
})
58+
({
6059
owner = "mekhontsev";
6160
repo = "imgui_md";
6261
rev = "8ca75c5f7663f314821e3d0b2c51011792bee68f";
6362
hash = "sha256-uxhY81DWLRRCceYn9khk3rwzT+2f9PNMIMT9OrkPfFc=";
64-
};
65-
xbyak = fetchFromGitHub {
63+
})
64+
({
6665
owner = "herumi";
6766
repo = "xbyak";
6867
rev = "2fb843c3287918038c8f76276a590c25cc7ec5ee";
6968
hash = "sha256-XZce+kEZ7dipI19WY43ycOjzM2dZyANMEN5+GhoNYUk=";
70-
};
71-
luafs = fetchFromGitHub {
69+
})
70+
({
7271
owner = "lunarmodules";
7372
repo = "luafilesystem";
7473
rev = "912e06714fc276c15b4d5d1b42bd2b11edb8deff";
7574
hash = "sha256-BShByo2NhVrOHDPze/JXfeFWq36PFrI2HVugR2MDB0A=";
76-
};
77-
luajit = fetchFromGitHub {
75+
})
76+
({
7877
owner = "grumpycoders";
7978
repo = "luajit";
8079
rev = "66fadd16a51955cfbd770de62806cfbdd7c6c818";
8180
hash = "sha256-nFlDr79GC8MsL6ausAsEPJwL8OJrFydB37tpD5mS1C8=";
82-
};
83-
imgui = fetchFromGitHub {
81+
})
82+
({
8483
owner = "ocornut";
8584
repo = "imgui";
8685
rev = "368123ab06b2b573d585e52f84cd782c5c006697";
8786
hash = "sha256-6VOs7a31bEfAG75SQAY2X90h/f/HvqZmN615WXYkUOA=";
88-
};
89-
sdl-db = fetchFromGitHub {
87+
})
88+
({
9089
owner = "mdqinc";
9190
repo = "SDL_GameControllerDB";
9291
rev = "b1e342774cbb35467dfdd3634d4f0181a76cbc89";
9392
hash = "sha256-LYvO+chDVo6D++fuFbxqSRltGW3y82SESmtFj39TdSA=";
93+
})
94+
] ++ lib.optional stdenv.hostPlatform.isAarch {
95+
owner = "grumpycoders";
96+
repo = "vixl";
97+
rev = "53ad192b26ddf6edd228a24ae1cffc363b442c01";
98+
hash = "sha256-p9Z2lFzhqnHnFWfqT6BIJBVw2ZpkVIxykhG3jUHXA84=";
99+
} ++ lib.optional withOpenbios {
100+
owner = "grumpycoders";
101+
repo = "uC-sdk";
102+
rev = "69e06871824e2d62069487a7426ded09090ceb69";
103+
hash = "sha256-VamLhNtXxilcvd6ch76ronhB7DcKfw2eL7CuLwHFbp8=";
94104
};
105+
106+
fetchSubmodule = { owner, repo, rev, hash }@args:
107+
"cp -ru --no-preserve=all ${(fetchFromGitHub args).out} source/third_party/${repo}";
108+
95109
in stdenv.mkDerivation {
96110
pname = "pcsx-redux";
97111
version = "0.99test";
98112
inherit src;
99113

100114
postUnpack = ''
101-
rm -rf source/third_party/miniaudio
102-
rm -rf source/third_party/zep
103-
rm -rf source/third_party/nanosvg
104-
rm -rf source/third_party/nanovg
105-
rm -rf source/third_party/imgui
106-
rm -rf source/third_party/imgui_md
107-
rm -rf source/third_party/xbyak
108-
rm -rf source/third_party/luafilesystem
109-
rm -rf source/third_party/SDL_GameControllerDB
110-
rm -rf source/third_party/tracy
111-
rm -rf source/third_party/luajit
112-
113-
cp -r ${miniaudio.out} source/third_party/miniaudio
114-
cp -r ${zep.out} source/third_party/zep
115-
cp -r ${nanosvg.out} source/third_party/nanosvg
116-
cp -r ${nanovg.out} source/third_party/nanovg
117-
cp -r ${imgui.out} source/third_party/imgui
118-
cp -r ${imgui-md.out} source/third_party/imgui_md
119-
cp -r ${xbyak.out} source/third_party/xbyak
120-
cp -r ${luafs.out} source/third_party/luafilesystem
121-
cp -r ${sdl-db.out} source/third_party/SDL_GameControllerDB
122-
cp -r ${tracy.src} source/third_party/tracy
123-
cp -r ${luajit.out} source/third_party/luajit
124-
125-
chmod -R +w source/third_party/miniaudio
126-
chmod -R +w source/third_party/zep
127-
chmod -R +w source/third_party/nanosvg
128-
chmod -R +w source/third_party/nanovg
129-
chmod -R +w source/third_party/imgui
130-
chmod -R +w source/third_party/imgui_md
131-
chmod -R +w source/third_party/luafilesystem
132-
chmod -R +w source/third_party/SDL_GameControllerDB
133-
chmod -R +w source/third_party/tracy
134-
chmod -R +w source/third_party/luajit
135-
''
136-
+ lib.optionalString stdenv.hostPlatform.isAarch ''
137-
cp -r ${vixl.out} source/third_party/vixl
138-
chmod -R +w source/third_party/vixl
139-
'';
115+
cp -ru --no-preserve=all ${miniaudio.out} source/third_party/miniaudio
116+
cp -ru --no-preserve=all ${tracy.src} source/third_party/tracy
117+
'' + builtins.concatStringsSep "\n" (map fetchSubmodule submodules);
140118

141119
nativeBuildInputs = [
142120
pkg-config
143121
imagemagick
122+
] ++ lib.optionals withOpenbios [
123+
# unwrap them
124+
gccMips.cc
125+
gccMips.bintools.bintools
126+
zip
144127
];
145128

146129
buildInputs = [
@@ -168,6 +151,14 @@ in stdenv.mkDerivation {
168151
];
169152

170153
makeFlags = [
154+
(lib.optionalString withOpenbios "openbios")
155+
"pcsx-redux"
156+
"PREFIX=mipsel-unknown-none-elf"
157+
];
158+
159+
installFlags = [
160+
"install"
161+
(lib.optionalString withOpenbios "install-openbios")
171162
"DESTDIR=$(out)"
172163
];
173164

@@ -176,7 +167,7 @@ in stdenv.mkDerivation {
176167
enableDebugging = debugBuild;
177168

178169
enableParallelBuilding = true;
179-
NIX_BUILD_CORES = 2;
170+
NIX_BUILD_CORES = 4;
180171

181172
meta = {
182173
homepage = "https://pcsx-redux.consoledev.net";

src/core/cdrom.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1466,6 +1466,7 @@ class CDRomImpl : public PCSX::CDRom {
14661466
memFile->write<uint8_t>(m_transfer[m_transferIndex++]);
14671467
adjustTransferIndex();
14681468
}
1469+
PCSX::g_emulator->m_mem->msanDmaWrite(madr, cdsize);
14691470
if (PCSX::g_emulator->settings.get<PCSX::Emulator::SettingDebugSettings>()
14701471
.get<PCSX::Emulator::DebugSettings::Debug>()) {
14711472
PCSX::g_emulator->m_debug->checkDMAwrite(3, madr, cdsize);

src/core/gdb-server.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,9 @@ static const std::string memoryMap = R"(<?xml version="1.0"?>
270270
<memory type="ram" start="0xffffffff9fc00000" length="0x80000"/>
271271
<memory type="ram" start="0xffffffffbfc00000" length="0x80000"/>
272272
273+
<!-- MSAN -->
274+
<memory type="ram" start="0x0000000020000000" length="0x60000000"/>
275+
273276
<!-- This really is only for 0xfffe0130 -->
274277
<memory type="ram" start="0xfffffffffffe0000" length="0x200"/>
275278
</memory-map>

src/core/gpu.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,7 @@ void PCSX::GPU::dma(uint32_t madr, uint32_t bcr, uint32_t chcr) { // GPU
514514
size = (bcr >> 16) * (bcr & 0xffff);
515515
directDMARead(ptr, size, madr);
516516
g_emulator->m_cpu->Clear(madr, size);
517+
g_emulator->m_mem->msanDmaWrite(madr, size * 4);
517518
if (g_emulator->settings.get<Emulator::SettingDebugSettings>().get<Emulator::DebugSettings::Debug>()) {
518519
g_emulator->m_debug->checkDMAwrite(2, madr, size * 4);
519520
}

src/core/mdec.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,7 @@ void PCSX::MDEC::dma1(uint32_t adr, uint32_t bcr, uint32_t chcr) {
480480
size *= 4;
481481
/* I guess the memory speed is limitating */
482482
dmacnt = size;
483+
g_emulator->m_mem->msanDmaWrite(adr, size);
483484
if (g_emulator->settings.get<Emulator::SettingDebugSettings>().get<Emulator::DebugSettings::Debug>()) {
484485
g_emulator->m_debug->checkDMAwrite(1, adr, size);
485486
}

src/core/pcsxlua.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ LuaBreakpoint* addBreakpoint(uint32_t address, PCSX::Debug::BreakpointType type,
4747
bool (*invoker)(uint32_t address, unsigned width, const char* cause), const char* label) {
4848
LuaBreakpoint* ret = new LuaBreakpoint();
4949
auto* bp = PCSX::g_emulator->m_debug->addBreakpoint(
50-
address, type, width, std::string("Lua Breakpoint ") + cause, label,
50+
address, type, width, std::string("Lua Breakpoint"), cause,
5151
[invoker](const PCSX::Debug::Breakpoint* self, uint32_t address, unsigned width, const char* cause) {
5252
try {
5353
return invoker(address, width, cause);

src/core/psxdma.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ void dma4(uint32_t madr, uint32_t bcr, uint32_t chcr) { // SPU
6161
}
6262
size = (bcr >> 16) * (bcr & 0xffff) * 2;
6363
PCSX::g_emulator->m_spu->readDMAMem(ptr, size);
64+
PCSX::g_emulator->m_mem->msanDmaWrite(madr, size * 2);
6465
if (PCSX::g_emulator->settings.get<PCSX::Emulator::SettingDebugSettings>()
6566
.get<PCSX::Emulator::DebugSettings::Debug>()) {
6667
PCSX::g_emulator->m_debug->checkDMAwrite(4, madr, size * 2);
@@ -116,6 +117,7 @@ void dma6(uint32_t madr, uint32_t bcr, uint32_t chcr) {
116117
mem++;
117118
*mem = 0xffffff;
118119
}
120+
PCSX::g_emulator->m_mem->msanDmaWrite(madr, size * 4);
119121
if (PCSX::g_emulator->settings.get<PCSX::Emulator::SettingDebugSettings>()
120122
.get<PCSX::Emulator::DebugSettings::Debug>()) {
121123
PCSX::g_emulator->m_debug->checkDMAwrite(6, madr, size * 4);

src/core/psxmem.cc

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -791,21 +791,39 @@ ssize_t PCSX::Memory::MemoryAsFile::writeAt(const void *src, size_t size, size_t
791791
return ret;
792792
}
793793

794-
void PCSX::Memory::MemoryAsFile::readBlock(void *dest, size_t size, size_t ptr) {
794+
void PCSX::Memory::MemoryAsFile::readBlock(void *dest_, size_t size, size_t ptr) {
795+
auto dest = reinterpret_cast<uint8_t *>(dest_);
795796
auto block = m_memory->m_readLUT[ptr / c_blockSize];
796797
if (!block) {
797798
memset(dest, 0, size);
799+
if (m_memory->msanInitialized()) {
800+
for (size_t i = 0; i < size; ++i) {
801+
size_t msanPtr = ptr + i;
802+
if (inMsanRange(msanPtr) && (m_memory->msanGetStatus<1>(msanPtr) == MsanStatus::OK)) {
803+
dest[i] = m_memory->m_msanRAM[msanPtr - c_msanStart];
804+
}
805+
}
806+
}
798807
return;
799808
}
800809
auto offset = ptr % c_blockSize;
801810
auto toCopy = std::min(size, c_blockSize - offset);
802811
memcpy(dest, block + offset, toCopy);
803812
}
804813

805-
void PCSX::Memory::MemoryAsFile::writeBlock(const void *src, size_t size, size_t ptr) {
814+
void PCSX::Memory::MemoryAsFile::writeBlock(const void *src_, size_t size, size_t ptr) {
806815
// Yes. That's not a bug nor a typo.
816+
auto src = reinterpret_cast<const uint8_t *>(src_);
807817
auto block = m_memory->m_readLUT[ptr / c_blockSize];
808818
if (!block) {
819+
if (m_memory->msanInitialized()) {
820+
for (size_t i = 0; i < size; ++i) {
821+
size_t msanPtr = ptr + i;
822+
if (inMsanRange(msanPtr)) {
823+
m_memory->m_msanRAM[msanPtr - c_msanStart] = src[i];
824+
}
825+
}
826+
}
809827
return;
810828
}
811829
auto offset = ptr % c_blockSize;

0 commit comments

Comments
 (0)