diff --git a/rpcs3/Emu/RSX/Common/texture_cache.h b/rpcs3/Emu/RSX/Common/texture_cache.h index 62686544ed..28a6038e6a 100644 --- a/rpcs3/Emu/RSX/Common/texture_cache.h +++ b/rpcs3/Emu/RSX/Common/texture_cache.h @@ -18,7 +18,8 @@ namespace rsx { shader_read = 0, blit_engine_src = 1, - blit_engine_dst = 2 + blit_engine_dst = 2, + framebuffer_storage = 3 }; struct cached_texture_section : public rsx::buffered_section @@ -271,12 +272,7 @@ namespace rsx { auto obj = *It; - if (discard_only) - obj.first->discard(); - else - obj.first->unprotect(); - - if (obj.first->is_flushable() && allow_flush) + if (obj.first->is_flushable()) { sections_to_flush.push_back(obj.first); } @@ -286,6 +282,11 @@ namespace rsx m_unreleased_texture_objects++; } + if (discard_only) + obj.first->discard(); + else + obj.first->unprotect(); + obj.second->remove_one(); } @@ -325,7 +326,7 @@ namespace rsx template std::pair> invalidate_range_impl(u32 address, u32 range, bool discard, bool allow_flush, Args&... extras) { - return invalidate_range_impl_base(address, range, discard, true, allow_flush, std::forward(extras)...); + return invalidate_range_impl_base(address, range, discard, false, allow_flush, std::forward(extras)...); } bool is_hw_blit_engine_compatible(const u32 format) const @@ -406,7 +407,7 @@ namespace rsx { if (!confirm_dimensions || tex.matches(rsx_address, width, height, depth, mipmaps)) { - if (!tex.is_locked()) + if (!tex.is_locked() && tex.get_context() == texture_upload_context::framebuffer_storage) range_data.notify(rsx_address, rsx_size); return tex; @@ -475,6 +476,7 @@ namespace rsx region.protect(utils::protection::no); region.create(width, height, 1, 1, nullptr, image, pitch, false, std::forward(extras)...); + region.set_context(texture_upload_context::framebuffer_storage); } template @@ -598,9 +600,6 @@ namespace rsx reader_lock lock(m_cache_mutex); for (const auto &tex: sections_to_flush) { - if (tex->is_flushed()) - continue; - if (!tex->flush(std::forward(extras)...)) { //Missed address, note this diff --git a/rpcs3/Emu/RSX/GL/GLGSRender.cpp b/rpcs3/Emu/RSX/GL/GLGSRender.cpp index 004b9d5c92..78a3b75ab8 100644 --- a/rpcs3/Emu/RSX/GL/GLGSRender.cpp +++ b/rpcs3/Emu/RSX/GL/GLGSRender.cpp @@ -1204,7 +1204,7 @@ u64 GLGSRender::timestamp() const bool GLGSRender::on_access_violation(u32 address, bool is_writing) { - bool can_flush = (std::this_thread::get_id() != m_thread_id); + bool can_flush = (std::this_thread::get_id() == m_thread_id); auto result = m_gl_texture_cache.invalidate_address(address, can_flush); if (!result.first) @@ -1224,7 +1224,7 @@ bool GLGSRender::on_access_violation(u32 address, bool is_writing) return true; } - return false; + return true; } void GLGSRender::on_notify_memory_unmapped(u32 address_base, u32 size) diff --git a/rpcs3/Emu/RSX/GL/GLTextureCache.h b/rpcs3/Emu/RSX/GL/GLTextureCache.h index 440629c5c2..d7145921ff 100644 --- a/rpcs3/Emu/RSX/GL/GLTextureCache.h +++ b/rpcs3/Emu/RSX/GL/GLTextureCache.h @@ -443,22 +443,21 @@ namespace gl { //Read-only texture, destroy texture memory glDeleteTextures(1, &vram_texture); - vram_texture = 0; } else { //Destroy pbo cache since vram texture is managed elsewhere glDeleteBuffers(1, &pbo_id); - pbo_id = 0; - pbo_size = 0; if (scaled_texture) - { glDeleteTextures(1, &scaled_texture); - scaled_texture = 0; - } } + vram_texture = 0; + scaled_texture = 0; + pbo_id = 0; + pbo_size = 0; + if (!m_fence.is_empty()) m_fence.destroy(); } diff --git a/rpcs3/Emu/RSX/VK/VKTextureCache.h b/rpcs3/Emu/RSX/VK/VKTextureCache.h index bad61220b2..0a20d8cff3 100644 --- a/rpcs3/Emu/RSX/VK/VKTextureCache.h +++ b/rpcs3/Emu/RSX/VK/VKTextureCache.h @@ -80,6 +80,12 @@ namespace vk } } + void destroy() + { + vram_texture = nullptr; + release_dma_resources(); + } + bool exists() const { return (vram_texture != nullptr); @@ -355,7 +361,7 @@ namespace vk void free_texture_section(cached_texture_section& tex) override { m_discardable_storage.push_back(tex); - tex.release_dma_resources(); + tex.destroy(); } vk::image_view* create_temporary_subresource_view(vk::command_buffer& cmd, vk::image* source, u32 /*gcm_format*/, u16 x, u16 y, u16 w, u16 h) override @@ -394,7 +400,7 @@ namespace vk VkImageCopy copy_rgn; copy_rgn.srcOffset = { (s32)x, (s32)y, 0 }; - copy_rgn.dstOffset = { (s32)x, (s32)y, 0 }; + copy_rgn.dstOffset = { (s32)0, (s32)0, 0 }; copy_rgn.dstSubresource = { aspect, 0, 0, 1 }; copy_rgn.srcSubresource = { aspect, 0, 0, 1 }; copy_rgn.extent = { w, h, 1 };