Edit

kc3-lang/angle/src/libANGLE/validationCL.h

Branch :

  • Show log

    Commit

  • Author : John Plate
    Date : 2021-05-25 16:54:11
    Hash : 51ab3dc3
    Message : CL: Improve validation readablity Improve validation readablity by introducing a bit field class and by changing how the CL error code is returned. Bug: angleproject:6001 Change-Id: I51deb745454e5281de725481edef85eb30be28c7 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2919690 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Cody Northrop <cnorthrop@google.com> Commit-Queue: John Plate <jplate@google.com>

  • src/libANGLE/validationCL.h
  • //
    // Copyright 2021 The ANGLE Project Authors. All rights reserved.
    // Use of this source code is governed by a BSD-style license that can be
    // found in the LICENSE file.
    //
    
    // validationCL.h: Validation functions for generic CL entry point parameters
    
    #ifndef LIBANGLE_VALIDATIONCL_H_
    #define LIBANGLE_VALIDATIONCL_H_
    
    #include "libANGLE/CLBuffer.h"
    #include "libANGLE/CLCommandQueue.h"
    #include "libANGLE/CLContext.h"
    #include "libANGLE/CLDevice.h"
    #include "libANGLE/CLEvent.h"
    #include "libANGLE/CLImage.h"
    #include "libANGLE/CLKernel.h"
    #include "libANGLE/CLMemory.h"
    #include "libANGLE/CLPlatform.h"
    #include "libANGLE/CLProgram.h"
    #include "libANGLE/CLSampler.h"
    
    #define ANGLE_CL_VALIDATE_VOID(EP, ...)              \
        do                                               \
        {                                                \
            if (Validate##EP(__VA_ARGS__) != CL_SUCCESS) \
            {                                            \
                return;                                  \
            }                                            \
        } while (0)
    
    #define ANGLE_CL_VALIDATE_ERROR(EP, ...)              \
        do                                                \
        {                                                 \
            cl_int errorCode = Validate##EP(__VA_ARGS__); \
            if (errorCode != CL_SUCCESS)                  \
            {                                             \
                return errorCode;                         \
            }                                             \
        } while (0)
    
    #define ANGLE_CL_VALIDATE_ERRCODE_RET(EP, ...)        \
        do                                                \
        {                                                 \
            cl_int errorCode = Validate##EP(__VA_ARGS__); \
            if (errorCode != CL_SUCCESS)                  \
            {                                             \
                if (errcode_ret != nullptr)               \
                {                                         \
                    *errcode_ret = errorCode;             \
                }                                         \
                return nullptr;                           \
            }                                             \
        } while (0)
    
    #define ANGLE_CL_VALIDATE_POINTER(EP, ...)            \
        do                                                \
        {                                                 \
            cl_int errorCode = Validate##EP(__VA_ARGS__); \
            if (errorCode != CL_SUCCESS)                  \
            {                                             \
                return nullptr;                           \
            }                                             \
        } while (0)
    
    #endif  // LIBANGLE_VALIDATIONCL_H_