Skip to content

Commit

Permalink
Disable screen rotation in non-buffered rendering (as it won't worK)
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed May 12, 2015
1 parent 3f78307 commit 95b6b50
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 26 deletions.
4 changes: 2 additions & 2 deletions GPU/Common/FramebufferCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
#include "GPU/GPUInterface.h"
#include "GPU/GPUState.h"

void CenterRect(float *x, float *y, float *w, float *h, float origW, float origH, float frameW, float frameH) {
void CenterRect(float *x, float *y, float *w, float *h, float origW, float origH, float frameW, float frameH, int rotation) {
float outW;
float outH;

bool rotated = g_Config.iInternalScreenRotation == ROTATION_LOCKED_VERTICAL || g_Config.iInternalScreenRotation == ROTATION_LOCKED_VERTICAL180;
bool rotated = rotation == ROTATION_LOCKED_VERTICAL || rotation == ROTATION_LOCKED_VERTICAL180;

if (g_Config.bStretchToDisplay) {
outW = frameW;
Expand Down
2 changes: 1 addition & 1 deletion GPU/Common/FramebufferCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,4 +237,4 @@ class FramebufferManagerCommon {
};
};

void CenterRect(float *x, float *y, float *w, float *h, float origW, float origH, float frameW, float frameH);
void CenterRect(float *x, float *y, float *w, float *h, float origW, float origH, float frameW, float frameH, int rotation);
10 changes: 6 additions & 4 deletions GPU/Directx9/FramebufferDX9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,9 @@ namespace DX9 {
// Should try to unify this path with the regular path somehow, but this simple solution works for most of the post shaders
// (it always runs at output resolution so FXAA may look odd).
float x, y, w, h;
CenterRect(&x, &y, &w, &h, 480.0f, 272.0f, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight);
DrawActiveTexture(drawPixelsTex_, x, y, w, h, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, false, 0.0f, 0.0f, 480.0f / 512.0f, g_Config.iInternalScreenRotation);
int uvRotation = (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE) ? g_Config.iInternalScreenRotation : ROTATION_LOCKED_HORIZONTAL;
CenterRect(&x, &y, &w, &h, 480.0f, 272.0f, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, uvRotation);
DrawActiveTexture(drawPixelsTex_, x, y, w, h, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, false, 0.0f, 0.0f, 480.0f / 512.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) {
Expand Down Expand Up @@ -741,7 +742,8 @@ namespace DX9 {

// Output coordinates
float x, y, w, h;
CenterRect(&x, &y, &w, &h, 480.0f, 272.0f, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight);
int uvRotation = (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE) ? g_Config.iInternalScreenRotation : ROTATION_LOCKED_HORIZONTAL;
CenterRect(&x, &y, &w, &h, 480.0f, 272.0f, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, uvRotation);

const float u0 = offsetX / (float)vfb->bufferWidth;
const float v0 = offsetY / (float)vfb->bufferHeight;
Expand All @@ -767,7 +769,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, g_Config.iInternalScreenRotation);
DrawActiveTexture(colorTexture, x, y, w, h, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, false, u0, v0, u1, v1, uvRotation);
}
}
/*
Expand Down
3 changes: 1 addition & 2 deletions GPU/Directx9/StateMappingDX9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -664,10 +664,9 @@ void TransformDrawEngineDX9::ApplyDrawState(int prim) {
renderWidthFactor = (float)renderWidth / framebufferManager_->GetTargetBufferWidth();
renderHeightFactor = (float)renderHeight / framebufferManager_->GetTargetBufferHeight();
} else {
// TODO: Aspect-ratio aware and centered
float pixelW = PSP_CoreParameter().pixelWidth;
float pixelH = PSP_CoreParameter().pixelHeight;
CenterRect(&renderX, &renderY, &renderWidth, &renderHeight, 480, 272, pixelW, pixelH);
CenterRect(&renderX, &renderY, &renderWidth, &renderHeight, 480, 272, pixelW, pixelH, ROTATION_LOCKED_HORIZONTAL);
renderWidthFactor = renderWidth / 480.0f;
renderHeightFactor = renderHeight / 272.0f;
}
Expand Down
16 changes: 9 additions & 7 deletions GPU/GLES/Framebuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ void FramebufferManager::CompileDraw2DProgram() {
float v_pixel_delta = v_delta;
if (postShaderAtOutputResolution_) {
float x, y, w, h;
CenterRect(&x, &y, &w, &h, 480.0f, 272.0f, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight);
CenterRect(&x, &y, &w, &h, 480.0f, 272.0f, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, ROTATION_LOCKED_HORIZONTAL);
u_pixel_delta = 1.0f / w;
v_pixel_delta = 1.0f / h;
}
Expand Down Expand Up @@ -419,8 +419,8 @@ void FramebufferManager::DrawFramebuffer(const u8 *srcPixels, GEBufferFormat src
// Should try to unify this path with the regular path somehow, but this simple solution works for most of the post shaders
// (it always runs at output resolution so FXAA may look odd).
float x, y, w, h;
CenterRect(&x, &y, &w, &h, 480.0f, 272.0f, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight);
int uvRotation = g_Config.iInternalScreenRotation;
int uvRotation = (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE) ? g_Config.iInternalScreenRotation : ROTATION_LOCKED_HORIZONTAL;
CenterRect(&x, &y, &w, &h, 480.0f, 272.0f, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, uvRotation);
if (cardboardSettings.enabled) {
// Left Eye Image
glstate.viewport.set(cardboardSettings.leftEyeXPosition, cardboardSettings.screenYPosition, cardboardSettings.screenWidth, cardboardSettings.screenHeight);
Expand Down Expand Up @@ -1049,9 +1049,11 @@ void FramebufferManager::CopyDisplayToOutput() {

GLuint colorTexture = fbo_get_color_texture(vfb->fbo);

int uvRotation = (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE) ? g_Config.iInternalScreenRotation : ROTATION_LOCKED_HORIZONTAL;

// Output coordinates
float x, y, w, h;
CenterRect(&x, &y, &w, &h, 480.0f, 272.0f, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight);
CenterRect(&x, &y, &w, &h, 480.0f, 272.0f, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, uvRotation);

// TODO ES3: Use glInvalidateFramebuffer to discard depth/stencil data at the end of frame.

Expand All @@ -1072,7 +1074,7 @@ void FramebufferManager::CopyDisplayToOutput() {
} else {
// Fullscreen Image
glstate.viewport.set(0, 0, PSP_CoreParameter().pixelWidth, PSP_CoreParameter().pixelHeight);
DrawActiveTexture(colorTexture, x, y, w, h, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, true, u0, v0, u1, v1, NULL, g_Config.iInternalScreenRotation);
DrawActiveTexture(colorTexture, x, y, w, h, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, true, u0, v0, u1, v1, NULL, uvRotation);
}
} else if (usePostShader_ && extraFBOs_.size() == 1 && !postShaderAtOutputResolution_) {
// An additional pass, post-processing shader to the extra FBO.
Expand Down Expand Up @@ -1103,7 +1105,7 @@ void FramebufferManager::CopyDisplayToOutput() {
} else {
// Fullscreen Image
glstate.viewport.set(0, 0, PSP_CoreParameter().pixelWidth, PSP_CoreParameter().pixelHeight);
DrawActiveTexture(colorTexture, x, y, w, h, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, true, u0, v0, u1, v1);
DrawActiveTexture(colorTexture, x, y, w, h, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, true, u0, v0, u1, v1, NULL, uvRotation);
}

if (gl_extensions.GLES3 && glInvalidateFramebuffer != nullptr) {
Expand All @@ -1123,7 +1125,7 @@ void FramebufferManager::CopyDisplayToOutput() {
} else {
// Fullscreen Image
glstate.viewport.set(0, 0, PSP_CoreParameter().pixelWidth, PSP_CoreParameter().pixelHeight);
DrawActiveTexture(colorTexture, x, y, w, h, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, true, u0, v0, u1, v1, postShaderProgram_, g_Config.iInternalScreenRotation);
DrawActiveTexture(colorTexture, x, y, w, h, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, true, u0, v0, u1, v1, postShaderProgram_, uvRotation);
}
}

Expand Down
3 changes: 0 additions & 3 deletions GPU/GLES/Framebuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ class TextureCache;
class TransformDrawEngine;
class ShaderManager;

void CenterRect(float *x, float *y, float *w, float *h,
float origW, float origH, float frameW, float frameH);

#ifndef USING_GLES2
// Simple struct for asynchronous PBO readbacks
struct AsyncPBO {
Expand Down
3 changes: 1 addition & 2 deletions GPU/GLES/StateMapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -725,10 +725,9 @@ void TransformDrawEngine::ApplyDrawState(int prim) {
renderWidthFactor = (float)renderWidth / framebufferManager_->GetTargetBufferWidth();
renderHeightFactor = (float)renderHeight / framebufferManager_->GetTargetBufferHeight();
} else {
// TODO: Aspect-ratio aware and centered
float pixelW = PSP_CoreParameter().pixelWidth;
float pixelH = PSP_CoreParameter().pixelHeight;
CenterRect(&renderX, &renderY, &renderWidth, &renderHeight, 480, 272, pixelW, pixelH);
CenterRect(&renderX, &renderY, &renderWidth, &renderHeight, 480, 272, pixelW, pixelH, ROTATION_LOCKED_HORIZONTAL);
renderWidthFactor = renderWidth / 480.0f;
renderHeightFactor = renderHeight / 272.0f;
}
Expand Down
4 changes: 2 additions & 2 deletions GPU/Software/SoftGpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ u32 clut[4096];

// TODO: This one lives in GPU/GLES/Framebuffer.cpp, move it to somewhere common.
void CenterRect(float *x, float *y, float *w, float *h,
float origW, float origH, float frameW, float frameH);
float origW, float origH, float frameW, float frameH, int rotation);

GLuint OpenGL_CompileProgram(const char* vertexShader, const char* fragmentShader)
{
Expand Down Expand Up @@ -247,7 +247,7 @@ void SoftGPU::CopyToCurrentFboFromDisplayRam(int srcwidth, int srcheight)
glUseProgram(program);

float x, y, w, h;
CenterRect(&x, &y, &w, &h, 480.0f, 272.0f, dstwidth, dstheight);
CenterRect(&x, &y, &w, &h, 480.0f, 272.0f, dstwidth, dstheight, ROTATION_LOCKED_HORIZONTAL);

x /= 0.5f * dstwidth;
y /= 0.5f * dstheight;
Expand Down
7 changes: 4 additions & 3 deletions UI/GameSettingsScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,9 @@ void GameSettingsScreen::CreateViews() {

// Not sure if we should call this one something different? For now we call it the same as the Android screen rotation option and just put it on the graphics tab.
static const char *screenRotation[] = {"Landscape", "Portrait", "Landscape Reversed", "Portrait Reversed"};
PopupMultiChoice *rot = graphicsSettings->Add(new PopupMultiChoice(&g_Config.iInternalScreenRotation, c->T("Screen Rotation"), screenRotation, 1, ARRAY_SIZE(screenRotation), c, screenManager()));
rot->OnChoice.Handle(this, &GameSettingsScreen::OnScreenRotation);

PopupMultiChoice *scrRotChoice = graphicsSettings->Add(new PopupMultiChoice(&g_Config.iInternalScreenRotation, c->T("Screen Rotation"), screenRotation, 1, ARRAY_SIZE(screenRotation), c, screenManager()));
scrRotChoice->SetEnabledPtr(&screenRotEnable_);
screenRotEnable_ = (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE);

#ifdef ANDROID
static const char *deviceResolutions[] = { "Native device resolution", "Auto (same as Rendering)", "1x PSP", "2x PSP", "3x PSP", "4x PSP", "5x PSP" };
Expand Down Expand Up @@ -656,6 +656,7 @@ UI::EventReturn GameSettingsScreen::OnRenderingMode(UI::EventParams &e) {

postProcEnable_ = !g_Config.bSoftwareRendering && (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE);
resolutionEnable_ = !g_Config.bSoftwareRendering && (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE);
screenRotEnable_ = (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE);

if (g_Config.iRenderingMode == FB_NON_BUFFERED_MODE) {
g_Config.bAutoFrameSkip = false;
Expand Down
1 change: 1 addition & 0 deletions UI/GameSettingsScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class GameSettingsScreen : public UIDialogScreenWithGameBackground {
bool postProcEnable_;
bool resolutionEnable_;
bool bloomHackEnable_;
bool screenRotEnable_;
};

class DeveloperToolsScreen : public UIDialogScreenWithBackground {
Expand Down

0 comments on commit 95b6b50

Please sign in to comment.