2018-08-27 16:30:40 +02:00
|
|
|
/*
|
2020-01-08 10:39:51 +01:00
|
|
|
* Copyright (C) 2018-2020 Intel Corporation
|
2018-08-27 16:30:40 +02:00
|
|
|
*
|
2018-09-18 09:11:08 +02:00
|
|
|
* SPDX-License-Identifier: MIT
|
2018-08-27 16:30:40 +02:00
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2020-01-27 17:28:10 +01:00
|
|
|
#include "core/helpers/timestamp_packet.h"
|
2019-08-29 12:15:33 +02:00
|
|
|
#include "core/os_interface/windows/windows_wrapper.h"
|
2020-01-08 10:39:51 +01:00
|
|
|
#include "runtime/helpers/windows/gl_helper.h"
|
2018-08-27 16:30:40 +02:00
|
|
|
#include "runtime/sharings/gl/gl_arb_sync_event.h"
|
2020-01-21 11:07:55 +01:00
|
|
|
#include "runtime/sharings/gl/windows/gl_sharing_windows.h"
|
2018-08-27 16:30:40 +02:00
|
|
|
|
2019-05-29 12:33:09 +02:00
|
|
|
#include <algorithm>
|
2019-02-27 11:39:32 +01:00
|
|
|
#include <cstdint>
|
|
|
|
|
#include <memory>
|
|
|
|
|
|
2018-08-27 16:30:40 +02:00
|
|
|
namespace Os {
|
|
|
|
|
extern const char *openglDllName;
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
namespace NEO {
|
2018-08-27 16:30:40 +02:00
|
|
|
|
2019-05-29 12:33:09 +02:00
|
|
|
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;
|
|
|
|
|
}
|
2019-03-26 11:59:46 +01:00
|
|
|
} // namespace NEO
|