mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-01 14:58:14 +00:00
Unify GetFramebuffer in GLES and D3D11.
D3D9 is left behind for now, and Vulkan still needs implementation - got a branch with initial work towards that.
This commit is contained in:
1 parent
62972cb891
commit
9b1ee6fce6
6 files changed
+44
-88
No files matched your search
@@ -1835,3 +1835,46 @@ void FramebufferManagerCommon::ShowScreenResolution() {
|
||||
host->NotifyUserMessage(messageStream.str(), 2.0f, 0xFFFFFF, "resize");
|
||||
INFO_LOG(SYSTEM, "%s", messageStream.str().c_str());
|
||||
}
|
||||
|
||||
bool FramebufferManagerCommon::GetFramebuffer(u32 fb_address, int fb_stride, GEBufferFormat format, GPUDebugBuffer &buffer, int maxRes) {
|
||||
VirtualFramebuffer *vfb = currentRenderVfb_;
|
||||
if (!vfb) {
|
||||
vfb = GetVFBAt(fb_address);
|
||||
}
|
||||
|
||||
if (!vfb) {
|
||||
// If there's no vfb and we're drawing there, must be memory?
|
||||
buffer = GPUDebugBuffer(Memory::GetPointer(fb_address | 0x04000000), fb_stride, 512, format);
|
||||
return true;
|
||||
}
|
||||
|
||||
int w = vfb->renderWidth, h = vfb->renderHeight;
|
||||
|
||||
Draw::Framebuffer *bound = nullptr;
|
||||
|
||||
if (vfb->fbo) {
|
||||
if (maxRes > 0 && vfb->renderWidth > vfb->width * maxRes) {
|
||||
w = vfb->width * maxRes;
|
||||
h = vfb->height * maxRes;
|
||||
|
||||
Draw::Framebuffer *tempFBO = GetTempFBO(w, h);
|
||||
VirtualFramebuffer tempVfb = *vfb;
|
||||
tempVfb.fbo = tempFBO;
|
||||
tempVfb.bufferWidth = vfb->width;
|
||||
tempVfb.bufferHeight = vfb->height;
|
||||
tempVfb.renderWidth = w;
|
||||
tempVfb.renderHeight = h;
|
||||
BlitFramebuffer(&tempVfb, 0, 0, vfb, 0, 0, vfb->width, vfb->height, 0);
|
||||
|
||||
bound = tempFBO;
|
||||
} else {
|
||||
bound = vfb->fbo;
|
||||
}
|
||||
}
|
||||
|
||||
buffer.Allocate(w, h, GE_FORMAT_8888, !useBufferedRendering_, true);
|
||||
bool retval = draw_->CopyFramebufferToMemorySync(bound, Draw::FB_COLOR_BIT, 0, 0, w, h, Draw::DataFormat::R8G8B8A8_UNORM, buffer.GetData(), w);
|
||||
// We may have blitted to a temp FBO.
|
||||
RebindFramebuffer();
|
||||
return retval;
|
||||
}
|
||||
@@ -278,7 +278,7 @@ public:
|
||||
Draw::Framebuffer *GetTempFBO(u16 w, u16 h, Draw::FBColorDepth colorDepth = Draw::FBO_8888);
|
||||
|
||||
// Debug features
|
||||
virtual bool GetFramebuffer(u32 fb_address, int fb_stride, GEBufferFormat format, GPUDebugBuffer &buffer, int maxRes) = 0;
|
||||
virtual bool GetFramebuffer(u32 fb_address, int fb_stride, GEBufferFormat format, GPUDebugBuffer &buffer, int maxRes);
|
||||
virtual bool GetDepthbuffer(u32 fb_address, int fb_stride, u32 z_address, int z_stride, GPUDebugBuffer &buffer) = 0;
|
||||
virtual bool GetStencilbuffer(u32 fb_address, int fb_stride, GPUDebugBuffer &buffer) = 0;
|
||||
virtual bool GetOutputFramebuffer(GPUDebugBuffer &buffer) = 0;
|
||||
|
||||
@@ -875,48 +875,6 @@ void FramebufferManagerD3D11::Resized() {
|
||||
CompilePostShader();
|
||||
}
|
||||
|
||||
// Lots of this code could be shared (like the downsampling).
|
||||
bool FramebufferManagerD3D11::GetFramebuffer(u32 fb_address, int fb_stride, GEBufferFormat format, GPUDebugBuffer &buffer, int maxRes) {
|
||||
VirtualFramebuffer *vfb = currentRenderVfb_;
|
||||
if (!vfb) {
|
||||
vfb = GetVFBAt(fb_address);
|
||||
}
|
||||
|
||||
if (!vfb) {
|
||||
// If there's no vfb and we're drawing there, must be memory?
|
||||
buffer = GPUDebugBuffer(Memory::GetPointer(fb_address | 0x04000000), fb_stride, 512, format);
|
||||
return true;
|
||||
}
|
||||
|
||||
int w = vfb->renderWidth, h = vfb->renderHeight;
|
||||
Draw::Framebuffer *bound = nullptr;
|
||||
if (vfb->fbo) {
|
||||
if (maxRes > 0 && vfb->renderWidth > vfb->width * maxRes) {
|
||||
w = vfb->width * maxRes;
|
||||
h = vfb->height * maxRes;
|
||||
|
||||
Draw::Framebuffer *tempFBO = GetTempFBO(w, h);
|
||||
VirtualFramebuffer tempVfb = *vfb;
|
||||
tempVfb.fbo = tempFBO;
|
||||
tempVfb.bufferWidth = vfb->width;
|
||||
tempVfb.bufferHeight = vfb->height;
|
||||
tempVfb.renderWidth = w;
|
||||
tempVfb.renderHeight = h;
|
||||
BlitFramebuffer(&tempVfb, 0, 0, vfb, 0, 0, vfb->width, vfb->height, 0);
|
||||
|
||||
bound = tempFBO;
|
||||
} else {
|
||||
bound = vfb->fbo;
|
||||
}
|
||||
}
|
||||
if (!bound)
|
||||
return false;
|
||||
|
||||
buffer.Allocate(w, h, GE_FORMAT_8888, !useBufferedRendering_, true);
|
||||
|
||||
return draw_->CopyFramebufferToMemorySync(bound, Draw::FB_COLOR_BIT, 0, 0, w, h, Draw::DataFormat::R8G8B8A8_UNORM, buffer.GetData(), w);
|
||||
}
|
||||
|
||||
bool FramebufferManagerD3D11::GetDepthStencilBuffer(VirtualFramebuffer *vfb, GPUDebugBuffer &buffer, bool stencil) {
|
||||
int w = vfb->renderWidth, h = vfb->renderHeight;
|
||||
Draw::Framebuffer *fboForRead = nullptr;
|
||||
|
||||
@@ -67,7 +67,6 @@ public:
|
||||
|
||||
virtual bool NotifyStencilUpload(u32 addr, int size, bool skipZero = false) override;
|
||||
|
||||
bool GetFramebuffer(u32 fb_address, int fb_stride, GEBufferFormat format, GPUDebugBuffer &buffer, int maxRes) override;
|
||||
bool GetDepthbuffer(u32 fb_address, int fb_stride, u32 z_address, int z_stride, GPUDebugBuffer &buffer) override;
|
||||
bool GetStencilbuffer(u32 fb_address, int fb_stride, GPUDebugBuffer &buffer) override;
|
||||
bool GetOutputFramebuffer(GPUDebugBuffer &buffer) override;
|
||||
|
||||
@@ -1167,49 +1167,6 @@ void FramebufferManagerGLES::Resized() {
|
||||
}
|
||||
}
|
||||
|
||||
bool FramebufferManagerGLES::GetFramebuffer(u32 fb_address, int fb_stride, GEBufferFormat format, GPUDebugBuffer &buffer, int maxRes) {
|
||||
VirtualFramebuffer *vfb = currentRenderVfb_;
|
||||
if (!vfb) {
|
||||
vfb = GetVFBAt(fb_address);
|
||||
}
|
||||
|
||||
if (!vfb) {
|
||||
// If there's no vfb and we're drawing there, must be memory?
|
||||
buffer = GPUDebugBuffer(Memory::GetPointer(fb_address | 0x04000000), fb_stride, 512, format);
|
||||
return true;
|
||||
}
|
||||
|
||||
int w = vfb->renderWidth, h = vfb->renderHeight;
|
||||
|
||||
Draw::Framebuffer *bound = nullptr;
|
||||
|
||||
if (vfb->fbo) {
|
||||
if (maxRes > 0 && vfb->renderWidth > vfb->width * maxRes) {
|
||||
w = vfb->width * maxRes;
|
||||
h = vfb->height * maxRes;
|
||||
|
||||
Draw::Framebuffer *tempFBO = GetTempFBO(w, h);
|
||||
VirtualFramebuffer tempVfb = *vfb;
|
||||
tempVfb.fbo = tempFBO;
|
||||
tempVfb.bufferWidth = vfb->width;
|
||||
tempVfb.bufferHeight = vfb->height;
|
||||
tempVfb.renderWidth = w;
|
||||
tempVfb.renderHeight = h;
|
||||
BlitFramebuffer(&tempVfb, 0, 0, vfb, 0, 0, vfb->width, vfb->height, 0);
|
||||
|
||||
bound = tempFBO;
|
||||
} else {
|
||||
bound = vfb->fbo;
|
||||
}
|
||||
}
|
||||
|
||||
buffer.Allocate(w, h, GE_FORMAT_8888, !useBufferedRendering_, true);
|
||||
bool retval = draw_->CopyFramebufferToMemorySync(bound, Draw::FB_COLOR_BIT, 0, 0, w, h, Draw::DataFormat::R8G8B8A8_UNORM, buffer.GetData(), w);
|
||||
// We may have blitted to a temp FBO.
|
||||
RebindFramebuffer();
|
||||
return retval;
|
||||
}
|
||||
|
||||
bool FramebufferManagerGLES::GetOutputFramebuffer(GPUDebugBuffer &buffer) {
|
||||
int pw = PSP_CoreParameter().pixelWidth;
|
||||
int ph = PSP_CoreParameter().pixelHeight;
|
||||
|
||||
@@ -84,7 +84,6 @@ public:
|
||||
|
||||
bool NotifyStencilUpload(u32 addr, int size, bool skipZero = false) override;
|
||||
|
||||
bool GetFramebuffer(u32 fb_address, int fb_stride, GEBufferFormat format, GPUDebugBuffer &buffer, int maxRes) override;
|
||||
bool GetDepthbuffer(u32 fb_address, int fb_stride, u32 z_address, int z_stride, GPUDebugBuffer &buffer) override;
|
||||
bool GetStencilbuffer(u32 fb_address, int fb_stride, GPUDebugBuffer &buffer) override;
|
||||
bool GetOutputFramebuffer(GPUDebugBuffer &buffer) override;
|
||||
|
||||
Reference in new issue
Block a user