mirror of
https://github.com/holub/mame
synced 2025-06-29 15:38:53 +03:00
Fix cocktail mode crash
This commit is contained in:
parent
a99df78801
commit
124b4ab8a7
@ -62,7 +62,7 @@ void bgfx_chain_entry::submit(int view, render_primitive* prim, texture_manager&
|
|||||||
put_screen_buffer(prim, &buffer);
|
put_screen_buffer(prim, &buffer);
|
||||||
bgfx::setVertexBuffer(&buffer);
|
bgfx::setVertexBuffer(&buffer);
|
||||||
|
|
||||||
setup_auto_uniforms(prim, textures, screen_width, screen_height, rotation_type, swap_xy);
|
setup_auto_uniforms(prim, textures, screen_width, screen_height, rotation_type, swap_xy, screen);
|
||||||
|
|
||||||
for (bgfx_entry_uniform* uniform : m_uniforms)
|
for (bgfx_entry_uniform* uniform : m_uniforms)
|
||||||
{
|
{
|
||||||
@ -85,14 +85,19 @@ void bgfx_chain_entry::submit(int view, render_primitive* prim, texture_manager&
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void bgfx_chain_entry::setup_screensize_uniforms(texture_manager& textures, uint16_t screen_width, uint16_t screen_height)
|
void bgfx_chain_entry::setup_screensize_uniforms(texture_manager& textures, uint16_t screen_width, uint16_t screen_height, int32_t screen)
|
||||||
{
|
{
|
||||||
float width = screen_width;
|
float width = screen_width;
|
||||||
float height = screen_height;
|
float height = screen_height;
|
||||||
if (m_inputs.size() > 0)
|
if (m_inputs.size() > 0)
|
||||||
{
|
{
|
||||||
width = float(textures.provider(m_inputs[0].texture())->width());
|
std::string name = m_inputs[0].texture();
|
||||||
height = float(textures.provider(m_inputs[0].texture())->height());
|
if (name == "previous")
|
||||||
|
{
|
||||||
|
name = name + std::to_string(screen);
|
||||||
|
}
|
||||||
|
width = float(textures.provider(name)->width());
|
||||||
|
height = float(textures.provider(name)->height());
|
||||||
}
|
}
|
||||||
|
|
||||||
bgfx_uniform* screen_dims = m_effect->uniform("u_screen_dims");
|
bgfx_uniform* screen_dims = m_effect->uniform("u_screen_dims");
|
||||||
@ -140,9 +145,9 @@ void bgfx_chain_entry::setup_swapxy_uniform(bool swap_xy)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void bgfx_chain_entry::setup_auto_uniforms(render_primitive* prim, texture_manager& textures, uint16_t screen_width, uint16_t screen_height, uint32_t rotation_type, bool swap_xy)
|
void bgfx_chain_entry::setup_auto_uniforms(render_primitive* prim, texture_manager& textures, uint16_t screen_width, uint16_t screen_height, uint32_t rotation_type, bool swap_xy, int32_t screen)
|
||||||
{
|
{
|
||||||
setup_screensize_uniforms(textures, screen_width, screen_height);
|
setup_screensize_uniforms(textures, screen_width, screen_height, screen);
|
||||||
setup_sourcesize_uniform(prim);
|
setup_sourcesize_uniform(prim);
|
||||||
setup_rotationtype_uniform(rotation_type);
|
setup_rotationtype_uniform(rotation_type);
|
||||||
setup_swapxy_uniform(swap_xy);
|
setup_swapxy_uniform(swap_xy);
|
||||||
|
@ -43,8 +43,8 @@ public:
|
|||||||
bool skip();
|
bool skip();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setup_auto_uniforms(render_primitive* prim, texture_manager& textures, uint16_t screen_width, uint16_t screen_height, uint32_t rotation_type, bool swap_xy);
|
void setup_auto_uniforms(render_primitive* prim, texture_manager& textures, uint16_t screen_width, uint16_t screen_height, uint32_t rotation_type, bool swap_xy, int32_t screen);
|
||||||
void setup_screensize_uniforms(texture_manager& textures, uint16_t screen_width, uint16_t screen_height);
|
void setup_screensize_uniforms(texture_manager& textures, uint16_t screen_width, uint16_t screen_height, int32_t screen);
|
||||||
void setup_sourcesize_uniform(render_primitive* prim);
|
void setup_sourcesize_uniform(render_primitive* prim);
|
||||||
void setup_rotationtype_uniform(uint32_t rotation_type);
|
void setup_rotationtype_uniform(uint32_t rotation_type);
|
||||||
void setup_swapxy_uniform(bool swap_xy);
|
void setup_swapxy_uniform(bool swap_xy);
|
||||||
|
@ -765,6 +765,7 @@ int renderer_bgfx::handle_screen_chains()
|
|||||||
|
|
||||||
int renderer_bgfx::draw(int update)
|
int renderer_bgfx::draw(int update)
|
||||||
{
|
{
|
||||||
|
m_screens.clear();
|
||||||
int window_index = window().m_index;
|
int window_index = window().m_index;
|
||||||
int post_view_index = handle_screen_chains();
|
int post_view_index = handle_screen_chains();
|
||||||
int view_index = window_index;
|
int view_index = window_index;
|
||||||
@ -837,7 +838,7 @@ int renderer_bgfx::draw(int update)
|
|||||||
bool atlas_valid = update_atlas();
|
bool atlas_valid = update_atlas();
|
||||||
|
|
||||||
render_primitive *prim = window().m_primlist->first();
|
render_primitive *prim = window().m_primlist->first();
|
||||||
int32_t screen = 0;
|
std::vector<screen_device*> screens;
|
||||||
while (prim != nullptr)
|
while (prim != nullptr)
|
||||||
{
|
{
|
||||||
UINT32 blend = PRIMFLAG_GET_BLENDMODE(prim->flags);
|
UINT32 blend = PRIMFLAG_GET_BLENDMODE(prim->flags);
|
||||||
@ -845,13 +846,24 @@ int renderer_bgfx::draw(int update)
|
|||||||
bgfx::TransientVertexBuffer buffer;
|
bgfx::TransientVertexBuffer buffer;
|
||||||
allocate_buffer(prim, blend, &buffer);
|
allocate_buffer(prim, blend, &buffer);
|
||||||
|
|
||||||
buffer_status status = buffer_primitives(view_index, atlas_valid, &prim, &buffer, screen);
|
int32_t screen = 0;
|
||||||
|
if (PRIMFLAG_GET_SCREENTEX(prim->flags))
|
||||||
if (status == BUFFER_SCREEN)
|
|
||||||
{
|
{
|
||||||
screen++;
|
for (screen = 0; screen < screens.size(); screen++)
|
||||||
|
{
|
||||||
|
if (screens[screen] == prim->container->screen())
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (screen == screens.size())
|
||||||
|
{
|
||||||
|
screens.push_back(prim->container->screen());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buffer_status status = buffer_primitives(view_index, atlas_valid, &prim, &buffer, screen);
|
||||||
|
|
||||||
if (status != BUFFER_EMPTY && status != BUFFER_SCREEN)
|
if (status != BUFFER_EMPTY && status != BUFFER_SCREEN)
|
||||||
{
|
{
|
||||||
bgfx::setVertexBuffer(&buffer);
|
bgfx::setVertexBuffer(&buffer);
|
||||||
|
@ -92,6 +92,8 @@ private:
|
|||||||
const bgfx::Memory* mame_texture_data_to_bgfx_texture_data(UINT32 format, int width, int height, int rowpixels, const rgb_t *palette, void *base);
|
const bgfx::Memory* mame_texture_data_to_bgfx_texture_data(UINT32 format, int width, int height, int rowpixels, const rgb_t *palette, void *base);
|
||||||
UINT32 get_texture_hash(render_primitive *prim);
|
UINT32 get_texture_hash(render_primitive *prim);
|
||||||
|
|
||||||
|
std::vector<screen_device*> m_screens;
|
||||||
|
|
||||||
bgfx_target* m_framebuffer;
|
bgfx_target* m_framebuffer;
|
||||||
bgfx_texture* m_texture_cache;
|
bgfx_texture* m_texture_cache;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user