shader_recompiler: Fix handling unbound depth image.

This commit is contained in:
squidbus 2025-06-21 16:11:01 -07:00
parent 802124309d
commit 5d6abfe3f4
2 changed files with 15 additions and 14 deletions

View File

@ -308,17 +308,17 @@ 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();
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) {
image = AmdGpu::Image::NullDepth();
}
}
return image;
}

View File

@ -369,13 +369,14 @@ void PatchImageSharp(IR::Block& block, IR::Inst& inst, Info& info, Descriptors&
auto image = info.ReadUdSharp<AmdGpu::Image>(tsharp);
if (!image.Valid()) {
LOG_ERROR(Render_Vulkan, "Shader compiled with unbound image!");
image = AmdGpu::Image::Null();
}
const auto data_fmt = image.GetDataFmt();
if (inst_info.is_depth && data_fmt != AmdGpu::DataFormat::Format16 &&
data_fmt != AmdGpu::DataFormat::Format32) {
LOG_ERROR(Render_Vulkan, "Shader compiled using non-depth image with depth instruction!");
image = AmdGpu::Image::NullDepth();
image = inst_info.is_depth ? AmdGpu::Image::NullDepth() : AmdGpu::Image::Null();
} else if (inst_info.is_depth) {
const auto data_fmt = image.GetDataFmt();
if (data_fmt != AmdGpu::DataFormat::Format16 && data_fmt != AmdGpu::DataFormat::Format32) {
LOG_ERROR(Render_Vulkan,
"Shader compiled using non-depth image with depth instruction!");
image = AmdGpu::Image::NullDepth();
}
}
ASSERT(image.GetType() != AmdGpu::ImageType::Invalid);
const bool is_written = inst.GetOpcode() == IR::Opcode::ImageWrite;