mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-12-10 05:38:49 +00:00
Avoid clearing depth on partial HTILE writes (#3167)
* vk_rasterizer: Avoid full depth clear in case of partial HTILE update * resource_tracking: Mark image as written when its used with atomics
This commit is contained in:
@@ -511,7 +511,8 @@ bool Rasterizer::IsComputeMetaClear(const Pipeline* pipeline) {
|
||||
// will need its full emulation anyways.
|
||||
for (const auto& desc : info.buffers) {
|
||||
const VAddr address = desc.GetSharp(info).base_address;
|
||||
if (!desc.IsSpecial() && desc.is_written && texture_cache.ClearMeta(address)) {
|
||||
if (!desc.IsSpecial() && desc.is_written && !desc.is_read &&
|
||||
texture_cache.ClearMeta(address)) {
|
||||
// Assume all slices were updates
|
||||
LOG_TRACE(Render_Vulkan, "Metadata update skipped");
|
||||
return true;
|
||||
|
||||
@@ -27,10 +27,9 @@ enum ImageFlagBits : u32 {
|
||||
CpuDirty = 1 << 1, ///< Contents have been modified from the CPU
|
||||
GpuDirty = 1 << 2, ///< Contents have been modified from the GPU (valid data in buffer cache)
|
||||
Dirty = MaybeCpuDirty | CpuDirty | GpuDirty,
|
||||
GpuModified = 1 << 3, ///< Contents have been modified from the GPU
|
||||
Registered = 1 << 6, ///< True when the image is registered
|
||||
Picked = 1 << 7, ///< Temporary flag to mark the image as picked
|
||||
MetaRegistered = 1 << 8, ///< True when metadata for this surface is known and registered
|
||||
GpuModified = 1 << 3, ///< Contents have been modified from the GPU
|
||||
Registered = 1 << 6, ///< True when the image is registered
|
||||
Picked = 1 << 7, ///< Temporary flag to mark the image as picked
|
||||
};
|
||||
DECLARE_ENUM_FLAG_OPERATORS(ImageFlagBits)
|
||||
|
||||
|
||||
@@ -451,20 +451,16 @@ ImageView& TextureCache::FindRenderTarget(BaseDesc& desc) {
|
||||
UpdateImage(image_id);
|
||||
|
||||
// Register meta data for this color buffer
|
||||
if (!(image.flags & ImageFlagBits::MetaRegistered)) {
|
||||
if (desc.info.meta_info.cmask_addr) {
|
||||
surface_metas.emplace(desc.info.meta_info.cmask_addr,
|
||||
MetaDataInfo{.type = MetaDataInfo::Type::CMask});
|
||||
image.info.meta_info.cmask_addr = desc.info.meta_info.cmask_addr;
|
||||
image.flags |= ImageFlagBits::MetaRegistered;
|
||||
}
|
||||
if (desc.info.meta_info.cmask_addr) {
|
||||
surface_metas.emplace(desc.info.meta_info.cmask_addr,
|
||||
MetaDataInfo{.type = MetaDataInfo::Type::CMask});
|
||||
image.info.meta_info.cmask_addr = desc.info.meta_info.cmask_addr;
|
||||
}
|
||||
|
||||
if (desc.info.meta_info.fmask_addr) {
|
||||
surface_metas.emplace(desc.info.meta_info.fmask_addr,
|
||||
MetaDataInfo{.type = MetaDataInfo::Type::FMask});
|
||||
image.info.meta_info.fmask_addr = desc.info.meta_info.fmask_addr;
|
||||
image.flags |= ImageFlagBits::MetaRegistered;
|
||||
}
|
||||
if (desc.info.meta_info.fmask_addr) {
|
||||
surface_metas.emplace(desc.info.meta_info.fmask_addr,
|
||||
MetaDataInfo{.type = MetaDataInfo::Type::FMask});
|
||||
image.info.meta_info.fmask_addr = desc.info.meta_info.fmask_addr;
|
||||
}
|
||||
|
||||
return RegisterImageView(image_id, desc.view_info);
|
||||
@@ -479,15 +475,11 @@ ImageView& TextureCache::FindDepthTarget(BaseDesc& desc) {
|
||||
UpdateImage(image_id);
|
||||
|
||||
// Register meta data for this depth buffer
|
||||
if (!(image.flags & ImageFlagBits::MetaRegistered)) {
|
||||
if (desc.info.meta_info.htile_addr) {
|
||||
surface_metas.emplace(
|
||||
desc.info.meta_info.htile_addr,
|
||||
MetaDataInfo{.type = MetaDataInfo::Type::HTile,
|
||||
.clear_mask = image.info.meta_info.htile_clear_mask});
|
||||
image.info.meta_info.htile_addr = desc.info.meta_info.htile_addr;
|
||||
image.flags |= ImageFlagBits::MetaRegistered;
|
||||
}
|
||||
if (desc.info.meta_info.htile_addr) {
|
||||
surface_metas.emplace(desc.info.meta_info.htile_addr,
|
||||
MetaDataInfo{.type = MetaDataInfo::Type::HTile,
|
||||
.clear_mask = image.info.meta_info.htile_clear_mask});
|
||||
image.info.meta_info.htile_addr = desc.info.meta_info.htile_addr;
|
||||
}
|
||||
|
||||
// If there is a stencil attachment, link depth and stencil.
|
||||
|
||||
Reference in New Issue
Block a user