1 // SwiftShader Software Renderer
\r
3 // Copyright(c) 2005-2013 TransGaming Inc.
\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
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
15 #ifndef LIBGLESV2_CONTEXT_H_
\r
16 #define LIBGLESV2_CONTEXT_H_
\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 "common/Image.hpp"
\r
23 #include "Renderer/Sampler.hpp"
\r
24 #include "TransformFeedback.h"
\r
26 #include <GLES2/gl2.h>
\r
27 #include <GLES2/gl2ext.h>
\r
28 #include <GLES3/gl3.h>
\r
29 #include <EGL/egl.h>
\r
43 struct TranslatedAttribute;
\r
44 struct TranslatedIndexData;
\r
53 class Texture2DArray;
\r
54 class TextureCubeMap;
\r
55 class TextureExternal;
\r
58 class RenderbufferStorage;
\r
61 class StreamingIndexBuffer;
\r
62 class Stencilbuffer;
\r
63 class DepthStencilbuffer;
\r
64 class VertexDataManager;
\r
65 class IndexDataManager;
\r
74 MAX_VERTEX_ATTRIBS = VERTEX_ATTRIBUTES,
\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 MAX_ELEMENT_INDEX = 0x7FFFFFFF,
\r
84 MAX_ELEMENTS_INDICES = 0x7FFFFFFF,
\r
85 MAX_ELEMENTS_VERTICES = 0x7FFFFFFF,
\r
86 MAX_VERTEX_OUTPUT_VECTORS = 16,
\r
87 MAX_FRAGMENT_INPUT_VECTORS = 15,
\r
88 MIN_PROGRAM_TEXEL_OFFSET = -8,
\r
89 MAX_PROGRAM_TEXEL_OFFSET = 7,
\r
92 const GLenum compressedTextureFormats[] =
\r
96 GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
\r
97 GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
\r
98 GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE,
\r
99 GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE,
\r
101 #if (GL_ES_VERSION_3_0)
\r
102 GL_COMPRESSED_R11_EAC,
\r
103 GL_COMPRESSED_SIGNED_R11_EAC,
\r
104 GL_COMPRESSED_RG11_EAC,
\r
105 GL_COMPRESSED_SIGNED_RG11_EAC,
\r
106 GL_COMPRESSED_RGB8_ETC2,
\r
107 GL_COMPRESSED_SRGB8_ETC2,
\r
108 GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,
\r
109 GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,
\r
110 GL_COMPRESSED_RGBA8_ETC2_EAC,
\r
111 GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,
\r
112 GL_COMPRESSED_RGBA_ASTC_4x4_KHR,
\r
113 GL_COMPRESSED_RGBA_ASTC_5x4_KHR,
\r
114 GL_COMPRESSED_RGBA_ASTC_5x5_KHR,
\r
115 GL_COMPRESSED_RGBA_ASTC_6x5_KHR,
\r
116 GL_COMPRESSED_RGBA_ASTC_6x6_KHR,
\r
117 GL_COMPRESSED_RGBA_ASTC_8x5_KHR,
\r
118 GL_COMPRESSED_RGBA_ASTC_8x6_KHR,
\r
119 GL_COMPRESSED_RGBA_ASTC_8x8_KHR,
\r
120 GL_COMPRESSED_RGBA_ASTC_10x5_KHR,
\r
121 GL_COMPRESSED_RGBA_ASTC_10x6_KHR,
\r
122 GL_COMPRESSED_RGBA_ASTC_10x8_KHR,
\r
123 GL_COMPRESSED_RGBA_ASTC_10x10_KHR,
\r
124 GL_COMPRESSED_RGBA_ASTC_12x10_KHR,
\r
125 GL_COMPRESSED_RGBA_ASTC_12x12_KHR,
\r
126 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,
\r
127 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,
\r
128 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,
\r
129 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,
\r
130 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,
\r
131 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,
\r
132 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,
\r
133 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,
\r
134 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,
\r
135 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,
\r
136 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,
\r
137 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,
\r
138 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,
\r
139 GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR,
\r
143 const GLint NUM_COMPRESSED_TEXTURE_FORMATS = sizeof(compressedTextureFormats) / sizeof(compressedTextureFormats[0]);
\r
145 const float ALIASED_LINE_WIDTH_RANGE_MIN = 1.0f;
\r
146 const float ALIASED_LINE_WIDTH_RANGE_MAX = 1.0f;
\r
147 const float ALIASED_POINT_SIZE_RANGE_MIN = 0.125f;
\r
148 const float ALIASED_POINT_SIZE_RANGE_MAX = 8192.0f;
\r
149 const float MAX_TEXTURE_MAX_ANISOTROPY = 16.0f;
\r
153 QUERY_ANY_SAMPLES_PASSED,
\r
154 QUERY_ANY_SAMPLES_PASSED_CONSERVATIVE,
\r
155 QUERY_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN,
\r
168 // Helper structure describing a single vertex attribute
\r
169 class VertexAttribute
\r
172 VertexAttribute() : mType(GL_FLOAT), mSize(0), mNormalized(false), mStride(0), mDivisor(0), mPointer(NULL), mArrayEnabled(false)
\r
174 mCurrentValue[0].f = 0.0f;
\r
175 mCurrentValue[1].f = 0.0f;
\r
176 mCurrentValue[2].f = 0.0f;
\r
177 mCurrentValue[3].f = 1.0f;
\r
178 mCurrentValueType = ValueUnion::FloatType;
\r
181 int typeSize() const
\r
185 case GL_BYTE: return mSize * sizeof(GLbyte);
\r
186 case GL_UNSIGNED_BYTE: return mSize * sizeof(GLubyte);
\r
187 case GL_SHORT: return mSize * sizeof(GLshort);
\r
188 case GL_UNSIGNED_SHORT: return mSize * sizeof(GLushort);
\r
189 case GL_FIXED: return mSize * sizeof(GLfixed);
\r
190 case GL_FLOAT: return mSize * sizeof(GLfloat);
\r
191 default: UNREACHABLE(mType); return mSize * sizeof(GLfloat);
\r
195 GLsizei stride() const
\r
197 return mStride ? mStride : typeSize();
\r
200 inline float getCurrentValueBitsAsFloat(int i) const
\r
202 return mCurrentValue[i].f;
\r
205 inline float getCurrentValueF(int i) const
\r
207 switch(mCurrentValueType)
\r
209 case ValueUnion::FloatType: return mCurrentValue[i].f;
\r
210 case ValueUnion::IntType: return static_cast<float>(mCurrentValue[i].i);
\r
211 case ValueUnion::UIntType: return static_cast<float>(mCurrentValue[i].ui);
\r
212 default: UNREACHABLE(mCurrentValueType); return mCurrentValue[i].f;
\r
216 inline GLint getCurrentValueI(int i) const
\r
218 switch(mCurrentValueType)
\r
220 case ValueUnion::FloatType: return static_cast<GLint>(mCurrentValue[i].f);
\r
221 case ValueUnion::IntType: return mCurrentValue[i].i;
\r
222 case ValueUnion::UIntType: return static_cast<GLint>(mCurrentValue[i].ui);
\r
223 default: UNREACHABLE(mCurrentValueType); return mCurrentValue[i].i;
\r
227 inline GLuint getCurrentValueUI(int i) const
\r
229 switch(mCurrentValueType)
\r
231 case ValueUnion::FloatType: return static_cast<GLuint>(mCurrentValue[i].f);
\r
232 case ValueUnion::IntType: return static_cast<GLuint>(mCurrentValue[i].i);
\r
233 case ValueUnion::UIntType: return mCurrentValue[i].ui;
\r
234 default: UNREACHABLE(mCurrentValueType); return mCurrentValue[i].ui;
\r
238 inline void setCurrentValue(const GLfloat *values)
\r
240 mCurrentValue[0].f = values[0];
\r
241 mCurrentValue[1].f = values[1];
\r
242 mCurrentValue[2].f = values[2];
\r
243 mCurrentValue[3].f = values[3];
\r
244 mCurrentValueType = ValueUnion::FloatType;
\r
247 inline void setCurrentValue(const GLint *values)
\r
249 mCurrentValue[0].i = values[0];
\r
250 mCurrentValue[1].i = values[1];
\r
251 mCurrentValue[2].i = values[2];
\r
252 mCurrentValue[3].i = values[3];
\r
253 mCurrentValueType = ValueUnion::IntType;
\r
256 inline void setCurrentValue(const GLuint *values)
\r
258 mCurrentValue[0].ui = values[0];
\r
259 mCurrentValue[1].ui = values[1];
\r
260 mCurrentValue[2].ui = values[2];
\r
261 mCurrentValue[3].ui = values[3];
\r
262 mCurrentValueType = ValueUnion::UIntType;
\r
265 // From glVertexAttribPointer
\r
269 GLsizei mStride; // 0 means natural stride
\r
270 GLuint mDivisor; // From glVertexAttribDivisor
\r
274 const void *mPointer;
\r
278 gl::BindingPointer<Buffer> mBoundBuffer; // Captured when glVertexAttribPointer is called.
\r
280 bool mArrayEnabled; // From glEnable/DisableVertexAttribArray
\r
285 enum Type { FloatType, IntType, UIntType };
\r
292 ValueUnion mCurrentValue[4]; // From glVertexAttrib
\r
293 ValueUnion::Type mCurrentValueType;
\r
296 typedef VertexAttribute VertexAttributeArray[MAX_VERTEX_ATTRIBS];
\r
298 // Helper structure to store all raw state
\r
301 Color colorClearValue;
\r
302 GLclampf depthClearValue;
\r
303 int stencilClearValue;
\r
305 bool cullFaceEnabled;
\r
308 bool depthTestEnabled;
\r
311 GLenum sourceBlendRGB;
\r
312 GLenum destBlendRGB;
\r
313 GLenum sourceBlendAlpha;
\r
314 GLenum destBlendAlpha;
\r
315 GLenum blendEquationRGB;
\r
316 GLenum blendEquationAlpha;
\r
318 bool stencilTestEnabled;
\r
319 GLenum stencilFunc;
\r
321 GLuint stencilMask;
\r
322 GLenum stencilFail;
\r
323 GLenum stencilPassDepthFail;
\r
324 GLenum stencilPassDepthPass;
\r
325 GLuint stencilWritemask;
\r
326 GLenum stencilBackFunc;
\r
327 GLint stencilBackRef;
\r
328 GLuint stencilBackMask;
\r
329 GLenum stencilBackFail;
\r
330 GLenum stencilBackPassDepthFail;
\r
331 GLenum stencilBackPassDepthPass;
\r
332 GLuint stencilBackWritemask;
\r
333 bool polygonOffsetFillEnabled;
\r
334 GLfloat polygonOffsetFactor;
\r
335 GLfloat polygonOffsetUnits;
\r
336 bool sampleAlphaToCoverageEnabled;
\r
337 bool sampleCoverageEnabled;
\r
338 GLclampf sampleCoverageValue;
\r
339 bool sampleCoverageInvert;
\r
340 bool scissorTestEnabled;
\r
341 bool ditherEnabled;
\r
342 bool primitiveRestartFixedIndexEnabled;
\r
343 bool rasterizerDiscardEnabled;
\r
344 bool colorLogicOpEnabled;
\r
345 GLenum logicalOperation;
\r
349 GLenum generateMipmapHint;
\r
350 GLenum fragmentShaderDerivativeHint;
\r
354 GLsizei viewportWidth;
\r
355 GLsizei viewportHeight;
\r
361 GLsizei scissorWidth;
\r
362 GLsizei scissorHeight;
\r
365 bool colorMaskGreen;
\r
366 bool colorMaskBlue;
\r
367 bool colorMaskAlpha;
\r
370 unsigned int activeSampler; // Active texture unit selector - GL_TEXTURE0
\r
371 gl::BindingPointer<Buffer> arrayBuffer;
\r
372 gl::BindingPointer<Buffer> copyReadBuffer;
\r
373 gl::BindingPointer<Buffer> copyWriteBuffer;
\r
374 gl::BindingPointer<Buffer> pixelPackBuffer;
\r
375 gl::BindingPointer<Buffer> pixelUnpackBuffer;
\r
376 gl::BindingPointer<Buffer> genericUniformBuffer;
\r
377 gl::BindingPointer<Buffer> uniformBuffers[MAX_UNIFORM_BUFFER_BINDINGS];
\r
379 GLuint readFramebuffer;
\r
380 GLuint drawFramebuffer;
\r
381 GLuint readFramebufferColorIndex;
\r
382 GLuint drawFramebufferColorIndices[MAX_COLOR_ATTACHMENTS];
\r
383 gl::BindingPointer<Renderbuffer> renderbuffer;
\r
384 GLuint currentProgram;
\r
385 GLuint vertexArray;
\r
386 GLuint transformFeedback;
\r
387 gl::BindingPointer<Sampler> sampler[MAX_COMBINED_TEXTURE_IMAGE_UNITS];
\r
389 VertexAttribute vertexAttribute[MAX_VERTEX_ATTRIBS];
\r
390 gl::BindingPointer<Texture> samplerTexture[TEXTURE_TYPE_COUNT][MAX_COMBINED_TEXTURE_IMAGE_UNITS];
\r
391 gl::BindingPointer<Query> activeQuery[QUERY_TYPE_COUNT];
\r
393 egl::Image::UnpackInfo unpackInfo;
\r
394 GLint packAlignment;
\r
395 GLint packRowLength;
\r
396 GLint packSkipPixels;
\r
397 GLint packSkipRows;
\r
400 class Context : public egl::Context
\r
403 Context(const egl::Config *config, const Context *shareContext, EGLint clientVersion);
\r
405 virtual void makeCurrent(egl::Surface *surface);
\r
406 virtual EGLint getClientVersion() const;
\r
408 void markAllStateDirty();
\r
410 // State manipulation
\r
411 void setClearColor(float red, float green, float blue, float alpha);
\r
412 void setClearDepth(float depth);
\r
413 void setClearStencil(int stencil);
\r
415 void setCullFaceEnabled(bool enabled);
\r
416 bool isCullFaceEnabled() const;
\r
417 void setCullMode(GLenum mode);
\r
418 void setFrontFace(GLenum front);
\r
420 void setDepthTestEnabled(bool enabled);
\r
421 bool isDepthTestEnabled() const;
\r
422 void setDepthFunc(GLenum depthFunc);
\r
423 void setDepthRange(float zNear, float zFar);
\r
425 void setBlendEnabled(bool enabled);
\r
426 bool isBlendEnabled() const;
\r
427 void setBlendFactors(GLenum sourceRGB, GLenum destRGB, GLenum sourceAlpha, GLenum destAlpha);
\r
428 void setBlendColor(float red, float green, float blue, float alpha);
\r
429 void setBlendEquation(GLenum rgbEquation, GLenum alphaEquation);
\r
431 void setStencilTestEnabled(bool enabled);
\r
432 bool isStencilTestEnabled() const;
\r
433 void setStencilParams(GLenum stencilFunc, GLint stencilRef, GLuint stencilMask);
\r
434 void setStencilBackParams(GLenum stencilBackFunc, GLint stencilBackRef, GLuint stencilBackMask);
\r
435 void setStencilWritemask(GLuint stencilWritemask);
\r
436 void setStencilBackWritemask(GLuint stencilBackWritemask);
\r
437 void setStencilOperations(GLenum stencilFail, GLenum stencilPassDepthFail, GLenum stencilPassDepthPass);
\r
438 void setStencilBackOperations(GLenum stencilBackFail, GLenum stencilBackPassDepthFail, GLenum stencilBackPassDepthPass);
\r
440 void setPolygonOffsetFillEnabled(bool enabled);
\r
441 bool isPolygonOffsetFillEnabled() const;
\r
442 void setPolygonOffsetParams(GLfloat factor, GLfloat units);
\r
444 void setSampleAlphaToCoverageEnabled(bool enabled);
\r
445 bool isSampleAlphaToCoverageEnabled() const;
\r
446 void setSampleCoverageEnabled(bool enabled);
\r
447 bool isSampleCoverageEnabled() const;
\r
448 void setSampleCoverageParams(GLclampf value, bool invert);
\r
450 void setDitherEnabled(bool enabled);
\r
451 bool isDitherEnabled() const;
\r
453 void setPrimitiveRestartFixedIndexEnabled(bool enabled);
\r
454 bool isPrimitiveRestartFixedIndexEnabled() const;
\r
456 void setRasterizerDiscardEnabled(bool enabled);
\r
457 bool isRasterizerDiscardEnabled() const;
\r
459 void setLineWidth(GLfloat width);
\r
461 void setGenerateMipmapHint(GLenum hint);
\r
462 void setFragmentShaderDerivativeHint(GLenum hint);
\r
464 void setViewportParams(GLint x, GLint y, GLsizei width, GLsizei height);
\r
466 void setScissorTestEnabled(bool enabled);
\r
467 bool isScissorTestEnabled() const;
\r
468 void setScissorParams(GLint x, GLint y, GLsizei width, GLsizei height);
\r
470 void setColorMask(bool red, bool green, bool blue, bool alpha);
\r
471 unsigned int getColorMask() const;
\r
472 void setDepthMask(bool mask);
\r
474 void setActiveSampler(unsigned int active);
\r
476 GLuint getReadFramebufferName() const;
\r
477 GLuint getDrawFramebufferName() const;
\r
478 GLuint getRenderbufferName() const;
\r
480 void setReadFramebufferColorIndex(GLuint index);
\r
481 void setDrawFramebufferColorIndices(GLsizei n, const GLenum *bufs);
\r
482 GLuint getReadFramebufferColorIndex() const;
\r
484 GLuint getActiveQuery(GLenum target) const;
\r
486 GLuint getArrayBufferName() const;
\r
487 GLuint getElementArrayBufferName() const;
\r
489 void setVertexAttribArrayEnabled(unsigned int attribNum, bool enabled);
\r
490 void setVertexAttribDivisor(unsigned int attribNum, GLuint divisor);
\r
491 const VertexAttribute &getVertexAttribState(unsigned int attribNum) const;
\r
492 void setVertexAttribState(unsigned int attribNum, Buffer *boundBuffer, GLint size, GLenum type,
\r
493 bool normalized, GLsizei stride, const void *pointer);
\r
494 const void *getVertexAttribPointer(unsigned int attribNum) const;
\r
496 const VertexAttributeArray &getVertexArrayAttributes();
\r
497 // Context attribute current values can be queried independently from VAO current values
\r
498 const VertexAttributeArray &getCurrentVertexAttributes();
\r
500 void setUnpackAlignment(GLint alignment);
\r
501 void setUnpackRowLength(GLint rowLength);
\r
502 void setUnpackImageHeight(GLint imageHeight);
\r
503 void setUnpackSkipPixels(GLint skipPixels);
\r
504 void setUnpackSkipRows(GLint skipRows);
\r
505 void setUnpackSkipImages(GLint skipImages);
\r
506 const egl::Image::UnpackInfo& getUnpackInfo() const;
\r
508 void setPackAlignment(GLint alignment);
\r
509 void setPackRowLength(GLint rowLength);
\r
510 void setPackSkipPixels(GLint skipPixels);
\r
511 void setPackSkipRows(GLint skipRows);
\r
513 // These create and destroy methods are merely pass-throughs to
\r
514 // ResourceManager, which owns these object types
\r
515 GLuint createBuffer();
\r
516 GLuint createShader(GLenum type);
\r
517 GLuint createProgram();
\r
518 GLuint createTexture();
\r
519 GLuint createRenderbuffer();
\r
520 GLuint createSampler();
\r
521 GLsync createFenceSync(GLenum condition, GLbitfield flags);
\r
523 void deleteBuffer(GLuint buffer);
\r
524 void deleteShader(GLuint shader);
\r
525 void deleteProgram(GLuint program);
\r
526 void deleteTexture(GLuint texture);
\r
527 void deleteRenderbuffer(GLuint renderbuffer);
\r
528 void deleteSampler(GLuint sampler);
\r
529 void deleteFenceSync(GLsync fenceSync);
\r
531 // Framebuffers are owned by the Context, so these methods do not pass through
\r
532 GLuint createFramebuffer();
\r
533 void deleteFramebuffer(GLuint framebuffer);
\r
535 // Fences are owned by the Context
\r
536 GLuint createFence();
\r
537 void deleteFence(GLuint fence);
\r
539 // Queries are owned by the Context
\r
540 GLuint createQuery();
\r
541 void deleteQuery(GLuint query);
\r
543 // Vertex arrays are owned by the Context
\r
544 GLuint createVertexArray();
\r
545 void deleteVertexArray(GLuint array);
\r
547 // Transform feedbacks are owned by the Context
\r
548 GLuint createTransformFeedback();
\r
549 void deleteTransformFeedback(GLuint transformFeedback);
\r
551 void bindArrayBuffer(GLuint buffer);
\r
552 void bindElementArrayBuffer(GLuint buffer);
\r
553 void bindCopyReadBuffer(GLuint buffer);
\r
554 void bindCopyWriteBuffer(GLuint buffer);
\r
555 void bindPixelPackBuffer(GLuint buffer);
\r
556 void bindPixelUnpackBuffer(GLuint buffer);
\r
557 void bindTransformFeedbackBuffer(GLuint buffer);
\r
558 void bindTexture2D(GLuint texture);
\r
559 void bindTextureCubeMap(GLuint texture);
\r
560 void bindTextureExternal(GLuint texture);
\r
561 void bindTexture3D(GLuint texture);
\r
562 void bindTexture2DArray(GLuint texture);
\r
563 void bindReadFramebuffer(GLuint framebuffer);
\r
564 void bindDrawFramebuffer(GLuint framebuffer);
\r
565 void bindRenderbuffer(GLuint renderbuffer);
\r
566 bool bindVertexArray(GLuint array);
\r
567 void bindGenericUniformBuffer(GLuint buffer);
\r
568 void bindIndexedUniformBuffer(GLuint buffer, GLuint index, GLintptr offset, GLsizeiptr size);
\r
569 void bindGenericTransformFeedbackBuffer(GLuint buffer);
\r
570 void bindIndexedTransformFeedbackBuffer(GLuint buffer, GLuint index, GLintptr offset, GLsizeiptr size);
\r
571 bool bindTransformFeedback(GLuint transformFeedback);
\r
572 bool bindSampler(GLuint unit, GLuint sampler);
\r
573 void useProgram(GLuint program);
\r
575 void beginQuery(GLenum target, GLuint query);
\r
576 void endQuery(GLenum target);
\r
578 void setFramebufferZero(Framebuffer *framebuffer);
\r
580 void setRenderbufferStorage(RenderbufferStorage *renderbuffer);
\r
582 void setVertexAttrib(GLuint index, const GLfloat *values);
\r
583 void setVertexAttrib(GLuint index, const GLint *values);
\r
584 void setVertexAttrib(GLuint index, const GLuint *values);
\r
586 Buffer *getBuffer(GLuint handle) const;
\r
587 Fence *getFence(GLuint handle) const;
\r
588 FenceSync *getFenceSync(GLsync handle) const;
\r
589 Shader *getShader(GLuint handle) const;
\r
590 Program *getProgram(GLuint handle) const;
\r
591 virtual Texture *getTexture(GLuint handle) const;
\r
592 Framebuffer *getFramebuffer(GLuint handle) const;
\r
593 virtual Renderbuffer *getRenderbuffer(GLuint handle) const;
\r
594 Query *getQuery(GLuint handle) const;
\r
595 VertexArray *getVertexArray(GLuint array) const;
\r
596 VertexArray *getCurrentVertexArray() const;
\r
597 TransformFeedback *getTransformFeedback(GLuint transformFeedback) const;
\r
598 TransformFeedback *getTransformFeedback() const;
\r
599 Sampler *getSampler(GLuint sampler) const;
\r
600 bool isSampler(GLuint sampler) const;
\r
602 Buffer *getArrayBuffer() const;
\r
603 Buffer *getElementArrayBuffer() const;
\r
604 Buffer *getCopyReadBuffer() const;
\r
605 Buffer *getCopyWriteBuffer() const;
\r
606 Buffer *getPixelPackBuffer() const;
\r
607 Buffer *getPixelUnpackBuffer() const;
\r
608 Buffer *getGenericUniformBuffer() const;
\r
609 bool getBuffer(GLenum target, es2::Buffer **buffer) const;
\r
610 Program *getCurrentProgram() const;
\r
611 Texture2D *getTexture2D() const;
\r
612 Texture3D *getTexture3D() const;
\r
613 Texture2DArray *getTexture2DArray() const;
\r
614 TextureCubeMap *getTextureCubeMap() const;
\r
615 TextureExternal *getTextureExternal() const;
\r
616 Texture *getSamplerTexture(unsigned int sampler, TextureType type) const;
\r
617 Framebuffer *getReadFramebuffer() const;
\r
618 Framebuffer *getDrawFramebuffer() const;
\r
620 bool getFloatv(GLenum pname, GLfloat *params) const;
\r
621 template<typename T> bool getIntegerv(GLenum pname, T *params) const;
\r
622 bool getBooleanv(GLenum pname, GLboolean *params) const;
\r
623 template<typename T> bool getTransformFeedbackiv(GLuint xfb, GLenum pname, T *param) const;
\r
624 void samplerParameteri(GLuint sampler, GLenum pname, GLint param);
\r
625 void samplerParameterf(GLuint sampler, GLenum pname, GLfloat param);
\r
626 GLint getSamplerParameteri(GLuint sampler, GLenum pname);
\r
627 GLfloat getSamplerParameterf(GLuint sampler, GLenum pname);
\r
629 bool getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *numParams) const;
\r
631 bool hasZeroDivisor() const;
\r
633 void readPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei *bufSize, void* pixels);
\r
634 void clear(GLbitfield mask);
\r
635 void clearColorBuffer(GLint drawbuffer, const GLint *value);
\r
636 void clearColorBuffer(GLint drawbuffer, const GLuint *value);
\r
637 void clearColorBuffer(GLint drawbuffer, const GLfloat *value);
\r
638 void clearDepthBuffer(GLint drawbuffer, const GLfloat *value);
\r
639 void clearStencilBuffer(GLint drawbuffer, const GLint *value);
\r
640 void clearDepthStencilBuffer(GLint drawbuffer, GLfloat depth, GLint stencil);
\r
641 void drawArrays(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount = 1);
\r
642 void drawElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLsizei instanceCount = 1);
\r
646 void recordInvalidEnum();
\r
647 void recordInvalidValue();
\r
648 void recordInvalidOperation();
\r
649 void recordOutOfMemory();
\r
650 void recordInvalidFramebufferOperation();
\r
654 static int getSupportedMultiSampleDepth(sw::Format format, int requested);
\r
656 void blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
\r
657 GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
\r
660 virtual void bindTexImage(egl::Surface *surface);
\r
661 virtual EGLenum validateSharedImage(EGLenum target, GLuint name, GLuint textureLevel);
\r
662 virtual egl::Image *createSharedImage(EGLenum target, GLuint name, GLuint textureLevel);
\r
664 Device *getDevice();
\r
666 const GLubyte* getExtensions(GLuint index, GLuint* numExt = nullptr) const;
\r
669 virtual ~Context();
\r
671 egl::Image *getScissoredImage(GLint drawbuffer, int &x0, int &y0, int &width, int &height, bool depthStencil);
\r
672 void applyScissor(int width, int height);
\r
673 bool applyRenderTarget();
\r
674 void applyState(GLenum drawMode);
\r
675 GLenum applyVertexBuffer(GLint base, GLint first, GLsizei count, GLsizei instanceId);
\r
676 GLenum applyIndexBuffer(const void *indices, GLuint start, GLuint end, GLsizei count, GLenum mode, GLenum type, TranslatedIndexData *indexInfo);
\r
677 void applyShaders();
\r
678 void applyTextures();
\r
679 void applyTextures(sw::SamplerType type);
\r
680 void applyTexture(sw::SamplerType type, int sampler, Texture *texture);
\r
682 void detachBuffer(GLuint buffer);
\r
683 void detachTexture(GLuint texture);
\r
684 void detachFramebuffer(GLuint framebuffer);
\r
685 void detachRenderbuffer(GLuint renderbuffer);
\r
686 void detachSampler(GLuint sampler);
\r
688 bool cullSkipsDraw(GLenum drawMode);
\r
689 bool isTriangleMode(GLenum drawMode);
\r
691 Query *createQuery(GLuint handle, GLenum type);
\r
693 const EGLint clientVersion;
\r
694 const egl::Config *const mConfig;
\r
698 gl::BindingPointer<Texture2D> mTexture2DZero;
\r
699 gl::BindingPointer<Texture3D> mTexture3DZero;
\r
700 gl::BindingPointer<Texture2DArray> mTexture2DArrayZero;
\r
701 gl::BindingPointer<TextureCubeMap> mTextureCubeMapZero;
\r
702 gl::BindingPointer<TextureExternal> mTextureExternalZero;
\r
704 typedef std::map<GLint, Framebuffer*> FramebufferMap;
\r
705 FramebufferMap mFramebufferMap;
\r
706 gl::NameSpace mFramebufferNameSpace;
\r
708 typedef std::map<GLint, Fence*> FenceMap;
\r
709 FenceMap mFenceMap;
\r
710 gl::NameSpace mFenceNameSpace;
\r
712 typedef std::map<GLint, Query*> QueryMap;
\r
713 QueryMap mQueryMap;
\r
714 gl::NameSpace mQueryNameSpace;
\r
716 typedef std::map<GLint, VertexArray*> VertexArrayMap;
\r
717 VertexArrayMap mVertexArrayMap;
\r
718 gl::NameSpace mVertexArrayNameSpace;
\r
720 typedef std::map<GLint, TransformFeedback*> TransformFeedbackMap;
\r
721 TransformFeedbackMap mTransformFeedbackMap;
\r
722 gl::NameSpace mTransformFeedbackNameSpace;
\r
724 VertexDataManager *mVertexDataManager;
\r
725 IndexDataManager *mIndexDataManager;
\r
729 bool mInvalidValue;
\r
730 bool mInvalidOperation;
\r
732 bool mInvalidFramebufferOperation;
\r
734 bool mHasBeenCurrent;
\r
736 unsigned int mAppliedProgramSerial;
\r
738 // state caching flags
\r
739 bool mDepthStateDirty;
\r
740 bool mMaskStateDirty;
\r
741 bool mPixelPackingStateDirty;
\r
742 bool mBlendStateDirty;
\r
743 bool mStencilStateDirty;
\r
744 bool mPolygonOffsetStateDirty;
\r
745 bool mSampleStateDirty;
\r
746 bool mFrontFaceDirty;
\r
747 bool mDitherStateDirty;
\r
750 ResourceManager *mResourceManager;
\r
754 #endif // INCLUDE_CONTEXT_H_
\r