13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#ifndef _TCUCOMPRESSEDTEXTURE_HPP 23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#define _TCUCOMPRESSEDTEXTURE_HPP 33c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*------------------------------------------------------------------------- 43c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program Tester Core 53c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * ---------------------------------------- 63c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 73c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Copyright 2014 The Android Open Source Project 83c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 93c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Licensed under the Apache License, Version 2.0 (the "License"); 103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * you may not use this file except in compliance with the License. 113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * You may obtain a copy of the License at 123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * http://www.apache.org/licenses/LICENSE-2.0 143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Unless required by applicable law or agreed to in writing, software 163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * distributed under the License is distributed on an "AS IS" BASIS, 173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * See the License for the specific language governing permissions and 193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * limitations under the License. 203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*! 223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \file 233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Compressed Texture Utilities. 243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuDefs.hpp" 273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTexture.hpp" 283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <vector> 303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 313c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace tcu 323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*--------------------------------------------------------------------*//*! 353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Compressed texture 363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * This class implements container for common compressed texture formats. 383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Reference decoding to uncompressed formats is supported. 393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 403c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass CompressedTexture 413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 423c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum Format 443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ETC1_RGB8 = 0, 463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EAC_R11, 473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EAC_SIGNED_R11, 483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EAC_RG11, 493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry EAC_SIGNED_RG11, 503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ETC2_RGB8, 513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ETC2_SRGB8, 523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ETC2_RGB8_PUNCHTHROUGH_ALPHA1, 533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ETC2_SRGB8_PUNCHTHROUGH_ALPHA1, 543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ETC2_EAC_RGBA8, 553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ETC2_EAC_SRGB8_ALPHA8, 563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ASTC_4x4_RGBA, 583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ASTC_5x4_RGBA, 593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ASTC_5x5_RGBA, 603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ASTC_6x5_RGBA, 613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ASTC_6x6_RGBA, 623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ASTC_8x5_RGBA, 633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ASTC_8x6_RGBA, 643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ASTC_8x8_RGBA, 653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ASTC_10x5_RGBA, 663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ASTC_10x6_RGBA, 673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ASTC_10x8_RGBA, 683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ASTC_10x10_RGBA, 693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ASTC_12x10_RGBA, 703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ASTC_12x12_RGBA, 713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ASTC_4x4_SRGB8_ALPHA8, 723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ASTC_5x4_SRGB8_ALPHA8, 733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ASTC_5x5_SRGB8_ALPHA8, 743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ASTC_6x5_SRGB8_ALPHA8, 753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ASTC_6x6_SRGB8_ALPHA8, 763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ASTC_8x5_SRGB8_ALPHA8, 773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ASTC_8x6_SRGB8_ALPHA8, 783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ASTC_8x8_SRGB8_ALPHA8, 793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ASTC_10x5_SRGB8_ALPHA8, 803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ASTC_10x6_SRGB8_ALPHA8, 813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ASTC_10x8_SRGB8_ALPHA8, 823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ASTC_10x10_SRGB8_ALPHA8, 833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ASTC_12x10_SRGB8_ALPHA8, 843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ASTC_12x12_SRGB8_ALPHA8, 853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FORMAT_LAST 873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry struct DecompressionParams 903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool isASTCModeLDR; //!< \note Ignored if not ASTC format. 923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DecompressionParams (bool isASTCModeLDR_) : isASTCModeLDR(isASTCModeLDR_) {} 943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CompressedTexture (Format format, int width, int height, int depth = 1); 983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CompressedTexture (void); 993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~CompressedTexture (void); 1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void setStorage (Format format, int width, int height, int depth = 1); 1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getWidth (void) const { return m_width; } 1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getHeight (void) const { return m_height; } 1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Format getFormat (void) const { return m_format; } 1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getDataSize (void) const { return (int)m_data.size(); } 1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const void* getData (void) const { return &m_data[0]; } 1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void* getData (void) { return &m_data[0]; } 1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TextureFormat getUncompressedFormat (void) const; 1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void decompress (const PixelBufferAccess& dst, const DecompressionParams& params = DecompressionParams(false)) const; 1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Format m_format; 1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_width; 1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_height; 1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_depth; 1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<deUint8> m_data; 1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool isEtcFormat (CompressedTexture::Format fmt); 1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool isASTCFormat (CompressedTexture::Format fmt); 1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool isASTCSRGBFormat (CompressedTexture::Format fmt); 1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1253c827367444ee418f129b2c238299f49d3264554Jarkko PoyryIVec3 getASTCBlockSize (CompressedTexture::Format fmt); 1263c827367444ee418f129b2c238299f49d3264554Jarkko PoyryCompressedTexture::Format getASTCFormatByBlockSize (int width, int height, int depth, bool isSRGB); 1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // tcu 1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#endif // _TCUCOMPRESSEDTEXTURE_HPP 131