Skip to content

Commit

Permalink
Return KTX_NOT_FOUND when a GPU proc is not found. (KhronosGroup#770)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkCallow authored Sep 17, 2023
1 parent bee8ae6 commit 0faf491
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 16 deletions.
2 changes: 1 addition & 1 deletion include/ktx.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ typedef enum ktx_error_code_e {
KTX_GL_ERROR, /*!< GL operations resulted in an error. */
KTX_INVALID_OPERATION, /*!< The operation is not allowed in the current state. */
KTX_INVALID_VALUE, /*!< A parameter value was not valid */
KTX_NOT_FOUND, /*!< Requested key was not found */
KTX_NOT_FOUND, /*!< Requested metadata key or required dynamically loaded GPU function was not found. */
KTX_OUT_OF_MEMORY, /*!< Not enough memory to complete the operation. */
KTX_TRANSCODE_FAILED, /*!< Transcoding of block compressed texture failed. */
KTX_UNKNOWN_FILE_FORMAT, /*!< The file not a KTX file */
Expand Down
4 changes: 2 additions & 2 deletions lib/gl_funcs.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ struct glFuncPtrs gl;
*(void **)(&gl.func) = LoadProcAddr(ktxOpenGLModuleHandle, #func); \
if ( !gl.func && required ) { \
fprintf(stderr, noloadmsg, #func); \
return KTX_FALSE; \
return KTX_NOT_FOUND; \
}
#else
#define GL_FUNCTION(type, func, required) \
Expand All @@ -112,7 +112,7 @@ struct glFuncPtrs gl;
gl.func = (type)LoadProcAddr(ktxOpenGLModuleHandle, #func); \
if ( !gl.func && required) { \
fprintf(stderr, noloadmsg, #func); \
return KTX_FALSE; \
return KTX_NOT_FOUND; \
}
#endif

Expand Down
6 changes: 5 additions & 1 deletion lib/glloader.c
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,8 @@ ktxTexture_GLUploadPrivate(ktxTexture* This, ktx_glformatinfo* formatInfo,
* glGenTextures or gl*TexImage*. The GL error
* will be returned in @p *glerror, if glerror
* is not @c NULL.
* @exception KTX_NOT_FOUND A dynamically loaded OpenGL {,ES} function
* required by the loader was not found.
* @exception KTX_UNSUPPORTED_TEXTURE_TYPE The type of texture is not supported
* by the current OpenGL context.
*/
Expand Down Expand Up @@ -974,6 +976,8 @@ ktxTexture1_GLUpload(ktxTexture1* This, GLuint* pTexture, GLenum* pTarget,
* glGenTextures or gl*TexImage*. The GL error
* will be returned in @p *glerror, if glerror
* is not @c NULL.
* @exception KTX_NOT_FOUND A dynamically loaded OpenGL {,ES} function
* required by the loader was not found.
* @exception KTX_UNSUPPORTED_TEXTURE_TYPE The type of texture is not supported
* by the current OpenGL context.
*/
Expand Down Expand Up @@ -1041,7 +1045,7 @@ ktxTexture2_GLUpload(ktxTexture2* This, GLuint* pTexture, GLenum* pTarget,
* @~English
* @brief Create a GL texture object from a ktxTexture1 object.
*
* In ordert to ensure that the GL uploader is not linked into an application unless explicitly called,
* In order to ensure that the GL uploader is not linked into an application unless explicitly called,
* this is not a virtual function. It determines the texture type then dispatches to the correct function.
*
* @copydetails ktxTexture1::ktxTexture1_GLUpload
Expand Down
2 changes: 1 addition & 1 deletion lib/strings.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ static const char* const errorStrings[] = {
"GL error occurred.", /* KTX_GL_ERROR */
"Operation not allowed in the current state.", /* KTX_INVALID_OPERATION */
"Invalid parameter value.", /* KTX_INVALID_VALUE */
"Key not found.", /* KTX_NOT_FOUND */
"Metadata key or loader-required GPU function not found.", /* KTX_NOT_FOUND */
"Out of memory.", /* KTX_OUT_OF_MEMORY */
"Transcoding of block compressed texture failed.",/* KTX_TRANSCODE_FAILED */
"Not a KTX file.", /* KTX_UNKNOWN_FILE_FORMAT */
Expand Down
26 changes: 15 additions & 11 deletions lib/vkloader.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@ generateMipmaps(ktxVulkanTexture* vkTexture, ktxVulkanDeviceInfo* vdi,
* @brief Create a ktxVulkanDeviceInfo object.
*
* Allocates CPU memory for a ktxVulkanDeviceInfo object then calls
* ktxVulkanDeviceInfo_construct(). See it for documentation of the
* ktxVulkanDeviceInfo\_Construct(). See it for documentation of the
* parameters.
*
* @return a pointer to the constructed ktxVulkanDeviceInfo.
*
* @sa ktxVulkanDeviceInfo_construct(), ktxVulkanDeviceInfo_destroy()
* @sa ktxVulkanDeviceInfo\_Construct(), ktxVulkanDeviceInfo\_Destroy()
*/
ktxVulkanDeviceInfo*
ktxVulkanDeviceInfo_Create(VkPhysicalDevice physicalDevice, VkDevice device,
Expand All @@ -111,12 +111,12 @@ ktxVulkanDeviceInfo_Create(VkPhysicalDevice physicalDevice, VkDevice device,
* @brief Create a ktxVulkanDeviceInfo object.
*
* Allocates CPU memory for a ktxVulkanDeviceInfo object then calls
* ktxVulkanDeviceInfo_construct(). See it for documentation of the
* ktxVulkanDeviceInfo\_Construct(). See it for documentation of the
* parameters.
*
* @return a pointer to the constructed ktxVulkanDeviceInfo.
*
* @sa ktxVulkanDeviceInfo_construct(), ktxVulkanDeviceInfo_destroy()
* @sa ktxVulkanDeviceInfo\_Construct(), ktxVulkanDeviceInfo\_Destroy()
*/
ktxVulkanDeviceInfo*
ktxVulkanDeviceInfo_CreateEx(VkInstance instance,
Expand Down Expand Up @@ -164,10 +164,14 @@ ktxVulkanDeviceInfo_CreateEx(VkInstance instance,
* Pass a valid ktxVulkanDeviceInfo* to any Vulkan KTX image loading
* function to provide it with the information.
*
* @returns KTX_SUCCESS on success, KTX_OUT_OF_MEMORY if a command buffer could
* not be allocated.
* @returns KTX\_SUCCESS on success, other KTX\_\* enum values on error.
*
* @sa ktxVulkanDeviceInfo_destruct()
* @exception KTX_NOT_FOUND A dynamically loaded Vulkan function
* required by the loader was not found.
*
* @exception KTX_OUT_OF_MEMORY A command buffer could not be allocated.
*
* @sa ktxVulkanDeviceInfo\_Destruct()
*
* @param This pointer to the ktxVulkanDeviceInfo object to
* initialize.
Expand Down Expand Up @@ -217,7 +221,7 @@ do { \
if ((member).fun == NULL) { \
(member).fun = (PFN_##fun)ktxLoadVulkanFunction(#fun); \
if ((member).fun == NULL) { \
return KTX_FALSE; \
return KTX_NOT_FOUND; \
}\
} \
} while (0)
Expand All @@ -227,7 +231,7 @@ do { \
if ((member).fun == NULL) { \
(member).fun = (PFN_##fun)((member).vkGetInstanceProcAddr)((instance), #fun); \
if ((member).fun == NULL) { \
return KTX_FALSE; \
return KTX_NOT_FOUND; \
}\
} \
} while (0)
Expand All @@ -237,7 +241,7 @@ do { \
if ((member).fun == NULL) { \
(member).fun = (PFN_##fun)((member).vkGetDeviceProcAddr)((device), #fun); \
if ((member).fun == NULL) { \
return KTX_FALSE; \
return KTX_NOT_FOUND; \
}\
} \
} while (0)
Expand Down Expand Up @@ -369,7 +373,7 @@ ktxVulkanDeviceInfo_Destruct(ktxVulkanDeviceInfo* This)
* @~English
* @brief Destroy a ktxVulkanDeviceInfo object.
*
* Calls ktxVulkanDeviceInfo_destruct() then frees the ktxVulkanDeviceInfo.
* Calls ktxVulkanDeviceInfo\_Destruct() then frees the ktxVulkanDeviceInfo.
*
* @param This pointer to the ktxVulkanDeviceInfo to destroy.
*/
Expand Down

0 comments on commit 0faf491

Please sign in to comment.