2017-12-21 00:45:38 +01:00
|
|
|
/*
|
2022-06-14 18:00:02 +00:00
|
|
|
* Copyright (C) 2018-2022 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
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/execution_environment/execution_environment.h"
|
|
|
|
#include "shared/source/helpers/hw_info.h"
|
2021-01-21 13:10:13 +01:00
|
|
|
#include "shared/test/common/helpers/default_hw_info.h"
|
2022-06-29 19:17:47 +00:00
|
|
|
#include "shared/test/common/test_macros/hw_test.h"
|
2020-02-24 10:22:30 +01:00
|
|
|
|
2021-10-06 17:00:24 +00:00
|
|
|
#include "opencl/source/helpers/cl_memory_properties_helpers.h"
|
2020-02-22 22:50:57 +01:00
|
|
|
#include "opencl/source/mem_obj/image.h"
|
|
|
|
#include "opencl/source/platform/platform.h"
|
2020-05-28 14:05:12 +02:00
|
|
|
#include "opencl/test/unit_test/fixtures/cl_device_fixture.h"
|
2020-02-23 15:20:22 +01:00
|
|
|
#include "opencl/test/unit_test/mocks/mock_context.h"
|
2020-03-17 14:25:44 +01:00
|
|
|
#include "opencl/test/unit_test/mocks/mock_platform.h"
|
2019-02-27 11:39:32 +01:00
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
#include "CL/cl.h"
|
2019-02-27 11:39:32 +01:00
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
#include <cassert>
|
|
|
|
#include <cstdio>
|
|
|
|
|
|
|
|
struct Image1dDefaults {
|
|
|
|
enum { flags = 0 };
|
|
|
|
static const cl_image_format imageFormat;
|
|
|
|
static const cl_image_desc imageDesc;
|
|
|
|
static void *hostPtr;
|
2019-03-26 11:59:46 +01:00
|
|
|
static NEO::Context *context;
|
2017-12-21 00:45:38 +01:00
|
|
|
};
|
|
|
|
|
2020-11-25 16:54:47 +00:00
|
|
|
struct Image1dBufferDefaults : public Image1dDefaults {
|
|
|
|
static const cl_image_desc imageDesc;
|
|
|
|
};
|
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
struct Image2dDefaults : public Image1dDefaults {
|
|
|
|
static const cl_image_desc imageDesc;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Image3dDefaults : public Image2dDefaults {
|
|
|
|
static const cl_image_desc imageDesc;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Image2dArrayDefaults : public Image2dDefaults {
|
|
|
|
static const cl_image_desc imageDesc;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Image1dArrayDefaults : public Image2dDefaults {
|
|
|
|
static const cl_image_desc imageDesc;
|
|
|
|
};
|
|
|
|
|
2021-03-29 16:39:45 +00:00
|
|
|
struct ImageWithoutHostPtr : public Image1dDefaults {
|
|
|
|
enum { flags = 0 };
|
|
|
|
static void *hostPtr;
|
|
|
|
};
|
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
template <typename BaseClass>
|
|
|
|
struct ImageUseHostPtr : public BaseClass {
|
|
|
|
enum { flags = BaseClass::flags | CL_MEM_USE_HOST_PTR };
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename BaseClass>
|
|
|
|
struct ImageReadOnly : public BaseClass {
|
|
|
|
enum { flags = BaseClass::flags | CL_MEM_READ_ONLY };
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename BaseClass>
|
|
|
|
struct ImageWriteOnly : public BaseClass {
|
|
|
|
enum { flags = BaseClass::flags | CL_MEM_WRITE_ONLY };
|
|
|
|
};
|
|
|
|
|
2022-06-14 18:00:02 +00:00
|
|
|
struct LuminanceImage : public ImageReadOnly<Image2dDefaults> {
|
|
|
|
static const cl_image_format imageFormat;
|
|
|
|
};
|
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
template <typename Traits>
|
|
|
|
struct ImageHelper {
|
2019-03-26 11:59:46 +01:00
|
|
|
using Context = NEO::Context;
|
|
|
|
using Image = NEO::Image;
|
|
|
|
using MockContext = NEO::MockContext;
|
2017-12-21 00:45:38 +01:00
|
|
|
|
|
|
|
static Image *create(Context *context = Traits::context, const cl_image_desc *imgDesc = &Traits::imageDesc,
|
|
|
|
const cl_image_format *imgFormat = &Traits::imageFormat) {
|
|
|
|
auto retVal = CL_INVALID_VALUE;
|
2020-04-30 15:47:43 +02:00
|
|
|
auto surfaceFormat = Image::getSurfaceFormatFromTable(Traits::flags, imgFormat, context->getDevice(0)->getHardwareInfo().capabilityTable.supportsOcl21Features);
|
2017-12-21 00:45:38 +01:00
|
|
|
auto image = Image::create(
|
|
|
|
context,
|
2021-10-06 17:00:24 +00:00
|
|
|
NEO::ClMemoryPropertiesHelper::createMemoryProperties(Traits::flags, 0, 0, &context->getDevice(0)->getDevice()),
|
2017-12-21 00:45:38 +01:00
|
|
|
Traits::flags,
|
2019-10-17 14:18:55 +02:00
|
|
|
0,
|
2017-12-21 00:45:38 +01:00
|
|
|
surfaceFormat,
|
|
|
|
imgDesc,
|
|
|
|
Traits::hostPtr,
|
|
|
|
retVal);
|
|
|
|
|
|
|
|
return image;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename Traits = Image1dDefaults>
|
|
|
|
struct Image1dHelper : public ImageHelper<Traits> {
|
|
|
|
};
|
|
|
|
|
2020-11-25 16:54:47 +00:00
|
|
|
template <typename Traits = Image1dBufferDefaults>
|
|
|
|
struct Image1dBufferHelper : public ImageHelper<Traits> {
|
|
|
|
};
|
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
template <typename Traits = Image2dDefaults>
|
|
|
|
struct Image2dHelper : public ImageHelper<Traits> {
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename Traits = Image3dDefaults>
|
|
|
|
struct Image3dHelper : public ImageHelper<Traits> {
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename Traits = Image2dArrayDefaults>
|
|
|
|
struct Image2dArrayHelper : public ImageHelper<Traits> {
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename Traits = Image1dArrayDefaults>
|
|
|
|
struct Image1dArrayHelper : public ImageHelper<Traits> {
|
|
|
|
};
|
2018-07-19 17:55:31 +02:00
|
|
|
|
2019-07-17 11:48:05 +02:00
|
|
|
struct ImageClearColorFixture : ::testing::Test {
|
2019-03-26 11:59:46 +01:00
|
|
|
using MockContext = NEO::MockContext;
|
|
|
|
using Image = NEO::Image;
|
2018-07-19 17:55:31 +02:00
|
|
|
|
2019-07-17 11:48:05 +02:00
|
|
|
template <typename FamilyType>
|
|
|
|
void setUpImpl() {
|
2019-05-08 17:16:25 +02:00
|
|
|
hardwareInfo.capabilityTable.ftrRenderCompressedImages = true;
|
2018-07-27 13:59:39 +02:00
|
|
|
|
2020-09-01 12:38:50 +02:00
|
|
|
NEO::platformsImpl->clear();
|
2020-03-04 08:51:02 +01:00
|
|
|
NEO::constructPlatform()->peekExecutionEnvironment()->prepareRootDeviceEnvironments(1u);
|
|
|
|
NEO::platform()->peekExecutionEnvironment()->rootDeviceEnvironments[0]->setHwInfo(&hardwareInfo);
|
2020-02-25 16:38:47 +01:00
|
|
|
NEO::platform()->peekExecutionEnvironment()->rootDeviceEnvironments[0]->initGmm();
|
2018-07-19 17:55:31 +02:00
|
|
|
}
|
|
|
|
|
2019-07-17 11:48:05 +02:00
|
|
|
template <typename FamilyType>
|
|
|
|
typename FamilyType::RENDER_SURFACE_STATE getSurfaceState() {
|
|
|
|
using AUXILIARY_SURFACE_MODE = typename FamilyType::RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE;
|
|
|
|
auto surfaceState = FamilyType::cmdInitRenderSurfaceState;
|
|
|
|
surfaceState.setAuxiliarySurfaceMode(AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_CCS_E);
|
|
|
|
return surfaceState;
|
2018-07-19 17:55:31 +02:00
|
|
|
}
|
|
|
|
|
2020-03-24 17:04:08 +01:00
|
|
|
NEO::HardwareInfo hardwareInfo = *NEO::defaultHwInfo;
|
2018-07-19 17:55:31 +02:00
|
|
|
MockContext context;
|
|
|
|
std::unique_ptr<Image> image;
|
|
|
|
};
|