diff --git a/libretro_core_options.h b/libretro_core_options.h index bb633081..81290a8d 100644 --- a/libretro_core_options.h +++ b/libretro_core_options.h @@ -186,6 +186,17 @@ struct retro_core_option_definition option_defs_us[] = { }, "disabled" }, + { + BEETLE_OPT(track_textures), + "Track Textures", + "Prerequisite for texture dumping and replacement. Will probably crash in most games.", + { + { "disabled", NULL }, + { "enabled", NULL }, + { NULL, NULL }, + }, + "disabled" + }, #ifdef TEXTURE_DUMPING_ENABLED { BEETLE_OPT(dump_textures), diff --git a/parallel-psx/renderer/renderer.cpp b/parallel-psx/renderer/renderer.cpp index c21b4cf2..14a12021 100644 --- a/parallel-psx/renderer/renderer.cpp +++ b/parallel-psx/renderer/renderer.cpp @@ -466,7 +466,9 @@ void Renderer::set_draw_rect(const Rect &rect) void Renderer::clear_rect(const Rect &rect, FBColor color) { - tracker.clearRegion(rect); + if (texture_tracking_enabled) { + tracker.clearRegion(rect); + } last_scanout.reset(); atlas.clear_rect(rect, color); @@ -554,7 +556,9 @@ void Renderer::copy_vram_to_cpu_synchronous(const Rect &rect, uint16_t *vram) for (uint16_t x = 0; x < rect.width; x++) vram[(y + rect.y) * FB_WIDTH + (x + rect.x)] = uint16_t(mapped[y * rect.width + x]); - tracker.notifyReadback(rect, vram); + if (texture_tracking_enabled) { + tracker.notifyReadback(rect, vram); + } device.unmap_host_buffer(*buffer, MEMORY_ACCESS_READ_BIT); @@ -879,7 +883,9 @@ ImageHandle Renderer::scanout_vram_to_texture(bool scaled) ImageHandle Renderer::scanout_to_texture() { atlas.flush_render_pass(); - tracker.endFrame(); + if (texture_tracking_enabled) { + tracker.endFrame(); + } if (last_scanout) return last_scanout; @@ -1298,9 +1304,11 @@ HdTextureHandle Renderer::get_hd_texture_index(const Rect &vram_rect, bool &fast mode.palette_offset_x = 0; mode.palette_offset_y = 0; } - return tracker.get_hd_texture_index(vram_rect, mode, render_state.texture_offset_x, render_state.texture_offset_y, fastpath_capable_out, cache_hit_out); - // HDTODO: hd_texture_index = getHdTextureIndex(snoop); - // HDTODO: otherwise set hd_texture_index = last_hd_texture_index + if (texture_tracking_enabled) { + return tracker.get_hd_texture_index(vram_rect, mode, render_state.texture_offset_x, render_state.texture_offset_y, fastpath_capable_out, cache_hit_out); + } else { + return HdTextureHandle::make_none(); + } } void Renderer::build_attribs(BufferVertex *output, const Vertex *vertices, unsigned count, HdTextureHandle &hd_texture_index) @@ -2218,7 +2226,9 @@ void Renderer::blit_vram(const Rect &dst, const Rect &src) last_scanout.reset(); auto domain = atlas.blit_vram(dst, src); - tracker.blit(dst, src); + if (texture_tracking_enabled) { + tracker.blit(dst, src); + } if (dst.intersects(src)) { @@ -2343,7 +2353,12 @@ Vulkan::CommandBufferHandle &Renderer::command_buffer_hack_fixme() { } void Renderer::notify_texture_upload(Rect uploadRect, uint16_t *vram) { - tracker.upload(uploadRect, vram); + if (texture_tracking_enabled) { + tracker.upload(uploadRect, vram); + } +} +void Renderer::set_track_textures(bool enable) { + texture_tracking_enabled = enable; } void Renderer::set_dump_textures(bool enable) { tracker.dump_enabled = enable; @@ -2457,6 +2472,8 @@ void Renderer::reset_queue() reset_scissor_queue(); - tracker.on_queues_reset(); + if (texture_tracking_enabled) { + tracker.on_queues_reset(); + } } } diff --git a/parallel-psx/renderer/renderer.hpp b/parallel-psx/renderer/renderer.hpp index faebabfd..4f5397b2 100644 --- a/parallel-psx/renderer/renderer.hpp +++ b/parallel-psx/renderer/renderer.hpp @@ -150,6 +150,7 @@ public: Renderer(Vulkan::Device &device, unsigned scaling, unsigned msaa, const SaveState *save_state); ~Renderer(); + void set_track_textures(bool enable); void set_dump_textures(bool enable); void set_replace_textures(bool enable); @@ -387,6 +388,7 @@ private: Vulkan::Semaphore scanout_semaphore; std::vector scaled_views; FBAtlas atlas; + bool texture_tracking_enabled = false; TextureTracker tracker; Vulkan::CommandBufferHandle cmd; diff --git a/rsx/rsx_lib_vulkan.cpp b/rsx/rsx_lib_vulkan.cpp index e3336615..7defc6df 100644 --- a/rsx/rsx_lib_vulkan.cpp +++ b/rsx/rsx_lib_vulkan.cpp @@ -55,6 +55,7 @@ static vector> defer; static dither_mode dither_mode = DITHER_NATIVE; static bool dump_textures = false; static bool replace_textures = false; +static bool track_textures = false; static bool crop_overscan; static int image_offset_cycles; static int initial_scanline; @@ -370,6 +371,15 @@ void rsx_vulkan_refresh_variables(void) else widescreen_hack = false; } + + var.key = BEETLE_OPT(track_textures); + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "enabled")) + track_textures = true; + else + track_textures = false; + } var.key = BEETLE_OPT(dump_textures); if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) @@ -389,6 +399,14 @@ void rsx_vulkan_refresh_variables(void) replace_textures = false; } + struct retro_core_option_display option_display; + option_display.visible = track_textures; + + option_display.key = BEETLE_OPT(dump_textures); + environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY, &option_display); + option_display.key = BEETLE_OPT(replace_textures); + environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY, &option_display); + var.key = BEETLE_OPT(frame_duping); if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { @@ -474,6 +492,7 @@ void rsx_vulkan_finalize_frame(const void *fb, unsigned width, return; } + renderer->set_track_textures(track_textures); renderer->set_dump_textures(dump_textures); renderer->set_replace_textures(replace_textures); renderer->set_adaptive_smoothing(adaptive_smoothing);