diff options
| author | 2016-04-19 16:29:30 +0200 | |
|---|---|---|
| committer | 2016-04-19 16:29:30 +0200 | |
| commit | f8034ac81238c8637c149dc40efdc4c42dda9545 (patch) | |
| tree | 9c34c76d9067ce8e3803764896b10c4cfa401df9 | |
| parent | c64b88bc78a4810ce0c75eb4d6651e5a26cc2bad (diff) | |
bgfx: Added SuperEagle shader. [Ryan Holtz]
28 files changed, 450 insertions, 0 deletions
diff --git a/bgfx/chains/supereagle.json b/bgfx/chains/supereagle.json new file mode 100644 index 00000000000..0f12a85e095 --- /dev/null +++ b/bgfx/chains/supereagle.json @@ -0,0 +1,44 @@ +// license:GPL-2.0+ +// copyright-holders:The DOSBox Team + +/* SuperEagle code */ +/* Copied from the Dosbox source code */ +/* Copyright (C) 2002-2007 The DOSBox Team */ +/* License: GNU-GPL */ +/* Adapted by guest(r) on 16.4.2007 */ + +{ + "name": "Super Eagle", + "author": "Shader version by The DOSBox Team", + "targets": [ + { + "name": "scaled_out", + "mode": "guest", + "scale": 2, + "doublebuffer": true + }, + { + "name": "internal", + "mode": "native", + "doublebuffer": true + } + ], + "passes": [ + { + "effect": "supereagle/supereagle", + "name": "Super Eagle pass", + "input": [ + { "sampler": "decal", "texture": "screen" }, + { "sampler": "LUT", "texture": "bgfx/chains/hq2x.png", "bilinear": true } + ], + "output": "scaled_out" + }, + { "effect": "hq2x/blit", + "name": "Final Blit", + "input": [ + { "sampler": "s_tex", "target": "scaled_out" } + ], + "output": "output" + } + ] +}
\ No newline at end of file diff --git a/bgfx/effects/supereagle/blit.json b/bgfx/effects/supereagle/blit.json new file mode 100644 index 00000000000..24c3acf5a5d --- /dev/null +++ b/bgfx/effects/supereagle/blit.json @@ -0,0 +1,121 @@ +// license:BSD-3-Clause +// copyright-holders:Ryan Holtz +//============================================================ +// +// blit.json: A simple texture-to-target copy. +// +//============================================================ +{ + // blend (required): The blend state for this effect. + "blend": { + // equation (optional): What equation to perform on the source and destination blend values. + // values: "add", "sub", "revSub", "min", "max" + // default: "add" + // + // "subtract" and "revSubtract" are provided as aliases for "sub" and "revSub" + "equation": "add", + + // blend function parameters (optional): What factors to use in the blend function when calculating the final pixel. + // values: "0", "1", "srccolor", "1-srccolor", "dstcolor", "1-dstcolor", "srcalpha", "1-srcalpha", "dstalpha", "1-dstalpha" + // defaults (srcColor, srcAlpha): "1" + // defaults (dstColor, dstAlpha): "0" + // + // "zero", "one", "invsrccolor", "invdstcolor", "invsrcalpha", and "invdstalpha" are provided as aliases for "0", "1", "1-srccolor", "1-dstcolor", "1-srcalpha", and "1-dstalpha" + "srcColor": "srcalpha", + "dstColor": "1-srcalpha", + "srcAlpha": "srcalpha", + "dstAlpha": "1-srcalpha" + }, + + // depth (required): The depth state for this effect. + "depth": { + // function (optional): The depth function to use when drawing. + // values: "never", "less", "equal", "lequal", "greater", "notequal", "gequal", "always" + // default: "always" + "function": "always", + + // writeenable (optional): Whether to store Z-buffer data. + // values: true, false + // default: false + "writeenable": false + }, + + // cull (required): The cull mode for this effect. + "cull": { + // mode (optional): What winding, if any, to cull. + // values: "none", "cw", "ccw" + // default: "ccw" + // + // "clockwise" and "counterclockwise" are provided as aliases for "cw" and "ccw" + "mode": "none" + }, + + // write (required): Write enable for color and alpha channels. + "write": { + // rgb (optional): Whether to store color data when drawing. + // values: true, false + // default: false + "rgb": true, + + // alpha (optional): Whether to store alpha data when drawing. + // values: true, false + // default: false + "alpha": true + }, + + // vertex (required): The vertex shader to use when drawing. + // value: A string containing the path and name of a shader file to use, minus the extension. + "vertex": "chains/supereagle/vs_blit", + + // pixel/fragment (required): The pixel or fragment shader to use when drawing. + // value: A string containing the path and name of a shader file to use, minus the extension. + "fragment": "chains/supereagle/fs_blit", + + // uniforms (required): The list of uniforms for this effect. Can be empty, but must exist. + "uniforms": [ + { + // name (required): The name of the uniform, as used in either the vertex or pixel/fragment shader. + // value: A string containing the name of the uniform as described above. + // + // NOTE: Some names correspond to special values that will be automatically filled by the BGFX + // code if they are used by the shader. These names are: + // "u_screen_dims" + // The dimensions of the first texture input if present, otherwise the dimensions of the output window. + // Valid values: xy + // "u_inv_screen_dims" + // The reciprocal of u_screen_dims. + // Valid values: xy + // "u_source_dims" + // The size, in pixels, of the screen texture incoming to the chain. + // Valid values: xy + // "u_rotation_type" + // This screen's rotation type. 0 if ROT0, 1 if ROT90, 2 if ROT180, 3 of ROT270. + // Valid values: x + // "u_swap_xy" + // Whether this screen is swapped on the X and Y axes. 1 if true, 0 if false. + // Valid values: x + // "u_quad_dims" + // The dimensions, in pixels, occupied by this one screen primitive itself in the output window. + // Valid values: xy + // "u_tex_sizeN" + // The dimensions, in pixels, of the texture in input pair N. Starts at 0. + // valid values: xy + "name": "s_tex", + + // type (required): The type of the uniform. + // values: "int", "vec4", "mat3", "mat4" + // + // Note: "int" should only be used for samplers. + "type": "int", + + // values (required): The array of numbers with which to initialize the uniform. + // value: A JSON array containin the correct amount of numbers to initialize a uniform of the + // above-specified type. The following size rules should be followed: + // "int": 1 float + // "vec4": 4 floats + // "mat3": 9 floats + // "mat4": 16 floats + "values": [ 1.0 ] + } + ] +}
\ No newline at end of file diff --git a/bgfx/effects/supereagle/supereagle.json b/bgfx/effects/supereagle/supereagle.json new file mode 100644 index 00000000000..03f40691751 --- /dev/null +++ b/bgfx/effects/supereagle/supereagle.json @@ -0,0 +1,35 @@ +// license:GPL-2.0+ +// copyright-holders:The DOSBox Team + +/* SuperEagle code */ +/* Copied from the Dosbox source code */ +/* Copyright (C) 2002-2007 The DOSBox Team */ +/* License: GNU-GPL */ +/* Adapted by guest(r) on 16.4.2007 */ +{ + "blend": { + "equation": "add", + "srcColor": "1", + "dstColor": "0", + "srcAlpha": "1", + "dstAlpha": "0" + }, + "depth": { + "function": "always", + "writeenable": false + }, + "cull": { + "mode": "none" + }, + "write": { + "rgb": true, + "alpha": true + }, + "vertex": "chains/supereagle/vs_eagle", + "fragment": "chains/supereagle/fs_eagle", + "uniforms": [ + { "name": "decal", "type": "int", "values": [ 1.0 ] }, + { "name": "LUT", "type": "int", "values": [ 1.0 ] }, + { "name": "u_tex_size0", "type": "vec4", "values": [ 1.0, 1.0, 0.0, 0.0 ] } + ] +}
\ No newline at end of file diff --git a/bgfx/shaders/dx11/chains/supereagle/fs_blit.bin b/bgfx/shaders/dx11/chains/supereagle/fs_blit.bin Binary files differnew file mode 100644 index 00000000000..7b633fde6ed --- /dev/null +++ b/bgfx/shaders/dx11/chains/supereagle/fs_blit.bin diff --git a/bgfx/shaders/dx11/chains/supereagle/fs_eagle.bin b/bgfx/shaders/dx11/chains/supereagle/fs_eagle.bin Binary files differnew file mode 100644 index 00000000000..085fbc010d6 --- /dev/null +++ b/bgfx/shaders/dx11/chains/supereagle/fs_eagle.bin diff --git a/bgfx/shaders/dx11/chains/supereagle/vs_blit.bin b/bgfx/shaders/dx11/chains/supereagle/vs_blit.bin Binary files differnew file mode 100644 index 00000000000..8ca25c11eae --- /dev/null +++ b/bgfx/shaders/dx11/chains/supereagle/vs_blit.bin diff --git a/bgfx/shaders/dx11/chains/supereagle/vs_eagle.bin b/bgfx/shaders/dx11/chains/supereagle/vs_eagle.bin Binary files differnew file mode 100644 index 00000000000..d4773f1abdf --- /dev/null +++ b/bgfx/shaders/dx11/chains/supereagle/vs_eagle.bin diff --git a/bgfx/shaders/dx9/chains/supereagle/fs_blit.bin b/bgfx/shaders/dx9/chains/supereagle/fs_blit.bin Binary files differnew file mode 100644 index 00000000000..7db80471603 --- /dev/null +++ b/bgfx/shaders/dx9/chains/supereagle/fs_blit.bin diff --git a/bgfx/shaders/dx9/chains/supereagle/fs_eagle.bin b/bgfx/shaders/dx9/chains/supereagle/fs_eagle.bin Binary files differnew file mode 100644 index 00000000000..7f099756105 --- /dev/null +++ b/bgfx/shaders/dx9/chains/supereagle/fs_eagle.bin diff --git a/bgfx/shaders/dx9/chains/supereagle/vs_blit.bin b/bgfx/shaders/dx9/chains/supereagle/vs_blit.bin Binary files differnew file mode 100644 index 00000000000..87ff0b96020 --- /dev/null +++ b/bgfx/shaders/dx9/chains/supereagle/vs_blit.bin diff --git a/bgfx/shaders/dx9/chains/supereagle/vs_eagle.bin b/bgfx/shaders/dx9/chains/supereagle/vs_eagle.bin Binary files differnew file mode 100644 index 00000000000..6bf98d22532 --- /dev/null +++ b/bgfx/shaders/dx9/chains/supereagle/vs_eagle.bin diff --git a/bgfx/shaders/gles/chains/supereagle/fs_blit.bin b/bgfx/shaders/gles/chains/supereagle/fs_blit.bin Binary files differnew file mode 100644 index 00000000000..fab8eaf63d2 --- /dev/null +++ b/bgfx/shaders/gles/chains/supereagle/fs_blit.bin diff --git a/bgfx/shaders/gles/chains/supereagle/fs_eagle.bin b/bgfx/shaders/gles/chains/supereagle/fs_eagle.bin Binary files differnew file mode 100644 index 00000000000..76ba019d544 --- /dev/null +++ b/bgfx/shaders/gles/chains/supereagle/fs_eagle.bin diff --git a/bgfx/shaders/gles/chains/supereagle/vs_blit.bin b/bgfx/shaders/gles/chains/supereagle/vs_blit.bin Binary files differnew file mode 100644 index 00000000000..499face3174 --- /dev/null +++ b/bgfx/shaders/gles/chains/supereagle/vs_blit.bin diff --git a/bgfx/shaders/gles/chains/supereagle/vs_eagle.bin b/bgfx/shaders/gles/chains/supereagle/vs_eagle.bin Binary files differnew file mode 100644 index 00000000000..a67ebb5a044 --- /dev/null +++ b/bgfx/shaders/gles/chains/supereagle/vs_eagle.bin diff --git a/bgfx/shaders/glsl/chains/supereagle/fs_blit.bin b/bgfx/shaders/glsl/chains/supereagle/fs_blit.bin Binary files differnew file mode 100644 index 00000000000..3104b9e54b2 --- /dev/null +++ b/bgfx/shaders/glsl/chains/supereagle/fs_blit.bin diff --git a/bgfx/shaders/glsl/chains/supereagle/fs_eagle.bin b/bgfx/shaders/glsl/chains/supereagle/fs_eagle.bin Binary files differnew file mode 100644 index 00000000000..1c640de9db8 --- /dev/null +++ b/bgfx/shaders/glsl/chains/supereagle/fs_eagle.bin diff --git a/bgfx/shaders/glsl/chains/supereagle/vs_blit.bin b/bgfx/shaders/glsl/chains/supereagle/vs_blit.bin Binary files differnew file mode 100644 index 00000000000..88ad318046c --- /dev/null +++ b/bgfx/shaders/glsl/chains/supereagle/vs_blit.bin diff --git a/bgfx/shaders/glsl/chains/supereagle/vs_eagle.bin b/bgfx/shaders/glsl/chains/supereagle/vs_eagle.bin Binary files differnew file mode 100644 index 00000000000..d5eccb4c173 --- /dev/null +++ b/bgfx/shaders/glsl/chains/supereagle/vs_eagle.bin diff --git a/bgfx/shaders/metal/chains/supereagle/fs_blit.bin b/bgfx/shaders/metal/chains/supereagle/fs_blit.bin Binary files differnew file mode 100644 index 00000000000..a0cb475e932 --- /dev/null +++ b/bgfx/shaders/metal/chains/supereagle/fs_blit.bin diff --git a/bgfx/shaders/metal/chains/supereagle/fs_eagle.bin b/bgfx/shaders/metal/chains/supereagle/fs_eagle.bin Binary files differnew file mode 100644 index 00000000000..2d70baf9545 --- /dev/null +++ b/bgfx/shaders/metal/chains/supereagle/fs_eagle.bin diff --git a/bgfx/shaders/metal/chains/supereagle/vs_blit.bin b/bgfx/shaders/metal/chains/supereagle/vs_blit.bin Binary files differnew file mode 100644 index 00000000000..eee8677be39 --- /dev/null +++ b/bgfx/shaders/metal/chains/supereagle/vs_blit.bin diff --git a/bgfx/shaders/metal/chains/supereagle/vs_eagle.bin b/bgfx/shaders/metal/chains/supereagle/vs_eagle.bin Binary files differnew file mode 100644 index 00000000000..268549ac9d2 --- /dev/null +++ b/bgfx/shaders/metal/chains/supereagle/vs_eagle.bin diff --git a/src/osd/modules/render/bgfx/shaders/chains/supereagle/fs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/supereagle/fs_blit.sc new file mode 100644 index 00000000000..874846cce0d --- /dev/null +++ b/src/osd/modules/render/bgfx/shaders/chains/supereagle/fs_blit.sc @@ -0,0 +1,14 @@ +$input v_color0, texCoord + +// license:BSD-3-Clause +// copyright-holders:Dario Manesku + +#include "common.sh" + +// Samplers +SAMPLER2D(s_tex, 0); + +void main() +{ + gl_FragColor = texture2D(s_tex, texCoord) * v_color0; +} diff --git a/src/osd/modules/render/bgfx/shaders/chains/supereagle/fs_eagle.sc b/src/osd/modules/render/bgfx/shaders/chains/supereagle/fs_eagle.sc new file mode 100644 index 00000000000..a07a848ffbd --- /dev/null +++ b/src/osd/modules/render/bgfx/shaders/chains/supereagle/fs_eagle.sc @@ -0,0 +1,165 @@ +$input v_color0, texCoord, t1, t2, t3, t4, t5, t6, t7, t8 + +// license:GPL-2.0+ +// copyright-holders:The DOSBox Team + +/* SuperEagle code */ +/* Copied from the Dosbox source code */ +/* Copyright (C) 2002-2007 The DOSBox Team */ +/* License: GNU-GPL */ +/* Adapted by guest(r) on 16.4.2007 */ + +#include "common.sh" + +// Autos +uniform vec4 u_tex_size0; + +// Samplers +SAMPLER2D(decal, 0); + +float reduce(vec3 color) +{ + return dot(color, vec3(65536.0, 255.0, 1.0)); +} + +/* GET_RESULT function */ +/* Copyright (c) 1999-2001 by Derek Liauw Kie Fa */ +/* License: GNU-GPL */ +float GET_RESULT(float A, float B, float C, float D) +{ + float x = 0.0; + float y = 0.0; + float r = 0.0; + if (A == C) x += 1.0; else if (B == C) y += 1.0; + if (A == D) x += 1.0; else if (B == D) y += 1.0; + if (x <= 1.0) r += 1.0; + if (y <= 1.0) r -= 1.0; + return r; +} + +void main() +{ + vec2 fp = fract(texCoord * u_tex_size0.xy); + + // Reading the texels + + vec3 C0 = texture2D(decal, t1.xy).xyz; + vec3 C1 = texture2D(decal, t1.zw).xyz; + vec3 C2 = texture2D(decal, t2.xy).xyz; + vec3 D3 = texture2D(decal, t2.zw).xyz; + vec3 C3 = texture2D(decal, t3.xy).xyz; + vec3 C4 = texture2D(decal, texCoord).xyz; + vec3 C5 = texture2D(decal, t3.zw).xyz; + vec3 D4 = texture2D(decal, t4.xy).xyz; + vec3 C6 = texture2D(decal, t4.zw).xyz; + vec3 C7 = texture2D(decal, t5.xy).xyz; + vec3 C8 = texture2D(decal, t5.zw).xyz; + vec3 D5 = texture2D(decal, t6.xy).xyz; + vec3 D0 = texture2D(decal, t6.zw).xyz; + vec3 D1 = texture2D(decal, t7.xy).xyz; + vec3 D2 = texture2D(decal, t7.zw).xyz; + vec3 D6 = texture2D(decal, t8.xy).xyz; + + vec3 p00,p10,p01,p11; + + // reducing float3 to float + float c0 = reduce(C0); float c1 = reduce(C1); + float c2 = reduce(C2); float c3 = reduce(C3); + float c4 = reduce(C4); float c5 = reduce(C5); + float c6 = reduce(C6); float c7 = reduce(C7); + float c8 = reduce(C8); float d0 = reduce(D0); + float d1 = reduce(D1); float d2 = reduce(D2); + float d3 = reduce(D3); float d4 = reduce(D4); + float d5 = reduce(D5); float d6 = reduce(D6); + + /* SuperEagle code */ + /* Copied from the Dosbox source code */ + /* Copyright (C) 2002-2007 The DOSBox Team */ + /* License: GNU-GPL */ + /* Adapted by guest(r) on 16.4.2007 */ + if (c4 != c8) + { + if (c7 == c5) + { + p01 = p10 = C7; + if ((c6 == c7) || (c5 == c2)) + { + p00 = 0.25 * (3.0 * C7 + C4); + } + else + { + p00 = 0.5 * (C4 + C5); + } + + if ((c5 == d4) || (c7 == d1)) + { + p11 = 0.25 * (3.0 * C7 + C8); + } + else + { + p11 = 0.5 * (C7 + C8); + } + } + else + { + p11 = 0.125 * (6.0 * C8 + C7 + C5); + p00 = 0.125 * (6.0 * C4 + C7 + C5); + + p10 = 0.125 * (6.0 * C7 + C4 + C8); + p01 = 0.125 * (6.0 * C5 + C4 + C8); + } + } + else + { + if (c7 != c5) + { + p11 = p00 = C4; + + if ((c1 == c4) || (c8 == d5)) + { + p01 = 0.25 * (3.0 * C4 + C5); + } + else + { + p01 = 0.5 * (C4 + C5); + } + + if ((c8 == d2) || (c3 == c4)) + { + p10 = 0.25 * (3.0 * C4 + C7); + } + else + { + p10 = 0.5 * (C7 + C8); + } + } + else + { + float r = 0.0; + r += GET_RESULT(c5, c4, c6, d1); + r += GET_RESULT(c5, c4, c3, c1); + r += GET_RESULT(c5, c4, d2, d5); + r += GET_RESULT(c5, c4, c2, d4); + + if (r > 0.0) + { + p01 = p10 = C7; + p00 = p11 = 0.5 * (C4 + C5); + } + else if (r < 0.0) + { + p11 = p00 = C4; + p01 = p10 = 0.5 * (C4 + C5); + } + else + { + p11 = p00 = C4; + p01 = p10 = C7; + } + } + } + + p10 = (fp.x < 0.50) ? (fp.y < 0.50 ? p00 : p10) : (fp.y < 0.50 ? p01: p11); + + gl_FragColor = vec4(p10.rgb, 1.0); +} diff --git a/src/osd/modules/render/bgfx/shaders/chains/supereagle/varying.def.sc b/src/osd/modules/render/bgfx/shaders/chains/supereagle/varying.def.sc new file mode 100644 index 00000000000..7adabc462e5 --- /dev/null +++ b/src/osd/modules/render/bgfx/shaders/chains/supereagle/varying.def.sc @@ -0,0 +1,14 @@ +vec4 v_color0 : COLOR0 = vec4(1.0, 0.0, 0.0, 1.0); +vec2 texCoord : TEXCOORD0 = vec2(0.0, 0.0); +vec4 t1 : TEXCOORD1 = vec4(0.0, 0.0, 0.0, 0.0); +vec4 t2 : TEXCOORD2 = vec4(0.0, 0.0, 0.0, 0.0); +vec4 t3 : TEXCOORD3 = vec4(0.0, 0.0, 0.0, 0.0); +vec4 t4 : TEXCOORD4 = vec4(0.0, 0.0, 0.0, 0.0); +vec4 t5 : TEXCOORD5 = vec4(0.0, 0.0, 0.0, 0.0); +vec4 t6 : TEXCOORD6 = vec4(0.0, 0.0, 0.0, 0.0); +vec4 t7 : TEXCOORD7 = vec4(0.0, 0.0, 0.0, 0.0); +vec4 t8 : TEXCOORD8 = vec4(0.0, 0.0, 0.0, 0.0); + +vec3 a_position : POSITION; +vec4 a_color0 : COLOR0; +vec2 a_texcoord0 : TEXCOORD0; diff --git a/src/osd/modules/render/bgfx/shaders/chains/supereagle/vs_blit.sc b/src/osd/modules/render/bgfx/shaders/chains/supereagle/vs_blit.sc new file mode 100644 index 00000000000..7d857008291 --- /dev/null +++ b/src/osd/modules/render/bgfx/shaders/chains/supereagle/vs_blit.sc @@ -0,0 +1,14 @@ +$input a_position, a_texcoord0, a_color0 +$output texCoord, v_color0 + +// license:BSD-3-Clause +// copyright-holders:Dario Manesku + +#include "common.sh" + +void main() +{ + gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0)); + texCoord = a_texcoord0.xy; + v_color0 = a_color0; +} diff --git a/src/osd/modules/render/bgfx/shaders/chains/supereagle/vs_eagle.sc b/src/osd/modules/render/bgfx/shaders/chains/supereagle/vs_eagle.sc new file mode 100644 index 00000000000..d233629a036 --- /dev/null +++ b/src/osd/modules/render/bgfx/shaders/chains/supereagle/vs_eagle.sc @@ -0,0 +1,43 @@ +$input a_position, a_texcoord0, a_color0 +$output v_color0, texCoord, t1, t2, t3, t4, t5, t6, t7, t8 + +// license:GPL-2.0+ +// copyright-holders:The DOSBox Team + +/* SuperEagle code */ +/* Copied from the Dosbox source code */ +/* Copyright (C) 2002-2007 The DOSBox Team */ +/* License: GNU-GPL */ +/* Adapted by guest(r) on 16.4.2007 */ + +#include "common.sh" + +// Autos +uniform vec4 u_tex_size0; + +void main() +{ + gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0)); + v_color0 = a_color0; + + vec2 ps = vec2(1.0, 1.0) / u_tex_size0.xy; + float dx = ps.x; + float dy = ps.y; + + texCoord = a_texcoord0.xy; + t1.xy = texCoord + vec2(-dx,-dy); + t1.zw = texCoord + vec2(-dx, 0); + t2.xy = texCoord + vec2(+dx,-dy); + t2.zw = texCoord + vec2(+dx+dx,-dy); + t3.xy = texCoord + vec2(-dx, 0); + t3.zw = texCoord + vec2(+dx, 0); + t4.xy = texCoord + vec2(+dx+dx, 0); + t4.zw = texCoord + vec2(-dx,+dy); + t5.xy = texCoord + vec2( 0,+dy); + t5.zw = texCoord + vec2(+dx,+dy); + t6.xy = texCoord + vec2(+dx+dx,+dy); + t6.zw = texCoord + vec2(-dx,+dy+dy); + t7.xy = texCoord + vec2( 0,+dy+dy); + t7.zw = texCoord + vec2(+dx,+dy+dy); + t8.xy = texCoord + vec2(+dx+dx,+dy+dy); +} |
