SWDEV-528351 - Adds hipTexRefSetGet* tests (#183)

* SWDEV-528351 - Adds hipTexRefSetGet* tests

* SWDEV-528351 - Adds hipTexRefSetGet* tests

* SWDEV-528351 - Adds hipTexRefSetGet* tests

[ROCm/hip-tests commit: d6f415cf54]
Este commit está contenido en:
Betigeri, Sourabh
2025-08-05 08:10:17 -07:00
cometido por GitHub
padre dddeed5177
commit d3aa32b8cc
Se han modificado 6 ficheros con 314 adiciones y 0 borrados
@@ -64,6 +64,12 @@ set(TEST_SRC
hipTexRefGetFlags.cc
hipTexRefSetAddressMode.cc
hipTexRefGetAddressMode.cc
hipTexRefSetGetFilterMode.cc
hipTexRefSetGetMipmapFilterMode.cc
hipTexRefSetGetMipmapLevelBias.cc
hipTexRefSetGetMipmapLevelClamp.cc
hipTexRefSetGetMipmappedArray.cc
)
# tests not for gfx90a+
@@ -0,0 +1,65 @@
/*
Copyright (c) 2024 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 WARRANNTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNNESS 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 INN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR INN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include <hip_test_common.hh>
texture<float, 2, hipReadModeElementType> tex;
// Test for hipTexRefSetFilterMode and hipTexRefGetFilterMode, including error handling
TEST_CASE("Unit_hipTexRefSetGetFilterMode") {
CHECK_IMAGE_SUPPORT;
// Retrieve the texture reference for our symbol
const textureReference* texRefConst = nullptr;
HIP_CHECK(hipGetTextureReference(&texRefConst, &tex));
REQUIRE(texRefConst != nullptr);
// Implementation expects non-const textureReference*
textureReference* texRef = const_cast<textureReference*>(texRefConst);
hipTextureFilterMode mode;
SECTION("Default filter mode is Point") {
HIP_CHECK(hipTexRefGetFilterMode(&mode, texRef));
REQUIRE(mode == hipFilterModePoint);
}
SECTION("Set filter mode to Linear and verify") {
HIP_CHECK(hipTexRefSetFilterMode(texRef, hipFilterModeLinear));
HIP_CHECK(hipTexRefGetFilterMode(&mode, texRef));
REQUIRE(mode == hipFilterModeLinear);
}
SECTION("Set filter mode back to Point and verify") {
HIP_CHECK(hipTexRefSetFilterMode(texRef, hipFilterModePoint));
HIP_CHECK(hipTexRefGetFilterMode(&mode, texRef));
REQUIRE(mode == hipFilterModePoint);
}
SECTION("Invalid arguments: null texture reference pointer") {
// Setting filter mode with null texRef should fail
hipError_t errSet = hipTexRefSetFilterMode(nullptr, hipFilterModeLinear);
REQUIRE(errSet == hipErrorInvalidValue);
// Getting filter mode with null texRef should fail
hipError_t errGetRef = hipTexRefGetFilterMode(&mode, nullptr);
REQUIRE(errGetRef == hipErrorInvalidValue);
// Getting filter mode with null mode pointer should fail
hipError_t errGetMode = hipTexRefGetFilterMode(nullptr, texRef);
REQUIRE(errGetMode == hipErrorInvalidValue);
}
}
@@ -0,0 +1,58 @@
/*
Copyright (c) 2025 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 WARRANNTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNNESS 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 INN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR INN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include <hip_test_common.hh>
texture<float, 2, hipReadModeElementType> tex;
// Test for hipTexRefSetMipmapFilterMode and hipTexRefGetMipmapFilterMode, including error handling
TEST_CASE("Unit_hipTexRefSetGetMipmapFilterMode") {
CHECK_IMAGE_SUPPORT;
// Retrieve the texture reference for our symbol
const textureReference* texRefConst = nullptr;
HIP_CHECK(hipGetTextureReference(&texRefConst, &tex));
REQUIRE(texRefConst != nullptr);
// Implementation expects non-const textureReference*
textureReference* texRef = const_cast<textureReference*>(texRefConst);
hipTextureFilterMode mipMode;
SECTION("Set mipmap filter mode to Linear and verify") {
HIP_CHECK(hipTexRefSetMipmapFilterMode(texRef, hipFilterModeLinear));
auto res = hipTexRefGetMipmapFilterMode(&mipMode, texRef);
REQUIRE(res == hipErrorInvalidValue);
REQUIRE(mipMode == hipFilterModeLinear);
}
SECTION("Set mipmap filter mode back to Point and verify") {
HIP_CHECK(hipTexRefSetMipmapFilterMode(texRef, hipFilterModePoint));
auto res = hipTexRefGetMipmapFilterMode(&mipMode, texRef);
REQUIRE(res == hipErrorInvalidValue);
REQUIRE(mipMode == hipFilterModePoint);
}
SECTION("Invalid arguments: null pointers") {
hipError_t err;
err = hipTexRefSetMipmapFilterMode(nullptr, hipFilterModeLinear);
REQUIRE(err == hipErrorInvalidValue);
err = hipTexRefGetMipmapFilterMode(&mipMode, nullptr);
REQUIRE(err == hipErrorInvalidValue);
err = hipTexRefGetMipmapFilterMode(nullptr, texRef);
REQUIRE(err == hipErrorInvalidValue);
}
}
@@ -0,0 +1,52 @@
/*
Copyright (c) 2025 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 WARRANNTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNNESS 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 INN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR INN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include <hip_test_common.hh>
texture<float, 2, hipReadModeElementType> tex;
// Test for hipTexRefSetMipmapLevelBias and hipTexRefGetMipmapLevelBias, including error handling
TEST_CASE("Unit_hipTexRefSetGetMipmapLevelBias") {
CHECK_IMAGE_SUPPORT;
// Retrieve the texture reference for our symbol
const textureReference* texRefConst = nullptr;
HIP_CHECK(hipGetTextureReference(&texRefConst, &tex));
REQUIRE(texRefConst != nullptr);
// Implementation expects non-const textureReference*
textureReference* texRef = const_cast<textureReference*>(texRefConst);
float bias = 0.0;
SECTION("Set mipmap level bias to custom value and verify") {
float newBias = 2.25;
HIP_CHECK(hipTexRefSetMipmapLevelBias(texRef, newBias));
auto res = hipTexRefGetMipmapLevelBias(&bias, texRef);
REQUIRE(res == hipErrorInvalidValue);
REQUIRE(bias == newBias);
}
SECTION("Invalid arguments: null pointers") {
hipError_t err;
err = hipTexRefSetMipmapLevelBias(nullptr, 1.0f);
REQUIRE(err == hipErrorInvalidValue);
err = hipTexRefGetMipmapLevelBias(nullptr, texRef);
REQUIRE(err == hipErrorInvalidValue);
err = hipTexRefGetMipmapLevelBias(&bias, nullptr);
REQUIRE(err == hipErrorInvalidValue);
}
}
@@ -0,0 +1,57 @@
/*
Copyright (c) 2025 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 WARRANNTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNNESS 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 INN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR INN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include <hip_test_common.hh>
#include <float.h>
texture<float, 2, hipReadModeElementType> tex;
// Test for hipTexRefSetMipmapLevelClamp and hipTexRefGetMipmapLevelClamp, including error handling
TEST_CASE("Unit_texRefSetGetMipmapLevelClamp") {
CHECK_IMAGE_SUPPORT;
// Retrieve the texture reference for our symbol
const textureReference* texRefConst = nullptr;
HIP_CHECK(hipGetTextureReference(&texRefConst, &tex));
REQUIRE(texRefConst != nullptr);
// Implementation expects non-const textureReference*
textureReference* texRef = const_cast<textureReference*>(texRefConst);
float minClamp = 0.0f, maxClamp = 0.0f;
SECTION("Set mipmap level clamp to custom values and verify") {
float newMin = 1.5f, newMax = 5.5f;
HIP_CHECK(hipTexRefSetMipmapLevelClamp(texRef, newMin, newMax));
auto res = hipTexRefGetMipmapLevelClamp(&minClamp, &maxClamp, texRefConst);
REQUIRE(res == hipErrorInvalidValue);
REQUIRE(minClamp == newMin);
REQUIRE(maxClamp == newMax);
}
SECTION("Invalid arguments: null pointers") {
hipError_t err;
err = hipTexRefSetMipmapLevelClamp(nullptr, 1.0f, 2.0f);
REQUIRE(err == hipErrorInvalidValue);
err = hipTexRefGetMipmapLevelClamp(nullptr, &maxClamp, texRefConst);
REQUIRE(err == hipErrorInvalidValue);
err = hipTexRefGetMipmapLevelClamp(&minClamp, nullptr, texRefConst);
REQUIRE(err == hipErrorInvalidValue);
err = hipTexRefGetMipmapLevelClamp(&minClamp, &maxClamp, nullptr);
REQUIRE(err == hipErrorInvalidValue);
}
}
@@ -0,0 +1,76 @@
/*
Copyright (c) 2025 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 WARRANNTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNNESS 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 INN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR INN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include <hip_test_common.hh>
texture<float, 2, hipReadModeElementType> tex;
// Test for hipTexRefSetMipmappedArray and hipTexRefGetMipmappedArray, including error handling
TEST_CASE("Unit_hipTexRefSetGetMipmappedArray") {
CHECK_IMAGE_SUPPORT;
// Retrieve the texture reference for our symbol
const textureReference* texRefConst = nullptr;
HIP_CHECK(hipGetTextureReference(&texRefConst, &tex));
REQUIRE(texRefConst != nullptr);
// Implementation expects non-const textureReference*
textureReference* texRef = const_cast<textureReference*>(texRefConst);
hipMipmappedArray_t mipArr = nullptr;
hipMipmappedArray_t outArr = nullptr;
unsigned int Flags = 0;
SECTION("Default mipmapped array GET returns invalid value when none bound") {
hipError_t err = hipTexRefGetMipMappedArray(&outArr, texRef);
REQUIRE(err == hipErrorInvalidValue);
}
SECTION("Set and get mipmapped array") {
hipMipmappedArray_t mipmapped_array;
HIP_RESOURCE_DESC res_desc{};
hipExtent extent;
hipChannelFormatDesc channel_desc;
unsigned int width = 256, height = 256, mipmap_level = 2;
res_desc.resType = HIP_RESOURCE_TYPE_MIPMAPPED_ARRAY;
channel_desc = hipCreateChannelDesc<float>();
extent = make_hipExtent(width, height, 0);
auto res = hipMallocMipmappedArray(&mipmapped_array, &channel_desc, extent, 2 * mipmap_level,
hipArrayDefault);
if (res == hipErrorNotSupported) {
SUCCEED("Mipmapped arrays not supported on this device");
return;
}
HIP_CHECK(res);
HIP_CHECK(hipTexRefSetMipmappedArray(texRef, mipmapped_array, Flags));
HIP_CHECK(hipTexRefGetMipMappedArray(&outArr, texRef));
REQUIRE(outArr == mipmapped_array);
HIP_CHECK(hipFreeMipmappedArray(mipmapped_array));
}
SECTION("Invalid arguments: null pointers") {
hipError_t err;
err = hipTexRefSetMipmappedArray(nullptr, mipArr, Flags);
REQUIRE(err == hipErrorInvalidValue);
err = hipTexRefGetMipMappedArray(&outArr, nullptr);
REQUIRE(err == hipErrorInvalidValue);
err = hipTexRefGetMipMappedArray(nullptr, texRef);
REQUIRE(err == hipErrorInvalidValue);
}
}