Add packaging for TIZEN
[platform/upstream/VK-GL-CTS.git] / framework / randomshaders / rsgExecutionContext.hpp
1 #ifndef _RSGEXECUTIONCONTEXT_HPP
2 #define _RSGEXECUTIONCONTEXT_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 Shader Execution Context.
24  *//*--------------------------------------------------------------------*/
25
26 #include "rsgDefs.hpp"
27 #include "rsgVariable.hpp"
28 #include "rsgVariableValue.hpp"
29 #include "rsgSamplers.hpp"
30
31 #include <vector>
32 #include <map>
33
34 namespace rsg
35 {
36
37 enum
38 {
39         EXEC_VEC_WIDTH  = 64
40 };
41
42 typedef ConstStridedValueAccess<EXEC_VEC_WIDTH>                 ExecConstValueAccess;
43 typedef StridedValueAccess<EXEC_VEC_WIDTH>                              ExecValueAccess;
44 typedef ValueStorage<EXEC_VEC_WIDTH>                                    ExecValueStorage;
45
46 typedef std::map<const Variable*, ExecValueStorage*>    VarValueMap;
47
48 class ExecMaskStorage
49 {
50 public:
51                                                         ExecMaskStorage (bool initVal = true);
52
53         ExecValueAccess                 getValue                (void);
54         ExecConstValueAccess    getValue                (void) const;
55
56 private:
57         Scalar                                  m_data[EXEC_VEC_WIDTH];
58 };
59
60 class ExecutionContext
61 {
62 public:
63                                                                         ExecutionContext                (const Sampler2DMap& samplers2D, const SamplerCubeMap& samplersCube);
64                                                                         ~ExecutionContext               (void);
65
66         ExecValueAccess                                 getValue                                (const Variable* variable);
67         const Sampler2D&                                getSampler2D                    (const Variable* variable) const;
68         const SamplerCube&                              getSamplerCube                  (const Variable* variable) const;
69
70         ExecConstValueAccess                    getExecutionMask                (void) const;
71
72         void                                                    andExecutionMask                (ExecConstValueAccess value); // Pushes computed value
73         void                                                    pushExecutionMask               (ExecConstValueAccess value);
74
75         void                                                    popExecutionMask                (void);
76
77 protected:
78                                                                         ExecutionContext                (const ExecutionContext& other);
79         ExecutionContext&                               operator=                               (const ExecutionContext& other);
80
81         VarValueMap                                             m_varValues;
82         const Sampler2DMap&                             m_samplers2D;
83         const SamplerCubeMap&                   m_samplersCube;
84         std::vector<ExecMaskStorage>    m_execMaskStack;
85 };
86
87 void assignMasked (ExecValueAccess dst, ExecConstValueAccess src, ExecConstValueAccess mask);
88
89 } // rsg
90
91 #endif // _RSGEXECUTIONCONTEXT_HPP