Skip to content

Commit

Permalink
Fixed Vulkan issue when attachment size does not match framebuffer size.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kennyalive committed Oct 7, 2017
1 parent 3644533 commit 089104f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/engine/platform/win_glimp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
7 changes: 7 additions & 0 deletions visual-studio/DeclareDPIAware.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" >
<asmv3:application>
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
<dpiAware>true/pm</dpiAware>
</asmv3:windowsSettings>
</asmv3:application>
</assembly>
6 changes: 6 additions & 0 deletions visual-studio/quake3.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@
</OutputFile>
</Bscmake>
<PostBuildEvent />
<Manifest>
<AdditionalManifestFiles>DeclareDPIAware.manifest</AdditionalManifestFiles>
</Manifest>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Midl>
Expand Down Expand Up @@ -127,6 +130,9 @@
<OutputFile>
</OutputFile>
</Bscmake>
<Manifest>
<AdditionalManifestFiles>DeclareDPIAware.manifest</AdditionalManifestFiles>
</Manifest>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\src\engine\server\sv_bot.c">
Expand Down

0 comments on commit 089104f

Please sign in to comment.