keep fixing parallel-rdp stuff

This commit is contained in:
CocoSimone
2022-08-06 18:46:47 +02:00
parent c5303ede59
commit 8a450e110b
19 changed files with 64 additions and 45 deletions

BIN
external/frag.spv vendored Normal file

Binary file not shown.

View File

@@ -55,13 +55,18 @@ target_include_directories(parallel-rdp PUBLIC
parallel-rdp-standalone/vulkan
parallel-rdp-standalone/vulkan-headers/include
parallel-rdp-standalone/util
../../src/cores
../../src/n64
../../src/n64/core/
../../src/n64/core/cpu/
../../src/n64/core/cpu/registers
parallel-rdp-standalone
..
../../src/frontend
../../src
../imgui
../imgui/imgui
../imgui/imgui/backends
.
)
if(WIN32)

View File

@@ -1,5 +1,5 @@
#include <parallel-rdp/ParallelRDPWrapper.hpp>
#include <n64/core/RDP.hpp>
#include <ParallelRDPWrapper.hpp>
#include <core/RDP.hpp>
#include <memory>
#include <rdp_device.hpp>
#include <util.hpp>
@@ -115,7 +115,7 @@ WSI* LoadWSIPlatform(Vulkan::WSIPlatform* wsi_platform, std::unique_ptr<Parallel
wsi->set_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<uintptr_t>(rdram);
uintptr_t offset = 0;

View File

@@ -2,7 +2,7 @@
#include <Core.hpp>
#include <wsi.hpp>
#include <SDL2/SDL.h>
#include <n64/core/mmio/VI.hpp>
#include <core/mmio/VI.hpp>
struct Window;
static SDL_Window* window;

BIN
external/vert.spv vendored Normal file

Binary file not shown.

View File

@@ -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)

View File

@@ -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<n64::Core*>(core.get())->GetVI());
else UpdateScreenParallelRdpNoGame(window);
}
if(core.initialized)
core.Run();
if(core.initialized) UpdateScreenParallelRdp(window, core.GetVI());
else UpdateScreenParallelRdpNoGame(window);
}
}

View File

@@ -1,11 +1,11 @@
#pragma once
#include <BaseCore.hpp>
#include <Core.hpp>
#include <imgui/Window.hpp>
struct App {
App() : window(core) {};
void Run();
private:
std::shared_ptr<BaseCore> core;
n64::Core core;
Window window;
};

View File

@@ -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)

View File

@@ -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

View File

@@ -6,7 +6,7 @@
#include <parallel-rdp/ParallelRDPWrapper.hpp>
#include <utility>
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<n64::Core>(outpath);
core->initialized = true;
core->system = System::Nintendo64;
core.LoadROM(outpath);
NFD_FreePath(outpath);
}
}

View File

@@ -10,7 +10,7 @@
#include <vector>
struct Window {
explicit Window(n64::Core& core);
explicit Window(const n64::Core& core);
~Window();
ImDrawData* Present();

View File

@@ -1,7 +1,7 @@
#include <frontend/App.hpp>
int main() {
App app;
app.Run();
App* app = new App;
app->Run();
return 0;
}

View File

@@ -2,8 +2,9 @@
#include <SDL2/SDL_events.h>
namespace n64 {
Core::Core(const std::string& rom) {
void Core::LoadROM(const std::string& rom) {
mem.LoadROM(rom);
initialized = true;
}
void Core::Run() {

View File

@@ -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;

View File

@@ -1,6 +1,6 @@
#pragma once
#include <n64/core/cpu/Registers.hpp>
#include <n64/core/Mem.hpp>
#include <Registers.hpp>
#include <Mem.hpp>
namespace n64 {
struct Cpu {

View File

@@ -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
../../
)

View File

@@ -1,6 +1,6 @@
#pragma once
#include <n64/core/cpu/registers/Cop0.hpp>
#include <n64/core/cpu/registers/Cop1.hpp>
#include <Cop0.hpp>
#include <Cop1.hpp>
namespace n64 {
struct Registers {

View File

@@ -4,6 +4,7 @@
#include <cassert>
#include <portable_endian_bswap.h>
#include <fstream>
#include <vector>
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<char*>(buf), size);
file.close();
return size;
}
}