Skip to content

Commit

Permalink
Fix GLES2 unit tests failures on Android device
Browse files Browse the repository at this point in the history
Summary: Came across these failures while testing D49475245 on a device.

Differential Revision: D49622629

fbshipit-source-id: 2efdf233d6aed3406bc976b052e577a443eeb2aa
  • Loading branch information
Thiago Goulart authored and facebook-github-bot committed Sep 26, 2023
1 parent 6948072 commit 15e4fb4
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions src/igl/tests/Texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,8 @@ TEST(TextureRangeDesc, WithNumFaces) {
TEST(TextureRangeDesc, Validate) {
constexpr size_t kMax = std::numeric_limits<uint32_t>::max();
constexpr size_t kMaxPlus1 = std::numeric_limits<uint32_t>::max() + 1;
// Overflow validation logic doesn't work on 32bit architectures
constexpr bool kRunOverflowTests = (sizeof(size_t) > sizeof(uint32_t));

// 2D
EXPECT_TRUE(TextureRangeDesc::new2D(0, 0, 1024, 1024).validate().isOk());
Expand All @@ -484,34 +486,40 @@ TEST(TextureRangeDesc, Validate) {
EXPECT_TRUE(TextureRangeDesc::new2D(0, 0, kMax, 1).validate().isOk());
EXPECT_TRUE(TextureRangeDesc::new2D(0, 0, 1024, 1024, kMax, 1).validate().isOk());

EXPECT_FALSE(TextureRangeDesc::new2D(0, 0, kMax, 1024).validate().isOk());
EXPECT_FALSE(TextureRangeDesc::new2D(0, 0, 1024, kMax).validate().isOk());
if (kRunOverflowTests) {
EXPECT_FALSE(TextureRangeDesc::new2D(0, 0, kMax, 1024).validate().isOk());
EXPECT_FALSE(TextureRangeDesc::new2D(0, 0, 1024, kMax).validate().isOk());

EXPECT_FALSE(TextureRangeDesc::new2D(1, 1, 1, kMax).validate().isOk());
EXPECT_FALSE(TextureRangeDesc::new2D(1, 1, kMax, 1).validate().isOk());
EXPECT_FALSE(TextureRangeDesc::new2D(1, 1, 1, kMax).validate().isOk());
EXPECT_FALSE(TextureRangeDesc::new2D(1, 1, kMax, 1).validate().isOk());

EXPECT_FALSE(TextureRangeDesc::new2D(0, 0, 1, kMaxPlus1).validate().isOk());
EXPECT_FALSE(TextureRangeDesc::new2D(0, 0, kMaxPlus1, 1).validate().isOk());
EXPECT_FALSE(TextureRangeDesc::new2D(0, 0, 1, kMaxPlus1).validate().isOk());
EXPECT_FALSE(TextureRangeDesc::new2D(0, 0, kMaxPlus1, 1).validate().isOk());
}

EXPECT_FALSE(TextureRangeDesc::new2D(0, 0, 1024, 1024, 0, 12).validate().isOk());

// 2D Array
EXPECT_TRUE(TextureRangeDesc::new2DArray(0, 0, 1024, 1024, 0, 1024).validate().isOk());
EXPECT_TRUE(TextureRangeDesc::new2DArray(0, 0, 1, 1, 0, kMax).validate().isOk());

EXPECT_FALSE(TextureRangeDesc::new2DArray(0, 0, 1024, 1024, 0, kMax).validate().isOk());
EXPECT_FALSE(TextureRangeDesc::new2DArray(0, 0, 1, 1, 1, kMax).validate().isOk());
if (kRunOverflowTests) {
EXPECT_FALSE(TextureRangeDesc::new2DArray(0, 0, 1024, 1024, 0, kMax).validate().isOk());
EXPECT_FALSE(TextureRangeDesc::new2DArray(0, 0, 1, 1, 1, kMax).validate().isOk());

EXPECT_FALSE(TextureRangeDesc::new2DArray(0, 0, 1, 1, 0, kMaxPlus1).validate().isOk());
EXPECT_FALSE(TextureRangeDesc::new2DArray(0, 0, 1, 1, 0, kMaxPlus1).validate().isOk());
}

// 3D
EXPECT_TRUE(TextureRangeDesc::new3D(0, 0, 0, 1024, 1024, 1024).validate().isOk());
EXPECT_TRUE(TextureRangeDesc::new3D(0, 0, 0, 1, 1, kMax).validate().isOk());

EXPECT_FALSE(TextureRangeDesc::new3D(0, 0, 0, 1024, 1024, kMax).validate().isOk());
EXPECT_FALSE(TextureRangeDesc::new3D(0, 0, 1, 1, 1, kMax).validate().isOk());
if (kRunOverflowTests) {
EXPECT_FALSE(TextureRangeDesc::new3D(0, 0, 0, 1024, 1024, kMax).validate().isOk());
EXPECT_FALSE(TextureRangeDesc::new3D(0, 0, 1, 1, 1, kMax).validate().isOk());

EXPECT_FALSE(TextureRangeDesc::new3D(0, 0, 0, 1, 1, kMaxPlus1).validate().isOk());
EXPECT_FALSE(TextureRangeDesc::new3D(0, 0, 0, 1, 1, kMaxPlus1).validate().isOk());
}

// Cube
EXPECT_TRUE(TextureRangeDesc::newCube(0, 0, 1024, 1024).validate().isOk());
Expand Down

0 comments on commit 15e4fb4

Please sign in to comment.