From 687e212dfe4fd9d9eb565110d3143b7f83c122a7 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sat, 20 Jan 2024 02:14:36 +1000 Subject: [PATCH] GPU/HW: Shader compile fix --- src/core/gpu_hw_shadergen.cpp | 16 +++++++++------- src/duckstation-qt/enhancementsettingswidget.cpp | 1 + 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/core/gpu_hw_shadergen.cpp b/src/core/gpu_hw_shadergen.cpp index 398592ed7..994f23784 100644 --- a/src/core/gpu_hw_shadergen.cpp +++ b/src/core/gpu_hw_shadergen.cpp @@ -774,16 +774,18 @@ float4 SampleFromVRAM(uint4 texpage, float2 coords) // From https://alex.vlachos.com/graphics/Alex_Vlachos_Advanced_VR_Rendering_GDC2015.pdf // and https://www.shadertoy.com/view/MslGR8 (5th one starting from the bottom) // NOTE: `frag_coord` is in pixels (i.e. not normalized UV). -float3 ApplyDebanding(float2 frag_coord) { +float3 ApplyDebanding(float2 frag_coord) +{ #if DEBANDING - // Iestyn's RGB dither (7 asm instructions) from Portal 2 X360, slightly modified for VR. - float3 dither = float3(dot(vec2(171.0, 231.0), frag_coord)); - dither.rgb = fract(dither.rgb / float3(103.0, 71.0, 97.0)); + // Iestyn's RGB dither (7 asm instructions) from Portal 2 X360, slightly modified for VR. + float ditherc = dot(vec2(171.0, 231.0), frag_coord); + float3 dither = float3(ditherc, ditherc, ditherc); + dither = fract(dither / float3(103.0, 71.0, 97.0)); - // Subtract 0.5 to avoid slightly brightening the whole viewport. - return (dither.rgb - 0.5) / 255.0; + // Subtract 0.5 to avoid slightly brightening the whole viewport. + return (dither - 0.5) / 255.0; #else - return float3(0.0); + return float3(0.0, 0.0, 0.0); #endif } )"; diff --git a/src/duckstation-qt/enhancementsettingswidget.cpp b/src/duckstation-qt/enhancementsettingswidget.cpp index c6594b22c..fcc6a0717 100644 --- a/src/duckstation-qt/enhancementsettingswidget.cpp +++ b/src/duckstation-qt/enhancementsettingswidget.cpp @@ -22,6 +22,7 @@ EnhancementSettingsWidget::EnhancementSettingsWidget(SettingsWindow* dialog, QWi Settings::DEFAULT_GPU_DOWNSAMPLE_MODE); SettingWidgetBinder::BindWidgetToIntSetting(sif, m_ui.gpuDownsampleScale, "GPU", "DownsampleScale", 1); SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.trueColor, "GPU", "TrueColor", false); + SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.debanding, "GPU", "Debanding", false); SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.scaledDithering, "GPU", "ScaledDithering", false); SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.disableInterlacing, "GPU", "DisableInterlacing", true); SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.forceNTSCTimings, "GPU", "ForceNTSCTimings", false);