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