test_image_sampler.cpp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. #define BOOST_TEST_MODULE TestImageSampler
  11. #include <boost/test/unit_test.hpp>
  12. #include <iostream>
  13. #include <boost/compute/system.hpp>
  14. #include <boost/compute/image/image_sampler.hpp>
  15. #include "quirks.hpp"
  16. #include "context_setup.hpp"
  17. namespace compute = boost::compute;
  18. BOOST_AUTO_TEST_CASE(get_context)
  19. {
  20. if(!supports_image_samplers(device)){
  21. std::cerr << "skipping get_context test" << std::endl;
  22. return;
  23. }
  24. compute::image_sampler sampler(context, true, CL_ADDRESS_NONE, CL_FILTER_NEAREST);
  25. BOOST_CHECK(sampler.get_context() == context);
  26. }
  27. BOOST_AUTO_TEST_CASE(get_info)
  28. {
  29. if(!supports_image_samplers(device)){
  30. std::cerr << "skipping get_info test" << std::endl;
  31. return;
  32. }
  33. compute::image_sampler sampler(context, true, CL_ADDRESS_NONE, CL_FILTER_NEAREST);
  34. BOOST_CHECK_EQUAL(sampler.get_info<bool>(CL_SAMPLER_NORMALIZED_COORDS), true);
  35. BOOST_CHECK_EQUAL(
  36. sampler.get_info<cl_addressing_mode>(CL_SAMPLER_ADDRESSING_MODE),
  37. cl_addressing_mode(CL_ADDRESS_NONE)
  38. );
  39. BOOST_CHECK_EQUAL(
  40. sampler.get_info<cl_filter_mode>(CL_SAMPLER_FILTER_MODE),
  41. cl_filter_mode(CL_FILTER_NEAREST)
  42. );
  43. sampler = compute::image_sampler(context, false, CL_ADDRESS_CLAMP, CL_FILTER_LINEAR);
  44. BOOST_CHECK_EQUAL(sampler.get_info<bool>(CL_SAMPLER_NORMALIZED_COORDS), false);
  45. BOOST_CHECK_EQUAL(
  46. sampler.get_info<cl_addressing_mode>(CL_SAMPLER_ADDRESSING_MODE),
  47. cl_addressing_mode(CL_ADDRESS_CLAMP)
  48. );
  49. BOOST_CHECK_EQUAL(
  50. sampler.get_info<cl_filter_mode>(CL_SAMPLER_FILTER_MODE),
  51. cl_filter_mode(CL_FILTER_LINEAR)
  52. );
  53. }
  54. BOOST_AUTO_TEST_SUITE_END()