diff --git a/projects/hip-tests/catch/unit/texture/CMakeLists.txt b/projects/hip-tests/catch/unit/texture/CMakeLists.txt index 0b18379c7b..fe4c0a8d1d 100644 --- a/projects/hip-tests/catch/unit/texture/CMakeLists.txt +++ b/projects/hip-tests/catch/unit/texture/CMakeLists.txt @@ -45,6 +45,12 @@ set(TEST_SRC hipTexObjectTests.cc hipTextureObjectTests.cc hipBindTextureToMipmappedArray.cc + hipMallocMipmappedArray.cc + hipFreeMipmappedArray.cc + hipGetMipmappedArrayLevel.cc + hipMipmappedArrayCreate.cc + hipMipmappedArrayDestroy.cc + hipMipmappedArrayGetLevel.cc ) if(WIN32) diff --git a/projects/hip-tests/catch/unit/texture/hipFreeMipmappedArray.cc b/projects/hip-tests/catch/unit/texture/hipFreeMipmappedArray.cc new file mode 100644 index 0000000000..c0ca080d26 --- /dev/null +++ b/projects/hip-tests/catch/unit/texture/hipFreeMipmappedArray.cc @@ -0,0 +1,60 @@ +/* +Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#include + +/** + * @addtogroup hipFreeMipmappedArray hipFreeMipmappedArray + * @{ + * @ingroup TextureTest + */ + +/** + * Test Description + * ------------------------ + * - Negative parameters test for `hipFreeMipmappedArray`. + * Test source + * ------------------------ + * - unit/texture/hipFreeMipmappedArray.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.7 + */ +TEST_CASE("Unit_hipFreeMipmappedArray_Negative_Parameters") { + CHECK_IMAGE_SUPPORT; + + SECTION("array is nullptr") { + HIP_CHECK_ERROR(hipFreeMipmappedArray(nullptr), hipErrorInvalidValue); + } + + SECTION("double free") { + hipMipmappedArray_t array; + hipChannelFormatDesc desc = hipCreateChannelDesc(); + hipExtent extent = make_hipExtent(4, 4, 6); + unsigned int levels = 4; + + HIP_CHECK(hipMallocMipmappedArray(&array, &desc, extent, levels, 0)); + + HIP_CHECK(hipFreeMipmappedArray(array)); + HIP_CHECK_ERROR(hipFreeMipmappedArray(array), hipErrorContextIsDestroyed); + } +} \ No newline at end of file diff --git a/projects/hip-tests/catch/unit/texture/hipGetMipmappedArrayLevel.cc b/projects/hip-tests/catch/unit/texture/hipGetMipmappedArrayLevel.cc new file mode 100644 index 0000000000..0740c06d04 --- /dev/null +++ b/projects/hip-tests/catch/unit/texture/hipGetMipmappedArrayLevel.cc @@ -0,0 +1,67 @@ +/* +Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#include + +/** + * @addtogroup hipGetMipmappedArrayLevel hipGetMipmappedArrayLevel + * @{ + * @ingroup TextureTest + */ + +/** + * Test Description + * ------------------------ + * - Negative parameters test for `hipGetMipmappedArrayLevel`. + * Test source + * ------------------------ + * - unit/texture/hipGetMipmappedArrayLevel.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.7 + */ +TEST_CASE("Unit_hipGetMipmappedArrayLevel_Negative_Parameters") { + CHECK_IMAGE_SUPPORT; + + hipMipmappedArray_t array; + hipChannelFormatDesc desc = hipCreateChannelDesc(); + hipExtent extent = make_hipExtent(4, 4, 6); + unsigned int levels = 4; + + HIP_CHECK(hipMallocMipmappedArray(&array, &desc, extent, levels, 0)); + + hipArray_t levelArray; + + SECTION("levelArray is nullptr") { + HIP_CHECK_ERROR(hipGetMipmappedArrayLevel(nullptr, array, 2), hipErrorInvalidValue); + } + + SECTION("mipmappedArray is nullptr") { + HIP_CHECK_ERROR(hipGetMipmappedArrayLevel(&levelArray, nullptr, 2), hipErrorInvalidHandle); + } + + SECTION("level index is greater than number of levels") { + HIP_CHECK_ERROR(hipGetMipmappedArrayLevel(&levelArray, array, 4), hipErrorInvalidValue); + } + + HIP_CHECK(hipFreeMipmappedArray(array)); +} \ No newline at end of file diff --git a/projects/hip-tests/catch/unit/texture/hipMallocMipmappedArray.cc b/projects/hip-tests/catch/unit/texture/hipMallocMipmappedArray.cc new file mode 100644 index 0000000000..364f481465 --- /dev/null +++ b/projects/hip-tests/catch/unit/texture/hipMallocMipmappedArray.cc @@ -0,0 +1,117 @@ +/* +Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#include + +/** + * @addtogroup hipMallocMipmappedArray hipMallocMipmappedArray + * @{ + * @ingroup TextureTest + */ + +/** + * Test Description + * ------------------------ + * - Negative parameters test for `hipMallocMipmappedArray`. + * Test source + * ------------------------ + * - unit/texture/hipMallocMipmappedArray.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.7 + */ +TEST_CASE("Unit_hipMallocMipmappedArray_Negative_Parameters") { + CHECK_IMAGE_SUPPORT; + + hipMipmappedArray_t array; + hipChannelFormatDesc desc = hipCreateChannelDesc(); + hipExtent extent = make_hipExtent(4, 4, 6); + unsigned int levels = 4; + + SECTION("mipmappedArray is nullptr") { + HIP_CHECK_ERROR(hipMallocMipmappedArray(nullptr, &desc, extent, levels, 0), + hipErrorInvalidValue); + } + + SECTION("desc is nullptr") { + HIP_CHECK_ERROR(hipMallocMipmappedArray(&array, nullptr, extent, levels, 0), + hipErrorInvalidValue); + } + + SECTION("extent is zero") { + extent = {}; + HIP_CHECK_ERROR(hipMallocMipmappedArray(&array, &desc, extent, levels, 0), + hipErrorInvalidValue); + } + + SECTION("invalid flags") { + HIP_CHECK_ERROR( + hipMallocMipmappedArray(&array, &desc, extent, levels, static_cast(-1)), + hipErrorInvalidValue); + } + + SECTION("hipArrayCubemap && depth != height") { + extent.height = 5; + HIP_CHECK_ERROR(hipMallocMipmappedArray(&array, &desc, extent, levels, hipArrayCubemap), + hipErrorInvalidValue); + } + + SECTION("hipArrayCubemap && depth != 6") { + extent.depth = 12; + HIP_CHECK_ERROR(hipMallocMipmappedArray(&array, &desc, extent, levels, hipArrayCubemap), + hipErrorInvalidValue); + } + + SECTION("hipArrayCubemap && hipArrayLayered && depth is not a multiple of 6") { + extent.depth = 13; + HIP_CHECK_ERROR( + hipMallocMipmappedArray(&array, &desc, extent, levels, hipArrayCubemap | hipArrayLayered), + hipErrorInvalidValue); + } + + SECTION("hipArrayTextureGather && 1D array") { + extent.height = 0; + extent.depth = 0; + HIP_CHECK_ERROR(hipMallocMipmappedArray(&array, &desc, extent, levels, hipArrayTextureGather), + hipErrorInvalidValue); + } + + SECTION("hipArrayTextureGather && 3D array") { + HIP_CHECK_ERROR(hipMallocMipmappedArray(&array, &desc, extent, levels, hipArrayTextureGather), + hipErrorInvalidValue); + } + +#if HT_NVIDIA // Disabled due to defect EXSWHTEC-365 + SECTION("hipArraySparse && 1D array") { + extent.height = 0; + extent.depth = 0; + HIP_CHECK_ERROR(hipMallocMipmappedArray(&array, &desc, extent, levels, cudaArraySparse), + hipErrorInvalidValue); + } + + SECTION("hipArraySparse && cubemap array") { + HIP_CHECK_ERROR( + hipMallocMipmappedArray(&array, &desc, extent, levels, hipArrayCubemap | cudaArraySparse), + hipErrorInvalidValue); + } +#endif +} \ No newline at end of file diff --git a/projects/hip-tests/catch/unit/texture/hipMipmappedArrayCreate.cc b/projects/hip-tests/catch/unit/texture/hipMipmappedArrayCreate.cc new file mode 100644 index 0000000000..33f80a1a9a --- /dev/null +++ b/projects/hip-tests/catch/unit/texture/hipMipmappedArrayCreate.cc @@ -0,0 +1,118 @@ +/* +Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#include +#include + +/** + * @addtogroup hipMipmappedArrayCreate hipMipmappedArrayCreate + * @{ + * @ingroup TextureTest + */ + +/** + * Test Description + * ------------------------ + * - Negative parameters test for `hipMipmappedArrayCreate`. + * Test source + * ------------------------ + * - unit/texture/hipMipmappedArrayCreate.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.7 + */ +TEST_CASE("Unit_hipMipmappedArrayCreate_Negative_Parameters") { + CHECK_IMAGE_SUPPORT; + + hipmipmappedArray array; + + HIP_ARRAY3D_DESCRIPTOR desc = {}; + using vec_info = vector_info; + desc.Format = vec_info::format; + desc.NumChannels = vec_info::size; + desc.Width = 4; + desc.Height = 4; + desc.Depth = 6; + desc.Flags = 0; + + unsigned int levels = 4; + + HIP_CHECK(hipFree(0)); + + SECTION("mipmappedArray is nullptr") { + HIP_CHECK_ERROR(hipMipmappedArrayCreate(nullptr, &desc, levels), hipErrorInvalidValue); + } + + SECTION("desc is nullptr") { + HIP_CHECK_ERROR(hipMipmappedArrayCreate(&array, nullptr, levels), hipErrorInvalidValue); + } + + SECTION("extent is zero") { + desc.Width = 0; + desc.Height = 0; + desc.Depth = 0; + HIP_CHECK_ERROR(hipMipmappedArrayCreate(&array, &desc, levels), hipErrorInvalidValue); + } + + SECTION("invalid flags") { + desc.Flags = static_cast(-1); + HIP_CHECK_ERROR(hipMipmappedArrayCreate(&array, &desc, levels), hipErrorInvalidValue); + } + + SECTION("hipArrayCubemap && depth != 6") { + desc.Depth = 5; + desc.Flags = hipArrayCubemap; + HIP_CHECK_ERROR(hipMipmappedArrayCreate(&array, &desc, levels), hipErrorInvalidValue); + } + + SECTION("hipArrayCubemap && hipArrayLayered && depth is not a multiple of 6") { + desc.Depth = 13; + desc.Flags = hipArrayCubemap | hipArrayLayered; + HIP_CHECK_ERROR(hipMipmappedArrayCreate(&array, &desc, levels), hipErrorInvalidValue); + } + + SECTION("hipArrayTextureGather && 1D array") { + desc.Height = 0; + desc.Depth = 0; + desc.Flags = hipArrayTextureGather; + HIP_CHECK_ERROR(hipMipmappedArrayCreate(&array, &desc, levels), hipErrorInvalidValue); + } + + SECTION("hipArrayTextureGather && 3D array") { + desc.Flags = hipArrayTextureGather; + HIP_CHECK_ERROR(hipMipmappedArrayCreate(&array, &desc, levels), hipErrorInvalidValue); + } + +#if HT_NVIDIA // Disabled due to defect EXSWHTEC-365 + SECTION("hipArraySparse && 1D array") { + desc.Height = 0; + desc.Depth = 0; + desc.Flags = cudaArraySparse; + HIP_CHECK_ERROR(hipMipmappedArrayCreate(&array, &desc, levels), hipErrorInvalidValue); + } + + SECTION("hipArraySparse && cubemap array") { + desc.Flags = hipArrayCubemap | cudaArraySparse; + HIP_CHECK_ERROR(hipMipmappedArrayCreate(&array, &desc, levels), hipErrorInvalidValue); + } +#endif +} \ No newline at end of file diff --git a/projects/hip-tests/catch/unit/texture/hipMipmappedArrayDestroy.cc b/projects/hip-tests/catch/unit/texture/hipMipmappedArrayDestroy.cc new file mode 100644 index 0000000000..3706cc48ff --- /dev/null +++ b/projects/hip-tests/catch/unit/texture/hipMipmappedArrayDestroy.cc @@ -0,0 +1,71 @@ +/* +Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#include +#include + +/** + * @addtogroup hipMipmappedArrayDestroy hipMipmappedArrayDestroy + * @{ + * @ingroup TextureTest + */ + +/** + * Test Description + * ------------------------ + * - Negative parameters test for `hipMipmappedArrayDestroy`. + * Test source + * ------------------------ + * - unit/texture/hipMipmappedArrayDestroy.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.7 + */ +TEST_CASE("Unit_hipMipmappedArrayDestroy_Negative_Parameters") { + CHECK_IMAGE_SUPPORT; + + HIP_CHECK(hipFree(0)); + + SECTION("array is nullptr") { + HIP_CHECK_ERROR(hipMipmappedArrayDestroy(nullptr), hipErrorInvalidHandle); + } + + SECTION("double free") { + hipmipmappedArray array; + + HIP_ARRAY3D_DESCRIPTOR desc = {}; + using vec_info = vector_info; + desc.Format = vec_info::format; + desc.NumChannels = vec_info::size; + desc.Width = 4; + desc.Height = 4; + desc.Depth = 6; + desc.Flags = 0; + + unsigned int levels = 4; + + HIP_CHECK(hipMipmappedArrayCreate(&array, &desc, levels)); + + HIP_CHECK(hipMipmappedArrayDestroy(array)); + HIP_CHECK_ERROR(hipMipmappedArrayDestroy(array), hipErrorContextIsDestroyed); + } +} \ No newline at end of file diff --git a/projects/hip-tests/catch/unit/texture/hipMipmappedArrayGetLevel.cc b/projects/hip-tests/catch/unit/texture/hipMipmappedArrayGetLevel.cc new file mode 100644 index 0000000000..70c4dfa10a --- /dev/null +++ b/projects/hip-tests/catch/unit/texture/hipMipmappedArrayGetLevel.cc @@ -0,0 +1,77 @@ +/* +Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#include +#include + +/** + * @addtogroup hipMipmappedArrayGetLevel hipMipmappedArrayGetLevel + * @{ + * @ingroup TextureTest + */ + +/** + * Test Description + * ------------------------ + * - Negative parameters test for `hipMipmappedArrayGetLevel`. + * Test source + * ------------------------ + * - unit/texture/hipMipmappedArrayGetLevel.cc + * Test requirements + * ------------------------ + * - HIP_VERSION >= 5.7 + */ +TEST_CASE("Unit_hipMipmappedArrayGetLevel_Negative_Parameters") { + CHECK_IMAGE_SUPPORT; + + hipmipmappedArray array; + + HIP_ARRAY3D_DESCRIPTOR desc = {}; + using vec_info = vector_info; + desc.Format = vec_info::format; + desc.NumChannels = vec_info::size; + desc.Width = 4; + desc.Height = 4; + desc.Depth = 6; + desc.Flags = 0; + + unsigned int levels = 4; + + HIP_CHECK(hipFree(0)); + HIP_CHECK(hipMipmappedArrayCreate(&array, &desc, levels)); + + hiparray levelArray; + + SECTION("levelArray is nullptr") { + HIP_CHECK_ERROR(hipMipmappedArrayGetLevel(nullptr, array, 2), hipErrorInvalidValue); + } + + SECTION("mipmappedArray is nullptr") { + HIP_CHECK_ERROR(hipMipmappedArrayGetLevel(&levelArray, nullptr, 2), hipErrorInvalidHandle); + } + + SECTION("level index is greater than number of levels") { + HIP_CHECK_ERROR(hipMipmappedArrayGetLevel(&levelArray, array, 4), hipErrorInvalidValue); + } + + HIP_CHECK(hipMipmappedArrayDestroy(array)); +} \ No newline at end of file