• 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     cl_int getInfo(SamplerInfo name, size_t valueSize, void *value, size_t *valueSizeRet) const;
23 
24   public:
25     using PropArray = std::vector<cl_sampler_properties>;
26 
27     ~Sampler() override;
28 
29     const Context &getContext() const;
30     const PropArray &getProperties() const;
31     cl_bool getNormalizedCoords() const;
32     AddressingMode getAddressingMode() const;
33     FilterMode getFilterMode() const;
34 
35     template <typename T = rx::CLSamplerImpl>
36     T &getImpl() const;
37 
38   private:
39     Sampler(Context &context,
40             PropArray &&properties,
41             cl_bool normalizedCoords,
42             AddressingMode addressingMode,
43             FilterMode filterMode,
44             cl_int &errorCode);
45 
46     const ContextPtr mContext;
47     const PropArray mProperties;
48     const cl_bool mNormalizedCoords;
49     const AddressingMode mAddressingMode;
50     const FilterMode mFilterMode;
51     const rx::CLSamplerImpl::Ptr mImpl;
52 
53     friend class Object;
54 };
55 
getContext()56 inline const Context &Sampler::getContext() const
57 {
58     return *mContext;
59 }
60 
getProperties()61 inline const Sampler::PropArray &Sampler::getProperties() const
62 {
63     return mProperties;
64 }
65 
getNormalizedCoords()66 inline cl_bool Sampler::getNormalizedCoords() const
67 {
68     return mNormalizedCoords;
69 }
70 
getAddressingMode()71 inline AddressingMode Sampler::getAddressingMode() const
72 {
73     return mAddressingMode;
74 }
75 
getFilterMode()76 inline FilterMode Sampler::getFilterMode() const
77 {
78     return mFilterMode;
79 }
80 
81 template <typename T>
getImpl()82 inline T &Sampler::getImpl() const
83 {
84     return static_cast<T &>(*mImpl);
85 }
86 
87 }  // namespace cl
88 
89 #endif  // LIBANGLE_CLSAMPLER_H_
90