From 61b2a8afaf012e28ef14ad946ee0bb8319232aa6 Mon Sep 17 00:00:00 2001 From: MooglyGuy Date: Sun, 13 Oct 2019 20:55:11 +0200 Subject: -bgfx: Do texture format conversion via a full-screen GPU pass. [Ryan Holtz] --- bgfx/effects/misc/blit_palette16.json | 123 +++++++++++++++++++++ bgfx/effects/misc/texconv_palette16.json | 26 +++++ bgfx/effects/misc/texconv_rgb32.json | 25 +++++ bgfx/effects/misc/texconv_yuy16.json | 27 +++++ .../shaders/dx11/chains/misc/fs_blit_palette16.bin | Bin 0 -> 608 bytes bgfx/shaders/dx11/chains/misc/fs_blit_rgb32.bin | Bin 0 -> 422 bytes bgfx/shaders/dx11/chains/misc/fs_blit_yuy16.bin | Bin 0 -> 1272 bytes bgfx/shaders/dx9/chains/misc/fs_blit_palette16.bin | Bin 0 -> 481 bytes bgfx/shaders/dx9/chains/misc/fs_blit_rgb32.bin | Bin 0 -> 291 bytes bgfx/shaders/dx9/chains/misc/fs_blit_yuy16.bin | Bin 0 -> 873 bytes .../shaders/essl/chains/misc/fs_blit_palette16.bin | Bin 0 -> 433 bytes bgfx/shaders/essl/chains/misc/fs_blit_rgb32.bin | Bin 0 -> 270 bytes bgfx/shaders/essl/chains/misc/fs_blit_yuy16.bin | Bin 0 -> 1681 bytes .../shaders/glsl/chains/misc/fs_blit_palette16.bin | Bin 0 -> 410 bytes bgfx/shaders/glsl/chains/misc/fs_blit_rgb32.bin | Bin 0 -> 253 bytes bgfx/shaders/glsl/chains/misc/fs_blit_yuy16.bin | Bin 0 -> 1603 bytes .../metal/chains/misc/fs_blit_palette16.bin | Bin 0 -> 853 bytes bgfx/shaders/metal/chains/misc/fs_blit_rgb32.bin | Bin 0 -> 648 bytes bgfx/shaders/metal/chains/misc/fs_blit_yuy16.bin | Bin 0 -> 2099 bytes 19 files changed, 201 insertions(+) create mode 100644 bgfx/effects/misc/blit_palette16.json create mode 100644 bgfx/effects/misc/texconv_palette16.json create mode 100644 bgfx/effects/misc/texconv_rgb32.json create mode 100644 bgfx/effects/misc/texconv_yuy16.json create mode 100644 bgfx/shaders/dx11/chains/misc/fs_blit_palette16.bin create mode 100644 bgfx/shaders/dx11/chains/misc/fs_blit_rgb32.bin create mode 100644 bgfx/shaders/dx11/chains/misc/fs_blit_yuy16.bin create mode 100644 bgfx/shaders/dx9/chains/misc/fs_blit_palette16.bin create mode 100644 bgfx/shaders/dx9/chains/misc/fs_blit_rgb32.bin create mode 100644 bgfx/shaders/dx9/chains/misc/fs_blit_yuy16.bin create mode 100644 bgfx/shaders/essl/chains/misc/fs_blit_palette16.bin create mode 100644 bgfx/shaders/essl/chains/misc/fs_blit_rgb32.bin create mode 100644 bgfx/shaders/essl/chains/misc/fs_blit_yuy16.bin create mode 100644 bgfx/shaders/glsl/chains/misc/fs_blit_palette16.bin create mode 100644 bgfx/shaders/glsl/chains/misc/fs_blit_rgb32.bin create mode 100644 bgfx/shaders/glsl/chains/misc/fs_blit_yuy16.bin create mode 100644 bgfx/shaders/metal/chains/misc/fs_blit_palette16.bin create mode 100644 bgfx/shaders/metal/chains/misc/fs_blit_rgb32.bin create mode 100644 bgfx/shaders/metal/chains/misc/fs_blit_yuy16.bin (limited to 'bgfx') diff --git a/bgfx/effects/misc/blit_palette16.json b/bgfx/effects/misc/blit_palette16.json new file mode 100644 index 00000000000..99d849ddd23 --- /dev/null +++ b/bgfx/effects/misc/blit_palette16.json @@ -0,0 +1,123 @@ +// license:BSD-3-Clause +// copyright-holders:Ryan Holtz +//============================================================ +// +// blit_palette16.json: A palettized 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/misc/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/misc/fs_blit_palette16", + + // 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 ] + }, + { "name": "s_pal", "type": "int", "values": [ 1.0 ] }, + { "name": "u_inv_tex_size1", "type": "vec4", "values": [ 1.0, 1.0, 0.0, 0.0 ] } + ] +} \ No newline at end of file diff --git a/bgfx/effects/misc/texconv_palette16.json b/bgfx/effects/misc/texconv_palette16.json new file mode 100644 index 00000000000..4fc8e169d0e --- /dev/null +++ b/bgfx/effects/misc/texconv_palette16.json @@ -0,0 +1,26 @@ +// license:BSD-3-Clause +// copyright-holders:Ryan Holtz +//=============================================================== +// +// texconv_palette16.json: A palettized texture-to-target copy. +// +//=============================================================== +{ + "blend": { + "equation": "add", + "srcColor": "srcalpha", + "dstColor": "1-srcalpha", + "srcAlpha": "srcalpha", + "dstAlpha": "1-srcalpha" + }, + "depth": { "function": "always", "writeenable": false }, + "cull": { "mode": "none" }, + "write": { "rgb": true, "alpha": true }, + "vertex": "chains/misc/vs_blit", + "fragment": "chains/misc/fs_blit_palette16", + "uniforms": [ + { "name": "s_tex", "type": "int", "values": [ 1.0 ] }, + { "name": "s_pal", "type": "int", "values": [ 1.0 ] }, + { "name": "u_inv_tex_size1", "type": "vec4", "values": [ 1.0, 1.0, 0.0, 0.0 ] } + ] +} \ No newline at end of file diff --git a/bgfx/effects/misc/texconv_rgb32.json b/bgfx/effects/misc/texconv_rgb32.json new file mode 100644 index 00000000000..9522eabf720 --- /dev/null +++ b/bgfx/effects/misc/texconv_rgb32.json @@ -0,0 +1,25 @@ +// license:BSD-3-Clause +// copyright-holders:Ryan Holtz +//=============================================================== +// +// texconv_rgb32.json: An opaque texture-to-target copy. +// +//=============================================================== +{ + "blend": { + "equation": "add", + "srcColor": "srcalpha", + "dstColor": "1-srcalpha", + "srcAlpha": "srcalpha", + "dstAlpha": "1-srcalpha" + }, + "depth": { "function": "always", "writeenable": false }, + "cull": { "mode": "none" }, + "write": { "rgb": true, "alpha": true }, + "vertex": "chains/misc/vs_blit", + "fragment": "chains/misc/fs_blit_rgb32", + "uniforms": [ + { "name": "s_tex", "type": "int", "values": [ 1.0 ] }, + { "name": "s_pal", "type": "int", "values": [ 1.0 ] } + ] +} \ No newline at end of file diff --git a/bgfx/effects/misc/texconv_yuy16.json b/bgfx/effects/misc/texconv_yuy16.json new file mode 100644 index 00000000000..76ae99bfe7e --- /dev/null +++ b/bgfx/effects/misc/texconv_yuy16.json @@ -0,0 +1,27 @@ +// license:BSD-3-Clause +// copyright-holders:Ryan Holtz +//=============================================================== +// +// texconv_yuy16.json: An opaque texture-to-target copy with +// YUY16 conversion. +// +//=============================================================== +{ + "blend": { + "equation": "add", + "srcColor": "srcalpha", + "dstColor": "1-srcalpha", + "srcAlpha": "srcalpha", + "dstAlpha": "1-srcalpha" + }, + "depth": { "function": "always", "writeenable": false }, + "cull": { "mode": "none" }, + "write": { "rgb": true, "alpha": true }, + "vertex": "chains/misc/vs_blit", + "fragment": "chains/misc/fs_blit_yuy16", + "uniforms": [ + { "name": "s_tex", "type": "int", "values": [ 1.0 ] }, + { "name": "u_tex_size0", "type": "vec4", "values": [ 1.0, 1.0, 0.0, 0.0 ] }, + { "name": "u_inv_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/misc/fs_blit_palette16.bin b/bgfx/shaders/dx11/chains/misc/fs_blit_palette16.bin new file mode 100644 index 00000000000..937e6a397eb Binary files /dev/null and b/bgfx/shaders/dx11/chains/misc/fs_blit_palette16.bin differ diff --git a/bgfx/shaders/dx11/chains/misc/fs_blit_rgb32.bin b/bgfx/shaders/dx11/chains/misc/fs_blit_rgb32.bin new file mode 100644 index 00000000000..54315d2a785 Binary files /dev/null and b/bgfx/shaders/dx11/chains/misc/fs_blit_rgb32.bin differ diff --git a/bgfx/shaders/dx11/chains/misc/fs_blit_yuy16.bin b/bgfx/shaders/dx11/chains/misc/fs_blit_yuy16.bin new file mode 100644 index 00000000000..22595d9a301 Binary files /dev/null and b/bgfx/shaders/dx11/chains/misc/fs_blit_yuy16.bin differ diff --git a/bgfx/shaders/dx9/chains/misc/fs_blit_palette16.bin b/bgfx/shaders/dx9/chains/misc/fs_blit_palette16.bin new file mode 100644 index 00000000000..de732eaeb0a Binary files /dev/null and b/bgfx/shaders/dx9/chains/misc/fs_blit_palette16.bin differ diff --git a/bgfx/shaders/dx9/chains/misc/fs_blit_rgb32.bin b/bgfx/shaders/dx9/chains/misc/fs_blit_rgb32.bin new file mode 100644 index 00000000000..95ee0243f77 Binary files /dev/null and b/bgfx/shaders/dx9/chains/misc/fs_blit_rgb32.bin differ diff --git a/bgfx/shaders/dx9/chains/misc/fs_blit_yuy16.bin b/bgfx/shaders/dx9/chains/misc/fs_blit_yuy16.bin new file mode 100644 index 00000000000..4cb90783758 Binary files /dev/null and b/bgfx/shaders/dx9/chains/misc/fs_blit_yuy16.bin differ diff --git a/bgfx/shaders/essl/chains/misc/fs_blit_palette16.bin b/bgfx/shaders/essl/chains/misc/fs_blit_palette16.bin new file mode 100644 index 00000000000..89d4238ff31 Binary files /dev/null and b/bgfx/shaders/essl/chains/misc/fs_blit_palette16.bin differ diff --git a/bgfx/shaders/essl/chains/misc/fs_blit_rgb32.bin b/bgfx/shaders/essl/chains/misc/fs_blit_rgb32.bin new file mode 100644 index 00000000000..27ac711287b Binary files /dev/null and b/bgfx/shaders/essl/chains/misc/fs_blit_rgb32.bin differ diff --git a/bgfx/shaders/essl/chains/misc/fs_blit_yuy16.bin b/bgfx/shaders/essl/chains/misc/fs_blit_yuy16.bin new file mode 100644 index 00000000000..486b2e54fae Binary files /dev/null and b/bgfx/shaders/essl/chains/misc/fs_blit_yuy16.bin differ diff --git a/bgfx/shaders/glsl/chains/misc/fs_blit_palette16.bin b/bgfx/shaders/glsl/chains/misc/fs_blit_palette16.bin new file mode 100644 index 00000000000..fcc74605d9d Binary files /dev/null and b/bgfx/shaders/glsl/chains/misc/fs_blit_palette16.bin differ diff --git a/bgfx/shaders/glsl/chains/misc/fs_blit_rgb32.bin b/bgfx/shaders/glsl/chains/misc/fs_blit_rgb32.bin new file mode 100644 index 00000000000..fb202dc8be6 Binary files /dev/null and b/bgfx/shaders/glsl/chains/misc/fs_blit_rgb32.bin differ diff --git a/bgfx/shaders/glsl/chains/misc/fs_blit_yuy16.bin b/bgfx/shaders/glsl/chains/misc/fs_blit_yuy16.bin new file mode 100644 index 00000000000..10af2a13cd1 Binary files /dev/null and b/bgfx/shaders/glsl/chains/misc/fs_blit_yuy16.bin differ diff --git a/bgfx/shaders/metal/chains/misc/fs_blit_palette16.bin b/bgfx/shaders/metal/chains/misc/fs_blit_palette16.bin new file mode 100644 index 00000000000..189a3035cfc Binary files /dev/null and b/bgfx/shaders/metal/chains/misc/fs_blit_palette16.bin differ diff --git a/bgfx/shaders/metal/chains/misc/fs_blit_rgb32.bin b/bgfx/shaders/metal/chains/misc/fs_blit_rgb32.bin new file mode 100644 index 00000000000..149a4ae93cc Binary files /dev/null and b/bgfx/shaders/metal/chains/misc/fs_blit_rgb32.bin differ diff --git a/bgfx/shaders/metal/chains/misc/fs_blit_yuy16.bin b/bgfx/shaders/metal/chains/misc/fs_blit_yuy16.bin new file mode 100644 index 00000000000..a21369934bb Binary files /dev/null and b/bgfx/shaders/metal/chains/misc/fs_blit_yuy16.bin differ -- cgit v1.2.3-70-g09d2