Add method checkResourceCompatibility
Change-Id: I858f54cbeac86121882ca0dec1a5f35eca034dbd Signed-off-by: Kamil Diedrich <kamil.diedrich@intel.com>
This commit is contained in:
parent
a025dc6985
commit
0ff6358c17
|
@ -10,6 +10,7 @@
|
||||||
#include "runtime/command_stream/linear_stream.h"
|
#include "runtime/command_stream/linear_stream.h"
|
||||||
#include "runtime/gen_common/aub_mapper.h"
|
#include "runtime/gen_common/aub_mapper.h"
|
||||||
#include "runtime/gen_common/hw_cmds.h"
|
#include "runtime/gen_common/hw_cmds.h"
|
||||||
|
#include "runtime/mem_obj/buffer.h"
|
||||||
|
|
||||||
#include "CL/cl.h"
|
#include "CL/cl.h"
|
||||||
|
|
||||||
|
@ -42,6 +43,7 @@ class HwHelper {
|
||||||
virtual const AubMemDump::LrcaHelper &getCsTraits(aub_stream::EngineType engineType) const = 0;
|
virtual const AubMemDump::LrcaHelper &getCsTraits(aub_stream::EngineType engineType) const = 0;
|
||||||
virtual bool supportsYTiling() const = 0;
|
virtual bool supportsYTiling() const = 0;
|
||||||
virtual bool obtainRenderBufferCompressionPreference(const HardwareInfo &hwInfo) const = 0;
|
virtual bool obtainRenderBufferCompressionPreference(const HardwareInfo &hwInfo) const = 0;
|
||||||
|
virtual void checkResourceCompatibility(Buffer *buffer, cl_int &errorCode) = 0;
|
||||||
static bool renderCompressedBuffersSupported(const HardwareInfo &hwInfo);
|
static bool renderCompressedBuffersSupported(const HardwareInfo &hwInfo);
|
||||||
static bool renderCompressedImagesSupported(const HardwareInfo &hwInfo);
|
static bool renderCompressedImagesSupported(const HardwareInfo &hwInfo);
|
||||||
static bool cacheFlushAfterWalkerSupported(const HardwareInfo &hwInfo);
|
static bool cacheFlushAfterWalkerSupported(const HardwareInfo &hwInfo);
|
||||||
|
@ -127,6 +129,8 @@ class HwHelperHw : public HwHelper {
|
||||||
|
|
||||||
bool obtainRenderBufferCompressionPreference(const HardwareInfo &hwInfo) const override;
|
bool obtainRenderBufferCompressionPreference(const HardwareInfo &hwInfo) const override;
|
||||||
|
|
||||||
|
void checkResourceCompatibility(Buffer *buffer, cl_int &errorCode) override;
|
||||||
|
|
||||||
bool timestampPacketWriteSupported() const override;
|
bool timestampPacketWriteSupported() const override;
|
||||||
|
|
||||||
bool isPageTableManagerSupported(const HardwareInfo &hwInfo) const override;
|
bool isPageTableManagerSupported(const HardwareInfo &hwInfo) const override;
|
||||||
|
|
|
@ -97,6 +97,10 @@ bool HwHelperHw<Family>::timestampPacketWriteSupported() const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename GfxFamily>
|
||||||
|
inline void HwHelperHw<GfxFamily>::checkResourceCompatibility(Buffer *buffer, cl_int &errorCode) {
|
||||||
|
}
|
||||||
|
|
||||||
template <typename Family>
|
template <typename Family>
|
||||||
void HwHelperHw<Family>::setRenderSurfaceStateForBuffer(ExecutionEnvironment &executionEnvironment,
|
void HwHelperHw<Family>::setRenderSurfaceStateForBuffer(ExecutionEnvironment &executionEnvironment,
|
||||||
void *surfaceStateBuffer,
|
void *surfaceStateBuffer,
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "runtime/helpers/aligned_memory.h"
|
#include "runtime/helpers/aligned_memory.h"
|
||||||
#include "runtime/helpers/basic_math.h"
|
#include "runtime/helpers/basic_math.h"
|
||||||
#include "runtime/helpers/get_info.h"
|
#include "runtime/helpers/get_info.h"
|
||||||
|
#include "runtime/helpers/hw_helper.h"
|
||||||
#include "runtime/helpers/hw_info.h"
|
#include "runtime/helpers/hw_info.h"
|
||||||
#include "runtime/helpers/mipmap.h"
|
#include "runtime/helpers/mipmap.h"
|
||||||
#include "runtime/helpers/ptr_math.h"
|
#include "runtime/helpers/ptr_math.h"
|
||||||
|
@ -186,6 +187,13 @@ Image *Image::create(Context *context,
|
||||||
bool zeroCopy = false;
|
bool zeroCopy = false;
|
||||||
bool transferNeeded = false;
|
bool transferNeeded = false;
|
||||||
if (((imageDesc->image_type == CL_MEM_OBJECT_IMAGE1D_BUFFER) || (imageDesc->image_type == CL_MEM_OBJECT_IMAGE2D)) && (parentBuffer != nullptr)) {
|
if (((imageDesc->image_type == CL_MEM_OBJECT_IMAGE1D_BUFFER) || (imageDesc->image_type == CL_MEM_OBJECT_IMAGE2D)) && (parentBuffer != nullptr)) {
|
||||||
|
|
||||||
|
HwHelper::get(context->getDevice(0)->getHardwareInfo().pPlatform->eRenderCoreFamily).checkResourceCompatibility(parentBuffer, errcodeRet);
|
||||||
|
|
||||||
|
if (errcodeRet != CL_SUCCESS) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
memory = parentBuffer->getGraphicsAllocation();
|
memory = parentBuffer->getGraphicsAllocation();
|
||||||
// Image from buffer - we never allocate memory, we use what buffer provides
|
// Image from buffer - we never allocate memory, we use what buffer provides
|
||||||
zeroCopy = true;
|
zeroCopy = true;
|
||||||
|
|
|
@ -41,6 +41,7 @@ set(IGDRCL_SRCS_tests_helpers
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/mipmap_tests.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/mipmap_tests.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/per_thread_data_tests.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/per_thread_data_tests.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/ptr_math_tests.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/ptr_math_tests.cpp
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/raii_hw_helper.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/queue_helpers_tests.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/queue_helpers_tests.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/sampler_helpers_tests.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/sampler_helpers_tests.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/string_to_hash_tests.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/string_to_hash_tests.cpp
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2019 Intel Corporation
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: MIT
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "runtime/helpers/hw_helper.h"
|
||||||
|
|
||||||
|
namespace NEO {
|
||||||
|
extern HwHelper *hwHelperFactory[IGFX_MAX_CORE];
|
||||||
|
|
||||||
|
template <class MockHelper>
|
||||||
|
class RAIIHwHelperFactory {
|
||||||
|
public:
|
||||||
|
GFXCORE_FAMILY gfxCoreFamily;
|
||||||
|
HwHelper *hwHelper;
|
||||||
|
MockHelper mockHwHelper;
|
||||||
|
|
||||||
|
RAIIHwHelperFactory(GFXCORE_FAMILY gfxCoreFamily) {
|
||||||
|
this->gfxCoreFamily = gfxCoreFamily;
|
||||||
|
hwHelper = hwHelperFactory[this->gfxCoreFamily];
|
||||||
|
hwHelperFactory[this->gfxCoreFamily] = &mockHwHelper;
|
||||||
|
}
|
||||||
|
|
||||||
|
~RAIIHwHelperFactory() {
|
||||||
|
hwHelperFactory[this->gfxCoreFamily] = hwHelper;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // namespace NEO
|
|
@ -511,7 +511,7 @@ TEST_F(RenderCompressedBuffersTests, givenBufferNotCompressedAllocationAndNoHost
|
||||||
EXPECT_EQ(buffer->getGraphicsAllocation()->getAllocationType(), GraphicsAllocation::AllocationType::BUFFER_COMPRESSED);
|
EXPECT_EQ(buffer->getGraphicsAllocation()->getAllocationType(), GraphicsAllocation::AllocationType::BUFFER_COMPRESSED);
|
||||||
} else {
|
} else {
|
||||||
EXPECT_TRUE(buffer->isMemObjZeroCopy());
|
EXPECT_TRUE(buffer->isMemObjZeroCopy());
|
||||||
EXPECT_EQ(buffer->getGraphicsAllocation()->getAllocationType(), GraphicsAllocation::AllocationType::BUFFER);
|
EXPECT_EQ(buffer->getGraphicsAllocation()->getAllocationType(), GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,15 +6,21 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "runtime/helpers/aligned_memory.h"
|
#include "runtime/helpers/aligned_memory.h"
|
||||||
|
#include "runtime/helpers/hw_helper.h"
|
||||||
#include "runtime/mem_obj/buffer.h"
|
#include "runtime/mem_obj/buffer.h"
|
||||||
#include "runtime/mem_obj/image.h"
|
#include "runtime/mem_obj/image.h"
|
||||||
#include "test.h"
|
#include "test.h"
|
||||||
#include "unit_tests/fixtures/device_fixture.h"
|
#include "unit_tests/fixtures/device_fixture.h"
|
||||||
|
#include "unit_tests/helpers/raii_hw_helper.h"
|
||||||
#include "unit_tests/mocks/mock_context.h"
|
#include "unit_tests/mocks/mock_context.h"
|
||||||
#include "unit_tests/mocks/mock_gmm.h"
|
#include "unit_tests/mocks/mock_gmm.h"
|
||||||
|
|
||||||
using namespace NEO;
|
using namespace NEO;
|
||||||
|
|
||||||
|
namespace NEO {
|
||||||
|
extern HwHelper *hwHelperFactory[IGFX_MAX_CORE];
|
||||||
|
}
|
||||||
|
|
||||||
// Tests for cl_khr_image2d_from_buffer
|
// Tests for cl_khr_image2d_from_buffer
|
||||||
class Image2dFromBufferTest : public DeviceFixture, public ::testing::Test {
|
class Image2dFromBufferTest : public DeviceFixture, public ::testing::Test {
|
||||||
public:
|
public:
|
||||||
|
@ -391,3 +397,28 @@ TEST_F(Image2dFromBufferTest, givenBufferWhenImageFromBufferThenIsImageFromBuffe
|
||||||
buffer->release();
|
buffer->release();
|
||||||
imageDesc.mem_object = memObj;
|
imageDesc.mem_object = memObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HWTEST_F(Image2dFromBufferTest, givenBufferWhenImageFromBufferThenIsImageFromBufferSetAndAllocationTypeIsBufferNullptr) {
|
||||||
|
class MockHwHelperHw : public HwHelperHw<FamilyType> {
|
||||||
|
public:
|
||||||
|
void checkResourceCompatibility(Buffer *buffer, cl_int &errorCode) override {
|
||||||
|
errorCode = CL_INVALID_MEM_OBJECT;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
auto raiiFactory = RAIIHwHelperFactory<MockHwHelperHw>(context.getDevice(0)->getHardwareInfo().pPlatform->eRenderCoreFamily);
|
||||||
|
|
||||||
|
cl_int errCode = CL_SUCCESS;
|
||||||
|
auto buffer = Buffer::create(&context, 0, 1, nullptr, errCode);
|
||||||
|
imageDesc.image_type = CL_MEM_OBJECT_IMAGE2D;
|
||||||
|
auto memObj = imageDesc.mem_object;
|
||||||
|
imageDesc.mem_object = buffer;
|
||||||
|
|
||||||
|
Image *imageFromBuffer = createImage();
|
||||||
|
EXPECT_EQ(CL_INVALID_MEM_OBJECT, retVal);
|
||||||
|
|
||||||
|
EXPECT_EQ(imageFromBuffer, nullptr);
|
||||||
|
|
||||||
|
buffer->release();
|
||||||
|
imageDesc.mem_object = memObj;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue