Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameter validation layer does not account for extended enums #1779

Open
kbenzie opened this issue Jun 21, 2024 · 0 comments
Open

Parameter validation layer does not account for extended enums #1779

kbenzie opened this issue Jun 21, 2024 · 0 comments
Assignees
Labels
bug Something isn't working loader Loader related feature/bug
Milestone

Comments

@kbenzie
Copy link
Contributor

kbenzie commented Jun 21, 2024

Validation of ur_mem_type_t, which is extended by the experimental bindless images feature, does not correctly validate the extended enumeration UR_MEM_TYPE_IMAGE_CUBEMAP_EXP.

        if (pImageDesc && UR_MEM_TYPE_IMAGE1D_ARRAY < pImageDesc->type) {
            return UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR;
        }
typedef enum ur_mem_type_t {
    UR_MEM_TYPE_IMAGE2D = 0,                ///< 2D image object
    UR_MEM_TYPE_IMAGE3D = 1,                ///< 3D image object
    UR_MEM_TYPE_IMAGE2D_ARRAY = 2,          ///< 2D image array object
    UR_MEM_TYPE_IMAGE1D = 3,                ///< 1D image object
    UR_MEM_TYPE_IMAGE1D_ARRAY = 4,          ///< 1D image array object
    UR_MEM_TYPE_IMAGE_CUBEMAP_EXP = 0x2000, ///< Experimental cubemap image object
    /// @cond
    UR_MEM_TYPE_FORCE_UINT32 = 0x7fffffff
    /// @endcond

} ur_mem_type_t;

This results in valid usage of the bindless images entry points which take a ur_mem_type_t returning the UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR erroneously.

Given the gap in valid values, validation should instead look like this:

        if (pImageDesc) {
            switch (pImageDesc->type) {
            case UR_MEM_TYPE_IMAGE2D:
            case UR_MEM_TYPE_IMAGE3D:
            case UR_MEM_TYPE_IMAGE2D_ARRAY:
            case UR_MEM_TYPE_IMAGE1D:
            case UR_MEM_TYPE_IMAGE1D_ARRAY:
            case UR_MEM_TYPE_IMAGE2D:
            case UR_MEM_TYPE_IMAGE_CUBEMAP_EXP:
                break;
            default:
                return UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR;
            }
        }
@kbenzie kbenzie added bug Something isn't working loader Loader related feature/bug labels Jun 21, 2024
@kbenzie kbenzie added this to the Backlog milestone Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working loader Loader related feature/bug
Projects
None yet
Development

No branches or pull requests

2 participants