13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#ifndef _SGLRSHADERPROGRAM_HPP
23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#define _SGLRSHADERPROGRAM_HPP
33c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*-------------------------------------------------------------------------
43c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program OpenGL ES Utilities
53c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * ------------------------------------------------
63c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
73c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Copyright 2014 The Android Open Source Project
83c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
93c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Licensed under the Apache License, Version 2.0 (the "License");
103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * you may not use this file except in compliance with the License.
113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * You may obtain a copy of the License at
123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *      http://www.apache.org/licenses/LICENSE-2.0
143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Unless required by applicable law or agreed to in writing, software
163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * distributed under the License is distributed on an "AS IS" BASIS,
173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * See the License for the specific language governing permissions and
193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * limitations under the License.
203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*!
223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \file
233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief SGLR shader program.
243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuDefs.hpp"
273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "rrShaders.hpp"
283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluShaderUtil.hpp"
293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <vector>
313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <string>
323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
333c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace sglr
343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
363c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace rc
373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
383c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Texture1D;
393c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Texture2D;
403c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TextureCube;
413c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Texture2DArray;
423c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Texture3D;
433c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TextureCubeArray;
443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // rc
453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
463c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ShaderProgram;
473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
483c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace pdec
493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
513c827367444ee418f129b2c238299f49d3264554Jarkko Poyryenum VaryingFlags
523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VARYINGFLAG_NONE		= 0,
543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VARYINGFLAG_FLATSHADE	= (1 << 0),
553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
573c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct VertexAttribute
583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						VertexAttribute				(const std::string& name_, rr::GenericVecType type_) : name(name_), type(type_) { }
603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::string			name;
623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	rr::GenericVecType	type;
633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
653c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct VertexToFragmentVarying
663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						VertexToFragmentVarying		(rr::GenericVecType type_, int flags = VARYINGFLAG_NONE) : type(type_), flatshade((flags & VARYINGFLAG_FLATSHADE) != 0) { }
683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	rr::GenericVecType	type;
703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool				flatshade;
713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
733c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct VertexToGeometryVarying
743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						VertexToGeometryVarying		(rr::GenericVecType type_, int flags = VARYINGFLAG_NONE) : type(type_), flatshade((flags & VARYINGFLAG_FLATSHADE) != 0) { }
763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	rr::GenericVecType	type;
783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool				flatshade;
793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
813c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct GeometryToFragmentVarying
823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						GeometryToFragmentVarying	(rr::GenericVecType type_, int flags = VARYINGFLAG_NONE) : type(type_), flatshade((flags & VARYINGFLAG_FLATSHADE) != 0) { }
843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	rr::GenericVecType	type;
863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool				flatshade;
873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
893c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct FragmentOutput
903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						FragmentOutput				(rr::GenericVecType type_) : type(type_) { }
923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	rr::GenericVecType	type;
943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
963c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct Uniform
973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						Uniform						(const std::string& name_, glu::DataType type_) : name(name_), type(type_) { }
993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::string			name;
1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::DataType		type;
1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct VertexSource
1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						VertexSource				(const std::string& str) : source(str) { }
1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::string			source;
1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct FragmentSource
1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						FragmentSource				(const std::string& str) : source(str) { }
1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::string			source;
1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct GeometrySource
1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						GeometrySource				(const std::string& str) : source(str) { }
1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::string			source;
1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct GeometryShaderDeclaration
1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									GeometryShaderDeclaration	(rr::GeometryShaderInputType inputType_,
1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry																 rr::GeometryShaderOutputType outputType_,
1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry																 size_t numOutputVertices_,
1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry																 size_t numInvocations_ = 1)
1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									: inputType			(inputType_)
1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									, outputType		(outputType_)
1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									, numOutputVertices	(numOutputVertices_)
1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									, numInvocations	(numInvocations_)
1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									{
1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									}
1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	rr::GeometryShaderInputType		inputType;
1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	rr::GeometryShaderOutputType	outputType;
1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	size_t							numOutputVertices;
1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	size_t							numInvocations;
1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ShaderProgramDeclaration
1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											ShaderProgramDeclaration		(void);
1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ShaderProgramDeclaration&				operator<<						(const VertexAttribute&);
1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ShaderProgramDeclaration&				operator<<						(const VertexToFragmentVarying&);
1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ShaderProgramDeclaration&				operator<<						(const VertexToGeometryVarying&);
1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ShaderProgramDeclaration&				operator<<						(const GeometryToFragmentVarying&);
1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ShaderProgramDeclaration&				operator<<						(const FragmentOutput&);
1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ShaderProgramDeclaration&				operator<<						(const Uniform&);
1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ShaderProgramDeclaration&				operator<<						(const VertexSource&);
1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ShaderProgramDeclaration&				operator<<						(const FragmentSource&);
1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ShaderProgramDeclaration&				operator<<						(const GeometrySource&);
1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ShaderProgramDeclaration&				operator<<						(const GeometryShaderDeclaration&);
1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	inline bool								hasGeometryShader				(void) const							{ return m_geometryShaderSet; }
1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	inline size_t							getVertexInputCount				(void) const							{ return m_vertexAttributes.size(); }
1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	inline size_t							getVertexOutputCount			(void) const							{ return hasGeometryShader() ? m_vertexToGeometryVaryings.size() : m_vertexToFragmentVaryings.size(); }
1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	inline size_t							getFragmentInputCount			(void) const							{ return hasGeometryShader() ? m_geometryToFragmentVaryings.size() : m_vertexToFragmentVaryings.size(); }
1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	inline size_t							getFragmentOutputCount			(void) const							{ return m_fragmentOutputs.size(); }
1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	inline size_t							getGeometryInputCount			(void) const							{ return hasGeometryShader() ? m_vertexToGeometryVaryings.size() : 0; }
1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	inline size_t							getGeometryOutputCount			(void) const							{ return hasGeometryShader() ? m_geometryToFragmentVaryings.size() : 0; }
1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool									valid							(void) const;
1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<VertexAttribute>			m_vertexAttributes;
1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<VertexToFragmentVarying>	m_vertexToFragmentVaryings;
1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<VertexToGeometryVarying>	m_vertexToGeometryVaryings;
1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<GeometryToFragmentVarying>	m_geometryToFragmentVaryings;
1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<FragmentOutput>				m_fragmentOutputs;
1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<Uniform>					m_uniforms;
1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::string								m_vertexSource;
1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::string								m_fragmentSource;
1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::string								m_geometrySource;
1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GeometryShaderDeclaration				m_geometryDecl;
1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool									m_vertexShaderSet;
1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool									m_fragmentShaderSet;
1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool									m_geometryShaderSet;
1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	friend class ::sglr::ShaderProgram;
1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // pdec
1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct UniformSlot
1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::string		name;
1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::DataType	type;
1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	union
1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deInt32		i;
1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deInt32		i4[4];
2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		float		f;
2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		float		f4[4];
2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		float		m3[3*3];	//!< row major, can be fed directly to tcu::Matrix constructor
2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		float		m4[4*4];	//!< row major, can be fed directly to tcu::Matrix constructor
2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	} value;
2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	union
2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const void*					ptr;
2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const rc::Texture1D*		tex1D;
2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const rc::Texture2D*		tex2D;
2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const rc::TextureCube*		texCube;
2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const rc::Texture2DArray*	tex2DArray;
2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const rc::Texture3D*		tex3D;
2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const rc::TextureCubeArray*	texCubeArray;
2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	} sampler;
2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	inline UniformSlot (void)
2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: type(glu::TYPE_LAST)
2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		value.i = 0;
2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		sampler.ptr = DE_NULL;
2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ShaderProgram : private rr::VertexShader, private rr::GeometryShader, private rr::FragmentShader
2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry											ShaderProgram		(const pdec::ShaderProgramDeclaration&);
2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual									~ShaderProgram		(void);
2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const UniformSlot&						getUniformByName	(const char* name) const;
2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	inline const rr::VertexShader*			getVertexShader		(void) const { return static_cast<const rr::VertexShader*>(this);   }
2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	inline const rr::FragmentShader*		getFragmentShader	(void) const { return static_cast<const rr::FragmentShader*>(this); }
2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	inline const rr::GeometryShader*		getGeometryShader	(void) const { return static_cast<const rr::GeometryShader*>(this); }
2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void							shadeVertices		(const rr::VertexAttrib* inputs, rr::VertexPacket* const* packets, const int numPackets) const = 0;
2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void							shadeFragments		(rr::FragmentPacket* packets, const int numPackets, const rr::FragmentShadingContext& context) const = 0;
2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void							shadePrimitives		(rr::GeometryEmitter& output, int verticesIn, const rr::PrimitivePacket* packets, const int numPackets, int invocationID) const;
2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<std::string>				m_attributeNames;
2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<UniformSlot>				m_uniforms;
2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const std::string						m_vertSrc;
2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const std::string						m_fragSrc;
2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const std::string						m_geomSrc;
2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const bool								m_hasGeometryShader;
2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	friend class ReferenceContext;	// for uniform access
2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	friend class GLContext;			// for source string access
2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // sglr
2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#endif // _SGLRSHADERPROGRAM_HPP
260