2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2019-02-27 18:39:32 +08:00
|
|
|
* Copyright (C) 2017-2019 Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
2018-09-18 15:11:08 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
2018-06-21 17:36:47 +08:00
|
|
|
#include "runtime/gmm_helper/gmm.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
#include "runtime/gmm_helper/gmm_helper.h"
|
|
|
|
#include "runtime/helpers/options.h"
|
|
|
|
#include "runtime/helpers/surface_formats.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
#include "unit_tests/mocks/mock_device.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
#include "unit_tests/mocks/mock_gmm_resource_info.h"
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2017-12-21 07:45:38 +08:00
|
|
|
namespace MockGmmParams {
|
|
|
|
static SurfaceFormatInfo mockSurfaceFormat;
|
|
|
|
}
|
|
|
|
|
|
|
|
class MockGmm : public Gmm {
|
|
|
|
public:
|
2018-06-28 19:38:15 +08:00
|
|
|
static std::unique_ptr<Gmm> queryImgParams(ImageInfo &imgInfo) {
|
2018-06-29 17:48:19 +08:00
|
|
|
return std::unique_ptr<Gmm>(new Gmm(imgInfo));
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
2018-04-04 15:29:48 +08:00
|
|
|
static ImageInfo initImgInfo(cl_image_desc &imgDesc, int baseMipLevel, const SurfaceFormatInfo *surfaceFormat) {
|
2017-12-21 07:45:38 +08:00
|
|
|
ImageInfo imgInfo = {0};
|
2018-04-04 15:29:48 +08:00
|
|
|
imgInfo.baseMipLevel = baseMipLevel;
|
2017-12-21 07:45:38 +08:00
|
|
|
imgInfo.imgDesc = &imgDesc;
|
|
|
|
if (!surfaceFormat) {
|
2018-09-11 19:08:29 +08:00
|
|
|
ArrayRef<const SurfaceFormatInfo> readWriteSurfaceFormats = SurfaceFormats::readWrite();
|
2017-12-21 07:45:38 +08:00
|
|
|
MockGmmParams::mockSurfaceFormat = readWriteSurfaceFormats[0]; // any valid format
|
|
|
|
imgInfo.surfaceFormat = &MockGmmParams::mockSurfaceFormat;
|
|
|
|
} else {
|
|
|
|
imgInfo.surfaceFormat = surfaceFormat;
|
|
|
|
}
|
|
|
|
return imgInfo;
|
|
|
|
}
|
2019-03-06 23:07:28 +08:00
|
|
|
|
|
|
|
static GraphicsAllocation *allocateImage2d(MemoryManager &memoryManager) {
|
|
|
|
cl_image_desc imgDesc{};
|
|
|
|
imgDesc.image_type = CL_MEM_OBJECT_IMAGE2D;
|
|
|
|
imgDesc.image_width = 5;
|
|
|
|
imgDesc.image_height = 5;
|
|
|
|
auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr);
|
|
|
|
return memoryManager.allocateGraphicsMemoryWithProperties(AllocationProperties{&imgInfo, true});
|
|
|
|
}
|
2017-12-21 07:45:38 +08:00
|
|
|
};
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|