summaryrefslogtreecommitdiffstats
path: root/gfx/angle/src/libANGLE/Context.cpp
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2018-07-11 18:11:13 +0200
committerwolfbeast <mcwerewolf@gmail.com>2018-07-11 18:11:13 +0200
commit4f2ecd53a9daaf88bb7d075745eefb6e2e4741e0 (patch)
treef000dd831240707a03b8c806db292c2a15cde3ce /gfx/angle/src/libANGLE/Context.cpp
parent3b7ffb477eec078c7036c92c6a51bb5de6de4f28 (diff)
downloadUXP-4f2ecd53a9daaf88bb7d075745eefb6e2e4741e0.tar
UXP-4f2ecd53a9daaf88bb7d075745eefb6e2e4741e0.tar.gz
UXP-4f2ecd53a9daaf88bb7d075745eefb6e2e4741e0.tar.lz
UXP-4f2ecd53a9daaf88bb7d075745eefb6e2e4741e0.tar.xz
UXP-4f2ecd53a9daaf88bb7d075745eefb6e2e4741e0.zip
Roll back to ANGLE/2845
Diffstat (limited to 'gfx/angle/src/libANGLE/Context.cpp')
-rwxr-xr-xgfx/angle/src/libANGLE/Context.cpp470
1 files changed, 155 insertions, 315 deletions
diff --git a/gfx/angle/src/libANGLE/Context.cpp b/gfx/angle/src/libANGLE/Context.cpp
index d74f33057..c79f3b7b7 100755
--- a/gfx/angle/src/libANGLE/Context.cpp
+++ b/gfx/angle/src/libANGLE/Context.cpp
@@ -35,11 +35,9 @@
#include "libANGLE/VertexArray.h"
#include "libANGLE/formatutils.h"
#include "libANGLE/validationES.h"
-#include "libANGLE/Workarounds.h"
#include "libANGLE/renderer/ContextImpl.h"
#include "libANGLE/renderer/EGLImplFactory.h"
#include "libANGLE/queryconversions.h"
-#include "libANGLE/queryutils.h"
namespace
{
@@ -97,21 +95,22 @@ std::vector<gl::Path *> GatherPaths(gl::ResourceManager &resourceManager,
}
template <typename T>
-gl::Error GetQueryObjectParameter(gl::Query *query, GLenum pname, T *params)
+gl::Error GetQueryObjectParameter(gl::Context *context, GLuint id, GLenum pname, T *params)
{
- ASSERT(query != nullptr);
+ gl::Query *queryObject = context->getQuery(id, false, GL_NONE);
+ ASSERT(queryObject != nullptr);
switch (pname)
{
case GL_QUERY_RESULT_EXT:
- return query->getResult(params);
+ return queryObject->getResult(params);
case GL_QUERY_RESULT_AVAILABLE_EXT:
{
bool available;
- gl::Error error = query->isResultAvailable(&available);
+ gl::Error error = queryObject->isResultAvailable(&available);
if (!error.isError())
{
- *params = gl::ConvertFromGLboolean<T>(available);
+ *params = static_cast<T>(available ? GL_TRUE : GL_FALSE);
}
return error;
}
@@ -149,11 +148,6 @@ EGLint GetClientMinorVersion(const egl::AttributeMap &attribs)
return static_cast<EGLint>(attribs.get(EGL_CONTEXT_MINOR_VERSION, 0));
}
-gl::Version GetClientVersion(const egl::AttributeMap &attribs)
-{
- return gl::Version(GetClientMajorVersion(attribs), GetClientMinorVersion(attribs));
-}
-
GLenum GetResetStrategy(const egl::AttributeMap &attribs)
{
EGLAttrib attrib = attribs.get(EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT,
@@ -172,15 +166,12 @@ GLenum GetResetStrategy(const egl::AttributeMap &attribs)
bool GetRobustAccess(const egl::AttributeMap &attribs)
{
- return (attribs.get(EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT, EGL_FALSE) == EGL_TRUE) ||
- ((attribs.get(EGL_CONTEXT_FLAGS_KHR, 0) & EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR) !=
- 0);
+ return (attribs.get(EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT, EGL_FALSE) == EGL_TRUE);
}
bool GetDebug(const egl::AttributeMap &attribs)
{
- return (attribs.get(EGL_CONTEXT_OPENGL_DEBUG, EGL_FALSE) == EGL_TRUE) ||
- ((attribs.get(EGL_CONTEXT_FLAGS_KHR, 0) & EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR) != 0);
+ return (attribs.get(EGL_CONTEXT_OPENGL_DEBUG, EGL_FALSE) == EGL_TRUE);
}
bool GetNoError(const egl::AttributeMap &attribs)
@@ -188,16 +179,6 @@ bool GetNoError(const egl::AttributeMap &attribs)
return (attribs.get(EGL_CONTEXT_OPENGL_NO_ERROR_KHR, EGL_FALSE) == EGL_TRUE);
}
-bool GetWebGLContext(const egl::AttributeMap &attribs)
-{
- return (attribs.get(EGL_CONTEXT_WEBGL_COMPATIBILITY_ANGLE, EGL_FALSE) == EGL_TRUE);
-}
-
-bool GetBindGeneratesResource(const egl::AttributeMap &attribs)
-{
- return (attribs.get(EGL_CONTEXT_BIND_GENERATES_RESOURCE_CHROMIUM, EGL_TRUE) == EGL_TRUE);
-}
-
std::string GetObjectLabelFromPointer(GLsizei length, const GLchar *label)
{
std::string labelName;
@@ -238,38 +219,34 @@ Context::Context(rx::EGLImplFactory *implFactory,
const Context *shareContext,
const egl::AttributeMap &attribs)
- : ValidationContext(GetClientVersion(attribs),
+ : ValidationContext(GetClientMajorVersion(attribs),
+ GetClientMinorVersion(attribs),
&mGLState,
mCaps,
mTextureCaps,
mExtensions,
nullptr,
mLimitations,
- mFramebufferMap,
GetNoError(attribs)),
mImplementation(implFactory->createContext(mState)),
mCompiler(nullptr),
+ mClientMajorVersion(GetClientMajorVersion(attribs)),
+ mClientMinorVersion(GetClientMinorVersion(attribs)),
mConfig(config),
mClientType(EGL_OPENGL_ES_API),
mHasBeenCurrent(false),
mContextLost(false),
mResetStatus(GL_NO_ERROR),
- mContextLostForced(false),
mResetStrategy(GetResetStrategy(attribs)),
mRobustAccess(GetRobustAccess(attribs)),
mCurrentSurface(nullptr),
mResourceManager(nullptr)
{
- if (mRobustAccess)
- {
- UNIMPLEMENTED();
- }
+ ASSERT(!mRobustAccess); // Unimplemented
- initCaps(GetWebGLContext(attribs));
- initWorkarounds();
+ initCaps();
- mGLState.initialize(mCaps, mExtensions, getClientVersion(), GetDebug(attribs),
- GetBindGeneratesResource(attribs));
+ mGLState.initialize(mCaps, mExtensions, mClientMajorVersion, GetDebug(attribs));
mFenceNVHandleAllocator.setBaseHandle(0);
@@ -297,7 +274,7 @@ Context::Context(rx::EGLImplFactory *implFactory,
Texture *zeroTextureCube = new Texture(mImplementation.get(), 0, GL_TEXTURE_CUBE_MAP);
mZeroTextures[GL_TEXTURE_CUBE_MAP].set(zeroTextureCube);
- if (getClientVersion() >= Version(3, 0))
+ if (mClientMajorVersion >= 3)
{
// TODO: These could also be enabled via extension
Texture *zeroTexture3D = new Texture(mImplementation.get(), 0, GL_TEXTURE_3D);
@@ -320,7 +297,7 @@ Context::Context(rx::EGLImplFactory *implFactory,
bindArrayBuffer(0);
bindElementArrayBuffer(0);
- bindRenderbuffer(GL_RENDERBUFFER, 0);
+ bindRenderbuffer(0);
bindGenericUniformBuffer(0);
for (unsigned int i = 0; i < mCaps.maxCombinedUniformBlocks; i++)
@@ -333,7 +310,7 @@ Context::Context(rx::EGLImplFactory *implFactory,
bindPixelPackBuffer(0);
bindPixelUnpackBuffer(0);
- if (getClientVersion() >= Version(3, 0))
+ if (mClientMajorVersion >= 3)
{
// [OpenGL ES 3.0.2] section 2.14.1 pg 85:
// In the initial state, a default transform feedback object is bound and treated as
@@ -379,7 +356,6 @@ Context::Context(rx::EGLImplFactory *implFactory,
mBlitDirtyBits.set(State::DIRTY_BIT_SCISSOR_TEST_ENABLED);
mBlitDirtyBits.set(State::DIRTY_BIT_SCISSOR);
- mBlitDirtyBits.set(State::DIRTY_BIT_FRAMEBUFFER_SRGB);
mBlitDirtyObjects.set(State::DIRTY_OBJECT_READ_FRAMEBUFFER);
mBlitDirtyObjects.set(State::DIRTY_OBJECT_DRAW_FRAMEBUFFER);
@@ -830,6 +806,16 @@ Buffer *Context::getBuffer(GLuint handle) const
return mResourceManager->getBuffer(handle);
}
+Shader *Context::getShader(GLuint handle) const
+{
+ return mResourceManager->getShader(handle);
+}
+
+Program *Context::getProgram(GLuint handle) const
+{
+ return mResourceManager->getProgram(handle);
+}
+
Texture *Context::getTexture(GLuint handle) const
{
return mResourceManager->getTexture(handle);
@@ -986,6 +972,13 @@ void Context::bindDrawFramebuffer(GLuint framebufferHandle)
mGLState.setDrawFramebufferBinding(framebuffer);
}
+void Context::bindRenderbuffer(GLuint renderbufferHandle)
+{
+ Renderbuffer *renderbuffer =
+ mResourceManager->checkRenderbufferAllocation(mImplementation.get(), renderbufferHandle);
+ mGLState.setRenderbufferBinding(renderbuffer);
+}
+
void Context::bindVertexArray(GLuint vertexArrayHandle)
{
VertexArray *vertexArray = checkVertexArrayAllocation(vertexArrayHandle);
@@ -1135,24 +1128,24 @@ void Context::getQueryiv(GLenum target, GLenum pname, GLint *params)
}
}
-void Context::getQueryObjectiv(GLuint id, GLenum pname, GLint *params)
+Error Context::getQueryObjectiv(GLuint id, GLenum pname, GLint *params)
{
- handleError(GetQueryObjectParameter(getQuery(id), pname, params));
+ return GetQueryObjectParameter(this, id, pname, params);
}
-void Context::getQueryObjectuiv(GLuint id, GLenum pname, GLuint *params)
+Error Context::getQueryObjectuiv(GLuint id, GLenum pname, GLuint *params)
{
- handleError(GetQueryObjectParameter(getQuery(id), pname, params));
+ return GetQueryObjectParameter(this, id, pname, params);
}
-void Context::getQueryObjecti64v(GLuint id, GLenum pname, GLint64 *params)
+Error Context::getQueryObjecti64v(GLuint id, GLenum pname, GLint64 *params)
{
- handleError(GetQueryObjectParameter(getQuery(id), pname, params));
+ return GetQueryObjectParameter(this, id, pname, params);
}
-void Context::getQueryObjectui64v(GLuint id, GLenum pname, GLuint64 *params)
+Error Context::getQueryObjectui64v(GLuint id, GLenum pname, GLuint64 *params)
{
- handleError(GetQueryObjectParameter(getQuery(id), pname, params));
+ return GetQueryObjectParameter(this, id, pname, params);
}
Framebuffer *Context::getFramebuffer(unsigned int handle) const
@@ -1301,10 +1294,10 @@ void Context::getIntegerv(GLenum pname, GLint *params)
case GL_MIN_PROGRAM_TEXEL_OFFSET: *params = mCaps.minProgramTexelOffset; break;
case GL_MAX_PROGRAM_TEXEL_OFFSET: *params = mCaps.maxProgramTexelOffset; break;
case GL_MAJOR_VERSION:
- *params = getClientVersion().major;
+ *params = mClientMajorVersion;
break;
case GL_MINOR_VERSION:
- *params = getClientVersion().minor;
+ *params = mClientMinorVersion;
break;
case GL_MAX_ELEMENTS_INDICES: *params = mCaps.maxElementsIndices; break;
case GL_MAX_ELEMENTS_VERTICES: *params = mCaps.maxElementsVertices; break;
@@ -1539,6 +1532,7 @@ void Context::getIntegeri_v(GLenum target, GLuint index, GLint *data)
GLenum nativeType;
unsigned int numParams;
bool queryStatus = getIndexedQueryParameterInfo(target, &nativeType, &numParams);
+ UNUSED_ASSERTION_VARIABLE(queryStatus);
ASSERT(queryStatus);
if (nativeType == GL_INT)
@@ -1571,6 +1565,7 @@ void Context::getInteger64i_v(GLenum target, GLuint index, GLint64 *data)
GLenum nativeType;
unsigned int numParams;
bool queryStatus = getIndexedQueryParameterInfo(target, &nativeType, &numParams);
+ UNUSED_ASSERTION_VARIABLE(queryStatus);
ASSERT(queryStatus);
if (nativeType == GL_INT_64_ANGLEX)
@@ -1591,6 +1586,7 @@ void Context::getBooleani_v(GLenum target, GLuint index, GLboolean *data)
GLenum nativeType;
unsigned int numParams;
bool queryStatus = getIndexedQueryParameterInfo(target, &nativeType, &numParams);
+ UNUSED_ASSERTION_VARIABLE(queryStatus);
ASSERT(queryStatus);
if (nativeType == GL_BOOL)
@@ -1919,12 +1915,7 @@ void Context::handleError(const Error &error)
{
if (error.isError())
{
- GLenum code = error.getCode();
- mErrors.insert(code);
- if (code == GL_OUT_OF_MEMORY && getWorkarounds().loseContextOnOutOfMemory)
- {
- markContextLost();
- }
+ mErrors.insert(error.getCode());
if (!error.getMessage().empty())
{
@@ -1955,10 +1946,7 @@ GLenum Context::getError()
void Context::markContextLost()
{
if (mResetStrategy == GL_LOSE_CONTEXT_ON_RESET_EXT)
- {
mResetStatus = GL_UNKNOWN_CONTEXT_RESET_EXT;
- mContextLostForced = true;
- }
mContextLost = true;
}
@@ -1997,11 +1985,8 @@ GLenum Context::getResetStatus()
mContextLost = true;
}
}
- else if (!mContextLostForced && mResetStatus != GL_NO_ERROR)
+ else if (mResetStatus != GL_NO_ERROR)
{
- // If markContextLost was used to mark the context lost then
- // assume that is not recoverable, and continue to report the
- // lost reset status for the lifetime of this context.
mResetStatus = mImplementation->getResetStatus();
}
@@ -2092,13 +2077,11 @@ Framebuffer *Context::checkFramebufferAllocation(GLuint framebuffer)
bool Context::isVertexArrayGenerated(GLuint vertexArray)
{
- ASSERT(mVertexArrayMap.find(0) != mVertexArrayMap.end());
return mVertexArrayMap.find(vertexArray) != mVertexArrayMap.end();
}
bool Context::isTransformFeedbackGenerated(GLuint transformFeedback)
{
- ASSERT(mTransformFeedbackMap.find(0) != mTransformFeedbackMap.end());
return mTransformFeedbackMap.find(transformFeedback) != mTransformFeedbackMap.end();
}
@@ -2192,44 +2175,102 @@ void Context::setVertexAttribDivisor(GLuint index, GLuint divisor)
void Context::samplerParameteri(GLuint sampler, GLenum pname, GLint param)
{
- Sampler *samplerObject =
- mResourceManager->checkSamplerAllocation(mImplementation.get(), sampler);
- SetSamplerParameteri(samplerObject, pname, param);
-}
+ mResourceManager->checkSamplerAllocation(mImplementation.get(), sampler);
-void Context::samplerParameteriv(GLuint sampler, GLenum pname, const GLint *param)
-{
- Sampler *samplerObject =
- mResourceManager->checkSamplerAllocation(mImplementation.get(), sampler);
- SetSamplerParameteriv(samplerObject, pname, param);
+ Sampler *samplerObject = getSampler(sampler);
+ ASSERT(samplerObject);
+
+ // clang-format off
+ switch (pname)
+ {
+ case GL_TEXTURE_MIN_FILTER: samplerObject->setMinFilter(static_cast<GLenum>(param)); break;
+ case GL_TEXTURE_MAG_FILTER: samplerObject->setMagFilter(static_cast<GLenum>(param)); break;
+ case GL_TEXTURE_WRAP_S: samplerObject->setWrapS(static_cast<GLenum>(param)); break;
+ case GL_TEXTURE_WRAP_T: samplerObject->setWrapT(static_cast<GLenum>(param)); break;
+ case GL_TEXTURE_WRAP_R: samplerObject->setWrapR(static_cast<GLenum>(param)); break;
+ case GL_TEXTURE_MAX_ANISOTROPY_EXT: samplerObject->setMaxAnisotropy(std::min(static_cast<GLfloat>(param), getExtensions().maxTextureAnisotropy)); break;
+ case GL_TEXTURE_MIN_LOD: samplerObject->setMinLod(static_cast<GLfloat>(param)); break;
+ case GL_TEXTURE_MAX_LOD: samplerObject->setMaxLod(static_cast<GLfloat>(param)); break;
+ case GL_TEXTURE_COMPARE_MODE: samplerObject->setCompareMode(static_cast<GLenum>(param)); break;
+ case GL_TEXTURE_COMPARE_FUNC: samplerObject->setCompareFunc(static_cast<GLenum>(param)); break;
+ default: UNREACHABLE(); break;
+ }
+ // clang-format on
}
void Context::samplerParameterf(GLuint sampler, GLenum pname, GLfloat param)
{
- Sampler *samplerObject =
- mResourceManager->checkSamplerAllocation(mImplementation.get(), sampler);
- SetSamplerParameterf(samplerObject, pname, param);
-}
+ mResourceManager->checkSamplerAllocation(mImplementation.get(), sampler);
-void Context::samplerParameterfv(GLuint sampler, GLenum pname, const GLfloat *param)
-{
- Sampler *samplerObject =
- mResourceManager->checkSamplerAllocation(mImplementation.get(), sampler);
- SetSamplerParameterfv(samplerObject, pname, param);
+ Sampler *samplerObject = getSampler(sampler);
+ ASSERT(samplerObject);
+
+ // clang-format off
+ switch (pname)
+ {
+ case GL_TEXTURE_MIN_FILTER: samplerObject->setMinFilter(uiround<GLenum>(param)); break;
+ case GL_TEXTURE_MAG_FILTER: samplerObject->setMagFilter(uiround<GLenum>(param)); break;
+ case GL_TEXTURE_WRAP_S: samplerObject->setWrapS(uiround<GLenum>(param)); break;
+ case GL_TEXTURE_WRAP_T: samplerObject->setWrapT(uiround<GLenum>(param)); break;
+ case GL_TEXTURE_WRAP_R: samplerObject->setWrapR(uiround<GLenum>(param)); break;
+ case GL_TEXTURE_MAX_ANISOTROPY_EXT: samplerObject->setMaxAnisotropy(std::min(param, getExtensions().maxTextureAnisotropy)); break;
+ case GL_TEXTURE_MIN_LOD: samplerObject->setMinLod(param); break;
+ case GL_TEXTURE_MAX_LOD: samplerObject->setMaxLod(param); break;
+ case GL_TEXTURE_COMPARE_MODE: samplerObject->setCompareMode(uiround<GLenum>(param)); break;
+ case GL_TEXTURE_COMPARE_FUNC: samplerObject->setCompareFunc(uiround<GLenum>(param)); break;
+ default: UNREACHABLE(); break;
+ }
+ // clang-format on
}
-void Context::getSamplerParameteriv(GLuint sampler, GLenum pname, GLint *params)
+GLint Context::getSamplerParameteri(GLuint sampler, GLenum pname)
{
- const Sampler *samplerObject =
- mResourceManager->checkSamplerAllocation(mImplementation.get(), sampler);
- QuerySamplerParameteriv(samplerObject, pname, params);
+ mResourceManager->checkSamplerAllocation(mImplementation.get(), sampler);
+
+ Sampler *samplerObject = getSampler(sampler);
+ ASSERT(samplerObject);
+
+ // clang-format off
+ switch (pname)
+ {
+ case GL_TEXTURE_MIN_FILTER: return static_cast<GLint>(samplerObject->getMinFilter());
+ case GL_TEXTURE_MAG_FILTER: return static_cast<GLint>(samplerObject->getMagFilter());
+ case GL_TEXTURE_WRAP_S: return static_cast<GLint>(samplerObject->getWrapS());
+ case GL_TEXTURE_WRAP_T: return static_cast<GLint>(samplerObject->getWrapT());
+ case GL_TEXTURE_WRAP_R: return static_cast<GLint>(samplerObject->getWrapR());
+ case GL_TEXTURE_MAX_ANISOTROPY_EXT: return static_cast<GLint>(samplerObject->getMaxAnisotropy());
+ case GL_TEXTURE_MIN_LOD: return iround<GLint>(samplerObject->getMinLod());
+ case GL_TEXTURE_MAX_LOD: return iround<GLint>(samplerObject->getMaxLod());
+ case GL_TEXTURE_COMPARE_MODE: return static_cast<GLint>(samplerObject->getCompareMode());
+ case GL_TEXTURE_COMPARE_FUNC: return static_cast<GLint>(samplerObject->getCompareFunc());
+ default: UNREACHABLE(); return 0;
+ }
+ // clang-format on
}
-void Context::getSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat *params)
+GLfloat Context::getSamplerParameterf(GLuint sampler, GLenum pname)
{
- const Sampler *samplerObject =
- mResourceManager->checkSamplerAllocation(mImplementation.get(), sampler);
- QuerySamplerParameterfv(samplerObject, pname, params);
+ mResourceManager->checkSamplerAllocation(mImplementation.get(), sampler);
+
+ Sampler *samplerObject = getSampler(sampler);
+ ASSERT(samplerObject);
+
+ // clang-format off
+ switch (pname)
+ {
+ case GL_TEXTURE_MIN_FILTER: return static_cast<GLfloat>(samplerObject->getMinFilter());
+ case GL_TEXTURE_MAG_FILTER: return static_cast<GLfloat>(samplerObject->getMagFilter());
+ case GL_TEXTURE_WRAP_S: return static_cast<GLfloat>(samplerObject->getWrapS());
+ case GL_TEXTURE_WRAP_T: return static_cast<GLfloat>(samplerObject->getWrapT());
+ case GL_TEXTURE_WRAP_R: return static_cast<GLfloat>(samplerObject->getWrapR());
+ case GL_TEXTURE_MAX_ANISOTROPY_EXT: return samplerObject->getMaxAnisotropy();
+ case GL_TEXTURE_MIN_LOD: return samplerObject->getMinLod();
+ case GL_TEXTURE_MAX_LOD: return samplerObject->getMaxLod();
+ case GL_TEXTURE_COMPARE_MODE: return static_cast<GLfloat>(samplerObject->getCompareMode());
+ case GL_TEXTURE_COMPARE_FUNC: return static_cast<GLfloat>(samplerObject->getCompareFunc());
+ default: UNREACHABLE(); return 0;
+ }
+ // clang-format on
}
void Context::programParameteri(GLuint program, GLenum pname, GLint value)
@@ -2251,30 +2292,26 @@ void Context::initRendererString()
mRendererString = MakeStaticString(rendererString.str());
}
-const char *Context::getRendererString() const
+const std::string &Context::getRendererString() const
{
return mRendererString;
}
void Context::initExtensionStrings()
{
- for (const auto &extensionString : mExtensions.getStrings())
- {
- mExtensionStrings.push_back(MakeStaticString(extensionString));
- }
+ mExtensionStrings = mExtensions.getStrings();
std::ostringstream combinedStringStream;
- std::copy(mExtensionStrings.begin(), mExtensionStrings.end(),
- std::ostream_iterator<const char *>(combinedStringStream, " "));
- mExtensionString = MakeStaticString(combinedStringStream.str());
+ std::copy(mExtensionStrings.begin(), mExtensionStrings.end(), std::ostream_iterator<std::string>(combinedStringStream, " "));
+ mExtensionString = combinedStringStream.str();
}
-const char *Context::getExtensionString() const
+const std::string &Context::getExtensionString() const
{
return mExtensionString;
}
-const char *Context::getExtensionString(size_t idx) const
+const std::string &Context::getExtensionString(size_t idx) const
{
return mExtensionStrings[idx];
}
@@ -2305,7 +2342,7 @@ bool Context::hasActiveTransformFeedback(GLuint program) const
return false;
}
-void Context::initCaps(bool webGLContext)
+void Context::initCaps()
{
mCaps = mImplementation->getNativeCaps();
@@ -2313,7 +2350,7 @@ void Context::initCaps(bool webGLContext)
mLimitations = mImplementation->getNativeLimitations();
- if (getClientVersion() < Version(3, 0))
+ if (mClientMajorVersion < 3)
{
// Disable ES3+ extensions
mExtensions.colorBufferFloat = false;
@@ -2321,7 +2358,7 @@ void Context::initCaps(bool webGLContext)
mExtensions.textureNorm16 = false;
}
- if (getClientVersion() > Version(2, 0))
+ if (mClientMajorVersion > 2)
{
// FIXME(geofflang): Don't support EXT_sRGB in non-ES2 contexts
//mExtensions.sRGB = false;
@@ -2330,7 +2367,6 @@ void Context::initCaps(bool webGLContext)
// Some extensions are always available because they are implemented in the GL layer.
mExtensions.bindUniformLocation = true;
mExtensions.vertexArrayObject = true;
- mExtensions.bindGeneratesResource = true;
// Enable the no error extension if the context was created with the flag.
mExtensions.noError = mSkipValidation;
@@ -2342,9 +2378,6 @@ void Context::initCaps(bool webGLContext)
mExtensions.maxDebugGroupStackDepth = 1024;
mExtensions.maxLabelLength = 1024;
- // Explicitly enable GL_ANGLE_robust_client_memory
- mExtensions.robustClientMemory = true;
-
// Apply implementation limits
mCaps.maxVertexAttributes = std::min<GLuint>(mCaps.maxVertexAttributes, MAX_VERTEX_ATTRIBS);
mCaps.maxVertexUniformBlocks = std::min<GLuint>(mCaps.maxVertexUniformBlocks, IMPLEMENTATION_MAX_VERTEX_SHADER_UNIFORM_BUFFERS);
@@ -2352,25 +2385,7 @@ void Context::initCaps(bool webGLContext)
mCaps.maxFragmentInputComponents = std::min<GLuint>(mCaps.maxFragmentInputComponents, IMPLEMENTATION_MAX_VARYING_VECTORS * 4);
- // WebGL compatibility
- mExtensions.webglCompatibility = webGLContext;
- for (const auto &extensionInfo : GetExtensionInfoMap())
- {
- // If this context is for WebGL, disable all enableable extensions
- if (webGLContext && extensionInfo.second.Enableable)
- {
- mExtensions.*(extensionInfo.second.ExtensionsMember) = false;
- }
- }
-
- // Generate texture caps
- updateCaps();
-}
-
-void Context::updateCaps()
-{
mCaps.compressedTextureFormats.clear();
- mTextureCaps.clear();
const TextureCapsMap &rendererFormats = mImplementation->getNativeTextureCaps();
for (TextureCapsMap::const_iterator i = rendererFormats.begin(); i != rendererFormats.end(); i++)
@@ -2384,11 +2399,11 @@ void Context::updateCaps()
// Caps are AND'd with the renderer caps because some core formats are still unsupported in
// ES3.
formatCaps.texturable =
- formatCaps.texturable && formatInfo.textureSupport(getClientVersion(), mExtensions);
+ formatCaps.texturable && formatInfo.textureSupport(mClientMajorVersion, mExtensions);
formatCaps.renderable =
- formatCaps.renderable && formatInfo.renderSupport(getClientVersion(), mExtensions);
+ formatCaps.renderable && formatInfo.renderSupport(mClientMajorVersion, mExtensions);
formatCaps.filterable =
- formatCaps.filterable && formatInfo.filterSupport(getClientVersion(), mExtensions);
+ formatCaps.filterable && formatInfo.filterSupport(mClientMajorVersion, mExtensions);
// OpenGL ES does not support multisampling with integer formats
if (!formatInfo.renderSupport || formatInfo.componentType == GL_INT || formatInfo.componentType == GL_UNSIGNED_INT)
@@ -2405,13 +2420,6 @@ void Context::updateCaps()
}
}
-void Context::initWorkarounds()
-{
- // Lose the context upon out of memory error if the application is
- // expecting to watch for those events.
- mWorkarounds.loseContextOnOutOfMemory = (mResetStrategy == GL_LOSE_CONTEXT_ON_RESET_EXT);
-}
-
void Context::syncRendererState()
{
const State::DirtyBits &dirtyBits = mGLState.getDirtyBits();
@@ -2504,11 +2512,6 @@ void Context::readPixels(GLint x,
GLenum type,
GLvoid *pixels)
{
- if (width == 0 || height == 0)
- {
- return;
- }
-
syncStateForReadPixels();
Framebuffer *framebufferObject = mGLState.getReadFramebuffer();
@@ -2547,11 +2550,6 @@ void Context::copyTexSubImage2D(GLenum target,
GLsizei width,
GLsizei height)
{
- if (width == 0 || height == 0)
- {
- return;
- }
-
// Only sync the read FBO
mGLState.syncDirtyObject(GL_READ_FRAMEBUFFER);
@@ -2574,11 +2572,6 @@ void Context::copyTexSubImage3D(GLenum target,
GLsizei width,
GLsizei height)
{
- if (width == 0 || height == 0)
- {
- return;
- }
-
// Only sync the read FBO
mGLState.syncDirtyObject(GL_READ_FRAMEBUFFER);
@@ -2931,32 +2924,6 @@ void Context::generateMipmap(GLenum target)
handleError(texture->generateMipmap());
}
-GLboolean Context::enableExtension(const char *name)
-{
- const ExtensionInfoMap &extensionInfos = GetExtensionInfoMap();
- ASSERT(extensionInfos.find(name) != extensionInfos.end());
- const auto &extension = extensionInfos.at(name);
- ASSERT(extension.Enableable);
-
- if (mExtensions.*(extension.ExtensionsMember))
- {
- // Extension already enabled
- return GL_TRUE;
- }
-
- const auto &nativeExtensions = mImplementation->getNativeExtensions();
- if (!(nativeExtensions.*(extension.ExtensionsMember)))
- {
- // Underlying implementation does not support this valid extension
- return GL_FALSE;
- }
-
- mExtensions.*(extension.ExtensionsMember) = true;
- updateCaps();
- initExtensionStrings();
- return GL_TRUE;
-}
-
void Context::copyTextureCHROMIUM(GLuint sourceId,
GLuint destId,
GLint internalFormat,
@@ -3003,21 +2970,19 @@ void Context::copySubTextureCHROMIUM(GLuint sourceId,
unpackUnmultiplyAlpha == GL_TRUE, sourceTexture));
}
-void Context::compressedCopyTextureCHROMIUM(GLuint sourceId, GLuint destId)
-{
- syncStateForTexImage();
-
- gl::Texture *sourceTexture = getTexture(sourceId);
- gl::Texture *destTexture = getTexture(destId);
- handleError(destTexture->copyCompressedTexture(sourceTexture));
-}
-
-void Context::getBufferPointerv(GLenum target, GLenum pname, void **params)
+void Context::getBufferPointerv(GLenum target, GLenum /*pname*/, void **params)
{
Buffer *buffer = mGLState.getTargetBuffer(target);
ASSERT(buffer);
- QueryBufferPointerv(buffer, pname, params);
+ if (!buffer->isMapped())
+ {
+ *params = nullptr;
+ }
+ else
+ {
+ *params = buffer->getMapPointer();
+ }
}
GLvoid *Context::mapBuffer(GLenum target, GLenum access)
@@ -3104,21 +3069,11 @@ void Context::blendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf a
mGLState.setBlendColor(clamp01(red), clamp01(green), clamp01(blue), clamp01(alpha));
}
-void Context::blendEquation(GLenum mode)
-{
- mGLState.setBlendEquation(mode, mode);
-}
-
void Context::blendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
{
mGLState.setBlendEquation(modeRGB, modeAlpha);
}
-void Context::blendFunc(GLenum sfactor, GLenum dfactor)
-{
- mGLState.setBlendFactors(sfactor, dfactor, sfactor, dfactor);
-}
-
void Context::blendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
{
mGLState.setBlendFactors(srcRGB, dstRGB, srcAlpha, dstAlpha);
@@ -3475,119 +3430,4 @@ void Context::popDebugGroup()
mGLState.getDebug().popGroup();
}
-void Context::bufferData(GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage)
-{
- Buffer *buffer = mGLState.getTargetBuffer(target);
- ASSERT(buffer);
- handleError(buffer->bufferData(target, data, size, usage));
-}
-
-void Context::bufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data)
-{
- if (data == nullptr)
- {
- return;
- }
-
- Buffer *buffer = mGLState.getTargetBuffer(target);
- ASSERT(buffer);
- handleError(buffer->bufferSubData(target, data, size, offset));
-}
-
-void Context::attachShader(GLuint program, GLuint shader)
-{
- auto programObject = mResourceManager->getProgram(program);
- auto shaderObject = mResourceManager->getShader(shader);
- ASSERT(programObject && shaderObject);
- programObject->attachShader(shaderObject);
-}
-
-const Workarounds &Context::getWorkarounds() const
-{
- return mWorkarounds;
-}
-
-void Context::copyBufferSubData(GLenum readTarget,
- GLenum writeTarget,
- GLintptr readOffset,
- GLintptr writeOffset,
- GLsizeiptr size)
-{
- // if size is zero, the copy is a successful no-op
- if (size == 0)
- {
- return;
- }
-
- // TODO(jmadill): cache these.
- Buffer *readBuffer = mGLState.getTargetBuffer(readTarget);
- Buffer *writeBuffer = mGLState.getTargetBuffer(writeTarget);
-
- handleError(writeBuffer->copyBufferSubData(readBuffer, readOffset, writeOffset, size));
-}
-
-void Context::bindAttribLocation(GLuint program, GLuint index, const GLchar *name)
-{
- Program *programObject = getProgram(program);
- // TODO(jmadill): Re-use this from the validation if possible.
- ASSERT(programObject);
- programObject->bindAttributeLocation(index, name);
-}
-
-void Context::bindBuffer(GLenum target, GLuint buffer)
-{
- switch (target)
- {
- case GL_ARRAY_BUFFER:
- bindArrayBuffer(buffer);
- break;
- case GL_ELEMENT_ARRAY_BUFFER:
- bindElementArrayBuffer(buffer);
- break;
- case GL_COPY_READ_BUFFER:
- bindCopyReadBuffer(buffer);
- break;
- case GL_COPY_WRITE_BUFFER:
- bindCopyWriteBuffer(buffer);
- break;
- case GL_PIXEL_PACK_BUFFER:
- bindPixelPackBuffer(buffer);
- break;
- case GL_PIXEL_UNPACK_BUFFER:
- bindPixelUnpackBuffer(buffer);
- break;
- case GL_UNIFORM_BUFFER:
- bindGenericUniformBuffer(buffer);
- break;
- case GL_TRANSFORM_FEEDBACK_BUFFER:
- bindGenericTransformFeedbackBuffer(buffer);
- break;
-
- default:
- UNREACHABLE();
- break;
- }
-}
-
-void Context::bindFramebuffer(GLenum target, GLuint framebuffer)
-{
- if (target == GL_READ_FRAMEBUFFER || target == GL_FRAMEBUFFER)
- {
- bindReadFramebuffer(framebuffer);
- }
-
- if (target == GL_DRAW_FRAMEBUFFER || target == GL_FRAMEBUFFER)
- {
- bindDrawFramebuffer(framebuffer);
- }
-}
-
-void Context::bindRenderbuffer(GLenum target, GLuint renderbuffer)
-{
- ASSERT(target == GL_RENDERBUFFER);
- Renderbuffer *object =
- mResourceManager->checkRenderbufferAllocation(mImplementation.get(), renderbuffer);
- mGLState.setRenderbufferBinding(object);
-}
-
} // namespace gl