From 5c6bdff44b0f172556d22240f267e36a70ce105c Mon Sep 17 00:00:00 2001 From: Sergey Kosarevsky Date: Tue, 7 Nov 2023 22:23:40 -0800 Subject: [PATCH] igl | Add helper methods to TextureFormatProperties Summary: Added helper methods to `TextureFormatProperties`: ``` bool isInteger() const noexcept; bool hasColor() const noexcept; bool hasDepth() const noexcept; bool hasStencil() const noexcept; ``` Reviewed By: KyleFung Differential Revision: D51093229 fbshipit-source-id: ec97aac516357943f84789c21d1506434ffc7746 --- src/igl/Texture.h | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/igl/Texture.h b/src/igl/Texture.h index 37ad6a0c76..47e45fa98d 100644 --- a/src/igl/Texture.h +++ b/src/igl/Texture.h @@ -257,29 +257,46 @@ struct TextureFormatProperties { [[nodiscard]] bool isCompressed() const noexcept { return (flags & Flags::Compressed) != 0; } + /** + * @brief true for integer texture formats. + */ + [[nodiscard]] bool isInteger() const noexcept { + return (flags & Flags::Integer) != 0; + } /** * @brief true for sRGB texture formats. */ [[nodiscard]] bool isSRGB() const noexcept { return (flags & Flags::sRGB) != 0; } + + [[nodiscard]] bool hasDepth() const noexcept { + return (flags & Flags::Depth) != 0; + } + [[nodiscard]] bool hasStencil() const noexcept { + return (flags & Flags::Stencil) != 0; + } + [[nodiscard]] bool hasColor() const noexcept { + return !hasDepth() && !hasStencil(); + } + /** * @brief true for depth-only texture formats (e.g., TextureFormat::Z_UNorm24). */ [[nodiscard]] bool isDepthOnly() const noexcept { - return (flags & Flags::Depth) != 0 && (flags & Flags::Stencil) == 0; + return hasDepth() && !hasStencil(); } /** * @brief true for depth-only and depth-stencil texture formats. */ [[nodiscard]] bool isDepthOrDepthStencil() const noexcept { - return (flags & Flags::Depth) != 0; + return hasDepth(); } /** * @brief true for stencil-only texture formats (e.g., TextureFormat::S_UInt8). */ [[nodiscard]] bool isStencilOnly() const noexcept { - return (flags & Flags::Depth) == 0 && (flags & Flags::Stencil) != 0; + return !hasDepth() && hasStencil(); } /** * @brief true for depth-only, stencil-only and depth-stencil texture formats.