Skip to content

Commit aeca5e6

Browse files
authored
Return KTX_NOT_FOUND when a GPU proc is not found. (#770)
Fixes #768.
1 parent 6856fdb commit aeca5e6

File tree

5 files changed

+24
-16
lines changed

5 files changed

+24
-16
lines changed

include/ktx.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ typedef enum ktx_error_code_e {
177177
KTX_GL_ERROR, /*!< GL operations resulted in an error. */
178178
KTX_INVALID_OPERATION, /*!< The operation is not allowed in the current state. */
179179
KTX_INVALID_VALUE, /*!< A parameter value was not valid */
180-
KTX_NOT_FOUND, /*!< Requested key was not found */
180+
KTX_NOT_FOUND, /*!< Requested metadata key or required dynamically loaded GPU function was not found. */
181181
KTX_OUT_OF_MEMORY, /*!< Not enough memory to complete the operation. */
182182
KTX_TRANSCODE_FAILED, /*!< Transcoding of block compressed texture failed. */
183183
KTX_UNKNOWN_FILE_FORMAT, /*!< The file not a KTX file */

lib/gl_funcs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ struct glFuncPtrs gl;
102102
*(void **)(&gl.func) = LoadProcAddr(ktxOpenGLModuleHandle, #func); \
103103
if ( !gl.func && required ) { \
104104
fprintf(stderr, noloadmsg, #func); \
105-
return KTX_FALSE; \
105+
return KTX_NOT_FOUND; \
106106
}
107107
#else
108108
#define GL_FUNCTION(type, func, required) \
@@ -112,7 +112,7 @@ struct glFuncPtrs gl;
112112
gl.func = (type)LoadProcAddr(ktxOpenGLModuleHandle, #func); \
113113
if ( !gl.func && required) { \
114114
fprintf(stderr, noloadmsg, #func); \
115-
return KTX_FALSE; \
115+
return KTX_NOT_FOUND; \
116116
}
117117
#endif
118118

lib/glloader.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -890,6 +890,8 @@ ktxTexture_GLUploadPrivate(ktxTexture* This, ktx_glformatinfo* formatInfo,
890890
* glGenTextures or gl*TexImage*. The GL error
891891
* will be returned in @p *glerror, if glerror
892892
* is not @c NULL.
893+
* @exception KTX_NOT_FOUND A dynamically loaded OpenGL {,ES} function
894+
* required by the loader was not found.
893895
* @exception KTX_UNSUPPORTED_TEXTURE_TYPE The type of texture is not supported
894896
* by the current OpenGL context.
895897
*/
@@ -974,6 +976,8 @@ ktxTexture1_GLUpload(ktxTexture1* This, GLuint* pTexture, GLenum* pTarget,
974976
* glGenTextures or gl*TexImage*. The GL error
975977
* will be returned in @p *glerror, if glerror
976978
* is not @c NULL.
979+
* @exception KTX_NOT_FOUND A dynamically loaded OpenGL {,ES} function
980+
* required by the loader was not found.
977981
* @exception KTX_UNSUPPORTED_TEXTURE_TYPE The type of texture is not supported
978982
* by the current OpenGL context.
979983
*/
@@ -1041,7 +1045,7 @@ ktxTexture2_GLUpload(ktxTexture2* This, GLuint* pTexture, GLenum* pTarget,
10411045
* @~English
10421046
* @brief Create a GL texture object from a ktxTexture1 object.
10431047
*
1044-
* In ordert to ensure that the GL uploader is not linked into an application unless explicitly called,
1048+
* In order to ensure that the GL uploader is not linked into an application unless explicitly called,
10451049
* this is not a virtual function. It determines the texture type then dispatches to the correct function.
10461050
*
10471051
* @copydetails ktxTexture1::ktxTexture1_GLUpload

lib/strings.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ static const char* const errorStrings[] = {
3131
"GL error occurred.", /* KTX_GL_ERROR */
3232
"Operation not allowed in the current state.", /* KTX_INVALID_OPERATION */
3333
"Invalid parameter value.", /* KTX_INVALID_VALUE */
34-
"Key not found.", /* KTX_NOT_FOUND */
34+
"Metadata key or loader-required GPU function not found.", /* KTX_NOT_FOUND */
3535
"Out of memory.", /* KTX_OUT_OF_MEMORY */
3636
"Transcoding of block compressed texture failed.",/* KTX_TRANSCODE_FAILED */
3737
"Not a KTX file.", /* KTX_UNKNOWN_FILE_FORMAT */

lib/vkloader.c

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,12 @@ generateMipmaps(ktxVulkanTexture* vkTexture, ktxVulkanDeviceInfo* vdi,
8989
* @brief Create a ktxVulkanDeviceInfo object.
9090
*
9191
* Allocates CPU memory for a ktxVulkanDeviceInfo object then calls
92-
* ktxVulkanDeviceInfo_construct(). See it for documentation of the
92+
* ktxVulkanDeviceInfo\_Construct(). See it for documentation of the
9393
* parameters.
9494
*
9595
* @return a pointer to the constructed ktxVulkanDeviceInfo.
9696
*
97-
* @sa ktxVulkanDeviceInfo_construct(), ktxVulkanDeviceInfo_destroy()
97+
* @sa ktxVulkanDeviceInfo\_Construct(), ktxVulkanDeviceInfo\_Destroy()
9898
*/
9999
ktxVulkanDeviceInfo*
100100
ktxVulkanDeviceInfo_Create(VkPhysicalDevice physicalDevice, VkDevice device,
@@ -111,12 +111,12 @@ ktxVulkanDeviceInfo_Create(VkPhysicalDevice physicalDevice, VkDevice device,
111111
* @brief Create a ktxVulkanDeviceInfo object.
112112
*
113113
* Allocates CPU memory for a ktxVulkanDeviceInfo object then calls
114-
* ktxVulkanDeviceInfo_construct(). See it for documentation of the
114+
* ktxVulkanDeviceInfo\_Construct(). See it for documentation of the
115115
* parameters.
116116
*
117117
* @return a pointer to the constructed ktxVulkanDeviceInfo.
118118
*
119-
* @sa ktxVulkanDeviceInfo_construct(), ktxVulkanDeviceInfo_destroy()
119+
* @sa ktxVulkanDeviceInfo\_Construct(), ktxVulkanDeviceInfo\_Destroy()
120120
*/
121121
ktxVulkanDeviceInfo*
122122
ktxVulkanDeviceInfo_CreateEx(VkInstance instance,
@@ -164,10 +164,14 @@ ktxVulkanDeviceInfo_CreateEx(VkInstance instance,
164164
* Pass a valid ktxVulkanDeviceInfo* to any Vulkan KTX image loading
165165
* function to provide it with the information.
166166
*
167-
* @returns KTX_SUCCESS on success, KTX_OUT_OF_MEMORY if a command buffer could
168-
* not be allocated.
167+
* @returns KTX\_SUCCESS on success, other KTX\_\* enum values on error.
169168
*
170-
* @sa ktxVulkanDeviceInfo_destruct()
169+
* @exception KTX_NOT_FOUND A dynamically loaded Vulkan function
170+
* required by the loader was not found.
171+
*
172+
* @exception KTX_OUT_OF_MEMORY A command buffer could not be allocated.
173+
*
174+
* @sa ktxVulkanDeviceInfo\_Destruct()
171175
*
172176
* @param This pointer to the ktxVulkanDeviceInfo object to
173177
* initialize.
@@ -217,7 +221,7 @@ do { \
217221
if ((member).fun == NULL) { \
218222
(member).fun = (PFN_##fun)ktxLoadVulkanFunction(#fun); \
219223
if ((member).fun == NULL) { \
220-
return KTX_FALSE; \
224+
return KTX_NOT_FOUND; \
221225
}\
222226
} \
223227
} while (0)
@@ -227,7 +231,7 @@ do { \
227231
if ((member).fun == NULL) { \
228232
(member).fun = (PFN_##fun)((member).vkGetInstanceProcAddr)((instance), #fun); \
229233
if ((member).fun == NULL) { \
230-
return KTX_FALSE; \
234+
return KTX_NOT_FOUND; \
231235
}\
232236
} \
233237
} while (0)
@@ -237,7 +241,7 @@ do { \
237241
if ((member).fun == NULL) { \
238242
(member).fun = (PFN_##fun)((member).vkGetDeviceProcAddr)((device), #fun); \
239243
if ((member).fun == NULL) { \
240-
return KTX_FALSE; \
244+
return KTX_NOT_FOUND; \
241245
}\
242246
} \
243247
} while (0)
@@ -369,7 +373,7 @@ ktxVulkanDeviceInfo_Destruct(ktxVulkanDeviceInfo* This)
369373
* @~English
370374
* @brief Destroy a ktxVulkanDeviceInfo object.
371375
*
372-
* Calls ktxVulkanDeviceInfo_destruct() then frees the ktxVulkanDeviceInfo.
376+
* Calls ktxVulkanDeviceInfo\_Destruct() then frees the ktxVulkanDeviceInfo.
373377
*
374378
* @param This pointer to the ktxVulkanDeviceInfo to destroy.
375379
*/

0 commit comments

Comments
 (0)