shader_recompiler: Fix handling unbound depth image. (#3143)

* shader_recompiler: Fix handling unbound depth image.

* shader_recompiler: Consolidate unbound image handling.
This commit is contained in:
squidbus 2025-06-21 22:18:00 -07:00 committed by GitHub
parent d9dac05db2
commit 669b19c2f3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 20 additions and 27 deletions

View file

@ -308,17 +308,19 @@ constexpr AmdGpu::Image ImageResource::GetSharp(const Info& info) const noexcept
if (!is_r128) {
image = info.ReadUdSharp<AmdGpu::Image>(sharp_idx);
} else {
AmdGpu::Buffer buf = info.ReadUdSharp<AmdGpu::Buffer>(sharp_idx);
const auto buf = info.ReadUdSharp<AmdGpu::Buffer>(sharp_idx);
memcpy(&image, &buf, sizeof(buf));
}
if (!image.Valid()) {
// Fall back to null image if unbound.
return AmdGpu::Image::Null();
}
const auto data_fmt = image.GetDataFmt();
if (is_depth && data_fmt != AmdGpu::DataFormat::Format16 &&
data_fmt != AmdGpu::DataFormat::Format32) {
return AmdGpu::Image::NullDepth();
LOG_DEBUG(Render_Vulkan, "Encountered unbound image!");
image = is_depth ? AmdGpu::Image::NullDepth() : AmdGpu::Image::Null();
} else if (is_depth) {
const auto data_fmt = image.GetDataFmt();
if (data_fmt != AmdGpu::DataFormat::Format16 && data_fmt != AmdGpu::DataFormat::Format32) {
LOG_DEBUG(Render_Vulkan, "Encountered non-depth image used with depth instruction!");
image = AmdGpu::Image::NullDepth();
}
}
return image;
}