summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/angle/src/libGLESv2/State.cpp
diff options
context:
space:
mode:
authorAndrew Knight <andrew.knight@digia.com>2014-09-25 13:22:55 +0300
committerAndrew Knight <andrew.knight@digia.com>2014-09-29 16:09:29 +0200
commit311157c3c6849e8efccd88f7594bb34c570a6780 (patch)
treea50c252b638488326529c0e69aa05e42abce7462 /src/3rdparty/angle/src/libGLESv2/State.cpp
parent04d3a89e20d49a3b5015b071bfdedc81973b090c (diff)
ANGLE: Upgrade to 2.1~abce76206141
Upgrade to address issues discovered since the last upgrade. Patch notes: 0000-General-fixes-for-ANGLE-2.1.patch added removal of the unused third-party tracing functions 0003-Fix-compilation-with-MinGW-gcc-64-bit.patch removed as it is no longer needed 0011-ANGLE-Fix-compilation-error-on-MinGW-caused-by-trace.patch removed as it is no longer needed 0016-ANGLE-Fix-compilation-with-MinGW-D3D11.patch now supports MinGW 64-bit [ChangeLog][Third-party libraries] ANGLE updated to 2.1~f8602ad91e4f Task-number: QTBUG-40649 Task-number: QTBUG-40658 Task-number: QTBUG-41031 Task-number: QTBUG-41081 Task-number: QTBUG-41308 Task-number: QTBUG-41563 Change-Id: I9f776c8d5cb94ddb12d608a8d5630bfc54437bea Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Oliver Wolff <oliver.wolff@digia.com> Reviewed-by: Kai Koehne <kai.koehne@digia.com>
Diffstat (limited to 'src/3rdparty/angle/src/libGLESv2/State.cpp')
-rw-r--r--src/3rdparty/angle/src/libGLESv2/State.cpp124
1 files changed, 82 insertions, 42 deletions
diff --git a/src/3rdparty/angle/src/libGLESv2/State.cpp b/src/3rdparty/angle/src/libGLESv2/State.cpp
index b552701727..3c03b90e56 100644
--- a/src/3rdparty/angle/src/libGLESv2/State.cpp
+++ b/src/3rdparty/angle/src/libGLESv2/State.cpp
@@ -1,4 +1,3 @@
-#include "precompiled.h"
//
// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
@@ -10,6 +9,7 @@
#include "libGLESv2/State.h"
#include "libGLESv2/Context.h"
+#include "libGLESv2/Caps.h"
#include "libGLESv2/VertexArray.h"
#include "libGLESv2/Query.h"
#include "libGLESv2/Framebuffer.h"
@@ -19,8 +19,18 @@
namespace gl
{
+
State::State()
{
+}
+
+State::~State()
+{
+ reset();
+}
+
+void State::initialize(const Caps& caps, GLuint clientVersion)
+{
mContext = NULL;
setClearColor(0.0f, 0.0f, 0.0f, 0.0f);
@@ -66,7 +76,7 @@ State::State()
mDepthStencil.stencilMask = -1;
mDepthStencil.stencilWritemask = -1;
mDepthStencil.stencilBackFunc = GL_ALWAYS;
- mDepthStencil.stencilBackMask = - 1;
+ mDepthStencil.stencilBackMask = -1;
mDepthStencil.stencilBackWritemask = -1;
mDepthStencil.stencilFail = GL_KEEP;
mDepthStencil.stencilPassDepthFail = GL_KEEP;
@@ -98,18 +108,24 @@ State::State()
mBlend.colorMaskBlue = true;
mBlend.colorMaskAlpha = true;
+ mActiveSampler = 0;
+
const GLfloat defaultFloatValues[] = { 0.0f, 0.0f, 0.0f, 1.0f };
for (int attribIndex = 0; attribIndex < MAX_VERTEX_ATTRIBS; attribIndex++)
{
mVertexAttribCurrentValues[attribIndex].setFloatValues(defaultFloatValues);
}
- for (unsigned int textureUnit = 0; textureUnit < ArraySize(mSamplers); textureUnit++)
+ mSamplerTextures[GL_TEXTURE_2D].resize(caps.maxCombinedTextureImageUnits);
+ mSamplerTextures[GL_TEXTURE_CUBE_MAP].resize(caps.maxCombinedTextureImageUnits);
+ if (clientVersion >= 3)
{
- mSamplers[textureUnit].set(NULL);
+ // TODO: These could also be enabled via extension
+ mSamplerTextures[GL_TEXTURE_2D_ARRAY].resize(caps.maxCombinedTextureImageUnits);
+ mSamplerTextures[GL_TEXTURE_3D].resize(caps.maxCombinedTextureImageUnits);
}
- mActiveSampler = 0;
+ mSamplers.resize(caps.maxCombinedTextureImageUnits);
mActiveQueries[GL_ANY_SAMPLES_PASSED].set(NULL);
mActiveQueries[GL_ANY_SAMPLES_PASSED_CONSERVATIVE].set(NULL);
@@ -122,15 +138,20 @@ State::State()
mDrawFramebuffer = NULL;
}
-State::~State()
+void State::reset()
{
- for (int type = 0; type < TEXTURE_TYPE_COUNT; type++)
+ for (TextureBindingMap::iterator bindingVec = mSamplerTextures.begin(); bindingVec != mSamplerTextures.end(); bindingVec++)
{
- for (int sampler = 0; sampler < IMPLEMENTATION_MAX_COMBINED_TEXTURE_IMAGE_UNITS; sampler++)
+ TextureBindingVector &textureVector = bindingVec->second;
+ for (size_t textureIdx = 0; textureIdx < textureVector.size(); textureIdx++)
{
- mSamplerTexture[type][sampler].set(NULL);
+ textureVector[textureIdx].set(NULL);
}
}
+ for (size_t samplerIdx = 0; samplerIdx < mSamplers.size(); samplerIdx++)
+ {
+ mSamplers[samplerIdx].set(NULL);
+ }
const GLfloat defaultFloatValues[] = { 0.0f, 0.0f, 0.0f, 1.0f };
for (int attribIndex = 0; attribIndex < MAX_VERTEX_ATTRIBS; attribIndex++)
@@ -245,15 +266,8 @@ ClearParameters State::getClearParameters(GLbitfield mask) const
{
if (framebufferObject->getStencilbuffer() != NULL)
{
- rx::RenderTarget *depthStencil = framebufferObject->getStencilbuffer()->getDepthStencil();
- if (!depthStencil)
- {
- ERR("Depth stencil pointer unexpectedly null.");
- ClearParameters nullClearParam = { 0 };
- return nullClearParam;
- }
-
- if (GetStencilBits(depthStencil->getActualFormat()) > 0)
+ GLenum stencilActualFormat = framebufferObject->getStencilbuffer()->getActualFormat();
+ if (GetInternalFormatInfo(stencilActualFormat).stencilBits > 0)
{
clearParams.clearStencil = true;
}
@@ -591,26 +605,26 @@ unsigned int State::getActiveSampler() const
return mActiveSampler;
}
-void State::setSamplerTexture(TextureType type, Texture *texture)
+void State::setSamplerTexture(GLenum type, Texture *texture)
{
- mSamplerTexture[type][mActiveSampler].set(texture);
+ mSamplerTextures[type][mActiveSampler].set(texture);
}
-Texture *State::getSamplerTexture(unsigned int sampler, TextureType type) const
+Texture *State::getSamplerTexture(unsigned int sampler, GLenum type) const
{
- GLuint texid = mSamplerTexture[type][sampler].id();
+ const BindingPointer<Texture>& binding = mSamplerTextures.at(type)[sampler];
- if (texid == 0) // Special case: 0 refers to default textures held by Context
+ if (binding.id() == 0) // Special case: 0 refers to default textures held by Context
{
return NULL;
}
- return mSamplerTexture[type][sampler].get();
+ return binding.get();
}
-GLuint State::getSamplerTextureId(unsigned int sampler, TextureType type) const
+GLuint State::getSamplerTextureId(unsigned int sampler, GLenum type) const
{
- return mSamplerTexture[type][sampler].id();
+ return mSamplerTextures.at(type)[sampler].id();
}
void State::detachTexture(GLuint texture)
@@ -624,13 +638,15 @@ void State::detachTexture(GLuint texture)
// If a texture object is deleted, it is as if all texture units which are bound to that texture object are
// rebound to texture object zero
- for (int type = 0; type < TEXTURE_TYPE_COUNT; type++)
+ for (TextureBindingMap::iterator bindingVec = mSamplerTextures.begin(); bindingVec != mSamplerTextures.end(); bindingVec++)
{
- for (int sampler = 0; sampler < IMPLEMENTATION_MAX_COMBINED_TEXTURE_IMAGE_UNITS; sampler++)
+ TextureBindingVector &textureVector = bindingVec->second;
+ for (size_t textureIdx = 0; textureIdx < textureVector.size(); textureIdx++)
{
- if (mSamplerTexture[type][sampler].id() == texture)
+ BindingPointer<Texture> &binding = textureVector[textureIdx];
+ if (binding.id() == texture)
{
- mSamplerTexture[type][sampler].set(NULL);
+ binding.set(NULL);
}
}
}
@@ -658,7 +674,7 @@ void State::setSamplerBinding(GLuint textureUnit, Sampler *sampler)
GLuint State::getSamplerId(GLuint textureUnit) const
{
- ASSERT(textureUnit < ArraySize(mSamplers));
+ ASSERT(textureUnit < mSamplers.size());
return mSamplers[textureUnit].id();
}
@@ -673,11 +689,12 @@ void State::detachSampler(GLuint sampler)
// If a sampler object that is currently bound to one or more texture units is
// deleted, it is as though BindSampler is called once for each texture unit to
// which the sampler is bound, with unit set to the texture unit and sampler set to zero.
- for (unsigned int textureUnit = 0; textureUnit < ArraySize(mSamplers); textureUnit++)
+ for (size_t textureUnit = 0; textureUnit < mSamplers.size(); textureUnit++)
{
- if (mSamplers[textureUnit].id() == sampler)
+ BindingPointer<Sampler> &samplerBinding = mSamplers[textureUnit];
+ if (samplerBinding.id() == sampler)
{
- mSamplers[textureUnit].set(NULL);
+ samplerBinding.set(NULL);
}
}
}
@@ -1315,20 +1332,20 @@ void State::getIntegerv(GLenum pname, GLint *params)
}
break;
case GL_TEXTURE_BINDING_2D:
- ASSERT(mActiveSampler < mContext->getMaximumCombinedTextureImageUnits());
- *params = mSamplerTexture[TEXTURE_2D][mActiveSampler].id();
+ ASSERT(mActiveSampler < mContext->getCaps().maxCombinedTextureImageUnits);
+ *params = mSamplerTextures.at(GL_TEXTURE_2D)[mActiveSampler].id();
break;
case GL_TEXTURE_BINDING_CUBE_MAP:
- ASSERT(mActiveSampler < mContext->getMaximumCombinedTextureImageUnits());
- *params = mSamplerTexture[TEXTURE_CUBE][mActiveSampler].id();
+ ASSERT(mActiveSampler < mContext->getCaps().maxCombinedTextureImageUnits);
+ *params = mSamplerTextures.at(GL_TEXTURE_CUBE_MAP)[mActiveSampler].id();
break;
case GL_TEXTURE_BINDING_3D:
- ASSERT(mActiveSampler < mContext->getMaximumCombinedTextureImageUnits());
- *params = mSamplerTexture[TEXTURE_3D][mActiveSampler].id();
+ ASSERT(mActiveSampler <mContext->getCaps().maxCombinedTextureImageUnits);
+ *params = mSamplerTextures.at(GL_TEXTURE_3D)[mActiveSampler].id();
break;
case GL_TEXTURE_BINDING_2D_ARRAY:
- ASSERT(mActiveSampler < mContext->getMaximumCombinedTextureImageUnits());
- *params = mSamplerTexture[TEXTURE_2D_ARRAY][mActiveSampler].id();
+ ASSERT(mActiveSampler < mContext->getCaps().maxCombinedTextureImageUnits);
+ *params = mSamplerTextures.at(GL_TEXTURE_2D_ARRAY)[mActiveSampler].id();
break;
case GL_UNIFORM_BUFFER_BINDING:
*params = mGenericUniformBuffer.id();
@@ -1412,4 +1429,27 @@ bool State::getIndexedInteger64v(GLenum target, GLuint index, GLint64 *data)
return true;
}
+bool State::hasMappedBuffer(GLenum target) const
+{
+ if (target == GL_ARRAY_BUFFER)
+ {
+ for (unsigned int attribIndex = 0; attribIndex < gl::MAX_VERTEX_ATTRIBS; attribIndex++)
+ {
+ const gl::VertexAttribute &vertexAttrib = getVertexAttribState(attribIndex);
+ gl::Buffer *boundBuffer = vertexAttrib.buffer.get();
+ if (vertexAttrib.enabled && boundBuffer && boundBuffer->isMapped())
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+ else
+ {
+ Buffer *buffer = getTargetBuffer(target);
+ return (buffer && buffer->isMapped());
+ }
+}
+
}