mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-10-08 11:33:28 +00:00
Support full VSync control in SDL OpenGL.
(Not yet Qt). Forgot about iOS SDL headless buildfix Additional iOS buildfix
This commit is contained in:
parent
f5afb2dbbd
commit
6560192d8e
@ -40,13 +40,3 @@ public:
|
||||
|
||||
virtual Draw::DrawContext *GetDrawContext() = 0;
|
||||
};
|
||||
|
||||
class DummyGraphicsContext : public GraphicsContext {
|
||||
public:
|
||||
void Shutdown() override {}
|
||||
void SwapInterval(int interval) override {}
|
||||
void SwapBuffers() override {}
|
||||
void Resize() override {}
|
||||
|
||||
Draw::DrawContext *GetDrawContext() override { return nullptr; }
|
||||
};
|
||||
|
@ -530,7 +530,7 @@ static int DefaultInternalResolution() {
|
||||
}
|
||||
|
||||
static bool DefaultFrameskipUnthrottle() {
|
||||
#if !PPSSPP_PLATFORM(WINDOWS) || PPSSPP_PLATFORM(UWP)
|
||||
#if PPSSPP_PLATFORM(ANDROID) || defined(USING_QT_UI) || PPSSPP_PLATFORM(UWP) || PPSSPP_PLATFORM(IOS)
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
|
@ -467,7 +467,7 @@ void GPUCommon::Reinitialize() {
|
||||
}
|
||||
|
||||
void GPUCommon::UpdateVsyncInterval(bool force) {
|
||||
#ifdef _WIN32
|
||||
#if !(PPSSPP_PLATFORM(ANDROID) || USING_QT_UI || PPSSPP_PLATFORM(UWP) || PPSSPP_PLATFORM(IOS))
|
||||
int desiredVSyncInterval = g_Config.bVSync ? 1 : 0;
|
||||
if (PSP_CoreParameter().unthrottle) {
|
||||
desiredVSyncInterval = 0;
|
||||
|
@ -364,9 +364,7 @@ private:
|
||||
double timeSteppingStarted_;
|
||||
double timeSpentStepping_;
|
||||
|
||||
#ifdef _WIN32
|
||||
int lastVsync_ = -1;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct CommonCommandTableEntry {
|
||||
|
@ -56,6 +56,8 @@ public:
|
||||
renderManager_->SetInflightFrames(g_Config.iInflightFrames);
|
||||
bool success = draw_->CreatePresets();
|
||||
_assert_msg_(G3D, success, "Failed to compile preset shaders");
|
||||
|
||||
// TODO: Need to figure out how to implement SetSwapInterval for Qt.
|
||||
}
|
||||
|
||||
~QtGLGraphicsContext() {
|
||||
@ -65,7 +67,10 @@ public:
|
||||
}
|
||||
|
||||
void Shutdown() override {}
|
||||
void SwapInterval(int interval) override {}
|
||||
void SwapInterval(int interval) override {
|
||||
// See TODO in constructor.
|
||||
// renderManager_->SwapInterval(interval);
|
||||
}
|
||||
void SwapBuffers() override {}
|
||||
void Resize() override {}
|
||||
|
||||
|
@ -423,10 +423,19 @@ int SDLGLGraphicsContext::Init(SDL_Window *&window, int x, int y, int mode, std:
|
||||
SDL_GL_SwapWindow(window_);
|
||||
#endif
|
||||
});
|
||||
|
||||
renderManager_->SetSwapIntervalFunction([&](int interval) {
|
||||
ILOG("SDL SwapInterval: %d", interval);
|
||||
SDL_GL_SetSwapInterval(interval);
|
||||
});
|
||||
window_ = window;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SDLGLGraphicsContext::SwapInterval(int interval) {
|
||||
renderManager_->SwapInterval(interval);
|
||||
}
|
||||
|
||||
void SDLGLGraphicsContext::Shutdown() {
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "gfx/gl_common.h"
|
||||
#include "Common/GraphicsContext.h"
|
||||
|
||||
class SDLGLGraphicsContext : public DummyGraphicsContext {
|
||||
class SDLGLGraphicsContext : public GraphicsContext {
|
||||
public:
|
||||
SDLGLGraphicsContext() {
|
||||
}
|
||||
@ -20,6 +20,11 @@ public:
|
||||
// Do nothing, the render thread takes care of this.
|
||||
}
|
||||
|
||||
// Gets forwarded to the render thread.
|
||||
void SwapInterval(int interval) override;
|
||||
|
||||
void Resize() override {}
|
||||
|
||||
Draw::DrawContext *GetDrawContext() override {
|
||||
return draw_;
|
||||
}
|
||||
|
@ -338,7 +338,7 @@ void GameSettingsScreen::CreateViews() {
|
||||
return !g_Config.bSoftwareRendering && g_Config.iRenderingMode != FB_NON_BUFFERED_MODE;
|
||||
});
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#if PPSSPP_PLATFORM(ANDROID)
|
||||
if (System_GetPropertyInt(SYSPROP_DEVICE_TYPE) != DEVICE_TYPE_TV) {
|
||||
static const char *deviceResolutions[] = { "Native device resolution", "Auto (same as Rendering)", "1x PSP", "2x PSP", "3x PSP", "4x PSP", "5x PSP" };
|
||||
int max_res_temp = std::max(System_GetPropertyInt(SYSPROP_DISPLAY_XRES), System_GetPropertyInt(SYSPROP_DISPLAY_YRES)) / 480 + 2;
|
||||
@ -350,7 +350,7 @@ void GameSettingsScreen::CreateViews() {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !PPSSPP_PLATFORM(ANDROID)
|
||||
#if !(PPSSPP_PLATFORM(ANDROID) || defined(USING_QT_UI) || PPSSPP_PLATFORM(UWP)) || PPSSPP_PLATFORM(IOS)
|
||||
CheckBox *vSync = graphicsSettings->Add(new CheckBox(&g_Config.bVSync, gr->T("VSync")));
|
||||
vSync->OnClick.Add([=](EventParams &e) {
|
||||
NativeResized();
|
||||
|
@ -297,7 +297,6 @@ public:
|
||||
OpenGLPipeline(GLRenderManager *render) : render_(render) {
|
||||
}
|
||||
~OpenGLPipeline() {
|
||||
DLOG("OpenGLPipeline released");
|
||||
for (auto &iter : shaders) {
|
||||
iter->Release();
|
||||
}
|
||||
@ -979,7 +978,6 @@ Pipeline *OpenGLContext::CreateGraphicsPipeline(const PipelineDesc &desc) {
|
||||
pipeline->dynamicUniforms = *desc.uniformDesc;
|
||||
pipeline->dynamicUniformLocs_.resize(desc.uniformDesc->uniforms.size());
|
||||
}
|
||||
ILOG("Linking shaders.");
|
||||
if (pipeline->LinkShaders()) {
|
||||
// Build the rest of the virtual pipeline object.
|
||||
pipeline->prim = primToGL[(int)desc.prim];
|
||||
|
@ -53,7 +53,7 @@ SDL_Window *CreateHiddenWindow() {
|
||||
return SDL_CreateWindow("PPSSPPHeadless", 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, flags);
|
||||
}
|
||||
|
||||
class GLDummyGraphicsContext : public DummyGraphicsContext {
|
||||
class GLDummyGraphicsContext : public GraphicsContext {
|
||||
public:
|
||||
GLDummyGraphicsContext() {
|
||||
}
|
||||
@ -92,6 +92,11 @@ public:
|
||||
renderManager_->StopThread();
|
||||
}
|
||||
|
||||
void Shutdown() override {}
|
||||
void Resize() override {}
|
||||
void SwapInterval(int interval) override {}
|
||||
void SwapBuffers() override {}
|
||||
|
||||
private:
|
||||
Draw::DrawContext *draw_;
|
||||
GLRenderManager *renderManager_ = nullptr;
|
||||
@ -124,7 +129,7 @@ bool GLDummyGraphicsContext::InitFromRenderThread(std::string *errorMessage) {
|
||||
glContext_ = SDL_GL_CreateContext(screen_);
|
||||
|
||||
// Ensure that the swap interval is set after context creation (needed for kmsdrm)
|
||||
SDL_GL_SetSwapInterval(1);
|
||||
SDL_GL_SetSwapInterval(0);
|
||||
|
||||
#ifndef USING_GLES2
|
||||
// Some core profile drivers elide certain extensions from GL_EXTENSIONS/etc.
|
||||
|
@ -38,7 +38,7 @@
|
||||
#define IS_IPAD() ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad)
|
||||
#define IS_IPHONE() ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone)
|
||||
|
||||
class IOSGraphicsContext : public DummyGraphicsContext {
|
||||
class IOSGraphicsContext : public GraphicsContext {
|
||||
public:
|
||||
IOSGraphicsContext() {
|
||||
CheckGLExtensions();
|
||||
@ -55,6 +55,12 @@ public:
|
||||
Draw::DrawContext *GetDrawContext() override {
|
||||
return draw_;
|
||||
}
|
||||
|
||||
void SwapInterval(int interval) override {}
|
||||
void SwapBuffers() override {}
|
||||
void Resize() override {}
|
||||
void Shutdown() override {}
|
||||
|
||||
void ThreadStart() override {
|
||||
renderManager_->ThreadStart(draw_);
|
||||
}
|
||||
@ -71,6 +77,7 @@ public:
|
||||
renderManager_->WaitUntilQueueIdle();
|
||||
renderManager_->StopThread();
|
||||
}
|
||||
|
||||
private:
|
||||
Draw::DrawContext *draw_;
|
||||
GLRenderManager *renderManager_;
|
||||
|
Loading…
Reference in New Issue
Block a user