summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/angle/src/libGLESv2/State.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/angle/src/libGLESv2/State.cpp')
-rw-r--r--src/3rdparty/angle/src/libGLESv2/State.cpp125
1 files changed, 67 insertions, 58 deletions
diff --git a/src/3rdparty/angle/src/libGLESv2/State.cpp b/src/3rdparty/angle/src/libGLESv2/State.cpp
index 3c03b90e56..b5b62f5848 100644
--- a/src/3rdparty/angle/src/libGLESv2/State.cpp
+++ b/src/3rdparty/angle/src/libGLESv2/State.cpp
@@ -10,18 +10,20 @@
#include "libGLESv2/Context.h"
#include "libGLESv2/Caps.h"
-#include "libGLESv2/VertexArray.h"
-#include "libGLESv2/Query.h"
#include "libGLESv2/Framebuffer.h"
#include "libGLESv2/FramebufferAttachment.h"
-#include "libGLESv2/renderer/RenderTarget.h"
+#include "libGLESv2/Query.h"
+#include "libGLESv2/VertexArray.h"
#include "libGLESv2/formatutils.h"
+#include "libGLESv2/renderer/RenderTarget.h"
namespace gl
{
State::State()
{
+ mMaxDrawBuffers = 0;
+ mMaxCombinedTextureImageUnits = 0;
}
State::~State()
@@ -31,7 +33,8 @@ State::~State()
void State::initialize(const Caps& caps, GLuint clientVersion)
{
- mContext = NULL;
+ mMaxDrawBuffers = caps.maxDrawBuffers;
+ mMaxCombinedTextureImageUnits = caps.maxCombinedTextureImageUnits;
setClearColor(0.0f, 0.0f, 0.0f, 0.0f);
@@ -111,11 +114,15 @@ void State::initialize(const Caps& caps, GLuint clientVersion)
mActiveSampler = 0;
const GLfloat defaultFloatValues[] = { 0.0f, 0.0f, 0.0f, 1.0f };
- for (int attribIndex = 0; attribIndex < MAX_VERTEX_ATTRIBS; attribIndex++)
+ mVertexAttribCurrentValues.resize(caps.maxVertexAttributes);
+ for (size_t attribIndex = 0; attribIndex < mVertexAttribCurrentValues.size(); ++attribIndex)
{
mVertexAttribCurrentValues[attribIndex].setFloatValues(defaultFloatValues);
}
+ mUniformBuffers.resize(caps.maxCombinedUniformBlocks);
+ mTransformFeedbackBuffers.resize(caps.maxTransformFeedbackSeparateAttributes);
+
mSamplerTextures[GL_TEXTURE_2D].resize(caps.maxCombinedTextureImageUnits);
mSamplerTextures[GL_TEXTURE_CUBE_MAP].resize(caps.maxCombinedTextureImageUnits);
if (clientVersion >= 3)
@@ -153,12 +160,6 @@ void State::reset()
mSamplers[samplerIdx].set(NULL);
}
- const GLfloat defaultFloatValues[] = { 0.0f, 0.0f, 0.0f, 1.0f };
- for (int attribIndex = 0; attribIndex < MAX_VERTEX_ATTRIBS; attribIndex++)
- {
- mVertexAttribCurrentValues[attribIndex].setFloatValues(defaultFloatValues);
- }
-
mArrayBuffer.set(NULL);
mRenderbuffer.set(NULL);
@@ -170,15 +171,15 @@ void State::reset()
}
mGenericUniformBuffer.set(NULL);
- for (int i = 0; i < IMPLEMENTATION_MAX_COMBINED_SHADER_UNIFORM_BUFFERS; i++)
+ mGenericTransformFeedbackBuffer.set(NULL);
+ for (BufferVector::iterator bufItr = mUniformBuffers.begin(); bufItr != mUniformBuffers.end(); ++bufItr)
{
- mUniformBuffers[i].set(NULL);
+ bufItr->set(NULL);
}
- mGenericTransformFeedbackBuffer.set(NULL);
- for (int i = 0; i < IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_BUFFERS; i++)
+ for (BufferVector::iterator bufItr = mTransformFeedbackBuffers.begin(); bufItr != mTransformFeedbackBuffers.end(); ++bufItr)
{
- mTransformFeedbackBuffers[i].set(NULL);
+ bufItr->set(NULL);
}
mCopyReadBuffer.set(NULL);
@@ -485,7 +486,7 @@ void State::setSampleCoverageParams(GLclampf value, bool invert)
mSampleCoverageInvert = invert;
}
-void State::getSampleCoverageParams(GLclampf *value, bool *invert)
+void State::getSampleCoverageParams(GLclampf *value, bool *invert) const
{
ASSERT(value != NULL && invert != NULL);
@@ -612,14 +613,7 @@ void State::setSamplerTexture(GLenum type, Texture *texture)
Texture *State::getSamplerTexture(unsigned int sampler, GLenum type) const
{
- const BindingPointer<Texture>& binding = mSamplerTextures.at(type)[sampler];
-
- if (binding.id() == 0) // Special case: 0 refers to default textures held by Context
- {
- return NULL;
- }
-
- return binding.get();
+ return mSamplerTextures.at(type)[sampler].get();
}
GLuint State::getSamplerTextureId(unsigned int sampler, GLenum type) const
@@ -627,7 +621,7 @@ GLuint State::getSamplerTextureId(unsigned int sampler, GLenum type) const
return mSamplerTextures.at(type)[sampler].id();
}
-void State::detachTexture(GLuint texture)
+void State::detachTexture(const TextureMap &zeroTextures, GLuint texture)
{
// Textures have a detach method on State rather than a simple
// removeBinding, because the zero/null texture objects are managed
@@ -640,13 +634,15 @@ void State::detachTexture(GLuint texture)
for (TextureBindingMap::iterator bindingVec = mSamplerTextures.begin(); bindingVec != mSamplerTextures.end(); bindingVec++)
{
+ GLenum textureType = bindingVec->first;
TextureBindingVector &textureVector = bindingVec->second;
for (size_t textureIdx = 0; textureIdx < textureVector.size(); textureIdx++)
{
BindingPointer<Texture> &binding = textureVector[textureIdx];
if (binding.id() == texture)
{
- binding.set(NULL);
+ // Zero textures are the "default" textures instead of NULL
+ binding.set(zeroTextures.at(textureType).get());
}
}
}
@@ -667,6 +663,19 @@ void State::detachTexture(GLuint texture)
}
}
+void State::initializeZeroTextures(const TextureMap &zeroTextures)
+{
+ for (TextureMap::const_iterator i = zeroTextures.begin(); i != zeroTextures.end(); i++)
+ {
+ TextureBindingVector &samplerTextureArray = mSamplerTextures[i->first];
+
+ for (size_t textureUnit = 0; textureUnit < samplerTextureArray.size(); ++textureUnit)
+ {
+ samplerTextureArray[textureUnit].set(i->second.get());
+ }
+ }
+}
+
void State::setSamplerBinding(GLuint textureUnit, Sampler *sampler)
{
mSamplers[textureUnit].set(sampler);
@@ -947,14 +956,14 @@ void State::setIndexedUniformBufferBinding(GLuint index, Buffer *buffer, GLintpt
GLuint State::getIndexedUniformBufferId(GLuint index) const
{
- ASSERT(index < IMPLEMENTATION_MAX_COMBINED_SHADER_UNIFORM_BUFFERS);
+ ASSERT(static_cast<size_t>(index) < mUniformBuffers.size());
return mUniformBuffers[index].id();
}
Buffer *State::getIndexedUniformBuffer(GLuint index) const
{
- ASSERT(index < IMPLEMENTATION_MAX_COMBINED_SHADER_UNIFORM_BUFFERS);
+ ASSERT(static_cast<size_t>(index) < mUniformBuffers.size());
return mUniformBuffers[index].get();
}
@@ -971,25 +980,30 @@ void State::setIndexedTransformFeedbackBufferBinding(GLuint index, Buffer *buffe
GLuint State::getIndexedTransformFeedbackBufferId(GLuint index) const
{
- ASSERT(index < IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_BUFFERS);
+ ASSERT(static_cast<size_t>(index) < mTransformFeedbackBuffers.size());
return mTransformFeedbackBuffers[index].id();
}
Buffer *State::getIndexedTransformFeedbackBuffer(GLuint index) const
{
- ASSERT(index < IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_BUFFERS);
+ ASSERT(static_cast<size_t>(index) < mTransformFeedbackBuffers.size());
return mTransformFeedbackBuffers[index].get();
}
GLuint State::getIndexedTransformFeedbackBufferOffset(GLuint index) const
{
- ASSERT(index < IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_BUFFERS);
+ ASSERT(static_cast<size_t>(index) < mTransformFeedbackBuffers.size());
return mTransformFeedbackBuffers[index].getOffset();
}
+size_t State::getTransformFeedbackBufferIndexRange() const
+{
+ return mTransformFeedbackBuffers.size();
+}
+
void State::setCopyReadBufferBinding(Buffer *buffer)
{
mCopyReadBuffer.set(buffer);
@@ -1033,19 +1047,19 @@ void State::setEnableVertexAttribArray(unsigned int attribNum, bool enabled)
void State::setVertexAttribf(GLuint index, const GLfloat values[4])
{
- ASSERT(index < gl::MAX_VERTEX_ATTRIBS);
+ ASSERT(static_cast<size_t>(index) < mVertexAttribCurrentValues.size());
mVertexAttribCurrentValues[index].setFloatValues(values);
}
void State::setVertexAttribu(GLuint index, const GLuint values[4])
{
- ASSERT(index < gl::MAX_VERTEX_ATTRIBS);
+ ASSERT(static_cast<size_t>(index) < mVertexAttribCurrentValues.size());
mVertexAttribCurrentValues[index].setUnsignedIntValues(values);
}
void State::setVertexAttribi(GLuint index, const GLint values[4])
{
- ASSERT(index < gl::MAX_VERTEX_ATTRIBS);
+ ASSERT(static_cast<size_t>(index) < mVertexAttribCurrentValues.size());
mVertexAttribCurrentValues[index].setIntValues(values);
}
@@ -1062,15 +1076,10 @@ const VertexAttribute &State::getVertexAttribState(unsigned int attribNum) const
const VertexAttribCurrentValueData &State::getVertexAttribCurrentValue(unsigned int attribNum) const
{
- ASSERT(attribNum < MAX_VERTEX_ATTRIBS);
+ ASSERT(static_cast<size_t>(attribNum) < mVertexAttribCurrentValues.size());
return mVertexAttribCurrentValues[attribNum];
}
-const VertexAttribCurrentValueData *State::getVertexAttribCurrentValues() const
-{
- return mVertexAttribCurrentValues;
-}
-
const void *State::getVertexAttribPointer(unsigned int attribNum) const
{
return getVertexArray()->getVertexAttribute(attribNum).pointer;
@@ -1180,12 +1189,12 @@ void State::getFloatv(GLenum pname, GLfloat *params)
}
}
-void State::getIntegerv(GLenum pname, GLint *params)
+void State::getIntegerv(const gl::Data &data, GLenum pname, GLint *params)
{
if (pname >= GL_DRAW_BUFFER0_EXT && pname <= GL_DRAW_BUFFER15_EXT)
{
unsigned int colorAttachment = (pname - GL_DRAW_BUFFER0_EXT);
- ASSERT(colorAttachment < mContext->getCaps().maxDrawBuffers);
+ ASSERT(colorAttachment < mMaxDrawBuffers);
Framebuffer *framebuffer = mDrawFramebuffer;
*params = framebuffer->getDrawBufferState(colorAttachment);
return;
@@ -1238,12 +1247,12 @@ void State::getIntegerv(GLenum pname, GLint *params)
case GL_SAMPLES:
{
gl::Framebuffer *framebuffer = mDrawFramebuffer;
- if (framebuffer->completeness() == GL_FRAMEBUFFER_COMPLETE)
+ if (framebuffer->completeness(data) == GL_FRAMEBUFFER_COMPLETE)
{
switch (pname)
{
case GL_SAMPLE_BUFFERS:
- if (framebuffer->getSamples() != 0)
+ if (framebuffer->getSamples(data) != 0)
{
*params = 1;
}
@@ -1253,7 +1262,7 @@ void State::getIntegerv(GLenum pname, GLint *params)
}
break;
case GL_SAMPLES:
- *params = framebuffer->getSamples();
+ *params = framebuffer->getSamples(data);
break;
}
}
@@ -1332,19 +1341,19 @@ void State::getIntegerv(GLenum pname, GLint *params)
}
break;
case GL_TEXTURE_BINDING_2D:
- ASSERT(mActiveSampler < mContext->getCaps().maxCombinedTextureImageUnits);
+ ASSERT(mActiveSampler < mMaxCombinedTextureImageUnits);
*params = mSamplerTextures.at(GL_TEXTURE_2D)[mActiveSampler].id();
break;
case GL_TEXTURE_BINDING_CUBE_MAP:
- ASSERT(mActiveSampler < mContext->getCaps().maxCombinedTextureImageUnits);
+ ASSERT(mActiveSampler < mMaxCombinedTextureImageUnits);
*params = mSamplerTextures.at(GL_TEXTURE_CUBE_MAP)[mActiveSampler].id();
break;
case GL_TEXTURE_BINDING_3D:
- ASSERT(mActiveSampler <mContext->getCaps().maxCombinedTextureImageUnits);
+ ASSERT(mActiveSampler < mMaxCombinedTextureImageUnits);
*params = mSamplerTextures.at(GL_TEXTURE_3D)[mActiveSampler].id();
break;
case GL_TEXTURE_BINDING_2D_ARRAY:
- ASSERT(mActiveSampler < mContext->getCaps().maxCombinedTextureImageUnits);
+ ASSERT(mActiveSampler < mMaxCombinedTextureImageUnits);
*params = mSamplerTextures.at(GL_TEXTURE_2D_ARRAY)[mActiveSampler].id();
break;
case GL_UNIFORM_BUFFER_BINDING:
@@ -1376,13 +1385,13 @@ bool State::getIndexedIntegerv(GLenum target, GLuint index, GLint *data)
switch (target)
{
case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
- if (index < IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_BUFFERS)
+ if (static_cast<size_t>(index) < mTransformFeedbackBuffers.size())
{
*data = mTransformFeedbackBuffers[index].id();
}
break;
case GL_UNIFORM_BUFFER_BINDING:
- if (index < IMPLEMENTATION_MAX_COMBINED_SHADER_UNIFORM_BUFFERS)
+ if (static_cast<size_t>(index) < mUniformBuffers.size())
{
*data = mUniformBuffers[index].id();
}
@@ -1399,25 +1408,25 @@ bool State::getIndexedInteger64v(GLenum target, GLuint index, GLint64 *data)
switch (target)
{
case GL_TRANSFORM_FEEDBACK_BUFFER_START:
- if (index < IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_BUFFERS)
+ if (static_cast<size_t>(index) < mTransformFeedbackBuffers.size())
{
*data = mTransformFeedbackBuffers[index].getOffset();
}
break;
case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE:
- if (index < IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_BUFFERS)
+ if (static_cast<size_t>(index) < mTransformFeedbackBuffers.size())
{
*data = mTransformFeedbackBuffers[index].getSize();
}
break;
case GL_UNIFORM_BUFFER_START:
- if (index < IMPLEMENTATION_MAX_COMBINED_SHADER_UNIFORM_BUFFERS)
+ if (static_cast<size_t>(index) < mUniformBuffers.size())
{
*data = mUniformBuffers[index].getOffset();
}
break;
case GL_UNIFORM_BUFFER_SIZE:
- if (index < IMPLEMENTATION_MAX_COMBINED_SHADER_UNIFORM_BUFFERS)
+ if (static_cast<size_t>(index) < mUniformBuffers.size())
{
*data = mUniformBuffers[index].getSize();
}
@@ -1433,9 +1442,9 @@ bool State::hasMappedBuffer(GLenum target) const
{
if (target == GL_ARRAY_BUFFER)
{
- for (unsigned int attribIndex = 0; attribIndex < gl::MAX_VERTEX_ATTRIBS; attribIndex++)
+ for (size_t attribIndex = 0; attribIndex < mVertexAttribCurrentValues.size(); attribIndex++)
{
- const gl::VertexAttribute &vertexAttrib = getVertexAttribState(attribIndex);
+ const gl::VertexAttribute &vertexAttrib = getVertexAttribState(static_cast<unsigned int>(attribIndex));
gl::Buffer *boundBuffer = vertexAttrib.buffer.get();
if (vertexAttrib.enabled && boundBuffer && boundBuffer->isMapped())
{