mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-12 12:45:56 +00:00
Avoid clearing depth on partial HTILE writes (#3167)
Some checks are pending
Build and Release / reuse (push) Waiting to run
Build and Release / clang-format (push) Waiting to run
Build and Release / get-info (push) Waiting to run
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / windows-qt (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / macos-qt (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-qt (push) Blocked by required conditions
Build and Release / linux-sdl-gcc (push) Blocked by required conditions
Build and Release / linux-qt-gcc (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions
Some checks are pending
Build and Release / reuse (push) Waiting to run
Build and Release / clang-format (push) Waiting to run
Build and Release / get-info (push) Waiting to run
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / windows-qt (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / macos-qt (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-qt (push) Blocked by required conditions
Build and Release / linux-sdl-gcc (push) Blocked by required conditions
Build and Release / linux-qt-gcc (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions
* 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:
parent
83056712e0
commit
59dd73492b
5 changed files with 28 additions and 30 deletions
|
@ -58,6 +58,7 @@ struct BufferResource {
|
||||||
BufferType buffer_type;
|
BufferType buffer_type;
|
||||||
u8 instance_attrib{};
|
u8 instance_attrib{};
|
||||||
bool is_written{};
|
bool is_written{};
|
||||||
|
bool is_read{};
|
||||||
bool is_formatted{};
|
bool is_formatted{};
|
||||||
|
|
||||||
bool IsSpecial() const noexcept {
|
bool IsSpecial() const noexcept {
|
||||||
|
|
|
@ -197,6 +197,7 @@ public:
|
||||||
auto& buffer = buffer_resources[index];
|
auto& buffer = buffer_resources[index];
|
||||||
buffer.used_types |= desc.used_types;
|
buffer.used_types |= desc.used_types;
|
||||||
buffer.is_written |= desc.is_written;
|
buffer.is_written |= desc.is_written;
|
||||||
|
buffer.is_read |= desc.is_read;
|
||||||
buffer.is_formatted |= desc.is_formatted;
|
buffer.is_formatted |= desc.is_formatted;
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
@ -367,6 +368,7 @@ s32 TryHandleInlineCbuf(IR::Inst& inst, Info& info, Descriptors& descriptors,
|
||||||
.used_types = BufferDataType(inst, cbuf.GetNumberFmt()),
|
.used_types = BufferDataType(inst, cbuf.GetNumberFmt()),
|
||||||
.inline_cbuf = cbuf,
|
.inline_cbuf = cbuf,
|
||||||
.buffer_type = BufferType::Guest,
|
.buffer_type = BufferType::Guest,
|
||||||
|
.is_read = true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -378,11 +380,13 @@ void PatchBufferSharp(IR::Block& block, IR::Inst& inst, Info& info, Descriptors&
|
||||||
IR::Inst* producer = handle->Arg(0).InstRecursive();
|
IR::Inst* producer = handle->Arg(0).InstRecursive();
|
||||||
SharpLocation sharp;
|
SharpLocation sharp;
|
||||||
std::tie(sharp, buffer) = TrackSharp<AmdGpu::Buffer>(producer, info);
|
std::tie(sharp, buffer) = TrackSharp<AmdGpu::Buffer>(producer, info);
|
||||||
|
const bool is_written = IsBufferStore(inst);
|
||||||
binding = descriptors.Add(BufferResource{
|
binding = descriptors.Add(BufferResource{
|
||||||
.sharp_idx = sharp,
|
.sharp_idx = sharp,
|
||||||
.used_types = BufferDataType(inst, buffer.GetNumberFmt()),
|
.used_types = BufferDataType(inst, buffer.GetNumberFmt()),
|
||||||
.buffer_type = BufferType::Guest,
|
.buffer_type = BufferType::Guest,
|
||||||
.is_written = IsBufferStore(inst),
|
.is_written = is_written,
|
||||||
|
.is_read = !is_written,
|
||||||
.is_formatted = inst.GetOpcode() == IR::Opcode::LoadBufferFormatF32 ||
|
.is_formatted = inst.GetOpcode() == IR::Opcode::LoadBufferFormatF32 ||
|
||||||
inst.GetOpcode() == IR::Opcode::StoreBufferFormatF32,
|
inst.GetOpcode() == IR::Opcode::StoreBufferFormatF32,
|
||||||
});
|
});
|
||||||
|
@ -409,11 +413,12 @@ void PatchImageSharp(IR::Block& block, IR::Inst& inst, Info& info, Descriptors&
|
||||||
// Read image sharp.
|
// Read image sharp.
|
||||||
const auto tsharp = TrackSharp(tsharp_handle, info);
|
const auto tsharp = TrackSharp(tsharp_handle, info);
|
||||||
const auto inst_info = inst.Flags<IR::TextureInstInfo>();
|
const auto inst_info = inst.Flags<IR::TextureInstInfo>();
|
||||||
const bool is_written = inst.GetOpcode() == IR::Opcode::ImageWrite;
|
const bool is_atomic = IsImageAtomicInstruction(inst);
|
||||||
|
const bool is_written = inst.GetOpcode() == IR::Opcode::ImageWrite || is_atomic;
|
||||||
const ImageResource image_res = {
|
const ImageResource image_res = {
|
||||||
.sharp_idx = tsharp,
|
.sharp_idx = tsharp,
|
||||||
.is_depth = bool(inst_info.is_depth),
|
.is_depth = bool(inst_info.is_depth),
|
||||||
.is_atomic = IsImageAtomicInstruction(inst),
|
.is_atomic = is_atomic,
|
||||||
.is_array = bool(inst_info.is_array),
|
.is_array = bool(inst_info.is_array),
|
||||||
.is_written = is_written,
|
.is_written = is_written,
|
||||||
.is_r128 = bool(inst_info.is_r128),
|
.is_r128 = bool(inst_info.is_r128),
|
||||||
|
|
|
@ -511,7 +511,8 @@ bool Rasterizer::IsComputeMetaClear(const Pipeline* pipeline) {
|
||||||
// will need its full emulation anyways.
|
// will need its full emulation anyways.
|
||||||
for (const auto& desc : info.buffers) {
|
for (const auto& desc : info.buffers) {
|
||||||
const VAddr address = desc.GetSharp(info).base_address;
|
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
|
// Assume all slices were updates
|
||||||
LOG_TRACE(Render_Vulkan, "Metadata update skipped");
|
LOG_TRACE(Render_Vulkan, "Metadata update skipped");
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -30,7 +30,6 @@ enum ImageFlagBits : u32 {
|
||||||
GpuModified = 1 << 3, ///< Contents have been modified from the GPU
|
GpuModified = 1 << 3, ///< Contents have been modified from the GPU
|
||||||
Registered = 1 << 6, ///< True when the image is registered
|
Registered = 1 << 6, ///< True when the image is registered
|
||||||
Picked = 1 << 7, ///< Temporary flag to mark the image as picked
|
Picked = 1 << 7, ///< Temporary flag to mark the image as picked
|
||||||
MetaRegistered = 1 << 8, ///< True when metadata for this surface is known and registered
|
|
||||||
};
|
};
|
||||||
DECLARE_ENUM_FLAG_OPERATORS(ImageFlagBits)
|
DECLARE_ENUM_FLAG_OPERATORS(ImageFlagBits)
|
||||||
|
|
||||||
|
|
|
@ -451,20 +451,16 @@ ImageView& TextureCache::FindRenderTarget(BaseDesc& desc) {
|
||||||
UpdateImage(image_id);
|
UpdateImage(image_id);
|
||||||
|
|
||||||
// Register meta data for this color buffer
|
// Register meta data for this color buffer
|
||||||
if (!(image.flags & ImageFlagBits::MetaRegistered)) {
|
|
||||||
if (desc.info.meta_info.cmask_addr) {
|
if (desc.info.meta_info.cmask_addr) {
|
||||||
surface_metas.emplace(desc.info.meta_info.cmask_addr,
|
surface_metas.emplace(desc.info.meta_info.cmask_addr,
|
||||||
MetaDataInfo{.type = MetaDataInfo::Type::CMask});
|
MetaDataInfo{.type = MetaDataInfo::Type::CMask});
|
||||||
image.info.meta_info.cmask_addr = desc.info.meta_info.cmask_addr;
|
image.info.meta_info.cmask_addr = desc.info.meta_info.cmask_addr;
|
||||||
image.flags |= ImageFlagBits::MetaRegistered;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (desc.info.meta_info.fmask_addr) {
|
if (desc.info.meta_info.fmask_addr) {
|
||||||
surface_metas.emplace(desc.info.meta_info.fmask_addr,
|
surface_metas.emplace(desc.info.meta_info.fmask_addr,
|
||||||
MetaDataInfo{.type = MetaDataInfo::Type::FMask});
|
MetaDataInfo{.type = MetaDataInfo::Type::FMask});
|
||||||
image.info.meta_info.fmask_addr = desc.info.meta_info.fmask_addr;
|
image.info.meta_info.fmask_addr = desc.info.meta_info.fmask_addr;
|
||||||
image.flags |= ImageFlagBits::MetaRegistered;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return RegisterImageView(image_id, desc.view_info);
|
return RegisterImageView(image_id, desc.view_info);
|
||||||
|
@ -479,15 +475,11 @@ ImageView& TextureCache::FindDepthTarget(BaseDesc& desc) {
|
||||||
UpdateImage(image_id);
|
UpdateImage(image_id);
|
||||||
|
|
||||||
// Register meta data for this depth buffer
|
// Register meta data for this depth buffer
|
||||||
if (!(image.flags & ImageFlagBits::MetaRegistered)) {
|
|
||||||
if (desc.info.meta_info.htile_addr) {
|
if (desc.info.meta_info.htile_addr) {
|
||||||
surface_metas.emplace(
|
surface_metas.emplace(desc.info.meta_info.htile_addr,
|
||||||
desc.info.meta_info.htile_addr,
|
|
||||||
MetaDataInfo{.type = MetaDataInfo::Type::HTile,
|
MetaDataInfo{.type = MetaDataInfo::Type::HTile,
|
||||||
.clear_mask = image.info.meta_info.htile_clear_mask});
|
.clear_mask = image.info.meta_info.htile_clear_mask});
|
||||||
image.info.meta_info.htile_addr = desc.info.meta_info.htile_addr;
|
image.info.meta_info.htile_addr = desc.info.meta_info.htile_addr;
|
||||||
image.flags |= ImageFlagBits::MetaRegistered;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there is a stencil attachment, link depth and stencil.
|
// If there is a stencil attachment, link depth and stencil.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue