2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2022-02-04 21:59:01 +08:00
|
|
|
* Copyright (C) 2018-2022 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
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/gmm_helper/gmm.h"
|
2021-10-14 23:37:18 +08:00
|
|
|
#include "shared/source/helpers/surface_format_info.h"
|
2020-03-19 21:26:08 +08:00
|
|
|
#include "shared/source/memory_manager/memory_manager.h"
|
2021-01-21 20:10:13 +08:00
|
|
|
#include "shared/test/common/mocks/mock_device.h"
|
2021-10-09 02:32:21 +08:00
|
|
|
#include "shared/test/common/mocks/mock_gmm_resource_info.h"
|
2021-01-21 20:10:13 +08:00
|
|
|
#include "shared/test/common/mocks/mock_graphics_allocation.h"
|
2020-02-24 17:22:30 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2017-12-21 07:45:38 +08:00
|
|
|
namespace MockGmmParams {
|
2021-10-14 23:37:18 +08:00
|
|
|
static SurfaceFormatInfo mockSurfaceFormat = {GMM_FORMAT_R8G8B8A8_UNORM_TYPE, GFX3DSTATE_SURFACEFORMAT::GFX3DSTATE_SURFACEFORMAT_R8G8B8A8_UNORM, 0, 4, 1, 4};
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
class MockGmm : public Gmm {
|
|
|
|
public:
|
2019-07-02 18:50:29 +08:00
|
|
|
using Gmm::Gmm;
|
|
|
|
using Gmm::setupImageResourceParams;
|
|
|
|
|
2022-04-27 18:20:10 +08:00
|
|
|
MockGmm(GmmHelper *gmmHelper) : Gmm(gmmHelper, nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true){};
|
2019-07-02 18:50:29 +08:00
|
|
|
|
2022-04-27 18:20:10 +08:00
|
|
|
static std::unique_ptr<Gmm> queryImgParams(GmmHelper *gmmHelper, ImageInfo &imgInfo, bool preferCompression) {
|
|
|
|
return std::unique_ptr<Gmm>(new Gmm(gmmHelper, imgInfo, {}, preferCompression));
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
2021-10-14 23:37:18 +08:00
|
|
|
static ImageInfo initImgInfo(ImageDescriptor &imgDesc, int baseMipLevel, const SurfaceFormatInfo *surfaceFormat) {
|
2020-01-08 18:11:54 +08:00
|
|
|
ImageInfo imgInfo = {};
|
2018-04-04 15:29:48 +08:00
|
|
|
imgInfo.baseMipLevel = baseMipLevel;
|
2021-10-14 23:37:18 +08:00
|
|
|
imgInfo.imgDesc = imgDesc;
|
2017-12-21 07:45:38 +08:00
|
|
|
if (!surfaceFormat) {
|
2021-10-14 23:37:18 +08:00
|
|
|
imgInfo.surfaceFormat = &MockGmmParams::mockSurfaceFormat;
|
2017-12-21 07:45:38 +08:00
|
|
|
} else {
|
2021-10-14 23:37:18 +08:00
|
|
|
imgInfo.surfaceFormat = surfaceFormat;
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
return imgInfo;
|
|
|
|
}
|
2019-03-06 23:07:28 +08:00
|
|
|
|
|
|
|
static GraphicsAllocation *allocateImage2d(MemoryManager &memoryManager) {
|
2021-10-14 23:37:18 +08:00
|
|
|
ImageDescriptor imgDesc{};
|
|
|
|
imgDesc.imageType = ImageType::Image2D;
|
|
|
|
imgDesc.imageWidth = 5;
|
|
|
|
imgDesc.imageHeight = 5;
|
2019-03-06 23:07:28 +08:00
|
|
|
auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr);
|
2022-02-04 21:59:01 +08:00
|
|
|
return memoryManager.allocateGraphicsMemoryWithProperties({mockRootDeviceIndex, true, imgInfo, AllocationType::IMAGE, mockDeviceBitfield});
|
2019-03-06 23:07:28 +08:00
|
|
|
}
|
2017-12-21 07:45:38 +08:00
|
|
|
};
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|