• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef _GL4CSHADERBALLOTTESTS_HPP
2 #define _GL4CSHADERBALLOTTESTS_HPP
3 /*-------------------------------------------------------------------------
4 * OpenGL Conformance Test Suite
5 * -----------------------------
6 *
7 * Copyright (c) 2014-2017 The Khronos Group Inc.
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  gl4cShaderBallotTests.hpp
23 * \brief Conformance tests for the ARB_shader_ballot functionality.
24 */ /*-------------------------------------------------------------------*/
25 
26 #include "esextcTestCaseBase.hpp"
27 #include "glcTestCase.hpp"
28 #include "gluShaderProgram.hpp"
29 
30 #include <map>
31 #include <vector>
32 
33 namespace gl4cts
34 {
35 class ShaderBallotBaseTestCase : public glcts::TestCaseBase
36 {
37 public:
38 	class ShaderPipeline
39 	{
40 	private:
41 		glu::ShaderProgram* m_programRender;
42 		glu::ShaderProgram* m_programCompute;
43 		glu::ShaderType		m_testedShader;
44 
45 		std::vector<std::string> m_shaders[glu::SHADERTYPE_LAST];
46 		char**					 m_shaderChunks[glu::SHADERTYPE_LAST];
47 
48 		std::map<std::string, std::string> m_specializationMap;
49 
50 		void renderQuad(deqp::Context& context);
51 		void executeComputeShader(deqp::Context& context);
52 
53 	public:
54 		ShaderPipeline(glu::ShaderType testedShader, const std::string& contentSnippet,
55 					   std::map<std::string, std::string> specMap = std::map<std::string, std::string>());
56 		~ShaderPipeline();
57 
58 		const char* const* getShaderParts(glu::ShaderType shaderType) const;
59 		unsigned int getShaderPartsCount(glu::ShaderType shaderType) const;
60 
61 		void use(deqp::Context& context);
62 
setShaderPrograms(glu::ShaderProgram * programRender,glu::ShaderProgram * programCompute)63 		inline void setShaderPrograms(glu::ShaderProgram* programRender, glu::ShaderProgram* programCompute)
64 		{
65 			m_programRender  = programRender;
66 			m_programCompute = programCompute;
67 		}
68 
getSpecializationMap() const69 		inline const std::map<std::string, std::string>& getSpecializationMap() const
70 		{
71 			return m_specializationMap;
72 		}
73 
74 		void test(deqp::Context& context);
75 	};
76 
77 protected:
78 	/* Protected methods */
79 	void createShaderPrograms(ShaderPipeline& pipeline);
80 
81 	/* Protected members*/
82 	std::vector<ShaderPipeline*> m_shaderPipelines;
83 
84 	typedef std::vector<ShaderPipeline*>::iterator ShaderPipelineIter;
85 
86 public:
87 	/* Public methods */
ShaderBallotBaseTestCase(deqp::Context & context,const char * name,const char * description)88 	ShaderBallotBaseTestCase(deqp::Context& context, const char* name, const char* description)
89 		: TestCaseBase(context, glcts::ExtParameters(glu::GLSL_VERSION_450, glcts::EXTENSIONTYPE_EXT), name,
90 					   description)
91 	{
92 	}
93 
94 	virtual ~ShaderBallotBaseTestCase();
95 
96 	static bool validateScreenPixels(deqp::Context& context, tcu::Vec4 desiredColor, tcu::Vec4 ignoredColor);
97 	static bool validateScreenPixelsSameColor(deqp::Context& context, tcu::Vec4 ignoredColor);
98 	static bool validateColor(tcu::Vec4 testedColor, tcu::Vec4 desiredColor);
99 };
100 
101 /** Test verifies availability of new build-in features
102 **/
103 class ShaderBallotAvailabilityTestCase : public ShaderBallotBaseTestCase
104 {
105 public:
106 	/* Public methods */
107 	ShaderBallotAvailabilityTestCase(deqp::Context& context);
108 
109 	void init();
110 
111 	tcu::TestNode::IterateResult iterate();
112 };
113 
114 /** Test verifies values of gl_SubGroup*MaskARB variables
115 **/
116 class ShaderBallotBitmasksTestCase : public ShaderBallotBaseTestCase
117 {
118 public:
119 	/* Public methods */
120 	ShaderBallotBitmasksTestCase(deqp::Context& context);
121 
122 	void init();
123 
124 	tcu::TestNode::IterateResult iterate();
125 
126 protected:
127 	/* Protected members*/
128 	std::map<std::string, std::string> m_maskVars;
129 
130 	typedef std::map<std::string, std::string>::iterator MaskVarIter;
131 };
132 
133 /** Test verifies ballotARB calls and returned results
134 **/
135 class ShaderBallotFunctionBallotTestCase : public ShaderBallotBaseTestCase
136 {
137 public:
138 	/* Public methods */
139 	ShaderBallotFunctionBallotTestCase(deqp::Context& context);
140 
141 	void init();
142 
143 	tcu::TestNode::IterateResult iterate();
144 };
145 
146 /** Test verifies readInvocationARB and readFirstInvocationARB function calls
147 **/
148 class ShaderBallotFunctionReadTestCase : public ShaderBallotBaseTestCase
149 {
150 public:
151 	/* Public methods */
152 	ShaderBallotFunctionReadTestCase(deqp::Context& context);
153 
154 	void init();
155 
156 	tcu::TestNode::IterateResult iterate();
157 };
158 
159 class ShaderBallotTests : public deqp::TestCaseGroup
160 {
161 public:
162 	ShaderBallotTests(deqp::Context& context);
163 	void init(void);
164 
165 private:
166 	ShaderBallotTests(const ShaderBallotTests& other);
167 	ShaderBallotTests& operator=(const ShaderBallotTests& other);
168 };
169 
170 } /* gl4cts namespace */
171 
172 #endif // _GL4CSHADERBALLOTTESTS_HPP
173