1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@gmail.com>
3 //
4 // Distributed under the Boost Software License, Version 1.0
5 // See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt
7 //
8 // See http://boostorg.github.com/compute for more information.
9 //---------------------------------------------------------------------------//
10
11 #define BOOST_TEST_MODULE TestImageSampler
12 #include <boost/test/unit_test.hpp>
13
14 #include <iostream>
15
16 #include <boost/compute/system.hpp>
17 #include <boost/compute/image/image_sampler.hpp>
18
19 #include "quirks.hpp"
20 #include "context_setup.hpp"
21
22 namespace compute = boost::compute;
23
BOOST_AUTO_TEST_CASE(get_context)24 BOOST_AUTO_TEST_CASE(get_context)
25 {
26 if(!supports_image_samplers(device)){
27 std::cerr << "skipping get_context test" << std::endl;
28 return;
29 }
30
31 compute::image_sampler sampler(context, true, CL_ADDRESS_NONE, CL_FILTER_NEAREST);
32 BOOST_CHECK(sampler.get_context() == context);
33 }
34
BOOST_AUTO_TEST_CASE(get_info)35 BOOST_AUTO_TEST_CASE(get_info)
36 {
37 if(!supports_image_samplers(device)){
38 std::cerr << "skipping get_info test" << std::endl;
39 return;
40 }
41
42 compute::image_sampler sampler(context, true, CL_ADDRESS_NONE, CL_FILTER_NEAREST);
43 BOOST_CHECK_EQUAL(sampler.get_info<bool>(CL_SAMPLER_NORMALIZED_COORDS), true);
44 BOOST_CHECK_EQUAL(
45 sampler.get_info<cl_addressing_mode>(CL_SAMPLER_ADDRESSING_MODE),
46 cl_addressing_mode(CL_ADDRESS_NONE)
47 );
48 BOOST_CHECK_EQUAL(
49 sampler.get_info<cl_filter_mode>(CL_SAMPLER_FILTER_MODE),
50 cl_filter_mode(CL_FILTER_NEAREST)
51 );
52
53 sampler = compute::image_sampler(context, false, CL_ADDRESS_CLAMP, CL_FILTER_LINEAR);
54 BOOST_CHECK_EQUAL(sampler.get_info<bool>(CL_SAMPLER_NORMALIZED_COORDS), false);
55 BOOST_CHECK_EQUAL(
56 sampler.get_info<cl_addressing_mode>(CL_SAMPLER_ADDRESSING_MODE),
57 cl_addressing_mode(CL_ADDRESS_CLAMP)
58 );
59 BOOST_CHECK_EQUAL(
60 sampler.get_info<cl_filter_mode>(CL_SAMPLER_FILTER_MODE),
61 cl_filter_mode(CL_FILTER_LINEAR)
62 );
63 }
64
65 BOOST_AUTO_TEST_SUITE_END()
66