mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-20 20:49:12 +12:00
Merge branch 'master' into bottom-screen
This commit is contained in:
commit
7b859ad602
11 changed files with 107 additions and 69 deletions
|
@ -1,7 +1,10 @@
|
|||
#include "PICA/gpu.hpp"
|
||||
|
||||
#include <array>
|
||||
#include <cstdio>
|
||||
|
||||
#include "PICA/float_types.hpp"
|
||||
#include "PICA/regs.hpp"
|
||||
#include <cstdio>
|
||||
|
||||
using namespace Floats;
|
||||
|
||||
|
@ -41,7 +44,7 @@ void GPU::drawArrays(bool indexed) {
|
|||
drawArrays<false>();
|
||||
}
|
||||
|
||||
Vertex* vertices = new Vertex[Renderer::vertexBufferSize];
|
||||
static std::array<Vertex, Renderer::vertexBufferSize> vertices;
|
||||
|
||||
template <bool indexed>
|
||||
void GPU::drawArrays() {
|
||||
|
@ -205,7 +208,7 @@ void GPU::drawArrays() {
|
|||
OpenGL::Triangle, OpenGL::TriangleStrip, OpenGL::TriangleFan, OpenGL::Triangle
|
||||
};
|
||||
const auto shape = primTypes[primType];
|
||||
renderer.drawVertices(shape, vertices, vertexCount);
|
||||
renderer.drawVertices(shape, std::span(vertices).first(vertexCount));
|
||||
}
|
||||
|
||||
Vertex GPU::getImmediateModeVertex() {
|
||||
|
|
|
@ -157,7 +157,7 @@ void GPU::writeInternalReg(u32 index, u32 value, u32 mask) {
|
|||
// If we've reached 3 verts, issue a draw call
|
||||
// Handle rendering depending on the primitive type
|
||||
if (immediateModeVertIndex == 3) {
|
||||
renderer.drawVertices(OpenGL::Triangle, &immediateModeVertices[0], 3);
|
||||
renderer.drawVertices(OpenGL::Triangle, immediateModeVertices);
|
||||
|
||||
switch (primType) {
|
||||
// Triangle or geometry primitive. Draw a triangle and discard all vertices
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include "kernel.hpp"
|
||||
|
||||
#include "arm_defs.hpp"
|
||||
// This header needs to be included because I did stupid forward decl hack so the kernel and CPU can both access each other
|
||||
#include "kernel.hpp"
|
||||
// This header needs to be included because I did stupid forward decl hack so the kernel and CPU can both access each
|
||||
// other
|
||||
#include "cpu.hpp"
|
||||
#include "resource_limits.hpp"
|
||||
|
||||
|
@ -20,17 +22,17 @@ void Kernel::switchThread(int newThreadIndex) {
|
|||
}
|
||||
|
||||
// Backup context
|
||||
std::memcpy(&oldThread.gprs[0], &cpu.regs()[0], 16 * sizeof(u32)); // Backup the 16 GPRs
|
||||
std::memcpy(&oldThread.fprs[0], &cpu.fprs()[0], 32 * sizeof(u32)); // Backup the 32 FPRs
|
||||
oldThread.cpsr = cpu.getCPSR(); // Backup CPSR
|
||||
oldThread.fpscr = cpu.getFPSCR(); // Backup FPSCR
|
||||
std::memcpy(oldThread.gprs.data(), cpu.regs().data(), cpu.regs().size_bytes()); // Backup the 16 GPRs
|
||||
std::memcpy(oldThread.fprs.data(), cpu.fprs().data(), cpu.fprs().size_bytes()); // Backup the 32 FPRs
|
||||
oldThread.cpsr = cpu.getCPSR(); // Backup CPSR
|
||||
oldThread.fpscr = cpu.getFPSCR(); // Backup FPSCR
|
||||
|
||||
// Load new context
|
||||
std::memcpy(&cpu.regs()[0], &newThread.gprs[0], 16 * sizeof(u32)); // Load 16 GPRs
|
||||
std::memcpy(&cpu.fprs()[0], &newThread.fprs[0], 32 * sizeof(u32)); // Load 32 FPRs
|
||||
cpu.setCPSR(newThread.cpsr); // Load CPSR
|
||||
cpu.setFPSCR(newThread.fpscr); // Load FPSCR
|
||||
cpu.setTLSBase(newThread.tlsBase); // Load CP15 thread-local-storage pointer register
|
||||
std::memcpy(cpu.regs().data(), newThread.gprs.data(), cpu.regs().size_bytes()); // Load 16 GPRs
|
||||
std::memcpy(cpu.fprs().data(), newThread.fprs.data(), cpu.fprs().size_bytes()); // Load 32 FPRs
|
||||
cpu.setCPSR(newThread.cpsr); // Load CPSR
|
||||
cpu.setFPSCR(newThread.fpscr); // Load FPSCR
|
||||
cpu.setTLSBase(newThread.tlsBase); // Load CP15 thread-local-storage pointer register
|
||||
|
||||
currentThreadIndex = newThreadIndex;
|
||||
}
|
||||
|
|
|
@ -237,6 +237,15 @@ void Renderer::initGraphicsContext() {
|
|||
reset();
|
||||
}
|
||||
|
||||
// TODO: Maybe merge this with drawVertices
|
||||
void Renderer::getGraphicsContext() {
|
||||
OpenGL::disableScissor();
|
||||
|
||||
vbo.bind();
|
||||
vao.bind();
|
||||
triangleProgram.use();
|
||||
}
|
||||
|
||||
// Set up the OpenGL blending context to match the emulated PICA
|
||||
void Renderer::setupBlending() {
|
||||
const bool blendingEnabled = (regs[PICAInternalRegs::ColourOperation] & (1 << 8)) != 0;
|
||||
|
@ -282,13 +291,7 @@ void Renderer::setupBlending() {
|
|||
}
|
||||
}
|
||||
|
||||
void Renderer::drawVertices(OpenGL::Primitives primType, Vertex* vertices, u32 count) {
|
||||
OpenGL::disableScissor();
|
||||
|
||||
vbo.bind();
|
||||
vao.bind();
|
||||
triangleProgram.use();
|
||||
|
||||
void Renderer::drawVertices(OpenGL::Primitives primType, std::span<const Vertex> vertices) {
|
||||
// Adjust alpha test if necessary
|
||||
const u32 alphaControl = regs[PICAInternalRegs::AlphaTestConfig];
|
||||
if (alphaControl != oldAlphaControl) {
|
||||
|
@ -375,8 +378,8 @@ void Renderer::drawVertices(OpenGL::Primitives primType, Vertex* vertices, u32 c
|
|||
}
|
||||
}
|
||||
|
||||
vbo.bufferVertsSub(vertices, count);
|
||||
OpenGL::draw(primType, count);
|
||||
vbo.bufferVertsSub(vertices);
|
||||
OpenGL::draw(primType, vertices.size());
|
||||
}
|
||||
|
||||
constexpr u32 topScreenBuffer = 0x1f000000;
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
#include "services/service_manager.hpp"
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "ipc.hpp"
|
||||
#include "kernel.hpp"
|
||||
|
||||
ServiceManager::ServiceManager(std::array<u32, 16>& regs, Memory& mem, GPU& gpu, u32& currentPID, Kernel& kernel)
|
||||
ServiceManager::ServiceManager(std::span<u32, 16> regs, Memory& mem, GPU& gpu, u32& currentPID, Kernel& kernel)
|
||||
: regs(regs), mem(mem), kernel(kernel), ac(mem), am(mem), boss(mem), act(mem), apt(mem, kernel), cam(mem),
|
||||
cecd(mem, kernel), cfg(mem), dlp_srvr(mem), dsp(mem, kernel), hid(mem, kernel), frd(mem), fs(mem, kernel),
|
||||
gsp_gpu(mem, gpu, kernel, currentPID), gsp_lcd(mem), ldr(mem), mic(mem), nfc(mem, kernel), nim(mem), ndm(mem),
|
||||
ptm(mem), y2r(mem, kernel) {}
|
||||
cecd(mem, kernel), cfg(mem), dlp_srvr(mem), dsp(mem, kernel), hid(mem, kernel), frd(mem), fs(mem, kernel),
|
||||
gsp_gpu(mem, gpu, kernel, currentPID), gsp_lcd(mem), ldr(mem), mic(mem), nfc(mem, kernel), nim(mem), ndm(mem),
|
||||
ptm(mem), y2r(mem, kernel) {}
|
||||
|
||||
static constexpr int MAX_NOTIFICATION_COUNT = 16;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue