mirror of
https://github.com/holub/mame
synced 2025-04-19 15:11:37 +03:00
parent
5b483a2f44
commit
af2860f6f1
@ -156,6 +156,7 @@
|
||||
"passes": [
|
||||
{
|
||||
"effect": "crt-geom/phosphor_apply",
|
||||
"applytint": true,
|
||||
"name": "phosphor apply",
|
||||
"uniforms": [
|
||||
{ "uniform": "u_phosphor_power", "slider": "phosphor_power" },
|
||||
|
@ -108,6 +108,7 @@
|
||||
"passes": [
|
||||
{
|
||||
"effect": "crt-geom/crt-geom",
|
||||
"applytint": true,
|
||||
"name": "CRT",
|
||||
"uniforms": [
|
||||
{ "uniform": "curvature", "slider": "curvature" },
|
||||
|
@ -8,6 +8,7 @@
|
||||
],
|
||||
"passes": [
|
||||
{ "effect": "misc/blit",
|
||||
"applytint": true,
|
||||
"name": "Copy To Filtered Texture",
|
||||
"input": [
|
||||
{ "sampler": "s_tex", "texture": "screen" }
|
||||
|
@ -26,6 +26,7 @@
|
||||
"passes": [
|
||||
{
|
||||
"effect": "eagle/supereagle",
|
||||
"applytint": true,
|
||||
"name": "Super Eagle pass",
|
||||
"input": [
|
||||
{ "sampler": "decal", "texture": "screen" },
|
||||
|
@ -43,6 +43,7 @@
|
||||
"passes": [
|
||||
{
|
||||
"effect": "hqx/hq2x",
|
||||
"applytint": true,
|
||||
"name": "HQ2x pass",
|
||||
"input": [
|
||||
{ "sampler": "decal", "texture": "screen" },
|
||||
|
@ -43,6 +43,7 @@
|
||||
"passes": [
|
||||
{
|
||||
"effect": "hqx/hq3x",
|
||||
"applytint": true,
|
||||
"name": "HQ3x pass",
|
||||
"input": [
|
||||
{ "sampler": "decal", "texture": "screen" },
|
||||
|
@ -43,6 +43,7 @@
|
||||
"passes": [
|
||||
{
|
||||
"effect": "hqx/hq4x",
|
||||
"applytint": true,
|
||||
"name": "HQ4x pass",
|
||||
"input": [
|
||||
{ "sampler": "decal", "texture": "screen" },
|
||||
|
@ -10,6 +10,7 @@
|
||||
"passes": [
|
||||
{
|
||||
"effect": "misc/blit",
|
||||
"applytint": true,
|
||||
"name": "Copy To Filtered Texture",
|
||||
"input": [
|
||||
{ "sampler": "s_tex", "texture": "screen" }
|
||||
|
@ -2,6 +2,7 @@
|
||||
"author": "Ryan Holtz",
|
||||
"passes": [
|
||||
{ "effect": "misc/blit",
|
||||
"applytint": true,
|
||||
"name": "Unfiltered Upscale",
|
||||
"input": [
|
||||
{ "sampler": "s_tex", "texture": "screen" }
|
||||
|
@ -42,6 +42,7 @@
|
||||
"passes": [
|
||||
{
|
||||
"effect": "xbr/super-xbr/super-2xbr-3d-pass0",
|
||||
"applytint": true,
|
||||
"name": "Pass 0",
|
||||
"input": [
|
||||
{ "sampler": "s0", "texture": "screen" }
|
||||
|
@ -42,6 +42,7 @@
|
||||
"passes": [
|
||||
{
|
||||
"effect": "xbr/super-xbr/super-2xbr-3d-pass0",
|
||||
"applytint": true,
|
||||
"name": "Pass 0",
|
||||
"input": [
|
||||
{ "sampler": "s0", "texture": "screen" }
|
||||
|
@ -42,6 +42,7 @@
|
||||
"passes": [
|
||||
{
|
||||
"effect": "xbr/super-xbr/super-4xbr-3d-pass0",
|
||||
"applytint": true,
|
||||
"name": "Pass 0",
|
||||
"input": [
|
||||
{ "sampler": "s0", "texture": "screen" }
|
||||
|
@ -42,6 +42,7 @@
|
||||
"passes": [
|
||||
{
|
||||
"effect": "xbr/super-xbr/super-4xbr-3d-pass0",
|
||||
"applytint": true,
|
||||
"name": "Pass 0",
|
||||
"input": [
|
||||
{ "sampler": "s0", "texture": "screen" }
|
||||
|
@ -49,6 +49,7 @@
|
||||
"passes": [
|
||||
{
|
||||
"effect": "xbr/super-xbr/super-xbr-pass0",
|
||||
"applytint": true,
|
||||
"name": "Pass 0",
|
||||
"input": [
|
||||
{ "sampler": "s0", "texture": "screen" }
|
||||
|
@ -49,6 +49,7 @@
|
||||
"passes": [
|
||||
{
|
||||
"effect": "xbr/super-xbr/super-xbr-pass0",
|
||||
"applytint": true,
|
||||
"name": "Pass 0",
|
||||
"input": [
|
||||
{ "sampler": "s0", "texture": "screen" }
|
||||
|
@ -63,6 +63,7 @@
|
||||
"passes": [
|
||||
{
|
||||
"effect": "xbr/super-xbr/super-xbr-pass0",
|
||||
"applytint": true,
|
||||
"name": "Pass 0",
|
||||
"input": [
|
||||
{ "sampler": "s0", "texture": "screen" }
|
||||
|
@ -48,6 +48,7 @@
|
||||
"passes": [
|
||||
{
|
||||
"effect": "misc/deposterize-pass0",
|
||||
"applytint": true,
|
||||
"name": "Deposterize, Pass 0",
|
||||
"input": [
|
||||
{ "sampler": "decal", "texture": "screen" }
|
||||
|
@ -42,6 +42,7 @@
|
||||
"passes": [
|
||||
{
|
||||
"effect": "xbr/super-xbr/super-xbr-fast-pass0",
|
||||
"applytint": true,
|
||||
"name": "Pass 0",
|
||||
"input": [
|
||||
{ "sampler": "s0", "texture": "screen" }
|
||||
|
@ -55,6 +55,7 @@
|
||||
"passes": [
|
||||
{
|
||||
"effect": "xbr/super-xbr/super-xbr-fast-pass0",
|
||||
"applytint": true,
|
||||
"name": "Pass 0",
|
||||
"input": [
|
||||
{ "sampler": "s0", "texture": "screen" }
|
||||
|
@ -22,6 +22,7 @@
|
||||
"passes": [
|
||||
{
|
||||
"effect": "xbr/xbr-hybrid/2xbr-hybrid-v4b",
|
||||
"applytint": true,
|
||||
"name": "Pass 0",
|
||||
"input": [
|
||||
{ "sampler": "decal", "texture": "screen" }
|
||||
|
@ -32,6 +32,7 @@
|
||||
"passes": [
|
||||
{
|
||||
"effect": "xbr/xbr-lv1-noblend",
|
||||
"applytint": true,
|
||||
"name": "Main Pass",
|
||||
"input": [
|
||||
{ "sampler": "decal", "texture": "screen" }
|
||||
|
@ -32,6 +32,7 @@
|
||||
"passes": [
|
||||
{
|
||||
"effect": "xbr/xbr-lv2-3d",
|
||||
"applytint": true,
|
||||
"name": "Main Pass",
|
||||
"input": [
|
||||
{ "sampler": "decal", "texture": "screen" }
|
||||
|
@ -41,6 +41,7 @@
|
||||
"passes": [
|
||||
{
|
||||
"effect": "xbr/xbr-lv2-multipass/xbr-lv2-accuracy-pass0",
|
||||
"applytint": true,
|
||||
"name": "Pass 0",
|
||||
"input": [
|
||||
{ "sampler": "decal", "texture": "screen" }
|
||||
|
@ -21,6 +21,7 @@
|
||||
"passes": [
|
||||
{
|
||||
"effect": "xbr/xbr-lv2-multipass/xbr-lv2-accuracy-pass0",
|
||||
"applytint": true,
|
||||
"name": "Pass 0",
|
||||
"input": [
|
||||
{ "sampler": "decal", "texture": "screen" }
|
||||
|
@ -15,6 +15,7 @@
|
||||
"passes": [
|
||||
{
|
||||
"effect": "misc/deposterize-pass0",
|
||||
"applytint": true,
|
||||
"name": "Deposterize, Pass 0",
|
||||
"input": [
|
||||
{ "sampler": "decal", "texture": "screen" }
|
||||
|
@ -32,6 +32,7 @@
|
||||
"passes": [
|
||||
{
|
||||
"effect": "xbr/xbr-lv2-fast",
|
||||
"applytint": true,
|
||||
"name": "Main Pass",
|
||||
"input": [
|
||||
{ "sampler": "decal", "texture": "screen" }
|
||||
|
@ -42,6 +42,7 @@
|
||||
"passes": [
|
||||
{
|
||||
"effect": "xbr/xbr-lv2-multipass/xbr-lv2-c-pass0",
|
||||
"applytint": true,
|
||||
"name": "Pass 0",
|
||||
"input": [
|
||||
{ "sampler": "decal", "texture": "screen" }
|
||||
|
@ -32,6 +32,7 @@
|
||||
"passes": [
|
||||
{
|
||||
"effect": "xbr/xbr-lv2-noblend",
|
||||
"applytint": true,
|
||||
"name": "Main Pass",
|
||||
"input": [
|
||||
{ "sampler": "decal", "texture": "screen" }
|
||||
|
@ -32,6 +32,7 @@
|
||||
"passes": [
|
||||
{
|
||||
"effect": "xbr/xbr-lv2",
|
||||
"applytint": true,
|
||||
"name": "Main Pass",
|
||||
"input": [
|
||||
{ "sampler": "decal", "texture": "screen" }
|
||||
|
@ -42,6 +42,7 @@
|
||||
"passes": [
|
||||
{
|
||||
"effect": "xbr/xbr-lv3-multipass/xbr-lv3-pass0",
|
||||
"applytint": true,
|
||||
"name": "Pass 0",
|
||||
"input": [
|
||||
{ "sampler": "decal", "texture": "screen" }
|
||||
|
@ -32,6 +32,7 @@
|
||||
"passes": [
|
||||
{
|
||||
"effect": "xbr/xbr-lv3-noblend",
|
||||
"applytint": true,
|
||||
"name": "Main Pass",
|
||||
"input": [
|
||||
{ "sampler": "decal", "texture": "screen" }
|
||||
|
@ -32,6 +32,7 @@
|
||||
"passes": [
|
||||
{
|
||||
"effect": "xbr/xbr-lv3",
|
||||
"applytint": true,
|
||||
"name": "Main Pass",
|
||||
"input": [
|
||||
{ "sampler": "decal", "texture": "screen" }
|
||||
|
@ -56,6 +56,7 @@
|
||||
"passes": [
|
||||
{
|
||||
"effect": "xbr/xbr-mlv4-multipass/xbr-mlv4-pass1",
|
||||
"applytint": true,
|
||||
"name": "Pass 1",
|
||||
"input": [
|
||||
{ "sampler": "decal", "texture": "screen" }
|
||||
|
@ -49,6 +49,7 @@
|
||||
"passes": [
|
||||
{
|
||||
"effect": "xbr/xbr-mlv4-multipass/xbr-mlv4-pass1",
|
||||
"applytint": true,
|
||||
"name": "Pass 0",
|
||||
"input": [
|
||||
{ "sampler": "decal", "texture": "screen" }
|
||||
|
@ -6,27 +6,6 @@
|
||||
//
|
||||
//============================================================
|
||||
{
|
||||
// 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.
|
||||
|
26
bgfx/effects/misc/bcg_adjust.json
Normal file
26
bgfx/effects/misc/bcg_adjust.json
Normal file
@ -0,0 +1,26 @@
|
||||
// license:BSD-3-Clause
|
||||
// copyright-holders:Ryan Holtz
|
||||
//===============================================================
|
||||
//
|
||||
// bcg_adjust.json: Brightness/Contrast/Gamma adjustment.
|
||||
//
|
||||
//===============================================================
|
||||
{
|
||||
"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_bcg",
|
||||
"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 ] }
|
||||
]
|
||||
}
|
BIN
bgfx/shaders/dx11/chains/misc/fs_blit_bcg.bin
Normal file
BIN
bgfx/shaders/dx11/chains/misc/fs_blit_bcg.bin
Normal file
Binary file not shown.
BIN
bgfx/shaders/dx9/chains/misc/fs_blit_bcg.bin
Normal file
BIN
bgfx/shaders/dx9/chains/misc/fs_blit_bcg.bin
Normal file
Binary file not shown.
BIN
bgfx/shaders/essl/chains/misc/fs_blit_bcg.bin
Normal file
BIN
bgfx/shaders/essl/chains/misc/fs_blit_bcg.bin
Normal file
Binary file not shown.
BIN
bgfx/shaders/glsl/chains/misc/fs_blit_bcg.bin
Normal file
BIN
bgfx/shaders/glsl/chains/misc/fs_blit_bcg.bin
Normal file
Binary file not shown.
BIN
bgfx/shaders/metal/chains/misc/fs_blit_bcg.bin
Normal file
BIN
bgfx/shaders/metal/chains/misc/fs_blit_bcg.bin
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
bgfx/shaders/spirv/chains/misc/fs_blit_bcg.bin
Normal file
BIN
bgfx/shaders/spirv/chains/misc/fs_blit_bcg.bin
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -697,7 +697,7 @@ const rgb_t *render_container::bcg_lookup_table(int texformat, u32 &out_length,
|
||||
case TEXFORMAT_RGB32:
|
||||
case TEXFORMAT_ARGB32:
|
||||
case TEXFORMAT_YUY16:
|
||||
out_length = 256;
|
||||
out_length = ARRAY_LENGTH(m_bcglookup256);
|
||||
return m_bcglookup256;
|
||||
|
||||
default:
|
||||
|
@ -143,14 +143,14 @@ uint32_t bgfx_chain::applicable_passes()
|
||||
return applicable_passes;
|
||||
}
|
||||
|
||||
void bgfx_chain::prepend_converter(bgfx_effect *effect, chain_manager &chains)
|
||||
void bgfx_chain::insert_effect(uint32_t index, bgfx_effect *effect, std::string name, std::string source, chain_manager &chains)
|
||||
{
|
||||
clear_state *clear = new clear_state(BGFX_CLEAR_COLOR | BGFX_CLEAR_DEPTH | BGFX_CLEAR_STENCIL, 0, 1.0f, 0);
|
||||
std::vector<bgfx_suppressor*> suppressors;
|
||||
|
||||
std::vector<bgfx_input_pair*> inputs;
|
||||
std::vector<std::string> available_textures;
|
||||
inputs.push_back(new bgfx_input_pair(0, "s_tex", "source", available_textures, "", chains, m_screen_index));
|
||||
inputs.push_back(new bgfx_input_pair(0, "s_tex", source, available_textures, "", chains, m_screen_index));
|
||||
inputs.push_back(new bgfx_input_pair(1, "s_pal", "palette", available_textures, "", chains, m_screen_index));
|
||||
|
||||
std::vector<bgfx_entry_uniform*> uniforms;
|
||||
@ -163,8 +163,7 @@ void bgfx_chain::prepend_converter(bgfx_effect *effect, chain_manager &chains)
|
||||
uniforms.push_back(new bgfx_value_uniform(new bgfx_uniform("u_inv_tex_size0", bgfx::UniformType::Vec4), values, 4));
|
||||
uniforms.push_back(new bgfx_value_uniform(new bgfx_uniform("u_inv_tex_size1", bgfx::UniformType::Vec4), values, 4));
|
||||
|
||||
m_entries.insert(m_entries.begin(), new bgfx_chain_entry("XXconvert", effect, clear, suppressors, inputs, uniforms, m_targets, "screen"));
|
||||
m_has_converter = true;
|
||||
m_entries.insert(m_entries.begin() + index, new bgfx_chain_entry(name, effect, clear, suppressors, inputs, uniforms, m_targets, "screen", false));
|
||||
|
||||
const uint32_t screen_width = chains.targets().width(TARGET_STYLE_GUEST, m_screen_index);
|
||||
const uint32_t screen_height = chains.targets().height(TARGET_STYLE_GUEST, m_screen_index);
|
||||
|
@ -39,8 +39,12 @@ public:
|
||||
uint32_t applicable_passes();
|
||||
bool transform() const { return m_transform; }
|
||||
bool has_converter() const { return m_has_converter; }
|
||||
bool has_adjuster() const { return m_has_adjuster; }
|
||||
|
||||
void prepend_converter(bgfx_effect *effect, chain_manager &chains);
|
||||
// Setters
|
||||
void set_has_converter(bool has_converter) { m_has_converter = has_converter; }
|
||||
void set_has_adjuster(bool has_adjuster) { m_has_adjuster = has_adjuster; }
|
||||
void insert_effect(uint32_t index, bgfx_effect *effect, std::string name, std::string source, chain_manager &chains);
|
||||
|
||||
private:
|
||||
std::string m_name;
|
||||
@ -56,6 +60,7 @@ private:
|
||||
int64_t m_current_time;
|
||||
uint32_t m_screen_index;
|
||||
bool m_has_converter;
|
||||
bool m_has_adjuster;
|
||||
};
|
||||
|
||||
#endif // __DRAWBGFX_CHAIN__
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
#include <bgfx/bgfx.h>
|
||||
#include <bx/math.h>
|
||||
#include <cmath>
|
||||
|
||||
#include "chainmanager.h"
|
||||
#include "chainentry.h"
|
||||
@ -29,7 +30,7 @@
|
||||
#include "render.h"
|
||||
|
||||
|
||||
bgfx_chain_entry::bgfx_chain_entry(std::string name, bgfx_effect* effect, clear_state* clear, std::vector<bgfx_suppressor*> suppressors, std::vector<bgfx_input_pair*> inputs, std::vector<bgfx_entry_uniform*> uniforms, target_manager& targets, std::string output)
|
||||
bgfx_chain_entry::bgfx_chain_entry(std::string name, bgfx_effect* effect, clear_state* clear, std::vector<bgfx_suppressor*> suppressors, std::vector<bgfx_input_pair*> inputs, std::vector<bgfx_entry_uniform*> uniforms, target_manager& targets, std::string output, bool apply_tint)
|
||||
: m_name(name)
|
||||
, m_effect(effect)
|
||||
, m_clear(clear)
|
||||
@ -38,6 +39,7 @@ bgfx_chain_entry::bgfx_chain_entry(std::string name, bgfx_effect* effect, clear_
|
||||
, m_uniforms(uniforms)
|
||||
, m_targets(targets)
|
||||
, m_output(output)
|
||||
, m_apply_tint(apply_tint)
|
||||
{
|
||||
}
|
||||
|
||||
@ -68,8 +70,18 @@ void bgfx_chain_entry::submit(int view, chain_manager::screen_prim &prim, textur
|
||||
input->bind(m_effect, screen);
|
||||
}
|
||||
|
||||
uint32_t tint = 0xffffffff;
|
||||
if (m_apply_tint)
|
||||
{
|
||||
const uint8_t a = (uint8_t)std::round(prim.m_prim->color.a * 255);
|
||||
const uint8_t r = (uint8_t)std::round(prim.m_prim->color.r * 255);
|
||||
const uint8_t g = (uint8_t)std::round(prim.m_prim->color.g * 255);
|
||||
const uint8_t b = (uint8_t)std::round(prim.m_prim->color.b * 255);
|
||||
tint = (a << 24) | (r << 16) | (g << 8) | b;
|
||||
}
|
||||
|
||||
bgfx::TransientVertexBuffer buffer;
|
||||
put_screen_buffer(prim.m_screen_width, prim.m_screen_height, &buffer);
|
||||
put_screen_buffer(prim.m_screen_width, prim.m_screen_height, tint, &buffer);
|
||||
bgfx::setVertexBuffer(0, &buffer);
|
||||
|
||||
setup_auto_uniforms(prim, textures, screen_count, screen_width, screen_height, screen_scale_x, screen_scale_y, screen_offset_x, screen_offset_y, rotation_type, swap_xy, screen);
|
||||
@ -268,7 +280,7 @@ bool bgfx_chain_entry::setup_view(int view, uint16_t screen_width, uint16_t scre
|
||||
return true;
|
||||
}
|
||||
|
||||
void bgfx_chain_entry::put_screen_buffer(uint16_t screen_width, uint16_t screen_height, bgfx::TransientVertexBuffer* buffer) const
|
||||
void bgfx_chain_entry::put_screen_buffer(uint16_t screen_width, uint16_t screen_height, uint32_t screen_tint, bgfx::TransientVertexBuffer* buffer) const
|
||||
{
|
||||
if (6 == bgfx::getAvailTransientVertexBuffer(6, ScreenVertex::ms_decl))
|
||||
{
|
||||
@ -304,42 +316,42 @@ void bgfx_chain_entry::put_screen_buffer(uint16_t screen_width, uint16_t screen_
|
||||
vertex[0].m_x = x[0];
|
||||
vertex[0].m_y = y[0];
|
||||
vertex[0].m_z = 0;
|
||||
vertex[0].m_rgba = 0xffffffff;
|
||||
vertex[0].m_rgba = screen_tint;
|
||||
vertex[0].m_u = u[0];
|
||||
vertex[0].m_v = v[0];
|
||||
|
||||
vertex[1].m_x = x[1];
|
||||
vertex[1].m_y = y[1];
|
||||
vertex[1].m_z = 0;
|
||||
vertex[1].m_rgba = 0xffffffff;
|
||||
vertex[1].m_rgba = screen_tint;
|
||||
vertex[1].m_u = u[1];
|
||||
vertex[1].m_v = v[1];
|
||||
|
||||
vertex[2].m_x = x[3];
|
||||
vertex[2].m_y = y[3];
|
||||
vertex[2].m_z = 0;
|
||||
vertex[2].m_rgba = 0xffffffff;
|
||||
vertex[2].m_rgba = screen_tint;
|
||||
vertex[2].m_u = u[3];
|
||||
vertex[2].m_v = v[3];
|
||||
|
||||
vertex[3].m_x = x[3];
|
||||
vertex[3].m_y = y[3];
|
||||
vertex[3].m_z = 0;
|
||||
vertex[3].m_rgba = 0xffffffff;
|
||||
vertex[3].m_rgba = screen_tint;
|
||||
vertex[3].m_u = u[3];
|
||||
vertex[3].m_v = v[3];
|
||||
|
||||
vertex[4].m_x = x[2];
|
||||
vertex[4].m_y = y[2];
|
||||
vertex[4].m_z = 0;
|
||||
vertex[4].m_rgba = 0xffffffff;
|
||||
vertex[4].m_rgba = screen_tint;
|
||||
vertex[4].m_u = u[2];
|
||||
vertex[4].m_v = v[2];
|
||||
|
||||
vertex[5].m_x = x[0];
|
||||
vertex[5].m_y = y[0];
|
||||
vertex[5].m_z = 0;
|
||||
vertex[5].m_rgba = 0xffffffff;
|
||||
vertex[5].m_rgba = screen_tint;
|
||||
vertex[5].m_u = u[0];
|
||||
vertex[5].m_v = v[0];
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ class target_manager;
|
||||
class bgfx_chain_entry
|
||||
{
|
||||
public:
|
||||
bgfx_chain_entry(std::string name, bgfx_effect* effect, clear_state* clear, std::vector<bgfx_suppressor*> suppressors, std::vector<bgfx_input_pair*> inputs, std::vector<bgfx_entry_uniform*> uniforms, target_manager& targets, std::string output);
|
||||
bgfx_chain_entry(std::string name, bgfx_effect* effect, clear_state* clear, std::vector<bgfx_suppressor*> suppressors, std::vector<bgfx_input_pair*> inputs, std::vector<bgfx_entry_uniform*> uniforms, target_manager& targets, std::string output, bool apply_tint);
|
||||
~bgfx_chain_entry();
|
||||
|
||||
void submit(int view, chain_manager::screen_prim &prim, texture_manager& textures, uint16_t screen_count, uint16_t screen_width, uint16_t screen_height, float screen_scale_x, float screen_scale_y, float screen_offset_x, float screen_offset_y, uint32_t rotation_type, bool swap_xy, uint64_t blend, int32_t screen);
|
||||
@ -59,7 +59,7 @@ private:
|
||||
void setup_screenindex_uniform(int32_t screen) const;
|
||||
|
||||
bool setup_view(int view, uint16_t screen_width, uint16_t screen_height, int32_t screen) const;
|
||||
void put_screen_buffer(uint16_t screen_width, uint16_t screen_height, bgfx::TransientVertexBuffer* buffer) const;
|
||||
void put_screen_buffer(uint16_t screen_width, uint16_t screen_height, uint32_t screen_tint, bgfx::TransientVertexBuffer* buffer) const;
|
||||
|
||||
std::string m_name;
|
||||
bgfx_effect* m_effect;
|
||||
@ -69,6 +69,7 @@ private:
|
||||
std::vector<bgfx_entry_uniform*> m_uniforms;
|
||||
target_manager& m_targets;
|
||||
std::string m_output;
|
||||
bool m_apply_tint;
|
||||
};
|
||||
|
||||
#endif // __DRAWBGFX_CHAIN_ENTRY__
|
||||
|
@ -183,6 +183,10 @@ bgfx_chain_entry* chain_entry_reader::read_from_value(const Value& value, std::s
|
||||
}
|
||||
}
|
||||
|
||||
// Parse whether or not to apply screen tint in this pass
|
||||
bool applytint = get_bool(value, "applytint", false);
|
||||
|
||||
// Parse uniforms
|
||||
std::vector<bgfx_entry_uniform*> uniforms;
|
||||
if (value.HasMember("uniforms"))
|
||||
{
|
||||
@ -228,7 +232,7 @@ bgfx_chain_entry* chain_entry_reader::read_from_value(const Value& value, std::s
|
||||
}
|
||||
|
||||
std::string output = value["output"].GetString();
|
||||
return new bgfx_chain_entry(name, effect, clear, suppressors, inputs, uniforms, chains.targets(), output);
|
||||
return new bgfx_chain_entry(name, effect, clear, suppressors, inputs, uniforms, chains.targets(), output, applytint);
|
||||
}
|
||||
|
||||
bool chain_entry_reader::validate_parameters(const Value& value, std::string prefix)
|
||||
@ -242,5 +246,6 @@ bool chain_entry_reader::validate_parameters(const Value& value, std::string pre
|
||||
if (!READER_CHECK(!value.HasMember("input") || value["input"].IsArray(), (prefix + "Value 'input' must be an array\n").c_str())) return false;
|
||||
if (!READER_CHECK(!value.HasMember("uniforms") || value["uniforms"].IsArray(), (prefix + "Value 'uniforms' must be an array\n").c_str())) return false;
|
||||
if (!READER_CHECK(!value.HasMember("disablewhen") || value["disablewhen"].IsArray(), (prefix + "Value 'disablewhen' must be an array\n").c_str())) return false;
|
||||
if (!READER_CHECK(!value.HasMember("applytint") || value["applytint"].IsBool(), (prefix + "Value 'applytint' must be a bool\n").c_str())) return false;
|
||||
return true;
|
||||
}
|
||||
|
@ -64,6 +64,7 @@ void chain_manager::init_texture_converters()
|
||||
m_converters.push_back(m_effects.effect("misc/texconv_rgb32"));
|
||||
m_converters.push_back(nullptr);
|
||||
m_converters.push_back(m_effects.effect("misc/texconv_yuy16"));
|
||||
m_adjuster = m_effects.effect("misc/bcg_adjust");
|
||||
}
|
||||
|
||||
void chain_manager::refresh_available_chains()
|
||||
@ -156,7 +157,7 @@ bgfx_chain* chain_manager::load_chain(std::string name, uint32_t screen_index)
|
||||
bx::FileReader reader;
|
||||
if (!bx::open(&reader, path.c_str()))
|
||||
{
|
||||
printf("Unable to open chain file %s, falling back to no post processing\n", path.c_str());
|
||||
osd_printf_warning("Unable to open chain file %s, falling back to no post processing\n", path.c_str());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -175,8 +176,8 @@ bgfx_chain* chain_manager::load_chain(std::string name, uint32_t screen_index)
|
||||
if (document.HasParseError())
|
||||
{
|
||||
std::string error(GetParseError_En(document.GetParseError()));
|
||||
printf("Unable to parse chain %s. Errors returned:\n", path.c_str());
|
||||
printf("%s\n", error.c_str());
|
||||
osd_printf_warning("Unable to parse chain %s. Errors returned:\n", path.c_str());
|
||||
osd_printf_warning("%s\n", error.c_str());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -184,7 +185,7 @@ bgfx_chain* chain_manager::load_chain(std::string name, uint32_t screen_index)
|
||||
|
||||
if (chain == nullptr)
|
||||
{
|
||||
printf("Unable to load chain %s, falling back to no post processing\n", path.c_str());
|
||||
osd_printf_warning("Unable to load chain %s, falling back to no post processing\n", path.c_str());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -443,11 +444,12 @@ uint32_t chain_manager::update_screen_textures(uint32_t view, render_primitive *
|
||||
|
||||
const uint32_t src_format = (prim.m_flags & PRIMFLAG_TEXFORMAT_MASK) >> PRIMFLAG_TEXFORMAT_SHIFT;
|
||||
const bool needs_conversion = m_converters[src_format] != nullptr;
|
||||
const bool needs_adjust = prim.m_prim->texture.palette != nullptr && src_format != TEXFORMAT_PALETTE16;
|
||||
std::string screen_index = std::to_string(screen);
|
||||
std::string source_name = "source" + screen_index;
|
||||
std::string screen_name = "screen" + screen_index;
|
||||
std::string palette_name = "palette" + screen_index;
|
||||
std::string full_name = needs_conversion ? source_name : screen_name;
|
||||
std::string full_name = (needs_conversion || needs_adjust) ? source_name : screen_name;
|
||||
if (texture && (texture->width() != tex_width || texture->height() != tex_height))
|
||||
{
|
||||
m_textures.add_provider(full_name, nullptr);
|
||||
@ -483,21 +485,19 @@ uint32_t chain_manager::update_screen_textures(uint32_t view, render_primitive *
|
||||
m_textures.add_provider(palette_name, palette);
|
||||
}
|
||||
|
||||
if (screen >= m_screen_textures.size())
|
||||
while (screen >= m_screen_textures.size())
|
||||
{
|
||||
m_screen_textures.push_back(texture);
|
||||
if (palette)
|
||||
{
|
||||
m_screen_palettes.push_back(palette);
|
||||
}
|
||||
m_screen_textures.push_back(nullptr);
|
||||
}
|
||||
else
|
||||
m_screen_textures[screen] = texture;
|
||||
|
||||
while (screen >= m_screen_palettes.size())
|
||||
{
|
||||
m_screen_textures[screen] = texture;
|
||||
if (palette)
|
||||
{
|
||||
m_screen_palettes[screen] = palette;
|
||||
}
|
||||
m_screen_palettes.push_back(nullptr);
|
||||
}
|
||||
if (palette)
|
||||
{
|
||||
m_screen_palettes[screen] = palette;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -506,17 +506,40 @@ uint32_t chain_manager::update_screen_textures(uint32_t view, render_primitive *
|
||||
|
||||
if (prim.m_prim->texture.palette)
|
||||
{
|
||||
m_palette_temp.resize(palette->width() * palette->height() * 4);
|
||||
uint16_t palette_width = (uint16_t)std::min(prim.m_palette_length, 256U);
|
||||
uint16_t palette_height = (uint16_t)std::max((prim.m_palette_length + 255) / 256, 1U);
|
||||
const uint32_t palette_size = palette_width * palette_height * 4;
|
||||
m_palette_temp.resize(palette_size);
|
||||
memcpy(&m_palette_temp[0], prim.m_prim->texture.palette, prim.m_palette_length * 4);
|
||||
const bgfx::Memory *palmem = bgfx::copy(&m_palette_temp[0], palette->width() * palette->height() * 4);
|
||||
palette->update(palmem);
|
||||
const bgfx::Memory *palmem = bgfx::copy(&m_palette_temp[0], palette_size);
|
||||
|
||||
if (palette)
|
||||
{
|
||||
palette->update(palmem);
|
||||
}
|
||||
else
|
||||
{
|
||||
palette = new bgfx_texture(palette_name, bgfx::TextureFormat::BGRA8, palette_width, palette_height, palmem, BGFX_SAMPLER_U_CLAMP | BGFX_SAMPLER_V_CLAMP | BGFX_SAMPLER_MIN_POINT | BGFX_SAMPLER_MAG_POINT | BGFX_SAMPLER_MIP_POINT, palette_width * 4);
|
||||
m_textures.add_provider(palette_name, palette);
|
||||
while (screen >= m_screen_palettes.size())
|
||||
{
|
||||
m_screen_palettes.push_back(nullptr);
|
||||
}
|
||||
m_screen_palettes[screen] = palette;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bgfx_chain* chain = screen_chain(screen);
|
||||
if (chain && needs_adjust && !chain->has_adjuster())
|
||||
{
|
||||
chain->insert_effect(chain->has_converter() ? 1 : 0, m_adjuster, "XXadjust", needs_conversion ? "screen" : "source", *this);
|
||||
chain->set_has_adjuster(true);
|
||||
}
|
||||
if (chain && needs_conversion && !chain->has_converter())
|
||||
{
|
||||
chain->prepend_converter(m_converters[src_format], *this);
|
||||
chain->insert_effect(0, m_converters[src_format], "XXconvert", "source", *this);
|
||||
chain->set_has_converter(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -147,6 +147,7 @@ private:
|
||||
std::vector<bgfx_texture*> m_screen_textures;
|
||||
std::vector<bgfx_texture*> m_screen_palettes;
|
||||
std::vector<bgfx_effect*> m_converters;
|
||||
bgfx_effect * m_adjuster;
|
||||
std::vector<screen_prim> m_screen_prims;
|
||||
std::vector<uint8_t> m_palette_temp;
|
||||
|
||||
|
@ -46,7 +46,9 @@ bgfx_input_pair::~bgfx_input_pair()
|
||||
|
||||
void bgfx_input_pair::bind(bgfx_effect *effect, const int32_t screen) const
|
||||
{
|
||||
assert(effect->uniform(m_sampler) != nullptr);
|
||||
if (effect->uniform(m_sampler) == nullptr)
|
||||
return;
|
||||
|
||||
std::string name = m_texture + std::to_string(screen);
|
||||
|
||||
bgfx_texture_handle_provider* provider = chains().textures().provider(name);
|
||||
|
@ -0,0 +1,24 @@
|
||||
$input v_color0, v_texcoord0
|
||||
|
||||
// license:BSD-3-Clause
|
||||
// copyright-holders:Ryan Holtz
|
||||
|
||||
#include "common.sh"
|
||||
|
||||
// Samplers
|
||||
SAMPLER2D(s_tex, 0);
|
||||
SAMPLER2D(s_pal, 1);
|
||||
|
||||
uniform vec4 u_inv_tex_size1;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 src = texture2D(s_tex, v_texcoord0);
|
||||
vec2 blu_uv = vec2(src.b * 256.0, 0.0) * u_inv_tex_size1.xy;
|
||||
vec2 grn_uv = vec2(src.g * 256.0, 1.0) * u_inv_tex_size1.xy;
|
||||
vec2 red_uv = vec2(src.r * 256.0, 2.0) * u_inv_tex_size1.xy;
|
||||
float blu = texture2D(s_pal, blu_uv).b;
|
||||
float grn = texture2D(s_pal, grn_uv).g;
|
||||
float red = texture2D(s_pal, red_uv).r;
|
||||
gl_FragColor = vec4(red, grn, blu, src.a) * v_color0;
|
||||
}
|
@ -9,8 +9,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __DRAWBGFX_STATE_READER__
|
||||
#define __DRAWBGFX_STATE_READER__
|
||||
#ifndef DRAWBGFX_STATE_READER
|
||||
#define DRAWBGFX_STATE_READER
|
||||
|
||||
#include <rapidjson/document.h>
|
||||
|
||||
@ -63,4 +63,4 @@ private:
|
||||
static void get_vec_values(const Value& value_array, float* data, const unsigned int count);
|
||||
};
|
||||
|
||||
#endif // __DRAWBGFX_STATE_READER__
|
||||
#endif // DRAWBGFX_STATE_READER
|
||||
|
@ -2,14 +2,14 @@
|
||||
// copyright-holders:Ryan Holtz
|
||||
//============================================================
|
||||
//
|
||||
// cullreader.h - BGFX alpha/color write state JSON reader
|
||||
// writereader.h - BGFX alpha/color write state JSON reader
|
||||
//
|
||||
//============================================================
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __DRAWBGFX_WRITE_READER__
|
||||
#define __DRAWBGFX_WRITE_READER__
|
||||
#ifndef DRAWBGFX_WRITE_READER
|
||||
#define DRAWBGFX_WRITE_READER
|
||||
|
||||
#include "statereader.h"
|
||||
|
||||
@ -18,4 +18,4 @@ public:
|
||||
static uint64_t read_from_value(const Value& value);
|
||||
};
|
||||
|
||||
#endif // __DRAWBGFX_WRITE_READER__
|
||||
#endif // DRAWBGFX_WRITE_READER
|
||||
|
@ -78,7 +78,7 @@ uint64_t bgfx_util::get_blend_state(uint32_t blend)
|
||||
case BLENDMODE_ALPHA:
|
||||
return BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_SRC_ALPHA, BGFX_STATE_BLEND_INV_SRC_ALPHA);
|
||||
case BLENDMODE_RGB_MULTIPLY:
|
||||
return BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_DST_COLOR, BGFX_STATE_BLEND_ZERO);
|
||||
return BGFX_STATE_BLEND_FUNC_SEPARATE(BGFX_STATE_BLEND_DST_COLOR, BGFX_STATE_BLEND_ZERO, BGFX_STATE_BLEND_DST_ALPHA, BGFX_STATE_BLEND_ZERO);
|
||||
case BLENDMODE_ADD:
|
||||
return BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_SRC_ALPHA, BGFX_STATE_BLEND_ONE);
|
||||
default:
|
||||
|
Loading…
Reference in New Issue
Block a user