summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd
diff options
context:
space:
mode:
authorGravatarGravatar MooglyGuy <therealmogminer@gmail.com>2019-10-23 13:43:14 +0200
committerGravatarGravatar MooglyGuy <therealmogminer@gmail.com>2019-10-23 13:43:26 +0200
commitec4bee1371353b2767a1260637ab5317646970ca (patch)
treea12b8ebac95681a53fad3b951bdd2b9b4d69a919 /src/osd
parentc185a0402924694833514800601abd46a36994fd (diff)
-bgfx: Fixed incorrect pitch of palette uploads, fixes 16-bit palettized textures in Vulkan backend on BGFX. nw
Diffstat (limited to 'src/osd')
-rw-r--r--src/osd/modules/render/bgfx/chainmanager.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/osd/modules/render/bgfx/chainmanager.cpp b/src/osd/modules/render/bgfx/chainmanager.cpp
index aa7adb4b5fb..74300d55f97 100644
--- a/src/osd/modules/render/bgfx/chainmanager.cpp
+++ b/src/osd/modules/render/bgfx/chainmanager.cpp
@@ -475,9 +475,11 @@ uint32_t chain_manager::update_screen_textures(uint32_t view, render_primitive *
if (prim.m_prim->texture.palette)
{
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 / 256, 1U);
- const bgfx::Memory *palmem = bgfx::copy(prim.m_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);
+ uint16_t palette_height = (uint16_t)std::max((prim.m_palette_length + 255) / 256, 1U);
+ uint8_t palette_temp[palette_width * palette_height * 4];
+ memcpy(palette_temp, prim.m_prim->texture.palette, prim.m_palette_length * 4);
+ const bgfx::Memory *palmem = bgfx::copy(palette_temp, 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 * 4);
m_textures.add_provider(palette_name, palette);
}
@@ -496,7 +498,9 @@ uint32_t chain_manager::update_screen_textures(uint32_t view, render_primitive *
if (prim.m_prim->texture.palette)
{
- const bgfx::Memory *palmem = bgfx::copy(prim.m_prim->texture.palette, palette->width() * palette->height() * 4);
+ uint8_t palette_temp[palette->width() * palette->height() * 4];
+ memcpy(palette_temp, prim.m_prim->texture.palette, prim.m_palette_length * 4);
+ const bgfx::Memory *palmem = bgfx::copy(palette_temp, palette->width() * palette->height() * 4);
palette->update(palmem);
}
}