summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd
diff options
context:
space:
mode:
authorGravatarGravatar Vas Crabb <vas@vastheman.com>2019-10-25 18:16:49 +1100
committerGravatarGravatar Vas Crabb <vas@vastheman.com>2019-10-25 18:16:49 +1100
commitb0ffbe067cab35f9dd1939be3ebececd5e8b23fe (patch)
treeefe63304a437f0e873eab20d7ae2ee240680f29c /src/osd
parent17d95ecab5740b72528e93f7f67eca96f4b6543c (diff)
(nw) keep a persistent temporary palette buffer in bgfx chain manager, back out some unintentional screen changes
Diffstat (limited to 'src/osd')
-rw-r--r--src/osd/modules/render/bgfx/chainmanager.cpp12
-rw-r--r--src/osd/modules/render/bgfx/chainmanager.h1
2 files changed, 7 insertions, 6 deletions
diff --git a/src/osd/modules/render/bgfx/chainmanager.cpp b/src/osd/modules/render/bgfx/chainmanager.cpp
index 74300d55f97..e6d046db69c 100644
--- a/src/osd/modules/render/bgfx/chainmanager.cpp
+++ b/src/osd/modules/render/bgfx/chainmanager.cpp
@@ -476,9 +476,9 @@ uint32_t chain_manager::update_screen_textures(uint32_t view, render_primitive *
{
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 + 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);
+ m_palette_temp.resize(palette_width * palette_height * 4);
+ memcpy(&m_palette_temp[0], prim.m_prim->texture.palette, prim.m_palette_length * 4);
+ const bgfx::Memory *palmem = bgfx::copy(&m_palette_temp[0], 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);
}
@@ -498,9 +498,9 @@ uint32_t chain_manager::update_screen_textures(uint32_t view, render_primitive *
if (prim.m_prim->texture.palette)
{
- 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);
+ m_palette_temp.resize(palette->width() * palette->height() * 4);
+ memcpy(&m_palette_temp[0], prim.m_prim->texture.palette, prim.m_palette_length * 4);
+ const bgfx::Memory *palmem = bgfx::copy(&m_palette_temp[0], palette->width() * palette->height() * 4);
palette->update(palmem);
}
}
diff --git a/src/osd/modules/render/bgfx/chainmanager.h b/src/osd/modules/render/bgfx/chainmanager.h
index cbdff1ab3a3..aa5edbecd39 100644
--- a/src/osd/modules/render/bgfx/chainmanager.h
+++ b/src/osd/modules/render/bgfx/chainmanager.h
@@ -148,6 +148,7 @@ private:
std::vector<bgfx_texture*> m_screen_palettes;
std::vector<bgfx_effect*> m_converters;
std::vector<screen_prim> m_screen_prims;
+ std::vector<uint8_t> m_palette_temp;
static const uint32_t CHAIN_NONE;
};