wsi: swap immediately when fast forwarding
This commit is contained in:
parent
d55a26c242
commit
3474901e58
|
@ -564,25 +564,24 @@ void VulkanContext::CreateSwapChain()
|
|||
// The FIFO present mode is guaranteed by the spec to be supported
|
||||
vk::PresentModeKHR swapchainPresentMode = vk::PresentModeKHR::eFifo;
|
||||
// Use FIFO on mobile, prefer Mailbox on desktop
|
||||
#if HOST_CPU != CPU_ARM && HOST_CPU != CPU_ARM64 && !defined(__ANDROID__)
|
||||
for (auto& presentMode : physicalDevice.getSurfacePresentModesKHR(GetSurface()))
|
||||
{
|
||||
if (presentMode == vk::PresentModeKHR::eMailbox && vendorID != VENDOR_ATI && vendorID != VENDOR_AMD)
|
||||
#if HOST_CPU != CPU_ARM && HOST_CPU != CPU_ARM64 && !defined(__ANDROID__)
|
||||
if (swapOnVSync && presentMode == vk::PresentModeKHR::eMailbox
|
||||
&& vendorID != VENDOR_ATI && vendorID != VENDOR_AMD)
|
||||
{
|
||||
INFO_LOG(RENDERER, "Using mailbox present mode");
|
||||
swapchainPresentMode = vk::PresentModeKHR::eMailbox;
|
||||
break;
|
||||
}
|
||||
#ifdef TEST_AUTOMATION
|
||||
if (presentMode == vk::PresentModeKHR::eImmediate)
|
||||
#endif
|
||||
if (!swapOnVSync && presentMode == vk::PresentModeKHR::eImmediate)
|
||||
{
|
||||
INFO_LOG(RENDERER, "Using immediate present mode");
|
||||
swapchainPresentMode = vk::PresentModeKHR::eImmediate;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
vk::SurfaceTransformFlagBitsKHR preTransform = (surfaceCapabilities.supportedTransforms & vk::SurfaceTransformFlagBitsKHR::eIdentity) ? vk::SurfaceTransformFlagBitsKHR::eIdentity : surfaceCapabilities.currentTransform;
|
||||
|
||||
|
@ -802,6 +801,13 @@ void VulkanContext::Present() noexcept
|
|||
}
|
||||
renderDone = false;
|
||||
}
|
||||
#ifndef TEST_AUTOMATION
|
||||
if (swapOnVSync == settings.input.fastForwardMode)
|
||||
{
|
||||
swapOnVSync = !settings.input.fastForwardMode;
|
||||
resized = true;
|
||||
}
|
||||
#endif
|
||||
if (resized)
|
||||
try {
|
||||
CreateSwapChain();
|
||||
|
|
|
@ -140,6 +140,11 @@ private:
|
|||
u32 width = 0;
|
||||
u32 height = 0;
|
||||
bool resized = false;
|
||||
#ifndef TEST_AUTOMATION
|
||||
bool swapOnVSync = true;
|
||||
#else
|
||||
bool swapOnVSync = false;
|
||||
#endif
|
||||
vk::UniqueInstance instance;
|
||||
vk::PhysicalDevice physicalDevice;
|
||||
|
||||
|
|
|
@ -181,7 +181,12 @@ bool EGLGraphicsContext::Init()
|
|||
#ifdef TARGET_PANDORA
|
||||
fbdev = open("/dev/fb0", O_RDONLY);
|
||||
#else
|
||||
eglSwapInterval(display, 1);
|
||||
#ifndef TEST_AUTOMATION
|
||||
swapOnVSync = true;
|
||||
#else
|
||||
swapOnVSync = false;
|
||||
#endif
|
||||
eglSwapInterval(display, (int)swapOnVSync);
|
||||
#endif
|
||||
|
||||
PostInit();
|
||||
|
@ -215,12 +220,11 @@ void EGLGraphicsContext::Swap()
|
|||
{
|
||||
#ifdef TEST_AUTOMATION
|
||||
do_swap_automation();
|
||||
#endif
|
||||
#if 0 && defined(TARGET_PANDORA)
|
||||
if (fbdev >= 0)
|
||||
#else
|
||||
if (swapOnVSync == settings.input.fastForwardMode)
|
||||
{
|
||||
int arg = 0;
|
||||
ioctl(fbdev,FBIO_WAITFORVSYNC,&arg);
|
||||
swapOnVSync = !settings.input.fastForwardMode;
|
||||
eglSwapInterval(display, (int)swapOnVSync);
|
||||
}
|
||||
#endif
|
||||
eglSwapBuffers(display, surface);
|
||||
|
|
|
@ -55,6 +55,7 @@ private:
|
|||
#ifdef TARGET_PANDORA
|
||||
int fbdev = -1;
|
||||
#endif
|
||||
bool swapOnVSync = false;
|
||||
};
|
||||
|
||||
extern EGLGraphicsContext theGLContext;
|
||||
|
|
|
@ -79,11 +79,12 @@ bool SDLGLGraphicsContext::Init()
|
|||
SDL_GL_MakeCurrent(window, glcontext);
|
||||
#ifndef TEST_AUTOMATION
|
||||
// Swap at vsync
|
||||
SDL_GL_SetSwapInterval(1);
|
||||
swapOnVSync = true;
|
||||
#else
|
||||
// Swap immediately
|
||||
SDL_GL_SetSwapInterval(0);
|
||||
swapOnVSync = false;
|
||||
#endif
|
||||
SDL_GL_SetSwapInterval((int)swapOnVSync);
|
||||
|
||||
#ifdef GLES
|
||||
load_gles_symbols();
|
||||
|
@ -103,6 +104,12 @@ void SDLGLGraphicsContext::Swap()
|
|||
{
|
||||
#ifdef TEST_AUTOMATION
|
||||
do_swap_automation();
|
||||
#else
|
||||
if (swapOnVSync == settings.input.fastForwardMode)
|
||||
{
|
||||
swapOnVSync = !settings.input.fastForwardMode;
|
||||
SDL_GL_SetSwapInterval((int)swapOnVSync);
|
||||
}
|
||||
#endif
|
||||
SDL_GL_SwapWindow(window);
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@ public:
|
|||
private:
|
||||
SDL_Window* window = nullptr;
|
||||
SDL_GLContext glcontext = nullptr;
|
||||
bool swapOnVSync = false;
|
||||
};
|
||||
|
||||
extern SDLGLGraphicsContext theGLContext;
|
||||
|
|
|
@ -82,6 +82,21 @@ bool XGLGraphicsContext::Init()
|
|||
unsigned int tempu;
|
||||
XGetGeometry(display, window, &win, &temp, &temp, (u32 *)&screen_width, (u32 *)&screen_height, &tempu, &tempu);
|
||||
|
||||
#ifndef TEST_AUTOMATION
|
||||
swapOnVSync = true;
|
||||
#else
|
||||
swapOnVSync = false;
|
||||
#endif
|
||||
glXSwapIntervalMESA = (int (*)(unsigned))glXGetProcAddress((const GLubyte*)"glXSwapIntervalMESA");
|
||||
if (glXSwapIntervalMESA != nullptr)
|
||||
glXSwapIntervalMESA((unsigned)swapOnVSync);
|
||||
else
|
||||
{
|
||||
glXSwapIntervalEXT = (PFNGLXSWAPINTERVALEXTPROC)glXGetProcAddress((const GLubyte*)"glXSwapIntervalEXT");
|
||||
if (glXSwapIntervalEXT != nullptr)
|
||||
glXSwapIntervalEXT(display, window, (int)swapOnVSync);
|
||||
}
|
||||
|
||||
PostInit();
|
||||
|
||||
return true;
|
||||
|
@ -142,32 +157,22 @@ void XGLGraphicsContext::Swap()
|
|||
{
|
||||
#ifdef TEST_AUTOMATION
|
||||
do_swap_automation();
|
||||
#else
|
||||
if (swapOnVSync == settings.input.fastForwardMode)
|
||||
{
|
||||
swapOnVSync = !settings.input.fastForwardMode;
|
||||
if (glXSwapIntervalMESA != nullptr)
|
||||
glXSwapIntervalMESA((unsigned)swapOnVSync);
|
||||
else if (glXSwapIntervalEXT != nullptr)
|
||||
glXSwapIntervalEXT(display, window, (int)swapOnVSync);
|
||||
}
|
||||
#endif
|
||||
glXSwapBuffers(display, window);
|
||||
|
||||
Window win;
|
||||
int temp;
|
||||
unsigned int tempu, new_w, new_h;
|
||||
XGetGeometry(display, window, &win, &temp, &temp, &new_w, &new_h, &tempu, &tempu);
|
||||
|
||||
//if resized, clear up the draw buffers, to avoid out-of-draw-area junk data
|
||||
if (new_w != screen_width || new_h != screen_height) {
|
||||
screen_width = new_w;
|
||||
screen_height = new_h;
|
||||
}
|
||||
|
||||
#if 0
|
||||
//handy to debug really stupid render-not-working issues ...
|
||||
|
||||
glcache.ClearColor(0, 0.5, 1, 1);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
glXSwapBuffers(display, window);
|
||||
|
||||
|
||||
glcache.ClearColor(1, 0.5, 0, 1);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
glXSwapBuffers(display, window);
|
||||
#endif
|
||||
unsigned int tempu;
|
||||
XGetGeometry(display, window, &win, &temp, &temp, (u32 *)&screen_width, (u32 *)&screen_height, &tempu, &tempu);
|
||||
}
|
||||
|
||||
void XGLGraphicsContext::Term()
|
||||
|
|
|
@ -41,6 +41,9 @@ private:
|
|||
Display *display;
|
||||
GLXContext context;
|
||||
GLXFBConfig* framebufferConfigs = nullptr;
|
||||
PFNGLXSWAPINTERVALEXTPROC glXSwapIntervalEXT = nullptr;
|
||||
int (*glXSwapIntervalMESA)(unsigned int interval) = nullptr;
|
||||
bool swapOnVSync = false;
|
||||
};
|
||||
|
||||
extern XGLGraphicsContext theGLContext;
|
||||
|
|
Loading…
Reference in New Issue