Fix crash when using pillarbox shaders, nw

This commit is contained in:
therealmogminer@gmail.com 2016-05-27 14:45:28 +02:00
parent db284904b2
commit f263110d93
64 changed files with 326 additions and 12 deletions

View File

@ -79,7 +79,7 @@
"output": "internal"
},
{
"effect": "misc/saturation",
"effect": "pillarbox_left_horizontal/offset_sat",
"name": "Saturation Pass",
"disablewhen": [
{ "type": "slider", "condition": "equal", "name": "saturation", "value": 100 }

View File

@ -79,7 +79,7 @@
"output": "internal"
},
{
"effect": "misc/saturation",
"effect": "pillarbox_left_vertical/offset_sat",
"name": "Saturation Pass",
"disablewhen": [
{ "type": "slider", "condition": "equal", "name": "saturation", "value": 100 }

View File

@ -79,7 +79,7 @@
"output": "internal"
},
{
"effect": "misc/saturation",
"effect": "pillarbox_right_horizontal/offset_sat",
"name": "Saturation Pass",
"disablewhen": [
{ "type": "slider", "condition": "equal", "name": "saturation", "value": 100 }

View File

@ -79,7 +79,7 @@
"output": "internal"
},
{
"effect": "misc/saturation",
"effect": "pillarbox_right_vertical/offset_sat",
"name": "Saturation Pass",
"disablewhen": [
{ "type": "slider", "condition": "equal", "name": "saturation", "value": 100 }

View File

@ -0,0 +1,34 @@
// license:BSD-3-Clause
// copyright-holders:Ryan Holtz
//============================================================
//
// offset_sat.json: Applies saturation to an image.
//
// Additionally, takes only a portion of the image, as
// this instance is intended for the left-hand pillarbox
// when displaying 4:3 content on a 16:9 screen.
//
//============================================================
{
"blend": {
"equation": "add",
"srcColor": "srcalpha",
"dstColor": "1-srcalpha",
"srcAlpha": "srcalpha",
"dstAlpha": "1-srcalpha"
},
"depth": {
"function": "always"
},
"cull": { "mode": "none" },
"write": {
"rgb": true,
"alpha": true
},
"vertex": "chains/pillarbox_left_horizontal/vs_offset_sat",
"fragment": "chains/pillarbox_left_horizontal/fs_offset_sat",
"uniforms": [
{ "name": "s_tex", "type": "int", "values": [ 1.0 ] },
{ "name": "u_saturation", "type": "vec4", "values": [ 1.0, 0.0, 0.0, 0.0 ] }
]
}

View File

@ -0,0 +1,34 @@
// license:BSD-3-Clause
// copyright-holders:Ryan Holtz
//============================================================
//
// offset_sat.json: Applies saturation to an image.
//
// Additionally, takes only a portion of the image, as
// this instance is intended for the left-hand pillarbox
// when displaying 3:4 content on a 16:9 screen.
//
//============================================================
{
"blend": {
"equation": "add",
"srcColor": "srcalpha",
"dstColor": "1-srcalpha",
"srcAlpha": "srcalpha",
"dstAlpha": "1-srcalpha"
},
"depth": {
"function": "always"
},
"cull": { "mode": "none" },
"write": {
"rgb": true,
"alpha": true
},
"vertex": "chains/pillarbox_left_vertical/vs_offset_sat",
"fragment": "chains/pillarbox_left_vertical/fs_offset_sat",
"uniforms": [
{ "name": "s_tex", "type": "int", "values": [ 1.0 ] },
{ "name": "u_saturation", "type": "vec4", "values": [ 1.0, 0.0, 0.0, 0.0 ] }
]
}

View File

@ -0,0 +1,34 @@
// license:BSD-3-Clause
// copyright-holders:Ryan Holtz
//============================================================
//
// offset_sat.json: Applies saturation to an image.
//
// Additionally, takes only a portion of the image, as
// this instance is intended for the right-hand pillarbox
// when displaying 4:3 content on a 16:9 screen.
//
//============================================================
{
"blend": {
"equation": "add",
"srcColor": "srcalpha",
"dstColor": "1-srcalpha",
"srcAlpha": "srcalpha",
"dstAlpha": "1-srcalpha"
},
"depth": {
"function": "always"
},
"cull": { "mode": "none" },
"write": {
"rgb": true,
"alpha": true
},
"vertex": "chains/pillarbox_right_horizontal/vs_offset_sat",
"fragment": "chains/pillarbox_right_horizontal/fs_offset_sat",
"uniforms": [
{ "name": "s_tex", "type": "int", "values": [ 1.0 ] },
{ "name": "u_saturation", "type": "vec4", "values": [ 1.0, 0.0, 0.0, 0.0 ] }
]
}

View File

@ -0,0 +1,34 @@
// license:BSD-3-Clause
// copyright-holders:Ryan Holtz
//============================================================
//
// offset_sat.json: Applies saturation to an image.
//
// Additionally, takes only a portion of the image, as
// this instance is intended for the right-hand pillarbox
// when displaying 3:4 content on a 16:9 screen.
//
//============================================================
{
"blend": {
"equation": "add",
"srcColor": "srcalpha",
"dstColor": "1-srcalpha",
"srcAlpha": "srcalpha",
"dstAlpha": "1-srcalpha"
},
"depth": {
"function": "always"
},
"cull": { "mode": "none" },
"write": {
"rgb": true,
"alpha": true
},
"vertex": "chains/pillarbox_right_vertical/vs_offset_sat",
"fragment": "chains/pillarbox_right_vertical/fs_offset_sat",
"uniforms": [
{ "name": "s_tex", "type": "int", "values": [ 1.0 ] },
{ "name": "u_saturation", "type": "vec4", "values": [ 1.0, 0.0, 0.0, 0.0 ] }
]
}

View File

@ -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)
{

View File

@ -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();
}
}

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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;
}