• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2021 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 // CLSampler.h: Defines the cl::Sampler class, which describes how to sample an OpenCL Image.
7 
8 #ifndef LIBANGLE_CLSAMPLER_H_
9 #define LIBANGLE_CLSAMPLER_H_
10 
11 #include "libANGLE/CLObject.h"
12 #include "libANGLE/renderer/CLSamplerImpl.h"
13 
14 namespace cl
15 {
16 
17 class Sampler final : public _cl_sampler, public Object
18 {
19   public:
20     // Front end entry functions, only called from OpenCL entry points
21 
22     angle::Result getInfo(SamplerInfo name,
23                           size_t valueSize,
24                           void *value,
25                           size_t *valueSizeRet) const;
26 
27   public:
28     using PropArray = std::vector<cl_sampler_properties>;
29 
30     ~Sampler() override;
31 
32     const Context &getContext() const;
33     const PropArray &getProperties() const;
34     cl_bool getNormalizedCoords() const;
35     AddressingMode getAddressingMode() const;
36     FilterMode getFilterMode() const;
37 
38     template <typename T = rx::CLSamplerImpl>
39     T &getImpl() const;
40 
41   private:
42     Sampler(Context &context,
43             PropArray &&properties,
44             cl_bool normalizedCoords,
45             AddressingMode addressingMode,
46             FilterMode filterMode);
47 
48     const ContextPtr mContext;
49     const PropArray mProperties;
50     const cl_bool mNormalizedCoords;
51     const AddressingMode mAddressingMode;
52     const FilterMode mFilterMode;
53     rx::CLSamplerImpl::Ptr mImpl;
54 
55     friend class Object;
56 };
57 
getContext()58 inline const Context &Sampler::getContext() const
59 {
60     return *mContext;
61 }
62 
getProperties()63 inline const Sampler::PropArray &Sampler::getProperties() const
64 {
65     return mProperties;
66 }
67 
getNormalizedCoords()68 inline cl_bool Sampler::getNormalizedCoords() const
69 {
70     return mNormalizedCoords;
71 }
72 
getAddressingMode()73 inline AddressingMode Sampler::getAddressingMode() const
74 {
75     return mAddressingMode;
76 }
77 
getFilterMode()78 inline FilterMode Sampler::getFilterMode() const
79 {
80     return mFilterMode;
81 }
82 
83 template <typename T>
getImpl()84 inline T &Sampler::getImpl() const
85 {
86     return static_cast<T &>(*mImpl);
87 }
88 
89 }  // namespace cl
90 
91 #endif  // LIBANGLE_CLSAMPLER_H_
92