OSDN Git Service

Added utility function for OpenGL extension strings
[android-x86/external-swiftshader.git] / src / OpenGL / libGLESv2 / Context.h
1 // SwiftShader Software Renderer\r
2 //\r
3 // Copyright(c) 2005-2013 TransGaming Inc.\r
4 //\r
5 // All rights reserved. No part of this software may be copied, distributed, transmitted,\r
6 // transcribed, stored in a retrieval system, translated into any human or computer\r
7 // language by any means, or disclosed to third parties without the explicit written\r
8 // agreement of TransGaming Inc. Without such an agreement, no rights or licenses, express\r
9 // or implied, including but not limited to any patent rights, are granted to you.\r
10 //\r
11 \r
12 // Context.h: Defines the Context class, managing all GL state and performing\r
13 // rendering operations. It is the GLES2 specific implementation of EGLContext.\r
14 \r
15 #ifndef LIBGLESV2_CONTEXT_H_\r
16 #define LIBGLESV2_CONTEXT_H_\r
17 \r
18 #include "libEGL/Context.hpp"\r
19 #include "ResourceManager.h"\r
20 #include "common/NameSpace.hpp"\r
21 #include "common/Object.hpp"\r
22 #include "Image.hpp"\r
23 #include "Renderer/Sampler.hpp"\r
24 #include "TransformFeedback.h"\r
25 \r
26 #define GL_APICALL\r
27 #include <GLES2/gl2.h>\r
28 #include <GLES2/gl2ext.h>\r
29 #include <GLES3/gl3.h>\r
30 #define EGLAPI\r
31 #include <EGL/egl.h>\r
32 \r
33 #include <map>\r
34 #include <string>\r
35 \r
36 namespace egl\r
37 {\r
38 class Display;\r
39 class Surface;\r
40 class Config;\r
41 }\r
42 \r
43 namespace es2\r
44 {\r
45 struct TranslatedAttribute;\r
46 struct TranslatedIndexData;\r
47 \r
48 class Device;\r
49 class Buffer;\r
50 class Shader;\r
51 class Program;\r
52 class Texture;\r
53 class Texture2D;\r
54 class Texture3D;\r
55 class TextureCubeMap;\r
56 class TextureExternal;\r
57 class Framebuffer;\r
58 class Renderbuffer;\r
59 class RenderbufferStorage;\r
60 class Colorbuffer;\r
61 class Depthbuffer;\r
62 class StreamingIndexBuffer;\r
63 class Stencilbuffer;\r
64 class DepthStencilbuffer;\r
65 class VertexDataManager;\r
66 class IndexDataManager;\r
67 class Fence;\r
68 class Query;\r
69 class Sampler;\r
70 class VertexArray;\r
71 \r
72 enum\r
73 {\r
74     MAX_VERTEX_ATTRIBS = 16,\r
75         MAX_UNIFORM_VECTORS = 256,   // Device limit\r
76     MAX_VERTEX_UNIFORM_VECTORS = VERTEX_UNIFORM_VECTORS - 3,   // Reserve space for gl_DepthRange\r
77     MAX_VARYING_VECTORS = 10,\r
78     MAX_TEXTURE_IMAGE_UNITS = TEXTURE_IMAGE_UNITS,\r
79     MAX_VERTEX_TEXTURE_IMAGE_UNITS = VERTEX_TEXTURE_IMAGE_UNITS,\r
80     MAX_COMBINED_TEXTURE_IMAGE_UNITS = MAX_TEXTURE_IMAGE_UNITS + MAX_VERTEX_TEXTURE_IMAGE_UNITS,\r
81     MAX_FRAGMENT_UNIFORM_VECTORS = FRAGMENT_UNIFORM_VECTORS - 3,    // Reserve space for gl_DepthRange\r
82     MAX_DRAW_BUFFERS = 1,\r
83 };\r
84 \r
85 const GLenum compressedTextureFormats[] =\r
86 {\r
87         GL_ETC1_RGB8_OES,\r
88 #if (S3TC_SUPPORT)\r
89         GL_COMPRESSED_RGB_S3TC_DXT1_EXT,\r
90         GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,\r
91         GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE,\r
92         GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE,\r
93 #endif\r
94 #if (GL_ES_VERSION_3_0)\r
95         GL_COMPRESSED_R11_EAC,\r
96         GL_COMPRESSED_SIGNED_R11_EAC,\r
97         GL_COMPRESSED_RG11_EAC,\r
98         GL_COMPRESSED_SIGNED_RG11_EAC,\r
99         GL_COMPRESSED_RGB8_ETC2,\r
100         GL_COMPRESSED_SRGB8_ETC2,\r
101         GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,\r
102         GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,\r
103         GL_COMPRESSED_RGBA8_ETC2_EAC,\r
104         GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,\r
105 #endif\r
106 };\r
107 \r
108 const GLint NUM_COMPRESSED_TEXTURE_FORMATS = sizeof(compressedTextureFormats) / sizeof(compressedTextureFormats[0]);\r
109 \r
110 const float ALIASED_LINE_WIDTH_RANGE_MIN = 1.0f;\r
111 const float ALIASED_LINE_WIDTH_RANGE_MAX = 1.0f;\r
112 const float ALIASED_POINT_SIZE_RANGE_MIN = 0.125f;\r
113 const float ALIASED_POINT_SIZE_RANGE_MAX = 8192.0f;\r
114 const float MAX_TEXTURE_MAX_ANISOTROPY = 16.0f;\r
115 \r
116 enum QueryType\r
117 {\r
118     QUERY_ANY_SAMPLES_PASSED,\r
119     QUERY_ANY_SAMPLES_PASSED_CONSERVATIVE,\r
120 \r
121     QUERY_TYPE_COUNT\r
122 };\r
123 \r
124 struct Color\r
125 {\r
126     float red;\r
127     float green;\r
128     float blue;\r
129     float alpha;\r
130 };\r
131 \r
132 // Helper structure describing a single vertex attribute\r
133 class VertexAttribute\r
134 {\r
135   public:\r
136     VertexAttribute() : mType(GL_FLOAT), mSize(0), mNormalized(false), mStride(0), mDivisor(0), mPointer(NULL), mArrayEnabled(false)\r
137     {\r
138         mCurrentValue[0].f = 0.0f;\r
139         mCurrentValue[1].f = 0.0f;\r
140         mCurrentValue[2].f = 0.0f;\r
141         mCurrentValue[3].f = 1.0f;\r
142                 mCurrentValueType = ValueUnion::FloatType;\r
143     }\r
144 \r
145     int typeSize() const\r
146     {\r
147         switch (mType)\r
148         {\r
149         case GL_BYTE:           return mSize * sizeof(GLbyte);\r
150         case GL_UNSIGNED_BYTE:  return mSize * sizeof(GLubyte);\r
151         case GL_SHORT:          return mSize * sizeof(GLshort);\r
152         case GL_UNSIGNED_SHORT: return mSize * sizeof(GLushort);\r
153         case GL_FIXED:          return mSize * sizeof(GLfixed);\r
154         case GL_FLOAT:          return mSize * sizeof(GLfloat);\r
155         default: UNREACHABLE(); return mSize * sizeof(GLfloat);\r
156         }\r
157     }\r
158 \r
159     GLsizei stride() const\r
160     {\r
161         return mStride ? mStride : typeSize();\r
162     }\r
163 \r
164         inline float getCurrentValue(int i) const\r
165         {\r
166                 switch(mCurrentValueType)\r
167                 {\r
168                 case ValueUnion::FloatType:     return mCurrentValue[i].f;\r
169                 case ValueUnion::IntType:       return static_cast<float>(mCurrentValue[i].i);\r
170                 case ValueUnion::UIntType:      return static_cast<float>(mCurrentValue[i].ui);\r
171                 default: UNREACHABLE();         return mCurrentValue[i].f;\r
172                 }\r
173         }\r
174 \r
175         inline GLint getCurrentValueI(int i) const\r
176         {\r
177                 switch(mCurrentValueType)\r
178                 {\r
179                 case ValueUnion::FloatType:     return static_cast<GLint>(mCurrentValue[i].f);\r
180                 case ValueUnion::IntType:       return mCurrentValue[i].i;\r
181                 case ValueUnion::UIntType:      return static_cast<GLint>(mCurrentValue[i].ui);\r
182                 default: UNREACHABLE();         return mCurrentValue[i].i;\r
183                 }\r
184         }\r
185 \r
186         inline GLuint getCurrentValueUI(int i) const\r
187         {\r
188                 switch(mCurrentValueType)\r
189                 {\r
190                 case ValueUnion::FloatType:     return static_cast<GLuint>(mCurrentValue[i].f);\r
191                 case ValueUnion::IntType:       return static_cast<GLuint>(mCurrentValue[i].i);\r
192                 case ValueUnion::UIntType:      return mCurrentValue[i].ui;\r
193                 default: UNREACHABLE();         return mCurrentValue[i].ui;\r
194                 }\r
195         }\r
196 \r
197         inline void setCurrentValue(const GLfloat *values)\r
198         {\r
199                 mCurrentValue[0].f = values[0];\r
200                 mCurrentValue[1].f = values[1];\r
201                 mCurrentValue[2].f = values[2];\r
202                 mCurrentValue[3].f = values[3];\r
203                 mCurrentValueType = ValueUnion::FloatType;\r
204         }\r
205 \r
206         inline void setCurrentValue(const GLint *values)\r
207         {\r
208                 mCurrentValue[0].i = values[0];\r
209                 mCurrentValue[1].i = values[1];\r
210                 mCurrentValue[2].i = values[2];\r
211                 mCurrentValue[3].i = values[3];\r
212                 mCurrentValueType = ValueUnion::IntType;\r
213         }\r
214 \r
215         inline void setCurrentValue(const GLuint *values)\r
216         {\r
217                 mCurrentValue[0].ui = values[0];\r
218                 mCurrentValue[1].ui = values[1];\r
219                 mCurrentValue[2].ui = values[2];\r
220                 mCurrentValue[3].ui = values[3];\r
221                 mCurrentValueType = ValueUnion::UIntType;\r
222         }\r
223 \r
224     // From glVertexAttribPointer\r
225     GLenum mType;\r
226     GLint mSize;\r
227     bool mNormalized;\r
228     GLsizei mStride;   // 0 means natural stride\r
229     GLuint mDivisor;   // From glVertexAttribDivisor\r
230 \r
231     union\r
232     {\r
233         const void *mPointer;\r
234         intptr_t mOffset;\r
235     };\r
236 \r
237     gl::BindingPointer<Buffer> mBoundBuffer;   // Captured when glVertexAttribPointer is called.\r
238 \r
239     bool mArrayEnabled;   // From glEnable/DisableVertexAttribArray\r
240 private:\r
241         union ValueUnion\r
242         {\r
243                 enum Type { FloatType, IntType, UIntType };\r
244 \r
245                 float f;\r
246                 GLint i;\r
247                 GLuint ui;\r
248         };\r
249         ValueUnion mCurrentValue[4];   // From glVertexAttrib\r
250         ValueUnion::Type mCurrentValueType;\r
251 };\r
252 \r
253 typedef VertexAttribute VertexAttributeArray[MAX_VERTEX_ATTRIBS];\r
254 \r
255 // Helper structure to store all raw state\r
256 struct State\r
257 {\r
258     Color colorClearValue;\r
259     GLclampf depthClearValue;\r
260     int stencilClearValue;\r
261 \r
262     bool cullFace;\r
263     GLenum cullMode;\r
264     GLenum frontFace;\r
265     bool depthTest;\r
266     GLenum depthFunc;\r
267     bool blend;\r
268     GLenum sourceBlendRGB;\r
269     GLenum destBlendRGB;\r
270     GLenum sourceBlendAlpha;\r
271     GLenum destBlendAlpha;\r
272     GLenum blendEquationRGB;\r
273     GLenum blendEquationAlpha;\r
274     Color blendColor;\r
275     bool stencilTest;\r
276     GLenum stencilFunc;\r
277     GLint stencilRef;\r
278     GLuint stencilMask;\r
279     GLenum stencilFail;\r
280     GLenum stencilPassDepthFail;\r
281     GLenum stencilPassDepthPass;\r
282     GLuint stencilWritemask;\r
283     GLenum stencilBackFunc;\r
284     GLint stencilBackRef;\r
285     GLuint stencilBackMask;\r
286     GLenum stencilBackFail;\r
287     GLenum stencilBackPassDepthFail;\r
288     GLenum stencilBackPassDepthPass;\r
289     GLuint stencilBackWritemask;\r
290     bool polygonOffsetFill;\r
291     GLfloat polygonOffsetFactor;\r
292     GLfloat polygonOffsetUnits;\r
293     bool sampleAlphaToCoverage;\r
294     bool sampleCoverage;\r
295     GLclampf sampleCoverageValue;\r
296     bool sampleCoverageInvert;\r
297     bool scissorTest;\r
298     bool dither;\r
299     bool primitiveRestartFixedIndex;\r
300     bool rasterizerDiscard;\r
301 \r
302     GLfloat lineWidth;\r
303 \r
304     GLenum generateMipmapHint;\r
305     GLenum fragmentShaderDerivativeHint;\r
306 \r
307     GLint viewportX;\r
308     GLint viewportY;\r
309     GLsizei viewportWidth;\r
310     GLsizei viewportHeight;\r
311     float zNear;\r
312     float zFar;\r
313 \r
314     GLint scissorX;\r
315     GLint scissorY;\r
316     GLsizei scissorWidth;\r
317     GLsizei scissorHeight;\r
318 \r
319     bool colorMaskRed;\r
320     bool colorMaskGreen;\r
321     bool colorMaskBlue;\r
322     bool colorMaskAlpha;\r
323     bool depthMask;\r
324 \r
325     unsigned int activeSampler;   // Active texture unit selector - GL_TEXTURE0\r
326     gl::BindingPointer<Buffer> arrayBuffer;\r
327     gl::BindingPointer<Buffer> elementArrayBuffer;\r
328     GLuint readFramebuffer;\r
329     GLuint drawFramebuffer;\r
330     gl::BindingPointer<Renderbuffer> renderbuffer;\r
331     GLuint currentProgram;\r
332     gl::BindingPointer<VertexArray> vertexArray;\r
333         GLuint transformFeedback;\r
334         gl::BindingPointer<Sampler> sampler[MAX_COMBINED_TEXTURE_IMAGE_UNITS];\r
335 \r
336     VertexAttribute vertexAttribute[MAX_VERTEX_ATTRIBS];\r
337     gl::BindingPointer<Texture> samplerTexture[TEXTURE_TYPE_COUNT][MAX_COMBINED_TEXTURE_IMAGE_UNITS];\r
338         gl::BindingPointer<Query> activeQuery[QUERY_TYPE_COUNT];\r
339 \r
340     GLint unpackAlignment;\r
341     GLint packAlignment;\r
342 };\r
343 \r
344 class Context : public egl::Context\r
345 {\r
346 public:\r
347     Context(const egl::Config *config, const Context *shareContext, EGLint clientVersion);\r
348 \r
349         virtual void makeCurrent(egl::Surface *surface);\r
350         virtual EGLint getClientVersion();\r
351 \r
352     void markAllStateDirty();\r
353 \r
354     // State manipulation\r
355     void setClearColor(float red, float green, float blue, float alpha);\r
356     void setClearDepth(float depth);\r
357     void setClearStencil(int stencil);\r
358 \r
359     void setCullFace(bool enabled);\r
360     bool isCullFaceEnabled() const;\r
361     void setCullMode(GLenum mode);\r
362     void setFrontFace(GLenum front);\r
363 \r
364     void setDepthTest(bool enabled);\r
365     bool isDepthTestEnabled() const;\r
366     void setDepthFunc(GLenum depthFunc);\r
367     void setDepthRange(float zNear, float zFar);\r
368     \r
369     void setBlend(bool enabled);\r
370     bool isBlendEnabled() const;\r
371     void setBlendFactors(GLenum sourceRGB, GLenum destRGB, GLenum sourceAlpha, GLenum destAlpha);\r
372     void setBlendColor(float red, float green, float blue, float alpha);\r
373     void setBlendEquation(GLenum rgbEquation, GLenum alphaEquation);\r
374 \r
375     void setStencilTest(bool enabled);\r
376     bool isStencilTestEnabled() const;\r
377     void setStencilParams(GLenum stencilFunc, GLint stencilRef, GLuint stencilMask);\r
378     void setStencilBackParams(GLenum stencilBackFunc, GLint stencilBackRef, GLuint stencilBackMask);\r
379     void setStencilWritemask(GLuint stencilWritemask);\r
380     void setStencilBackWritemask(GLuint stencilBackWritemask);\r
381     void setStencilOperations(GLenum stencilFail, GLenum stencilPassDepthFail, GLenum stencilPassDepthPass);\r
382     void setStencilBackOperations(GLenum stencilBackFail, GLenum stencilBackPassDepthFail, GLenum stencilBackPassDepthPass);\r
383 \r
384     void setPolygonOffsetFill(bool enabled);\r
385     bool isPolygonOffsetFillEnabled() const;\r
386     void setPolygonOffsetParams(GLfloat factor, GLfloat units);\r
387 \r
388     void setSampleAlphaToCoverage(bool enabled);\r
389     bool isSampleAlphaToCoverageEnabled() const;\r
390     void setSampleCoverage(bool enabled);\r
391     bool isSampleCoverageEnabled() const;\r
392     void setSampleCoverageParams(GLclampf value, bool invert);\r
393 \r
394     void setDither(bool enabled);\r
395     bool isDitherEnabled() const;\r
396 \r
397     void setPrimitiveRestartFixedIndex(bool enabled);\r
398     bool isPrimitiveRestartFixedIndexEnabled() const;\r
399 \r
400     void setRasterizerDiscard(bool enabled);\r
401     bool isRasterizerDiscardEnabled() const;\r
402 \r
403     void setLineWidth(GLfloat width);\r
404 \r
405     void setGenerateMipmapHint(GLenum hint);\r
406     void setFragmentShaderDerivativeHint(GLenum hint);\r
407 \r
408     void setViewportParams(GLint x, GLint y, GLsizei width, GLsizei height);\r
409 \r
410         void setScissorTest(bool enabled);\r
411     bool isScissorTestEnabled() const;\r
412     void setScissorParams(GLint x, GLint y, GLsizei width, GLsizei height);\r
413 \r
414     void setColorMask(bool red, bool green, bool blue, bool alpha);\r
415     void setDepthMask(bool mask);\r
416 \r
417     void setActiveSampler(unsigned int active);\r
418 \r
419     GLuint getReadFramebufferName() const;\r
420     GLuint getDrawFramebufferName() const;\r
421     GLuint getRenderbufferName() const;\r
422 \r
423         GLuint getActiveQuery(GLenum target) const;\r
424 \r
425     GLuint getArrayBufferName() const;\r
426 \r
427     void setEnableVertexAttribArray(unsigned int attribNum, bool enabled);\r
428     void setVertexAttribDivisor(unsigned int attribNum, GLuint divisor);\r
429     const VertexAttribute &getVertexAttribState(unsigned int attribNum);\r
430     void setVertexAttribState(unsigned int attribNum, Buffer *boundBuffer, GLint size, GLenum type,\r
431                               bool normalized, GLsizei stride, const void *pointer);\r
432     const void *getVertexAttribPointer(unsigned int attribNum) const;\r
433 \r
434     const VertexAttributeArray &getVertexAttributes();\r
435 \r
436     void setUnpackAlignment(GLint alignment);\r
437     GLint getUnpackAlignment() const;\r
438 \r
439     void setPackAlignment(GLint alignment);\r
440     GLint getPackAlignment() const;\r
441 \r
442     // These create  and destroy methods are merely pass-throughs to \r
443     // ResourceManager, which owns these object types\r
444     GLuint createBuffer();\r
445     GLuint createShader(GLenum type);\r
446     GLuint createProgram();\r
447     GLuint createTexture();\r
448     GLuint createRenderbuffer();\r
449 \r
450     void deleteBuffer(GLuint buffer);\r
451     void deleteShader(GLuint shader);\r
452     void deleteProgram(GLuint program);\r
453     void deleteTexture(GLuint texture);\r
454     void deleteRenderbuffer(GLuint renderbuffer);\r
455 \r
456     // Framebuffers are owned by the Context, so these methods do not pass through\r
457     GLuint createFramebuffer();\r
458     void deleteFramebuffer(GLuint framebuffer);\r
459 \r
460     // Fences are owned by the Context\r
461     GLuint createFence();\r
462     void deleteFence(GLuint fence);\r
463 \r
464         // Queries are owned by the Context\r
465     GLuint createQuery();\r
466     void deleteQuery(GLuint query);\r
467 \r
468         // Vertex arrays are owned by the Context\r
469         GLuint createVertexArray();\r
470         void deleteVertexArray(GLuint array);\r
471 \r
472         // Transform feedbacks are owned by the Context\r
473         GLuint createTransformFeedback();\r
474         void deleteTransformFeedback(GLuint transformFeedback);\r
475 \r
476         // Samplers are owned by the Context\r
477         GLuint createSampler();\r
478         void deleteSampler(GLuint sampler);\r
479 \r
480     void bindArrayBuffer(GLuint buffer);\r
481     void bindElementArrayBuffer(GLuint buffer);\r
482     void bindTexture2D(GLuint texture);\r
483     void bindTextureCubeMap(GLuint texture);\r
484     void bindTextureExternal(GLuint texture);\r
485         void bindTexture3D(GLuint texture);\r
486     void bindReadFramebuffer(GLuint framebuffer);\r
487     void bindDrawFramebuffer(GLuint framebuffer);\r
488     void bindRenderbuffer(GLuint renderbuffer);\r
489         bool bindVertexArray(GLuint array);\r
490         bool bindTransformFeedback(GLuint transformFeedback);\r
491         bool bindSampler(GLuint unit, GLuint sampler);\r
492     void useProgram(GLuint program);\r
493 \r
494         void beginQuery(GLenum target, GLuint query);\r
495     void endQuery(GLenum target);\r
496 \r
497     void setFramebufferZero(Framebuffer *framebuffer);\r
498 \r
499     void setRenderbufferStorage(RenderbufferStorage *renderbuffer);\r
500 \r
501     void setVertexAttrib(GLuint index, const GLfloat *values);\r
502     void setVertexAttrib(GLuint index, const GLint *values);\r
503     void setVertexAttrib(GLuint index, const GLuint *values);\r
504 \r
505     Buffer *getBuffer(GLuint handle);\r
506     Fence *getFence(GLuint handle);\r
507     Shader *getShader(GLuint handle);\r
508     Program *getProgram(GLuint handle);\r
509     virtual Texture *getTexture(GLuint handle);\r
510     Framebuffer *getFramebuffer(GLuint handle);\r
511     virtual Renderbuffer *getRenderbuffer(GLuint handle);\r
512         Query *getQuery(GLuint handle, bool create, GLenum type);\r
513         VertexArray *getVertexArray(GLuint array);\r
514         TransformFeedback *getTransformFeedback(GLuint transformFeedback);\r
515         TransformFeedback *getTransformFeedback();\r
516         Sampler *getSampler(GLuint sampler);\r
517 \r
518     Buffer *getArrayBuffer();\r
519     Buffer *getElementArrayBuffer();\r
520     Program *getCurrentProgram();\r
521     Texture2D *getTexture2D();\r
522         Texture3D *getTexture3D();\r
523         TextureCubeMap *getTextureCubeMap();\r
524     TextureExternal *getTextureExternal();\r
525     Texture *getSamplerTexture(unsigned int sampler, TextureType type);\r
526     Framebuffer *getReadFramebuffer();\r
527     Framebuffer *getDrawFramebuffer();\r
528 \r
529     bool getFloatv(GLenum pname, GLfloat *params);\r
530     bool getIntegerv(GLenum pname, GLint *params);\r
531     bool getBooleanv(GLenum pname, GLboolean *params);\r
532         bool getTransformFeedbackiv(GLuint xfb, GLenum pname, GLint *param);\r
533 \r
534     bool getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *numParams);\r
535 \r
536     void readPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei *bufSize, void* pixels);\r
537     void clear(GLbitfield mask);\r
538     void drawArrays(GLenum mode, GLint first, GLsizei count);\r
539     void drawElements(GLenum mode, GLsizei count, GLenum type, const void *indices);\r
540     void finish();\r
541     void flush();\r
542 \r
543     void recordInvalidEnum();\r
544     void recordInvalidValue();\r
545     void recordInvalidOperation();\r
546     void recordOutOfMemory();\r
547     void recordInvalidFramebufferOperation();\r
548 \r
549     GLenum getError();\r
550 \r
551     static int getSupportedMultiSampleDepth(sw::Format format, int requested);\r
552     \r
553     void blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, \r
554                          GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,\r
555                          GLbitfield mask);\r
556 \r
557         virtual void bindTexImage(egl::Surface *surface);\r
558         virtual EGLenum validateSharedImage(EGLenum target, GLuint name, GLuint textureLevel);\r
559         virtual egl::Image *createSharedImage(EGLenum target, GLuint name, GLuint textureLevel);\r
560 \r
561         Device *getDevice();\r
562 \r
563         const GLubyte* getExtensions(GLuint index, GLuint* numExt = nullptr);\r
564 \r
565 private:\r
566         virtual ~Context();\r
567 \r
568     bool applyRenderTarget();\r
569     void applyState(GLenum drawMode);\r
570     GLenum applyVertexBuffer(GLint base, GLint first, GLsizei count);\r
571     GLenum applyIndexBuffer(const void *indices, GLsizei count, GLenum mode, GLenum type, TranslatedIndexData *indexInfo);\r
572     void applyShaders();\r
573     void applyTextures();\r
574     void applyTextures(sw::SamplerType type);\r
575         void applyTexture(sw::SamplerType type, int sampler, Texture *texture);\r
576 \r
577     void detachBuffer(GLuint buffer);\r
578     void detachTexture(GLuint texture);\r
579     void detachFramebuffer(GLuint framebuffer);\r
580     void detachRenderbuffer(GLuint renderbuffer);\r
581 \r
582     bool cullSkipsDraw(GLenum drawMode);\r
583     bool isTriangleMode(GLenum drawMode);\r
584 \r
585         const EGLint clientVersion;\r
586     const egl::Config *const mConfig;\r
587 \r
588     State mState;\r
589 \r
590         gl::BindingPointer<Texture2D> mTexture2DZero;\r
591         gl::BindingPointer<Texture3D> mTexture3DZero;\r
592         gl::BindingPointer<TextureCubeMap> mTextureCubeMapZero;\r
593     gl::BindingPointer<TextureExternal> mTextureExternalZero;\r
594 \r
595     typedef std::map<GLint, Framebuffer*> FramebufferMap;\r
596     FramebufferMap mFramebufferMap;\r
597     gl::NameSpace mFramebufferNameSpace;\r
598 \r
599     typedef std::map<GLint, Fence*> FenceMap;\r
600     FenceMap mFenceMap;\r
601     gl::NameSpace mFenceNameSpace;\r
602 \r
603         typedef std::map<GLint, Query*> QueryMap;\r
604     QueryMap mQueryMap;\r
605     gl::NameSpace mQueryNameSpace;\r
606 \r
607         typedef std::map<GLint, VertexArray*> VertexArrayMap;\r
608         VertexArrayMap mVertexArrayMap;\r
609         gl::NameSpace mVertexArrayNameSpace;\r
610 \r
611         typedef std::map<GLint, TransformFeedback*> TransformFeedbackMap;\r
612         TransformFeedbackMap mTransformFeedbackMap;\r
613         gl::NameSpace mTransformFeedbackNameSpace;\r
614 \r
615         typedef std::map<GLint, Sampler*> SamplerMap;\r
616         SamplerMap mSamplerMap;\r
617         gl::NameSpace mSamplerNameSpace;\r
618 \r
619     VertexDataManager *mVertexDataManager;\r
620     IndexDataManager *mIndexDataManager;\r
621 \r
622     // Recorded errors\r
623     bool mInvalidEnum;\r
624     bool mInvalidValue;\r
625     bool mInvalidOperation;\r
626     bool mOutOfMemory;\r
627     bool mInvalidFramebufferOperation;\r
628 \r
629     bool mHasBeenCurrent;\r
630 \r
631     unsigned int mAppliedProgramSerial;\r
632     \r
633     // state caching flags\r
634     bool mDepthStateDirty;\r
635     bool mMaskStateDirty;\r
636     bool mPixelPackingStateDirty;\r
637     bool mBlendStateDirty;\r
638     bool mStencilStateDirty;\r
639     bool mPolygonOffsetStateDirty;\r
640     bool mSampleStateDirty;\r
641     bool mFrontFaceDirty;\r
642     bool mDitherStateDirty;\r
643 \r
644         Device *device;\r
645     ResourceManager *mResourceManager;\r
646 };\r
647 }\r
648 \r
649 #endif   // INCLUDE_CONTEXT_H_\r