diff --git a/runtime/mem_obj/image.inl b/runtime/mem_obj/image.inl index 7833071167..cfe21c67cf 100644 --- a/runtime/mem_obj/image.inl +++ b/runtime/mem_obj/image.inl @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -110,7 +110,7 @@ void ImageHw::setImageArg(void *memory, bool setAsMediaBlockImage, ui surfaceState->setRenderTargetViewExtent(renderTargetViewExtent); surfaceState->setMinimumArrayElement(minimumArrayElement); surfaceState->setSurfaceMinLod(this->mipLevel + mipLevel); - surfaceState->setMipCountLod(this->mipCount - 1); + surfaceState->setMipCountLod((this->mipCount > 0) ? (this->mipCount - 1) : 0); // SurfaceQpitch is in rows but must be a multiple of VALIGN surfaceState->setSurfaceQpitch(qPitch); diff --git a/unit_tests/mem_obj/image_set_arg_tests.cpp b/unit_tests/mem_obj/image_set_arg_tests.cpp index 825f4364d9..e0c881b0f9 100644 --- a/unit_tests/mem_obj/image_set_arg_tests.cpp +++ b/unit_tests/mem_obj/image_set_arg_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -169,6 +169,7 @@ HWTEST_F(ImageSetArgTest, setKernelArgImageUsingNormalImage) { auto computedWidth = surfaceState.getWidth(); EXPECT_EQ(srcImage->getImageDesc().image_width, computedWidth); + EXPECT_EQ(0u, surfaceState.getMipCountLod()); } HWTEST_F(ImageSetArgTest, givenCubeMapIndexWhenSetKernelArgImageIsCalledThenModifySurfaceState) {