shithub: choc

Download patch

ref: 8bc6097e992bfd4122614b9f9d63611b730e01ce
parent: 3f45e0c828e6df45b91451fcebba8f5f611b2b28
author: Simon Howard <fraggle@soulsphere.org>
date: Sun Feb 5 13:06:51 EST 2017

video: Add config variable for texture pixel limit.

We use an intermediate texture for scaling up the screen accurately and
limit this to 1600x1200, but for very high resolution displays there can
be some slight blurriness around pixels when they are examined closely.
So provide the ability to override this and use even more memory if
desired.

Thanks to Linguica for the report. This fixes #859.

--- a/src/i_video.c
+++ b/src/i_video.c
@@ -114,6 +114,10 @@
 
 int fullscreen_width = 0, fullscreen_height = 0;
 
+// Maximum number of pixels to use for intermediate scale buffer.
+
+static int max_scaling_buffer_pixels = 1600 * 1200;
+
 // Run in full screen mode?  (int type for config code)
 
 int fullscreen = true;
@@ -587,16 +591,29 @@
         h_upscale = 1;
     }
 
-    // Limit maximum texture dimensions to 1600x1200.
-    // It's really diminishing returns at this point.
+    // We limit the amount of texture memory used for the intermediate buffer.
+    // By default we limit to 1600x1200, which gives pretty good results, but
+    // we allow the user to override this and use more if they want to use
+    // even more (or less, if their graphics card can't handle it).
 
-    if (w_upscale * SCREENWIDTH > 1600)
+    if (max_scaling_buffer_pixels < SCREENWIDTH * SCREENHEIGHT)
     {
-        w_upscale = 1600 / SCREENWIDTH;
+        I_Error("CreateUpscaledTexture: max_scaling_buffer_pixels too small "
+                "to create a texture buffer: %d < %d",
+                max_scaling_buffer_pixels, SCREENWIDTH * SCREENHEIGHT);
     }
-    if (h_upscale * SCREENHEIGHT > 1200)
+
+    while (w_upscale * h_upscale * SCREENWIDTH * SCREENHEIGHT
+           > max_scaling_buffer_pixels)
     {
-        h_upscale = 1200 / SCREENHEIGHT;
+        if (w_upscale > h_upscale)
+        {
+            --w_upscale;
+        }
+        else
+        {
+            --h_upscale;
+        }
     }
 
     // Create a new texture only if the upscale factors have actually changed.
@@ -1334,6 +1351,7 @@
     M_BindIntVariable("fullscreen_width",          &fullscreen_width);
     M_BindIntVariable("fullscreen_height",         &fullscreen_height);
     M_BindIntVariable("force_software_renderer",   &force_software_renderer);
+    M_BindIntVariable("max_scaling_buffer_pixels", &max_scaling_buffer_pixels);
     M_BindIntVariable("window_width",              &window_width);
     M_BindIntVariable("window_height",             &window_height);
     M_BindIntVariable("grabmouse",                 &grabmouse);
--- a/src/m_config.c
+++ b/src/m_config.c
@@ -764,6 +764,14 @@
     CONFIG_VARIABLE_INT(force_software_renderer),
 
     //!
+    // Maximum number of pixels to use for intermediate scaling buffer.
+    // More pixels mean that the screen can be rendered more precisely,
+    // but there are diminishing returns on quality. The default limits
+    // to a 1600x1200 buffer.
+
+    CONFIG_VARIABLE_INT(max_scaling_buffer_pixels),
+
+    //!
     // Number of milliseconds to wait on startup after the video mode
     // has been set, before the game will start.  This allows the
     // screen to settle on some monitors that do not display an image
--- a/src/setup/display.c
+++ b/src/setup/display.c
@@ -71,6 +71,7 @@
 static int fullscreen_width = 0, fullscreen_height = 0;
 static int window_width = 640, window_height = 480;
 static int startup_delay = 1000;
+static int max_scaling_buffer_pixels = 1600 * 1200;
 static int usegamma = 0;
 
 int graphical_startup = 1;
@@ -260,6 +261,7 @@
     M_BindIntVariable("usegamma",                  &usegamma);
     M_BindIntVariable("png_screenshots",           &png_screenshots);
     M_BindIntVariable("force_software_renderer",   &force_software_renderer);
+    M_BindIntVariable("max_scaling_buffer_pixels", &max_scaling_buffer_pixels);
 
     if (gamemission == doom || gamemission == heretic
      || gamemission == strife)