Context.h revision ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddb
1a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block// 2a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. 3a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block// Use of this source code is governed by a BSD-style license that can be 4a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block// found in the LICENSE file. 5a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block// 6a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 7a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block// Context.h: Defines the gl::Context class, managing all GL state and performing 8a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block// rendering operations. It is the GLES2 specific implementation of EGLContext. 9a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 105abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick#ifndef LIBGLESV2_CONTEXT_H_ 115abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick#define LIBGLESV2_CONTEXT_H_ 12a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 13a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block#define GL_APICALL 14a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block#include <GLES2/gl2.h> 15ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch#include <GLES2/gl2ext.h> 16a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block#define EGLAPI 17a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block#include <EGL/egl.h> 18a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block#include <d3d9.h> 19a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 20a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block#include <map> 21a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 22a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block#include "common/angleutils.h" 235abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick#include "libGLESv2/ResourceManager.h" 245abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick#include "libGLESv2/RefCountObject.h" 25a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 26a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blocknamespace egl 27a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block{ 28a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blockclass Display; 29a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blockclass Surface; 30a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blockclass Config; 31a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block} 32a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 33a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blocknamespace gl 34a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block{ 35a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blockstruct TranslatedAttribute; 36a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blockstruct TranslatedIndexData; 37a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 38a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blockclass Buffer; 39a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blockclass Shader; 40a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blockclass Program; 41a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blockclass Texture; 42a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blockclass Texture2D; 43a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blockclass TextureCubeMap; 44a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blockclass Framebuffer; 45a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blockclass Renderbuffer; 465abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrickclass RenderbufferStorage; 47a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blockclass Colorbuffer; 48a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blockclass Depthbuffer; 49a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blockclass Stencilbuffer; 505abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrickclass DepthStencilbuffer; 51a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blockclass VertexDataManager; 52a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blockclass IndexDataManager; 53a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blockclass Blit; 54ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdochclass Fence; 55a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 56a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blockenum 57a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block{ 58ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch MAX_VERTEX_ATTRIBS = 16, 59ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch MAX_VERTEX_UNIFORM_VECTORS = 256 - 2, // 256 is the minimum for SM2, and in practice the maximum for DX9. Reserve space for dx_HalfPixelSize and dx_DepthRange. 60ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch MAX_VARYING_VECTORS_SM2 = 8, 61ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch MAX_VARYING_VECTORS_SM3 = 10, 62a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block MAX_COMBINED_TEXTURE_IMAGE_UNITS = 16, 63a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block MAX_VERTEX_TEXTURE_IMAGE_UNITS = 0, 64a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block MAX_TEXTURE_IMAGE_UNITS = 16, 65ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch MAX_FRAGMENT_UNIFORM_VECTORS_SM2 = 32 - 3, // Reserve space for dx_Viewport, dx_Depth, and dx_DepthRange. dx_PointOrLines and dx_FrontCCW use separate bool registers. 66ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch MAX_FRAGMENT_UNIFORM_VECTORS_SM3 = 224 - 3, 67a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block MAX_DRAW_BUFFERS = 1, 68a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 69a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block IMPLEMENTATION_COLOR_READ_FORMAT = GL_RGB, 70a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block IMPLEMENTATION_COLOR_READ_TYPE = GL_UNSIGNED_SHORT_5_6_5 71a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block}; 72a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 73a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blockconst float ALIASED_LINE_WIDTH_RANGE_MIN = 1.0f; 74a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blockconst float ALIASED_LINE_WIDTH_RANGE_MAX = 1.0f; 75a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blockconst float ALIASED_POINT_SIZE_RANGE_MIN = 1.0f; 765abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrickconst float ALIASED_POINT_SIZE_RANGE_MAX_SM2 = 1.0f; 775abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrickconst float ALIASED_POINT_SIZE_RANGE_MAX_SM3 = 64.0f; 78a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 79a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blockstruct Color 80a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block{ 81a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block float red; 82a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block float green; 83a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block float blue; 84a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block float alpha; 85a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block}; 86a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 87a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block// Helper structure describing a single vertex attribute 88ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdochclass VertexAttribute 89a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block{ 90a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block public: 91ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch VertexAttribute() : mType(GL_FLOAT), mSize(0), mNormalized(false), mStride(0), mPointer(NULL), mArrayEnabled(false) 92a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block { 93ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch mCurrentValue[0] = 0.0f; 94ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch mCurrentValue[1] = 0.0f; 95ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch mCurrentValue[2] = 0.0f; 96ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch mCurrentValue[3] = 1.0f; 97a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block } 98a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 99ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch int typeSize() const 100ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch { 101ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch switch (mType) 102ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch { 103ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch case GL_BYTE: return mSize * sizeof(GLbyte); 104ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch case GL_UNSIGNED_BYTE: return mSize * sizeof(GLubyte); 105ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch case GL_SHORT: return mSize * sizeof(GLshort); 106ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch case GL_UNSIGNED_SHORT: return mSize * sizeof(GLushort); 107ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch case GL_FIXED: return mSize * sizeof(GLfixed); 108ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch case GL_FLOAT: return mSize * sizeof(GLfloat); 109ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch default: UNREACHABLE(); return mSize * sizeof(GLfloat); 110ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch } 111ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch } 112ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch 113ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch GLsizei stride() const 114ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch { 115ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch return mStride ? mStride : typeSize(); 116ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch } 117ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch 118ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch // From glVertexAttribPointer 119a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block GLenum mType; 120a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block GLint mSize; 121a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block bool mNormalized; 122ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch GLsizei mStride; // 0 means natural stride 123a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 124ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch union 125ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch { 126ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch const void *mPointer; 127ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch intptr_t mOffset; 128ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch }; 129a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 130ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch BindingPointer<Buffer> mBoundBuffer; // Captured when glVertexAttribPointer is called. 131a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 132ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch bool mArrayEnabled; // From glEnable/DisableVertexAttribArray 133ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch float mCurrentValue[4]; // From glVertexAttrib 134a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block}; 135a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 136ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdochtypedef VertexAttribute VertexAttributeArray[MAX_VERTEX_ATTRIBS]; 137ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch 138a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block// Helper structure to store all raw state 139a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blockstruct State 140a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block{ 141a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block Color colorClearValue; 142a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block GLclampf depthClearValue; 143a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block int stencilClearValue; 144a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 145a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block bool cullFace; 146a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block GLenum cullMode; 147a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block GLenum frontFace; 148a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block bool depthTest; 149a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block GLenum depthFunc; 150a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block bool blend; 151a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block GLenum sourceBlendRGB; 152a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block GLenum destBlendRGB; 153a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block GLenum sourceBlendAlpha; 154a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block GLenum destBlendAlpha; 155a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block GLenum blendEquationRGB; 156a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block GLenum blendEquationAlpha; 157a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block Color blendColor; 158a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block bool stencilTest; 159a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block GLenum stencilFunc; 160a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block GLint stencilRef; 161a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block GLuint stencilMask; 162a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block GLenum stencilFail; 163a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block GLenum stencilPassDepthFail; 164a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block GLenum stencilPassDepthPass; 165a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block GLuint stencilWritemask; 166a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block GLenum stencilBackFunc; 167a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block GLint stencilBackRef; 168a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block GLuint stencilBackMask; 169a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block GLenum stencilBackFail; 170a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block GLenum stencilBackPassDepthFail; 171a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block GLenum stencilBackPassDepthPass; 172a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block GLuint stencilBackWritemask; 173a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block bool polygonOffsetFill; 174a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block GLfloat polygonOffsetFactor; 175a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block GLfloat polygonOffsetUnits; 176a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block bool sampleAlphaToCoverage; 177a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block bool sampleCoverage; 178a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block GLclampf sampleCoverageValue; 179a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block bool sampleCoverageInvert; 180a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block bool scissorTest; 181a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block bool dither; 182a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 183a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block GLfloat lineWidth; 184a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 185a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block GLenum generateMipmapHint; 186ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch GLenum fragmentShaderDerivativeHint; 187a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 188a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block GLint viewportX; 189a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block GLint viewportY; 190a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block GLsizei viewportWidth; 191a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block GLsizei viewportHeight; 192a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block float zNear; 193a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block float zFar; 194a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 195a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block GLint scissorX; 196a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block GLint scissorY; 197a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block GLsizei scissorWidth; 198a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block GLsizei scissorHeight; 199a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 200a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block bool colorMaskRed; 201a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block bool colorMaskGreen; 202a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block bool colorMaskBlue; 203a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block bool colorMaskAlpha; 204a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block bool depthMask; 205a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 206a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block int activeSampler; // Active texture unit selector - GL_TEXTURE0 2075abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick BindingPointer<Buffer> arrayBuffer; 2085abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick BindingPointer<Buffer> elementArrayBuffer; 2095abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick GLuint readFramebuffer; 2105abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick GLuint drawFramebuffer; 2115abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick BindingPointer<Renderbuffer> renderbuffer; 212a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block GLuint currentProgram; 213a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 214ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch VertexAttribute vertexAttribute[MAX_VERTEX_ATTRIBS]; 2155abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick BindingPointer<Texture> samplerTexture[SAMPLER_TYPE_COUNT][MAX_TEXTURE_IMAGE_UNITS]; 216a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 217a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block GLint unpackAlignment; 218a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block GLint packAlignment; 219a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block}; 220a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 221a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blockclass Context 222a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block{ 223a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block public: 2245abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick Context(const egl::Config *config, const gl::Context *shareContext); 225a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 226a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block ~Context(); 227a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 228a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void makeCurrent(egl::Display *display, egl::Surface *surface); 229a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 230a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void markAllStateDirty(); 231a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 232a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block // State manipulation 233a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void setClearColor(float red, float green, float blue, float alpha); 234a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 235a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void setClearDepth(float depth); 236a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 237a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void setClearStencil(int stencil); 238a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 239a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void setCullFace(bool enabled); 240a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block bool isCullFaceEnabled() const; 241a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 242a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void setCullMode(GLenum mode); 243a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 244a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void setFrontFace(GLenum front); 245a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 246a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void setDepthTest(bool enabled); 247a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block bool isDepthTestEnabled() const; 248a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 249a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void setDepthFunc(GLenum depthFunc); 250a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 251a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void setDepthRange(float zNear, float zFar); 252a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 253a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void setBlend(bool enabled); 254a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block bool isBlendEnabled() const; 255a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 256a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void setBlendFactors(GLenum sourceRGB, GLenum destRGB, GLenum sourceAlpha, GLenum destAlpha); 257a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void setBlendColor(float red, float green, float blue, float alpha); 258a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void setBlendEquation(GLenum rgbEquation, GLenum alphaEquation); 259a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 260a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void setStencilTest(bool enabled); 261a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block bool isStencilTestEnabled() const; 262a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 263a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void setStencilParams(GLenum stencilFunc, GLint stencilRef, GLuint stencilMask); 264a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void setStencilBackParams(GLenum stencilBackFunc, GLint stencilBackRef, GLuint stencilBackMask); 265a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void setStencilWritemask(GLuint stencilWritemask); 266a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void setStencilBackWritemask(GLuint stencilBackWritemask); 267a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void setStencilOperations(GLenum stencilFail, GLenum stencilPassDepthFail, GLenum stencilPassDepthPass); 268a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void setStencilBackOperations(GLenum stencilBackFail, GLenum stencilBackPassDepthFail, GLenum stencilBackPassDepthPass); 269a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 270a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void setPolygonOffsetFill(bool enabled); 271a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block bool isPolygonOffsetFillEnabled() const; 272a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 273a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void setPolygonOffsetParams(GLfloat factor, GLfloat units); 274a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 275a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void setSampleAlphaToCoverage(bool enabled); 276a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block bool isSampleAlphaToCoverageEnabled() const; 277a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 278a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void setSampleCoverage(bool enabled); 279a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block bool isSampleCoverageEnabled() const; 280a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 281a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void setSampleCoverageParams(GLclampf value, bool invert); 282a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 283a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void setScissorTest(bool enabled); 284a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block bool isScissorTestEnabled() const; 285a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 286a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void setDither(bool enabled); 287a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block bool isDitherEnabled() const; 288a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 289a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void setLineWidth(GLfloat width); 290a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 291a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void setGenerateMipmapHint(GLenum hint); 292ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch void setFragmentShaderDerivativeHint(GLenum hint); 293a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 294a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void setViewportParams(GLint x, GLint y, GLsizei width, GLsizei height); 295a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 296a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void setScissorParams(GLint x, GLint y, GLsizei width, GLsizei height); 297a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 298a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void setColorMask(bool red, bool green, bool blue, bool alpha); 299a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void setDepthMask(bool mask); 300a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 301a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void setActiveSampler(int active); 302a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 3035abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick GLuint getReadFramebufferHandle() const; 3045abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick GLuint getDrawFramebufferHandle() const; 305a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block GLuint getRenderbufferHandle() const; 306a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 307a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block GLuint getArrayBufferHandle() const; 308a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 309ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch void setEnableVertexAttribArray(unsigned int attribNum, bool enabled); 310ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch const VertexAttribute &getVertexAttribState(unsigned int attribNum); 3115abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick void setVertexAttribState(unsigned int attribNum, Buffer *boundBuffer, GLint size, GLenum type, 312a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block bool normalized, GLsizei stride, const void *pointer); 313a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block const void *getVertexAttribPointer(unsigned int attribNum) const; 314a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 315ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch const VertexAttributeArray &getVertexAttributes(); 316a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 317a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void setUnpackAlignment(GLint alignment); 318a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block GLint getUnpackAlignment() const; 319a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 320a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void setPackAlignment(GLint alignment); 321a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block GLint getPackAlignment() const; 322a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 3235abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick // These create and destroy methods are merely pass-throughs to 3245abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick // ResourceManager, which owns these object types 325a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block GLuint createBuffer(); 326a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block GLuint createShader(GLenum type); 327a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block GLuint createProgram(); 328a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block GLuint createTexture(); 329a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block GLuint createRenderbuffer(); 330a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 331a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void deleteBuffer(GLuint buffer); 332a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void deleteShader(GLuint shader); 333a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void deleteProgram(GLuint program); 334a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void deleteTexture(GLuint texture); 335a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void deleteRenderbuffer(GLuint renderbuffer); 336a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 3375abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick // Framebuffers are owned by the Context, so these methods do not pass through 3385abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick GLuint createFramebuffer(); 3395abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick void deleteFramebuffer(GLuint framebuffer); 3405abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick 341ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch // Fences are owned by the Context. 342ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch GLuint createFence(); 343ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch void deleteFence(GLuint fence); 344ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch 345a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void bindArrayBuffer(GLuint buffer); 346a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void bindElementArrayBuffer(GLuint buffer); 347a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void bindTexture2D(GLuint texture); 348a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void bindTextureCubeMap(GLuint texture); 3495abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick void bindReadFramebuffer(GLuint framebuffer); 3505abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick void bindDrawFramebuffer(GLuint framebuffer); 351a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void bindRenderbuffer(GLuint renderbuffer); 352a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void useProgram(GLuint program); 353a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 354a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void setFramebufferZero(Framebuffer *framebuffer); 3555abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick 3565abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick void setRenderbufferStorage(RenderbufferStorage *renderbuffer); 357a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 358a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void setVertexAttrib(GLuint index, const GLfloat *values); 359a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 360a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block Buffer *getBuffer(GLuint handle); 361ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch Fence *getFence(GLuint handle); 362a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block Shader *getShader(GLuint handle); 363a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block Program *getProgram(GLuint handle); 364a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block Texture *getTexture(GLuint handle); 365a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block Framebuffer *getFramebuffer(GLuint handle); 366a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block Renderbuffer *getRenderbuffer(GLuint handle); 367a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 368a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block Buffer *getArrayBuffer(); 369a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block Buffer *getElementArrayBuffer(); 370a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block Program *getCurrentProgram(); 371a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block Texture2D *getTexture2D(); 372a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block TextureCubeMap *getTextureCubeMap(); 373a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block Texture *getSamplerTexture(unsigned int sampler, SamplerType type); 3745abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick Framebuffer *getReadFramebuffer(); 3755abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick Framebuffer *getDrawFramebuffer(); 376a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 377a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block bool getFloatv(GLenum pname, GLfloat *params); 378a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block bool getIntegerv(GLenum pname, GLint *params); 379a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block bool getBooleanv(GLenum pname, GLboolean *params); 380a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 381a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block bool getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *numParams); 382a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 383a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block bool applyRenderTarget(bool ignoreViewport); 384a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void applyState(GLenum drawMode); 385ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch GLenum applyVertexBuffer(GLint first, GLsizei count); 386a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block GLenum applyIndexBuffer(const void *indices, GLsizei count, GLenum mode, GLenum type, TranslatedIndexData *indexInfo); 387a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void applyShaders(); 388a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void applyTextures(); 389a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 390a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void readPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels); 391a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void clear(GLbitfield mask); 392a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void drawArrays(GLenum mode, GLint first, GLsizei count); 393ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch void drawElements(GLenum mode, GLsizei count, GLenum type, const void *indices); 394a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void finish(); 395a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void flush(); 396a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 397ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch // Draw the last segment of a line loop 398ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch void drawClosingLine(unsigned int first, unsigned int last); 399ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch void drawClosingLine(GLsizei count, GLenum type, const void *indices); 400ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch 401a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void recordInvalidEnum(); 402a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void recordInvalidValue(); 403a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void recordInvalidOperation(); 404a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void recordOutOfMemory(); 405a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void recordInvalidFramebufferOperation(); 406a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 407a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block GLenum getError(); 408a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 4095abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick bool supportsShaderModel3() const; 410ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch int getMaximumVaryingVectors() const; 411ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch int getMaximumFragmentUniformVectors() const; 412ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch int getMaximumRenderbufferDimension() const; 413ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch int getMaximumTextureDimension() const; 414ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch int getMaximumCubeTextureDimension() const; 415ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch int getMaximumTextureLevel() const; 4165abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick GLsizei getMaxSupportedSamples() const; 4175abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick int getNearestSupportedSamples(D3DFORMAT format, int requested) const; 418a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block const char *getExtensionString() const; 419ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch bool supportsEventQueries() const; 4205abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick bool supportsCompressedTextures() const; 421ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch bool supportsFloatTextures() const; 422ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch bool supportsFloatLinearFilter() const; 423ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch bool supportsFloatRenderableTextures() const; 424ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch bool supportsHalfFloatTextures() const; 425ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch bool supportsHalfFloatLinearFilter() const; 426ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch bool supportsHalfFloatRenderableTextures() const; 427ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch bool supportsLuminanceTextures() const; 428ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch bool supportsLuminanceAlphaTextures() const; 429ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch bool supports32bitIndices() const; 4305abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick 4315abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick void blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, 4325abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, 4335abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick GLbitfield mask); 434a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 435a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block Blit *getBlitter() { return mBlit; } 436a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 437a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block const D3DCAPS9 &getDeviceCaps() { return mDeviceCaps; } 438a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 439a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block private: 440a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block DISALLOW_COPY_AND_ASSIGN(Context); 441a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 442a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void lookupAttributeMapping(TranslatedAttribute *attributes); 443a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 444a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void detachBuffer(GLuint buffer); 445a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void detachTexture(GLuint texture); 446a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void detachFramebuffer(GLuint framebuffer); 447a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void detachRenderbuffer(GLuint renderbuffer); 448a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 449a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block Texture *getIncompleteTexture(SamplerType type); 450a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 451a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block bool cullSkipsDraw(GLenum drawMode); 452a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block bool isTriangleMode(GLenum drawMode); 453a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 454a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block const egl::Config *const mConfig; 455a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 456a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block State mState; 457a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 458ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch BindingPointer<Texture2D> mTexture2DZero; 459ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch BindingPointer<TextureCubeMap> mTextureCubeMapZero; 460a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 461a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block typedef std::map<GLuint, Framebuffer*> FramebufferMap; 462a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block FramebufferMap mFramebufferMap; 463a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 464ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch typedef std::map<GLuint, Fence*> FenceMap; 465ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch FenceMap mFenceMap; 466ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch 467a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block void initExtensionString(); 468a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block std::string mExtensionString; 469a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 470a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block VertexDataManager *mVertexDataManager; 471a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block IndexDataManager *mIndexDataManager; 472a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 473a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block Blit *mBlit; 4745abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick 475ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch BindingPointer<Texture> mIncompleteTextures[SAMPLER_TYPE_COUNT]; 476a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 477a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block // Recorded errors 478a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block bool mInvalidEnum; 479a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block bool mInvalidValue; 480a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block bool mInvalidOperation; 481a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block bool mOutOfMemory; 482a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block bool mInvalidFramebufferOperation; 483a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 484a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block bool mHasBeenCurrent; 485a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 486a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block unsigned int mAppliedProgram; 487a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block unsigned int mAppliedRenderTargetSerial; 488a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block unsigned int mAppliedDepthbufferSerial; 4895abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick unsigned int mAppliedStencilbufferSerial; 490ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch bool mDepthStencilInitialized; 491a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 4925abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick bool mSupportsShaderModel3; 493ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch int mMaxRenderbufferDimension; 494ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch int mMaxTextureDimension; 495ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch int mMaxCubeTextureDimension; 496ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch int mMaxTextureLevel; 4975abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick std::map<D3DFORMAT, bool *> mMultiSampleSupport; 4985abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick GLsizei mMaxSupportedSamples; 499ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch bool mSupportsEventQueries; 5005abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick bool mSupportsCompressedTextures; 501ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch bool mSupportsFloatTextures; 502ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch bool mSupportsFloatLinearFilter; 503ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch bool mSupportsFloatRenderableTextures; 504ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch bool mSupportsHalfFloatTextures; 505ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch bool mSupportsHalfFloatLinearFilter; 506ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch bool mSupportsHalfFloatRenderableTextures; 507ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch bool mSupportsLuminanceTextures; 508ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch bool mSupportsLuminanceAlphaTextures; 509ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch bool mSupports32bitIndices; 510a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 511a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block // state caching flags 512a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block bool mClearStateDirty; 513a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block bool mCullStateDirty; 514a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block bool mDepthStateDirty; 515a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block bool mMaskStateDirty; 516a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block bool mPixelPackingStateDirty; 517a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block bool mBlendStateDirty; 518a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block bool mStencilStateDirty; 519a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block bool mPolygonOffsetStateDirty; 520a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block bool mScissorStateDirty; 521a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block bool mSampleStateDirty; 522a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block bool mFrontFaceDirty; 523a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block bool mDitherStateDirty; 524a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 525a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block IDirect3DStateBlock9 *mMaskedClearSavedState; 526a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 527a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block D3DCAPS9 mDeviceCaps; 5285abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick 5295abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick ResourceManager *mResourceManager; 530a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block}; 531a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block} 532a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 533a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blockextern "C" 534a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block{ 535a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block// Exported functions for use by EGL 5365abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrickgl::Context *glCreateContext(const egl::Config *config, const gl::Context *shareContext); 537a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blockvoid glDestroyContext(gl::Context *context); 538a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blockvoid glMakeCurrent(gl::Context *context, egl::Display *display, egl::Surface *surface); 539a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Blockgl::Context *glGetCurrentContext(); 540a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block__eglMustCastToProperFunctionPointerType __stdcall glGetProcAddress(const char *procname); 541a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block} 542a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block 543a9bfd6c4a32dfd9cc032cb67c6ccb8d09c16f579Steve Block#endif // INCLUDE_CONTEXT_H_ 544