diff --git a/CMakeLists.txt b/CMakeLists.txt index d4b1630ddc..9c881e500c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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/mem_obj/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) set(NEO__INSTRUMENTATION_DIR_SUFFIX ${BRANCH_DIR_SUFFIX}) diff --git a/opencl/source/os_interface/windows/gl/CMakeLists.txt b/opencl/source/os_interface/windows/gl/CMakeLists.txt deleted file mode 100644 index 9087015584..0000000000 --- a/opencl/source/os_interface/windows/gl/CMakeLists.txt +++ /dev/null @@ -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}) diff --git a/opencl/source/os_interface/windows/gl/gl_arb_sync_event_os.cpp b/opencl/source/os_interface/windows/gl/gl_arb_sync_event_os.cpp deleted file mode 100644 index aad2884c44..0000000000 --- a/opencl/source/os_interface/windows/gl/gl_arb_sync_event_os.cpp +++ /dev/null @@ -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 - -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(sharing); - - glSyncInfo.hContextToBlock = static_cast(sharingFunctions.getGLContextHandle()); - auto glDevice = static_cast(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(&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 diff --git a/opencl/source/os_interface/windows/gl/gl_sharing_win.cpp b/opencl/source/os_interface/windows/gl/gl_sharing_win.cpp deleted file mode 100644 index 4d62386f65..0000000000 --- a/opencl/source/os_interface/windows/gl/gl_sharing_win.cpp +++ /dev/null @@ -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 -#include -#include - -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(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 diff --git a/opencl/source/sharings/gl/gl_cl_image_format.cpp b/opencl/source/sharings/gl/gl_cl_image_format.cpp index 4197120ab2..44863b1b28 100644 --- a/opencl/source/sharings/gl/gl_cl_image_format.cpp +++ b/opencl/source/sharings/gl/gl_cl_image_format.cpp @@ -14,9 +14,9 @@ namespace NEO { bool GlTexture::setClImageFormat(int glFormat, cl_image_format &clImgFormat) { - auto clFormat = GlSharing::gLToCLFormats.find(static_cast(glFormat)); + auto clFormat = GlSharing::glToCLFormats.find(static_cast(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_order = clFormat->second.image_channel_order; return true; diff --git a/opencl/source/sharings/gl/gl_context_guard.h b/opencl/source/sharings/gl/gl_context_guard.h index 7734bd1fcb..adf54801ef 100644 --- a/opencl/source/sharings/gl/gl_context_guard.h +++ b/opencl/source/sharings/gl/gl_context_guard.h @@ -7,9 +7,10 @@ #pragma once -#include "opencl/source/os_interface/windows/gl/gl_sharing_os.h" #include "opencl/source/sharings/gl/gl_sharing.h" +#include "gl_types.h" + namespace NEO { class GLContextGuard { public: diff --git a/opencl/source/sharings/gl/gl_sharing.cpp b/opencl/source/sharings/gl/gl_sharing.cpp index a9ce35f5f3..db318109d6 100644 --- a/opencl/source/sharings/gl/gl_sharing.cpp +++ b/opencl/source/sharings/gl/gl_sharing.cpp @@ -19,7 +19,7 @@ namespace NEO { const uint32_t GLSharingFunctions::sharingId = SharingType::CLGL_SHARING; -const std::unordered_map GlSharing::gLToCLFormats = { +const std::unordered_map GlSharing::glToCLFormats = { {GL_RGBA8, {CL_RGBA, CL_UNORM_INT8}}, {GL_RGBA8I, {CL_RGBA, CL_SIGNED_INT8}}, {GL_RGBA16, {CL_RGBA, CL_UNORM_INT16}}, @@ -65,6 +65,40 @@ const std::unordered_map GlSharing::gLToCLFormats {GL_RG32UI, {CL_RG, CL_UNSIGNED_INT32}}, {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(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) { GLContextGuard guard(*sharingFunctions); synchronizeObject(updateData); diff --git a/opencl/source/sharings/gl/gl_sharing.h b/opencl/source/sharings/gl/gl_sharing.h index f51260f36a..40f29b00a6 100644 --- a/opencl/source/sharings/gl/gl_sharing.h +++ b/opencl/source/sharings/gl/gl_sharing.h @@ -68,7 +68,7 @@ class GlSharing : public SharingHandler { *pClGlObjectId = clGlObjectId; } } - static const std::unordered_map gLToCLFormats; + static const std::unordered_map glToCLFormats; protected: int synchronizeHandler(UpdateData &updateData) override; diff --git a/opencl/source/sharings/gl/windows/CMakeLists.txt b/opencl/source/sharings/gl/windows/CMakeLists.txt index 3c9df994a6..67d115bed4 100644 --- a/opencl/source/sharings/gl/windows/CMakeLists.txt +++ b/opencl/source/sharings/gl/windows/CMakeLists.txt @@ -11,10 +11,12 @@ if(WIN32) ${CMAKE_CURRENT_SOURCE_DIR}/gl_arb_sync_event_windows.cpp ${CMAKE_CURRENT_SOURCE_DIR}/gl_buffer_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.cpp ${CMAKE_CURRENT_SOURCE_DIR}/gl_sync_event_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 ) target_sources(${NEO_STATIC_LIB_NAME} PRIVATE ${RUNTIME_SRCS_SHARINGS_GL_WINDOWS}) diff --git a/opencl/source/sharings/gl/windows/gl_arb_sync_event_windows.cpp b/opencl/source/sharings/gl/windows/gl_arb_sync_event_windows.cpp index a2420cf95e..c1ea0cb5b5 100644 --- a/opencl/source/sharings/gl/windows/gl_arb_sync_event_windows.cpp +++ b/opencl/source/sharings/gl/windows/gl_arb_sync_event_windows.cpp @@ -7,6 +7,10 @@ #include "shared/source/command_stream/command_stream_receiver.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/source/command_queue/command_queue.h" @@ -18,6 +22,139 @@ #include 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(sharing); + + glSyncInfo.hContextToBlock = static_cast(sharingFunctions.getGLContextHandle()); + auto glDevice = static_cast(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(&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) : Event(&context, nullptr, CL_COMMAND_GL_FENCE_SYNC_OBJECT_KHR, CompletionStamp::levelNotReady, CompletionStamp::levelNotReady), glSyncInfo(std::make_unique()) { diff --git a/opencl/source/os_interface/windows/gl/gl_options.cpp b/opencl/source/sharings/gl/windows/gl_library_windows.cpp similarity index 100% rename from opencl/source/os_interface/windows/gl/gl_options.cpp rename to opencl/source/sharings/gl/windows/gl_library_windows.cpp diff --git a/opencl/source/sharings/gl/windows/gl_sharing_windows.h b/opencl/source/sharings/gl/windows/gl_sharing_windows.h index cbca17ddf1..ecfdb002b0 100644 --- a/opencl/source/sharings/gl/windows/gl_sharing_windows.h +++ b/opencl/source/sharings/gl/windows/gl_sharing_windows.h @@ -7,9 +7,9 @@ #pragma once -#include "opencl/source/os_interface/windows/gl/gl_sharing_os.h" #include "opencl/source/sharings/gl/gl_sharing.h" +#include "gl_types.h" #include namespace NEO { diff --git a/opencl/source/os_interface/windows/gl/gl_sharing_os.h b/opencl/source/sharings/gl/windows/include/gl_types.h similarity index 100% rename from opencl/source/os_interface/windows/gl/gl_sharing_os.h rename to opencl/source/sharings/gl/windows/include/gl_types.h diff --git a/opencl/test/unit_test/api/gl/cl_get_gl_context_info_khr_tests.cpp b/opencl/test/unit_test/api/gl/cl_get_gl_context_info_khr_tests.cpp index 5170ba6e73..7ba7270b67 100644 --- a/opencl/test/unit_test/api/gl/cl_get_gl_context_info_khr_tests.cpp +++ b/opencl/test/unit_test/api/gl/cl_get_gl_context_info_khr_tests.cpp @@ -12,7 +12,7 @@ #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_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; diff --git a/opencl/test/unit_test/mocks/gl/windows/mock_gl_sharing_windows.h b/opencl/test/unit_test/mocks/gl/windows/mock_gl_sharing_windows.h index 14c07200d3..8e7912f60f 100644 --- a/opencl/test/unit_test/mocks/gl/windows/mock_gl_sharing_windows.h +++ b/opencl/test/unit_test/mocks/gl/windows/mock_gl_sharing_windows.h @@ -8,7 +8,7 @@ #pragma once #include "opencl/extensions/public/cl_gl_private_intel.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" diff --git a/opencl/test/unit_test/os_interface/windows/gl/CMakeLists.txt b/opencl/test/unit_test/os_interface/windows/gl/CMakeLists.txt deleted file mode 100644 index f1d3df3fb3..0000000000 --- a/opencl/test/unit_test/os_interface/windows/gl/CMakeLists.txt +++ /dev/null @@ -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() diff --git a/opencl/test/unit_test/sharings/gl/windows/CMakeLists.txt b/opencl/test/unit_test/sharings/gl/windows/CMakeLists.txt index 42e360c1d0..479f1f56a6 100644 --- a/opencl/test/unit_test/sharings/gl/windows/CMakeLists.txt +++ b/opencl/test/unit_test/sharings/gl/windows/CMakeLists.txt @@ -9,6 +9,9 @@ if(WIN32) ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt ${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_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_sharing_enable_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/gl_sharing_tests.cpp diff --git a/opencl/test/unit_test/os_interface/windows/gl/gl_dll_helper.h b/opencl/test/unit_test/sharings/gl/windows/gl_dll_helper.h similarity index 100% rename from opencl/test/unit_test/os_interface/windows/gl/gl_dll_helper.h rename to opencl/test/unit_test/sharings/gl/windows/gl_dll_helper.h diff --git a/opencl/test/unit_test/os_interface/windows/gl/gl_options.cpp b/opencl/test/unit_test/sharings/gl/windows/gl_library_name.cpp similarity index 100% rename from opencl/test/unit_test/os_interface/windows/gl/gl_options.cpp rename to opencl/test/unit_test/sharings/gl/windows/gl_library_name.cpp diff --git a/opencl/test/unit_test/os_interface/windows/gl/gl_os_sharing_tests.cpp b/opencl/test/unit_test/sharings/gl/windows/gl_os_sharing_tests.cpp similarity index 100% rename from opencl/test/unit_test/os_interface/windows/gl/gl_os_sharing_tests.cpp rename to opencl/test/unit_test/sharings/gl/windows/gl_os_sharing_tests.cpp diff --git a/opencl/test/unit_test/sharings/gl/windows/gl_sharing_tests.cpp b/opencl/test/unit_test/sharings/gl/windows/gl_sharing_tests.cpp index de21e215af..ba247dc1d6 100644 --- a/opencl/test/unit_test/sharings/gl/windows/gl_sharing_tests.cpp +++ b/opencl/test/unit_test/sharings/gl/windows/gl_sharing_tests.cpp @@ -36,7 +36,7 @@ #include "opencl/test/unit_test/mocks/mock_memory_manager.h" #include "test.h" -#include "gl/gl_sharing_os.h" +#include "gl_types.h" using namespace NEO; bool MockGLSharingFunctions::SharingEnabled = false; @@ -769,7 +769,7 @@ TEST(glSharingBasicTest, givenNumEntriesLowerThanSupportedFormatsWhenGettingSupp EXPECT_EQ(CL_SUCCESS, retVal); - EXPECT_EQ(static_cast(GlSharing::gLToCLFormats.size()), numImageFormats); + EXPECT_EQ(static_cast(GlSharing::glToCLFormats.size()), numImageFormats); EXPECT_NE(0u, glFormats[0]); EXPECT_EQ(0u, glFormats[1]); EXPECT_EQ(0u, glFormats[2]); @@ -787,10 +787,10 @@ TEST(glSharingBasicTest, givenCorrectFlagsWhenGettingSupportedFormatsThenCorrect auto result = glSharingFunctions.getSupportedFormats(flag, image_type, arrayCount(glFormats), glFormats, &numImageFormats); EXPECT_EQ(CL_SUCCESS, result); - EXPECT_EQ(static_cast(GlSharing::gLToCLFormats.size()), numImageFormats); + EXPECT_EQ(static_cast(GlSharing::glToCLFormats.size()), numImageFormats); 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); EXPECT_EQ(CL_SUCCESS, result); - EXPECT_EQ(static_cast(GlSharing::gLToCLFormats.size()), numImageFormats); + EXPECT_EQ(static_cast(GlSharing::glToCLFormats.size()), numImageFormats); 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); EXPECT_EQ(CL_SUCCESS, result); - EXPECT_EQ(static_cast(GlSharing::gLToCLFormats.size()), numImageFormats); + EXPECT_EQ(static_cast(GlSharing::glToCLFormats.size()), numImageFormats); } TEST(glSharingBasicTest, givenNullNumImageFormatsWhenGettingSupportedFormatsThenNumFormatsIsNotDereferenced) { @@ -1304,6 +1304,6 @@ TEST_F(clGetSupportedGLTextureFormatsINTELTests, givenValidInputsWhenGettingForm EXPECT_NE(0u, numFormats); 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])); } }