blob: 90e80d92b573c96eff7d9747669d5d6dd3943b47 [file] [log] [blame]
//
// Copyright 2002 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Context.cpp: Implements the gl::Context class, managing all GL state and performing
// rendering operations. It is the GLES2 specific implementation of EGLContext.
#include "libANGLE/Context.h"
#include "libANGLE/Context.inl.h"
#include <string.h>
#include <iterator>
#include <sstream>
#include <vector>
#include "common/PackedEnums.h"
#include "common/matrix_utils.h"
#include "common/platform.h"
#include "common/utilities.h"
#include "common/version.h"
#include "libANGLE/Buffer.h"
#include "libANGLE/Compiler.h"
#include "libANGLE/Display.h"
#include "libANGLE/Fence.h"
#include "libANGLE/FrameCapture.h"
#include "libANGLE/Framebuffer.h"
#include "libANGLE/FramebufferAttachment.h"
#include "libANGLE/MemoryObject.h"
#include "libANGLE/Path.h"
#include "libANGLE/Program.h"
#include "libANGLE/ProgramPipeline.h"
#include "libANGLE/Query.h"
#include "libANGLE/Renderbuffer.h"
#include "libANGLE/ResourceManager.h"
#include "libANGLE/Sampler.h"
#include "libANGLE/Semaphore.h"
#include "libANGLE/Surface.h"
#include "libANGLE/Texture.h"
#include "libANGLE/TransformFeedback.h"
#include "libANGLE/VertexArray.h"
#include "libANGLE/formatutils.h"
#include "libANGLE/queryconversions.h"
#include "libANGLE/queryutils.h"
#include "libANGLE/renderer/DisplayImpl.h"
#include "libANGLE/renderer/Format.h"
#include "libANGLE/validationES.h"
namespace gl
{
namespace
{
template <typename T>
std::vector<Path *> GatherPaths(PathManager &resourceManager,
GLsizei numPaths,
const void *paths,
PathID pathBase)
{
std::vector<Path *> ret;
ret.reserve(numPaths);
const auto *nameArray = static_cast<const T *>(paths);
for (GLsizei i = 0; i < numPaths; ++i)
{
const GLuint pathName = nameArray[i] + pathBase.value;
ret.push_back(resourceManager.getPath({pathName}));
}
return ret;
}
std::vector<Path *> GatherPaths(PathManager &resourceManager,
GLsizei numPaths,
GLenum pathNameType,
const void *paths,
PathID pathBase)
{
switch (pathNameType)
{
case GL_UNSIGNED_BYTE:
return GatherPaths<GLubyte>(resourceManager, numPaths, paths, pathBase);
case GL_BYTE:
return GatherPaths<GLbyte>(resourceManager, numPaths, paths, pathBase);
case GL_UNSIGNED_SHORT:
return GatherPaths<GLushort>(resourceManager, numPaths, paths, pathBase);
case GL_SHORT:
return GatherPaths<GLshort>(resourceManager, numPaths, paths, pathBase);
case GL_UNSIGNED_INT:
return GatherPaths<GLuint>(resourceManager, numPaths, paths, pathBase);
case GL_INT:
return GatherPaths<GLint>(resourceManager, numPaths, paths, pathBase);
}
UNREACHABLE();
return std::vector<Path *>();
}
template <typename T>
angle::Result GetQueryObjectParameter(const Context *context, Query *query, GLenum pname, T *params)
{
ASSERT(query != nullptr || pname == GL_QUERY_RESULT_AVAILABLE_EXT);
switch (pname)
{
case GL_QUERY_RESULT_EXT:
return query->getResult(context, params);
case GL_QUERY_RESULT_AVAILABLE_EXT:
{
bool available = false;
if (context->isContextLost())
{
available = true;
}
else
{
ANGLE_TRY(query->isResultAvailable(context, &available));
}
*params = CastFromStateValue<T>(pname, static_cast<GLuint>(available));
return angle::Result::Continue;
}
default:
UNREACHABLE();
return angle::Result::Stop;
}
}
// Attribute map queries.
EGLint GetClientMajorVersion(const egl::AttributeMap &attribs)
{
return static_cast<EGLint>(attribs.get(EGL_CONTEXT_CLIENT_VERSION, 1));
}
EGLint GetClientMinorVersion(const egl::AttributeMap &attribs)
{
return static_cast<EGLint>(attribs.get(EGL_CONTEXT_MINOR_VERSION, 0));
}
bool GetBackwardCompatibleContext(const egl::AttributeMap &attribs)
{
return attribs.get(EGL_CONTEXT_OPENGL_BACKWARDS_COMPATIBLE_ANGLE, EGL_TRUE) == EGL_TRUE;
}
Version GetClientVersion(egl::Display *display, const egl::AttributeMap &attribs)
{
Version requestedVersion =
Version(GetClientMajorVersion(attribs), GetClientMinorVersion(attribs));
if (GetBackwardCompatibleContext(attribs))
{
if (requestedVersion.major == 1)
{
// If the user requests an ES1 context, we cannot return an ES 2+ context.
return Version(1, 1);
}
else
{
// Always up the version to at least the max conformant version this display supports.
// Only return a higher client version if requested.
return std::max(display->getImplementation()->getMaxConformantESVersion(),
requestedVersion);
}
}
else
{
return requestedVersion;
}
}
GLenum GetResetStrategy(const egl::AttributeMap &attribs)
{
EGLAttrib attrib =
attribs.get(EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT, EGL_NO_RESET_NOTIFICATION);
switch (attrib)
{
case EGL_NO_RESET_NOTIFICATION:
return GL_NO_RESET_NOTIFICATION_EXT;
case EGL_LOSE_CONTEXT_ON_RESET:
return GL_LOSE_CONTEXT_ON_RESET_EXT;
default:
UNREACHABLE();
return GL_NONE;
}
}
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);
}
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);
}
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 GetExtensionsEnabled(const egl::AttributeMap &attribs, bool webGLContext)
{
// If the context is WebGL, extensions are disabled by default
EGLAttrib defaultValue = webGLContext ? EGL_FALSE : EGL_TRUE;
return (attribs.get(EGL_EXTENSIONS_ENABLED_ANGLE, defaultValue) == EGL_TRUE);
}
bool GetBindGeneratesResource(const egl::AttributeMap &attribs)
{
return (attribs.get(EGL_CONTEXT_BIND_GENERATES_RESOURCE_CHROMIUM, EGL_TRUE) == EGL_TRUE);
}
bool GetClientArraysEnabled(const egl::AttributeMap &attribs)
{
return (attribs.get(EGL_CONTEXT_CLIENT_ARRAYS_ENABLED_ANGLE, EGL_TRUE) == EGL_TRUE);
}
bool GetRobustResourceInit(const egl::AttributeMap &attribs)
{
return (attribs.get(EGL_ROBUST_RESOURCE_INITIALIZATION_ANGLE, EGL_FALSE) == EGL_TRUE);
}
std::string GetObjectLabelFromPointer(GLsizei length, const GLchar *label)
{
std::string labelName;
if (label != nullptr)
{
size_t labelLength = length < 0 ? strlen(label) : length;
labelName = std::string(label, labelLength);
}
return labelName;
}
void GetObjectLabelBase(const std::string &objectLabel,
GLsizei bufSize,
GLsizei *length,
GLchar *label)
{
size_t writeLength = objectLabel.length();
if (label != nullptr && bufSize > 0)
{
writeLength = std::min(static_cast<size_t>(bufSize) - 1, objectLabel.length());
std::copy(objectLabel.begin(), objectLabel.begin() + writeLength, label);
label[writeLength] = '\0';
}
if (length != nullptr)
{
*length = static_cast<GLsizei>(writeLength);
}
}
// The rest default to false.
constexpr angle::PackedEnumMap<PrimitiveMode, bool, angle::EnumSize<PrimitiveMode>() + 1>
kValidBasicDrawModes = {{
{PrimitiveMode::Points, true},
{PrimitiveMode::Lines, true},
{PrimitiveMode::LineLoop, true},
{PrimitiveMode::LineStrip, true},
{PrimitiveMode::Triangles, true},
{PrimitiveMode::TriangleStrip, true},
{PrimitiveMode::TriangleFan, true},
}};
enum SubjectIndexes : angle::SubjectIndex
{
kTexture0SubjectIndex = 0,
kTextureMaxSubjectIndex = kTexture0SubjectIndex + IMPLEMENTATION_MAX_ACTIVE_TEXTURES,
kImage0SubjectIndex = kTextureMaxSubjectIndex,
kImageMaxSubjectIndex = kImage0SubjectIndex + IMPLEMENTATION_MAX_IMAGE_UNITS,
kUniformBuffer0SubjectIndex = kImageMaxSubjectIndex,
kUniformBufferMaxSubjectIndex =
kUniformBuffer0SubjectIndex + IMPLEMENTATION_MAX_UNIFORM_BUFFER_BINDINGS,
kSampler0SubjectIndex = kUniformBufferMaxSubjectIndex,
kSamplerMaxSubjectIndex = kSampler0SubjectIndex + IMPLEMENTATION_MAX_ACTIVE_TEXTURES,
kVertexArraySubjectIndex = kSamplerMaxSubjectIndex,
kReadFramebufferSubjectIndex,
kDrawFramebufferSubjectIndex
};
} // anonymous namespace
Context::Context(egl::Display *display,
const egl::Config *config,
const Context *shareContext,
TextureManager *shareTextures,
MemoryProgramCache *memoryProgramCache,
const EGLenum clientType,
const egl::AttributeMap &attribs,
const egl::DisplayExtensions &displayExtensions,
const egl::ClientExtensions &clientExtensions)
: mState(reinterpret_cast<ContextID>(this),
shareContext ? &shareContext->mState : nullptr,
shareTextures,
&mOverlay,
clientType,
GetClientVersion(display, attribs),
GetDebug(attribs),
GetBindGeneratesResource(attribs),
GetClientArraysEnabled(attribs),
GetRobustResourceInit(attribs),
memoryProgramCache != nullptr),
mShared(shareContext != nullptr),
mSkipValidation(GetNoError(attribs)),
mDisplayTextureShareGroup(shareTextures != nullptr),
mErrors(this),
mImplementation(display->getImplementation()
->createContext(mState, &mErrors, config, shareContext, attribs)),
mLabel(nullptr),
mCompiler(),
mConfig(config),
mHasBeenCurrent(false),
mContextLost(false),
mResetStatus(GraphicsResetStatus::NoError),
mContextLostForced(false),
mResetStrategy(GetResetStrategy(attribs)),
mRobustAccess(GetRobustAccess(attribs)),
mSurfacelessSupported(displayExtensions.surfacelessContext),
mExplicitContextAvailable(clientExtensions.explicitContext),
mCurrentDrawSurface(static_cast<egl::Surface *>(EGL_NO_SURFACE)),
mCurrentReadSurface(static_cast<egl::Surface *>(EGL_NO_SURFACE)),
mDisplay(static_cast<egl::Display *>(EGL_NO_DISPLAY)),
mWebGLContext(GetWebGLContext(attribs)),
mBufferAccessValidationEnabled(false),
mExtensionsEnabled(GetExtensionsEnabled(attribs, mWebGLContext)),
mMemoryProgramCache(memoryProgramCache),
mVertexArrayObserverBinding(this, kVertexArraySubjectIndex),
mDrawFramebufferObserverBinding(this, kDrawFramebufferSubjectIndex),
mReadFramebufferObserverBinding(this, kReadFramebufferSubjectIndex),
mScratchBuffer(1000u),
mZeroFilledBuffer(1000u),
mThreadPool(nullptr),
mFrameCapture(new angle::FrameCapture),
mOverlay(mImplementation.get())
{
for (angle::SubjectIndex uboIndex = kUniformBuffer0SubjectIndex;
uboIndex < kUniformBufferMaxSubjectIndex; ++uboIndex)
{
mUniformBufferObserverBindings.emplace_back(this, uboIndex);
}
for (angle::SubjectIndex samplerIndex = kSampler0SubjectIndex;
samplerIndex < kSamplerMaxSubjectIndex; ++samplerIndex)
{
mSamplerObserverBindings.emplace_back(this, samplerIndex);
}
for (angle::SubjectIndex imageIndex = kImage0SubjectIndex; imageIndex < kImageMaxSubjectIndex;
++imageIndex)
{
mImageObserverBindings.emplace_back(this, imageIndex);
}
}
void Context::initialize()
{
mImplementation->setMemoryProgramCache(mMemoryProgramCache);
initCaps();
if (mDisplay->getFrontendFeatures().syncFramebufferBindingsOnTexImage.enabled)
{
mTexImageDirtyBits.set(State::DIRTY_BIT_READ_FRAMEBUFFER_BINDING);
mTexImageDirtyBits.set(State::DIRTY_BIT_DRAW_FRAMEBUFFER_BINDING);
}
mState.initialize(this);
mFenceNVHandleAllocator.setBaseHandle(0);
// [OpenGL ES 2.0.24] section 3.7 page 83:
// In the initial state, TEXTURE_2D and TEXTURE_CUBE_MAP have two-dimensional
// and cube map texture state vectors respectively associated with them.
// In order that access to these initial textures not be lost, they are treated as texture
// objects all of whose names are 0.
Texture *zeroTexture2D = new Texture(mImplementation.get(), {0}, TextureType::_2D);
mZeroTextures[TextureType::_2D].set(this, zeroTexture2D);
Texture *zeroTextureCube = new Texture(mImplementation.get(), {0}, TextureType::CubeMap);
mZeroTextures[TextureType::CubeMap].set(this, zeroTextureCube);
if (getClientVersion() >= Version(3, 0) || mSupportedExtensions.texture3DOES)
{
Texture *zeroTexture3D = new Texture(mImplementation.get(), {0}, TextureType::_3D);
mZeroTextures[TextureType::_3D].set(this, zeroTexture3D);
}
if (getClientVersion() >= Version(3, 0))
{
Texture *zeroTexture2DArray =
new Texture(mImplementation.get(), {0}, TextureType::_2DArray);
mZeroTextures[TextureType::_2DArray].set(this, zeroTexture2DArray);
}
if (getClientVersion() >= Version(3, 1) || mSupportedExtensions.textureMultisample)
{
Texture *zeroTexture2DMultisample =
new Texture(mImplementation.get(), {0}, TextureType::_2DMultisample);
mZeroTextures[TextureType::_2DMultisample].set(this, zeroTexture2DMultisample);
}
if (getClientVersion() >= Version(3, 1))
{
Texture *zeroTexture2DMultisampleArray =
new Texture(mImplementation.get(), {0}, TextureType::_2DMultisampleArray);
mZeroTextures[TextureType::_2DMultisampleArray].set(this, zeroTexture2DMultisampleArray);
for (int i = 0; i < mState.mCaps.maxAtomicCounterBufferBindings; i++)
{
bindBufferRange(BufferBinding::AtomicCounter, i, {0}, 0, 0);
}
for (int i = 0; i < mState.mCaps.maxShaderStorageBufferBindings; i++)
{
bindBufferRange(BufferBinding::ShaderStorage, i, {0}, 0, 0);
}
}
if (mSupportedExtensions.textureRectangle)
{
Texture *zeroTextureRectangle =
new Texture(mImplementation.get(), {0}, TextureType::Rectangle);
mZeroTextures[TextureType::Rectangle].set(this, zeroTextureRectangle);
}
if (mSupportedExtensions.eglImageExternal || mSupportedExtensions.eglStreamConsumerExternal)
{
Texture *zeroTextureExternal =
new Texture(mImplementation.get(), {0}, TextureType::External);
mZeroTextures[TextureType::External].set(this, zeroTextureExternal);
}
mState.initializeZeroTextures(this, mZeroTextures);
bindVertexArray({0});
if (getClientVersion() >= Version(3, 0))
{
// [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
// a transform feedback object with a name of zero. That object is bound any time
// BindTransformFeedback is called with id of zero
bindTransformFeedback(GL_TRANSFORM_FEEDBACK, {0});
}
for (auto type : angle::AllEnums<BufferBinding>())
{
bindBuffer(type, {0});
}
bindRenderbuffer(GL_RENDERBUFFER, {0});
for (int i = 0; i < mState.mCaps.maxUniformBufferBindings; i++)
{
bindBufferRange(BufferBinding::Uniform, i, {0}, 0, -1);
}
// Initialize GLES1 renderer if appropriate.
if (getClientVersion() < Version(2, 0))
{
mGLES1Renderer.reset(new GLES1Renderer());
}
// Initialize dirty bit masks
mAllDirtyBits.set();
mDrawDirtyObjects.set(State::DIRTY_OBJECT_DRAW_FRAMEBUFFER);
mDrawDirtyObjects.set(State::DIRTY_OBJECT_VERTEX_ARRAY);
mDrawDirtyObjects.set(State::DIRTY_OBJECT_TEXTURES);
mDrawDirtyObjects.set(State::DIRTY_OBJECT_PROGRAM);
mDrawDirtyObjects.set(State::DIRTY_OBJECT_SAMPLERS);
mDrawDirtyObjects.set(State::DIRTY_OBJECT_IMAGES);
mPathOperationDirtyObjects.set(State::DIRTY_OBJECT_DRAW_FRAMEBUFFER);
mPathOperationDirtyObjects.set(State::DIRTY_OBJECT_VERTEX_ARRAY);
mPathOperationDirtyObjects.set(State::DIRTY_OBJECT_TEXTURES);
mPathOperationDirtyObjects.set(State::DIRTY_OBJECT_SAMPLERS);
mTexImageDirtyBits.set(State::DIRTY_BIT_UNPACK_STATE);
mTexImageDirtyBits.set(State::DIRTY_BIT_UNPACK_BUFFER_BINDING);
// No dirty objects.
// Readpixels uses the pack state and read FBO
mReadPixelsDirtyBits.set(State::DIRTY_BIT_PACK_STATE);
mReadPixelsDirtyBits.set(State::DIRTY_BIT_PACK_BUFFER_BINDING);
mReadPixelsDirtyBits.set(State::DIRTY_BIT_READ_FRAMEBUFFER_BINDING);
mReadPixelsDirtyObjects.set(State::DIRTY_OBJECT_READ_FRAMEBUFFER);
mClearDirtyBits.set(State::DIRTY_BIT_RASTERIZER_DISCARD_ENABLED);
mClearDirtyBits.set(State::DIRTY_BIT_SCISSOR_TEST_ENABLED);
mClearDirtyBits.set(State::DIRTY_BIT_SCISSOR);
mClearDirtyBits.set(State::DIRTY_BIT_VIEWPORT);
mClearDirtyBits.set(State::DIRTY_BIT_CLEAR_COLOR);
mClearDirtyBits.set(State::DIRTY_BIT_CLEAR_DEPTH);
mClearDirtyBits.set(State::DIRTY_BIT_CLEAR_STENCIL);
mClearDirtyBits.set(State::DIRTY_BIT_COLOR_MASK);
mClearDirtyBits.set(State::DIRTY_BIT_DEPTH_MASK);
mClearDirtyBits.set(State::DIRTY_BIT_STENCIL_WRITEMASK_FRONT);
mClearDirtyBits.set(State::DIRTY_BIT_STENCIL_WRITEMASK_BACK);
mClearDirtyBits.set(State::DIRTY_BIT_DRAW_FRAMEBUFFER_BINDING);
// We sync the draw Framebuffer manually in prepareForClear to allow the clear calls to do
// more custom handling for robust resource init.
mBlitDirtyBits.set(State::DIRTY_BIT_SCISSOR_TEST_ENABLED);
mBlitDirtyBits.set(State::DIRTY_BIT_SCISSOR);
mBlitDirtyBits.set(State::DIRTY_BIT_FRAMEBUFFER_SRGB);
mBlitDirtyBits.set(State::DIRTY_BIT_READ_FRAMEBUFFER_BINDING);
mBlitDirtyBits.set(State::DIRTY_BIT_DRAW_FRAMEBUFFER_BINDING);
mBlitDirtyObjects.set(State::DIRTY_OBJECT_READ_FRAMEBUFFER);
mBlitDirtyObjects.set(State::DIRTY_OBJECT_DRAW_FRAMEBUFFER);
mComputeDirtyBits.set(State::DIRTY_BIT_SHADER_STORAGE_BUFFER_BINDING);
mComputeDirtyBits.set(State::DIRTY_BIT_UNIFORM_BUFFER_BINDINGS);
mComputeDirtyBits.set(State::DIRTY_BIT_ATOMIC_COUNTER_BUFFER_BINDING);
mComputeDirtyBits.set(State::DIRTY_BIT_PROGRAM_BINDING);
mComputeDirtyBits.set(State::DIRTY_BIT_PROGRAM_EXECUTABLE);
mComputeDirtyBits.set(State::DIRTY_BIT_TEXTURE_BINDINGS);
mComputeDirtyBits.set(State::DIRTY_BIT_SAMPLER_BINDINGS);
mComputeDirtyBits.set(State::DIRTY_BIT_IMAGE_BINDINGS);
mComputeDirtyBits.set(State::DIRTY_BIT_DISPATCH_INDIRECT_BUFFER_BINDING);
mComputeDirtyObjects.set(State::DIRTY_OBJECT_TEXTURES);
mComputeDirtyObjects.set(State::DIRTY_OBJECT_PROGRAM);
mComputeDirtyObjects.set(State::DIRTY_OBJECT_IMAGES);
mComputeDirtyObjects.set(State::DIRTY_OBJECT_SAMPLERS);
mCopyImageDirtyBits.set(State::DIRTY_BIT_READ_FRAMEBUFFER_BINDING);
mCopyImageDirtyObjects.set(State::DIRTY_OBJECT_READ_FRAMEBUFFER);
ANGLE_CONTEXT_TRY(mImplementation->initialize());
// Initialize overlay after implementation is initialized.
ANGLE_CONTEXT_TRY(mOverlay.init(this));
}
egl::Error Context::onDestroy(const egl::Display *display)
{
// Dump frame capture if enabled.
mFrameCapture->onEndFrame(this);
if (mGLES1Renderer)
{
mGLES1Renderer->onDestroy(this, &mState);
}
ANGLE_TRY(unMakeCurrent(display));
for (auto fence : mFenceNVMap)
{
SafeDelete(fence.second);
}
mFenceNVMap.clear();
for (auto query : mQueryMap)
{
if (query.second != nullptr)
{
query.second->release(this);
}
}
mQueryMap.clear();
for (auto vertexArray : mVertexArrayMap)
{
if (vertexArray.second)
{
vertexArray.second->onDestroy(this);
}
}
mVertexArrayMap.clear();
for (auto transformFeedback : mTransformFeedbackMap)
{
if (transformFeedback.second != nullptr)
{
transformFeedback.second->release(this);
}
}
mTransformFeedbackMap.clear();
for (BindingPointer<Texture> &zeroTexture : mZeroTextures)
{
if (zeroTexture.get() != nullptr)
{
zeroTexture.set(this, nullptr);
}
}
releaseShaderCompiler();
mState.reset(this);
mState.mBufferManager->release(this);
mState.mShaderProgramManager->release(this);
mState.mTextureManager->release(this);
mState.mRenderbufferManager->release(this);
mState.mSamplerManager->release(this);
mState.mSyncManager->release(this);
mState.mPathManager->release(this);
mState.mFramebufferManager->release(this);
mState.mProgramPipelineManager->release(this);
mState.mMemoryObjectManager->release(this);
mState.mSemaphoreManager->release(this);
mThreadPool.reset();
mImplementation->onDestroy(this);
mOverlay.destroy(this);
return egl::NoError();
}
Context::~Context() {}
void Context::setLabel(EGLLabelKHR label)
{
mLabel = label;
}
EGLLabelKHR Context::getLabel() const
{
return mLabel;
}
egl::Error Context::makeCurrent(egl::Display *display,
egl::Surface *drawSurface,
egl::Surface *readSurface)
{
mDisplay = display;
if (!mHasBeenCurrent)
{
initialize();
initRendererString();
initVersionStrings();
initExtensionStrings();
int width = 0;
int height = 0;
if (drawSurface != nullptr)
{
width = drawSurface->getWidth();
height = drawSurface->getHeight();
}
mState.setViewportParams(0, 0, width, height);
mState.setScissorParams(0, 0, width, height);
mHasBeenCurrent = true;
}
// TODO(jmadill): Rework this when we support ContextImpl
mState.setAllDirtyBits();
mState.setAllDirtyObjects();
ANGLE_TRY(setDefaultFramebuffer(drawSurface, readSurface));
// Notify the renderer of a context switch.
angle::Result implResult = mImplementation->onMakeCurrent(this);
// If the implementation fails onMakeCurrent, unset the default framebuffer.
if (implResult != angle::Result::Continue)
{
ANGLE_TRY(unsetDefaultFramebuffer());
return angle::ResultToEGL(implResult);
}
return egl::NoError();
}
egl::Error Context::unMakeCurrent(const egl::Display *display)
{
ANGLE_TRY(unsetDefaultFramebuffer());
return angle::ResultToEGL(mImplementation->onUnMakeCurrent(this));
}
BufferID Context::createBuffer()
{
return mState.mBufferManager->createBuffer();
}
GLuint Context::createProgram()
{
return mState.mShaderProgramManager->createProgram(mImplementation.get()).value;
}
GLuint Context::createShader(ShaderType type)
{
return mState.mShaderProgramManager
->createShader(mImplementation.get(), mState.mLimitations, type)
.value;
}
TextureID Context::createTexture()
{
return mState.mTextureManager->createTexture();
}
RenderbufferID Context::createRenderbuffer()
{
return mState.mRenderbufferManager->createRenderbuffer();
}
void Context::tryGenPaths(GLsizei range, PathID *createdOut)
{
ANGLE_CONTEXT_TRY(mState.mPathManager->createPaths(this, range, createdOut));
}
GLuint Context::genPaths(GLsizei range)
{
PathID created = {0};
tryGenPaths(range, &created);
return created.value;
}
// Returns an unused framebuffer name
FramebufferID Context::createFramebuffer()
{
return mState.mFramebufferManager->createFramebuffer();
}
void Context::genFencesNV(GLsizei n, FenceNVID *fences)
{
for (int i = 0; i < n; i++)
{
GLuint handle = mFenceNVHandleAllocator.allocate();
mFenceNVMap.assign({handle}, new FenceNV(mImplementation->createFenceNV()));
fences[i] = {handle};
}
}
ProgramPipelineID Context::createProgramPipeline()
{
return mState.mProgramPipelineManager->createProgramPipeline();
}
GLuint Context::createShaderProgramv(ShaderType type, GLsizei count, const GLchar *const *strings)
{
UNIMPLEMENTED();
return 0u;
}
MemoryObjectID Context::createMemoryObject()
{
return mState.mMemoryObjectManager->createMemoryObject(mImplementation.get());
}
SemaphoreID Context::createSemaphore()
{
return mState.mSemaphoreManager->createSemaphore(mImplementation.get());
}
void Context::deleteBuffer(BufferID bufferName)
{
Buffer *buffer = mState.mBufferManager->getBuffer(bufferName);
if (buffer)
{
detachBuffer(buffer);
}
mState.mBufferManager->deleteObject(this, bufferName);
}
void Context::deleteShader(ShaderProgramID shader)
{
mState.mShaderProgramManager->deleteShader(this, shader);
}
void Context::deleteProgram(ShaderProgramID program)
{
mState.mShaderProgramManager->deleteProgram(this, program);
}
void Context::deleteTexture(TextureID texture)
{
if (mState.mTextureManager->getTexture(texture))
{
detachTexture(texture);
}
mState.mTextureManager->deleteObject(this, texture);
}
void Context::deleteRenderbuffer(RenderbufferID renderbuffer)
{
if (mState.mRenderbufferManager->getRenderbuffer(renderbuffer))
{
detachRenderbuffer(renderbuffer);
}
mState.mRenderbufferManager->deleteObject(this, renderbuffer);
}
void Context::deleteSync(GLsync sync)
{
// The spec specifies the underlying Fence object is not deleted until all current
// wait commands finish. However, since the name becomes invalid, we cannot query the fence,
// and since our API is currently designed for being called from a single thread, we can delete
// the fence immediately.
mState.mSyncManager->deleteObject(this, static_cast<GLuint>(reinterpret_cast<uintptr_t>(sync)));
}
void Context::deleteProgramPipeline(ProgramPipelineID pipeline)
{
if (mState.mProgramPipelineManager->getProgramPipeline(pipeline))
{
detachProgramPipeline(pipeline);
}
mState.mProgramPipelineManager->deleteObject(this, pipeline);
}
void Context::deleteMemoryObject(MemoryObjectID memoryObject)
{
mState.mMemoryObjectManager->deleteMemoryObject(this, memoryObject);
}
void Context::deleteSemaphore(SemaphoreID semaphore)
{
mState.mSemaphoreManager->deleteSemaphore(this, semaphore);
}
void Context::deletePaths(PathID first, GLsizei range)
{
mState.mPathManager->deletePaths(first, range);
}
GLboolean Context::isPath(PathID path)
{
const auto *pathObj = mState.mPathManager->getPath(path);
if (pathObj == nullptr)
return false;
return pathObj->hasPathData();
}
bool Context::isPathGenerated(PathID path) const
{
return mState.mPathManager->hasPath(path);
}
void Context::pathCommands(PathID path,
GLsizei numCommands,
const GLubyte *commands,
GLsizei numCoords,
GLenum coordType,
const void *coords)
{
auto *pathObject = mState.mPathManager->getPath(path);
ANGLE_CONTEXT_TRY(pathObject->setCommands(numCommands, commands, numCoords, coordType, coords));
}
void Context::pathParameterf(PathID path, GLenum pname, GLfloat value)
{
Path *pathObj = mState.mPathManager->getPath(path);
switch (pname)
{
case GL_PATH_STROKE_WIDTH_CHROMIUM:
pathObj->setStrokeWidth(value);
break;
case GL_PATH_END_CAPS_CHROMIUM:
pathObj->setEndCaps(static_cast<GLenum>(value));
break;
case GL_PATH_JOIN_STYLE_CHROMIUM:
pathObj->setJoinStyle(static_cast<GLenum>(value));
break;
case GL_PATH_MITER_LIMIT_CHROMIUM:
pathObj->setMiterLimit(value);
break;
case GL_PATH_STROKE_BOUND_CHROMIUM:
pathObj->setStrokeBound(value);
break;
default:
UNREACHABLE();
break;
}
}
void Context::pathParameteri(PathID path, GLenum pname, GLint value)
{
// TODO(jmadill): Should use proper clamping/casting.
pathParameterf(path, pname, static_cast<GLfloat>(value));
}
void Context::getPathParameterfv(PathID path, GLenum pname, GLfloat *value)
{
const Path *pathObj = mState.mPathManager->getPath(path);
switch (pname)
{
case GL_PATH_STROKE_WIDTH_CHROMIUM:
*value = pathObj->getStrokeWidth();
break;
case GL_PATH_END_CAPS_CHROMIUM:
*value = static_cast<GLfloat>(pathObj->getEndCaps());
break;
case GL_PATH_JOIN_STYLE_CHROMIUM:
*value = static_cast<GLfloat>(pathObj->getJoinStyle());
break;
case GL_PATH_MITER_LIMIT_CHROMIUM:
*value = pathObj->getMiterLimit();
break;
case GL_PATH_STROKE_BOUND_CHROMIUM:
*value = pathObj->getStrokeBound();
break;
default:
UNREACHABLE();
break;
}
}
void Context::getPathParameteriv(PathID path, GLenum pname, GLint *value)
{
GLfloat val = 0.0f;
getPathParameterfv(path, pname, value != nullptr ? &val : nullptr);
if (value)
*value = static_cast<GLint>(val);
}
void Context::pathStencilFunc(GLenum func, GLint ref, GLuint mask)
{
mState.setPathStencilFunc(func, ref, mask);
}
// GL_CHROMIUM_lose_context
void Context::loseContext(GraphicsResetStatus current, GraphicsResetStatus other)
{
// TODO(geofflang): mark the rest of the share group lost. Requires access to the entire share
// group from a context. http://anglebug.com/3379
markContextLost(current);
}
void Context::deleteFramebuffer(FramebufferID framebuffer)
{
if (mState.mFramebufferManager->getFramebuffer(framebuffer))
{
detachFramebuffer(framebuffer);
}
mState.mFramebufferManager->deleteObject(this, framebuffer);
}
void Context::deleteFencesNV(GLsizei n, const FenceNVID *fences)
{
for (int i = 0; i < n; i++)
{
FenceNVID fence = fences[i];
FenceNV *fenceObject = nullptr;
if (mFenceNVMap.erase(fence, &fenceObject))
{
mFenceNVHandleAllocator.release(fence.value);
delete fenceObject;
}
}
}
Buffer *Context::getBuffer(BufferID handle) const
{
return mState.mBufferManager->getBuffer(handle);
}
Renderbuffer *Context::getRenderbuffer(RenderbufferID handle) const
{
return mState.mRenderbufferManager->getRenderbuffer(handle);
}
Sync *Context::getSync(GLsync handle) const
{
return mState.mSyncManager->getSync(static_cast<GLuint>(reinterpret_cast<uintptr_t>(handle)));
}
VertexArray *Context::getVertexArray(VertexArrayID handle) const
{
return mVertexArrayMap.query(handle);
}
Sampler *Context::getSampler(SamplerID handle) const
{
return mState.mSamplerManager->getSampler(handle);
}
TransformFeedback *Context::getTransformFeedback(TransformFeedbackID handle) const
{
return mTransformFeedbackMap.query(handle);
}
ProgramPipeline *Context::getProgramPipeline(ProgramPipelineID handle) const
{
return mState.mProgramPipelineManager->getProgramPipeline(handle);
}
gl::LabeledObject *Context::getLabeledObject(GLenum identifier, GLuint name) const
{
switch (identifier)
{
case GL_BUFFER:
return getBuffer({name});
case GL_SHADER:
return getShader({name});
case GL_PROGRAM:
return getProgramNoResolveLink({name});
case GL_VERTEX_ARRAY:
return getVertexArray({name});
case GL_QUERY:
return getQuery({name});
case GL_TRANSFORM_FEEDBACK:
return getTransformFeedback({name});
case GL_SAMPLER:
return getSampler({name});
case GL_TEXTURE:
return getTexture({name});
case GL_RENDERBUFFER:
return getRenderbuffer({name});
case GL_FRAMEBUFFER:
return getFramebuffer({name});
default:
UNREACHABLE();
return nullptr;
}
}
gl::LabeledObject *Context::getLabeledObjectFromPtr(const void *ptr) const
{
return getSync(reinterpret_cast<GLsync>(const_cast<void *>(ptr)));
}
void Context::objectLabel(GLenum identifier, GLuint name, GLsizei length, const GLchar *label)
{
gl::LabeledObject *object = getLabeledObject(identifier, name);
ASSERT(object != nullptr);
std::string labelName = GetObjectLabelFromPointer(length, label);
object->setLabel(this, labelName);
// TODO(jmadill): Determine if the object is dirty based on 'name'. Conservatively assume the
// specified object is active until we do this.
mState.setObjectDirty(identifier);
}
void Context::objectPtrLabel(const void *ptr, GLsizei length, const GLchar *label)
{
gl::LabeledObject *object = getLabeledObjectFromPtr(ptr);
ASSERT(object != nullptr);
std::string labelName = GetObjectLabelFromPointer(length, label);
object->setLabel(this, labelName);
}
void Context::getObjectLabel(GLenum identifier,
GLuint name,
GLsizei bufSize,
GLsizei *length,
GLchar *label)
{
gl::LabeledObject *object = getLabeledObject(identifier, name);
ASSERT(object != nullptr);
const std::string &objectLabel = object->getLabel();
GetObjectLabelBase(objectLabel, bufSize, length, label);
}
void Context::getObjectPtrLabel(const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label)
{
gl::LabeledObject *object = getLabeledObjectFromPtr(ptr);
ASSERT(object != nullptr);
const std::string &objectLabel = object->getLabel();
GetObjectLabelBase(objectLabel, bufSize, length, label);
}
GLboolean Context::isSampler(SamplerID samplerName)
{
return mState.mSamplerManager->isSampler(samplerName);
}
void Context::bindTexture(TextureType target, TextureID handle)
{
Texture *texture = nullptr;
if (handle.value == 0)
{
texture = mZeroTextures[target].get();
}
else
{
texture =
mState.mTextureManager->checkTextureAllocation(mImplementation.get(), handle, target);
}
ASSERT(texture);
mState.setSamplerTexture(this, target, texture);
mStateCache.onActiveTextureChange(this);
}
void Context::bindReadFramebuffer(FramebufferID framebufferHandle)
{
Framebuffer *framebuffer = mState.mFramebufferManager->checkFramebufferAllocation(
mImplementation.get(), mState.mCaps, framebufferHandle);
mState.setReadFramebufferBinding(framebuffer);
mReadFramebufferObserverBinding.bind(framebuffer);
}
void Context::bindDrawFramebuffer(FramebufferID framebufferHandle)
{
Framebuffer *framebuffer = mState.mFramebufferManager->checkFramebufferAllocation(
mImplementation.get(), mState.mCaps, framebufferHandle);
mState.setDrawFramebufferBinding(framebuffer);
mDrawFramebufferObserverBinding.bind(framebuffer);
mStateCache.onDrawFramebufferChange(this);
}
void Context::bindVertexArray(VertexArrayID vertexArrayHandle)
{
VertexArray *vertexArray = checkVertexArrayAllocation(vertexArrayHandle);
mState.setVertexArrayBinding(this, vertexArray);
mVertexArrayObserverBinding.bind(vertexArray);
mStateCache.onVertexArrayBindingChange(this);
}
void Context::bindVertexBuffer(GLuint bindingIndex,
BufferID bufferHandle,
GLintptr offset,
GLsizei stride)
{
Buffer *buffer =
mState.mBufferManager->checkBufferAllocation(mImplementation.get(), bufferHandle);
mState.bindVertexBuffer(this, bindingIndex, buffer, offset, stride);
mStateCache.onVertexArrayStateChange(this);
}
void Context::bindSampler(GLuint textureUnit, SamplerID samplerHandle)
{
ASSERT(textureUnit < static_cast<GLuint>(mState.mCaps.maxCombinedTextureImageUnits));
Sampler *sampler =
mState.mSamplerManager->checkSamplerAllocation(mImplementation.get(), samplerHandle);
mState.setSamplerBinding(this, textureUnit, sampler);
mSamplerObserverBindings[textureUnit].bind(sampler);
mStateCache.onActiveTextureChange(this);
}
void Context::bindImageTexture(GLuint unit,
TextureID texture,
GLint level,
GLboolean layered,
GLint layer,
GLenum access,
GLenum format)
{
Texture *tex = mState.mTextureManager->getTexture(texture);
mState.setImageUnit(this, unit, tex, level, layered, layer, access, format);
mImageObserverBindings[unit].bind(tex);
}
void Context::useProgram(ShaderProgramID program)
{
ANGLE_CONTEXT_TRY(mState.setProgram(this, getProgramResolveLink(program)));
mStateCache.onProgramExecutableChange(this);
}
void Context::useProgramStages(ProgramPipelineID pipeline,
GLbitfield stages,
ShaderProgramID program)
{
UNIMPLEMENTED();
}
void Context::bindTransformFeedback(GLenum target, TransformFeedbackID transformFeedbackHandle)
{
ASSERT(target == GL_TRANSFORM_FEEDBACK);
TransformFeedback *transformFeedback =
checkTransformFeedbackAllocation(transformFeedbackHandle);
mState.setTransformFeedbackBinding(this, transformFeedback);
}
void Context::bindProgramPipeline(ProgramPipelineID pipelineHandle)
{
ProgramPipeline *pipeline = mState.mProgramPipelineManager->checkProgramPipelineAllocation(
mImplementation.get(), pipelineHandle);
mState.setProgramPipelineBinding(this, pipeline);
}
void Context::beginQuery(QueryType target, QueryID query)
{
Query *queryObject = getQuery(query, true, target);
ASSERT(queryObject);
// begin query
ANGLE_CONTEXT_TRY(queryObject->begin(this));
// set query as active for specified target only if begin succeeded
mState.setActiveQuery(this, target, queryObject);
mStateCache.onQueryChange(this);
}
void Context::endQuery(QueryType target)
{
Query *queryObject = mState.getActiveQuery(target);
ASSERT(queryObject);
// Intentionally don't call try here. We don't want an early return.
(void)(queryObject->end(this));
// Always unbind the query, even if there was an error. This may delete the query object.
mState.setActiveQuery(this, target, nullptr);
mStateCache.onQueryChange(this);
}
void Context::queryCounter(QueryID id, QueryType target)
{
ASSERT(target == QueryType::Timestamp);
Query *queryObject = getQuery(id, true, target);
ASSERT(queryObject);
ANGLE_CONTEXT_TRY(queryObject->queryCounter(this));
}
void Context::getQueryiv(QueryType target, GLenum pname, GLint *params)
{
switch (pname)
{
case GL_CURRENT_QUERY_EXT:
params[0] = mState.getActiveQueryId(target).value;
break;
case GL_QUERY_COUNTER_BITS_EXT:
switch (target)
{
case QueryType::TimeElapsed:
params[0] = getExtensions().queryCounterBitsTimeElapsed;
break;
case QueryType::Timestamp:
params[0] = getExtensions().queryCounterBitsTimestamp;
break;
default:
UNREACHABLE();
params[0] = 0;
break;
}
break;
default:
UNREACHABLE();
return;
}
}
void Context::getQueryivRobust(QueryType target,
GLenum pname,
GLsizei bufSize,
GLsizei *length,
GLint *params)
{
getQueryiv(target, pname, params);
}
void Context::getUnsignedBytev(GLenum pname, GLubyte *data)
{
UNIMPLEMENTED();
}
void Context::getUnsignedBytei_v(GLenum target, GLuint index, GLubyte *data)
{
UNIMPLEMENTED();
}
void Context::getQueryObjectiv(QueryID id, GLenum pname, GLint *params)
{
ANGLE_CONTEXT_TRY(GetQueryObjectParameter(this, getQuery(id), pname, params));
}
void Context::getQueryObjectivRobust(QueryID id,
GLenum pname,
GLsizei bufSize,
GLsizei *length,
GLint *params)
{
getQueryObjectiv(id, pname, params);
}
void Context::getQueryObjectuiv(QueryID id, GLenum pname, GLuint *params)
{
ANGLE_CONTEXT_TRY(GetQueryObjectParameter(this, getQuery(id), pname, params));
}
void Context::getQueryObjectuivRobust(QueryID id,
GLenum pname,
GLsizei bufSize,
GLsizei *length,
GLuint *params)
{
getQueryObjectuiv(id, pname, params);
}
void Context::getQueryObjecti64v(QueryID id, GLenum pname, GLint64 *params)
{
ANGLE_CONTEXT_TRY(GetQueryObjectParameter(this, getQuery(id), pname, params));
}
void Context::getQueryObjecti64vRobust(QueryID id,
GLenum pname,
GLsizei bufSize,
GLsizei *length,
GLint64 *params)
{
getQueryObjecti64v(id, pname, params);
}
void Context::getQueryObjectui64v(QueryID id, GLenum pname, GLuint64 *params)
{
ANGLE_CONTEXT_TRY(GetQueryObjectParameter(this, getQuery(id), pname, params));
}
void Context::getQueryObjectui64vRobust(QueryID id,
GLenum pname,
GLsizei bufSize,
GLsizei *length,
GLuint64 *params)
{
getQueryObjectui64v(id, pname, params);
}
Framebuffer *Context::getFramebuffer(FramebufferID handle) const
{
return mState.mFramebufferManager->getFramebuffer(handle);
}
FenceNV *Context::getFenceNV(FenceNVID handle)
{
return mFenceNVMap.query(handle);
}
Query *Context::getQuery(QueryID handle, bool create, QueryType type)
{
if (!mQueryMap.contains(handle))
{
return nullptr;
}
Query *query = mQueryMap.query(handle);
if (!query && create)
{
ASSERT(type != QueryType::InvalidEnum);
query = new Query(mImplementation->createQuery(type), handle);
query->addRef();
mQueryMap.assign(handle, query);
}
return query;
}
Query *Context::getQuery(QueryID handle) const
{
return mQueryMap.query(handle);
}
Texture *Context::getTextureByType(TextureType type) const
{
ASSERT(ValidTextureTarget(this, type) || ValidTextureExternalTarget(this, type));
return mState.getTargetTexture(type);
}
Texture *Context::getTextureByTarget(TextureTarget target) const
{
return getTextureByType(TextureTargetToType(target));
}
Texture *Context::getSamplerTexture(unsigned int sampler, TextureType type) const
{
return mState.getSamplerTexture(sampler, type);
}
Compiler *Context::getCompiler() const
{
if (mCompiler.get() == nullptr)
{
mCompiler.set(this, new Compiler(mImplementation.get(), mState));
}
return mCompiler.get();
}
void Context::getBooleanvImpl(GLenum pname, GLboolean *params)
{
switch (pname)
{
case GL_SHADER_COMPILER:
*params = GL_TRUE;
break;
case GL_CONTEXT_ROBUST_ACCESS_EXT:
*params = ConvertToGLBoolean(mRobustAccess);
break;
default:
mState.getBooleanv(pname, params);
break;
}
}
void Context::getFloatvImpl(GLenum pname, GLfloat *params)
{
// Queries about context capabilities and maximums are answered by Context.
// Queries about current GL state values are answered by State.
switch (pname)
{
case GL_ALIASED_LINE_WIDTH_RANGE:
params[0] = mState.mCaps.minAliasedLineWidth;
params[1] = mState.mCaps.maxAliasedLineWidth;
break;
case GL_ALIASED_POINT_SIZE_RANGE:
params[0] = mState.mCaps.minAliasedPointSize;
params[1] = mState.mCaps.maxAliasedPointSize;
break;
case GL_SMOOTH_POINT_SIZE_RANGE:
params[0] = mState.mCaps.minSmoothPointSize;
params[1] = mState.mCaps.maxSmoothPointSize;
break;
case GL_SMOOTH_LINE_WIDTH_RANGE:
params[0] = mState.mCaps.minSmoothLineWidth;
params[1] = mState.mCaps.maxSmoothLineWidth;
break;
case GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT:
ASSERT(mState.mExtensions.textureFilterAnisotropic);
*params = mState.mExtensions.maxTextureAnisotropy;
break;
case GL_MAX_TEXTURE_LOD_BIAS:
*params = mState.mCaps.maxLODBias;
break;
case GL_PATH_MODELVIEW_MATRIX_CHROMIUM:
case GL_PATH_PROJECTION_MATRIX_CHROMIUM:
{
// GLES1 emulation: // GL_PATH_(MODELVIEW|PROJECTION)_MATRIX_CHROMIUM collides with the
// GLES1 constants for modelview/projection matrix.
if (getClientVersion() < Version(2, 0))
{
mState.getFloatv(pname, params);
}
else
{
ASSERT(mState.mExtensions.pathRendering);
const GLfloat *m = mState.getPathRenderingMatrix(pname);
memcpy(params, m, 16 * sizeof(GLfloat));
}
}
break;
default:
mState.getFloatv(pname, params);
break;
}
}
void Context::getIntegervImpl(GLenum pname, GLint *params)
{
// Queries about context capabilities and maximums are answered by Context.
// Queries about current GL state values are answered by State.
switch (pname)
{
case GL_MAX_VERTEX_ATTRIBS:
*params = mState.mCaps.maxVertexAttributes;
break;
case GL_MAX_VERTEX_UNIFORM_VECTORS:
*params = mState.mCaps.maxVertexUniformVectors;
break;
case GL_MAX_VERTEX_UNIFORM_COMPONENTS:
*params = mState.mCaps.maxShaderUniformComponents[ShaderType::Vertex];
break;
case GL_MAX_VARYING_VECTORS:
*params = mState.mCaps.maxVaryingVectors;
break;
case GL_MAX_VARYING_COMPONENTS:
*params = mState.mCaps.maxVertexOutputComponents;
break;
case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS:
*params = mState.mCaps.maxCombinedTextureImageUnits;
break;
case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS:
*params = mState.mCaps.maxShaderTextureImageUnits[ShaderType::Vertex];
break;
case GL_MAX_TEXTURE_IMAGE_UNITS:
*params = mState.mCaps.maxShaderTextureImageUnits[ShaderType::Fragment];
break;
case GL_MAX_FRAGMENT_UNIFORM_VECTORS:
*params = mState.mCaps.maxFragmentUniformVectors;
break;
case GL_MAX_FRAGMENT_UNIFORM_COMPONENTS:
*params = mState.mCaps.maxShaderUniformComponents[ShaderType::Fragment];
break;
case GL_MAX_RENDERBUFFER_SIZE:
*params = mState.mCaps.maxRenderbufferSize;
break;
case GL_MAX_COLOR_ATTACHMENTS_EXT:
*params = mState.mCaps.maxColorAttachments;
break;
case GL_MAX_DRAW_BUFFERS_EXT:
*params = mState.mCaps.maxDrawBuffers;
break;
case GL_SUBPIXEL_BITS:
*params = mState.mCaps.subPixelBits;
break;
case GL_MAX_TEXTURE_SIZE:
*params = mState.mCaps.max2DTextureSize;
break;
case GL_MAX_RECTANGLE_TEXTURE_SIZE_ANGLE:
*params = mState.mCaps.maxRectangleTextureSize;
break;
case GL_MAX_CUBE_MAP_TEXTURE_SIZE:
*params = mState.mCaps.maxCubeMapTextureSize;
break;
case GL_MAX_3D_TEXTURE_SIZE:
*params = mState.mCaps.max3DTextureSize;
break;
case GL_MAX_ARRAY_TEXTURE_LAYERS:
*params = mState.mCaps.maxArrayTextureLayers;
break;
case GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT:
*params = mState.mCaps.uniformBufferOffsetAlignment;
break;
case GL_MAX_UNIFORM_BUFFER_BINDINGS:
*params = mState.mCaps.maxUniformBufferBindings;
break;
case GL_MAX_VERTEX_UNIFORM_BLOCKS:
*params = mState.mCaps.maxShaderUniformBlocks[ShaderType::Vertex];
break;
case GL_MAX_FRAGMENT_UNIFORM_BLOCKS:
*params = mState.mCaps.maxShaderUniformBlocks[ShaderType::Fragment];
break;
case GL_MAX_COMBINED_UNIFORM_BLOCKS:
*params = mState.mCaps.maxCombinedUniformBlocks;
break;
case GL_MAX_VERTEX_OUTPUT_COMPONENTS:
*params = mState.mCaps.maxVertexOutputComponents;
break;
case GL_MAX_FRAGMENT_INPUT_COMPONENTS:
*params = mState.mCaps.maxFragmentInputComponents;
break;
case GL_MIN_PROGRAM_TEXEL_OFFSET:
*params = mState.mCaps.minProgramTexelOffset;
break;
case GL_MAX_PROGRAM_TEXEL_OFFSET:
*params = mState.mCaps.maxProgramTexelOffset;
break;
case GL_MAJOR_VERSION:
*params = getClientVersion().major;
break;
case GL_MINOR_VERSION:
*params = getClientVersion().minor;
break;
case GL_MAX_ELEMENTS_INDICES:
*params = mState.mCaps.maxElementsIndices;
break;
case GL_MAX_ELEMENTS_VERTICES:
*params = mState.mCaps.maxElementsVertices;
break;
case GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS:
*params = mState.mCaps.maxTransformFeedbackInterleavedComponents;
break;
case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS:
*params = mState.mCaps.maxTransformFeedbackSeparateAttributes;
break;
case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS:
*params = mState.mCaps.maxTransformFeedbackSeparateComponents;
break;
case GL_NUM_COMPRESSED_TEXTURE_FORMATS:
*params = static_cast<GLint>(mState.mCaps.compressedTextureFormats.size());
break;
case GL_MAX_SAMPLES_ANGLE:
*params = mState.mCaps.maxSamples;
break;
case GL_MAX_VIEWPORT_DIMS:
{
params[0] = mState.mCaps.maxViewportWidth;
params[1] = mState.mCaps.maxViewportHeight;
}
break;
case GL_COMPRESSED_TEXTURE_FORMATS:
std::copy(mState.mCaps.compressedTextureFormats.begin(),
mState.mCaps.compressedTextureFormats.end(), params);
break;
case GL_RESET_NOTIFICATION_STRATEGY_EXT:
*params = mResetStrategy;
break;
case GL_NUM_SHADER_BINARY_FORMATS:
*params = static_cast<GLint>(mState.mCaps.shaderBinaryFormats.size());
break;
case GL_SHADER_BINARY_FORMATS:
std::copy(mState.mCaps.shaderBinaryFormats.begin(),
mState.mCaps.shaderBinaryFormats.end(), params);
break;
case GL_NUM_PROGRAM_BINARY_FORMATS:
*params = static_cast<GLint>(mState.mCaps.programBinaryFormats.size());
break;
case GL_PROGRAM_BINARY_FORMATS:
std::copy(mState.mCaps.programBinaryFormats.begin(),
mState.mCaps.programBinaryFormats.end(), params);
break;
case GL_NUM_EXTENSIONS:
*params = static_cast<GLint>(mExtensionStrings.size());
break;
// Desktop client flags
case GL_CONTEXT_FLAGS:
ASSERT(getClientType() == EGL_OPENGL_API);
*params = 0;
break;
case GL_CONTEXT_PROFILE_MASK:
ASSERT(getClientType() == EGL_OPENGL_API);
*params = GL_CONTEXT_COMPATIBILITY_PROFILE_BIT;
break;
// GL_ANGLE_request_extension
case GL_NUM_REQUESTABLE_EXTENSIONS_ANGLE:
*params = static_cast<GLint>(mRequestableExtensionStrings.size());
break;
// GL_KHR_debug
case GL_MAX_DEBUG_MESSAGE_LENGTH:
*params = mState.mExtensions.maxDebugMessageLength;
break;
case GL_MAX_DEBUG_LOGGED_MESSAGES:
*params = mState.mExtensions.maxDebugLoggedMessages;
break;
case GL_MAX_DEBUG_GROUP_STACK_DEPTH:
*params = mState.mExtensions.maxDebugGroupStackDepth;
break;
case GL_MAX_LABEL_LENGTH:
*params = mState.mExtensions.maxLabelLength;
break;
// GL_OVR_multiview2
case GL_MAX_VIEWS_OVR:
*params = mState.mExtensions.maxViews;
break;
// GL_EXT_disjoint_timer_query
case GL_GPU_DISJOINT_EXT:
*params = mImplementation->getGPUDisjoint();
break;
case GL_MAX_FRAMEBUFFER_WIDTH:
*params = mState.mCaps.maxFramebufferWidth;
break;
case GL_MAX_FRAMEBUFFER_HEIGHT:
*params = mState.mCaps.maxFramebufferHeight;
break;
case GL_MAX_FRAMEBUFFER_SAMPLES:
*params = mState.mCaps.maxFramebufferSamples;
break;
case GL_MAX_SAMPLE_MASK_WORDS:
*params = mState.mCaps.maxSampleMaskWords;
break;
case GL_MAX_COLOR_TEXTURE_SAMPLES:
*params = mState.mCaps.maxColorTextureSamples;
break;
case GL_MAX_DEPTH_TEXTURE_SAMPLES:
*params = mState.mCaps.maxDepthTextureSamples;
break;
case GL_MAX_INTEGER_SAMPLES:
*params = mState.mCaps.maxIntegerSamples;
break;
case GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET:
*params = mState.mCaps.maxVertexAttribRelativeOffset;
break;
case GL_MAX_VERTEX_ATTRIB_BINDINGS:
*params = mState.mCaps.maxVertexAttribBindings;
break;
case GL_MAX_VERTEX_ATTRIB_STRIDE:
*params = mState.mCaps.maxVertexAttribStride;
break;
case GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS:
*params = mState.mCaps.maxShaderAtomicCounterBuffers[ShaderType::Vertex];
break;
case GL_MAX_VERTEX_ATOMIC_COUNTERS:
*params = mState.mCaps.maxShaderAtomicCounters[ShaderType::Vertex];
break;
case GL_MAX_VERTEX_IMAGE_UNIFORMS:
*params = mState.mCaps.maxShaderImageUniforms[ShaderType::Vertex];
break;
case GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS:
*params = mState.mCaps.maxShaderStorageBlocks[ShaderType::Vertex];
break;
case GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS:
*params = mState.mCaps.maxShaderAtomicCounterBuffers[ShaderType::Fragment];
break;
case GL_MAX_FRAGMENT_ATOMIC_COUNTERS:
*params = mState.mCaps.maxShaderAtomicCounters[ShaderType::Fragment];
break;
case GL_MAX_FRAGMENT_IMAGE_UNIFORMS:
*params = mState.mCaps.maxShaderImageUniforms[ShaderType::Fragment];
break;
case GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS:
*params = mState.mCaps.maxShaderStorageBlocks[ShaderType::Fragment];
break;
case GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET:
*params = mState.mCaps.minProgramTextureGatherOffset;
break;
case GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET:
*params = mState.mCaps.maxProgramTextureGatherOffset;
break;
case GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS:
*params = mState.mCaps.maxComputeWorkGroupInvocations;
break;
case GL_MAX_COMPUTE_UNIFORM_BLOCKS:
*params = mState.mCaps.maxShaderUniformBlocks[ShaderType::Compute];
break;
case GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS:
*params = mState.mCaps.maxShaderTextureImageUnits[ShaderType::Compute];
break;
case GL_MAX_COMPUTE_SHARED_MEMORY_SIZE:
*params = mState.mCaps.maxComputeSharedMemorySize;
break;
case GL_MAX_COMPUTE_UNIFORM_COMPONENTS:
*params = mState.mCaps.maxShaderUniformComponents[ShaderType::Compute];
break;
case GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS:
*params = mState.mCaps.maxShaderAtomicCounterBuffers[ShaderType::Compute];
break;
case GL_MAX_COMPUTE_ATOMIC_COUNTERS:
*params = mState.mCaps.maxShaderAtomicCounters[ShaderType::Compute];
break;
case GL_MAX_COMPUTE_IMAGE_UNIFORMS:
*params = mState.mCaps.maxShaderImageUniforms[ShaderType::Compute];
break;
case GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS:
*params = static_cast<GLint>(
mState.mCaps.maxCombinedShaderUniformComponents[ShaderType::Compute]);
break;
case GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS:
*params = mState.mCaps.maxShaderStorageBlocks[ShaderType::Compute];
break;
case GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES:
*params = mState.mCaps.maxCombinedShaderOutputResources;
break;
case GL_MAX_UNIFORM_LOCATIONS:
*params = mState.mCaps.maxUniformLocations;
break;
case GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS:
*params = mState.mCaps.maxAtomicCounterBufferBindings;
break;
case GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE:
*params = mState.mCaps.maxAtomicCounterBufferSize;
break;
case GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS:
*params = mState.mCaps.maxCombinedAtomicCounterBuffers;
break;
case GL_MAX_COMBINED_ATOMIC_COUNTERS:
*params = mState.mCaps.maxCombinedAtomicCounters;
break;
case GL_MAX_IMAGE_UNITS:
*params = mState.mCaps.maxImageUnits;
break;
case GL_MAX_COMBINED_IMAGE_UNIFORMS:
*params = mState.mCaps.maxCombinedImageUniforms;
break;
case GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS:
*params = mState.mCaps.maxShaderStorageBufferBindings;
break;
case GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS:
*params = mState.mCaps.maxCombinedShaderStorageBlocks;
break;
case GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT:
*params = mState.mCaps.shaderStorageBufferOffsetAlignment;
break;
// GL_EXT_geometry_shader
case GL_MAX_FRAMEBUFFER_LAYERS_EXT:
*params = mState.mCaps.maxFramebufferLayers;
break;
case GL_LAYER_PROVOKING_VERTEX_EXT:
*params = mState.mCaps.layerProvokingVertex;
break;
case GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT:
*params = mState.mCaps.maxShaderUniformComponents[ShaderType::Geometry];
break;
case GL_MAX_GEOMETRY_UNIFORM_BLOCKS_EXT:
*params = mState.mCaps.maxShaderUniformBlocks[ShaderType::Geometry];
break;
case GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS_EXT:
*params = static_cast<GLint>(
mState.mCaps.maxCombinedShaderUniformComponents[ShaderType::Geometry]);
break;
case GL_MAX_GEOMETRY_INPUT_COMPONENTS_EXT:
*params = mState.mCaps.maxGeometryInputComponents;
break;
case GL_MAX_GEOMETRY_OUTPUT_COMPONENTS_EXT:
*params = mState.mCaps.maxGeometryOutputComponents;
break;
case GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT:
*params = mState.mCaps.maxGeometryOutputVertices;
break;
case GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT:
*params = mState.mCaps.maxGeometryTotalOutputComponents;
break;
case GL_MAX_GEOMETRY_SHADER_INVOCATIONS_EXT:
*params = mState.mCaps.maxGeometryShaderInvocations;
break;
case GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT:
*params = mState.mCaps.maxShaderTextureImageUnits[ShaderType::Geometry];
break;
case GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS_EXT:
*params = mState.mCaps.maxShaderAtomicCounterBuffers[ShaderType::Geometry];
break;
case GL_MAX_GEOMETRY_ATOMIC_COUNTERS_EXT:
*params = mState.mCaps.maxShaderAtomicCounters[ShaderType::Geometry];
break;
case GL_MAX_GEOMETRY_IMAGE_UNIFORMS_EXT:
*params = mState.mCaps.maxShaderImageUniforms[ShaderType::Geometry];
break;
case GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS_EXT:
*params = mState.mCaps.maxShaderStorageBlocks[ShaderType::Geometry];
break;
// GLES1 emulation: Caps queries
case GL_MAX_TEXTURE_UNITS:
*params = mState.mCaps.maxMultitextureUnits;
break;
case GL_MAX_MODELVIEW_STACK_DEPTH:
*params = mState.mCaps.maxModelviewMatrixStackDepth;
break;
case GL_MAX_PROJECTION_STACK_DEPTH:
*params = mState.mCaps.maxProjectionMatrixStackDepth;
break;
case GL_MAX_TEXTURE_STACK_DEPTH:
*params = mState.mCaps.maxTextureMatrixStackDepth;
break;
case GL_MAX_LIGHTS:
*params = mState.mCaps.maxLights;
break;
case GL_MAX_CLIP_PLANES:
*params = mState.mCaps.maxClipPlanes;
break;
// GLES1 emulation: Vertex attribute queries
case GL_VERTEX_ARRAY_BUFFER_BINDING:
case GL_NORMAL_ARRAY_BUFFER_BINDING:
case GL_COLOR_ARRAY_BUFFER_BINDING:
case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES:
case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING:
getVertexAttribiv(static_cast<GLuint>(vertexArrayIndex(ParamToVertexArrayType(pname))),
GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, params);
break;
case GL_VERTEX_ARRAY_STRIDE:
case GL_NORMAL_ARRAY_STRIDE:
case GL_COLOR_ARRAY_STRIDE:
case GL_POINT_SIZE_ARRAY_STRIDE_OES:
case GL_TEXTURE_COORD_ARRAY_STRIDE:
getVertexAttribiv(static_cast<GLuint>(vertexArrayIndex(ParamToVertexArrayType(pname))),
GL_VERTEX_ATTRIB_ARRAY_STRIDE, params);
break;
case GL_VERTEX_ARRAY_SIZE:
case GL_COLOR_ARRAY_SIZE:
case GL_TEXTURE_COORD_ARRAY_SIZE:
getVertexAttribiv(static_cast<GLuint>(vertexArrayIndex(ParamToVertexArrayType(pname))),
GL_VERTEX_ATTRIB_ARRAY_SIZE, params);
break;
case GL_VERTEX_ARRAY_TYPE:
case GL_COLOR_ARRAY_TYPE:
case GL_NORMAL_ARRAY_TYPE:
case GL_POINT_SIZE_ARRAY_TYPE_OES:
case GL_TEXTURE_COORD_ARRAY_TYPE:
getVertexAttribiv(static_cast<GLuint>(vertexArrayIndex(ParamToVertexArrayType(pname))),
GL_VERTEX_ATTRIB_ARRAY_TYPE, params);
break;
// GL_KHR_parallel_shader_compile
case GL_MAX_SHADER_COMPILER_THREADS_KHR:
*params = mState.getMaxShaderCompilerThreads();
break;
// GL_EXT_blend_func_extended
case GL_MAX_DUAL_SOURCE_DRAW_BUFFERS_EXT:
*params = mState.mExtensions.maxDualSourceDrawBuffers;
break;
default:
ANGLE_CONTEXT_TRY(mState.getIntegerv(this, pname, params));
break;
}
}
void Context::getInteger64vImpl(GLenum pname, GLint64 *params)
{
// Queries about context capabilities and maximums are answered by Context.
// Queries about current GL state values are answered by State.
switch (pname)
{
case GL_MAX_ELEMENT_INDEX:
*params = mState.mCaps.maxElementIndex;
break;
case GL_MAX_UNIFORM_BLOCK_SIZE:
*params = mState.mCaps.maxUniformBlockSize;
break;
case GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS:
*params = mState.mCaps.maxCombinedShaderUniformComponents[ShaderType::Vertex];
break;
case GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS:
*params = mState.mCaps.maxCombinedShaderUniformComponents[ShaderType::Fragment];
break;
case GL_MAX_SERVER_WAIT_TIMEOUT:
*params = mState.mCaps.maxServerWaitTimeout;
break;
// GL_EXT_disjoint_timer_query
case GL_TIMESTAMP_EXT:
*params = mImplementation->getTimestamp();
break;
case GL_MAX_SHADER_STORAGE_BLOCK_SIZE:
*params = mState.mCaps.maxShaderStorageBlockSize;
break;
default:
UNREACHABLE();
break;
}
}
void Context::getPointerv(GLenum pname, void **params)
{
mState.getPointerv(this, pname, params);
}
void Context::getPointervRobustANGLERobust(GLenum pname,
GLsizei bufSize,
GLsizei *length,
void **params)
{
UNIMPLEMENTED();
}
void Context::getIntegeri_v(GLenum target, GLuint index, GLint *data)
{
// Queries about context capabilities and maximums are answered by Context.
// Queries about current GL state values are answered by State.
GLenum nativeType;
unsigned int numParams;
bool queryStatus = getIndexedQueryParameterInfo(target, &nativeType, &numParams);
ASSERT(queryStatus);
if (nativeType == GL_INT)
{
switch (target)
{
case GL_MAX_COMPUTE_WORK_GROUP_COUNT:
ASSERT(index < 3u);
*data = mState.mCaps.maxComputeWorkGroupCount[index];
break;
case GL_MAX_COMPUTE_WORK_GROUP_SIZE:
ASSERT(index < 3u);
*data = mState.mCaps.maxComputeWorkGroupSize[index];
break;
default:
mState.getIntegeri_v(target, index, data);
}
}
else
{
CastIndexedStateValues(this, nativeType, target, index, numParams, data);
}
}
void Context::getIntegeri_vRobust(GLenum target,
GLuint index,
GLsizei bufSize,
GLsizei *length,
GLint *data)
{
getIntegeri_v(target, index, data);
}
void Context::getInteger64i_v(GLenum target, GLuint index, GLint64 *data)
{
// Queries about context capabilities and maximums are answered by Context.
// Queries about current GL state values are answered by State.
GLenum nativeType;
unsigned int numParams;
bool queryStatus = getIndexedQueryParameterInfo(target, &nativeType, &numParams);
ASSERT(queryStatus);
if (nativeType == GL_INT_64_ANGLEX)
{
mState.getInteger64i_v(target, index, data);
}
else
{
CastIndexedStateValues(this, nativeType, target, index, numParams, data);
}
}
void Context::getInteger64i_vRobust(GLenum target,
GLuint index,
GLsizei bufSize,
GLsizei *length,
GLint64 *data)
{
getInteger64i_v(target, index, data);
}
void Context::getBooleani_v(GLenum target, GLuint index, GLboolean *data)
{
// Queries about context capabilities and maximums are answered by Context.
// Queries about current GL state values are answered by State.
GLenum nativeType;
unsigned int numParams;
bool queryStatus = getIndexedQueryParameterInfo(target, &nativeType, &numParams);
ASSERT(queryStatus);
if (nativeType == GL_BOOL)
{
mState.getBooleani_v(target, index, data);
}
else
{
CastIndexedStateValues(this, nativeType, target, index, numParams, data);
}
}
void Context::getBooleani_vRobust(GLenum target,
GLuint index,
GLsizei bufSize,
GLsizei *length,
GLboolean *data)
{
getBooleani_v(target, index, data);
}
void Context::getBufferParameteriv(BufferBinding target, GLenum pname, GLint *params)
{
Buffer *buffer = mState.getTargetBuffer(target);
QueryBufferParameteriv(buffer, pname, params);
}
void Context::getBufferParameterivRobust(BufferBinding target,
GLenum pname,
GLsizei bufSize,
GLsizei *length,
GLint *params)
{
getBufferParameteriv(target, pname, params);
}
void Context::getFramebufferAttachmentParameteriv(GLenum target,
GLenum attachment,
GLenum pname,
GLint *params)
{
const Framebuffer *framebuffer = mState.getTargetFramebuffer(target);
QueryFramebufferAttachmentParameteriv(this, framebuffer, attachment, pname, params);
}
void Context::getFramebufferAttachmentParameterivRobust(GLenum target,
GLenum attachment,
GLenum pname,
GLsizei bufSize,
GLsizei *length,
GLint *params)
{
getFramebufferAttachmentParameteriv(target, attachment, pname, params);
}
void Context::getRenderbufferParameteriv(GLenum target, GLenum pname, GLint *params)
{
Renderbuffer *renderbuffer = mState.getCurrentRenderbuffer();
QueryRenderbufferiv(this, renderbuffer, pname, params);
}
void Context::getRenderbufferParameterivRobust(GLenum target,
GLenum pname,
GLsizei bufSize,
GLsizei *length,
GLint *params)
{
getRenderbufferParameteriv(target, pname, params);
}
void Context::texBuffer(GLenum target, GLenum internalformat, BufferID buffer)
{
UNIMPLEMENTED();
}
void Context::texBufferRange(GLenum target,
GLenum internalformat,
BufferID buffer,
GLintptr offset,
GLsizeiptr size)
{
UNIMPLEMENTED();
}
void Context::getTexParameterfv(TextureType target, GLenum pname, GLfloat *params)
{
const Texture *const texture = getTextureByType(target);
QueryTexParameterfv(this, texture, pname, params);
}
void Context::getTexParameterfvRobust(TextureType target,
GLenum pname,
GLsizei bufSize,
GLsizei *length,
GLfloat *params)
{
getTexParameterfv(target, pname, params);
}
void Context::getTexParameteriv(TextureType target, GLenum pname, GLint *params)
{
const Texture *const texture = getTextureByType(target);
QueryTexParameteriv(this, texture, pname, params);
}
void Context::getTexParameterIiv(TextureType target, GLenum pname, GLint *params)
{
const Texture *const texture = getTextureByType(target);
QueryTexParameterIiv(this, texture, pname, params);
}
void Context::getTexParameterIuiv(TextureType target, GLenum pname, GLuint *params)
{
const Texture *const texture = getTextureByType(target);
QueryTexParameterIuiv(this, texture, pname, params);
}
void Context::getTexParameterivRobust(TextureType target,
GLenum pname,
GLsizei bufSize,
GLsizei *length,
GLint *params)
{
getTexParameteriv(target, pname, params);
}
void Context::getTexParameterIivRobust(TextureType target,
GLenum pname,
GLsizei bufSize,
GLsizei *length,
GLint *params)
{
UNIMPLEMENTED();
}
void Context::getTexParameterIuivRobust(TextureType target,
GLenum pname,
GLsizei bufSize,
GLsizei *length,
GLuint *params)
{
UNIMPLEMENTED();
}
void Context::getTexLevelParameteriv(TextureTarget target, GLint level, GLenum pname, GLint *params)
{
Texture *texture = getTextureByTarget(target);
QueryTexLevelParameteriv(texture, target, level, pname, params);
}
void Context::getTexLevelParameterivRobust(TextureTarget target,
GLint level,
GLenum pname,
GLsizei bufSize,
GLsizei *length,
GLint *params)
{
UNIMPLEMENTED();
}
void Context::getTexLevelParameterfv(TextureTarget target,
GLint level,
GLenum pname,
GLfloat *params)
{
Texture *texture = getTextureByTarget(target);
QueryTexLevelParameterfv(texture, target, level, pname, params);
}
void Context::getTexLevelParameterfvRobust(TextureTarget target,
GLint level,
GLenum pname,
GLsizei bufSize,
GLsizei *length,
GLfloat *params)
{
UNIMPLEMENTED();
}
void Context::texParameterf(TextureType target, GLenum pname, GLfloat param)
{
Texture *const texture = getTextureByType(target);
SetTexParameterf(this, texture, pname, param);
}
void Context::texParameterfv(TextureType target, GLenum pname, const GLfloat *params)
{
Texture *const texture = getTextureByType(target);
SetTexParameterfv(this, texture, pname, params);
}
void Context::texParameterfvRobust(TextureType target,
GLenum pname,
GLsizei bufSize,
const GLfloat *params)
{
texParameterfv(target, pname, params);
}
void Context::texParameteri(TextureType target, GLenum pname, GLint param)
{
Texture *const texture = getTextureByType(target);
SetTexParameteri(this, texture, pname, param);
}
void Context::texParameteriv(TextureType target, GLenum pname, const GLint *params)
{
Texture *const texture = getTextureByType(target);
SetTexParameteriv(this, texture, pname, params);
}
void Context::texParameterIiv(TextureType target, GLenum pname, const GLint *params)
{
Texture *const texture = getTextureByType(target);
SetTexParameterIiv(this, texture, pname, params);
}
void Context::texParameterIuiv(TextureType target, GLenum pname, const GLuint *params)
{
Texture *const texture = getTextureByType(target);
SetTexParameterIuiv(this, texture, pname, params);
}
void Context::texParameterivRobust(TextureType target,
GLenum pname,
GLsizei bufSize,
const GLint *params)
{
texParameteriv(target, pname, params);
}
void Context::texParameterIivRobust(TextureType target,
GLenum pname,
GLsizei bufSize,
const GLint *params)
{
UNIMPLEMENTED();
}
void Context::texParameterIuivRobust(TextureType target,
GLenum pname,
GLsizei bufSize,
const GLuint *params)
{
UNIMPLEMENTED();
}
void Context::drawArraysInstanced(PrimitiveMode mode,
GLint first,
GLsizei count,
GLsizei instanceCount)
{
// No-op if count draws no primitives for given mode
if (noopDrawInstanced(mode, count, instanceCount))
{
return;
}
ANGLE_CONTEXT_TRY(prepareForDraw(mode));
ANGLE_CONTEXT_TRY(
mImplementation->drawArraysInstanced(this, mode, first, count, instanceCount));
MarkTransformFeedbackBufferUsage(this, count, instanceCount);
MarkShaderStorageBufferUsage(this);
}
void Context::drawElementsInstanced(PrimitiveMode mode,
GLsizei count,
DrawElementsType type,
const void *indices,
GLsizei instances)
{
// No-op if count draws no primitives for given mode
if (noopDrawInstanced(mode, count, instances))
{
return;
}
ANGLE_CONTEXT_TRY(prepareForDraw(mode));
ANGLE_CONTEXT_TRY(
mImplementation->drawElementsInstanced(this, mode, count, type, indices, instances));
MarkShaderStorageBufferUsage(this);
}
void Context::drawElementsBaseVertex(PrimitiveMode mode,
GLsizei count,
DrawElementsType type,
const void *indices,
GLint basevertex)
{
// No-op if count draws no primitives for given mode
if (noopDraw(mode, count))
{
return;
}
ANGLE_CONTEXT_TRY(prepareForDraw(mode));
ANGLE_CONTEXT_TRY(
mImplementation->drawElementsBaseVertex(this, mode, count, type, indices, basevertex));
MarkShaderStorageBufferUsage(this);
}
void Context::drawElementsInstancedBaseVertex(PrimitiveMode mode,
GLsizei count,
DrawElementsType type,
const void *indices,
GLsizei instancecount,
GLint basevertex)
{
// No-op if count draws no primitives for given mode
if (noopDrawInstanced(mode, count, instancecount))
{
return;
}
ANGLE_CONTEXT_TRY(prepareForDraw(mode));
ANGLE_CONTEXT_TRY(mImplementation->drawElementsInstancedBaseVertex(
this, mode, count, type, indices, instancecount, basevertex));
MarkShaderStorageBufferUsage(this);
}
void Context::drawRangeElements(PrimitiveMode mode,
GLuint start,
GLuint end,
GLsizei count,
DrawElementsType type,
const void *indices)
{
// No-op if count draws no primitives for given mode
if (noopDraw(mode, count))
{
return;
}
ANGLE_CONTEXT_TRY(prepareForDraw(mode));
ANGLE_CONTEXT_TRY(
mImplementation->drawRangeElements(this, mode, start, end, count, type, indices));
MarkShaderStorageBufferUsage(this);
}
void Context::drawRangeElementsBaseVertex(PrimitiveMode mode,
GLuint start,
GLuint end,
GLsizei count,
DrawElementsType type,
const void *indices,
GLint basevertex)
{
// No-op if count draws no primitives for given mode
if (noopDraw(mode, count))
{
return;
}
ANGLE_CONTEXT_TRY(prepareForDraw(mode));
ANGLE_CONTEXT_TRY(mImplementation->drawRangeElementsBaseVertex(this, mode, start, end, count,
type, indices, basevertex));
MarkShaderStorageBufferUsage(this);
}
void Context::drawArraysIndirect(PrimitiveMode mode, const void *indirect)
{
ANGLE_CONTEXT_TRY(prepareForDraw(mode));
ANGLE_CONTEXT_TRY(mImplementation->drawArraysIndirect(this, mode, indirect));
MarkShaderStorageBufferUsage(this);
}
void Context::drawElementsIndirect(PrimitiveMode mode, DrawElementsType type, const void *indirect)
{
ANGLE_CONTEXT_TRY(prepareForDraw(mode));
ANGLE_CONTEXT_TRY(mImplementation->drawElementsIndirect(this, mode, type, indirect));
MarkShaderStorageBufferUsage(this);
}
void Context::flush()
{
ANGLE_CONTEXT_TRY(mImplementation->flush(this));
}
void Context::finish()
{
ANGLE_CONTEXT_TRY(mImplementation->finish(this));
}
void Context::insertEventMarker(GLsizei length, const char *marker)
{
ASSERT(mImplementation);
mImplementation->insertEventMarker(length, marker);
}
void Context::pushGroupMarker(GLsizei length, const char *marker)
{
ASSERT(mImplementation);
if (marker == nullptr)
{
// From the EXT_debug_marker spec,
// "If <marker> is null then an empty string is pushed on the stack."
mImplementation->pushGroupMarker(length, "");
}
else
{
mImplementation->pushGroupMarker(length, marker);
}
}
void Context::popGroupMarker()
{
ASSERT(mImplementation);
mImplementation->popGroupMarker();
}
void Context::bindUniformLocation(ShaderProgramID program, GLint location, const GLchar *name)
{
Program *programObject = getProgramResolveLink(program);
ASSERT(programObject);
programObject->bindUniformLocation(location, name);
}
void Context::coverageModulation(GLenum components)
{
mState.setCoverageModulation(components);
}
void Context::matrixLoadf(GLenum matrixMode, const GLfloat *matrix)
{
mState.loadPathRenderingMatrix(matrixMode, matrix);
}
void Context::matrixLoadIdentity(GLenum matrixMode)
{
GLfloat I[16];
angle::Matrix<GLfloat>::setToIdentity(I);
mState.loadPathRenderingMatrix(matrixMode, I);
}
void Context::stencilFillPath(PathID path, GLenum fillMode, GLuint mask)
{
const auto *pathObj = mState.mPathManager->getPath(path);
if (!pathObj)
return;
ANGLE_CONTEXT_TRY(syncStateForPathOperation());
mImplementation->stencilFillPath(pathObj, fillMode, mask);
}
void Context::stencilStrokePath(PathID path, GLint reference, GLuint mask)
{
const auto *pathObj = mState.mPathManager->getPath(path);
if (!pathObj)
return;
ANGLE_CONTEXT_TRY(syncStateForPathOperation());
mImplementation->stencilStrokePath(pathObj, reference, mask);
}
void Context::coverFillPath(PathID path, GLenum coverMode)
{
const auto *pathObj = mState.mPathManager->getPath(path);
if (!pathObj)
return;
ANGLE_CONTEXT_TRY(syncStateForPathOperation());
mImplementation->coverFillPath(pathObj, coverMode);
}
void Context::coverStrokePath(PathID path, GLenum coverMode)
{
const auto *pathObj = mState.mPathManager->getPath(path);
if (!pathObj)
return;
ANGLE_CONTEXT_TRY(syncStateForPathOperation());
mImplementation->coverStrokePath(pathObj, coverMode);
}
void Context::stencilThenCoverFillPath(PathID path, GLenum fillMode, GLuint mask, GLenum coverMode)
{
const auto *pathObj = mState.mPathManager->getPath(path);
if (!pathObj)
return;
ANGLE_CONTEXT_TRY(syncStateForPathOperation());
mImplementation->stencilThenCoverFillPath(pathObj, fillMode, mask, coverMode);
}
void Context::stencilThenCoverStrokePath(PathID path,
GLint reference,
GLuint mask,
GLenum coverMode)
{
const auto *pathObj = mState.mPathManager->getPath(path);
if (!pathObj)
return;
ANGLE_CONTEXT_TRY(syncStateForPathOperation());
mImplementation->stencilThenCoverStrokePath(pathObj, reference, mask, coverMode);
}
void Context::coverFillPathInstanced(GLsizei numPaths,
GLenum pathNameType,
const void *paths,
PathID pathBase,
GLenum coverMode,
GLenum transformType,
const GLfloat *transformValues)
{
const auto &pathObjects =
GatherPaths(*mState.mPathManager, numPaths, pathNameType, paths, pathBase);
ANGLE_CONTEXT_TRY(syncStateForPathOperation());
mImplementation->coverFillPathInstanced(pathObjects, coverMode, transformType, transformValues);
}
void Context::coverStrokePathInstanced(GLsizei numPaths,
GLenum pathNameType,
const void *paths,
PathID pathBase,
GLenum coverMode,
GLenum transformType,
const GLfloat *transformValues)
{
const auto &pathObjects =
GatherPaths(*mState.mPathManager, numPaths, pathNameType, paths, pathBase);
// TODO(svaisanen@nvidia.com): maybe sync only state required for path rendering?
ANGLE_CONTEXT_TRY(syncStateForPathOperation());
mImplementation->coverStrokePathInstanced(pathObjects, coverMode, transformType,
transformValues);
}
void Context::stencilFillPathInstanced(GLsizei numPaths,
GLenum pathNameType,
const void *paths,
PathID pathBase,
GLenum fillMode,
GLuint mask,
GLenum transformType,
const GLfloat *transformValues)
{
const auto &pathObjects =
GatherPaths(*mState.mPathManager, numPaths, pathNameType, paths, pathBase);
// TODO(svaisanen@nvidia.com): maybe sync only state required for path rendering?
ANGLE_CONTEXT_TRY(syncStateForPathOperation());
mImplementation->stencilFillPathInstanced(pathObjects, fillMode, mask, transformType,
transformValues);
}
void Context::stencilStrokePathInstanced(GLsizei numPaths,
GLenum pathNameType,
const void *paths,
PathID pathBase,
GLint reference,
GLuint mask,
GLenum transformType,
const GLfloat *transformValues)
{
const auto &pathObjects =
GatherPaths(*mState.mPathManager, numPaths, pathNameType, paths, pathBase);
ANGLE_CONTEXT_TRY(syncStateForPathOperation());
mImplementation->stencilStrokePathInstanced(pathObjects, reference, mask, transformType,
transformValues);
}
void Context::stencilThenCoverFillPathInstanced(GLsizei numPaths,
GLenum pathNameType,
const void *paths,
PathID pathBase,
GLenum fillMode,
GLuint mask,
GLenum coverMode,
GLenum transformType,
const GLfloat *transformValues)
{
const auto &pathObjects =
GatherPaths(*mState.mPathManager, numPaths, pathNameType, paths, pathBase);
ANGLE_CONTEXT_TRY(syncStateForPathOperation());
mImplementation->stencilThenCoverFillPathInstanced(pathObjects, coverMode, fillMode, mask,
transformType, transformValues);
}
void Context::stencilThenCoverStrokePathInstanced(GLsizei numPaths,
GLenum pathNameType,
const void *paths,
PathID pathBase,
GLint reference,
GLuint mask,
GLenum coverMode,
GLenum transformType,
const GLfloat *transformValues)
{
const auto &pathObjects =
GatherPaths(*mState.mPathManager, numPaths, pathNameType, paths, pathBase);
ANGLE_CONTEXT_TRY(syncStateForPathOperation());
mImplementation->stencilThenCoverStrokePathInstanced(pathObjects, coverMode, reference, mask,
transformType, transformValues);
}
void Context::bindFragmentInputLocation(ShaderProgramID program, GLint location, const GLchar *name)
{
auto *programObject = getProgramResolveLink(program);
programObject->bindFragmentInputLocation(location, name);
}
void Context::programPathFragmentInputGen(ShaderProgramID program,
GLint location,
GLenum genMode,
GLint components,
const GLfloat *coeffs)
{
auto *programObject = getProgramResolveLink(program);
programObject->pathFragmentInputGen(location, genMode, components, coeffs);
}
GLuint Context::getProgramResourceIndex(ShaderProgramID program,
GLenum programInterface,
const GLchar *name)
{
const Program *programObject = getProgramResolveLink(program);
return QueryProgramResourceIndex(programObject, programInterface, name);
}
void Context::getProgramResourceName(ShaderProgramID program,
GLenum programInterface,
GLuint index,
GLsizei bufSize,
GLsizei *length,
GLchar *name)
{
const Program *programObject = getProgramResolveLink(program);
QueryProgramResourceName(programObject, programInterface, index, bufSize, length, name);
}
GLint Context::getProgramResourceLocation(ShaderProgramID program,
GLenum programInterface,
const GLchar *name)
{
const Program *programObject = getProgramResolveLink(program);
return QueryProgramResourceLocation(programObject, programInterface, name);
}
void Context::getProgramResourceiv(ShaderProgramID program,
GLenum programInterface,
GLuint index,
GLsizei propCount,
const GLenum *props,
GLsizei bufSize,
GLsizei *length,
GLint *params)
{
const Program *programObject = getProgramResolveLink(program);
QueryProgramResourceiv(programObject, programInterface, index, propCount, props, bufSize,
length, params);
}
void Context::getProgramInterfaceiv(ShaderProgramID program,
GLenum programInterface,
GLenum pname,
GLint *params)
{
const Program *programObject = getProgramResolveLink(program);
QueryProgramInterfaceiv(programObject, programInterface, pname, params);
}
void Context::getProgramInterfaceivRobust(ShaderProgramID program,
GLenum programInterface,
GLenum pname,
GLsizei bufSize,
GLsizei *length,
GLint *params)
{
UNIMPLEMENTED();
}
void Context::handleError(GLenum errorCode,
const char *message,
const char *file,
const char *function,
unsigned int line)
{
mErrors.handleError(errorCode, message, file, function, line);
}
void Context::validationError(GLenum errorCode, const char *message)
{
mErrors.validationError(errorCode, message);
}
// Get one of the recorded errors and clear its flag, if any.
// [OpenGL ES 2.0.24] section 2.5 page 13.
GLenum Context::getError()
{
if (mErrors.empty())
{
return GL_NO_ERROR;
}
else
{
return mErrors.popError();
}
}
// NOTE: this function should not assume that this context is current!
void Context::markContextLost(GraphicsResetStatus status)
{
ASSERT(status != GraphicsResetStatus::NoError);
if (mResetStrategy == GL_LOSE_CONTEXT_ON_RESET_EXT)
{
mResetStatus = status;
mContextLostForced = true;
}
mContextLost = true;
}
GLenum Context::getGraphicsResetStatus()
{
// Even if the application doesn't want to know about resets, we want to know
// as it will allow us to skip all the calls.
if (mResetStrategy == GL_NO_RESET_NOTIFICATION_EXT)
{
if (!mContextLost && mImplementation->getResetStatus() != GraphicsResetStatus::NoError)
{
mContextLost = true;
}
// EXT_robustness, section 2.6: If the reset notification behavior is
// NO_RESET_NOTIFICATION_EXT, then the implementation will never deliver notification of
// reset events, and GetGraphicsResetStatusEXT will always return NO_ERROR.
return GL_NO_ERROR;
}
// The GL_EXT_robustness spec says that if a reset is encountered, a reset
// status should be returned at least once, and GL_NO_ERROR should be returned
// once the device has finished resetting.
if (!mContextLost)
{
ASSERT(mResetStatus == GraphicsResetStatus::NoError);
mResetStatus = mImplementation->getResetStatus();
if (mResetStatus != GraphicsResetStatus::NoError)
{
mContextLost = true;
}
}
else if (!mContextLostForced && mResetStatus != GraphicsResetStatus::NoError)
{
// 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();
}
return ToGLenum(mResetStatus);
}
bool Context::isResetNotificationEnabled()
{
return (mResetStrategy == GL_LOSE_CONTEXT_ON_RESET_EXT);
}
const egl::Config *Context::getConfig() const
{
return mConfig;
}
EGLenum Context::getClientType() const
{
return mState.getClientType();
}
EGLenum Context::getRenderBuffer() const
{
const Framebuffer *framebuffer =
mState.mFramebufferManager->getFramebuffer(Framebuffer::kDefaultDrawFramebufferHandle);
if (framebuffer == nullptr)
{
return EGL_NONE;
}
const FramebufferAttachment *backAttachment = framebuffer->getAttachment(this, GL_BACK);
ASSERT(backAttachment != nullptr);
return backAttachment->getSurface()->getRenderBuffer();
}
VertexArray *Context::checkVertexArrayAllocation(VertexArrayID vertexArrayHandle)
{
// Only called after a prior call to Gen.
VertexArray *vertexArray = getVertexArray(vertexArrayHandle);
if (!vertexArray)
{
vertexArray =
new VertexArray(mImplementation.get(), vertexArrayHandle,
mState.mCaps.maxVertexAttributes, mState.mCaps.maxVertexAttribBindings);
vertexArray->setBufferAccessValidationEnabled(mBufferAccessValidationEnabled);
mVertexArrayMap.assign(vertexArrayHandle, vertexArray);
}
return vertexArray;
}
TransformFeedback *Context::checkTransformFeedbackAllocation(
TransformFeedbackID transformFeedbackHandle)
{
// Only called after a prior call to Gen.
TransformFeedback *transformFeedback = getTransformFeedback(transformFeedbackHandle);
if (!transformFeedback)
{
transformFeedback =
new TransformFeedback(mImplementation.get(), transformFeedbackHandle, mState.mCaps);
transformFeedback->addRef();
mTransformFeedbackMap.assign(transformFeedbackHandle, transformFeedback);
}
return transformFeedback;
}
bool Context::isVertexArrayGenerated(VertexArrayID vertexArray)
{
ASSERT(mVertexArrayMap.contains({0}));
return mVertexArrayMap.contains(vertexArray);
}
bool Context::isTransformFeedbackGenerated(TransformFeedbackID transformFeedback)
{
ASSERT(mTransformFeedbackMap.contains({0}));
return mTransformFeedbackMap.contains(transformFeedback);
}
void Context::detachTexture(TextureID texture)
{
// The State cannot unbind image observers itself, they are owned by the Context
Texture *tex = mState.mTextureManager->getTexture(texture);
for (auto &imageBinding : mImageObserverBindings)
{
if (imageBinding.getSubject() == tex)
{
imageBinding.reset();
}
}
// Simple pass-through to State's detachTexture method, as textures do not require
// allocation map management either here or in the resource manager at detach time.
// Zero textures are held by the Context, and we don't attempt to request them from
// the State.
mState.detachTexture(this, mZeroTextures, texture);
}
void Context::detachBuffer(Buffer *buffer)
{
// Simple pass-through to State's detachBuffer method, since
// only buffer attachments to container objects that are bound to the current context
// should be detached. And all those are available in State.
// [OpenGL ES 3.2] section 5.1.2 page 45:
// Attachments to unbound container objects, such as
// deletion of a buffer attached to a vertex array object which is not bound to the context,
// are not affected and continue to act as references on the deleted object
ANGLE_CONTEXT_TRY(mState.detachBuffer(this, buffer));
}
void Context::detachFramebuffer(FramebufferID framebuffer)
{
// Framebuffer detachment is handled by Context, because 0 is a valid
// Framebuffer object, and a pointer to it must be passed from Context
// to State at binding time.
// [OpenGL ES 2.0.24] section 4.4 page 107:
// If a framebuffer that is currently bound to the target FRAMEBUFFER is deleted, it is as
// though BindFramebuffer had been executed with the target of FRAMEBUFFER and framebuffer of
// zero.
if (mState.removeReadFramebufferBinding(framebuffer) && framebuffer.value != 0)
{
bindReadFramebuffer({0});
}
if (mState.removeDrawFramebufferBinding(framebuffer) && framebuffer.value != 0)
{
bindDrawFramebuffer({0});
}
}
void Context::detachRenderbuffer(RenderbufferID renderbuffer)
{
mState.detachRenderbuffer(this, renderbuffer);
}
void Context::detachVertexArray(VertexArrayID vertexArray)
{
// Vertex array detachment is handled by Context, because 0 is a valid
// VAO, and a pointer to it must be passed from Context to State at
// binding time.
// [OpenGL ES 3.0.2] section 2.10 page 43:
// If a vertex array object that is currently bound is deleted, the binding
// for that object reverts to zero and the default vertex array becomes current.
if (mState.removeVertexArrayBinding(this, vertexArray))
{
bindVertexArray({0});
}
}
void Context::detachTransformFeedback(TransformFeedbackID transformFeedback)
{
// Transform feedback detachment is handled by Context, because 0 is a valid
// transform feedback, and a pointer to it must be passed from Context to State at
// binding time.
// The OpenGL specification doesn't mention what should happen when the currently bound
// transform feedback object is deleted. Since it is a container object, we treat it like
// VAOs and FBOs and set the current bound transform feedback back to 0.
if (mState.removeTransformFeedbackBinding(this, transformFeedback))
{
bindTransformFeedback(GL_TRANSFORM_FEEDBACK, {0});
}
}
void Context::detachSampler(SamplerID sampler)
{
mState.detachSampler(this, sampler);
}
void Context::detachProgramPipeline(ProgramPipelineID pipeline)
{
mState.detachProgramPipeline(this, pipeline);
}
void Context::vertexAttribDivisor(GLuint index, GLuint divisor)
{
mState.setVertexAttribDivisor(this, index, divisor);
mStateCache.onVertexArrayStateChange(this);
}
void Context::samplerParameteri(SamplerID sampler, GLenum pname, GLint param)
{
Sampler *const samplerObject =
mState.mSamplerManager->checkSamplerAllocation(mImplementation.get(), sampler);
SetSamplerParameteri(this, samplerObject, pname, param);
}
void Context::samplerParameteriv(SamplerID sampler, GLenum pname, const GLint *param)
{
Sampler *const samplerObject =
mState.mSamplerManager->checkSamplerAllocation(mImplementation.get(), sampler);
SetSamplerParameteriv(this, samplerObject, pname, param);
}
void Context::samplerParameterIiv(SamplerID sampler, GLenum pname, const GLint *param)
{
Sampler *const samplerObject =
mState.mSamplerManager->checkSamplerAllocation(mImplementation.get(), sampler);
SetSamplerParameterIiv(this, samplerObject, pname, param);
}