mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Tracking the internal allocation when creating a buffer
This fix prevents the creation of a buffer from the pointer obtained from clEnqueueMapBuffer Change-Id: I203f2d5263eeb02fe0d73bc9db159438af3cf1fc
This commit is contained in:

committed by
sys_ocldev

parent
c46f716d6c
commit
fe56c57318
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Intel Corporation
|
||||
* Copyright (c) 2017 - 2018, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
@ -104,6 +104,28 @@ TEST_F(clEnqueueMapBufferTests, validInputs_returnsSuccess) {
|
||||
clReleaseEvent(eventReturned);
|
||||
}
|
||||
|
||||
TEST_F(clEnqueueMapBufferTests, GivenMappedPointerWhenCreateBufferFormThisPointerThenReturnInvalidHostPointer) {
|
||||
unsigned int bufferSize = 16;
|
||||
|
||||
cl_mem buffer = clCreateBuffer(pContext, CL_MEM_READ_WRITE, bufferSize, nullptr, &retVal);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_NE(nullptr, buffer);
|
||||
|
||||
void *hostPointer = clEnqueueMapBuffer(pCommandQueue, buffer, CL_TRUE, CL_MAP_READ, 0, bufferSize, 0, nullptr, nullptr, &retVal);
|
||||
EXPECT_NE(nullptr, hostPointer);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
retVal = clEnqueueUnmapMemObject(pCommandQueue, buffer, hostPointer, 0, NULL, NULL);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
auto bufferFromHostPtr = clCreateBuffer(pContext, CL_MEM_USE_HOST_PTR, bufferSize, hostPointer, &retVal);
|
||||
EXPECT_EQ(CL_INVALID_HOST_PTR, retVal);
|
||||
EXPECT_EQ(nullptr, bufferFromHostPtr);
|
||||
|
||||
retVal = clReleaseMemObject(buffer);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
}
|
||||
|
||||
class EnqueueMapBufferFlagsTest : public api_fixture,
|
||||
public testing::TestWithParam<uint64_t /*cl_mem_flags*/> {
|
||||
public:
|
||||
|
Reference in New Issue
Block a user