mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-07-04 23:31:19 +01:00
Texture_Cache: Force Framebuffer reset if an active render target is unregistered.
This commit is contained in:
parent
913b7a6872
commit
5818959e54
3 changed files with 36 additions and 10 deletions
|
@ -200,8 +200,9 @@ public:
|
|||
modification_tick = tick;
|
||||
}
|
||||
|
||||
void MarkAsRenderTarget(const bool is_target) {
|
||||
void MarkAsRenderTarget(const bool is_target, const u32 index) {
|
||||
this->is_target = is_target;
|
||||
this->index = index;
|
||||
}
|
||||
|
||||
void MarkAsPicked(const bool is_picked) {
|
||||
|
@ -221,6 +222,10 @@ public:
|
|||
return is_target;
|
||||
}
|
||||
|
||||
u32 GetRenderTarget() const {
|
||||
return index;
|
||||
}
|
||||
|
||||
bool IsRegistered() const {
|
||||
return is_registered;
|
||||
}
|
||||
|
@ -311,6 +316,7 @@ private:
|
|||
bool is_target{};
|
||||
bool is_registered{};
|
||||
bool is_picked{};
|
||||
u32 index{0xFFFFFFFF};
|
||||
u64 modification_tick{};
|
||||
};
|
||||
|
||||
|
|
|
@ -290,12 +290,19 @@ std::size_t SurfaceParams::GetLayerSize(bool as_host_size, bool uncompressed) co
|
|||
|
||||
std::size_t SurfaceParams::GetInnerMipmapMemorySize(u32 level, bool as_host_size,
|
||||
bool uncompressed) const {
|
||||
const bool tiled{as_host_size ? false : is_tiled};
|
||||
const u32 width{GetMipmapSize(uncompressed, GetMipWidth(level), GetDefaultBlockWidth())};
|
||||
const u32 height{GetMipmapSize(uncompressed, GetMipHeight(level), GetDefaultBlockHeight())};
|
||||
const u32 depth{is_layered ? 1U : GetMipDepth(level)};
|
||||
return Tegra::Texture::CalculateSize(tiled, GetBytesPerPixel(), width, height, depth,
|
||||
GetMipBlockHeight(level), GetMipBlockDepth(level));
|
||||
if (is_tiled) {
|
||||
return Tegra::Texture::CalculateSize(!as_host_size, GetBytesPerPixel(), width, height, depth,
|
||||
GetMipBlockHeight(level), GetMipBlockDepth(level));
|
||||
} else {
|
||||
if (as_host_size || IsBuffer()) {
|
||||
return GetBytesPerPixel()*width*height*depth;
|
||||
} else {
|
||||
return pitch*height*depth;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool SurfaceParams::operator==(const SurfaceParams& rhs) const {
|
||||
|
|
|
@ -133,11 +133,11 @@ public:
|
|||
regs.zeta.memory_layout.block_depth, regs.zeta.memory_layout.type)};
|
||||
auto surface_view = GetSurface(gpu_addr, depth_params, preserve_contents, true);
|
||||
if (depth_buffer.target)
|
||||
depth_buffer.target->MarkAsRenderTarget(false);
|
||||
depth_buffer.target->MarkAsRenderTarget(false, -1);
|
||||
depth_buffer.target = surface_view.first;
|
||||
depth_buffer.view = surface_view.second;
|
||||
if (depth_buffer.target)
|
||||
depth_buffer.target->MarkAsRenderTarget(true);
|
||||
depth_buffer.target->MarkAsRenderTarget(true, 8);
|
||||
return surface_view.second;
|
||||
}
|
||||
|
||||
|
@ -167,11 +167,11 @@ public:
|
|||
auto surface_view = GetSurface(gpu_addr, SurfaceParams::CreateForFramebuffer(system, index),
|
||||
preserve_contents, true);
|
||||
if (render_targets[index].target)
|
||||
render_targets[index].target->MarkAsRenderTarget(false);
|
||||
render_targets[index].target->MarkAsRenderTarget(false, -1);
|
||||
render_targets[index].target = surface_view.first;
|
||||
render_targets[index].view = surface_view.second;
|
||||
if (render_targets[index].target)
|
||||
render_targets[index].target->MarkAsRenderTarget(true);
|
||||
render_targets[index].target->MarkAsRenderTarget(true, static_cast<u32>(index));
|
||||
return surface_view.second;
|
||||
}
|
||||
|
||||
|
@ -191,7 +191,7 @@ public:
|
|||
if (depth_buffer.target == nullptr) {
|
||||
return;
|
||||
}
|
||||
depth_buffer.target->MarkAsRenderTarget(false);
|
||||
depth_buffer.target->MarkAsRenderTarget(false, -1);
|
||||
depth_buffer.target = nullptr;
|
||||
depth_buffer.view = nullptr;
|
||||
}
|
||||
|
@ -200,7 +200,7 @@ public:
|
|||
if (render_targets[index].target == nullptr) {
|
||||
return;
|
||||
}
|
||||
render_targets[index].target->MarkAsRenderTarget(false);
|
||||
render_targets[index].target->MarkAsRenderTarget(false, -1);
|
||||
render_targets[index].target = nullptr;
|
||||
render_targets[index].view = nullptr;
|
||||
}
|
||||
|
@ -270,6 +270,16 @@ protected:
|
|||
// and reading it from a sepparate buffer.
|
||||
virtual void BufferCopy(TSurface& src_surface, TSurface& dst_surface) = 0;
|
||||
|
||||
void ManageRenderTargetUnregister(TSurface& surface) {
|
||||
auto& maxwell3d = system.GPU().Maxwell3D();
|
||||
u32 index = surface->GetRenderTarget();
|
||||
if (index == 8) {
|
||||
maxwell3d.dirty_flags.zeta_buffer = true;
|
||||
} else {
|
||||
maxwell3d.dirty_flags.color_buffer.set(index, true);
|
||||
}
|
||||
}
|
||||
|
||||
void Register(TSurface surface) {
|
||||
const GPUVAddr gpu_addr = surface->GetGpuAddr();
|
||||
const CacheAddr cache_ptr = ToCacheAddr(system.GPU().MemoryManager().GetPointer(gpu_addr));
|
||||
|
@ -294,6 +304,9 @@ protected:
|
|||
if (guard_render_targets && surface->IsProtected()) {
|
||||
return;
|
||||
}
|
||||
if (!guard_render_targets && surface->IsRenderTarget()) {
|
||||
ManageRenderTargetUnregister(surface);
|
||||
}
|
||||
const GPUVAddr gpu_addr = surface->GetGpuAddr();
|
||||
const CacheAddr cache_ptr = surface->GetCacheAddr();
|
||||
const std::size_t size = surface->GetSizeInBytes();
|
||||
|
|
Loading…
Reference in a new issue