mirror of https://github.com/inolen/redream.git
fix assert on video context destroy
This commit is contained in:
parent
67612f9055
commit
80f806492f
|
@ -133,8 +133,8 @@ static int emu_texture_cmp(const struct rb_node *rb_lhs,
|
||||||
|
|
||||||
static struct rb_callbacks emu_texture_cb = {&emu_texture_cmp, NULL, NULL};
|
static struct rb_callbacks emu_texture_cb = {&emu_texture_cmp, NULL, NULL};
|
||||||
|
|
||||||
static void emu_clear_textures(struct emu *emu) {
|
static void emu_dirty_textures(struct emu *emu) {
|
||||||
LOG_INFO("emu_clear_textures");
|
LOG_INFO("emu_dirty_textures");
|
||||||
|
|
||||||
struct rb_node *it = rb_first(&emu->live_textures);
|
struct rb_node *it = rb_first(&emu->live_textures);
|
||||||
|
|
||||||
|
@ -178,6 +178,14 @@ static void emu_palette_modified(const struct exception_state *ex, void *data) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void emu_free_texture(struct emu *emu, struct emu_texture *tex) {
|
||||||
|
/* remove from live tree */
|
||||||
|
rb_unlink(&emu->live_textures, &tex->live_it, &emu_texture_cb);
|
||||||
|
|
||||||
|
/* add back to free list */
|
||||||
|
list_add(&emu->free_textures, &tex->free_it);
|
||||||
|
}
|
||||||
|
|
||||||
static struct emu_texture *emu_alloc_texture(struct emu *emu, union tsp tsp,
|
static struct emu_texture *emu_alloc_texture(struct emu *emu, union tsp tsp,
|
||||||
union tcw tcw) {
|
union tcw tcw) {
|
||||||
/* remove from free list */
|
/* remove from free list */
|
||||||
|
@ -308,7 +316,7 @@ static void emu_toggle_tracing(struct emu *emu) {
|
||||||
|
|
||||||
/* clear texture cache in order to generate insert events for all
|
/* clear texture cache in order to generate insert events for all
|
||||||
textures referenced while tracing */
|
textures referenced while tracing */
|
||||||
emu_clear_textures(emu);
|
emu_dirty_textures(emu);
|
||||||
|
|
||||||
LOG_INFO("begin tracing to %s", filename);
|
LOG_INFO("begin tracing to %s", filename);
|
||||||
} else {
|
} else {
|
||||||
|
@ -473,7 +481,7 @@ static void emu_paint(struct emu *emu) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (igMenuItem("clear texture cache", NULL, 0, 1)) {
|
if (igMenuItem("clear texture cache", NULL, 0, 1)) {
|
||||||
emu_clear_textures(emu);
|
emu_dirty_textures(emu);
|
||||||
}
|
}
|
||||||
|
|
||||||
igEndMenu();
|
igEndMenu();
|
||||||
|
@ -670,14 +678,18 @@ static void emu_host_context_destroyed(void *userdata) {
|
||||||
thread_join(emu->video_thread, &result);
|
thread_join(emu->video_thread, &result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* reset texture cache */
|
/* destroy video renderer objects */
|
||||||
emu_clear_textures(emu);
|
|
||||||
|
|
||||||
/* destroy video renderer */
|
|
||||||
struct render_backend *r2 = emu_video_renderer(emu);
|
struct render_backend *r2 = emu_video_renderer(emu);
|
||||||
video_bind_context(emu->host, r2);
|
video_bind_context(emu->host, r2);
|
||||||
|
|
||||||
|
rb_for_each_entry_safe(tex, &emu->live_textures, struct emu_texture,
|
||||||
|
live_it) {
|
||||||
|
r_destroy_texture(r2, tex->handle);
|
||||||
|
emu_free_texture(emu, tex);
|
||||||
|
}
|
||||||
|
|
||||||
r_destroy_framebuffer(r2, emu->video_fb);
|
r_destroy_framebuffer(r2, emu->video_fb);
|
||||||
|
|
||||||
if (emu->video_sync) {
|
if (emu->video_sync) {
|
||||||
r_destroy_sync(r2, emu->video_sync);
|
r_destroy_sync(r2, emu->video_sync);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue