summaryrefslogtreecommitdiffstats
path: root/Source/ThirdParty/ANGLE/src/libGLESv2/Context.h
diff options
context:
space:
mode:
Diffstat (limited to 'Source/ThirdParty/ANGLE/src/libGLESv2/Context.h')
-rw-r--r--Source/ThirdParty/ANGLE/src/libGLESv2/Context.h217
1 files changed, 166 insertions, 51 deletions
diff --git a/Source/ThirdParty/ANGLE/src/libGLESv2/Context.h b/Source/ThirdParty/ANGLE/src/libGLESv2/Context.h
index 2906664..8dccf0f 100644
--- a/Source/ThirdParty/ANGLE/src/libGLESv2/Context.h
+++ b/Source/ThirdParty/ANGLE/src/libGLESv2/Context.h
@@ -1,5 +1,5 @@
//
-// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
+// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
@@ -18,10 +18,12 @@
#include <d3d9.h>
#include <map>
+#include <hash_map>
#include "common/angleutils.h"
+#include "common/RefCountObject.h"
#include "libGLESv2/ResourceManager.h"
-#include "libGLESv2/RefCountObject.h"
+#include "libGLESv2/HandleAllocator.h"
namespace egl
{
@@ -46,23 +48,29 @@ class Renderbuffer;
class RenderbufferStorage;
class Colorbuffer;
class Depthbuffer;
+class StreamingIndexBuffer;
class Stencilbuffer;
class DepthStencilbuffer;
class VertexDataManager;
class IndexDataManager;
class Blit;
class Fence;
+class Query;
enum
{
+ D3D9_MAX_FLOAT_CONSTANTS = 256,
+ D3D9_MAX_BOOL_CONSTANTS = 16,
+ D3D9_MAX_INT_CONSTANTS = 16,
+
MAX_VERTEX_ATTRIBS = 16,
- 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.
+ MAX_VERTEX_UNIFORM_VECTORS = D3D9_MAX_FLOAT_CONSTANTS - 2, // Reserve space for dx_HalfPixelSize and dx_DepthRange.
MAX_VARYING_VECTORS_SM2 = 8,
MAX_VARYING_VECTORS_SM3 = 10,
- MAX_COMBINED_TEXTURE_IMAGE_UNITS = 16,
- MAX_VERTEX_TEXTURE_IMAGE_UNITS = 0,
MAX_TEXTURE_IMAGE_UNITS = 16,
- 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.
+ MAX_VERTEX_TEXTURE_IMAGE_UNITS_VTF = 4, // For devices supporting vertex texture fetch
+ MAX_COMBINED_TEXTURE_IMAGE_UNITS_VTF = MAX_TEXTURE_IMAGE_UNITS + MAX_VERTEX_TEXTURE_IMAGE_UNITS_VTF,
+ MAX_FRAGMENT_UNIFORM_VECTORS_SM2 = 32 - 3, // Reserve space for dx_Coord, dx_Depth, and dx_DepthRange. dx_PointOrLines and dx_FrontCCW use separate bool registers.
MAX_FRAGMENT_UNIFORM_VECTORS_SM3 = 224 - 3,
MAX_DRAW_BUFFERS = 1,
@@ -70,6 +78,14 @@ enum
IMPLEMENTATION_COLOR_READ_TYPE = GL_UNSIGNED_SHORT_5_6_5
};
+enum QueryType
+{
+ QUERY_ANY_SAMPLES_PASSED,
+ QUERY_ANY_SAMPLES_PASSED_CONSERVATIVE,
+
+ QUERY_TYPE_COUNT
+};
+
const float ALIASED_LINE_WIDTH_RANGE_MIN = 1.0f;
const float ALIASED_LINE_WIDTH_RANGE_MAX = 1.0f;
const float ALIASED_POINT_SIZE_RANGE_MIN = 1.0f;
@@ -88,7 +104,7 @@ struct Color
class VertexAttribute
{
public:
- VertexAttribute() : mType(GL_FLOAT), mSize(0), mNormalized(false), mStride(0), mPointer(NULL), mArrayEnabled(false)
+ VertexAttribute() : mType(GL_FLOAT), mSize(0), mNormalized(false), mStride(0), mPointer(NULL), mArrayEnabled(false), mDivisor(0)
{
mCurrentValue[0] = 0.0f;
mCurrentValue[1] = 0.0f;
@@ -131,6 +147,7 @@ class VertexAttribute
bool mArrayEnabled; // From glEnable/DisableVertexAttribArray
float mCurrentValue[4]; // From glVertexAttrib
+ unsigned int mDivisor;
};
typedef VertexAttribute VertexAttributeArray[MAX_VERTEX_ATTRIBS];
@@ -203,7 +220,7 @@ struct State
bool colorMaskAlpha;
bool depthMask;
- int activeSampler; // Active texture unit selector - GL_TEXTURE0
+ unsigned int activeSampler; // Active texture unit selector - GL_TEXTURE0
BindingPointer<Buffer> arrayBuffer;
BindingPointer<Buffer> elementArrayBuffer;
GLuint readFramebuffer;
@@ -212,16 +229,53 @@ struct State
GLuint currentProgram;
VertexAttribute vertexAttribute[MAX_VERTEX_ATTRIBS];
- BindingPointer<Texture> samplerTexture[SAMPLER_TYPE_COUNT][MAX_TEXTURE_IMAGE_UNITS];
+ BindingPointer<Texture> samplerTexture[TEXTURE_TYPE_COUNT][MAX_COMBINED_TEXTURE_IMAGE_UNITS_VTF];
+ BindingPointer<Query> activeQuery[QUERY_TYPE_COUNT];
GLint unpackAlignment;
GLint packAlignment;
+ bool packReverseRowOrder;
+};
+
+// Helper class to construct and cache vertex declarations
+class VertexDeclarationCache
+{
+ public:
+ VertexDeclarationCache();
+ ~VertexDeclarationCache();
+
+ GLenum applyDeclaration(IDirect3DDevice9 *device, TranslatedAttribute attributes[], Program *program, GLsizei instances, GLsizei *repeatDraw);
+
+ void markStateDirty();
+
+ private:
+ UINT mMaxLru;
+
+ enum { NUM_VERTEX_DECL_CACHE_ENTRIES = 16 };
+
+ struct VBData
+ {
+ unsigned int serial;
+ unsigned int stride;
+ unsigned int offset;
+ };
+
+ VBData mAppliedVBs[MAX_VERTEX_ATTRIBS];
+ IDirect3DVertexDeclaration9 *mLastSetVDecl;
+ bool mInstancingEnabled;
+
+ struct VertexDeclCacheEntry
+ {
+ D3DVERTEXELEMENT9 cachedElements[MAX_VERTEX_ATTRIBS + 1];
+ UINT lruCount;
+ IDirect3DVertexDeclaration9 *vertexDeclaration;
+ } mVertexDeclCache[NUM_VERTEX_DECL_CACHE_ENTRIES];
};
class Context
{
public:
- Context(const egl::Config *config, const gl::Context *shareContext);
+ Context(const egl::Config *config, const gl::Context *shareContext, bool notifyResets, bool robustAccess);
~Context();
@@ -229,6 +283,9 @@ class Context
void markAllStateDirty();
+ virtual void markContextLost();
+ bool isContextLost();
+
// State manipulation
void setClearColor(float red, float green, float blue, float alpha);
@@ -298,7 +355,7 @@ class Context
void setColorMask(bool red, bool green, bool blue, bool alpha);
void setDepthMask(bool mask);
- void setActiveSampler(int active);
+ void setActiveSampler(unsigned int active);
GLuint getReadFramebufferHandle() const;
GLuint getDrawFramebufferHandle() const;
@@ -306,6 +363,8 @@ class Context
GLuint getArrayBufferHandle() const;
+ GLuint getActiveQuery(GLenum target) const;
+
void setEnableVertexAttribArray(unsigned int attribNum, bool enabled);
const VertexAttribute &getVertexAttribState(unsigned int attribNum);
void setVertexAttribState(unsigned int attribNum, Buffer *boundBuffer, GLint size, GLenum type,
@@ -320,6 +379,9 @@ class Context
void setPackAlignment(GLint alignment);
GLint getPackAlignment() const;
+ void setPackReverseRowOrder(bool reverseRowOrder);
+ bool getPackReverseRowOrder() const;
+
// These create and destroy methods are merely pass-throughs to
// ResourceManager, which owns these object types
GLuint createBuffer();
@@ -341,6 +403,10 @@ class Context
// Fences are owned by the Context.
GLuint createFence();
void deleteFence(GLuint fence);
+
+ // Queries are owned by the Context;
+ GLuint createQuery();
+ void deleteQuery(GLuint query);
void bindArrayBuffer(GLuint buffer);
void bindElementArrayBuffer(GLuint buffer);
@@ -351,11 +417,15 @@ class Context
void bindRenderbuffer(GLuint renderbuffer);
void useProgram(GLuint program);
+ void beginQuery(GLenum target, GLuint query);
+ void endQuery(GLenum target);
+
void setFramebufferZero(Framebuffer *framebuffer);
void setRenderbufferStorage(RenderbufferStorage *renderbuffer);
void setVertexAttrib(GLuint index, const GLfloat *values);
+ void setVertexAttribDivisor(GLuint index, GLuint divisor);
Buffer *getBuffer(GLuint handle);
Fence *getFence(GLuint handle);
@@ -364,13 +434,14 @@ class Context
Texture *getTexture(GLuint handle);
Framebuffer *getFramebuffer(GLuint handle);
Renderbuffer *getRenderbuffer(GLuint handle);
+ Query *getQuery(GLuint handle, bool create, GLenum type);
Buffer *getArrayBuffer();
Buffer *getElementArrayBuffer();
Program *getCurrentProgram();
Texture2D *getTexture2D();
TextureCubeMap *getTextureCubeMap();
- Texture *getSamplerTexture(unsigned int sampler, SamplerType type);
+ Texture *getSamplerTexture(unsigned int sampler, TextureType type);
Framebuffer *getReadFramebuffer();
Framebuffer *getDrawFramebuffer();
@@ -380,23 +451,13 @@ class Context
bool getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *numParams);
- bool applyRenderTarget(bool ignoreViewport);
- void applyState(GLenum drawMode);
- GLenum applyVertexBuffer(GLint first, GLsizei count);
- GLenum applyIndexBuffer(const void *indices, GLsizei count, GLenum mode, GLenum type, TranslatedIndexData *indexInfo);
- void applyShaders();
- void applyTextures();
-
- void readPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels);
+ void readPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei *bufSize, void* pixels);
void clear(GLbitfield mask);
- void drawArrays(GLenum mode, GLint first, GLsizei count);
- void drawElements(GLenum mode, GLsizei count, GLenum type, const void *indices);
- void finish();
- void flush();
+ void drawArrays(GLenum mode, GLint first, GLsizei count, GLsizei instances);
+ void drawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei instances);
+ void sync(bool block); // flush/finish
- // Draw the last segment of a line loop
- void drawClosingLine(unsigned int first, unsigned int last);
- void drawClosingLine(GLsizei count, GLenum type, const void *indices);
+ void drawLineLoop(GLsizei count, GLenum type, const GLvoid *indices, int minIndex);
void recordInvalidEnum();
void recordInvalidValue();
@@ -405,9 +466,13 @@ class Context
void recordInvalidFramebufferOperation();
GLenum getError();
+ GLenum getResetStatus();
+ virtual bool isResetNotificationEnabled();
bool supportsShaderModel3() const;
int getMaximumVaryingVectors() const;
+ unsigned int getMaximumVertexTextureImageUnits() const;
+ unsigned int getMaximumCombinedTextureImageUnits() const;
int getMaximumFragmentUniformVectors() const;
int getMaximumRenderbufferDimension() const;
int getMaximumTextureDimension() const;
@@ -416,17 +481,23 @@ class Context
GLsizei getMaxSupportedSamples() const;
int getNearestSupportedSamples(D3DFORMAT format, int requested) const;
const char *getExtensionString() const;
+ const char *getRendererString() const;
bool supportsEventQueries() const;
- bool supportsCompressedTextures() const;
- bool supportsFloatTextures() const;
- bool supportsFloatLinearFilter() const;
- bool supportsFloatRenderableTextures() const;
- bool supportsHalfFloatTextures() const;
- bool supportsHalfFloatLinearFilter() const;
- bool supportsHalfFloatRenderableTextures() const;
+ bool supportsOcclusionQueries() const;
+ bool supportsDXT1Textures() const;
+ bool supportsDXT3Textures() const;
+ bool supportsDXT5Textures() const;
+ bool supportsFloat32Textures() const;
+ bool supportsFloat32LinearFilter() const;
+ bool supportsFloat32RenderableTextures() const;
+ bool supportsFloat16Textures() const;
+ bool supportsFloat16LinearFilter() const;
+ bool supportsFloat16RenderableTextures() const;
bool supportsLuminanceTextures() const;
bool supportsLuminanceAlphaTextures() const;
bool supports32bitIndices() const;
+ bool supportsNonPower2Texture() const;
+ bool supportsInstancing() const;
void blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
@@ -439,40 +510,59 @@ class Context
private:
DISALLOW_COPY_AND_ASSIGN(Context);
- void lookupAttributeMapping(TranslatedAttribute *attributes);
+ bool applyRenderTarget(bool ignoreViewport);
+ void applyState(GLenum drawMode);
+ GLenum applyVertexBuffer(GLint first, GLsizei count, GLsizei instances, GLsizei *repeatDraw);
+ GLenum applyIndexBuffer(const GLvoid *indices, GLsizei count, GLenum mode, GLenum type, TranslatedIndexData *indexInfo);
+ void applyShaders();
+ void applyTextures();
+ void applyTextures(SamplerType type);
void detachBuffer(GLuint buffer);
void detachTexture(GLuint texture);
void detachFramebuffer(GLuint framebuffer);
void detachRenderbuffer(GLuint renderbuffer);
- Texture *getIncompleteTexture(SamplerType type);
+ Texture *getIncompleteTexture(TextureType type);
bool cullSkipsDraw(GLenum drawMode);
bool isTriangleMode(GLenum drawMode);
+ void initExtensionString();
+ void initRendererString();
+
const egl::Config *const mConfig;
+ egl::Display *mDisplay;
+ IDirect3DDevice9 *mDevice;
- State mState;
+ State mState;
BindingPointer<Texture2D> mTexture2DZero;
BindingPointer<TextureCubeMap> mTextureCubeMapZero;
- typedef std::map<GLuint, Framebuffer*> FramebufferMap;
+ typedef stdext::hash_map<GLuint, Framebuffer*> FramebufferMap;
FramebufferMap mFramebufferMap;
+ HandleAllocator mFramebufferHandleAllocator;
- typedef std::map<GLuint, Fence*> FenceMap;
+ typedef stdext::hash_map<GLuint, Fence*> FenceMap;
FenceMap mFenceMap;
+ HandleAllocator mFenceHandleAllocator;
+
+ typedef stdext::hash_map<GLuint, Query*> QueryMap;
+ QueryMap mQueryMap;
+ HandleAllocator mQueryHandleAllocator;
- void initExtensionString();
std::string mExtensionString;
+ std::string mRendererString;
VertexDataManager *mVertexDataManager;
IndexDataManager *mIndexDataManager;
Blit *mBlit;
+
+ StreamingIndexBuffer *mLineLoopIB;
- BindingPointer<Texture> mIncompleteTextures[SAMPLER_TYPE_COUNT];
+ BindingPointer<Texture> mIncompleteTextures[TEXTURE_TYPE_COUNT];
// Recorded errors
bool mInvalidEnum;
@@ -481,15 +571,33 @@ class Context
bool mOutOfMemory;
bool mInvalidFramebufferOperation;
+ // Current/lost context flags
bool mHasBeenCurrent;
-
- unsigned int mAppliedProgram;
+ bool mContextLost;
+ GLenum mResetStatus;
+ GLenum mResetStrategy;
+ bool mRobustAccess;
+
+ unsigned int mAppliedTextureSerialPS[MAX_TEXTURE_IMAGE_UNITS];
+ unsigned int mAppliedTextureSerialVS[MAX_VERTEX_TEXTURE_IMAGE_UNITS_VTF];
+ unsigned int mAppliedProgramSerial;
unsigned int mAppliedRenderTargetSerial;
unsigned int mAppliedDepthbufferSerial;
unsigned int mAppliedStencilbufferSerial;
+ unsigned int mAppliedIBSerial;
bool mDepthStencilInitialized;
+ bool mViewportInitialized;
+ D3DVIEWPORT9 mSetViewport;
+ bool mRenderTargetDescInitialized;
+ D3DSURFACE_DESC mRenderTargetDesc;
+ bool mDxUniformsDirty;
+ Program *mCachedCurrentProgram;
+ Framebuffer *mBoundDrawFramebuffer;
bool mSupportsShaderModel3;
+ bool mSupportsVertexTexture;
+ bool mSupportsNonPower2Texture;
+ bool mSupportsInstancing;
int mMaxRenderbufferDimension;
int mMaxTextureDimension;
int mMaxCubeTextureDimension;
@@ -497,16 +605,20 @@ class Context
std::map<D3DFORMAT, bool *> mMultiSampleSupport;
GLsizei mMaxSupportedSamples;
bool mSupportsEventQueries;
- bool mSupportsCompressedTextures;
- bool mSupportsFloatTextures;
- bool mSupportsFloatLinearFilter;
- bool mSupportsFloatRenderableTextures;
- bool mSupportsHalfFloatTextures;
- bool mSupportsHalfFloatLinearFilter;
- bool mSupportsHalfFloatRenderableTextures;
+ bool mSupportsOcclusionQueries;
+ bool mSupportsDXT1Textures;
+ bool mSupportsDXT3Textures;
+ bool mSupportsDXT5Textures;
+ bool mSupportsFloat32Textures;
+ bool mSupportsFloat32LinearFilter;
+ bool mSupportsFloat32RenderableTextures;
+ bool mSupportsFloat16Textures;
+ bool mSupportsFloat16LinearFilter;
+ bool mSupportsFloat16RenderableTextures;
bool mSupportsLuminanceTextures;
bool mSupportsLuminanceAlphaTextures;
bool mSupports32bitIndices;
+ int mNumCompressedTextureFormats;
// state caching flags
bool mClearStateDirty;
@@ -527,17 +639,20 @@ class Context
D3DCAPS9 mDeviceCaps;
ResourceManager *mResourceManager;
+
+ VertexDeclarationCache mVertexDeclarationCache;
};
}
extern "C"
{
// Exported functions for use by EGL
-gl::Context *glCreateContext(const egl::Config *config, const gl::Context *shareContext);
+gl::Context *glCreateContext(const egl::Config *config, const gl::Context *shareContext, bool notifyResets, bool robustAccess);
void glDestroyContext(gl::Context *context);
void glMakeCurrent(gl::Context *context, egl::Display *display, egl::Surface *surface);
gl::Context *glGetCurrentContext();
__eglMustCastToProperFunctionPointerType __stdcall glGetProcAddress(const char *procname);
+bool __stdcall glBindTexImage(egl::Surface *surface);
}
#endif // INCLUDE_CONTEXT_H_