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