LEFT | RIGHT |
1 // | 1 // |
2 // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. | 2 // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. |
3 // Use of this source code is governed by a BSD-style license that can be | 3 // Use of this source code is governed by a BSD-style license that can be |
4 // found in the LICENSE file. | 4 // found in the LICENSE file. |
5 // | 5 // |
6 | 6 |
7 // Context.cpp: Implements the gl::Context class, managing all GL state and perf
orming | 7 // Context.cpp: Implements the gl::Context class, managing all GL state and perf
orming |
8 // rendering operations. It is the GLES2 specific implementation of EGLContext. | 8 // rendering operations. It is the GLES2 specific implementation of EGLContext. |
9 | 9 |
10 #include "libGLESv2/Context.h" | 10 #include "libGLESv2/Context.h" |
11 | 11 |
12 #include <algorithm> | 12 #include <algorithm> |
13 | 13 |
14 #include "libEGL/Display.h" | 14 #include "libEGL/Display.h" |
15 | 15 |
16 #include "libGLESv2/main.h" | 16 #include "libGLESv2/main.h" |
17 #include "libGLESv2/mathutil.h" | 17 #include "libGLESv2/mathutil.h" |
18 #include "libGLESv2/utilities.h" | 18 #include "libGLESv2/utilities.h" |
19 #include "libGLESv2/Blit.h" | 19 #include "libGLESv2/Blit.h" |
20 #include "libGLESv2/ResourceManager.h" | 20 #include "libGLESv2/ResourceManager.h" |
21 #include "libGLESv2/Buffer.h" | 21 #include "libGLESv2/Buffer.h" |
22 #include "libGLESv2/Fence.h" | 22 #include "libGLESv2/Fence.h" |
23 #include "libGLESv2/FrameBuffer.h" | 23 #include "libGLESv2/FrameBuffer.h" |
24 #include "libGLESv2/Program.h" | 24 #include "libGLESv2/Program.h" |
25 #include "libGLESv2/RenderBuffer.h" | 25 #include "libGLESv2/RenderBuffer.h" |
26 #include "libGLESv2/Shader.h" | 26 #include "libGLESv2/Shader.h" |
27 #include "libGLESv2/Texture.h" | 27 #include "libGLESv2/Texture.h" |
28 #include "libGLESv2/geometry/backend.h" | |
29 #include "libGLESv2/geometry/VertexDataManager.h" | 28 #include "libGLESv2/geometry/VertexDataManager.h" |
30 #include "libGLESv2/geometry/IndexDataManager.h" | 29 #include "libGLESv2/geometry/IndexDataManager.h" |
31 #include "libGLESv2/geometry/dx9.h" | |
32 | 30 |
33 #undef near | 31 #undef near |
34 #undef far | 32 #undef far |
35 | 33 |
36 namespace gl | 34 namespace gl |
37 { | 35 { |
38 Context::Context(const egl::Config *config, const gl::Context *shareContext) | 36 Context::Context(const egl::Config *config, const gl::Context *shareContext) |
39 : mConfig(config) | 37 : mConfig(config) |
40 { | 38 { |
41 setClearColor(0.0f, 0.0f, 0.0f, 0.0f); | 39 setClearColor(0.0f, 0.0f, 0.0f, 0.0f); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 bindTexture2D(0); | 130 bindTexture2D(0); |
133 bindReadFramebuffer(0); | 131 bindReadFramebuffer(0); |
134 bindDrawFramebuffer(0); | 132 bindDrawFramebuffer(0); |
135 bindRenderbuffer(0); | 133 bindRenderbuffer(0); |
136 | 134 |
137 mState.currentProgram = 0; | 135 mState.currentProgram = 0; |
138 | 136 |
139 mState.packAlignment = 4; | 137 mState.packAlignment = 4; |
140 mState.unpackAlignment = 4; | 138 mState.unpackAlignment = 4; |
141 | 139 |
142 mBufferBackEnd = NULL; | |
143 mVertexDataManager = NULL; | 140 mVertexDataManager = NULL; |
144 mIndexDataManager = NULL; | 141 mIndexDataManager = NULL; |
145 mBlit = NULL; | 142 mBlit = NULL; |
146 | 143 |
147 mInvalidEnum = false; | 144 mInvalidEnum = false; |
148 mInvalidValue = false; | 145 mInvalidValue = false; |
149 mInvalidOperation = false; | 146 mInvalidOperation = false; |
150 mOutOfMemory = false; | 147 mOutOfMemory = false; |
151 mInvalidFramebufferOperation = false; | 148 mInvalidFramebufferOperation = false; |
152 | 149 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 mState.vertexAttribute[i].mBoundBuffer.set(NULL); | 202 mState.vertexAttribute[i].mBoundBuffer.set(NULL); |
206 } | 203 } |
207 | 204 |
208 mState.arrayBuffer.set(NULL); | 205 mState.arrayBuffer.set(NULL); |
209 mState.elementArrayBuffer.set(NULL); | 206 mState.elementArrayBuffer.set(NULL); |
210 mState.renderbuffer.set(NULL); | 207 mState.renderbuffer.set(NULL); |
211 | 208 |
212 mTexture2DZero.set(NULL); | 209 mTexture2DZero.set(NULL); |
213 mTextureCubeMapZero.set(NULL); | 210 mTextureCubeMapZero.set(NULL); |
214 | 211 |
215 delete mBufferBackEnd; | |
216 delete mVertexDataManager; | 212 delete mVertexDataManager; |
217 delete mIndexDataManager; | 213 delete mIndexDataManager; |
218 delete mBlit; | 214 delete mBlit; |
219 | 215 |
220 if (mMaskedClearSavedState) | 216 if (mMaskedClearSavedState) |
221 { | 217 { |
222 mMaskedClearSavedState->Release(); | 218 mMaskedClearSavedState->Release(); |
223 } | 219 } |
224 | 220 |
225 mResourceManager->release(); | 221 mResourceManager->release(); |
226 } | 222 } |
227 | 223 |
228 void Context::makeCurrent(egl::Display *display, egl::Surface *surface) | 224 void Context::makeCurrent(egl::Display *display, egl::Surface *surface) |
229 { | 225 { |
230 IDirect3DDevice9 *device = display->getDevice(); | 226 IDirect3DDevice9 *device = display->getDevice(); |
231 | 227 |
232 if (!mHasBeenCurrent) | 228 if (!mHasBeenCurrent) |
233 { | 229 { |
234 mDeviceCaps = display->getDeviceCaps(); | 230 mDeviceCaps = display->getDeviceCaps(); |
235 | 231 |
236 mBufferBackEnd = new Dx9BackEnd(this, device); | 232 mVertexDataManager = new VertexDataManager(this, device); |
237 mVertexDataManager = new VertexDataManager(this, mBufferBackEnd); | 233 mIndexDataManager = new IndexDataManager(this, device); |
238 mIndexDataManager = new IndexDataManager(this, mBufferBackEnd); | |
239 mBlit = new Blit(this); | 234 mBlit = new Blit(this); |
240 | 235 |
241 mSupportsShaderModel3 = mDeviceCaps.PixelShaderVersion == D3DPS_VERSION(
3, 0); | 236 mSupportsShaderModel3 = mDeviceCaps.PixelShaderVersion == D3DPS_VERSION(
3, 0); |
242 | 237 |
243 mMaxTextureDimension = std::min(std::min((int)mDeviceCaps.MaxTextureWidt
h, (int)mDeviceCaps.MaxTextureHeight), | 238 mMaxTextureDimension = std::min(std::min((int)mDeviceCaps.MaxTextureWidt
h, (int)mDeviceCaps.MaxTextureHeight), |
244 (int)gl::IMPLEMENTATION_MAX_TEXTURE_SIZE
); | 239 (int)gl::IMPLEMENTATION_MAX_TEXTURE_SIZE
); |
245 mMaxCubeTextureDimension = std::min(mMaxTextureDimension, (int)gl::IMPLE
MENTATION_MAX_CUBE_MAP_TEXTURE_SIZE); | 240 mMaxCubeTextureDimension = std::min(mMaxTextureDimension, (int)gl::IMPLE
MENTATION_MAX_CUBE_MAP_TEXTURE_SIZE); |
246 mMaxRenderbufferDimension = mMaxTextureDimension; | 241 mMaxRenderbufferDimension = mMaxTextureDimension; |
247 mMaxTextureLevel = log2(mMaxTextureDimension) + 1; | 242 mMaxTextureLevel = log2(mMaxTextureDimension) + 1; |
248 TRACE("MaxTextureDimension=%d, MaxCubeTextureDimension=%d, MaxRenderbuff
erDimension=%d, MaxTextureLevel=%d", | 243 TRACE("MaxTextureDimension=%d, MaxCubeTextureDimension=%d, MaxRenderbuff
erDimension=%d, MaxTextureLevel=%d", |
(...skipping 24 matching lines...) Expand all Loading... |
273 } | 268 } |
274 | 269 |
275 mMaxSupportedSamples = max; | 270 mMaxSupportedSamples = max; |
276 | 271 |
277 mSupportsEventQueries = display->getEventQuerySupport(); | 272 mSupportsEventQueries = display->getEventQuerySupport(); |
278 mSupportsCompressedTextures = display->getCompressedTextureSupport(); | 273 mSupportsCompressedTextures = display->getCompressedTextureSupport(); |
279 mSupportsFloatTextures = display->getFloatTextureSupport(&mSupportsFloat
LinearFilter, &mSupportsFloatRenderableTextures); | 274 mSupportsFloatTextures = display->getFloatTextureSupport(&mSupportsFloat
LinearFilter, &mSupportsFloatRenderableTextures); |
280 mSupportsHalfFloatTextures = display->getHalfFloatTextureSupport(&mSuppo
rtsHalfFloatLinearFilter, &mSupportsHalfFloatRenderableTextures); | 275 mSupportsHalfFloatTextures = display->getHalfFloatTextureSupport(&mSuppo
rtsHalfFloatLinearFilter, &mSupportsHalfFloatRenderableTextures); |
281 mSupportsLuminanceTextures = display->getLuminanceTextureSupport(); | 276 mSupportsLuminanceTextures = display->getLuminanceTextureSupport(); |
282 mSupportsLuminanceAlphaTextures = display->getLuminanceAlphaTextureSuppo
rt(); | 277 mSupportsLuminanceAlphaTextures = display->getLuminanceAlphaTextureSuppo
rt(); |
| 278 |
| 279 mSupports32bitIndices = mDeviceCaps.MaxVertexIndex >= (1 << 16); |
283 | 280 |
284 initExtensionString(); | 281 initExtensionString(); |
285 | 282 |
286 mState.viewportX = 0; | 283 mState.viewportX = 0; |
287 mState.viewportY = 0; | 284 mState.viewportY = 0; |
288 mState.viewportWidth = surface->getWidth(); | 285 mState.viewportWidth = surface->getWidth(); |
289 mState.viewportHeight = surface->getHeight(); | 286 mState.viewportHeight = surface->getHeight(); |
290 | 287 |
291 mState.scissorX = 0; | 288 mState.scissorX = 0; |
292 mState.scissorY = 0; | 289 mState.scissorY = 0; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 mCullStateDirty = true; | 329 mCullStateDirty = true; |
333 mDepthStateDirty = true; | 330 mDepthStateDirty = true; |
334 mMaskStateDirty = true; | 331 mMaskStateDirty = true; |
335 mBlendStateDirty = true; | 332 mBlendStateDirty = true; |
336 mStencilStateDirty = true; | 333 mStencilStateDirty = true; |
337 mPolygonOffsetStateDirty = true; | 334 mPolygonOffsetStateDirty = true; |
338 mScissorStateDirty = true; | 335 mScissorStateDirty = true; |
339 mSampleStateDirty = true; | 336 mSampleStateDirty = true; |
340 mDitherStateDirty = true; | 337 mDitherStateDirty = true; |
341 mFrontFaceDirty = true; | 338 mFrontFaceDirty = true; |
342 | |
343 if (mBufferBackEnd != NULL) | |
344 { | |
345 mBufferBackEnd->invalidate(); | |
346 } | |
347 } | 339 } |
348 | 340 |
349 void Context::setClearColor(float red, float green, float blue, float alpha) | 341 void Context::setClearColor(float red, float green, float blue, float alpha) |
350 { | 342 { |
351 mState.colorClearValue.red = red; | 343 mState.colorClearValue.red = red; |
352 mState.colorClearValue.green = green; | 344 mState.colorClearValue.green = green; |
353 mState.colorClearValue.blue = blue; | 345 mState.colorClearValue.blue = blue; |
354 mState.colorClearValue.alpha = alpha; | 346 mState.colorClearValue.alpha = alpha; |
355 } | 347 } |
356 | 348 |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
736 GLuint Context::getRenderbufferHandle() const | 728 GLuint Context::getRenderbufferHandle() const |
737 { | 729 { |
738 return mState.renderbuffer.id(); | 730 return mState.renderbuffer.id(); |
739 } | 731 } |
740 | 732 |
741 GLuint Context::getArrayBufferHandle() const | 733 GLuint Context::getArrayBufferHandle() const |
742 { | 734 { |
743 return mState.arrayBuffer.id(); | 735 return mState.arrayBuffer.id(); |
744 } | 736 } |
745 | 737 |
746 void Context::setVertexAttribEnabled(unsigned int attribNum, bool enabled) | 738 void Context::setEnableVertexAttribArray(unsigned int attribNum, bool enabled) |
747 { | 739 { |
748 mState.vertexAttribute[attribNum].mEnabled = enabled; | 740 mState.vertexAttribute[attribNum].mArrayEnabled = enabled; |
749 } | 741 } |
750 | 742 |
751 const AttributeState &Context::getVertexAttribState(unsigned int attribNum) | 743 const VertexAttribute &Context::getVertexAttribState(unsigned int attribNum) |
752 { | 744 { |
753 return mState.vertexAttribute[attribNum]; | 745 return mState.vertexAttribute[attribNum]; |
754 } | 746 } |
755 | 747 |
756 void Context::setVertexAttribState(unsigned int attribNum, Buffer *boundBuffer,
GLint size, GLenum type, bool normalized, | 748 void Context::setVertexAttribState(unsigned int attribNum, Buffer *boundBuffer,
GLint size, GLenum type, bool normalized, |
757 GLsizei stride, const void *pointer) | 749 GLsizei stride, const void *pointer) |
758 { | 750 { |
759 mState.vertexAttribute[attribNum].mBoundBuffer.set(boundBuffer); | 751 mState.vertexAttribute[attribNum].mBoundBuffer.set(boundBuffer); |
760 mState.vertexAttribute[attribNum].mSize = size; | 752 mState.vertexAttribute[attribNum].mSize = size; |
761 mState.vertexAttribute[attribNum].mType = type; | 753 mState.vertexAttribute[attribNum].mType = type; |
762 mState.vertexAttribute[attribNum].mNormalized = normalized; | 754 mState.vertexAttribute[attribNum].mNormalized = normalized; |
763 mState.vertexAttribute[attribNum].mStride = stride; | 755 mState.vertexAttribute[attribNum].mStride = stride; |
764 mState.vertexAttribute[attribNum].mPointer = pointer; | 756 mState.vertexAttribute[attribNum].mPointer = pointer; |
765 } | 757 } |
766 | 758 |
767 const void *Context::getVertexAttribPointer(unsigned int attribNum) const | 759 const void *Context::getVertexAttribPointer(unsigned int attribNum) const |
768 { | 760 { |
769 return mState.vertexAttribute[attribNum].mPointer; | 761 return mState.vertexAttribute[attribNum].mPointer; |
770 } | 762 } |
771 | 763 |
772 // returns entire set of attributes as a block | 764 const VertexAttributeArray &Context::getVertexAttributes() |
773 const AttributeState *Context::getVertexAttribBlock() | |
774 { | 765 { |
775 return mState.vertexAttribute; | 766 return mState.vertexAttribute; |
776 } | 767 } |
777 | 768 |
778 void Context::setPackAlignment(GLint alignment) | 769 void Context::setPackAlignment(GLint alignment) |
779 { | 770 { |
780 mState.packAlignment = alignment; | 771 mState.packAlignment = alignment; |
781 } | 772 } |
782 | 773 |
783 GLint Context::getPackAlignment() const | 774 GLint Context::getPackAlignment() const |
(...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1690 } | 1681 } |
1691 | 1682 |
1692 mScissorStateDirty = false; | 1683 mScissorStateDirty = false; |
1693 } | 1684 } |
1694 | 1685 |
1695 if (mState.currentProgram) | 1686 if (mState.currentProgram) |
1696 { | 1687 { |
1697 Program *programObject = getCurrentProgram(); | 1688 Program *programObject = getCurrentProgram(); |
1698 | 1689 |
1699 GLint halfPixelSize = programObject->getDxHalfPixelSizeLocation(); | 1690 GLint halfPixelSize = programObject->getDxHalfPixelSizeLocation(); |
1700 GLfloat xy[2] = {1.0f / viewport.Width, 1.0f / viewport.Height}; | 1691 GLfloat xy[2] = {1.0f / viewport.Width, -1.0f / viewport.Height}; |
1701 programObject->setUniform2fv(halfPixelSize, 1, xy); | 1692 programObject->setUniform2fv(halfPixelSize, 1, xy); |
1702 | 1693 |
1703 GLint viewport = programObject->getDxViewportLocation(); | 1694 GLint viewport = programObject->getDxViewportLocation(); |
1704 GLfloat whxy[4] = {mState.viewportWidth / 2.0f, mState.viewportHeight /
2.0f,· | 1695 GLfloat whxy[4] = {mState.viewportWidth / 2.0f, mState.viewportHeight /
2.0f,· |
1705 (float)mState.viewportX + mState.viewportWidth / 2.0f,········ | 1696 (float)mState.viewportX + mState.viewportWidth / 2.0f,········ |
1706 (float)mState.viewportY + mState.viewportHeight / 2.0f
}; | 1697 (float)mState.viewportY + mState.viewportHeight / 2.0f
}; |
1707 programObject->setUniform4fv(viewport, 1, whxy); | 1698 programObject->setUniform4fv(viewport, 1, whxy); |
1708 | 1699 |
1709 GLint depth = programObject->getDxDepthLocation(); | 1700 GLint depth = programObject->getDxDepthLocation(); |
1710 GLfloat dz[2] = {(zFar - zNear) / 2.0f, (zNear + zFar) / 2.0f}; | 1701 GLfloat dz[2] = {(zFar - zNear) / 2.0f, (zNear + zFar) / 2.0f}; |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1958 } | 1949 } |
1959 | 1950 |
1960 mFrontFaceDirty = false; | 1951 mFrontFaceDirty = false; |
1961 } | 1952 } |
1962 | 1953 |
1963 // Fill in the semanticIndex field of the array of TranslatedAttributes based on
the active GLSL program. | 1954 // Fill in the semanticIndex field of the array of TranslatedAttributes based on
the active GLSL program. |
1964 void Context::lookupAttributeMapping(TranslatedAttribute *attributes) | 1955 void Context::lookupAttributeMapping(TranslatedAttribute *attributes) |
1965 { | 1956 { |
1966 for (int i = 0; i < MAX_VERTEX_ATTRIBS; i++) | 1957 for (int i = 0; i < MAX_VERTEX_ATTRIBS; i++) |
1967 { | 1958 { |
1968 if (attributes[i].enabled) | 1959 if (attributes[i].active) |
1969 { | 1960 { |
1970 attributes[i].semanticIndex = getCurrentProgram()->getSemanticIndex(
i); | 1961 attributes[i].semanticIndex = getCurrentProgram()->getSemanticIndex(
i); |
1971 } | 1962 } |
1972 } | 1963 } |
1973 } | 1964 } |
1974 | 1965 |
1975 GLenum Context::applyVertexBuffer(GLenum mode, GLint first, GLsizei count, bool
*useIndexing, TranslatedIndexData *indexInfo) | 1966 GLenum Context::applyVertexBuffer(GLint first, GLsizei count) |
1976 { | 1967 { |
1977 TranslatedAttribute translated[MAX_VERTEX_ATTRIBS]; | 1968 TranslatedAttribute translated[MAX_VERTEX_ATTRIBS]; |
1978 | 1969 |
1979 GLenum err = mVertexDataManager->preRenderValidate(first, count, translated)
; | 1970 GLenum err = mVertexDataManager->prepareVertexData(first, count, translated)
; |
1980 if (err != GL_NO_ERROR) | 1971 if (err != GL_NO_ERROR) |
1981 { | 1972 { |
1982 return err; | 1973 return err; |
1983 } | 1974 } |
1984 | 1975 |
1985 lookupAttributeMapping(translated); | 1976 lookupAttributeMapping(translated); |
1986 | 1977 |
1987 mBufferBackEnd->setupAttributesPreDraw(translated); | 1978 mVertexDataManager->setupAttributes(translated); |
1988 | 1979 |
1989 for (int i = 0; i < MAX_VERTEX_ATTRIBS; i++) | |
1990 { | |
1991 if (translated[i].enabled && translated[i].nonArray) | |
1992 { | |
1993 err = mIndexDataManager->preRenderValidateUnindexed(mode, count, ind
exInfo); | |
1994 if (err != GL_NO_ERROR) | |
1995 { | |
1996 return err; | |
1997 } | |
1998 | |
1999 mBufferBackEnd->setupIndicesPreDraw(*indexInfo); | |
2000 | |
2001 *useIndexing = true; | |
2002 return GL_NO_ERROR; | |
2003 } | |
2004 } | |
2005 | |
2006 *useIndexing = false; | |
2007 return GL_NO_ERROR; | 1980 return GL_NO_ERROR; |
2008 } | |
2009 | |
2010 GLenum Context::applyVertexBuffer(const TranslatedIndexData &indexInfo) | |
2011 { | |
2012 TranslatedAttribute translated[MAX_VERTEX_ATTRIBS]; | |
2013 | |
2014 GLenum err = mVertexDataManager->preRenderValidate(indexInfo.minIndex, index
Info.maxIndex-indexInfo.minIndex+1, translated); | |
2015 | |
2016 if (err == GL_NO_ERROR) | |
2017 { | |
2018 lookupAttributeMapping(translated); | |
2019 | |
2020 mBufferBackEnd->setupAttributesPreDraw(translated); | |
2021 } | |
2022 | |
2023 return err; | |
2024 } | 1981 } |
2025 | 1982 |
2026 // Applies the indices and element array bindings to the Direct3D 9 device | 1983 // Applies the indices and element array bindings to the Direct3D 9 device |
2027 GLenum Context::applyIndexBuffer(const void *indices, GLsizei count, GLenum mode
, GLenum type, TranslatedIndexData *indexInfo) | 1984 GLenum Context::applyIndexBuffer(const void *indices, GLsizei count, GLenum mode
, GLenum type, TranslatedIndexData *indexInfo) |
2028 { | 1985 { |
2029 GLenum err = mIndexDataManager->preRenderValidate(mode, type, count, mState.
elementArrayBuffer.get(), indices, indexInfo); | 1986 IDirect3DDevice9 *device = getDevice(); |
| 1987 GLenum err = mIndexDataManager->prepareIndexData(type, count, mState.element
ArrayBuffer.get(), indices, indexInfo); |
2030 | 1988 |
2031 if (err == GL_NO_ERROR) | 1989 if (err == GL_NO_ERROR) |
2032 { | 1990 { |
2033 mBufferBackEnd->setupIndicesPreDraw(*indexInfo); | 1991 device->SetIndices(indexInfo->indexBuffer); |
2034 } | 1992 } |
2035 | 1993 |
2036 return err; | 1994 return err; |
2037 } | 1995 } |
2038 | 1996 |
2039 // Applies the shaders and shader constants to the Direct3D 9 device | 1997 // Applies the shaders and shader constants to the Direct3D 9 device |
2040 void Context::applyShaders() | 1998 void Context::applyShaders() |
2041 { | 1999 { |
2042 IDirect3DDevice9 *device = getDevice(); | 2000 IDirect3DDevice9 *device = getDevice(); |
2043 Program *programObject = getCurrentProgram(); | 2001 Program *programObject = getCurrentProgram(); |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2195 for (int j = 0; j < rect.bottom - rect.top; j++) | 2153 for (int j = 0; j < rect.bottom - rect.top; j++) |
2196 { | 2154 { |
2197 if (desc.Format == D3DFMT_A8R8G8B8 && | 2155 if (desc.Format == D3DFMT_A8R8G8B8 && |
2198 format == GL_BGRA_EXT && | 2156 format == GL_BGRA_EXT && |
2199 type == GL_UNSIGNED_BYTE) | 2157 type == GL_UNSIGNED_BYTE) |
2200 { | 2158 { |
2201 // Fast path for EXT_read_format_bgra, given | 2159 // Fast path for EXT_read_format_bgra, given |
2202 // an RGBA source buffer. Note that buffers with no | 2160 // an RGBA source buffer. Note that buffers with no |
2203 // alpha go through the slow path below. | 2161 // alpha go through the slow path below. |
2204 memcpy(dest + j * outputPitch, | 2162 memcpy(dest + j * outputPitch, |
2205 source + j * lock.Pitch, | 2163 source + j * inputPitch, |
2206 (rect.right - rect.left) * 4); | 2164 (rect.right - rect.left) * 4); |
2207 continue; | 2165 continue; |
2208 } | 2166 } |
2209 | 2167 |
2210 for (int i = 0; i < rect.right - rect.left; i++) | 2168 for (int i = 0; i < rect.right - rect.left; i++) |
2211 { | 2169 { |
2212 float r; | 2170 float r; |
2213 float g; | 2171 float g; |
2214 float b; | 2172 float b; |
2215 float a; | 2173 float a; |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2482 device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE); | 2440 device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE); |
2483 device->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID); | 2441 device->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID); |
2484 device->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE); | 2442 device->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE); |
2485 device->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); | 2443 device->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); |
2486 device->SetRenderState(D3DRS_CLIPPLANEENABLE, 0); | 2444 device->SetRenderState(D3DRS_CLIPPLANEENABLE, 0); |
2487 device->SetRenderState(D3DRS_COLORWRITEENABLE, 0); | 2445 device->SetRenderState(D3DRS_COLORWRITEENABLE, 0); |
2488 device->SetRenderState(D3DRS_STENCILENABLE, FALSE); | 2446 device->SetRenderState(D3DRS_STENCILENABLE, FALSE); |
2489 device->SetPixelShader(NULL); | 2447 device->SetPixelShader(NULL); |
2490 device->SetVertexShader(NULL); | 2448 device->SetVertexShader(NULL); |
2491 device->SetFVF(D3DFVF_XYZRHW | D3DFVF_DIFFUSE); | 2449 device->SetFVF(D3DFVF_XYZRHW | D3DFVF_DIFFUSE); |
2492 device->SetStreamSourceFreq(0, 1); | |
2493 device->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_DISABLE); | 2450 device->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_DISABLE); |
2494 | 2451 |
2495 hr = device->EndStateBlock(&mMaskedClearSavedState); | 2452 hr = device->EndStateBlock(&mMaskedClearSavedState); |
2496 ASSERT(SUCCEEDED(hr) || hr == D3DERR_OUTOFVIDEOMEMORY || hr == E_OUT
OFMEMORY); | 2453 ASSERT(SUCCEEDED(hr) || hr == D3DERR_OUTOFVIDEOMEMORY || hr == E_OUT
OFMEMORY); |
2497 } | 2454 } |
2498 | 2455 |
2499 ASSERT(mMaskedClearSavedState != NULL); | 2456 ASSERT(mMaskedClearSavedState != NULL); |
2500 | 2457 |
2501 if (mMaskedClearSavedState != NULL) | 2458 if (mMaskedClearSavedState != NULL) |
2502 { | 2459 { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2538 mStencilStateDirty = true; | 2495 mStencilStateDirty = true; |
2539 } | 2496 } |
2540 else | 2497 else |
2541 { | 2498 { |
2542 device->SetRenderState(D3DRS_STENCILENABLE, FALSE); | 2499 device->SetRenderState(D3DRS_STENCILENABLE, FALSE); |
2543 } | 2500 } |
2544 | 2501 |
2545 device->SetPixelShader(NULL); | 2502 device->SetPixelShader(NULL); |
2546 device->SetVertexShader(NULL); | 2503 device->SetVertexShader(NULL); |
2547 device->SetFVF(D3DFVF_XYZRHW | D3DFVF_DIFFUSE); | 2504 device->SetFVF(D3DFVF_XYZRHW | D3DFVF_DIFFUSE); |
2548 device->SetStreamSourceFreq(0, 1); | |
2549 device->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_DISABLE); | 2505 device->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_DISABLE); |
2550 | 2506 |
2551 struct Vertex | 2507 struct Vertex |
2552 { | 2508 { |
2553 float x, y, z, w; | 2509 float x, y, z, w; |
2554 D3DCOLOR diffuse; | 2510 D3DCOLOR diffuse; |
2555 }; | 2511 }; |
2556 | 2512 |
2557 Vertex quad[4]; | 2513 Vertex quad[4]; |
2558 quad[0].x = 0.0f; | 2514 quad[0].x = 0.0f; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2620 return; | 2576 return; |
2621 } | 2577 } |
2622 | 2578 |
2623 if (!applyRenderTarget(false)) | 2579 if (!applyRenderTarget(false)) |
2624 { | 2580 { |
2625 return; | 2581 return; |
2626 } | 2582 } |
2627 | 2583 |
2628 applyState(mode); | 2584 applyState(mode); |
2629 | 2585 |
2630 TranslatedIndexData indexInfo; | 2586 GLenum err = applyVertexBuffer(first, count); |
2631 bool useIndexing; | |
2632 GLenum err = applyVertexBuffer(mode, first, count, &useIndexing, &indexInfo)
; | |
2633 if (err != GL_NO_ERROR) | 2587 if (err != GL_NO_ERROR) |
2634 { | 2588 { |
2635 return error(err); | 2589 return error(err); |
2636 } | 2590 } |
2637 | 2591 |
2638 applyShaders(); | 2592 applyShaders(); |
2639 applyTextures(); | 2593 applyTextures(); |
2640 | 2594 |
2641 if (!getCurrentProgram()->validateSamplers()) | 2595 if (!getCurrentProgram()->validateSamplers()) |
2642 { | 2596 { |
2643 return error(GL_INVALID_OPERATION); | 2597 return error(GL_INVALID_OPERATION); |
2644 } | 2598 } |
2645 | 2599 |
2646 if (!cullSkipsDraw(mode)) | 2600 if (!cullSkipsDraw(mode)) |
2647 { | 2601 { |
2648 display->startScene(); | 2602 display->startScene(); |
2649 if (useIndexing) | 2603 ········ |
2650 { | 2604 device->DrawPrimitive(primitiveType, 0, primitiveCount); |
2651 device->DrawIndexedPrimitive(primitiveType, -(INT)indexInfo.minIndex
, indexInfo.minIndex, indexInfo.maxIndex-indexInfo.minIndex+1, indexInfo.offset/
indexInfo.indexSize, primitiveCount); | 2605 |
2652 } | 2606 if (mode == GL_LINE_LOOP) // Draw the last segment separately |
2653 else | 2607 { |
2654 { | 2608 drawClosingLine(first, first + count - 1); |
2655 device->DrawPrimitive(primitiveType, 0, primitiveCount); | 2609 } |
2656 } | 2610 } |
2657 } | 2611 } |
2658 } | 2612 |
2659 | 2613 void Context::drawElements(GLenum mode, GLsizei count, GLenum type, const void *
indices) |
2660 void Context::drawElements(GLenum mode, GLsizei count, GLenum type, const void*
indices) | |
2661 { | 2614 { |
2662 if (!mState.currentProgram) | 2615 if (!mState.currentProgram) |
2663 { | 2616 { |
2664 return error(GL_INVALID_OPERATION); | 2617 return error(GL_INVALID_OPERATION); |
2665 } | 2618 } |
2666 | 2619 |
2667 if (!indices && !mState.elementArrayBuffer) | 2620 if (!indices && !mState.elementArrayBuffer) |
2668 { | 2621 { |
2669 return error(GL_INVALID_OPERATION); | 2622 return error(GL_INVALID_OPERATION); |
2670 } | 2623 } |
(...skipping 18 matching lines...) Expand all Loading... |
2689 | 2642 |
2690 applyState(mode); | 2643 applyState(mode); |
2691 | 2644 |
2692 TranslatedIndexData indexInfo; | 2645 TranslatedIndexData indexInfo; |
2693 GLenum err = applyIndexBuffer(indices, count, mode, type, &indexInfo); | 2646 GLenum err = applyIndexBuffer(indices, count, mode, type, &indexInfo); |
2694 if (err != GL_NO_ERROR) | 2647 if (err != GL_NO_ERROR) |
2695 { | 2648 { |
2696 return error(err); | 2649 return error(err); |
2697 } | 2650 } |
2698 | 2651 |
2699 err = applyVertexBuffer(indexInfo); | 2652 GLsizei vertexCount = indexInfo.maxIndex - indexInfo.minIndex + 1; |
| 2653 err = applyVertexBuffer(indexInfo.minIndex, vertexCount); |
2700 if (err != GL_NO_ERROR) | 2654 if (err != GL_NO_ERROR) |
2701 { | 2655 { |
2702 return error(err); | 2656 return error(err); |
2703 } | 2657 } |
2704 | 2658 |
2705 applyShaders(); | 2659 applyShaders(); |
2706 applyTextures(); | 2660 applyTextures(); |
2707 | 2661 |
2708 if (!getCurrentProgram()->validateSamplers()) | 2662 if (!getCurrentProgram()->validateSamplers()) |
2709 { | 2663 { |
2710 return error(GL_INVALID_OPERATION); | 2664 return error(GL_INVALID_OPERATION); |
2711 } | 2665 } |
2712 | 2666 |
2713 if (!cullSkipsDraw(mode)) | 2667 if (!cullSkipsDraw(mode)) |
2714 { | 2668 { |
2715 display->startScene(); | 2669 display->startScene(); |
2716 device->DrawIndexedPrimitive(primitiveType, -(INT)indexInfo.minIndex, in
dexInfo.minIndex, indexInfo.maxIndex-indexInfo.minIndex+1, indexInfo.offset/inde
xInfo.indexSize, primitiveCount); | 2670 |
| 2671 device->DrawIndexedPrimitive(primitiveType, -(INT)indexInfo.minIndex, in
dexInfo.minIndex, vertexCount, indexInfo.startIndex, primitiveCount); |
| 2672 |
| 2673 if (mode == GL_LINE_LOOP) // Draw the last segment separately |
| 2674 { |
| 2675 drawClosingLine(count, type, indices); |
| 2676 } |
2717 } | 2677 } |
2718 } | 2678 } |
2719 | 2679 |
2720 void Context::finish() | 2680 void Context::finish() |
2721 { | 2681 { |
2722 egl::Display *display = getDisplay(); | 2682 egl::Display *display = getDisplay(); |
2723 IDirect3DDevice9 *device = getDevice(); | 2683 IDirect3DDevice9 *device = getDevice(); |
2724 IDirect3DQuery9 *occlusionQuery = NULL; | 2684 IDirect3DQuery9 *occlusionQuery = NULL; |
2725 | 2685 |
2726 HRESULT result = device->CreateQuery(D3DQUERYTYPE_OCCLUSION, &occlusionQuery
); | 2686 HRESULT result = device->CreateQuery(D3DQUERYTYPE_OCCLUSION, &occlusionQuery
); |
2727 | 2687 |
2728 if (result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY) | 2688 if (result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY) |
2729 { | 2689 { |
2730 return error(GL_OUT_OF_MEMORY); | 2690 return error(GL_OUT_OF_MEMORY); |
2731 } | 2691 } |
2732 | 2692 |
2733 ASSERT(SUCCEEDED(result)); | 2693 ASSERT(SUCCEEDED(result)); |
2734 | 2694 |
2735 if (occlusionQuery) | 2695 if (occlusionQuery) |
2736 { | 2696 { |
2737 IDirect3DStateBlock9 *savedState = NULL; | 2697 IDirect3DStateBlock9 *savedState = NULL; |
2738 device->CreateStateBlock(D3DSBT_ALL, &savedState); | 2698 device->CreateStateBlock(D3DSBT_ALL, &savedState); |
2739 | 2699 |
2740 HRESULT result = occlusionQuery->Issue(D3DISSUE_BEGIN); | 2700 HRESULT result = occlusionQuery->Issue(D3DISSUE_BEGIN); |
2741 ASSERT(SUCCEEDED(result)); | 2701 ASSERT(SUCCEEDED(result)); |
2742 | 2702 |
2743 // Render something outside the render target | 2703 // Render something outside the render target |
2744 device->SetStreamSourceFreq(0, 1); | |
2745 device->SetPixelShader(NULL); | 2704 device->SetPixelShader(NULL); |
2746 device->SetVertexShader(NULL); | 2705 device->SetVertexShader(NULL); |
2747 device->SetFVF(D3DFVF_XYZRHW); | 2706 device->SetFVF(D3DFVF_XYZRHW); |
2748 float data[4] = {-1.0f, -1.0f, -1.0f, 1.0f}; | 2707 float data[4] = {-1.0f, -1.0f, -1.0f, 1.0f}; |
2749 display->startScene(); | 2708 display->startScene(); |
2750 device->DrawPrimitiveUP(D3DPT_POINTLIST, 1, data, sizeof(data)); | 2709 device->DrawPrimitiveUP(D3DPT_POINTLIST, 1, data, sizeof(data)); |
2751 | 2710 |
2752 result = occlusionQuery->Issue(D3DISSUE_END); | 2711 result = occlusionQuery->Issue(D3DISSUE_END); |
2753 ASSERT(SUCCEEDED(result)); | 2712 ASSERT(SUCCEEDED(result)); |
2754 | 2713 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2790 result = eventQuery->GetData(NULL, 0, D3DGETDATA_FLUSH); | 2749 result = eventQuery->GetData(NULL, 0, D3DGETDATA_FLUSH); |
2791 eventQuery->Release(); | 2750 eventQuery->Release(); |
2792 | 2751 |
2793 if (result == D3DERR_DEVICELOST) | 2752 if (result == D3DERR_DEVICELOST) |
2794 { | 2753 { |
2795 error(GL_OUT_OF_MEMORY); | 2754 error(GL_OUT_OF_MEMORY); |
2796 } | 2755 } |
2797 } | 2756 } |
2798 } | 2757 } |
2799 | 2758 |
| 2759 void Context::drawClosingLine(unsigned int first, unsigned int last) |
| 2760 { |
| 2761 IDirect3DDevice9 *device = getDevice(); |
| 2762 IDirect3DIndexBuffer9 *indexBuffer = NULL; |
| 2763 HRESULT result = D3DERR_INVALIDCALL; |
| 2764 |
| 2765 if (supports32bitIndices()) |
| 2766 { |
| 2767 result = device->CreateIndexBuffer(8, D3DUSAGE_WRITEONLY, D3DFMT_INDEX32
, D3DPOOL_DEFAULT, &indexBuffer, 0); |
| 2768 |
| 2769 if (SUCCEEDED(result)) |
| 2770 { |
| 2771 unsigned int *data; |
| 2772 result = indexBuffer->Lock(0, 0, (void**)&data, 0); |
| 2773 |
| 2774 if (SUCCEEDED(result)) |
| 2775 { |
| 2776 data[0] = last; |
| 2777 data[1] = first; |
| 2778 } |
| 2779 } |
| 2780 } |
| 2781 else |
| 2782 { |
| 2783 result = device->CreateIndexBuffer(4, D3DUSAGE_WRITEONLY, D3DFMT_INDEX16
, D3DPOOL_DEFAULT, &indexBuffer, 0); |
| 2784 |
| 2785 if (SUCCEEDED(result)) |
| 2786 { |
| 2787 unsigned short *data; |
| 2788 result = indexBuffer->Lock(0, 0, (void**)&data, 0); |
| 2789 |
| 2790 if (SUCCEEDED(result)) |
| 2791 { |
| 2792 data[0] = last; |
| 2793 data[1] = first; |
| 2794 } |
| 2795 } |
| 2796 } |
| 2797 ···· |
| 2798 if (SUCCEEDED(result)) |
| 2799 { |
| 2800 indexBuffer->Unlock(); |
| 2801 device->SetIndices(indexBuffer); |
| 2802 |
| 2803 device->DrawIndexedPrimitive(D3DPT_LINELIST, 0, 0, 2, 0, 1); |
| 2804 |
| 2805 indexBuffer->Release(); |
| 2806 } |
| 2807 else |
| 2808 { |
| 2809 ERR("Could not create an index buffer for closing a line loop."); |
| 2810 error(GL_OUT_OF_MEMORY); |
| 2811 } |
| 2812 } |
| 2813 |
| 2814 void Context::drawClosingLine(GLsizei count, GLenum type, const void *indices) |
| 2815 { |
| 2816 unsigned int first = 0; |
| 2817 unsigned int last = 0; |
| 2818 |
| 2819 if (mState.elementArrayBuffer.get()) |
| 2820 { |
| 2821 Buffer *indexBuffer = mState.elementArrayBuffer.get(); |
| 2822 intptr_t offset = reinterpret_cast<intptr_t>(indices); |
| 2823 indices = static_cast<const GLubyte*>(indexBuffer->data()) + offset; |
| 2824 } |
| 2825 |
| 2826 switch (type) |
| 2827 { |
| 2828 case GL_UNSIGNED_BYTE: |
| 2829 first = static_cast<const GLubyte*>(indices)[0]; |
| 2830 last = static_cast<const GLubyte*>(indices)[count - 1]; |
| 2831 break; |
| 2832 case GL_UNSIGNED_SHORT: |
| 2833 first = static_cast<const GLushort*>(indices)[0]; |
| 2834 last = static_cast<const GLushort*>(indices)[count - 1]; |
| 2835 break; |
| 2836 case GL_UNSIGNED_INT: |
| 2837 first = static_cast<const GLuint*>(indices)[0]; |
| 2838 last = static_cast<const GLuint*>(indices)[count - 1]; |
| 2839 break; |
| 2840 default: UNREACHABLE(); |
| 2841 } |
| 2842 |
| 2843 drawClosingLine(first, last); |
| 2844 } |
| 2845 |
2800 void Context::recordInvalidEnum() | 2846 void Context::recordInvalidEnum() |
2801 { | 2847 { |
2802 mInvalidEnum = true; | 2848 mInvalidEnum = true; |
2803 } | 2849 } |
2804 | 2850 |
2805 void Context::recordInvalidValue() | 2851 void Context::recordInvalidValue() |
2806 { | 2852 { |
2807 mInvalidValue = true; | 2853 mInvalidValue = true; |
2808 } | 2854 } |
2809 | 2855 |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2969 } | 3015 } |
2970 | 3016 |
2971 bool Context::supportsLuminanceTextures() const | 3017 bool Context::supportsLuminanceTextures() const |
2972 { | 3018 { |
2973 return mSupportsLuminanceTextures; | 3019 return mSupportsLuminanceTextures; |
2974 } | 3020 } |
2975 | 3021 |
2976 bool Context::supportsLuminanceAlphaTextures() const | 3022 bool Context::supportsLuminanceAlphaTextures() const |
2977 { | 3023 { |
2978 return mSupportsLuminanceAlphaTextures; | 3024 return mSupportsLuminanceAlphaTextures; |
| 3025 } |
| 3026 |
| 3027 bool Context::supports32bitIndices() const |
| 3028 { |
| 3029 return mSupports32bitIndices; |
2979 } | 3030 } |
2980 | 3031 |
2981 void Context::detachBuffer(GLuint buffer) | 3032 void Context::detachBuffer(GLuint buffer) |
2982 { | 3033 { |
2983 // [OpenGL ES 2.0.24] section 2.9 page 22: | 3034 // [OpenGL ES 2.0.24] section 2.9 page 22: |
2984 // If a buffer object is deleted while it is bound, all bindings to that obj
ect in the current context | 3035 // If a buffer object is deleted while it is bound, all bindings to that obj
ect in the current context |
2985 // (i.e. in the thread that called Delete-Buffers) are reset to zero. | 3036 // (i.e. in the thread that called Delete-Buffers) are reset to zero. |
2986 | 3037 |
2987 if (mState.arrayBuffer.id() == buffer) | 3038 if (mState.arrayBuffer.id() == buffer) |
2988 { | 3039 { |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3156 | 3207 |
3157 void Context::setVertexAttrib(GLuint index, const GLfloat *values) | 3208 void Context::setVertexAttrib(GLuint index, const GLfloat *values) |
3158 { | 3209 { |
3159 ASSERT(index < gl::MAX_VERTEX_ATTRIBS); | 3210 ASSERT(index < gl::MAX_VERTEX_ATTRIBS); |
3160 | 3211 |
3161 mState.vertexAttribute[index].mCurrentValue[0] = values[0]; | 3212 mState.vertexAttribute[index].mCurrentValue[0] = values[0]; |
3162 mState.vertexAttribute[index].mCurrentValue[1] = values[1]; | 3213 mState.vertexAttribute[index].mCurrentValue[1] = values[1]; |
3163 mState.vertexAttribute[index].mCurrentValue[2] = values[2]; | 3214 mState.vertexAttribute[index].mCurrentValue[2] = values[2]; |
3164 mState.vertexAttribute[index].mCurrentValue[3] = values[3]; | 3215 mState.vertexAttribute[index].mCurrentValue[3] = values[3]; |
3165 | 3216 |
3166 mVertexDataManager->dirtyCurrentValues(); | 3217 mVertexDataManager->dirtyCurrentValue(index); |
3167 } | 3218 } |
3168 | 3219 |
3169 void Context::initExtensionString() | 3220 void Context::initExtensionString() |
3170 { | 3221 { |
3171 mExtensionString += "GL_OES_packed_depth_stencil "; | 3222 mExtensionString += "GL_OES_packed_depth_stencil "; |
3172 mExtensionString += "GL_EXT_texture_format_BGRA8888 "; | 3223 mExtensionString += "GL_EXT_texture_format_BGRA8888 "; |
3173 mExtensionString += "GL_EXT_read_format_bgra "; | 3224 mExtensionString += "GL_EXT_read_format_bgra "; |
3174 mExtensionString += "GL_ANGLE_framebuffer_blit "; | 3225 mExtensionString += "GL_ANGLE_framebuffer_blit "; |
3175 mExtensionString += "GL_OES_rgb8_rgba8 "; | 3226 mExtensionString += "GL_OES_rgb8_rgba8 "; |
3176 mExtensionString += "GL_OES_standard_derivatives "; | 3227 mExtensionString += "GL_OES_standard_derivatives "; |
(...skipping 26 matching lines...) Expand all Loading... |
3203 if (supportsHalfFloatLinearFilter()) | 3254 if (supportsHalfFloatLinearFilter()) |
3204 { | 3255 { |
3205 mExtensionString += "GL_OES_texture_half_float_linear "; | 3256 mExtensionString += "GL_OES_texture_half_float_linear "; |
3206 } | 3257 } |
3207 | 3258 |
3208 if (getMaxSupportedSamples() != 0) | 3259 if (getMaxSupportedSamples() != 0) |
3209 { | 3260 { |
3210 mExtensionString += "GL_ANGLE_framebuffer_multisample "; | 3261 mExtensionString += "GL_ANGLE_framebuffer_multisample "; |
3211 } | 3262 } |
3212 | 3263 |
3213 if (mBufferBackEnd->supportIntIndices()) | 3264 if (supports32bitIndices()) |
3214 { | 3265 { |
3215 mExtensionString += "GL_OES_element_index_uint "; | 3266 mExtensionString += "GL_OES_element_index_uint "; |
3216 } | 3267 } |
3217 | 3268 |
3218 std::string::size_type end = mExtensionString.find_last_not_of(' '); | 3269 std::string::size_type end = mExtensionString.find_last_not_of(' '); |
3219 if (end != std::string::npos) | 3270 if (end != std::string::npos) |
3220 { | 3271 { |
3221 mExtensionString.resize(end+1); | 3272 mExtensionString.resize(end+1); |
3222 } | 3273 } |
3223 } | 3274 } |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3380 } | 3431 } |
3381 | 3432 |
3382 if (destTrimmedRect.bottom > drawBufferHeight) | 3433 if (destTrimmedRect.bottom > drawBufferHeight) |
3383 { | 3434 { |
3384 int yDiff = destTrimmedRect.bottom - drawBufferHeight; | 3435 int yDiff = destTrimmedRect.bottom - drawBufferHeight; |
3385 destTrimmedRect.bottom = drawBufferHeight; | 3436 destTrimmedRect.bottom = drawBufferHeight; |
3386 sourceTrimmedRect.bottom -= yDiff; | 3437 sourceTrimmedRect.bottom -= yDiff; |
3387 } | 3438 } |
3388 | 3439 |
3389 bool partialBufferCopy = false; | 3440 bool partialBufferCopy = false; |
3390 if (sourceTrimmedRect.bottom - sourceTrimmedRect.top < readFramebuffer->getC
olorbuffer()->getHeight() || | 3441 if (sourceTrimmedRect.bottom - sourceTrimmedRect.top < readBufferHeight || |
3391 sourceTrimmedRect.right - sourceTrimmedRect.left < readFramebuffer->getC
olorbuffer()->getWidth() ||· | 3442 sourceTrimmedRect.right - sourceTrimmedRect.left < readBufferWidth ||· |
3392 destTrimmedRect.bottom - destTrimmedRect.top < drawFramebuffer->getColor
buffer()->getHeight() || | 3443 destTrimmedRect.bottom - destTrimmedRect.top < drawBufferHeight || |
3393 destTrimmedRect.right - destTrimmedRect.left < drawFramebuffer->getColor
buffer()->getWidth() || | 3444 destTrimmedRect.right - destTrimmedRect.left < drawBufferWidth || |
3394 sourceTrimmedRect.top != 0 || destTrimmedRect.top != 0 || sourceTrimmedR
ect.left != 0 || destTrimmedRect.left != 0) | 3445 sourceTrimmedRect.top != 0 || destTrimmedRect.top != 0 || sourceTrimmedR
ect.left != 0 || destTrimmedRect.left != 0) |
3395 { | 3446 { |
3396 partialBufferCopy = true; | 3447 partialBufferCopy = true; |
3397 } | 3448 } |
3398 | 3449 |
3399 if (mask & GL_COLOR_BUFFER_BIT) | 3450 if (mask & GL_COLOR_BUFFER_BIT) |
3400 { | 3451 { |
3401 const bool validReadType = readFramebuffer->getColorbufferType() == GL_T
EXTURE_2D || | 3452 const bool validReadType = readFramebuffer->getColorbufferType() == GL_T
EXTURE_2D || |
3402 readFramebuffer->getColorbufferType() == GL_RENDERBUFFER; | 3453 readFramebuffer->getColorbufferType() == GL_RENDERBUFFER; |
3403 const bool validDrawType = drawFramebuffer->getColorbufferType() == GL_T
EXTURE_2D || | 3454 const bool validDrawType = drawFramebuffer->getColorbufferType() == GL_T
EXTURE_2D || |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3523 void glMakeCurrent(gl::Context *context, egl::Display *display, egl::Surface *su
rface) | 3574 void glMakeCurrent(gl::Context *context, egl::Display *display, egl::Surface *su
rface) |
3524 { | 3575 { |
3525 gl::makeCurrent(context, display, surface); | 3576 gl::makeCurrent(context, display, surface); |
3526 } | 3577 } |
3527 | 3578 |
3528 gl::Context *glGetCurrentContext() | 3579 gl::Context *glGetCurrentContext() |
3529 { | 3580 { |
3530 return gl::getContext(); | 3581 return gl::getContext(); |
3531 } | 3582 } |
3532 } | 3583 } |
LEFT | RIGHT |