Browse Source

Made regression tests for sub-image texture criterias.

David Piuva 5 years ago
parent
commit
0044d54143
2 changed files with 12 additions and 10 deletions
  1. 7 9
      Source/DFPSR/api/imageAPI.h
  2. 5 1
      Source/test/tests/ImageTest.cpp

+ 7 - 9
Source/DFPSR/api/imageAPI.h

@@ -91,19 +91,17 @@ namespace dsr {
 	// Post-condition: Returns true iff image contains a mip-map pyramid generated by image_generatePyramid
 	// Returns false without a warning if the image handle is empty
 	bool image_hasPyramid(const ImageRgbaU8& image);
-	// Post-condition: Returns true iff image fulfills the criterias for being a texture
+	// Post-condition:
+	//   Returns true iff image fulfills the criterias for being a texture
+	//   Returns false without a warning if the image handle is empty
 	// Texture criterias:
-	//  * Each dimension of width and height should be a power-of-two
-	//    width = 2 ^ N
-	//    height = 2 ^ N
-	//  * Width and height should also be from 4 to 16384 pixels
+	//  * Each dimension of width and height should be a power-of-two from 4 to 16384
+	//    width = 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192 or 16384
+	//    height = 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192 or 16384
 	//    Large enough to allow padding-free SIMD vectorization of 128-bit vectors (4 x 32 = 128)
 	//    Small enough to allow expressing the total size in bytes using a signed 32-bit integer
-	//    4 <= width <= 16384
-	//    4 <= height <= 16384
-	//  * Each row must consume the whole stride
+	//  * If it's a sub-image, it must also consume the whole with of the original image so that width times pixel size equals the stride
 	//    Textures may not contain padding in the rows, but it's okay to use sub-images from a vertical atlas where the whole width is consumed
-	// Returns false without a warning if the image handle is empty
 	bool image_isTexture(const ImageRgbaU8& image);
 
 // Pixel access

+ 5 - 1
Source/test/tests/ImageTest.cpp

@@ -56,7 +56,7 @@ START_TEST(Image)
 		ASSERT_EQUAL(image_hasPyramid(image), true);
 	}
 	{ // Texture criterias
-		ImageRgbaU8 image;
+		ImageRgbaU8 image, subImage;
 		image = image_create_RgbaU8(2, 2);
 		ASSERT_EQUAL(image_isTexture(image), false); // Too small
 		image = image_create_RgbaU8(13, 8);
@@ -66,9 +66,13 @@ START_TEST(Image)
 		image = image_create_RgbaU8(4, 4);
 		ASSERT_EQUAL(image_isTexture(image), true); // Okay
 		image = image_create_RgbaU8(4, 16384);
+		subImage = image_getSubImage(image, IRect(0, 0, 4, 128));
 		ASSERT_EQUAL(image_isTexture(image), true); // Okay
+		ASSERT_EQUAL(image_isTexture(subImage), true); // Okay to use full-width vertical sub-images
 		image = image_create_RgbaU8(16384, 4);
+		subImage = image_getSubImage(image, IRect(0, 0, 128, 4));
 		ASSERT_EQUAL(image_isTexture(image), true); // Okay
+		ASSERT_EQUAL(image_isTexture(subImage), false); // Not okay to use partial width leading to partial stride
 		image = image_create_RgbaU8(16384 + 1, 4);
 		ASSERT_EQUAL(image_isTexture(image), false); // Too wide and not power-of-two width
 		image = image_create_RgbaU8(32768, 4);