From 7a3829bb87bb0e024b16df6ab9dba6326f7d38bf Mon Sep 17 00:00:00 2001 From: Tobias Frisch <tfrisch@uni-koblenz.de> Date: Mon, 29 Aug 2022 23:52:01 +0200 Subject: [PATCH] Added function to check format for stencil portion Signed-off-by: Tobias Frisch <tfrisch@uni-koblenz.de> --- include/vkcv/Image.hpp | 9 +++++++++ src/vkcv/Image.cpp | 26 ++++++++++++++++++++------ 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/include/vkcv/Image.hpp b/include/vkcv/Image.hpp index dc74a011..5e5e7645 100644 --- a/include/vkcv/Image.hpp +++ b/include/vkcv/Image.hpp @@ -23,6 +23,15 @@ namespace vkcv { * otherwise false. */ bool isDepthFormat(const vk::Format format); + + /** + * @brief Returns whether an image format is usable as stencil buffer. + * + * @param format Vulkan image format + * @return True, if the format is valid to use as stencil buffer, + * otherwise false. + */ + bool isStencilFormat(const vk::Format format); /** * @brief Class for image handling and filling data. diff --git a/src/vkcv/Image.cpp b/src/vkcv/Image.cpp index 84a706f8..8b406045 100644 --- a/src/vkcv/Image.cpp +++ b/src/vkcv/Image.cpp @@ -12,12 +12,26 @@ namespace vkcv{ bool isDepthFormat(const vk::Format format) { switch (format) { - case(vk::Format::eD16Unorm): return true; - case(vk::Format::eD16UnormS8Uint): return true; - case(vk::Format::eD24UnormS8Uint): return true; - case(vk::Format::eD32Sfloat): return true; - case(vk::Format::eD32SfloatS8Uint): return true; - default: return false; + case(vk::Format::eD16Unorm): + case(vk::Format::eD16UnormS8Uint): + case(vk::Format::eD24UnormS8Uint): + case(vk::Format::eD32Sfloat): + case(vk::Format::eD32SfloatS8Uint): + return true; + default: + return false; + } + } + + bool isStencilFormat(const vk::Format format) { + switch (format) { + case(vk::Format::eS8Uint): + case(vk::Format::eD16UnormS8Uint): + case(vk::Format::eD24UnormS8Uint): + case(vk::Format::eD32SfloatS8Uint): + return true; + default: + return false; } } -- GitLab