- Improved compressed texture system handling (it avoid code duplicate between all drivers).
- Added ETC1 and ETC2 compressed textures support via PVR loader. (This feature require tests on platform which support ETC1 and ETC2 formats). git-svn-id: http://svn.code.sf.net/p/irrlicht/code/branches/ogl-es@4530 dfc29bdd-3216-0410-991c-e03cc46cb475master
parent
c277059e51
commit
636966da49
|
@ -127,6 +127,12 @@ namespace video
|
|||
//! Support for PVRTC2 compressed textures.
|
||||
EVDF_TEXTURE_COMPRESSED_PVRTC2,
|
||||
|
||||
//! Support for ETC1 compressed textures.
|
||||
EVDF_TEXTURE_COMPRESSED_ETC1,
|
||||
|
||||
//! Support for ETC2 compressed textures.
|
||||
EVDF_TEXTURE_COMPRESSED_ETC2,
|
||||
|
||||
//! Only used for counting the elements of this enum
|
||||
EVDF_COUNT
|
||||
};
|
||||
|
|
|
@ -125,16 +125,21 @@ public:
|
|||
case ECF_DXT4:
|
||||
case ECF_DXT5:
|
||||
return 32;
|
||||
case ECF_PVRTC_R2G2B2:
|
||||
return 6;
|
||||
case ECF_PVRTC_A2R2G2B2:
|
||||
case ECF_PVRTC2_A2R2G2B2:
|
||||
return 8;
|
||||
case ECF_PVRTC_R4G4B4:
|
||||
case ECF_PVRTC_RGB2:
|
||||
return 12;
|
||||
case ECF_PVRTC_A4R4G4B4:
|
||||
case ECF_PVRTC2_A4R4G4B4:
|
||||
case ECF_PVRTC_ARGB2:
|
||||
case ECF_PVRTC2_ARGB2:
|
||||
return 16;
|
||||
case ECF_PVRTC_RGB4:
|
||||
return 24;
|
||||
case ECF_PVRTC_ARGB4:
|
||||
case ECF_PVRTC2_ARGB4:
|
||||
return 32;
|
||||
case ECF_ETC1:
|
||||
case ECF_ETC2_RGB:
|
||||
return 24;
|
||||
case ECF_ETC2_ARGB:
|
||||
return 32;
|
||||
case ECF_R16F:
|
||||
return 16;
|
||||
case ECF_G16R16F:
|
||||
|
@ -171,20 +176,25 @@ public:
|
|||
case ECF_DXT5:
|
||||
compressedImageSize = ((width + 3) / 4) * ((height + 3) / 4) * 16;
|
||||
break;
|
||||
case ECF_PVRTC_R2G2B2:
|
||||
case ECF_PVRTC_A2R2G2B2:
|
||||
case ECF_PVRTC_RGB2:
|
||||
case ECF_PVRTC_ARGB2:
|
||||
compressedImageSize = (core::max_<u32>(width, 16) * core::max_<u32>(height, 8) * 2 + 7) / 8;
|
||||
break;
|
||||
case ECF_PVRTC_R4G4B4:
|
||||
case ECF_PVRTC_A4R4G4B4:
|
||||
case ECF_PVRTC_RGB4:
|
||||
case ECF_PVRTC_ARGB4:
|
||||
compressedImageSize = (core::max_<u32>(width, 8) * core::max_<u32>(height, 8) * 4 + 7) / 8;
|
||||
break;
|
||||
case ECF_PVRTC2_A2R2G2B2:
|
||||
case ECF_PVRTC2_ARGB2:
|
||||
compressedImageSize = core::ceil32(width / 8.0f) * core::ceil32(height / 4.0f) * 8;
|
||||
break;
|
||||
case ECF_PVRTC2_A4R4G4B4:
|
||||
case ECF_PVRTC2_ARGB4:
|
||||
case ECF_ETC1:
|
||||
case ECF_ETC2_RGB:
|
||||
compressedImageSize = core::ceil32(width / 4.0f) * core::ceil32(height / 4.0f) * 8;
|
||||
break;
|
||||
case ECF_ETC2_ARGB:
|
||||
compressedImageSize = core::ceil32(width / 4.0f) * core::ceil32(height / 4.0f) * 16;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -202,12 +212,15 @@ public:
|
|||
case ECF_DXT3:
|
||||
case ECF_DXT4:
|
||||
case ECF_DXT5:
|
||||
case ECF_PVRTC_R2G2B2:
|
||||
case ECF_PVRTC_A2R2G2B2:
|
||||
case ECF_PVRTC2_A2R2G2B2:
|
||||
case ECF_PVRTC_R4G4B4:
|
||||
case ECF_PVRTC_A4R4G4B4:
|
||||
case ECF_PVRTC2_A4R4G4B4:
|
||||
case ECF_PVRTC_RGB2:
|
||||
case ECF_PVRTC_ARGB2:
|
||||
case ECF_PVRTC2_ARGB2:
|
||||
case ECF_PVRTC_RGB4:
|
||||
case ECF_PVRTC_ARGB4:
|
||||
case ECF_PVRTC2_ARGB4:
|
||||
case ECF_ETC1:
|
||||
case ECF_ETC2_RGB:
|
||||
case ECF_ETC2_ARGB:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
|
@ -220,6 +233,9 @@ public:
|
|||
if it is restricted to RTTs. */
|
||||
static bool isRenderTargetOnlyFormat(const ECOLOR_FORMAT format)
|
||||
{
|
||||
if (isCompressedFormat(format))
|
||||
return false;
|
||||
|
||||
switch(format)
|
||||
{
|
||||
case ECF_A1R5G5B5:
|
||||
|
|
|
@ -48,23 +48,32 @@ namespace video
|
|||
//! DXT5 color format.
|
||||
ECF_DXT5,
|
||||
|
||||
//! PVRTC RGB 2bpp
|
||||
ECF_PVRTC_R2G2B2,
|
||||
//! PVRTC RGB 2bpp.
|
||||
ECF_PVRTC_RGB2,
|
||||
|
||||
//! PVRTC ARGB 2bpp
|
||||
ECF_PVRTC_A2R2G2B2,
|
||||
//! PVRTC ARGB 2bpp.
|
||||
ECF_PVRTC_ARGB2,
|
||||
|
||||
//! PVRTC RGB 4bpp
|
||||
ECF_PVRTC_R4G4B4,
|
||||
//! PVRTC RGB 4bpp.
|
||||
ECF_PVRTC_RGB4,
|
||||
|
||||
//! PVRTC ARGB 4bpp
|
||||
ECF_PVRTC_A4R4G4B4,
|
||||
//! PVRTC ARGB 4bpp.
|
||||
ECF_PVRTC_ARGB4,
|
||||
|
||||
//! PVRTC2 ARGB 2bpp
|
||||
ECF_PVRTC2_A2R2G2B2,
|
||||
//! PVRTC2 ARGB 2bpp.
|
||||
ECF_PVRTC2_ARGB2,
|
||||
|
||||
//! PVRTC2 ARGB 4bpp
|
||||
ECF_PVRTC2_A4R4G4B4,
|
||||
//! PVRTC2 ARGB 4bpp.
|
||||
ECF_PVRTC2_ARGB4,
|
||||
|
||||
//! ETC1 RGB.
|
||||
ECF_ETC1,
|
||||
|
||||
//! ETC2 RGB.
|
||||
ECF_ETC2_RGB,
|
||||
|
||||
//! ETC2 ARGB.
|
||||
ECF_ETC2_ARGB,
|
||||
|
||||
/** Floating Point formats. The following formats may only be used for render target textures. */
|
||||
|
||||
|
|
|
@ -610,11 +610,6 @@ bool CD3D8Driver::queryFeature(E_VIDEO_DRIVER_FEATURE feature) const
|
|||
case EVDF_BLEND_OPERATIONS:
|
||||
case EVDF_TEXTURE_MATRIX:
|
||||
return true;
|
||||
case EVDF_TEXTURE_COMPRESSED_DXT:
|
||||
return false; // TO-DO
|
||||
case EVDF_TEXTURE_COMPRESSED_PVRTC:
|
||||
case EVDF_TEXTURE_COMPRESSED_PVRTC2:
|
||||
return false;
|
||||
default:
|
||||
return false;
|
||||
};
|
||||
|
|
|
@ -686,6 +686,8 @@ bool CD3D9Driver::queryFeature(E_VIDEO_DRIVER_FEATURE feature) const
|
|||
return true;
|
||||
case EVDF_TEXTURE_COMPRESSED_PVRTC:
|
||||
case EVDF_TEXTURE_COMPRESSED_PVRTC2:
|
||||
case EVDF_TEXTURE_COMPRESSED_ETC1:
|
||||
case EVDF_TEXTURE_COMPRESSED_ETC2:
|
||||
return false;
|
||||
default:
|
||||
return false;
|
||||
|
|
|
@ -67,32 +67,10 @@ CD3D9Texture::CD3D9Texture(IImage* image, CD3D9Driver* driver,
|
|||
|
||||
if (image)
|
||||
{
|
||||
if(image->getColorFormat() == ECF_DXT1 || image->getColorFormat() == ECF_DXT2 || image->getColorFormat() == ECF_DXT3 || image->getColorFormat() == ECF_DXT4 || image->getColorFormat() == ECF_DXT5)
|
||||
{
|
||||
if(!Driver->queryFeature(EVDF_TEXTURE_COMPRESSED_DXT))
|
||||
{
|
||||
os::Printer::log("DXT texture compression not available.", ELL_ERROR);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(image->getColorFormat() == ECF_PVRTC_R2G2B2 || image->getColorFormat() == ECF_PVRTC_A2R2G2B2 || image->getColorFormat() == ECF_PVRTC_R4G4B4 || image->getColorFormat() == ECF_PVRTC_A4R4G4B4)
|
||||
{
|
||||
if(!Driver->queryFeature(EVDF_TEXTURE_COMPRESSED_PVRTC))
|
||||
{
|
||||
os::Printer::log("PVRTC texture compression not available.", ELL_ERROR);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(image->getColorFormat() == ECF_PVRTC2_A2R2G2B2 || image->getColorFormat() == ECF_PVRTC2_A4R4G4B4)
|
||||
{
|
||||
if(!Driver->queryFeature(EVDF_TEXTURE_COMPRESSED_PVRTC2))
|
||||
{
|
||||
os::Printer::log("PVRTC2 texture compression not available.", ELL_ERROR);
|
||||
return;
|
||||
}
|
||||
}
|
||||
IsCompressed = IImage::isCompressedFormat(image->getColorFormat());
|
||||
|
||||
if (!Driver->checkColorFormat(image->getColorFormat(), image->getDimension()))
|
||||
return;
|
||||
|
||||
if (createTexture(flags, image))
|
||||
{
|
||||
|
@ -445,13 +423,7 @@ bool CD3D9Texture::copyTexture(IImage * image)
|
|||
|
||||
if (IsCompressed)
|
||||
{
|
||||
u32 compressedDataSize = 0;
|
||||
|
||||
if(ColorFormat == ECF_DXT1)
|
||||
compressedDataSize = ((TextureSize.Width + 3) / 4) * ((TextureSize.Height + 3) / 4) * 8;
|
||||
else if (ColorFormat == ECF_DXT2 || ColorFormat == ECF_DXT3 || ColorFormat == ECF_DXT4 || ColorFormat == ECF_DXT5)
|
||||
compressedDataSize = ((TextureSize.Width + 3) / 4) * ((TextureSize.Height + 3) / 4) * 16;
|
||||
|
||||
u32 compressedDataSize = IImage::getCompressedImageSize(ColorFormat, TextureSize.Width, TextureSize.Height);
|
||||
memcpy(rect.pBits, image->lock(), compressedDataSize);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -95,22 +95,25 @@ IImage* CImageLoaderPVR::loadImage(io::IReadFile* file) const
|
|||
switch(header.PixelFormat)
|
||||
{
|
||||
case 0: // PVRTC 2bpp RGB
|
||||
format = ECF_PVRTC_R2G2B2;
|
||||
format = ECF_PVRTC_RGB2;
|
||||
break;
|
||||
case 1: // PVRTC 2bpp RGBA
|
||||
format = ECF_PVRTC_A2R2G2B2;
|
||||
format = ECF_PVRTC_ARGB2;
|
||||
break;
|
||||
case 2: // PVRTC 4bpp RGB
|
||||
format = ECF_PVRTC_R4G4B4;
|
||||
format = ECF_PVRTC_RGB4;
|
||||
break;
|
||||
case 3: // PVRTC 4bpp RGBA
|
||||
format = ECF_PVRTC_A4R4G4B4;
|
||||
format = ECF_PVRTC_ARGB4;
|
||||
break;
|
||||
case 4: // PVRTC-II 2bpp
|
||||
format = ECF_PVRTC2_A2R2G2B2;
|
||||
format = ECF_PVRTC2_ARGB2;
|
||||
break;
|
||||
case 5: // PVRTC-II 4bpp
|
||||
format = ECF_PVRTC2_A4R4G4B4;
|
||||
format = ECF_PVRTC2_ARGB4;
|
||||
break;
|
||||
case 6: // ETC1
|
||||
format = ECF_ETC1;
|
||||
break;
|
||||
case 7: // DXT1 / BC1
|
||||
format = ECF_DXT1;
|
||||
|
@ -123,6 +126,15 @@ IImage* CImageLoaderPVR::loadImage(io::IReadFile* file) const
|
|||
case 11: // DXT5 / BC3
|
||||
format = ECF_DXT5;
|
||||
break;
|
||||
case 22: // ETC2 RGB
|
||||
format = ECF_ETC2_RGB;
|
||||
break;
|
||||
case 23: // ETC2 RGBA
|
||||
format = ECF_ETC2_ARGB;
|
||||
break;
|
||||
default:
|
||||
format = ECF_UNKNOWN;
|
||||
break;
|
||||
}
|
||||
|
||||
if (format != ECF_UNKNOWN)
|
||||
|
|
|
@ -2356,6 +2356,89 @@ void CNullDriver::printVersion()
|
|||
}
|
||||
|
||||
|
||||
// Check support for compression texture format.
|
||||
bool CNullDriver::checkColorFormat(ECOLOR_FORMAT format, const core::dimension2d<u32>& textureSize) const
|
||||
{
|
||||
bool status = true;
|
||||
|
||||
switch (format)
|
||||
{
|
||||
case ECF_DXT1:
|
||||
case ECF_DXT2:
|
||||
case ECF_DXT3:
|
||||
case ECF_DXT4:
|
||||
case ECF_DXT5:
|
||||
{
|
||||
core::dimension2d<u32> potSize = textureSize.getOptimalSize(true, false);
|
||||
|
||||
if(!queryFeature(EVDF_TEXTURE_COMPRESSED_DXT))
|
||||
{
|
||||
os::Printer::log("DXT texture compression not available.", ELL_ERROR);
|
||||
status = false;
|
||||
}
|
||||
else if(potSize != textureSize)
|
||||
{
|
||||
os::Printer::log("Invalid size of image for DXT compressed texture, size of image must be POT.", ELL_ERROR);
|
||||
status = false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ECF_PVRTC_RGB2:
|
||||
case ECF_PVRTC_ARGB2:
|
||||
case ECF_PVRTC_RGB4:
|
||||
case ECF_PVRTC_ARGB4:
|
||||
{
|
||||
core::dimension2d<u32> potSize = textureSize.getOptimalSize(true, true);
|
||||
|
||||
if(!queryFeature(EVDF_TEXTURE_COMPRESSED_PVRTC))
|
||||
{
|
||||
os::Printer::log("PVRTC texture compression not available.", ELL_ERROR);
|
||||
status = false;
|
||||
}
|
||||
else if(potSize != textureSize)
|
||||
{
|
||||
os::Printer::log("Invalid size of image for PVRTC compressed texture, size of image must be POT and squared.", ELL_ERROR);
|
||||
status = false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ECF_PVRTC2_ARGB2:
|
||||
case ECF_PVRTC2_ARGB4:
|
||||
{
|
||||
if(!queryFeature(EVDF_TEXTURE_COMPRESSED_PVRTC2))
|
||||
{
|
||||
os::Printer::log("PVRTC2 texture compression not available.", ELL_ERROR);
|
||||
status = false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ECF_ETC1:
|
||||
{
|
||||
if(!queryFeature(EVDF_TEXTURE_COMPRESSED_ETC1))
|
||||
{
|
||||
os::Printer::log("ETC1 texture compression not available.", ELL_ERROR);
|
||||
status = false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ECF_ETC2_RGB:
|
||||
case ECF_ETC2_ARGB:
|
||||
{
|
||||
if(!queryFeature(EVDF_TEXTURE_COMPRESSED_ETC2))
|
||||
{
|
||||
os::Printer::log("ETC2 texture compression not available.", ELL_ERROR);
|
||||
status = false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
//! creates a video driver
|
||||
IVideoDriver* createNullDriver(io::IFileSystem* io, const core::dimension2d<u32>& screenSize)
|
||||
{
|
||||
|
|
|
@ -691,6 +691,9 @@ namespace video
|
|||
// prints renderer version
|
||||
void printVersion();
|
||||
|
||||
// Check support for compression texture format.
|
||||
bool checkColorFormat(ECOLOR_FORMAT format, const core::dimension2d<u32>& textureSize) const;
|
||||
|
||||
//! normal map lookup 32 bit version
|
||||
inline f32 nml32(int x, int y, int pitch, int height, s32 *p) const
|
||||
{
|
||||
|
|
|
@ -227,6 +227,10 @@ namespace video
|
|||
return FeatureAvailable[IRR_IMG_texture_compression_pvrtc];
|
||||
case EVDF_TEXTURE_COMPRESSED_PVRTC2:
|
||||
return FeatureAvailable[IRR_IMG_texture_compression_pvrtc2];
|
||||
case EVDF_TEXTURE_COMPRESSED_ETC1:
|
||||
return FeatureAvailable[IRR_OES_compressed_ETC1_RGB8_texture];
|
||||
case EVDF_TEXTURE_COMPRESSED_ETC2:
|
||||
return false;
|
||||
case EVDF_STENCIL_BUFFER:
|
||||
return StencilBuffer;
|
||||
default:
|
||||
|
|
|
@ -61,8 +61,10 @@ COGLES2Texture::COGLES2Texture(IImage* origImage, const io::path& name, void* mi
|
|||
|
||||
HasMipMaps = Driver->getTextureCreationFlag(ETCF_CREATE_MIP_MAPS);
|
||||
getImageValues(origImage);
|
||||
|
||||
IsCompressed = IImage::isCompressedFormat(ColorFormat);
|
||||
|
||||
if (checkFormatCompatibility())
|
||||
if (Driver->checkColorFormat(ColorFormat, origImage->getDimension()))
|
||||
{
|
||||
if (IsCompressed)
|
||||
{
|
||||
|
@ -240,7 +242,7 @@ void COGLES2Texture::getFormatParameters(ECOLOR_FORMAT format, GLint& internalFo
|
|||
break;
|
||||
#endif
|
||||
#ifdef GL_IMG_texture_compression_pvrtc
|
||||
case ECF_PVRTC_R2G2B2:
|
||||
case ECF_PVRTC_RGB2:
|
||||
internalFormat = GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG;
|
||||
filtering = GL_LINEAR;
|
||||
pixelFormat = GL_RGB;
|
||||
|
@ -248,7 +250,7 @@ void COGLES2Texture::getFormatParameters(ECOLOR_FORMAT format, GLint& internalFo
|
|||
break;
|
||||
#endif
|
||||
#ifdef GL_IMG_texture_compression_pvrtc
|
||||
case ECF_PVRTC_A2R2G2B2:
|
||||
case ECF_PVRTC_ARGB2:
|
||||
internalFormat = GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;
|
||||
filtering = GL_LINEAR;
|
||||
pixelFormat = GL_RGBA;
|
||||
|
@ -256,7 +258,7 @@ void COGLES2Texture::getFormatParameters(ECOLOR_FORMAT format, GLint& internalFo
|
|||
break;
|
||||
#endif
|
||||
#ifdef GL_IMG_texture_compression_pvrtc
|
||||
case ECF_PVRTC_R4G4B4:
|
||||
case ECF_PVRTC_RGB4:
|
||||
internalFormat = GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG;
|
||||
filtering = GL_LINEAR;
|
||||
pixelFormat = GL_RGB;
|
||||
|
@ -264,7 +266,7 @@ void COGLES2Texture::getFormatParameters(ECOLOR_FORMAT format, GLint& internalFo
|
|||
break;
|
||||
#endif
|
||||
#ifdef GL_IMG_texture_compression_pvrtc
|
||||
case ECF_PVRTC_A4R4G4B4:
|
||||
case ECF_PVRTC_ARGB4:
|
||||
internalFormat = GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;
|
||||
filtering = GL_LINEAR;
|
||||
pixelFormat = GL_RGBA;
|
||||
|
@ -272,7 +274,7 @@ void COGLES2Texture::getFormatParameters(ECOLOR_FORMAT format, GLint& internalFo
|
|||
break;
|
||||
#endif
|
||||
#ifdef GL_IMG_texture_compression_pvrtc2
|
||||
case ECF_PVRTC2_A2R2G2B2:
|
||||
case ECF_PVRTC2_ARGB2:
|
||||
internalFormat = GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG;
|
||||
filtering = GL_LINEAR;
|
||||
pixelFormat = GL_RGBA;
|
||||
|
@ -280,12 +282,36 @@ void COGLES2Texture::getFormatParameters(ECOLOR_FORMAT format, GLint& internalFo
|
|||
break;
|
||||
#endif
|
||||
#ifdef GL_IMG_texture_compression_pvrtc2
|
||||
case ECF_PVRTC2_A4R4G4B4:
|
||||
case ECF_PVRTC2_ARGB4:
|
||||
internalFormat = GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG;
|
||||
filtering = GL_LINEAR;
|
||||
pixelFormat = GL_RGBA;
|
||||
type = GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG;
|
||||
break;
|
||||
#endif
|
||||
#ifdef GL_OES_compressed_ETC1_RGB8_texture
|
||||
case ECF_ETC1:
|
||||
internalFormat = GL_ETC1_RGB8_OES;
|
||||
filtering = GL_LINEAR;
|
||||
pixelFormat = GL_RGB;
|
||||
type = GL_ETC1_RGB8_OES;
|
||||
break;
|
||||
#endif
|
||||
#ifdef GL_ES_VERSION_3_0 // TO-DO - fix when extension name will be available
|
||||
case ECF_ETC2_RGB:
|
||||
internalFormat = GL_COMPRESSED_RGB8_ETC2;
|
||||
filtering = GL_LINEAR;
|
||||
pixelFormat = GL_RGB;
|
||||
type = GL_COMPRESSED_RGB8_ETC2;
|
||||
break;
|
||||
#endif
|
||||
#ifdef GL_ES_VERSION_3_0 // TO-DO - fix when extension name will be available
|
||||
case ECF_ETC2_ARGB:
|
||||
internalFormat = GL_COMPRESSED_RGBA8_ETC2_EAC;
|
||||
filtering = GL_LINEAR;
|
||||
pixelFormat = GL_RGBA;
|
||||
type = GL_COMPRESSED_RGBA8_ETC2_EAC;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
os::Printer::log("Unsupported texture format", ELL_ERROR);
|
||||
|
@ -334,77 +360,6 @@ void COGLES2Texture::getImageValues(IImage* image)
|
|||
}
|
||||
|
||||
|
||||
//! check format compatibility.
|
||||
bool COGLES2Texture::checkFormatCompatibility()
|
||||
{
|
||||
bool status = true;
|
||||
|
||||
switch (ColorFormat)
|
||||
{
|
||||
case ECF_DXT1:
|
||||
case ECF_DXT2:
|
||||
case ECF_DXT3:
|
||||
case ECF_DXT4:
|
||||
case ECF_DXT5:
|
||||
{
|
||||
if(!Driver->queryFeature(EVDF_TEXTURE_COMPRESSED_DXT))
|
||||
{
|
||||
os::Printer::log("DXT texture compression not available.", ELL_ERROR);
|
||||
status = false;
|
||||
}
|
||||
else if(ImageSize != TextureSize)
|
||||
{
|
||||
os::Printer::log("Invalid size of image for DXTn compressed texture, size of image must be POT.", ELL_ERROR);
|
||||
status = false;
|
||||
}
|
||||
else
|
||||
IsCompressed = true;
|
||||
}
|
||||
break;
|
||||
case ECF_PVRTC_R2G2B2:
|
||||
case ECF_PVRTC_A2R2G2B2:
|
||||
case ECF_PVRTC_R4G4B4:
|
||||
case ECF_PVRTC_A4R4G4B4:
|
||||
{
|
||||
if(!Driver->queryFeature(EVDF_TEXTURE_COMPRESSED_PVRTC))
|
||||
{
|
||||
os::Printer::log("PVRTC texture compression not available.", ELL_ERROR);
|
||||
status = false;
|
||||
}
|
||||
else if(ImageSize != TextureSize)
|
||||
{
|
||||
os::Printer::log("Invalid size of image for PVRTC compressed texture, size of image must be POT.", ELL_ERROR);
|
||||
status = false;
|
||||
}
|
||||
else if(TextureSize.Height != TextureSize.Width)
|
||||
{
|
||||
os::Printer::log("Invalid size of image for PVRTC compressed texture, size of image must be squared.", ELL_ERROR);
|
||||
status = false;
|
||||
}
|
||||
else
|
||||
IsCompressed = true;
|
||||
}
|
||||
break;
|
||||
case ECF_PVRTC2_A2R2G2B2:
|
||||
case ECF_PVRTC2_A4R4G4B4:
|
||||
{
|
||||
if(!Driver->queryFeature(EVDF_TEXTURE_COMPRESSED_PVRTC2))
|
||||
{
|
||||
os::Printer::log("PVRTC2 texture compression not available.", ELL_ERROR);
|
||||
status = false;
|
||||
}
|
||||
else
|
||||
IsCompressed = true;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
//! copies the the texture into an open gl texture.
|
||||
void COGLES2Texture::uploadTexture(bool newTexture, void* mipmapData, u32 level)
|
||||
{
|
||||
|
|
|
@ -124,9 +124,6 @@ protected:
|
|||
//! get important numbers of the image and hw texture
|
||||
void getImageValues(IImage* image);
|
||||
|
||||
//! check format compatibility.
|
||||
bool checkFormatCompatibility();
|
||||
|
||||
//! copies the texture into an OpenGL texture.
|
||||
/** \param newTexture True if method is called for a newly created texture for the first time. Otherwise call with false to improve memory handling.
|
||||
\param mipmapData Pointer to raw mipmap data, including all necessary mip levels, in the same format as the main texture image.
|
||||
|
|
|
@ -205,6 +205,10 @@ namespace video
|
|||
case EVDF_TEXTURE_COMPRESSED_PVRTC:
|
||||
case EVDF_TEXTURE_COMPRESSED_PVRTC2:
|
||||
return false; // PowerVR need improvements here
|
||||
case EVDF_TEXTURE_COMPRESSED_ETC1:
|
||||
return false; // Android based devices need improvements here
|
||||
case EVDF_TEXTURE_COMPRESSED_ETC2:
|
||||
return false;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -793,7 +793,10 @@ bool COpenGLExtensionHandler::queryFeature(E_VIDEO_DRIVER_FEATURE feature) const
|
|||
return FeatureAvailable[IRR_EXT_texture_compression_s3tc];
|
||||
case EVDF_TEXTURE_COMPRESSED_PVRTC: // Currently disabled, but in future maybe special extension will be available.
|
||||
case EVDF_TEXTURE_COMPRESSED_PVRTC2:
|
||||
case EVDF_TEXTURE_COMPRESSED_ETC1:
|
||||
return false;
|
||||
case EVDF_TEXTURE_COMPRESSED_ETC2:
|
||||
return FeatureAvailable[IRR_ARB_ES3_compatibility];
|
||||
default:
|
||||
return false;
|
||||
};
|
||||
|
|
|
@ -136,6 +136,7 @@ static const char* const OpenGLFeatureStrings[] = {
|
|||
"GL_ARB_draw_indirect",
|
||||
"GL_ARB_draw_instanced",
|
||||
"GL_ARB_ES2_compatibility",
|
||||
"GL_ARB_ES3_compatibility",
|
||||
"GL_ARB_explicit_attrib_location",
|
||||
"GL_ARB_fragment_coord_conventions",
|
||||
"GL_ARB_fragment_program",
|
||||
|
@ -554,6 +555,7 @@ class COpenGLExtensionHandler
|
|||
IRR_ARB_draw_indirect,
|
||||
IRR_ARB_draw_instanced,
|
||||
IRR_ARB_ES2_compatibility,
|
||||
IRR_ARB_ES3_compatibility,
|
||||
IRR_ARB_explicit_attrib_location,
|
||||
IRR_ARB_fragment_coord_conventions,
|
||||
IRR_ARB_fragment_program,
|
||||
|
|
|
@ -34,7 +34,9 @@ COpenGLTexture::COpenGLTexture(IImage* origImage, const io::path& name, void* mi
|
|||
HasMipMaps = Driver->getTextureCreationFlag(ETCF_CREATE_MIP_MAPS);
|
||||
getImageValues(origImage);
|
||||
|
||||
if (checkFormatCompatibility())
|
||||
IsCompressed = IImage::isCompressedFormat(ColorFormat);
|
||||
|
||||
if (Driver->checkColorFormat(ColorFormat, origImage->getDimension()))
|
||||
{
|
||||
if (IsCompressed)
|
||||
{
|
||||
|
@ -202,7 +204,7 @@ void COpenGLTexture::getFormatParameters(ECOLOR_FORMAT format, GLint& internalFo
|
|||
break;
|
||||
#endif
|
||||
#ifdef GL_IMG_texture_compression_pvrtc
|
||||
case ECF_PVRTC_R2G2B2:
|
||||
case ECF_PVRTC_RGB2:
|
||||
internalFormat = GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG;
|
||||
filtering = GL_LINEAR;
|
||||
pixelFormat = GL_RGB;
|
||||
|
@ -210,7 +212,7 @@ void COpenGLTexture::getFormatParameters(ECOLOR_FORMAT format, GLint& internalFo
|
|||
break;
|
||||
#endif
|
||||
#ifdef GL_IMG_texture_compression_pvrtc
|
||||
case ECF_PVRTC_A2R2G2B2:
|
||||
case ECF_PVRTC_ARGB2:
|
||||
internalFormat = GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;
|
||||
filtering = GL_LINEAR;
|
||||
pixelFormat = GL_RGBA;
|
||||
|
@ -218,7 +220,7 @@ void COpenGLTexture::getFormatParameters(ECOLOR_FORMAT format, GLint& internalFo
|
|||
break;
|
||||
#endif
|
||||
#ifdef GL_IMG_texture_compression_pvrtc
|
||||
case ECF_PVRTC_R4G4B4:
|
||||
case ECF_PVRTC_RGB4:
|
||||
internalFormat = GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG;
|
||||
filtering = GL_LINEAR;
|
||||
pixelFormat = GL_RGB;
|
||||
|
@ -226,7 +228,7 @@ void COpenGLTexture::getFormatParameters(ECOLOR_FORMAT format, GLint& internalFo
|
|||
break;
|
||||
#endif
|
||||
#ifdef GL_IMG_texture_compression_pvrtc
|
||||
case ECF_PVRTC_A4R4G4B4:
|
||||
case ECF_PVRTC_ARGB4:
|
||||
internalFormat = GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;
|
||||
filtering = GL_LINEAR;
|
||||
pixelFormat = GL_RGBA;
|
||||
|
@ -234,19 +236,43 @@ void COpenGLTexture::getFormatParameters(ECOLOR_FORMAT format, GLint& internalFo
|
|||
break;
|
||||
#endif
|
||||
#ifdef GL_IMG_texture_compression_pvrtc2
|
||||
case ECF_PVRTC2_A2R2G2B2:
|
||||
internalFormat = COMPRESSED_RGBA_PVRTC_2BPPV2_IMG;
|
||||
case ECF_PVRTC2_ARGB2:
|
||||
internalFormat = GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG;
|
||||
filtering = GL_LINEAR;
|
||||
pixelFormat = GL_RGBA;
|
||||
type = COMPRESSED_RGBA_PVRTC_2BPPV2_IMG;
|
||||
type = GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG;
|
||||
break;
|
||||
#endif
|
||||
#ifdef GL_IMG_texture_compression_pvrtc2
|
||||
case ECF_PVRTC2_A4R4G4B4:
|
||||
internalFormat = COMPRESSED_RGBA_PVRTC_4BPPV2_IMG;
|
||||
case ECF_PVRTC2_ARGB4:
|
||||
internalFormat = GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG;
|
||||
filtering = GL_LINEAR;
|
||||
pixelFormat = GL_RGBA;
|
||||
type = COMPRESSED_RGBA_PVRTC_4BPPV2_IMG;
|
||||
type = GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG;
|
||||
break;
|
||||
#endif
|
||||
#ifdef GL_OES_compressed_ETC1_RGB8_texture
|
||||
case ECF_ETC1:
|
||||
internalFormat = GL_ETC1_RGB8_OES;
|
||||
filtering = GL_LINEAR;
|
||||
pixelFormat = GL_RGB;
|
||||
type = GL_ETC1_RGB8_OES;
|
||||
break;
|
||||
#endif
|
||||
#ifdef GL_ARB_ES3_compatibility
|
||||
case ECF_ETC2_RGB:
|
||||
internalFormat = GL_COMPRESSED_RGB8_ETC2;
|
||||
filtering = GL_LINEAR;
|
||||
pixelFormat = GL_RGB;
|
||||
type = GL_COMPRESSED_RGB8_ETC2;
|
||||
break;
|
||||
#endif
|
||||
#ifdef GL_ARB_ES3_compatibility
|
||||
case ECF_ETC2_ARGB:
|
||||
internalFormat = GL_COMPRESSED_RGBA8_ETC2_EAC;
|
||||
filtering = GL_LINEAR;
|
||||
pixelFormat = GL_RGBA;
|
||||
type = GL_COMPRESSED_RGBA8_ETC2_EAC;
|
||||
break;
|
||||
#endif
|
||||
#ifdef GL_ARB_texture_rg
|
||||
|
@ -301,6 +327,12 @@ void COpenGLTexture::getFormatParameters(ECOLOR_FORMAT format, GLint& internalFo
|
|||
internalFormat = GL_SRGB_ALPHA_EXT;
|
||||
else if (internalFormat == GL_RGB)
|
||||
internalFormat = GL_SRGB_EXT;
|
||||
#ifdef GL_ARB_ES3_compatibility
|
||||
else if (internalFormat == GL_COMPRESSED_RGBA8_ETC2_EAC)
|
||||
internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC;
|
||||
else if (internalFormat == GL_COMPRESSED_RGB8_ETC2)
|
||||
internalFormat = GL_COMPRESSED_SRGB8_ETC2;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -340,77 +372,6 @@ void COpenGLTexture::getImageValues(IImage* image)
|
|||
}
|
||||
|
||||
|
||||
//! check format compatibility.
|
||||
bool COpenGLTexture::checkFormatCompatibility()
|
||||
{
|
||||
bool status = true;
|
||||
|
||||
switch (ColorFormat)
|
||||
{
|
||||
case ECF_DXT1:
|
||||
case ECF_DXT2:
|
||||
case ECF_DXT3:
|
||||
case ECF_DXT4:
|
||||
case ECF_DXT5:
|
||||
{
|
||||
if(!Driver->queryFeature(EVDF_TEXTURE_COMPRESSED_DXT))
|
||||
{
|
||||
os::Printer::log("DXT texture compression not available.", ELL_ERROR);
|
||||
status = false;
|
||||
}
|
||||
else if(ImageSize != TextureSize)
|
||||
{
|
||||
os::Printer::log("Invalid size of image for DXTn compressed texture, size of image must be POT.", ELL_ERROR);
|
||||
status = false;
|
||||
}
|
||||
else
|
||||
IsCompressed = true;
|
||||
}
|
||||
break;
|
||||
case ECF_PVRTC_R2G2B2:
|
||||
case ECF_PVRTC_A2R2G2B2:
|
||||
case ECF_PVRTC_R4G4B4:
|
||||
case ECF_PVRTC_A4R4G4B4:
|
||||
{
|
||||
if(!Driver->queryFeature(EVDF_TEXTURE_COMPRESSED_PVRTC))
|
||||
{
|
||||
os::Printer::log("PVRTC texture compression not available.", ELL_ERROR);
|
||||
status = false;
|
||||
}
|
||||
else if(ImageSize != TextureSize)
|
||||
{
|
||||
os::Printer::log("Invalid size of image for PVRTC compressed texture, size of image must be POT.", ELL_ERROR);
|
||||
status = false;
|
||||
}
|
||||
else if(TextureSize.Height != TextureSize.Width)
|
||||
{
|
||||
os::Printer::log("Invalid size of image for PVRTC compressed texture, size of image must be squared.", ELL_ERROR);
|
||||
status = false;
|
||||
}
|
||||
else
|
||||
IsCompressed = true;
|
||||
}
|
||||
break;
|
||||
case ECF_PVRTC2_A2R2G2B2:
|
||||
case ECF_PVRTC2_A4R4G4B4:
|
||||
{
|
||||
if(!Driver->queryFeature(EVDF_TEXTURE_COMPRESSED_PVRTC2))
|
||||
{
|
||||
os::Printer::log("PVRTC2 texture compression not available.", ELL_ERROR);
|
||||
status = false;
|
||||
}
|
||||
else
|
||||
IsCompressed = true;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
//! copies the the texture into an open gl texture.
|
||||
void COpenGLTexture::uploadTexture(bool newTexture, void* mipmapData, u32 level)
|
||||
{
|
||||
|
|
|
@ -143,9 +143,6 @@ protected:
|
|||
//! get important numbers of the image and hw texture
|
||||
void getImageValues(IImage* image);
|
||||
|
||||
//! check format compatibility.
|
||||
bool checkFormatCompatibility();
|
||||
|
||||
//! copies the texture into an OpenGL texture.
|
||||
/** \param newTexture True if method is called for a newly created texture for the first time. Otherwise call with false to improve memory handling.
|
||||
\param mipmapData Pointer to raw mipmap data, including all necessary mip levels, in the same format as the main texture image.
|
||||
|
|
Loading…
Reference in New Issue