1#ifndef _RSGPROGRAMEXECUTOR_HPP
2#define _RSGPROGRAMEXECUTOR_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 Program Executor.
24 *//*--------------------------------------------------------------------*/
25
26#include "rsgDefs.hpp"
27#include "rsgShader.hpp"
28#include "rsgVariableValue.hpp"
29#include "tcuTexture.hpp"
30#include "rsgSamplers.hpp"
31
32#include <vector>
33
34namespace tcu
35{
36class Surface;
37}
38
39namespace rsg
40{
41
42class ProgramExecutor
43{
44public:
45								ProgramExecutor			(const tcu::PixelBufferAccess& dst, int gridWidth, int gridHeight);
46								~ProgramExecutor		(void);
47
48	void						setTexture				(int samplerNdx, const tcu::Texture2D* texture, const tcu::Sampler& sampler);
49	void						setTexture				(int samplerNdx, const tcu::TextureCube* texture, const tcu::Sampler& sampler);
50
51	void						execute					(const Shader& vertexShader, const Shader& fragmentShader, const std::vector<VariableValue>& uniforms);
52
53private:
54	tcu::PixelBufferAccess		m_dst;
55	int							m_gridWidth;
56	int							m_gridHeight;
57
58	Sampler2DMap				m_samplers2D;
59	SamplerCubeMap				m_samplersCube;
60};
61
62inline void getVertexInterpolationCoords (float& xd, float& yd, float x, float y, int inputElementNdx)
63{
64	if (inputElementNdx % 4 < 2)
65		xd = x;
66	else
67		xd = 1.0f - x;
68
69	if (inputElementNdx % 2 == 0)
70		yd = y;
71	else
72		yd = 1.0f - y;
73}
74
75} // rsg
76
77#endif // _RSGPROGRAMEXECUTOR_HPP
78