summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd/modules/render/bgfx/chain.cpp
diff options
context:
space:
mode:
author MooglyGuy <therealmogminer@gmail.com>2019-10-13 20:55:11 +0200
committer MooglyGuy <therealmogminer@gmail.com>2019-10-13 20:59:35 +0200
commit61b2a8afaf012e28ef14ad946ee0bb8319232aa6 (patch)
tree0aaf403f6258de9adbbeacaac92206fdf1c7aa27 /src/osd/modules/render/bgfx/chain.cpp
parentcd6b9ac9beb76e640f39227555ad6907a36d38f9 (diff)
-bgfx: Do texture format conversion via a full-screen GPU pass. [Ryan Holtz]
Diffstat (limited to 'src/osd/modules/render/bgfx/chain.cpp')
-rw-r--r--src/osd/modules/render/bgfx/chain.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/osd/modules/render/bgfx/chain.cpp b/src/osd/modules/render/bgfx/chain.cpp
index c7691973854..25dccf87eed 100644
--- a/src/osd/modules/render/bgfx/chain.cpp
+++ b/src/osd/modules/render/bgfx/chain.cpp
@@ -13,11 +13,14 @@
#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"
@@ -33,6 +36,7 @@ bgfx_chain::bgfx_chain(std::string name, std::string author, bool transform, tar
, m_target_list(target_list)
, m_current_time(0)
, m_screen_index(screen_index)
+ , m_has_converter(false)
{
for (bgfx_target* target : m_target_list)
{
@@ -138,3 +142,31 @@ uint32_t bgfx_chain::applicable_passes()
return applicable_passes;
}
+
+void bgfx_chain::prepend_converter(bgfx_effect *effect, 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(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));
+
+ m_entries.insert(m_entries.begin(), new bgfx_chain_entry("XXconvert", effect, clear, suppressors, inputs, uniforms, m_targets, "screen"));
+ m_has_converter = true;
+
+ 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.create_target("screen", bgfx::TextureFormat::RGBA8, screen_width, screen_height, TARGET_STYLE_GUEST, true, false, 1, m_screen_index);
+}