/* * Copyright (C) 2018-2023 Intel Corporation * * SPDX-License-Identifier: MIT * */ #pragma once #include "opencl/source/helpers/base_object.h" #include "opencl/source/helpers/error_mappers.h" #include namespace NEO { // Provide some aggregators... typedef std::pair EventWaitList; typedef std::pair DeviceList; typedef std::pair MemObjList; // Custom validators enum NonZeroBufferSize : size_t; enum PatternSize : size_t; template CLType withCastToInternal(CLType clObject, InternalType **internalObject) { *internalObject = NEO::castToObject(clObject); return (*internalObject) ? clObject : nullptr; } // This is the default instance of validateObject. // It should be specialized for specific types. template inline cl_int validateObject(Type object) { return CL_SUCCESS; } // Example of specialization. cl_int validateObject(void *ptr); cl_int validateObject(cl_context context); cl_int validateObject(cl_device_id device); cl_int validateObject(cl_platform_id platform); cl_int validateObject(cl_command_queue commandQueue); cl_int validateObject(cl_event platform); cl_int validateObject(cl_mem mem); cl_int validateObject(cl_sampler sampler); cl_int validateObject(cl_program program); cl_int validateObject(cl_kernel kernel); cl_int validateObject(const EventWaitList &eventWaitList); cl_int validateObject(const DeviceList &deviceList); cl_int validateObject(const MemObjList &memObjList); cl_int validateObject(const NonZeroBufferSize &nzbs); cl_int validateObject(const PatternSize &ps); cl_int validateObject(bool isValid); // This is the sentinel for the follow variadic template definition. inline cl_int validateObjects() { return CL_SUCCESS; } // This provides variadic object validation. // It automatically checks for nullptrs and then passes // onto type specific validator. template inline cl_int validateObjects(const Type &object, Types... rest) { auto retVal = validateObject(object); return CL_SUCCESS != retVal ? retVal : validateObjects(rest...); } template inline cl_int validateObjects(Type *object, Types... rest) { auto retVal = object ? validateObject(object) : NullObjectErrorMapper::retVal; return CL_SUCCESS != retVal ? retVal : validateObjects(rest...); } cl_int validateYuvOperation(const size_t *origin, const size_t *region); bool isPackedYuvImage(const cl_image_format *imageFormat); bool isNV12Image(const cl_image_format *imageFormat); } // namespace NEO