summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author therealmogminer@gmail.com <therealmogminer@gmail.com>2016-03-23 15:11:12 +0100
committer therealmogminer@gmail.com <therealmogminer@gmail.com>2016-03-23 15:11:12 +0100
commit9f48ad4fbb303d9ac7ca50a8b6f9e68739227f49 (patch)
tree11a933b642d6b815089cdbce5569734d0a970c40
parent5fa870ccee2dfd5c803d3fc2533a379f2ea19b18 (diff)
Add screen-specific shader chain support, nw
-rw-r--r--bgfx/effects/defocus.json2
-rw-r--r--bgfx/effects/distortion.json19
-rw-r--r--bgfx/shaders/dx11/fs_blit.binbin40856 -> 42904 bytes
-rw-r--r--bgfx/shaders/dx11/fs_color.binbin43257 -> 45305 bytes
-rw-r--r--bgfx/shaders/dx11/fs_deconverge.binbin41060 -> 43108 bytes
-rw-r--r--bgfx/shaders/dx11/fs_defocus.binbin45804 -> 49898 bytes
-rw-r--r--bgfx/shaders/dx11/fs_distortion.binbin56045 -> 60482 bytes
-rw-r--r--bgfx/shaders/dx11/fs_gui.binbin40856 -> 42904 bytes
-rw-r--r--bgfx/shaders/dx11/fs_ntsc_decode.binbin58919 -> 60967 bytes
-rw-r--r--bgfx/shaders/dx11/fs_ntsc_encode.binbin48331 -> 50379 bytes
-rw-r--r--bgfx/shaders/dx11/fs_phosphor.binbin41094 -> 45190 bytes
-rw-r--r--bgfx/shaders/dx11/fs_post.binbin55640 -> 57688 bytes
-rw-r--r--bgfx/shaders/dx11/fs_screen.binbin40856 -> 42904 bytes
-rw-r--r--bgfx/shaders/dx11/vs_blit.binbin38987 -> 43083 bytes
-rw-r--r--bgfx/shaders/dx11/vs_color.binbin38987 -> 43083 bytes
-rw-r--r--bgfx/shaders/dx11/vs_deconverge.binbin43788 -> 45836 bytes
-rw-r--r--bgfx/shaders/dx11/vs_defocus.binbin38987 -> 43083 bytes
-rw-r--r--bgfx/shaders/dx11/vs_distortion.binbin38987 -> 43083 bytes
-rw-r--r--bgfx/shaders/dx11/vs_gui.binbin38987 -> 43083 bytes
-rw-r--r--bgfx/shaders/dx11/vs_ntsc_decode.binbin38987 -> 43083 bytes
-rw-r--r--bgfx/shaders/dx11/vs_ntsc_encode.binbin38987 -> 43083 bytes
-rw-r--r--bgfx/shaders/dx11/vs_phosphor.binbin38987 -> 43083 bytes
-rw-r--r--bgfx/shaders/dx11/vs_post.binbin41216 -> 43264 bytes
-rw-r--r--bgfx/shaders/dx11/vs_screen.binbin38987 -> 43083 bytes
-rw-r--r--bgfx/shaders/dx9/fs_blit.binbin605 -> 613 bytes
-rw-r--r--bgfx/shaders/dx9/fs_color.binbin1466 -> 1474 bytes
-rw-r--r--bgfx/shaders/dx9/fs_deconverge.binbin1009 -> 1017 bytes
-rw-r--r--bgfx/shaders/dx9/fs_defocus.binbin1805 -> 1807 bytes
-rw-r--r--bgfx/shaders/dx9/fs_distortion.binbin4874 -> 5447 bytes
-rw-r--r--bgfx/shaders/dx9/fs_gui.binbin605 -> 613 bytes
-rw-r--r--bgfx/shaders/dx9/fs_ntsc_decode.binbin7456 -> 7464 bytes
-rw-r--r--bgfx/shaders/dx9/fs_ntsc_encode.binbin3520 -> 3528 bytes
-rw-r--r--bgfx/shaders/dx9/fs_phosphor.binbin975 -> 983 bytes
-rw-r--r--bgfx/shaders/dx9/fs_post.binbin4637 -> 4645 bytes
-rw-r--r--bgfx/shaders/dx9/fs_screen.binbin605 -> 613 bytes
-rw-r--r--bgfx/shaders/dx9/vs_blit.binbin886 -> 894 bytes
-rw-r--r--bgfx/shaders/dx9/vs_color.binbin886 -> 894 bytes
-rw-r--r--bgfx/shaders/dx9/vs_deconverge.binbin1791 -> 1799 bytes
-rw-r--r--bgfx/shaders/dx9/vs_defocus.binbin890 -> 898 bytes
-rw-r--r--bgfx/shaders/dx9/vs_distortion.binbin890 -> 898 bytes
-rw-r--r--bgfx/shaders/dx9/vs_gui.binbin886 -> 894 bytes
-rw-r--r--bgfx/shaders/dx9/vs_ntsc_decode.binbin894 -> 902 bytes
-rw-r--r--bgfx/shaders/dx9/vs_ntsc_encode.binbin894 -> 902 bytes
-rw-r--r--bgfx/shaders/dx9/vs_phosphor.binbin890 -> 898 bytes
-rw-r--r--bgfx/shaders/dx9/vs_post.binbin1163 -> 1171 bytes
-rw-r--r--bgfx/shaders/dx9/vs_screen.binbin886 -> 894 bytes
-rw-r--r--bgfx/shaders/gles/fs_defocus.binbin1057 -> 1051 bytes
-rw-r--r--bgfx/shaders/gles/fs_distortion.binbin3904 -> 5160 bytes
-rw-r--r--bgfx/shaders/glsl/fs_defocus.binbin1022 -> 1016 bytes
-rw-r--r--bgfx/shaders/glsl/fs_distortion.binbin3725 -> 4921 bytes
-rw-r--r--bgfx/shaders/metal/fs_defocus.binbin2295 -> 2291 bytes
-rw-r--r--bgfx/shaders/metal/fs_distortion.binbin4313 -> 5557 bytes
-rw-r--r--src/osd/modules/lib/osdobj_common.cpp2
-rw-r--r--src/osd/modules/lib/osdobj_common.h4
-rw-r--r--src/osd/modules/render/bgfx/chainentry.cpp35
-rw-r--r--src/osd/modules/render/bgfx/chainentry.h11
-rw-r--r--src/osd/modules/render/bgfx/chainentryreader.cpp5
-rw-r--r--src/osd/modules/render/bgfx/effectmanager.cpp24
-rw-r--r--src/osd/modules/render/bgfx/effectreader.cpp7
-rw-r--r--src/osd/modules/render/bgfx/fs_defocus.sc6
-rw-r--r--src/osd/modules/render/bgfx/fs_distortion.sc75
-rw-r--r--src/osd/modules/render/bgfx/inputpair.cpp15
-rw-r--r--src/osd/modules/render/drawbgfx.cpp122
-rw-r--r--src/osd/modules/render/drawbgfx.h7
64 files changed, 219 insertions, 115 deletions
diff --git a/bgfx/effects/defocus.json b/bgfx/effects/defocus.json
index 364283f9f48..4c14ae05d76 100644
--- a/bgfx/effects/defocus.json
+++ b/bgfx/effects/defocus.json
@@ -18,7 +18,7 @@
"fragment": "fs_defocus",
"uniforms": [
{ "name": "s_tex", "type": "int", "values": [ 1.0 ] },
- { "name": "u_screen_dims", "type": "vec4", "values": [ 1.0, 0.0, 0.0, 0.0 ] },
+ { "name": "u_tex_size0", "type": "vec4", "values": [ 1.0, 0.0, 0.0, 0.0 ] },
{ "name": "u_defocus", "type": "vec4", "values": [ 0.5, 0.5, 0.0, 0.0 ] }
]
} \ No newline at end of file
diff --git a/bgfx/effects/distortion.json b/bgfx/effects/distortion.json
index de216b397b2..13de69a40f6 100644
--- a/bgfx/effects/distortion.json
+++ b/bgfx/effects/distortion.json
@@ -17,13 +17,16 @@
"vertex": "vs_distortion",
"fragment": "fs_distortion",
"uniforms": [
- { "name": "s_tex", "type": "int", "values": [ 0.0 ] },
- { "name": "u_screen_dims", "type": "vec4", "values": [ 1.0, 1.0, 0.0, 0.0 ] },
- { "name": "u_curvature", "type": "vec4", "values": [ 0.25, 0.0, 0.0, 0.0 ] },
- { "name": "u_round_corner", "type": "vec4", "values": [ 0.2, 0.0, 0.0, 0.0 ] },
- { "name": "u_smooth_border", "type": "vec4", "values": [ 0.05, 0.0, 0.0, 0.0 ] },
- { "name": "u_vignetting", "type": "vec4", "values": [ 0.20, 0.0, 0.0, 0.0 ] },
- { "name": "u_reflection", "type": "vec4", "values": [ 0.30, 0.0, 0.0, 0.0 ] },
- { "name": "u_rotation_type", "type": "vec4", "values": [ 0.0, 0.0, 0.0, 0.0 ] }
+ { "name": "s_tex", "type": "int", "values": [ 0.0 ] },
+ { "name": "u_swap_xy", "type": "vec4", "values": [ 0.0, 0.0, 0.0, 0.0 ] },
+ { "name": "u_screen_dims", "type": "vec4", "values": [ 1.0, 1.0, 0.0, 0.0 ] },
+ { "name": "u_quad_dims", "type": "vec4", "values": [ 1.0, 1.0, 0.0, 0.0 ] },
+ { "name": "u_rotation_type", "type": "vec4", "values": [ 0.0, 0.0, 0.0, 0.0 ] },
+ { "name": "u_prepare_vector", "type": "vec4", "values": [ 0.0, 0.0, 0.0, 0.0 ] },
+ { "name": "u_curvature", "type": "vec4", "values": [ 0.25, 0.0, 0.0, 0.0 ] },
+ { "name": "u_round_corner", "type": "vec4", "values": [ 0.2, 0.0, 0.0, 0.0 ] },
+ { "name": "u_smooth_border", "type": "vec4", "values": [ 0.05, 0.0, 0.0, 0.0 ] },
+ { "name": "u_vignetting", "type": "vec4", "values": [ 0.20, 0.0, 0.0, 0.0 ] },
+ { "name": "u_reflection", "type": "vec4", "values": [ 0.30, 0.0, 0.0, 0.0 ] }
]
} \ No newline at end of file
diff --git a/bgfx/shaders/dx11/fs_blit.bin b/bgfx/shaders/dx11/fs_blit.bin
index 9b82df8d3bc..9aa3ecb3227 100644
--- a/bgfx/shaders/dx11/fs_blit.bin
+++ b/bgfx/shaders/dx11/fs_blit.bin
Binary files differ
diff --git a/bgfx/shaders/dx11/fs_color.bin b/bgfx/shaders/dx11/fs_color.bin
index 388dd403690..aa3b9a2687a 100644
--- a/bgfx/shaders/dx11/fs_color.bin
+++ b/bgfx/shaders/dx11/fs_color.bin
Binary files differ
diff --git a/bgfx/shaders/dx11/fs_deconverge.bin b/bgfx/shaders/dx11/fs_deconverge.bin
index 7f114eb40de..3af60d5f943 100644
--- a/bgfx/shaders/dx11/fs_deconverge.bin
+++ b/bgfx/shaders/dx11/fs_deconverge.bin
Binary files differ
diff --git a/bgfx/shaders/dx11/fs_defocus.bin b/bgfx/shaders/dx11/fs_defocus.bin
index 2b62ecfea50..ffc56866624 100644
--- a/bgfx/shaders/dx11/fs_defocus.bin
+++ b/bgfx/shaders/dx11/fs_defocus.bin
Binary files differ
diff --git a/bgfx/shaders/dx11/fs_distortion.bin b/bgfx/shaders/dx11/fs_distortion.bin
index 8bb9b1d8de9..f416e039385 100644
--- a/bgfx/shaders/dx11/fs_distortion.bin
+++ b/bgfx/shaders/dx11/fs_distortion.bin
Binary files differ
diff --git a/bgfx/shaders/dx11/fs_gui.bin b/bgfx/shaders/dx11/fs_gui.bin
index 7091eac73e3..fcb14803035 100644
--- a/bgfx/shaders/dx11/fs_gui.bin
+++ b/bgfx/shaders/dx11/fs_gui.bin
Binary files differ
diff --git a/bgfx/shaders/dx11/fs_ntsc_decode.bin b/bgfx/shaders/dx11/fs_ntsc_decode.bin
index 8ba3903ec0a..1c9cf8feb54 100644
--- a/bgfx/shaders/dx11/fs_ntsc_decode.bin
+++ b/bgfx/shaders/dx11/fs_ntsc_decode.bin
Binary files differ
diff --git a/bgfx/shaders/dx11/fs_ntsc_encode.bin b/bgfx/shaders/dx11/fs_ntsc_encode.bin
index 0b9a2ef1c2d..26ea7d7b35b 100644
--- a/bgfx/shaders/dx11/fs_ntsc_encode.bin
+++ b/bgfx/shaders/dx11/fs_ntsc_encode.bin
Binary files differ
diff --git a/bgfx/shaders/dx11/fs_phosphor.bin b/bgfx/shaders/dx11/fs_phosphor.bin
index 4e9463b9e43..0eae4ac059a 100644
--- a/bgfx/shaders/dx11/fs_phosphor.bin
+++ b/bgfx/shaders/dx11/fs_phosphor.bin
Binary files differ
diff --git a/bgfx/shaders/dx11/fs_post.bin b/bgfx/shaders/dx11/fs_post.bin
index 2966d31caed..037d3e4b5f5 100644
--- a/bgfx/shaders/dx11/fs_post.bin
+++ b/bgfx/shaders/dx11/fs_post.bin
Binary files differ
diff --git a/bgfx/shaders/dx11/fs_screen.bin b/bgfx/shaders/dx11/fs_screen.bin
index 77db0e11cdf..855a5c142f1 100644
--- a/bgfx/shaders/dx11/fs_screen.bin
+++ b/bgfx/shaders/dx11/fs_screen.bin
Binary files differ
diff --git a/bgfx/shaders/dx11/vs_blit.bin b/bgfx/shaders/dx11/vs_blit.bin
index 921983524a6..fe9ce0d3a0b 100644
--- a/bgfx/shaders/dx11/vs_blit.bin
+++ b/bgfx/shaders/dx11/vs_blit.bin
Binary files differ
diff --git a/bgfx/shaders/dx11/vs_color.bin b/bgfx/shaders/dx11/vs_color.bin
index e8537348c73..e51c5294eb0 100644
--- a/bgfx/shaders/dx11/vs_color.bin
+++ b/bgfx/shaders/dx11/vs_color.bin
Binary files differ
diff --git a/bgfx/shaders/dx11/vs_deconverge.bin b/bgfx/shaders/dx11/vs_deconverge.bin
index 04b7f26d457..d9a8ae72830 100644
--- a/bgfx/shaders/dx11/vs_deconverge.bin
+++ b/bgfx/shaders/dx11/vs_deconverge.bin
Binary files differ
diff --git a/bgfx/shaders/dx11/vs_defocus.bin b/bgfx/shaders/dx11/vs_defocus.bin
index 48e32ee5d8c..6ada3526c81 100644
--- a/bgfx/shaders/dx11/vs_defocus.bin
+++ b/bgfx/shaders/dx11/vs_defocus.bin
Binary files differ
diff --git a/bgfx/shaders/dx11/vs_distortion.bin b/bgfx/shaders/dx11/vs_distortion.bin
index d56ecb58e4f..34362427383 100644
--- a/bgfx/shaders/dx11/vs_distortion.bin
+++ b/bgfx/shaders/dx11/vs_distortion.bin
Binary files differ
diff --git a/bgfx/shaders/dx11/vs_gui.bin b/bgfx/shaders/dx11/vs_gui.bin
index a534317dfb9..42e835bfbf2 100644
--- a/bgfx/shaders/dx11/vs_gui.bin
+++ b/bgfx/shaders/dx11/vs_gui.bin
Binary files differ
diff --git a/bgfx/shaders/dx11/vs_ntsc_decode.bin b/bgfx/shaders/dx11/vs_ntsc_decode.bin
index 1d83e3d9ea4..fb8cb2b32cb 100644
--- a/bgfx/shaders/dx11/vs_ntsc_decode.bin
+++ b/bgfx/shaders/dx11/vs_ntsc_decode.bin
Binary files differ
diff --git a/bgfx/shaders/dx11/vs_ntsc_encode.bin b/bgfx/shaders/dx11/vs_ntsc_encode.bin
index d58e84749dc..35c358065e3 100644
--- a/bgfx/shaders/dx11/vs_ntsc_encode.bin
+++ b/bgfx/shaders/dx11/vs_ntsc_encode.bin
Binary files differ
diff --git a/bgfx/shaders/dx11/vs_phosphor.bin b/bgfx/shaders/dx11/vs_phosphor.bin
index 72def3ab605..ec6373d87f4 100644
--- a/bgfx/shaders/dx11/vs_phosphor.bin
+++ b/bgfx/shaders/dx11/vs_phosphor.bin
Binary files differ
diff --git a/bgfx/shaders/dx11/vs_post.bin b/bgfx/shaders/dx11/vs_post.bin
index 3495e27a797..d4e0aeaaede 100644
--- a/bgfx/shaders/dx11/vs_post.bin
+++ b/bgfx/shaders/dx11/vs_post.bin
Binary files differ
diff --git a/bgfx/shaders/dx11/vs_screen.bin b/bgfx/shaders/dx11/vs_screen.bin
index 320f9d80e71..30c31ad3e7b 100644
--- a/bgfx/shaders/dx11/vs_screen.bin
+++ b/bgfx/shaders/dx11/vs_screen.bin
Binary files differ
diff --git a/bgfx/shaders/dx9/fs_blit.bin b/bgfx/shaders/dx9/fs_blit.bin
index 87431a56e71..b0f01ee708c 100644
--- a/bgfx/shaders/dx9/fs_blit.bin
+++ b/bgfx/shaders/dx9/fs_blit.bin
Binary files differ
diff --git a/bgfx/shaders/dx9/fs_color.bin b/bgfx/shaders/dx9/fs_color.bin
index bcde8844dd2..68f1eae9dc0 100644
--- a/bgfx/shaders/dx9/fs_color.bin
+++ b/bgfx/shaders/dx9/fs_color.bin
Binary files differ
diff --git a/bgfx/shaders/dx9/fs_deconverge.bin b/bgfx/shaders/dx9/fs_deconverge.bin
index b98ee3cb31d..6417bf6ad00 100644
--- a/bgfx/shaders/dx9/fs_deconverge.bin
+++ b/bgfx/shaders/dx9/fs_deconverge.bin
Binary files differ
diff --git a/bgfx/shaders/dx9/fs_defocus.bin b/bgfx/shaders/dx9/fs_defocus.bin
index 6ba9faa3292..275e264bf06 100644
--- a/bgfx/shaders/dx9/fs_defocus.bin
+++ b/bgfx/shaders/dx9/fs_defocus.bin
Binary files differ
diff --git a/bgfx/shaders/dx9/fs_distortion.bin b/bgfx/shaders/dx9/fs_distortion.bin
index 7b0fa91eb2f..b25548edd31 100644
--- a/bgfx/shaders/dx9/fs_distortion.bin
+++ b/bgfx/shaders/dx9/fs_distortion.bin
Binary files differ
diff --git a/bgfx/shaders/dx9/fs_gui.bin b/bgfx/shaders/dx9/fs_gui.bin
index 405e3c1f4d9..b64c72268cc 100644
--- a/bgfx/shaders/dx9/fs_gui.bin
+++ b/bgfx/shaders/dx9/fs_gui.bin
Binary files differ
diff --git a/bgfx/shaders/dx9/fs_ntsc_decode.bin b/bgfx/shaders/dx9/fs_ntsc_decode.bin
index c5731a1312b..1ebb9526280 100644
--- a/bgfx/shaders/dx9/fs_ntsc_decode.bin
+++ b/bgfx/shaders/dx9/fs_ntsc_decode.bin
Binary files differ
diff --git a/bgfx/shaders/dx9/fs_ntsc_encode.bin b/bgfx/shaders/dx9/fs_ntsc_encode.bin
index 375d4339fcc..019a55a80ab 100644
--- a/bgfx/shaders/dx9/fs_ntsc_encode.bin
+++ b/bgfx/shaders/dx9/fs_ntsc_encode.bin
Binary files differ
diff --git a/bgfx/shaders/dx9/fs_phosphor.bin b/bgfx/shaders/dx9/fs_phosphor.bin
index 7fbfb7d2433..eafc92b4ecf 100644
--- a/bgfx/shaders/dx9/fs_phosphor.bin
+++ b/bgfx/shaders/dx9/fs_phosphor.bin
Binary files differ
diff --git a/bgfx/shaders/dx9/fs_post.bin b/bgfx/shaders/dx9/fs_post.bin
index 8bb9bd011e5..6f08bba57a4 100644
--- a/bgfx/shaders/dx9/fs_post.bin
+++ b/bgfx/shaders/dx9/fs_post.bin
Binary files differ
diff --git a/bgfx/shaders/dx9/fs_screen.bin b/bgfx/shaders/dx9/fs_screen.bin
index 6599df87a61..81f469b607b 100644
--- a/bgfx/shaders/dx9/fs_screen.bin
+++ b/bgfx/shaders/dx9/fs_screen.bin
Binary files differ
diff --git a/bgfx/shaders/dx9/vs_blit.bin b/bgfx/shaders/dx9/vs_blit.bin
index 4e60f251806..63d53341092 100644
--- a/bgfx/shaders/dx9/vs_blit.bin
+++ b/bgfx/shaders/dx9/vs_blit.bin
Binary files differ
diff --git a/bgfx/shaders/dx9/vs_color.bin b/bgfx/shaders/dx9/vs_color.bin
index 2532e2376f1..1dd85de84ae 100644
--- a/bgfx/shaders/dx9/vs_color.bin
+++ b/bgfx/shaders/dx9/vs_color.bin
Binary files differ
diff --git a/bgfx/shaders/dx9/vs_deconverge.bin b/bgfx/shaders/dx9/vs_deconverge.bin
index cd3e0330f90..d826f546c9a 100644
--- a/bgfx/shaders/dx9/vs_deconverge.bin
+++ b/bgfx/shaders/dx9/vs_deconverge.bin
Binary files differ
diff --git a/bgfx/shaders/dx9/vs_defocus.bin b/bgfx/shaders/dx9/vs_defocus.bin
index cdddfc9b285..90eedcc43eb 100644
--- a/bgfx/shaders/dx9/vs_defocus.bin
+++ b/bgfx/shaders/dx9/vs_defocus.bin
Binary files differ
diff --git a/bgfx/shaders/dx9/vs_distortion.bin b/bgfx/shaders/dx9/vs_distortion.bin
index 02062b46eeb..72faf4cd3df 100644
--- a/bgfx/shaders/dx9/vs_distortion.bin
+++ b/bgfx/shaders/dx9/vs_distortion.bin
Binary files differ
diff --git a/bgfx/shaders/dx9/vs_gui.bin b/bgfx/shaders/dx9/vs_gui.bin
index 3a63611639e..c1c19c4b95e 100644
--- a/bgfx/shaders/dx9/vs_gui.bin
+++ b/bgfx/shaders/dx9/vs_gui.bin
Binary files differ
diff --git a/bgfx/shaders/dx9/vs_ntsc_decode.bin b/bgfx/shaders/dx9/vs_ntsc_decode.bin
index 34128b63dde..5030b370e69 100644
--- a/bgfx/shaders/dx9/vs_ntsc_decode.bin
+++ b/bgfx/shaders/dx9/vs_ntsc_decode.bin
Binary files differ
diff --git a/bgfx/shaders/dx9/vs_ntsc_encode.bin b/bgfx/shaders/dx9/vs_ntsc_encode.bin
index b4b99825650..1db3699e541 100644
--- a/bgfx/shaders/dx9/vs_ntsc_encode.bin
+++ b/bgfx/shaders/dx9/vs_ntsc_encode.bin
Binary files differ
diff --git a/bgfx/shaders/dx9/vs_phosphor.bin b/bgfx/shaders/dx9/vs_phosphor.bin
index edbe4e5e316..441a155b3db 100644
--- a/bgfx/shaders/dx9/vs_phosphor.bin
+++ b/bgfx/shaders/dx9/vs_phosphor.bin
Binary files differ
diff --git a/bgfx/shaders/dx9/vs_post.bin b/bgfx/shaders/dx9/vs_post.bin
index 9a0e8092fbb..43eec77a6f4 100644
--- a/bgfx/shaders/dx9/vs_post.bin
+++ b/bgfx/shaders/dx9/vs_post.bin
Binary files differ
diff --git a/bgfx/shaders/dx9/vs_screen.bin b/bgfx/shaders/dx9/vs_screen.bin
index a1cd3901b69..e3bd9417ad8 100644
--- a/bgfx/shaders/dx9/vs_screen.bin
+++ b/bgfx/shaders/dx9/vs_screen.bin
Binary files differ
diff --git a/bgfx/shaders/gles/fs_defocus.bin b/bgfx/shaders/gles/fs_defocus.bin
index ce0b956494a..98ff6f0b9cf 100644
--- a/bgfx/shaders/gles/fs_defocus.bin
+++ b/bgfx/shaders/gles/fs_defocus.bin
Binary files differ
diff --git a/bgfx/shaders/gles/fs_distortion.bin b/bgfx/shaders/gles/fs_distortion.bin
index d423d9b7fb8..e518fc0f0a3 100644
--- a/bgfx/shaders/gles/fs_distortion.bin
+++ b/bgfx/shaders/gles/fs_distortion.bin
Binary files differ
diff --git a/bgfx/shaders/glsl/fs_defocus.bin b/bgfx/shaders/glsl/fs_defocus.bin
index d56afae0f77..0adf5a7fd67 100644
--- a/bgfx/shaders/glsl/fs_defocus.bin
+++ b/bgfx/shaders/glsl/fs_defocus.bin
Binary files differ
diff --git a/bgfx/shaders/glsl/fs_distortion.bin b/bgfx/shaders/glsl/fs_distortion.bin
index 9ec60e1a440..11087b688ff 100644
--- a/bgfx/shaders/glsl/fs_distortion.bin
+++ b/bgfx/shaders/glsl/fs_distortion.bin
Binary files differ
diff --git a/bgfx/shaders/metal/fs_defocus.bin b/bgfx/shaders/metal/fs_defocus.bin
index 76825e22010..52900807388 100644
--- a/bgfx/shaders/metal/fs_defocus.bin
+++ b/bgfx/shaders/metal/fs_defocus.bin
Binary files differ
diff --git a/bgfx/shaders/metal/fs_distortion.bin b/bgfx/shaders/metal/fs_distortion.bin
index 6c8b0562037..6dca893e794 100644
--- a/bgfx/shaders/metal/fs_distortion.bin
+++ b/bgfx/shaders/metal/fs_distortion.bin
Binary files differ
diff --git a/src/osd/modules/lib/osdobj_common.cpp b/src/osd/modules/lib/osdobj_common.cpp
index abbb9241049..970ee53c60a 100644
--- a/src/osd/modules/lib/osdobj_common.cpp
+++ b/src/osd/modules/lib/osdobj_common.cpp
@@ -144,7 +144,7 @@ const options_entry osd_options::s_option_entries[] =
{ OSDOPTION_BGFX_PATH, "bgfx", OPTION_STRING, "path to BGFX-related files" },
{ OSDOPTION_BGFX_BACKEND, "auto", OPTION_STRING, "BGFX backend to use (d3d9, d3d11, metal, opengl, gles)" },
{ OSDOPTION_BGFX_DEBUG, "0", OPTION_BOOLEAN, "enable BGFX debugging statistics" },
- { OSDOPTION_BGFX_SCREEN_CHAIN, "default", OPTION_STRING, "screen chain JSON file to use" },
+ { OSDOPTION_BGFX_SCREEN_CHAINS, "default", OPTION_STRING, "comma-delimited list of JSON files to use per-screen" },
{ OSDOPTION_BGFX_SHADOW_MASK, "shadow-mask.png", OPTION_STRING, "shadow mask texture name" },
{ OSDOPTION_BGFX_PRESCALE_X, "2", OPTION_INTEGER, "x prescale" },
{ OSDOPTION_BGFX_PRESCALE_Y, "2", OPTION_INTEGER, "y prescale" },
diff --git a/src/osd/modules/lib/osdobj_common.h b/src/osd/modules/lib/osdobj_common.h
index 0b08745a22d..3c50c4fe9c5 100644
--- a/src/osd/modules/lib/osdobj_common.h
+++ b/src/osd/modules/lib/osdobj_common.h
@@ -80,7 +80,7 @@
#define OSDOPTION_BGFX_PATH "bgfx_path"
#define OSDOPTION_BGFX_BACKEND "bgfx_backend"
#define OSDOPTION_BGFX_DEBUG "bgfx_debug"
-#define OSDOPTION_BGFX_SCREEN_CHAIN "bgfx_screen_chain"
+#define OSDOPTION_BGFX_SCREEN_CHAINS "bgfx_screen_chains"
#define OSDOPTION_BGFX_SHADOW_MASK "bgfx_shadow_mask"
#define OSDOPTION_BGFX_PRESCALE_X "bgfx_prescale_x"
#define OSDOPTION_BGFX_PRESCALE_Y "bgfx_prescale_y"
@@ -157,7 +157,7 @@ public:
const char *bgfx_path() const { return value(OSDOPTION_BGFX_PATH); }
const char *bgfx_backend() const { return value(OSDOPTION_BGFX_BACKEND); }
const bool bgfx_debug() const { return bool_value(OSDOPTION_BGFX_DEBUG); }
- const char *bgfx_screen_chain() const { return value(OSDOPTION_BGFX_SCREEN_CHAIN); }
+ const char *bgfx_screen_chains() const { return value(OSDOPTION_BGFX_SCREEN_CHAINS); }
const char *bgfx_shadow_mask() const { return value(OSDOPTION_BGFX_SHADOW_MASK); }
const uint32_t bgfx_prescale_x() const { return int_value(OSDOPTION_BGFX_PRESCALE_X); }
const uint32_t bgfx_prescale_y() const { return int_value(OSDOPTION_BGFX_PRESCALE_Y); }
diff --git a/src/osd/modules/render/bgfx/chainentry.cpp b/src/osd/modules/render/bgfx/chainentry.cpp
index 3826b4999b2..866236aebb4 100644
--- a/src/osd/modules/render/bgfx/chainentry.cpp
+++ b/src/osd/modules/render/bgfx/chainentry.cpp
@@ -111,7 +111,7 @@ void bgfx_chain_entry::setup_screensize_uniforms(texture_manager& textures, uint
}
}
-void bgfx_chain_entry::setup_sourcesize_uniform(render_primitive* prim)
+void bgfx_chain_entry::setup_sourcesize_uniform(render_primitive* prim) const
{
bgfx_uniform* source_dims = m_effect->uniform("u_source_dims");
if (source_dims != nullptr)
@@ -121,7 +121,7 @@ void bgfx_chain_entry::setup_sourcesize_uniform(render_primitive* prim)
}
}
-void bgfx_chain_entry::setup_rotationtype_uniform(uint32_t rotation_type)
+void bgfx_chain_entry::setup_rotationtype_uniform(uint32_t rotation_type) const
{
bgfx_uniform* rotation_type_uniform = m_effect->uniform("u_rotation_type");
if (rotation_type_uniform != nullptr)
@@ -131,14 +131,24 @@ void bgfx_chain_entry::setup_rotationtype_uniform(uint32_t rotation_type)
}
}
-void bgfx_chain_entry::setup_swapxy_uniform(bool swap_xy)
+void bgfx_chain_entry::setup_swapxy_uniform(bool swap_xy) const
{
- bgfx_uniform* swap_xy_uniform = m_effect->uniform("u_swap_xy");
- if (swap_xy_uniform != nullptr)
- {
- float values[1] = { swap_xy ? 1.0f : 0.0f };
- swap_xy_uniform->set(values, sizeof(float));
- }
+ bgfx_uniform* swap_xy_uniform = m_effect->uniform("u_swap_xy");
+ if (swap_xy_uniform != nullptr)
+ {
+ float values[1] = { swap_xy ? 1.0f : 0.0f };
+ swap_xy_uniform->set(values, sizeof(float));
+ }
+}
+
+void bgfx_chain_entry::setup_quaddims_uniform(render_primitive* prim) const
+{
+ bgfx_uniform* quad_dims_uniform = m_effect->uniform("u_quad_dims");
+ if (quad_dims_uniform != nullptr)
+ {
+ float values[2] = { (prim->bounds.x1 - prim->bounds.x0) + 0.5f, (prim->bounds.y1 - prim->bounds.y0) + 0.5f};
+ quad_dims_uniform->set(values, sizeof(float) * 2);
+ }
}
void bgfx_chain_entry::setup_auto_uniforms(render_primitive* prim, texture_manager& textures, uint16_t screen_width, uint16_t screen_height, uint32_t rotation_type, bool swap_xy, int32_t screen)
@@ -147,9 +157,10 @@ void bgfx_chain_entry::setup_auto_uniforms(render_primitive* prim, texture_manag
setup_sourcesize_uniform(prim);
setup_rotationtype_uniform(rotation_type);
setup_swapxy_uniform(swap_xy);
+ setup_quaddims_uniform(prim);
}
-bool bgfx_chain_entry::setup_view(int view, uint16_t screen_width, uint16_t screen_height, int32_t screen)
+bool bgfx_chain_entry::setup_view(int view, uint16_t screen_width, uint16_t screen_height, int32_t screen) const
{
bgfx::FrameBufferHandle handle = BGFX_INVALID_HANDLE;
uint16_t width = screen_width;
@@ -174,11 +185,11 @@ bool bgfx_chain_entry::setup_view(int view, uint16_t screen_width, uint16_t scre
bx::mtxOrtho(projMat, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 100.0f);
bgfx::setViewTransform(view, nullptr, projMat);
- bgfx::setViewClear(view, BGFX_CLEAR_COLOR | BGFX_CLEAR_DEPTH, 0x000000ff, 1.0f, 0);
+ bgfx::setViewClear(view, BGFX_CLEAR_COLOR | BGFX_CLEAR_DEPTH, 0x00ff00ff, 1.0f, 0);
return true;
}
-void bgfx_chain_entry::put_screen_buffer(render_primitive* prim, bgfx::TransientVertexBuffer* buffer)
+void bgfx_chain_entry::put_screen_buffer(render_primitive* prim, bgfx::TransientVertexBuffer* buffer) const
{
if (bgfx::checkAvailTransientVertexBuffer(6, ScreenVertex::ms_decl))
{
diff --git a/src/osd/modules/render/bgfx/chainentry.h b/src/osd/modules/render/bgfx/chainentry.h
index 00662dcf0cd..a80fc8656c0 100644
--- a/src/osd/modules/render/bgfx/chainentry.h
+++ b/src/osd/modules/render/bgfx/chainentry.h
@@ -45,12 +45,13 @@ public:
private:
void setup_auto_uniforms(render_primitive* prim, texture_manager& textures, uint16_t screen_width, uint16_t screen_height, uint32_t rotation_type, bool swap_xy, int32_t screen);
void setup_screensize_uniforms(texture_manager& textures, uint16_t screen_width, uint16_t screen_height, int32_t screen);
- void setup_sourcesize_uniform(render_primitive* prim);
- void setup_rotationtype_uniform(uint32_t rotation_type);
- void setup_swapxy_uniform(bool swap_xy);
+ void setup_sourcesize_uniform(render_primitive* prim) const;
+ void setup_rotationtype_uniform(uint32_t rotation_type) const;
+ void setup_swapxy_uniform(bool swap_xy) const;
+ void setup_quaddims_uniform(render_primitive* prim) const;
- bool setup_view(int view, uint16_t screen_width, uint16_t screen_height, int32_t screen);
- void put_screen_buffer(render_primitive* prim, bgfx::TransientVertexBuffer* buffer);
+ bool setup_view(int view, uint16_t screen_width, uint16_t screen_height, int32_t screen) const;
+ void put_screen_buffer(render_primitive* prim, bgfx::TransientVertexBuffer* buffer) const;
std::string m_name;
bgfx_effect* m_effect;
diff --git a/src/osd/modules/render/bgfx/chainentryreader.cpp b/src/osd/modules/render/bgfx/chainentryreader.cpp
index e98b704a853..07088181d2d 100644
--- a/src/osd/modules/render/bgfx/chainentryreader.cpp
+++ b/src/osd/modules/render/bgfx/chainentryreader.cpp
@@ -36,6 +36,11 @@ bgfx_chain_entry* chain_entry_reader::read_from_value(const Value& value, std::s
}
bgfx_effect* effect = effects.effect(value["effect"].GetString());
+ if (effect == nullptr)
+ {
+ return nullptr;
+ }
+
std::string name = value["name"].GetString();
std::vector<bgfx_input_pair> inputs;
diff --git a/src/osd/modules/render/bgfx/effectmanager.cpp b/src/osd/modules/render/bgfx/effectmanager.cpp
index 7522a88dc8c..a34b5c52d82 100644
--- a/src/osd/modules/render/bgfx/effectmanager.cpp
+++ b/src/osd/modules/render/bgfx/effectmanager.cpp
@@ -12,6 +12,7 @@
#include "emu.h"
#include <rapidjson/document.h>
+#include <rapidjson/error/en.h>
#include <bgfx/bgfxplatform.h>
#include <bgfx/bgfx.h>
@@ -52,7 +53,11 @@ bgfx_effect* effect_manager::load_effect(std::string name)
std::string path = std::string(m_options.bgfx_path()) + "/effects/" + name;
bx::CrtFileReader reader;
- bx::open(&reader, path.c_str());
+ if (!bx::open(&reader, path.c_str()))
+ {
+ printf("Unable to open effect file %s\n", path.c_str());
+ return nullptr;
+ }
int32_t size (bx::getSize(&reader));
@@ -63,9 +68,22 @@ bgfx_effect* effect_manager::load_effect(std::string name)
Document document;
document.Parse<0>(data);
- bgfx_effect* effect = effect_reader::read_from_value(document, "Effect '" + name + "': ", m_shaders);
- m_effects[name] = effect;
+ if (document.HasParseError()) {
+ std::string error(GetParseError_En(document.GetParseError()));
+ printf("Unable to parse effect %s. Errors returned:\n", path.c_str());
+ printf("%s\n", error.c_str());
+ return nullptr;
+ }
+
+ bgfx_effect* effect = effect_reader::read_from_value(document, "Effect '" + name + "': ", m_shaders);
+
+ if (effect == nullptr) {
+ printf("Unable to load effect %s\n", path.c_str());
+ return nullptr;
+ }
+
+ m_effects[name] = effect;
return effect;
}
diff --git a/src/osd/modules/render/bgfx/effectreader.cpp b/src/osd/modules/render/bgfx/effectreader.cpp
index 80a8b73abed..b787dec12a3 100644
--- a/src/osd/modules/render/bgfx/effectreader.cpp
+++ b/src/osd/modules/render/bgfx/effectreader.cpp
@@ -42,7 +42,12 @@ bgfx_effect* effect_reader::read_from_value(const Value& value, std::string pref
const Value& uniform_array = value["uniforms"];
for (UINT32 i = 0; i < uniform_array.Size(); i++)
{
- uniforms.push_back(uniform_reader::read_from_value(uniform_array[i], prefix + "uniforms[" + std::to_string(i) + "]: "));
+ bgfx_uniform* uniform = uniform_reader::read_from_value(uniform_array[i], prefix + "uniforms[" + std::to_string(i) + "]: ");
+ if (uniform == nullptr)
+ {
+ return nullptr;
+ }
+ uniforms.push_back(uniform);
}
std::string vertex_name(value["vertex"].GetString());
diff --git a/src/osd/modules/render/bgfx/fs_defocus.sc b/src/osd/modules/render/bgfx/fs_defocus.sc
index 03c442e4780..8c3ee7a4e6c 100644
--- a/src/osd/modules/render/bgfx/fs_defocus.sc
+++ b/src/osd/modules/render/bgfx/fs_defocus.sc
@@ -9,7 +9,7 @@ $input v_color0, v_texcoord0
#include "../../../../../3rdparty/bgfx/examples/common/common.sh"
// Autos
-uniform vec4 u_screen_dims;
+uniform vec4 u_tex_size0;
// User-supplied
uniform vec4 u_defocus;
@@ -32,7 +32,7 @@ void main()
const vec2 Coord7Offset = vec2( 0.50, -0.75);
const vec2 Coord8Offset = vec2( 1.00, -0.25);
- vec2 DefocusTexelDims = u_defocus.xy / u_screen_dims.xy;
+ vec2 DefocusTexelDims = u_defocus.xy / u_tex_size0.xy;
vec4 d0 = texture2D(s_tex, v_texcoord0);
vec4 d1 = texture2D(s_tex, v_texcoord0 + Coord1Offset * DefocusTexelDims);
@@ -46,5 +46,5 @@ void main()
vec4 blurred = (d0 + d1 + d2 + d3 + d4 + d5 + d6 + d7 + d8) / 9.0;
- gl_FragColor = vec4(blurred.xyz, 1.0) * v_color0;
+ gl_FragColor = vec4(blurred.rgb, 1.0) * v_color0;
}
diff --git a/src/osd/modules/render/bgfx/fs_distortion.sc b/src/osd/modules/render/bgfx/fs_distortion.sc
index a80286cfb1a..b3678abc669 100644
--- a/src/osd/modules/render/bgfx/fs_distortion.sc
+++ b/src/osd/modules/render/bgfx/fs_distortion.sc
@@ -9,10 +9,13 @@ $input v_color0, v_texcoord0
#include "../../../../../3rdparty/bgfx/examples/common/common.sh"
// Autos
+uniform vec4 u_swap_xy;
uniform vec4 u_screen_dims;
+uniform vec4 u_quad_dims;
uniform vec4 u_rotation_type;
// User-supplied
+uniform vec4 u_prepare_vector;
uniform vec4 u_curvature;
uniform vec4 u_round_corner;
uniform vec4 u_smooth_border;
@@ -46,15 +49,6 @@ float roundBox(vec2 p, vec2 b, float r)
return length(max(abs(p) - b + r, 0.0)) - r;
}
-vec2 GetRatioCorrection()
-{
- float ScreenQuadRatio = 1.0;
-
- return ScreenQuadRatio > 1.0f
- ? vec2(1.0, 1.0f / ScreenQuadRatio)
- : vec2(ScreenQuadRatio, 1.0);
-}
-
float GetNoiseFactor(float n, float random)
{
// smaller n become more noisy
@@ -77,22 +71,37 @@ float GetVignetteFactor(vec2 coord, float amount)
float GetSpotAddend(vec2 coord, float amount)
{
- vec2 RatioCorrection = GetRatioCorrection();
-
- // normalized screen quad ratio
- vec2 QuadRatio = vec2(1.0, u_screen_dims.y / u_screen_dims.x);
-
- // normalized screen quad ratio
- // upper right quadrant
- vec2 spotOffset = vec2(-0.25, 0.25); // 0 degrees
- if (u_rotation_type.x == 1.0)
- spotOffset = vec2(-0.25, -0.25); // 90 degrees
- if (u_rotation_type.x == 2.0)
- spotOffset = vec2(0.25, -0.25); // 180 degrees
- if (u_rotation_type.x == 3.0)
- spotOffset = vec2(0.25, 0.25); // 270 degrees
-
- vec2 SpotCoord = (coord + spotOffset * RatioCorrection) / RatioCorrection;
+ vec2 SpotCoord = coord;
+
+ // hack for vector screen
+ if (u_prepare_vector.x > 0.0)
+ {
+ // upper right quadrant
+ vec2 spotOffset = vec2(-0.25, 0.25); // 0 degrees
+ if (u_rotation_type.x == 1.0)
+ spotOffset = vec2(-0.25, -0.25); // 90 degrees
+ if (u_rotation_type.x == 2.0)
+ spotOffset = vec2(0.25, -0.25); // 180 degrees
+ if (u_rotation_type.x == 3.0)
+ spotOffset = vec2(0.25, 0.25); // 270 degrees
+
+ // normalized screen canvas ratio
+ vec2 CanvasRatio = ((u_swap_xy.x > 0.0) ? vec2(u_quad_dims.x / u_quad_dims.y, 1.0) : vec2(1.0, u_quad_dims.y / u_quad_dims.x));
+
+ SpotCoord += spotOffset;
+ SpotCoord *= CanvasRatio;
+ }
+ else
+ {
+ // upper right quadrant
+ vec2 spotOffset = vec2(-0.25, 0.25);
+
+ // normalized screen canvas ratio
+ vec2 CanvasRatio = ((u_swap_xy.x > 0.0) ? vec2(1.0, u_quad_dims.x / u_quad_dims.y) : vec2(1.0, u_quad_dims.y / u_quad_dims.x));
+
+ SpotCoord += spotOffset;
+ SpotCoord *= CanvasRatio;
+ }
float SpotBlur = amount;
@@ -110,17 +119,17 @@ float GetSpotAddend(vec2 coord, float amount)
float GetRoundCornerFactor(vec2 coord, float radiusAmount, float smoothAmount)
{
- vec2 RatioCorrection = GetRatioCorrection();
-
// reduce smooth amount down to radius amount
smoothAmount = min(smoothAmount, radiusAmount);
- float range = min(u_screen_dims.x, u_screen_dims.y) * 0.5;
+ vec2 quadDims = (u_prepare_vector.x > 0.0 && u_swap_xy.x > 0.0) ? u_quad_dims.yx : u_quad_dims.xy;
+
+ float range = min(quadDims.x, quadDims.y) * 0.5;
float radius = range * max(radiusAmount, 0.0025);
float smooth_val = 1.0 / (range * max(smoothAmount, 0.0025));
// compute box
- float box = roundBox(u_screen_dims.xy * (coord * 2.0f), u_screen_dims.xy * RatioCorrection, radius);
+ float box = roundBox(quadDims * (coord * 2.0f), quadDims, radius);
// apply smooth
box *= smooth_val;
@@ -155,20 +164,12 @@ vec2 GetDistortedCoords(vec2 centerCoord, float amount)
vec2 GetCoords(vec2 coord, float distortionAmount)
{
- vec2 RatioCorrection = GetRatioCorrection();
-
// center coordinates
coord -= 0.5;
- // apply ratio difference between screen and quad
- coord /= RatioCorrection;
-
// distort coordinates
coord = GetDistortedCoords(coord, distortionAmount);
- // revert ratio difference between screen and quad
- coord *= RatioCorrection;
-
// un-center coordinates
coord += 0.5;
diff --git a/src/osd/modules/render/bgfx/inputpair.cpp b/src/osd/modules/render/bgfx/inputpair.cpp
index d04c77e8a92..8603f7caa5e 100644
--- a/src/osd/modules/render/bgfx/inputpair.cpp
+++ b/src/osd/modules/render/bgfx/inputpair.cpp
@@ -29,10 +29,19 @@ bgfx_input_pair::bgfx_input_pair(int index, std::string sampler, std::string tex
void bgfx_input_pair::bind(bgfx_effect *effect, target_manager& targets, texture_manager& textures, const int32_t screen) const
{
assert(effect->uniform(m_sampler) != nullptr);
- std::string texture = m_texture;
+ std::string name = m_texture;
if (targets.target(m_texture + std::to_string(screen)) != nullptr)
{
- texture = m_texture + std::to_string(screen);
+ name = m_texture + std::to_string(screen);
}
- bgfx::setTexture(m_index, effect->uniform(m_sampler)->handle(), textures.handle(texture));
+
+ bgfx_texture_handle_provider* provider = textures.provider(name);
+ bgfx_uniform *tex_size = effect->uniform("u_tex_size" + std::to_string(m_index));
+ if (tex_size != nullptr)
+ {
+ float values[2] = { float(provider->width()), float(provider->height()) };
+ tex_size->set(values, sizeof(float) * 2);
+ }
+
+ bgfx::setTexture(m_index, effect->uniform(m_sampler)->handle(), textures.handle(name));
}
diff --git a/src/osd/modules/render/drawbgfx.cpp b/src/osd/modules/render/drawbgfx.cpp
index ccfd6cdd642..2dc986b0ecd 100644
--- a/src/osd/modules/render/drawbgfx.cpp
+++ b/src/osd/modules/render/drawbgfx.cpp
@@ -66,10 +66,11 @@ const char* renderer_bgfx::WINDOW_PREFIX = "Window 0, ";
#define GIBBERISH (0)
//============================================================
-// TYPES
+// STATICS
//============================================================
bool renderer_bgfx::s_window_set = false;
+uint32_t renderer_bgfx::s_current_view = 0;
//============================================================
// renderer_bgfx::create
@@ -190,7 +191,7 @@ int renderer_bgfx::create()
m_screen_effect[3] = m_effects->effect("screen_add");
m_chains = new chain_manager(options, *m_textures, *m_targets, *m_effects, m_width[window().m_index], m_height[window().m_index]);
- m_screen_chain = m_chains->chain(options.bgfx_screen_chain(), window().machine(), window().m_index);
+ parse_screen_chains(options.bgfx_screen_chains());
m_sliders_dirty = true;
uint32_t flags = BGFX_TEXTURE_U_CLAMP | BGFX_TEXTURE_V_CLAMP | BGFX_TEXTURE_MIN_POINT | BGFX_TEXTURE_MAG_POINT | BGFX_TEXTURE_MIP_POINT;
@@ -206,6 +207,36 @@ int renderer_bgfx::create()
}
//============================================================
+// parse_screen_chains
+//============================================================
+
+void renderer_bgfx::parse_screen_chains(std::string chain_str)
+{
+ std::vector<std::string> chains;
+ uint32_t length = chain_str.length();
+ uint32_t last_start = 0;
+ for (uint32_t i = 0; i < length + 1; i++)
+ {
+ if (i == length || chain_str[i] == ',')
+ {
+ chains.push_back(chain_str.substr(last_start, i - last_start));
+ last_start = i + 1;
+ }
+ }
+
+ for (uint32_t index = 0; index < chains.size(); index++)
+ {
+ bgfx_chain* chain = m_chains->chain(chains[index], window().machine(), index);
+ if (chain == nullptr)
+ {
+ chains.clear();
+ return;
+ }
+ m_screen_chains.push_back(chain);
+ }
+}
+
+//============================================================
// destructor
//============================================================
@@ -350,7 +381,8 @@ void renderer_bgfx::process_screen_quad(int screen, render_primitive* prim)
m_targets->update_guest_targets(screen, tex_width, tex_height);
- m_screen_chain->process(prim, screen * m_screen_chain->applicable_passes(), screen, *m_textures, window(), get_blend_state(PRIMFLAG_GET_BLENDMODE(prim->flags)));
+ screen_chain(screen)->process(prim, s_current_view, screen, *m_textures, window(), get_blend_state(PRIMFLAG_GET_BLENDMODE(prim->flags)));
+ s_current_view += screen_chain(screen)->applicable_passes();
m_textures->add_provider("screen", nullptr);
delete texture;
@@ -727,23 +759,29 @@ const bgfx::Memory* renderer_bgfx::mame_texture_data_to_bgfx_texture_data(UINT32
int renderer_bgfx::handle_screen_chains()
{
- if (!m_screen_chain)
+ if (m_screen_chains.size() == 0)
{
return 0;
}
window().m_primlist->acquire_lock();
- // process
render_primitive *prim = window().m_primlist->first();
+ // Determine how many post-processing passes are needed
int screens = 0;
- screen_device_iterator iter(window().machine().root_device());
- for (const screen_device *screen = iter.first(); screen != nullptr; screen = iter.next()) {
- screens++;
+ while (prim != nullptr)
+ {
+ if (PRIMFLAG_GET_SCREENTEX(prim->flags))
+ {
+ screens++;
+ }
+ prim = prim->next();
}
m_targets->update_screen_count(screens);
+ // Process each screen as necessary
+ prim = window().m_primlist->first();
int seen_screen_quads = 0;
while (prim != nullptr)
{
@@ -757,25 +795,34 @@ int renderer_bgfx::handle_screen_chains()
window().m_primlist->release_lock();
- uint32_t total_passes = seen_screen_quads * m_screen_chain->applicable_passes();
- bgfx::setViewFrameBuffer(total_passes, BGFX_INVALID_HANDLE);
+ bgfx::setViewFrameBuffer(s_current_view, BGFX_INVALID_HANDLE);
- return total_passes;
+ return s_current_view;
+}
+
+bgfx_chain* renderer_bgfx::screen_chain(int32_t screen)
+{
+ if (screen >= m_screen_chains.size())
+ {
+ return m_screen_chains[m_screen_chains.size() - 1];
+ }
+ else
+ {
+ return m_screen_chains[screen];
+ }
}
int renderer_bgfx::draw(int update)
{
- m_screens.clear();
int window_index = window().m_index;
- int post_view_index = handle_screen_chains();
- int view_index = window_index;
- int first_view_index = 0;
- if (m_screen_chain && post_view_index > 0)
+ if (window_index == 0)
{
- view_index += post_view_index;
- first_view_index = post_view_index;
+ s_current_view = 0;
}
+ handle_screen_chains();
+ int view_index = s_current_view;
+
// Set view 0 default viewport.
osd_dim wdim = window().get_size();
m_width[window_index] = wdim.width();
@@ -803,7 +850,7 @@ int renderer_bgfx::draw(int update)
m_dimensions = osd_dim(m_width[window_index], m_height[window_index]);
bgfx::setViewClear(view_index
, BGFX_CLEAR_COLOR | BGFX_CLEAR_DEPTH
- , 0x000000ff
+ , 0x00ff00ff
, 1.0f
, 0
);
@@ -811,12 +858,10 @@ int renderer_bgfx::draw(int update)
bgfx::frame();
return 0;
}
- }
- if (view_index != first_view_index)
- {
- bgfx::setViewFrameBuffer(view_index, m_framebuffer->target());
- }
+ bgfx::setViewFrameBuffer(view_index, m_framebuffer->target());
+ }
+
bgfx::setViewSeq(view_index, true);
bgfx::setViewRect(view_index, 0, 0, m_width[window_index], m_height[window_index]);
@@ -885,11 +930,13 @@ int renderer_bgfx::draw(int update)
// Advance to next frame. Rendering thread will be kicked to
// process submitted rendering primitives.
- if (view_index == first_view_index)
+ if (window_index == 0)
{
bgfx::frame();
}
+ s_current_view++;
+
return 0;
}
@@ -928,7 +975,7 @@ renderer_bgfx::buffer_status renderer_bgfx::buffer_primitives(int view, bool atl
return BUFFER_PRE_FLUSH;
}
- if (PRIMFLAG_GET_SCREENTEX((*prim)->flags) && m_screen_chain != nullptr)
+ if (PRIMFLAG_GET_SCREENTEX((*prim)->flags) && m_screen_chains.size() > 0)
{
render_post_screen_quad(view, *prim, buffer, screen);
return BUFFER_SCREEN;
@@ -1148,24 +1195,27 @@ void renderer_bgfx::allocate_buffer(render_primitive *prim, UINT32 blend, bgfx::
slider_state* renderer_bgfx::get_slider_list()
{
- if (!m_screen_chain)
+ if (m_screen_chains.size() == 0)
{
return nullptr;
}
slider_state *listhead = nullptr;
slider_state **tailptr = &listhead;
- std::vector<bgfx_slider*> sliders = m_screen_chain->sliders();
- for (bgfx_slider* slider : sliders)
+ for (bgfx_chain* chain : m_screen_chains)
{
- if (*tailptr == nullptr)
- {
- *tailptr = slider->core_slider();
- }
- else
+ std::vector<bgfx_slider*> sliders = chain->sliders();
+ for (bgfx_slider* slider : sliders)
{
- (*tailptr)->next = slider->core_slider();
- tailptr = &(*tailptr)->next;
+ if (*tailptr == nullptr)
+ {
+ *tailptr = slider->core_slider();
+ }
+ else
+ {
+ (*tailptr)->next = slider->core_slider();
+ tailptr = &(*tailptr)->next;
+ }
}
}
if (*tailptr != nullptr)
diff --git a/src/osd/modules/render/drawbgfx.h b/src/osd/modules/render/drawbgfx.h
index a79fcb9cb30..db95d3d2550 100644
--- a/src/osd/modules/render/drawbgfx.h
+++ b/src/osd/modules/render/drawbgfx.h
@@ -61,6 +61,8 @@ public:
private:
int handle_screen_chains();
+ void parse_screen_chains(std::string chain_str);
+ bgfx_chain* screen_chain(int32_t screen);
void allocate_buffer(render_primitive *prim, UINT32 blend, bgfx::TransientVertexBuffer *buffer);
enum buffer_status
@@ -92,8 +94,6 @@ private:
const bgfx::Memory* mame_texture_data_to_bgfx_texture_data(UINT32 format, int width, int height, int rowpixels, const rgb_t *palette, void *base);
UINT32 get_texture_hash(render_primitive *prim);
- std::vector<screen_device*> m_screens;
-
bgfx_target* m_framebuffer;
bgfx_texture* m_texture_cache;
@@ -108,7 +108,7 @@ private:
bgfx_effect* m_gui_effect[4];
bgfx_effect* m_screen_effect[4];
- bgfx_chain* m_screen_chain;
+ std::vector<bgfx_chain*> m_screen_chains;
std::map<UINT32, rectangle_packer::packed_rectangle> m_hash_to_entry;
std::vector<rectangle_packer::packable_rectangle> m_texinfo;
@@ -123,6 +123,7 @@ private:
static const uint32_t WHITE_HASH;
static bool s_window_set;
+ static uint32_t s_current_view;
};
#endif