Depal: Apply the half-pixel offset that looked the least wrong. Still not right.

This commit is contained in:
Henrik Rydgard 2014-09-20 22:08:42 +02:00 committed by Unknown W. Brackets
parent 7b76f7ae60
commit 869f74d1b0
2 changed files with 28 additions and 28 deletions

View file

@ -63,33 +63,33 @@ namespace DX9 {
void CenterRect(float *x, float *y, float *w, float *h,
float origW, float origH, float frameW, float frameH) {
if (g_Config.bStretchToDisplay) {
*x = 0;
*y = 0;
*w = frameW;
*h = frameH;
return;
*x = 0;
*y = 0;
*w = frameW;
*h = frameH;
return;
}
float origRatio = origW/origH;
float frameRatio = frameW/frameH;
if (origRatio > frameRatio) {
// Image is wider than frame. Center vertically.
float scale = origW / frameW;
*x = 0.0f;
*w = frameW;
*h = frameW / origRatio;
// Stretch a little bit
if (g_Config.bPartialStretch)
*h = (frameH + *h) / 2.0f; // (408 + 720) / 2 = 564
*y = (frameH - *h) / 2.0f;
// Image is wider than frame. Center vertically.
float scale = origW / frameW;
*x = 0.0f;
*w = frameW;
*h = frameW / origRatio;
// Stretch a little bit
if (g_Config.bPartialStretch)
*h = (frameH + *h) / 2.0f; // (408 + 720) / 2 = 564
*y = (frameH - *h) / 2.0f;
} else {
// Image is taller than frame. Center horizontally.
float scale = origH / frameH;
*y = 0.0f;
*h = frameH;
*w = frameH * origRatio;
*x = (frameW - *w) / 2.0f;
// Image is taller than frame. Center horizontally.
float scale = origH / frameH;
*y = 0.0f;
*h = frameH;
*w = frameH * origRatio;
*x = (frameW - *w) / 2.0f;
}
}
@ -202,8 +202,6 @@ namespace DX9 {
convBuf = (u8*)rect.pBits;
// Final format is BGRA(directx)
// TODO: We can just change the texture format and flip some bits around instead of this.
if (srcPixelFormat != GE_FORMAT_8888 || srcStride != 512) {
for (int y = 0; y < height; y++) {
switch (srcPixelFormat) {

View file

@ -910,13 +910,15 @@ void TextureCacheDX9::SetTextureFramebuffer(TexCacheEntry *entry, VirtualFramebu
FBO *depalFBO = framebufferManager_->GetTempFBO(framebuffer->renderWidth, framebuffer->renderHeight, FBO_8888);
fbo_bind_as_render_target(depalFBO);
static const float pos[12 + 8] = {
-1, 1, 0, 0, 0,
1, 1, 0, 1, 0,
1, -1, 0, 1, 1,
-1, -1, 0, 0, 1,
float xoff = -0.5f / framebuffer->renderWidth;
float yoff = 0.5f / framebuffer->renderHeight;
const float pos[12 + 8] = {
-1 + xoff, 1 + yoff, 0, 0, 0,
1 + xoff, 1 + yoff, 0, 1, 0,
1 + xoff, -1 + yoff, 0, 1, 1,
-1 + xoff, -1 + yoff, 0, 0, 1,
};
static const u16 indices[4] = { 0, 1, 3, 2 };
shaderManager_->DirtyLastShader();