From 089104f677d8cfba6c917282de70711441151d67 Mon Sep 17 00:00:00 2001 From: Artem Kharytoniuk Date: Sat, 7 Oct 2017 18:02:36 +0300 Subject: [PATCH] Fixed Vulkan issue when attachment size does not match framebuffer size. The main part of the fix is to specify app's DPI awareness. It is done by specifying Windows DPI awareness in manifest file. Additionally the test was added to ensure that selected r_mode does not exceed current desktop size. --- src/engine/platform/win_glimp.c | 16 ++++++++++++++++ visual-studio/DeclareDPIAware.manifest | 7 +++++++ visual-studio/quake3.vcxproj | 6 ++++++ 3 files changed, 29 insertions(+) create mode 100644 visual-studio/DeclareDPIAware.manifest diff --git a/src/engine/platform/win_glimp.c b/src/engine/platform/win_glimp.c index 9198926..de18871 100644 --- a/src/engine/platform/win_glimp.c +++ b/src/engine/platform/win_glimp.c @@ -538,6 +538,22 @@ static void SetMode(int mode, qboolean fullscreen) { ri.Printf( PRINT_ALL, " invalid mode\n" ); ri.Error(ERR_FATAL, "SetMode - could not set the given mode (%d)\n", mode); } + + // Ensure that window size does not exceed desktop size. + // CreateWindow Win32 API does not allow to create windows larger than desktop. + int desktop_width = GetDesktopWidth(); + int desktop_height = GetDesktopHeight(); + + if (glConfig.vidWidth > desktop_width || glConfig.vidHeight > desktop_height) { + int default_mode = 4; + ri.Printf(PRINT_WARNING, "\nMode %d specifies width that is larger than desktop width: using default mode %d\n", mode, default_mode); + + ri.Printf( PRINT_ALL, "...setting mode %d:", default_mode ); + if (!R_GetModeInfo(&glConfig.vidWidth, &glConfig.vidHeight, &glConfig.windowAspect, default_mode)) { + ri.Printf( PRINT_ALL, " invalid mode\n" ); + ri.Error(ERR_FATAL, "SetMode - could not set the given mode (%d)\n", default_mode); + } + } } glConfig.isFullscreen = fullscreen; ri.Printf( PRINT_ALL, " %d %d %s\n", glConfig.vidWidth, glConfig.vidHeight, fullscreen ? "FS" : "W"); diff --git a/visual-studio/DeclareDPIAware.manifest b/visual-studio/DeclareDPIAware.manifest new file mode 100644 index 0000000..4b4b3e7 --- /dev/null +++ b/visual-studio/DeclareDPIAware.manifest @@ -0,0 +1,7 @@ + + + + true/pm + + + diff --git a/visual-studio/quake3.vcxproj b/visual-studio/quake3.vcxproj index 0a20894..1c08b83 100644 --- a/visual-studio/quake3.vcxproj +++ b/visual-studio/quake3.vcxproj @@ -91,6 +91,9 @@ + + DeclareDPIAware.manifest + @@ -127,6 +130,9 @@ + + DeclareDPIAware.manifest +