Imagination PowerVR SDK Blog

PVRTexLib crashes on 64-bit


#1

latest version crashes when I try to create ETC2/PVRTC textures

Crash occurs only on 64-bit!
32-bit works fine

It crashes here:
[pre] ~MetaDataBlock[]
{
if [Data]
delete [] Data;
Data = NULL;
}[/pre]

I’m executing with this code:
[pre]Bool CompressPVRTC2[Int x, Int y, Ptr data, Int type, Int quality, Ptr &compressed_data, Int &compressed_size]
{
compressed_data=NULL;
compressed_size=0;

using namespace pvrtexture;
CPVRTextureHeader header[PVRStandard8PixelType.PixelTypeID, y, x];
CPVRTexture texture[header, data];

if[Transcode[texture, EPVRTPixelFormat[type], ePVRTVarTypeUnsignedByteNorm, ePVRTCSpacelRGB, ECompressorQuality[quality], false]] // dithering makes smooth gradients [like sky] very bad so always disable them
{
Ptr data=texture.getDataPtr [];
Int size=texture.getDataSize[];
if[data && size>0]
{
memcpy[compressed_data=malloc[size], data, compressed_size=size];
return true;
}
}
return false;
}[/pre]


#2

Also, please note that I’m using Visual Studio 2015.

And had to define the missing symbols manually:

[pre]
#ifdef _WIN32 // TODO: check if in the future this entire block can be removed once a new version of PVRTexLib is released
#define _NO_CRT_STDIO_INLINE
#include <stdio.h>
#include <corecrt_wstdio.h>
extern “C” FILE* __iob_func[unsigned i] {return __acrt_iob_func[i];}
int _vsnprintf_l[char* const _Buffer, size_t const _BufferCount, char const* const _Format, _locale_t const _Locale, va_list _ArgList]
{
int const _Result = __stdio_common_vsprintf[_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS | _CRT_INTERNAL_PRINTF_LEGACY_VSPRINTF_NULL_TERMINATION, _Buffer, _BufferCount, _Format, _Locale, _ArgList];
return _Result < 0 ? -1 : _Result;
}
int _vscprintf_l[char const* const _Format, _locale_t const _Locale, va_list _ArgList]
{
int const _Result = __stdio_common_vsprintf[_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS | _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR, NULL, 0, _Format, _Locale, _ArgList];
return _Result < 0 ? -1 : _Result;
}
int _vsprintf_p_l[char* const _Buffer, size_t const _BufferCount, char const* const _Format, _locale_t const _Locale, va_list _ArgList]
{
int const _Result = __stdio_common_vsprintf_p[_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, _Buffer, _BufferCount, _Format, _Locale, _ArgList];
return _Result < 0 ? -1 : _Result;
}
int _vscprintf_p_l[char const* const _Format, _locale_t const _Locale, va_list _ArgList]
{
int const _Result = __stdio_common_vsprintf_p[_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS | _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR, NULL, 0, _Format, _Locale, _ArgList];
return _Result < 0 ? -1 : _Result;
}
int _vsnprintf[char* const _Buffer, size_t const _BufferCount, char const* const _Format, va_list _ArgList] {return _vsnprintf_l[_Buffer, _BufferCount, _Format, NULL, _ArgList];}
int _vscprintf[char const* const _Format, va_list _ArgList] {return _vscprintf_l[_Format, NULL, _ArgList];}
int _vsprintf_p[char* const _Buffer, size_t const _BufferCount, char const* const _Format, va_list _ArgList] {return _vsprintf_p_l[_Buffer, _BufferCount, _Format, NULL, _ArgList];}
int _vscprintf_p[char const* const _Format, va_list _ArgList] {return _vscprintf_p_l[_Format, NULL, _ArgList];}
int vsprintf[char* const _Buffer, char const* const _Format, va_list _ArgList] {return _vsnprintf_l[_Buffer, [size_t]-1, _Format, NULL, _ArgList];}
int vfprintf[FILE* const _Stream, char const* const _Format, va_list _ArgList] {return _vfprintf_l[_Stream, _Format, NULL, _ArgList];}
int vprintf[char const* const _Format, va_list _ArgList] {return _vfprintf_l[stdout, _Format, NULL, _ArgList];}
#endif[/pre]


#3

I’ve just verified this and when I compile with VS 2013 toolset, then it works OK.

So please add support for VS 2015, thanks!


#4

Hi Greg,

Are you using the PVRTexLib dynamic library or the static one? We’re planning to deprecate the static library in future releases due to the maintenance cost of supporting multiple versions of Visual Studio.


#5

Hi Joe,

I’m using the static library.

Please kindly do not remove static libraries, as it’s seriously much less hassle with them.
You don’t need to support multiple versions of Visual Studio, just support one, that is compatible with latest version of Visual Studio, it’s important to stay up to date with technology.

Right now distributing both dll + static lib is the best option, so developers can choose what’s best for them.

Please please please do not remove the static lib


#6

Hi Greg,

Many of our users are stuck on older revisions of Visual Studio. We have to consider very carefully how much time is spent configuring and maintaining static libraries, particularly as the DLL can be used by everyone. We will take your feedback into consideration though.


#7

Hi Joe,

I’m aware of that, my recommendation is tell them to upgrade.

It is better to support newer VS rather than older VS in my opinion.

Besides:
VS 2015 Community is free
latest versions of VS will usually generate the most optimized code
Win10 is also free if that matters

I had the same dilemma recently, I was using VS 2008 for some things, up until few weeks ago, but I’ve finally decided to make the jump to 2015, and I don’t regret it.


#8

Hi Greg,

Apologies for the delayed response. Unfortunately, it’s not as easy as recommending our users to upgrade to the latest version of Visual Studio. For many complex projects that are heavily tied into a particular version of the IDE, for example game engines that use many third party binaries that are compiled for a specific version of Visual Studio, upgrading isn’t viable. This leaves us with two options; only provide dynamic libraries that work for everyone, or allocate resources to maintaining many static libraries. We’ve chosen to discontinue the static libraries so we can allocate resources to more pertinent tasks.


#9

Hi,

I’m a game engine developer myself, I’m the creator of http://esenthel.com (Windows Mac Linux Android iOS Web game engine).

I’m using heaps of 3rd party libs:
-AdMob
-ISPC Texture Compressor
-Bullet
-Chartboost
-Diff Match Patch
-Facebook
-FBX
-Flac
-FreeType
-JpegTurbo
-LZ4
-LZHAM
-LZMA
-Mpg123
-Oculus
-Ogg
-OpenAL
-Opus
-PhysX
-Png
-PVRTC
-Recast
-Snappy
-SQLite
-SteamWorks
-Theora
-Tiff
-Vorbis
-VPX
-Webp
-Zlib

And none of them are holding me back from using them with VS 2015. Only FBX, Steam and PhysX require DLL’s, while all others for Windows I can use as static LIB’s.

I was even able to make your PVRTexLib static lib work with VS 2015 using a trick.

I hope you reconsider providing static libs for VS 2015, thank you.