mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Add support for ntHandles in OCL
Signed-off-by: Kamil Diedrich <kamil.diedrich@intel.com>
This commit is contained in:

committed by
Compute-Runtime-Automation

parent
5dda77d628
commit
97ea332a9f
@ -115,6 +115,16 @@ TEST_F(ValidExportHostPtr, givenInvalidPropertiesWithDmaBufWhenValidateInputAndC
|
||||
clReleaseMemObject(buffer);
|
||||
}
|
||||
|
||||
TEST_F(ValidExportHostPtr, givenInvalidPropertiesWithOpaqueWin32WhenValidateInputAndCreateBufferThenNullptrIsReturned) {
|
||||
cl_mem_properties properties[] = {CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KHR, 0x1234, 0};
|
||||
cl_mem buffer = BufferFunctions::validateInputAndCreateBuffer(context.get(), properties, flags, 0, g_scTestBufferSizeInBytes, nullptr, retVal);
|
||||
|
||||
EXPECT_EQ(retVal, CL_INVALID_PROPERTY);
|
||||
EXPECT_EQ(buffer, nullptr);
|
||||
|
||||
clReleaseMemObject(buffer);
|
||||
}
|
||||
|
||||
TEST_F(ValidExportHostPtr, givenPropertiesWithDmaBufWhenValidateInputAndCreateBufferThenCorrectBufferIsSet) {
|
||||
|
||||
cl_mem_properties properties[] = {CL_EXTERNAL_MEMORY_HANDLE_DMA_BUF_KHR, 0x1234, 0};
|
||||
|
@ -102,7 +102,7 @@ struct ValidExportHostPtr
|
||||
Buffer *buffer = nullptr;
|
||||
};
|
||||
|
||||
TEST_F(ValidExportHostPtr, givenPropertiesWithDmaBufWhenValidateInputAndCreateBufferThenCorrectBufferIsSet) {
|
||||
TEST_F(ValidExportHostPtr, givenPropertiesWithDmaBufWhenValidateInputAndCreateBufferThenInvalidPropertyIsSet) {
|
||||
cl_mem_properties properties[] = {CL_EXTERNAL_MEMORY_HANDLE_DMA_BUF_KHR, 0x1234, 0};
|
||||
auto buffer = BufferFunctions::validateInputAndCreateBuffer(context.get(), properties, flags, 0, g_scTestBufferSizeInBytes, nullptr, retVal);
|
||||
EXPECT_EQ(retVal, CL_INVALID_PROPERTY);
|
||||
@ -110,3 +110,29 @@ TEST_F(ValidExportHostPtr, givenPropertiesWithDmaBufWhenValidateInputAndCreateBu
|
||||
|
||||
clReleaseMemObject(buffer);
|
||||
}
|
||||
|
||||
TEST_F(ValidExportHostPtr, givenInvalidPropertiesWithNtHandleWhenValidateInputAndCreateBufferThenCorrectBufferIsSet) {
|
||||
|
||||
osHandle invalidHandle = static_cast<MockMemoryManager *>(pClExecutionEnvironment->memoryManager.get())->invalidSharedHandle;
|
||||
cl_mem_properties properties[] = {CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KHR, invalidHandle, 0};
|
||||
cl_mem buffer = BufferFunctions::validateInputAndCreateBuffer(context.get(), properties, flags, 0, g_scTestBufferSizeInBytes, nullptr, retVal);
|
||||
|
||||
EXPECT_EQ(retVal, CL_INVALID_MEM_OBJECT);
|
||||
EXPECT_EQ(static_cast<MockMemoryManager *>(pClExecutionEnvironment->memoryManager.get())->capturedSharedHandle, properties[1]);
|
||||
EXPECT_EQ(buffer, nullptr);
|
||||
|
||||
clReleaseMemObject(buffer);
|
||||
}
|
||||
|
||||
TEST_F(ValidExportHostPtr, givenPropertiesWithNtHandleWhenValidateInputAndCreateBufferThenCorrectBufferIsSet) {
|
||||
|
||||
cl_mem_properties properties[] = {CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KHR, 0x1234, 0};
|
||||
cl_mem buffer = BufferFunctions::validateInputAndCreateBuffer(context.get(), properties, flags, 0, g_scTestBufferSizeInBytes, nullptr, retVal);
|
||||
|
||||
EXPECT_EQ(retVal, CL_SUCCESS);
|
||||
EXPECT_EQ(static_cast<MockMemoryManager *>(pClExecutionEnvironment->memoryManager.get())->capturedSharedHandle, properties[1]);
|
||||
EXPECT_EQ(static_cast<Buffer *>(buffer)->getGraphicsAllocation(0u)->getAllocationType(), NEO::AllocationType::SHARED_BUFFER);
|
||||
EXPECT_NE(buffer, nullptr);
|
||||
|
||||
clReleaseMemObject(buffer);
|
||||
}
|
||||
|
Reference in New Issue
Block a user