SWDEV-1 - Merge github PRs to amd-staging

Change-Id: I2944a63ddc2eec8dc1403d9790ffffbaec343385
Cette révision appartient à :
Rakesh Roy
2024-03-04 11:51:34 +05:30
révision 57bc68acb1
366 fichiers modifiés avec 55399 ajouts et 2073 suppressions
+61
Voir le fichier
@@ -53,6 +53,67 @@ set(TEST_SRC
hipMipmappedArrayGetLevel.cc
)
# tests not for MI200+
set(NOT_FOR_MI200_AND_ABOVE_TEST
tex1Dfetch.cc
tex1D.cc
tex1DLayered.cc
tex1DGrad.cc
tex1DLayeredGrad.cc
tex1DLayeredLod.cc
tex1DLod.cc
tex3D.cc
tex3DLod.cc
tex3DGrad.cc
texCubemap.cc
texCubemapLod.cc
texCubemapGrad.cc
texCubemapLayered.cc
texCubemapLayeredLod.cc
texCubemapLayeredGrad.cc
tex2Dgather.cc
tex2D.cc
tex2DLayered.cc
tex2DGrad.cc
tex2DLayeredGrad.cc
tex2DLod.cc
tex2DLayeredLod.cc
tex3D.cc
tex3DLod.cc
tex3DGrad.cc
)
set(MI200_AND_ABOVE_TARGETS gfx90a gfx940 gfx941 gfx942)
function(CheckRejectedArchs OFFLOAD_ARCH_STR_LOCAL)
set(ARCH_CHECK -1 PARENT_SCOPE)
string(REGEX MATCHALL "--offload-arch=gfx[0-9a-z]+" OFFLOAD_ARCH_LIST ${OFFLOAD_ARCH_STR_LOCAL})
foreach(OFFLOAD_ARCH IN LISTS OFFLOAD_ARCH_LIST)
string(REGEX MATCHALL "--offload-arch=(gfx[0-9a-z]+)" matches ${OFFLOAD_ARCH})
if (CMAKE_MATCH_COUNT EQUAL 1)
if (CMAKE_MATCH_1 IN_LIST MI200_AND_ABOVE_TARGETS)
set(ARCH_CHECK 1 PARENT_SCOPE)
endif() # CMAKE_MATCH_1
endif() # CMAKE_MATCH_COUNT
endforeach() # OFFLOAD_ARCH_LIST
endfunction() # CheckAcceptedArchs
if(HIP_PLATFORM MATCHES "amd")
if (DEFINED OFFLOAD_ARCH_STR)
CheckRejectedArchs(${OFFLOAD_ARCH_STR})
elseif(DEFINED $ENV{HCC_AMDGPU_TARGET})
CheckRejectedArchs($ENV{HCC_AMDGPU_TARGET})
else()
set(ARCH_CHECK -1)
endif()
if(${ARCH_CHECK} EQUAL -1)
message(STATUS "Adding test: ${NOT_FOR_MI200_AND_ABOVE_TEST}")
set(TEST_SRC ${TEST_SRC} ${NOT_FOR_MI200_AND_ABOVE_TEST})
else()
message(STATUS "Removing test: ${NOT_FOR_MI200_AND_ABOVE_TEST}")
endif()
else()
set(TEST_SRC ${TEST_SRC} ${NOT_FOR_MI200_AND_ABOVE_TEST})
endif()
if(WIN32)
set(TEST_SRC
${TEST_SRC}
+307
Voir le fichier
@@ -33,6 +33,14 @@ __host__ __device__ inline float GetCoordinate(size_t iteration, size_t N, size_
return normalized_coords ? x / dim : x;
}
template <typename TexelType>
__global__ void tex1DfetchKernel(TexelType* const out, size_t N, hipTextureObject_t tex_obj) {
const auto tid = cg::this_grid().thread_rank();
if (tid >= N) return;
out[tid] = tex1D<TexelType>(tex_obj, tid);
}
template <typename TexelType>
__global__ void tex1DKernel(TexelType* const out, size_t N, hipTextureObject_t tex_obj,
size_t width, size_t num_subdivisions, bool normalized_coords) {
@@ -43,6 +51,66 @@ __global__ void tex1DKernel(TexelType* const out, size_t N, hipTextureObject_t t
out[tid] = tex1D<TexelType>(tex_obj, x);
}
template <typename TexelType>
__global__ void tex1DLodKernel(TexelType* const out, size_t N, hipTextureObject_t tex_obj,
size_t width, size_t num_subdivisions, bool normalized_coords,
float level_of_detail) {
const auto tid = cg::this_grid().thread_rank();
if (tid >= N) return;
float x = GetCoordinate(tid, N, width, num_subdivisions, normalized_coords);
out[tid] = tex1DLod<TexelType>(tex_obj, x, level_of_detail);
}
template <typename TexelType>
__global__ void tex1DLayeredLodKernel(TexelType* const out, size_t N, hipTextureObject_t tex_obj,
size_t width, size_t num_subdivisions, bool normalized_coords,
int layer, float level_of_detail) {
const auto tid = cg::this_grid().thread_rank();
if (tid >= N) return;
float x = GetCoordinate(tid, N, width, num_subdivisions, normalized_coords);
out[tid] = tex1DLayeredLod<TexelType>(tex_obj, x, layer, level_of_detail);
}
template <typename TexelType>
__global__ void tex1DGradKernel(TexelType* const out, size_t N, hipTextureObject_t tex_obj,
size_t width, size_t num_subdivisions, bool normalized_coords,
float dx, float dy) {
const auto tid = cg::this_grid().thread_rank();
if (tid >= N) return;
float x = GetCoordinate(tid, N, width, num_subdivisions, normalized_coords);
out[tid] = tex1DGrad<TexelType>(tex_obj, x, dx, dy);
}
template <typename TexelType>
__global__ void tex1DLayeredGradKernel(TexelType* const out, size_t N, hipTextureObject_t tex_obj,
size_t width, size_t num_subdivisions,
bool normalized_coords, int layer, float dx, float dy) {
const auto tid = cg::this_grid().thread_rank();
if (tid >= N) return;
float x = GetCoordinate(tid, N, width, num_subdivisions, normalized_coords);
out[tid] = tex1DLayeredGrad<TexelType>(tex_obj, x, layer, dx, dy);
}
template <typename TexelType>
__global__ void tex2DgatherKernel(TexelType* const out, int comp, size_t N_x, size_t N_y,
hipTextureObject_t tex_obj, size_t width, size_t height,
size_t num_subdivisions, bool normalized_coords) {
const auto tid_x = blockIdx.x * blockDim.x + threadIdx.x;
if (tid_x >= N_x) return;
const auto tid_y = blockIdx.y * blockDim.y + threadIdx.y;
if (tid_y >= N_y) return;
float x = GetCoordinate(tid_x, N_x, width, num_subdivisions, normalized_coords);
float y = GetCoordinate(tid_y, N_y, height, num_subdivisions, normalized_coords);
out[tid_y * N_x + tid_x] = tex2Dgather<TexelType>(tex_obj, x, y, comp);
}
template <typename TexelType>
__global__ void tex2DKernel(TexelType* const out, size_t N_x, size_t N_y,
hipTextureObject_t tex_obj, size_t width, size_t height,
@@ -59,6 +127,73 @@ __global__ void tex2DKernel(TexelType* const out, size_t N_x, size_t N_y,
out[tid_y * N_x + tid_x] = tex2D<TexelType>(tex_obj, x, y);
}
template <typename TexelType>
__global__ void tex2DGradKernel(TexelType* const out, size_t N_x, size_t N_y,
hipTextureObject_t tex_obj, size_t width, size_t height,
size_t num_subdivisions, bool normalized_coords, float2 dx,
float2 dy) {
const auto tid_x = blockIdx.x * blockDim.x + threadIdx.x;
if (tid_x >= N_x) return;
const auto tid_y = blockIdx.y * blockDim.y + threadIdx.y;
if (tid_y >= N_y) return;
float x = GetCoordinate(tid_x, N_x, width, num_subdivisions, normalized_coords);
float y = GetCoordinate(tid_y, N_y, height, num_subdivisions, normalized_coords);
out[tid_y * N_x + tid_x] = tex2DGrad<TexelType>(tex_obj, x, y, dx, dy);
}
template <typename TexelType>
__global__ void tex2DLayeredGradKernel(TexelType* const out, size_t N_x, size_t N_y,
hipTextureObject_t tex_obj, size_t width, size_t height,
size_t num_subdivisions, bool normalized_coords, float layer,
float2 dx, float2 dy) {
const auto tid_x = blockIdx.x * blockDim.x + threadIdx.x;
if (tid_x >= N_x) return;
const auto tid_y = blockIdx.y * blockDim.y + threadIdx.y;
if (tid_y >= N_y) return;
float x = GetCoordinate(tid_x, N_x, width, num_subdivisions, normalized_coords);
float y = GetCoordinate(tid_y, N_y, height, num_subdivisions, normalized_coords);
out[tid_y * N_x + tid_x] = tex2DLayeredGrad<TexelType>(tex_obj, x, y, layer, dx, dy);
}
template <typename TexelType>
__global__ void tex2DLodKernel(TexelType* const out, size_t N_x, size_t N_y,
hipTextureObject_t tex_obj, size_t width, size_t height,
size_t num_subdivisions, bool normalized_coords, float level) {
const auto tid_x = blockIdx.x * blockDim.x + threadIdx.x;
if (tid_x >= N_x) return;
const auto tid_y = blockIdx.y * blockDim.y + threadIdx.y;
if (tid_y >= N_y) return;
float x = GetCoordinate(tid_x, N_x, width, num_subdivisions, normalized_coords);
float y = GetCoordinate(tid_y, N_y, height, num_subdivisions, normalized_coords);
out[tid_y * N_x + tid_x] = tex2DLod<TexelType>(tex_obj, x, y, level);
}
template <typename TexelType>
__global__ void tex2DLayeredLodKernel(TexelType* const out, size_t N_x, size_t N_y,
hipTextureObject_t tex_obj, size_t width, size_t height,
size_t num_subdivisions, bool normalized_coords, int layer,
float level) {
const auto tid_x = blockIdx.x * blockDim.x + threadIdx.x;
if (tid_x >= N_x) return;
const auto tid_y = blockIdx.y * blockDim.y + threadIdx.y;
if (tid_y >= N_y) return;
float x = GetCoordinate(tid_x, N_x, width, num_subdivisions, normalized_coords);
float y = GetCoordinate(tid_y, N_y, height, num_subdivisions, normalized_coords);
out[tid_y * N_x + tid_x] = tex2DLayeredLod<TexelType>(tex_obj, x, y, layer, level);
}
template <typename TexelType>
__global__ void tex3DKernel(TexelType* const out, size_t N_x, size_t N_y, size_t N_z,
hipTextureObject_t tex_obj, size_t width, size_t height, size_t depth,
@@ -79,6 +214,111 @@ __global__ void tex3DKernel(TexelType* const out, size_t N_x, size_t N_y, size_t
out[tid_z * N_x * N_y + tid_y * N_x + tid_x] = tex3D<TexelType>(tex_obj, x, y, z);
}
template <typename TexelType>
__global__ void tex3DLodKernel(TexelType* const out, size_t N_x, size_t N_y, size_t N_z,
hipTextureObject_t tex_obj, size_t width, size_t height,
size_t depth, size_t num_subdivisions, bool normalized_coords,
float level) {
const auto tid_x = blockIdx.x * blockDim.x + threadIdx.x;
if (tid_x >= N_x) return;
const auto tid_y = blockIdx.y * blockDim.y + threadIdx.y;
if (tid_y >= N_y) return;
const auto tid_z = blockIdx.z * blockDim.z + threadIdx.z;
if (tid_z >= N_z) return;
float x = GetCoordinate(tid_x, N_x, width, num_subdivisions, normalized_coords);
float y = GetCoordinate(tid_y, N_y, height, num_subdivisions, normalized_coords);
float z = GetCoordinate(tid_z, N_z, depth, num_subdivisions, normalized_coords);
out[tid_z * N_x * N_y + tid_y * N_x + tid_x] = tex3DLod<TexelType>(tex_obj, x, y, z, level);
}
template <typename TexelType>
__global__ void tex3DGradKernel(TexelType* const out, size_t N_x, size_t N_y, size_t N_z,
hipTextureObject_t tex_obj, size_t width, size_t height,
size_t depth, size_t num_subdivisions, bool normalized_coords,
float4 dx, float4 dy) {
const auto tid_x = blockIdx.x * blockDim.x + threadIdx.x;
if (tid_x >= N_x) return;
const auto tid_y = blockIdx.y * blockDim.y + threadIdx.y;
if (tid_y >= N_y) return;
const auto tid_z = blockIdx.z * blockDim.z + threadIdx.z;
if (tid_z >= N_z) return;
float x = GetCoordinate(tid_x, N_x, width, num_subdivisions, normalized_coords);
float y = GetCoordinate(tid_y, N_y, height, num_subdivisions, normalized_coords);
float z = GetCoordinate(tid_z, N_z, depth, num_subdivisions, normalized_coords);
out[tid_z * N_x * N_y + tid_y * N_x + tid_x] = tex3DGrad<TexelType>(tex_obj, x, y, z, dx, dy);
}
template <typename TexelType>
__global__ void texCubemapKernel(TexelType* const out, size_t N_x, size_t N_y, size_t N_z,
hipTextureObject_t tex_obj, size_t width, size_t height,
size_t depth, size_t num_subdivisions, bool normalized_coords) {
const auto tid_x = blockIdx.x * blockDim.x + threadIdx.x;
if (tid_x >= N_x) return;
const auto tid_y = blockIdx.y * blockDim.y + threadIdx.y;
if (tid_y >= N_y) return;
const auto tid_z = blockIdx.z * blockDim.z + threadIdx.z;
if (tid_z >= N_z) return;
float x = GetCoordinate(tid_x, N_x, width, num_subdivisions, normalized_coords);
float y = GetCoordinate(tid_y, N_y, height, num_subdivisions, normalized_coords);
float z = GetCoordinate(tid_z, N_z, depth, num_subdivisions, normalized_coords);
out[tid_z * N_x * N_y + tid_y * N_x + tid_x] = texCubemap<TexelType>(tex_obj, x, y, z);
}
template <typename TexelType>
__global__ void texCubemapLodKernel(TexelType* const out, size_t N_x, size_t N_y, size_t N_z,
hipTextureObject_t tex_obj, size_t width, size_t height,
size_t depth, size_t num_subdivisions, bool normalized_coords,
float level) {
const auto tid_x = blockIdx.x * blockDim.x + threadIdx.x;
if (tid_x >= N_x) return;
const auto tid_y = blockIdx.y * blockDim.y + threadIdx.y;
if (tid_y >= N_y) return;
const auto tid_z = blockIdx.z * blockDim.z + threadIdx.z;
if (tid_z >= N_z) return;
float x = GetCoordinate(tid_x, N_x, width, num_subdivisions, normalized_coords);
float y = GetCoordinate(tid_y, N_y, height, num_subdivisions, normalized_coords);
float z = GetCoordinate(tid_z, N_z, depth, num_subdivisions, normalized_coords);
out[tid_z * N_x * N_y + tid_y * N_x + tid_x] = texCubemapLod<TexelType>(tex_obj, x, y, z, level);
}
template <typename TexelType>
__global__ void texCubemapGradKernel(TexelType* const out, size_t N_x, size_t N_y, size_t N_z,
hipTextureObject_t tex_obj, size_t width, size_t height,
size_t depth, size_t num_subdivisions, bool normalized_coords,
float4 dx, float4 dy) {
const auto tid_x = blockIdx.x * blockDim.x + threadIdx.x;
if (tid_x >= N_x) return;
const auto tid_y = blockIdx.y * blockDim.y + threadIdx.y;
if (tid_y >= N_y) return;
const auto tid_z = blockIdx.z * blockDim.z + threadIdx.z;
if (tid_z >= N_z) return;
float x = GetCoordinate(tid_x, N_x, width, num_subdivisions, normalized_coords);
float y = GetCoordinate(tid_y, N_y, height, num_subdivisions, normalized_coords);
float z = GetCoordinate(tid_z, N_z, depth, num_subdivisions, normalized_coords);
out[tid_z * N_x * N_y + tid_y * N_x + tid_x] =
texCubemapGrad<TexelType>(tex_obj, x, y, z, dx, dy);
}
template <typename TexelType>
__global__ void tex1DLayeredKernel(TexelType* const out, size_t N, hipTextureObject_t tex_obj,
size_t width, size_t num_subdivisions, bool normalized_coords,
@@ -104,4 +344,71 @@ __global__ void tex2DLayeredKernel(TexelType* const out, size_t N_x, size_t N_y,
float y = GetCoordinate(tid_y, N_y, height, num_subdivisions, normalized_coords);
out[tid_y * N_x + tid_x] = tex2DLayered<TexelType>(tex_obj, x, y, layer);
}
template <typename TexelType>
__global__ void texCubemapLayeredKernel(TexelType* const out, size_t N_x, size_t N_y, size_t N_z,
hipTextureObject_t tex_obj, size_t width, size_t height,
size_t depth, size_t num_subdivisions,
bool normalized_coords, size_t layer) {
const auto tid_x = blockIdx.x * blockDim.x + threadIdx.x;
if (tid_x >= N_x) return;
const auto tid_y = blockIdx.y * blockDim.y + threadIdx.y;
if (tid_y >= N_y) return;
const auto tid_z = blockIdx.z * blockDim.z + threadIdx.z;
if (tid_z >= N_z) return;
float x = GetCoordinate(tid_x, N_x, width, num_subdivisions, normalized_coords);
float y = GetCoordinate(tid_y, N_y, height, num_subdivisions, normalized_coords);
float z = GetCoordinate(tid_z, N_z, depth, num_subdivisions, normalized_coords);
out[tid_z * N_x * N_y + tid_y * N_x + tid_x] =
texCubemapLayered<TexelType>(tex_obj, x, y, z, layer);
}
template <typename TexelType>
__global__ void texCubemapLayeredLodKernel(TexelType* const out, size_t N_x, size_t N_y, size_t N_z,
hipTextureObject_t tex_obj, size_t width, size_t height,
size_t depth, size_t num_subdivisions,
bool normalized_coords, size_t layer, float level) {
const auto tid_x = blockIdx.x * blockDim.x + threadIdx.x;
if (tid_x >= N_x) return;
const auto tid_y = blockIdx.y * blockDim.y + threadIdx.y;
if (tid_y >= N_y) return;
const auto tid_z = blockIdx.z * blockDim.z + threadIdx.z;
if (tid_z >= N_z) return;
float x = GetCoordinate(tid_x, N_x, width, num_subdivisions, normalized_coords);
float y = GetCoordinate(tid_y, N_y, height, num_subdivisions, normalized_coords);
float z = GetCoordinate(tid_z, N_z, depth, num_subdivisions, normalized_coords);
out[tid_z * N_x * N_y + tid_y * N_x + tid_x] =
texCubemapLayeredLod<TexelType>(tex_obj, x, y, z, layer, level);
}
template <typename TexelType>
__global__ void texCubemapLayeredGradKernel(TexelType* const out, size_t N_x, size_t N_y,
size_t N_z, hipTextureObject_t tex_obj, size_t width,
size_t height, size_t depth, size_t num_subdivisions,
bool normalized_coords, size_t layer, float4 dx,
float4 dy) {
const auto tid_x = blockIdx.x * blockDim.x + threadIdx.x;
if (tid_x >= N_x) return;
const auto tid_y = blockIdx.y * blockDim.y + threadIdx.y;
if (tid_y >= N_y) return;
const auto tid_z = blockIdx.z * blockDim.z + threadIdx.z;
if (tid_z >= N_z) return;
float x = GetCoordinate(tid_x, N_x, width, num_subdivisions, normalized_coords);
float y = GetCoordinate(tid_y, N_y, height, num_subdivisions, normalized_coords);
float z = GetCoordinate(tid_z, N_z, depth, num_subdivisions, normalized_coords);
out[tid_z * N_x * N_y + tid_y * N_x + tid_x] =
texCubemapLayeredGrad<TexelType>(tex_obj, x, y, z, layer, dx, dy);
}
+27 -6
Voir le fichier
@@ -34,6 +34,7 @@ template <typename TestType> struct TextureTestParams {
size_t layers;
size_t num_subdivisions;
hipTextureDesc tex_desc;
bool cubemap;
size_t Size() const {
return extent.width * (extent.height ?: 1) * (extent.depth ?: 1) * (layers ?: 1);
@@ -53,6 +54,10 @@ template <typename TestType> struct TextureTestParams {
size_t Depth() const { return extent.depth; }
unsigned int Flags() const {
return (Layered() ? hipArrayLayered : 0u) | (cubemap ? hipArrayCubemap : 0u);
}
hipExtent LayeredExtent() const {
return Layered() ? make_hipExtent(Width(), Height(), layers) : extent;
}
@@ -94,19 +99,25 @@ template <typename TestType> struct TextureTestParams {
tex_desc.addressMode[0] = address_mode_x;
if (extent.height) tex_desc.addressMode[1] = address_mode_y;
if (extent.depth) tex_desc.addressMode[2] = address_mode_z;
tex_desc.mipmapFilterMode = tex_desc.filterMode;
}
};
template <typename TestType, bool normalized_read = false> struct TextureTestFixture {
template <typename TestType, bool normalized_read = false, bool mipmap = false>
struct TextureTestFixture {
using VecType = vec4<TestType>;
using OutType = std::conditional_t<normalized_read, vec4<float>, VecType>;
template <typename T>
using ArrayAllocGuardType =
std::conditional_t<mipmap, MipmappedArrayAllocGuard<T>, ArrayAllocGuard<T>>;
TextureTestParams<TestType> params;
hipResourceDesc res_desc;
LinearAllocGuard<VecType> host_alloc;
TextureReference<VecType> tex_h;
ArrayAllocGuard<VecType> tex_alloc_d;
ArrayAllocGuardType<VecType> tex_alloc_d;
TextureGuard tex;
LinearAllocGuard<OutType> out_alloc_d;
std::vector<OutType> out_alloc_h;
@@ -115,7 +126,7 @@ template <typename TestType, bool normalized_read = false> struct TextureTestFix
: params{p},
host_alloc{LinearAllocs::hipHostMalloc, sizeof(VecType) * params.Size()},
tex_h{host_alloc.ptr(), params.extent, params.layers},
tex_alloc_d{params.LayeredExtent(), params.Layered() ? hipArrayLayered : 0u},
tex_alloc_d{params.LayeredExtent(), params.Flags()},
tex{ResDesc(), &params.tex_desc},
out_alloc_d{LinearAllocs::hipMalloc, sizeof(OutType) * params.NumIters()},
out_alloc_h(params.NumIters()) {}
@@ -127,7 +138,12 @@ template <typename TestType, bool normalized_read = false> struct TextureTestFix
}
hipMemcpy3DParms memcpy_params = {};
memcpy_params.dstArray = tex_alloc_d.ptr();
memset(&memcpy_params, 0, sizeof(hipMemcpy3DParms));
if constexpr (mipmap) {
memcpy_params.dstArray = tex_alloc_d.GetLevel(0);
} else {
memcpy_params.dstArray = tex_alloc_d.ptr();
}
memcpy_params.extent = params.LayeredExtent();
memcpy_params.extent.height = memcpy_params.extent.height ?: 1;
memcpy_params.extent.depth = memcpy_params.extent.depth ?: 1;
@@ -137,8 +153,13 @@ template <typename TestType, bool normalized_read = false> struct TextureTestFix
HIP_CHECK(hipMemcpy3D(&memcpy_params));
memset(&res_desc, 0, sizeof(res_desc));
res_desc.resType = hipResourceTypeArray;
res_desc.res.array.array = tex_alloc_d.ptr();
if constexpr (mipmap) {
res_desc.resType = hipResourceTypeMipmappedArray;
res_desc.res.mipmap.mipmap = tex_alloc_d.ptr();
} else {
res_desc.resType = hipResourceTypeArray;
res_desc.res.array.array = tex_alloc_d.ptr();
}
return &res_desc;
}
+139
Voir le fichier
@@ -0,0 +1,139 @@
/*
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 <hip_test_common.hh>
#include "kernels.hh"
#include "test_fixture.hh"
/**
* @addtogroup tex1D tex1D
* @{
* @ingroup TextureTest
*/
/**
* Test Description
* ------------------------
* - Test texture fetching with `tex1D` 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/tex1D.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
TEMPLATE_TEST_CASE("Unit_tex1D_Positive_ReadModeElementType", "", char, unsigned char, short,
unsigned short, int, unsigned int, float) {
CHECK_IMAGE_SUPPORT;
TextureTestParams<TestType> params = {};
params.extent = make_hipExtent(1024, 0, 0);
params.num_subdivisions = 4;
params.GenerateTextureDesc();
TextureTestFixture<TestType> fixture{params};
const auto [num_threads, num_blocks] = GetLaunchConfig(1024, params.NumItersX());
tex1DKernel<vec4<TestType>><<<num_blocks, num_threads>>>(
fixture.out_alloc_d.ptr(), params.NumItersX(), fixture.tex.object(), params.Width(),
params.num_subdivisions, params.tex_desc.normalizedCoords);
fixture.LoadOutput();
for (auto i = 0u; i < params.NumItersX(); ++i) {
float x = GetCoordinate(i, params.NumItersX(), params.Width(), params.num_subdivisions,
params.tex_desc.normalizedCoords);
INFO("Index: " << i);
INFO("Filtering mode: " << FilteringModeToString(params.tex_desc.filterMode));
INFO("Normalized coordinates: " << std::boolalpha << params.tex_desc.normalizedCoords);
INFO("Address mode: " << AddressModeToString(params.tex_desc.addressMode[0]));
INFO("x: " << std::fixed << std::setprecision(16) << x);
auto ref_val = fixture.tex_h.Tex1D(x, params.tex_desc);
REQUIRE(ref_val.x == fixture.out_alloc_h[i].x);
REQUIRE(ref_val.y == fixture.out_alloc_h[i].y);
REQUIRE(ref_val.z == fixture.out_alloc_h[i].z);
REQUIRE(ref_val.w == fixture.out_alloc_h[i].w);
}
}
/**
* Test Description
* ------------------------
* - Test texture fetching with `tex1D` 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/tex1D.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
TEMPLATE_TEST_CASE("Unit_tex1D_Positive_ReadModeNormalizedFloat", "", char, unsigned char, short,
unsigned short) {
CHECK_IMAGE_SUPPORT;
TextureTestParams<TestType> params = {};
params.extent = make_hipExtent(1024, 0, 0);
params.num_subdivisions = 4;
params.GenerateTextureDesc(hipReadModeNormalizedFloat);
TextureTestFixture<TestType, true> fixture{params};
const auto [num_threads, num_blocks] = GetLaunchConfig(1024, params.NumItersX());
tex1DKernel<vec4<float>><<<num_blocks, num_threads>>>(
fixture.out_alloc_d.ptr(), params.NumItersX(), fixture.tex.object(), params.Width(),
params.num_subdivisions, params.tex_desc.normalizedCoords);
fixture.LoadOutput();
for (auto i = 0u; i < params.NumItersX(); ++i) {
float x = GetCoordinate(i, params.NumItersX(), params.Width(), params.num_subdivisions,
params.tex_desc.normalizedCoords);
INFO("i: " << i);
INFO("Filtering mode: " << FilteringModeToString(params.tex_desc.filterMode));
INFO("Normalized coordinates: " << std::boolalpha << params.tex_desc.normalizedCoords);
INFO("Address mode: " << AddressModeToString(params.tex_desc.addressMode[0]));
INFO("x: " << std::fixed << std::setprecision(16) << x);
auto ref_val =
Vec4Map<TestType>(fixture.tex_h.Tex1D(x, params.tex_desc), NormalizeInteger<TestType>);
REQUIRE(ref_val.x == fixture.out_alloc_h[i].x);
REQUIRE(ref_val.y == fixture.out_alloc_h[i].y);
REQUIRE(ref_val.z == fixture.out_alloc_h[i].z);
REQUIRE(ref_val.w == fixture.out_alloc_h[i].w);
}
}
+139
Voir le fichier
@@ -0,0 +1,139 @@
/*
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 <hip_test_common.hh>
#include "kernels.hh"
#include "test_fixture.hh"
/**
* @addtogroup tex1DGrad tex1DGrad
* @{
* @ingroup TextureTest
*/
/**
* Test Description
* ------------------------
* - Test texture fetching with `tex1DGrad` 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/tex1DGrad.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.7
*/
TEMPLATE_TEST_CASE("Unit_tex1DGrad_Positive_ReadModeElementType", "", char, unsigned char, short,
unsigned short, int, unsigned int, float) {
CHECK_IMAGE_SUPPORT;
TextureTestParams<TestType> params = {};
params.extent = make_hipExtent(1024, 0, 0);
params.num_subdivisions = 4;
params.GenerateTextureDesc();
TextureTestFixture<TestType, false, true> fixture{params};
const auto [num_threads, num_blocks] = GetLaunchConfig(1024, params.NumItersX());
tex1DGradKernel<vec4<TestType>><<<num_blocks, num_threads>>>(
fixture.out_alloc_d.ptr(), params.NumItersX(), fixture.tex.object(), params.Width(),
params.num_subdivisions, params.tex_desc.normalizedCoords, 0.5f, 0.5f);
fixture.LoadOutput();
for (auto i = 0u; i < params.NumItersX(); ++i) {
float x = GetCoordinate(i, params.NumItersX(), params.Width(), params.num_subdivisions,
params.tex_desc.normalizedCoords);
INFO("Index: " << i);
INFO("Filtering mode: " << FilteringModeToString(params.tex_desc.filterMode));
INFO("Normalized coordinates: " << std::boolalpha << params.tex_desc.normalizedCoords);
INFO("Address mode: " << AddressModeToString(params.tex_desc.addressMode[0]));
INFO("x: " << std::fixed << std::setprecision(16) << x);
auto ref_val = fixture.tex_h.Tex1D(x, params.tex_desc);
REQUIRE(ref_val.x == fixture.out_alloc_h[i].x);
REQUIRE(ref_val.y == fixture.out_alloc_h[i].y);
REQUIRE(ref_val.z == fixture.out_alloc_h[i].z);
REQUIRE(ref_val.w == fixture.out_alloc_h[i].w);
}
}
/**
* Test Description
* ------------------------
* - Test texture fetching with `tex1DGrad` 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/tex1DGrad.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.7
*/
TEMPLATE_TEST_CASE("Unit_tex1DGrad_Positive_ReadModeNormalizedFloat", "", char, unsigned char,
short, unsigned short) {
CHECK_IMAGE_SUPPORT;
TextureTestParams<TestType> params = {};
params.extent = make_hipExtent(1024, 0, 0);
params.num_subdivisions = 4;
params.GenerateTextureDesc(hipReadModeNormalizedFloat);
TextureTestFixture<TestType, true, true> fixture{params};
const auto [num_threads, num_blocks] = GetLaunchConfig(1024, params.NumItersX());
tex1DGradKernel<vec4<float>><<<num_blocks, num_threads>>>(
fixture.out_alloc_d.ptr(), params.NumItersX(), fixture.tex.object(), params.Width(),
params.num_subdivisions, params.tex_desc.normalizedCoords, 0.5f, 0.5f);
fixture.LoadOutput();
for (auto i = 0u; i < params.NumItersX(); ++i) {
float x = GetCoordinate(i, params.NumItersX(), params.Width(), params.num_subdivisions,
params.tex_desc.normalizedCoords);
INFO("i: " << i);
INFO("Filtering mode: " << FilteringModeToString(params.tex_desc.filterMode));
INFO("Normalized coordinates: " << std::boolalpha << params.tex_desc.normalizedCoords);
INFO("Address mode: " << AddressModeToString(params.tex_desc.addressMode[0]));
INFO("x: " << std::fixed << std::setprecision(16) << x);
auto ref_val =
Vec4Map<TestType>(fixture.tex_h.Tex1D(x, params.tex_desc), NormalizeInteger<TestType>);
REQUIRE(ref_val.x == fixture.out_alloc_h[i].x);
REQUIRE(ref_val.y == fixture.out_alloc_h[i].y);
REQUIRE(ref_val.z == fixture.out_alloc_h[i].z);
REQUIRE(ref_val.w == fixture.out_alloc_h[i].w);
}
}
+149
Voir le fichier
@@ -0,0 +1,149 @@
/*
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 <hip_test_common.hh>
#include "kernels.hh"
#include "test_fixture.hh"
/**
* @addtogroup tex1DLayered tex1DLayered
* @{
* @ingroup TextureTest
*/
/**
* Test Description
* ------------------------
* - Test texture fetching with `tex1DLayered` 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/tex1DLayered.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
TEMPLATE_TEST_CASE("Unit_tex1DLayered_Positive_ReadModeElementType", "", char, unsigned char, short,
unsigned short, int, unsigned int, float) {
CHECK_IMAGE_SUPPORT;
TextureTestParams<TestType> params = {};
params.extent = make_hipExtent(1024, 0, 0);
params.layers = 2;
params.num_subdivisions = 4;
params.GenerateTextureDesc();
TextureTestFixture<TestType> fixture{params};
const auto [num_threads, num_blocks] = GetLaunchConfig(1024, params.NumItersX());
for (auto layer = 0u; layer < params.layers; ++layer) {
tex1DLayeredKernel<vec4<TestType>><<<num_blocks, num_threads>>>(
fixture.out_alloc_d.ptr(), params.NumItersX(), fixture.tex.object(), params.Width(),
params.num_subdivisions, params.tex_desc.normalizedCoords, layer);
fixture.LoadOutput();
for (auto i = 0u; i < params.NumItersX(); ++i) {
float x = GetCoordinate(i, params.NumItersX(), params.Width(), params.num_subdivisions,
params.tex_desc.normalizedCoords);
INFO("Layer: " << layer);
INFO("i: " << i);
INFO("Filtering mode: " << FilteringModeToString(params.tex_desc.filterMode));
INFO("Normalized coordinates: " << std::boolalpha << params.tex_desc.normalizedCoords);
INFO("Address mode: " << AddressModeToString(params.tex_desc.addressMode[0]));
INFO("x: " << std::fixed << std::setprecision(16) << x);
const auto ref_val = fixture.tex_h.Tex1DLayered(x, layer, params.tex_desc);
REQUIRE(ref_val.x == fixture.out_alloc_h[i].x);
REQUIRE(ref_val.y == fixture.out_alloc_h[i].y);
REQUIRE(ref_val.z == fixture.out_alloc_h[i].z);
REQUIRE(ref_val.w == fixture.out_alloc_h[i].w);
}
}
}
/**
* Test Description
* ------------------------
* - Test texture fetching with `tex1DLayered` 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/tex1DLayered.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
TEMPLATE_TEST_CASE("Unit_tex1DLayered_Positive_ReadModeNormalizedFloat", "", char, unsigned char,
short, unsigned short) {
CHECK_IMAGE_SUPPORT;
TextureTestParams<TestType> params = {};
params.extent = make_hipExtent(1024, 0, 0);
params.layers = 2;
params.num_subdivisions = 4;
params.GenerateTextureDesc(hipReadModeNormalizedFloat);
TextureTestFixture<TestType, true> fixture{params};
const auto [num_threads, num_blocks] = GetLaunchConfig(1024, params.NumItersX());
for (auto layer = 0u; layer < params.layers; ++layer) {
tex1DLayeredKernel<vec4<float>><<<num_blocks, num_threads>>>(
fixture.out_alloc_d.ptr(), params.NumItersX(), fixture.tex.object(), params.Width(),
params.num_subdivisions, params.tex_desc.normalizedCoords, layer);
fixture.LoadOutput();
for (auto i = 0u; i < params.NumItersX(); ++i) {
float x = GetCoordinate(i, params.NumItersX(), params.Width(), params.num_subdivisions,
params.tex_desc.normalizedCoords);
INFO("Layer: " << layer);
INFO("Index: " << i);
INFO("Filtering mode: " << FilteringModeToString(params.tex_desc.filterMode));
INFO("Normalized coordinates: " << std::boolalpha << params.tex_desc.normalizedCoords);
INFO("Address mode: " << AddressModeToString(params.tex_desc.addressMode[0]));
INFO("x: " << std::fixed << std::setprecision(16) << x);
auto ref_val = Vec4Map<TestType>(fixture.tex_h.Tex1DLayered(x, layer, params.tex_desc),
NormalizeInteger<TestType>);
REQUIRE(ref_val.x == fixture.out_alloc_h[i].x);
REQUIRE(ref_val.y == fixture.out_alloc_h[i].y);
REQUIRE(ref_val.z == fixture.out_alloc_h[i].z);
REQUIRE(ref_val.w == fixture.out_alloc_h[i].w);
}
}
}
+150
Voir le fichier
@@ -0,0 +1,150 @@
/*
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 <hip_test_common.hh>
#include "kernels.hh"
#include "test_fixture.hh"
/**
* @addtogroup tex1DLayeredGrad tex1DLayeredGrad
* @{
* @ingroup TextureTest
*/
/**
* Test Description
* ------------------------
* - Test texture fetching with `tex1DLayeredGrad` 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/tex1DLayeredGrad.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.7
*/
TEMPLATE_TEST_CASE("Unit_tex1DLayeredGrad_Positive_ReadModeElementType", "", char, unsigned char,
short, unsigned short, int, unsigned int, float) {
CHECK_IMAGE_SUPPORT;
TextureTestParams<TestType> params = {};
params.extent = make_hipExtent(1024, 0, 0);
params.layers = 2;
params.num_subdivisions = 4;
params.GenerateTextureDesc();
TextureTestFixture<TestType, false, true> fixture{params};
const auto [num_threads, num_blocks] = GetLaunchConfig(1024, params.NumItersX());
for (auto layer = 0u; layer < params.layers; ++layer) {
tex1DLayeredGradKernel<vec4<TestType>><<<num_blocks, num_threads>>>(
fixture.out_alloc_d.ptr(), params.NumItersX(), fixture.tex.object(), params.Width(),
params.num_subdivisions, params.tex_desc.normalizedCoords, layer, 0.5f, 0.5f);
fixture.LoadOutput();
for (auto i = 0u; i < params.NumItersX(); ++i) {
float x = GetCoordinate(i, params.NumItersX(), params.Width(), params.num_subdivisions,
params.tex_desc.normalizedCoords);
INFO("Layer: " << layer);
INFO("Index: " << i);
INFO("Filtering mode: " << FilteringModeToString(params.tex_desc.filterMode));
INFO("Normalized coordinates: " << std::boolalpha << params.tex_desc.normalizedCoords);
INFO("Address mode: " << AddressModeToString(params.tex_desc.addressMode[0]));
INFO("x: " << std::fixed << std::setprecision(16) << x);
auto ref_val = fixture.tex_h.Tex1DLayered(x, layer, params.tex_desc);
REQUIRE(ref_val.x == fixture.out_alloc_h[i].x);
REQUIRE(ref_val.y == fixture.out_alloc_h[i].y);
REQUIRE(ref_val.z == fixture.out_alloc_h[i].z);
REQUIRE(ref_val.w == fixture.out_alloc_h[i].w);
}
}
}
/**
* Test Description
* ------------------------
* - Test texture fetching with `tex1DLayeredGrad` 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/tex1DLayeredGrad.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.7
*/
TEMPLATE_TEST_CASE("Unit_tex1DLayeredGrad_Positive_ReadModeNormalizedFloat", "", char,
unsigned char, short, unsigned short) {
CHECK_IMAGE_SUPPORT;
TextureTestParams<TestType> params = {};
params.extent = make_hipExtent(1024, 0, 0);
params.layers = 2;
params.num_subdivisions = 4;
params.GenerateTextureDesc(hipReadModeNormalizedFloat);
TextureTestFixture<TestType, true, true> fixture{params};
const auto [num_threads, num_blocks] = GetLaunchConfig(1024, params.NumItersX());
for (auto layer = 0u; layer < params.layers; ++layer) {
tex1DLayeredGradKernel<vec4<float>><<<num_blocks, num_threads>>>(
fixture.out_alloc_d.ptr(), params.NumItersX(), fixture.tex.object(), params.Width(),
params.num_subdivisions, params.tex_desc.normalizedCoords, layer, 0.5f, 0.5f);
fixture.LoadOutput();
for (auto i = 0u; i < params.NumItersX(); ++i) {
float x = GetCoordinate(i, params.NumItersX(), params.Width(), params.num_subdivisions,
params.tex_desc.normalizedCoords);
INFO("Layer: " << layer);
INFO("i: " << i);
INFO("Filtering mode: " << FilteringModeToString(params.tex_desc.filterMode));
INFO("Normalized coordinates: " << std::boolalpha << params.tex_desc.normalizedCoords);
INFO("Address mode: " << AddressModeToString(params.tex_desc.addressMode[0]));
INFO("Filter mode: " << FilteringModeToString(params.tex_desc.filterMode));
INFO("x: " << std::fixed << std::setprecision(16) << x);
auto ref_val = Vec4Map<TestType>(fixture.tex_h.Tex1DLayered(x, layer, params.tex_desc),
NormalizeInteger<TestType>);
REQUIRE(ref_val.x == fixture.out_alloc_h[i].x);
REQUIRE(ref_val.y == fixture.out_alloc_h[i].y);
REQUIRE(ref_val.z == fixture.out_alloc_h[i].z);
REQUIRE(ref_val.w == fixture.out_alloc_h[i].w);
}
}
}
+149
Voir le fichier
@@ -0,0 +1,149 @@
/*
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 <hip_test_common.hh>
#include "kernels.hh"
#include "test_fixture.hh"
/**
* @addtogroup tex1DLayeredLod tex1DLayeredLod
* @{
* @ingroup TextureTest
*/
/**
* Test Description
* ------------------------
* - Test texture fetching with `tex1DLayeredLod` 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/tex1DLayeredLod.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.7
*/
TEMPLATE_TEST_CASE("Unit_tex1DLayeredLod_Positive_ReadModeElementType", "", char, unsigned char,
short, unsigned short, int, unsigned int, float) {
CHECK_IMAGE_SUPPORT;
TextureTestParams<TestType> params = {};
params.extent = make_hipExtent(1024, 0, 0);
params.layers = 2;
params.num_subdivisions = 4;
params.GenerateTextureDesc();
TextureTestFixture<TestType, false, true> fixture{params};
const auto [num_threads, num_blocks] = GetLaunchConfig(1024, params.NumItersX());
for (auto layer = 0u; layer < params.layers; ++layer) {
tex1DLayeredLodKernel<vec4<TestType>><<<num_blocks, num_threads>>>(
fixture.out_alloc_d.ptr(), params.NumItersX(), fixture.tex.object(), params.Width(),
params.num_subdivisions, params.tex_desc.normalizedCoords, layer, 0);
fixture.LoadOutput();
for (auto i = 0u; i < params.NumItersX(); ++i) {
float x = GetCoordinate(i, params.NumItersX(), params.Width(), params.num_subdivisions,
params.tex_desc.normalizedCoords);
INFO("Layer: " << layer);
INFO("Index: " << i);
INFO("Filtering mode: " << FilteringModeToString(params.tex_desc.filterMode));
INFO("Normalized coordinates: " << std::boolalpha << params.tex_desc.normalizedCoords);
INFO("Address mode: " << AddressModeToString(params.tex_desc.addressMode[0]));
INFO("x: " << std::fixed << std::setprecision(16) << x);
auto ref_val = fixture.tex_h.Tex1DLayered(x, layer, params.tex_desc);
REQUIRE(ref_val.x == fixture.out_alloc_h[i].x);
REQUIRE(ref_val.y == fixture.out_alloc_h[i].y);
REQUIRE(ref_val.z == fixture.out_alloc_h[i].z);
REQUIRE(ref_val.w == fixture.out_alloc_h[i].w);
}
}
}
/**
* Test Description
* ------------------------
* - Test texture fetching with `tex1DLayeredLod` 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/tex1DLayeredLod.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.7
*/
TEMPLATE_TEST_CASE("Unit_tex1DLayeredLod_Positive_ReadModeNormalizedFloat", "", char, unsigned char,
short, unsigned short) {
CHECK_IMAGE_SUPPORT;
TextureTestParams<TestType> params = {};
params.extent = make_hipExtent(1024, 0, 0);
params.layers = 2;
params.num_subdivisions = 4;
params.GenerateTextureDesc(hipReadModeNormalizedFloat);
TextureTestFixture<TestType, true, true> fixture{params};
const auto [num_threads, num_blocks] = GetLaunchConfig(1024, params.NumItersX());
for (auto layer = 0u; layer < params.layers; ++layer) {
tex1DLayeredLodKernel<vec4<float>><<<num_blocks, num_threads>>>(
fixture.out_alloc_d.ptr(), params.NumItersX(), fixture.tex.object(), params.Width(),
params.num_subdivisions, params.tex_desc.normalizedCoords, layer, 0);
fixture.LoadOutput();
for (auto i = 0u; i < params.NumItersX(); ++i) {
float x = GetCoordinate(i, params.NumItersX(), params.Width(), params.num_subdivisions,
params.tex_desc.normalizedCoords);
INFO("Layer: " << layer);
INFO("i: " << i);
INFO("Filtering mode: " << FilteringModeToString(params.tex_desc.filterMode));
INFO("Normalized coordinates: " << std::boolalpha << params.tex_desc.normalizedCoords);
INFO("Address mode: " << AddressModeToString(params.tex_desc.addressMode[0]));
INFO("x: " << std::fixed << std::setprecision(16) << x);
auto ref_val = Vec4Map<TestType>(fixture.tex_h.Tex1DLayered(x, layer, params.tex_desc),
NormalizeInteger<TestType>);
REQUIRE(ref_val.x == fixture.out_alloc_h[i].x);
REQUIRE(ref_val.y == fixture.out_alloc_h[i].y);
REQUIRE(ref_val.z == fixture.out_alloc_h[i].z);
REQUIRE(ref_val.w == fixture.out_alloc_h[i].w);
}
}
}
+139
Voir le fichier
@@ -0,0 +1,139 @@
/*
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 <hip_test_common.hh>
#include "kernels.hh"
#include "test_fixture.hh"
/**
* @addtogroup tex1DLod tex1DLod
* @{
* @ingroup TextureTest
*/
/**
* Test Description
* ------------------------
* - Test texture fetching with `tex1DLod` 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/tex1DLod.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.7
*/
TEMPLATE_TEST_CASE("Unit_tex1DLod_Positive_ReadModeElementType", "", char, unsigned char, short,
unsigned short, int, unsigned int, float) {
CHECK_IMAGE_SUPPORT;
TextureTestParams<TestType> params = {};
params.extent = make_hipExtent(1024, 0, 0);
params.num_subdivisions = 4;
params.GenerateTextureDesc();
TextureTestFixture<TestType, false, true> fixture{params};
const auto [num_threads, num_blocks] = GetLaunchConfig(1024, params.NumItersX());
tex1DLodKernel<vec4<TestType>><<<num_blocks, num_threads>>>(
fixture.out_alloc_d.ptr(), params.NumItersX(), fixture.tex.object(), params.Width(),
params.num_subdivisions, params.tex_desc.normalizedCoords, 0);
fixture.LoadOutput();
for (auto i = 0u; i < params.NumItersX(); ++i) {
float x = GetCoordinate(i, params.NumItersX(), params.Width(), params.num_subdivisions,
params.tex_desc.normalizedCoords);
INFO("Index: " << i);
INFO("Filtering mode: " << FilteringModeToString(params.tex_desc.filterMode));
INFO("Normalized coordinates: " << std::boolalpha << params.tex_desc.normalizedCoords);
INFO("Address mode: " << AddressModeToString(params.tex_desc.addressMode[0]));
INFO("x: " << std::fixed << std::setprecision(16) << x);
auto ref_val = fixture.tex_h.Tex1D(x, params.tex_desc);
REQUIRE(ref_val.x == fixture.out_alloc_h[i].x);
REQUIRE(ref_val.y == fixture.out_alloc_h[i].y);
REQUIRE(ref_val.z == fixture.out_alloc_h[i].z);
REQUIRE(ref_val.w == fixture.out_alloc_h[i].w);
}
}
/**
* Test Description
* ------------------------
* - Test texture fetching with `tex1DLod` 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/tex1DLod.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.7
*/
TEMPLATE_TEST_CASE("Unit_tex1DLod_Positive_ReadModeNormalizedFloat", "", char, unsigned char, short,
unsigned short) {
CHECK_IMAGE_SUPPORT;
TextureTestParams<TestType> params = {};
params.extent = make_hipExtent(1024, 0, 0);
params.num_subdivisions = 4;
params.GenerateTextureDesc(hipReadModeNormalizedFloat);
TextureTestFixture<TestType, true, true> fixture{params};
const auto [num_threads, num_blocks] = GetLaunchConfig(1024, params.NumItersX());
tex1DLodKernel<vec4<float>><<<num_blocks, num_threads>>>(
fixture.out_alloc_d.ptr(), params.NumItersX(), fixture.tex.object(), params.Width(),
params.num_subdivisions, params.tex_desc.normalizedCoords, 0);
fixture.LoadOutput();
for (auto i = 0u; i < params.NumItersX(); ++i) {
float x = GetCoordinate(i, params.NumItersX(), params.Width(), params.num_subdivisions,
params.tex_desc.normalizedCoords);
INFO("i: " << i);
INFO("Filtering mode: " << FilteringModeToString(params.tex_desc.filterMode));
INFO("Normalized coordinates: " << std::boolalpha << params.tex_desc.normalizedCoords);
INFO("Address mode: " << AddressModeToString(params.tex_desc.addressMode[0]));
INFO("x: " << std::fixed << std::setprecision(16) << x);
auto ref_val =
Vec4Map<TestType>(fixture.tex_h.Tex1D(x, params.tex_desc), NormalizeInteger<TestType>);
REQUIRE(ref_val.x == fixture.out_alloc_h[i].x);
REQUIRE(ref_val.y == fixture.out_alloc_h[i].y);
REQUIRE(ref_val.z == fixture.out_alloc_h[i].z);
REQUIRE(ref_val.w == fixture.out_alloc_h[i].w);
}
}
+162
Voir le fichier
@@ -0,0 +1,162 @@
/*
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 <vector>
#include <hip_test_common.hh>
#include <resource_guards.hh>
#include "kernels.hh"
#include "utils.hh"
#include "vec4.hh"
/**
* @addtogroup tex1D tex1D
* @{
* @ingroup TextureTest
*/
/**
* Test Description
* ------------------------
* - Test texture fetching with `tex1Dfetch` and read mode set to `hipReadModeElementType`.
* Test source
* ------------------------
* - unit/texture/tex1Dfetch.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
TEMPLATE_TEST_CASE("Unit_tex1Dfetch_Positive_ReadModeElementType", "", char, unsigned char, short,
unsigned short, int, unsigned int, float) {
CHECK_IMAGE_SUPPORT;
std::vector<vec4<TestType>> tex_h(1024);
for (auto i = 0u; i < tex_h.size(); ++i) {
tex_h[i].x = i + 7;
tex_h[i].y = i + 7;
tex_h[i].z = i + 7;
tex_h[i].w = i + 7;
}
const auto alloc_size = tex_h.size() * sizeof(vec4<TestType>);
LinearAllocGuard<vec4<TestType>> tex_alloc_d(LinearAllocs::hipMalloc, alloc_size);
HIP_CHECK(hipMemcpy(tex_alloc_d.ptr(), tex_h.data(), alloc_size, hipMemcpyHostToDevice));
hipResourceDesc res_desc;
memset(&res_desc, 0, sizeof(res_desc));
res_desc.resType = hipResourceTypeLinear;
res_desc.res.linear.devPtr = tex_alloc_d.ptr();
res_desc.res.linear.desc = hipCreateChannelDesc<vec4<TestType>>();
res_desc.res.linear.sizeInBytes = alloc_size;
hipTextureDesc tex_desc;
memset(&tex_desc, 0, sizeof(tex_desc));
tex_desc.filterMode = hipFilterModePoint;
tex_desc.readMode = hipReadModeElementType;
tex_desc.normalizedCoords = false;
tex_desc.addressMode[0] = hipAddressModeClamp;
LinearAllocGuard<vec4<TestType>> out_alloc_d(LinearAllocs::hipMalloc, alloc_size);
TextureGuard tex(&res_desc, &tex_desc);
const auto num_threads = std::min<size_t>(1024, tex_h.size());
const auto num_blocks = (tex_h.size() + num_threads - 1) / num_threads;
tex1DfetchKernel<vec4<TestType>>
<<<num_blocks, num_threads>>>(out_alloc_d.ptr(), tex_h.size(), tex.object());
std::vector<vec4<TestType>> out_alloc_h(tex_h.size());
HIP_CHECK(hipMemcpy(out_alloc_h.data(), out_alloc_d.ptr(), alloc_size, hipMemcpyDeviceToHost));
HIP_CHECK(hipDeviceSynchronize());
for (auto i = 0u; i < out_alloc_h.size(); ++i) {
INFO("Index: " << i);
const auto ref_val = tex_h[i];
REQUIRE(ref_val.x == out_alloc_h[i].x);
REQUIRE(ref_val.y == out_alloc_h[i].y);
REQUIRE(ref_val.z == out_alloc_h[i].z);
REQUIRE(ref_val.w == out_alloc_h[i].w);
}
}
/**
* Test Description
* ------------------------
* - Test texture fetching with `tex1Dfetch` and read mode set to `hipReadModeNormalizedFloat`.
* Test source
* ------------------------
* - unit/texture/tex1Dfetch.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
TEMPLATE_TEST_CASE("Unit_tex1Dfetch_Positive_ReadModeNormalizedFloat", "", char, unsigned char,
short, unsigned short) {
CHECK_IMAGE_SUPPORT;
std::vector<vec4<TestType>> tex_h(1024);
for (auto i = 0u; i < tex_h.size(); ++i) {
tex_h[i].x = i + 7;
tex_h[i].y = i + 7;
tex_h[i].z = i + 7;
tex_h[i].w = i + 7;
}
const auto alloc_size = tex_h.size() * sizeof(vec4<TestType>);
LinearAllocGuard<vec4<TestType>> tex_alloc_d(LinearAllocs::hipMalloc, alloc_size);
HIP_CHECK(hipMemcpy(tex_alloc_d.ptr(), tex_h.data(), alloc_size, hipMemcpyHostToDevice));
hipResourceDesc res_desc;
memset(&res_desc, 0, sizeof(res_desc));
res_desc.resType = hipResourceTypeLinear;
res_desc.res.linear.devPtr = tex_alloc_d.ptr();
res_desc.res.linear.desc = hipCreateChannelDesc<vec4<TestType>>();
res_desc.res.linear.sizeInBytes = alloc_size;
hipTextureDesc tex_desc;
memset(&tex_desc, 0, sizeof(tex_desc));
tex_desc.filterMode = hipFilterModePoint;
tex_desc.readMode = hipReadModeElementType;
tex_desc.normalizedCoords = false;
tex_desc.addressMode[0] = hipAddressModeClamp;
LinearAllocGuard<vec4<float>> out_alloc_d(LinearAllocs::hipMalloc, alloc_size);
TextureGuard tex(&res_desc, &tex_desc);
const auto num_threads = std::min<size_t>(1024, tex_h.size());
const auto num_blocks = (tex_h.size() + num_threads - 1) / num_threads;
tex1DfetchKernel<vec4<float>>
<<<num_blocks, num_threads>>>(out_alloc_d.ptr(), tex_h.size(), tex.object());
std::vector<vec4<float>> out_alloc_h(tex_h.size());
HIP_CHECK(hipMemcpy(out_alloc_h.data(), out_alloc_d.ptr(), alloc_size, hipMemcpyDeviceToHost));
HIP_CHECK(hipDeviceSynchronize());
for (auto i = 0u; i < out_alloc_h.size(); ++i) {
INFO("Index: " << i);
const auto ref_val = Vec4Map<TestType>(tex_h[i], NormalizeInteger<TestType>);
REQUIRE(ref_val.x == out_alloc_h[i].x);
REQUIRE(ref_val.y == out_alloc_h[i].y);
REQUIRE(ref_val.z == out_alloc_h[i].z);
REQUIRE(ref_val.w == out_alloc_h[i].w);
}
}
+173
Voir le fichier
@@ -0,0 +1,173 @@
/*
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 <hip_test_common.hh>
#include "kernels.hh"
#include "test_fixture.hh"
/**
* @addtogroup tex2D tex2D
* @{
* @ingroup TextureTest
*/
/**
* Test Description
* ------------------------
* - Test texture fetching with `tex2D` 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/tex2D.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
TEMPLATE_TEST_CASE("Unit_tex2D_Positive_ReadModeElementType", "", char, unsigned char, short,
unsigned short, int, unsigned int, float) {
CHECK_IMAGE_SUPPORT;
TextureTestParams<TestType> params = {};
params.extent = make_hipExtent(16, 4, 0);
params.num_subdivisions = 4;
params.GenerateTextureDesc();
TextureTestFixture<TestType> fixture{params};
const auto [num_threads_x, num_blocks_x] = GetLaunchConfig(32, params.NumItersX());
const auto [num_threads_y, num_blocks_y] = GetLaunchConfig(32, params.NumItersY());
dim3 dim_grid;
dim_grid.x = num_blocks_x;
dim_grid.y = num_blocks_y;
dim3 dim_block;
dim_block.x = num_threads_x;
dim_block.y = num_threads_y;
tex2DKernel<vec4<TestType>><<<dim_grid, dim_block>>>(
fixture.out_alloc_d.ptr(), params.NumItersX(), params.NumItersY(), fixture.tex.object(),
params.Width(), params.Height(), params.num_subdivisions, params.tex_desc.normalizedCoords);
HIP_CHECK(hipGetLastError());
fixture.LoadOutput();
for (auto i = 0u; i < params.NumItersX() * params.NumItersY(); ++i) {
float x = i % params.NumItersX();
float y = i / params.NumItersX();
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);
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("x: " << std::fixed << std::setprecision(16) << x);
INFO("y: " << std::fixed << std::setprecision(16) << y);
const auto ref_val = fixture.tex_h.Tex2D(x, y, params.tex_desc);
REQUIRE(ref_val.x == fixture.out_alloc_h[i].x);
REQUIRE(ref_val.y == fixture.out_alloc_h[i].y);
REQUIRE(ref_val.z == fixture.out_alloc_h[i].z);
REQUIRE(ref_val.w == fixture.out_alloc_h[i].w);
}
}
/**
* Test Description
* ------------------------
* - Test texture fetching with `tex2D` 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/tex2D.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
TEMPLATE_TEST_CASE("Unit_tex2D_Positive_ReadModeNormalizedFloat", "", char, unsigned char, short,
unsigned short) {
CHECK_IMAGE_SUPPORT;
TextureTestParams<TestType> params = {};
params.extent = make_hipExtent(16, 4, 0);
params.num_subdivisions = 4;
params.GenerateTextureDesc(hipReadModeNormalizedFloat);
TextureTestFixture<TestType, true> fixture{params};
const auto [num_threads_x, num_blocks_x] = GetLaunchConfig(32, params.NumItersX());
const auto [num_threads_y, num_blocks_y] = GetLaunchConfig(32, params.NumItersY());
dim3 dim_grid;
dim_grid.x = num_blocks_x;
dim_grid.y = num_blocks_y;
dim3 dim_block;
dim_block.x = num_threads_x;
dim_block.y = num_threads_y;
tex2DKernel<vec4<float>><<<dim_grid, dim_block>>>(
fixture.out_alloc_d.ptr(), params.NumItersX(), params.NumItersY(), fixture.tex.object(),
params.Width(), params.Height(), params.num_subdivisions, params.tex_desc.normalizedCoords);
HIP_CHECK(hipGetLastError());
fixture.LoadOutput();
for (auto i = 0u; i < params.NumItersX() * params.NumItersY(); ++i) {
float x = i % params.NumItersX();
float y = i / 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);
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("x: " << std::fixed << std::setprecision(16) << x);
INFO("y: " << std::fixed << std::setprecision(16) << y);
auto ref_val =
Vec4Map<TestType>(fixture.tex_h.Tex2D(x, y, params.tex_desc), NormalizeInteger<TestType>);
REQUIRE(ref_val.x == fixture.out_alloc_h[i].x);
REQUIRE(ref_val.y == fixture.out_alloc_h[i].y);
REQUIRE(ref_val.z == fixture.out_alloc_h[i].z);
REQUIRE(ref_val.w == fixture.out_alloc_h[i].w);
}
}
+175
Voir le fichier
@@ -0,0 +1,175 @@
/*
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 <hip_test_common.hh>
#include "kernels.hh"
#include "test_fixture.hh"
/**
* @addtogroup tex2DGrad tex2DGrad
* @{
* @ingroup TextureTest
*/
/**
* Test Description
* ------------------------
* - Test texture fetching with `tex2DGrad` 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/tex2DGrad.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.7
*/
TEMPLATE_TEST_CASE("Unit_tex2DGrad_Positive_ReadModeElementType", "", char, unsigned char, short,
unsigned short, int, unsigned int, float) {
CHECK_IMAGE_SUPPORT;
TextureTestParams<TestType> params = {};
params.extent = make_hipExtent(16, 4, 0);
params.num_subdivisions = 4;
params.GenerateTextureDesc();
TextureTestFixture<TestType, false, true> fixture{params};
const auto [num_threads_x, num_blocks_x] = GetLaunchConfig(32, params.NumItersX());
const auto [num_threads_y, num_blocks_y] = GetLaunchConfig(32, params.NumItersY());
dim3 dim_grid;
dim_grid.x = num_blocks_x;
dim_grid.y = num_blocks_y;
dim3 dim_block;
dim_block.x = num_threads_x;
dim_block.y = num_threads_y;
tex2DGradKernel<vec4<TestType>><<<dim_grid, dim_block>>>(
fixture.out_alloc_d.ptr(), params.NumItersX(), params.NumItersY(), fixture.tex.object(),
params.Width(), params.Height(), params.num_subdivisions, params.tex_desc.normalizedCoords,
float2{0.5f, 0.5f}, float2{0.5f, 0.5f});
HIP_CHECK(hipGetLastError());
fixture.LoadOutput();
for (auto i = 0u; i < params.NumItersX() * params.NumItersY(); ++i) {
float x = i % params.NumItersX();
float y = i / params.NumItersX();
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);
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("x: " << std::fixed << std::setprecision(16) << x);
INFO("y: " << std::fixed << std::setprecision(16) << y);
const auto ref_val = fixture.tex_h.Tex2D(x, y, params.tex_desc);
REQUIRE(ref_val.x == fixture.out_alloc_h[i].x);
REQUIRE(ref_val.y == fixture.out_alloc_h[i].y);
REQUIRE(ref_val.z == fixture.out_alloc_h[i].z);
REQUIRE(ref_val.w == fixture.out_alloc_h[i].w);
}
}
/**
* Test Description
* ------------------------
* - Test texture fetching with `tex2DGrad` 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/tex2DGrad.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.7
*/
TEMPLATE_TEST_CASE("Unit_tex2DGrad_Positive_ReadModeNormalizedFloat", "", char, unsigned char,
short, unsigned short) {
CHECK_IMAGE_SUPPORT;
TextureTestParams<TestType> params = {};
params.extent = make_hipExtent(16, 4, 0);
params.num_subdivisions = 4;
params.GenerateTextureDesc(hipReadModeNormalizedFloat);
TextureTestFixture<TestType, true, true> fixture{params};
const auto [num_threads_x, num_blocks_x] = GetLaunchConfig(32, params.NumItersX());
const auto [num_threads_y, num_blocks_y] = GetLaunchConfig(32, params.NumItersY());
dim3 dim_grid;
dim_grid.x = num_blocks_x;
dim_grid.y = num_blocks_y;
dim3 dim_block;
dim_block.x = num_threads_x;
dim_block.y = num_threads_y;
tex2DGradKernel<vec4<float>><<<dim_grid, dim_block>>>(
fixture.out_alloc_d.ptr(), params.NumItersX(), params.NumItersY(), fixture.tex.object(),
params.Width(), params.Height(), params.num_subdivisions, params.tex_desc.normalizedCoords,
float2{0.5f, 0.5f}, float2{0.5f, 0.5f});
HIP_CHECK(hipGetLastError());
fixture.LoadOutput();
for (auto i = 0u; i < params.NumItersX() * params.NumItersY(); ++i) {
float x = i % params.NumItersX();
float y = i / params.NumItersX();
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);
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("x: " << std::fixed << std::setprecision(16) << x);
INFO("y: " << std::fixed << std::setprecision(16) << y);
auto ref_val =
Vec4Map<TestType>(fixture.tex_h.Tex2D(x, y, params.tex_desc), NormalizeInteger<TestType>);
REQUIRE(ref_val.x == fixture.out_alloc_h[i].x);
REQUIRE(ref_val.y == fixture.out_alloc_h[i].y);
REQUIRE(ref_val.z == fixture.out_alloc_h[i].z);
REQUIRE(ref_val.w == fixture.out_alloc_h[i].w);
}
}
+183
Voir le fichier
@@ -0,0 +1,183 @@
/*
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 <hip_test_common.hh>
#include "kernels.hh"
#include "test_fixture.hh"
/**
* @addtogroup tex2DLayered tex2DLayered
* @{
* @ingroup TextureTest
*/
/**
* Test Description
* ------------------------
* - Test texture fetching with `tex2DLayered` 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/tex2DLayered.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
TEMPLATE_TEST_CASE("Unit_tex2DLayered_Positive_ReadModeElementType", "", char, unsigned char, short,
unsigned short, int, unsigned int, float) {
CHECK_IMAGE_SUPPORT;
TextureTestParams<TestType> params = {};
params.extent = make_hipExtent(16, 4, 0);
params.layers = 2;
params.num_subdivisions = 4;
params.GenerateTextureDesc();
TextureTestFixture<TestType> fixture{params};
const auto [num_threads_x, num_blocks_x] = GetLaunchConfig(32, params.NumItersX());
const auto [num_threads_y, num_blocks_y] = GetLaunchConfig(32, params.NumItersY());
dim3 dim_grid;
dim_grid.x = num_blocks_x;
dim_grid.y = num_blocks_y;
dim3 dim_block;
dim_block.x = num_threads_x;
dim_block.y = num_threads_y;
for (auto layer = 0u; layer < params.layers; ++layer) {
tex2DLayeredKernel<vec4<TestType>>
<<<dim_grid, dim_block>>>(fixture.out_alloc_d.ptr(), params.NumItersX(), params.NumItersY(),
fixture.tex.object(), params.Width(), params.Height(),
params.num_subdivisions, params.tex_desc.normalizedCoords, layer);
HIP_CHECK(hipGetLastError());
fixture.LoadOutput();
for (auto i = 0u; i < params.NumItersX() * params.NumItersY(); ++i) {
float x = i % params.NumItersX();
float y = i / params.NumItersX();
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);
INFO("Layer: " << layer);
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("x: " << std::fixed << std::setprecision(16) << x);
INFO("y: " << std::fixed << std::setprecision(16) << y);
const auto ref_val = fixture.tex_h.Tex2DLayered(x, y, layer, params.tex_desc);
REQUIRE(ref_val.x == fixture.out_alloc_h[i].x);
REQUIRE(ref_val.y == fixture.out_alloc_h[i].y);
REQUIRE(ref_val.z == fixture.out_alloc_h[i].z);
REQUIRE(ref_val.w == fixture.out_alloc_h[i].w);
}
}
}
/**
* Test Description
* ------------------------
* - Test texture fetching with `tex2DLayered` 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/tex2DLayered.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
TEMPLATE_TEST_CASE("Unit_tex2DLayered_Positive_ReadModeNormalizedFloat", "", char, unsigned char,
short, unsigned short) {
CHECK_IMAGE_SUPPORT;
TextureTestParams<TestType> params = {};
params.extent = make_hipExtent(16, 4, 0);
params.layers = 2;
params.num_subdivisions = 4;
params.GenerateTextureDesc(hipReadModeNormalizedFloat);
TextureTestFixture<TestType, true> fixture{params};
const auto [num_threads_x, num_blocks_x] = GetLaunchConfig(32, params.NumItersX());
const auto [num_threads_y, num_blocks_y] = GetLaunchConfig(32, params.NumItersY());
dim3 dim_grid;
dim_grid.x = num_blocks_x;
dim_grid.y = num_blocks_y;
dim3 dim_block;
dim_block.x = num_threads_x;
dim_block.y = num_threads_y;
for (auto layer = 0u; layer < params.layers; ++layer) {
tex2DLayeredKernel<vec4<float>>
<<<dim_grid, dim_block>>>(fixture.out_alloc_d.ptr(), params.NumItersX(), params.NumItersY(),
fixture.tex.object(), params.Width(), params.Height(),
params.num_subdivisions, params.tex_desc.normalizedCoords, layer);
HIP_CHECK(hipGetLastError());
fixture.LoadOutput();
for (auto i = 0u; i < params.NumItersX() * params.NumItersY(); ++i) {
float x = i % params.NumItersX();
float y = i / params.NumItersX();
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);
INFO("Layer: " << layer);
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("x: " << std::fixed << std::setprecision(16) << x);
INFO("y: " << std::fixed << std::setprecision(16) << y);
auto ref_val = Vec4Map<TestType>(fixture.tex_h.Tex2DLayered(x, y, layer, params.tex_desc),
NormalizeInteger<TestType>);
REQUIRE(ref_val.x == fixture.out_alloc_h[i].x);
REQUIRE(ref_val.y == fixture.out_alloc_h[i].y);
REQUIRE(ref_val.z == fixture.out_alloc_h[i].z);
REQUIRE(ref_val.w == fixture.out_alloc_h[i].w);
}
}
}
+183
Voir le fichier
@@ -0,0 +1,183 @@
/*
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 <hip_test_common.hh>
#include "kernels.hh"
#include "test_fixture.hh"
/**
* @addtogroup tex2DLayeredGrad tex2DLayeredGrad
* @{
* @ingroup TextureTest
*/
/**
* Test Description
* ------------------------
* - Test texture fetching with `tex2DLayeredGrad` 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/tex2DLayeredGrad.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.7
*/
TEMPLATE_TEST_CASE("Unit_tex2DLayeredGrad_Positive_ReadModeElementType", "", char, unsigned char,
short, unsigned short, int, unsigned int, float) {
CHECK_IMAGE_SUPPORT;
TextureTestParams<TestType> params = {};
params.extent = make_hipExtent(16, 4, 0);
params.layers = 2;
params.num_subdivisions = 4;
params.GenerateTextureDesc();
TextureTestFixture<TestType, false, true> fixture{params};
const auto [num_threads_x, num_blocks_x] = GetLaunchConfig(32, params.NumItersX());
const auto [num_threads_y, num_blocks_y] = GetLaunchConfig(32, params.NumItersY());
dim3 dim_grid;
dim_grid.x = num_blocks_x;
dim_grid.y = num_blocks_y;
dim3 dim_block;
dim_block.x = num_threads_x;
dim_block.y = num_threads_y;
for (auto layer = 0u; layer < params.layers; ++layer) {
tex2DLayeredGradKernel<vec4<TestType>><<<dim_grid, dim_block>>>(
fixture.out_alloc_d.ptr(), params.NumItersX(), params.NumItersY(), fixture.tex.object(),
params.Width(), params.Height(), params.num_subdivisions, params.tex_desc.normalizedCoords,
layer, float2{0.5f, 0.5f}, float2{0.5f, 0.5f});
HIP_CHECK(hipGetLastError());
fixture.LoadOutput();
for (auto i = 0u; i < params.NumItersX() * params.NumItersY(); ++i) {
float x = i % params.NumItersX();
float y = i / params.NumItersX();
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);
INFO("Layer: " << layer);
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("x: " << std::fixed << std::setprecision(16) << x);
INFO("y: " << std::fixed << std::setprecision(16) << y);
const auto ref_val = fixture.tex_h.Tex2DLayered(x, y, layer, params.tex_desc);
REQUIRE(ref_val.x == fixture.out_alloc_h[i].x);
REQUIRE(ref_val.y == fixture.out_alloc_h[i].y);
REQUIRE(ref_val.z == fixture.out_alloc_h[i].z);
REQUIRE(ref_val.w == fixture.out_alloc_h[i].w);
}
}
}
/**
* Test Description
* ------------------------
* - Test texture fetching with `tex2DLayeredGrad` 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/tex2DLayeredGrad.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.7
*/
TEMPLATE_TEST_CASE("Unit_tex2DLayeredGrad_Positive_ReadModeNormalizedFloat", "", char,
unsigned char, short, unsigned short) {
CHECK_IMAGE_SUPPORT;
TextureTestParams<TestType> params = {};
params.extent = make_hipExtent(16, 4, 0);
params.layers = 2;
params.num_subdivisions = 4;
params.GenerateTextureDesc(hipReadModeNormalizedFloat);
TextureTestFixture<TestType, true, true> fixture{params};
const auto [num_threads_x, num_blocks_x] = GetLaunchConfig(32, params.NumItersX());
const auto [num_threads_y, num_blocks_y] = GetLaunchConfig(32, params.NumItersY());
dim3 dim_grid;
dim_grid.x = num_blocks_x;
dim_grid.y = num_blocks_y;
dim3 dim_block;
dim_block.x = num_threads_x;
dim_block.y = num_threads_y;
for (auto layer = 0u; layer < params.layers; ++layer) {
tex2DLayeredGradKernel<vec4<float>><<<dim_grid, dim_block>>>(
fixture.out_alloc_d.ptr(), params.NumItersX(), params.NumItersY(), fixture.tex.object(),
params.Width(), params.Height(), params.num_subdivisions, params.tex_desc.normalizedCoords,
layer, float2{0.5f, 0.5f}, float2{0.5f, 0.5f});
HIP_CHECK(hipGetLastError());
fixture.LoadOutput();
for (auto i = 0u; i < params.NumItersX() * params.NumItersY(); ++i) {
float x = i % params.NumItersX();
float y = i / params.NumItersX();
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);
INFO("Layer: " << layer);
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("x: " << std::fixed << std::setprecision(16) << x);
INFO("y: " << std::fixed << std::setprecision(16) << y);
auto ref_val = Vec4Map<TestType>(fixture.tex_h.Tex2DLayered(x, y, layer, params.tex_desc),
NormalizeInteger<TestType>);
REQUIRE(ref_val.x == fixture.out_alloc_h[i].x);
REQUIRE(ref_val.y == fixture.out_alloc_h[i].y);
REQUIRE(ref_val.z == fixture.out_alloc_h[i].z);
REQUIRE(ref_val.w == fixture.out_alloc_h[i].w);
}
}
}
+183
Voir le fichier
@@ -0,0 +1,183 @@
/*
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 <hip_test_common.hh>
#include "kernels.hh"
#include "test_fixture.hh"
/**
* @addtogroup tex2DLayeredLod tex2DLayeredLod
* @{
* @ingroup TextureTest
*/
/**
* Test Description
* ------------------------
* - Test texture fetching with `tex2DLayeredLod` 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/tex2DLayeredLod.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.7
*/
TEMPLATE_TEST_CASE("Unit_tex2DLayeredLod_Positive_ReadModeElementType", "", char, unsigned char,
short, unsigned short, int, unsigned int, float) {
CHECK_IMAGE_SUPPORT;
TextureTestParams<TestType> params = {};
params.extent = make_hipExtent(16, 4, 0);
params.layers = 2;
params.num_subdivisions = 4;
params.GenerateTextureDesc();
TextureTestFixture<TestType, false, true> fixture{params};
const auto [num_threads_x, num_blocks_x] = GetLaunchConfig(32, params.NumItersX());
const auto [num_threads_y, num_blocks_y] = GetLaunchConfig(32, params.NumItersY());
dim3 dim_grid;
dim_grid.x = num_blocks_x;
dim_grid.y = num_blocks_y;
dim3 dim_block;
dim_block.x = num_threads_x;
dim_block.y = num_threads_y;
for (auto layer = 0u; layer < params.layers; ++layer) {
tex2DLayeredLodKernel<vec4<TestType>><<<dim_grid, dim_block>>>(
fixture.out_alloc_d.ptr(), params.NumItersX(), params.NumItersY(), fixture.tex.object(),
params.Width(), params.Height(), params.num_subdivisions, params.tex_desc.normalizedCoords,
layer, 0);
HIP_CHECK(hipGetLastError());
fixture.LoadOutput();
for (auto i = 0u; i < params.NumItersX() * params.NumItersY(); ++i) {
float x = i % params.NumItersX();
float y = i / params.NumItersX();
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);
INFO("Layer: " << layer);
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("x: " << std::fixed << std::setprecision(16) << x);
INFO("y: " << std::fixed << std::setprecision(16) << y);
const auto ref_val = fixture.tex_h.Tex2DLayered(x, y, layer, params.tex_desc);
REQUIRE(ref_val.x == fixture.out_alloc_h[i].x);
REQUIRE(ref_val.y == fixture.out_alloc_h[i].y);
REQUIRE(ref_val.z == fixture.out_alloc_h[i].z);
REQUIRE(ref_val.w == fixture.out_alloc_h[i].w);
}
}
}
/**
* Test Description
* ------------------------
* - Test texture fetching with `tex2DLayeredLod` 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/tex2DLayeredLod.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.7
*/
TEMPLATE_TEST_CASE("Unit_tex2DLayeredLod_Positive_ReadModeNormalizedFloat", "", char, unsigned char,
short, unsigned short) {
CHECK_IMAGE_SUPPORT;
TextureTestParams<TestType> params = {};
params.extent = make_hipExtent(16, 4, 0);
params.layers = 2;
params.num_subdivisions = 4;
params.GenerateTextureDesc(hipReadModeNormalizedFloat);
TextureTestFixture<TestType, true, true> fixture{params};
const auto [num_threads_x, num_blocks_x] = GetLaunchConfig(32, params.NumItersX());
const auto [num_threads_y, num_blocks_y] = GetLaunchConfig(32, params.NumItersY());
dim3 dim_grid;
dim_grid.x = num_blocks_x;
dim_grid.y = num_blocks_y;
dim3 dim_block;
dim_block.x = num_threads_x;
dim_block.y = num_threads_y;
for (auto layer = 0u; layer < params.layers; ++layer) {
tex2DLayeredLodKernel<vec4<float>><<<dim_grid, dim_block>>>(
fixture.out_alloc_d.ptr(), params.NumItersX(), params.NumItersY(), fixture.tex.object(),
params.Width(), params.Height(), params.num_subdivisions, params.tex_desc.normalizedCoords,
layer, 0);
HIP_CHECK(hipGetLastError());
fixture.LoadOutput();
for (auto i = 0u; i < params.NumItersX() * params.NumItersY(); ++i) {
float x = i % params.NumItersX();
float y = i / params.NumItersX();
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);
INFO("Layer: " << layer);
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("x: " << std::fixed << std::setprecision(16) << x);
INFO("y: " << std::fixed << std::setprecision(16) << y);
auto ref_val = Vec4Map<TestType>(fixture.tex_h.Tex2DLayered(x, y, layer, params.tex_desc),
NormalizeInteger<TestType>);
REQUIRE(ref_val.x == fixture.out_alloc_h[i].x);
REQUIRE(ref_val.y == fixture.out_alloc_h[i].y);
REQUIRE(ref_val.z == fixture.out_alloc_h[i].z);
REQUIRE(ref_val.w == fixture.out_alloc_h[i].w);
}
}
}
+175
Voir le fichier
@@ -0,0 +1,175 @@
/*
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 <hip_test_common.hh>
#include "kernels.hh"
#include "test_fixture.hh"
/**
* @addtogroup tex2DLod tex2DLod
* @{
* @ingroup TextureTest
*/
/**
* Test Description
* ------------------------
* - Test texture fetching with `tex2DLod` 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/tex2DLod.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.7
*/
TEMPLATE_TEST_CASE("Unit_tex2DLod_Positive_ReadModeElementType", "", char, unsigned char, short,
unsigned short, int, unsigned int, float) {
CHECK_IMAGE_SUPPORT;
TextureTestParams<TestType> params = {};
params.extent = make_hipExtent(16, 4, 0);
params.num_subdivisions = 4;
params.GenerateTextureDesc();
TextureTestFixture<TestType, false, true> fixture{params};
const auto [num_threads_x, num_blocks_x] = GetLaunchConfig(32, params.NumItersX());
const auto [num_threads_y, num_blocks_y] = GetLaunchConfig(32, params.NumItersY());
dim3 dim_grid;
dim_grid.x = num_blocks_x;
dim_grid.y = num_blocks_y;
dim3 dim_block;
dim_block.x = num_threads_x;
dim_block.y = num_threads_y;
tex2DLodKernel<vec4<TestType>>
<<<dim_grid, dim_block>>>(fixture.out_alloc_d.ptr(), params.NumItersX(), params.NumItersY(),
fixture.tex.object(), params.Width(), params.Height(),
params.num_subdivisions, params.tex_desc.normalizedCoords, 0);
HIP_CHECK(hipGetLastError());
fixture.LoadOutput();
for (auto i = 0u; i < params.NumItersX() * params.NumItersY(); ++i) {
float x = i % params.NumItersX();
float y = i / params.NumItersX();
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);
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("x: " << std::fixed << std::setprecision(16) << x);
INFO("y: " << std::fixed << std::setprecision(16) << y);
const auto ref_val = fixture.tex_h.Tex2D(x, y, params.tex_desc);
REQUIRE(ref_val.x == fixture.out_alloc_h[i].x);
REQUIRE(ref_val.y == fixture.out_alloc_h[i].y);
REQUIRE(ref_val.z == fixture.out_alloc_h[i].z);
REQUIRE(ref_val.w == fixture.out_alloc_h[i].w);
}
}
/**
* Test Description
* ------------------------
* - Test texture fetching with `tex2DLod` 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/tex2DLod.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.7
*/
TEMPLATE_TEST_CASE("Unit_tex2DLod_Positive_ReadModeNormalizedFloat", "", char, unsigned char, short,
unsigned short) {
CHECK_IMAGE_SUPPORT;
TextureTestParams<TestType> params = {};
params.extent = make_hipExtent(16, 4, 0);
params.num_subdivisions = 4;
params.GenerateTextureDesc(hipReadModeNormalizedFloat);
TextureTestFixture<TestType, true, true> fixture{params};
const auto [num_threads_x, num_blocks_x] = GetLaunchConfig(32, params.NumItersX());
const auto [num_threads_y, num_blocks_y] = GetLaunchConfig(32, params.NumItersY());
dim3 dim_grid;
dim_grid.x = num_blocks_x;
dim_grid.y = num_blocks_y;
dim3 dim_block;
dim_block.x = num_threads_x;
dim_block.y = num_threads_y;
tex2DLodKernel<vec4<float>>
<<<dim_grid, dim_block>>>(fixture.out_alloc_d.ptr(), params.NumItersX(), params.NumItersY(),
fixture.tex.object(), params.Width(), params.Height(),
params.num_subdivisions, params.tex_desc.normalizedCoords, 0);
HIP_CHECK(hipGetLastError());
fixture.LoadOutput();
for (auto i = 0u; i < params.NumItersX() * params.NumItersY(); ++i) {
float x = i % params.NumItersX();
float y = i / params.NumItersX();
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);
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("x: " << std::fixed << std::setprecision(16) << x);
INFO("y: " << std::fixed << std::setprecision(16) << y);
auto ref_val =
Vec4Map<TestType>(fixture.tex_h.Tex2D(x, y, params.tex_desc), NormalizeInteger<TestType>);
REQUIRE(ref_val.x == fixture.out_alloc_h[i].x);
REQUIRE(ref_val.y == fixture.out_alloc_h[i].y);
REQUIRE(ref_val.z == fixture.out_alloc_h[i].z);
REQUIRE(ref_val.w == fixture.out_alloc_h[i].w);
}
}
+104
Voir le fichier
@@ -0,0 +1,104 @@
/*
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 <hip_test_common.hh>
#include "kernels.hh"
#include "test_fixture.hh"
/**
* @addtogroup tex2Dgather tex2Dgather
* @{
* @ingroup TextureTest
*/
/**
* Test Description
* ------------------------
* - Test texture fetching with `tex2Dgather` 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/tex2Dgather.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
TEMPLATE_TEST_CASE("Unit_tex2Dgather_Positive_ReadModeElementType", "", char, unsigned char, short,
unsigned short, int, unsigned int, float) {
CHECK_IMAGE_SUPPORT;
TextureTestParams<TestType> params = {};
params.extent = make_hipExtent(16, 4, 0);
params.num_subdivisions = 4;
params.GenerateTextureDesc();
TextureTestFixture<TestType> fixture{params};
const auto [num_threads_x, num_blocks_x] = GetLaunchConfig(32, params.NumItersX());
const auto [num_threads_y, num_blocks_y] = GetLaunchConfig(32, params.NumItersY());
dim3 dim_grid;
dim_grid.x = num_blocks_x;
dim_grid.y = num_blocks_y;
dim3 dim_block;
dim_block.x = num_threads_x;
dim_block.y = num_threads_y;
const int comp = GENERATE(0, 1, 2, 3);
tex2DgatherKernel<vec4<TestType>><<<dim_grid, dim_block>>>(
fixture.out_alloc_d.ptr(), comp, params.NumItersX(), params.NumItersY(), fixture.tex.object(),
params.Width(), params.Height(), params.num_subdivisions, params.tex_desc.normalizedCoords);
HIP_CHECK(hipGetLastError());
fixture.LoadOutput();
for (auto i = 0u; i < params.NumItersX() * params.NumItersY(); ++i) {
float x = i % params.NumItersX();
float y = i / params.NumItersX();
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);
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("x: " << std::fixed << std::setprecision(16) << x);
INFO("y: " << std::fixed << std::setprecision(16) << y);
const auto ref_val = fixture.tex_h.Tex2DGather(x, y, comp, params.tex_desc);
REQUIRE(ref_val.x == fixture.out_alloc_h[i].x);
REQUIRE(ref_val.y == fixture.out_alloc_h[i].y);
REQUIRE(ref_val.z == fixture.out_alloc_h[i].z);
REQUIRE(ref_val.w == fixture.out_alloc_h[i].w);
}
}
+194
Voir le fichier
@@ -0,0 +1,194 @@
/*
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 <hip_test_common.hh>
#include "kernels.hh"
#include "test_fixture.hh"
/**
* @addtogroup tex3D tex3D
* @{
* @ingroup TextureTest
*/
/**
* Test Description
* ------------------------
* - Test texture fetching with `tex3D` 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/tex3D.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
TEMPLATE_TEST_CASE("Unit_tex3D_Positive_ReadModeElementType", "", char, unsigned char, short,
unsigned short, int, unsigned int, float) {
CHECK_IMAGE_SUPPORT;
TextureTestParams<TestType> params = {};
params.extent = make_hipExtent(2, 4, 2);
params.num_subdivisions = 2;
params.GenerateTextureDesc();
TextureTestFixture<TestType> 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;
tex3DKernel<vec4<TestType>><<<dim_grid, dim_block>>>(
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);
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);
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);
const auto ref_val = fixture.tex_h.Tex3D(x, y, z, params.tex_desc);
REQUIRE(ref_val.x == fixture.out_alloc_h[i].x);
REQUIRE(ref_val.y == fixture.out_alloc_h[i].y);
REQUIRE(ref_val.z == fixture.out_alloc_h[i].z);
REQUIRE(ref_val.w == fixture.out_alloc_h[i].w);
}
}
/**
* Test Description
* ------------------------
* - Test texture fetching with `tex3D` 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/tex3D.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
TEMPLATE_TEST_CASE("Unit_tex3D_Positive_ReadModeNormalizedFloat", "", char, unsigned char, short,
unsigned short) {
CHECK_IMAGE_SUPPORT;
TextureTestParams<TestType> params = {};
params.extent = make_hipExtent(2, 2, 2);
params.num_subdivisions = 2;
params.GenerateTextureDesc(hipReadModeNormalizedFloat);
TextureTestFixture<TestType, true> 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;
tex3DKernel<vec4<float>><<<dim_grid, dim_block>>>(
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);
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);
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);
auto ref_val = Vec4Map<TestType>(fixture.tex_h.Tex3D(x, y, z, params.tex_desc),
NormalizeInteger<TestType>);
REQUIRE(ref_val.x == fixture.out_alloc_h[i].x);
REQUIRE(ref_val.y == fixture.out_alloc_h[i].y);
REQUIRE(ref_val.z == fixture.out_alloc_h[i].z);
REQUIRE(ref_val.w == fixture.out_alloc_h[i].w);
}
}
+193
Voir le fichier
@@ -0,0 +1,193 @@
/*
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 <hip_test_common.hh>
#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
*/
TEMPLATE_TEST_CASE("Unit_tex3DGrad_Positive_ReadModeElementType", "", char, unsigned char, short,
unsigned short, int, unsigned int, float) {
CHECK_IMAGE_SUPPORT;
TextureTestParams<TestType> params = {};
params.extent = make_hipExtent(2, 2, 2);
params.num_subdivisions = 2;
params.GenerateTextureDesc();
TextureTestFixture<TestType, false, true> 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<vec4<TestType>><<<dim_grid, dim_block>>>(
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);
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);
const auto ref_val = fixture.tex_h.Tex3D(x, y, z, params.tex_desc);
REQUIRE(ref_val.x == fixture.out_alloc_h[i].x);
REQUIRE(ref_val.y == fixture.out_alloc_h[i].y);
REQUIRE(ref_val.z == fixture.out_alloc_h[i].z);
REQUIRE(ref_val.w == fixture.out_alloc_h[i].w);
}
}
/**
* 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
*/
TEMPLATE_TEST_CASE("Unit_tex3DGrad_Positive_ReadModeNormalizedFloat", "", char, unsigned char,
short, unsigned short) {
CHECK_IMAGE_SUPPORT;
TextureTestParams<TestType> params = {};
params.extent = make_hipExtent(2, 2, 2);
params.num_subdivisions = 2;
params.GenerateTextureDesc(hipReadModeNormalizedFloat);
TextureTestFixture<TestType, true, true> 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<vec4<float>><<<dim_grid, dim_block>>>(
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);
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);
auto ref_val = Vec4Map<TestType>(fixture.tex_h.Tex3D(x, y, z, params.tex_desc),
NormalizeInteger<TestType>);
REQUIRE(ref_val.x == fixture.out_alloc_h[i].x);
REQUIRE(ref_val.y == fixture.out_alloc_h[i].y);
REQUIRE(ref_val.z == fixture.out_alloc_h[i].z);
REQUIRE(ref_val.w == fixture.out_alloc_h[i].w);
}
}
+193
Voir le fichier
@@ -0,0 +1,193 @@
/*
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 <hip_test_common.hh>
#include "kernels.hh"
#include "test_fixture.hh"
/**
* @addtogroup tex3DLod tex3DLod
* @{
* @ingroup TextureTest
*/
/**
* Test Description
* ------------------------
* - Test texture fetching with `tex3DLod` 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/tex3DLod.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.7
*/
TEMPLATE_TEST_CASE("Unit_tex3DLod_Positive_ReadModeElementType", "", char, unsigned char, short,
unsigned short, int, unsigned int, float) {
CHECK_IMAGE_SUPPORT;
TextureTestParams<TestType> params = {};
params.extent = make_hipExtent(2, 2, 2);
params.num_subdivisions = 2;
params.GenerateTextureDesc();
TextureTestFixture<TestType, false, true> 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;
tex3DLodKernel<vec4<TestType>><<<dim_grid, dim_block>>>(
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, 0.0);
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);
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);
const auto ref_val = fixture.tex_h.Tex3D(x, y, z, params.tex_desc);
REQUIRE(ref_val.x == fixture.out_alloc_h[i].x);
REQUIRE(ref_val.y == fixture.out_alloc_h[i].y);
REQUIRE(ref_val.z == fixture.out_alloc_h[i].z);
REQUIRE(ref_val.w == fixture.out_alloc_h[i].w);
}
}
/**
* Test Description
* ------------------------
* - Test texture fetching with `tex3DLod` 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/tex3DLod.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.7
*/
TEMPLATE_TEST_CASE("Unit_tex3DLod_Positive_ReadModeNormalizedFloat", "", char, unsigned char, short,
unsigned short) {
CHECK_IMAGE_SUPPORT;
TextureTestParams<TestType> params = {};
params.extent = make_hipExtent(2, 2, 2);
params.num_subdivisions = 2;
params.GenerateTextureDesc(hipReadModeNormalizedFloat);
TextureTestFixture<TestType, true, true> 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;
tex3DLodKernel<vec4<float>><<<dim_grid, dim_block>>>(
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, 0.0);
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);
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);
auto ref_val = Vec4Map<TestType>(fixture.tex_h.Tex3D(x, y, z, params.tex_desc),
NormalizeInteger<TestType>);
REQUIRE(ref_val.x == fixture.out_alloc_h[i].x);
REQUIRE(ref_val.y == fixture.out_alloc_h[i].y);
REQUIRE(ref_val.z == fixture.out_alloc_h[i].z);
REQUIRE(ref_val.w == fixture.out_alloc_h[i].w);
}
}
+203
Voir le fichier
@@ -0,0 +1,203 @@
/*
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 <hip_test_common.hh>
#include "kernels.hh"
#include "test_fixture.hh"
/**
* @addtogroup texCubemap texCubemap
* @{
* @ingroup TextureTest
*/
/**
* Test Description
* ------------------------
* - Test texture fetching with `texCubemap` 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/texCubemap.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
TEMPLATE_TEST_CASE("Unit_texCubemap_Positive_ReadModeElementType", "", char, unsigned char, short,
unsigned short, int, unsigned int, float) {
CHECK_IMAGE_SUPPORT;
TextureTestParams<TestType> params = {};
params.extent = make_hipExtent(2, 2, 6);
params.num_subdivisions = 4;
params.cubemap = true;
params.GenerateTextureDesc();
TextureTestFixture<TestType> 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;
texCubemapKernel<vec4<TestType>><<<dim_grid, dim_block>>>(
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);
HIP_CHECK(hipGetLastError());
fixture.LoadOutput();
for (auto k = 0u; k < params.NumItersZ(); ++k) {
for (auto j = 0u; j < params.NumItersY(); ++j) {
for (auto i = 0u; i < params.NumItersX(); ++i) {
float x = GetCoordinate(i, params.NumItersX(), params.Width(), params.num_subdivisions,
params.tex_desc.normalizedCoords);
float y = GetCoordinate(j, params.NumItersY(), params.Height(), params.num_subdivisions,
params.tex_desc.normalizedCoords);
float z = GetCoordinate(k, params.NumItersZ(), params.Depth(), params.num_subdivisions,
params.tex_desc.normalizedCoords);
INFO("i: " << i);
INFO("j: " << j);
INFO("k: " << k);
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);
auto index = k * params.NumItersX() * params.NumItersY() + j * params.NumItersX() + i;
const auto ref_val = fixture.tex_h.TexCubemap(x, y, z, params.tex_desc);
REQUIRE(ref_val.x == fixture.out_alloc_h[index].x);
REQUIRE(ref_val.y == fixture.out_alloc_h[index].y);
REQUIRE(ref_val.z == fixture.out_alloc_h[index].z);
REQUIRE(ref_val.w == fixture.out_alloc_h[index].w);
}
}
}
}
/**
* Test Description
* ------------------------
* - Test texture fetching with `texCubemap` 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/texCubemap.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
TEMPLATE_TEST_CASE("Unit_texCubemap_Positive_ReadModeNormalizedFloat", "", char, unsigned char,
short, unsigned short) {
CHECK_IMAGE_SUPPORT;
TextureTestParams<TestType> params = {};
params.extent = make_hipExtent(2, 2, 6);
params.num_subdivisions = 4;
params.cubemap = true;
params.GenerateTextureDesc(hipReadModeNormalizedFloat);
TextureTestFixture<TestType, true> 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;
texCubemapKernel<vec4<float>><<<dim_grid, dim_block>>>(
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);
HIP_CHECK(hipGetLastError());
fixture.LoadOutput();
for (auto k = 0u; k < params.NumItersZ(); ++k) {
for (auto j = 0u; j < params.NumItersY(); ++j) {
for (auto i = 0u; i < params.NumItersX(); ++i) {
float x = GetCoordinate(i, params.NumItersX(), params.Width(), params.num_subdivisions,
params.tex_desc.normalizedCoords);
float y = GetCoordinate(j, params.NumItersY(), params.Height(), params.num_subdivisions,
params.tex_desc.normalizedCoords);
float z = GetCoordinate(k, params.NumItersZ(), params.Depth(), params.num_subdivisions,
params.tex_desc.normalizedCoords);
INFO("i: " << i);
INFO("j: " << j);
INFO("k: " << k);
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);
auto index = k * params.NumItersX() * params.NumItersY() + j * params.NumItersX() + i;
auto ref_val = Vec4Map<TestType>(fixture.tex_h.TexCubemap(x, y, z, params.tex_desc),
NormalizeInteger<TestType>);
REQUIRE(ref_val.x == fixture.out_alloc_h[index].x);
REQUIRE(ref_val.y == fixture.out_alloc_h[index].y);
REQUIRE(ref_val.z == fixture.out_alloc_h[index].z);
REQUIRE(ref_val.w == fixture.out_alloc_h[index].w);
}
}
}
}
+203
Voir le fichier
@@ -0,0 +1,203 @@
/*
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 <hip_test_common.hh>
#include "kernels.hh"
#include "test_fixture.hh"
/**
* @addtogroup texCubemapGrad texCubemapGrad
* @{
* @ingroup TextureTest
*/
/**
* Test Description
* ------------------------
* - Test texture fetching with `texCubemapGrad` 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/texCubemapGrad.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.7
*/
TEMPLATE_TEST_CASE("Unit_texCubemapGrad_Positive_ReadModeElementType", "", char, unsigned char,
short, unsigned short, int, unsigned int, float) {
CHECK_IMAGE_SUPPORT;
TextureTestParams<TestType> params = {};
params.extent = make_hipExtent(2, 2, 6);
params.num_subdivisions = 4;
params.cubemap = true;
params.GenerateTextureDesc();
TextureTestFixture<TestType, false, true> 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;
texCubemapGradKernel<vec4<TestType>><<<dim_grid, dim_block>>>(
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 k = 0u; k < params.NumItersZ(); ++k) {
for (auto j = 0u; j < params.NumItersY(); ++j) {
for (auto i = 0u; i < params.NumItersX(); ++i) {
float x = GetCoordinate(i, params.NumItersX(), params.Width(), params.num_subdivisions,
params.tex_desc.normalizedCoords);
float y = GetCoordinate(j, params.NumItersY(), params.Height(), params.num_subdivisions,
params.tex_desc.normalizedCoords);
float z = GetCoordinate(k, params.NumItersZ(), params.Depth(), params.num_subdivisions,
params.tex_desc.normalizedCoords);
INFO("i: " << i);
INFO("j: " << j);
INFO("k: " << k);
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);
auto index = k * params.NumItersX() * params.NumItersY() + j * params.NumItersX() + i;
const auto ref_val = fixture.tex_h.TexCubemap(x, y, z, params.tex_desc);
REQUIRE(ref_val.x == fixture.out_alloc_h[index].x);
REQUIRE(ref_val.y == fixture.out_alloc_h[index].y);
REQUIRE(ref_val.z == fixture.out_alloc_h[index].z);
REQUIRE(ref_val.w == fixture.out_alloc_h[index].w);
}
}
}
}
/**
* Test Description
* ------------------------
* - Test texture fetching with `texCubemapGrad` 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/texCubemapGrad.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.7
*/
TEMPLATE_TEST_CASE("Unit_texCubemapGrad_Positive_ReadModeNormalizedFloat", "", char, unsigned char,
short, unsigned short) {
CHECK_IMAGE_SUPPORT;
TextureTestParams<TestType> params = {};
params.extent = make_hipExtent(2, 2, 6);
params.num_subdivisions = 4;
params.cubemap = true;
params.GenerateTextureDesc(hipReadModeNormalizedFloat);
TextureTestFixture<TestType, true, true> 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;
texCubemapGradKernel<vec4<float>><<<dim_grid, dim_block>>>(
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 k = 0u; k < params.NumItersZ(); ++k) {
for (auto j = 0u; j < params.NumItersY(); ++j) {
for (auto i = 0u; i < params.NumItersX(); ++i) {
float x = GetCoordinate(i, params.NumItersX(), params.Width(), params.num_subdivisions,
params.tex_desc.normalizedCoords);
float y = GetCoordinate(j, params.NumItersY(), params.Height(), params.num_subdivisions,
params.tex_desc.normalizedCoords);
float z = GetCoordinate(k, params.NumItersZ(), params.Depth(), params.num_subdivisions,
params.tex_desc.normalizedCoords);
INFO("i: " << i);
INFO("j: " << j);
INFO("k: " << k);
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);
auto index = k * params.NumItersX() * params.NumItersY() + j * params.NumItersX() + i;
auto ref_val = Vec4Map<TestType>(fixture.tex_h.TexCubemap(x, y, z, params.tex_desc),
NormalizeInteger<TestType>);
REQUIRE(ref_val.x == fixture.out_alloc_h[index].x);
REQUIRE(ref_val.y == fixture.out_alloc_h[index].y);
REQUIRE(ref_val.z == fixture.out_alloc_h[index].z);
REQUIRE(ref_val.w == fixture.out_alloc_h[index].w);
}
}
}
}
+209
Voir le fichier
@@ -0,0 +1,209 @@
/*
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 <hip_test_common.hh>
#include "kernels.hh"
#include "test_fixture.hh"
/**
* @addtogroup texCubemapLayered texCubemapLayered
* @{
* @ingroup TextureTest
*/
/**
* Test Description
* ------------------------
* - Test texture fetching with `texCubemapLayered` 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/texCubemapLayered.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
TEMPLATE_TEST_CASE("Unit_texCubemapLayered_Positive_ReadModeElementType", "", char, unsigned char,
short, unsigned short, int, unsigned int, float) {
CHECK_IMAGE_SUPPORT;
TextureTestParams<TestType> params = {};
params.extent = make_hipExtent(2, 2, 6);
params.num_subdivisions = 4;
params.layers = 1;
params.cubemap = true;
params.GenerateTextureDesc();
TextureTestFixture<TestType> 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;
for (auto layer = 0u; layer < params.layers; ++layer) {
texCubemapLayeredKernel<vec4<TestType>><<<dim_grid, dim_block>>>(
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, layer);
HIP_CHECK(hipGetLastError());
fixture.LoadOutput();
for (auto k = 0u; k < params.NumItersZ(); ++k) {
for (auto j = 0u; j < params.NumItersY(); ++j) {
for (auto i = 0u; i < params.NumItersX(); ++i) {
float x = GetCoordinate(i, params.NumItersX(), params.Width(), params.num_subdivisions,
params.tex_desc.normalizedCoords);
float y = GetCoordinate(j, params.NumItersY(), params.Height(), params.num_subdivisions,
params.tex_desc.normalizedCoords);
float z = GetCoordinate(k, params.NumItersZ(), params.Depth(), params.num_subdivisions,
params.tex_desc.normalizedCoords);
INFO("Layer: " << layer);
INFO("i: " << i);
INFO("j: " << j);
INFO("k: " << k);
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);
auto index = k * params.NumItersX() * params.NumItersY() + j * params.NumItersX() + i;
const auto ref_val = fixture.tex_h.TexCubemap(x, y, z, params.tex_desc);
REQUIRE(ref_val.x == fixture.out_alloc_h[index].x);
REQUIRE(ref_val.y == fixture.out_alloc_h[index].y);
REQUIRE(ref_val.z == fixture.out_alloc_h[index].z);
REQUIRE(ref_val.w == fixture.out_alloc_h[index].w);
}
}
}
}
}
/**
* Test Description
* ------------------------
* - Test texture fetching with `texCubemapLayered` 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/texCubemapLayered.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
TEMPLATE_TEST_CASE("Unit_texCubemapLayered_Positive_ReadModeNormalizedFloat", "", char,
unsigned char, short, unsigned short) {
CHECK_IMAGE_SUPPORT;
TextureTestParams<TestType> params = {};
params.extent = make_hipExtent(2, 2, 6);
params.num_subdivisions = 4;
params.layers = 1;
params.cubemap = true;
params.GenerateTextureDesc(hipReadModeNormalizedFloat);
TextureTestFixture<TestType, true> 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;
for (auto layer = 0u; layer < params.layers; ++layer) {
texCubemapLayeredKernel<vec4<float>><<<dim_grid, dim_block>>>(
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, layer);
HIP_CHECK(hipGetLastError());
fixture.LoadOutput();
for (auto k = 0u; k < params.NumItersZ(); ++k) {
for (auto j = 0u; j < params.NumItersY(); ++j) {
for (auto i = 0u; i < params.NumItersX(); ++i) {
float x = GetCoordinate(i, params.NumItersX(), params.Width(), params.num_subdivisions,
params.tex_desc.normalizedCoords);
float y = GetCoordinate(j, params.NumItersY(), params.Height(), params.num_subdivisions,
params.tex_desc.normalizedCoords);
float z = GetCoordinate(k, params.NumItersZ(), params.Depth(), params.num_subdivisions,
params.tex_desc.normalizedCoords);
INFO("Layer: " << layer);
INFO("i: " << i);
INFO("j: " << j);
INFO("k: " << k);
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);
auto index = k * params.NumItersX() * params.NumItersY() + j * params.NumItersX() + i;
auto ref_val = Vec4Map<TestType>(fixture.tex_h.TexCubemap(x, y, z, params.tex_desc),
NormalizeInteger<TestType>);
REQUIRE(ref_val.x == fixture.out_alloc_h[index].x);
REQUIRE(ref_val.y == fixture.out_alloc_h[index].y);
REQUIRE(ref_val.z == fixture.out_alloc_h[index].z);
REQUIRE(ref_val.w == fixture.out_alloc_h[index].w);
}
}
}
}
}
+211
Voir le fichier
@@ -0,0 +1,211 @@
/*
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 <hip_test_common.hh>
#include "kernels.hh"
#include "test_fixture.hh"
/**
* @addtogroup texCubemapLayeredGrad texCubemapLayeredGrad
* @{
* @ingroup TextureTest
*/
/**
* Test Description
* ------------------------
* - Test texture fetching with `texCubemapLayeredGrad` 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/texCubemapLayeredGrad.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.7
*/
TEMPLATE_TEST_CASE("Unit_texCubemapLayeredGrad_Positive_ReadModeElementType", "", char,
unsigned char, short, unsigned short, int, unsigned int, float) {
CHECK_IMAGE_SUPPORT;
TextureTestParams<TestType> params = {};
params.extent = make_hipExtent(2, 2, 6);
params.num_subdivisions = 4;
params.layers = 1;
params.cubemap = true;
params.GenerateTextureDesc();
TextureTestFixture<TestType, false, true> 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;
for (auto layer = 0u; layer < params.layers; ++layer) {
texCubemapLayeredGradKernel<vec4<TestType>><<<dim_grid, dim_block>>>(
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, layer, float4{}, float4{});
HIP_CHECK(hipGetLastError());
fixture.LoadOutput();
for (auto k = 0u; k < params.NumItersZ(); ++k) {
for (auto j = 0u; j < params.NumItersY(); ++j) {
for (auto i = 0u; i < params.NumItersX(); ++i) {
float x = GetCoordinate(i, params.NumItersX(), params.Width(), params.num_subdivisions,
params.tex_desc.normalizedCoords);
float y = GetCoordinate(j, params.NumItersY(), params.Height(), params.num_subdivisions,
params.tex_desc.normalizedCoords);
float z = GetCoordinate(k, params.NumItersZ(), params.Depth(), params.num_subdivisions,
params.tex_desc.normalizedCoords);
INFO("Layer: " << layer);
INFO("i: " << i);
INFO("j: " << j);
INFO("k: " << k);
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);
auto index = k * params.NumItersX() * params.NumItersY() + j * params.NumItersX() + i;
const auto ref_val = fixture.tex_h.TexCubemap(x, y, z, params.tex_desc);
REQUIRE(ref_val.x == fixture.out_alloc_h[index].x);
REQUIRE(ref_val.y == fixture.out_alloc_h[index].y);
REQUIRE(ref_val.z == fixture.out_alloc_h[index].z);
REQUIRE(ref_val.w == fixture.out_alloc_h[index].w);
}
}
}
}
}
/**
* Test Description
* ------------------------
* - Test texture fetching with `texCubemapLayeredGrad` 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/texCubemapLayeredGrad.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.7
*/
TEMPLATE_TEST_CASE("Unit_texCubemapLayeredGrad_Positive_ReadModeNormalizedFloat", "", char,
unsigned char, short, unsigned short) {
CHECK_IMAGE_SUPPORT;
TextureTestParams<TestType> params = {};
params.extent = make_hipExtent(2, 2, 6);
params.num_subdivisions = 4;
params.layers = 1;
params.cubemap = true;
params.GenerateTextureDesc(hipReadModeNormalizedFloat);
TextureTestFixture<TestType, true, true> 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;
for (auto layer = 0u; layer < params.layers; ++layer) {
texCubemapLayeredGradKernel<vec4<float>><<<dim_grid, dim_block>>>(
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, layer, float4{}, float4{});
HIP_CHECK(hipGetLastError());
fixture.LoadOutput();
for (auto k = 0u; k < params.NumItersZ(); ++k) {
for (auto j = 0u; j < params.NumItersY(); ++j) {
for (auto i = 0u; i < params.NumItersX(); ++i) {
float x = GetCoordinate(i, params.NumItersX(), params.Width(), params.num_subdivisions,
params.tex_desc.normalizedCoords);
float y = GetCoordinate(j, params.NumItersY(), params.Height(), params.num_subdivisions,
params.tex_desc.normalizedCoords);
float z = GetCoordinate(k, params.NumItersZ(), params.Depth(), params.num_subdivisions,
params.tex_desc.normalizedCoords);
INFO("Layer: " << layer);
INFO("i: " << i);
INFO("j: " << j);
INFO("k: " << k);
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);
auto index = k * params.NumItersX() * params.NumItersY() + j * params.NumItersX() + i;
auto ref_val = Vec4Map<TestType>(fixture.tex_h.TexCubemap(x, y, z, params.tex_desc),
NormalizeInteger<TestType>);
REQUIRE(ref_val.x == fixture.out_alloc_h[index].x);
REQUIRE(ref_val.y == fixture.out_alloc_h[index].y);
REQUIRE(ref_val.z == fixture.out_alloc_h[index].z);
REQUIRE(ref_val.w == fixture.out_alloc_h[index].w);
}
}
}
}
}
+211
Voir le fichier
@@ -0,0 +1,211 @@
/*
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 <hip_test_common.hh>
#include "kernels.hh"
#include "test_fixture.hh"
/**
* @addtogroup texCubemapLayeredLod texCubemapLayeredLod
* @{
* @ingroup TextureTest
*/
/**
* Test Description
* ------------------------
* - Test texture fetching with `texCubemapLayeredLod` 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/texCubemapLayeredLod.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.7
*/
TEMPLATE_TEST_CASE("Unit_texCubemapLayeredLod_Positive_ReadModeElementType", "", char,
unsigned char, short, unsigned short, int, unsigned int, float) {
CHECK_IMAGE_SUPPORT;
TextureTestParams<TestType> params = {};
params.extent = make_hipExtent(2, 2, 6);
params.num_subdivisions = 4;
params.layers = 1;
params.cubemap = true;
params.GenerateTextureDesc();
TextureTestFixture<TestType, false, true> 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;
for (auto layer = 0u; layer < params.layers; ++layer) {
texCubemapLayeredLodKernel<vec4<TestType>><<<dim_grid, dim_block>>>(
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, layer, 0.0);
HIP_CHECK(hipGetLastError());
fixture.LoadOutput();
for (auto k = 0u; k < params.NumItersZ(); ++k) {
for (auto j = 0u; j < params.NumItersY(); ++j) {
for (auto i = 0u; i < params.NumItersX(); ++i) {
float x = GetCoordinate(i, params.NumItersX(), params.Width(), params.num_subdivisions,
params.tex_desc.normalizedCoords);
float y = GetCoordinate(j, params.NumItersY(), params.Height(), params.num_subdivisions,
params.tex_desc.normalizedCoords);
float z = GetCoordinate(k, params.NumItersZ(), params.Depth(), params.num_subdivisions,
params.tex_desc.normalizedCoords);
INFO("Layer: " << layer);
INFO("i: " << i);
INFO("j: " << j);
INFO("k: " << k);
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);
auto index = k * params.NumItersX() * params.NumItersY() + j * params.NumItersX() + i;
const auto ref_val = fixture.tex_h.TexCubemap(x, y, z, params.tex_desc);
REQUIRE(ref_val.x == fixture.out_alloc_h[index].x);
REQUIRE(ref_val.y == fixture.out_alloc_h[index].y);
REQUIRE(ref_val.z == fixture.out_alloc_h[index].z);
REQUIRE(ref_val.w == fixture.out_alloc_h[index].w);
}
}
}
}
}
/**
* Test Description
* ------------------------
* - Test texture fetching with `texCubemapLayeredLod` 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/texCubemapLayeredLod.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.7
*/
TEMPLATE_TEST_CASE("Unit_texCubemapLayeredLod_Positive_ReadModeNormalizedFloat", "", char,
unsigned char, short, unsigned short) {
CHECK_IMAGE_SUPPORT;
TextureTestParams<TestType> params = {};
params.extent = make_hipExtent(2, 2, 6);
params.num_subdivisions = 4;
params.layers = 1;
params.cubemap = true;
params.GenerateTextureDesc(hipReadModeNormalizedFloat);
TextureTestFixture<TestType, true, true> 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;
for (auto layer = 0u; layer < params.layers; ++layer) {
texCubemapLayeredLodKernel<vec4<float>><<<dim_grid, dim_block>>>(
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, layer, 0.0);
HIP_CHECK(hipGetLastError());
fixture.LoadOutput();
for (auto k = 0u; k < params.NumItersZ(); ++k) {
for (auto j = 0u; j < params.NumItersY(); ++j) {
for (auto i = 0u; i < params.NumItersX(); ++i) {
float x = GetCoordinate(i, params.NumItersX(), params.Width(), params.num_subdivisions,
params.tex_desc.normalizedCoords);
float y = GetCoordinate(j, params.NumItersY(), params.Height(), params.num_subdivisions,
params.tex_desc.normalizedCoords);
float z = GetCoordinate(k, params.NumItersZ(), params.Depth(), params.num_subdivisions,
params.tex_desc.normalizedCoords);
INFO("Layer: " << layer);
INFO("i: " << i);
INFO("j: " << j);
INFO("k: " << k);
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);
auto index = k * params.NumItersX() * params.NumItersY() + j * params.NumItersX() + i;
auto ref_val = Vec4Map<TestType>(fixture.tex_h.TexCubemap(x, y, z, params.tex_desc),
NormalizeInteger<TestType>);
REQUIRE(ref_val.x == fixture.out_alloc_h[index].x);
REQUIRE(ref_val.y == fixture.out_alloc_h[index].y);
REQUIRE(ref_val.z == fixture.out_alloc_h[index].z);
REQUIRE(ref_val.w == fixture.out_alloc_h[index].w);
}
}
}
}
}
+203
Voir le fichier
@@ -0,0 +1,203 @@
/*
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 <hip_test_common.hh>
#include "kernels.hh"
#include "test_fixture.hh"
/**
* @addtogroup texCubemapLod texCubemapLod
* @{
* @ingroup TextureTest
*/
/**
* Test Description
* ------------------------
* - Test texture fetching with `texCubemapLod` 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/texCubemapLod.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.7
*/
TEMPLATE_TEST_CASE("Unit_texCubemapLod_Positive_ReadModeElementType", "", char, unsigned char,
short, unsigned short, int, unsigned int, float) {
CHECK_IMAGE_SUPPORT;
TextureTestParams<TestType> params = {};
params.extent = make_hipExtent(2, 2, 6);
params.num_subdivisions = 4;
params.cubemap = true;
params.GenerateTextureDesc();
TextureTestFixture<TestType, false, true> 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;
texCubemapLodKernel<vec4<TestType>><<<dim_grid, dim_block>>>(
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, 0.0);
HIP_CHECK(hipGetLastError());
fixture.LoadOutput();
for (auto k = 0u; k < params.NumItersZ(); ++k) {
for (auto j = 0u; j < params.NumItersY(); ++j) {
for (auto i = 0u; i < params.NumItersX(); ++i) {
float x = GetCoordinate(i, params.NumItersX(), params.Width(), params.num_subdivisions,
params.tex_desc.normalizedCoords);
float y = GetCoordinate(j, params.NumItersY(), params.Height(), params.num_subdivisions,
params.tex_desc.normalizedCoords);
float z = GetCoordinate(k, params.NumItersZ(), params.Depth(), params.num_subdivisions,
params.tex_desc.normalizedCoords);
INFO("i: " << i);
INFO("j: " << j);
INFO("k: " << k);
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);
auto index = k * params.NumItersX() * params.NumItersY() + j * params.NumItersX() + i;
const auto ref_val = fixture.tex_h.TexCubemap(x, y, z, params.tex_desc);
REQUIRE(ref_val.x == fixture.out_alloc_h[index].x);
REQUIRE(ref_val.y == fixture.out_alloc_h[index].y);
REQUIRE(ref_val.z == fixture.out_alloc_h[index].z);
REQUIRE(ref_val.w == fixture.out_alloc_h[index].w);
}
}
}
}
/**
* Test Description
* ------------------------
* - Test texture fetching with `texCubemapLod` 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/texCubemapLod.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.7
*/
TEMPLATE_TEST_CASE("Unit_texCubemapLod_Positive_ReadModeNormalizedFloat", "", char, unsigned char,
short, unsigned short) {
CHECK_IMAGE_SUPPORT;
TextureTestParams<TestType> params = {};
params.extent = make_hipExtent(2, 2, 6);
params.num_subdivisions = 4;
params.cubemap = true;
params.GenerateTextureDesc(hipReadModeNormalizedFloat);
TextureTestFixture<TestType, true, true> 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;
texCubemapLodKernel<vec4<float>><<<dim_grid, dim_block>>>(
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, 0.0);
HIP_CHECK(hipGetLastError());
fixture.LoadOutput();
for (auto k = 0u; k < params.NumItersZ(); ++k) {
for (auto j = 0u; j < params.NumItersY(); ++j) {
for (auto i = 0u; i < params.NumItersX(); ++i) {
float x = GetCoordinate(i, params.NumItersX(), params.Width(), params.num_subdivisions,
params.tex_desc.normalizedCoords);
float y = GetCoordinate(j, params.NumItersY(), params.Height(), params.num_subdivisions,
params.tex_desc.normalizedCoords);
float z = GetCoordinate(k, params.NumItersZ(), params.Depth(), params.num_subdivisions,
params.tex_desc.normalizedCoords);
INFO("i: " << i);
INFO("j: " << j);
INFO("k: " << k);
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);
auto index = k * params.NumItersX() * params.NumItersY() + j * params.NumItersX() + i;
auto ref_val = Vec4Map<TestType>(fixture.tex_h.TexCubemap(x, y, z, params.tex_desc),
NormalizeInteger<TestType>);
REQUIRE(ref_val.x == fixture.out_alloc_h[index].x);
REQUIRE(ref_val.y == fixture.out_alloc_h[index].y);
REQUIRE(ref_val.z == fixture.out_alloc_h[index].z);
REQUIRE(ref_val.w == fixture.out_alloc_h[index].w);
}
}
}
}
+98
Voir le fichier
@@ -26,6 +26,10 @@ THE SOFTWARE.
#include "fixed_point.hh"
#if defined(_WIN64)
typedef __int64 ssize_t;
#endif // _WIN64
template <typename TexelType> class TextureReference {
public:
TextureReference(TexelType* alloc, hipExtent extent, size_t layers)
@@ -35,6 +39,42 @@ template <typename TexelType> class TextureReference {
return Tex1DLayered(x, 0, tex_desc);
}
TexelType Tex2DGather(float x, float y, int comp, const hipTextureDesc& tex_desc) const {
x = tex_desc.normalizedCoords ? x * extent_.width : x;
y = tex_desc.normalizedCoords ? y * extent_.height : y;
const auto [i, alpha] = GetLinearFilteringParams(x);
const auto [j, beta] = GetLinearFilteringParams(y);
const auto T_i0j0 = Sample(i, j, 0, tex_desc.addressMode);
const auto T_i1j0 = Sample(i + 1.0f, j, 0, tex_desc.addressMode);
const auto T_i0j1 = Sample(i, j + 1.0f, 0, tex_desc.addressMode);
const auto T_i1j1 = Sample(i + 1.0f, j + 1.0f, 0, tex_desc.addressMode);
const auto IndexVec4 = [](auto vec, int comp) {
switch (comp) {
case 0:
return vec.x;
case 1:
return vec.y;
case 2:
return vec.z;
case 3:
return vec.w;
default:
throw std::invalid_argument("Invalid gather comp");
}
};
TexelType texel;
texel.x = IndexVec4(T_i0j1, comp);
texel.y = IndexVec4(T_i1j1, comp);
texel.z = IndexVec4(T_i1j0, comp);
texel.w = IndexVec4(T_i0j0, comp);
return texel;
}
TexelType Tex2D(float x, float y, const hipTextureDesc& tex_desc) const {
return Tex2DLayered(x, y, 0, tex_desc);
}
@@ -52,6 +92,64 @@ template <typename TexelType> class TextureReference {
}
}
TexelType TexCubemap(float x, float y, float z, const hipTextureDesc& tex_desc) const {
x = tex_desc.normalizedCoords ? x * extent_.width : x;
y = tex_desc.normalizedCoords ? y * extent_.height : y;
z = tex_desc.normalizedCoords ? z * extent_.depth : z;
int face;
float m, s, t;
if (std::abs(x) > std::abs(y) && std::abs(x) > std::abs(z)) {
if (x >= 0) {
face = 0;
m = x;
s = -z;
t = -y;
} else {
face = 1;
m = -x;
s = z;
t = -y;
}
} else if (std::abs(y) >= std::abs(x) && std::abs(y) > std::abs(z)) {
if (y >= 0) {
face = 2;
m = y;
s = x;
t = z;
} else {
face = 3;
m = -y;
s = x;
t = -z;
}
} else {
if (z >= 0) {
face = 4;
m = z;
s = x;
t = -y;
} else {
face = 5;
m = -z;
s = -x;
t = -y;
}
}
float coord1 = (s / m + 1) / 2;
float coord2 = (t / m + 1) / 2;
if (tex_desc.filterMode == hipFilterModePoint) {
return Sample(roundf(coord1), roundf(coord2), face, tex_desc.addressMode);
} else if (tex_desc.filterMode == hipFilterModeLinear) {
return LinearFiltering(coord1, coord2, face, tex_desc.addressMode);
} else {
throw std::invalid_argument("Invalid hipFilterMode value");
}
}
TexelType Tex1DLayered(float x, int layer, const hipTextureDesc& tex_desc) const {
x = tex_desc.normalizedCoords ? x * extent_.width : x;
if (tex_desc.filterMode == hipFilterModePoint) {