From 8a450e110b8c27d828ec9f3d1aa7a5a4ca5ab81c Mon Sep 17 00:00:00 2001 From: CocoSimone Date: Sat, 6 Aug 2022 18:46:47 +0200 Subject: [PATCH] keep fixing parallel-rdp stuff --- external/frag.spv | Bin 0 -> 1844 bytes external/parallel-rdp/CMakeLists.txt | 7 ++++++- external/parallel-rdp/ParallelRDPWrapper.cpp | 14 +++++++------- external/parallel-rdp/ParallelRDPWrapper.hpp | 2 +- external/vert.spv | Bin 0 -> 1064 bytes src/CMakeLists.txt | 4 +++- src/frontend/App.cpp | 11 +++++------ src/frontend/App.hpp | 4 ++-- src/frontend/CMakeLists.txt | 7 +++++-- src/frontend/imgui/CMakeLists.txt | 4 ++++ src/frontend/imgui/Window.cpp | 6 ++---- src/frontend/imgui/Window.hpp | 2 +- src/main.cpp | 4 ++-- src/n64/Core.cpp | 3 ++- src/n64/Core.hpp | 6 ++++-- src/n64/core/Cpu.hpp | 4 ++-- src/n64/core/cpu/CMakeLists.txt | 8 ++++++-- src/n64/core/cpu/Registers.hpp | 4 ++-- src/util.hpp | 19 ++++++++++--------- 19 files changed, 64 insertions(+), 45 deletions(-) create mode 100644 external/frag.spv create mode 100644 external/vert.spv diff --git a/external/frag.spv b/external/frag.spv new file mode 100644 index 0000000000000000000000000000000000000000..5a0382be85febc88aa6e3d68a110491c5444e1c5 GIT binary patch literal 1844 zcmZQ(Qf6mhU}WH8;AQY+fB-=TCI&_Z1_o{hHZbk(6YQf`T#}+^Vrl?V!NaQBIK_xE@A zag9$dD2OjEsmw`@&&kY7jZeueN=+`wEK3Ec<3LiEnU|bXnu4r=m4O9pKFnTL24)6M z1_p-GG6n_^8|03%&@cv&I$j0_hT!C))YLo%1~vv(1`r?Q*5b^nR1ggl1Nl2YEv-1U z1Y`ya13$<-s76)>R zhaAWf1_lNXB)gT-#6Wg~#5fp0`k29P1ce#M3{ZH&%mDF0c7oJ{i~#XLb}E55V7)91 zAig4$FU-IM4tqs#EHHrCVhqd-Yzzzx3JeSk;tVVdpg02YLG~#yurPq!01^XX5TAZ}=97(jfGzd&w~V_*Th6{Hq~LF)M!7{GA>3TKdd5FZqlp!gAGU||q|+6~gL z4dn|$?EvW)g6apE2a^|r`bUI;i9w2ifdOQWG}IiB6i6M2F9YI$#aS3+86a*3`3)ow zqCtKJDS`3TK^%q#dk`O_Ul-~QP`Fq#fYJ*nErP;|g~0}#mKhj8;vj#4_@KA}

=H zcCfe|*lv(|2nLyN#J~a$Z&183Ff`apGH^0DLd^z+0oVyp0>+nSU}kV)U;wKFg^4p% z9wY{`8^j02Gf3EsffXFDpu7m;gWU6jfr){Y0pwOle1gIr6rQ%w_~rrUagh0}45089 zW?%rPcThaQ)QB)JFo49H8Cbz_FUr8c0MZ8%cVvL*6Nl;p#ScuM1UOwWFmyomNrK~x zfdM3L2hFD-F_0OcI0B_@ko!P!2QmW`Px1^53?T6x46NYz2Bl|^7%2W$FtC8dKxrN% z{+)rDK?US-1_p*-3@i*FaZp|YiGjia#D>|W3Qb$ccBwHiFo48&LG99DU|;}=f#U8b z0~6S6kU1dpzA~_b?bc*qU;x<-3S*FZkR330X)!P`faF2$(m`?;NL-tNfdM22G7rRt zxl0e~E>QY|g@HZ;0|Q7L76zaK7$gP?1CYC5=74CJy9}XrgWL*I53&R1E+Ym829P|+ zT_#BG0*MvVhtRaw|wZ z$PSP@tdQIRQe(-$z+lh7zyNXwhz&|Fpgac3S0F!w)Pv+eYCz!x$`7s#4B#>k#0RBu zH>jH -#include +#include +#include #include #include #include @@ -115,7 +115,7 @@ WSI* LoadWSIPlatform(Vulkan::WSIPlatform* wsi_platform, std::unique_ptrset_backbuffer_srgb(false); wsi->set_platform(wsi_platform); Context::SystemHandles handles; - if (!wsi->init_context_from_platform(1, handles)) { + if (!wsi->init_simple(1, handles)) { util::panic("Failed to initialize WSI!"); } @@ -139,11 +139,11 @@ void LoadParallelRDP(const u8* rdram) { fragLayout.sets[0].fp_mask = 1; fragLayout.sets[0].array_size[0] = 1; - u32* fullscreenQuadVert = nullptr, *fullscreenQuadFrag = nullptr; - util::ReadFileBinary("external/vert.spv", fullscreenQuadVert); - util::ReadFileBinary("external/frag.spv", fullscreenQuadFrag); + u32* fullscreenQuadVert, *fullscreenQuadFrag; + auto sizeVert = util::ReadFileBinary("external/vert.spv", fullscreenQuadVert); + auto sizeFrag = util::ReadFileBinary("external/frag.spv", fullscreenQuadFrag); - fullscreen_quad_program = wsi->get_device().request_program(fullscreenQuadVert, sizeof(fullscreenQuadVert), fullscreenQuadFrag, sizeof(fullscreenQuadFrag), &vertLayout, &fragLayout); + fullscreen_quad_program = wsi->get_device().request_program(fullscreenQuadVert, sizeVert, fullscreenQuadFrag, sizeFrag, &vertLayout, &fragLayout); auto aligned_rdram = reinterpret_cast(rdram); uintptr_t offset = 0; diff --git a/external/parallel-rdp/ParallelRDPWrapper.hpp b/external/parallel-rdp/ParallelRDPWrapper.hpp index ff617917..2422ad92 100644 --- a/external/parallel-rdp/ParallelRDPWrapper.hpp +++ b/external/parallel-rdp/ParallelRDPWrapper.hpp @@ -2,7 +2,7 @@ #include #include #include -#include +#include struct Window; static SDL_Window* window; diff --git a/external/vert.spv b/external/vert.spv new file mode 100644 index 0000000000000000000000000000000000000000..924cb24db622f29472049aa6b0a0601cb160ee94 GIT binary patch literal 1064 zcmZQ(Qf6mhU}WH8;AK!^fB-=TCI&_Z1_o{hHZbk(6YQf`T#}+^Vrl?V!N;uK3j+f~ZenI0h{Makz#zoHz#zlGz`)GF%)rFJz;K9>fq{jAi^1I|-re8d-N!XP zxu77vxTG>CH9jXZFEu_TvnVyWB(p3Pq>ckgU1nZ#PH76V0#*hV24wqK8Q2)O85kJS zbK(P1i^5WiN>VF8?qGw8gV-Rs{Nl`#%=|nCHU@UEdXOK%;+c6R!I@R5AayV~kekzU z;+=Cc3tTdbOA_;vQ{nnRz6Z&b=H$TTSQ(fZK>h}q!OFl2_J07(LIwr~kUS_n%0j~! zJQ!HP_Jh=d+zp~(Vjwqx#6UDm4CEG&7|33j7>ErL1BHV-12fn>kUDn;7O>rNAVV1# z7(jfGy)eEo0~0tt6u~jW0A`CZFf*_*Ffb@EFffQSurRPQFo5|Wvqc$Lz%dMx0~x6e z<#RHCQVl4ML9q%^4-%7uhB?d(E(Qh$5LRGdVc-F$2T;0VV6cYrL16~+3&K>3= zL40W_A7&ni4+=Yw`(XNI!TK5O%@|n0VFwB$kPt}C4+bU%Rt5$JTLu;ekQu_zd=SV0 zN}&u4VhjunATf}7n3y^#&!8~qV_*flL7stu0VD=;cK}oj6qg`A2sc8-6d4#8Kx#p9AaguORj literal 0 HcmV?d00001 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ba572693..2b784f86 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -6,7 +6,9 @@ set(CMAKE_CXX_STANDARD_REQUIRED true) add_subdirectory(n64) add_subdirectory(frontend) +find_package(fmt REQUIRED) + add_executable(natsukashii main.cpp) -target_link_libraries(natsukashii PUBLIC frontend n64) +target_link_libraries(natsukashii PUBLIC frontend n64 fmt) target_include_directories(natsukashii PUBLIC . ../external) diff --git a/src/frontend/App.cpp b/src/frontend/App.cpp index 2a256042..cc45b6a9 100644 --- a/src/frontend/App.cpp +++ b/src/frontend/App.cpp @@ -14,11 +14,10 @@ void App::Run() { done = true; } - if(core->initialized) - core->Run(); - if(core->system == System::Nintendo64) { - if(core->initialized) UpdateScreenParallelRdp(window, dynamic_cast(core.get())->GetVI()); - else UpdateScreenParallelRdpNoGame(window); - } + if(core.initialized) + core.Run(); + + if(core.initialized) UpdateScreenParallelRdp(window, core.GetVI()); + else UpdateScreenParallelRdpNoGame(window); } } \ No newline at end of file diff --git a/src/frontend/App.hpp b/src/frontend/App.hpp index 82a08e90..15b24dfd 100644 --- a/src/frontend/App.hpp +++ b/src/frontend/App.hpp @@ -1,11 +1,11 @@ #pragma once -#include +#include #include struct App { App() : window(core) {}; void Run(); private: - std::shared_ptr core; + n64::Core core; Window window; }; diff --git a/src/frontend/CMakeLists.txt b/src/frontend/CMakeLists.txt index f76072f8..6a5e8fe9 100644 --- a/src/frontend/CMakeLists.txt +++ b/src/frontend/CMakeLists.txt @@ -9,11 +9,14 @@ add_library(frontend target_include_directories(frontend PUBLIC . + .. ../../external ../../external/parallel-rdp ../../external/parallel-rdp/parallel-rdp-standalone/vulkan ../../external/parallel-rdp/parallel-rdp-standalone/util ../../external/parallel-rdp/parallel-rdp-standalone/volk - ../cores - ../cores/n64) + ../n64 + ../n64/core + ../n64/core/cpu + ../n64/core/cpu/registers) target_link_libraries(frontend PUBLIC frontend-imgui) diff --git a/src/frontend/imgui/CMakeLists.txt b/src/frontend/imgui/CMakeLists.txt index 9dbfe1eb..5f106ad8 100644 --- a/src/frontend/imgui/CMakeLists.txt +++ b/src/frontend/imgui/CMakeLists.txt @@ -10,7 +10,11 @@ add_library(frontend-imgui target_include_directories(frontend-imgui PUBLIC . + ../.. ../../n64 + ../../n64/core + ../../n64/core/cpu + ../../n64/core/cpu/registers ../../../external ../../../external/parallel-rdp/parallel-rdp-standalone/vulkan ../../../external/parallel-rdp/parallel-rdp-standalone/util diff --git a/src/frontend/imgui/Window.cpp b/src/frontend/imgui/Window.cpp index eb9b9fd8..c92850e4 100644 --- a/src/frontend/imgui/Window.cpp +++ b/src/frontend/imgui/Window.cpp @@ -6,7 +6,7 @@ #include #include -Window::Window(n64::Core& core) { +Window::Window(const n64::Core& core) { InitSDL(); InitParallelRDP(core.GetRDRAM()); InitImgui(); @@ -191,9 +191,7 @@ void Window::Render() { const nfdu8filteritem_t filter {"Nintendo 64 roms", "n64,z64,v64,N64,Z64,V64"}; nfdresult_t result = NFD_OpenDialog(&outpath, &filter, 1, nullptr); if(result == NFD_OKAY) { - core = std::make_shared(outpath); - core->initialized = true; - core->system = System::Nintendo64; + core.LoadROM(outpath); NFD_FreePath(outpath); } } diff --git a/src/frontend/imgui/Window.hpp b/src/frontend/imgui/Window.hpp index 07ac6201..9e928358 100644 --- a/src/frontend/imgui/Window.hpp +++ b/src/frontend/imgui/Window.hpp @@ -10,7 +10,7 @@ #include struct Window { - explicit Window(n64::Core& core); + explicit Window(const n64::Core& core); ~Window(); ImDrawData* Present(); diff --git a/src/main.cpp b/src/main.cpp index 8e21934f..f02f66cd 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,7 +1,7 @@ #include int main() { - App app; - app.Run(); + App* app = new App; + app->Run(); return 0; } \ No newline at end of file diff --git a/src/n64/Core.cpp b/src/n64/Core.cpp index ecbe7ad4..c12d8ec3 100644 --- a/src/n64/Core.cpp +++ b/src/n64/Core.cpp @@ -2,8 +2,9 @@ #include namespace n64 { -Core::Core(const std::string& rom) { +void Core::LoadROM(const std::string& rom) { mem.LoadROM(rom); + initialized = true; } void Core::Run() { diff --git a/src/n64/Core.hpp b/src/n64/Core.hpp index f31fd79d..def143e7 100644 --- a/src/n64/Core.hpp +++ b/src/n64/Core.hpp @@ -6,11 +6,13 @@ namespace n64 { struct Core { ~Core() = default; - explicit Core(const std::string&); + Core() = default; + void LoadROM(const std::string&); void Run(); void PollInputs(u32); VI& GetVI() { return mem.mmio.vi; } - const u8* GetRDRAM() { return mem.rdram.data(); } + const u8* GetRDRAM() const { return mem.rdram.data(); } + bool initialized = false; private: Mem mem; Cpu cpu; diff --git a/src/n64/core/Cpu.hpp b/src/n64/core/Cpu.hpp index c4bdcf91..1b95abd8 100644 --- a/src/n64/core/Cpu.hpp +++ b/src/n64/core/Cpu.hpp @@ -1,6 +1,6 @@ #pragma once -#include -#include +#include +#include namespace n64 { struct Cpu { diff --git a/src/n64/core/cpu/CMakeLists.txt b/src/n64/core/cpu/CMakeLists.txt index 8df0f3bf..e8065672 100644 --- a/src/n64/core/cpu/CMakeLists.txt +++ b/src/n64/core/cpu/CMakeLists.txt @@ -13,5 +13,9 @@ add_library(cpu registers/cop1instructions.cpp instructions.cpp) -target_include_directories(cpu PUBLIC registers . .. ../../ - ../../../../../external ../../../) +target_include_directories(cpu PUBLIC registers + . .. + ../../../../external + ../../../../src + ../../ +) diff --git a/src/n64/core/cpu/Registers.hpp b/src/n64/core/cpu/Registers.hpp index b7c26e7e..dccb5b31 100644 --- a/src/n64/core/cpu/Registers.hpp +++ b/src/n64/core/cpu/Registers.hpp @@ -1,6 +1,6 @@ #pragma once -#include -#include +#include +#include namespace n64 { struct Registers { diff --git a/src/util.hpp b/src/util.hpp index 84b3dc73..3a2b20d5 100644 --- a/src/util.hpp +++ b/src/util.hpp @@ -4,6 +4,7 @@ #include #include #include +#include namespace util { enum MessageType : u8 { @@ -145,20 +146,20 @@ inline size_t NextPow2(size_t num) { return num + 1; } -inline void ReadFileBinary(const std::string& path, void* buf) { - std::ifstream file("external/vert.spv", std::ios::binary); +inline auto ReadFileBinary(const std::string& path, u32* buf) { + std::ifstream file(path, std::ios::binary); file.unsetf(std::ios::skipws); if(!file.is_open()) { util::panic("Could not load file!\n"); } - file.seekg(std::ios::end); - auto size = file.tellg(); - file.seekg(std::ios::beg); - if(buf) - free(buf); - buf = calloc(size, 1); - file.read((char*)buf, size); + file.seekg(0, std::ios::end); + size_t size = file.tellg(); + file.seekg(0, std::ios::beg); + + buf = (u32*)calloc(size, 1); + file.read(reinterpret_cast(buf), size); file.close(); + return size; } } \ No newline at end of file