mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-16 02:59:49 +01:00
Two wrongs can appently make a right. Remove an inadvertent flip, add flips where we actually need them.
This commit is contained in:
1 parent
86bfce4006
commit
0266211b88
6 files changed
+46
-23
No files matched your search
+40
-17
@@ -390,21 +390,27 @@ void FramebufferManager::MakePixelTexture(const u8 *srcPixels, GEBufferFormat sr
|
||||
}
|
||||
|
||||
void FramebufferManager::DrawPixels(VirtualFramebuffer *vfb, int dstX, int dstY, const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, int width, int height) {
|
||||
if (useBufferedRendering_ && vfb->fbo) {
|
||||
float v0 = 0.0f, v1 = 1.0f;
|
||||
if (useBufferedRendering_ && vfb && vfb->fbo) {
|
||||
fbo_bind_as_render_target(vfb->fbo);
|
||||
glViewport(0, 0, vfb->renderWidth, vfb->renderHeight);
|
||||
} else {
|
||||
// We are drawing to the back buffer so need to flip.
|
||||
v0 = 1.0f;
|
||||
v1 = 0.0f;
|
||||
float x, y, w, h;
|
||||
CenterDisplayOutputRect(&x, &y, &w, &h, 480.0f, 272.0f, (float)pixelWidth_, (float)pixelHeight_, false, false);
|
||||
CenterDisplayOutputRect(&x, &y, &w, &h, 480.0f, 272.0f, (float)pixelWidth_, (float)pixelHeight_, ROTATION_LOCKED_HORIZONTAL, false);
|
||||
glViewport(x, y, w, h);
|
||||
}
|
||||
|
||||
MakePixelTexture(srcPixels, srcPixelFormat, srcStride, width, height);
|
||||
DisableState();
|
||||
DrawActiveTexture(0, dstX, dstY, width, height, vfb->bufferWidth, vfb->bufferHeight, 0.0f, 1.0f, 1.0f, 0.0f);
|
||||
|
||||
DrawActiveTexture(0, dstX, dstY, width, height, vfb->bufferWidth, vfb->bufferHeight, 0.0f, v0, 1.0f, v1);
|
||||
textureCache_->ForgetLastTexture();
|
||||
}
|
||||
|
||||
void FramebufferManager::DrawFramebuffer(const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, bool applyPostShader) {
|
||||
void FramebufferManager::DrawFramebufferToOutput(const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, bool applyPostShader) {
|
||||
MakePixelTexture(srcPixels, srcPixelFormat, srcStride, 512, 272);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, g_Config.iTexFiltering == TEX_FILTER_NEAREST ? GL_NEAREST : GL_LINEAR);
|
||||
|
||||
@@ -423,29 +429,35 @@ void FramebufferManager::DrawFramebuffer(const u8 *srcPixels, GEBufferFormat src
|
||||
glsl_bind(postShaderProgram_);
|
||||
UpdatePostShaderUniforms(renderWidth_, renderHeight_);
|
||||
}
|
||||
float u0 = 0.0f, u1 = 480.0f / 512.0f;
|
||||
float v0 = 0.0f, v1 = 1.0f;
|
||||
|
||||
// We are drawing directly to the back buffer.
|
||||
std::swap(v0, v1);
|
||||
|
||||
if (cardboardSettings.enabled) {
|
||||
// Left Eye Image
|
||||
glstate.viewport.set(cardboardSettings.leftEyeXPosition, cardboardSettings.screenYPosition, cardboardSettings.screenWidth, cardboardSettings.screenHeight);
|
||||
if (applyPostShader && usePostShader_ && useBufferedRendering_) {
|
||||
DrawActiveTexture(0, x, y, w, h, (float)pixelWidth_, (float)pixelHeight_, 0.0f, 0.0f, 480.0f / 512.0f, 1.0f, postShaderProgram_);
|
||||
DrawActiveTexture(0, x, y, w, h, (float)pixelWidth_, (float)pixelHeight_, u0, v0, u1, v1, postShaderProgram_);
|
||||
} else {
|
||||
DrawActiveTexture(0, x, y, w, h, (float)pixelWidth_, (float)pixelHeight_, 0.0f, 0.0f, 480.0f / 512.0f, 1.0f);
|
||||
DrawActiveTexture(0, x, y, w, h, (float)pixelWidth_, (float)pixelHeight_, u0, v0, u1, v1);
|
||||
}
|
||||
|
||||
// Right Eye Image
|
||||
glstate.viewport.set(cardboardSettings.rightEyeXPosition, cardboardSettings.screenYPosition, cardboardSettings.screenWidth, cardboardSettings.screenHeight);
|
||||
if (applyPostShader && usePostShader_ && useBufferedRendering_) {
|
||||
DrawActiveTexture(0, x, y, w, h, (float)pixelWidth_, (float)pixelHeight_, 0.0f, 0.0f, 480.0f / 512.0f, 1.0f, postShaderProgram_);
|
||||
DrawActiveTexture(0, x, y, w, h, (float)pixelWidth_, (float)pixelHeight_, u0, v0, u1, v1, postShaderProgram_);
|
||||
} else {
|
||||
DrawActiveTexture(0, x, y, w, h, (float)pixelWidth_, (float)pixelHeight_, 0.0f, 0.0f, 480.0f / 512.0f);
|
||||
DrawActiveTexture(0, x, y, w, h, (float)pixelWidth_, (float)pixelHeight_, u0, v0, u1, v1);
|
||||
}
|
||||
} else {
|
||||
// Fullscreen Image
|
||||
glstate.viewport.set(0, 0, pixelWidth_, pixelHeight_);
|
||||
if (applyPostShader && usePostShader_ && useBufferedRendering_) {
|
||||
DrawActiveTexture(0, x, y, w, h, (float)pixelWidth_, (float)pixelHeight_, 0.0f, 0.0f, 480.0f / 512.0f, 1.0f, postShaderProgram_, uvRotation);
|
||||
DrawActiveTexture(0, x, y, w, h, (float)pixelWidth_, (float)pixelHeight_, u0, v0, u1, v1, postShaderProgram_, uvRotation);
|
||||
} else {
|
||||
DrawActiveTexture(0, x, y, w, h, (float)pixelWidth_, (float)pixelHeight_, 0.0f, 0.0f, 480.0f / 512.0f, 1.0f, NULL, uvRotation);
|
||||
DrawActiveTexture(0, x, y, w, h, (float)pixelWidth_, (float)pixelHeight_, u0, v0, u1, v1, NULL, uvRotation);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -529,7 +541,7 @@ void FramebufferManager::DrawActiveTexture(GLuint texture, float x, float y, flo
|
||||
float invDestH = 1.0f / (destH * 0.5f);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
pos[i * 3] = pos[i * 3] * invDestW - 1.0f;
|
||||
pos[i * 3 + 1] = -(pos[i * 3 + 1] * invDestH - 1.0f);
|
||||
pos[i * 3 + 1] = pos[i * 3 + 1] * invDestH - 1.0f;
|
||||
}
|
||||
|
||||
if (!program) {
|
||||
@@ -653,7 +665,7 @@ void FramebufferManager::ResizeFramebufFBO(VirtualFramebuffer *vfb, u16 w, u16 h
|
||||
|
||||
vfb->fbo = fbo_create(vfb->renderWidth, vfb->renderHeight, 1, true, (FBOColorDepth)vfb->colorDepth);
|
||||
if (old.fbo) {
|
||||
INFO_LOG(SCEGE, "Resizing FBO for %08x : %i x %i x %i", vfb->fb_address, w, h, vfb->format);
|
||||
WARN_LOG(SCEGE, "Resizing FBO for %08x : %i x %i x %i", vfb->fb_address, w, h, vfb->format);
|
||||
if (vfb->fbo) {
|
||||
fbo_bind_as_render_target(vfb->fbo);
|
||||
ClearBuffer();
|
||||
@@ -1009,7 +1021,7 @@ void FramebufferManager::CopyDisplayToOutput() {
|
||||
|
||||
if (!vfb) {
|
||||
// Just a pointer to plain memory to draw. We should create a framebuffer, then draw to it.
|
||||
DrawFramebuffer(Memory::GetPointer(displayFramebufPtr_), displayFormat_, displayStride_, true);
|
||||
DrawFramebufferToOutput(Memory::GetPointer(displayFramebufPtr_), displayFormat_, displayStride_, true);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
@@ -1047,12 +1059,15 @@ void FramebufferManager::CopyDisplayToOutput() {
|
||||
|
||||
// TODO ES3: Use glInvalidateFramebuffer to discard depth/stencil data at the end of frame.
|
||||
|
||||
const float u0 = offsetX / (float)vfb->bufferWidth;
|
||||
const float v0 = offsetY / (float)vfb->bufferHeight;
|
||||
const float u1 = (480.0f + offsetX) / (float)vfb->bufferWidth;
|
||||
const float v1 = (272.0f + offsetY) / (float)vfb->bufferHeight;
|
||||
float u0 = offsetX / (float)vfb->bufferWidth;
|
||||
float v0 = offsetY / (float)vfb->bufferHeight;
|
||||
float u1 = (480.0f + offsetX) / (float)vfb->bufferWidth;
|
||||
float v1 = (272.0f + offsetY) / (float)vfb->bufferHeight;
|
||||
|
||||
if (!usePostShader_) {
|
||||
// We are doing the DrawActiveTexture call directly to the backbuffer here. Hence, we must
|
||||
// flip V.
|
||||
std::swap(v0, v1);
|
||||
if (cardboardSettings.enabled) {
|
||||
// Left Eye Image
|
||||
glstate.viewport.set(cardboardSettings.leftEyeXPosition, cardboardSettings.screenYPosition, cardboardSettings.screenWidth, cardboardSettings.screenHeight);
|
||||
@@ -1087,6 +1102,10 @@ void FramebufferManager::CopyDisplayToOutput() {
|
||||
}
|
||||
colorTexture = fbo_get_color_texture(extraFBOs_[0]);
|
||||
|
||||
// We are doing the DrawActiveTexture call directly to the backbuffer after here. Hence, we must
|
||||
// flip V.
|
||||
std::swap(v0, v1);
|
||||
|
||||
if (g_Config.bEnableCardboard) {
|
||||
// Left Eye Image
|
||||
glstate.viewport.set(cardboardSettings.leftEyeXPosition, cardboardSettings.screenYPosition, cardboardSettings.screenWidth, cardboardSettings.screenHeight);
|
||||
@@ -1107,6 +1126,10 @@ void FramebufferManager::CopyDisplayToOutput() {
|
||||
glInvalidateFramebuffer(GL_FRAMEBUFFER, 3, attachments);
|
||||
}
|
||||
} else {
|
||||
// We are doing the DrawActiveTexture call directly to the backbuffer here. Hence, we must
|
||||
// flip V.
|
||||
std::swap(v0, v1);
|
||||
|
||||
shaderManager_->DirtyLastShader(); // dirty lastShader_
|
||||
glsl_bind(postShaderProgram_);
|
||||
UpdatePostShaderUniforms(vfb->renderWidth, vfb->renderHeight);
|
||||
|
||||
Reference in new issue
Block a user