summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd
diff options
context:
space:
mode:
authorGravatarGravatar mooglyguy <therealmogminer@gmail.com>2019-11-22 22:00:34 +0100
committerGravatarGravatar mooglyguy <therealmogminer@gmail.com>2019-11-22 22:01:55 +0100
commited3fb56b47940aecbe7961b247861f878aa50127 (patch)
tree0f105176595b0e6bb3f9fee3b9da839b9644d81c /src/osd
parentba64eb34d9a3b1fcd7ed57188fd63d9142679299 (diff)
-bgfx: Fixed broken rendering when using bgfx_screen_chains none, nw
Diffstat (limited to 'src/osd')
-rw-r--r--src/osd/modules/render/bgfxutil.cpp10
-rw-r--r--src/osd/modules/render/bgfxutil.h1
-rw-r--r--src/osd/modules/render/drawbgfx.cpp24
3 files changed, 28 insertions, 7 deletions
diff --git a/src/osd/modules/render/bgfxutil.cpp b/src/osd/modules/render/bgfxutil.cpp
index eb847cbdba9..0f097b614a6 100644
--- a/src/osd/modules/render/bgfxutil.cpp
+++ b/src/osd/modules/render/bgfxutil.cpp
@@ -34,14 +34,18 @@ const bgfx::Memory* bgfx_util::mame_texture_data_to_bgfx_texture_data(bgfx::Text
}
bgfx::calcTextureSize(info, rowpixels, height, 1, false, false, 1, dst_format);
return bgfx::copy(base, info.storageSize);
- /*const bgfx::Memory* mem = bgfx::alloc(width * height * 4);
+}
+
+const bgfx::Memory* bgfx_util::mame_texture_data_to_argb32(uint32_t src_format, int width, int height, int rowpixels, const rgb_t *palette, void *base)
+{
+ const bgfx::Memory* mem = bgfx::alloc(width * height * 4);
uint32_t* dst = reinterpret_cast<uint32_t*>(mem->data);
uint16_t* src16 = reinterpret_cast<uint16_t*>(base);
uint32_t* src32 = reinterpret_cast<uint32_t*>(base);
for (int y = 0; y < height; y++)
{
- switch (format)
+ switch (src_format)
{
case PRIMFLAG_TEXFORMAT(TEXFORMAT_PALETTE16):
copy_util::copyline_palette16(dst, src16, width, palette);
@@ -64,7 +68,7 @@ const bgfx::Memory* bgfx_util::mame_texture_data_to_bgfx_texture_data(bgfx::Text
}
dst += width;
}
- return mem;*/
+ return mem;
}
uint64_t bgfx_util::get_blend_state(uint32_t blend)
diff --git a/src/osd/modules/render/bgfxutil.h b/src/osd/modules/render/bgfxutil.h
index f1311858324..a6a50436372 100644
--- a/src/osd/modules/render/bgfxutil.h
+++ b/src/osd/modules/render/bgfxutil.h
@@ -12,6 +12,7 @@ class bgfx_util
{
public:
static const bgfx::Memory* mame_texture_data_to_bgfx_texture_data(bgfx::TextureFormat::Enum &dst_format, uint32_t format, int width, int height, int rowpixels, const rgb_t *palette, void *base, uint16_t *out_pitch = nullptr);
+ static const bgfx::Memory* mame_texture_data_to_argb32(uint32_t src_format, int width, int height, int rowpixels, const rgb_t *palette, void *base);
static uint64_t get_blend_state(uint32_t blend);
};
diff --git a/src/osd/modules/render/drawbgfx.cpp b/src/osd/modules/render/drawbgfx.cpp
index 9372956d54b..cfcb3d687ca 100644
--- a/src/osd/modules/render/drawbgfx.cpp
+++ b/src/osd/modules/render/drawbgfx.cpp
@@ -597,19 +597,35 @@ void renderer_bgfx::render_textured_quad(render_primitive* prim, bgfx::Transient
texture_flags |= BGFX_SAMPLER_MIN_POINT | BGFX_SAMPLER_MAG_POINT | BGFX_SAMPLER_MIP_POINT;
}
+ const bool is_screen = PRIMFLAG_GET_SCREENTEX(prim->flags);
uint16_t tex_width(prim->texture.width);
uint16_t tex_height(prim->texture.height);
- bgfx::TextureHandle texture = m_textures->create_or_update_mame_texture(prim->flags & PRIMFLAG_TEXFORMAT_MASK
- , tex_width, tex_height, prim->texture.rowpixels, prim->texture.palette, prim->texture.base, prim->texture.seqid
- , texture_flags, prim->texture.unique_id, prim->texture.old_id);
+ bgfx::TextureHandle texture = BGFX_INVALID_HANDLE;
+ if (is_screen)
+ {
+ const bgfx::Memory* mem = bgfx_util::mame_texture_data_to_argb32(prim->flags & PRIMFLAG_TEXFORMAT_MASK
+ , tex_width, tex_height, prim->texture.rowpixels, prim->texture.palette, prim->texture.base);
+ texture = bgfx::createTexture2D(tex_width, tex_height, false, 1, bgfx::TextureFormat::RGBA8, texture_flags, mem);
+ }
+ else
+ {
+ texture = m_textures->create_or_update_mame_texture(prim->flags & PRIMFLAG_TEXFORMAT_MASK
+ , tex_width, tex_height, prim->texture.rowpixels, prim->texture.palette, prim->texture.base, prim->texture.seqid
+ , texture_flags, prim->texture.unique_id, prim->texture.old_id);
+ }
- bgfx_effect** effects = PRIMFLAG_GET_SCREENTEX(prim->flags) ? m_screen_effect : m_gui_effect;
+ bgfx_effect** effects = is_screen ? m_screen_effect : m_gui_effect;
uint32_t blend = PRIMFLAG_GET_BLENDMODE(prim->flags);
bgfx::setVertexBuffer(0,buffer);
bgfx::setTexture(0, effects[blend]->uniform("s_tex")->handle(), texture);
effects[blend]->submit(m_ortho_view->get_index());
+
+ if (is_screen)
+ {
+ bgfx::destroy(texture);
+ }
}
#define MAX_TEMP_COORDS 100