DPC++ Runtime
Runtime libraries for oneAPI DPC++
sampler.hpp
Go to the documentation of this file.
1 //==----------------- sampler.hpp - SYCL standard header file --------------==//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #pragma once
10 
12 #include <sycl/access/access.hpp>
13 #include <sycl/detail/cl.h>
14 #include <sycl/detail/common.hpp>
15 #include <sycl/detail/export.hpp>
16 #include <sycl/property_list.hpp>
17 
18 namespace sycl {
20 enum class addressing_mode : unsigned int {
26 };
27 
28 enum class filtering_mode : unsigned int {
31 };
32 
33 enum class coordinate_normalization_mode : unsigned int {
34  normalized = 1,
35  unnormalized = 0
36 };
37 
38 namespace detail {
39 template <typename DataT, int Dimensions, access::mode AccessMode,
41 class image_accessor;
42 }
43 
44 namespace detail {
45 #ifdef __SYCL_DEVICE_ONLY__
46 class __SYCL_EXPORT sampler_impl {
47 public:
48  sampler_impl() = default;
49 
50  sampler_impl(__ocl_sampler_t Sampler) : m_Sampler(Sampler) {}
51 
52  ~sampler_impl() = default;
53 
54  __ocl_sampler_t m_Sampler;
55 };
56 #else
57 class sampler_impl;
58 #endif
59 } // namespace detail
60 
66 class __SYCL_EXPORT __SYCL_SPECIAL_CLASS __SYCL_TYPE(sampler) sampler {
67 public:
68  sampler(coordinate_normalization_mode normalizationMode,
69  addressing_mode addressingMode, filtering_mode filteringMode,
70  const property_list &propList = {});
71 
72 #ifdef __SYCL_INTERNAL_API
73  sampler(cl_sampler clSampler, const context &syclContext);
74 #endif
75 
76  sampler(const sampler &rhs) = default;
77 
78  sampler(sampler &&rhs) = default;
79 
80  sampler &operator=(const sampler &rhs) = default;
81 
82  sampler &operator=(sampler &&rhs) = default;
83 
84  bool operator==(const sampler &rhs) const;
85 
86  bool operator!=(const sampler &rhs) const;
87 
91  template <typename propertyT> bool has_property() const noexcept;
92 
99  template <typename propertyT> propertyT get_property() const;
100 
101  addressing_mode get_addressing_mode() const;
102 
103  filtering_mode get_filtering_mode() const;
104 
105  coordinate_normalization_mode get_coordinate_normalization_mode() const;
106 
107 private:
108 #ifdef __SYCL_DEVICE_ONLY__
109  detail::sampler_impl impl;
110  void __init(__ocl_sampler_t Sampler) { impl.m_Sampler = Sampler; }
111  char padding[sizeof(std::shared_ptr<detail::sampler_impl>) - sizeof(impl)];
112 
113 public:
114  sampler() = default;
115 
116 private:
117 #else
118  std::shared_ptr<detail::sampler_impl> impl;
119  template <class Obj>
120  friend decltype(Obj::impl) detail::getSyclObjImpl(const Obj &SyclObject);
121 #endif
122  template <typename DataT, int Dimensions, sycl::access::mode AccessMode,
123  sycl::access::target AccessTarget,
125  friend class detail::image_accessor;
126 };
127 } // __SYCL_INLINE_VER_NAMESPACE(_V1)
128 } // namespace sycl
129 
130 namespace std {
131 template <> struct hash<sycl::sampler> {
132  size_t operator()(const sycl::sampler &s) const {
133 #ifdef __SYCL_DEVICE_ONLY__
134  (void)s;
135  return 0;
136 #else
137  return hash<std::shared_ptr<sycl::detail::sampler_impl>>()(
139 #endif
140  }
141 };
142 } // namespace std
#define __SYCL_SPECIAL_CLASS
Definition: defines.hpp:27
#define __SYCL_TYPE(x)
Definition: defines.hpp:33
#define __SYCL_INLINE_VER_NAMESPACE(X)
decltype(Obj::impl) getSyclObjImpl(const Obj &SyclObject)
Definition: common.hpp:240
static constexpr std::enable_if_t< HasProperty, typename FindCompileTimePropertyValueType< CTPropertyT, PropertiesT >::type > get_property()
Definition: properties.hpp:65
filtering_mode
Definition: sampler.hpp:28
class __SYCL_SPECIAL_CLASS __SYCL_TYPE(local_accessor) local_accessor class __SYCL_SPECIAL_CLASS IsPlaceholder
Definition: accessor.hpp:2749
bool operator!=(const multi_ptr< ElementType, Space, DecorateAddress > &lhs, const multi_ptr< ElementType, Space, DecorateAddress > &rhs)
Definition: multi_ptr.hpp:1362
coordinate_normalization_mode
Definition: sampler.hpp:33
class __SYCL_SPECIAL_CLASS __SYCL_TYPE(local_accessor) local_accessor class __SYCL_SPECIAL_CLASS Dimensions
Definition: accessor.hpp:2747
addressing_mode
Definition: sampler.hpp:20
class __SYCL_SPECIAL_CLASS __SYCL_TYPE(local_accessor) local_accessor class __SYCL_SPECIAL_CLASS AccessMode
Definition: accessor.hpp:2747
---— Error handling, matching OpenCL plugin semantics.
Definition: access.hpp:14
@ PI_SAMPLER_FILTER_MODE_NEAREST
Definition: pi.h:501
@ PI_SAMPLER_FILTER_MODE_LINEAR
Definition: pi.h:502
@ PI_SAMPLER_ADDRESSING_MODE_MIRRORED_REPEAT
Definition: pi.h:493
@ PI_SAMPLER_ADDRESSING_MODE_CLAMP
Definition: pi.h:496
@ PI_SAMPLER_ADDRESSING_MODE_NONE
Definition: pi.h:497
@ PI_SAMPLER_ADDRESSING_MODE_REPEAT
Definition: pi.h:494
@ PI_SAMPLER_ADDRESSING_MODE_CLAMP_TO_EDGE
Definition: pi.h:495
void * __ocl_sampler_t
simd< _Tp, _Abi > clamp(const simd< _Tp, _Abi > &, const simd< _Tp, _Abi > &, const simd< _Tp, _Abi > &)
size_t operator()(const sycl::sampler &s) const
Definition: sampler.hpp:132
bool operator==(const Slab &Lhs, const Slab &Rhs)