mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-24 21:18:24 +08:00
Return error when image arg does not support media block commands
Signed-off-by: Maciej Plewka <maciej.plewka@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
eb79500c60
commit
e56d18b69f
@@ -18,6 +18,7 @@
|
||||
#include "shared/source/helpers/ray_tracing_helper.h"
|
||||
#include "shared/source/helpers/register_offsets.h"
|
||||
#include "shared/source/helpers/string.h"
|
||||
#include "shared/source/helpers/supported_media_surface_formats.h"
|
||||
#include "shared/source/helpers/surface_format_info.h"
|
||||
#include "shared/source/kernel/implicit_args.h"
|
||||
#include "shared/source/kernel/kernel_arg_descriptor.h"
|
||||
@@ -635,6 +636,11 @@ ze_result_t KernelImp::setArgImage(uint32_t argIndex, size_t argSize, const void
|
||||
const auto &arg = kernelImmData->getDescriptor().payloadMappings.explicitArgs[argIndex].as<NEO::ArgDescImage>();
|
||||
const auto image = Image::fromHandle(*static_cast<const ze_image_handle_t *>(argVal));
|
||||
|
||||
auto surfFormat = image->getImageInfo().surfaceFormat->GenxSurfaceFormat;
|
||||
if (isMediaBlockImage && !NEO::SupportedMediaFormatsHelper::isMediaFormatSupported(surfFormat)) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_IMAGE_FORMAT;
|
||||
}
|
||||
|
||||
if (kernelImmData->getDescriptor().kernelAttributes.imageAddressingMode == NEO::KernelDescriptor::Bindless) {
|
||||
image->copySurfaceStateToSSH(patchBindlessSurfaceState(image->getAllocation(), arg.bindless), 0u, isMediaBlockImage);
|
||||
} else {
|
||||
|
||||
@@ -117,48 +117,48 @@ TEST_F(SetKernelArgCacheTest, givenValidBufferArgumentWhenSetMultipleTimesThenSe
|
||||
|
||||
size_t callCounter = 0u;
|
||||
|
||||
//first setArg - called
|
||||
// first setArg - called
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, mockKernel.setArgBuffer(0, sizeof(svmAllocation), &svmAllocation));
|
||||
EXPECT_EQ(++callCounter, mockKernel.setArgBufferWithAllocCalled);
|
||||
|
||||
//same setArg but allocationCounter == 0 - called
|
||||
// same setArg but allocationCounter == 0 - called
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, mockKernel.setArgBuffer(0, sizeof(svmAllocation), &svmAllocation));
|
||||
EXPECT_EQ(++callCounter, mockKernel.setArgBufferWithAllocCalled);
|
||||
|
||||
//same setArg - not called and argInfo.allocationCounter is updated
|
||||
// same setArg - not called and argInfo.allocationCounter is updated
|
||||
++svmAllocsManager->allocationsCounter;
|
||||
EXPECT_EQ(0u, mockKernel.kernelArgInfos[0].allocIdMemoryManagerCounter);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, mockKernel.setArgBuffer(0, sizeof(svmAllocation), &svmAllocation));
|
||||
EXPECT_EQ(callCounter, mockKernel.setArgBufferWithAllocCalled);
|
||||
EXPECT_EQ(svmAllocsManager->allocationsCounter, mockKernel.kernelArgInfos[0].allocIdMemoryManagerCounter);
|
||||
|
||||
//same setArg and allocationCounter - not called
|
||||
// same setArg and allocationCounter - not called
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, mockKernel.setArgBuffer(0, sizeof(svmAllocation), &svmAllocation));
|
||||
EXPECT_EQ(callCounter, mockKernel.setArgBufferWithAllocCalled);
|
||||
|
||||
//same setArg but different allocId - called
|
||||
// same setArg but different allocId - called
|
||||
svmAllocsManager->getSVMAlloc(svmAllocation)->setAllocId(1u);
|
||||
++svmAllocsManager->allocationsCounter;
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, mockKernel.setArgBuffer(0, sizeof(svmAllocation), &svmAllocation));
|
||||
EXPECT_EQ(++callCounter, mockKernel.setArgBufferWithAllocCalled);
|
||||
|
||||
//different value - called
|
||||
// different value - called
|
||||
auto secondSvmAllocation = svmAllocsManager->createSVMAlloc(4096, allocationProperties, context->rootDeviceIndices, context->deviceBitfields);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, mockKernel.setArgBuffer(0, sizeof(secondSvmAllocation), &secondSvmAllocation));
|
||||
EXPECT_EQ(++callCounter, mockKernel.setArgBufferWithAllocCalled);
|
||||
|
||||
//nullptr - not called, argInfo is updated
|
||||
// nullptr - not called, argInfo is updated
|
||||
EXPECT_FALSE(mockKernel.kernelArgInfos[0].isSetToNullptr);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, mockKernel.setArgBuffer(0, sizeof(nullptr), nullptr));
|
||||
EXPECT_EQ(callCounter, mockKernel.setArgBufferWithAllocCalled);
|
||||
EXPECT_TRUE(mockKernel.kernelArgInfos[0].isSetToNullptr);
|
||||
|
||||
//nullptr again - not called
|
||||
// nullptr again - not called
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, mockKernel.setArgBuffer(0, sizeof(nullptr), nullptr));
|
||||
EXPECT_EQ(callCounter, mockKernel.setArgBufferWithAllocCalled);
|
||||
EXPECT_TRUE(mockKernel.kernelArgInfos[0].isSetToNullptr);
|
||||
|
||||
//same value as before nullptr - called, argInfo is updated
|
||||
// same value as before nullptr - called, argInfo is updated
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, mockKernel.setArgBuffer(0, sizeof(secondSvmAllocation), &secondSvmAllocation));
|
||||
EXPECT_EQ(++callCounter, mockKernel.setArgBufferWithAllocCalled);
|
||||
EXPECT_FALSE(mockKernel.kernelArgInfos[0].isSetToNullptr);
|
||||
@@ -2207,6 +2207,7 @@ HWTEST2_F(SetKernelArg, givenImageAndBindfulKernelWhenSetArgImageThenCopySurface
|
||||
|
||||
template <GFXCORE_FAMILY gfxCoreFamily>
|
||||
struct MyMockImageMediaBlock : public WhiteBox<::L0::ImageCoreFamily<gfxCoreFamily>> {
|
||||
using WhiteBox<::L0::ImageCoreFamily<gfxCoreFamily>>::imgInfo;
|
||||
void copySurfaceStateToSSH(void *surfaceStateHeap, const uint32_t surfaceStateOffset, bool isMediaBlockArg) override {
|
||||
isMediaBlockPassedValue = isMediaBlockArg;
|
||||
}
|
||||
@@ -2251,6 +2252,44 @@ HWTEST2_F(SetKernelArg, givenSupportsMediaBlockAndIsMediaBlockImageWhenSetArgIma
|
||||
}
|
||||
}
|
||||
|
||||
HWTEST2_F(SetKernelArg, givenSupportsMediaBlockAndIsMediaBlockImagehaveUnsuportedMediaBlockFormatThenSetArgReturnErrCode, ImageSupport) {
|
||||
auto hwInfo = device->getNEODevice()->getRootDeviceEnvironment().getMutableHardwareInfo();
|
||||
createKernel();
|
||||
auto argIndex = 3u;
|
||||
auto &arg = const_cast<NEO::ArgDescriptor &>(kernel->kernelImmData->getDescriptor().payloadMappings.explicitArgs[argIndex]);
|
||||
auto imageHW = std::make_unique<MyMockImageMediaBlock<gfxCoreFamily>>();
|
||||
ze_image_desc_t desc = {};
|
||||
desc.stype = ZE_STRUCTURE_TYPE_IMAGE_DESC;
|
||||
auto ret = imageHW->initialize(device, &desc);
|
||||
ASSERT_EQ(ZE_RESULT_SUCCESS, ret);
|
||||
auto handle = imageHW->toHandle();
|
||||
|
||||
hwInfo->capabilityTable.supportsMediaBlock = true;
|
||||
arg.getExtendedTypeInfo().isMediaBlockImage = true;
|
||||
SurfaceFormatInfo surfInfo = {GMM_FORMAT_R32G32B32A32_FLOAT_TYPE, NEO::GFX3DSTATE_SURFACEFORMAT_R32G32B32A32_FLOAT, 0, 4, 4, 16};
|
||||
imageHW.get()->imgInfo.surfaceFormat = &surfInfo;
|
||||
EXPECT_EQ(kernel->setArgImage(argIndex, sizeof(imageHW.get()), &handle), ZE_RESULT_ERROR_UNSUPPORTED_IMAGE_FORMAT);
|
||||
}
|
||||
|
||||
HWTEST2_F(SetKernelArg, givenSupportsMediaBlockAndIsMediaBlockImagehaveSuportedMediaBlockFormatThenSetArgReturnSuccess, ImageSupport) {
|
||||
auto hwInfo = device->getNEODevice()->getRootDeviceEnvironment().getMutableHardwareInfo();
|
||||
createKernel();
|
||||
auto argIndex = 3u;
|
||||
auto &arg = const_cast<NEO::ArgDescriptor &>(kernel->kernelImmData->getDescriptor().payloadMappings.explicitArgs[argIndex]);
|
||||
auto imageHW = std::make_unique<MyMockImageMediaBlock<gfxCoreFamily>>();
|
||||
ze_image_desc_t desc = {};
|
||||
desc.stype = ZE_STRUCTURE_TYPE_IMAGE_DESC;
|
||||
auto ret = imageHW->initialize(device, &desc);
|
||||
ASSERT_EQ(ZE_RESULT_SUCCESS, ret);
|
||||
auto handle = imageHW->toHandle();
|
||||
|
||||
hwInfo->capabilityTable.supportsMediaBlock = true;
|
||||
arg.getExtendedTypeInfo().isMediaBlockImage = true;
|
||||
SurfaceFormatInfo surfInfo = {GMM_FORMAT_Y216, NEO::GFX3DSTATE_SURFACEFORMAT_R16G16B16A16_UNORM, 0, 4, 2, 8};
|
||||
imageHW.get()->imgInfo.surfaceFormat = &surfInfo;
|
||||
EXPECT_EQ(kernel->setArgImage(argIndex, sizeof(imageHW.get()), &handle), ZE_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
using ImportHostPointerSetKernelArg = Test<ImportHostPointerModuleFixture>;
|
||||
TEST_F(ImportHostPointerSetKernelArg, givenHostPointerImportedWhenSettingKernelArgThenUseHostPointerAllocation) {
|
||||
createKernel();
|
||||
|
||||
Reference in New Issue
Block a user