mirror of https://github.com/mosra/magnum.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1430 lines
60 KiB
1430 lines
60 KiB
|
13 years ago
|
/*
|
||
|
|
This file is part of Magnum.
|
||
|
|
|
||
|
8 years ago
|
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018
|
||
|
12 years ago
|
Vladimír Vondruš <mosra@centrum.cz>
|
||
|
13 years ago
|
|
||
|
|
Permission is hereby granted, free of charge, to any person obtaining a
|
||
|
|
copy of this software and associated documentation files (the "Software"),
|
||
|
|
to deal in the Software without restriction, including without limitation
|
||
|
|
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||
|
|
and/or sell copies of the Software, and to permit persons to whom the
|
||
|
|
Software is furnished to do so, subject to the following conditions:
|
||
|
|
|
||
|
|
The above copyright notice and this permission notice shall be included
|
||
|
|
in all copies or substantial portions of the Software.
|
||
|
|
|
||
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||
|
|
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||
|
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||
|
|
DEALINGS IN THE SOFTWARE.
|
||
|
|
*/
|
||
|
|
|
||
|
12 years ago
|
#include <Corrade/TestSuite/Compare/Container.h>
|
||
|
13 years ago
|
|
||
|
9 years ago
|
#include "Magnum/Context.h"
|
||
|
|
#include "Magnum/Extensions.h"
|
||
|
12 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
12 years ago
|
#include "Magnum/BufferImage.h"
|
||
|
12 years ago
|
#endif
|
||
|
12 years ago
|
#include "Magnum/CubeMapTexture.h"
|
||
|
12 years ago
|
#include "Magnum/Image.h"
|
||
|
10 years ago
|
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
|
#include "Magnum/ImageFormat.h"
|
||
|
|
#endif
|
||
|
9 years ago
|
#include "Magnum/OpenGLTester.h"
|
||
|
11 years ago
|
#include "Magnum/PixelFormat.h"
|
||
|
12 years ago
|
#include "Magnum/TextureFormat.h"
|
||
|
11 years ago
|
#include "Magnum/Math/Color.h"
|
||
|
11 years ago
|
#include "Magnum/Math/Range.h"
|
||
|
13 years ago
|
|
||
|
|
namespace Magnum { namespace Test {
|
||
|
|
|
||
|
9 years ago
|
struct CubeMapTextureGLTest: OpenGLTester {
|
||
|
11 years ago
|
explicit CubeMapTextureGLTest();
|
||
|
|
|
||
|
|
void construct();
|
||
|
11 years ago
|
void wrap();
|
||
|
|
|
||
|
11 years ago
|
void bind();
|
||
|
10 years ago
|
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
|
void bindImage();
|
||
|
|
#endif
|
||
|
11 years ago
|
|
||
|
|
void sampling();
|
||
|
8 years ago
|
#ifndef MAGNUM_TARGET_WEBGL
|
||
|
11 years ago
|
void samplingSRGBDecode();
|
||
|
8 years ago
|
#endif
|
||
|
11 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
void samplingSwizzle();
|
||
|
8 years ago
|
#elif !defined(MAGNUM_TARGET_WEBGL)
|
||
|
11 years ago
|
void samplingMaxLevel();
|
||
|
|
void samplingCompare();
|
||
|
|
#endif
|
||
|
11 years ago
|
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
11 years ago
|
void samplingBorderInteger();
|
||
|
|
#endif
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
void samplingDepthStencilMode();
|
||
|
|
#endif
|
||
|
8 years ago
|
#if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
11 years ago
|
void samplingBorder();
|
||
|
|
#endif
|
||
|
11 years ago
|
|
||
|
|
void storage();
|
||
|
|
|
||
|
|
void image();
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
void imageBuffer();
|
||
|
|
#endif
|
||
|
9 years ago
|
void subImage();
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
void subImageBuffer();
|
||
|
|
#endif
|
||
|
11 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
9 years ago
|
void subImageQuery();
|
||
|
|
void subImageQueryBuffer();
|
||
|
11 years ago
|
#endif
|
||
|
11 years ago
|
|
||
|
9 years ago
|
void compressedImage();
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
void compressedImageBuffer();
|
||
|
|
#endif
|
||
|
8 years ago
|
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
|
||
|
9 years ago
|
void immutableCompressedImage();
|
||
|
8 years ago
|
#endif
|
||
|
11 years ago
|
void compressedSubImage();
|
||
|
11 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
11 years ago
|
void compressedSubImageBuffer();
|
||
|
11 years ago
|
#endif
|
||
|
11 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
11 years ago
|
void compressedSubImageQuery();
|
||
|
|
void compressedSubImageQueryBuffer();
|
||
|
11 years ago
|
#endif
|
||
|
11 years ago
|
|
||
|
9 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
void fullImageQuery();
|
||
|
|
void fullImageQueryBuffer();
|
||
|
|
|
||
|
|
void compressedFullImageQuery();
|
||
|
|
void compressedFullImageQueryBuffer();
|
||
|
|
#endif
|
||
|
|
|
||
|
11 years ago
|
void generateMipmap();
|
||
|
|
|
||
|
|
void invalidateImage();
|
||
|
|
void invalidateSubImage();
|
||
|
9 years ago
|
};
|
||
|
|
|
||
|
|
namespace {
|
||
|
|
constexpr UnsignedByte Data[]{
|
||
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||
|
|
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
||
|
|
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
|
||
|
|
|
||
|
8 years ago
|
enum: std::size_t { PixelStorageDataCount =
|
||
|
|
#if !defined(MAGNUM_TARGET_GLES2) || !defined(MAGNUM_TARGET_WEBGL)
|
||
|
|
2
|
||
|
|
#else
|
||
|
|
1
|
||
|
|
#endif
|
||
|
|
};
|
||
|
9 years ago
|
|
||
|
|
const struct {
|
||
|
|
const char* name;
|
||
|
|
Containers::ArrayView<const UnsignedByte> data;
|
||
|
|
PixelStorage storage;
|
||
|
|
Containers::ArrayView<const UnsignedByte> dataSparse;
|
||
|
|
std::size_t offset;
|
||
|
|
} PixelStorageData[PixelStorageDataCount]{
|
||
|
|
{"default pixel storage",
|
||
|
|
Containers::arrayView(Data).suffix(8), {},
|
||
|
|
Containers::arrayView(Data).suffix(8), 0},
|
||
|
|
#if !defined(MAGNUM_TARGET_GLES2) || !defined(MAGNUM_TARGET_WEBGL)
|
||
|
|
{"skip Y",
|
||
|
|
Containers::arrayView(Data).suffix(8), PixelStorage{}.setSkip({0, 1, 0}),
|
||
|
9 years ago
|
Containers::arrayView(Data), 8}
|
||
|
9 years ago
|
#endif
|
||
|
|
};
|
||
|
|
|
||
|
|
/* Just 4x4 0x00 - 0x3f compressed using RGBA DXT3 by the driver */
|
||
|
|
constexpr UnsignedByte CompressedData[]{
|
||
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||
|
|
0, 17, 17, 34, 34, 51, 51, 67,
|
||
|
|
232, 57, 0, 0, 213, 255, 170, 2
|
||
|
|
};
|
||
|
11 years ago
|
|
||
|
9 years ago
|
enum: std::size_t { CompressedPixelStorageDataCount =
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
2
|
||
|
|
#else
|
||
|
|
1
|
||
|
|
#endif
|
||
|
|
};
|
||
|
|
|
||
|
|
const struct {
|
||
|
|
const char* name;
|
||
|
|
Containers::ArrayView<const UnsignedByte> data;
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
CompressedPixelStorage storage;
|
||
|
|
#endif
|
||
|
|
Containers::ArrayView<const UnsignedByte> dataSparse;
|
||
|
|
std::size_t offset;
|
||
|
|
} CompressedPixelStorageData[CompressedPixelStorageDataCount]{
|
||
|
|
{"default pixel storage",
|
||
|
|
Containers::arrayView(CompressedData).suffix(16),
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
{},
|
||
|
|
#endif
|
||
|
|
Containers::arrayView(CompressedData).suffix(16), 0},
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
{"skip Y",
|
||
|
|
Containers::arrayView(CompressedData).suffix(16),
|
||
|
|
CompressedPixelStorage{}
|
||
|
|
.setCompressedBlockSize({4, 4, 1})
|
||
|
|
.setCompressedBlockDataSize(16)
|
||
|
|
.setSkip({0, 4, 0}),
|
||
|
9 years ago
|
Containers::arrayView(CompressedData), 16}
|
||
|
9 years ago
|
#endif
|
||
|
|
};
|
||
|
11 years ago
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
9 years ago
|
constexpr UnsignedByte FullData[]{
|
||
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||
|
|
|
||
|
|
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
||
|
|
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
|
||
|
|
|
||
|
|
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
|
||
|
|
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
|
||
|
|
|
||
|
|
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
|
||
|
|
0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
|
||
|
|
|
||
|
|
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
|
||
|
|
0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
|
||
|
|
|
||
|
|
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
|
||
|
|
0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
|
||
|
|
|
||
|
|
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
|
||
|
|
0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f
|
||
|
|
};
|
||
|
|
|
||
|
|
enum: std::size_t { FullPixelStorageDataCount = 2 };
|
||
|
|
|
||
|
|
const struct {
|
||
|
|
const char* name;
|
||
|
|
Containers::ArrayView<const UnsignedByte> data;
|
||
|
|
PixelStorage storage;
|
||
|
|
std::size_t offset;
|
||
|
|
} FullPixelStorageData[FullPixelStorageDataCount]{
|
||
|
|
{"default pixel storage",
|
||
|
|
Containers::arrayView(FullData).suffix(16), {}, 0},
|
||
|
|
#if !defined(MAGNUM_TARGET_GLES2) || !defined(MAGNUM_TARGET_WEBGL)
|
||
|
|
{"skip Z",
|
||
|
|
Containers::arrayView(FullData).suffix(16), PixelStorage{}.setSkip({0, 0, 1}), 16}
|
||
|
|
#endif
|
||
|
|
};
|
||
|
|
|
||
|
|
/* Just 4x4 0x00 - 0x3f compressed using RGBA DXT3 by the driver, repeated
|
||
|
|
six times */
|
||
|
|
constexpr UnsignedByte CompressedFullData[]{
|
||
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||
|
|
|
||
|
|
0, 17, 17, 34, 34, 51, 51, 67,
|
||
|
|
232, 57, 0, 0, 213, 255, 170, 2,
|
||
|
|
0, 17, 17, 34, 34, 51, 51, 67,
|
||
|
|
232, 57, 0, 0, 213, 255, 170, 2,
|
||
|
|
0, 17, 17, 34, 34, 51, 51, 67,
|
||
|
|
232, 57, 0, 0, 213, 255, 170, 2,
|
||
|
|
|
||
|
|
0, 17, 17, 34, 34, 51, 51, 67,
|
||
|
|
232, 57, 0, 0, 213, 255, 170, 2,
|
||
|
|
0, 17, 17, 34, 34, 51, 51, 67,
|
||
|
|
232, 57, 0, 0, 213, 255, 170, 2,
|
||
|
|
0, 17, 17, 34, 34, 51, 51, 67,
|
||
|
|
232, 57, 0, 0, 213, 255, 170, 2
|
||
|
|
};
|
||
|
|
|
||
|
|
enum: std::size_t { CompressedFullPixelStorageDataCount =
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
2
|
||
|
|
#else
|
||
|
|
1
|
||
|
|
#endif
|
||
|
|
};
|
||
|
|
|
||
|
|
const struct {
|
||
|
|
const char* name;
|
||
|
|
Containers::ArrayView<const UnsignedByte> data;
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
CompressedPixelStorage storage;
|
||
|
|
#endif
|
||
|
|
std::size_t offset;
|
||
|
|
} CompressedFullPixelStorageData[CompressedFullPixelStorageDataCount]{
|
||
|
|
{"default pixel storage",
|
||
|
|
Containers::arrayView(CompressedFullData).suffix(16*4),
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
{},
|
||
|
|
#endif
|
||
|
|
0},
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
{"skip Z",
|
||
|
|
Containers::arrayView(CompressedFullData).suffix(16*4),
|
||
|
|
CompressedPixelStorage{}
|
||
|
|
.setCompressedBlockSize({4, 4, 1})
|
||
|
|
.setCompressedBlockDataSize(16)
|
||
|
|
.setSkip({0, 0, 4}), 16*4}
|
||
|
|
#endif
|
||
|
|
};
|
||
|
11 years ago
|
#endif
|
||
|
9 years ago
|
|
||
|
|
}
|
||
|
13 years ago
|
|
||
|
|
CubeMapTextureGLTest::CubeMapTextureGLTest() {
|
||
|
|
addTests({&CubeMapTextureGLTest::construct,
|
||
|
11 years ago
|
&CubeMapTextureGLTest::wrap,
|
||
|
|
|
||
|
12 years ago
|
&CubeMapTextureGLTest::bind,
|
||
|
10 years ago
|
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
|
&CubeMapTextureGLTest::bindImage,
|
||
|
|
#endif
|
||
|
12 years ago
|
|
||
|
13 years ago
|
&CubeMapTextureGLTest::sampling,
|
||
|
8 years ago
|
#ifndef MAGNUM_TARGET_WEBGL
|
||
|
12 years ago
|
&CubeMapTextureGLTest::samplingSRGBDecode,
|
||
|
8 years ago
|
#endif
|
||
|
12 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
&CubeMapTextureGLTest::samplingSwizzle,
|
||
|
8 years ago
|
#elif !defined(MAGNUM_TARGET_WEBGL)
|
||
|
12 years ago
|
&CubeMapTextureGLTest::samplingMaxLevel,
|
||
|
12 years ago
|
&CubeMapTextureGLTest::samplingCompare,
|
||
|
12 years ago
|
#endif
|
||
|
11 years ago
|
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
12 years ago
|
&CubeMapTextureGLTest::samplingBorderInteger,
|
||
|
12 years ago
|
#endif
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
12 years ago
|
&CubeMapTextureGLTest::samplingDepthStencilMode,
|
||
|
12 years ago
|
#endif
|
||
|
8 years ago
|
#if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
11 years ago
|
&CubeMapTextureGLTest::samplingBorder,
|
||
|
|
#endif
|
||
|
12 years ago
|
|
||
|
9 years ago
|
&CubeMapTextureGLTest::storage});
|
||
|
12 years ago
|
|
||
|
9 years ago
|
addInstancedTests({
|
||
|
|
&CubeMapTextureGLTest::image,
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
&CubeMapTextureGLTest::imageBuffer,
|
||
|
|
#endif
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
&CubeMapTextureGLTest::fullImageQuery,
|
||
|
|
&CubeMapTextureGLTest::fullImageQueryBuffer,
|
||
|
|
#endif
|
||
|
|
&CubeMapTextureGLTest::subImage,
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
&CubeMapTextureGLTest::subImageBuffer,
|
||
|
|
#endif
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
&CubeMapTextureGLTest::subImageQuery,
|
||
|
|
&CubeMapTextureGLTest::subImageQueryBuffer
|
||
|
|
#endif
|
||
|
|
}, PixelStorageDataCount);
|
||
|
12 years ago
|
|
||
|
9 years ago
|
addInstancedTests({
|
||
|
|
&CubeMapTextureGLTest::compressedImage,
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
&CubeMapTextureGLTest::compressedImageBuffer,
|
||
|
|
#endif
|
||
|
8 years ago
|
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
|
||
|
9 years ago
|
&CubeMapTextureGLTest::immutableCompressedImage,
|
||
|
8 years ago
|
#endif
|
||
|
9 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
&CubeMapTextureGLTest::compressedFullImageQuery,
|
||
|
|
&CubeMapTextureGLTest::compressedFullImageQueryBuffer,
|
||
|
|
#endif
|
||
|
|
&CubeMapTextureGLTest::compressedSubImage,
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
&CubeMapTextureGLTest::compressedSubImageBuffer,
|
||
|
|
#endif
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
&CubeMapTextureGLTest::compressedSubImageQuery,
|
||
|
|
&CubeMapTextureGLTest::compressedSubImageQueryBuffer
|
||
|
|
#endif
|
||
|
|
}, CompressedPixelStorageDataCount);
|
||
|
12 years ago
|
|
||
|
9 years ago
|
addTests({&CubeMapTextureGLTest::generateMipmap,
|
||
|
12 years ago
|
|
||
|
13 years ago
|
&CubeMapTextureGLTest::invalidateImage,
|
||
|
|
&CubeMapTextureGLTest::invalidateSubImage});
|
||
|
11 years ago
|
}
|
||
|
|
|
||
|
|
namespace {
|
||
|
|
template<std::size_t size, class T> Containers::ArrayView<const T> unsafeSuffix(const T(&data)[size], std::size_t offset) {
|
||
|
|
static_assert(sizeof(T) == 1, "");
|
||
|
|
return {data - offset, size + offset};
|
||
|
|
}
|
||
|
13 years ago
|
}
|
||
|
|
|
||
|
|
void CubeMapTextureGLTest::construct() {
|
||
|
|
{
|
||
|
|
CubeMapTexture texture;
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
CORRADE_VERIFY(texture.id() > 0);
|
||
|
|
}
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
}
|
||
|
|
|
||
|
11 years ago
|
void CubeMapTextureGLTest::wrap() {
|
||
|
|
GLuint id;
|
||
|
|
glGenTextures(1, &id);
|
||
|
|
|
||
|
|
/* Releasing won't delete anything */
|
||
|
|
{
|
||
|
|
auto texture = CubeMapTexture::wrap(id, ObjectFlag::DeleteOnDestruction);
|
||
|
|
CORRADE_COMPARE(texture.release(), id);
|
||
|
|
}
|
||
|
|
|
||
|
|
/* ...so we can wrap it again */
|
||
|
|
CubeMapTexture::wrap(id);
|
||
|
|
glDeleteTextures(1, &id);
|
||
|
|
}
|
||
|
|
|
||
|
12 years ago
|
void CubeMapTextureGLTest::bind() {
|
||
|
|
CubeMapTexture texture;
|
||
|
|
texture.bind(15);
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
12 years ago
|
|
||
|
|
AbstractTexture::unbind(15);
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
12 years ago
|
|
||
|
|
AbstractTexture::bind(7, {&texture, nullptr, &texture});
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
12 years ago
|
|
||
|
|
AbstractTexture::unbind(7, 3);
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
12 years ago
|
}
|
||
|
|
|
||
|
10 years ago
|
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
|
void CubeMapTextureGLTest::bindImage() {
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::shader_image_load_store>())
|
||
|
|
CORRADE_SKIP(Extensions::GL::ARB::shader_image_load_store::string() + std::string(" is not supported."));
|
||
|
|
#else
|
||
|
|
if(!Context::current().isVersionSupported(Version::GLES310))
|
||
|
|
CORRADE_SKIP("OpenGL ES 3.1 is not supported.");
|
||
|
|
#endif
|
||
|
|
|
||
|
|
CubeMapTexture texture;
|
||
|
|
texture.setStorage(1, TextureFormat::RGBA8, Vector2i{32})
|
||
|
10 years ago
|
.bindImage(2, 0, CubeMapCoordinate::NegativeX, ImageAccess::ReadWrite, ImageFormat::RGBA8);
|
||
|
10 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
|
texture.bindImageLayered(3, 0, ImageAccess::ReadWrite, ImageFormat::RGBA8);
|
||
|
|
|
||
|
|
AbstractTexture::unbindImage(2);
|
||
|
|
AbstractTexture::unbindImage(3);
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
AbstractTexture::bindImages(1, {&texture, nullptr, &texture});
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
|
AbstractTexture::unbindImages(1, 3);
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
#endif
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
13 years ago
|
void CubeMapTextureGLTest::sampling() {
|
||
|
|
CubeMapTexture texture;
|
||
|
|
texture.setMinificationFilter(Sampler::Filter::Linear, Sampler::Mipmap::Linear)
|
||
|
|
.setMagnificationFilter(Sampler::Filter::Linear)
|
||
|
12 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
12 years ago
|
.setMinLod(-750.0f)
|
||
|
|
.setMaxLod(750.0f)
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
.setLodBias(0.5f)
|
||
|
|
#endif
|
||
|
12 years ago
|
.setBaseLevel(1)
|
||
|
|
.setMaxLevel(750)
|
||
|
|
#endif
|
||
|
11 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
13 years ago
|
.setWrapping(Sampler::Wrapping::ClampToBorder)
|
||
|
|
.setBorderColor(Color3(0.5f))
|
||
|
11 years ago
|
#else
|
||
|
|
.setWrapping(Sampler::Wrapping::ClampToEdge)
|
||
|
|
#endif
|
||
|
12 years ago
|
.setMaxAnisotropy(Sampler::maxMaxAnisotropy())
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
.setCompareMode(Sampler::CompareMode::CompareRefToTexture)
|
||
|
|
.setCompareFunction(Sampler::CompareFunction::GreaterOrEqual)
|
||
|
|
#endif
|
||
|
|
;
|
||
|
13 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
}
|
||
|
|
|
||
|
8 years ago
|
#ifndef MAGNUM_TARGET_WEBGL
|
||
|
12 years ago
|
void CubeMapTextureGLTest::samplingSRGBDecode() {
|
||
|
|
#ifdef MAGNUM_TARGET_GLES2
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::EXT::sRGB>())
|
||
|
12 years ago
|
CORRADE_SKIP(Extensions::GL::EXT::sRGB::string() + std::string(" is not supported."));
|
||
|
|
#endif
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::EXT::texture_sRGB_decode>())
|
||
|
12 years ago
|
CORRADE_SKIP(Extensions::GL::EXT::texture_sRGB_decode::string() + std::string(" is not supported."));
|
||
|
|
|
||
|
|
CubeMapTexture texture;
|
||
|
|
texture.setSRGBDecode(false);
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
}
|
||
|
8 years ago
|
#endif
|
||
|
12 years ago
|
|
||
|
12 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
void CubeMapTextureGLTest::samplingSwizzle() {
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::texture_swizzle>())
|
||
|
12 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::texture_swizzle::string() + std::string(" is not supported."));
|
||
|
|
#endif
|
||
|
|
|
||
|
|
CubeMapTexture texture;
|
||
|
|
texture.setSwizzle<'b', 'g', 'r', '0'>();
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
}
|
||
|
8 years ago
|
#elif !defined(MAGNUM_TARGET_WEBGL)
|
||
|
12 years ago
|
void CubeMapTextureGLTest::samplingMaxLevel() {
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::APPLE::texture_max_level>())
|
||
|
12 years ago
|
CORRADE_SKIP(Extensions::GL::APPLE::texture_max_level::string() + std::string(" is not supported."));
|
||
|
|
|
||
|
|
CubeMapTexture texture;
|
||
|
|
texture.setMaxLevel(750);
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
}
|
||
|
12 years ago
|
|
||
|
|
void CubeMapTextureGLTest::samplingCompare() {
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::EXT::shadow_samplers>() ||
|
||
|
|
!Context::current().isExtensionSupported<Extensions::GL::NV::shadow_samplers_cube>())
|
||
|
12 years ago
|
CORRADE_SKIP(Extensions::GL::NV::shadow_samplers_cube::string() + std::string(" is not supported."));
|
||
|
|
|
||
|
|
CubeMapTexture texture;
|
||
|
|
texture.setCompareMode(Sampler::CompareMode::CompareRefToTexture)
|
||
|
|
.setCompareFunction(Sampler::CompareFunction::GreaterOrEqual);
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
}
|
||
|
12 years ago
|
#endif
|
||
|
|
|
||
|
11 years ago
|
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
12 years ago
|
void CubeMapTextureGLTest::samplingBorderInteger() {
|
||
|
11 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::EXT::texture_integer>())
|
||
|
12 years ago
|
CORRADE_SKIP(Extensions::GL::EXT::texture_integer::string() + std::string(" is not supported."));
|
||
|
11 years ago
|
#else
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::EXT::texture_border_clamp>())
|
||
|
11 years ago
|
CORRADE_SKIP(Extensions::GL::EXT::texture_border_clamp::string() + std::string(" is not supported."));
|
||
|
|
#endif
|
||
|
12 years ago
|
|
||
|
|
CubeMapTexture a;
|
||
|
|
a.setWrapping(Sampler::Wrapping::ClampToBorder)
|
||
|
|
.setBorderColor(Vector4i(1, 56, 78, -2));
|
||
|
|
CubeMapTexture b;
|
||
|
|
b.setWrapping(Sampler::Wrapping::ClampToBorder)
|
||
|
|
.setBorderColor(Vector4ui(35, 56, 78, 15));
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
}
|
||
|
12 years ago
|
#endif
|
||
|
12 years ago
|
|
||
|
12 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
12 years ago
|
void CubeMapTextureGLTest::samplingDepthStencilMode() {
|
||
|
12 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::stencil_texturing>())
|
||
|
12 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::stencil_texturing::string() + std::string(" is not supported."));
|
||
|
12 years ago
|
#else
|
||
|
10 years ago
|
if(!Context::current().isVersionSupported(Version::GLES310))
|
||
|
12 years ago
|
CORRADE_SKIP("OpenGL ES 3.1 not supported.");
|
||
|
|
#endif
|
||
|
12 years ago
|
|
||
|
|
CubeMapTexture texture;
|
||
|
|
texture.setDepthStencilMode(Sampler::DepthStencilMode::StencilIndex);
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
}
|
||
|
12 years ago
|
#endif
|
||
|
|
|
||
|
8 years ago
|
#if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
11 years ago
|
void CubeMapTextureGLTest::samplingBorder() {
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::NV::texture_border_clamp>() &&
|
||
|
|
!Context::current().isExtensionSupported<Extensions::GL::EXT::texture_border_clamp>())
|
||
|
11 years ago
|
CORRADE_SKIP("No required extension is supported.");
|
||
|
11 years ago
|
|
||
|
|
CubeMapTexture texture;
|
||
|
|
texture.setWrapping(Sampler::Wrapping::ClampToBorder)
|
||
|
|
.setBorderColor(Color3(0.5f));
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
13 years ago
|
void CubeMapTextureGLTest::storage() {
|
||
|
|
CubeMapTexture texture;
|
||
|
8 years ago
|
texture.setStorage(5,
|
||
|
|
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
|
||
|
|
TextureFormat::RGBA8,
|
||
|
|
#else
|
||
|
|
TextureFormat::RGBA,
|
||
|
|
#endif
|
||
|
|
Vector2i(32));
|
||
|
13 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
12 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
#ifdef MAGNUM_TARGET_GLES
|
||
|
10 years ago
|
if(!Context::current().isVersionSupported(Version::GLES310))
|
||
|
12 years ago
|
CORRADE_SKIP("OpenGL ES 3.1 not supported, skipping image size testing");
|
||
|
|
#endif
|
||
|
|
|
||
|
12 years ago
|
CORRADE_COMPARE(texture.imageSize(0), Vector2i(32));
|
||
|
|
CORRADE_COMPARE(texture.imageSize(1), Vector2i(16));
|
||
|
|
CORRADE_COMPARE(texture.imageSize(2), Vector2i(8));
|
||
|
|
CORRADE_COMPARE(texture.imageSize(3), Vector2i(4));
|
||
|
|
CORRADE_COMPARE(texture.imageSize(4), Vector2i(2));
|
||
|
13 years ago
|
/* Not available */
|
||
|
12 years ago
|
CORRADE_COMPARE(texture.imageSize(5), Vector2i(0));
|
||
|
13 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
#endif
|
||
|
|
}
|
||
|
|
|
||
|
8 years ago
|
namespace {
|
||
|
|
constexpr UnsignedByte Zero[4*4*4]{};
|
||
|
|
}
|
||
|
|
|
||
|
9 years ago
|
void CubeMapTextureGLTest::image() {
|
||
|
|
setTestCaseDescription(PixelStorageData[testCaseInstanceId()].name);
|
||
|
11 years ago
|
|
||
|
9 years ago
|
#ifdef MAGNUM_TARGET_GLES2
|
||
|
8 years ago
|
#ifndef MAGNUM_TARGET_WEBGL
|
||
|
9 years ago
|
if(PixelStorageData[testCaseInstanceId()].storage != PixelStorage{} && !Context::current().isExtensionSupported<Extensions::GL::EXT::unpack_subimage>())
|
||
|
|
CORRADE_SKIP(Extensions::GL::EXT::unpack_subimage::string() + std::string(" is not supported."));
|
||
|
8 years ago
|
#else
|
||
|
|
if(PixelStorageData[testCaseInstanceId()].storage != PixelStorage{})
|
||
|
|
CORRADE_SKIP("Image unpack is not supported in WebGL 1.");
|
||
|
|
#endif
|
||
|
9 years ago
|
#endif
|
||
|
11 years ago
|
|
||
|
8 years ago
|
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
|
||
|
|
constexpr TextureFormat format = TextureFormat::RGBA8;
|
||
|
|
#else
|
||
|
|
constexpr TextureFormat format = TextureFormat::RGBA;
|
||
|
|
#endif
|
||
|
|
|
||
|
11 years ago
|
CubeMapTexture texture;
|
||
|
8 years ago
|
texture.setImage(CubeMapCoordinate::PositiveX, 0, format, ImageView2D{PixelStorageData[testCaseInstanceId()].storage,
|
||
|
9 years ago
|
PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(2),
|
||
|
|
PixelStorageData[testCaseInstanceId()].dataSparse});
|
||
|
8 years ago
|
texture.setImage(CubeMapCoordinate::NegativeX, 0, format,
|
||
|
|
ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(2), Zero});
|
||
|
|
texture.setImage(CubeMapCoordinate::PositiveY, 0, format,
|
||
|
|
ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(2), Zero});
|
||
|
|
texture.setImage(CubeMapCoordinate::NegativeY, 0, format,
|
||
|
|
ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(2), Zero});
|
||
|
|
texture.setImage(CubeMapCoordinate::PositiveZ, 0, format,
|
||
|
|
ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(2), Zero});
|
||
|
|
texture.setImage(CubeMapCoordinate::NegativeZ, 0, format,
|
||
|
|
ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(2), Zero});
|
||
|
11 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
|
/** @todo How to test this on ES? */
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
10 years ago
|
Image2D image = texture.image(CubeMapCoordinate::PositiveX, 0,
|
||
|
9 years ago
|
{PixelStorageData[testCaseInstanceId()].storage,
|
||
|
|
PixelFormat::RGBA, PixelType::UnsignedByte});
|
||
|
11 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
|
CORRADE_COMPARE(image.size(), Vector2i(2));
|
||
|
9 years ago
|
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()).suffix(PixelStorageData[testCaseInstanceId()].offset),
|
||
|
|
PixelStorageData[testCaseInstanceId()].data,
|
||
|
|
TestSuite::Compare::Container);
|
||
|
11 years ago
|
#endif
|
||
|
|
}
|
||
|
|
|
||
|
9 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
void CubeMapTextureGLTest::imageBuffer() {
|
||
|
|
setTestCaseDescription(PixelStorageData[testCaseInstanceId()].name);
|
||
|
10 years ago
|
|
||
|
|
CubeMapTexture texture;
|
||
|
9 years ago
|
texture.setImage(CubeMapCoordinate::PositiveX, 0, TextureFormat::RGBA8,
|
||
|
|
BufferImage2D{PixelStorageData[testCaseInstanceId()].storage,
|
||
|
|
PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(2),
|
||
|
|
PixelStorageData[testCaseInstanceId()].dataSparse,
|
||
|
|
BufferUsage::StaticDraw});
|
||
|
8 years ago
|
texture.setImage(CubeMapCoordinate::NegativeX, 0, TextureFormat::RGBA8,
|
||
|
|
ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(2), Zero});
|
||
|
|
texture.setImage(CubeMapCoordinate::PositiveY, 0, TextureFormat::RGBA8,
|
||
|
|
ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(2), Zero});
|
||
|
|
texture.setImage(CubeMapCoordinate::NegativeY, 0, TextureFormat::RGBA8,
|
||
|
|
ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(2), Zero});
|
||
|
|
texture.setImage(CubeMapCoordinate::PositiveZ, 0, TextureFormat::RGBA8,
|
||
|
|
ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(2), Zero});
|
||
|
|
texture.setImage(CubeMapCoordinate::NegativeZ, 0, TextureFormat::RGBA8,
|
||
|
|
ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(2), Zero});
|
||
|
11 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
9 years ago
|
/** @todo How to test this on ES? */
|
||
|
11 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
9 years ago
|
BufferImage2D image = texture.image(CubeMapCoordinate::PositiveX, 0,
|
||
|
|
{PixelStorageData[testCaseInstanceId()].storage, PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead);
|
||
|
9 years ago
|
const auto imageData = image.buffer().data();
|
||
|
11 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
9 years ago
|
CORRADE_COMPARE(image.size(), Vector2i(2));
|
||
|
9 years ago
|
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(imageData).suffix(PixelStorageData[testCaseInstanceId()].offset),
|
||
|
9 years ago
|
PixelStorageData[testCaseInstanceId()].data,
|
||
|
|
TestSuite::Compare::Container);
|
||
|
11 years ago
|
#endif
|
||
|
|
}
|
||
|
9 years ago
|
#endif
|
||
|
|
|
||
|
|
namespace {
|
||
|
8 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
9 years ago
|
constexpr UnsignedByte SubDataComplete[]{
|
||
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||
|
|
0, 0, 0, 0, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0, 0, 0, 0,
|
||
|
|
0, 0, 0, 0, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0, 0, 0, 0,
|
||
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||
|
|
};
|
||
|
8 years ago
|
#endif
|
||
|
9 years ago
|
}
|
||
|
|
|
||
|
|
void CubeMapTextureGLTest::subImage() {
|
||
|
|
setTestCaseDescription(PixelStorageData[testCaseInstanceId()].name);
|
||
|
|
|
||
|
|
#ifdef MAGNUM_TARGET_GLES2
|
||
|
8 years ago
|
#ifndef MAGNUM_TARGET_WEBGL
|
||
|
9 years ago
|
if(PixelStorageData[testCaseInstanceId()].storage != PixelStorage{} && !Context::current().isExtensionSupported<Extensions::GL::EXT::unpack_subimage>())
|
||
|
|
CORRADE_SKIP(Extensions::GL::EXT::unpack_subimage::string() + std::string(" is not supported."));
|
||
|
8 years ago
|
#else
|
||
|
|
if(PixelStorageData[testCaseInstanceId()].storage != PixelStorage{})
|
||
|
|
CORRADE_SKIP("Image unpack is not supported in WebGL 1.");
|
||
|
|
#endif
|
||
|
|
#endif
|
||
|
|
|
||
|
|
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
|
||
|
|
constexpr TextureFormat format = TextureFormat::RGBA8;
|
||
|
|
#else
|
||
|
|
constexpr TextureFormat format = TextureFormat::RGBA;
|
||
|
9 years ago
|
#endif
|
||
|
11 years ago
|
|
||
|
|
CubeMapTexture texture;
|
||
|
8 years ago
|
texture.setImage(CubeMapCoordinate::PositiveX, 0, format,
|
||
|
9 years ago
|
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(4), Zero));
|
||
|
8 years ago
|
texture.setImage(CubeMapCoordinate::NegativeX, 0, format,
|
||
|
9 years ago
|
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(4), Zero));
|
||
|
8 years ago
|
texture.setImage(CubeMapCoordinate::PositiveY, 0, format,
|
||
|
9 years ago
|
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(4), Zero));
|
||
|
8 years ago
|
texture.setImage(CubeMapCoordinate::NegativeY, 0, format,
|
||
|
9 years ago
|
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(4), Zero));
|
||
|
8 years ago
|
texture.setImage(CubeMapCoordinate::PositiveZ, 0, format,
|
||
|
9 years ago
|
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(4), Zero));
|
||
|
8 years ago
|
texture.setImage(CubeMapCoordinate::NegativeZ, 0, format,
|
||
|
9 years ago
|
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(4), Zero));
|
||
|
|
texture.setSubImage(CubeMapCoordinate::PositiveX, 0, Vector2i(1), ImageView2D{
|
||
|
|
PixelStorageData[testCaseInstanceId()].storage,
|
||
|
|
PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(2),
|
||
|
|
PixelStorageData[testCaseInstanceId()].dataSparse});
|
||
|
11 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
|
/** @todo How to test this on ES? */
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
9 years ago
|
Image2D image = texture.image(CubeMapCoordinate::PositiveX, 0, {PixelFormat::RGBA, PixelType::UnsignedByte});
|
||
|
11 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
9 years ago
|
CORRADE_COMPARE(image.size(), Vector2i(4));
|
||
|
|
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()),
|
||
|
|
Containers::arrayView(SubDataComplete), TestSuite::Compare::Container);
|
||
|
11 years ago
|
#endif
|
||
|
|
}
|
||
|
|
|
||
|
9 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
void CubeMapTextureGLTest::subImageBuffer() {
|
||
|
|
setTestCaseDescription(PixelStorageData[testCaseInstanceId()].name);
|
||
|
10 years ago
|
|
||
|
|
CubeMapTexture texture;
|
||
|
9 years ago
|
texture.setImage(CubeMapCoordinate::PositiveX, 0, TextureFormat::RGBA8,
|
||
|
|
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(4), Zero));
|
||
|
|
texture.setImage(CubeMapCoordinate::NegativeX, 0, TextureFormat::RGBA8,
|
||
|
|
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(4), Zero));
|
||
|
|
texture.setImage(CubeMapCoordinate::PositiveY, 0, TextureFormat::RGBA8,
|
||
|
|
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(4), Zero));
|
||
|
|
texture.setImage(CubeMapCoordinate::NegativeY, 0, TextureFormat::RGBA8,
|
||
|
|
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(4), Zero));
|
||
|
|
texture.setImage(CubeMapCoordinate::PositiveZ, 0, TextureFormat::RGBA8,
|
||
|
|
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(4), Zero));
|
||
|
|
texture.setImage(CubeMapCoordinate::NegativeZ, 0, TextureFormat::RGBA8,
|
||
|
|
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(4), Zero));
|
||
|
|
texture.setSubImage(CubeMapCoordinate::PositiveX, 0, Vector2i(1), BufferImage2D{
|
||
|
|
PixelStorageData[testCaseInstanceId()].storage,
|
||
|
|
PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(2),
|
||
|
|
PixelStorageData[testCaseInstanceId()].dataSparse,
|
||
|
|
BufferUsage::StaticDraw});
|
||
|
11 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
9 years ago
|
/** @todo How to test this on ES? */
|
||
|
11 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
9 years ago
|
BufferImage2D image = texture.image(CubeMapCoordinate::PositiveX, 0, {PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead);
|
||
|
9 years ago
|
const auto imageData = image.buffer().data();
|
||
|
11 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
9 years ago
|
CORRADE_COMPARE(image.size(), Vector2i(4));
|
||
|
9 years ago
|
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(imageData),
|
||
|
|
Containers::arrayView(SubDataComplete),
|
||
|
9 years ago
|
TestSuite::Compare::Container);
|
||
|
11 years ago
|
#endif
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
9 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
void CubeMapTextureGLTest::subImageQuery() {
|
||
|
|
setTestCaseDescription(PixelStorageData[testCaseInstanceId()].name);
|
||
|
10 years ago
|
|
||
|
9 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::get_texture_sub_image>())
|
||
|
|
CORRADE_SKIP(Extensions::GL::ARB::get_texture_sub_image::string() + std::string(" is not supported."));
|
||
|
|
/* I'm too lazy to call setSubImage() six times */
|
||
|
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::direct_state_access>())
|
||
|
|
CORRADE_SKIP(Extensions::GL::ARB::direct_state_access::string() + std::string(" is not supported."));
|
||
|
10 years ago
|
|
||
|
|
CubeMapTexture texture;
|
||
|
9 years ago
|
texture.setStorage(1, TextureFormat::RGBA8, Vector2i{4})
|
||
|
|
.setSubImage(0, {}, ImageView3D{PixelFormat::RGBA, PixelType::UnsignedByte, {4, 4, 1}, SubDataComplete});
|
||
|
10 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
9 years ago
|
Image3D image = texture.subImage(0, Range3Di::fromSize({1, 1, 0}, {2, 2, 1}),
|
||
|
|
{PixelStorageData[testCaseInstanceId()].storage,
|
||
|
|
PixelFormat::RGBA, PixelType::UnsignedByte});
|
||
|
10 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
9 years ago
|
CORRADE_COMPARE(image.size(), Vector3i(2, 2, 1));
|
||
|
|
CORRADE_COMPARE_AS(Containers::arrayCast<const UnsignedByte>(image.data()).suffix(PixelStorageData[testCaseInstanceId()].offset),
|
||
|
|
PixelStorageData[testCaseInstanceId()].data,
|
||
|
|
TestSuite::Compare::Container);
|
||
|
10 years ago
|
}
|
||
|
|
|
||
|
9 years ago
|
void CubeMapTextureGLTest::subImageQueryBuffer() {
|
||
|
|
setTestCaseDescription(PixelStorageData[testCaseInstanceId()].name);
|
||
|
11 years ago
|
|
||
|
9 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::get_texture_sub_image>())
|
||
|
|
CORRADE_SKIP(Extensions::GL::ARB::get_texture_sub_image::string() + std::string(" is not supported."));
|
||
|
|
/* I'm too lazy to call setSubImage() six times */
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::direct_state_access>())
|
||
|
11 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::direct_state_access::string() + std::string(" is not supported."));
|
||
|
|
|
||
|
|
CubeMapTexture texture;
|
||
|
9 years ago
|
texture.setStorage(1, TextureFormat::RGBA8, Vector2i{4})
|
||
|
|
.setSubImage(0, {}, ImageView3D{PixelFormat::RGBA, PixelType::UnsignedByte, {4, 4, 1}, SubDataComplete});
|
||
|
11 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
9 years ago
|
BufferImage3D image = texture.subImage(0, Range3Di::fromSize({1, 1, 0}, {2, 2, 1}),
|
||
|
|
{PixelStorageData[testCaseInstanceId()].storage,
|
||
|
|
PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead);
|
||
|
9 years ago
|
const auto imageData = image.buffer().data();
|
||
|
11 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
9 years ago
|
CORRADE_COMPARE(image.size(), Vector3i(2, 2, 1));
|
||
|
9 years ago
|
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(imageData).suffix(PixelStorageData[testCaseInstanceId()].offset),
|
||
|
9 years ago
|
PixelStorageData[testCaseInstanceId()].data,
|
||
|
|
TestSuite::Compare::Container);
|
||
|
11 years ago
|
}
|
||
|
9 years ago
|
#endif
|
||
|
11 years ago
|
|
||
|
9 years ago
|
void CubeMapTextureGLTest::compressedImage() {
|
||
|
|
setTestCaseDescription(CompressedPixelStorageData[testCaseInstanceId()].name);
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_WEBGL
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::EXT::texture_compression_s3tc>())
|
||
|
11 years ago
|
CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported."));
|
||
|
9 years ago
|
#else
|
||
|
|
if(!Context::current().isExtensionSupported<Extensions::GL::WEBGL::compressed_texture_s3tc>())
|
||
|
|
CORRADE_SKIP(Extensions::GL::WEBGL::compressed_texture_s3tc::string() + std::string(" is not supported."));
|
||
|
|
#endif
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
if(CompressedPixelStorageData[testCaseInstanceId()].storage != CompressedPixelStorage{} && !Context::current().isExtensionSupported<Extensions::GL::ARB::compressed_texture_pixel_storage>())
|
||
|
|
CORRADE_SKIP(Extensions::GL::ARB::compressed_texture_pixel_storage::string() + std::string(" is not supported."));
|
||
|
|
#endif
|
||
|
|
|
||
|
|
const CompressedImageView2D view{
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
CompressedPixelStorageData[testCaseInstanceId()].storage,
|
||
|
|
#endif
|
||
|
|
CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{4},
|
||
|
|
CompressedPixelStorageData[testCaseInstanceId()].dataSparse};
|
||
|
11 years ago
|
|
||
|
|
CubeMapTexture texture;
|
||
|
9 years ago
|
texture.setCompressedImage(CubeMapCoordinate::PositiveX, 0, view)
|
||
|
|
.setCompressedImage(CubeMapCoordinate::NegativeX, 0, view)
|
||
|
|
.setCompressedImage(CubeMapCoordinate::PositiveY, 0, view)
|
||
|
|
.setCompressedImage(CubeMapCoordinate::NegativeY, 0, view)
|
||
|
|
.setCompressedImage(CubeMapCoordinate::PositiveZ, 0, view)
|
||
|
|
.setCompressedImage(CubeMapCoordinate::NegativeZ, 0, view);
|
||
|
11 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
9 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
CompressedImage2D image = texture.compressedImage(CubeMapCoordinate::PositiveX, 0, {CompressedPixelStorageData[testCaseInstanceId()].storage});
|
||
|
11 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
9 years ago
|
CORRADE_COMPARE(image.size(), Vector2i{4});
|
||
|
|
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()).suffix(CompressedPixelStorageData[testCaseInstanceId()].offset),
|
||
|
|
CompressedPixelStorageData[testCaseInstanceId()].data,
|
||
|
|
TestSuite::Compare::Container);
|
||
|
|
#endif
|
||
|
11 years ago
|
}
|
||
|
|
|
||
|
9 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
void CubeMapTextureGLTest::compressedImageBuffer() {
|
||
|
|
setTestCaseDescription(CompressedPixelStorageData[testCaseInstanceId()].name);
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_WEBGL
|
||
|
|
if(!Context::current().isExtensionSupported<Extensions::GL::EXT::texture_compression_s3tc>())
|
||
|
|
CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported."));
|
||
|
|
#else
|
||
|
|
if(!Context::current().isExtensionSupported<Extensions::GL::WEBGL::compressed_texture_s3tc>())
|
||
|
|
CORRADE_SKIP(Extensions::GL::WEBGL::compressed_texture_s3tc::string() + std::string(" is not supported."));
|
||
|
|
#endif
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
if(CompressedPixelStorageData[testCaseInstanceId()].storage != CompressedPixelStorage{} && !Context::current().isExtensionSupported<Extensions::GL::ARB::compressed_texture_pixel_storage>())
|
||
|
|
CORRADE_SKIP(Extensions::GL::ARB::compressed_texture_pixel_storage::string() + std::string(" is not supported."));
|
||
|
|
#endif
|
||
|
|
|
||
|
|
CompressedBufferImage2D buffer{
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
CompressedPixelStorageData[testCaseInstanceId()].storage,
|
||
|
|
#endif
|
||
|
|
CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{4},
|
||
|
|
CompressedPixelStorageData[testCaseInstanceId()].dataSparse,
|
||
|
|
BufferUsage::StaticDraw};
|
||
|
11 years ago
|
|
||
|
|
CubeMapTexture texture;
|
||
|
9 years ago
|
texture.setCompressedImage(CubeMapCoordinate::PositiveX, 0, buffer)
|
||
|
|
.setCompressedImage(CubeMapCoordinate::NegativeX, 0, buffer)
|
||
|
|
.setCompressedImage(CubeMapCoordinate::PositiveY, 0, buffer)
|
||
|
|
.setCompressedImage(CubeMapCoordinate::NegativeY, 0, buffer)
|
||
|
|
.setCompressedImage(CubeMapCoordinate::PositiveZ, 0, buffer)
|
||
|
|
.setCompressedImage(CubeMapCoordinate::NegativeZ, 0, buffer);
|
||
|
11 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
9 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
CompressedBufferImage2D image = texture.compressedImage(CubeMapCoordinate::PositiveX, 0,
|
||
|
|
{CompressedPixelStorageData[testCaseInstanceId()].storage}, BufferUsage::StaticRead);
|
||
|
9 years ago
|
const auto imageData = image.buffer().data();
|
||
|
11 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
9 years ago
|
CORRADE_COMPARE(image.size(), Vector2i{4});
|
||
|
9 years ago
|
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(imageData).suffix(CompressedPixelStorageData[testCaseInstanceId()].offset),
|
||
|
9 years ago
|
CompressedPixelStorageData[testCaseInstanceId()].data,
|
||
|
|
TestSuite::Compare::Container);
|
||
|
|
#endif
|
||
|
11 years ago
|
}
|
||
|
9 years ago
|
#endif
|
||
|
11 years ago
|
|
||
|
8 years ago
|
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
|
||
|
9 years ago
|
void CubeMapTextureGLTest::immutableCompressedImage() {
|
||
|
|
setTestCaseDescription(CompressedPixelStorageData[testCaseInstanceId()].name);
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::texture_storage>())
|
||
|
|
CORRADE_SKIP(Extensions::GL::ARB::texture_storage::string() + std::string(" is not supported."));
|
||
|
|
#elif defined(MAGNUM_TARGET_GLES2)
|
||
|
|
if(!Context::current().isExtensionSupported<Extensions::GL::EXT::texture_storage>())
|
||
|
|
CORRADE_SKIP(Extensions::GL::EXT::texture_storage::string() + std::string(" is not supported."));
|
||
|
|
#endif
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::EXT::texture_compression_s3tc>())
|
||
|
11 years ago
|
CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported."));
|
||
|
|
|
||
|
9 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
if(CompressedPixelStorageData[testCaseInstanceId()].storage != CompressedPixelStorage{} && !Context::current().isExtensionSupported<Extensions::GL::ARB::compressed_texture_pixel_storage>())
|
||
|
|
CORRADE_SKIP(Extensions::GL::ARB::compressed_texture_pixel_storage::string() + std::string(" is not supported."));
|
||
|
|
#endif
|
||
|
|
|
||
|
|
/* Testing that GL_TEXTURE_COMPRESSED_IMAGE_SIZE is consistent and returns
|
||
|
|
the same value regardless whether the texture is immutable or not. (Not
|
||
|
|
the case, at least on NVidia 358.16, compare with compressedImage() test
|
||
|
|
case that just calls setImage() six times instead of setStorage() and
|
||
|
|
gets value that's six times smaller. I couldn't find anything in the
|
||
|
|
specs so I suspect it's a bug). */
|
||
|
|
|
||
|
|
const CompressedImageView2D view{
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
CompressedPixelStorageData[testCaseInstanceId()].storage,
|
||
|
|
#endif
|
||
|
|
CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{4},
|
||
|
|
CompressedPixelStorageData[testCaseInstanceId()].dataSparse};
|
||
|
|
|
||
|
11 years ago
|
CubeMapTexture texture;
|
||
|
|
texture.setStorage(1, TextureFormat::CompressedRGBAS3tcDxt3, Vector2i{4})
|
||
|
9 years ago
|
.setCompressedSubImage(CubeMapCoordinate::PositiveX, 0, {}, view)
|
||
|
|
.setCompressedSubImage(CubeMapCoordinate::NegativeX, 0, {}, view)
|
||
|
|
.setCompressedSubImage(CubeMapCoordinate::PositiveY, 0, {}, view)
|
||
|
|
.setCompressedSubImage(CubeMapCoordinate::NegativeY, 0, {}, view)
|
||
|
|
.setCompressedSubImage(CubeMapCoordinate::PositiveZ, 0, {}, view)
|
||
|
|
.setCompressedSubImage(CubeMapCoordinate::NegativeZ, 0, {}, view);
|
||
|
11 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
9 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
CompressedImage2D image = texture.compressedImage(CubeMapCoordinate::NegativeY, 0, {CompressedPixelStorageData[testCaseInstanceId()].storage});
|
||
|
11 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
9 years ago
|
CORRADE_COMPARE(image.size(), Vector2i{4});
|
||
|
|
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()).suffix(CompressedPixelStorageData[testCaseInstanceId()].offset),
|
||
|
|
CompressedPixelStorageData[testCaseInstanceId()].data,
|
||
|
|
TestSuite::Compare::Container);
|
||
|
|
#endif
|
||
|
11 years ago
|
}
|
||
|
8 years ago
|
#endif
|
||
|
13 years ago
|
|
||
|
11 years ago
|
namespace {
|
||
|
11 years ago
|
/* Just 12x12 zeros compressed using RGBA DXT3 by the driver */
|
||
|
9 years ago
|
constexpr UnsignedByte CompressedZero[9*16]{};
|
||
|
11 years ago
|
|
||
|
8 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
11 years ago
|
/* Combination of CompressedZero and CompressedData */
|
||
|
9 years ago
|
constexpr UnsignedByte CompressedSubDataComplete[]{
|
||
|
11 years ago
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||
|
|
|
||
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||
|
|
0, 17, 17, 34, 34, 51, 51, 67,
|
||
|
|
232, 57, 0, 0, 213, 255, 170, 2,
|
||
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||
|
|
|
||
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||
|
|
0, 0, 0, 0, 0, 0, 0, 0
|
||
|
|
};
|
||
|
8 years ago
|
#endif
|
||
|
11 years ago
|
}
|
||
|
|
|
||
|
11 years ago
|
void CubeMapTextureGLTest::compressedSubImage() {
|
||
|
9 years ago
|
setTestCaseDescription(CompressedPixelStorageData[testCaseInstanceId()].name);
|
||
|
|
|
||
|
11 years ago
|
#ifndef MAGNUM_TARGET_WEBGL
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::EXT::texture_compression_s3tc>())
|
||
|
11 years ago
|
CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported."));
|
||
|
|
#else
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::WEBGL::compressed_texture_s3tc>())
|
||
|
11 years ago
|
CORRADE_SKIP(Extensions::GL::WEBGL::compressed_texture_s3tc::string() + std::string(" is not supported."));
|
||
|
|
#endif
|
||
|
|
|
||
|
10 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
9 years ago
|
if(CompressedPixelStorageData[testCaseInstanceId()].storage != CompressedPixelStorage{} && !Context::current().isExtensionSupported<Extensions::GL::ARB::compressed_texture_pixel_storage>())
|
||
|
|
CORRADE_SKIP(Extensions::GL::ARB::compressed_texture_pixel_storage::string() + std::string(" is not supported."));
|
||
|
10 years ago
|
#endif
|
||
|
|
|
||
|
11 years ago
|
CubeMapTexture texture;
|
||
|
10 years ago
|
texture.setCompressedImage(CubeMapCoordinate::PositiveX, 0,
|
||
|
11 years ago
|
CompressedImageView2D{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{12}, CompressedZero});
|
||
|
10 years ago
|
texture.setCompressedImage(CubeMapCoordinate::NegativeX, 0,
|
||
|
11 years ago
|
CompressedImageView2D{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{12}, CompressedZero});
|
||
|
10 years ago
|
texture.setCompressedImage(CubeMapCoordinate::PositiveY, 0,
|
||
|
11 years ago
|
CompressedImageView2D{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{12}, CompressedZero});
|
||
|
10 years ago
|
texture.setCompressedImage(CubeMapCoordinate::NegativeY, 0,
|
||
|
11 years ago
|
CompressedImageView2D{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{12}, CompressedZero});
|
||
|
10 years ago
|
texture.setCompressedImage(CubeMapCoordinate::PositiveZ, 0,
|
||
|
11 years ago
|
CompressedImageView2D{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{12}, CompressedZero});
|
||
|
10 years ago
|
texture.setCompressedImage(CubeMapCoordinate::NegativeZ, 0,
|
||
|
11 years ago
|
CompressedImageView2D{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{12}, CompressedZero});
|
||
|
10 years ago
|
texture.setCompressedSubImage(CubeMapCoordinate::PositiveX, 0, Vector2i{4}, CompressedImageView2D{
|
||
|
11 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
9 years ago
|
CompressedPixelStorageData[testCaseInstanceId()].storage,
|
||
|
11 years ago
|
#endif
|
||
|
9 years ago
|
CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{4},
|
||
|
|
CompressedPixelStorageData[testCaseInstanceId()].dataSparse});
|
||
|
11 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
10 years ago
|
CompressedImage2D image = texture.compressedImage(CubeMapCoordinate::PositiveX, 0, {});
|
||
|
11 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
|
CORRADE_COMPARE(image.size(), Vector2i{12});
|
||
|
10 years ago
|
|
||
|
|
{
|
||
|
9 years ago
|
CORRADE_EXPECT_FAIL_IF(CompressedPixelStorageData[testCaseInstanceId()].storage != CompressedPixelStorage{} && Context::current().isExtensionSupported<Extensions::GL::ARB::direct_state_access>() && (Context::current().detectedDriver() & Context::DetectedDriver::NVidia),
|
||
|
10 years ago
|
"Non-default compressed pixel storage for cube map textures behaves weirdly on NVidia for client-memory images when using ARB_direct_state_access");
|
||
|
10 years ago
|
|
||
|
9 years ago
|
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()),
|
||
|
|
Containers::arrayView(CompressedSubDataComplete),
|
||
|
|
TestSuite::Compare::Container);
|
||
|
10 years ago
|
}
|
||
|
11 years ago
|
#endif
|
||
|
|
}
|
||
|
|
|
||
|
13 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
11 years ago
|
void CubeMapTextureGLTest::compressedSubImageBuffer() {
|
||
|
9 years ago
|
setTestCaseDescription(CompressedPixelStorageData[testCaseInstanceId()].name);
|
||
|
|
|
||
|
11 years ago
|
#ifndef MAGNUM_TARGET_WEBGL
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::EXT::texture_compression_s3tc>())
|
||
|
11 years ago
|
CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported."));
|
||
|
|
#else
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::WEBGL::compressed_texture_s3tc>())
|
||
|
11 years ago
|
CORRADE_SKIP(Extensions::GL::WEBGL::compressed_texture_s3tc::string() + std::string(" is not supported."));
|
||
|
|
#endif
|
||
|
|
|
||
|
9 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
if(CompressedPixelStorageData[testCaseInstanceId()].storage != CompressedPixelStorage{} && !Context::current().isExtensionSupported<Extensions::GL::ARB::compressed_texture_pixel_storage>())
|
||
|
|
CORRADE_SKIP(Extensions::GL::ARB::compressed_texture_pixel_storage::string() + std::string(" is not supported."));
|
||
|
|
#endif
|
||
|
|
|
||
|
11 years ago
|
CubeMapTexture texture;
|
||
|
10 years ago
|
texture.setCompressedImage(CubeMapCoordinate::PositiveX, 0,
|
||
|
11 years ago
|
CompressedImageView2D{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{12}, CompressedZero});
|
||
|
10 years ago
|
texture.setCompressedImage(CubeMapCoordinate::NegativeX, 0,
|
||
|
11 years ago
|
CompressedImageView2D{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{12}, CompressedZero});
|
||
|
10 years ago
|
texture.setCompressedImage(CubeMapCoordinate::PositiveY, 0,
|
||
|
11 years ago
|
CompressedImageView2D{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{12}, CompressedZero});
|
||
|
10 years ago
|
texture.setCompressedImage(CubeMapCoordinate::NegativeY, 0,
|
||
|
11 years ago
|
CompressedImageView2D{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{12}, CompressedZero});
|
||
|
10 years ago
|
texture.setCompressedImage(CubeMapCoordinate::PositiveZ, 0,
|
||
|
11 years ago
|
CompressedImageView2D{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{12}, CompressedZero});
|
||
|
10 years ago
|
texture.setCompressedImage(CubeMapCoordinate::NegativeZ, 0,
|
||
|
11 years ago
|
CompressedImageView2D{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{12}, CompressedZero});
|
||
|
10 years ago
|
texture.setCompressedSubImage(CubeMapCoordinate::PositiveX, 0, Vector2i{4}, CompressedBufferImage2D{
|
||
|
11 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
9 years ago
|
CompressedPixelStorageData[testCaseInstanceId()].storage,
|
||
|
11 years ago
|
#endif
|
||
|
9 years ago
|
CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{4},
|
||
|
|
CompressedPixelStorageData[testCaseInstanceId()].dataSparse,
|
||
|
|
BufferUsage::StaticDraw});
|
||
|
11 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
10 years ago
|
CompressedBufferImage2D image = texture.compressedImage(CubeMapCoordinate::PositiveX, 0,
|
||
|
11 years ago
|
{}, BufferUsage::StaticRead);
|
||
|
9 years ago
|
const auto imageData = image.buffer().data();
|
||
|
11 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
|
CORRADE_COMPARE(image.size(), Vector2i{12});
|
||
|
9 years ago
|
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(imageData),
|
||
|
|
Containers::arrayView(CompressedSubDataComplete),
|
||
|
9 years ago
|
TestSuite::Compare::Container);
|
||
|
11 years ago
|
#endif
|
||
|
|
}
|
||
|
13 years ago
|
#endif
|
||
|
|
|
||
|
11 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
9 years ago
|
void CubeMapTextureGLTest::compressedSubImageQuery() {
|
||
|
|
setTestCaseDescription(CompressedPixelStorageData[testCaseInstanceId()].name);
|
||
|
|
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::get_texture_sub_image>())
|
||
|
11 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::get_texture_sub_image::string() + std::string(" is not supported."));
|
||
|
|
/* I'm too lazy to call setSubImage() six times */
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::direct_state_access>())
|
||
|
11 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::direct_state_access::string() + std::string(" is not supported."));
|
||
|
9 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::EXT::texture_compression_s3tc>())
|
||
|
|
CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported."));
|
||
|
|
if(CompressedPixelStorageData[testCaseInstanceId()].storage != CompressedPixelStorage{} && !Context::current().isExtensionSupported<Extensions::GL::ARB::compressed_texture_pixel_storage>())
|
||
|
|
CORRADE_SKIP(Extensions::GL::ARB::compressed_texture_pixel_storage::string() + std::string(" is not supported."));
|
||
|
9 years ago
|
if(CompressedPixelStorageData[testCaseInstanceId()].storage == CompressedPixelStorage{} && !Context::current().isExtensionSupported<Extensions::GL::ARB::internalformat_query2>())
|
||
|
|
CORRADE_SKIP(Extensions::GL::ARB::internalformat_query2::string() + std::string(" is not supported."));
|
||
|
11 years ago
|
|
||
|
|
CubeMapTexture texture;
|
||
|
9 years ago
|
texture.setStorage(1, TextureFormat::CompressedRGBAS3tcDxt3, Vector2i{12})
|
||
|
|
.setCompressedSubImage(0, {}, CompressedImageView3D{CompressedPixelFormat::RGBAS3tcDxt3, {12, 12, 1}, CompressedSubDataComplete});
|
||
|
11 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
9 years ago
|
CompressedImage3D image = texture.compressedSubImage(0, Range3Di::fromSize({4, 4, 0}, {4, 4, 1}), {CompressedPixelStorageData[testCaseInstanceId()].storage});
|
||
|
11 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
9 years ago
|
CORRADE_COMPARE(image.size(), (Vector3i{4, 4, 1}));
|
||
|
|
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()).suffix(CompressedPixelStorageData[testCaseInstanceId()].offset),
|
||
|
|
CompressedPixelStorageData[testCaseInstanceId()].data,
|
||
|
|
TestSuite::Compare::Container);
|
||
|
11 years ago
|
}
|
||
|
|
|
||
|
9 years ago
|
void CubeMapTextureGLTest::compressedSubImageQueryBuffer() {
|
||
|
|
setTestCaseDescription(CompressedPixelStorageData[testCaseInstanceId()].name);
|
||
|
|
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::get_texture_sub_image>())
|
||
|
11 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::get_texture_sub_image::string() + std::string(" is not supported."));
|
||
|
|
/* I'm too lazy to call setSubImage() six times */
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::direct_state_access>())
|
||
|
11 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::direct_state_access::string() + std::string(" is not supported."));
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::EXT::texture_compression_s3tc>())
|
||
|
11 years ago
|
CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported."));
|
||
|
9 years ago
|
if(CompressedPixelStorageData[testCaseInstanceId()].storage != CompressedPixelStorage{} && !Context::current().isExtensionSupported<Extensions::GL::ARB::compressed_texture_pixel_storage>())
|
||
|
|
CORRADE_SKIP(Extensions::GL::ARB::compressed_texture_pixel_storage::string() + std::string(" is not supported."));
|
||
|
9 years ago
|
if(CompressedPixelStorageData[testCaseInstanceId()].storage == CompressedPixelStorage{} && !Context::current().isExtensionSupported<Extensions::GL::ARB::internalformat_query2>())
|
||
|
|
CORRADE_SKIP(Extensions::GL::ARB::internalformat_query2::string() + std::string(" is not supported."));
|
||
|
11 years ago
|
|
||
|
|
CubeMapTexture texture;
|
||
|
|
texture.setStorage(1, TextureFormat::CompressedRGBAS3tcDxt3, Vector2i{12})
|
||
|
9 years ago
|
.setCompressedSubImage(0, {}, CompressedImageView3D{CompressedPixelFormat::RGBAS3tcDxt3, {12, 12, 1}, CompressedSubDataComplete});
|
||
|
11 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
9 years ago
|
CompressedBufferImage3D image = texture.compressedSubImage(0, Range3Di::fromSize({4, 4, 0}, {4, 4, 1}), {CompressedPixelStorageData[testCaseInstanceId()].storage}, BufferUsage::StaticRead);
|
||
|
9 years ago
|
const auto imageData = image.buffer().data();
|
||
|
11 years ago
|
|
||
|
9 years ago
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
11 years ago
|
|
||
|
9 years ago
|
CORRADE_COMPARE(image.size(), (Vector3i{4, 4, 1}));
|
||
|
9 years ago
|
CORRADE_COMPARE_AS(
|
||
|
|
Containers::arrayCast<UnsignedByte>(imageData).suffix(CompressedPixelStorageData[testCaseInstanceId()].offset),
|
||
|
9 years ago
|
CompressedPixelStorageData[testCaseInstanceId()].data,
|
||
|
|
TestSuite::Compare::Container);
|
||
|
|
}
|
||
|
|
#endif
|
||
|
11 years ago
|
|
||
|
9 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
void CubeMapTextureGLTest::fullImageQuery() {
|
||
|
|
setTestCaseDescription(FullPixelStorageData[testCaseInstanceId()].name);
|
||
|
|
|
||
|
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::direct_state_access>())
|
||
|
|
CORRADE_SKIP(Extensions::GL::ARB::direct_state_access::string() + std::string(" is not supported."));
|
||
|
|
|
||
|
|
CubeMapTexture texture;
|
||
|
|
texture.setStorage(1, TextureFormat::RGBA8, Vector2i{2, 2})
|
||
|
|
.setSubImage(0, {}, ImageView3D{
|
||
|
|
PixelFormat::RGBA, PixelType::UnsignedByte, {2, 2, 6},
|
||
|
|
FullPixelStorageData[testCaseInstanceId()].data});
|
||
|
11 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
9 years ago
|
Image3D image = texture.image(0,
|
||
|
|
{FullPixelStorageData[testCaseInstanceId()].storage, PixelFormat::RGBA, PixelType::UnsignedByte});
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
|
CORRADE_COMPARE(image.size(), Vector3i(2, 2, 6));
|
||
|
|
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()).suffix(FullPixelStorageData[testCaseInstanceId()].offset),
|
||
|
|
FullPixelStorageData[testCaseInstanceId()].data,
|
||
|
|
TestSuite::Compare::Container);
|
||
|
11 years ago
|
}
|
||
|
|
|
||
|
9 years ago
|
void CubeMapTextureGLTest::fullImageQueryBuffer() {
|
||
|
|
setTestCaseDescription(FullPixelStorageData[testCaseInstanceId()].name);
|
||
|
|
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::direct_state_access>())
|
||
|
11 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::direct_state_access::string() + std::string(" is not supported."));
|
||
|
|
|
||
|
|
CubeMapTexture texture;
|
||
|
9 years ago
|
texture.setStorage(1, TextureFormat::RGBA8, Vector2i{2})
|
||
|
|
.setSubImage(0, {}, BufferImage3D{
|
||
|
|
PixelFormat::RGBA, PixelType::UnsignedByte, {2, 2, 6},
|
||
|
|
FullPixelStorageData[testCaseInstanceId()].data,
|
||
|
|
BufferUsage::StaticDraw});
|
||
|
11 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
9 years ago
|
BufferImage3D image = texture.image(0,
|
||
|
|
{FullPixelStorageData[testCaseInstanceId()].storage, PixelFormat::RGBA,
|
||
|
|
PixelType::UnsignedByte}, BufferUsage::StaticRead);
|
||
|
11 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
9 years ago
|
CORRADE_COMPARE(image.size(), Vector3i(2, 2, 6));
|
||
|
9 years ago
|
const auto imageData = image.buffer().data();
|
||
|
|
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(imageData).suffix(FullPixelStorageData[testCaseInstanceId()].offset),
|
||
|
9 years ago
|
FullPixelStorageData[testCaseInstanceId()].data, TestSuite::Compare::Container);
|
||
|
11 years ago
|
}
|
||
|
11 years ago
|
|
||
|
9 years ago
|
void CubeMapTextureGLTest::compressedFullImageQuery() {
|
||
|
|
setTestCaseDescription(CompressedFullPixelStorageData[testCaseInstanceId()].name);
|
||
|
|
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::direct_state_access>())
|
||
|
11 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::direct_state_access::string() + std::string(" is not supported."));
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::EXT::texture_compression_s3tc>())
|
||
|
11 years ago
|
CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported."));
|
||
|
9 years ago
|
if(CompressedPixelStorageData[testCaseInstanceId()].storage != CompressedPixelStorage{} && !Context::current().isExtensionSupported<Extensions::GL::ARB::compressed_texture_pixel_storage>())
|
||
|
|
CORRADE_SKIP(Extensions::GL::ARB::compressed_texture_pixel_storage::string() + std::string(" is not supported."));
|
||
|
11 years ago
|
|
||
|
|
CubeMapTexture texture;
|
||
|
9 years ago
|
texture.setStorage(1, TextureFormat::CompressedRGBAS3tcDxt3, Vector2i{4})
|
||
|
|
.setCompressedSubImage(0, {}, CompressedImageView3D{
|
||
|
|
CompressedPixelFormat::RGBAS3tcDxt3, {4, 4, 6},
|
||
|
|
CompressedFullPixelStorageData[testCaseInstanceId()].data});
|
||
|
11 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
9 years ago
|
CompressedImage3D image = texture.compressedImage(0, {CompressedFullPixelStorageData[testCaseInstanceId()].storage});
|
||
|
11 years ago
|
|
||
|
9 years ago
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
11 years ago
|
|
||
|
9 years ago
|
CORRADE_COMPARE(image.size(), (Vector3i{4, 4, 6}));
|
||
|
|
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()).suffix(CompressedFullPixelStorageData[testCaseInstanceId()].offset),
|
||
|
|
CompressedFullPixelStorageData[testCaseInstanceId()].data,
|
||
|
|
TestSuite::Compare::Container);
|
||
|
|
}
|
||
|
11 years ago
|
|
||
|
9 years ago
|
void CubeMapTextureGLTest::compressedFullImageQueryBuffer() {
|
||
|
|
setTestCaseDescription(CompressedFullPixelStorageData[testCaseInstanceId()].name);
|
||
|
|
|
||
|
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::direct_state_access>())
|
||
|
|
CORRADE_SKIP(Extensions::GL::ARB::direct_state_access::string() + std::string(" is not supported."));
|
||
|
|
if(!Context::current().isExtensionSupported<Extensions::GL::EXT::texture_compression_s3tc>())
|
||
|
|
CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported."));
|
||
|
|
if(CompressedPixelStorageData[testCaseInstanceId()].storage != CompressedPixelStorage{} && !Context::current().isExtensionSupported<Extensions::GL::ARB::compressed_texture_pixel_storage>())
|
||
|
|
CORRADE_SKIP(Extensions::GL::ARB::compressed_texture_pixel_storage::string() + std::string(" is not supported."));
|
||
|
|
|
||
|
|
CubeMapTexture texture;
|
||
|
|
texture.setStorage(1, TextureFormat::CompressedRGBAS3tcDxt3, Vector2i{4})
|
||
|
|
.setCompressedSubImage(0, {}, CompressedBufferImage3D{
|
||
|
|
CompressedPixelFormat::RGBAS3tcDxt3, {4, 4, 6},
|
||
|
|
CompressedFullPixelStorageData[testCaseInstanceId()].data,
|
||
|
|
BufferUsage::StaticDraw});
|
||
|
11 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
9 years ago
|
CompressedBufferImage3D image = texture.compressedImage(0, {CompressedFullPixelStorageData[testCaseInstanceId()].storage}, BufferUsage::StaticRead);
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
|
CORRADE_COMPARE(image.size(), (Vector3i{4, 4, 6}));
|
||
|
9 years ago
|
const auto imageData = image.buffer().data();
|
||
|
|
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(imageData).suffix(CompressedFullPixelStorageData[testCaseInstanceId()].offset),
|
||
|
9 years ago
|
CompressedFullPixelStorageData[testCaseInstanceId()].data,
|
||
|
|
TestSuite::Compare::Container);
|
||
|
11 years ago
|
}
|
||
|
11 years ago
|
#endif
|
||
|
|
|
||
|
13 years ago
|
void CubeMapTextureGLTest::generateMipmap() {
|
||
|
8 years ago
|
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
|
||
|
|
constexpr TextureFormat format = TextureFormat::RGBA8;
|
||
|
|
#else
|
||
|
|
constexpr TextureFormat format = TextureFormat::RGBA;
|
||
|
|
#endif
|
||
|
|
|
||
|
13 years ago
|
CubeMapTexture texture;
|
||
|
8 years ago
|
texture.setImage(CubeMapCoordinate::PositiveX, 0, format,
|
||
|
11 years ago
|
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(32)));
|
||
|
8 years ago
|
texture.setImage(CubeMapCoordinate::PositiveY, 0, format,
|
||
|
11 years ago
|
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(32)));
|
||
|
8 years ago
|
texture.setImage(CubeMapCoordinate::PositiveZ, 0, format,
|
||
|
11 years ago
|
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(32)));
|
||
|
8 years ago
|
texture.setImage(CubeMapCoordinate::NegativeX, 0, format,
|
||
|
11 years ago
|
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(32)));
|
||
|
8 years ago
|
texture.setImage(CubeMapCoordinate::NegativeY, 0, format,
|
||
|
11 years ago
|
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(32)));
|
||
|
8 years ago
|
texture.setImage(CubeMapCoordinate::NegativeZ, 0, format,
|
||
|
11 years ago
|
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(32)));
|
||
|
13 years ago
|
|
||
|
|
/** @todo How to test this on ES? */
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
12 years ago
|
CORRADE_COMPARE(texture.imageSize(0), Vector2i(32));
|
||
|
|
CORRADE_COMPARE(texture.imageSize(1), Vector2i( 0));
|
||
|
13 years ago
|
#endif
|
||
|
|
|
||
|
|
texture.generateMipmap();
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
|
/** @todo How to test this on ES? */
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
12 years ago
|
CORRADE_COMPARE(texture.imageSize(0), Vector2i(32));
|
||
|
|
CORRADE_COMPARE(texture.imageSize(1), Vector2i(16));
|
||
|
|
CORRADE_COMPARE(texture.imageSize(2), Vector2i( 8));
|
||
|
|
CORRADE_COMPARE(texture.imageSize(3), Vector2i( 4));
|
||
|
|
CORRADE_COMPARE(texture.imageSize(4), Vector2i( 2));
|
||
|
|
CORRADE_COMPARE(texture.imageSize(5), Vector2i( 1));
|
||
|
13 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
#endif
|
||
|
|
}
|
||
|
|
|
||
|
|
void CubeMapTextureGLTest::invalidateImage() {
|
||
|
|
CubeMapTexture texture;
|
||
|
8 years ago
|
texture.setStorage(2,
|
||
|
|
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
|
||
|
|
TextureFormat::RGBA8,
|
||
|
|
#else
|
||
|
|
TextureFormat::RGBA,
|
||
|
|
#endif
|
||
|
|
Vector2i(32));
|
||
|
13 years ago
|
texture.invalidateImage(1);
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
}
|
||
|
|
|
||
|
|
void CubeMapTextureGLTest::invalidateSubImage() {
|
||
|
|
CubeMapTexture texture;
|
||
|
8 years ago
|
texture.setStorage(2,
|
||
|
|
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
|
||
|
|
TextureFormat::RGBA8,
|
||
|
|
#else
|
||
|
|
TextureFormat::RGBA,
|
||
|
|
#endif
|
||
|
|
Vector2i(32));
|
||
|
12 years ago
|
texture.invalidateSubImage(1, Vector3i(2), Vector3i(Vector2i(8), 4));
|
||
|
13 years ago
|
|
||
|
9 years ago
|
{
|
||
|
8 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
/* Mesa (last checked version 18.0.0) treats cube map images as having
|
||
|
9 years ago
|
only single layer instead of 6, so the above invalidation call
|
||
|
|
fails. Relevant source code (scroll up to see imageDepth = 1):
|
||
|
8 years ago
|
https://github.com/mesa3d/mesa/blob/051fddb4a9e6abb6f2cf9c892e34c8739983c794/src/mesa/main/texobj.c#L2293 */
|
||
|
9 years ago
|
CORRADE_EXPECT_FAIL_IF((Context::current().detectedDriver() & Context::DetectedDriver::Mesa),
|
||
|
|
"Broken on Mesa.");
|
||
|
8 years ago
|
#endif
|
||
|
9 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
}
|
||
|
13 years ago
|
}
|
||
|
|
|
||
|
|
}}
|
||
|
|
|
||
|
9 years ago
|
CORRADE_TEST_MAIN(Magnum::Test::CubeMapTextureGLTest)
|