From 1ad39cb5dd52e87c4b00b17456a1dcdbb89e74d7 Mon Sep 17 00:00:00 2001 From: MooglyGuy Date: Sun, 13 Mar 2022 02:30:02 +0100 Subject: -bgfx: Added default LUT PNG, fixes LUT-effect crash. Fixed external texture loading, restoring HQx filters. [Ryan Holtz] (#9401) --- artwork/lut-default.png | Bin 0 -> 491596 bytes bgfx/effects/misc/lut.json | 13 ++++--------- bgfx/shaders/dx11/chains/misc/fs_lut.bin | Bin 830 -> 954 bytes bgfx/shaders/dx9/chains/misc/fs_lut.bin | Bin 513 -> 665 bytes bgfx/shaders/essl/chains/misc/fs_lut.bin | Bin 840 -> 1050 bytes bgfx/shaders/glsl/chains/misc/fs_lut.bin | Bin 798 -> 990 bytes bgfx/shaders/metal/chains/misc/fs_lut.bin | Bin 1197 -> 1434 bytes bgfx/shaders/spirv/chains/misc/fs_lut.bin | Bin 1872 -> 2464 bytes src/osd/modules/lib/osdobj_common.cpp | 2 +- .../modules/render/bgfx/shaders/chains/misc/fs_lut.sc | 13 ++++++------- src/osd/modules/render/bgfx/texturemanager.cpp | 2 +- src/osd/windows/winmain.cpp | 4 ++-- 12 files changed, 14 insertions(+), 20 deletions(-) create mode 100644 artwork/lut-default.png diff --git a/artwork/lut-default.png b/artwork/lut-default.png new file mode 100644 index 00000000000..7c82396f7eb Binary files /dev/null and b/artwork/lut-default.png differ diff --git a/bgfx/effects/misc/lut.json b/bgfx/effects/misc/lut.json index eda8224ec2a..a1c3c0d0d22 100644 --- a/bgfx/effects/misc/lut.json +++ b/bgfx/effects/misc/lut.json @@ -19,14 +19,9 @@ "vertex": "chains/misc/vs_lut", "fragment": "chains/misc/fs_lut", "uniforms": [ - { - "name": "s_tex", - "type": "int", - "values": [ 1.0 ] - }, { - "name": "s_3dlut", - "type": "int", - "values": [ 1.0 ] - } + { "name": "s_tex", "type": "int", "values": [ 1.0 ] }, + { "name": "s_3dlut", "type": "int", "values": [ 1.0 ] }, + { "name": "u_tex_size1", "type": "vec4", "values": [ 1.0, 1.0, 0.0, 0.0 ] }, + { "name": "u_inv_tex_size1", "type": "vec4", "values": [ 1.0, 1.0, 0.0, 0.0 ] } ] } diff --git a/bgfx/shaders/dx11/chains/misc/fs_lut.bin b/bgfx/shaders/dx11/chains/misc/fs_lut.bin index 6aa1e00e450..2172681ea9f 100644 Binary files a/bgfx/shaders/dx11/chains/misc/fs_lut.bin and b/bgfx/shaders/dx11/chains/misc/fs_lut.bin differ diff --git a/bgfx/shaders/dx9/chains/misc/fs_lut.bin b/bgfx/shaders/dx9/chains/misc/fs_lut.bin index 4ad181dc43a..fe815923543 100644 Binary files a/bgfx/shaders/dx9/chains/misc/fs_lut.bin and b/bgfx/shaders/dx9/chains/misc/fs_lut.bin differ diff --git a/bgfx/shaders/essl/chains/misc/fs_lut.bin b/bgfx/shaders/essl/chains/misc/fs_lut.bin index fdbb338c0b5..28e0619e2b3 100644 Binary files a/bgfx/shaders/essl/chains/misc/fs_lut.bin and b/bgfx/shaders/essl/chains/misc/fs_lut.bin differ diff --git a/bgfx/shaders/glsl/chains/misc/fs_lut.bin b/bgfx/shaders/glsl/chains/misc/fs_lut.bin index cf06257c601..a2dc6945636 100644 Binary files a/bgfx/shaders/glsl/chains/misc/fs_lut.bin and b/bgfx/shaders/glsl/chains/misc/fs_lut.bin differ diff --git a/bgfx/shaders/metal/chains/misc/fs_lut.bin b/bgfx/shaders/metal/chains/misc/fs_lut.bin index 813a12048e0..8a52d38f700 100644 Binary files a/bgfx/shaders/metal/chains/misc/fs_lut.bin and b/bgfx/shaders/metal/chains/misc/fs_lut.bin differ diff --git a/bgfx/shaders/spirv/chains/misc/fs_lut.bin b/bgfx/shaders/spirv/chains/misc/fs_lut.bin index b8e051b650d..ccf2f5b8380 100644 Binary files a/bgfx/shaders/spirv/chains/misc/fs_lut.bin and b/bgfx/shaders/spirv/chains/misc/fs_lut.bin differ diff --git a/src/osd/modules/lib/osdobj_common.cpp b/src/osd/modules/lib/osdobj_common.cpp index be06da29767..52ddca76ca0 100644 --- a/src/osd/modules/lib/osdobj_common.cpp +++ b/src/osd/modules/lib/osdobj_common.cpp @@ -159,7 +159,7 @@ const options_entry osd_options::s_option_entries[] = { OSDOPTION_BGFX_DEBUG, "0", OPTION_BOOLEAN, "enable BGFX debugging statistics" }, { OSDOPTION_BGFX_SCREEN_CHAINS, "default", OPTION_STRING, "comma-delimited list of screen chain JSON names, colon-delimited per-window" }, { OSDOPTION_BGFX_SHADOW_MASK, "slot-mask.png", OPTION_STRING, "shadow mask texture name" }, - { OSDOPTION_BGFX_LUT, "", OPTION_STRING, "LUT texture name" }, + { OSDOPTION_BGFX_LUT, "lut-default.png", OPTION_STRING, "LUT texture name" }, { OSDOPTION_BGFX_AVI_NAME, OSDOPTVAL_AUTO, OPTION_STRING, "filename for BGFX output logging" }, // End of list diff --git a/src/osd/modules/render/bgfx/shaders/chains/misc/fs_lut.sc b/src/osd/modules/render/bgfx/shaders/chains/misc/fs_lut.sc index 2c8cffab7e1..6b00e4a1934 100644 --- a/src/osd/modules/render/bgfx/shaders/chains/misc/fs_lut.sc +++ b/src/osd/modules/render/bgfx/shaders/chains/misc/fs_lut.sc @@ -5,9 +5,9 @@ $input v_color0, v_texcoord0 #include "common.sh" -#define LUT_TEXTURE_WIDTH 4096.0f -#define LUT_SIZE 64.0f -#define LUT_SCALE vec2(1.0f / LUT_TEXTURE_WIDTH, 1.0f / LUT_SIZE) +// Autos +uniform vec4 u_tex_size1; +uniform vec4 u_inv_tex_size1; SAMPLER2D(s_tex, 0); SAMPLER2D(s_3dlut, 1); @@ -17,13 +17,12 @@ void main() vec4 bp = texture2D(s_tex, v_texcoord0); vec3 color = bp.rgb; // NOTE: Do not change the order of parameters here. - vec3 lutcoord = vec3(color.rg * ((LUT_SIZE - 1.0f) + 0.5f) * - LUT_SCALE, (LUT_SIZE - 1.0f) * color.b); + vec3 lutcoord = vec3(color.rg * ((u_tex_size1.y - 1.0) + 0.5) * u_inv_tex_size1.xy, (u_tex_size1.y - 1.0) * color.b); float shift = floor(lutcoord.z); - lutcoord.x += shift * LUT_SCALE.y; + lutcoord.x += shift * u_inv_tex_size1.y; color.rgb = mix(texture2D(s_3dlut, lutcoord.xy).rgb, - texture2D(s_3dlut, vec2(lutcoord.x + LUT_SCALE.y, + texture2D(s_3dlut, vec2(lutcoord.x + u_inv_tex_size1.y, lutcoord.y)).rgb, lutcoord.z - shift); gl_FragColor = vec4(color, bp.a) * v_color0; } diff --git a/src/osd/modules/render/bgfx/texturemanager.cpp b/src/osd/modules/render/bgfx/texturemanager.cpp index a61d77c9177..25512c14e5d 100644 --- a/src/osd/modules/render/bgfx/texturemanager.cpp +++ b/src/osd/modules/render/bgfx/texturemanager.cpp @@ -81,7 +81,7 @@ bgfx_texture* texture_manager::create_png_texture(std::string path, std::string auto* base = reinterpret_cast(bitmap.raw_pixptr(0)); for (int y = 0; y < height; y++) { - copy_util::copyline_argb32(data32 + y * width, base + y * rowpixels, width, nullptr); + copy_util::copyline_argb32_to_bgra(data32 + y * width, base + y * rowpixels, width, nullptr); } if (screen >= 0) diff --git a/src/osd/windows/winmain.cpp b/src/osd/windows/winmain.cpp index ba66380f71e..77eeeaf476e 100644 --- a/src/osd/windows/winmain.cpp +++ b/src/osd/windows/winmain.cpp @@ -262,9 +262,9 @@ const options_entry windows_options::s_option_entries[] = { WINOPTION_BLOOM_LEVEL6_WEIGHT, "0.04", OPTION_FLOAT, "bloom level 6 weight (1/4 smaller that level 5 target)" }, { WINOPTION_BLOOM_LEVEL7_WEIGHT, "0.02", OPTION_FLOAT, "bloom level 7 weight (1/4 smaller that level 6 target)" }, { WINOPTION_BLOOM_LEVEL8_WEIGHT, "0.01", OPTION_FLOAT, "bloom level 8 weight (1/4 smaller that level 7 target)" }, - { WINOPTION_LUT_TEXTURE, "", OPTION_STRING, "3D LUT texture filename for screen, PNG format" }, + { WINOPTION_LUT_TEXTURE, "lut-default.png", OPTION_STRING, "3D LUT texture filename for screen, PNG format" }, { WINOPTION_LUT_ENABLE, "0", OPTION_BOOLEAN, "Enables 3D LUT to be applied to screen after post-processing" }, - { WINOPTION_UI_LUT_TEXTURE, "", OPTION_STRING, "3D LUT texture filename of UI, PNG format" }, + { WINOPTION_UI_LUT_TEXTURE, "lut-default.png", OPTION_STRING, "3D LUT texture filename of UI, PNG format" }, { WINOPTION_UI_LUT_ENABLE, "0", OPTION_BOOLEAN, "enable 3D LUT to be applied to UI and artwork after post-processing" }, // full screen options -- cgit v1.2.3