13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#ifndef _SGLRREFERENCECONTEXT_HPP
23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#define _SGLRREFERENCECONTEXT_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 Reference Rendering Context.
243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuDefs.hpp"
273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "sglrContext.hpp"
283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuPixelFormat.hpp"
293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuSurface.hpp"
303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTexture.hpp"
313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuVector.hpp"
323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "rrFragmentOperations.hpp"
333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "rrRenderState.hpp"
343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "rrRenderer.hpp"
353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "rrMultisamplePixelBufferAccess.hpp"
365e334966c020f28d520c1c6bb36193990195fe0eJarkko Pöyry#include "gluRenderContext.hpp"
373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluShaderUtil.hpp"
385e334966c020f28d520c1c6bb36193990195fe0eJarkko Pöyry#include "deArrayBuffer.hpp"
393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <map>
413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <vector>
423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
433c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace sglr
443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
453c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace rc
463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
483c827367444ee418f129b2c238299f49d3264554Jarkko Poyryenum
493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	MAX_TEXTURE_SIZE_LOG2		= 14,
513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	MAX_TEXTURE_SIZE			= 1<<MAX_TEXTURE_SIZE_LOG2
523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
543c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass NamedObject
553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
563c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual			~NamedObject		(void) {}
583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32		getName				(void) const	{ return m_name;								}
603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int				getRefCount			(void) const	{ return m_refCount;							}
623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void			incRefCount			(void)			{ m_refCount += 1;								}
633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void			decRefCount			(void)			{ DE_ASSERT(m_refCount > 0); m_refCount -= 1;	}
643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
653c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					NamedObject			(deUint32 name) : m_name(name), m_refCount(1) {}
673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
683c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32		m_name;
703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int				m_refCount;
713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
733c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Texture : public NamedObject
743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
753c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	enum Type
773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TYPE_1D,
793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TYPE_2D,
803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TYPE_CUBE_MAP,
813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TYPE_2D_ARRAY,
823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TYPE_3D,
833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TYPE_CUBE_MAP_ARRAY,
843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TYPE_LAST
863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								Texture			(deUint32 name, Type type);
893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual						~Texture		(void) {}
903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Type						getType			(void) const	{ return m_type;			}
923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int							getBaseLevel	(void) const	{ return m_baseLevel;		}
943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int							getMaxLevel		(void) const	{ return m_maxLevel;		}
953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool						isImmutable		(void) const	{ return m_immutable;		}
963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void						setBaseLevel	(int baseLevel)	{ m_baseLevel = baseLevel;	}
983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void						setMaxLevel		(int maxLevel)	{ m_maxLevel = maxLevel;	}
993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void						setImmutable	(void)			{ m_immutable = true;		}
1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const tcu::Sampler&			getSampler		(void) const	{ return m_sampler;			}
1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::Sampler&				getSampler		(void)			{ return m_sampler;			}
1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Type						m_type;
1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool						m_immutable;
1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::Sampler				m_sampler;
1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int							m_baseLevel;
1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int							m_maxLevel;
1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry//! Class for managing list of texture levels.
1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TextureLevelArray
1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry										TextureLevelArray	(void);
1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry										~TextureLevelArray	(void);
1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1215e334966c020f28d520c1c6bb36193990195fe0eJarkko Pöyry	bool								hasLevel			(int level) const	{ return deInBounds32(level, 0, DE_LENGTH_OF_ARRAY(m_data)) && !m_data[level].empty();	}
1225e334966c020f28d520c1c6bb36193990195fe0eJarkko Pöyry	const tcu::PixelBufferAccess&		getLevel			(int level)			{ DE_ASSERT(hasLevel(level)); return m_access[level];									}
1235e334966c020f28d520c1c6bb36193990195fe0eJarkko Pöyry	const tcu::ConstPixelBufferAccess&	getLevel			(int level) const	{ DE_ASSERT(hasLevel(level)); return m_access[level];									}
1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1255e334966c020f28d520c1c6bb36193990195fe0eJarkko Pöyry	const tcu::ConstPixelBufferAccess*	getLevels			(void) const		{ return &m_access[0];																	}
1265a0a3bbda9383ed89e44198619b9564282905865Jarkko Pöyry	const tcu::ConstPixelBufferAccess*	getEffectiveLevels	(void) const		{ return &m_effectiveAccess[0];															}
1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void								allocLevel			(int level, const tcu::TextureFormat& format, int width, int height, int depth);
1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void								clearLevel			(int level);
1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void								clear				(void);
1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1335a0a3bbda9383ed89e44198619b9564282905865Jarkko Pöyry	void								updateSamplerMode	(tcu::Sampler::DepthStencilMode);
1345a0a3bbda9383ed89e44198619b9564282905865Jarkko Pöyry
1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
1365e334966c020f28d520c1c6bb36193990195fe0eJarkko Pöyry	de::ArrayBuffer<deUint8>			m_data[MAX_TEXTURE_SIZE_LOG2];
1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::PixelBufferAccess				m_access[MAX_TEXTURE_SIZE_LOG2];
1385a0a3bbda9383ed89e44198619b9564282905865Jarkko Pöyry	tcu::ConstPixelBufferAccess			m_effectiveAccess[MAX_TEXTURE_SIZE_LOG2];	//!< the currently effective sampling mode. For Depth-stencil texture always either Depth or stencil.
1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Texture1D : public Texture
1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry										Texture1D		(deUint32 name = 0);
1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual								~Texture1D		(void);
1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void								clearLevels		(void) { m_levels.clear(); }
1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool								hasLevel		(int level) const	{ return m_levels.hasLevel(level);	}
1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const tcu::ConstPixelBufferAccess&	getLevel		(int level) const	{ return m_levels.getLevel(level);	}
1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const tcu::PixelBufferAccess&		getLevel		(int level)			{ return m_levels.getLevel(level);	}
1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void								allocLevel		(int level, const tcu::TextureFormat& format, int width);
1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool								isComplete		(void) const;
1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1575a0a3bbda9383ed89e44198619b9564282905865Jarkko Pöyry	void								updateView		(tcu::Sampler::DepthStencilMode mode); // \note View must be refreshed after texture parameter/size changes, before calling sample*()
1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::Vec4							sample			(float s, float lod) const;
1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void								sample4			(tcu::Vec4 output[4], const float packetTexcoords[4], float lodBias = 0.0f) const;
1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TextureLevelArray					m_levels;
1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::Texture2DView					m_view;
1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Texture2D : public Texture
1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry										Texture2D		(deUint32 name = 0);
1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual								~Texture2D		(void);
1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void								clearLevels		(void) { m_levels.clear(); }
1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool								hasLevel		(int level) const	{ return m_levels.hasLevel(level);	}
1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const tcu::ConstPixelBufferAccess&	getLevel		(int level) const	{ return m_levels.getLevel(level);	}
1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const tcu::PixelBufferAccess&		getLevel		(int level)			{ return m_levels.getLevel(level);	}
1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void								allocLevel		(int level, const tcu::TextureFormat& format, int width, int height);
1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool								isComplete		(void) const;
1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1835a0a3bbda9383ed89e44198619b9564282905865Jarkko Pöyry	void								updateView		(tcu::Sampler::DepthStencilMode mode); // \note View must be refreshed after texture parameter/size changes, before calling sample*()
1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::Vec4							sample			(float s, float t, float lod) const;
1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void								sample4			(tcu::Vec4 output[4], const tcu::Vec2 packetTexcoords[4], float lodBias = 0.0f) const;
1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TextureLevelArray					m_levels;
1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::Texture2DView					m_view;
1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TextureCube : public Texture
1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry										TextureCube		(deUint32 name = 0);
1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual								~TextureCube	(void);
1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void								clearLevels		(void);
2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool								hasFace			(int level, tcu::CubeFace face) const	{ return m_levels[face].hasLevel(level);	}
2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const tcu::PixelBufferAccess&		getFace			(int level, tcu::CubeFace face)			{ return m_levels[face].getLevel(level);	}
2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const tcu::ConstPixelBufferAccess&	getFace			(int level, tcu::CubeFace face) const	{ return m_levels[face].getLevel(level);	}
2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void								allocFace		(int level, tcu::CubeFace face, const tcu::TextureFormat& format, int width, int height);
2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool								isComplete		(void) const;
2085a0a3bbda9383ed89e44198619b9564282905865Jarkko Pöyry	void								updateView		(tcu::Sampler::DepthStencilMode mode); // \note View must be refreshed after texture parameter/size changes, before calling sample*()
2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::Vec4							sample			(float s, float t, float p, float lod) const;
2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void								sample4			(tcu::Vec4 output[4], const tcu::Vec3 packetTexcoords[4], float lodBias = 0.0f) const;
2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TextureLevelArray					m_levels[tcu::CUBEFACE_LAST];
2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TextureCubeView				m_view;
2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Texture2DArray : public Texture
2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry										Texture2DArray	(deUint32 name = 0);
2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual								~Texture2DArray	(void);
2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void								clearLevels		(void) { m_levels.clear(); }
2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool								hasLevel		(int level) const	{ return m_levels.hasLevel(level);	}
2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const tcu::ConstPixelBufferAccess&	getLevel		(int level) const	{ return m_levels.getLevel(level);	}
2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const tcu::PixelBufferAccess&		getLevel		(int level)			{ return m_levels.getLevel(level);	}
2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void								allocLevel		(int level, const tcu::TextureFormat& format, int width, int height, int numLayers);
2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool								isComplete		(void) const;
2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2345a0a3bbda9383ed89e44198619b9564282905865Jarkko Pöyry	void								updateView		(tcu::Sampler::DepthStencilMode mode); // \note View must be refreshed after texture parameter/size changes, before calling sample*()
2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::Vec4							sample			(float s, float t, float r, float lod) const;
2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void								sample4			(tcu::Vec4 output[4], const tcu::Vec3 packetTexcoords[4], float lodBias = 0.0f) const;
2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TextureLevelArray					m_levels;
2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::Texture2DArrayView				m_view;
2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Texture3D : public Texture
2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry										Texture3D		(deUint32 name = 0);
2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual								~Texture3D		(void);
2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void								clearLevels		(void) { m_levels.clear(); }
2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool								hasLevel		(int level) const	{ return m_levels.hasLevel(level);	}
2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const tcu::ConstPixelBufferAccess&	getLevel		(int level) const	{ return m_levels.getLevel(level);	}
2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const tcu::PixelBufferAccess&		getLevel		(int level)			{ return m_levels.getLevel(level);	}
2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void								allocLevel		(int level, const tcu::TextureFormat& format, int width, int height, int numLayers);
2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool								isComplete		(void) const;
2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2605a0a3bbda9383ed89e44198619b9564282905865Jarkko Pöyry	void								updateView		(tcu::Sampler::DepthStencilMode mode); // \note View must be refreshed after texture parameter/size changes, before calling sample*()
2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::Vec4							sample			(float s, float t, float r, float lod) const;
2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void								sample4			(tcu::Vec4 output[4], const tcu::Vec3 packetTexcoords[4], float lodBias = 0.0f) const;
2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TextureLevelArray					m_levels;
2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::Texture3DView					m_view;
2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TextureCubeArray : public Texture
2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry										TextureCubeArray	(deUint32 name = 0);
2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual								~TextureCubeArray	(void);
2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void								clearLevels			(void) { m_levels.clear(); }
2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool								hasLevel			(int level) const	{ return m_levels.hasLevel(level);	}
2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const tcu::ConstPixelBufferAccess&	getLevel			(int level) const	{ return m_levels.getLevel(level);	}
2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const tcu::PixelBufferAccess&		getLevel			(int level)			{ return m_levels.getLevel(level);	}
2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void								allocLevel			(int level, const tcu::TextureFormat& format, int width, int height, int numLayers);
2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool								isComplete			(void) const;
2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2865a0a3bbda9383ed89e44198619b9564282905865Jarkko Pöyry	void								updateView			(tcu::Sampler::DepthStencilMode mode); // \note View must be refreshed after texture parameter/size changes, before calling sample*()
2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::Vec4							sample				(float s, float t, float r, float q, float lod) const;
2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void								sample4				(tcu::Vec4 output[4], const tcu::Vec4 packetTexcoords[4], float lodBias = 0.0f) const;
2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TextureLevelArray					m_levels;
2933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TextureCubeArrayView			m_view;
2943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Renderbuffer : public NamedObject
2973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2983c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	enum Format
3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		FORMAT_DEPTH_COMPONENT16,
3023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		FORMAT_RGBA4,
3033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		FORMAT_RGB5_A1,
3043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		FORMAT_RGB565,
3053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		FORMAT_STENCIL_INDEX8,
3063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		FORMAT_LAST
3083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
3093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								Renderbuffer		(deUint32 name);
3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual						~Renderbuffer		(void);
3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void						setStorage			(const tcu::TextureFormat& format, int width, int height);
3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int							getWidth			(void) const	{ return m_data.getWidth();		}
3163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int							getHeight			(void) const	{ return m_data.getHeight();	}
3173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TextureFormat			getFormat			(void) const	{ return m_data.getFormat();	}
3183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::PixelBufferAccess		getAccess			(void)			{ return m_data.getAccess();	}
3203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::ConstPixelBufferAccess	getAccess			(void) const	{ return m_data.getAccess();	}
3213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3223c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TextureLevel			m_data;
3243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
3253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3263c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass Framebuffer : public NamedObject
3273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3283c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
3293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	enum AttachmentPoint
3303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ATTACHMENTPOINT_COLOR0,
3323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ATTACHMENTPOINT_DEPTH,
3333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ATTACHMENTPOINT_STENCIL,
3343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ATTACHMENTPOINT_LAST
3363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
3373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	enum AttachmentType
3393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ATTACHMENTTYPE_RENDERBUFFER,
3413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ATTACHMENTTYPE_TEXTURE,
3423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		ATTACHMENTTYPE_LAST
3443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
3453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	enum TexTarget
3473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TEXTARGET_2D,
3493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TEXTARGET_CUBE_MAP_POSITIVE_X,
3503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TEXTARGET_CUBE_MAP_POSITIVE_Y,
3513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TEXTARGET_CUBE_MAP_POSITIVE_Z,
3523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TEXTARGET_CUBE_MAP_NEGATIVE_X,
3533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TEXTARGET_CUBE_MAP_NEGATIVE_Y,
3543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TEXTARGET_CUBE_MAP_NEGATIVE_Z,
3553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TEXTARGET_2D_ARRAY,
3563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TEXTARGET_3D,
3573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TEXTARGET_CUBE_MAP_ARRAY,
3583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TEXTARGET_LAST
3603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
3613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	struct Attachment
3633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		AttachmentType	type;
3653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32		name;
3663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TexTarget		texTarget;
3673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int				level;
3683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int				layer;
3693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		Attachment (void)
3713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			: type		(ATTACHMENTTYPE_LAST)
3723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			, name		(0)
3733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			, texTarget	(TEXTARGET_LAST)
3743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			, level		(0)
3753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			, layer		(0)
3763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
3773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
3783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
3793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							Framebuffer		(deUint32 name);
3813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual					~Framebuffer	(void);
3823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Attachment&				getAttachment	(AttachmentPoint point)			{ return m_attachments[point]; }
3843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const Attachment&		getAttachment	(AttachmentPoint point) const	{ return m_attachments[point]; }
3853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3863c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
3873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	Attachment			m_attachments[ATTACHMENTPOINT_LAST];
3893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
3903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3913c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass DataBuffer : public NamedObject
3923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3933c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
3943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							DataBuffer			(deUint32 name) : NamedObject(name) {}
3953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							~DataBuffer			(void) {}
3963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void					setStorage			(int size) { m_data.resize(size); }
3983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int						getSize				(void) const	{ return (int)m_data.size();					}
4003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const deUint8*			getData				(void) const	{ return m_data.empty() ? DE_NULL : &m_data[0];	}
4013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint8*				getData				(void)			{ return m_data.empty() ? DE_NULL : &m_data[0];	}
4023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4033c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
4043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<deUint8>	m_data;
4053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
4063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4073c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass VertexArray : public NamedObject
4083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4093c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
4103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	struct VertexAttribArray
4113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
4123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		bool			enabled;
4133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int				size;
4143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int				stride;
4153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32		type;
4163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		bool			normalized;
4183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		bool			integer;
4193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int				divisor;
4203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		/**
4223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		  ! These three variables define the state. bufferDeleted is needed to distinguish
4233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		  ! drawing from user pointer and offset to a deleted buffer from each other.
4243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		  !
4253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		  ! Only these three combinations are possible:
4263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		  ! 1) bufferDeleted = false, bufferBinding = NULL, pointer = user_ptr.   < render from a user ptr
4273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		  ! 2) bufferDeleted = false, bufferBinding = ptr,  pointer = offset.     < render from a buffer with offset
4283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		  ! 3) bufferDeleted = true,  bufferBinding = NULL, pointer = offset      < render from a deleted buffer. Don't do anything
4293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		  !
4303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		  ! (bufferFreed = true) implies (bufferBinding = NULL)
4313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		 */
4323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		bool			bufferDeleted;
4333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		rc::DataBuffer*	bufferBinding;
4343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const void*		pointer;
4353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
4363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									VertexArray		(deUint32 name, int maxVertexAttribs);
4383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									~VertexArray	(void) {}
4393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	rc::DataBuffer*					m_elementArrayBufferBinding;
4413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<VertexAttribArray>	m_arrays;
4423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
4433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4443c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ShaderProgramObjectContainer : public NamedObject
4453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4463c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
4473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									ShaderProgramObjectContainer	(deUint32 name, ShaderProgram* program);
4483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry									~ShaderProgramObjectContainer	(void);
4493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ShaderProgram*					m_program;
4513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool							m_deleteFlag;
4523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
4533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4543c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename T>
4553c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ObjectManager
4563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4573c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
4583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							ObjectManager			(void);
4593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							~ObjectManager			(void);
4603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32				allocateName			(void);
4623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void					insert					(T* object);
4633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	T*						find					(deUint32 name);
4643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void					acquireReference		(T* object);
4663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void					releaseReference		(T* object);
4673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int						getCount				(void) const { return (int)m_objects.size(); }
4693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void					getAll					(typename std::vector<T*>& objects) const;
4703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4713c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
4723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							ObjectManager			(const ObjectManager<T>& other);
4733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ObjectManager&			operator=				(const ObjectManager<T>& other);
4743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32				m_lastName;
4763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::map<deUint32, T*>	m_objects;
4773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
4783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4793c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename T>
4803c827367444ee418f129b2c238299f49d3264554Jarkko PoyryObjectManager<T>::ObjectManager (void)
4813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: m_lastName(0)
4823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4853c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename T>
4863c827367444ee418f129b2c238299f49d3264554Jarkko PoyryObjectManager<T>::~ObjectManager (void)
4873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	DE_ASSERT(m_objects.size() == 0);
4893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4913c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename T>
4923c827367444ee418f129b2c238299f49d3264554Jarkko PoyrydeUint32 ObjectManager<T>::allocateName (void)
4933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TCU_CHECK(m_lastName != 0xffffffff);
4953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return ++m_lastName;
4963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4983c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename T>
4993c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid ObjectManager<T>::insert (T* object)
5003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32 name = object->getName();
5023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	DE_ASSERT(object->getName() != 0);
5033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (name > m_lastName)
5053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_lastName = name;
5063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_objects.insert(std::pair<deUint32, T*>(name, object));
5083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5103c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename T>
5113c827367444ee418f129b2c238299f49d3264554Jarkko PoyryT* ObjectManager<T>::find (deUint32 name)
5123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	typename std::map<deUint32, T*>::iterator it = m_objects.find(name);
5143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (it != m_objects.end())
5153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return it->second;
5163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	else
5173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return DE_NULL;
5183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5203c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename T>
5213c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid ObjectManager<T>::acquireReference (T* object)
5223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	DE_ASSERT(find(object->getName()) == object);
5243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	object->incRefCount();
5253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5273c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename T>
5283c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid ObjectManager<T>::releaseReference (T* object)
5293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	DE_ASSERT(find(object->getName()) == object);
5313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	object->decRefCount();
5323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (object->getRefCount() == 0)
5343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
5353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_objects.erase(object->getName());
5363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		delete object;
5373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
5383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5403c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename T>
5413c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid ObjectManager<T>::getAll (typename std::vector<T*>& objects) const
5423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	objects.resize(m_objects.size());
5443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	typename std::vector<T*>::iterator dst = objects.begin();
5453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (typename std::map<deUint32, T*>::const_iterator i = m_objects.begin();
5473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		 i != m_objects.end(); i++)
5483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
5493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		*dst++ = i->second;
5503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
5513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // rc
5543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5553c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct ReferenceContextLimits
5563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ReferenceContextLimits (void)
5583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		: contextType				(glu::ApiType::es(3,0))
5593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, maxTextureImageUnits		(16)
5603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, maxTexture2DSize			(2048)
5613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, maxTextureCubeSize		(2048)
5623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, maxTexture2DArrayLayers	(256)
5633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, maxTexture3DSize			(256)
5643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, maxRenderbufferSize		(2048)
5653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		, maxVertexAttribs			(16)
5663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
5673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
5683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								ReferenceContextLimits	(const glu::RenderContext& renderCtx);
5703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void						addExtension			(const char* extension);
5723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::ContextType			contextType;
5743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int							maxTextureImageUnits;
5763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int							maxTexture2DSize;
5773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int							maxTextureCubeSize;
5783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int							maxTexture2DArrayLayers;
5793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int							maxTexture3DSize;
5803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int							maxRenderbufferSize;
5813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int							maxVertexAttribs;
5823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Both variants are needed since there are glGetString() and glGetStringi()
5843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<std::string>	extensionList;
5853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::string					extensionStr;
5863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
5873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5883c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ReferenceContextBuffers
5893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5903c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
5913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ReferenceContextBuffers (const tcu::PixelFormat& colorBits, int depthBits, int stencilBits, int width, int height, int samples = 1);
5923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	rr::MultisamplePixelBufferAccess	getColorbuffer		(void) { return rr::MultisamplePixelBufferAccess::fromMultisampleAccess(m_colorbuffer.getAccess());	}
5943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	rr::MultisamplePixelBufferAccess	getDepthbuffer		(void) { return rr::MultisamplePixelBufferAccess::fromMultisampleAccess(m_depthbuffer.getAccess());	}
5953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	rr::MultisamplePixelBufferAccess	getStencilbuffer	(void) { return rr::MultisamplePixelBufferAccess::fromMultisampleAccess(m_stencilbuffer.getAccess());	}
5963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5973c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
5983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TextureLevel	m_colorbuffer;
5993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TextureLevel	m_depthbuffer;
6003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TextureLevel	m_stencilbuffer;
6013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
6023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6033c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ReferenceContext : public Context
6043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6053c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
6063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							ReferenceContext		(const ReferenceContextLimits& limits, const rr::MultisamplePixelBufferAccess& colorbuffer, const rr::MultisamplePixelBufferAccess& depthbuffer, const rr::MultisamplePixelBufferAccess& stencilbuffer);
6073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual					~ReferenceContext		(void);
6083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual int				getWidth				(void) const	{ return m_defaultColorbuffer.raw().getHeight();	}
6103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual int				getHeight				(void) const	{ return m_defaultColorbuffer.raw().getDepth();		}
6113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			viewport				(int x, int y, int width, int height) { m_viewport = tcu::IVec4(x, y, width, height); }
6133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			activeTexture			(deUint32 texture);
6143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			bindTexture				(deUint32 target, deUint32 texture);
6163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			genTextures				(int numTextures, deUint32* textures);
6173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			deleteTextures			(int numTextures, const deUint32* textures);
6183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			bindFramebuffer			(deUint32 target, deUint32 framebuffer);
6203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			genFramebuffers			(int numFramebuffers, deUint32* framebuffers);
6213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			deleteFramebuffers		(int numFramebuffers, const deUint32* framebuffers);
6223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			bindRenderbuffer		(deUint32 target, deUint32 renderbuffer);
6243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			genRenderbuffers		(int numRenderbuffers, deUint32* renderbuffers);
6253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			deleteRenderbuffers		(int numRenderbuffers, const deUint32* renderbuffers);
6263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			pixelStorei				(deUint32 pname, int param);
6283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			texImage1D				(deUint32 target, int level, deUint32 internalFormat, int width, int border, deUint32 format, deUint32 type, const void* data);
6293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			texImage2D				(deUint32 target, int level, deUint32 internalFormat, int width, int height, int border, deUint32 format, deUint32 type, const void* data);
6303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			texImage3D				(deUint32 target, int level, deUint32 internalFormat, int width, int height, int depth, int border, deUint32 format, deUint32 type, const void* data);
6313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			texSubImage1D			(deUint32 target, int level, int xoffset, int width, deUint32 format, deUint32 type, const void* data);
6323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			texSubImage2D			(deUint32 target, int level, int xoffset, int yoffset, int width, int height, deUint32 format, deUint32 type, const void* data);
6333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			texSubImage3D			(deUint32 target, int level, int xoffset, int yoffset, int zoffset, int width, int height, int depth, deUint32 format, deUint32 type, const void* data);
6343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			copyTexImage1D			(deUint32 target, int level, deUint32 internalFormat, int x, int y, int width, int border);
6353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			copyTexImage2D			(deUint32 target, int level, deUint32 internalFormat, int x, int y, int width, int height, int border);
6363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			copyTexSubImage1D		(deUint32 target, int level, int xoffset, int x, int y, int width);
6373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			copyTexSubImage2D		(deUint32 target, int level, int xoffset, int yoffset, int x, int y, int width, int height);
6383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			copyTexSubImage3D		(deUint32 target, int level, int xoffset, int yoffset, int zoffset, int x, int y, int width, int height);
6393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			texStorage2D			(deUint32 target, int levels, deUint32 internalFormat, int width, int height);
6413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			texStorage3D			(deUint32 target, int levels, deUint32 internalFormat, int width, int height, int depth);
6423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			texParameteri			(deUint32 target, deUint32 pname, int value);
6443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			framebufferTexture2D	(deUint32 target, deUint32 attachment, deUint32 textarget, deUint32 texture, int level);
6463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			framebufferTextureLayer	(deUint32 target, deUint32 attachment, deUint32 texture, int level, int layer);
6473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			framebufferRenderbuffer	(deUint32 target, deUint32 attachment, deUint32 renderbuffertarget, deUint32 renderbuffer);
6483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual deUint32		checkFramebufferStatus	(deUint32 target);
6493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			getFramebufferAttachmentParameteriv	(deUint32 target, deUint32 attachment, deUint32 pname, int* params);
6513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			renderbufferStorage				(deUint32 target, deUint32 internalformat, int width, int height);
6533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			renderbufferStorageMultisample	(deUint32 target, int samples, deUint32 internalFormat, int width, int height);
6543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			bindBuffer				(deUint32 target, deUint32 buffer);
6563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			genBuffers				(int numBuffers, deUint32* buffers);
6573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			deleteBuffers			(int numBuffers, const deUint32* buffers);
6583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			bufferData				(deUint32 target, deIntptr size, const void* data, deUint32 usage);
6603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			bufferSubData			(deUint32 target, deIntptr offset, deIntptr size, const void* data);
6613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			clearColor				(float red, float green, float blue, float alpha);
6633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			clearDepthf				(float depth);
6643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			clearStencil			(int stencil);
6653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			clear					(deUint32 buffers);
6673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			clearBufferiv			(deUint32 buffer, int drawbuffer, const int* value);
6683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			clearBufferfv			(deUint32 buffer, int drawbuffer, const float* value);
6693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			clearBufferuiv			(deUint32 buffer, int drawbuffer, const deUint32* value);
6703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			clearBufferfi			(deUint32 buffer, int drawbuffer, float depth, int stencil);
6713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			scissor					(int x, int y, int width, int height);
6723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			enable					(deUint32 cap);
6743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			disable					(deUint32 cap);
6753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			stencilFunc				(deUint32 func, int ref, deUint32 mask);
6773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			stencilOp				(deUint32 sfail, deUint32 dpfail, deUint32 dppass);
6783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			stencilFuncSeparate		(deUint32 face, deUint32 func, int ref, deUint32 mask);
6793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			stencilOpSeparate		(deUint32 face, deUint32 sfail, deUint32 dpfail, deUint32 dppass);
6803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			depthFunc				(deUint32 func);
6823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			depthRangef				(float n, float f);
6833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			depthRange				(double n, double f);
6843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			polygonOffset			(float factor, float units);
6863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			provokingVertex			(deUint32 convention);
6873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			primitiveRestartIndex	(deUint32 index);
6883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			blendEquation			(deUint32 mode);
6903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			blendEquationSeparate	(deUint32 modeRGB, deUint32 modeAlpha);
6913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			blendFunc				(deUint32 src, deUint32 dst);
6923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			blendFuncSeparate		(deUint32 srcRGB, deUint32 dstRGB, deUint32 srcAlpha, deUint32 dstAlpha);
6933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			blendColor				(float red, float green, float blue, float alpha);
6943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			colorMask				(deBool r, deBool g, deBool b, deBool a);
6963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			depthMask				(deBool mask);
6973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			stencilMask				(deUint32 mask);
6983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			stencilMaskSeparate		(deUint32 face, deUint32 mask);
6993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			blitFramebuffer			(int srcX0, int srcY0, int srcX1, int srcY1, int dstX0, int dstY0, int dstX1, int dstY1, deUint32 mask, deUint32 filter);
7013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			invalidateSubFramebuffer(deUint32 target, int numAttachments, const deUint32* attachments, int x, int y, int width, int height);
7033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			invalidateFramebuffer	(deUint32 target, int numAttachments, const deUint32* attachments);
7043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			bindVertexArray			(deUint32 array);
7063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			genVertexArrays			(int numArrays, deUint32* vertexArrays);
7073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			deleteVertexArrays		(int numArrays, const deUint32* vertexArrays);
7083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			vertexAttribPointer		(deUint32 index, int size, deUint32 type, deBool normalized, int stride, const void *pointer);
7103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			vertexAttribIPointer	(deUint32 index, int size, deUint32 type, int stride, const void *pointer);
7113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			enableVertexAttribArray	(deUint32 index);
7123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			disableVertexAttribArray(deUint32 index);
7133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			vertexAttribDivisor		(deUint32 index, deUint32 divisor);
7143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			vertexAttrib1f			(deUint32 index, float);
7163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			vertexAttrib2f			(deUint32 index, float, float);
7173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			vertexAttrib3f			(deUint32 index, float, float, float);
7183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			vertexAttrib4f			(deUint32 index, float, float, float, float);
7193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			vertexAttribI4i			(deUint32 index, deInt32, deInt32, deInt32, deInt32);
7203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			vertexAttribI4ui		(deUint32 index, deUint32, deUint32, deUint32, deUint32);
7213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual deInt32			getAttribLocation		(deUint32 program, const char *name);
7233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			uniform1f				(deInt32 location, float);
7253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			uniform1i				(deInt32 location, deInt32);
7263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			uniform1fv				(deInt32 index, deInt32 count, const float*);
7273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			uniform2fv				(deInt32 index, deInt32 count, const float*);
7283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			uniform3fv				(deInt32 index, deInt32 count, const float*);
7293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			uniform4fv				(deInt32 index, deInt32 count, const float*);
7303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			uniform1iv				(deInt32 index, deInt32 count, const deInt32*);
7313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			uniform2iv				(deInt32 index, deInt32 count, const deInt32*);
7323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			uniform3iv				(deInt32 index, deInt32 count, const deInt32*);
7333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			uniform4iv				(deInt32 index, deInt32 count, const deInt32*);
734b0a384bf9b6816d4e3e594b37955d220d66ac7d1Jarkko Pöyry	virtual void			uniformMatrix3fv		(deInt32 location, deInt32 count, deBool transpose, const float *value);
735b0a384bf9b6816d4e3e594b37955d220d66ac7d1Jarkko Pöyry	virtual void			uniformMatrix4fv		(deInt32 location, deInt32 count, deBool transpose, const float *value);
7363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual deInt32			getUniformLocation		(deUint32 program, const char *name);
7373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			lineWidth				(float);
7393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			drawArrays				(deUint32 mode, int first, int count);
7413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			drawArraysInstanced		(deUint32 mode, int first, int count, int instanceCount);
7423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			drawElements			(deUint32 mode, int count, deUint32 type, const void *indices);
7433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			drawElementsBaseVertex	(deUint32 mode, int count, deUint32 type, const void *indices, int baseVertex);
7443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			drawElementsInstanced	(deUint32 mode, int count, deUint32 type, const void *indices, int instanceCount);
7453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			drawElementsInstancedBaseVertex	(deUint32 mode, int count, deUint32 type, const void *indices, int instanceCount, int baseVertex);
7463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			drawRangeElements		(deUint32 mode, deUint32 start, deUint32 end, int count, deUint32 type, const void *indices);
7473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			drawRangeElementsBaseVertex (deUint32 mode, deUint32 start, deUint32 end, int count, deUint32 type, const void *indices, int baseVertex);
7483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			drawArraysIndirect		(deUint32 mode, const void *indirect);
7493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			drawElementsIndirect	(deUint32 mode, deUint32 type, const void *indirect);
7503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			multiDrawArrays			(deUint32 mode, const int* first, const int* count, int primCount);
7523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			multiDrawElements		(deUint32 mode, const int* count, deUint32 type, const void** indices, int primCount);
7533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			multiDrawElementsBaseVertex (deUint32 mode, const int* count, deUint32 type, const void** indices, int primCount, const int* baseVertex);
7543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual deUint32		createProgram			(ShaderProgram* program);
7563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			useProgram				(deUint32 program);
7573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			deleteProgram			(deUint32 program);
7583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			readPixels				(int x, int y, int width, int height, deUint32 format, deUint32 type, void* data);
7603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual deUint32		getError				(void);
7613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			finish					(void);
7623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void			getIntegerv				(deUint32 pname, int* params);
7643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual const char*		getString				(deUint32 pname);
7653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Expose helpers from Context.
7673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using Context::readPixels;
7683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using Context::texImage2D;
7693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using Context::texSubImage2D;
7703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7713c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
7723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							ReferenceContext		(const ReferenceContext& other); // Not allowed!
7733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ReferenceContext&		operator=				(const ReferenceContext& other); // Not allowed!
7743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void					deleteTexture			(rc::Texture* texture);
7763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void					deleteFramebuffer		(rc::Framebuffer* framebuffer);
7773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void					deleteRenderbuffer		(rc::Renderbuffer* renderbuffer);
7783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void					deleteBuffer			(rc::DataBuffer* buffer);
7793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void					deleteVertexArray		(rc::VertexArray* vertexArray);
7803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void					deleteProgramObject		(rc::ShaderProgramObjectContainer* sp);
7813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void					acquireFboAttachmentReference	(const rc::Framebuffer::Attachment& attachment);
7833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void					releaseFboAttachmentReference	(const rc::Framebuffer::Attachment& attachment);
7843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::PixelBufferAccess	getFboAttachment		(const rc::Framebuffer& framebuffer, rc::Framebuffer::AttachmentPoint point);
7853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32				blitResolveMultisampleFramebuffer (deUint32 mask, const tcu::IVec4& srcRect, const tcu::IVec4& dstRect, bool flipX, bool flipY);
7873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	rr::MultisamplePixelBufferAccess	getDrawColorbuffer		(void)	{ return (m_drawFramebufferBinding) ? (rr::MultisamplePixelBufferAccess::fromSinglesampleAccess(getFboAttachment(*m_drawFramebufferBinding, rc::Framebuffer::ATTACHMENTPOINT_COLOR0)))	:	(m_defaultColorbuffer);		}
7893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	rr::MultisamplePixelBufferAccess	getDrawDepthbuffer		(void)	{ return (m_drawFramebufferBinding) ? (rr::MultisamplePixelBufferAccess::fromSinglesampleAccess(getFboAttachment(*m_drawFramebufferBinding, rc::Framebuffer::ATTACHMENTPOINT_DEPTH)))	:	(m_defaultDepthbuffer);		}
7903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	rr::MultisamplePixelBufferAccess	getDrawStencilbuffer	(void)	{ return (m_drawFramebufferBinding) ? (rr::MultisamplePixelBufferAccess::fromSinglesampleAccess(getFboAttachment(*m_drawFramebufferBinding, rc::Framebuffer::ATTACHMENTPOINT_STENCIL)))	:	(m_defaultStencilbuffer);	}
7913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	rr::MultisamplePixelBufferAccess	getReadColorbuffer		(void)	{ return (m_readFramebufferBinding) ? (rr::MultisamplePixelBufferAccess::fromSinglesampleAccess(getFboAttachment(*m_readFramebufferBinding, rc::Framebuffer::ATTACHMENTPOINT_COLOR0)))	:	(m_defaultColorbuffer);		}
7923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	rr::MultisamplePixelBufferAccess	getReadDepthbuffer		(void)	{ return (m_readFramebufferBinding) ? (rr::MultisamplePixelBufferAccess::fromSinglesampleAccess(getFboAttachment(*m_readFramebufferBinding, rc::Framebuffer::ATTACHMENTPOINT_DEPTH)))	:	(m_defaultDepthbuffer);		}
7933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	rr::MultisamplePixelBufferAccess	getReadStencilbuffer	(void)	{ return (m_readFramebufferBinding) ? (rr::MultisamplePixelBufferAccess::fromSinglesampleAccess(getFboAttachment(*m_readFramebufferBinding, rc::Framebuffer::ATTACHMENTPOINT_STENCIL)))	:	(m_defaultStencilbuffer);	}
7943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const rc::Texture2D&	getTexture2D			(int unitNdx) const;
7963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const rc::TextureCube&	getTextureCube			(int unitNdx) const;
7973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const tcu::IVec4&		getViewport				(void) const { return m_viewport; }
7983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void					setError				(deUint32 error);
8003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void					setTex1DBinding			(int unit, rc::Texture1D*			tex1D);
8023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void					setTex2DBinding			(int unit, rc::Texture2D*			tex2D);
8033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void					setTexCubeBinding		(int unit, rc::TextureCube*			texCube);
8043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void					setTex2DArrayBinding	(int unit, rc::Texture2DArray*		tex2DArray);
8053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void					setTex3DBinding			(int unit, rc::Texture3D*			tex3D);
8063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void					setTexCubeArrayBinding	(int unit, rc::TextureCubeArray*	texCubeArray);
8073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void					setBufferBinding		(deUint32 target, rc::DataBuffer* buffer);
8093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	rc::DataBuffer*			getBufferBinding		(deUint32 target) const;
8103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void*					getPixelPackPtr			(void* ptrOffset) const			{ return m_pixelPackBufferBinding ? (void*)((deUintptr)m_pixelPackBufferBinding->getData()+(deUintptr)ptrOffset) : ptrOffset;	}
8123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const void*				getPixelUnpackPtr		(const void* ptrOffset) const	{ return m_pixelUnpackBufferBinding ? (const void*)((deUintptr)m_pixelUnpackBufferBinding->getData()+(deUintptr)ptrOffset) : ptrOffset; }
8133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool					predrawErrorChecks		(deUint32 mode);
8153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void					drawWithReference		(const rr::PrimitiveList& primitives, int instanceCount);
8163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Helpers for getting valid access object based on current unpack state.
8183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::ConstPixelBufferAccess		getUnpack2DAccess		(const tcu::TextureFormat& format, int width, int height, const void* data);
8193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::ConstPixelBufferAccess		getUnpack3DAccess		(const tcu::TextureFormat& format, int width, int height, int depth, const void* data);
8203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void					uniformv				(deInt32 index, glu::DataType type, deInt32 count, const void*);
8223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	struct TextureUnit
8243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
8253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		rc::Texture1D*			tex1DBinding;
8273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		rc::Texture2D*			tex2DBinding;
8283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		rc::TextureCube*		texCubeBinding;
8293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		rc::Texture2DArray*		tex2DArrayBinding;
8303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		rc::Texture3D*			tex3DBinding;
8313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		rc::TextureCubeArray*	texCubeArrayBinding;
8323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		rc::Texture1D			default1DTex;
8343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		rc::Texture2D			default2DTex;
8353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		rc::TextureCube			defaultCubeTex;
8363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		rc::Texture2DArray		default2DArrayTex;
8373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		rc::Texture3D			default3DTex;
8383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		rc::TextureCubeArray	defaultCubeArrayTex;
8393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TextureUnit (void)
8413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			: tex1DBinding			(DE_NULL)
8423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			, tex2DBinding			(DE_NULL)
8433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			, texCubeBinding		(DE_NULL)
8443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			, tex2DArrayBinding		(DE_NULL)
8453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			, tex3DBinding			(DE_NULL)
8463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			, texCubeArrayBinding	(DE_NULL)
8473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			, default1DTex			(0)
8483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			, default2DTex			(0)
8493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			, defaultCubeTex		(0)
8503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			, default2DArrayTex		(0)
8513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			, default3DTex			(0)
8523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			, defaultCubeArrayTex	(0)
8533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
8543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
8553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
8563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	struct StencilState
8583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
8593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32		func;
8603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int				ref;
8613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32		opMask;
8623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32		opStencilFail;
8633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32		opDepthFail;
8643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32		opDepthPass;
8653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		deUint32		writeMask;
8663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		StencilState (void);
8683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
8693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ReferenceContextLimits						m_limits;
8713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	rr::MultisamplePixelBufferAccess			m_defaultColorbuffer;
8733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	rr::MultisamplePixelBufferAccess			m_defaultDepthbuffer;
8743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	rr::MultisamplePixelBufferAccess			m_defaultStencilbuffer;
8753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	rc::VertexArray								m_clientVertexArray;
8763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::IVec4									m_viewport;
8783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	rc::ObjectManager<rc::Texture>				m_textures;
8803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	rc::ObjectManager<rc::Framebuffer>			m_framebuffers;
8813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	rc::ObjectManager<rc::Renderbuffer>			m_renderbuffers;
8823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	rc::ObjectManager<rc::DataBuffer>			m_buffers;
8833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	rc::ObjectManager<rc::VertexArray>			m_vertexArrays;
8843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	rc::ObjectManager<rc::ShaderProgramObjectContainer>		m_programs;
8853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int											m_activeTexture;
8873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<TextureUnit>					m_textureUnits;
8883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	rc::Texture1D								m_emptyTex1D;
8893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	rc::Texture2D								m_emptyTex2D;
8903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	rc::TextureCube								m_emptyTexCube;
8913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	rc::Texture2DArray							m_emptyTex2DArray;
8923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	rc::Texture3D								m_emptyTex3D;
8933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	rc::TextureCubeArray						m_emptyTexCubeArray;
8943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int											m_pixelUnpackRowLength;
8963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int											m_pixelUnpackSkipRows;
8973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int											m_pixelUnpackSkipPixels;
8983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int											m_pixelUnpackImageHeight;
8993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int											m_pixelUnpackSkipImages;
9003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int											m_pixelUnpackAlignment;
9013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int											m_pixelPackAlignment;
9023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	rc::Framebuffer*							m_readFramebufferBinding;
9043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	rc::Framebuffer*							m_drawFramebufferBinding;
9053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	rc::Renderbuffer*							m_renderbufferBinding;
9063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	rc::VertexArray*							m_vertexArrayBinding;
9073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	rc::ShaderProgramObjectContainer*			m_currentProgram;
9083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	rc::DataBuffer*								m_arrayBufferBinding;
9103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	rc::DataBuffer*								m_pixelPackBufferBinding;
9113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	rc::DataBuffer*								m_pixelUnpackBufferBinding;
9123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	rc::DataBuffer*								m_transformFeedbackBufferBinding;
9133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	rc::DataBuffer*								m_uniformBufferBinding;
9143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	rc::DataBuffer*								m_copyReadBufferBinding;
9153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	rc::DataBuffer*								m_copyWriteBufferBinding;
9163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	rc::DataBuffer*								m_drawIndirectBufferBinding;
9173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::Vec4									m_clearColor;
9193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	float										m_clearDepth;
9203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int											m_clearStencil;
9213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool										m_scissorEnabled;
9233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::IVec4									m_scissorBox;
9243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool										m_stencilTestEnabled;
9263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	StencilState								m_stencil[rr::FACETYPE_LAST];
9273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool										m_depthTestEnabled;
9293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32									m_depthFunc;
9303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	float										m_depthRangeNear;
9313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	float										m_depthRangeFar;
9323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	float										m_polygonOffsetFactor;
9343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	float										m_polygonOffsetUnits;
9353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool										m_polygonOffsetFillEnabled;
9363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool										m_provokingFirstVertexConvention;
9383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool										m_blendEnabled;
9403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32									m_blendModeRGB;
9413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32									m_blendModeAlpha;
9423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32									m_blendFactorSrcRGB;
9433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32									m_blendFactorDstRGB;
9443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32									m_blendFactorSrcAlpha;
9453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32									m_blendFactorDstAlpha;
9463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::Vec4									m_blendColor;
9473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool										m_sRGBUpdateEnabled;
9493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool										m_depthClampEnabled;
9513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::BVec4									m_colorMask;
9533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool										m_depthMask;
9543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<rr::GenericVec4>				m_currentAttribs;
9563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	float										m_lineWidth;
9573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool										m_primitiveRestartFixedIndex;
9593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool										m_primitiveRestartSettableIndex;
9603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32									m_primitiveRestartIndex;
9613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32									m_lastError;
9633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	rr::FragmentProcessor						m_fragmentProcessor;
9653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<rr::Fragment>					m_fragmentBuffer;
9663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<float>							m_fragmentDepths;
96793df37596ea66700965094b3aa2830cf4f2ca5aaJarkko Pöyry} DE_WARN_UNUSED_TYPE;
9683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // sglr
9703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#endif // _SGLRREFERENCECONTEXT_HPP
972