Disable screen rotation in non-buffered rendering (as it won't worK)

This commit is contained in:
Henrik Rydgard 2015-05-12 22:44:02 +02:00
parent 3f7830743a
commit 95b6b50fd5
10 changed files with 27 additions and 26 deletions

View file

@ -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;

View file

@ -237,4 +237,4 @@ protected:
};
};
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);

View file

@ -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) {
@ -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;
@ -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);
}
}
/*

View file

@ -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;
}

View file

@ -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;
}
@ -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);
@ -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.
@ -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.
@ -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) {
@ -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);
}
}

View file

@ -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 {

View file

@ -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;
}

View file

@ -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)
{
@ -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;

View file

@ -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" };
@ -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;

View file

@ -109,6 +109,7 @@ private:
bool postProcEnable_;
bool resolutionEnable_;
bool bloomHackEnable_;
bool screenRotEnable_;
};
class DeveloperToolsScreen : public UIDialogScreenWithBackground {