Bugzilla – Bug 576
Small fixes and enhancements
Last modified: 2012-01-19 01:27:41 PST
Created attachment 93 [details]
Patch for fixes/enhancements in this bugreport
Patch in attachment contains some small fixes and enhancements:
- ifndef for SUPPORT_SOFTWARE_ETC_UNPACK, gives control over this flag also in compiler preprocessor (so no need to change sources to control it)
- KTX_GL_UNPACK_ALIGNMENT - to not make 'magic' value in code, and also check to not call glPixelStorei if not needed
- clean-up around ppKvd, previously if you passed '*ppKvd != 0' then you might not know if you must to free that pointer/memory or not (especially when ktxLoadTexture fails). Now *ppKvd is NULL'ed at beginning, and it will return allocated memory only if function ktxLoadTexture will succeed and there will be some key-value data (*pKvdLen > 0). At ktxLoadTexture failure you don't need to release *ppKvd as it will always points to NULL.
- if texture name was generated (by glGenTextures), but function failed, then there was a 'texture name leak' (how 'big' it could be, is dependant on implementation of OpenGL/ES API)
- conditional code for glTexParameteri with GL_GENERATE_MIPMAP, as OpenGL ES 2.0 doesn't support it (http://www.khronos.org/opengles/sdk/docs/man/xhtml/glTexParameter.xml)
Incorporated in SVN r16638.
The only change I had any objection to is the one to only set the unpack alignment if it is not already 4. Nevertheless I have taken it.
My objection is that the thousands of users of an API should not have to do things like this. If setting a value in an API is an expensive operation the few API implementations should protect themselves to ensure they do nothing if the new value is the same as the current value. Furthermore I can't imagine that setting the unpack alignment is an expensive operation. It should merely store the value for future use.