Skip to content

Commit

Permalink
Create tests for 3 texture format functions
Browse files Browse the repository at this point in the history
Summary: ^^

Reviewed By: corporateshark, mmaurer

Differential Revision: D62876033

fbshipit-source-id: d70548969521781d7260da375b73283fff69707c
  • Loading branch information
francoiscoulombe authored and facebook-github-bot committed Sep 19, 2024
1 parent df4d8c1 commit 0de174f
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/igl/tests/vulkan/TextureFormat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,34 @@
#include <igl/vulkan/util/TextureFormat.h>

namespace igl::vulkan::tests {
TEST(TextureFormatUtilTest, invertRedAndBlue) {
ASSERT_EQ(VK_FORMAT_B8G8R8A8_UNORM, util::invertRedAndBlue(VK_FORMAT_R8G8B8A8_UNORM));
ASSERT_EQ(VK_FORMAT_R8G8B8A8_UNORM, util::invertRedAndBlue(VK_FORMAT_B8G8R8A8_UNORM));
ASSERT_EQ(VK_FORMAT_R8G8B8A8_SRGB, util::invertRedAndBlue(VK_FORMAT_B8G8R8A8_SRGB));
ASSERT_EQ(VK_FORMAT_B8G8R8A8_SRGB, util::invertRedAndBlue(VK_FORMAT_R8G8B8A8_SRGB));
ASSERT_EQ(VK_FORMAT_A2R10G10B10_UNORM_PACK32,
util::invertRedAndBlue(VK_FORMAT_A2B10G10R10_UNORM_PACK32));
ASSERT_EQ(VK_FORMAT_A2B10G10R10_UNORM_PACK32,
util::invertRedAndBlue(VK_FORMAT_A2R10G10B10_UNORM_PACK32));
}

TEST(TextureFormatUtilTest, isTextureFormatRGB) {
ASSERT_TRUE(util::isTextureFormatRGB(VK_FORMAT_R8G8B8A8_UNORM));
ASSERT_TRUE(util::isTextureFormatRGB(VK_FORMAT_R8G8B8A8_SRGB));
ASSERT_TRUE(util::isTextureFormatRGB(VK_FORMAT_A2R10G10B10_UNORM_PACK32));
ASSERT_FALSE(util::isTextureFormatRGB(VK_FORMAT_B8G8R8A8_UNORM));
ASSERT_FALSE(util::isTextureFormatRGB(VK_FORMAT_B8G8R8A8_SRGB));
ASSERT_FALSE(util::isTextureFormatRGB(VK_FORMAT_A2B10G10R10_UNORM_PACK32));
}

TEST(TextureFormatUtilTest, isTextureFormatBGR) {
ASSERT_FALSE(util::isTextureFormatBGR(VK_FORMAT_R8G8B8A8_UNORM));
ASSERT_FALSE(util::isTextureFormatBGR(VK_FORMAT_R8G8B8A8_SRGB));
ASSERT_FALSE(util::isTextureFormatBGR(VK_FORMAT_A2R10G10B10_UNORM_PACK32));
ASSERT_TRUE(util::isTextureFormatBGR(VK_FORMAT_B8G8R8A8_UNORM));
ASSERT_TRUE(util::isTextureFormatBGR(VK_FORMAT_B8G8R8A8_SRGB));
ASSERT_TRUE(util::isTextureFormatBGR(VK_FORMAT_A2B10G10R10_UNORM_PACK32));
}

TEST(TextureFormatUtilTest, vkTextureFormatToTextureFormat) {
ASSERT_EQ(util::vkTextureFormatToTextureFormat(VK_FORMAT_UNDEFINED), igl::TextureFormat::Invalid);
Expand Down

0 comments on commit 0de174f

Please sign in to comment.