summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp6
-rw-r--r--src/video_core/texture_cache/surface_base.cpp19
-rw-r--r--src/video_core/texture_cache/texture_cache.h14
3 files changed, 29 insertions, 10 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index d0e7b61e7..63ee83391 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -722,7 +722,7 @@ void RasterizerOpenGL::FlushRegion(CacheAddr addr, u64 size) {
if (!addr || !size) {
return;
}
- // texture_cache.FlushRegion(addr, size);
+ texture_cache.FlushRegion(addr, size);
global_cache.FlushRegion(addr, size);
}
@@ -738,7 +738,9 @@ void RasterizerOpenGL::InvalidateRegion(CacheAddr addr, u64 size) {
}
void RasterizerOpenGL::FlushAndInvalidateRegion(CacheAddr addr, u64 size) {
- FlushRegion(addr, size);
+ if (Settings::values.use_accurate_gpu_emulation) {
+ FlushRegion(addr, size);
+ }
InvalidateRegion(addr, size);
}
diff --git a/src/video_core/texture_cache/surface_base.cpp b/src/video_core/texture_cache/surface_base.cpp
index 5e994cf08..dc5013240 100644
--- a/src/video_core/texture_cache/surface_base.cpp
+++ b/src/video_core/texture_cache/surface_base.cpp
@@ -63,6 +63,9 @@ void SurfaceBaseImpl::LoadBuffer(Tegra::MemoryManager& memory_manager,
std::vector<u8>& staging_buffer) {
MICROPROFILE_SCOPE(GPU_Load_Texture);
const auto host_ptr{memory_manager.GetPointer(gpu_addr)};
+ if (!host_ptr) {
+ return;
+ }
if (params.is_tiled) {
ASSERT_MSG(params.block_width == 1, "Block width is defined as {} on texture target {}",
params.block_width, static_cast<u32>(params.target));
@@ -103,7 +106,10 @@ void SurfaceBaseImpl::LoadBuffer(Tegra::MemoryManager& memory_manager,
void SurfaceBaseImpl::FlushBuffer(Tegra::MemoryManager& memory_manager,
std::vector<u8>& staging_buffer) {
MICROPROFILE_SCOPE(GPU_Flush_Texture);
- auto host_ptr = memory_manager.GetPointer(gpu_addr);
+ const auto host_ptr{memory_manager.GetPointer(gpu_addr)};
+ if (!host_ptr) {
+ return;
+ }
if (params.is_tiled) {
ASSERT_MSG(params.block_width == 1, "Block width is defined as {}", params.block_width);
for (u32 level = 0; level < params.num_levels; ++level) {
@@ -112,25 +118,22 @@ void SurfaceBaseImpl::FlushBuffer(Tegra::MemoryManager& memory_manager,
staging_buffer.data() + host_offset, level);
}
} else {
- UNIMPLEMENTED();
- /*
ASSERT(params.target == SurfaceTarget::Texture2D);
ASSERT(params.num_levels == 1);
- const u32 bpp{params.GetFormatBpp() / 8};
+ const u32 bpp{params.GetBytesPerPixel()};
const u32 copy_size{params.width * bpp};
if (params.pitch == copy_size) {
- std::memcpy(host_ptr, staging_buffer.data(), memory_size);
+ std::memcpy(host_ptr, staging_buffer.data(), guest_memory_size);
} else {
u8* start{host_ptr};
const u8* read_to{staging_buffer.data()};
- for (u32 h = params.GetHeight(); h > 0; --h) {
+ for (u32 h = params.height; h > 0; --h) {
std::memcpy(start, read_to, copy_size);
- start += params.GetPitch();
+ start += params.pitch;
read_to += copy_size;
}
}
- */
}
}
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h
index 554b9a228..422bf3e58 100644
--- a/src/video_core/texture_cache/texture_cache.h
+++ b/src/video_core/texture_cache/texture_cache.h
@@ -61,6 +61,20 @@ public:
}
}
+ void FlushRegion(CacheAddr addr, std::size_t size) {
+ auto surfaces = GetSurfacesInRegion(addr, size);
+ if (surfaces.empty()) {
+ return;
+ }
+ std::sort(surfaces.begin(), surfaces.end(),
+ [](const TSurface& a, const TSurface& b) -> bool {
+ return a->GetModificationTick() < b->GetModificationTick();
+ });
+ for (const auto& surface : surfaces) {
+ FlushSurface(surface);
+ }
+ }
+
TView GetTextureSurface(const Tegra::Texture::FullTextureInfo& config,
const VideoCommon::Shader::Sampler& entry) {
const auto gpu_addr{config.tic.Address()};