• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 constexpr int EXEC_VEC_WIDTH = 64;
38 
39 typedef ConstStridedValueAccess<EXEC_VEC_WIDTH>			ExecConstValueAccess;
40 typedef StridedValueAccess<EXEC_VEC_WIDTH>				ExecValueAccess;
41 typedef ValueStorage<EXEC_VEC_WIDTH>					ExecValueStorage;
42 
43 typedef std::map<const Variable*, ExecValueStorage*>	VarValueMap;
44 
45 class ExecMaskStorage
46 {
47 public:
48 							ExecMaskStorage	(bool initVal = true);
49 
50 	ExecValueAccess			getValue		(void);
51 	ExecConstValueAccess	getValue		(void) const;
52 
53 private:
54 	Scalar					m_data[EXEC_VEC_WIDTH];
55 };
56 
57 class ExecutionContext
58 {
59 public:
60 									ExecutionContext		(const Sampler2DMap& samplers2D, const SamplerCubeMap& samplersCube);
61 									~ExecutionContext		(void);
62 
63 	ExecValueAccess					getValue				(const Variable* variable);
64 	const Sampler2D&				getSampler2D			(const Variable* variable) const;
65 	const SamplerCube&				getSamplerCube			(const Variable* variable) const;
66 
67 	ExecConstValueAccess			getExecutionMask		(void) const;
68 
69 	void							andExecutionMask		(ExecConstValueAccess value); // Pushes computed value
70 	void							pushExecutionMask		(ExecConstValueAccess value);
71 
72 	void							popExecutionMask		(void);
73 
74 protected:
75 									ExecutionContext		(const ExecutionContext& other);
76 	ExecutionContext&				operator=				(const ExecutionContext& other);
77 
78 	VarValueMap						m_varValues;
79 	const Sampler2DMap&				m_samplers2D;
80 	const SamplerCubeMap&			m_samplersCube;
81 	std::vector<ExecMaskStorage>	m_execMaskStack;
82 };
83 
84 void assignMasked (ExecValueAccess dst, ExecConstValueAccess src, ExecConstValueAccess mask);
85 
86 } // rsg
87 
88 #endif // _RSGEXECUTIONCONTEXT_HPP
89