1 // 2 // Copyright 2021 The ANGLE Project Authors. All rights reserved. 3 // Use of this source code is governed by a BSD-style license that can be 4 // found in the LICENSE file. 5 // 6 // cl_utils.h: Helper functions for the CL front end 7 8 #ifndef LIBANGLE_CL_UTILS_H_ 9 #define LIBANGLE_CL_UTILS_H_ 10 11 #include "libANGLE/renderer/CLtypes.h" 12 13 namespace cl 14 { 15 16 size_t GetChannelCount(cl_channel_order channelOrder); 17 18 size_t GetElementSize(const cl_image_format &image_format); 19 OverlapRegions(size_t offset1,size_t offset2,size_t size)20inline bool OverlapRegions(size_t offset1, size_t offset2, size_t size) 21 { 22 // From https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_API.html 23 // The regions overlap if src_offset <= dst_offset <= src_offset + size - 1 24 // or if dst_offset <= src_offset <= dst_offset + size - 1. 25 return (offset1 <= offset2 && offset2 <= offset1 + size - 1u) || 26 (offset2 <= offset1 && offset1 <= offset2 + size - 1u); 27 } 28 29 bool IsValidImageFormat(const cl_image_format *imageFormat, const rx::CLExtensions &extensions); 30 31 } // namespace cl 32 33 #endif // LIBANGLE_CL_UTILS_H_ 34