mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-08 07:05:40 +12:00
[GPU/GSP] Get our first command list
This commit is contained in:
parent
8692e7fc6b
commit
09000da701
4 changed files with 21 additions and 6 deletions
|
@ -30,7 +30,7 @@ class Emulator {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Emulator() : window(sf::VideoMode(width, height), "Alber", sf::Style::Default, sf::ContextSettings(0, 0, 0, 4, 3)),
|
Emulator() : window(sf::VideoMode(width, height), "Alber", sf::Style::Default, sf::ContextSettings(0, 0, 0, 4, 3)),
|
||||||
kernel(cpu, memory, gpu), cpu(memory, kernel) {
|
kernel(cpu, memory, gpu), cpu(memory, kernel), gpu(memory) {
|
||||||
reset();
|
reset();
|
||||||
window.setActive(true);
|
window.setActive(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "helpers.hpp"
|
#include "helpers.hpp"
|
||||||
|
#include "memory.hpp"
|
||||||
|
|
||||||
class GPU {
|
class GPU {
|
||||||
|
Memory& mem;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GPU() {}
|
GPU(Memory& mem) : mem(mem) {}
|
||||||
void clearBuffer(u32 startAddress, u32 endAddress, u32 value, u32 control);
|
void clearBuffer(u32 startAddress, u32 endAddress, u32 value, u32 control);
|
||||||
void reset();
|
void reset();
|
||||||
};
|
};
|
|
@ -26,7 +26,7 @@ class GPUService {
|
||||||
// This is the PID of that process
|
// This is the PID of that process
|
||||||
u32 privilegedProcess;
|
u32 privilegedProcess;
|
||||||
|
|
||||||
void processCommands();
|
void processCommandBuffer();
|
||||||
|
|
||||||
// Service commands
|
// Service commands
|
||||||
void acquireRight(u32 messagePointer);
|
void acquireRight(u32 messagePointer);
|
||||||
|
@ -37,7 +37,8 @@ class GPUService {
|
||||||
void writeHwRegs(u32 messagePointer);
|
void writeHwRegs(u32 messagePointer);
|
||||||
void writeHwRegsWithMask(u32 messagePointer);
|
void writeHwRegsWithMask(u32 messagePointer);
|
||||||
|
|
||||||
// GPU commands processed via TriggerCmdReqQueue
|
// GSP commands processed via TriggerCmdReqQueue
|
||||||
|
void processCommandList(u32* cmd);
|
||||||
void memoryFill(u32* cmd);
|
void memoryFill(u32* cmd);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -16,6 +16,7 @@ namespace ServiceCommands {
|
||||||
// Commands written to shared memory and processed by TriggerCmdReqQueue
|
// Commands written to shared memory and processed by TriggerCmdReqQueue
|
||||||
namespace GPUCommands {
|
namespace GPUCommands {
|
||||||
enum : u32 {
|
enum : u32 {
|
||||||
|
ProcessCommandList = 1,
|
||||||
MemoryFill = 2
|
MemoryFill = 2
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -186,14 +187,14 @@ void GPUService::setLCDForceBlack(u32 messagePointer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPUService::triggerCmdReqQueue(u32 messagePointer) {
|
void GPUService::triggerCmdReqQueue(u32 messagePointer) {
|
||||||
processCommands();
|
processCommandBuffer();
|
||||||
mem.write32(messagePointer + 4, Result::Success);
|
mem.write32(messagePointer + 4, Result::Success);
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
using namespace std::chrono_literals;
|
using namespace std::chrono_literals;
|
||||||
void GPUService::processCommands() {
|
void GPUService::processCommandBuffer() {
|
||||||
if (sharedMem == nullptr) [[unlikely]] { // Shared memory hasn't been set up yet
|
if (sharedMem == nullptr) [[unlikely]] { // Shared memory hasn't been set up yet
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -211,6 +212,7 @@ void GPUService::processCommands() {
|
||||||
while (commandsLeft != 0) {
|
while (commandsLeft != 0) {
|
||||||
u32 cmdID = cmd[0] & 0xff;
|
u32 cmdID = cmd[0] & 0xff;
|
||||||
switch (cmdID) {
|
switch (cmdID) {
|
||||||
|
case GPUCommands::ProcessCommandList: processCommandList(cmd); break;
|
||||||
case GPUCommands::MemoryFill: memoryFill(cmd); break;
|
case GPUCommands::MemoryFill: memoryFill(cmd); break;
|
||||||
default: Helpers::panic("GSP::GPU::ProcessCommands: Unknown cmd ID %d", cmdID);
|
default: Helpers::panic("GSP::GPU::ProcessCommands: Unknown cmd ID %d", cmdID);
|
||||||
}
|
}
|
||||||
|
@ -244,3 +246,13 @@ void GPUService::memoryFill(u32* cmd) {
|
||||||
gpu.clearBuffer(start1, end1, value1, control1);
|
gpu.clearBuffer(start1, end1, value1, control1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Actually send command list (aka display list) to GPU
|
||||||
|
void GPUService::processCommandList(u32* cmd) {
|
||||||
|
u32 address = cmd[1]; // Buffer address
|
||||||
|
u32 size = cmd[2]; // Buffer size
|
||||||
|
bool updateGas = cmd[3] == 1; // Update gas additive blend results (0 = don't update, 1 = update)
|
||||||
|
bool flushBuffer = cmd[7] == 1; // Flush buffer (0 = don't flush, 1 = flush)
|
||||||
|
|
||||||
|
Helpers::panic("GPU::GSP::processCommandList. Address: %08X, size: %08X", address, size);
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue