mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-08 14:02:58 +08:00
Add method checkResourceCompatibility
Change-Id: I858f54cbeac86121882ca0dec1a5f35eca034dbd Signed-off-by: Kamil Diedrich <kamil.diedrich@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
a025dc6985
commit
0ff6358c17
@@ -511,7 +511,7 @@ TEST_F(RenderCompressedBuffersTests, givenBufferNotCompressedAllocationAndNoHost
|
||||
EXPECT_EQ(buffer->getGraphicsAllocation()->getAllocationType(), GraphicsAllocation::AllocationType::BUFFER_COMPRESSED);
|
||||
} else {
|
||||
EXPECT_TRUE(buffer->isMemObjZeroCopy());
|
||||
EXPECT_EQ(buffer->getGraphicsAllocation()->getAllocationType(), GraphicsAllocation::AllocationType::BUFFER);
|
||||
EXPECT_EQ(buffer->getGraphicsAllocation()->getAllocationType(), GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,15 +6,21 @@
|
||||
*/
|
||||
|
||||
#include "runtime/helpers/aligned_memory.h"
|
||||
#include "runtime/helpers/hw_helper.h"
|
||||
#include "runtime/mem_obj/buffer.h"
|
||||
#include "runtime/mem_obj/image.h"
|
||||
#include "test.h"
|
||||
#include "unit_tests/fixtures/device_fixture.h"
|
||||
#include "unit_tests/helpers/raii_hw_helper.h"
|
||||
#include "unit_tests/mocks/mock_context.h"
|
||||
#include "unit_tests/mocks/mock_gmm.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
namespace NEO {
|
||||
extern HwHelper *hwHelperFactory[IGFX_MAX_CORE];
|
||||
}
|
||||
|
||||
// Tests for cl_khr_image2d_from_buffer
|
||||
class Image2dFromBufferTest : public DeviceFixture, public ::testing::Test {
|
||||
public:
|
||||
@@ -391,3 +397,28 @@ TEST_F(Image2dFromBufferTest, givenBufferWhenImageFromBufferThenIsImageFromBuffe
|
||||
buffer->release();
|
||||
imageDesc.mem_object = memObj;
|
||||
}
|
||||
|
||||
HWTEST_F(Image2dFromBufferTest, givenBufferWhenImageFromBufferThenIsImageFromBufferSetAndAllocationTypeIsBufferNullptr) {
|
||||
class MockHwHelperHw : public HwHelperHw<FamilyType> {
|
||||
public:
|
||||
void checkResourceCompatibility(Buffer *buffer, cl_int &errorCode) override {
|
||||
errorCode = CL_INVALID_MEM_OBJECT;
|
||||
}
|
||||
};
|
||||
|
||||
auto raiiFactory = RAIIHwHelperFactory<MockHwHelperHw>(context.getDevice(0)->getHardwareInfo().pPlatform->eRenderCoreFamily);
|
||||
|
||||
cl_int errCode = CL_SUCCESS;
|
||||
auto buffer = Buffer::create(&context, 0, 1, nullptr, errCode);
|
||||
imageDesc.image_type = CL_MEM_OBJECT_IMAGE2D;
|
||||
auto memObj = imageDesc.mem_object;
|
||||
imageDesc.mem_object = buffer;
|
||||
|
||||
Image *imageFromBuffer = createImage();
|
||||
EXPECT_EQ(CL_INVALID_MEM_OBJECT, retVal);
|
||||
|
||||
EXPECT_EQ(imageFromBuffer, nullptr);
|
||||
|
||||
buffer->release();
|
||||
imageDesc.mem_object = memObj;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user