GS: Now the GIF is able to process data via DMAC

This commit is contained in:
Correia 2024-05-21 16:49:25 -03:00
parent f29ccdb34a
commit 4caec4452a
4 changed files with 23 additions and 8 deletions

View File

@ -4,17 +4,19 @@
namespace cosmic::gs {
constexpr u64 downBufferSize{2048 * 2048 / 4};
void GsEngine::resetGraphics() {
transferBuffer.qw128Count = 0;
transferBuffer.indexAddr = 0;
if (!*transferBuffer.downloadBuffer) {
transferBuffer.downloadBuffer = os::MappedMemory<os::vec>{downBufferSize};
videoBuffer.qw128Count = {};
videoBuffer.indexAddr = {};
framesCounter = {};
if (!videoBuffer) {
videoBuffer = GsPayloadDataPacket{downBufferSize};
}
}
std::tuple<bool, os::vec> GsEngine::readGsData() {
bool hasData{transferBuffer.qw128Count != 0};
bool hasData{videoBuffer.qw128Count != 0};
os::vec vec{};
if (hasData) {
const os::vec eve{transferBuffer.consume()};
const auto eve{videoBuffer.consume()};
vec[0] = eve[0];
vec[1] = eve[1];
}

View File

@ -6,6 +6,9 @@
#include <gamedb/title_patches.h>
namespace cosmic::gs {
struct GsPayloadDataPacket {
GsPayloadDataPacket(u64 bufferSize)
: downloadBuffer(bufferSize)
{}
u32 qw128Count;
os::MappedMemory<os::vec> downloadBuffer;
u32 indexAddr;
@ -16,6 +19,9 @@ namespace cosmic::gs {
qw128Count--;
return data;
}
operator bool() const {
return downloadBuffer;
}
};
enum GsRegisters {
GsBusDir
@ -65,7 +71,7 @@ namespace cosmic::gs {
gamedb::SwitchPatches gswAddrAlias{};
private:
GsPayloadDataPacket transferBuffer;
GsPayloadDataPacket videoBuffer;
// Internal registers (accessible via GIF)
u64 prim;
@ -74,6 +80,7 @@ namespace cosmic::gs {
std::pair<u16, u16> uv;
CoordinatesXyz xyz2;
u8 fog;
u64 framesCounter;
void writePrimitive(u64 primitive);
};

View File

@ -50,6 +50,7 @@ namespace cosmic::vm {
static void runFrameLoop(Ref<EmuVm>& vm);
static void stepMips(Ref<EmuVm>& vm, u32 mips, u32 iop, u32 bus);
static void stepVus(Ref<EmuVm>& vm, u32 mips, u32 bus);
static void stepGs(Ref<EmuVm>& vm, u32 bus);
std::thread vmThread;
std::shared_ptr<SharedVm> vmSharedPtr;

View File

@ -16,6 +16,9 @@ namespace cosmic::vm {
vm->vu01->vpu0Cop2.pulse(mips);
vm->vu01->vpu1Dlo.pulse(mips);
}
void EmuThread::stepGs(Ref<EmuVm>& vm, u32 bus) {
vm->gsGif->update(bus);
}
void EmuThread::runFrameLoop(Ref<EmuVm>& vm) {
auto sched{vm->scheduler};
@ -30,7 +33,9 @@ namespace cosmic::vm {
case EmotionEngine:
stepMips(vm, mipsCycles, iopCycles, busCycles);
break;
case GS: break;
case GS:
stepGs(vm, busCycles);
break;
case VUs:
stepVus(vm, mipsCycles, busCycles);
break;