55
66#include < uur/fixtures.h>
77
8+ struct urKernelSetArgSamplerTestWithParam
9+ : uur::urBaseKernelTestWithParam<uur::SamplerCreateParamT> {
10+ void SetUp () {
11+ program_name = " image_copy" ;
12+ UUR_RETURN_ON_FATAL_FAILURE (
13+ uur::urBaseKernelTestWithParam<uur::SamplerCreateParamT>::SetUp ());
14+ UUR_RETURN_ON_FATAL_FAILURE (
15+ uur::urBaseKernelTestWithParam<uur::SamplerCreateParamT>::Build ());
16+
17+ const auto param = getParam ();
18+ const auto normalized = std::get<0 >(param);
19+ const auto addr_mode = std::get<1 >(param);
20+ const auto filter_mode = std::get<2 >(param);
21+
22+ ur_sampler_desc_t sampler_desc = {
23+ UR_STRUCTURE_TYPE_SAMPLER_DESC, /* sType */
24+ nullptr , /* pNext */
25+ normalized, /* normalizedCoords */
26+ addr_mode, /* addressingMode */
27+ filter_mode /* filterMode */
28+ };
29+ ASSERT_SUCCESS (urSamplerCreate (context, &sampler_desc, &sampler));
30+ }
31+
32+ void TearDown () {
33+ if (sampler) {
34+ ASSERT_SUCCESS (urSamplerRelease (sampler));
35+ }
36+ UUR_RETURN_ON_FATAL_FAILURE (uur::urBaseKernelTestWithParam<
37+ uur::SamplerCreateParamT>::TearDown ());
38+ }
39+
40+ ur_sampler_handle_t sampler = nullptr ;
41+ };
42+
43+ UUR_TEST_SUITE_P (
44+ urKernelSetArgSamplerTestWithParam,
45+ ::testing::Combine (
46+ ::testing::Values (true , false ),
47+ ::testing::Values(UR_SAMPLER_ADDRESSING_MODE_NONE,
48+ UR_SAMPLER_ADDRESSING_MODE_CLAMP_TO_EDGE,
49+ UR_SAMPLER_ADDRESSING_MODE_CLAMP,
50+ UR_SAMPLER_ADDRESSING_MODE_REPEAT,
51+ UR_SAMPLER_ADDRESSING_MODE_MIRRORED_REPEAT),
52+ ::testing::Values(UR_SAMPLER_FILTER_MODE_NEAREST,
53+ UR_SAMPLER_FILTER_MODE_LINEAR)),
54+ uur::deviceTestWithParamPrinter<uur::SamplerCreateParamT>);
55+
56+ TEST_P (urKernelSetArgSamplerTestWithParam, Success) {
57+ uint32_t arg_index = 2 ;
58+ ASSERT_SUCCESS (urKernelSetArgSampler (kernel, arg_index, nullptr , sampler));
59+ }
60+
861struct urKernelSetArgSamplerTest : uur::urBaseKernelTest {
962 void SetUp () {
1063 program_name = " image_copy" ;
1164 UUR_RETURN_ON_FATAL_FAILURE (urBaseKernelTest::SetUp ());
12- // Images and samplers are not available on AMD
13- ur_platform_backend_t backend;
14- ASSERT_SUCCESS (urPlatformGetInfo (platform, UR_PLATFORM_INFO_BACKEND,
15- sizeof (backend), &backend, nullptr ));
16- if (backend == UR_PLATFORM_BACKEND_HIP) {
17- GTEST_SKIP () << " Sampler are not supported on hip." ;
18- }
1965 Build ();
2066 ur_sampler_desc_t sampler_desc = {
2167 UR_STRUCTURE_TYPE_SAMPLER_DESC, /* sType */
@@ -36,10 +82,14 @@ struct urKernelSetArgSamplerTest : uur::urBaseKernelTest {
3682
3783 ur_sampler_handle_t sampler = nullptr ;
3884};
85+
3986UUR_INSTANTIATE_KERNEL_TEST_SUITE_P (urKernelSetArgSamplerTest);
4087
41- TEST_P (urKernelSetArgSamplerTest, Success) {
42- ASSERT_SUCCESS (urKernelSetArgSampler (kernel, 2 , nullptr , sampler));
88+ TEST_P (urKernelSetArgSamplerTest, SuccessWithProps) {
89+ ur_kernel_arg_sampler_properties_t props{
90+ UR_STRUCTURE_TYPE_KERNEL_ARG_SAMPLER_PROPERTIES, nullptr };
91+ size_t arg_index = 2 ;
92+ ASSERT_SUCCESS (urKernelSetArgSampler (kernel, arg_index, &props, sampler));
4393}
4494
4595TEST_P (urKernelSetArgSamplerTest, InvalidNullHandleKernel) {
0 commit comments