mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-08 05:56:36 +08:00
Fix checks for image mip level in OpenCL builtins
Signed-off-by: Maciej Dziuban <maciej.dziuban@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
4168ee8120
commit
edf339fdf1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2020 Intel Corporation
|
||||
* Copyright (C) 2017-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -55,7 +55,7 @@ cl_int CommandQueueHw<GfxFamily>::enqueueCopyBufferToImage(
|
||||
dc.srcOffset = {srcOffset, 0, 0};
|
||||
dc.dstOffset = dstOrigin;
|
||||
dc.size = region;
|
||||
if (dstImage->getImageDesc().num_mip_levels > 0) {
|
||||
if (isMipMapped(dstImage->getImageDesc())) {
|
||||
dc.dstMipLevel = findMipLevel(dstImage->getImageDesc().image_type, dstOrigin);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2020 Intel Corporation
|
||||
* Copyright (C) 2017-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -51,10 +51,10 @@ cl_int CommandQueueHw<GfxFamily>::enqueueCopyImage(
|
||||
dc.srcOffset = srcOrigin;
|
||||
dc.dstOffset = dstOrigin;
|
||||
dc.size = region;
|
||||
if (srcImage->getImageDesc().num_mip_levels > 0) {
|
||||
if (isMipMapped(srcImage->getImageDesc())) {
|
||||
dc.srcMipLevel = findMipLevel(srcImage->getImageDesc().image_type, srcOrigin);
|
||||
}
|
||||
if (dstImage->getImageDesc().num_mip_levels > 0) {
|
||||
if (isMipMapped(dstImage->getImageDesc())) {
|
||||
dc.dstMipLevel = findMipLevel(dstImage->getImageDesc().image_type, dstOrigin);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2020 Intel Corporation
|
||||
* Copyright (C) 2017-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -54,7 +54,7 @@ cl_int CommandQueueHw<GfxFamily>::enqueueCopyImageToBuffer(
|
||||
dc.srcOffset = srcOrigin;
|
||||
dc.dstOffset = {dstOffset, 0, 0};
|
||||
dc.size = region;
|
||||
if (srcImage->getImageDesc().num_mip_levels > 0) {
|
||||
if (isMipMapped(srcImage->getImageDesc())) {
|
||||
dc.srcMipLevel = findMipLevel(srcImage->getImageDesc().image_type, srcOrigin);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2020 Intel Corporation
|
||||
* Copyright (C) 2017-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -101,7 +101,7 @@ cl_int CommandQueueHw<GfxFamily>::enqueueReadImage(
|
||||
dc.size = region;
|
||||
dc.srcRowPitch = (srcImage->getImageDesc().image_type == CL_MEM_OBJECT_IMAGE1D_ARRAY) ? inputSlicePitch : inputRowPitch;
|
||||
dc.srcSlicePitch = inputSlicePitch;
|
||||
if (srcImage->getImageDesc().num_mip_levels > 0) {
|
||||
if (isMipMapped(srcImage->getImageDesc())) {
|
||||
dc.srcMipLevel = findMipLevel(srcImage->getImageDesc().image_type, origin);
|
||||
}
|
||||
dc.transferAllocation = mapAllocation ? mapAllocation : hostPtrSurf.getAllocation();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2020 Intel Corporation
|
||||
* Copyright (C) 2017-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -90,7 +90,7 @@ cl_int CommandQueueHw<GfxFamily>::enqueueWriteImage(
|
||||
dc.size = region;
|
||||
dc.dstRowPitch = ((dstImage->getImageDesc().image_type == CL_MEM_OBJECT_IMAGE1D_ARRAY) && (inputSlicePitch > inputRowPitch)) ? inputSlicePitch : inputRowPitch;
|
||||
dc.dstSlicePitch = inputSlicePitch;
|
||||
if (dstImage->getImageDesc().num_mip_levels > 0) {
|
||||
if (isMipMapped(dstImage->getImageDesc())) {
|
||||
dc.dstMipLevel = findMipLevel(dstImage->getImageDesc().image_type, origin);
|
||||
}
|
||||
dc.transferAllocation = mapAllocation ? mapAllocation : hostPtrSurf.getAllocation();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2020 Intel Corporation
|
||||
* Copyright (C) 2017-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "opencl/source/built_ins/builtins_dispatch_builder.h"
|
||||
#include "opencl/test/unit_test/command_queue/enqueue_copy_buffer_to_image_fixture.h"
|
||||
#include "opencl/test/unit_test/fixtures/one_mip_level_image_fixture.h"
|
||||
#include "opencl/test/unit_test/gen_common/gen_commands_common_validation.h"
|
||||
#include "opencl/test/unit_test/helpers/unit_test_helper.h"
|
||||
#include "opencl/test/unit_test/libult/ult_command_stream_receiver.h"
|
||||
@@ -336,3 +337,23 @@ HWTEST_F(EnqueueCopyBufferToImageStatefulTest, givenBigBufferWhenCopyingBufferTo
|
||||
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
}
|
||||
|
||||
using OneMipLevelCopyBufferToImageImageTests = Test<OneMipLevelImageFixture>;
|
||||
|
||||
HWTEST_F(OneMipLevelCopyBufferToImageImageTests, GivenNotMippedImageWhenCopyingBufferToImageThenDoNotProgramDestinationMipLevel) {
|
||||
auto srcBuffer = std::unique_ptr<Buffer>(createBuffer());
|
||||
auto queue = createQueue<FamilyType>();
|
||||
auto retVal = queue->enqueueCopyBufferToImage(
|
||||
srcBuffer.get(),
|
||||
image.get(),
|
||||
0u,
|
||||
origin,
|
||||
region,
|
||||
0,
|
||||
nullptr,
|
||||
nullptr);
|
||||
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_TRUE(builtinOpsParamsCaptured);
|
||||
EXPECT_EQ(0u, usedBuiltinOpsParams.dstMipLevel);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2020 Intel Corporation
|
||||
* Copyright (C) 2017-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "opencl/source/built_ins/builtins_dispatch_builder.h"
|
||||
#include "opencl/test/unit_test/command_queue/enqueue_copy_image_fixture.h"
|
||||
#include "opencl/test/unit_test/fixtures/one_mip_level_image_fixture.h"
|
||||
#include "opencl/test/unit_test/gen_common/gen_commands_common_validation.h"
|
||||
#include "opencl/test/unit_test/helpers/unit_test_helper.h"
|
||||
#include "opencl/test/unit_test/libult/ult_command_stream_receiver.h"
|
||||
@@ -325,3 +326,24 @@ INSTANTIATE_TEST_CASE_P(MipMapCopyImageTest_GivenImagesWithNonZeroMipLevelsWhenC
|
||||
::testing::Combine(
|
||||
::testing::ValuesIn(types),
|
||||
::testing::ValuesIn(types)));
|
||||
|
||||
using OneMipLevelCopyImageImageTests = Test<OneMipLevelImageFixture>;
|
||||
|
||||
HWTEST_F(OneMipLevelCopyImageImageTests, GivenNotMippedImageWhenCopyingImageThenDoNotProgramSourceAndDestinationMipLevels) {
|
||||
auto dstImage = std::unique_ptr<Image>(createImage());
|
||||
auto queue = createQueue<FamilyType>();
|
||||
auto retVal = queue->enqueueCopyImage(
|
||||
image.get(),
|
||||
dstImage.get(),
|
||||
origin,
|
||||
origin,
|
||||
region,
|
||||
0,
|
||||
nullptr,
|
||||
nullptr);
|
||||
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_TRUE(builtinOpsParamsCaptured);
|
||||
EXPECT_EQ(0u, usedBuiltinOpsParams.srcMipLevel);
|
||||
EXPECT_EQ(0u, usedBuiltinOpsParams.dstMipLevel);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2020 Intel Corporation
|
||||
* Copyright (C) 2017-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "opencl/source/built_ins/builtins_dispatch_builder.h"
|
||||
#include "opencl/test/unit_test/command_queue/enqueue_copy_image_to_buffer_fixture.h"
|
||||
#include "opencl/test/unit_test/fixtures/one_mip_level_image_fixture.h"
|
||||
#include "opencl/test/unit_test/gen_common/gen_commands_common_validation.h"
|
||||
#include "opencl/test/unit_test/helpers/unit_test_helper.h"
|
||||
#include "opencl/test/unit_test/libult/ult_command_stream_receiver.h"
|
||||
@@ -334,3 +335,23 @@ HWTEST_F(EnqueueCopyImageToBufferStatefulTest, givenBufferWhenCopyingImageToBuff
|
||||
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
}
|
||||
|
||||
using OneMipLevelCopyImageToBufferImageTests = Test<OneMipLevelImageFixture>;
|
||||
|
||||
HWTEST_F(OneMipLevelCopyImageToBufferImageTests, GivenNotMippedImageWhenCopyingImageToBufferThenDoNotProgramSourceMipLevel) {
|
||||
auto dstBuffer = std::unique_ptr<Buffer>(createBuffer());
|
||||
auto queue = createQueue<FamilyType>();
|
||||
auto retVal = queue->enqueueCopyImageToBuffer(
|
||||
image.get(),
|
||||
dstBuffer.get(),
|
||||
origin,
|
||||
region,
|
||||
0u,
|
||||
0,
|
||||
nullptr,
|
||||
nullptr);
|
||||
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_TRUE(builtinOpsParamsCaptured);
|
||||
EXPECT_EQ(0u, usedBuiltinOpsParams.srcMipLevel);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
#include "opencl/source/built_ins/builtins_dispatch_builder.h"
|
||||
#include "opencl/test/unit_test/command_queue/enqueue_read_image_fixture.h"
|
||||
#include "opencl/test/unit_test/fixtures/one_mip_level_image_fixture.h"
|
||||
#include "opencl/test/unit_test/gen_common/gen_commands_common_validation.h"
|
||||
#include "opencl/test/unit_test/helpers/unit_test_helper.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_builtin_dispatch_info_builder.h"
|
||||
@@ -639,3 +640,24 @@ HWTEST_F(NegativeFailAllocationTest, givenEnqueueWriteImageWhenHostPtrAllocation
|
||||
|
||||
EXPECT_EQ(CL_OUT_OF_RESOURCES, retVal);
|
||||
}
|
||||
|
||||
using OneMipLevelReadImageTests = Test<OneMipLevelImageFixture>;
|
||||
|
||||
HWTEST_F(OneMipLevelReadImageTests, GivenNotMippedImageWhenReadingImageThenDoNotProgramSourceMipLevel) {
|
||||
auto queue = createQueue<FamilyType>();
|
||||
auto retVal = queue->enqueueReadImage(
|
||||
image.get(),
|
||||
CL_TRUE,
|
||||
origin,
|
||||
region,
|
||||
0,
|
||||
0,
|
||||
cpuPtr,
|
||||
nullptr,
|
||||
0,
|
||||
nullptr,
|
||||
nullptr);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_TRUE(builtinOpsParamsCaptured);
|
||||
EXPECT_EQ(0u, usedBuiltinOpsParams.srcMipLevel);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#include "opencl/source/built_ins/builtins_dispatch_builder.h"
|
||||
#include "opencl/test/unit_test/command_queue/enqueue_write_image_fixture.h"
|
||||
#include "opencl/test/unit_test/fixtures/one_mip_level_image_fixture.h"
|
||||
#include "opencl/test/unit_test/gen_common/gen_commands_common_validation.h"
|
||||
#include "opencl/test/unit_test/helpers/unit_test_helper.h"
|
||||
#include "opencl/test/unit_test/libult/ult_command_stream_receiver.h"
|
||||
@@ -572,3 +573,24 @@ HWTEST_F(NegativeFailAllocationTest, givenEnqueueReadImageWhenHostPtrAllocationC
|
||||
|
||||
EXPECT_EQ(CL_OUT_OF_RESOURCES, retVal);
|
||||
}
|
||||
|
||||
using OneMipLevelWriteImageTests = Test<OneMipLevelImageFixture>;
|
||||
|
||||
HWTEST_F(OneMipLevelWriteImageTests, GivenNotMippedImageWhenWritingImageThenDoNotProgramDestinationMipLevel) {
|
||||
auto queue = createQueue<FamilyType>();
|
||||
auto retVal = queue->enqueueWriteImage(
|
||||
image.get(),
|
||||
CL_TRUE,
|
||||
origin,
|
||||
region,
|
||||
0,
|
||||
0,
|
||||
cpuPtr,
|
||||
nullptr,
|
||||
0,
|
||||
nullptr,
|
||||
nullptr);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_TRUE(builtinOpsParamsCaptured);
|
||||
EXPECT_EQ(0u, usedBuiltinOpsParams.dstMipLevel);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (C) 2018-2020 Intel Corporation
|
||||
# Copyright (C) 2018-2021 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
@@ -39,6 +39,7 @@ set(IGDRCL_SRCS_tests_fixtures
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_execution_environment_gmm_fixture.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_execution_environment_gmm_fixture.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/multi_root_device_fixture.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/one_mip_level_image_fixture.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/platform_fixture.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/platform_fixture.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/run_kernel_fixture.h
|
||||
|
||||
70
opencl/test/unit_test/fixtures/one_mip_level_image_fixture.h
Normal file
70
opencl/test/unit_test/fixtures/one_mip_level_image_fixture.h
Normal file
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "opencl/source/command_queue/command_queue_hw.h"
|
||||
#include "opencl/test/unit_test/fixtures/image_fixture.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_context.h"
|
||||
#include "test.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
struct OneMipLevelImageFixture {
|
||||
template <typename GfxFamily>
|
||||
struct CommandQueueHwMock : CommandQueueHw<GfxFamily> {
|
||||
OneMipLevelImageFixture &fixture;
|
||||
CommandQueueHwMock(OneMipLevelImageFixture &fixture)
|
||||
: CommandQueueHw<GfxFamily>(&fixture.context, fixture.context.getDevice(0), nullptr, false),
|
||||
fixture(fixture) {}
|
||||
|
||||
void enqueueHandlerHook(const unsigned int commandType, const MultiDispatchInfo &multiDispatchInfo) override {
|
||||
fixture.builtinOpsParamsCaptured = true;
|
||||
fixture.usedBuiltinOpsParams = multiDispatchInfo.peekBuiltinOpParams();
|
||||
}
|
||||
};
|
||||
|
||||
void SetUp() {
|
||||
REQUIRE_IMAGES_OR_SKIP(defaultHwInfo);
|
||||
|
||||
cl_image_desc imageDesc = Image3dDefaults::imageDesc;
|
||||
this->region[0] = imageDesc.image_width;
|
||||
this->region[1] = imageDesc.image_height;
|
||||
this->region[2] = imageDesc.image_depth;
|
||||
|
||||
this->image.reset(createImage());
|
||||
}
|
||||
|
||||
void TearDown() {
|
||||
}
|
||||
|
||||
Image *createImage() {
|
||||
cl_image_desc imageDesc = Image3dDefaults::imageDesc;
|
||||
imageDesc.num_mip_levels = 1;
|
||||
return ImageHelper<Image3dDefaults>::create(&context, &imageDesc);
|
||||
}
|
||||
|
||||
Buffer *createBuffer() {
|
||||
return BufferHelper<>::create(&context);
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
std::unique_ptr<CommandQueue> createQueue() {
|
||||
return std::unique_ptr<CommandQueue>(new CommandQueueHwMock<GfxFamily>(*this));
|
||||
}
|
||||
|
||||
MockContext context;
|
||||
std::unique_ptr<Image> image;
|
||||
size_t origin[4] = {0, 0, 0, 0xdeadbeef};
|
||||
size_t region[4] = {0, 0, 0, 0};
|
||||
void *cpuPtr = Image3dDefaults::hostPtr;
|
||||
|
||||
BuiltinOpParams usedBuiltinOpsParams;
|
||||
bool builtinOpsParamsCaptured;
|
||||
};
|
||||
|
||||
} // namespace NEO
|
||||
Reference in New Issue
Block a user