summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd/modules/render/bgfx
diff options
context:
space:
mode:
Diffstat (limited to 'src/osd/modules/render/bgfx')
-rw-r--r--src/osd/modules/render/bgfx/chain.cpp32
-rw-r--r--src/osd/modules/render/bgfx/chain.h6
-rw-r--r--src/osd/modules/render/bgfx/chainentry.h4
-rw-r--r--src/osd/modules/render/bgfx/chainentryreader.cpp2
-rw-r--r--src/osd/modules/render/bgfx/chainmanager.cpp89
-rw-r--r--src/osd/modules/render/bgfx/chainmanager.h5
-rw-r--r--src/osd/modules/render/bgfx/effect.cpp8
-rw-r--r--src/osd/modules/render/bgfx/entryuniform.h4
-rw-r--r--src/osd/modules/render/bgfx/inputpair.cpp14
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/hlsl/fs_chroma.sc9
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/misc/fs_blit_palette16.sc19
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/misc/fs_blit_rgb32.sc14
-rw-r--r--src/osd/modules/render/bgfx/shaders/chains/misc/fs_blit_yuy16.sc37
-rw-r--r--src/osd/modules/render/bgfx/shaders/makefile27
-rw-r--r--src/osd/modules/render/bgfx/shaders/shader.mk8
-rw-r--r--src/osd/modules/render/bgfx/suppressorreader.cpp1
-rw-r--r--src/osd/modules/render/bgfx/texture.cpp10
-rw-r--r--src/osd/modules/render/bgfx/texture.h4
-rw-r--r--src/osd/modules/render/bgfx/texturemanager.cpp20
-rw-r--r--src/osd/modules/render/bgfx/uniform.cpp6
-rw-r--r--src/osd/modules/render/bgfx/uniformreader.cpp2
-rw-r--r--src/osd/modules/render/bgfx/vertex.h2
22 files changed, 266 insertions, 57 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);
+}
diff --git a/src/osd/modules/render/bgfx/chain.h b/src/osd/modules/render/bgfx/chain.h
index 157f92173cf..cb5668d3368 100644
--- a/src/osd/modules/render/bgfx/chain.h
+++ b/src/osd/modules/render/bgfx/chain.h
@@ -38,7 +38,10 @@ public:
std::vector<bgfx_slider*>& sliders() { return m_sliders; }
std::vector<bgfx_chain_entry*>& entries() { return m_entries; }
uint32_t applicable_passes();
- bool transform() { return m_transform; }
+ bool transform() const { return m_transform; }
+ bool has_converter() const { return m_has_converter; }
+
+ void prepend_converter(bgfx_effect *effect, chain_manager &chains);
private:
std::string m_name;
@@ -53,6 +56,7 @@ private:
std::map<std::string, bgfx_target*> m_target_map;
int64_t m_current_time;
uint32_t m_screen_index;
+ bool m_has_converter;
};
#endif // __DRAWBGFX_CHAIN__
diff --git a/src/osd/modules/render/bgfx/chainentry.h b/src/osd/modules/render/bgfx/chainentry.h
index 64130c5c93e..e143def6c56 100644
--- a/src/osd/modules/render/bgfx/chainentry.h
+++ b/src/osd/modules/render/bgfx/chainentry.h
@@ -11,8 +11,8 @@
#pragma once
-#ifndef __DRAWBGFX_CHAIN_ENTRY__
-#define __DRAWBGFX_CHAIN_ENTRY__
+#ifndef DRAWBGFX_CHAIN_ENTRY
+#define DRAWBGFX_CHAIN_ENTRY
#include <bgfx/bgfx.h>
diff --git a/src/osd/modules/render/bgfx/chainentryreader.cpp b/src/osd/modules/render/bgfx/chainentryreader.cpp
index bff221ec40c..d48b214f83d 100644
--- a/src/osd/modules/render/bgfx/chainentryreader.cpp
+++ b/src/osd/modules/render/bgfx/chainentryreader.cpp
@@ -84,7 +84,7 @@ bgfx_chain_entry* chain_entry_reader::read_from_value(const Value& value, std::s
texture_name = chains.options().value(option.c_str());
}
- if (texture_name != "" && texture_name != "screen")
+ if (texture_name != "" && texture_name != "screen" && texture_name != "palette")
{
if (selection == "")
{
diff --git a/src/osd/modules/render/bgfx/chainmanager.cpp b/src/osd/modules/render/bgfx/chainmanager.cpp
index 62df9be9613..eb22cb1d253 100644
--- a/src/osd/modules/render/bgfx/chainmanager.cpp
+++ b/src/osd/modules/render/bgfx/chainmanager.cpp
@@ -49,6 +49,7 @@ chain_manager::chain_manager(running_machine& machine, osd_options& options, tex
{
refresh_available_chains();
parse_chain_selections(options.bgfx_screen_chains());
+ init_texture_converters();
}
chain_manager::~chain_manager()
@@ -56,6 +57,15 @@ chain_manager::~chain_manager()
destroy_chains();
}
+void chain_manager::init_texture_converters()
+{
+ m_converters.push_back(nullptr);
+ m_converters.push_back(m_effects.effect("misc/texconv_palette16"));
+ 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"));
+}
+
void chain_manager::refresh_available_chains()
{
m_available_chains.clear();
@@ -288,17 +298,73 @@ bgfx_chain* chain_manager::screen_chain(uint32_t screen)
}
}
-void chain_manager::process_screen_quad(uint32_t view, uint32_t screen, render_primitive* prim, osd_window &window)
+void chain_manager::process_screen_quad(uint32_t view, uint32_t screen, render_primitive* prim, osd_window& window)
{
- uint16_t tex_width(prim->texture.width);
- uint16_t tex_height(prim->texture.height);
+ uint16_t tex_width(prim->texture.width);
+ uint16_t tex_height(prim->texture.height);
+
+ bgfx_texture* texture = screen < m_screen_textures.size() ? m_screen_textures[screen] : nullptr;
+ bgfx_texture* palette = screen < m_screen_palettes.size() ? m_screen_palettes[screen] : nullptr;
+
+ const uint32_t src_format = (prim->flags & PRIMFLAG_TEXFORMAT_MASK) >> PRIMFLAG_TEXFORMAT_SHIFT;
+ const bool needs_conversion = m_converters[src_format] != nullptr;
+ 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;
+ if (texture && (texture->width() != tex_width || texture->height() != tex_height))
+ {
+ m_textures.add_provider(full_name, nullptr);
+ delete texture;
+ texture = nullptr;
+
+ if (palette)
+ {
+ m_textures.add_provider(palette_name, nullptr);
+ delete palette;
+ palette = nullptr;
+ }
+ }
- const bgfx::Memory* mem = bgfx_util::mame_texture_data_to_bgfx_texture_data(prim->flags & PRIMFLAG_TEXFORMAT_MASK,
- tex_width, tex_height, prim->texture.rowpixels, prim->texture.palette, prim->texture.base);
+ bgfx::TextureFormat::Enum dst_format = bgfx::TextureFormat::RGBA8;
+ uint16_t pitch = tex_width;
+ const bgfx::Memory* mem = bgfx_util::mame_texture_data_to_bgfx_texture_data(dst_format, prim->flags & PRIMFLAG_TEXFORMAT_MASK,
+ tex_width, tex_height, prim->texture.rowpixels, prim->texture.palette, prim->texture.base, &pitch);
- std::string full_name = "screen" + std::to_string(screen);
- bgfx_texture *texture = new bgfx_texture(full_name, bgfx::TextureFormat::RGBA8, tex_width, tex_height, mem, BGFX_SAMPLER_U_CLAMP | BGFX_SAMPLER_V_CLAMP | BGFX_SAMPLER_MIN_POINT | BGFX_SAMPLER_MAG_POINT | BGFX_SAMPLER_MIP_POINT);
- m_textures.add_provider(full_name, texture);
+ if (texture == nullptr)
+ {
+ bgfx_texture *texture = new bgfx_texture(full_name, dst_format, tex_width, tex_height, mem, BGFX_SAMPLER_U_CLAMP | BGFX_SAMPLER_V_CLAMP | BGFX_SAMPLER_MIN_POINT | BGFX_SAMPLER_MAG_POINT | BGFX_SAMPLER_MIP_POINT, pitch);
+ m_textures.add_provider(full_name, texture);
+
+ if (prim->texture.palette)
+ {
+ uint16_t palette_width = (uint16_t)std::min(prim->texture.palette_length, 256U);
+ uint16_t palette_height = (uint16_t)std::max(prim->texture.palette_length / 256, 1U);
+ const bgfx::Memory *palmem = bgfx::copy(prim->texture.palette, palette_width * palette_height * 4);
+ 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);
+ m_textures.add_provider(palette_name, palette);
+ }
+
+ if (screen >= m_screen_textures.size())
+ {
+ m_screen_textures.push_back(texture);
+ if (palette)
+ {
+ m_screen_palettes.push_back(palette);
+ }
+ }
+ }
+ else
+ {
+ texture->update(mem, pitch);
+
+ if (prim->texture.palette)
+ {
+ const bgfx::Memory *palmem = bgfx::copy(prim->texture.palette, palette->width() * palette->height() * 4);
+ palette->update(palmem);
+ }
+ }
const bool any_targets_rebuilt = m_targets.update_target_sizes(screen, tex_width, tex_height, TARGET_STYLE_GUEST);
if (any_targets_rebuilt)
@@ -313,11 +379,12 @@ void chain_manager::process_screen_quad(uint32_t view, uint32_t screen, render_p
}
bgfx_chain* chain = screen_chain(screen);
+ if (needs_conversion && !chain->has_converter())
+ {
+ chain->prepend_converter(m_converters[src_format], *this);
+ }
chain->process(prim, view, screen, m_textures, window, bgfx_util::get_blend_state(PRIMFLAG_GET_BLENDMODE(prim->flags)));
view += chain->applicable_passes();
-
- m_textures.add_provider(full_name, nullptr);
- delete texture;
}
std::vector<render_primitive*> chain_manager::count_screens(render_primitive* prim)
diff --git a/src/osd/modules/render/bgfx/chainmanager.h b/src/osd/modules/render/bgfx/chainmanager.h
index 4c76a02ee25..e03622d28f2 100644
--- a/src/osd/modules/render/bgfx/chainmanager.h
+++ b/src/osd/modules/render/bgfx/chainmanager.h
@@ -77,6 +77,8 @@ private:
void destroy_chains();
void reload_chains();
+ void init_texture_converters();
+
void refresh_available_chains();
void destroy_unloaded_chains();
void find_available_chains(std::string root, std::string path);
@@ -106,6 +108,9 @@ private:
std::vector<ui::menu_item> m_selection_sliders;
std::vector<std::unique_ptr<slider_state>> m_core_sliders;
std::vector<int32_t> m_current_chain;
+ std::vector<bgfx_texture*> m_screen_textures;
+ std::vector<bgfx_texture*> m_screen_palettes;
+ std::vector<bgfx_effect*> m_converters;
static const uint32_t CHAIN_NONE;
};
diff --git a/src/osd/modules/render/bgfx/effect.cpp b/src/osd/modules/render/bgfx/effect.cpp
index da5207f114b..9359faeb494 100644
--- a/src/osd/modules/render/bgfx/effect.cpp
+++ b/src/osd/modules/render/bgfx/effect.cpp
@@ -52,11 +52,5 @@ void bgfx_effect::submit(int view, uint64_t blend)
bgfx_uniform* bgfx_effect::uniform(std::string name)
{
std::map<std::string, bgfx_uniform*>::iterator iter = m_uniforms.find(name);
-
- if (iter != m_uniforms.end())
- {
- return iter->second;
- }
-
- return nullptr;
+ return iter != m_uniforms.end() ? iter->second : nullptr;
}
diff --git a/src/osd/modules/render/bgfx/entryuniform.h b/src/osd/modules/render/bgfx/entryuniform.h
index 4ba30250e6e..9c1462f360f 100644
--- a/src/osd/modules/render/bgfx/entryuniform.h
+++ b/src/osd/modules/render/bgfx/entryuniform.h
@@ -11,8 +11,8 @@
#pragma once
-#ifndef __DRAWBGFX_ENTRY_UNIFORM__
-#define __DRAWBGFX_ENTRY_UNIFORM__
+#ifndef DRAWBGFX_ENTRY_UNIFORM
+#define DRAWBGFX_ENTRY_UNIFORM
#include <bgfx/bgfx.h>
diff --git a/src/osd/modules/render/bgfx/inputpair.cpp b/src/osd/modules/render/bgfx/inputpair.cpp
index 98d0594e27a..8d4441ccffe 100644
--- a/src/osd/modules/render/bgfx/inputpair.cpp
+++ b/src/osd/modules/render/bgfx/inputpair.cpp
@@ -50,13 +50,23 @@ void bgfx_input_pair::bind(bgfx_effect *effect, const int32_t screen) const
std::string name = m_texture + std::to_string(screen);
bgfx_texture_handle_provider* provider = chains().textures().provider(name);
- bgfx_uniform *tex_size = effect->uniform("u_tex_size" + std::to_string(m_index));
- if (tex_size != nullptr)
+ if (!provider)
+ return;
+
+ bgfx_uniform *tex_size = effect->uniform("u_tex_size" + std::to_string(m_index));
+ if (tex_size && provider)
{
float values[2] = { float(provider->width()), float(provider->height()) };
tex_size->set(values, sizeof(float) * 2);
}
+ bgfx_uniform *inv_tex_size = effect->uniform("u_inv_tex_size" + std::to_string(m_index));
+ if (inv_tex_size && provider)
+ {
+ float values[2] = { 1.0f / float(provider->width()), 1.0f / float(provider->height()) };
+ inv_tex_size->set(values, sizeof(float) * 2);
+ }
+
bgfx::setTexture(m_index, effect->uniform(m_sampler)->handle(), chains().textures().handle(name));
}
diff --git a/src/osd/modules/render/bgfx/shaders/chains/hlsl/fs_chroma.sc b/src/osd/modules/render/bgfx/shaders/chains/hlsl/fs_chroma.sc
index 51bb14676d3..c0d8ba07ac7 100644
--- a/src/osd/modules/render/bgfx/shaders/chains/hlsl/fs_chroma.sc
+++ b/src/osd/modules/render/bgfx/shaders/chains/hlsl/fs_chroma.sc
@@ -22,11 +22,20 @@ void main()
vec4 cin = texture2D(s_tex, v_texcoord0);
vec4 cout = vec4(0.0, 0.0, 0.0, cin.a);
mat3 xy = mat3(u_chroma_a.xyz, u_chroma_b.xyz, u_chroma_c.xyz);
+
+#ifdef TRANSPOSED_XYZ_TO_sRGB
const mat3 XYZ_TO_sRGB = mat3(
3.2406, -0.9689, 0.0557,
-1.5372, 1.8758, -0.2040,
-0.4986, 0.0415, 1.0570
);
+#else
+ const mat3 XYZ_TO_sRGB = mat3(
+ 3.2406, -1.5372, -0.4986,
+ -0.9689, 1.8758, 0.0415,
+ 0.0557, -0.2040, 1.0570
+ );
+#endif
for (int i = 0; i < 3; ++i) {
float Y = u_y_gain[i] * cin[i];
diff --git a/src/osd/modules/render/bgfx/shaders/chains/misc/fs_blit_palette16.sc b/src/osd/modules/render/bgfx/shaders/chains/misc/fs_blit_palette16.sc
new file mode 100644
index 00000000000..82236d954a3
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/misc/fs_blit_palette16.sc
@@ -0,0 +1,19 @@
+$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()
+{
+ vec2 palette_uv = texture2D(s_tex, v_texcoord0).rg;
+ palette_uv.xy = (palette_uv.xy * vec2(256.0, 256.0)) * u_inv_tex_size1.xy;
+ gl_FragColor = vec4(texture2D(s_pal, palette_uv).rgb, 1.0) * v_color0;
+}
diff --git a/src/osd/modules/render/bgfx/shaders/chains/misc/fs_blit_rgb32.sc b/src/osd/modules/render/bgfx/shaders/chains/misc/fs_blit_rgb32.sc
new file mode 100644
index 00000000000..4292e6cddc6
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/misc/fs_blit_rgb32.sc
@@ -0,0 +1,14 @@
+$input v_color0, v_texcoord0
+
+// license:BSD-3-Clause
+// copyright-holders:Ryan Holtz
+
+#include "common.sh"
+
+// Samplers
+SAMPLER2D(s_tex, 0);
+
+void main()
+{
+ gl_FragColor = vec4(texture2D(s_tex, v_texcoord0).rgb, 1.0) * v_color0;
+}
diff --git a/src/osd/modules/render/bgfx/shaders/chains/misc/fs_blit_yuy16.sc b/src/osd/modules/render/bgfx/shaders/chains/misc/fs_blit_yuy16.sc
new file mode 100644
index 00000000000..7f91cbc2db0
--- /dev/null
+++ b/src/osd/modules/render/bgfx/shaders/chains/misc/fs_blit_yuy16.sc
@@ -0,0 +1,37 @@
+$input v_color0, v_texcoord0
+
+// license:BSD-3-Clause
+// copyright-holders:Ryan Holtz
+
+#include "common.sh"
+
+// Samplers
+SAMPLER2D(s_tex, 0);
+
+vec4 u_tex_size0;
+vec4 u_inv_tex_size0;
+
+vec3 ycc_to_rgb(float y, float cb, float cr)
+{
+ float r = saturate(y + 1.40200 * (cr - 0.5));
+ float g = saturate(y - 0.34414 * (cb - 0.5) - 0.71414 * (cr - 0.5));
+ float b = saturate(y + 1.77200 * (cb - 0.5));
+ return vec3(r, g, b);
+}
+
+void main()
+{
+ vec2 size_minus_one = u_tex_size0.xy - vec2(1.0, 1.0);
+ vec2 original_uv = round(v_texcoord0.xy * size_minus_one);
+ float mod_val = mod(original_uv.x, 2.0);
+ vec2 rounded_uv = round(vec2(original_uv.x - mod_val, original_uv.y));
+ vec2 next_uv = rounded_uv + vec2(1.0, 0.0);
+ vec2 srcpix0 = texture2D(s_tex, rounded_uv / size_minus_one).rg;
+ vec2 srcpix1 = texture2D(s_tex, next_uv / size_minus_one).rg;
+ float cr = srcpix1.r;
+ float cb = srcpix0.r;
+ if (mod_val < 1.0)
+ gl_FragColor = vec4(ycc_to_rgb(srcpix0.g, cb, cr), 1.0) * v_color0;
+ else
+ gl_FragColor = vec4(ycc_to_rgb(srcpix1.g, cb, cr), 1.0) * v_color0;
+}
diff --git a/src/osd/modules/render/bgfx/shaders/makefile b/src/osd/modules/render/bgfx/shaders/makefile
index 1ca45471b9b..c998f2564d9 100644
--- a/src/osd/modules/render/bgfx/shaders/makefile
+++ b/src/osd/modules/render/bgfx/shaders/makefile
@@ -12,25 +12,28 @@ SUBDIRS := $(patsubst .,,$(patsubst ./,,$(shell find . -type d)))
rebuild: main $(SUBDIRS)
endif
+.NOTPARALLEL:
$(SUBDIRS):
@echo $@
ifeq ($(OS),windows)
- @make -s --no-print-directory TARGET=0 SHADERS_DIR=$@/ clean all
- @make -s --no-print-directory TARGET=1 SHADERS_DIR=$@/ clean all
+ $(SILENT) $(MAKE) --no-print-directory TARGET=0 SHADERS_DIR=$@/ clean all SILENT="$(SILENT)"
+ $(SILENT) $(MAKE) --no-print-directory TARGET=1 SHADERS_DIR=$@/ clean all SILENT="$(SILENT)"
endif
- @make -s --no-print-directory TARGET=2 SHADERS_DIR=$@/ clean all
- @make -s --no-print-directory TARGET=3 SHADERS_DIR=$@/ clean all
- @make -s --no-print-directory TARGET=4 SHADERS_DIR=$@/ clean all
- @make -s --no-print-directory TARGET=5 SHADERS_DIR=$@/ clean all
+ $(SILENT) $(MAKE) --no-print-directory TARGET=2 SHADERS_DIR=$@/ clean all SILENT="$(SILENT)"
+ $(SILENT) $(MAKE) --no-print-directory TARGET=3 SHADERS_DIR=$@/ clean all SILENT="$(SILENT)"
+ $(SILENT) $(MAKE) --no-print-directory TARGET=4 SHADERS_DIR=$@/ clean all SILENT="$(SILENT)"
+ $(SILENT) $(MAKE) --no-print-directory TARGET=5 SHADERS_DIR=$@/ clean all SILENT="$(SILENT)"
+ $(SILENT) $(MAKE) --no-print-directory TARGET=7 SHADERS_DIR=$@/ clean all SILENT="$(SILENT)"
main:
ifeq ($(OS),windows)
- @make -s --no-print-directory TARGET=0 clean all
- @make -s --no-print-directory TARGET=1 clean all
+ $(SILENT) $(MAKE) --no-print-directory TARGET=0 clean all SILENT="$(SILENT)"
+ $(SILENT) $(MAKE) --no-print-directory TARGET=1 clean all SILENT="$(SILENT)"
endif
- @make -s --no-print-directory TARGET=2 clean all
- @make -s --no-print-directory TARGET=3 clean all
- @make -s --no-print-directory TARGET=4 clean all
- @make -s --no-print-directory TARGET=5 clean all
+ $(SILENT) $(MAKE) --no-print-directory TARGET=2 clean all SILENT="$(SILENT)"
+ $(SILENT) $(MAKE) --no-print-directory TARGET=3 clean all SILENT="$(SILENT)"
+ $(SILENT) $(MAKE) --no-print-directory TARGET=4 clean all SILENT="$(SILENT)"
+ $(SILENT) $(MAKE) --no-print-directory TARGET=5 clean all SILENT="$(SILENT)"
+ $(SILENT) $(MAKE) --no-print-directory TARGET=7 clean all SILENT="$(SILENT)"
.PHONY: main rebuild $(SUBDIRS)
diff --git a/src/osd/modules/render/bgfx/shaders/shader.mk b/src/osd/modules/render/bgfx/shaders/shader.mk
index e7db3cdc242..b9cf2f47cef 100644
--- a/src/osd/modules/render/bgfx/shaders/shader.mk
+++ b/src/osd/modules/render/bgfx/shaders/shader.mk
@@ -43,24 +43,24 @@ SHADER_PATH=shaders/dx11/$(SHADERS_DIR)
else
ifeq ($(TARGET), 2)
VS_FLAGS=--platform nacl
-FS_FLAGS=--platform nacl
+FS_FLAGS=--platform nacl --define TRANSPOSED_XYZ_TO_sRGB
SHADER_PATH=shaders/essl/$(SHADERS_DIR)
else
ifeq ($(TARGET), 3)
VS_FLAGS=--platform android
-FS_FLAGS=--platform android
+FS_FLAGS=--platform android --define TRANSPOSED_XYZ_TO_sRGB
CS_FLAGS=--platform android
SHADER_PATH=shaders/essl/$(SHADERS_DIR)
else
ifeq ($(TARGET), 4)
VS_FLAGS=--platform linux -p 120
-FS_FLAGS=--platform linux -p 120
+FS_FLAGS=--platform linux -p 120 --define TRANSPOSED_XYZ_TO_sRGB
CS_FLAGS=--platform linux -p 430
SHADER_PATH=shaders/glsl/$(SHADERS_DIR)
else
ifeq ($(TARGET), 5)
VS_FLAGS=--platform osx -p metal
-FS_FLAGS=--platform osx -p metal
+FS_FLAGS=--platform osx -p metal --define TRANSPOSED_XYZ_TO_sRGB
CS_FLAGS=--platform osx -p metal
SHADER_PATH=shaders/metal/$(SHADERS_DIR)
else
diff --git a/src/osd/modules/render/bgfx/suppressorreader.cpp b/src/osd/modules/render/bgfx/suppressorreader.cpp
index 77a109a264b..024a99e20f8 100644
--- a/src/osd/modules/render/bgfx/suppressorreader.cpp
+++ b/src/osd/modules/render/bgfx/suppressorreader.cpp
@@ -77,6 +77,7 @@ bgfx_suppressor* suppressor_reader::read_from_value(const Value& value, std::str
bool suppressor_reader::validate_parameters(const Value& value, std::string prefix)
{
+ if (!READER_CHECK(value["type"].IsString(), (prefix + "Value 'type' must be a string\n").c_str())) return false;
if (!READER_CHECK(value.HasMember("name"), (prefix + "Must have string value 'name'\n").c_str())) return false;
if (!READER_CHECK(value["name"].IsString(), (prefix + "Value 'name' must be a string\n").c_str())) return false;
if (!READER_CHECK(value.HasMember("value"), (prefix + "Must have numeric or array value 'value'\n").c_str())) return false;
diff --git a/src/osd/modules/render/bgfx/texture.cpp b/src/osd/modules/render/bgfx/texture.cpp
index ecbf51121ab..7b6747e0c54 100644
--- a/src/osd/modules/render/bgfx/texture.cpp
+++ b/src/osd/modules/render/bgfx/texture.cpp
@@ -32,7 +32,7 @@ bgfx_texture::bgfx_texture(std::string name, bgfx::TextureFormat::Enum format, u
}
}
-bgfx_texture::bgfx_texture(std::string name, bgfx::TextureFormat::Enum format, uint16_t width, uint16_t height, const bgfx::Memory* data, uint32_t flags)
+bgfx_texture::bgfx_texture(std::string name, bgfx::TextureFormat::Enum format, uint16_t width, uint16_t height, const bgfx::Memory* data, uint32_t flags, uint16_t pitch)
: m_name(name)
, m_format(format)
, m_width(width)
@@ -40,10 +40,16 @@ bgfx_texture::bgfx_texture(std::string name, bgfx::TextureFormat::Enum format, u
{
bgfx::TextureInfo info;
bgfx::calcTextureSize(info, width, height, 1, false, false, 1, format);
- m_texture = bgfx::createTexture2D(width, height, false, 1, format, flags, data);
+ m_texture = bgfx::createTexture2D(width, height, false, 1, format, flags, nullptr);
+ bgfx::updateTexture2D(m_texture, 0, 0, 0, 0, width, height, data, pitch);
}
bgfx_texture::~bgfx_texture()
{
bgfx::destroy(m_texture);
}
+
+void bgfx_texture::update(const bgfx::Memory *data, uint16_t pitch)
+{
+ bgfx::updateTexture2D(m_texture, 0, 0, 0, 0, m_width, m_height, data, pitch);
+}
diff --git a/src/osd/modules/render/bgfx/texture.h b/src/osd/modules/render/bgfx/texture.h
index 7cb6d988150..1d5b1dd9f6d 100644
--- a/src/osd/modules/render/bgfx/texture.h
+++ b/src/osd/modules/render/bgfx/texture.h
@@ -21,7 +21,7 @@ class bgfx_texture : public bgfx_texture_handle_provider
{
public:
bgfx_texture(std::string name, bgfx::TextureFormat::Enum format, uint16_t width, uint16_t height, uint32_t flags, void* data);
- bgfx_texture(std::string name, bgfx::TextureFormat::Enum format, uint16_t width, uint16_t height, const bgfx::Memory* data, uint32_t flags = BGFX_SAMPLER_U_CLAMP | BGFX_SAMPLER_V_CLAMP);
+ bgfx_texture(std::string name, bgfx::TextureFormat::Enum format, uint16_t width, uint16_t height, const bgfx::Memory* data, uint32_t flags = BGFX_SAMPLER_U_CLAMP | BGFX_SAMPLER_V_CLAMP, uint16_t pitch = UINT16_MAX);
virtual ~bgfx_texture();
// Getters
@@ -34,6 +34,8 @@ public:
virtual bgfx::TextureHandle texture() const override { return m_texture; }
virtual bool is_target() const override { return false; }
+ void update(const bgfx::Memory *data, uint16_t pitch = UINT16_MAX);
+
protected:
std::string m_name;
bgfx::TextureFormat::Enum m_format;
diff --git a/src/osd/modules/render/bgfx/texturemanager.cpp b/src/osd/modules/render/bgfx/texturemanager.cpp
index a5fbca97f35..e2614133205 100644
--- a/src/osd/modules/render/bgfx/texturemanager.cpp
+++ b/src/osd/modules/render/bgfx/texturemanager.cpp
@@ -116,8 +116,10 @@ bgfx::TextureHandle texture_manager::create_or_update_mame_texture(uint32_t form
}
else
{
- const bgfx::Memory* mem = bgfx_util::mame_texture_data_to_bgfx_texture_data(format, width, height, rowpixels, palette, base);
- bgfx::updateTexture2D(handle, 0, 0, 0, 0, (uint16_t)width, (uint16_t)height, mem);
+ bgfx::TextureFormat::Enum dst_format = bgfx::TextureFormat::BGRA8;
+ uint16_t pitch = width;
+ const bgfx::Memory* mem = bgfx_util::mame_texture_data_to_bgfx_texture_data(dst_format, format, width, height, rowpixels, palette, base, &pitch);
+ bgfx::updateTexture2D(handle, 0, 0, 0, 0, (uint16_t)width, (uint16_t)height, mem, pitch);
return handle;
}
}
@@ -142,8 +144,10 @@ bgfx::TextureHandle texture_manager::create_or_update_mame_texture(uint32_t form
}
else
{
- const bgfx::Memory* mem = bgfx_util::mame_texture_data_to_bgfx_texture_data(format, width, height, rowpixels, palette, base);
- bgfx::updateTexture2D(handle, 0, 0, 0, 0, (uint16_t)width, (uint16_t)height, mem);
+ bgfx::TextureFormat::Enum dst_format = bgfx::TextureFormat::BGRA8;
+ uint16_t pitch = width;
+ const bgfx::Memory* mem = bgfx_util::mame_texture_data_to_bgfx_texture_data(dst_format, format, width, height, rowpixels, palette, base, &pitch);
+ bgfx::updateTexture2D(handle, 0, 0, 0, 0, (uint16_t)width, (uint16_t)height, mem, pitch);
return handle;
}
}
@@ -151,9 +155,11 @@ bgfx::TextureHandle texture_manager::create_or_update_mame_texture(uint32_t form
}
}
- const bgfx::Memory* mem = bgfx_util::mame_texture_data_to_bgfx_texture_data(format, width, height, rowpixels, palette, base);
- handle = bgfx::createTexture2D(width, height, false, 1, bgfx::TextureFormat::RGBA8, flags, nullptr);
- bgfx::updateTexture2D(handle, 0, 0, 0, 0, (uint16_t)width, (uint16_t)height, mem);
+ bgfx::TextureFormat::Enum dst_format = bgfx::TextureFormat::BGRA8;
+ uint16_t pitch = width;
+ const bgfx::Memory* mem = bgfx_util::mame_texture_data_to_bgfx_texture_data(dst_format, format, width, height, rowpixels, palette, base, &pitch);
+ handle = bgfx::createTexture2D(width, height, false, 1, dst_format, flags, nullptr);
+ bgfx::updateTexture2D(handle, 0, 0, 0, 0, (uint16_t)width, (uint16_t)height, mem, pitch);
m_mame_textures[key] = { handle, seqid, width, height };
return handle;
diff --git a/src/osd/modules/render/bgfx/uniform.cpp b/src/osd/modules/render/bgfx/uniform.cpp
index ef33c11f128..dc81475ad59 100644
--- a/src/osd/modules/render/bgfx/uniform.cpp
+++ b/src/osd/modules/render/bgfx/uniform.cpp
@@ -29,7 +29,7 @@ bgfx_uniform::~bgfx_uniform()
void bgfx_uniform::upload()
{
- if (m_type != bgfx::UniformType::Int1)
+ if (m_type != bgfx::UniformType::Sampler)
{
bgfx::setUniform(m_handle, m_data);
}
@@ -42,7 +42,7 @@ bgfx_uniform* bgfx_uniform::set(float* value)
bgfx_uniform* bgfx_uniform::set_int(int value)
{
- return set(&value, get_size_for_type(bgfx::UniformType::Int1));
+ return set(&value, get_size_for_type(bgfx::UniformType::Sampler));
}
bgfx_uniform* bgfx_uniform::set_mat3(float* value)
@@ -69,7 +69,7 @@ size_t bgfx_uniform::get_size_for_type(bgfx::UniformType::Enum type)
case bgfx::UniformType::Vec4:
return sizeof(float) * 4;
- case bgfx::UniformType::Int1:
+ case bgfx::UniformType::Sampler:
return sizeof(int);
case bgfx::UniformType::Mat3:
diff --git a/src/osd/modules/render/bgfx/uniformreader.cpp b/src/osd/modules/render/bgfx/uniformreader.cpp
index 3e3cb5db318..c97ca484e48 100644
--- a/src/osd/modules/render/bgfx/uniformreader.cpp
+++ b/src/osd/modules/render/bgfx/uniformreader.cpp
@@ -11,7 +11,7 @@
#include "uniform.h"
const uniform_reader::string_to_enum uniform_reader::TYPE_NAMES[uniform_reader::TYPE_COUNT] = {
- { "int", bgfx::UniformType::Int1 },
+ { "int", bgfx::UniformType::Sampler },
{ "vec4", bgfx::UniformType::Vec4 },
{ "mat3", bgfx::UniformType::Mat3 },
{ "mat4", bgfx::UniformType::Mat4 }
diff --git a/src/osd/modules/render/bgfx/vertex.h b/src/osd/modules/render/bgfx/vertex.h
index 32b3c36064f..2036296a9d0 100644
--- a/src/osd/modules/render/bgfx/vertex.h
+++ b/src/osd/modules/render/bgfx/vertex.h
@@ -31,7 +31,7 @@ struct ScreenVertex
.end();
}
- static bgfx::VertexDecl ms_decl;
+ static bgfx::VertexLayout ms_decl;
};
#endif // __DRAWBGFX_VERTEX__