mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-02 22:28:45 +00:00
shader_recompiler: support for partially bound cubemaps
This commit is contained in:
parent
0bf3678b6d
commit
223a7e4eef
4 changed files with 20 additions and 4 deletions
|
@ -482,10 +482,11 @@ void PatchImageInstruction(IR::Block& block, IR::Inst& inst, Info& info, Descrip
|
||||||
}
|
}
|
||||||
ASSERT(image.GetType() != AmdGpu::ImageType::Invalid);
|
ASSERT(image.GetType() != AmdGpu::ImageType::Invalid);
|
||||||
const bool is_storage = IsImageStorageInstruction(inst);
|
const bool is_storage = IsImageStorageInstruction(inst);
|
||||||
|
const auto type = image.IsPartialCubemap() ? AmdGpu::ImageType::Color2DArray : image.GetType();
|
||||||
u32 image_binding = descriptors.Add(ImageResource{
|
u32 image_binding = descriptors.Add(ImageResource{
|
||||||
.sgpr_base = tsharp.sgpr_base,
|
.sgpr_base = tsharp.sgpr_base,
|
||||||
.dword_offset = tsharp.dword_offset,
|
.dword_offset = tsharp.dword_offset,
|
||||||
.type = image.GetType(),
|
.type = type,
|
||||||
.nfmt = static_cast<AmdGpu::NumberFormat>(image.GetNumberFmt()),
|
.nfmt = static_cast<AmdGpu::NumberFormat>(image.GetNumberFmt()),
|
||||||
.is_storage = is_storage,
|
.is_storage = is_storage,
|
||||||
.is_depth = bool(inst_info.is_depth),
|
.is_depth = bool(inst_info.is_depth),
|
||||||
|
|
|
@ -62,7 +62,8 @@ struct StageSpecialization {
|
||||||
});
|
});
|
||||||
ForEachSharp(binding, images, info->images,
|
ForEachSharp(binding, images, info->images,
|
||||||
[](auto& spec, const auto& desc, AmdGpu::Image sharp) {
|
[](auto& spec, const auto& desc, AmdGpu::Image sharp) {
|
||||||
spec.type = sharp.GetType();
|
spec.type = sharp.IsPartialCubemap() ? AmdGpu::ImageType::Color2DArray
|
||||||
|
: sharp.GetType();
|
||||||
spec.is_integer = AmdGpu::IsInteger(sharp.GetNumberFmt());
|
spec.is_integer = AmdGpu::IsInteger(sharp.GetNumberFmt());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -241,7 +241,7 @@ struct Image {
|
||||||
u32 NumLayers() const {
|
u32 NumLayers() const {
|
||||||
u32 slices = GetType() == ImageType::Color3D ? 1 : depth + 1;
|
u32 slices = GetType() == ImageType::Color3D ? 1 : depth + 1;
|
||||||
if (GetType() == ImageType::Cube) {
|
if (GetType() == ImageType::Cube) {
|
||||||
slices *= 6;
|
slices = std::max(last_array + 1, 6);
|
||||||
}
|
}
|
||||||
if (pow2pad) {
|
if (pow2pad) {
|
||||||
slices = std::bit_ceil(slices);
|
slices = std::bit_ceil(slices);
|
||||||
|
@ -282,6 +282,11 @@ struct Image {
|
||||||
bool IsTiled() const {
|
bool IsTiled() const {
|
||||||
return GetTilingMode() != TilingMode::Display_Linear;
|
return GetTilingMode() != TilingMode::Display_Linear;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsPartialCubemap() const {
|
||||||
|
const auto viewed_slice = last_array - base_array + 1;
|
||||||
|
return GetType() == ImageType::Cube && viewed_slice < 6;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
static_assert(sizeof(Image) == 32); // 256bits
|
static_assert(sizeof(Image) == 32); // 256bits
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,6 @@ vk::Format TrySwizzleFormat(vk::Format format, u32 dst_sel) {
|
||||||
|
|
||||||
ImageViewInfo::ImageViewInfo(const AmdGpu::Image& image, bool is_storage_) noexcept
|
ImageViewInfo::ImageViewInfo(const AmdGpu::Image& image, bool is_storage_) noexcept
|
||||||
: is_storage{is_storage_} {
|
: is_storage{is_storage_} {
|
||||||
type = ConvertImageViewType(image.GetType());
|
|
||||||
const auto dfmt = image.GetDataFmt();
|
const auto dfmt = image.GetDataFmt();
|
||||||
auto nfmt = image.GetNumberFmt();
|
auto nfmt = image.GetNumberFmt();
|
||||||
if (is_storage && nfmt == AmdGpu::NumberFormat::Srgb) {
|
if (is_storage && nfmt == AmdGpu::NumberFormat::Srgb) {
|
||||||
|
@ -79,10 +78,20 @@ ImageViewInfo::ImageViewInfo(const AmdGpu::Image& image, bool is_storage_) noexc
|
||||||
range.base.layer = image.base_array;
|
range.base.layer = image.base_array;
|
||||||
range.extent.levels = image.last_level + 1;
|
range.extent.levels = image.last_level + 1;
|
||||||
range.extent.layers = image.last_array + 1;
|
range.extent.layers = image.last_array + 1;
|
||||||
|
type = ConvertImageViewType(image.GetType());
|
||||||
|
|
||||||
|
// Adjust view type for partial cubemaps and arrays
|
||||||
|
if (image.IsPartialCubemap()) {
|
||||||
|
type = vk::ImageViewType::e2DArray;
|
||||||
|
}
|
||||||
|
if (type == vk::ImageViewType::eCube && range.extent.layers > 6) {
|
||||||
|
type = vk::ImageViewType::eCubeArray;
|
||||||
|
}
|
||||||
if (type == vk::ImageViewType::e3D && range.extent.layers > 1) {
|
if (type == vk::ImageViewType::e3D && range.extent.layers > 1) {
|
||||||
// Some games pass incorrect layer count for 3D textures so we need to fixup it
|
// Some games pass incorrect layer count for 3D textures so we need to fixup it
|
||||||
range.extent.layers = 1;
|
range.extent.layers = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_storage) {
|
if (!is_storage) {
|
||||||
mapping.r = ConvertComponentSwizzle(image.dst_sel_x);
|
mapping.r = ConvertComponentSwizzle(image.dst_sel_x);
|
||||||
mapping.g = ConvertComponentSwizzle(image.dst_sel_y);
|
mapping.g = ConvertComponentSwizzle(image.dst_sel_y);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue