/* * Copyright (c) Advanced Micro Devices, Inc., or its affiliates. * * SPDX-License-Identifier: MIT */ #include #include "kernels.hh" #include "test_fixture.hh" /** * @addtogroup tex3DGrad tex3DGrad * @{ * @ingroup TextureTest */ /** * Test Description * ------------------------ * - Test texture fetching with `tex3DGrad` and read mode set to `hipReadModeElementType`. The * test is performed with: * - normalized coordinates * - non-normalized coordinates * - Nearest-point sampling * - Linear filtering * - All combinations of different addressing modes. * Test source * ------------------------ * - unit/texture/tex3DGrad.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.7 */ HIP_TEMPLATE_TEST_CASE(Unit_tex3DGrad_Positive_ReadModeElementType, char, unsigned char, short, unsigned short, int, unsigned int, float) { CHECK_IMAGE_SUPPORT; TextureTestParams params = {}; params.extent = make_hipExtent(2, 2, 2); params.num_subdivisions = 2; params.GenerateTextureDesc(); TextureTestFixture fixture{params}; const auto [num_threads_x, num_blocks_x] = GetLaunchConfig(10, params.NumItersX()); const auto [num_threads_y, num_blocks_y] = GetLaunchConfig(10, params.NumItersY()); const auto [num_threads_z, num_blocks_z] = GetLaunchConfig(10, params.NumItersZ()); dim3 dim_grid; dim_grid.x = num_blocks_x; dim_grid.y = num_blocks_y; dim_grid.z = num_blocks_z; dim3 dim_block; dim_block.x = num_threads_x; dim_block.y = num_threads_y; dim_block.z = num_threads_z; tex3DGradKernel><<>>( fixture.out_alloc_d.ptr(), params.NumItersX(), params.NumItersY(), params.NumItersZ(), fixture.tex.object(), params.Width(), params.Height(), params.Depth(), params.num_subdivisions, params.tex_desc.normalizedCoords, float4{}, float4{}); HIP_CHECK(hipGetLastError()); fixture.LoadOutput(); for (auto i = 0u; i < params.NumIters(); ++i) { const auto plane = i % (params.NumItersX() * params.NumItersY()); float x = plane % params.NumItersX(); float y = plane / params.NumItersX(); float z = i / (params.NumItersX() * params.NumItersY()); x = GetCoordinate(x, params.NumItersX(), params.Width(), params.num_subdivisions, params.tex_desc.normalizedCoords); y = GetCoordinate(y, params.NumItersY(), params.Height(), params.num_subdivisions, params.tex_desc.normalizedCoords); z = GetCoordinate(z, params.NumItersZ(), params.Depth(), params.num_subdivisions, params.tex_desc.normalizedCoords); const auto ref_val = fixture.tex_h.Tex3D(x, y, z, params.tex_desc); if (!fixture.Verify(fixture.out_alloc_h[i], ref_val)) { INFO("Filtering mode: " << FilteringModeToString(params.tex_desc.filterMode)); INFO("Normalized coordinates: " << std::boolalpha << params.tex_desc.normalizedCoords); INFO("Address mode X: " << AddressModeToString(params.tex_desc.addressMode[0])); INFO("Address mode Y: " << AddressModeToString(params.tex_desc.addressMode[1])); INFO("Address mode Z: " << AddressModeToString(params.tex_desc.addressMode[2])); INFO("x: " << std::fixed << std::setprecision(16) << x); INFO("y: " << std::fixed << std::setprecision(16) << y); INFO("z: " << std::fixed << std::setprecision(16) << z); REQUIRE(false); } } } /** * Test Description * ------------------------ * - Test texture fetching with `tex3DGrad` and read mode set to `hipReadModeNormalizedFloat`. * The test is performed with: * - normalized coordinates * - non-normalized coordinates * - Nearest-point sampling * - Linear filtering * - All combinations of different addressing modes. * Test source * ------------------------ * - unit/texture/tex3DGrad.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.7 */ HIP_TEMPLATE_TEST_CASE(Unit_tex3DGrad_Positive_ReadModeNormalizedFloat, char, unsigned char, short, unsigned short) { CHECK_IMAGE_SUPPORT; TextureTestParams params = {}; params.extent = make_hipExtent(2, 2, 2); params.num_subdivisions = 2; params.GenerateTextureDesc(hipReadModeNormalizedFloat); TextureTestFixture fixture{params}; const auto [num_threads_x, num_blocks_x] = GetLaunchConfig(10, params.NumItersX()); const auto [num_threads_y, num_blocks_y] = GetLaunchConfig(10, params.NumItersY()); const auto [num_threads_z, num_blocks_z] = GetLaunchConfig(10, params.NumItersZ()); dim3 dim_grid; dim_grid.x = num_blocks_x; dim_grid.y = num_blocks_y; dim_grid.z = num_blocks_z; dim3 dim_block; dim_block.x = num_threads_x; dim_block.y = num_threads_y; dim_block.z = num_threads_z; tex3DGradKernel><<>>( fixture.out_alloc_d.ptr(), params.NumItersX(), params.NumItersY(), params.NumItersZ(), fixture.tex.object(), params.Width(), params.Height(), params.Depth(), params.num_subdivisions, params.tex_desc.normalizedCoords, float4{}, float4{}); HIP_CHECK(hipGetLastError()); fixture.LoadOutput(); for (auto i = 0u; i < params.NumIters(); ++i) { const auto plane = i % (params.NumItersX() * params.NumItersY()); float x = plane % params.NumItersX(); float y = plane / params.NumItersX(); float z = i / (params.NumItersX() * params.NumItersY()); x = GetCoordinate(x, params.NumItersX(), params.Width(), params.num_subdivisions, params.tex_desc.normalizedCoords); y = GetCoordinate(y, params.NumItersY(), params.Height(), params.num_subdivisions, params.tex_desc.normalizedCoords); z = GetCoordinate(z, params.NumItersZ(), params.Depth(), params.num_subdivisions, params.tex_desc.normalizedCoords); auto ref_val = fixture.tex_h.Tex3D(x, y, z, params.tex_desc); if (!fixture.Verify(fixture.out_alloc_h[i], ref_val)) { INFO("Filtering mode: " << FilteringModeToString(params.tex_desc.filterMode)); INFO("Normalized coordinates: " << std::boolalpha << params.tex_desc.normalizedCoords); INFO("Address mode X: " << AddressModeToString(params.tex_desc.addressMode[0])); INFO("Address mode Y: " << AddressModeToString(params.tex_desc.addressMode[1])); INFO("Address mode Z: " << AddressModeToString(params.tex_desc.addressMode[2])); INFO("x: " << std::fixed << std::setprecision(16) << x); INFO("y: " << std::fixed << std::setprecision(16) << y); INFO("z: " << std::fixed << std::setprecision(16) << z); REQUIRE(false); } } } /** * End doxygen group TextureTest. * @} */