Skip to content

Commit

Permalink
igl | Add helper methods to TextureFormatProperties
Browse files Browse the repository at this point in the history
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
  • Loading branch information
corporateshark authored and facebook-github-bot committed Nov 8, 2023
1 parent 4265f25 commit 5c6bdff
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions src/igl/Texture.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 5c6bdff

Please sign in to comment.