xref: /aosp_15_r20/external/deqp/framework/randomshaders/rsgSamplers.hpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
1 #ifndef _RSGSAMPLERS_HPP
2 #define _RSGSAMPLERS_HPP
3 /*-------------------------------------------------------------------------
4  * drawElements Quality Program Random Shader Generator
5  * ----------------------------------------------------
6  *
7  * Copyright 2014 The Android Open Source Project
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  *//*!
22  * \file
23  * \brief Samplers.
24  *//*--------------------------------------------------------------------*/
25 
26 #include "rsgDefs.hpp"
27 #include "tcuTexture.hpp"
28 
29 #include <map>
30 
31 namespace rsg
32 {
33 
34 class Sampler2D
35 {
36 public:
Sampler2D(void)37     Sampler2D(void) : m_texture(DE_NULL), m_sampler()
38     {
39     }
40 
Sampler2D(const tcu::Texture2D * texture,const tcu::Sampler & sampler)41     Sampler2D(const tcu::Texture2D *texture, const tcu::Sampler &sampler) : m_texture(texture), m_sampler(sampler)
42     {
43     }
44 
sample(float s,float t,float lod) const45     inline tcu::Vec4 sample(float s, float t, float lod) const
46     {
47         return m_texture->sample(m_sampler, s, t, lod);
48     }
49 
50 private:
51     const tcu::Texture2D *m_texture;
52     tcu::Sampler m_sampler;
53 };
54 
55 class SamplerCube
56 {
57 public:
SamplerCube(void)58     SamplerCube(void) : m_texture(DE_NULL), m_sampler()
59     {
60     }
61 
SamplerCube(const tcu::TextureCube * texture,const tcu::Sampler & sampler)62     SamplerCube(const tcu::TextureCube *texture, const tcu::Sampler &sampler) : m_texture(texture), m_sampler(sampler)
63     {
64     }
65 
sample(float s,float t,float r,float lod) const66     inline tcu::Vec4 sample(float s, float t, float r, float lod) const
67     {
68         return m_texture->sample(m_sampler, s, t, r, lod);
69     }
70 
71 private:
72     const tcu::TextureCube *m_texture;
73     tcu::Sampler m_sampler;
74 };
75 
76 typedef std::map<int, Sampler2D> Sampler2DMap;
77 typedef std::map<int, SamplerCube> SamplerCubeMap;
78 
79 } // namespace rsg
80 
81 #endif // _RSGSAMPLERS_HPP
82