mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-21 03:16:54 +02:00
centralize swizzles
This commit is contained in:
@@ -86,41 +86,67 @@ namespace Libs::Graphics {
|
||||
return view_format == BgraSrgbStorageViewFormat(image_format) && swizzle == DstSel(6, 5, 4, 7);
|
||||
}
|
||||
|
||||
[[nodiscard]] inline int SelectSampledColorView(VkFormat image_format, VkFormat view_format,
|
||||
uint32_t swizzle) noexcept {
|
||||
[[nodiscard]] inline bool IsValidSampledColorSwizzle(uint32_t swizzle) noexcept {
|
||||
if ((swizzle & ~0xfffu) != 0) {
|
||||
return false;
|
||||
}
|
||||
for (uint32_t channel = 0; channel < 4; channel++) {
|
||||
switch (GetDstSel(swizzle, channel)) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
case 7: break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
[[nodiscard]] inline bool IsSupportedSampledColorView(VkFormat image_format,
|
||||
VkFormat view_format,
|
||||
uint32_t swizzle) noexcept {
|
||||
if (!IsValidSampledColorSwizzle(swizzle)) {
|
||||
return false;
|
||||
}
|
||||
if (image_format == view_format || IsRgba8SrgbReinterpretation(image_format, view_format)) {
|
||||
return true;
|
||||
}
|
||||
if ((IsRgba16UintFloatReinterpretation(image_format, view_format) ||
|
||||
IsRgba8UnormUintReinterpretation(image_format, view_format)) &&
|
||||
swizzle == DstSel(4, 5, 6, 7)) {
|
||||
return VulkanImage::VIEW_DEFAULT;
|
||||
return true;
|
||||
}
|
||||
if (image_format == view_format) {
|
||||
switch (swizzle) {
|
||||
case DstSel(4, 5, 6, 7): return VulkanImage::VIEW_DEFAULT;
|
||||
case DstSel(4, 0, 0, 1): return VulkanImage::VIEW_R001;
|
||||
case DstSel(4, 5, 0, 1): return VulkanImage::VIEW_RG01;
|
||||
case DstSel(4, 5, 6, 1): return VulkanImage::VIEW_RGB1;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
if (image_format == VK_FORMAT_R16G16B16A16_SFLOAT && view_format == image_format &&
|
||||
swizzle == DstSel(7, 6, 5, 4)) {
|
||||
return VulkanImage::VIEW_ABGR;
|
||||
}
|
||||
if (IsBgraToRgbaSampledView(image_format, view_format) && swizzle == DstSel(6, 5, 4, 7)) {
|
||||
return VulkanImage::VIEW_BGRA_TO_RGBA;
|
||||
return IsBgraToRgbaSampledView(image_format, view_format) &&
|
||||
swizzle == DstSel(6, 5, 4, 7);
|
||||
}
|
||||
|
||||
[[nodiscard]] inline uint32_t SelectSampledColorView(VkFormat image_format, VkFormat view_format,
|
||||
uint32_t swizzle) noexcept {
|
||||
if (IsSupportedSampledColorView(image_format, view_format, swizzle)) {
|
||||
return swizzle;
|
||||
}
|
||||
UnsupportedColorView("sampled", image_format, view_format, swizzle);
|
||||
}
|
||||
|
||||
[[nodiscard]] inline int SelectSampledDepthView(VkFormat image_format, VkFormat view_format,
|
||||
uint32_t swizzle) noexcept {
|
||||
if (IsSupportedSampledDepthFormat(image_format, view_format)) {
|
||||
switch (swizzle) {
|
||||
case DstSel(4, 4, 4, 4): return VulkanImage::VIEW_DEPTH_TEXTURE;
|
||||
case DstSel(4, 0, 0, 0): return VulkanImage::VIEW_R000;
|
||||
case DstSel(4, 0, 0, 1): return VulkanImage::VIEW_R001;
|
||||
default: break;
|
||||
}
|
||||
[[nodiscard]] inline bool IsSupportedSampledDepthView(VkFormat image_format, VkFormat view_format,
|
||||
uint32_t swizzle) noexcept {
|
||||
if (!IsSupportedSampledDepthFormat(image_format, view_format)) {
|
||||
return false;
|
||||
}
|
||||
switch (swizzle) {
|
||||
case DstSel(4, 4, 4, 4):
|
||||
case DstSel(4, 0, 0, 0):
|
||||
case DstSel(4, 0, 0, 1): return true;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
|
||||
[[nodiscard]] inline uint32_t SelectSampledDepthView(VkFormat image_format, VkFormat view_format,
|
||||
uint32_t swizzle) noexcept {
|
||||
if (IsSupportedSampledDepthView(image_format, view_format, swizzle)) {
|
||||
return swizzle;
|
||||
}
|
||||
EXIT("unsupported sampled depth image view: image_format=%d view_format=%d swizzle=0x%03x\n",
|
||||
static_cast<int>(image_format), static_cast<int>(view_format), swizzle);
|
||||
@@ -134,8 +160,8 @@ IsSupportedSampledDepthResource(const ShaderRecompiler::IR::ImageResource& resou
|
||||
!resource.written && !resource.atomic;
|
||||
}
|
||||
|
||||
[[nodiscard]] inline bool IsSupportedSampledDepthUintResource(
|
||||
const ShaderRecompiler::IR::ImageResource& resource) noexcept {
|
||||
[[nodiscard]] inline bool
|
||||
IsSupportedSampledDepthUintResource(const ShaderRecompiler::IR::ImageResource& resource) noexcept {
|
||||
return resource.kind == ShaderRecompiler::IR::ResourceKind::ImageUint &&
|
||||
resource.dimension == ShaderRecompiler::Decoder::ImageDimension::Dim2D &&
|
||||
resource.mip_mode == ShaderRecompiler::IR::ImageMipMode::None && resource.read &&
|
||||
|
||||
Reference in New Issue
Block a user