Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

d3d9: Support blitting depth on frame switch #8535

Merged
merged 1 commit into from
Jan 31, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions GPU/Directx9/FramebufferDX9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,6 @@ namespace DX9 {
// If depth wasn't updated, then we're at least "two degrees" away from the data.
// This is an optimization: it probably doesn't need to be copied in this case.
} else {
// TODO: Needs work
BlitFramebufferDepth(prevVfb, vfb);
}
}
Expand Down Expand Up @@ -521,16 +520,14 @@ namespace DX9 {
}

void FramebufferManagerDX9::BlitFramebufferDepth(VirtualFramebuffer *src, VirtualFramebuffer *dst) {
if (src->z_address == dst->z_address &&
src->z_stride != 0 && dst->z_stride != 0 &&
src->renderWidth == dst->renderWidth &&
src->renderHeight == dst->renderHeight) {

bool matchingDepthBuffer = src->z_address == dst->z_address && src->z_stride != 0 && dst->z_stride != 0;
bool matchingSize = src->width == dst->width && src->height == dst->height;
if (matchingDepthBuffer && matchingSize) {
// Doesn't work. Use a shader maybe?
/*fbo_unbind();
fbo_unbind();

LPDIRECT3DTEXTURE9 srcTex = fbo_get_depth_texture(src->fbo);
LPDIRECT3DTEXTURE9 dstTex = fbo_get_depth_texture(dst->fbo);
LPDIRECT3DTEXTURE9 srcTex = fbo_get_depth_texture(src->fbo_dx9);
LPDIRECT3DTEXTURE9 dstTex = fbo_get_depth_texture(dst->fbo_dx9);

if (srcTex && dstTex) {
D3DSURFACE_DESC srcDesc;
Expand All @@ -543,12 +540,16 @@ namespace DX9 {
HRESULT srcLockRes = srcTex->LockRect(0, &srcLock, nullptr, D3DLOCK_READONLY);
HRESULT dstLockRes = dstTex->LockRect(0, &dstLock, nullptr, 0);
if (SUCCEEDED(srcLockRes) && SUCCEEDED(dstLockRes)) {
int pitch = std::min(srcLock.Pitch, dstLock.Pitch);
u32 pitch = std::min(srcLock.Pitch, dstLock.Pitch);
u32 w = std::min(pitch / 4, std::min(srcDesc.Width, dstDesc.Width));
u32 h = std::min(srcDesc.Height, dstDesc.Height);
const u8 *srcp = (const u8 *)srcLock.pBits;
u8 *dstp = (u8 *)dstLock.pBits;
// TODO: Optimize. But probably don't change the stencil bits.
for (u32 y = 0; y < h; ++y) {
memcpy(dstp, srcp, pitch);
for (u32 x = 0; x < w; ++x) {
memcpy(dstp + x * 4, srcp + x * 4, 3);
}
dstp += dstLock.Pitch;
srcp += srcLock.Pitch;
}
Expand All @@ -561,7 +562,7 @@ namespace DX9 {
}
}

RebindFramebuffer();*/
RebindFramebuffer();
}
}

Expand Down