diff --git a/docs/source/about/advanced_usage.rst b/docs/source/about/advanced_usage.rst index 88e000594c9..b8e000eff5b 100644 --- a/docs/source/about/advanced_usage.rst +++ b/docs/source/about/advanced_usage.rst @@ -434,6 +434,21 @@ dwmflush dwmflush = enabled +point_filtering +^^^^^^^^^^^^^^^ + +**Description** + Enable nearest point filtering for scaling from captured screen to streamed video. + May be useful for retro games or pixel-perfect streaming to low-resolution devices (PlayStation Vita, for example). + +**Default** + ``disabled`` + +**Example** + .. code-block:: text + + point_filtering = enabled + Audio ----- diff --git a/src/config.cpp b/src/config.cpp index 6e4c93e37f5..cd254eccf44 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -379,7 +379,8 @@ namespace config { {}, // encoder {}, // adapter_name {}, // output_name - true // dwmflush + true, // dwmflush + false //point_filtering }; audio_t audio { @@ -969,6 +970,7 @@ namespace config { string_f(vars, "adapter_name", video.adapter_name); string_f(vars, "output_name", video.output_name); bool_f(vars, "dwmflush", video.dwmflush); + bool_f(vars, "point_filtering", video.point_filtering); path_f(vars, "pkey", nvhttp.pkey); path_f(vars, "cert", nvhttp.cert); diff --git a/src/config.h b/src/config.h index 2c32e7afd1b..047634fd087 100644 --- a/src/config.h +++ b/src/config.h @@ -60,6 +60,7 @@ namespace config { std::string adapter_name; std::string output_name; bool dwmflush; + bool point_filtering; }; struct audio_t { diff --git a/src/platform/linux/graphics.cpp b/src/platform/linux/graphics.cpp index a0506554bf8..59c14ecc761 100644 --- a/src/platform/linux/graphics.cpp +++ b/src/platform/linux/graphics.cpp @@ -4,6 +4,7 @@ */ #include "graphics.h" #include "src/video.h" +#include "src/config.h" #include @@ -48,13 +49,19 @@ namespace gl { ctx.GenTextures(textures.size(), textures.begin()); float color[] = { 0.0f, 0.0f, 0.0f, 1.0f }; + + GLint filtering = GL_LINEAR; + if (config::video.point_filtering) + { + filtering = GL_POINT; + } for (auto tex : textures) { gl::ctx.BindTexture(GL_TEXTURE_2D, tex); gl::ctx.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); // x gl::ctx.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); // y - gl::ctx.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - gl::ctx.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + gl::ctx.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filtering); + gl::ctx.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filtering); gl::ctx.TexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, color); } diff --git a/src/platform/windows/display_vram.cpp b/src/platform/windows/display_vram.cpp index 4519243a1af..b3bb25b5fd1 100644 --- a/src/platform/windows/display_vram.cpp +++ b/src/platform/windows/display_vram.cpp @@ -18,6 +18,7 @@ extern "C" { #include "misc.h" #include "src/main.h" #include "src/video.h" +#include "src/config.h" #define SUNSHINE_SHADERS_DIR SUNSHINE_ASSETS_DIR "/shaders/directx" namespace platf { @@ -695,8 +696,14 @@ namespace platf::dxgi { return -1; } + D3D11_FILTER filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR; + if (config::video.point_filtering) + { + filter = D3D11_FILTER_MIN_MAG_MIP_POINT; + } + D3D11_SAMPLER_DESC sampler_desc {}; - sampler_desc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR; + sampler_desc.Filter = filter; sampler_desc.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP; sampler_desc.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP; sampler_desc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP; @@ -1263,8 +1270,14 @@ namespace platf::dxgi { return -1; } + D3D11_FILTER filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR; + if (config::video.point_filtering) + { + filter = D3D11_FILTER_MIN_MAG_MIP_POINT; + } + D3D11_SAMPLER_DESC sampler_desc {}; - sampler_desc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR; + sampler_desc.Filter = filter; sampler_desc.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP; sampler_desc.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP; sampler_desc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP; diff --git a/src_assets/common/assets/web/config.html b/src_assets/common/assets/web/config.html index 489398fc58c..34c164d0a8d 100644 --- a/src_assets/common/assets/web/config.html +++ b/src_assets/common/assets/web/config.html @@ -594,6 +594,17 @@

Configuration

Disable if you encounter any VSync-related issues. +
+ + +
+ Enable this to not interpolate captured screen to video size.
+ May be useful for pixel-perfect streaming. +
+
Configuration "controller": "enabled", "install_steam_audio_drivers": "enabled", "dwmflush": "enabled", + "point_filtering": "enabled", "encoder": "", "fps": "[10,30,60,90,120]", "gamepad": "auto",