Remove gl sharing related code from os_interface

Change-Id: Iece2fbdadefe338384f8961eef2720ff9b381e23
Signed-off-by: Maciej Dziuban <maciej.dziuban@intel.com>
This commit is contained in:
Maciej Dziuban
2020-03-30 15:54:49 +00:00
committed by sys_ocldev
parent 2ac968e6c2
commit 24cee4611d
21 changed files with 196 additions and 264 deletions

View File

@@ -818,7 +818,9 @@ include_directories(${NEO_SOURCE_DIR}/opencl/source/command_queue/definitions${B
include_directories(${NEO_SOURCE_DIR}/opencl/source/command_stream/definitions${BRANCH_DIR_SUFFIX}) include_directories(${NEO_SOURCE_DIR}/opencl/source/command_stream/definitions${BRANCH_DIR_SUFFIX})
include_directories(${NEO_SOURCE_DIR}/opencl/source/mem_obj/definitions${BRANCH_DIR_SUFFIX}) include_directories(${NEO_SOURCE_DIR}/opencl/source/mem_obj/definitions${BRANCH_DIR_SUFFIX})
include_directories(${NEO_SOURCE_DIR}/opencl/source/memory_manager/definitions${BRANCH_DIR_SUFFIX}) include_directories(${NEO_SOURCE_DIR}/opencl/source/memory_manager/definitions${BRANCH_DIR_SUFFIX})
if (MSVC)
include_directories(${NEO_SOURCE_DIR}/opencl/source/sharings/gl/windows/include)
endif()
if(HAVE_INSTRUMENTATION) if(HAVE_INSTRUMENTATION)
set(NEO__INSTRUMENTATION_DIR_SUFFIX ${BRANCH_DIR_SUFFIX}) set(NEO__INSTRUMENTATION_DIR_SUFFIX ${BRANCH_DIR_SUFFIX})

View File

@@ -1,18 +0,0 @@
#
# Copyright (C) 2017-2020 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
set(RUNTIME_SRCS_OS_INTERFACE_WINDOWS_GL
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/gl_arb_sync_event_os.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gl_sharing_win.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gl_options.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gl_sharing_os.h
)
if(WIN32)
target_sources(${NEO_STATIC_LIB_NAME} PRIVATE ${RUNTIME_SRCS_OS_INTERFACE_WINDOWS_GL})
endif()
set_property(GLOBAL PROPERTY RUNTIME_SRCS_OS_INTERFACE_WINDOWS_GL ${RUNTIME_SRCS_OS_INTERFACE_WINDOWS_GL})

View File

@@ -1,156 +0,0 @@
/*
* Copyright (C) 2018-2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/command_stream/command_stream_receiver.h"
#include "shared/source/helpers/timestamp_packet.h"
#include "shared/source/os_interface/os_interface.h"
#include "shared/source/os_interface/windows/gdi_interface.h"
#include "shared/source/os_interface/windows/os_context_win.h"
#include "shared/source/os_interface/windows/os_interface.h"
#include "shared/source/os_interface/windows/wddm/wddm.h"
#include "opencl/extensions/public/cl_gl_private_intel.h"
#include "opencl/source/context/context.h"
#include "opencl/source/sharings/gl/gl_arb_sync_event.h"
#include "opencl/source/sharings/gl/windows/gl_sharing_windows.h"
#include <GL/gl.h>
namespace NEO {
void destroySync(Gdi &gdi, D3DKMT_HANDLE sync) {
if (!sync) {
return;
}
D3DKMT_DESTROYSYNCHRONIZATIONOBJECT destroySyncInfo = {0};
destroySyncInfo.hSyncObject = sync;
NTSTATUS status = gdi.destroySynchronizationObject(&destroySyncInfo);
DEBUG_BREAK_IF(0 != status);
}
void destroyEvent(OSInterface &osInterface, HANDLE event) {
if (!event) {
return;
}
auto ret = osInterface.get()->closeHandle(event);
DEBUG_BREAK_IF(TRUE != ret);
}
void cleanupArbSyncObject(OSInterface &osInterface, CL_GL_SYNC_INFO *glSyncInfo) {
if (nullptr == glSyncInfo) {
return;
}
auto gdi = osInterface.get()->getWddm()->getGdi();
UNRECOVERABLE_IF(nullptr == gdi);
destroySync(*gdi, glSyncInfo->serverSynchronizationObject);
destroySync(*gdi, glSyncInfo->clientSynchronizationObject);
destroySync(*gdi, glSyncInfo->submissionSynchronizationObject);
destroyEvent(osInterface, glSyncInfo->event);
destroyEvent(osInterface, glSyncInfo->submissionEvent);
destroyArbSyncEventName(glSyncInfo->eventName);
destroyArbSyncEventName(glSyncInfo->submissionEventName);
}
bool setupArbSyncObject(GLSharingFunctions &sharing, OSInterface &osInterface, CL_GL_SYNC_INFO &glSyncInfo) {
auto &sharingFunctions = static_cast<GLSharingFunctionsWindows &>(sharing);
glSyncInfo.hContextToBlock = static_cast<D3DKMT_HANDLE>(sharingFunctions.getGLContextHandle());
auto glDevice = static_cast<D3DKMT_HANDLE>(sharingFunctions.getGLDeviceHandle());
auto wddm = osInterface.get()->getWddm();
D3DKMT_CREATESYNCHRONIZATIONOBJECT serverSyncInitInfo = {0};
serverSyncInitInfo.hDevice = glDevice;
serverSyncInitInfo.Info.Type = D3DDDI_SEMAPHORE;
serverSyncInitInfo.Info.Semaphore.MaxCount = 32;
serverSyncInitInfo.Info.Semaphore.InitialCount = 0;
NTSTATUS serverSyncInitStatus = wddm->getGdi()->createSynchronizationObject(&serverSyncInitInfo);
glSyncInfo.serverSynchronizationObject = serverSyncInitInfo.hSyncObject;
glSyncInfo.eventName = createArbSyncEventName();
glSyncInfo.event = osInterface.get()->createEvent(NULL, TRUE, FALSE, glSyncInfo.eventName);
D3DKMT_CREATESYNCHRONIZATIONOBJECT2 clientSyncInitInfo = {0};
clientSyncInitInfo.hDevice = glDevice;
clientSyncInitInfo.Info.Type = D3DDDI_CPU_NOTIFICATION;
clientSyncInitInfo.Info.CPUNotification.Event = glSyncInfo.event;
NTSTATUS clientSyncInitStatus = wddm->getGdi()->createSynchronizationObject2(&clientSyncInitInfo);
glSyncInfo.clientSynchronizationObject = clientSyncInitInfo.hSyncObject;
D3DKMT_CREATESYNCHRONIZATIONOBJECT2 submissionSyncEventInfo = {0};
glSyncInfo.submissionEventName = createArbSyncEventName();
glSyncInfo.submissionEvent = osInterface.get()->createEvent(NULL, TRUE, FALSE, glSyncInfo.submissionEventName);
submissionSyncEventInfo.hDevice = glDevice;
submissionSyncEventInfo.Info.Type = D3DDDI_CPU_NOTIFICATION;
submissionSyncEventInfo.Info.CPUNotification.Event = glSyncInfo.submissionEvent;
auto submissionSyncInitStatus = wddm->getGdi()->createSynchronizationObject2(&submissionSyncEventInfo);
glSyncInfo.submissionSynchronizationObject = submissionSyncEventInfo.hSyncObject;
glSyncInfo.waitCalled = false;
bool setupFailed =
(glSyncInfo.event == nullptr) ||
(glSyncInfo.submissionEvent == nullptr) ||
(0 != serverSyncInitStatus) ||
(0 != clientSyncInitStatus) ||
(0 != submissionSyncInitStatus);
if (setupFailed) {
DEBUG_BREAK_IF(true);
cleanupArbSyncObject(osInterface, &glSyncInfo);
return false;
}
return true;
}
void signalArbSyncObject(OsContext &osContext, CL_GL_SYNC_INFO &glSyncInfo) {
auto osContextWin = static_cast<OsContextWin *>(&osContext);
UNRECOVERABLE_IF(!osContextWin);
auto wddm = osContextWin->getWddm();
D3DKMT_SIGNALSYNCHRONIZATIONOBJECT signalServerClientSyncInfo = {0};
signalServerClientSyncInfo.hContext = osContextWin->getWddmContextHandle();
signalServerClientSyncInfo.Flags.SignalAtSubmission = 0; // Wait for GPU to complete processing command buffer
signalServerClientSyncInfo.ObjectHandleArray[0] = glSyncInfo.serverSynchronizationObject;
signalServerClientSyncInfo.ObjectHandleArray[1] = glSyncInfo.clientSynchronizationObject;
signalServerClientSyncInfo.ObjectCount = 2;
NTSTATUS status = wddm->getGdi()->signalSynchronizationObject(&signalServerClientSyncInfo);
if (0 != status) {
DEBUG_BREAK_IF(true);
return;
}
D3DKMT_SIGNALSYNCHRONIZATIONOBJECT signalSubmissionSyncInfo = {0};
signalSubmissionSyncInfo.hContext = osContextWin->getWddmContextHandle();
signalSubmissionSyncInfo.Flags.SignalAtSubmission = 1; // Don't wait for GPU to complete processing command buffer
signalSubmissionSyncInfo.ObjectHandleArray[0] = glSyncInfo.submissionSynchronizationObject;
signalSubmissionSyncInfo.ObjectCount = 1;
status = wddm->getGdi()->signalSynchronizationObject(&signalSubmissionSyncInfo);
DEBUG_BREAK_IF(0 != status);
}
void serverWaitForArbSyncObject(OSInterface &osInterface, CL_GL_SYNC_INFO &glSyncInfo) {
auto wddm = osInterface.get()->getWddm();
D3DKMT_WAITFORSYNCHRONIZATIONOBJECT waitForSyncInfo = {0};
waitForSyncInfo.hContext = glSyncInfo.hContextToBlock;
waitForSyncInfo.ObjectCount = 1;
waitForSyncInfo.ObjectHandleArray[0] = glSyncInfo.serverSynchronizationObject;
NTSTATUS status = wddm->getGdi()->waitForSynchronizationObject(&waitForSyncInfo);
if (status != 0) {
DEBUG_BREAK_IF(true);
return;
}
glSyncInfo.waitCalled = true;
}
} // namespace NEO

View File

@@ -1,58 +0,0 @@
/*
* Copyright (C) 2018-2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/helpers/timestamp_packet.h"
#include "shared/source/os_interface/windows/windows_wrapper.h"
#include "opencl/source/helpers/windows/gl_helper.h"
#include "opencl/source/sharings/gl/gl_arb_sync_event.h"
#include "opencl/source/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

View File

@@ -14,9 +14,9 @@
namespace NEO { namespace NEO {
bool GlTexture::setClImageFormat(int glFormat, cl_image_format &clImgFormat) { bool GlTexture::setClImageFormat(int glFormat, cl_image_format &clImgFormat) {
auto clFormat = GlSharing::gLToCLFormats.find(static_cast<GLenum>(glFormat)); auto clFormat = GlSharing::glToCLFormats.find(static_cast<GLenum>(glFormat));
if (clFormat != GlSharing::gLToCLFormats.end()) { if (clFormat != GlSharing::glToCLFormats.end()) {
clImgFormat.image_channel_data_type = clFormat->second.image_channel_data_type; clImgFormat.image_channel_data_type = clFormat->second.image_channel_data_type;
clImgFormat.image_channel_order = clFormat->second.image_channel_order; clImgFormat.image_channel_order = clFormat->second.image_channel_order;
return true; return true;

View File

@@ -7,9 +7,10 @@
#pragma once #pragma once
#include "opencl/source/os_interface/windows/gl/gl_sharing_os.h"
#include "opencl/source/sharings/gl/gl_sharing.h" #include "opencl/source/sharings/gl/gl_sharing.h"
#include "gl_types.h"
namespace NEO { namespace NEO {
class GLContextGuard { class GLContextGuard {
public: public:

View File

@@ -19,7 +19,7 @@
namespace NEO { namespace NEO {
const uint32_t GLSharingFunctions::sharingId = SharingType::CLGL_SHARING; const uint32_t GLSharingFunctions::sharingId = SharingType::CLGL_SHARING;
const std::unordered_map<GLenum, const cl_image_format> GlSharing::gLToCLFormats = { const std::unordered_map<GLenum, const cl_image_format> GlSharing::glToCLFormats = {
{GL_RGBA8, {CL_RGBA, CL_UNORM_INT8}}, {GL_RGBA8, {CL_RGBA, CL_UNORM_INT8}},
{GL_RGBA8I, {CL_RGBA, CL_SIGNED_INT8}}, {GL_RGBA8I, {CL_RGBA, CL_SIGNED_INT8}},
{GL_RGBA16, {CL_RGBA, CL_UNORM_INT16}}, {GL_RGBA16, {CL_RGBA, CL_UNORM_INT16}},
@@ -65,6 +65,40 @@ const std::unordered_map<GLenum, const cl_image_format> GlSharing::gLToCLFormats
{GL_RG32UI, {CL_RG, CL_UNSIGNED_INT32}}, {GL_RG32UI, {CL_RG, CL_UNSIGNED_INT32}},
{GL_RGB10, {CL_RGBA, CL_UNORM_INT16}}}; {GL_RGB10, {CL_RGBA, CL_UNORM_INT16}}};
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) {
const auto elementsToCopy = std::min(numEntries, formatsCount);
uint32_t outputFormatsIndex = 0;
for (const auto &formatMapping : GlSharing::glToCLFormats) {
formats[outputFormatsIndex++] = formatMapping.first;
if (outputFormatsIndex == elementsToCopy) {
break;
}
}
}
return CL_SUCCESS;
}
int GlSharing::synchronizeHandler(UpdateData &updateData) { int GlSharing::synchronizeHandler(UpdateData &updateData) {
GLContextGuard guard(*sharingFunctions); GLContextGuard guard(*sharingFunctions);
synchronizeObject(updateData); synchronizeObject(updateData);

View File

@@ -68,7 +68,7 @@ class GlSharing : public SharingHandler {
*pClGlObjectId = clGlObjectId; *pClGlObjectId = clGlObjectId;
} }
} }
static const std::unordered_map<GLenum, const cl_image_format> gLToCLFormats; static const std::unordered_map<GLenum, const cl_image_format> glToCLFormats;
protected: protected:
int synchronizeHandler(UpdateData &updateData) override; int synchronizeHandler(UpdateData &updateData) override;

View File

@@ -11,10 +11,12 @@ if(WIN32)
${CMAKE_CURRENT_SOURCE_DIR}/gl_arb_sync_event_windows.cpp ${CMAKE_CURRENT_SOURCE_DIR}/gl_arb_sync_event_windows.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gl_buffer_windows.cpp ${CMAKE_CURRENT_SOURCE_DIR}/gl_buffer_windows.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gl_context_guard_windows.cpp ${CMAKE_CURRENT_SOURCE_DIR}/gl_context_guard_windows.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gl_library_windows.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gl_sharing_windows.h ${CMAKE_CURRENT_SOURCE_DIR}/gl_sharing_windows.h
${CMAKE_CURRENT_SOURCE_DIR}/gl_sharing_windows.cpp ${CMAKE_CURRENT_SOURCE_DIR}/gl_sharing_windows.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gl_sync_event_windows.cpp ${CMAKE_CURRENT_SOURCE_DIR}/gl_sync_event_windows.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gl_texture_windows.cpp ${CMAKE_CURRENT_SOURCE_DIR}/gl_texture_windows.cpp
${CMAKE_CURRENT_SOURCE_DIR}/include/gl_types.h
${CMAKE_CURRENT_SOURCE_DIR}/win_enable_gl.h ${CMAKE_CURRENT_SOURCE_DIR}/win_enable_gl.h
) )
target_sources(${NEO_STATIC_LIB_NAME} PRIVATE ${RUNTIME_SRCS_SHARINGS_GL_WINDOWS}) target_sources(${NEO_STATIC_LIB_NAME} PRIVATE ${RUNTIME_SRCS_SHARINGS_GL_WINDOWS})

View File

@@ -7,6 +7,10 @@
#include "shared/source/command_stream/command_stream_receiver.h" #include "shared/source/command_stream/command_stream_receiver.h"
#include "shared/source/device/device.h" #include "shared/source/device/device.h"
#include "shared/source/os_interface/windows/gdi_interface.h"
#include "shared/source/os_interface/windows/os_context_win.h"
#include "shared/source/os_interface/windows/os_interface.h"
#include "shared/source/os_interface/windows/wddm/wddm.h"
#include "opencl/extensions/public/cl_gl_private_intel.h" #include "opencl/extensions/public/cl_gl_private_intel.h"
#include "opencl/source/command_queue/command_queue.h" #include "opencl/source/command_queue/command_queue.h"
@@ -18,6 +22,139 @@
#include <GL/gl.h> #include <GL/gl.h>
namespace NEO { namespace NEO {
void destroySync(Gdi &gdi, D3DKMT_HANDLE sync) {
if (!sync) {
return;
}
D3DKMT_DESTROYSYNCHRONIZATIONOBJECT destroySyncInfo = {};
destroySyncInfo.hSyncObject = sync;
NTSTATUS status = gdi.destroySynchronizationObject(&destroySyncInfo);
DEBUG_BREAK_IF(STATUS_SUCCESS != status);
}
void destroyEvent(OSInterface &osInterface, HANDLE event) {
if (!event) {
return;
}
auto ret = osInterface.get()->closeHandle(event);
DEBUG_BREAK_IF(TRUE != ret);
}
void cleanupArbSyncObject(OSInterface &osInterface, CL_GL_SYNC_INFO *glSyncInfo) {
if (nullptr == glSyncInfo) {
return;
}
auto gdi = osInterface.get()->getWddm()->getGdi();
UNRECOVERABLE_IF(nullptr == gdi);
destroySync(*gdi, glSyncInfo->serverSynchronizationObject);
destroySync(*gdi, glSyncInfo->clientSynchronizationObject);
destroySync(*gdi, glSyncInfo->submissionSynchronizationObject);
destroyEvent(osInterface, glSyncInfo->event);
destroyEvent(osInterface, glSyncInfo->submissionEvent);
destroyArbSyncEventName(glSyncInfo->eventName);
destroyArbSyncEventName(glSyncInfo->submissionEventName);
}
bool setupArbSyncObject(GLSharingFunctions &sharing, OSInterface &osInterface, CL_GL_SYNC_INFO &glSyncInfo) {
auto &sharingFunctions = static_cast<GLSharingFunctionsWindows &>(sharing);
glSyncInfo.hContextToBlock = static_cast<D3DKMT_HANDLE>(sharingFunctions.getGLContextHandle());
auto glDevice = static_cast<D3DKMT_HANDLE>(sharingFunctions.getGLDeviceHandle());
auto wddm = osInterface.get()->getWddm();
D3DKMT_CREATESYNCHRONIZATIONOBJECT serverSyncInitInfo = {};
serverSyncInitInfo.hDevice = glDevice;
serverSyncInitInfo.Info.Type = D3DDDI_SEMAPHORE;
serverSyncInitInfo.Info.Semaphore.MaxCount = 32;
serverSyncInitInfo.Info.Semaphore.InitialCount = 0;
NTSTATUS serverSyncInitStatus = wddm->getGdi()->createSynchronizationObject(&serverSyncInitInfo);
glSyncInfo.serverSynchronizationObject = serverSyncInitInfo.hSyncObject;
glSyncInfo.eventName = createArbSyncEventName();
glSyncInfo.event = osInterface.get()->createEvent(NULL, TRUE, FALSE, glSyncInfo.eventName);
D3DKMT_CREATESYNCHRONIZATIONOBJECT2 clientSyncInitInfo = {};
clientSyncInitInfo.hDevice = glDevice;
clientSyncInitInfo.Info.Type = D3DDDI_CPU_NOTIFICATION;
clientSyncInitInfo.Info.CPUNotification.Event = glSyncInfo.event;
NTSTATUS clientSyncInitStatus = wddm->getGdi()->createSynchronizationObject2(&clientSyncInitInfo);
glSyncInfo.clientSynchronizationObject = clientSyncInitInfo.hSyncObject;
D3DKMT_CREATESYNCHRONIZATIONOBJECT2 submissionSyncEventInfo = {};
glSyncInfo.submissionEventName = createArbSyncEventName();
glSyncInfo.submissionEvent = osInterface.get()->createEvent(NULL, TRUE, FALSE, glSyncInfo.submissionEventName);
submissionSyncEventInfo.hDevice = glDevice;
submissionSyncEventInfo.Info.Type = D3DDDI_CPU_NOTIFICATION;
submissionSyncEventInfo.Info.CPUNotification.Event = glSyncInfo.submissionEvent;
auto submissionSyncInitStatus = wddm->getGdi()->createSynchronizationObject2(&submissionSyncEventInfo);
glSyncInfo.submissionSynchronizationObject = submissionSyncEventInfo.hSyncObject;
glSyncInfo.waitCalled = false;
bool setupFailed =
(glSyncInfo.event == nullptr) ||
(glSyncInfo.submissionEvent == nullptr) ||
(STATUS_SUCCESS != serverSyncInitStatus) ||
(STATUS_SUCCESS != clientSyncInitStatus) ||
(STATUS_SUCCESS != submissionSyncInitStatus);
if (setupFailed) {
DEBUG_BREAK_IF(true);
cleanupArbSyncObject(osInterface, &glSyncInfo);
return false;
}
return true;
}
void signalArbSyncObject(OsContext &osContext, CL_GL_SYNC_INFO &glSyncInfo) {
auto osContextWin = static_cast<OsContextWin *>(&osContext);
UNRECOVERABLE_IF(!osContextWin);
auto wddm = osContextWin->getWddm();
D3DKMT_SIGNALSYNCHRONIZATIONOBJECT signalServerClientSyncInfo = {};
signalServerClientSyncInfo.hContext = osContextWin->getWddmContextHandle();
signalServerClientSyncInfo.Flags.SignalAtSubmission = 0; // Wait for GPU to complete processing command buffer
signalServerClientSyncInfo.ObjectHandleArray[0] = glSyncInfo.serverSynchronizationObject;
signalServerClientSyncInfo.ObjectHandleArray[1] = glSyncInfo.clientSynchronizationObject;
signalServerClientSyncInfo.ObjectCount = 2;
NTSTATUS status = wddm->getGdi()->signalSynchronizationObject(&signalServerClientSyncInfo);
if (STATUS_SUCCESS != status) {
DEBUG_BREAK_IF(true);
return;
}
D3DKMT_SIGNALSYNCHRONIZATIONOBJECT signalSubmissionSyncInfo = {};
signalSubmissionSyncInfo.hContext = osContextWin->getWddmContextHandle();
signalSubmissionSyncInfo.Flags.SignalAtSubmission = 1; // Don't wait for GPU to complete processing command buffer
signalSubmissionSyncInfo.ObjectHandleArray[0] = glSyncInfo.submissionSynchronizationObject;
signalSubmissionSyncInfo.ObjectCount = 1;
status = wddm->getGdi()->signalSynchronizationObject(&signalSubmissionSyncInfo);
DEBUG_BREAK_IF(STATUS_SUCCESS != status);
}
void serverWaitForArbSyncObject(OSInterface &osInterface, CL_GL_SYNC_INFO &glSyncInfo) {
auto wddm = osInterface.get()->getWddm();
D3DKMT_WAITFORSYNCHRONIZATIONOBJECT waitForSyncInfo = {};
waitForSyncInfo.hContext = glSyncInfo.hContextToBlock;
waitForSyncInfo.ObjectCount = 1;
waitForSyncInfo.ObjectHandleArray[0] = glSyncInfo.serverSynchronizationObject;
NTSTATUS status = wddm->getGdi()->waitForSynchronizationObject(&waitForSyncInfo);
if (status != STATUS_SUCCESS) {
DEBUG_BREAK_IF(true);
return;
}
glSyncInfo.waitCalled = true;
}
GlArbSyncEvent::GlArbSyncEvent(Context &context) GlArbSyncEvent::GlArbSyncEvent(Context &context)
: Event(&context, nullptr, CL_COMMAND_GL_FENCE_SYNC_OBJECT_KHR, CompletionStamp::levelNotReady, CompletionStamp::levelNotReady), : Event(&context, nullptr, CL_COMMAND_GL_FENCE_SYNC_OBJECT_KHR, CompletionStamp::levelNotReady, CompletionStamp::levelNotReady),
glSyncInfo(std::make_unique<CL_GL_SYNC_INFO>()) { glSyncInfo(std::make_unique<CL_GL_SYNC_INFO>()) {

View File

@@ -7,9 +7,9 @@
#pragma once #pragma once
#include "opencl/source/os_interface/windows/gl/gl_sharing_os.h"
#include "opencl/source/sharings/gl/gl_sharing.h" #include "opencl/source/sharings/gl/gl_sharing.h"
#include "gl_types.h"
#include <GL/gl.h> #include <GL/gl.h>
namespace NEO { namespace NEO {

View File

@@ -12,7 +12,7 @@
#include "opencl/test/unit_test/api/cl_api_tests.h" #include "opencl/test/unit_test/api/cl_api_tests.h"
#include "opencl/test/unit_test/mocks/mock_device.h" #include "opencl/test/unit_test/mocks/mock_device.h"
#include "opencl/test/unit_test/mocks/mock_platform.h" #include "opencl/test/unit_test/mocks/mock_platform.h"
#include "opencl/test/unit_test/os_interface/windows/gl/gl_dll_helper.h" #include "opencl/test/unit_test/sharings/gl/windows/gl_dll_helper.h"
using namespace NEO; using namespace NEO;

View File

@@ -8,7 +8,7 @@
#pragma once #pragma once
#include "opencl/extensions/public/cl_gl_private_intel.h" #include "opencl/extensions/public/cl_gl_private_intel.h"
#include "opencl/source/sharings/gl/windows/gl_sharing_windows.h" #include "opencl/source/sharings/gl/windows/gl_sharing_windows.h"
#include "opencl/test/unit_test/os_interface/windows/gl/gl_dll_helper.h" #include "opencl/test/unit_test/sharings/gl/windows/gl_dll_helper.h"
#include "config.h" #include "config.h"

View File

@@ -1,15 +0,0 @@
#
# Copyright (C) 2017-2020 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
if(WIN32)
set(IGDRCL_SRCS_tests_os_interface_windows_gl
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/gl_os_sharing_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gl_options.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gl_dll_helper.h
)
target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_os_interface_windows_gl})
endif()

View File

@@ -9,6 +9,9 @@ if(WIN32)
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/gl_arb_sync_event_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/gl_arb_sync_event_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gl_create_from_texture_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/gl_create_from_texture_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gl_dll_helper.h
${CMAKE_CURRENT_SOURCE_DIR}/gl_library_name.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gl_os_sharing_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gl_reused_buffers_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/gl_reused_buffers_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gl_sharing_enable_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/gl_sharing_enable_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gl_sharing_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/gl_sharing_tests.cpp

View File

@@ -36,7 +36,7 @@
#include "opencl/test/unit_test/mocks/mock_memory_manager.h" #include "opencl/test/unit_test/mocks/mock_memory_manager.h"
#include "test.h" #include "test.h"
#include "gl/gl_sharing_os.h" #include "gl_types.h"
using namespace NEO; using namespace NEO;
bool MockGLSharingFunctions::SharingEnabled = false; bool MockGLSharingFunctions::SharingEnabled = false;
@@ -769,7 +769,7 @@ TEST(glSharingBasicTest, givenNumEntriesLowerThanSupportedFormatsWhenGettingSupp
EXPECT_EQ(CL_SUCCESS, retVal); EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_EQ(static_cast<uint32_t>(GlSharing::gLToCLFormats.size()), numImageFormats); EXPECT_EQ(static_cast<uint32_t>(GlSharing::glToCLFormats.size()), numImageFormats);
EXPECT_NE(0u, glFormats[0]); EXPECT_NE(0u, glFormats[0]);
EXPECT_EQ(0u, glFormats[1]); EXPECT_EQ(0u, glFormats[1]);
EXPECT_EQ(0u, glFormats[2]); EXPECT_EQ(0u, glFormats[2]);
@@ -787,10 +787,10 @@ TEST(glSharingBasicTest, givenCorrectFlagsWhenGettingSupportedFormatsThenCorrect
auto result = glSharingFunctions.getSupportedFormats(flag, image_type, arrayCount(glFormats), glFormats, &numImageFormats); auto result = glSharingFunctions.getSupportedFormats(flag, image_type, arrayCount(glFormats), glFormats, &numImageFormats);
EXPECT_EQ(CL_SUCCESS, result); EXPECT_EQ(CL_SUCCESS, result);
EXPECT_EQ(static_cast<uint32_t>(GlSharing::gLToCLFormats.size()), numImageFormats); EXPECT_EQ(static_cast<uint32_t>(GlSharing::glToCLFormats.size()), numImageFormats);
for (uint32_t formatIndex = 0; formatIndex < arrayCount(glFormats); formatIndex++) { for (uint32_t formatIndex = 0; formatIndex < arrayCount(glFormats); formatIndex++) {
EXPECT_NE(GlSharing::gLToCLFormats.end(), GlSharing::gLToCLFormats.find(glFormats[formatIndex])); EXPECT_NE(GlSharing::glToCLFormats.end(), GlSharing::glToCLFormats.find(glFormats[formatIndex]));
} }
} }
} }
@@ -807,10 +807,10 @@ TEST(glSharingBasicTest, givenSupportedImageTypesWhenGettingSupportedFormatsThen
auto result = glSharingFunctions.getSupportedFormats(flags, image_type, arrayCount(glFormats), glFormats, &numImageFormats); auto result = glSharingFunctions.getSupportedFormats(flags, image_type, arrayCount(glFormats), glFormats, &numImageFormats);
EXPECT_EQ(CL_SUCCESS, result); EXPECT_EQ(CL_SUCCESS, result);
EXPECT_EQ(static_cast<uint32_t>(GlSharing::gLToCLFormats.size()), numImageFormats); EXPECT_EQ(static_cast<uint32_t>(GlSharing::glToCLFormats.size()), numImageFormats);
for (auto glFormat : glFormats) { for (auto glFormat : glFormats) {
EXPECT_NE(GlSharing::gLToCLFormats.end(), GlSharing::gLToCLFormats.find(glFormat)); EXPECT_NE(GlSharing::glToCLFormats.end(), GlSharing::glToCLFormats.find(glFormat));
} }
} }
} }
@@ -824,7 +824,7 @@ TEST(glSharingBasicTest, givenZeroNumEntriesWhenGettingSupportedFormatsThenNumFo
auto result = glSharingFunctions.getSupportedFormats(flags, image_type, 0, nullptr, &numImageFormats); auto result = glSharingFunctions.getSupportedFormats(flags, image_type, 0, nullptr, &numImageFormats);
EXPECT_EQ(CL_SUCCESS, result); EXPECT_EQ(CL_SUCCESS, result);
EXPECT_EQ(static_cast<uint32_t>(GlSharing::gLToCLFormats.size()), numImageFormats); EXPECT_EQ(static_cast<uint32_t>(GlSharing::glToCLFormats.size()), numImageFormats);
} }
TEST(glSharingBasicTest, givenNullNumImageFormatsWhenGettingSupportedFormatsThenNumFormatsIsNotDereferenced) { TEST(glSharingBasicTest, givenNullNumImageFormatsWhenGettingSupportedFormatsThenNumFormatsIsNotDereferenced) {
@@ -1304,6 +1304,6 @@ TEST_F(clGetSupportedGLTextureFormatsINTELTests, givenValidInputsWhenGettingForm
EXPECT_NE(0u, numFormats); EXPECT_NE(0u, numFormats);
for (uint32_t i = 0; i < glFormatsCount; i++) { for (uint32_t i = 0; i < glFormatsCount; i++) {
EXPECT_NE(GlSharing::gLToCLFormats.end(), GlSharing::gLToCLFormats.find(glFormats[i])); EXPECT_NE(GlSharing::glToCLFormats.end(), GlSharing::glToCLFormats.find(glFormats[i]));
} }
} }