示例#1
0
	int run()
	{
		int Error(0);

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

		gli::texture TextureB(gli::TARGET_1D, gli::FORMAT_RGBA8_UNORM, gli::texture::texelcoord_type(4, 1, 1), 1, 1, 1);
		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 TextureC(gli::FORMAT_RGBA8_UNORM, gli::texture1D::texelcoord_type(4), 1);
		TextureC.clear(glm::u8vec4(255, 127, 0, 192));

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

		gli::texture1D TextureD(gli::FORMAT_RGBA8_UNORM, gli::texture1D::texelcoord_type(4), 1);
		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;

		return Error;
	}
示例#2
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;
}
示例#3
0
文件: gl.cpp 项目: 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;
	}
示例#4
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;
}
示例#5
0
文件: core_copy.cpp 项目: kvbits/gli
int test_texture1D
(
	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(
			gli::level_count(TextureSize),
			Formats[i],
			TextureSize);

		gli::texture1D TextureB = gli::copy(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::copy(TextureC);

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

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

		gli::texture1D TextureE = gli::copy(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;
}
示例#6
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;
}
示例#7
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;
	}
示例#8
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;
}
示例#9
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;
	}
示例#10
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;
	}
示例#11
0
	int test_texture(typename texture::dim_type Size, gli::format const & Format, std::vector<genType> const & Colors)
	{
		int Error(0);

		texture TextureA(Format, Size);

		for(std::size_t Level = 0; Level < TextureA.levels(); ++Level)
			TextureA[Level].clear(Colors[Level]);

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

		texture TextureC(gli::copy(TextureA));
		Error += TextureC == TextureA ? 0 : 1;

		texture TextureD(gli::copy(TextureB));
		Error += TextureD == TextureB ? 0 : 1;

		texture TextureE(gli::copy(TextureC, 1, 2));
		texture TextureF(TextureC, 1, 2);
		Error += TextureE == TextureF ? 0 : 1;

		texture TextureG(gli::copy(TextureD, 1, 2));
		texture TextureH(TextureD, 1, 2);
		Error += TextureG == TextureH ? 0 : 1;

		TextureG.clear(Colors[Colors.size() - 1]);
		TextureH.clear(Colors[Colors.size() - 1]);
		Error += TextureG == TextureH ? 0 : 1;

		TextureG.clear();
		TextureH.clear();
		Error += TextureG == TextureH ? 0 : 1;

		return Error;
	}
示例#12
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;
}
示例#13
0
文件: core_copy.cpp 项目: kvbits/gli
int test_textureCubeArray
(
	std::vector<gli::format> const & Formats, 
	gli::textureCubeArray::dim_type const & TextureSize
)
{
	int Error(0);

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

		gli::textureCubeArray TextureB = gli::copy(TextureA);

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

		gli::textureCubeArray TextureC(TextureA, 
			gli::textureCubeArray::size_type(0), TextureA.layers() - 1,
			gli::textureCubeArray::size_type(0), TextureA.faces() - 1,
			gli::textureCubeArray::size_type(1), gli::textureCubeArray::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::textureCubeArray TextureD = gli::copy(TextureC);

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

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

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

		gli::textureCubeArray TextureF(
			TextureA, 
			gli::textureCubeArray::size_type(0), TextureA.layers() - 1,
			gli::textureCubeArray::size_type(1), TextureA.faces() - 1, 
			gli::textureCubeArray::size_type(0), TextureA.levels() - 1); 

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

		gli::textureCubeArray TextureK(
			gli::textureCubeArray::size_type(4),
			gli::textureCubeArray::size_type(6),
			gli::level_count(TextureSize),
			Formats[i],
			TextureSize);

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

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

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

	return Error;
}
示例#14
0
int test_texture1DArray
(
	std::vector<gli::format> const & Formats, 
	gli::texture1D::size_type const & TextureSize
)
{
	int Error(0);

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

		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(
			gli::texture1DArray::size_type(4),
			gli::texture1DArray::size_type(glm::log2(float(TextureSize))) + 1,
			Formats[i],
			gli::texture1DArray::dimensions_type(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;
}
示例#15
0
文件: gl.cpp 项目: 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;
	}