blob: aea6a012c65994f112325733a7f03c9184d53a52 [file] [log] [blame]
/*-------------------------------------------------------------------------
* OpenGL Conformance Test Suite
* -----------------------------
*
* Copyright (c) 2018 The Khronos Group Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/ /*!
* \file es3cCopyTexImageConversionsTests.cpp
* \brief Tests verifying glCopyTexImage2D..
*/ /*-------------------------------------------------------------------*/
#include "es3cCopyTexImageConversionsTests.hpp"
#include "deMath.h"
#include "deSharedPtr.hpp"
#include "gluContextInfo.hpp"
#include "gluDefs.hpp"
#include "gluStrUtil.hpp"
#include "glwEnums.hpp"
#include "glwFunctions.hpp"
#include "tcuStringTemplate.hpp"
#include "tcuTestLog.hpp"
#include <cstring>
#include <limits>
#include <map>
using namespace glw;
namespace es3cts
{
// Amount of entries database should allocate for its entries upon creation.
#define N_START_CONVERSION_DATABASE_ENTRIES (32)
// Should 3D textures be used as source attachments, this field defines
// their depth. It MUST be at least 2, because the test implementation
// also uses second array (counted from one) to store the data-set information.
#define TEXTURE_DEPTH (2)
// Data set height
#define TEXTURE_HEIGHT (2)
// Data set width
#define TEXTURE_WIDTH (2)
// Defines for non color-renderable textures support
#define NUMBER_OF_ELEMENTS_IN_VEC4 (4)
#define NUMBER_OF_POINTS_TO_DRAW (TEXTURE_WIDTH * TEXTURE_HEIGHT)
#define TEXTURE_COORDINATES_ARRAY_SIZE (TEXTURE_WIDTH * TEXTURE_HEIGHT * NUMBER_OF_ELEMENTS_IN_VEC4 * sizeof(float))
#define TEXTURE_2D_SAMPLER_TYPE (0)
#define TEXTURE_3D_SAMPLER_TYPE (1)
#define TEXTURE_2D_ARRAY_SAMPLER_TYPE (2)
#define TEXTURE_CUBE_SAMPLER_TYPE (3)
#define SRC_TEXTURE_COORDS_ATTRIB_INDEX (1)
#define DST_TEXTURE_COORDS_ATTRIB_INDEX (0)
// Buffer object indices used for non color-renderable textures support.
#define COMPARISON_RESULT_BUFFER_OBJECT_INDEX (0)
#define SOURCE_TEXTURE_PIXELS_BUFFER_OBJECT_INDEX (1)
#define DESTINATION_TEXTURE_PIXELS_BUFFER_OBJECT_INDEX (2)
// Stores detailed information about:
// 1) what FBO effective internalformats can be used for glCopyTexImage2D(), assuming
// specific result texture's internalformat as passed by one of the arguments.
// 2) what internalformat the result texture object should use.
const GLenum conversionArray[] = {
/* GL_RGBA GL_RGB GL_LUMINANCE_ALPHA GL_LUMINANCE GL_ALPHA GL_R8 GL_R8_SNORM GL_RG8 GL_RG8_SNORM GL_RGB8 GL_RGB8_SNORM GL_RGB565 GL_RGBA4 GL_RGB5_A1 GL_RGBA8 GL_RGBA8_SNORM GL_RGB10_A2 GL_RGB10_A2UI GL_SRGB8 GL_SRGB8_ALPHA8 GL_R16F GL_RG16F GL_RGB16F GL_RGBA16F GL_R32F GL_RG32F GL_RGB32F GL_RGBA32F GL_R11F_G11F_B10F GL_RGB9_E5 GL_R8I GL_R8UI GL_R16I GL_R16UI GL_R32I GL_R32UI GL_RG8I GL_RG8UI GL_RG16I GL_RG16UI GL_RG32I GL_RG32UI GL_RGB8I GL_RGB8UI GL_RGB16I GL_RGB16UI GL_RGB32I GL_RGB32UI GL_RGBA8I GL_RGBA8UI GL_RGBA16I GL_RGBA16UI GL_RGBA32I GL_RGBA32UI */
/* GL_R8, */ GL_NONE, GL_NONE, GL_NONE, GL_LUMINANCE8_OES, GL_NONE, GL_R8, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE,
/* GL_RG8, */ GL_NONE, GL_NONE, GL_NONE, GL_LUMINANCE8_OES, GL_NONE, GL_R8, GL_NONE, GL_RG8, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE,
/* GL_RGB8, */ GL_NONE, GL_RGB8, GL_NONE, GL_LUMINANCE8_OES, GL_NONE, GL_R8, GL_NONE, GL_RG8, GL_NONE, GL_RGB8, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE,
/* GL_RGB565, */ GL_NONE, GL_RGB565, GL_NONE, GL_LUMINANCE8_OES, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_RGB565, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE,
/* GL_RGBA4, */ GL_RGBA4, GL_RGB565, GL_LUMINANCE8_ALPHA8_OES, GL_LUMINANCE8_OES, GL_ALPHA8_OES, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_RGBA4, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE,
/* GL_RGB5_A1, */ GL_RGB5_A1, GL_RGB565, GL_LUMINANCE8_ALPHA8_OES, GL_LUMINANCE8_OES, GL_ALPHA8_OES, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_RGB5_A1, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE,
/* GL_RGBA8, */ GL_RGBA8, GL_RGB8, GL_LUMINANCE8_ALPHA8_OES, GL_LUMINANCE8_OES, GL_ALPHA8_OES, GL_R8, GL_NONE, GL_RG8, GL_NONE, GL_RGB8, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_RGBA8, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE,
/* GL_RGB10_A2, */ GL_NONE, GL_RGB8, GL_NONE, GL_LUMINANCE8_OES, GL_ALPHA8_OES, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_RGB10_A2, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE,
/* GL_RGB10_A2UI, */ GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_RGB10_A2UI, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE,
/* GL_SRGB8_ALPHA8, */ GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_SRGB8, GL_SRGB8_ALPHA8, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE,
/* GL_R8I, */ GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_R8I, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE,
/* GL_R8UI, */ GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_R8UI, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE,
/* GL_R16I, */ GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_R16I, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE,
/* GL_R16UI, */ GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_R16UI, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE,
/* GL_R32I, */ GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_R32I, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE,
/* GL_R32UI, */ GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_R32UI, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE,
/* GL_RG8I, */ GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_R8I, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_RG8I, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE,
/* GL_RG8UI, */ GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_R8UI, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_RG8UI, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE,
/* GL_RG16I, */ GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_R16I, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_RG16I, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE,
/* GL_RG16UI, */ GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_R16UI, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_RG16UI, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE,
/* GL_RG32I, */ GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_R32I, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_RG32I, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE,
/* GL_RG32UI, */ GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_R32UI, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_RG32UI, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE,
/* GL_RGBA8I, */ GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_R8I, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_RG8I, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_RGB8I, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_RGBA8I, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE,
/* GL_RGBA8UI, */ GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_R8UI, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_RG8UI, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_RGB8UI, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_RGBA8UI, GL_NONE, GL_NONE, GL_NONE, GL_NONE,
/* GL_RGBA16I, */ GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_R16I, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_RG16I, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_RGB16I, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_RGBA16I, GL_NONE, GL_NONE, GL_NONE,
/* GL_RGBA16UI, */ GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_R16UI, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_RG16UI, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_RGB16UI, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_RGBA16UI, GL_NONE, GL_NONE,
/* GL_RGBA32I, */ GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_R32I, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_RG32I, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_RGB32I, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_RGBA32I, GL_NONE,
/* GL_RGBA32UI, */ GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_R32UI, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_RG32UI, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_RGB32UI, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_RGBA32UI,
/* GL_R16F, */ GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_R16F, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE,
/* GL_RG16F, */ GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_R16F, GL_RG16F, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE,
/* GL_R32F, */ GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_R32F, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE,
/* GL_RG32F, */ GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_R32F, GL_RG32F, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE,
/* GL_RGB16F, */ GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_R16F, GL_RG16F, GL_RGB16F, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE,
/* GL_RGBA16F, */ GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_R16F, GL_RG16F, GL_RGB16F, GL_RGBA16F, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE,
/* GL_RGB32F, */ GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_R32F, GL_RG32F, GL_RGB32F, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE,
/* GL_RGBA32F, */ GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_R32F, GL_RG32F, GL_RGB32F, GL_RGBA32F, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE,
};
// Tells:
// 1) how many rows conversion_array uses.
// 2) what destination internalformat (NOT effective internalformat!)
// corresponds to each entry.
// NOTE: If you need to modify this array, make sure conversion-array
// is updated accordingly!
const GLenum copyTexImage2DInternalFormatOrdering[] = { GL_RGBA,
GL_RGB,
GL_LUMINANCE_ALPHA,
GL_LUMINANCE,
GL_ALPHA,
GL_R8,
GL_R8_SNORM,
GL_RG8,
GL_RG8_SNORM,
GL_RGB8,
GL_RGB8_SNORM,
GL_RGB565,
GL_RGBA4,
GL_RGB5_A1,
GL_RGBA8,
GL_RGBA8_SNORM,
GL_RGB10_A2,
GL_RGB10_A2UI,
GL_SRGB8,
GL_SRGB8_ALPHA8,
GL_R16F,
GL_RG16F,
GL_RGB16F,
GL_RGBA16F,
GL_R32F,
GL_RG32F,
GL_RGB32F,
GL_RGBA32F,
GL_R11F_G11F_B10F,
GL_RGB9_E5,
GL_R8I,
GL_R8UI,
GL_R16I,
GL_R16UI,
GL_R32I,
GL_R32UI,
GL_RG8I,
GL_RG8UI,
GL_RG16I,
GL_RG16UI,
GL_RG32I,
GL_RG32UI,
GL_RGB8I,
GL_RGB8UI,
GL_RGB16I,
GL_RGB16UI,
GL_RGB32I,
GL_RGB32UI,
GL_RGBA8I,
GL_RGBA8UI,
GL_RGBA16I,
GL_RGBA16UI,
GL_RGBA32I,
GL_RGBA32UI };
// Ordering as per Bug 9807 table for FBO effective internalformats
const GLenum fboEffectiveInternalFormatOrdering[] = {
GL_R8, GL_RG8, GL_RGB8, GL_RGB565, GL_RGBA4, GL_RGB5_A1, GL_RGBA8, GL_RGB10_A2, GL_RGB10_A2UI,
GL_SRGB8_ALPHA8, GL_R8I, GL_R8UI, GL_R16I, GL_R16UI, GL_R32I, GL_R32UI, GL_RG8I, GL_RG8UI,
GL_RG16I, GL_RG16UI, GL_RG32I, GL_RG32UI, GL_RGBA8I, GL_RGBA8UI, GL_RGBA16I, GL_RGBA16UI, GL_RGBA32I,
GL_RGBA32UI, GL_R16F, GL_RG16F, GL_R32F, GL_RG32F, GL_RGB16F, GL_RGBA16F, GL_RGB32F, GL_RGBA32F,
};
// Tells how channels are ordered for a particular pixel.
enum ChannelOrder
{
CHANNEL_ORDER_ABGR,
CHANNEL_ORDER_BGR,
CHANNEL_ORDER_BGRA,
CHANNEL_ORDER_R,
CHANNEL_ORDER_RG,
CHANNEL_ORDER_RGB,
CHANNEL_ORDER_RGBA,
CHANNEL_ORDER_UNKNOWN
};
// Tells how many bits and what type is used for data representation
// for a single pixel channel.
enum ChannelDataType
{
CHANNEL_DATA_TYPE_NONE = 0,
CHANNEL_DATA_TYPE_SIGNED_BYTE_8BITS,
CHANNEL_DATA_TYPE_SIGNED_INTEGER_32BITS,
CHANNEL_DATA_TYPE_SIGNED_SHORT_16BITS,
CHANNEL_DATA_TYPE_UNSIGNED_BYTE_1BIT,
CHANNEL_DATA_TYPE_UNSIGNED_BYTE_2BITS,
CHANNEL_DATA_TYPE_UNSIGNED_BYTE_4BITS,
CHANNEL_DATA_TYPE_UNSIGNED_BYTE_5BITS,
CHANNEL_DATA_TYPE_UNSIGNED_BYTE_6BITS,
CHANNEL_DATA_TYPE_UNSIGNED_BYTE_8BITS,
CHANNEL_DATA_TYPE_UNSIGNED_INTEGER_32BITS,
CHANNEL_DATA_TYPE_UNSIGNED_SHORT_10BITS,
CHANNEL_DATA_TYPE_UNSIGNED_SHORT_16BITS,
CHANNEL_DATA_TYPE_FLOAT
};
// Structure holding uniform locations and object IDs.
// Those values are used to support non-color-renderable texture internalformat checks.
struct NonRenderableInternalformatSupportObjects
{
GLuint comparison_result_buffer_object_id;
GLuint dst_texture_pixels_buffer_object_id;
GLint dst_2D_texture_uniform_location;
GLint dst_Cube_texture_uniform_location;
GLuint fragment_shader_object_id;
GLuint program_object_id;
GLuint src_texture_pixels_buffer_object_id;
GLint src_2D_texture_uniform_location;
GLint src_2DArray_texture_uniform_location;
GLint src_3D_texture_uniform_location;
GLint src_Cube_texture_uniform_location;
GLuint transform_feedback_object_id;
GLuint vertex_shader_object_id;
GLint channels_to_compare_uniform_location;
GLint samplers_to_use_uniform_location;
GLuint src_texture_coordinates_buffer_object_id;
GLuint dst_texture_coordinates_buffer_object_id;
};
// Structure describing contents of a channel of a single pixel.
struct ChannelData
{
// Union that allows to access the data representation
// in a data_type-friendly manner
union {
signed char signed_byte_data;
signed int signed_integer_data;
signed short signed_short_data;
unsigned char unsigned_byte_data;
unsigned int unsigned_integer_data;
unsigned short unsigned_short_data;
float float_data;
};
// Data type used for channel representation
ChannelDataType data_type;
};
// Structure describing a single pixel.
struct PixelData
{
// Alpha channel data descriptor
ChannelData alpha;
// Blue channel data descriptor
ChannelData blue;
// Green channel data descriptor
ChannelData green;
// Red channel data descriptor
ChannelData red;
// For source pixels: GL internal-format used by all channels.
// For destination pixels: GL format to be used for gl.readPixels()
// operation in order to retrieve result data
// in a matching representation.
GLenum data_internalformat;
// For source pixels: GL type used by all channels.
// For destination pixels: GL type to be used for gl.readPixels()
// operation in order to retrieve result data
// in a matching representation.
GLenum data_type;
};
// To confirm contents of data stored in non-renderable internalformat, a special shader
// is used. This type definition tells which texture() function sampler should be used
// for sampling the texture data.
enum DataSamplerType
{
DATA_SAMPLER_FLOAT,
DATA_SAMPLER_INTEGER,
DATA_SAMPLER_UNSIGNED_INTEGER,
};
// When a special shader is used to check whether the copy succeeded we need to know which
// channels will have to be compared
enum PixelCompareChannel
{
PIXEL_COMPARE_CHANNEL_R = 0x1,
PIXEL_COMPARE_CHANNEL_G = 0x2,
PIXEL_COMPARE_CHANNEL_B = 0x4,
PIXEL_COMPARE_CHANNEL_A = 0x8,
PIXEL_COMPARE_CHANNEL_RG = PIXEL_COMPARE_CHANNEL_R | PIXEL_COMPARE_CHANNEL_G,
PIXEL_COMPARE_CHANNEL_RA = PIXEL_COMPARE_CHANNEL_R | PIXEL_COMPARE_CHANNEL_A,
PIXEL_COMPARE_CHANNEL_RGB = PIXEL_COMPARE_CHANNEL_RG | PIXEL_COMPARE_CHANNEL_B,
PIXEL_COMPARE_CHANNEL_RGBA = PIXEL_COMPARE_CHANNEL_RGB | PIXEL_COMPARE_CHANNEL_A,
};
// Structure describing a single conversion rule.
//
// For more details on meaning of these fields, please refer
// to doxygen of AddEntryToConversionDatabase() and similar.
struct ConversionDatabaseEntry
{
// Reference destination data expected for bottom-left corner
PixelData dst_bottomleft_corner;
// Reference destination data expected for bottom-right corner
PixelData dst_bottomright_corner;
// Reference destination data expected for top-left corner
PixelData dst_topleft_corner;
// Reference destination data expected for top-right corner
PixelData dst_topright_corner;
// Input bottom-left corner data to be used for conversion
PixelData src_bottomleft_corner;
// Input bottom-right corner data to be used for conversion
PixelData src_bottomright_corner;
// Input top-left corner data to be used for conversion
PixelData src_topleft_corner;
// Input top-right corner data to be used for conversion
PixelData src_topright_corner;
// What are the channels that we need to compare if gl.readPixels
// can't be used to read back the data
PixelCompareChannel channels_to_compare;
};
// Structure describing contents of an opaque conversion database handle.
class ConversionDatabase
{
public:
ConversionDatabase();
~ConversionDatabase();
void initializeDatabase();
bool isTypeSupportedByGLReadPixels(GLenum type);
bool isInternalFormatCompatibleWithType(GLenum type, GLenum internalformat);
bool convertNormalizedUnsignedFixedPoint(int* src_input_rgba_bits, int* src_attachment_rgba_bits,
int* dst_attachment_rgba_bits, int* dst_output_rgba_bits, int* src_rgba,
int* dst_rgba);
PixelData getAlpha8OESPixelData(GLenum type, unsigned char alpha);
PixelData getLuminance8OESPixelData(GLenum type, unsigned char luminance);
PixelData getLuminance8Alpha8OESPixelData(GLenum type, unsigned char luminance, unsigned char alpha);
PixelData getR16IPixelData(int is_source_pixel, GLenum type, int red);
PixelData getR16UIPixelData(int is_source_pixel, GLenum type, unsigned int red);
PixelData getR32IPixelData(int is_source_pixel, GLenum type, int red);
PixelData getR32UIPixelData(int is_source_pixel, GLenum type, unsigned int red);
PixelData getR8IPixelData(int is_source_pixel, GLenum type, int red);
PixelData getR8UIPixelData(int is_source_pixel, GLenum type, unsigned int red);
PixelData getR8PixelData(int is_source_pixel, GLenum type, unsigned char red);
PixelData getRG16IPixelData(int is_source_pixel, GLenum type, int red, int green);
PixelData getRG16UIPixelData(int is_source_pixel, GLenum type, unsigned int red, unsigned int green);
PixelData getRG32IPixelData(int is_source_pixel, GLenum type, int red, int green);
PixelData getRG32UIPixelData(int is_source_pixel, GLenum type, unsigned int red, unsigned int green);
PixelData getRG8IPixelData(int is_source_pixel, GLenum type, int red, int green);
PixelData getRG8UIPixelData(int is_source_pixel, GLenum type, unsigned int red, unsigned int green);
PixelData getRG8PixelData(int is_source_pixel, GLenum type, unsigned char red, unsigned char green);
PixelData getRGB10A2PixelData(GLenum type, unsigned short red, unsigned short green, unsigned short blue,
unsigned char alpha);
PixelData getRGB10A2UIPixelData(int is_source_pixel, GLenum type, unsigned int red, unsigned int green,
unsigned int blue, unsigned int alpha);
PixelData getRGB16IPixelData(int is_source_pixel, GLenum type, int red, int green, int blue);
PixelData getRGB16UIPixelData(int is_source_pixel, GLenum type, unsigned int red, unsigned int green,
unsigned int blue);
PixelData getRGB32IPixelData(int is_source_pixel, GLenum type, int red, int green, int blue);
PixelData getRGB32UIPixelData(int is_source_pixel, GLenum type, unsigned int red, unsigned int green,
unsigned int blue);
PixelData getRGB5A1PixelData(int is_source_pixel, GLenum type, unsigned int red, unsigned int green,
unsigned int blue, unsigned int alpha);
PixelData getRGB565PixelData(int is_source_pixel, GLenum type, int red, int green, int blue);
PixelData getRGB8PixelData(int is_source_pixel, GLenum type, unsigned char red, unsigned char green,
unsigned char blue);
PixelData getRGB8IPixelData(int is_source_pixel, GLenum type, int red, int green, int blue);
PixelData getRGB8UIPixelData(int is_source_pixel, GLenum type, unsigned int red, unsigned int green,
unsigned int blue);
PixelData getRGBA16IPixelData(int is_source_pixel, GLenum type, int red, int green, int blue, int alpha);
PixelData getRGBA16UIPixelData(int is_source_pixel, GLenum type, unsigned int red, unsigned int green,
unsigned int blue, unsigned int alpha);
PixelData getRGBA32IPixelData(GLenum type, int red, int green, int blue, int alpha);
PixelData getRGBA32UIPixelData(GLenum type, unsigned int red, unsigned int green, unsigned int blue,
unsigned int alpha);
PixelData getRGBA8IPixelData(int is_source_pixel, GLenum type, int red, int green, int blue, int alpha);
PixelData getRGBA8UIPixelData(int is_source_pixel, GLenum type, unsigned int red, unsigned int green,
unsigned int blue, unsigned int alpha);
PixelData getRGBA4PixelData(int is_source_pixel, GLenum type, unsigned char red, unsigned char green,
unsigned char blue, unsigned char alpha);
PixelData getRGBA8PixelData(GLenum type, unsigned char red, unsigned char green, unsigned char blue,
unsigned char alpha);
PixelData getSRGB8Alpha8PixelData(GLenum type, unsigned char red, unsigned char green, unsigned char blue,
unsigned char alpha);
PixelData getSRGB8PixelData(int is_source_pixel, GLenum type, unsigned char red, unsigned char green,
unsigned char blue);
PixelData getR16FPixelData(int is_source_pixel, GLenum type, float red);
PixelData getR32FPixelData(int is_source_pixel, GLenum type, float red);
PixelData getRG16FPixelData(int is_source_pixel, GLenum type, float red, float green);
PixelData getRG32FPixelData(int is_source_pixel, GLenum type, float red, float green);
PixelData getRGB16FPixelData(int is_source_pixel, GLenum type, float red, float green, float blue);
PixelData getRGB32FPixelData(int is_source_pixel, GLenum type, float red, float green, float blue);
PixelData getRGBA16FPixelData(GLenum type, float red, float green, float blue, float alpha);
PixelData getRGBA32FPixelData(GLenum type, float red, float green, float blue, float alpha);
protected:
void addEntryToConversionDatabase(PixelData src_topleft, PixelData dst_topleft, PixelData src_topright,
PixelData dst_topright, PixelData src_bottomleft, PixelData dst_bottomleft,
PixelData src_bottomright, PixelData dst_bottomright,
PixelCompareChannel channels_to_compare);
void configureConversionDatabase();
public:
// An array of _conversion_database_entry instances,
// storing all known conversion rules.
std::vector<ConversionDatabaseEntry> entries;
// Amount of entries allocated in the "entries" array so far.
unsigned int n_entries_allocated;
// Amount of entries added to the "entries" array so far.
unsigned int n_entries_added;
};
ConversionDatabase::ConversionDatabase() : n_entries_allocated(0), n_entries_added(0)
{
}
ConversionDatabase::~ConversionDatabase()
{
}
/** Initializes database instance. The database will be filled by the
* function with all available conversion rules, so it is a mistake to call
* ConfigureConversionDatabase() function for a handle reported by this function.
*
* The handle should be released with ReleaseConversionDatabase() when no longer
* needed.
*
* @return Handle to the newly created conversion database.
**/
void ConversionDatabase::initializeDatabase()
{
// Return when database was initialized earlier.
if (!entries.empty())
return;
entries.resize(N_START_CONVERSION_DATABASE_ENTRIES);
n_entries_allocated = N_START_CONVERSION_DATABASE_ENTRIES;
n_entries_added = 0;
if (entries.empty())
TCU_FAIL("Out of memory while pre-allocating space for conversion database entries");
deMemset(&entries[0], DE_NULL, N_START_CONVERSION_DATABASE_ENTRIES * sizeof(ConversionDatabaseEntry));
// Add all predefined entries that the test implementation is aware of
configureConversionDatabase();
}
/** Tells whether @param type can be used for a gl.readPixels() call.
*
* @param type GL type to consider.
*
* @return true if the type should be accepted by a gl.readPixels() call,
* false otherwise.
*/
bool ConversionDatabase::isTypeSupportedByGLReadPixels(GLenum type)
{
return (type == GL_INT) || (type == GL_UNSIGNED_BYTE) || (type == GL_UNSIGNED_INT) || (type == GL_FLOAT) ||
(type == GL_HALF_FLOAT) || (type == GL_UNSIGNED_INT_2_10_10_10_REV);
}
/** Tells whether @param type can be used with @param internalformat internal format.
*
* @param type GLES type to consider.
* @param internalformat GLES internal format to consider.
*
* @return true if the type is compatible with specific internal format, false otherwise.
**/
bool ConversionDatabase::isInternalFormatCompatibleWithType(GLenum type, GLenum internalformat)
{
bool result = false;
switch (type)
{
case GL_INT:
{
result = (internalformat == GL_R8I) || (internalformat == GL_R16I) || (internalformat == GL_R32I) ||
(internalformat == GL_RG8I) || (internalformat == GL_RG16I) || (internalformat == GL_RG32I) ||
(internalformat == GL_RGB8I) || (internalformat == GL_RGB16I) || (internalformat == GL_RGB32I) ||
(internalformat == GL_RGBA8I) || (internalformat == GL_RGBA16I) || (internalformat == GL_RGBA32I);
break;
}
case GL_UNSIGNED_BYTE:
{
result = (internalformat == GL_RGB) || (internalformat == GL_RGBA) || (internalformat == GL_LUMINANCE_ALPHA) ||
(internalformat == GL_LUMINANCE) || (internalformat == GL_LUMINANCE8_OES) ||
(internalformat == GL_LUMINANCE8_ALPHA8_OES) || (internalformat == GL_ALPHA) ||
(internalformat == GL_ALPHA8_OES) || (internalformat == GL_R8) || (internalformat == GL_R8_SNORM) ||
(internalformat == GL_RG8) || (internalformat == GL_RG8_SNORM) || (internalformat == GL_RGB8) ||
(internalformat == GL_SRGB8) || (internalformat == GL_RGB565) || (internalformat == GL_RGB8_SNORM) ||
(internalformat == GL_RGBA8) || (internalformat == GL_SRGB8_ALPHA8) ||
(internalformat == GL_RGBA8_SNORM) || (internalformat == GL_RGB5_A1) || (internalformat == GL_RGBA4);
break;
}
case GL_UNSIGNED_INT:
{
result = (internalformat == GL_R8UI) || (internalformat == GL_R16UI) || (internalformat == GL_R32UI) ||
(internalformat == GL_RG8UI) || (internalformat == GL_RG16UI) || (internalformat == GL_RG32UI) ||
(internalformat == GL_RGB8UI) || (internalformat == GL_RGB10_A2UI) || (internalformat == GL_RGB16UI) ||
(internalformat == GL_RGB32UI) || (internalformat == GL_RGBA8UI) || (internalformat == GL_RGBA16UI) ||
(internalformat == GL_RGBA32UI);
break;
}
case GL_UNSIGNED_INT_2_10_10_10_REV:
{
result = (internalformat == GL_RGB10_A2) || (internalformat == GL_RGB10_A2UI);
break;
}
case GL_FLOAT:
{
result = (internalformat == GL_RGB) || (internalformat == GL_RGBA) || (internalformat == GL_R32F) ||
(internalformat == GL_RG32F) || (internalformat == GL_RGB32F) || (internalformat == GL_RGBA32F);
break;
}
case GL_HALF_FLOAT:
{
result = (internalformat == GL_RGB) || (internalformat == GL_RGBA) || (internalformat == GL_R16F) ||
(internalformat == GL_RG16F) || (internalformat == GL_RGB16F) || (internalformat == GL_RGBA16F);
break;
}
default:
{
TCU_FAIL("Unsupported type");
}
}
return result;
}
/** Converts normalized unsigned fixed-point RGBA pixel representations
* from one resolution to another, simulating the result that one would
* get if glCopyTexImage2D() call was used for a single pixel, read
* afterward with a gl.readPixels() call.
*
* @param src_input_rgba_bits Pointer to an array storing 4 integers, representing
* amount of bits per channel, as used by input data,
* that will be fed to a GL object using gl.texImage2D()
* call or similar. Cannot be NULL.
* @param src_attachment_rgba_bits Pointer to an array storing 4 integers, representing
* amount of bits per channel, as used by data storage
* of an object attached to read buffer. Cannot be NULL.
* @param dst_attachment_rgba_bits Pointer to an array storing 4 integers, representing
* amount of bits per channel, as used by data storage
* of a texture object that glCopyTexImage2D() call will
* initialize. Cannot be NULL.
* @param dst_output_rgba_bits Pointer to an array storing 4 integers, representing
* amount of bits per channel, as requested by the user
* using the gl.readPixels() call. Cannot be NULL.
* @param src_rgba Pointer to an array storing 4 values representing
* RGBA channel. It is assumed the values do not exceed
* allowed precision, described by @param src_input_rgba_bits.
* Cannot be NULL.
* @param dst_rgba Deref will be used to store result of the conversion.
* Cannot be NULL.
*
* @return 1 if successful, 0 otherwise.
* */
bool ConversionDatabase::convertNormalizedUnsignedFixedPoint(int* src_input_rgba_bits, int* src_attachment_rgba_bits,
int* dst_attachment_rgba_bits, int* dst_output_rgba_bits,
int* src_rgba, int* dst_rgba)
{
float a_f32 = 0.0f;
float b_f32 = 0.0f;
float dst_rgba_f[4] = { 0.0f };
float g_f32 = 0.0f;
float r_f32 = 0.0f;
int src_rgba_intermediate[4] = { src_rgba[0], src_rgba[1], src_rgba[2], src_rgba[3] };
// Reduce or crank up precision before casting to floats
int bit_diffs_src_intermediate[] = { abs(src_input_rgba_bits[0] - src_attachment_rgba_bits[0]),
abs(src_input_rgba_bits[1] - src_attachment_rgba_bits[1]),
abs(src_input_rgba_bits[2] - src_attachment_rgba_bits[2]),
abs(src_input_rgba_bits[3] - src_attachment_rgba_bits[3]) };
for (unsigned int n = 0; n < sizeof(bit_diffs_src_intermediate) / sizeof(bit_diffs_src_intermediate[0]); ++n)
{
float tmp = ((float)src_rgba_intermediate[n]) / ((1 << src_input_rgba_bits[n]) - 1);
if (tmp > 1.0f)
tmp = 1.0f;
tmp *= (float)((1 << src_attachment_rgba_bits[n]) - 1);
src_rgba_intermediate[n] = (int)(0.5 + tmp);
}
// The following equations correspond to equation 2.1 from ES spec 3.0.2
r_f32 = ((float)src_rgba_intermediate[0]) / (float)((1 << src_attachment_rgba_bits[0]) - 1);
g_f32 = ((float)src_rgba_intermediate[1]) / (float)((1 << src_attachment_rgba_bits[1]) - 1);
b_f32 = ((float)src_rgba_intermediate[2]) / (float)((1 << src_attachment_rgba_bits[2]) - 1);
a_f32 = ((float)src_rgba_intermediate[3]) / (float)((1 << src_attachment_rgba_bits[3]) - 1);
// Clamp to <0, 1>. Since we're dealing with unsigned ints on input, there's
// no way we could be lower than 0.
if (r_f32 > 1.0f)
r_f32 = 1.0f;
if (g_f32 > 1.0f)
g_f32 = 1.0f;
if (b_f32 > 1.0f)
b_f32 = 1.0f;
if (a_f32 > 1.0f)
a_f32 = 1.0f;
// The following equations are taken from table 4.5 & equation 2.3,
// ES spec 3.0.2
dst_rgba_f[0] = (r_f32 * (float)((1 << dst_attachment_rgba_bits[0]) - 1));
dst_rgba_f[1] = (g_f32 * (float)((1 << dst_attachment_rgba_bits[1]) - 1));
dst_rgba_f[2] = (b_f32 * (float)((1 << dst_attachment_rgba_bits[2]) - 1));
dst_rgba_f[3] = (a_f32 * (float)((1 << dst_attachment_rgba_bits[3]) - 1));
// As per spec:
//
// The conversion from a floating-point value f to the corresponding
// unsigned normalized fixed-point value c is defined by first clamping
// f to the range [0,1], then computing
//
// f' = convert_float_uint(f * (2^b-1), b) [2.3]
//
// where convert_float_uint(r,b) returns one of the two unsigned binary
// integer values with exactly b bits which are closest to the floating-point
// value r (where *rounding to nearest is preferred*)
//
// C casting truncates the remainder, so if dst_rgba_f[x] is larger than or
// equal to 0.5, we need to take a ceiling of the value.
for (unsigned int n = 0; n < 4 /* channels */; ++n)
{
if (deFloatMod(dst_rgba_f[n], 1.0f) >= 0.5f)
dst_rgba_f[n] = deFloatCeil(dst_rgba_f[n]);
}
// Expand the data or reduce its precision, depending on the type requested by the caller.
dst_rgba[0] = ((unsigned int)dst_rgba_f[0]);
dst_rgba[1] = ((unsigned int)dst_rgba_f[1]);
dst_rgba[2] = ((unsigned int)dst_rgba_f[2]);
dst_rgba[3] = ((unsigned int)dst_rgba_f[3]);
for (unsigned int n = 0; n < 4 /* channels */; ++n)
{
float tmp = ((float)dst_rgba[n]) / ((1 << dst_attachment_rgba_bits[n]) - 1);
if (tmp > 1.0f)
tmp = 1.0f;
tmp *= (float)((1 << dst_output_rgba_bits[n]) - 1);
dst_rgba[n] = (int)(0.5 + tmp);
}
return true;
}
/** Retrieves a PixelData instance describing a single pixel stored in
* GL_ALPHA8 internal format.
*
* @param is_source_pixel 1 if the pixel is going to be used as conversion source,
* 0 otherwise.
* @param type GLES type the pixel uses. Must be GL_UNSIGNED_BYTE.
* @param red Value for red channel.
*
* @return Filled PixelData instance.
**/
PixelData ConversionDatabase::getAlpha8OESPixelData(GLenum type, unsigned char alpha)
{
PixelData result;
// Sanity checks
DE_ASSERT(type == GL_UNSIGNED_BYTE);
// Carry on
deMemset(&result, 0, sizeof(result));
result.alpha.unsigned_byte_data = alpha;
result.alpha.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_8BITS;
result.blue.data_type = CHANNEL_DATA_TYPE_NONE;
result.green.data_type = CHANNEL_DATA_TYPE_NONE;
result.red.data_type = CHANNEL_DATA_TYPE_NONE;
result.data_internalformat = GL_ALPHA8_OES;
result.data_type = type;
return result;
}
/** Retrieves a PixelData instance describing a single pixel stored in
* GL_LUMINANCE8 internal format.
*
* @param is_source_pixel 1 if the pixel is going to be used as conversion source,
* 0 otherwise.
* @param type GLES type the pixel uses. Must be GL_UNSIGNED_BYTE.
* @param luminance Luminance value. Will get cloned to blue/green/red channels.
*
* @return Filled PixelData instance.
**/
PixelData ConversionDatabase::getLuminance8OESPixelData(GLenum type, unsigned char luminance)
{
PixelData result;
/* Sanity checks */
DE_ASSERT(type == GL_UNSIGNED_BYTE);
/* Carry on */
deMemset(&result, 0, sizeof(result));
result.alpha.unsigned_byte_data = 255;
result.alpha.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_8BITS;
result.blue.unsigned_byte_data = luminance;
result.blue.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_8BITS;
result.green.unsigned_byte_data = luminance;
result.green.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_8BITS;
result.red.unsigned_byte_data = luminance;
result.red.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_8BITS;
result.data_internalformat = GL_LUMINANCE8_OES;
result.data_type = type;
return result;
}
/** Retrieves a PixelData instance describing a single pixel stored in
* GL_LUMINANCE8_ALPHA8 internal format.
*
* @param is_source_pixel 1 if the pixel is going to be used as conversion source,
* 0 otherwise.
* @param type GLES type the pixel uses. Must be GL_UNSIGNED_BYTE.
* @param luminance Luminance value. Will be cloned to blue/green/red channels.
* @param alpha Alpha channel value.
*
* @return Filled PixelData instance.
**/
PixelData ConversionDatabase::getLuminance8Alpha8OESPixelData(GLenum type, unsigned char luminance, unsigned char alpha)
{
PixelData result;
/* Sanity checks */
DE_ASSERT(type == GL_UNSIGNED_BYTE);
/* Carry on */
deMemset(&result, 0, sizeof(result));
result.alpha.unsigned_byte_data = alpha;
result.alpha.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_8BITS;
result.blue.unsigned_byte_data = luminance;
result.blue.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_8BITS;
result.green.unsigned_byte_data = luminance;
result.green.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_8BITS;
result.red.unsigned_byte_data = luminance;
result.red.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_8BITS;
result.data_internalformat = GL_LUMINANCE8_ALPHA8_OES;
result.data_type = type;
return result;
}
/** Retrieves a PixelData instance describing a single pixel stored in
* GL_R16I internal format.
*
* @param is_source_pixel 1 if the pixel is going to be used as conversion source,
* 0 otherwise.
* @param type GLES type the pixel uses. Must be:
* 1) GL_SHORT for source pixels.
* 2) GL_INT for destination pixels.
* @param red Value for red channel.
*
* @return Filled PixelData instance.
**/
PixelData ConversionDatabase::getR16IPixelData(int is_source_pixel, GLenum type, int red)
{
PixelData result;
/* Sanity checks */
if (is_source_pixel)
{
DE_ASSERT(type == GL_SHORT);
} /* if (is_source_pixel) */
else
{
DE_ASSERT(type == GL_INT);
}
/* Carry on */
deMemset(&result, 0, sizeof(result));
result.blue.data_type = CHANNEL_DATA_TYPE_NONE;
result.green.data_type = CHANNEL_DATA_TYPE_NONE;
if (is_source_pixel)
{
result.red.signed_short_data = red;
result.red.data_type = CHANNEL_DATA_TYPE_SIGNED_SHORT_16BITS;
} /* if (is_source_pixel) */
else
{
result.alpha.signed_integer_data = 1;
result.alpha.data_type = CHANNEL_DATA_TYPE_SIGNED_INTEGER_32BITS;
result.red.signed_integer_data = red;
result.red.data_type = CHANNEL_DATA_TYPE_SIGNED_INTEGER_32BITS;
}
result.data_internalformat = GL_R16I;
result.data_type = type;
return result;
}
/** Retrieves a PixelData instance describing a single pixel stored in
* GL_R16UI internal format.
*
* @param is_source_pixel 1 if the pixel is going to be used as conversion source,
* 0 otherwise.
* @param type GLES type the pixel uses. Must be:
* 1) GL_UNSIGNED_SHORT for source pixels.
* 2) GL_UNSIGNED_INT for destination pixels.
* @param red Value for red channel.
*
* @return Filled PixelData instance.
**/
PixelData ConversionDatabase::getR16UIPixelData(int is_source_pixel, GLenum type, unsigned int red)
{
PixelData result;
/* Sanity checks */
if (is_source_pixel)
{
DE_ASSERT(type == GL_UNSIGNED_SHORT);
} /* if (is_source_pixels) */
else
{
DE_ASSERT(type == GL_UNSIGNED_INT);
}
deMemset(&result, 0, sizeof(result));
result.alpha.data_type = CHANNEL_DATA_TYPE_NONE;
result.blue.data_type = CHANNEL_DATA_TYPE_NONE;
result.green.data_type = CHANNEL_DATA_TYPE_NONE;
if (is_source_pixel)
{
result.red.unsigned_short_data = red;
result.red.data_type = CHANNEL_DATA_TYPE_UNSIGNED_SHORT_16BITS;
} /* if (is_source_pixel) */
else
{
result.alpha.unsigned_integer_data = 1;
result.alpha.data_type = CHANNEL_DATA_TYPE_UNSIGNED_INTEGER_32BITS;
result.red.unsigned_integer_data = red;
result.red.data_type = CHANNEL_DATA_TYPE_UNSIGNED_INTEGER_32BITS;
}
result.data_internalformat = GL_R16UI;
result.data_type = type;
return result;
}
/** Retrieves a PixelData instance describing a single pixel stored in
* GL_R32I internal format.
*
* @param is_source_pixel 1 if the pixel is going to be used as conversion source,
* 0 otherwise.
* @param type GLES type the pixel uses. Must be GL_INT.
* @param red Value for red channel.
*
* @return Filled PixelData instance.
**/
PixelData ConversionDatabase::getR32IPixelData(int is_source_pixel, GLenum type, int red)
{
PixelData result;
DE_ASSERT(type == GL_INT);
deMemset(&result, 0, sizeof(result));
if (!is_source_pixel)
{
result.alpha.data_type = CHANNEL_DATA_TYPE_SIGNED_INTEGER_32BITS;
result.alpha.signed_integer_data = 1;
}
else
{
result.alpha.data_type = CHANNEL_DATA_TYPE_NONE;
}
result.blue.data_type = CHANNEL_DATA_TYPE_NONE;
result.green.data_type = CHANNEL_DATA_TYPE_NONE;
result.red.signed_integer_data = red;
result.red.data_type = CHANNEL_DATA_TYPE_SIGNED_INTEGER_32BITS;
result.data_internalformat = GL_R32I;
result.data_type = type;
return result;
}
/** Retrieves a PixelData instance describing a single pixel stored in
* GL_R32UI internal format.
*
* @param is_source_pixel 1 if the pixel is going to be used as conversion source,
* 0 otherwise.
* @param type GLES type the pixel uses. Must be GL_UNSIGNED_INT.
* @param red Value for red channel.
*
* @return Filled PixelData instance.
**/
PixelData ConversionDatabase::getR32UIPixelData(int is_source_pixel, GLenum type, unsigned int red)
{
PixelData result;
DE_ASSERT(type == GL_UNSIGNED_INT);
deMemset(&result, 0, sizeof(result));
if (!is_source_pixel)
{
result.alpha.data_type = CHANNEL_DATA_TYPE_UNSIGNED_INTEGER_32BITS;
result.alpha.unsigned_integer_data = 1;
} /* if (!is_source_pixel) */
else
{
result.alpha.data_type = CHANNEL_DATA_TYPE_NONE;
}
result.blue.data_type = CHANNEL_DATA_TYPE_NONE;
result.green.data_type = CHANNEL_DATA_TYPE_NONE;
result.red.unsigned_integer_data = red;
result.red.data_type = CHANNEL_DATA_TYPE_UNSIGNED_INTEGER_32BITS;
result.data_internalformat = GL_R32UI;
result.data_type = type;
return result;
}
/** Retrieves a PixelData instance describing a single pixel stored in
* GL_R8I internal format.
*
* @param is_source_pixel 1 if the pixel is going to be used as conversion source,
* 0 otherwise.
* @param type GLES type the pixel uses. Must be:
* 1) GL_BYTE for source pixels.
* 2) GL_INT for destination pixels.
* @param red Value for red channel.
*
* @return Filled PixelData instance.
**/
PixelData ConversionDatabase::getR8IPixelData(int is_source_pixel, GLenum type, int red)
{
PixelData result;
// Sanity checks
if (is_source_pixel)
DE_ASSERT(type == GL_BYTE);
else
DE_ASSERT(type == GL_INT);
// Carry on
deMemset(&result, 0, sizeof(result));
result.blue.data_type = CHANNEL_DATA_TYPE_NONE;
result.green.data_type = CHANNEL_DATA_TYPE_NONE;
if (is_source_pixel)
{
result.alpha.data_type = CHANNEL_DATA_TYPE_NONE;
result.red.signed_byte_data = red;
result.red.data_type = CHANNEL_DATA_TYPE_SIGNED_BYTE_8BITS;
}
else
{
result.alpha.data_type = CHANNEL_DATA_TYPE_SIGNED_INTEGER_32BITS;
result.alpha.signed_integer_data = 1;
result.red.data_type = CHANNEL_DATA_TYPE_SIGNED_INTEGER_32BITS;
result.red.signed_integer_data = red;
}
result.data_internalformat = GL_R8I;
result.data_type = type;
return result;
}
/** Retrieves a PixelData instance describing a single pixel stored in
* GL_R8UI internal format.
*
* @param is_source_pixel 1 if the pixel is going to be used as conversion source,
* 0 otherwise.
* @param type GLES type the pixel uses. Must be:
* 1) GL_UNSIGNED_BYTE for source pixels.
* 2) GL_UNSIGNED_INT for destination pixels.
* @param red Value for red channel.
*
* @return Filled PixelData instance.
**/
PixelData ConversionDatabase::getR8UIPixelData(int is_source_pixel, GLenum type, unsigned int red)
{
PixelData result;
/* Sanity checks */
if (is_source_pixel)
DE_ASSERT(type == GL_UNSIGNED_BYTE);
else
DE_ASSERT(type == GL_UNSIGNED_INT);
deMemset(&result, 0, sizeof(result));
result.blue.data_type = CHANNEL_DATA_TYPE_NONE;
result.green.data_type = CHANNEL_DATA_TYPE_NONE;
if (is_source_pixel)
{
result.alpha.data_type = CHANNEL_DATA_TYPE_NONE;
result.red.unsigned_byte_data = red;
result.red.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_8BITS;
}
else
{
result.alpha.data_type = CHANNEL_DATA_TYPE_UNSIGNED_INTEGER_32BITS;
result.alpha.unsigned_integer_data = 1;
result.red.data_type = CHANNEL_DATA_TYPE_UNSIGNED_INTEGER_32BITS;
result.red.unsigned_integer_data = red;
}
result.data_internalformat = GL_R8UI;
result.data_type = type;
return result;
}
/** Retrieves a PixelData instance describing a single pixel stored in
* GL_R8 internal format.
*
* @param is_source_pixel 1 if the pixel is going to be used as conversion source,
* 0 otherwise.
* @param type GLES type the pixel uses. Must beGL_UNSIGNED_BYTE.
* @param red Value for red channel.
*
* @return Filled PixelData instance.
**/
PixelData ConversionDatabase::getR8PixelData(int is_source_pixel, GLenum type, unsigned char red)
{
PixelData result;
DE_ASSERT(type == GL_UNSIGNED_BYTE);
deMemset(&result, 0, sizeof(result));
if (is_source_pixel)
{
result.alpha.data_type = CHANNEL_DATA_TYPE_NONE;
}
else
{
result.alpha.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_8BITS;
result.alpha.unsigned_byte_data = 255;
}
result.blue.data_type = CHANNEL_DATA_TYPE_NONE;
result.green.data_type = CHANNEL_DATA_TYPE_NONE;
result.red.unsigned_byte_data = red;
result.red.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_8BITS;
result.data_internalformat = GL_R8;
result.data_type = type;
return result;
}
/** Retrieves a PixelData instance describing a single pixel stored in
* GL_RG16I internal format.
*
* @param is_source_pixel 1 if the pixel is going to be used as conversion source,
* 0 otherwise.
* @param type GLES type the pixel uses. Must be:
* 1) GL_SHORT for source pixels.
* 2) GL_INT for destination pixels.
* @param red Value for red channel.
* @param green Value for green channel.
*
* @return Filled PixelData instance.
**/
PixelData ConversionDatabase::getRG16IPixelData(int is_source_pixel, GLenum type, int red, int green)
{
PixelData result;
if (is_source_pixel)
{
DE_ASSERT(type == GL_SHORT);
}
else
{
DE_ASSERT(type == GL_INT);
}
deMemset(&result, 0, sizeof(result));
result.blue.data_type = CHANNEL_DATA_TYPE_NONE;
if (is_source_pixel)
{
result.alpha.data_type = CHANNEL_DATA_TYPE_NONE;
result.green.signed_short_data = green;
result.green.data_type = CHANNEL_DATA_TYPE_SIGNED_SHORT_16BITS;
result.red.signed_short_data = red;
result.red.data_type = CHANNEL_DATA_TYPE_SIGNED_SHORT_16BITS;
}
else
{
result.alpha.data_type = CHANNEL_DATA_TYPE_SIGNED_INTEGER_32BITS;
result.alpha.signed_integer_data = 1;
result.green.data_type = CHANNEL_DATA_TYPE_SIGNED_INTEGER_32BITS;
result.green.signed_integer_data = green;
result.red.data_type = CHANNEL_DATA_TYPE_SIGNED_INTEGER_32BITS;
result.red.signed_integer_data = red;
}
result.data_internalformat = GL_RG16I;
result.data_type = type;
return result;
}
/** Retrieves a PixelData instance describing a single pixel stored in
* GL_RG16UI internal format.
*
* @param is_source_pixel 1 if the pixel is going to be used as conversion source,
* 0 otherwise.
* @param type GLES type the pixel uses. Must be:
* 1) GL_UNSIGNED_SHORT for source pixels.
* 2) GL_UNSIGNED_INT for destination pixels.
* @param red Value for red channel.
* @param green Value for green channel.
*
* @return Filled PixelData instance.
**/
PixelData ConversionDatabase::getRG16UIPixelData(int is_source_pixel, GLenum type, unsigned int red, unsigned int green)
{
PixelData result;
if (is_source_pixel)
DE_ASSERT(type == GL_UNSIGNED_SHORT);
else
DE_ASSERT(type == GL_UNSIGNED_INT);
deMemset(&result, 0, sizeof(result));
result.blue.data_type = CHANNEL_DATA_TYPE_NONE;
if (is_source_pixel)
{
result.alpha.data_type = CHANNEL_DATA_TYPE_NONE;
result.green.signed_short_data = green;
result.green.data_type = CHANNEL_DATA_TYPE_UNSIGNED_SHORT_16BITS;
result.red.signed_short_data = red;
result.red.data_type = CHANNEL_DATA_TYPE_UNSIGNED_SHORT_16BITS;
}
else
{
result.alpha.data_type = CHANNEL_DATA_TYPE_UNSIGNED_INTEGER_32BITS;
result.alpha.unsigned_integer_data = 1;
result.green.data_type = CHANNEL_DATA_TYPE_UNSIGNED_INTEGER_32BITS;
result.green.unsigned_integer_data = green;
result.red.data_type = CHANNEL_DATA_TYPE_UNSIGNED_INTEGER_32BITS;
result.red.unsigned_integer_data = red;
}
result.data_internalformat = GL_RG16UI;
result.data_type = type;
return result;
}
/** Retrieves a PixelData instance describing a single pixel stored in
* GL_RG32I internal format.
*
* @param is_source_pixel 1 if the pixel is going to be used as conversion source,
* 0 otherwise.
* @param type GLES type the pixel uses. Must be GL_INT.
* @param red Value for red channel.
* @param green Value for green channel.
*
* @return Filled PixelData instance.
**/
PixelData ConversionDatabase::getRG32IPixelData(int is_source_pixel, GLenum type, int red, int green)
{
PixelData result;
DE_ASSERT(type == GL_INT);
deMemset(&result, 0, sizeof(result));
if (is_source_pixel)
result.alpha.data_type = CHANNEL_DATA_TYPE_NONE;
else
{
result.alpha.data_type = CHANNEL_DATA_TYPE_SIGNED_INTEGER_32BITS;
result.alpha.signed_integer_data = 1;
}
result.blue.data_type = CHANNEL_DATA_TYPE_NONE;
result.green.signed_integer_data = green;
result.green.data_type = CHANNEL_DATA_TYPE_SIGNED_INTEGER_32BITS;
result.red.signed_integer_data = red;
result.red.data_type = CHANNEL_DATA_TYPE_SIGNED_INTEGER_32BITS;
result.data_internalformat = GL_RG32I;
result.data_type = type;
return result;
}
/** Retrieves a PixelData instance describing a single pixel stored in
* GL_RG32UI internal format.
*
* @param is_source_pixel 1 if the pixel is going to be used as conversion source,
* 0 otherwise.
* @param type GLES type the pixel uses. Must be GL_UNSIGNED_INT.
* @param red Value for red channel.
* @param green Value for green channel.
*
* @return Filled PixelData instance.
**/
PixelData ConversionDatabase::getRG32UIPixelData(int is_source_pixel, GLenum type, unsigned int red, unsigned int green)
{
PixelData result;
DE_ASSERT(type == GL_UNSIGNED_INT);
deMemset(&result, 0, sizeof(result));
if (is_source_pixel)
{
result.alpha.data_type = CHANNEL_DATA_TYPE_NONE;
}
else
{
result.alpha.data_type = CHANNEL_DATA_TYPE_UNSIGNED_INTEGER_32BITS;
result.alpha.unsigned_integer_data = 1;
}
result.blue.data_type = CHANNEL_DATA_TYPE_NONE;
result.green.unsigned_integer_data = green;
result.green.data_type = CHANNEL_DATA_TYPE_UNSIGNED_INTEGER_32BITS;
result.red.unsigned_integer_data = red;
result.red.data_type = CHANNEL_DATA_TYPE_UNSIGNED_INTEGER_32BITS;
result.data_internalformat = GL_RG32UI;
result.data_type = type;
return result;
}
/** Retrieves a PixelData instance describing a single pixel stored in
* GL_RG8I internal format.
*
* @param is_source_pixel 1 if the pixel is going to be used as conversion source,
* 0 otherwise.
* @param type GLES type the pixel uses. Must be:
* 1) GL_BYTE for source pixels.
* 2) GL_INT for destination pixels.
* @param red Value for red channel.
* @param green Value for green channel.
*
* @return Filled PixelData instance.
**/
PixelData ConversionDatabase::getRG8IPixelData(int is_source_pixel, GLenum type, int red, int green)
{
PixelData result;
if (is_source_pixel)
DE_ASSERT(type == GL_BYTE);
else
DE_ASSERT(type == GL_INT);
deMemset(&result, 0, sizeof(result));
result.blue.data_type = CHANNEL_DATA_TYPE_NONE;
if (is_source_pixel)
{
result.alpha.data_type = CHANNEL_DATA_TYPE_NONE;
result.green.signed_byte_data = green;
result.green.data_type = CHANNEL_DATA_TYPE_SIGNED_BYTE_8BITS;
result.red.signed_byte_data = red;
result.red.data_type = CHANNEL_DATA_TYPE_SIGNED_BYTE_8BITS;
} /* if (is_source_pixel) */
else
{
result.alpha.data_type = CHANNEL_DATA_TYPE_SIGNED_INTEGER_32BITS;
result.alpha.signed_integer_data = 1;
result.green.data_type = CHANNEL_DATA_TYPE_SIGNED_INTEGER_32BITS;
result.green.signed_integer_data = green;
result.red.data_type = CHANNEL_DATA_TYPE_SIGNED_INTEGER_32BITS;
result.red.signed_integer_data = red;
}
result.data_internalformat = GL_RG8I;
result.data_type = type;
return result;
}
/** Retrieves a PixelData instance describing a single pixel stored in
* GL_RGB8UI internal format.
*
* @param is_source_pixel 1 if the pixel is going to be used as conversion source,
* 0 otherwise.
* @param type GLES type the pixel uses. Must be:
* 1) GL_UNSIGNED_BYTE for source pixels.
* 2) GL_UNSIGNED_INT for destination pixels.
* @param red Value for red channel.
* @param green Value for green channel.
*
* @return Filled PixelData instance.
**/
PixelData ConversionDatabase::getRG8UIPixelData(int is_source_pixel, GLenum type, unsigned int red, unsigned int green)
{
PixelData result;
if (is_source_pixel)
DE_ASSERT(type == GL_UNSIGNED_BYTE);
else
DE_ASSERT(type == GL_UNSIGNED_INT);
deMemset(&result, 0, sizeof(result));
result.blue.data_type = CHANNEL_DATA_TYPE_NONE;
if (is_source_pixel)
{
result.alpha.data_type = CHANNEL_DATA_TYPE_NONE;
result.green.unsigned_byte_data = green;
result.green.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_8BITS;
result.red.unsigned_byte_data = red;
result.red.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_8BITS;
}
else
{
result.alpha.data_type = CHANNEL_DATA_TYPE_UNSIGNED_INTEGER_32BITS;
result.alpha.unsigned_integer_data = 1;
result.green.data_type = CHANNEL_DATA_TYPE_UNSIGNED_INTEGER_32BITS;
result.green.unsigned_integer_data = green;
result.red.data_type = CHANNEL_DATA_TYPE_UNSIGNED_INTEGER_32BITS;
result.red.unsigned_integer_data = red;
}
result.data_internalformat = GL_RG8UI;
result.data_type = type;
return result;
}
/** Retrieves a PixelData instance describing a single pixel stored in
* GL_RG8 internal format.
*
* @param is_source_pixel 1 if the pixel is going to be used as conversion source,
* 0 otherwise.
* @param type GLES type the pixel uses. Must be GL_UNSIGNED_BYTE.
* @param red Value for red channel.
* @param green Value for green channel.
*
* @return Filled PixelData instance.
**/
PixelData ConversionDatabase::getRG8PixelData(int is_source_pixel, GLenum type, unsigned char red, unsigned char green)
{
PixelData result;
DE_ASSERT(type == GL_UNSIGNED_BYTE);
deMemset(&result, 0, sizeof(result));
if (is_source_pixel)
{
result.alpha.data_type = CHANNEL_DATA_TYPE_NONE;
}
else
{
result.alpha.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_8BITS;
result.alpha.unsigned_byte_data = 255;
}
result.blue.data_type = CHANNEL_DATA_TYPE_NONE;
result.green.unsigned_byte_data = green;
result.green.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_8BITS;
result.red.unsigned_byte_data = red;
result.red.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_8BITS;
result.data_internalformat = GL_RG8;
result.data_type = type;
return result;
}
/** Retrieves a PixelData instance describing a single pixel stored in
* GL_RGB10_A2 internal format.
*
* @param is_source_pixel 1 if the pixel is going to be used as conversion source,
* 0 otherwise.
* @param type GLES type the pixel uses. Must be GL_UNSIGNED_INT_2_10_10_10_REV.
* @param red Value for red channel.
* @param green Value for green channel.
* @param blue Value for blue channel.
* @param alpha Value for alpha channel.
*
* @return Filled PixelData instance.
**/
PixelData ConversionDatabase::getRGB10A2PixelData(GLenum type, unsigned short red, unsigned short green,
unsigned short blue, unsigned char alpha)
{
PixelData result;
DE_ASSERT(red <= 1023);
DE_ASSERT(green <= 1023);
DE_ASSERT(blue <= 1023);
DE_ASSERT(alpha <= 3);
DE_ASSERT(type == GL_UNSIGNED_INT_2_10_10_10_REV);
deMemset(&result, 0, sizeof(result));
result.alpha.unsigned_byte_data = alpha;
result.alpha.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_2BITS;
result.blue.unsigned_short_data = blue;
result.blue.data_type = CHANNEL_DATA_TYPE_UNSIGNED_SHORT_10BITS;
result.green.unsigned_short_data = green;
result.green.data_type = CHANNEL_DATA_TYPE_UNSIGNED_SHORT_10BITS;
result.red.unsigned_short_data = red;
result.red.data_type = CHANNEL_DATA_TYPE_UNSIGNED_SHORT_10BITS;
result.data_internalformat = GL_RGB10_A2;
result.data_type = type;
return result;
}
/** Retrieves a PixelData instance describing a single pixel stored in
* GL_RGB10A2UI internal format.
*
* @param is_source_pixel 1 if the pixel is going to be used as conversion source,
* 0 otherwise.
* @param type GLES type the pixel uses. Must be:
* 1) GL_UNSIGNED_INT_2_10_10_10_REV for source pixels.
* 2) GL_UNSIGNED_INT for destination pixels.
* @param red Value for red channel.
* @param green Value for green channel.
* @param blue Value for blue channel.
* @param alpha Value for alpha channel.
*
* @return Filled PixelData instance.
**/
PixelData ConversionDatabase::getRGB10A2UIPixelData(int is_source_pixel, GLenum type, unsigned int red,
unsigned int green, unsigned int blue, unsigned int alpha)
{
PixelData result;
if (is_source_pixel)
DE_ASSERT(type == GL_UNSIGNED_INT_2_10_10_10_REV);
else
DE_ASSERT(type == GL_UNSIGNED_INT);
deMemset(&result, 0, sizeof(result));
if (is_source_pixel)
{
result.alpha.unsigned_byte_data = alpha;
result.alpha.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_2BITS;
result.blue.unsigned_short_data = blue;
result.blue.data_type = CHANNEL_DATA_TYPE_UNSIGNED_SHORT_10BITS;
result.green.unsigned_short_data = green;
result.green.data_type = CHANNEL_DATA_TYPE_UNSIGNED_SHORT_10BITS;
result.red.unsigned_short_data = red;
result.red.data_type = CHANNEL_DATA_TYPE_UNSIGNED_SHORT_10BITS;
}
else
{
result.alpha.unsigned_integer_data = alpha;
result.alpha.data_type = CHANNEL_DATA_TYPE_UNSIGNED_INTEGER_32BITS;
result.blue.unsigned_integer_data = blue;
result.blue.data_type = CHANNEL_DATA_TYPE_UNSIGNED_INTEGER_32BITS;
result.green.unsigned_integer_data = green;
result.green.data_type = CHANNEL_DATA_TYPE_UNSIGNED_INTEGER_32BITS;
result.red.unsigned_integer_data = red;
result.red.data_type = CHANNEL_DATA_TYPE_UNSIGNED_INTEGER_32BITS;
}
result.data_internalformat = GL_RGB10_A2UI;
result.data_type = type;
return result;
}
/** Retrieves a PixelData instance describing a single pixel stored in
* GL_RGB16I internal format.
*
* @param is_source_pixel 1 if the pixel is going to be used as conversion source,
* 0 otherwise.
* @param type GLES type the pixel uses. Must be:
* 1) GL_SHORT for source pixels.
* 2) GL_INT for destination pixels.
* @param red Value for red channel.
* @param green Value for green channel.
* @param blue Value for blue channel.
*
* @return Filled PixelData instance.
**/
PixelData ConversionDatabase::getRGB16IPixelData(int is_source_pixel, GLenum type, int red, int green, int blue)
{
PixelData result;
if (is_source_pixel)
DE_ASSERT(type == GL_SHORT);
else
DE_ASSERT(type == GL_INT);
deMemset(&result, 0, sizeof(result));
if (is_source_pixel)
{
result.alpha.data_type = CHANNEL_DATA_TYPE_NONE;
result.blue.data_type = CHANNEL_DATA_TYPE_SIGNED_SHORT_16BITS;
result.blue.signed_short_data = blue;
result.green.data_type = CHANNEL_DATA_TYPE_SIGNED_SHORT_16BITS;
result.green.signed_short_data = green;
result.red.data_type = CHANNEL_DATA_TYPE_SIGNED_SHORT_16BITS;
result.red.signed_short_data = red;
}
else
{
result.alpha.data_type = CHANNEL_DATA_TYPE_SIGNED_INTEGER_32BITS;
result.alpha.signed_integer_data = 1;
result.blue.data_type = CHANNEL_DATA_TYPE_SIGNED_INTEGER_32BITS;
result.blue.signed_integer_data = blue;
result.green.data_type = CHANNEL_DATA_TYPE_SIGNED_INTEGER_32BITS;
result.green.signed_integer_data = green;
result.red.data_type = CHANNEL_DATA_TYPE_SIGNED_INTEGER_32BITS;
result.red.signed_integer_data = red;
}
result.data_internalformat = GL_RGB16I;
result.data_type = type;
return result;
}
/** Retrieves a PixelData instance describing a single pixel stored in
* GL_RGB16UI internal format.
*
* @param is_source_pixel 1 if the pixel is going to be used as conversion source,
* 0 otherwise.
* @param type GLES type the pixel uses. Must be:
* 1) GL_UNSIGNED_SHORT for source pixels.
* 2) GL_UNSIGNED_INT for destination pixels.
* @param red Value for red channel.
* @param green Value for green channel.
* @param blue Value for blue channel.
*
* @return Filled PixelData instance.
**/
PixelData ConversionDatabase::getRGB16UIPixelData(int is_source_pixel, GLenum type, unsigned int red,
unsigned int green, unsigned int blue)
{
PixelData result;
if (is_source_pixel)
DE_ASSERT(type == GL_UNSIGNED_SHORT);
else
DE_ASSERT(type == GL_UNSIGNED_INT);
deMemset(&result, 0, sizeof(result));
if (is_source_pixel)
{
result.alpha.data_type = CHANNEL_DATA_TYPE_NONE;
result.blue.data_type = CHANNEL_DATA_TYPE_UNSIGNED_SHORT_16BITS;
result.blue.unsigned_short_data = blue;
result.green.data_type = CHANNEL_DATA_TYPE_UNSIGNED_SHORT_16BITS;
result.green.unsigned_short_data = green;
result.red.data_type = CHANNEL_DATA_TYPE_UNSIGNED_SHORT_16BITS;
result.red.unsigned_short_data = red;
}
else
{
result.alpha.data_type = CHANNEL_DATA_TYPE_NONE;
result.alpha.unsigned_integer_data = 1;
result.blue.data_type = CHANNEL_DATA_TYPE_UNSIGNED_INTEGER_32BITS;
result.blue.unsigned_integer_data = blue;
result.green.data_type = CHANNEL_DATA_TYPE_UNSIGNED_INTEGER_32BITS;
result.green.unsigned_integer_data = green;
result.red.data_type = CHANNEL_DATA_TYPE_UNSIGNED_INTEGER_32BITS;
result.red.unsigned_integer_data = red;
}
result.data_internalformat = GL_RGB16UI;
result.data_type = type;
return result;
}
/** Retrieves a PixelData instance describing a single pixel stored in
* GL_RGB32I internal format.
*
* @param is_source_pixel 1 if the pixel is going to be used as conversion source,
* 0 otherwise.
* @param type GLES type the pixel uses. Must be GL_INT.
* @param red Value for red channel.
* @param green Value for green channel.
* @param blue Value for blue channel.
*
* @return Filled PixelData instance.
**/
PixelData ConversionDatabase::getRGB32IPixelData(int is_source_pixel, GLenum type, int red, int green, int blue)
{
PixelData result;
DE_ASSERT(type == GL_INT);
deMemset(&result, 0, sizeof(result));
if (is_source_pixel)
{
result.alpha.data_type = CHANNEL_DATA_TYPE_NONE;
}
else
{
result.alpha.data_type = CHANNEL_DATA_TYPE_SIGNED_INTEGER_32BITS;
result.alpha.signed_integer_data = 1;
}
result.blue.data_type = CHANNEL_DATA_TYPE_SIGNED_INTEGER_32BITS;
result.blue.signed_integer_data = blue;
result.green.data_type = CHANNEL_DATA_TYPE_SIGNED_INTEGER_32BITS;
result.green.signed_integer_data = green;
result.red.data_type = CHANNEL_DATA_TYPE_SIGNED_INTEGER_32BITS;
result.red.signed_integer_data = red;
result.data_internalformat = GL_RGB32I;
result.data_type = type;
return result;
}
/** Retrieves a PixelData instance describing a single pixel stored in
* GL_RGB32UI internal format.
*
* @param is_source_pixel 1 if the pixel is going to be used as conversion source,
* 0 otherwise.
* @param type GLES type the pixel uses. Must be GL_UNSIGNED_INT.
* @param red Value for red channel.
* @param green Value for green channel.
* @param blue Value for blue channel.
*
* @return Filled PixelData instance.
**/
PixelData ConversionDatabase::getRGB32UIPixelData(int is_source_pixel, GLenum type, unsigned int red,
unsigned int green, unsigned int blue)
{
PixelData result;
DE_ASSERT(type == GL_UNSIGNED_INT);
deMemset(&result, 0, sizeof(result));
if (is_source_pixel)
{
result.alpha.data_type = CHANNEL_DATA_TYPE_NONE;
}
else
{
result.alpha.data_type = CHANNEL_DATA_TYPE_UNSIGNED_INTEGER_32BITS;
result.alpha.unsigned_integer_data = 1;
}
result.blue.data_type = CHANNEL_DATA_TYPE_UNSIGNED_INTEGER_32BITS;
result.blue.unsigned_integer_data = blue;
result.green.data_type = CHANNEL_DATA_TYPE_UNSIGNED_INTEGER_32BITS;
result.green.unsigned_integer_data = green;
result.red.data_type = CHANNEL_DATA_TYPE_UNSIGNED_INTEGER_32BITS;
result.red.unsigned_integer_data = red;
result.data_internalformat = GL_RGB32UI;
result.data_type = type;
return result;
}
/** Retrieves a PixelData instance describing a single pixel stored in
* GL_RGB5A1 internal format.
*
* @param is_source_pixel 1 if the pixel is going to be used as conversion source,
* 0 otherwise.
* @param type GLES type the pixel uses. Must be:
* 1) GL_UNSIGNED_BYTE or GL_UNSIGNED_SHORT_5_5_5_1 or
* GL_UNSIGNED_INT_2_10_10_10_REV for source pixels.
* 2) GL_UNSIGNED_BYTE for destination pixels.
* @param red Value for red channel.
* @param green Value for green channel.
* @param blue Value for blue channel.
* @param alpha Value for alpha channel.
*
* @return Filled PixelData instance.
**/
PixelData ConversionDatabase::getRGB5A1PixelData(int is_source_pixel, GLenum type, unsigned int red, unsigned int green,
unsigned int blue, unsigned int alpha)
{
PixelData result;
if (is_source_pixel)
{
DE_ASSERT(type == GL_UNSIGNED_BYTE || type == GL_UNSIGNED_SHORT_5_5_5_1 ||
type == GL_UNSIGNED_INT_2_10_10_10_REV);
}
else
{
DE_ASSERT(type == GL_UNSIGNED_BYTE);
}
deMemset(&result, 0, sizeof(result));
switch (type)
{
case GL_UNSIGNED_BYTE:
{
DE_ASSERT(red <= 255);
DE_ASSERT(green <= 255);
DE_ASSERT(blue <= 255);
DE_ASSERT(alpha <= 255);
// Fill the channel data structures
result.alpha.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_8BITS;
result.alpha.unsigned_byte_data = alpha;
result.blue.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_8BITS;
result.blue.unsigned_byte_data = blue;
result.green.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_8BITS;
result.green.unsigned_byte_data = green;
result.red.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_8BITS;
result.red.unsigned_byte_data = red;
break;
}
case GL_UNSIGNED_SHORT_5_5_5_1:
{
DE_ASSERT(red <= 31);
DE_ASSERT(green <= 31);
DE_ASSERT(blue <= 31);
DE_ASSERT(alpha == 0 || alpha == 1);
// Fill the channel data structures
result.alpha.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_1BIT;
result.alpha.unsigned_byte_data = alpha;
result.blue.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_5BITS;
result.blue.unsigned_byte_data = blue;
result.green.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_5BITS;
result.green.unsigned_byte_data = green;
result.red.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_5BITS;
result.red.unsigned_byte_data = red;
break;
}
case GL_UNSIGNED_INT_2_10_10_10_REV:
{
// Sanity checks
DE_ASSERT(red <= 1023);
DE_ASSERT(green <= 1023);
DE_ASSERT(blue <= 1023);
DE_ASSERT(alpha <= 3);
// Fill the channel data structures
result.alpha.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_2BITS;
result.alpha.unsigned_byte_data = alpha;
result.blue.data_type = CHANNEL_DATA_TYPE_UNSIGNED_SHORT_10BITS;
result.blue.unsigned_short_data = blue;
result.green.data_type = CHANNEL_DATA_TYPE_UNSIGNED_SHORT_10BITS;
result.green.unsigned_short_data = green;
result.red.data_type = CHANNEL_DATA_TYPE_UNSIGNED_SHORT_10BITS;
result.red.unsigned_short_data = red;
break;
}
}
result.data_internalformat = GL_RGB5_A1;
result.data_type = type;
return result;
}
/** Retrieves a PixelData instance describing a single pixel stored in
* GL_RGB565 internal format.
*
* @param is_source_pixel 1 if the pixel is going to be used as conversion source,
* 0 otherwise.
* @param type GLES type the pixel uses. Must be:
* 1) GL_UNSIGNED_BYTE or GL_UNSIGNED_SHORT_5_6_5 for source pixels.
* 2) GL_UNSIGNED_BYTE for destination pixels.
* @param red Value for red channel.
* @param green Value for green channel.
* @param blue Value for blue channel.
*
* @return Filled PixelData instance.
**/
PixelData ConversionDatabase::getRGB565PixelData(int is_source_pixel, GLenum type, int red, int green, int blue)
{
PixelData result;
if (is_source_pixel)
DE_ASSERT(type == GL_UNSIGNED_BYTE || type == GL_UNSIGNED_SHORT_5_6_5);
else
DE_ASSERT(type == GL_UNSIGNED_BYTE);
deMemset(&result, 0, sizeof(result));
switch (type)
{
case GL_UNSIGNED_BYTE:
{
// Fill the channel data structures
result.blue.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_8BITS;
result.blue.unsigned_byte_data = blue;
result.green.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_8BITS;
result.green.unsigned_byte_data = green;
result.red.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_8BITS;
result.red.unsigned_byte_data = red;
break;
}
case GL_UNSIGNED_SHORT_5_6_5:
{
DE_ASSERT(red >= 0 && red <= 31);
DE_ASSERT(green >= 0 && green <= 63);
DE_ASSERT(blue >= 0 && blue <= 31);
// Fill the channel data structures
result.blue.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_5BITS;
result.blue.unsigned_byte_data = blue;
result.green.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_6BITS;
result.green.unsigned_byte_data = green;
result.red.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_5BITS;
result.red.unsigned_byte_data = red;
break;
}
}
if (is_source_pixel)
{
result.alpha.data_type = CHANNEL_DATA_TYPE_NONE;
}
else
{
result.alpha.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_8BITS;
result.alpha.unsigned_byte_data = 255;
}
result.data_internalformat = GL_RGB565;
result.data_type = type;
return result;
}
/** Retrieves a PixelData instance describing a single pixel stored in
* GL_RGB8 internal format.
*
* @param is_source_pixel 1 if the pixel is going to be used as conversion source,
* 0 otherwise.
* @param type GLES type the pixel uses. Must be GL_UNSIGNED_BYTE.
* @param red Value for red channel.
* @param green Value for green channel.
* @param blue Value for blue channel.
*
* @return Filled PixelData instance.
**/
PixelData ConversionDatabase::getRGB8PixelData(int is_source_pixel, GLenum type, unsigned char red, unsigned char green,
unsigned char blue)
{
PixelData result;
DE_ASSERT(type == GL_UNSIGNED_BYTE);
deMemset(&result, 0, sizeof(result));
if (is_source_pixel)
{
result.alpha.data_type = CHANNEL_DATA_TYPE_NONE;
}
else
{
result.alpha.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_8BITS;
result.alpha.unsigned_byte_data = 255;
}
result.blue.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_8BITS;
result.blue.unsigned_byte_data = blue;
result.green.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_8BITS;
result.green.unsigned_byte_data = green;
result.red.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_8BITS;
result.red.unsigned_byte_data = red;
result.data_internalformat = GL_RGB8;
result.data_type = type;
return result;
}
/** Retrieves a PixelData instance describing a single pixel stored in
* GL_RGB8I internal format.
*
* @param is_source_pixel 1 if the pixel is going to be used as conversion source,
* 0 otherwise.
* @param type GLES type the pixel uses. Must be:
* 1) GL_BYTE for source pixels.
* 2) GL_INT for destination pixels.
* @param red Value for red channel.
* @param green Value for green channel.
* @param blue Value for blue channel.
*
* @return Filled PixelData instance.
**/
PixelData ConversionDatabase::getRGB8IPixelData(int is_source_pixel, GLenum type, int red, int green, int blue)
{
PixelData result;
if (is_source_pixel)
DE_ASSERT(type == GL_BYTE);
else
DE_ASSERT(type == GL_INT);
deMemset(&result, 0, sizeof(result));
if (is_source_pixel)
{
result.alpha.data_type = CHANNEL_DATA_TYPE_NONE;
result.blue.data_type = CHANNEL_DATA_TYPE_SIGNED_BYTE_8BITS;
result.blue.signed_byte_data = blue;
result.green.data_type = CHANNEL_DATA_TYPE_SIGNED_BYTE_8BITS;
result.green.signed_byte_data = green;
result.red.data_type = CHANNEL_DATA_TYPE_SIGNED_BYTE_8BITS;
result.red.signed_byte_data = red;
}
else
{
result.alpha.data_type = CHANNEL_DATA_TYPE_SIGNED_INTEGER_32BITS;
result.alpha.signed_integer_data = 1;
result.blue.data_type = CHANNEL_DATA_TYPE_SIGNED_INTEGER_32BITS;
result.blue.signed_integer_data = blue;
result.green.data_type = CHANNEL_DATA_TYPE_SIGNED_INTEGER_32BITS;
result.green.signed_integer_data = green;
result.red.data_type = CHANNEL_DATA_TYPE_SIGNED_INTEGER_32BITS;
result.red.signed_integer_data = red;
}
result.data_internalformat = GL_RGB8I;
result.data_type = type;
return result;
}
/** Retrieves a PixelData instance describing a single pixel stored in
* GL_RGB8UI internal format.
*
* @param is_source_pixel 1 if the pixel is going to be used as conversion source,
* 0 otherwise.
* @param type GLES type the pixel uses. Must be:
* 1) GL_UNSIGNED_BYTE for source pixels.
* 2) GL_UNSIGNED_INT for destination pixels.
* @param red Value for red channel.
* @param green Value for green channel.
* @param blue Value for blue channel.
* @param alpha Value for alpha channel.
*
* @return Filled PixelData instance.
**/
PixelData ConversionDatabase::getRGB8UIPixelData(int is_source_pixel, GLenum type, unsigned int red, unsigned int green,
unsigned int blue)
{
PixelData result;
if (is_source_pixel)
DE_ASSERT(type == GL_UNSIGNED_BYTE);
else
DE_ASSERT(type == GL_UNSIGNED_INT);
deMemset(&result, 0, sizeof(result));
if (is_source_pixel)
{
result.alpha.data_type = CHANNEL_DATA_TYPE_NONE;
result.blue.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_8BITS;
result.blue.unsigned_byte_data = blue;
result.green.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_8BITS;
result.green.unsigned_byte_data = green;
result.red.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_8BITS;
result.red.unsigned_byte_data = red;
}
else
{
result.alpha.data_type = CHANNEL_DATA_TYPE_UNSIGNED_INTEGER_32BITS;
result.alpha.unsigned_integer_data = 1;
result.blue.data_type = CHANNEL_DATA_TYPE_UNSIGNED_INTEGER_32BITS;
result.blue.unsigned_integer_data = blue;
result.green.data_type = CHANNEL_DATA_TYPE_UNSIGNED_INTEGER_32BITS;
result.green.unsigned_integer_data = green;
result.red.data_type = CHANNEL_DATA_TYPE_UNSIGNED_INTEGER_32BITS;
result.red.unsigned_integer_data = red;
}
result.data_internalformat = GL_RGB8UI;
result.data_type = type;
return result;
}
/** Retrieves a PixelData instance describing a single pixel stored in
* GL_RGBA16I internal format.
*
* @param is_source_pixel 1 if the pixel is going to be used as conversion source,
* 0 otherwise.
* @param type GLES type the pixel uses. Must be:
* 1) GL_SHORT for source pixels.
* 2) GL_INT for destination pixels.
* @param red Value for red channel.
* @param green Value for green channel.
* @param blue Value for blue channel.
* @param alpha Value for alpha channel.
*
* @return Filled PixelData instance.
**/
PixelData ConversionDatabase::getRGBA16IPixelData(int is_source_pixel, GLenum type, int red, int green, int blue,
int alpha)
{
PixelData result;
if (is_source_pixel)
DE_ASSERT(type == GL_SHORT);
else
DE_ASSERT(type == GL_INT);
deMemset(&result, 0, sizeof(result));
if (is_source_pixel)
{
result.alpha.data_type = CHANNEL_DATA_TYPE_SIGNED_SHORT_16BITS;
result.alpha.signed_short_data = alpha;
result.blue.data_type = CHANNEL_DATA_TYPE_SIGNED_SHORT_16BITS;
result.blue.signed_short_data = blue;
result.green.data_type = CHANNEL_DATA_TYPE_SIGNED_SHORT_16BITS;
result.green.signed_short_data = green;
result.red.data_type = CHANNEL_DATA_TYPE_SIGNED_SHORT_16BITS;
result.red.signed_short_data = red;
}
else
{
result.alpha.data_type = CHANNEL_DATA_TYPE_SIGNED_INTEGER_32BITS;
result.alpha.signed_integer_data = alpha;
result.blue.data_type = CHANNEL_DATA_TYPE_SIGNED_INTEGER_32BITS;
result.blue.signed_integer_data = blue;
result.green.data_type = CHANNEL_DATA_TYPE_SIGNED_INTEGER_32BITS;
result.green.signed_integer_data = green;
result.red.data_type = CHANNEL_DATA_TYPE_SIGNED_INTEGER_32BITS;
result.red.signed_integer_data = red;
}
result.data_internalformat = GL_RGBA16I;
result.data_type = type;
return result;
}
/** Retrieves a PixelData instance describing a single pixel stored in
* GL_RGBA16UI internal format.
*
* @param is_source_pixel 1 if the pixel is going to be used as conversion source,
* 0 otherwise.
* @param type GLES type the pixel uses. Must be:
* 1) GL_UNSIGNED_SHORT for source pixels.
* 2) GL_UNSIGNED_INT for destination pixels.
* @param red Value for red channel.
* @param green Value for green channel.
* @param blue Value for blue channel.
* @param alpha Value for alpha channel.
*
* @return Filled PixelData instance.
**/
PixelData ConversionDatabase::getRGBA16UIPixelData(int is_source_pixel, GLenum type, unsigned int red,
unsigned int green, unsigned int blue, unsigned int alpha)
{
PixelData result;
if (is_source_pixel)
DE_ASSERT(type == GL_UNSIGNED_SHORT);
else
DE_ASSERT(type == GL_UNSIGNED_INT);
deMemset(&result, 0, sizeof(result));
if (is_source_pixel)
{
result.alpha.data_type = CHANNEL_DATA_TYPE_UNSIGNED_SHORT_16BITS;
result.alpha.unsigned_short_data = alpha;
result.blue.data_type = CHANNEL_DATA_TYPE_UNSIGNED_SHORT_16BITS;
result.blue.unsigned_short_data = blue;
result.green.data_type = CHANNEL_DATA_TYPE_UNSIGNED_SHORT_16BITS;
result.green.unsigned_short_data = green;
result.red.data_type = CHANNEL_DATA_TYPE_UNSIGNED_SHORT_16BITS;
result.red.unsigned_short_data = red;
}
else
{
result.alpha.data_type = CHANNEL_DATA_TYPE_UNSIGNED_INTEGER_32BITS;
result.alpha.unsigned_integer_data = alpha;
result.blue.data_type = CHANNEL_DATA_TYPE_UNSIGNED_INTEGER_32BITS;
result.blue.unsigned_integer_data = blue;
result.green.data_type = CHANNEL_DATA_TYPE_UNSIGNED_INTEGER_32BITS;
result.green.unsigned_integer_data = green;
result.red.data_type = CHANNEL_DATA_TYPE_UNSIGNED_INTEGER_32BITS;
result.red.unsigned_integer_data = red;
}
result.data_internalformat = GL_RGBA16UI;
result.data_type = type;
return result;
}
/** Retrieves a PixelData instance describing a single pixel stored in
* GL_RGBA32I internal format.
*
* @param is_source_pixel 1 if the pixel is going to be used as conversion source,
* 0 otherwise.
* @param type GLES type the pixel uses. Must be GL_INT.
* @param red Value for red channel.
* @param green Value for green channel.
* @param blue Value for blue channel.
* @param alpha Value for alpha channel.
*
* @return Filled PixelData instance.
**/
PixelData ConversionDatabase::getRGBA32IPixelData(GLenum type, int red, int green, int blue, int alpha)
{
PixelData result;
DE_ASSERT(type == GL_INT);
deMemset(&result, 0, sizeof(result));
result.alpha.data_type = CHANNEL_DATA_TYPE_SIGNED_INTEGER_32BITS;
result.alpha.signed_integer_data = alpha;
result.blue.data_type = CHANNEL_DATA_TYPE_SIGNED_INTEGER_32BITS;
result.blue.signed_integer_data = blue;
result.green.data_type = CHANNEL_DATA_TYPE_SIGNED_INTEGER_32BITS;
result.green.signed_integer_data = green;
result.red.data_type = CHANNEL_DATA_TYPE_SIGNED_INTEGER_32BITS;
result.red.signed_integer_data = red;
result.data_internalformat = GL_RGBA32I;
result.data_type = type;
return result;
}
/** Retrieves a PixelData instance describing a single pixel stored in
* GL_RGBA32UI internal format.
*
* @param is_source_pixel 1 if the pixel is going to be used as conversion source,
* 0 otherwise.
* @param type GLES type the pixel uses. Must be GL_UNSIGNED_INT.
* @param red Value for red channel.
* @param green Value for green channel.
* @param blue Value for blue channel.
* @param alpha Value for alpha channel.
*
* @return Filled PixelData instance.
**/
PixelData ConversionDatabase::getRGBA32UIPixelData(GLenum type, unsigned int red, unsigned int green, unsigned int blue,
unsigned int alpha)
{
PixelData result;
DE_ASSERT(type == GL_UNSIGNED_INT);
deMemset(&result, 0, sizeof(result));
result.alpha.data_type = CHANNEL_DATA_TYPE_UNSIGNED_INTEGER_32BITS;
result.alpha.unsigned_integer_data = alpha;
result.blue.data_type = CHANNEL_DATA_TYPE_UNSIGNED_INTEGER_32BITS;
result.blue.unsigned_integer_data = blue;
result.green.data_type = CHANNEL_DATA_TYPE_UNSIGNED_INTEGER_32BITS;
result.green.unsigned_integer_data = green;
result.red.data_type = CHANNEL_DATA_TYPE_UNSIGNED_INTEGER_32BITS;
result.red.unsigned_integer_data = red;
result.data_internalformat = GL_RGBA32UI;
result.data_type = type;
return result;
}
/** Retrieves a PixelData instance describing a single pixel stored in
* GL_RGBA8I internal format.
*
* @param is_source_pixel 1 if the pixel is going to be used as conversion source,
* 0 otherwise.
* @param type GLES type the pixel uses. Must be:
* 1) GL_BYTE for source pixels.
* 2) GL_INT for destination pixels.
* @param red Value for red channel.
* @param green Value for green channel.
* @param blue Value for blue channel.
* @param alpha Value for alpha channel.
*
* @return Filled PixelData instance.
**/
PixelData ConversionDatabase::getRGBA8IPixelData(int is_source_pixel, GLenum type, int red, int green, int blue,
int alpha)
{
PixelData result;
if (is_source_pixel)
DE_ASSERT(type == GL_BYTE);
else
DE_ASSERT(type == GL_INT);
deMemset(&result, 0, sizeof(result));
if (is_source_pixel)
{
result.alpha.data_type = CHANNEL_DATA_TYPE_SIGNED_BYTE_8BITS;
result.alpha.signed_byte_data = alpha;
result.blue.data_type = CHANNEL_DATA_TYPE_SIGNED_BYTE_8BITS;
result.blue.signed_byte_data = blue;
result.green.data_type = CHANNEL_DATA_TYPE_SIGNED_BYTE_8BITS;
result.green.signed_byte_data = green;
result.red.data_type = CHANNEL_DATA_TYPE_SIGNED_BYTE_8BITS;
result.red.signed_byte_data = red;
}
else
{
result.alpha.data_type = CHANNEL_DATA_TYPE_SIGNED_INTEGER_32BITS;
result.alpha.signed_integer_data = alpha;
result.blue.data_type = CHANNEL_DATA_TYPE_SIGNED_INTEGER_32BITS;
result.blue.signed_integer_data = blue;
result.green.data_type = CHANNEL_DATA_TYPE_SIGNED_INTEGER_32BITS;
result.green.signed_integer_data = green;
result.red.data_type = CHANNEL_DATA_TYPE_SIGNED_INTEGER_32BITS;
result.red.signed_integer_data = red;
}
result.data_internalformat = GL_RGBA8I;
result.data_type = type;
return result;
}
/** Retrieves a PixelData instance describing a single pixel stored in
* GL_RGBA8UI internal format.
*
* @param is_source_pixel 1 if the pixel is going to be used as conversion source,
* 0 otherwise.
* @param type GLES type the pixel uses. Must be:
* 1) GL_UNSIGNED_BYTE for source pixels.
* 2) GL_UNSIGNED_INT for destination pixels.
* @param red Value for red channel.
* @param green Value for green channel.
* @param blue Value for blue channel.
* @param alpha Value for alpha channel.
*
* @return Filled PixelData instance.
**/
PixelData ConversionDatabase::getRGBA8UIPixelData(int is_source_pixel, GLenum type, unsigned int red,
unsigned int green, unsigned int blue, unsigned int alpha)
{
PixelData result;
if (is_source_pixel)
DE_ASSERT(type == GL_UNSIGNED_BYTE);
else
DE_ASSERT(type == GL_UNSIGNED_INT);
deMemset(&result, 0, sizeof(result));
if (is_source_pixel)
{
result.alpha.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_8BITS;
result.alpha.unsigned_byte_data = alpha;
result.blue.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_8BITS;
result.blue.unsigned_byte_data = blue;
result.green.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_8BITS;
result.green.unsigned_byte_data = green;
result.red.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_8BITS;
result.red.unsigned_byte_data = red;
}
else
{
result.alpha.data_type = CHANNEL_DATA_TYPE_UNSIGNED_INTEGER_32BITS;
result.alpha.unsigned_integer_data = alpha;
result.blue.data_type = CHANNEL_DATA_TYPE_UNSIGNED_INTEGER_32BITS;
result.blue.unsigned_integer_data = blue;
result.green.data_type = CHANNEL_DATA_TYPE_UNSIGNED_INTEGER_32BITS;
result.green.unsigned_integer_data = green;
result.red.data_type = CHANNEL_DATA_TYPE_UNSIGNED_INTEGER_32BITS;
result.red.unsigned_integer_data = red;
}
result.data_internalformat = GL_RGBA8UI;
result.data_type = type;
return result;
}
/** Retrieves a PixelData instance describing a single pixel stored in
* GL_RGBA4 internal format.
*
* @param is_source_pixel 1 if the pixel is going to be used as conversion source,
* 0 otherwise.
* @param type GLES type the pixel uses. Must be:
* 1) GL_UNSIGNED_BYTE or GL_UNSIGNED_SHORT_4_4_4_4 for source pixels.
* 2) GL_UNSIGNED_BYTE for destination pixels.
* @param red Value for red channel.
* @param green Value for green channel.
* @param blue Value for blue channel.
* @param alpha Value for alpha channel.
*
* @return Filled PixelData instance.
**/
PixelData ConversionDatabase::getRGBA4PixelData(int is_source_pixel, GLenum type, unsigned char red,
unsigned char green, unsigned char blue, unsigned char alpha)
{
PixelData result;
if (is_source_pixel)
DE_ASSERT(type == GL_UNSIGNED_BYTE || type == GL_UNSIGNED_SHORT_4_4_4_4);
else
DE_ASSERT(type == GL_UNSIGNED_BYTE);
deMemset(&result, 0, sizeof(result));
switch (type)
{
case GL_UNSIGNED_BYTE:
{
// Fill the channel data structures
result.alpha.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_8BITS;
result.alpha.unsigned_byte_data = alpha;
result.blue.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_8BITS;
result.blue.unsigned_byte_data = blue;
result.green.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_8BITS;
result.green.unsigned_byte_data = green;
result.red.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_8BITS;
result.red.unsigned_byte_data = red;
break;
}
case GL_UNSIGNED_SHORT_4_4_4_4:
{
DE_ASSERT(red <= 15);
DE_ASSERT(green <= 15);
DE_ASSERT(blue <= 15);
DE_ASSERT(alpha <= 15);
// Fill the channel data structures
result.alpha.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_4BITS;
result.alpha.unsigned_byte_data = alpha;
result.blue.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_4BITS;
result.blue.unsigned_byte_data = blue;
result.green.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_4BITS;
result.green.unsigned_byte_data = green;
result.red.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_4BITS;
result.red.unsigned_byte_data = red;
break;
}
}
result.data_internalformat = GL_RGBA4;
result.data_type = type;
return result;
}
/** Retrieves a PixelData instance describing a single pixel stored in
* GL_RGBA8 internal format.
*
* @param is_source_pixel 1 if the pixel is going to be used as conversion source,
* 0 otherwise.
* @param type GLES type the pixel uses. Must be GL_UNSIGNED_BYTE.
* @param red Value for red channel.
* @param green Value for green channel.
* @param blue Value for blue channel.
* @param alpha Value for alpha channel.
*
* @return Filled PixelData instance.
**/
PixelData ConversionDatabase::getRGBA8PixelData(GLenum type, unsigned char red, unsigned char green, unsigned char blue,
unsigned char alpha)
{
PixelData result;
DE_ASSERT(type == GL_UNSIGNED_BYTE);
deMemset(&result, 0, sizeof(result));
result.alpha.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_8BITS;
result.alpha.unsigned_byte_data = alpha;
result.blue.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_8BITS;
result.blue.unsigned_byte_data = blue;
result.green.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_8BITS;
result.green.unsigned_byte_data = green;
result.red.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_8BITS;
result.red.unsigned_byte_data = red;
result.data_internalformat = GL_RGBA8;
result.data_type = type;
return result;
}
/** Retrieves a PixelData instance describing a single pixel stored in
* GL_SRGB8_ALPHA8 internal format.
*
* @param type GLES type the pixel uses. Must be GL_UNSIGNED_BYTE.
* @param red Value for red channel.
* @param green Value for green channel.
* @param blue Value for blue channel.
* @param alpha Value for alpha channel.
*
* @return Filled PixelData instance.
**/
PixelData ConversionDatabase::getSRGB8Alpha8PixelData(GLenum type, unsigned char red, unsigned char green,
unsigned char blue, unsigned char alpha)
{
PixelData result = getRGBA8PixelData(type, red, green, blue, alpha);
result.data_internalformat = GL_SRGB8_ALPHA8;
return result;
}
/** Retrieves a PixelData instance describing a single pixel stored in
* GL_SRGB8 internal format.
*
* @param is_source_pixel 1 if the pixel is going to be used as conversion source,
* 0 otherwise.
* @param type GLES type the pixel uses. Must be GL_UNSIGNED_BYTE.
* @param red Value for red channel.
* @param green Value for green channel.
* @param blue Value for blue channel.
*
* @return Filled PixelData instance.
**/
PixelData ConversionDatabase::getSRGB8PixelData(int is_source_pixel, GLenum type, unsigned char red,
unsigned char green, unsigned char blue)
{
PixelData result = getSRGB8Alpha8PixelData(type, red, green, blue, 0);
if (is_source_pixel)
{
result.alpha.data_type = CHANNEL_DATA_TYPE_NONE;
result.alpha.unsigned_byte_data = 0;
}
else
{
result.alpha.data_type = CHANNEL_DATA_TYPE_UNSIGNED_BYTE_8BITS;
result.alpha.unsigned_byte_data = 255;
}
result.data_internalformat = GL_SRGB8;
return result;
}
/** Retrieves a PixelData instance describing a single pixel stored in
* GL_R16F internal format.
*
* @param is_source_pixel 1 if the pixel is going to be used as conversion source,
* 0 otherwise.
* @param type GLES type the pixel uses. Must be GL_HALF_FLOAT
* @param red Value for red channel.
*
* @return Filled PixelData instance.
**/
PixelData ConversionDatabase::getR16FPixelData(int is_source_pixel, GLenum type, float red)
{
PixelData result;
DE_ASSERT(type == GL_HALF_FLOAT);
deMemset(&result, 0, sizeof(result));
if (is_source_pixel)
{
result.red.float_data = red;