Files
compute-runtime/runtime/helpers/mipmap.h
Woloszyn, Wojciech 0ad81024b7 Implement cl_khr_mipmap_image [1/n]
- Add mipmap image handling for clEnqueueReadImage, clEnqueueWriteImage
- Fix mipmap image handling for clCreateImage

Change-Id: I42938a330b55c7e69a16c26dce3ab5d66f8a8938
2018-03-21 10:51:13 +01:00

51 lines
1.7 KiB
C++

/*
* Copyright (c) 2018, Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <cstdint>
#include "CL/cl.h"
namespace OCLRT {
inline uint32_t findMipLevel(cl_mem_object_type imageType, const size_t *origin) {
size_t mipLevel = 0;
switch (imageType) {
case CL_MEM_OBJECT_IMAGE1D:
mipLevel = origin[1];
break;
case CL_MEM_OBJECT_IMAGE1D_ARRAY:
case CL_MEM_OBJECT_IMAGE2D:
mipLevel = origin[2];
break;
case CL_MEM_OBJECT_IMAGE2D_ARRAY:
case CL_MEM_OBJECT_IMAGE3D:
mipLevel = origin[3];
break;
default:
mipLevel = 0;
}
return static_cast<uint32_t>(mipLevel);
}
} // namespace OCLRT