diff options
| author | Stenzek <stenzek@users.noreply.github.com> | 2017-04-30 00:44:06 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-04-30 00:44:06 +1000 |
| commit | a2cba6d72f049e86460491c875353584e167d613 (patch) | |
| tree | 91f077a0bb9cd269f73937f843a4922f5812dcc9 /Source/Core/VideoBackends/Vulkan/Util.cpp | |
| parent | da880c2a987e6553bec34a7a23ca6aff46bbede7 (diff) | |
| parent | cc851c41c11bdc1c192003021df6dc3c2d2b74fb (diff) | |
Merge pull request #5279 from stenzek/compressed-custom-textures
Native compressed custom texture support
Diffstat (limited to 'Source/Core/VideoBackends/Vulkan/Util.cpp')
| -rw-r--r-- | Source/Core/VideoBackends/Vulkan/Util.cpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/Source/Core/VideoBackends/Vulkan/Util.cpp b/Source/Core/VideoBackends/Vulkan/Util.cpp index 5de96e23cb..7ce433a79e 100644 --- a/Source/Core/VideoBackends/Vulkan/Util.cpp +++ b/Source/Core/VideoBackends/Vulkan/Util.cpp @@ -53,6 +53,20 @@ bool IsDepthFormat(VkFormat format) } } +bool IsCompressedFormat(VkFormat format) +{ + switch (format) + { + case VK_FORMAT_BC1_RGBA_UNORM_BLOCK: + case VK_FORMAT_BC2_UNORM_BLOCK: + case VK_FORMAT_BC3_UNORM_BLOCK: + return true; + + default: + return false; + } +} + VkFormat GetLinearFormat(VkFormat format) { switch (format) @@ -74,6 +88,25 @@ VkFormat GetLinearFormat(VkFormat format) } } +VkFormat GetVkFormatForHostTextureFormat(HostTextureFormat format) +{ + switch (format) + { + case HostTextureFormat::DXT1: + return VK_FORMAT_BC1_RGBA_UNORM_BLOCK; + + case HostTextureFormat::DXT3: + return VK_FORMAT_BC2_UNORM_BLOCK; + + case HostTextureFormat::DXT5: + return VK_FORMAT_BC3_UNORM_BLOCK; + + case HostTextureFormat::RGBA8: + default: + return VK_FORMAT_R8G8B8A8_UNORM; + } +} + u32 GetTexelSize(VkFormat format) { // Only contains pixel formats we use. @@ -91,12 +124,33 @@ u32 GetTexelSize(VkFormat format) case VK_FORMAT_B8G8R8A8_UNORM: return 4; + case VK_FORMAT_BC1_RGBA_UNORM_BLOCK: + return 8; + + case VK_FORMAT_BC2_UNORM_BLOCK: + case VK_FORMAT_BC3_UNORM_BLOCK: + return 16; + default: PanicAlert("Unhandled pixel format"); return 1; } } +u32 GetBlockSize(VkFormat format) +{ + switch (format) + { + case VK_FORMAT_BC1_RGBA_UNORM_BLOCK: + case VK_FORMAT_BC2_UNORM_BLOCK: + case VK_FORMAT_BC3_UNORM_BLOCK: + return 4; + + default: + return 1; + } +} + VkRect2D ClampRect2D(const VkRect2D& rect, u32 width, u32 height) { VkRect2D out; |
