mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-08 23:25:40 +12:00
Merge pull request #708 from wheremyfoodat/icache
GPU: Add sw texture copies
This commit is contained in:
commit
b559725920
4 changed files with 42 additions and 1 deletions
|
@ -53,6 +53,7 @@ class Renderer {
|
||||||
|
|
||||||
EmulatorConfig* emulatorConfig = nullptr;
|
EmulatorConfig* emulatorConfig = nullptr;
|
||||||
|
|
||||||
|
void doSoftwareTextureCopy(u32 inputAddr, u32 outputAddr, u32 copySize, u32 inputWidth, u32 inputGap, u32 outputWidth, u32 outputGap);
|
||||||
public:
|
public:
|
||||||
Renderer(GPU& gpu, const std::array<u32, regNum>& internalRegs, const std::array<u32, extRegNum>& externalRegs);
|
Renderer(GPU& gpu, const std::array<u32, regNum>& internalRegs, const std::array<u32, extRegNum>& externalRegs);
|
||||||
virtual ~Renderer();
|
virtual ~Renderer();
|
||||||
|
|
|
@ -792,6 +792,8 @@ void RendererGL::textureCopy(u32 inputAddr, u32 outputAddr, u32 totalBytes, u32
|
||||||
shutUpCounter++;
|
shutUpCounter++;
|
||||||
printf("RendererGL::TextureCopy failed to locate src framebuffer!\n");
|
printf("RendererGL::TextureCopy failed to locate src framebuffer!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
doSoftwareTextureCopy(inputAddr, outputAddr, copySize, inputWidth, inputGap, outputWidth, outputGap);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -426,7 +426,7 @@ void RendererMTL::textureCopy(u32 inputAddr, u32 outputAddr, u32 totalBytes, u32
|
||||||
// Find the source surface.
|
// Find the source surface.
|
||||||
auto srcFramebuffer = getColorRenderTarget(inputAddr, PICA::ColorFmt::RGBA8, copyStride, copyHeight, false);
|
auto srcFramebuffer = getColorRenderTarget(inputAddr, PICA::ColorFmt::RGBA8, copyStride, copyHeight, false);
|
||||||
if (!srcFramebuffer) {
|
if (!srcFramebuffer) {
|
||||||
Helpers::warn("RendererMTL::TextureCopy failed to locate src framebuffer!\n");
|
doSoftwareTextureCopy(inputAddr, outputAddr, copySize, inputWidth, inputGap, outputWidth, outputGap);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
nextRenderPassName = "Clear before texture copy";
|
nextRenderPassName = "Clear before texture copy";
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
|
#include "PICA/gpu.hpp"
|
||||||
|
|
||||||
Renderer::Renderer(GPU& gpu, const std::array<u32, regNum>& internalRegs, const std::array<u32, extRegNum>& externalRegs)
|
Renderer::Renderer(GPU& gpu, const std::array<u32, regNum>& internalRegs, const std::array<u32, extRegNum>& externalRegs)
|
||||||
: gpu(gpu), regs(internalRegs), externalRegs(externalRegs) {}
|
: gpu(gpu), regs(internalRegs), externalRegs(externalRegs) {}
|
||||||
Renderer::~Renderer() {}
|
Renderer::~Renderer() {}
|
||||||
|
@ -39,3 +41,39 @@ const char* Renderer::typeToString(RendererType rendererType) {
|
||||||
default: return "Invalid";
|
default: return "Invalid";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Renderer::doSoftwareTextureCopy(u32 inputAddr, u32 outputAddr, u32 copySize, u32 inputWidth, u32 inputGap, u32 outputWidth, u32 outputGap) {
|
||||||
|
u8* inputPointer = gpu.getPointerPhys<u8>(inputAddr);
|
||||||
|
u8* outputPointer = gpu.getPointerPhys<u8>(outputAddr);
|
||||||
|
|
||||||
|
if (inputPointer == nullptr || outputPointer == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
u32 inputBytesLeft = inputWidth;
|
||||||
|
u32 outputBytesLeft = outputWidth;
|
||||||
|
u32 copyBytesLeft = copySize;
|
||||||
|
|
||||||
|
while (copyBytesLeft > 0) {
|
||||||
|
const u32 bytes = std::min<u32>({inputBytesLeft, outputBytesLeft, copyBytesLeft});
|
||||||
|
std::memcpy(outputPointer, inputPointer, bytes);
|
||||||
|
|
||||||
|
inputPointer += bytes;
|
||||||
|
outputPointer += bytes;
|
||||||
|
|
||||||
|
inputBytesLeft -= bytes;
|
||||||
|
outputBytesLeft -= bytes;
|
||||||
|
copyBytesLeft -= bytes;
|
||||||
|
|
||||||
|
// Apply input and output gap when an input or output line ends
|
||||||
|
if (inputBytesLeft == 0) {
|
||||||
|
inputBytesLeft = inputWidth;
|
||||||
|
inputPointer += inputGap;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (outputBytesLeft == 0) {
|
||||||
|
outputBytesLeft = outputWidth;
|
||||||
|
outputPointer += outputGap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue