mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-28 00:03:14 +08:00
Change-Id: I78bf6a82df3399a2b79143333989bac81e7a392a Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
58 lines
1.8 KiB
C++
58 lines
1.8 KiB
C++
/*
|
|
* Copyright (C) 2018-2020 Intel Corporation
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*
|
|
*/
|
|
|
|
#include "core/helpers/timestamp_packet.h"
|
|
#include "core/os_interface/windows/windows_wrapper.h"
|
|
#include "runtime/helpers/windows/gl_helper.h"
|
|
#include "runtime/sharings/gl/gl_arb_sync_event.h"
|
|
#include "runtime/sharings/gl/windows/gl_sharing_windows.h"
|
|
|
|
#include <algorithm>
|
|
#include <cstdint>
|
|
#include <memory>
|
|
|
|
namespace Os {
|
|
extern const char *openglDllName;
|
|
}
|
|
|
|
namespace NEO {
|
|
|
|
cl_int GLSharingFunctions::getSupportedFormats(cl_mem_flags flags,
|
|
cl_mem_object_type imageType,
|
|
size_t numEntries,
|
|
cl_GLenum *formats,
|
|
uint32_t *numImageFormats) {
|
|
if (flags != CL_MEM_READ_ONLY && flags != CL_MEM_WRITE_ONLY && flags != CL_MEM_READ_WRITE && flags != CL_MEM_KERNEL_READ_AND_WRITE) {
|
|
return CL_INVALID_VALUE;
|
|
}
|
|
|
|
if (imageType != CL_MEM_OBJECT_IMAGE1D && imageType != CL_MEM_OBJECT_IMAGE2D &&
|
|
imageType != CL_MEM_OBJECT_IMAGE3D && imageType != CL_MEM_OBJECT_IMAGE1D_ARRAY &&
|
|
imageType != CL_MEM_OBJECT_IMAGE1D_BUFFER) {
|
|
return CL_INVALID_VALUE;
|
|
}
|
|
|
|
const auto formatsCount = GlSharing::gLToCLFormats.size();
|
|
if (numImageFormats != nullptr) {
|
|
*numImageFormats = static_cast<cl_uint>(formatsCount);
|
|
}
|
|
|
|
if (formats != nullptr && formatsCount > 0) {
|
|
auto elementsToCopy = std::min(numEntries, formatsCount);
|
|
uint32_t i = 0;
|
|
for (auto &x : GlSharing::gLToCLFormats) {
|
|
formats[i++] = x.first;
|
|
if (i == elementsToCopy) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
return CL_SUCCESS;
|
|
}
|
|
} // namespace NEO
|