summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd/modules/render/bgfx/chain.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/osd/modules/render/bgfx/chain.cpp')
-rw-r--r--src/osd/modules/render/bgfx/chain.cpp88
1 files changed, 68 insertions, 20 deletions
diff --git a/src/osd/modules/render/bgfx/chain.cpp b/src/osd/modules/render/bgfx/chain.cpp
index c7691973854..8d5adb0ec25 100644
--- a/src/osd/modules/render/bgfx/chain.cpp
+++ b/src/osd/modules/render/bgfx/chain.cpp
@@ -6,33 +6,48 @@
//
//============================================================
+#include "chain.h"
+
#include "emu.h"
+#include "render.h"
+#include "rendlay.h"
+#include "screen.h"
#include <bx/timer.h>
#include "slider.h"
#include "parameter.h"
#include "entryuniform.h"
+#include "valueuniform.h"
#include "texturemanager.h"
#include "targetmanager.h"
+#include "chainmanager.h"
#include "target.h"
#include "vertex.h"
-#include "screen.h"
+#include "clear.h"
#include "modules/osdwindow.h"
-#include "chain.h"
-
-bgfx_chain::bgfx_chain(std::string name, std::string author, bool transform, target_manager& targets, std::vector<bgfx_slider*> sliders, std::vector<bgfx_parameter*> params, std::vector<bgfx_chain_entry*> entries, std::vector<bgfx_target*> target_list, std::uint32_t screen_index)
- : m_name(name)
- , m_author(author)
+bgfx_chain::bgfx_chain(
+ std::string &&name,
+ std::string &&author,
+ bool transform,
+ target_manager& targets,
+ std::vector<bgfx_slider*> &&sliders,
+ std::vector<bgfx_parameter*> &&params,
+ std::vector<bgfx_chain_entry*> &&entries,
+ std::vector<bgfx_target*> &&target_list,
+ std::uint32_t screen_index)
+ : m_name(std::move(name))
+ , m_author(std::move(author))
, m_transform(transform)
, m_targets(targets)
- , m_sliders(sliders)
- , m_params(params)
- , m_entries(entries)
- , m_target_list(target_list)
+ , m_sliders(std::move(sliders))
+ , m_params(std::move(params))
+ , m_entries(std::move(entries))
+ , m_target_list(std::move(target_list))
, m_current_time(0)
, m_screen_index(screen_index)
+ , m_has_converter(false)
{
for (bgfx_target* target : m_target_list)
{
@@ -72,14 +87,14 @@ void bgfx_chain::repopulate_targets()
}
}
-void bgfx_chain::process(render_primitive* prim, int view, int screen, texture_manager& textures, osd_window& window, uint64_t blend)
+void bgfx_chain::process(chain_manager::screen_prim &prim, int view, int screen, texture_manager& textures, osd_window& window)
{
- screen_device_iterator screen_iterator(window.machine().root_device());
+ screen_device_enumerator screen_iterator(window.machine().root_device());
screen_device* screen_device = screen_iterator.byindex(screen);
- uint16_t screen_count(window.target()->current_view()->screens().count());
- uint16_t screen_width(floorf(prim->get_quad_width() + 0.5f));
- uint16_t screen_height(floorf(prim->get_quad_height() + 0.5f));
+ uint16_t screen_count(window.target()->current_view().visible_screen_count());
+ uint16_t screen_width = prim.m_quad_width;
+ uint16_t screen_height = prim.m_quad_height;
uint32_t rotation_type =
(window.target()->orientation() & ROT90) == ROT90 ? 1 :
(window.target()->orientation() & ROT180) == ROT180 ? 2 :
@@ -102,11 +117,12 @@ void bgfx_chain::process(render_primitive* prim, int view, int screen, texture_m
}
int current_view = view;
- for (bgfx_chain_entry* entry : m_entries)
+ for (size_t i = 0; i < m_entries.size(); i++)
{
- if (!entry->skip())
+ if (!m_entries[i]->skip())
{
- entry->submit(current_view, prim, textures, screen_count, screen_width, screen_height, screen_scale_x, screen_scale_y, screen_offset_x, screen_offset_y, rotation_type, swap_xy, blend, screen);
+ m_entries[i]->submit(current_view, 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);
current_view++;
}
}
@@ -115,13 +131,13 @@ void bgfx_chain::process(render_primitive* prim, int view, int screen, texture_m
static int64_t last = m_current_time;
const int64_t frameTime = m_current_time - last;
last = m_current_time;
- const double freq = double(bx::getHPFrequency());
+ const auto freq = double(bx::getHPFrequency());
const double toMs = 1000.0 / freq;
const double frameTimeInSeconds = (double)frameTime / 1000000.0;
for (bgfx_parameter* param : m_params)
{
- param->tick(frameTimeInSeconds* toMs);
+ param->tick(frameTimeInSeconds * toMs);
}
}
@@ -138,3 +154,35 @@ uint32_t bgfx_chain::applicable_passes()
return applicable_passes;
}
+
+void bgfx_chain::insert_effect(uint32_t index, bgfx_effect *effect, const bool apply_tint, std::string name, std::string source, chain_manager &chains)
+{
+ auto *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(1, "s_pal", "palette", available_textures, "", chains, m_screen_index));
+
+ std::vector<bgfx_entry_uniform*> uniforms;
+ float value = 1.0f;
+ float values[4] = { 1.0f, 1.0f, 0.0f, 0.0f };
+ uniforms.push_back(new bgfx_value_uniform(new bgfx_uniform("s_tex", bgfx::UniformType::Sampler), &value, 1));
+ uniforms.push_back(new bgfx_value_uniform(new bgfx_uniform("s_pal", bgfx::UniformType::Sampler), &value, 1));
+ uniforms.push_back(new bgfx_value_uniform(new bgfx_uniform("u_tex_size0", bgfx::UniformType::Vec4), values, 4));
+ uniforms.push_back(new bgfx_value_uniform(new bgfx_uniform("u_tex_size1", bgfx::UniformType::Vec4), values, 4));
+ 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));
+ uniforms.push_back(new bgfx_value_uniform(new bgfx_uniform("u_tex_bounds0", bgfx::UniformType::Vec4), values, 4));
+ uniforms.push_back(new bgfx_value_uniform(new bgfx_uniform("u_tex_bounds1", bgfx::UniformType::Vec4), values, 4));
+ uniforms.push_back(new bgfx_value_uniform(new bgfx_uniform("u_inv_tex_bounds0", bgfx::UniformType::Vec4), values, 4));
+ uniforms.push_back(new bgfx_value_uniform(new bgfx_uniform("u_inv_tex_bounds1", bgfx::UniformType::Vec4), values, 4));
+
+ m_entries.insert(m_entries.begin() + index, new bgfx_chain_entry(name, effect, clear, suppressors, inputs, uniforms, m_targets, "screen", apply_tint));
+
+ 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);
+ m_targets.destroy_target("screen", m_screen_index);
+ m_targets.create_target("screen", bgfx::TextureFormat::BGRA8, screen_width, screen_height, 1, 1, TARGET_STYLE_GUEST, true, false, 1, m_screen_index);
+}