Ejemplo n.º 1
0
int test_alloc()
{
	int Error(0);

	std::vector<gli::format> Formats;
	Formats.push_back(gli::FORMAT_RGBA8_UNORM);
	Formats.push_back(gli::FORMAT_RGB8_UNORM);
	Formats.push_back(gli::FORMAT_R8_SNORM);
	Formats.push_back(gli::FORMAT_RGB_DXT1_UNORM);
	Formats.push_back(gli::FORMAT_RGB_BP_UNORM);
	Formats.push_back(gli::FORMAT_RGBA32_SFLOAT);

	std::vector<gli::texture1DArray::dim_type> Sizes;
	Sizes.push_back(gli::texture1DArray::dim_type(16));
	Sizes.push_back(gli::texture1DArray::dim_type(32));
	Sizes.push_back(gli::texture1DArray::dim_type(15));
	Sizes.push_back(gli::texture1DArray::dim_type(17));
	Sizes.push_back(gli::texture1DArray::dim_type(1));

	for(std::size_t FormatIndex = 0; FormatIndex < Formats.size(); ++FormatIndex)
	for(std::size_t SizeIndex = 0; SizeIndex < Sizes.size(); ++SizeIndex)
	{
		gli::texture1DArray::dim_type Size(Sizes[SizeIndex]);

		gli::texture1DArray TextureA(Formats[FormatIndex], Size, 1);
		gli::texture1DArray TextureB(Formats[FormatIndex], Size, 1);

		Error += TextureA == TextureB ? 0 : 1;
	}

	return Error;
}
Ejemplo n.º 2
0
	int run()
	{
		int Error(0);

		std::vector<int> Sizes;
		Sizes.push_back(16);
		Sizes.push_back(32);
		Sizes.push_back(15);
		Sizes.push_back(17);
		Sizes.push_back(1);

		for(std::size_t TargetIndex = gli::TARGET_FIRST; TargetIndex <= gli::TARGET_LAST; ++TargetIndex)
		for(std::size_t FormatIndex = gli::FORMAT_FIRST; FormatIndex <= gli::FORMAT_LAST; ++FormatIndex)
		{
			gli::format const Format = static_cast<gli::format>(FormatIndex);
			gli::target const Target = static_cast<gli::target>(TargetIndex);
			gli::texture::size_type const Faces = gli::is_target_cube(Target) ? 6 : 1;

			if(gli::is_compressed(Format) && gli::is_target_1d(Target))
				continue;

			for(std::size_t SizeIndex = 0; SizeIndex < Sizes.size(); ++SizeIndex)
			{
				gli::texture::extent_type Size(Sizes[SizeIndex]);

				gli::texture TextureA(Target, Format, Size, 1, Faces, gli::levels(Size));
				gli::texture TextureB(Target, Format, Size, 1, Faces, gli::levels(Size));

				Error += TextureA == TextureB ? 0 : 1;
			}
		}

		return Error;
	}
Ejemplo n.º 3
0
	int run()
	{
		int Error(0);

		gli::texture TextureA(gli::TARGET_1D_ARRAY, gli::FORMAT_RGBA8_UNORM, gli::texture::texelcoord_type(4, 1, 1), 2, 1, 4);
		TextureA.clear(glm::u8vec4(255, 127, 0, 192));

		gli::texture TextureB(gli::TARGET_1D_ARRAY, gli::FORMAT_RGBA8_UNORM, gli::texture::texelcoord_type(4, 1, 1), 2, 1, 4);
		TextureB.clear(glm::u8vec4(0, 127, 255, 192));
		TextureB.swizzle<glm::u8vec4>(gli::swizzles(gli::SWIZZLE_BLUE, gli::SWIZZLE_GREEN, gli::SWIZZLE_RED, gli::SWIZZLE_ALPHA));

		Error += TextureA == TextureB ? 0 : 1;

		gli::texture1DArray TextureC(gli::FORMAT_RGBA8_UNORM, gli::texture1DArray::texelcoord_type(4), 2, 4);
		TextureC.clear(glm::u8vec4(255, 127, 0, 192));

		Error += TextureA == TextureC ? 0 : 1;

		gli::texture1DArray TextureD(gli::FORMAT_RGBA8_UNORM, gli::texture1DArray::texelcoord_type(4), 2, 4);
		TextureD.clear(glm::u8vec4(0, 127, 255, 192));
		TextureD.swizzle<glm::u8vec4>(gli::swizzles(gli::SWIZZLE_BLUE, gli::SWIZZLE_GREEN, gli::SWIZZLE_RED, gli::SWIZZLE_ALPHA));

		Error += TextureA == TextureD ? 0 : 1;
		Error += TextureC == TextureD ? 0 : 1;

		return Error;
	}
Ejemplo n.º 4
0
	int test()
	{
		int Error(0);

		gli::textureCube TextureA(gli::FORMAT_RGBA8_UNORM, gli::textureCube::texelcoord_type(8), 1);

		{
			std::vector<glm::u8vec4> Color;
			Color.push_back(glm::u8vec4(255,   0,   0, 255));
			Color.push_back(glm::u8vec4(255, 128,   0, 255));
			Color.push_back(glm::u8vec4(255, 255,   0, 255));
			Color.push_back(glm::u8vec4(  0, 255,   0, 255));
			Color.push_back(glm::u8vec4(  0, 128, 255, 255));
			Color.push_back(glm::u8vec4(  0,   0, 255, 255));

			for(gli::textureCube::size_type FaceIndex = 0; FaceIndex < TextureA.faces(); ++FaceIndex)
			for(gli::texture2D::size_type TexelIndex = 0, TexelCount = TextureA[FaceIndex].size<glm::u8vec4>(); TexelIndex < TexelCount; ++TexelIndex)
				*(TextureA[FaceIndex].data<glm::u8vec4>() + TexelIndex) = Color[FaceIndex];

			gli::save_dds(TextureA, "textureCubeA_rgba8_unorm.dds");
		}

		{
			gli::textureCube TextureB(gli::load_dds("textureCubeA_rgba8_unorm.dds"));
			gli::save_dds(TextureB, "textureCubeB_rgba8_unorm.dds");
			gli::textureCube TextureC(gli::load_dds("textureCubeB_rgba8_unorm.dds"));

			Error += TextureA == TextureB ? 0 : 1;
			Error += TextureA == TextureC ? 0 : 1;
			Error += TextureB == TextureC ? 0 : 1;
		}

		return Error;
	}
Ejemplo n.º 5
0
	int test()
	{
		int Error(0);

		std::vector<gli::format> Formats;
		Formats.push_back(gli::FORMAT_RGBA8_UNORM_PACK8);
		Formats.push_back(gli::FORMAT_RGB8_UNORM_PACK8);
		Formats.push_back(gli::FORMAT_R8_SNORM_PACK8);
		Formats.push_back(gli::FORMAT_RGB_DXT1_UNORM_BLOCK8);
		Formats.push_back(gli::FORMAT_RGBA_BP_UNORM_BLOCK16);
		Formats.push_back(gli::FORMAT_RGBA32_SFLOAT_PACK32);

		std::vector<gli::texture2DArray::texelcoord_type::value_type> Sizes;
		Sizes.push_back(16);
		Sizes.push_back(32);
		Sizes.push_back(15);
		Sizes.push_back(17);
		Sizes.push_back(1);

		for(std::size_t FormatIndex = 0; FormatIndex < Formats.size(); ++FormatIndex)
		for(std::size_t SizeIndex = 0; SizeIndex < Sizes.size(); ++SizeIndex)
		{
			gli::texture2DArray::texelcoord_type Size(Sizes[SizeIndex]);

			gli::texture2DArray TextureA(Formats[FormatIndex], Size, 1, gli::levels(Size));
			gli::texture2DArray TextureB(Formats[FormatIndex], Size, 1);

			Error += TextureA == TextureB ? 0 : 1;
		}

		return Error;
	}
Ejemplo n.º 6
0
	int test()
	{
		int Error(0);

		gli::texture2DArray TextureA(gli::FORMAT_RGBA8_UNORM_PACK8, gli::texture2D::texelcoord_type(2, 2), 2);
		{
			TextureA.clear(glm::u8vec4(255, 127, 0, 255));
			TextureA.store<glm::u8vec4>(gli::texture2DArray::texelcoord_type(0, 0), 1, 0, glm::u8vec4(255, 0, 0, 255));
			TextureA.store<glm::u8vec4>(gli::texture2DArray::texelcoord_type(1, 0), 1, 0, glm::u8vec4(255, 255, 0, 255));
			TextureA.store<glm::u8vec4>(gli::texture2DArray::texelcoord_type(1, 1), 1, 0, glm::u8vec4(0, 255, 0, 255));
			TextureA.store<glm::u8vec4>(gli::texture2DArray::texelcoord_type(0, 1), 1, 0, glm::u8vec4(0, 0, 255, 255));
			TextureA.store<glm::u8vec4>(gli::texture2DArray::texelcoord_type(0, 0), 1, 1, glm::u8vec4(0, 0, 0, 255));
			gli::save_dds(TextureA, "srgba8_unorm_4pixels.dds");
		}

		gli::texture2DArray TextureB(gli::load_dds("srgba8_unorm_4pixels.dds"));
		{
			glm::u8vec4 A = TextureB.load<glm::u8vec4>(gli::texture2D::texelcoord_type(0, 0), 1, 0);
			Error += glm::all(glm::equal(A, glm::u8vec4(255, 0, 0, 255))) ? 0 : 1;
			glm::u8vec4 B = TextureB.load<glm::u8vec4>(gli::texture2D::texelcoord_type(1, 0), 1, 0);
			Error += glm::all(glm::equal(B, glm::u8vec4(255, 255, 0, 255))) ? 0 : 1;
			glm::u8vec4 C = TextureB.load<glm::u8vec4>(gli::texture2D::texelcoord_type(1, 1), 1, 0);
			Error += glm::all(glm::equal(C, glm::u8vec4(0, 255, 0, 255))) ? 0 : 1;
			glm::u8vec4 D = TextureB.load<glm::u8vec4>(gli::texture2D::texelcoord_type(0, 1), 1, 0);
			Error += glm::all(glm::equal(D, glm::u8vec4(0, 0, 255, 255))) ? 0 : 1;
			glm::u8vec4 E = TextureB.load<glm::u8vec4>(gli::texture2D::texelcoord_type(0, 0), 1, 1);
			Error += glm::all(glm::equal(E, glm::u8vec4(0, 0, 0, 255))) ? 0 : 1;
		}

		Error += TextureA == TextureB ? 0 : 1;

		return Error;
	}
Ejemplo n.º 7
0
	int test()
	{
		int Error(0);

		gli::texture2DArray::dim_type const Size(16);
		gli::texture2D TextureA(gli::FORMAT_RGBA8_UNORM, Size, 1);
		gli::texture2D TextureB(gli::FORMAT_RGBA8_UNORM, Size, 1);

		{
			std::clock_t TimeStart = std::clock();

			TextureA.clear<glm::u8vec4>(glm::u8vec4(255, 127, 0, 255));

			std::clock_t TimeEnd = std::clock();

			printf(".clear() - Time: %lu\n", TimeEnd - TimeStart);
		}

		{
			std::clock_t TimeStart = std::clock();

			for(std::size_t y = 0; y < TextureB.dimensions().y; ++y)
			for(std::size_t x = 0; x < TextureB.dimensions().x; ++x)
				gli::texel_write<glm::u8vec4>(TextureB, gli::texture2D::dim_type(x, y), 0, glm::u8vec4(255, 127, 0, 255));

			std::clock_t TimeEnd = std::clock();

			printf("texelWrite - Time: %lu\n", TimeEnd - TimeStart);
		}

		Error += TextureA == TextureB ? 0 : 1;

		return Error;
	}
Ejemplo n.º 8
0
Archivo: gl.cpp Proyecto: SCISS-AB/gli
	int run()
	{
		int Error = 0;

		gli::gl GL(gli::gl::PROFILE_KTX);

		gli::texture2d TextureA(gli::FORMAT_RGB8_UNORM_PACK8, gli::texture2d::extent_type(2), 1, gli::texture2d::swizzles_type(gli::SWIZZLE_RED, gli::SWIZZLE_GREEN, gli::SWIZZLE_BLUE, gli::SWIZZLE_ALPHA));
		gli::gl::format FormatA = GL.translate(TextureA.format(), TextureA.swizzles());

		Error += FormatA.Internal == gli::gl::INTERNAL_RGB8_UNORM ? 0 : 1;
		Error += FormatA.External == gli::gl::EXTERNAL_RGB ? 0 : 1;
		Error += FormatA.Type == gli::gl::TYPE_U8 ? 0 : 1;
		// Swizzle is not supported by KTX, so we always return the constant default swizzle
		Error += FormatA.Swizzles == gli::gl::swizzles(gli::gl::SWIZZLE_RED, gli::gl::SWIZZLE_GREEN, gli::gl::SWIZZLE_BLUE, gli::gl::SWIZZLE_ALPHA) ? 0 : 1;

		gli::texture2d TextureB(gli::FORMAT_BGR8_UNORM_PACK8, gli::texture2d::extent_type(2), 1, gli::texture2d::swizzles_type(gli::SWIZZLE_RED, gli::SWIZZLE_GREEN, gli::SWIZZLE_BLUE, gli::SWIZZLE_ALPHA));
		gli::gl::format FormatB = GL.translate(TextureB.format(), TextureB.swizzles());

		Error += FormatB.Internal == gli::gl::INTERNAL_RGB8_UNORM ? 0 : 1;
		Error += FormatB.External == gli::gl::EXTERNAL_BGR ? 0 : 1;
		Error += FormatB.Type == gli::gl::TYPE_U8 ? 0 : 1;
		// Swizzle is not supported by KTX, so we always return the constant default swizzle
		Error += FormatB.Swizzles == gli::gl::swizzles(gli::gl::SWIZZLE_RED, gli::gl::SWIZZLE_GREEN, gli::gl::SWIZZLE_BLUE, gli::gl::SWIZZLE_ALPHA) ? 0 : 1;

		return Error;
	}
Ejemplo n.º 9
0
int test_alloc()
{
	int Error(0);

	std::vector<gli::format> Formats;
	Formats.push_back(gli::RGBA8_UNORM);
	Formats.push_back(gli::RGB8_UNORM);
	Formats.push_back(gli::R8_SNORM);
	Formats.push_back(gli::RGB_DXT1);
	Formats.push_back(gli::RGB_BP_UNORM);
	Formats.push_back(gli::RGBA32F);

	std::vector<gli::texture3D::dim_type::value_type> Sizes;
	Sizes.push_back(16);
	Sizes.push_back(32);
	Sizes.push_back(15);
	Sizes.push_back(17);
	Sizes.push_back(1);

	for(std::size_t FormatIndex = 0; FormatIndex < Formats.size(); ++FormatIndex)
	for(std::size_t SizeIndex = 0; SizeIndex < Sizes.size(); ++SizeIndex)
	{
		gli::texture3D::dim_type Size(Sizes[SizeIndex]);

		gli::texture3D TextureA(gli::level_count(Size), Formats[FormatIndex], Size);
		gli::texture3D TextureB(Formats[FormatIndex], Size);

		Error += TextureA == TextureB ? 0 : 1;
	}

	return Error;
}
Ejemplo n.º 10
0
int test_view1DArray
(
	std::vector<gli::format> const & Formats,
	gli::texture1DArray::dim_type const & TextureSize
)
{
	int Error(0);

	for(std::size_t i = 0; i < Formats.size(); ++i)
	{
		gli::texture1DArray TextureA(gli::texture1DArray::size_type(4), Formats[i], TextureSize);

		gli::texture1DArray TextureViewA(TextureA, 
			TextureA.baseLayer(), TextureA.maxLayer(), 
			TextureA.baseLevel(), TextureA.maxLevel());

		Error += TextureA == TextureViewA ? 0 : 1;

		gli::texture1DArray TextureViewC = gli::view(TextureA, 
			TextureA.baseLayer(), TextureA.maxLayer(), 
			TextureA.baseLevel(), TextureA.maxLevel());
		
		Error += TextureA == TextureViewC ? 0 : 1;
		Error += TextureViewC == TextureViewA ? 0 : 1;

		gli::texture1DArray TextureB(gli::texture1DArray::size_type(4), Formats[i], TextureSize / gli::texture1DArray::dim_type(2));

		Error += TextureA != TextureB ? 0 : 1;

		gli::texture1DArray TextureViewB(TextureA,
			TextureA.baseLayer(), TextureA.maxLayer(),
			TextureA.baseLevel() + 1, TextureA.maxLevel());

		Error += TextureA != TextureViewB ? 0 : 1;
		Error += TextureB == TextureViewB ? 0 : 1;

		gli::texture1DArray TextureViewD = gli::view(TextureA, 
			TextureA.baseLayer(), TextureA.maxLayer(), 
			TextureA.baseLevel() + 1, TextureA.maxLevel());

		Error += TextureViewD == TextureViewB ? 0 : 1;

		gli::texture1DArray TextureD(TextureA, 0, TextureA.layers() -1, 1, 3);

		Error += TextureA[0][1] == TextureD[0][0] ? 0 : 1;
		Error += TextureA[0][2] == TextureD[0][1] ? 0 : 1;

		gli::texture1DArray TextureE(TextureD, 0, TextureD.layers() -1, 0, TextureD.levels() - 1);

		Error += TextureE == TextureD ? 0 : 1;
		Error += TextureE[0] == TextureD[0] ? 0 : 1;

		gli::texture1DArray TextureF(TextureE, 1, 3, 0, TextureE.levels() - 1);

		Error += TextureF[0] == TextureD[1] ? 0 : 1;
		Error += TextureF[0] == TextureE[1] ? 0 : 1;
	}

	return Error;
}
Ejemplo n.º 11
0
int test_textureCubeArray
(
	std::vector<gli::format> const & Formats,
	gli::texture_cube_array::extent_type const & TextureSize
)
{
	int Error(0);

	for(std::size_t i = 0; i < Formats.size(); ++i)
	{
		gli::texture_cube_array TextureA(
			Formats[i],
			TextureSize,
			gli::texture_cube_array::size_type(4));

		gli::texture_cube_array TextureB(gli::duplicate(TextureA));

		Error += TextureA == TextureB ? 0 : 1;

		gli::texture_cube_array TextureC(TextureA, 
			gli::texture_cube_array::size_type(0), TextureA.layers() - 1,
			gli::texture_cube_array::size_type(0), TextureA.faces() - 1,
			gli::texture_cube_array::size_type(1), gli::texture_cube_array::size_type(2));

		Error += TextureA[0][0][1] == TextureC[0][0][0] ? 0 : 1;
		Error += TextureA[0][0][2] == TextureC[0][0][1] ? 0 : 1;
		Error += TextureA[0][1][1] == TextureC[0][1][0] ? 0 : 1;
		Error += TextureA[0][1][2] == TextureC[0][1][1] ? 0 : 1;

		gli::texture_cube_array TextureD(gli::duplicate(TextureC));

		Error += TextureC == TextureD ? 0 : 1;

		gli::texture_cube_array TextureG(gli::duplicate(
			TextureA,
			gli::texture_cube_array::size_type(0), TextureA.layers() - 1,
			gli::texture_cube_array::size_type(0), TextureA.faces() - 1,
			gli::texture_cube_array::size_type(0), TextureA.levels() - 1));
		Error += TextureA == TextureG ? 0 : 1;

		gli::texture_cube_array TextureK(
			Formats[i],
			TextureSize,
			4);

		gli::texture_cube_array TextureH(TextureK, 1, 2, 0, 5, 1, 2);
		gli::texture_cube_array TextureI(gli::duplicate(TextureH));

		Error += TextureH == TextureI ? 0 : 1;

		gli::texture_cube_array TextureJ(gli::duplicate(TextureK, 1, 2, 0, 5, 1, 2));
		Error += TextureH == TextureJ ? 0 : 1;
		Error += TextureI == TextureJ ? 0 : 1;
	}

	return Error;
}
Ejemplo n.º 12
0
Archivo: gl.cpp Proyecto: SCISS-AB/gli
	int run()
	{
		int Error = 0;

		gli::gl GL(gli::gl::PROFILE_GL32);

		gli::texture2d TextureA(gli::FORMAT_RGB8_UNORM_PACK8, gli::texture2d::extent_type(2), 1, gli::texture2d::swizzles_type(gli::SWIZZLE_RED, gli::SWIZZLE_GREEN, gli::SWIZZLE_BLUE, gli::SWIZZLE_ALPHA));
		gli::gl::format FormatA = GL.translate(TextureA.format(), TextureA.swizzles());

		Error += FormatA.Internal == gli::gl::INTERNAL_RGB8_UNORM ? 0 : 1;
		Error += FormatA.External == gli::gl::EXTERNAL_RGB ? 0 : 1;
		Error += FormatA.Type == gli::gl::TYPE_U8 ? 0 : 1;
		// Swizzle is not supported by OpenGL 3.2, so we always return the constant default swizzle
		Error += FormatA.Swizzles == gli::gl::swizzles(gli::gl::SWIZZLE_RED, gli::gl::SWIZZLE_GREEN, gli::gl::SWIZZLE_BLUE, gli::gl::SWIZZLE_ALPHA) ? 0 : 1;

		gli::texture2d TextureB(gli::FORMAT_BGR8_UNORM_PACK8, gli::texture2d::extent_type(2), 1, gli::texture2d::swizzles_type(gli::SWIZZLE_RED, gli::SWIZZLE_GREEN, gli::SWIZZLE_BLUE, gli::SWIZZLE_ALPHA));
		gli::gl::format FormatB = GL.translate(TextureB.format(), TextureB.swizzles());

		Error += FormatB.Internal == gli::gl::INTERNAL_RGB8_UNORM ? 0 : 1;
		Error += FormatB.External == gli::gl::EXTERNAL_BGR ? 0 : 1;
		Error += FormatB.Type == gli::gl::TYPE_U8 ? 0 : 1;
		// Swizzle is not supported by OpenGL 3.2, so we always return the constant default swizzle
		Error += FormatB.Swizzles == gli::gl::swizzles(gli::gl::SWIZZLE_RED, gli::gl::SWIZZLE_GREEN, gli::gl::SWIZZLE_BLUE, gli::gl::SWIZZLE_ALPHA) ? 0 : 1;

		{
			gli::texture2d TextureC(gli::FORMAT_R5G6B5_UNORM_PACK16, gli::texture2d::extent_type(2), 1, gli::texture2d::swizzles_type(gli::SWIZZLE_RED, gli::SWIZZLE_GREEN, gli::SWIZZLE_BLUE, gli::SWIZZLE_ALPHA));
			gli::gl::format FormatC = GL.translate(TextureC.format(), TextureC.swizzles());

			Error += FormatC.Internal == gli::gl::INTERNAL_R5G6B5 ? 0 : 1;
			Error += FormatC.External == gli::gl::EXTERNAL_RGB ? 0 : 1;
			Error += FormatC.Type == gli::gl::TYPE_UINT16_R5G6B5_REV ? 0 : 1;
			// Swizzle is not supported by OpenGL 3.2, so we always return the constant default swizzle
			Error += FormatC.Swizzles == gli::gl::swizzles(gli::gl::SWIZZLE_RED, gli::gl::SWIZZLE_GREEN, gli::gl::SWIZZLE_BLUE, gli::gl::SWIZZLE_ALPHA) ? 0 : 1;

			gli::format FormatD2 = GL.find(FormatC.Internal, FormatC.External, FormatC.Type);
			Error += FormatD2 == TextureC.format() ? 0 : 1;
		}

		{
			gli::texture2d TextureD(gli::FORMAT_B5G6R5_UNORM_PACK16, gli::texture2d::extent_type(2), 1, gli::texture2d::swizzles_type(gli::SWIZZLE_RED, gli::SWIZZLE_GREEN, gli::SWIZZLE_BLUE, gli::SWIZZLE_ALPHA));
			gli::gl::format FormatD = GL.translate(TextureD.format(), TextureD.swizzles());

			Error += FormatD.Internal == gli::gl::INTERNAL_R5G6B5 ? 0 : 1;
			Error += FormatD.External == gli::gl::EXTERNAL_RGB ? 0 : 1;
			Error += FormatD.Type == gli::gl::TYPE_UINT16_R5G6B5 ? 0 : 1;
			// Swizzle is not supported by OpenGL 3.2, so we always return the constant default swizzle
			Error += FormatD.Swizzles == gli::gl::swizzles(gli::gl::SWIZZLE_RED, gli::gl::SWIZZLE_GREEN, gli::gl::SWIZZLE_BLUE, gli::gl::SWIZZLE_ALPHA) ? 0 : 1;

			gli::format FormatD2 = GL.find(FormatD.Internal, FormatD.External, FormatD.Type);
			Error += FormatD2 == TextureD.format() ? 0 : 1;
		}

		return Error;
	}
Ejemplo n.º 13
0
	int test(std::string const & Filename)
	{
		int Error(0);

		gli::texture2D TextureA(gli::load_dds(path(Filename.c_str())));
		gli::save_dds(TextureA, Filename.c_str());
		gli::texture2D TextureB(gli::load_dds(Filename.c_str()));

		Error += TextureA == TextureB ? 0 : 1;

		return Error;
	}
Ejemplo n.º 14
0
int test_texture2DArray()
{
	int Error(0);

	{
		gli::texture2DArray Texture(
			gli::texture2D::size_type(2), 
			gli::texture2D::size_type(1), 
			gli::RGBA8_UNORM, 
			gli::texture2D::dimensions_type(8));

		std::vector<glm::u8vec4> Color;
		Color.push_back(glm::u8vec4(255, 128,   0, 255));
		Color.push_back(glm::u8vec4(  0, 128, 255, 255));

		for(gli::texture2DArray::size_type LayerIndex = 0; LayerIndex < Texture.layers(); ++LayerIndex)
		for(gli::texture2D::size_type TexelIndex = 0; TexelIndex < Texture[LayerIndex].size<glm::u8vec4>(); ++TexelIndex)
			*(Texture[LayerIndex].data<glm::u8vec4>() + TexelIndex) = Color[LayerIndex];

		gli::save_dds(Texture, "../../data/texture2DArray_rgba8u_256.dds");
	}

	{
		gli::texture2D TextureA(gli::load_dds("../../data/test-rgb8-256a.dds"));
		gli::texture2D TextureB(gli::load_dds("../../data/test-rgb8-256b.dds"));

		assert(TextureA.format() == TextureB.format());
		assert(glm::all(glm::equal(TextureA.dimensions(), TextureB.dimensions())));

		gli::texture2DArray Texture(
			gli::texture2D::size_type(2), 
			TextureA.levels(), 
			TextureA.format(), 
			TextureA.dimensions());

		memcpy(Texture[0].data(), TextureA.data(), TextureA.size());
		memcpy(Texture[1].data(), TextureB.data(), TextureB.size());

		gli::texture2D Texture0 = gli::copy(Texture[0]);
		gli::texture2D Texture1 = gli::copy(Texture[1]);

		gli::save_dds(Texture0, "../../data/test-rgb8-256-layer0-saved.dds");
		gli::save_dds(Texture1, "../../data/test-rgb8-256-layer1-saved.dds");
		gli::save_dds(Texture, "../../data/test-rgb8-256-array-saved.dds");
	}

	{
		gli::texture2DArray Texture(gli::load_dds("../../data/test-rgb8-256-array-saved.dds"));
		assert(!Texture.empty());
	}

	return 0;
}
Ejemplo n.º 15
0
	int test(std::vector<char> const & Data, std::string const & Filename)
	{
		int Error(0);

		gli::texture2D TextureA(gli::load_dds(&Data[0], Data.size()));
		std::vector<char> Memory;
		gli::save_dds(TextureA, Memory);
		gli::texture2D TextureB(gli::load_dds(&Memory[0], Memory.size()));

		Error += TextureA == TextureB ? 0 : 1;

		return Error;
	}
Ejemplo n.º 16
0
int test_viewCube
(
	std::vector<gli::format> const & Formats, 
	gli::textureCube::dim_type const & TextureSize
)
{
	int Error(0);

	for(std::size_t i = 0; i < Formats.size(); ++i)
	{
		gli::textureCube TextureA(gli::textureCube::size_type(6), gli::levels(TextureSize), Formats[i], TextureSize);

		gli::textureCube TextureViewA(TextureA,
			TextureA.baseFace(), TextureA.maxFace(),
			TextureA.baseLevel(), TextureA.maxLevel());

		Error += TextureA == TextureViewA ? 0 : 1;

		gli::textureCube::dim_type SizeB(TextureSize / gli::textureCube::dim_type(2));
		gli::textureCube TextureB(gli::textureCube::size_type(6), gli::levels(SizeB), Formats[i], SizeB);

		gli::textureCube TextureViewB(TextureA, TextureA.baseFace(), TextureA.maxFace(), TextureA.baseLevel() + 1, TextureA.maxLevel());

		Error += TextureB == TextureViewB ? 0 : 1;

		gli::textureCube TextureViewD = gli::view(TextureA, TextureA.baseFace(), TextureA.maxFace(), TextureA.baseLevel() + 1, TextureA.maxLevel());

		Error += TextureViewD == TextureViewB ? 0 : 1;

		gli::textureCube TextureD(TextureA, 0, TextureA.faces() -1, 1, 3);

		Error += TextureA[0][1] == TextureD[0][0] ? 0 : 1;
		Error += TextureA[0][2] == TextureD[0][1] ? 0 : 1;

		gli::textureCube TextureE(TextureD, 0, TextureD.faces() -1, 0, TextureD.levels() - 1);

		Error += TextureE == TextureD ? 0 : 1;
		Error += TextureE[0] == TextureD[0] ? 0 : 1;

		gli::textureCube TextureF(TextureE, 1, 3, 0, TextureE.levels() - 1);

		Error += TextureF[0] == TextureD[1] ? 0 : 1;
		Error += TextureF[0] == TextureE[1] ? 0 : 1;
	}

	return Error;
}
Ejemplo n.º 17
0
int run(gli::format Format, std::array<genType, 8> const & TestSamples)
{
    int Error = 0;

    gli::texture3d::extent_type const Extent(4, 4, 4);

    gli::texture3d TextureA(Format, Extent);
    TextureA.clear();
    for (std::size_t i = 0, n = 8; i < n; ++i)
        *(TextureA.data<genType>(0, 0, 1) + i) = TestSamples[i];

    gli::texture3d TextureB(Format, Extent);
    TextureB.clear();
    for (std::size_t z = 0; z < 2; ++z)
        for (std::size_t y = 0; y < 2; ++y)
            for (std::size_t x = 0; x < 2; ++x)
                TextureB.store(gli::texture3d::extent_type(x, y, z), 1, TestSamples[index3D(TextureB, 1, x, y, z)]);

    std::array<genType, 8> LoadedSamplesA;
    for (std::size_t z = 0; z < 2; ++z)
        for (std::size_t y = 0; y < 2; ++y)
            for (std::size_t x = 0; x < 2; ++x)
                LoadedSamplesA[index3D(TextureB, 1, x, y, z)] = TextureA.load<genType>(gli::texture3d::extent_type(x, y, z), 1);

    std::array<genType, 8> LoadedSamplesB;
    for (std::size_t z = 0; z < 2; ++z)
        for (std::size_t y = 0; y < 2; ++y)
            for (std::size_t x = 0; x < 2; ++x)
                LoadedSamplesB[index3D(TextureB, 1, x, y, z)] = TextureB.load<genType>(gli::texture3d::extent_type(x, y, z), 1);

    for (std::size_t i = 0, n = 8; i < n; ++i)
        Error += LoadedSamplesA[i] == TestSamples[i] ? 0 : 1;

    for (std::size_t i = 0, n = 8; i < n; ++i)
        Error += LoadedSamplesB[i] == TestSamples[i] ? 0 : 1;

    Error += TextureA == TextureB ? 0 : 1;

    gli::texture3d TextureC(TextureA, 1, 1);
    gli::texture3d TextureD(TextureB, 1, 1);

    Error += TextureC == TextureD ? 0 : 1;

    return Error;
}
Ejemplo n.º 18
0
Archivo: gl.cpp Proyecto: SCISS-AB/gli
	int run()
	{
		int Error = 0;

		gli::gl GL(gli::gl::PROFILE_ES20);

		{
			gli::texture2d TextureA(gli::FORMAT_RGBA16_SFLOAT_PACK16, gli::texture2d::extent_type(2), 1, gli::texture2d::swizzles_type(gli::SWIZZLE_RED, gli::SWIZZLE_GREEN, gli::SWIZZLE_BLUE, gli::SWIZZLE_ALPHA));
			gli::gl::format FormatA = GL.translate(TextureA.format(), TextureA.swizzles());

			// With OpenGL ES 2, the internal format is the external format so Internal is pretty much moot but this is the responsibility of GLI user.
			Error += FormatA.Internal == gli::gl::INTERNAL_RGBA16F ? 0 : 1;
			Error += FormatA.External == gli::gl::EXTERNAL_RGBA ? 0 : 1;
			Error += FormatA.Type == gli::gl::TYPE_F16_OES ? 0 : 1;
		}

		{
			gli::texture2d TextureB(gli::FORMAT_BGRA8_UNORM_PACK8, gli::texture2d::extent_type(2), 1, gli::texture2d::swizzles_type(gli::SWIZZLE_RED, gli::SWIZZLE_GREEN, gli::SWIZZLE_BLUE, gli::SWIZZLE_ALPHA));
			gli::gl::format FormatB = GL.translate(TextureB.format(), TextureB.swizzles());

			Error += FormatB.Internal == gli::gl::INTERNAL_BGRA8_UNORM ? 0 : 1;
			Error += FormatB.External == gli::gl::EXTERNAL_BGRA ? 0 : 1;
			Error += FormatB.Type == gli::gl::TYPE_U8 ? 0 : 1;
		}

		{
			gli::texture2d Texture(gli::FORMAT_LA8_UNORM_PACK8, gli::texture2d::extent_type(2), 1, gli::texture2d::swizzles_type(gli::SWIZZLE_RED, gli::SWIZZLE_GREEN, gli::SWIZZLE_BLUE, gli::SWIZZLE_ALPHA));
			gli::gl::format Format = GL.translate(Texture.format(), Texture.swizzles());

			Error += Format.Internal == gli::gl::INTERNAL_LUMINANCE8_ALPHA8 ? 0 : 1;
			Error += Format.External == gli::gl::EXTERNAL_LUMINANCE_ALPHA ? 0 : 1;
			Error += Format.Type == gli::gl::TYPE_U8 ? 0 : 1;
		}

		{
			gli::texture2d Texture(gli::FORMAT_LA8_UNORM_PACK8, gli::texture2d::extent_type(2), 1, gli::texture2d::swizzles_type(gli::SWIZZLE_RED, gli::SWIZZLE_GREEN, gli::SWIZZLE_BLUE, gli::SWIZZLE_ONE));
			gli::gl::format Format = GL.translate(Texture.format(), Texture.swizzles());

			Error += Format.Internal == gli::gl::INTERNAL_LUMINANCE8_ALPHA8 ? 0 : 1;
			Error += Format.External == gli::gl::EXTERNAL_LUMINANCE_ALPHA ? 0 : 1;
			Error += Format.Type == gli::gl::TYPE_U8 ? 0 : 1;
		}

		return Error;
	}
Ejemplo n.º 19
0
	int test(params const & Params)
	{
		int Error(0);

		gli::texture2D TextureA(gli::load_dds(path(Params.Filename.c_str())));
		Error += TextureA.format() == Params.Format ? 0 : 1;
		GLI_ASSERT(!Error);

		gli::save_dds(TextureA, Params.Filename.c_str());
		gli::texture2D TextureB(gli::load_dds(Params.Filename.c_str()));
		Error += TextureB.format() == Params.Format ? 0 : 1;
		GLI_ASSERT(!Error);

		Error += TextureA == TextureB ? 0 : 1;
		GLI_ASSERT(!Error);

		return Error;
	}
Ejemplo n.º 20
0
	int test(std::vector<char> const & Data, params const & Params)
	{
		int Error(0);

		gli::texture2D TextureA(gli::load_dds(&Data[0], Data.size()));
		Error += TextureA.format() == Params.Format ? 0 : 1;
		GLI_ASSERT(!Error);

		std::vector<char> Memory;
		gli::save_dds(TextureA, Memory);
		gli::texture2D TextureB(gli::load_dds(&Memory[0], Memory.size()));
		Error += TextureB.format() == Params.Format ? 0 : 1;
		GLI_ASSERT(!Error);

		Error += TextureA == TextureB ? 0 : 1;
		GLI_ASSERT(!Error);

		return Error;
	}
Ejemplo n.º 21
0
int test_view1D
(
	std::vector<gli::format> const & Formats,
	gli::texture1D::dim_type const & TextureSize
)
{
	int Error(0);

	for(std::size_t i = 0; i < Formats.size(); ++i)
	{
		gli::texture1D TextureA(Formats[i], TextureSize);
		gli::texture1D TextureViewA(TextureA, TextureA.base_level(), TextureA.max_level());

		Error += TextureA == TextureViewA ? 0 : 1;

		gli::texture1D TextureViewC = gli::view(TextureA, TextureA.base_level(), TextureA.max_level());

		Error += TextureA == TextureViewC ? 0 : 1;
		Error += TextureViewA == TextureViewC ? 0 : 1;

		gli::texture1D TextureB(Formats[i], TextureSize / gli::texture1D::dim_type(2));
		gli::texture1D TextureViewB(TextureA, TextureA.base_level() + 1, TextureA.max_level());

		Error += TextureB == TextureViewB ? 0 : 1;

		gli::texture1D TextureViewD = gli::view(TextureA, TextureA.base_level() + 1, TextureA.max_level());

		Error += TextureB == TextureViewD ? 0 : 1;
		Error += TextureViewB == TextureViewD ? 0 : 1;

		gli::texture1D TextureD(TextureA, 1, 3);

		Error += TextureA[1] == TextureD[0] ? 0 : 1;
		Error += TextureA[2] == TextureD[1] ? 0 : 1;

		gli::texture1D TextureE(TextureD, 1, 1);

		Error += TextureE[0] == TextureD[1] ? 0 : 1;
		Error += TextureE[0] == TextureA[2] ? 0 : 1;
	}

	return Error;
}
Ejemplo n.º 22
0
int test_texture1D
(
	std::vector<gli::format> const & Formats, 
	gli::texture1d::extent_type const & TextureSize
)
{
	int Error(0);

	for(std::size_t i = 0; i < Formats.size(); ++i)
	{
		gli::texture1d TextureA(
			Formats[i],
			TextureSize,
			gli::levels(TextureSize));

		gli::texture1d TextureB(gli::duplicate(TextureA));

		Error += TextureA == TextureB ? 0 : 1;

		gli::texture1d TextureC(TextureA, gli::texture1d::size_type(1), gli::texture1d::size_type(2));

		Error += TextureA[1] == TextureC[0] ? 0 : 1;
		Error += TextureA[2] == TextureC[1] ? 0 : 1;

		gli::texture1d TextureD(gli::duplicate(TextureC));

		Error += TextureC == TextureD ? 0 : 1;

		gli::texture1d TextureG(gli::duplicate(TextureA, 0, TextureA.levels() - 1));
		Error += TextureA == TextureG ? 0 : 1;

		gli::texture1d TextureE(gli::duplicate(TextureA, 1, TextureA.levels() - 2));
		Error += TextureA[1] == TextureE[0] ? 0 : 1;

		gli::texture1d TextureF(TextureA, 1, TextureA.levels() - 2);

		Error += TextureE == TextureF ? 0 : 1;
	}

	return Error;
}
Ejemplo n.º 23
0
int test_alloc()
{
	int Error(0);

	std::vector<gli::format> Formats;
	Formats.push_back(gli::RGBA8_UNORM);
	Formats.push_back(gli::RGB8_UNORM);
	Formats.push_back(gli::R8_SNORM);
	Formats.push_back(gli::RGB_DXT1);
	Formats.push_back(gli::RGB_BP_UNORM);
	Formats.push_back(gli::RGBA32F);

	std::vector<std::size_t> Sizes;
	Sizes.push_back(16);
	Sizes.push_back(32);
	Sizes.push_back(15);
	Sizes.push_back(17);
	Sizes.push_back(1);

	for(std::size_t FormatIndex = 0; FormatIndex < Formats.size(); ++FormatIndex)
	for(std::size_t SizeIndex = 0; SizeIndex < Sizes.size(); ++SizeIndex)
	{
		gli::textureCubeArray TextureA(
			2,
			6,
			gli::textureCubeArray::size_type(glm::log2(int(Sizes[SizeIndex])) + 1),
			Formats[FormatIndex],
			gli::textureCubeArray::dimensions_type(Sizes[SizeIndex]));

		gli::textureCubeArray TextureB(
			2,
			6,
			Formats[FormatIndex],
			gli::textureCubeArray::dimensions_type(Sizes[SizeIndex]));

		Error += TextureA == TextureB ? 0 : 1;
	}

	return Error;
}
Ejemplo n.º 24
0
	int run(gli::format Format, std::array<genType, 8> const & TestSamples)
	{
		int Error = 0;

		gli::texture2DArray::texelcoord_type const Dimensions(8, 4);

		gli::texture2DArray TextureA(Format, Dimensions, 3);
		TextureA.clear();
		for (std::size_t i = 0, n = 8; i < n; ++i)
			*(TextureA.data<genType>(2, 0, 1) + i) = TestSamples[i];

		gli::texture2DArray TextureB(Format, Dimensions, 3);
		TextureB.clear();
		for (std::size_t i = 0, n = 8; i < n; ++i)
			TextureB.store(gli::texture2DArray::texelcoord_type(i % 4, i / 4), 2, 1, TestSamples[i]);

		std::array<genType, 8> LoadedSamplesA;
		for (std::size_t i = 0, n = 8; i < n; ++i)
			LoadedSamplesA[i] = TextureA.load<genType>(gli::texture2DArray::texelcoord_type(i % 4, i / 4), 2, 1);

		std::array<genType, 8> LoadedSamplesB;
		for (std::size_t i = 0, n = 8; i < n; ++i)
			LoadedSamplesB[i] = TextureB.load<genType>(gli::texture2DArray::texelcoord_type(i % 4, i / 4), 2, 1);

		for (std::size_t i = 0, n = 8; i < n; ++i)
			Error += LoadedSamplesA[i] == TestSamples[i] ? 0 : 1;

		for (std::size_t i = 0, n = 8; i < n; ++i)
			Error += LoadedSamplesB[i] == TestSamples[i] ? 0 : 1;

		Error += TextureA == TextureB ? 0 : 1;

		gli::texture2DArray TextureC(TextureA, 2, 2, 1, 1);
		gli::texture2DArray TextureD(TextureB, 2, 2, 1, 1);

		Error += TextureC == TextureD ? 0 : 1;

		return Error;
	}
Ejemplo n.º 25
0
	int run(gli::format Format, std::array<genType, 6> const & TestSamples)
	{
		int Error = 0;

		gli::textureCube::texelcoord_type const Dimensions(2, 2);

		gli::textureCube TextureA(Format, Dimensions);
		TextureA.clear();
		for (std::size_t FaceIndex = 0, FaceCount = 6; FaceIndex < FaceCount; ++FaceIndex)
			*TextureA.data<genType>(0, FaceIndex, 1) = TestSamples[FaceIndex];

		gli::textureCube TextureB(Format, Dimensions);
		TextureB.clear();
		for (std::size_t FaceIndex = 0, FaceCount = 6; FaceIndex < FaceCount; ++FaceIndex)
			TextureB.store(gli::textureCube::texelcoord_type(0, 0), FaceIndex, 1, TestSamples[FaceIndex]);

		std::array<genType, 6> LoadedSamplesA;
		for (std::size_t FaceIndex = 0, FaceCount = 6; FaceIndex < FaceCount; ++FaceIndex)
			LoadedSamplesA[FaceIndex] = TextureA.load<genType>(gli::textureCube::texelcoord_type(0), FaceIndex, 1);

		std::array<genType, 6> LoadedSamplesB;
		for (std::size_t FaceIndex = 0, FaceCount = 6; FaceIndex < FaceCount; ++FaceIndex)
			LoadedSamplesB[FaceIndex] = TextureB.load<genType>(gli::textureCube::texelcoord_type(0), FaceIndex, 1);

		for (std::size_t FaceIndex = 0, FaceCount = 6; FaceIndex < FaceCount; ++FaceIndex)
			Error += LoadedSamplesA[FaceIndex] == TestSamples[FaceIndex] ? 0 : 1;

		for (std::size_t FaceIndex = 0, FaceCount = 6; FaceIndex < FaceCount; ++FaceIndex)
			Error += LoadedSamplesB[FaceIndex] == TestSamples[FaceIndex] ? 0 : 1;

		Error += TextureA == TextureB ? 0 : 1;

		gli::textureCube TextureC(TextureA, 0, 5, 1, 1);
		gli::textureCube TextureD(TextureB, 0, 5, 1, 1);

		Error += TextureC == TextureD ? 0 : 1;

		return Error;
	}
Ejemplo n.º 26
0
int test_texture2D
(
	std::vector<gli::format> const & Formats, 
	gli::texture2D::texelcoord_type const & TextureSize
)
{
	int Error(0);

	for(std::size_t i = 0; i < Formats.size(); ++i)
	{
		gli::texture2D TextureA(Formats[i], TextureSize);

		gli::texture2D TextureB(gli::copy(TextureA));
		Error += TextureA == TextureB ? 0 : 1;

		gli::texture2D TextureC(gli::view(
			TextureA, gli::texture2D::size_type(1), gli::texture2D::size_type(2)));

		Error += TextureA[1] == TextureC[0] ? 0 : 1;
		Error += TextureA[2] == TextureC[1] ? 0 : 1;

		gli::texture2D TextureD(gli::copy(TextureC));

		Error += TextureC == TextureD ? 0 : 1;

		gli::texture2D TextureG(gli::copy(TextureA, 0, TextureA.levels() - 1));
		Error += TextureA == TextureG ? 0 : 1;

		gli::texture2D TextureE(gli::copy(TextureA, 1, TextureA.levels() - 1));
		Error += TextureA[1] == TextureE[0] ? 0 : 1;

		gli::texture2D TextureF(gli::view(
			TextureA, 1, TextureA.levels() - 1));

		Error += TextureE == TextureF ? 0 : 1;
	}

	return Error;
}
Ejemplo n.º 27
0
	int run()
	{
		int Error(0);

		gli::texture TextureA(gli::TARGET_1D_ARRAY, gli::FORMAT_RGBA8_UNORM_PACK8, gli::texture::extent_type(4, 1, 1), 2, 1, 4);
		TextureA.clear(glm::u8vec4(255, 127, 0, 192));

		{
			gli::texture1d_array TextureA1(gli::FORMAT_RGBA8_UNORM_PACK8, gli::texture1d_array::extent_type(4), 1, 1);
			Error += TextureA.swizzles() == TextureA1.swizzles() ? 0 : 1;

			gli::texture1d_array TextureA2(gli::FORMAT_RGBA8_UNORM_PACK8, gli::texture1d_array::extent_type(4), 1, 1, gli::swizzles(gli::SWIZZLE_RED, gli::SWIZZLE_GREEN, gli::SWIZZLE_BLUE, gli::SWIZZLE_ALPHA));
			Error += TextureA.swizzles() == TextureA2.swizzles() ? 0 : 1;

			Error += TextureA1.swizzles() == TextureA2.swizzles() ? 0 : 1;
		}

		gli::texture TextureB(gli::TARGET_1D_ARRAY, gli::FORMAT_RGBA8_UNORM_PACK8, gli::texture::extent_type(4, 1, 1), 2, 1, 4);
		TextureB.clear(glm::u8vec4(0, 127, 255, 192));
		TextureB.swizzle<glm::u8vec4>(gli::swizzles(gli::SWIZZLE_BLUE, gli::SWIZZLE_GREEN, gli::SWIZZLE_RED, gli::SWIZZLE_ALPHA));

		Error += TextureA == TextureB ? 0 : 1;

		gli::texture1d_array TextureC(gli::FORMAT_RGBA8_UNORM_PACK8, gli::texture1d_array::extent_type(4), 2, 4);
		TextureC.clear(glm::u8vec4(255, 127, 0, 192));

		Error += TextureA == TextureC ? 0 : 1;

		gli::texture1d_array TextureD(gli::FORMAT_RGBA8_UNORM_PACK8, gli::texture1d_array::extent_type(4), 2, 4);
		TextureD.clear(glm::u8vec4(0, 127, 255, 192));
		TextureD.swizzle<glm::u8vec4>(gli::swizzles(gli::SWIZZLE_BLUE, gli::SWIZZLE_GREEN, gli::SWIZZLE_RED, gli::SWIZZLE_ALPHA));

		Error += TextureA == TextureD ? 0 : 1;
		Error += TextureC == TextureD ? 0 : 1;

		return Error;
	}
Ejemplo n.º 28
0
Archivo: gl.cpp Proyecto: SCISS-AB/gli
	int run()
	{
		int Error = 0;

		gli::gl GL(gli::gl::PROFILE_ES30);

		{
			gli::texture2d TextureA(gli::FORMAT_RGBA16_SFLOAT_PACK16, gli::texture2d::extent_type(2), 1, gli::texture2d::swizzles_type(gli::SWIZZLE_RED, gli::SWIZZLE_GREEN, gli::SWIZZLE_BLUE, gli::SWIZZLE_ALPHA));
			gli::gl::format FormatA = GL.translate(TextureA.format(), TextureA.swizzles());

			Error += FormatA.Internal == gli::gl::INTERNAL_RGBA16F ? 0 : 1;
			Error += FormatA.External == gli::gl::EXTERNAL_RGBA ? 0 : 1;
			Error += FormatA.Type == gli::gl::TYPE_F16 ? 0 : 1;
			Error += FormatA.Swizzles == gli::gl::swizzles(gli::gl::SWIZZLE_RED, gli::gl::SWIZZLE_GREEN, gli::gl::SWIZZLE_BLUE, gli::gl::SWIZZLE_ALPHA) ? 0 : 1;
		}

		{
			gli::texture2d TextureA(gli::FORMAT_RGB8_UNORM_PACK8, gli::texture2d::extent_type(2), 1, gli::texture2d::swizzles_type(gli::SWIZZLE_RED, gli::SWIZZLE_GREEN, gli::SWIZZLE_BLUE, gli::SWIZZLE_ALPHA));
			gli::gl::format FormatA = GL.translate(TextureA.format(), TextureA.swizzles());

			Error += FormatA.Internal == gli::gl::INTERNAL_RGB8_UNORM ? 0 : 1;
			Error += FormatA.External == gli::gl::EXTERNAL_RGB ? 0 : 1;
			Error += FormatA.Type == gli::gl::TYPE_U8 ? 0 : 1;
			Error += FormatA.Swizzles == gli::gl::swizzles(gli::gl::SWIZZLE_RED, gli::gl::SWIZZLE_GREEN, gli::gl::SWIZZLE_BLUE, gli::gl::SWIZZLE_ONE) ? 0 : 1;
		}

		{
			gli::texture2d TextureB(gli::FORMAT_BGR8_UNORM_PACK8, gli::texture2d::extent_type(2), 1, gli::texture2d::swizzles_type(gli::SWIZZLE_RED, gli::SWIZZLE_GREEN, gli::SWIZZLE_BLUE, gli::SWIZZLE_ALPHA));
			gli::gl::format FormatB = GL.translate(TextureB.format(), TextureB.swizzles());

			Error += FormatB.Internal == gli::gl::INTERNAL_RGB8_UNORM ? 0 : 1;
			Error += FormatB.External == gli::gl::EXTERNAL_RGB ? 0 : 1;
			Error += FormatB.Type == gli::gl::TYPE_U8 ? 0 : 1;
			Error += FormatB.Swizzles == gli::gl::swizzles(gli::gl::SWIZZLE_BLUE, gli::gl::SWIZZLE_GREEN, gli::gl::SWIZZLE_RED, gli::gl::SWIZZLE_ONE) ? 0 : 1;
		}

		{
			gli::texture2d TextureB(gli::FORMAT_BGRA8_UNORM_PACK8, gli::texture2d::extent_type(2), 1, gli::texture2d::swizzles_type(gli::SWIZZLE_RED, gli::SWIZZLE_GREEN, gli::SWIZZLE_BLUE, gli::SWIZZLE_ALPHA));
			gli::gl::format FormatB = GL.translate(TextureB.format(), TextureB.swizzles());

			Error += FormatB.Internal == gli::gl::INTERNAL_RGBA8_UNORM ? 0 : 1;
			Error += FormatB.External == gli::gl::EXTERNAL_RGBA ? 0 : 1;
			Error += FormatB.Type == gli::gl::TYPE_U8 ? 0 : 1;
			Error += FormatB.Swizzles == gli::gl::swizzles(gli::gl::SWIZZLE_BLUE, gli::gl::SWIZZLE_GREEN, gli::gl::SWIZZLE_RED, gli::gl::SWIZZLE_ALPHA) ? 0 : 1;
		}

		{
			gli::texture2d TextureB(gli::FORMAT_BGRA8_UNORM_PACK8, gli::texture2d::extent_type(2), 1, gli::texture2d::swizzles_type(gli::SWIZZLE_BLUE, gli::SWIZZLE_GREEN, gli::SWIZZLE_RED, gli::SWIZZLE_ALPHA));
			gli::gl::format FormatB = GL.translate(TextureB.format(), TextureB.swizzles());

			Error += FormatB.Internal == gli::gl::INTERNAL_RGBA8_UNORM ? 0 : 1;
			Error += FormatB.External == gli::gl::EXTERNAL_RGBA ? 0 : 1;
			Error += FormatB.Type == gli::gl::TYPE_U8 ? 0 : 1;
			Error += FormatB.Swizzles == gli::gl::swizzles(gli::gl::SWIZZLE_RED, gli::gl::SWIZZLE_GREEN, gli::gl::SWIZZLE_BLUE, gli::gl::SWIZZLE_ALPHA) ? 0 : 1;
		}

		{
			gli::texture2d Texture(gli::FORMAT_LA8_UNORM_PACK8, gli::texture2d::extent_type(2), 1, gli::texture2d::swizzles_type(gli::SWIZZLE_RED, gli::SWIZZLE_GREEN, gli::SWIZZLE_BLUE, gli::SWIZZLE_ALPHA));
			gli::gl::format Format = GL.translate(Texture.format(), Texture.swizzles());

			Error += Format.Internal == gli::gl::INTERNAL_RG8_UNORM ? 0 : 1;
			Error += Format.External == gli::gl::EXTERNAL_RG ? 0 : 1;
			Error += Format.Type == gli::gl::TYPE_U8 ? 0 : 1;
			Error += Format.Swizzles == gli::gl::swizzles(gli::gl::SWIZZLE_RED, gli::gl::SWIZZLE_RED, gli::gl::SWIZZLE_RED, gli::gl::SWIZZLE_GREEN) ? 0 : 1;
		}

		{
			gli::texture2d Texture(gli::FORMAT_LA8_UNORM_PACK8, gli::texture2d::extent_type(2), 1, gli::texture2d::swizzles_type(gli::SWIZZLE_RED, gli::SWIZZLE_GREEN, gli::SWIZZLE_BLUE, gli::SWIZZLE_ONE));
			gli::gl::format Format = GL.translate(Texture.format(), Texture.swizzles());

			Error += Format.Internal == gli::gl::INTERNAL_RG8_UNORM ? 0 : 1;
			Error += Format.External == gli::gl::EXTERNAL_RG ? 0 : 1;
			Error += Format.Type == gli::gl::TYPE_U8 ? 0 : 1;
			Error += Format.Swizzles == gli::gl::swizzles(gli::gl::SWIZZLE_RED, gli::gl::SWIZZLE_RED, gli::gl::SWIZZLE_RED, gli::gl::SWIZZLE_ONE) ? 0 : 1;
		}

		return Error;
	}
Ejemplo n.º 29
0
Archivo: gl.cpp Proyecto: SCISS-AB/gli
	int run()
	{
		int Error = 0;

		gli::gl GL(gli::gl::PROFILE_GL33);

		{
			gli::texture2d TextureA(gli::FORMAT_RGB8_UNORM_PACK8, gli::texture2d::extent_type(2), 1, gli::texture2d::swizzles_type(gli::SWIZZLE_RED, gli::SWIZZLE_GREEN, gli::SWIZZLE_BLUE, gli::SWIZZLE_ALPHA));
			gli::gl::format FormatA = GL.translate(TextureA.format(), TextureA.swizzles());

			Error += FormatA.Internal == gli::gl::INTERNAL_RGB8_UNORM ? 0 : 1;
			Error += FormatA.External == gli::gl::EXTERNAL_RGB ? 0 : 1;
			Error += FormatA.Type == gli::gl::TYPE_U8 ? 0 : 1;
			Error += FormatA.Swizzles == gli::gl::swizzles(gli::gl::SWIZZLE_RED, gli::gl::SWIZZLE_GREEN, gli::gl::SWIZZLE_BLUE, gli::gl::SWIZZLE_ONE) ? 0 : 1;
		}

		{
			gli::texture2d TextureB(gli::FORMAT_BGR8_UNORM_PACK8, gli::texture2d::extent_type(2), 1, gli::texture2d::swizzles_type(gli::SWIZZLE_RED, gli::SWIZZLE_GREEN, gli::SWIZZLE_BLUE, gli::SWIZZLE_ALPHA));
			gli::gl::format FormatB = GL.translate(TextureB.format(), TextureB.swizzles());

			Error += FormatB.Internal == gli::gl::INTERNAL_RGB8_UNORM ? 0 : 1;
			Error += FormatB.External == gli::gl::EXTERNAL_RGB ? 0 : 1;
			Error += FormatB.Type == gli::gl::TYPE_U8 ? 0 : 1;
			Error += FormatB.Swizzles == gli::gl::swizzles(gli::gl::SWIZZLE_BLUE, gli::gl::SWIZZLE_GREEN, gli::gl::SWIZZLE_RED, gli::gl::SWIZZLE_ONE) ? 0 : 1;
		}

		{
			gli::texture2d TextureC(gli::FORMAT_R5G6B5_UNORM_PACK16, gli::texture2d::extent_type(2), 1, gli::texture2d::swizzles_type(gli::SWIZZLE_RED, gli::SWIZZLE_GREEN, gli::SWIZZLE_BLUE, gli::SWIZZLE_ALPHA));
			gli::gl::format FormatC = GL.translate(TextureC.format(), TextureC.swizzles());

			Error += FormatC.Internal == gli::gl::INTERNAL_R5G6B5 ? 0 : 1;
			Error += FormatC.External == gli::gl::EXTERNAL_RGB ? 0 : 1;
			Error += FormatC.Type == gli::gl::TYPE_UINT16_R5G6B5_REV ? 0 : 1;
			Error += FormatC.Swizzles == gli::gl::swizzles(gli::gl::SWIZZLE_RED, gli::gl::SWIZZLE_GREEN, gli::gl::SWIZZLE_BLUE, gli::gl::SWIZZLE_ONE) ? 0 : 1;

			gli::format FormatD2 = GL.find(FormatC.Internal, FormatC.External, FormatC.Type);
			Error += FormatD2 == TextureC.format() ? 0 : 1;
		}

		{
			gli::texture2d TextureD(gli::FORMAT_B5G6R5_UNORM_PACK16, gli::texture2d::extent_type(2), 1, gli::texture2d::swizzles_type(gli::SWIZZLE_RED, gli::SWIZZLE_GREEN, gli::SWIZZLE_BLUE, gli::SWIZZLE_ALPHA));
			gli::gl::format FormatD = GL.translate(TextureD.format(), TextureD.swizzles());

			Error += FormatD.Internal == gli::gl::INTERNAL_R5G6B5 ? 0 : 1;
			Error += FormatD.External == gli::gl::EXTERNAL_RGB ? 0 : 1;
			Error += FormatD.Type == gli::gl::TYPE_UINT16_R5G6B5 ? 0 : 1;
			Error += FormatD.Swizzles == gli::gl::swizzles(gli::gl::SWIZZLE_RED, gli::gl::SWIZZLE_GREEN, gli::gl::SWIZZLE_BLUE, gli::gl::SWIZZLE_ONE) ? 0 : 1;

			gli::format FormatD2 = GL.find(FormatD.Internal, FormatD.External, FormatD.Type);
			Error += FormatD2 == TextureD.format() ? 0 : 1;
		}

		{
			gli::texture2d Texture(gli::FORMAT_LA8_UNORM_PACK8, gli::texture2d::extent_type(2), 1, gli::texture2d::swizzles_type(gli::SWIZZLE_RED, gli::SWIZZLE_GREEN, gli::SWIZZLE_BLUE, gli::SWIZZLE_ALPHA));
			gli::gl::format Format = GL.translate(Texture.format(), Texture.swizzles());

			Error += Format.Internal == gli::gl::INTERNAL_RG8_UNORM ? 0 : 1;
			Error += Format.External == gli::gl::EXTERNAL_RG ? 0 : 1;
			Error += Format.Type == gli::gl::TYPE_U8 ? 0 : 1;
			Error += Format.Swizzles == gli::gl::swizzles(gli::gl::SWIZZLE_RED, gli::gl::SWIZZLE_RED, gli::gl::SWIZZLE_RED, gli::gl::SWIZZLE_GREEN) ? 0 : 1;
		}

		{
			gli::texture2d Texture(gli::FORMAT_LA8_UNORM_PACK8, gli::texture2d::extent_type(2), 1, gli::texture2d::swizzles_type(gli::SWIZZLE_RED, gli::SWIZZLE_GREEN, gli::SWIZZLE_BLUE, gli::SWIZZLE_ONE));
			gli::gl::format Format = GL.translate(Texture.format(), Texture.swizzles());

			Error += Format.Internal == gli::gl::INTERNAL_RG8_UNORM ? 0 : 1;
			Error += Format.External == gli::gl::EXTERNAL_RG ? 0 : 1;
			Error += Format.Type == gli::gl::TYPE_U8 ? 0 : 1;
			Error += Format.Swizzles == gli::gl::swizzles(gli::gl::SWIZZLE_RED, gli::gl::SWIZZLE_RED, gli::gl::SWIZZLE_RED, gli::gl::SWIZZLE_ONE) ? 0 : 1;
		}

		return Error;
	}
Ejemplo n.º 30
0
int test_texture1DArray
(
	std::vector<gli::format> const & Formats,
	gli::texture1D::texelcoord_type const & TextureSize
)
{
	int Error(0);

	for(std::size_t i = 0; i < Formats.size(); ++i)
	{
		gli::texture1DArray TextureA(
			Formats[i],
			TextureSize,
			gli::texture1DArray::size_type(4));

		gli::texture1DArray TextureB(gli::copy(TextureA));

		Error += TextureA == TextureB ? 0 : 1;

		gli::texture1DArray TextureC(TextureA,
			gli::texture1DArray::size_type(0), TextureA.layers() - 1,
			gli::texture1DArray::size_type(1), gli::texture1DArray::size_type(2));

		Error += TextureA[0][1] == TextureC[0][0] ? 0 : 1;
		Error += TextureA[0][2] == TextureC[0][1] ? 0 : 1;
		Error += TextureA[1][1] == TextureC[1][0] ? 0 : 1;
		Error += TextureA[1][2] == TextureC[1][1] ? 0 : 1;

		gli::texture1DArray TextureD(gli::copy(TextureC));

		Error += TextureC == TextureD ? 0 : 1;

		gli::texture1DArray TextureG(gli::copy(
			TextureA,
			0, TextureA.layers() - 1,
			0, TextureA.levels() - 1));
		Error += TextureA == TextureG ? 0 : 1;

		gli::texture1DArray TextureE(gli::copy(
			TextureA,
			1, TextureA.layers() - 1,
			0, TextureA.levels() - 1));
		Error += TextureA[1] == TextureE[0] ? 0 : 1;

		gli::texture1DArray TextureF(
			TextureA, 
			1, TextureA.layers() - 1, 
			0, TextureA.levels() - 1); 

		Error += TextureE == TextureF ? 0 : 1;

		gli::texture1DArray TextureK(
			Formats[i],
			TextureSize,
			gli::texture1DArray::size_type(4),
			gli::levels(TextureSize));

		gli::texture1DArray TextureH(TextureK, 1, 2, 1, 2);
		gli::texture1DArray TextureI(gli::copy(TextureH));

		Error += TextureH == TextureI ? 0 : 1;

		gli::texture1DArray TextureJ(gli::copy(TextureK, 1, 2, 1, 2));
		Error += TextureH == TextureJ ? 0 : 1;
		Error += TextureI == TextureJ ? 0 : 1;
	}

	return Error;
}