Remove more obsolete v-flip support

This commit is contained in:
Henrik Rydgard 2015-11-01 13:32:03 +01:00
parent 1ce6801d42
commit 86bfce4006
5 changed files with 41 additions and 62 deletions

View file

@ -220,7 +220,7 @@ protected:
virtual void DecimateFBOs() = 0;
// Used by ReadFramebufferToMemory and later framebuffer block copies
virtual void BlitFramebuffer(VirtualFramebuffer *dst, int dstX, int dstY, VirtualFramebuffer *src, int srcX, int srcY, int w, int h, int bpp, bool flip = false) = 0;
virtual void BlitFramebuffer(VirtualFramebuffer *dst, int dstX, int dstY, VirtualFramebuffer *src, int srcX, int srcY, int w, int h, int bpp) = 0;
void EstimateDrawingSize(u32 fb_address, GEBufferFormat fb_format, int viewport_width, int viewport_height, int region_width, int region_height, int scissor_width, int scissor_height, int fb_stride, int &drawing_width, int &drawing_height);
u32 FramebufferByteSize(const VirtualFramebuffer *vfb) const;

View file

@ -193,7 +193,7 @@ namespace DX9 {
}
MakePixelTexture(srcPixels, srcPixelFormat, srcStride, width, height);
DisableState();
DrawActiveTexture(drawPixelsTex_, dstX, dstY, width, height, vfb->bufferWidth, vfb->bufferHeight, false, 0.0f, 0.0f, 1.0f, 1.0f);
DrawActiveTexture(drawPixelsTex_, dstX, dstY, width, height, vfb->bufferWidth, vfb->bufferHeight, 0.0f, 0.0f, 1.0f, 1.0f, ROTATION_LOCKED_HORIZONTAL);
textureCache_->ForgetLastTexture();
}
@ -208,14 +208,10 @@ namespace DX9 {
float x, y, w, h;
int uvRotation = (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE) ? g_Config.iInternalScreenRotation : ROTATION_LOCKED_HORIZONTAL;
CenterDisplayOutputRect(&x, &y, &w, &h, 480.0f, 272.0f, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, uvRotation, false);
DrawActiveTexture(drawPixelsTex_, x, y, w, h, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, false, 0.0f, 0.0f, 480.0f / 512.0f, 1.0f, uvRotation);
DrawActiveTexture(drawPixelsTex_, x, y, w, h, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, 0.0f, 0.0f, 480.0f / 512.0f, 1.0f, uvRotation);
}
void FramebufferManagerDX9::DrawActiveTexture(LPDIRECT3DTEXTURE9 tex, float x, float y, float w, float h, float destW, float destH, bool flip, float u0, float v0, float u1, float v1, int uvRotation) {
if (flip) {
std::swap(v0, v1);
}
void FramebufferManagerDX9::DrawActiveTexture(LPDIRECT3DTEXTURE9 tex, float x, float y, float w, float h, float destW, float destH, float u0, float v0, float u1, float v1, int uvRotation) {
// TODO: StretchRect instead?
float coord[20] = {
x,y,0, u0,v0,
@ -658,7 +654,7 @@ namespace DX9 {
}
}
BlitFramebuffer(&copyInfo, x, y, framebuffer, x, y, w, h, 0, false);
BlitFramebuffer(&copyInfo, x, y, framebuffer, x, y, w, h, 0);
RebindFramebuffer();
pD3Ddevice->SetTexture(stage, fbo_get_color_texture(renderCopy));
@ -794,7 +790,7 @@ namespace DX9 {
}
dxstate.texMipFilter.set(D3DTEXF_NONE);
dxstate.texMipLodBias.set(0);
DrawActiveTexture(colorTexture, x, y, w, h, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, false, u0, v0, u1, v1, uvRotation);
DrawActiveTexture(colorTexture, x, y, w, h, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, u0, v0, u1, v1, uvRotation);
}
}
/*
@ -837,7 +833,7 @@ namespace DX9 {
#endif
if (vfb) {
// We'll pseudo-blit framebuffers here to get a resized and flipped version of vfb.
// We'll pseudo-blit framebuffers here to get a resized version of vfb.
// For now we'll keep these on the same struct as the ones that can get displayed
// (and blatantly copy work already done above while at it).
VirtualFramebuffer *nvfb = 0;
@ -935,22 +931,22 @@ namespace DX9 {
gameUsesSequentialCopies_ = true;
}
}
BlitFramebuffer(nvfb, x, y, vfb, x, y, w, h, 0, false);
BlitFramebuffer(nvfb, x, y, vfb, x, y, w, h, 0);
PackFramebufferDirectx9_(nvfb, x, y, w, h);
RebindFramebuffer();
}
}
void FramebufferManagerDX9::BlitFramebuffer(VirtualFramebuffer *dst, int dstX, int dstY, VirtualFramebuffer *src, int srcX, int srcY, int w, int h, int bpp, bool flip) {
void FramebufferManagerDX9::BlitFramebuffer(VirtualFramebuffer *dst, int dstX, int dstY, VirtualFramebuffer *src, int srcX, int srcY, int w, int h, int bpp) {
if (!dst->fbo || !src->fbo || !useBufferedRendering_) {
// This can happen if they recently switched from non-buffered.
fbo_unbind();
return;
}
float srcXFactor = flip ? 1.0f : (float)src->renderWidth / (float)src->bufferWidth;
float srcYFactor = flip ? 1.0f : (float)src->renderHeight / (float)src->bufferHeight;
float srcXFactor = (float)src->renderWidth / (float)src->bufferWidth;
float srcYFactor = (float)src->renderHeight / (float)src->bufferHeight;
const int srcBpp = src->format == GE_FORMAT_8888 ? 4 : 2;
if (srcBpp != bpp && bpp != 0) {
srcXFactor = (srcXFactor * bpp) / srcBpp;
@ -960,8 +956,8 @@ namespace DX9 {
int srcY1 = srcY * srcYFactor;
int srcY2 = (srcY + h) * srcYFactor;
float dstXFactor = flip ? 1.0f : (float)dst->renderWidth / (float)dst->bufferWidth;
float dstYFactor = flip ? 1.0f : (float)dst->renderHeight / (float)dst->bufferHeight;
float dstXFactor = (float)dst->renderWidth / (float)dst->bufferWidth;
float dstYFactor = (float)dst->renderHeight / (float)dst->bufferHeight;
const int dstBpp = dst->format == GE_FORMAT_8888 ? 4 : 2;
if (dstBpp != bpp && bpp != 0) {
dstXFactor = (dstXFactor * bpp) / dstBpp;
@ -971,50 +967,33 @@ namespace DX9 {
int dstY1 = dstY * dstYFactor;
int dstY2 = (dstY + h) * dstYFactor;
if (flip) {
fbo_bind_as_render_target(dst->fbo);
dxstate.viewport.set(0, 0, dst->renderWidth, dst->renderHeight);
DisableState();
LPDIRECT3DSURFACE9 srcSurf = fbo_get_color_for_read(src->fbo);
LPDIRECT3DSURFACE9 dstSurf = fbo_get_color_for_write(dst->fbo);
RECT srcRect = {srcX1, srcY1, srcX2, srcY2};
RECT dstRect = {dstX1, dstY1, dstX2, dstY2};
fbo_bind_color_as_texture(src->fbo, 0);
D3DSURFACE_DESC desc;
srcSurf->GetDesc(&desc);
srcRect.right = std::min(srcRect.right, (LONG)desc.Width);
srcRect.bottom = std::min(srcRect.bottom, (LONG)desc.Height);
float srcW = src->bufferWidth;
float srcH = src->bufferHeight;
DrawActiveTexture(0, dstX1, dstY, w * dstXFactor, h, dst->bufferWidth, dst->bufferHeight, flip, srcX1 / srcW, srcY / srcH, srcX2 / srcW, (srcY + h) / srcH);
pD3Ddevice->SetTexture(0, NULL);
textureCache_->ForgetLastTexture();
dxstate.viewport.restore();
dstSurf->GetDesc(&desc);
dstRect.right = std::min(dstRect.right, (LONG)desc.Width);
dstRect.bottom = std::min(dstRect.bottom, (LONG)desc.Height);
RebindFramebuffer();
} else {
LPDIRECT3DSURFACE9 srcSurf = fbo_get_color_for_read(src->fbo);
LPDIRECT3DSURFACE9 dstSurf = fbo_get_color_for_write(dst->fbo);
RECT srcRect = {srcX1, srcY1, srcX2, srcY2};
RECT dstRect = {dstX1, dstY1, dstX2, dstY2};
D3DSURFACE_DESC desc;
srcSurf->GetDesc(&desc);
srcRect.right = std::min(srcRect.right, (LONG)desc.Width);
srcRect.bottom = std::min(srcRect.bottom, (LONG)desc.Height);
dstSurf->GetDesc(&desc);
dstRect.right = std::min(dstRect.right, (LONG)desc.Width);
dstRect.bottom = std::min(dstRect.bottom, (LONG)desc.Height);
// Direct3D 9 doesn't support rect -> self.
FBO *srcFBO = src->fbo;
if (src == dst) {
FBO *tempFBO = GetTempFBO(src->renderWidth, src->renderHeight, (FBOColorDepth)src->colorDepth);
HRESULT hr = fbo_blit_color(src->fbo, &srcRect, tempFBO, &srcRect, D3DTEXF_POINT);
if (SUCCEEDED(hr)) {
srcFBO = tempFBO;
}
// Direct3D 9 doesn't support rect -> self.
FBO *srcFBO = src->fbo;
if (src == dst) {
FBO *tempFBO = GetTempFBO(src->renderWidth, src->renderHeight, (FBOColorDepth)src->colorDepth);
HRESULT hr = fbo_blit_color(src->fbo, &srcRect, tempFBO, &srcRect, D3DTEXF_POINT);
if (SUCCEEDED(hr)) {
srcFBO = tempFBO;
}
}
HRESULT hr = fbo_blit_color(srcFBO, &srcRect, dst->fbo, &dstRect, D3DTEXF_POINT);
if (FAILED(hr)) {
ERROR_LOG_REPORT(G3D, "fbo_blit_color failed in blit: %08x (%08x -> %08x)", hr, src->fb_address, dst->fb_address);
}
HRESULT hr = fbo_blit_color(srcFBO, &srcRect, dst->fbo, &dstRect, D3DTEXF_POINT);
if (FAILED(hr)) {
ERROR_LOG_REPORT(G3D, "fbo_blit_color failed in blit: %08x (%08x -> %08x)", hr, src->fb_address, dst->fb_address);
}
}

View file

@ -59,7 +59,7 @@ public:
virtual void DrawPixels(VirtualFramebuffer *vfb, int dstX, int dstY, const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, int width, int height) override;
virtual void DrawFramebuffer(const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, bool applyPostShader) override;
void DrawActiveTexture(LPDIRECT3DTEXTURE9 texture, float x, float y, float w, float h, float destW, float destH, bool flip = false, float u0 = 0.0f, float v0 = 0.0f, float u1 = 1.0f, float v1 = 1.0f, int uvRotation = ROTATION_LOCKED_HORIZONTAL);
void DrawActiveTexture(LPDIRECT3DTEXTURE9 texture, float x, float y, float w, float h, float destW, float destH, float u0 = 0.0f, float v0 = 0.0f, float u1 = 1.0f, float v1 = 1.0f, int uvRotation = ROTATION_LOCKED_HORIZONTAL);
void DestroyAllFBOs();
@ -100,7 +100,7 @@ protected:
virtual void DecimateFBOs() override;
// Used by ReadFramebufferToMemory and later framebuffer block copies
virtual void BlitFramebuffer(VirtualFramebuffer *dst, int dstX, int dstY, VirtualFramebuffer *src, int srcX, int srcY, int w, int h, int bpp, bool flip = false) override;
virtual void BlitFramebuffer(VirtualFramebuffer *dst, int dstX, int dstY, VirtualFramebuffer *src, int srcX, int srcY, int w, int h, int bpp) override;
virtual void NotifyRenderFramebufferCreated(VirtualFramebuffer *vfb) override;
virtual void NotifyRenderFramebufferSwitched(VirtualFramebuffer *prevVfb, VirtualFramebuffer *vfb, bool isClearingDepth) override;

View file

@ -904,7 +904,7 @@ void FramebufferManager::BindFramebufferColor(int stage, u32 fbRawAddress, Virtu
}
}
BlitFramebuffer(&copyInfo, x, y, framebuffer, x, y, w, h, 0, false);
BlitFramebuffer(&copyInfo, x, y, framebuffer, x, y, w, h, 0);
fbo_bind_color_as_texture(renderCopy, 0);
} else {
@ -1255,7 +1255,7 @@ void FramebufferManager::ReadFramebufferToMemory(VirtualFramebuffer *vfb, bool s
gameUsesSequentialCopies_ = true;
}
}
BlitFramebuffer(nvfb, x, y, vfb, x, y, w, h, 0, true);
BlitFramebuffer(nvfb, x, y, vfb, x, y, w, h, 0);
// PackFramebufferSync_() - Synchronous pixel data transfer using glReadPixels
// PackFramebufferAsync_() - Asynchronous pixel data transfer using glReadPixels with PBOs
@ -1277,7 +1277,7 @@ void FramebufferManager::ReadFramebufferToMemory(VirtualFramebuffer *vfb, bool s
}
// TODO: If dimensions are the same, we can use glCopyImageSubData.
void FramebufferManager::BlitFramebuffer(VirtualFramebuffer *dst, int dstX, int dstY, VirtualFramebuffer *src, int srcX, int srcY, int w, int h, int bpp, bool flip) {
void FramebufferManager::BlitFramebuffer(VirtualFramebuffer *dst, int dstX, int dstY, VirtualFramebuffer *src, int srcX, int srcY, int w, int h, int bpp) {
if (!dst->fbo || !src->fbo || !useBufferedRendering_) {
// This can happen if they recently switched from non-buffered.
fbo_unbind();

View file

@ -130,7 +130,7 @@ protected:
virtual void DecimateFBOs() override;
// Used by ReadFramebufferToMemory and later framebuffer block copies
virtual void BlitFramebuffer(VirtualFramebuffer *dst, int dstX, int dstY, VirtualFramebuffer *src, int srcX, int srcY, int w, int h, int bpp, bool flip = false) override;
virtual void BlitFramebuffer(VirtualFramebuffer *dst, int dstX, int dstY, VirtualFramebuffer *src, int srcX, int srcY, int w, int h, int bpp) override;
virtual void NotifyRenderFramebufferCreated(VirtualFramebuffer *vfb) override;
virtual void NotifyRenderFramebufferSwitched(VirtualFramebuffer *prevVfb, VirtualFramebuffer *vfb, bool isClearingDepth) override;