Skip to content

Commit

Permalink
Allow block transfers to resize framebuffers.
Browse files Browse the repository at this point in the history
Helps the ending video in Valkyrie Profile.  See #6008.
  • Loading branch information
unknownbrackets committed Jul 24, 2016
1 parent 558b462 commit c9a9fc5
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 11 deletions.
5 changes: 5 additions & 0 deletions GPU/Common/FramebufferCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,11 @@ void FramebufferManagerCommon::NotifyBlockTransferAfter(u32 dstBasePtr, int dstS
const u8 *srcBase = Memory::GetPointerUnchecked(srcBasePtr) + (srcX + srcY * srcStride) * bpp;
int dstBpp = dstBuffer->format == GE_FORMAT_8888 ? 4 : 2;
float dstXFactor = (float)bpp / dstBpp;
if (dstWidth > dstBuffer->width || dstHeight > dstBuffer->height) {
// The buffer isn't big enough, and we have a clear hint of size. Resize.
// This happens in Valkyrie Profile when uploading video at the ending.
ResizeFramebufFBO(dstBuffer, dstWidth, dstHeight, false, true);
}
DrawPixels(dstBuffer, static_cast<int>(dstX * dstXFactor), dstY, srcBase, dstBuffer->format, static_cast<int>(srcStride * dstXFactor), static_cast<int>(dstWidth * dstXFactor), dstHeight);
SetColorUpdated(dstBuffer, skipDrawReason);
RebindFramebuffer();
Expand Down
2 changes: 1 addition & 1 deletion GPU/Common/FramebufferCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ class FramebufferManagerCommon {
static bool MaskedEqual(u32 addr1, u32 addr2);

virtual void DestroyFramebuf(VirtualFramebuffer *vfb) = 0;
virtual void ResizeFramebufFBO(VirtualFramebuffer *vfb, u16 w, u16 h, bool force = false) = 0;
virtual void ResizeFramebufFBO(VirtualFramebuffer *vfb, u16 w, u16 h, bool force = false, bool skipCopy = false) = 0;
virtual void NotifyRenderFramebufferCreated(VirtualFramebuffer *vfb) = 0;
virtual void NotifyRenderFramebufferSwitched(VirtualFramebuffer *prevVfb, VirtualFramebuffer *vfb, bool isClearingDepth) = 0;
virtual void NotifyRenderFramebufferUpdated(VirtualFramebuffer *vfb, bool vfbFormatChanged) = 0;
Expand Down
4 changes: 2 additions & 2 deletions GPU/Directx9/FramebufferDX9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ namespace DX9 {
}
}

void FramebufferManagerDX9::ResizeFramebufFBO(VirtualFramebuffer *vfb, u16 w, u16 h, bool force) {
void FramebufferManagerDX9::ResizeFramebufFBO(VirtualFramebuffer *vfb, u16 w, u16 h, bool force, bool skipCopy) {
VirtualFramebuffer old = *vfb;

if (force) {
Expand Down Expand Up @@ -362,7 +362,7 @@ namespace DX9 {
if (vfb->fbo) {
fbo_bind_as_render_target(vfb->fbo_dx9);
ClearBuffer();
if (!g_Config.bDisableSlowFramebufEffects) {
if (!skipCopy && !g_Config.bDisableSlowFramebufEffects) {
BlitFramebuffer(vfb, 0, 0, &old, 0, 0, std::min(vfb->bufferWidth, vfb->width), std::min(vfb->height, vfb->bufferHeight), 0);
}
}
Expand Down
4 changes: 2 additions & 2 deletions GPU/Directx9/FramebufferDX9.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ class FramebufferManagerDX9 : public FramebufferManagerCommon {

virtual bool NotifyStencilUpload(u32 addr, int size, bool skipZero = false) override;

void DestroyFramebuf(VirtualFramebuffer *vfb);
void ResizeFramebufFBO(VirtualFramebuffer *vfb, u16 w, u16 h, bool force = false);
void DestroyFramebuf(VirtualFramebuffer *vfb) override;
void ResizeFramebufFBO(VirtualFramebuffer *vfb, u16 w, u16 h, bool force = false, bool skipCopy = false) override;

bool GetCurrentFramebuffer(GPUDebugBuffer &buffer, int maxRes);
bool GetCurrentDepthbuffer(GPUDebugBuffer &buffer);
Expand Down
4 changes: 2 additions & 2 deletions GPU/GLES/Framebuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ void FramebufferManager::RebindFramebuffer() {
glstate.viewport.restore();
}

void FramebufferManager::ResizeFramebufFBO(VirtualFramebuffer *vfb, u16 w, u16 h, bool force) {
void FramebufferManager::ResizeFramebufFBO(VirtualFramebuffer *vfb, u16 w, u16 h, bool force, bool skipCopy) {
VirtualFramebuffer old = *vfb;

if (force) {
Expand Down Expand Up @@ -617,7 +617,7 @@ void FramebufferManager::ResizeFramebufFBO(VirtualFramebuffer *vfb, u16 w, u16 h
if (vfb->fbo) {
fbo_bind_as_render_target(vfb->fbo);
ClearBuffer();
if (!g_Config.bDisableSlowFramebufEffects) {
if (!skipCopy && !g_Config.bDisableSlowFramebufEffects) {
BlitFramebuffer(vfb, 0, 0, &old, 0, 0, std::min(vfb->bufferWidth, vfb->width), std::min(vfb->height, vfb->bufferHeight), 0);
}
}
Expand Down
2 changes: 1 addition & 1 deletion GPU/GLES/Framebuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class FramebufferManager : public FramebufferManagerCommon {
bool NotifyStencilUpload(u32 addr, int size, bool skipZero = false) override;

void DestroyFramebuf(VirtualFramebuffer *vfb) override;
void ResizeFramebufFBO(VirtualFramebuffer *vfb, u16 w, u16 h, bool force = false) override;
void ResizeFramebufFBO(VirtualFramebuffer *vfb, u16 w, u16 h, bool force = false, bool skipCopy = false) override;

bool GetFramebuffer(u32 fb_address, int fb_stride, GEBufferFormat format, GPUDebugBuffer &buffer, int maxRes);
bool GetDepthbuffer(u32 fb_address, int fb_stride, u32 z_address, int z_stride, GPUDebugBuffer &buffer);
Expand Down
4 changes: 2 additions & 2 deletions GPU/Vulkan/FramebufferVulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ void FramebufferManagerVulkan::RebindFramebuffer() {
// Switch command buffer?
}

void FramebufferManagerVulkan::ResizeFramebufFBO(VirtualFramebuffer *vfb, u16 w, u16 h, bool force) {
void FramebufferManagerVulkan::ResizeFramebufFBO(VirtualFramebuffer *vfb, u16 w, u16 h, bool force, bool skipCopy) {
return;

/*
Expand Down Expand Up @@ -596,7 +596,7 @@ void FramebufferManagerVulkan::ResizeFramebufFBO(VirtualFramebuffer *vfb, u16 w,
if (vfb->fbo_vk) {
/// fbo_bind_as_render_target(vfb->fbo_vk);
ClearBuffer();
if (!g_Config.bDisableSlowFramebufEffects) {
if (!skipCopy && !g_Config.bDisableSlowFramebufEffects) {
BlitFramebuffer(vfb, 0, 0, &old, 0, 0, std::min(vfb->bufferWidth, vfb->width), std::min(vfb->height, vfb->bufferHeight), 0);
}
}
Expand Down
2 changes: 1 addition & 1 deletion GPU/Vulkan/FramebufferVulkan.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class FramebufferManagerVulkan : public FramebufferManagerCommon {
bool NotifyStencilUpload(u32 addr, int size, bool skipZero = false) override;

void DestroyFramebuf(VirtualFramebuffer *vfb) override;
void ResizeFramebufFBO(VirtualFramebuffer *vfb, u16 w, u16 h, bool force = false) override;
void ResizeFramebufFBO(VirtualFramebuffer *vfb, u16 w, u16 h, bool force = false, bool skipCopy = false) override;

bool GetFramebuffer(u32 fb_address, int fb_stride, GEBufferFormat format, GPUDebugBuffer &buffer);
bool GetDepthbuffer(u32 fb_address, int fb_stride, u32 z_address, int z_stride, GPUDebugBuffer &buffer);
Expand Down

0 comments on commit c9a9fc5

Please sign in to comment.