summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd
diff options
context:
space:
mode:
author therealmogminer@gmail.com <therealmogminer@gmail.com>2016-05-27 14:45:28 +0200
committer therealmogminer@gmail.com <therealmogminer@gmail.com>2016-05-27 14:45:41 +0200
commitf263110d939ef9a7aee97d655266498ab2339996 (patch)
treef4ba27b676e1bca60b7624d4bb7aabb53e0b5f13 /src/osd
parentdb284904b23ab1d70139327ce8d77836f64ece92 (diff)
Fix crash when using pillarbox shaders, nw
Diffstat (limited to 'src/osd')
-rw-r--r--src/osd/modules/render/bgfx/chain.cpp18
-rw-r--r--src/osd/modules/render/bgfx/chainmanager.cpp6
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/misc/vs_saturation.sc2
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/pillarbox_left_horizontal/fs_offset_sat.sc25
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/pillarbox_left_horizontal/vs_offset_sat.sc17
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/pillarbox_left_vertical/fs_offset_sat.sc25
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/pillarbox_left_vertical/vs_offset_sat.sc17
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/pillarbox_right_horizontal/fs_offset_sat.sc25
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/pillarbox_right_horizontal/vs_offset_sat.sc17
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/pillarbox_right_vertical/fs_offset_sat.sc25
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/pillarbox_right_vertical/vs_offset_sat.sc17
11 files changed, 186 insertions, 8 deletions
diff --git a/src/osd/modules/render/bgfx/chain.cpp b/src/osd/modules/render/bgfx/chain.cpp
index b056037aba9..4ba069d18a4 100644
--- a/src/osd/modules/render/bgfx/chain.cpp
+++ b/src/osd/modules/render/bgfx/chain.cpp
@@ -76,7 +76,6 @@ void bgfx_chain::process(render_primitive* prim, int view, int screen, texture_m
{
screen_device_iterator screen_iterator(window.machine().root_device());
screen_device* screen_device = screen_iterator.byindex(screen);
- render_container &screen_container = screen_device->container();
int current_view = view;
uint16_t screen_width(floor((prim->bounds.x1 - prim->bounds.x0) + 0.5f));
@@ -88,10 +87,19 @@ void bgfx_chain::process(render_primitive* prim, int view, int screen, texture_m
bool orientation_swap_xy = (window.machine().system().flags & ORIENTATION_SWAP_XY) == ORIENTATION_SWAP_XY;
bool rotation_swap_xy = (window.target()->orientation() & ORIENTATION_SWAP_XY) == ORIENTATION_SWAP_XY;
bool swap_xy = orientation_swap_xy ^ rotation_swap_xy;
- float screen_scale_x = 1.0f / screen_container.xscale();
- float screen_scale_y = 1.0f / screen_container.yscale();
- float screen_offset_x = -screen_container.xoffset();
- float screen_offset_y = -screen_container.yoffset();
+
+ float screen_scale_x = 1.0f;
+ float screen_scale_y = 1.0f;
+ float screen_offset_x = 0.0f;
+ float screen_offset_y = 0.0f;
+ if (screen_device != nullptr)
+ {
+ render_container &screen_container = screen_device->container();
+ screen_scale_x = 1.0f / screen_container.xscale();
+ screen_scale_y = 1.0f / screen_container.yscale();
+ screen_offset_x = -screen_container.xoffset();
+ screen_offset_y = -screen_container.yoffset();
+ }
for (bgfx_chain_entry* entry : m_entries)
{
diff --git a/src/osd/modules/render/bgfx/chainmanager.cpp b/src/osd/modules/render/bgfx/chainmanager.cpp
index a5964afc502..0b1316280d4 100644
--- a/src/osd/modules/render/bgfx/chainmanager.cpp
+++ b/src/osd/modules/render/bgfx/chainmanager.cpp
@@ -448,8 +448,10 @@ uint32_t chain_manager::handle_screen_chains(uint32_t view, render_primitive *st
}
const bool any_targets_rebuilt = m_targets.update_target_sizes(screen_index, screen_width, screen_height, TARGET_STYLE_NATIVE);
- if (any_targets_rebuilt) {
- for (bgfx_chain* chain : m_screen_chains) {
+ if (any_targets_rebuilt)
+ {
+ for (bgfx_chain* chain : m_screen_chains)
+ {
chain->repopulate_targets();
}
}
diff --git a/src/osd/modules/render/bgfx/shaders/chains/misc/vs_saturation.sc b/src/osd/modules/render/bgfx/shaders/chains/misc/vs_saturation.sc
index fc524496a1f..405ef8feb3b 100644
--- a/src/osd/modules/render/bgfx/shaders/chains/misc/vs_saturation.sc
+++ b/src/osd/modules/render/bgfx/shaders/chains/misc/vs_saturation.sc
@@ -9,6 +9,6 @@ $output v_texcoord0, v_color0
void main()
{
gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
- v_texcoord0 = a_texcoord0 * vec2(1.0 * 0.8, 0.685185 * 0.9) + vec2(0.1, 0.1);
+ v_texcoord0 = a_texcoord0;
v_color0 = a_color0;
}
diff --git a/src/osd/modules/render/bgfx/shaders/chains/pillarbox_left_horizontal/fs_offset_sat.sc b/src/osd/modules/render/bgfx/shaders/chains/pillarbox_left_horizontal/fs_offset_sat.sc
new file mode 100644
index 00000000000..c14f61601c8
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/pillarbox_left_horizontal/fs_offset_sat.sc
@@ -0,0 +1,25 @@
+$input v_color0, v_texcoord0
+
+// license:BSD-3-Clause
+// copyright-holders:Ryan Holtz
+
+#include "common.sh"
+
+// User-supplied
+uniform vec4 u_saturation;
+
+// Samplers
+SAMPLER2D(s_tex, 0);
+
+void main()
+{
+ vec4 base = texture2D(s_tex, v_texcoord0);
+ vec3 rgb = base.rgb;
+
+ vec3 gray = vec3(0.299, 0.587, 0.114);
+ float luma = dot(rgb, gray);
+ vec3 chroma = rgb - luma;
+ vec3 saturated = luma + chroma * u_saturation.x;
+
+ gl_FragColor = vec4(saturated, base.a);
+}
diff --git a/src/osd/modules/render/bgfx/shaders/chains/pillarbox_left_horizontal/vs_offset_sat.sc b/src/osd/modules/render/bgfx/shaders/chains/pillarbox_left_horizontal/vs_offset_sat.sc
new file mode 100644
index 00000000000..f071beaaa26
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/pillarbox_left_horizontal/vs_offset_sat.sc
@@ -0,0 +1,17 @@
+$input a_position, a_texcoord0, a_color0
+$output v_texcoord0, v_color0
+
+// license:BSD-3-Clause
+// copyright-holders:Ryan Holtz
+
+// Vertex shader for the left-hand pillarbox when displaying 4:3 content on a 16:9 screen.
+// Crops off roughly 10% on all borders and takes only a portion of the right-hand side of the content
+
+#include "common.sh"
+
+void main()
+{
+ gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
+ v_texcoord0 = a_texcoord0 * vec2(0.16666666 * 0.9, 1.0 * 0.8) + vec2(0.1, 0.1);
+ v_color0 = a_color0;
+} \ No newline at end of file
diff --git a/src/osd/modules/render/bgfx/shaders/chains/pillarbox_left_vertical/fs_offset_sat.sc b/src/osd/modules/render/bgfx/shaders/chains/pillarbox_left_vertical/fs_offset_sat.sc
new file mode 100644
index 00000000000..c14f61601c8
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/pillarbox_left_vertical/fs_offset_sat.sc
@@ -0,0 +1,25 @@
+$input v_color0, v_texcoord0
+
+// license:BSD-3-Clause
+// copyright-holders:Ryan Holtz
+
+#include "common.sh"
+
+// User-supplied
+uniform vec4 u_saturation;
+
+// Samplers
+SAMPLER2D(s_tex, 0);
+
+void main()
+{
+ vec4 base = texture2D(s_tex, v_texcoord0);
+ vec3 rgb = base.rgb;
+
+ vec3 gray = vec3(0.299, 0.587, 0.114);
+ float luma = dot(rgb, gray);
+ vec3 chroma = rgb - luma;
+ vec3 saturated = luma + chroma * u_saturation.x;
+
+ gl_FragColor = vec4(saturated, base.a);
+}
diff --git a/src/osd/modules/render/bgfx/shaders/chains/pillarbox_left_vertical/vs_offset_sat.sc b/src/osd/modules/render/bgfx/shaders/chains/pillarbox_left_vertical/vs_offset_sat.sc
new file mode 100644
index 00000000000..a9f6649c1e5
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/pillarbox_left_vertical/vs_offset_sat.sc
@@ -0,0 +1,17 @@
+$input a_position, a_texcoord0, a_color0
+$output v_texcoord0, v_color0
+
+// license:BSD-3-Clause
+// copyright-holders:Ryan Holtz
+
+// Vertex shader for the left-hand pillarbox when displaying 3:4 content on a 16:9 screen.
+// Crops off roughly 10% on all borders and takes only a portion of the right-hand side of the content
+
+#include "common.sh"
+
+void main()
+{
+ gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
+ v_texcoord0 = a_texcoord0 * vec2(1.0 * 0.8, 0.685185 * 0.9) + vec2(0.1, 0.1);
+ v_color0 = a_color0;
+} \ No newline at end of file
diff --git a/src/osd/modules/render/bgfx/shaders/chains/pillarbox_right_horizontal/fs_offset_sat.sc b/src/osd/modules/render/bgfx/shaders/chains/pillarbox_right_horizontal/fs_offset_sat.sc
new file mode 100644
index 00000000000..c14f61601c8
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/pillarbox_right_horizontal/fs_offset_sat.sc
@@ -0,0 +1,25 @@
+$input v_color0, v_texcoord0
+
+// license:BSD-3-Clause
+// copyright-holders:Ryan Holtz
+
+#include "common.sh"
+
+// User-supplied
+uniform vec4 u_saturation;
+
+// Samplers
+SAMPLER2D(s_tex, 0);
+
+void main()
+{
+ vec4 base = texture2D(s_tex, v_texcoord0);
+ vec3 rgb = base.rgb;
+
+ vec3 gray = vec3(0.299, 0.587, 0.114);
+ float luma = dot(rgb, gray);
+ vec3 chroma = rgb - luma;
+ vec3 saturated = luma + chroma * u_saturation.x;
+
+ gl_FragColor = vec4(saturated, base.a);
+}
diff --git a/src/osd/modules/render/bgfx/shaders/chains/pillarbox_right_horizontal/vs_offset_sat.sc b/src/osd/modules/render/bgfx/shaders/chains/pillarbox_right_horizontal/vs_offset_sat.sc
new file mode 100644
index 00000000000..a473bc4123c
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/pillarbox_right_horizontal/vs_offset_sat.sc
@@ -0,0 +1,17 @@
+$input a_position, a_texcoord0, a_color0
+$output v_texcoord0, v_color0
+
+// license:BSD-3-Clause
+// copyright-holders:Ryan Holtz
+
+// Vertex shader for the right-hand pillarbox when displaying 4:3 content on a 16:9 screen.
+// Crops off roughly 10% on all borders and takes only a portion of the right-hand side of the content
+
+#include "common.sh"
+
+void main()
+{
+ gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
+ v_texcoord0 = a_texcoord0 * vec2(0.16666666 * 0.9, 1.0 * 0.8) + vec2(0.9 - 0.16666666 * 0.9, 0.1);
+ v_color0 = a_color0;
+} \ No newline at end of file
diff --git a/src/osd/modules/render/bgfx/shaders/chains/pillarbox_right_vertical/fs_offset_sat.sc b/src/osd/modules/render/bgfx/shaders/chains/pillarbox_right_vertical/fs_offset_sat.sc
new file mode 100644
index 00000000000..c14f61601c8
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/pillarbox_right_vertical/fs_offset_sat.sc
@@ -0,0 +1,25 @@
+$input v_color0, v_texcoord0
+
+// license:BSD-3-Clause
+// copyright-holders:Ryan Holtz
+
+#include "common.sh"
+
+// User-supplied
+uniform vec4 u_saturation;
+
+// Samplers
+SAMPLER2D(s_tex, 0);
+
+void main()
+{
+ vec4 base = texture2D(s_tex, v_texcoord0);
+ vec3 rgb = base.rgb;
+
+ vec3 gray = vec3(0.299, 0.587, 0.114);
+ float luma = dot(rgb, gray);
+ vec3 chroma = rgb - luma;
+ vec3 saturated = luma + chroma * u_saturation.x;
+
+ gl_FragColor = vec4(saturated, base.a);
+}
diff --git a/src/osd/modules/render/bgfx/shaders/chains/pillarbox_right_vertical/vs_offset_sat.sc b/src/osd/modules/render/bgfx/shaders/chains/pillarbox_right_vertical/vs_offset_sat.sc
new file mode 100644
index 00000000000..8af6a293d8e
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/pillarbox_right_vertical/vs_offset_sat.sc
@@ -0,0 +1,17 @@
+$input a_position, a_texcoord0, a_color0
+$output v_texcoord0, v_color0
+
+// license:BSD-3-Clause
+// copyright-holders:Ryan Holtz
+
+// Vertex shader for the right-hand pillarbox when displaying 3:4 content on a 16:9 screen.
+// Crops off roughly 10% on all borders and takes only a portion of the right-hand side of the content
+
+#include "common.sh"
+
+void main()
+{
+ gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0));
+ v_texcoord0 = a_texcoord0 * vec2(1.0 * 0.8, 0.685185 * 0.9) + vec2(0.1, 0.9 - 0.685185 * 0.9);
+ v_color0 = a_color0;
+} \ No newline at end of file