2019-03-12 21:19:01 +08:00
|
|
|
/*
|
2022-05-16 22:06:56 +08:00
|
|
|
* Copyright (C) 2019-2022 Intel Corporation
|
2019-03-12 21:19:01 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2022-06-07 17:30:54 +08:00
|
|
|
#pragma once
|
|
|
|
|
2021-01-21 20:10:13 +08:00
|
|
|
#include "shared/test/common/mocks/mock_device.h"
|
2021-10-05 20:54:33 +08:00
|
|
|
#include "shared/test/common/mocks/mock_memory_manager.h"
|
2022-06-30 03:17:47 +08:00
|
|
|
#include "shared/test/common/test_macros/hw_test.h"
|
2022-08-11 23:58:56 +08:00
|
|
|
#include "shared/test/common/utilities/base_object_utils.h"
|
2020-02-24 17:22:30 +08:00
|
|
|
|
2020-02-23 05:50:57 +08:00
|
|
|
#include "opencl/source/helpers/surface_formats.h"
|
2020-03-18 20:08:45 +08:00
|
|
|
#include "opencl/test/unit_test/mocks/mock_cl_device.h"
|
2020-02-23 22:20:22 +08:00
|
|
|
#include "opencl/test/unit_test/mocks/mock_context.h"
|
2019-03-12 21:19:01 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
using namespace NEO;
|
2019-03-12 21:19:01 +08:00
|
|
|
|
|
|
|
class ImageCompressionTests : public ::testing::Test {
|
|
|
|
public:
|
|
|
|
class MyMemoryManager : public MockMemoryManager {
|
|
|
|
public:
|
|
|
|
using MockMemoryManager::MockMemoryManager;
|
|
|
|
GraphicsAllocation *allocateGraphicsMemoryForImage(const AllocationData &allocationData) override {
|
|
|
|
mockMethodCalled = true;
|
2021-12-03 21:52:16 +08:00
|
|
|
capturedPreferCompressed = allocationData.flags.preferCompressed;
|
2019-03-12 21:19:01 +08:00
|
|
|
return OsAgnosticMemoryManager::allocateGraphicsMemoryForImage(allocationData);
|
|
|
|
}
|
|
|
|
bool mockMethodCalled = false;
|
2021-12-02 20:21:33 +08:00
|
|
|
bool capturedPreferCompressed = false;
|
2019-03-12 21:19:01 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
void SetUp() override {
|
2021-03-19 17:44:36 +08:00
|
|
|
mockExecutionEnvironment = new MockExecutionEnvironment();
|
|
|
|
myMemoryManager = new MyMemoryManager(*mockExecutionEnvironment);
|
|
|
|
mockExecutionEnvironment->memoryManager.reset(myMemoryManager);
|
|
|
|
|
|
|
|
mockDevice = std::make_unique<MockClDevice>(MockDevice::createWithExecutionEnvironment<MockDevice>(nullptr, mockExecutionEnvironment, 0u));
|
2022-05-16 22:06:56 +08:00
|
|
|
mockContext = makeReleaseable<MockContext>(mockDevice.get());
|
2019-03-12 21:19:01 +08:00
|
|
|
}
|
|
|
|
|
2021-03-19 17:44:36 +08:00
|
|
|
MockExecutionEnvironment *mockExecutionEnvironment;
|
2020-01-14 21:32:11 +08:00
|
|
|
std::unique_ptr<MockClDevice> mockDevice;
|
2019-03-12 21:19:01 +08:00
|
|
|
ReleaseableObjectPtr<MockContext> mockContext;
|
|
|
|
MyMemoryManager *myMemoryManager = nullptr;
|
|
|
|
|
|
|
|
cl_image_desc imageDesc = {};
|
2020-02-10 22:05:12 +08:00
|
|
|
cl_image_format imageFormat{CL_R, CL_UNSIGNED_INT8};
|
2019-03-12 21:19:01 +08:00
|
|
|
cl_mem_flags flags = CL_MEM_READ_WRITE;
|
|
|
|
cl_int retVal = CL_SUCCESS;
|
|
|
|
};
|