summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Fernando Sahmkow2019-07-11 15:15:21 -0400
committerGravatar FernandoS272019-07-14 12:00:31 -0400
commit5818959e543041fdff8965e71e52d55a05ee22de (patch)
tree1e168ded74b7b29a1822a8f5b0f07241db2c68d4 /src
parentGPU: Add a microprofile for macro interpreter (diff)
downloadyuzu-5818959e543041fdff8965e71e52d55a05ee22de.tar.gz
yuzu-5818959e543041fdff8965e71e52d55a05ee22de.tar.xz
yuzu-5818959e543041fdff8965e71e52d55a05ee22de.zip
Texture_Cache: Force Framebuffer reset if an active render target is unregistered.
Diffstat (limited to 'src')
-rw-r--r--src/video_core/texture_cache/surface_base.h8
-rw-r--r--src/video_core/texture_cache/surface_params.cpp13
-rw-r--r--src/video_core/texture_cache/texture_cache.h25
3 files changed, 36 insertions, 10 deletions
diff --git a/src/video_core/texture_cache/surface_base.h b/src/video_core/texture_cache/surface_base.h
index 8ba386a8a..fb6378bc7 100644
--- a/src/video_core/texture_cache/surface_base.h
+++ b/src/video_core/texture_cache/surface_base.h
@@ -200,8 +200,9 @@ public:
200 modification_tick = tick; 200 modification_tick = tick;
201 } 201 }
202 202
203 void MarkAsRenderTarget(const bool is_target) { 203 void MarkAsRenderTarget(const bool is_target, const u32 index) {
204 this->is_target = is_target; 204 this->is_target = is_target;
205 this->index = index;
205 } 206 }
206 207
207 void MarkAsPicked(const bool is_picked) { 208 void MarkAsPicked(const bool is_picked) {
@@ -221,6 +222,10 @@ public:
221 return is_target; 222 return is_target;
222 } 223 }
223 224
225 u32 GetRenderTarget() const {
226 return index;
227 }
228
224 bool IsRegistered() const { 229 bool IsRegistered() const {
225 return is_registered; 230 return is_registered;
226 } 231 }
@@ -311,6 +316,7 @@ private:
311 bool is_target{}; 316 bool is_target{};
312 bool is_registered{}; 317 bool is_registered{};
313 bool is_picked{}; 318 bool is_picked{};
319 u32 index{0xFFFFFFFF};
314 u64 modification_tick{}; 320 u64 modification_tick{};
315}; 321};
316 322
diff --git a/src/video_core/texture_cache/surface_params.cpp b/src/video_core/texture_cache/surface_params.cpp
index 9c56e2b4f..df9260859 100644
--- a/src/video_core/texture_cache/surface_params.cpp
+++ b/src/video_core/texture_cache/surface_params.cpp
@@ -290,12 +290,19 @@ std::size_t SurfaceParams::GetLayerSize(bool as_host_size, bool uncompressed) co
290 290
291std::size_t SurfaceParams::GetInnerMipmapMemorySize(u32 level, bool as_host_size, 291std::size_t SurfaceParams::GetInnerMipmapMemorySize(u32 level, bool as_host_size,
292 bool uncompressed) const { 292 bool uncompressed) const {
293 const bool tiled{as_host_size ? false : is_tiled};
294 const u32 width{GetMipmapSize(uncompressed, GetMipWidth(level), GetDefaultBlockWidth())}; 293 const u32 width{GetMipmapSize(uncompressed, GetMipWidth(level), GetDefaultBlockWidth())};
295 const u32 height{GetMipmapSize(uncompressed, GetMipHeight(level), GetDefaultBlockHeight())}; 294 const u32 height{GetMipmapSize(uncompressed, GetMipHeight(level), GetDefaultBlockHeight())};
296 const u32 depth{is_layered ? 1U : GetMipDepth(level)}; 295 const u32 depth{is_layered ? 1U : GetMipDepth(level)};
297 return Tegra::Texture::CalculateSize(tiled, GetBytesPerPixel(), width, height, depth, 296 if (is_tiled) {
298 GetMipBlockHeight(level), GetMipBlockDepth(level)); 297 return Tegra::Texture::CalculateSize(!as_host_size, GetBytesPerPixel(), width, height, depth,
298 GetMipBlockHeight(level), GetMipBlockDepth(level));
299 } else {
300 if (as_host_size || IsBuffer()) {
301 return GetBytesPerPixel()*width*height*depth;
302 } else {
303 return pitch*height*depth;
304 }
305 }
299} 306}
300 307
301bool SurfaceParams::operator==(const SurfaceParams& rhs) const { 308bool SurfaceParams::operator==(const SurfaceParams& rhs) const {
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h
index c9e72531a..5e9812bb9 100644
--- a/src/video_core/texture_cache/texture_cache.h
+++ b/src/video_core/texture_cache/texture_cache.h
@@ -133,11 +133,11 @@ public:
133 regs.zeta.memory_layout.block_depth, regs.zeta.memory_layout.type)}; 133 regs.zeta.memory_layout.block_depth, regs.zeta.memory_layout.type)};
134 auto surface_view = GetSurface(gpu_addr, depth_params, preserve_contents, true); 134 auto surface_view = GetSurface(gpu_addr, depth_params, preserve_contents, true);
135 if (depth_buffer.target) 135 if (depth_buffer.target)
136 depth_buffer.target->MarkAsRenderTarget(false); 136 depth_buffer.target->MarkAsRenderTarget(false, -1);
137 depth_buffer.target = surface_view.first; 137 depth_buffer.target = surface_view.first;
138 depth_buffer.view = surface_view.second; 138 depth_buffer.view = surface_view.second;
139 if (depth_buffer.target) 139 if (depth_buffer.target)
140 depth_buffer.target->MarkAsRenderTarget(true); 140 depth_buffer.target->MarkAsRenderTarget(true, 8);
141 return surface_view.second; 141 return surface_view.second;
142 } 142 }
143 143
@@ -167,11 +167,11 @@ public:
167 auto surface_view = GetSurface(gpu_addr, SurfaceParams::CreateForFramebuffer(system, index), 167 auto surface_view = GetSurface(gpu_addr, SurfaceParams::CreateForFramebuffer(system, index),
168 preserve_contents, true); 168 preserve_contents, true);
169 if (render_targets[index].target) 169 if (render_targets[index].target)
170 render_targets[index].target->MarkAsRenderTarget(false); 170 render_targets[index].target->MarkAsRenderTarget(false, -1);
171 render_targets[index].target = surface_view.first; 171 render_targets[index].target = surface_view.first;
172 render_targets[index].view = surface_view.second; 172 render_targets[index].view = surface_view.second;
173 if (render_targets[index].target) 173 if (render_targets[index].target)
174 render_targets[index].target->MarkAsRenderTarget(true); 174 render_targets[index].target->MarkAsRenderTarget(true, static_cast<u32>(index));
175 return surface_view.second; 175 return surface_view.second;
176 } 176 }
177 177
@@ -191,7 +191,7 @@ public:
191 if (depth_buffer.target == nullptr) { 191 if (depth_buffer.target == nullptr) {
192 return; 192 return;
193 } 193 }
194 depth_buffer.target->MarkAsRenderTarget(false); 194 depth_buffer.target->MarkAsRenderTarget(false, -1);
195 depth_buffer.target = nullptr; 195 depth_buffer.target = nullptr;
196 depth_buffer.view = nullptr; 196 depth_buffer.view = nullptr;
197 } 197 }
@@ -200,7 +200,7 @@ public:
200 if (render_targets[index].target == nullptr) { 200 if (render_targets[index].target == nullptr) {
201 return; 201 return;
202 } 202 }
203 render_targets[index].target->MarkAsRenderTarget(false); 203 render_targets[index].target->MarkAsRenderTarget(false, -1);
204 render_targets[index].target = nullptr; 204 render_targets[index].target = nullptr;
205 render_targets[index].view = nullptr; 205 render_targets[index].view = nullptr;
206 } 206 }
@@ -270,6 +270,16 @@ protected:
270 // and reading it from a sepparate buffer. 270 // and reading it from a sepparate buffer.
271 virtual void BufferCopy(TSurface& src_surface, TSurface& dst_surface) = 0; 271 virtual void BufferCopy(TSurface& src_surface, TSurface& dst_surface) = 0;
272 272
273 void ManageRenderTargetUnregister(TSurface& surface) {
274 auto& maxwell3d = system.GPU().Maxwell3D();
275 u32 index = surface->GetRenderTarget();
276 if (index == 8) {
277 maxwell3d.dirty_flags.zeta_buffer = true;
278 } else {
279 maxwell3d.dirty_flags.color_buffer.set(index, true);
280 }
281 }
282
273 void Register(TSurface surface) { 283 void Register(TSurface surface) {
274 const GPUVAddr gpu_addr = surface->GetGpuAddr(); 284 const GPUVAddr gpu_addr = surface->GetGpuAddr();
275 const CacheAddr cache_ptr = ToCacheAddr(system.GPU().MemoryManager().GetPointer(gpu_addr)); 285 const CacheAddr cache_ptr = ToCacheAddr(system.GPU().MemoryManager().GetPointer(gpu_addr));
@@ -294,6 +304,9 @@ protected:
294 if (guard_render_targets && surface->IsProtected()) { 304 if (guard_render_targets && surface->IsProtected()) {
295 return; 305 return;
296 } 306 }
307 if (!guard_render_targets && surface->IsRenderTarget()) {
308 ManageRenderTargetUnregister(surface);
309 }
297 const GPUVAddr gpu_addr = surface->GetGpuAddr(); 310 const GPUVAddr gpu_addr = surface->GetGpuAddr();
298 const CacheAddr cache_ptr = surface->GetCacheAddr(); 311 const CacheAddr cache_ptr = surface->GetCacheAddr();
299 const std::size_t size = surface->GetSizeInBytes(); 312 const std::size_t size = surface->GetSizeInBytes();