Skip to content

Commit

Permalink
IGL: Add an HDR flag to TextureFormatProperties
Browse files Browse the repository at this point in the history
Summary:
This diff adds an HDR flag to TextureFormatProperties. This flag is for color textures that use more that 8 bits per component.

The intent of this flag is to help situations where linear <-> sRGB conversions are being done manually. Specifically, it can help with detecting when a particular texture or framebuffer attachment might NOT require manual conversion.

Reviewed By: corporateshark, francoiscoulombe

Differential Revision: D61641678

fbshipit-source-id: c34c7e9e6e85f3351408b92572dd5cc9150211df
  • Loading branch information
Eric Griffith authored and facebook-github-bot committed Aug 26, 2024
1 parent 0343d7b commit 31352c0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/igl/Texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,9 @@ TextureFormatProperties TextureFormatProperties::fromTextureFormat(TextureFormat
COLOR(A_UNorm8, 1, 1, 0)
COLOR(L_UNorm8, 1, 1, 0)
COLOR(R_UNorm8, 1, 1, 0)
COLOR(R_F16, 1, 2, 0)
COLOR(R_UInt16, 1, 2, Flags::Integer)
COLOR(R_UNorm16, 1, 2, 0)
COLOR(R_F16, 1, 2, Flags::HDR)
COLOR(R_UInt16, 1, 2, Flags::Integer | Flags::HDR)
COLOR(R_UNorm16, 1, 2, Flags::HDR)
COLOR(B5G5R5A1_UNorm, 4, 2, 0)
COLOR(B5G6R5_UNorm, 3, 2, 0)
COLOR(ABGR_UNorm4, 4, 2, 0)
Expand All @@ -283,19 +283,19 @@ TextureFormatProperties TextureFormatProperties::fromTextureFormat(TextureFormat
COLOR(BGRA_UNorm8_Rev, 4, 4, 0)
COLOR(RGBA_SRGB, 4, 4, Flags::sRGB)
COLOR(BGRA_SRGB, 4, 4, Flags::sRGB)
COLOR(RG_F16, 2, 4, 0)
COLOR(RG_UInt16, 2, 4, Flags::Integer)
COLOR(RG_UNorm16, 2, 4, 0)
COLOR(RGB10_A2_UNorm_Rev, 4, 4, 0)
COLOR(RGB10_A2_Uint_Rev, 4, 4, Flags::Integer)
COLOR(BGR10_A2_Unorm, 4, 4, 0)
COLOR(R_F32, 1, 4, 0)
COLOR(RGB_F16, 3, 6, 0)
COLOR(RGBA_F16, 4, 8, 0)
COLOR(RG_F32, 2, 8, 0)
COLOR(RGB_F32, 3, 12, 0)
COLOR(RGBA_UInt32, 4, 16, Flags::Integer)
COLOR(RGBA_F32, 4, 16, 0)
COLOR(RG_F16, 2, 4, Flags::HDR)
COLOR(RG_UInt16, 2, 4, Flags::Integer | Flags::HDR)
COLOR(RG_UNorm16, 2, 4, Flags::HDR)
COLOR(RGB10_A2_UNorm_Rev, 4, 4, Flags::HDR)
COLOR(RGB10_A2_Uint_Rev, 4, 4, Flags::Integer | Flags::HDR)
COLOR(BGR10_A2_Unorm, 4, 4, Flags::HDR)
COLOR(R_F32, 1, 4, Flags::HDR)
COLOR(RGB_F16, 3, 6, Flags::HDR)
COLOR(RGBA_F16, 4, 8, Flags::HDR)
COLOR(RG_F32, 2, 8, Flags::HDR)
COLOR(RGB_F32, 3, 12, Flags::HDR)
COLOR(RGBA_UInt32, 4, 16, Flags::Integer | Flags::HDR)
COLOR(RGBA_F32, 4, 16, Flags::HDR)
COMPRESSED(RGBA_ASTC_4x4, 4, 16, 4, 4, 1, 1, 1, 1, 0)
COMPRESSED(SRGB8_A8_ASTC_4x4, 4, 16, 4, 4, 1, 1, 1, 1, Flags::sRGB)
COMPRESSED(RGBA_ASTC_5x4, 4, 16, 5, 4, 1, 1, 1, 1, 0)
Expand Down
7 changes: 7 additions & 0 deletions src/igl/Texture.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ struct TextureFormatProperties {
Compressed = 1 << 2,
sRGB = 1 << 3,
Integer = 1 << 4,
HDR = 1 << 5, // Color format with more than 8 bits per component
};

const char* IGL_NONNULL name = "Invalid";
Expand Down Expand Up @@ -278,6 +279,12 @@ struct TextureFormatProperties {
[[nodiscard]] bool isSRGB() const noexcept {
return (flags & Flags::sRGB) != 0;
}
/**
* @brief true for high precision color texture formats.
*/
[[nodiscard]] bool isHDR() const noexcept {
return (flags & Flags::HDR) != 0;
}

[[nodiscard]] bool hasDepth() const noexcept {
return (flags & Flags::Depth) != 0;
Expand Down

0 comments on commit 31352c0

Please sign in to comment.