#include "libANGLE/renderer/gl/StateManagerGL.h"
#include <string.h>
#include <algorithm>
#include <limits>
#include "anglebase/numerics/safe_conversions.h"
#include "common/bitset_utils.h"
#include "common/mathutil.h"
#include "common/matrix_utils.h"
#include "libANGLE/Context.h"
#include "libANGLE/Framebuffer.h"
#include "libANGLE/Query.h"
#include "libANGLE/TransformFeedback.h"
#include "libANGLE/VertexArray.h"
#include "libANGLE/histogram_macros.h"
#include "libANGLE/renderer/gl/BufferGL.h"
#include "libANGLE/renderer/gl/FramebufferGL.h"
#include "libANGLE/renderer/gl/FunctionsGL.h"
#include "libANGLE/renderer/gl/ProgramGL.h"
#include "libANGLE/renderer/gl/QueryGL.h"
#include "libANGLE/renderer/gl/SamplerGL.h"
#include "libANGLE/renderer/gl/TextureGL.h"
#include "libANGLE/renderer/gl/TransformFeedbackGL.h"
#include "libANGLE/renderer/gl/VertexArrayGL.h"
#include "platform/PlatformMethods.h"
namespace rx
{
namespace
{
static void ValidateStateHelper(const FunctionsGL *functions,
const GLuint localValue,
const GLenum pname,
const char *localName,
const char *driverName)
{ … }
}
VertexArrayStateGL::VertexArrayStateGL(size_t maxAttribs, size_t maxBindings)
: … { … }
StateManagerGL::IndexedBufferBinding::IndexedBufferBinding() : … { … }
StateManagerGL::StateManagerGL(const FunctionsGL *functions,
const gl::Caps &rendererCaps,
const gl::Extensions &extensions,
const angle::FeaturesGL &features)
: … { … }
StateManagerGL::~StateManagerGL()
{ … }
void StateManagerGL::deleteProgram(GLuint program)
{ … }
void StateManagerGL::deleteVertexArray(GLuint vao)
{ … }
void StateManagerGL::deleteTexture(GLuint texture)
{ … }
void StateManagerGL::deleteSampler(GLuint sampler)
{ … }
void StateManagerGL::deleteBuffer(GLuint buffer)
{ … }
void StateManagerGL::deleteFramebuffer(GLuint fbo)
{ … }
void StateManagerGL::deleteRenderbuffer(GLuint rbo)
{ … }
void StateManagerGL::deleteTransformFeedback(GLuint transformFeedback)
{ … }
void StateManagerGL::useProgram(GLuint program)
{ … }
void StateManagerGL::forceUseProgram(GLuint program)
{ … }
void StateManagerGL::bindVertexArray(GLuint vao, VertexArrayStateGL *vaoState)
{ … }
void StateManagerGL::forceBindVertexArray(GLuint vao, VertexArrayStateGL *vaoState)
{ … }
void StateManagerGL::bindBuffer(gl::BufferBinding target, GLuint buffer)
{ … }
void StateManagerGL::bindBufferBase(gl::BufferBinding target, size_t index, GLuint buffer)
{ … }
void StateManagerGL::bindBufferRange(gl::BufferBinding target,
size_t index,
GLuint buffer,
size_t offset,
size_t size)
{ … }
void StateManagerGL::activeTexture(size_t unit)
{ … }
void StateManagerGL::bindTexture(gl::TextureType type, GLuint texture)
{ … }
void StateManagerGL::invalidateTexture(gl::TextureType type)
{ … }
void StateManagerGL::bindSampler(size_t unit, GLuint sampler)
{ … }
void StateManagerGL::bindImageTexture(size_t unit,
GLuint texture,
GLint level,
GLboolean layered,
GLint layer,
GLenum access,
GLenum format)
{ … }
angle::Result StateManagerGL::setPixelUnpackState(const gl::Context *context,
const gl::PixelUnpackState &unpack)
{ … }
angle::Result StateManagerGL::setPixelUnpackBuffer(const gl::Context *context,
const gl::Buffer *pixelBuffer)
{ … }
angle::Result StateManagerGL::setPixelPackState(const gl::Context *context,
const gl::PixelPackState &pack)
{ … }
angle::Result StateManagerGL::setPixelPackBuffer(const gl::Context *context,
const gl::Buffer *pixelBuffer)
{ … }
void StateManagerGL::bindFramebuffer(GLenum type, GLuint framebuffer)
{ … }
void StateManagerGL::bindRenderbuffer(GLenum type, GLuint renderbuffer)
{ … }
void StateManagerGL::bindTransformFeedback(GLenum type, GLuint transformFeedback)
{ … }
void StateManagerGL::onTransformFeedbackStateChange()
{ … }
void StateManagerGL::beginQuery(gl::QueryType type, QueryGL *queryObject, GLuint queryId)
{ … }
void StateManagerGL::endQuery(gl::QueryType type, QueryGL *queryObject, GLuint queryId)
{ … }
void StateManagerGL::updateDrawIndirectBufferBinding(const gl::Context *context)
{ … }
void StateManagerGL::updateDispatchIndirectBufferBinding(const gl::Context *context)
{ … }
void StateManagerGL::pauseTransformFeedback()
{ … }
angle::Result StateManagerGL::pauseAllQueries(const gl::Context *context)
{ … }
angle::Result StateManagerGL::pauseQuery(const gl::Context *context, gl::QueryType type)
{ … }
angle::Result StateManagerGL::resumeAllQueries(const gl::Context *context)
{ … }
angle::Result StateManagerGL::resumeQuery(const gl::Context *context, gl::QueryType type)
{ … }
angle::Result StateManagerGL::onMakeCurrent(const gl::Context *context)
{ … }
void StateManagerGL::updateProgramTextureBindings(const gl::Context *context)
{ … }
void StateManagerGL::updateProgramStorageBufferBindings(const gl::Context *context)
{ … }
void StateManagerGL::updateProgramUniformBufferBindings(const gl::Context *context)
{ … }
void StateManagerGL::updateProgramAtomicCounterBufferBindings(const gl::Context *context)
{ … }
void StateManagerGL::updateProgramImageBindings(const gl::Context *context)
{ … }
void StateManagerGL::setAttributeCurrentData(size_t index,
const gl::VertexAttribCurrentValueData &data)
{ … }
void StateManagerGL::setScissorTestEnabled(bool enabled)
{ … }
void StateManagerGL::setScissor(const gl::Rectangle &scissor)
{ … }
void StateManagerGL::setViewport(const gl::Rectangle &viewport)
{ … }
void StateManagerGL::setDepthRange(float near, float far)
{ … }
void StateManagerGL::setClipControl(gl::ClipOrigin origin, gl::ClipDepthMode depth)
{ … }
void StateManagerGL::setClipControlWithEmulatedClipOrigin(const gl::ProgramExecutable *executable,
GLenum frontFace,
gl::ClipOrigin origin,
gl::ClipDepthMode depth)
{ … }
void StateManagerGL::setBlendEnabled(bool enabled)
{ … }
void StateManagerGL::setBlendEnabledIndexed(const gl::DrawBufferMask enabledMask)
{ … }
void StateManagerGL::setBlendColor(const gl::ColorF &blendColor)
{ … }
void StateManagerGL::setBlendAdvancedCoherent(bool enabled)
{ … }
void StateManagerGL::setBlendFuncs(const gl::BlendStateExt &blendStateExt)
{ … }
void StateManagerGL::setBlendEquations(const gl::BlendStateExt &blendStateExt)
{ … }
void StateManagerGL::setColorMask(bool red, bool green, bool blue, bool alpha)
{ … }
void StateManagerGL::setSampleAlphaToCoverageEnabled(bool enabled)
{ … }
void StateManagerGL::setSampleCoverageEnabled(bool enabled)
{ … }
void StateManagerGL::setSampleCoverage(float value, bool invert)
{ … }
void StateManagerGL::setSampleMaskEnabled(bool enabled)
{ … }
void StateManagerGL::setSampleMaski(GLuint maskNumber, GLbitfield mask)
{ … }
void StateManagerGL::setDepthTestEnabled(bool enabled)
{ … }
void StateManagerGL::setDepthFunc(GLenum depthFunc)
{ … }
void StateManagerGL::setDepthMask(bool mask)
{ … }
void StateManagerGL::setStencilTestEnabled(bool enabled)
{ … }
void StateManagerGL::setStencilFrontWritemask(GLuint mask)
{ … }
void StateManagerGL::setStencilBackWritemask(GLuint mask)
{ … }
void StateManagerGL::setStencilFrontFuncs(GLenum func, GLint ref, GLuint mask)
{ … }
void StateManagerGL::setStencilBackFuncs(GLenum func, GLint ref, GLuint mask)
{ … }
void StateManagerGL::setStencilFrontOps(GLenum sfail, GLenum dpfail, GLenum dppass)
{ … }
void StateManagerGL::setStencilBackOps(GLenum sfail, GLenum dpfail, GLenum dppass)
{ … }
void StateManagerGL::setCullFaceEnabled(bool enabled)
{ … }
void StateManagerGL::setCullFace(gl::CullFaceMode cullFace)
{ … }
void StateManagerGL::setFrontFace(GLenum frontFace)
{ … }
void StateManagerGL::setPolygonMode(gl::PolygonMode mode)
{ … }
void StateManagerGL::setPolygonOffsetPointEnabled(bool enabled)
{ … }
void StateManagerGL::setPolygonOffsetLineEnabled(bool enabled)
{ … }
void StateManagerGL::setPolygonOffsetFillEnabled(bool enabled)
{ … }
void StateManagerGL::setPolygonOffset(float factor, float units, float clamp)
{ … }
void StateManagerGL::setDepthClampEnabled(bool enabled)
{ … }
void StateManagerGL::setRasterizerDiscardEnabled(bool enabled)
{ … }
void StateManagerGL::setLineWidth(float width)
{ … }
angle::Result StateManagerGL::setPrimitiveRestartEnabled(const gl::Context *context, bool enabled)
{ … }
angle::Result StateManagerGL::setPrimitiveRestartIndex(const gl::Context *context, GLuint index)
{ … }
void StateManagerGL::setClearDepth(float clearDepth)
{ … }
void StateManagerGL::setClearColor(const gl::ColorF &clearColor)
{ … }
void StateManagerGL::setClearStencil(GLint clearStencil)
{ … }
angle::Result StateManagerGL::syncState(const gl::Context *context,
const gl::state::DirtyBits &glDirtyBits,
const gl::state::DirtyBits &bitMask,
const gl::state::ExtendedDirtyBits &extendedDirtyBits,
const gl::state::ExtendedDirtyBits &extendedBitMask)
{ … }
void StateManagerGL::setFramebufferSRGBEnabled(const gl::Context *context, bool enabled)
{ … }
void StateManagerGL::setFramebufferSRGBEnabledForFramebuffer(const gl::Context *context,
bool enabled,
const FramebufferGL *framebuffer)
{ … }
void StateManagerGL::setColorMaskForFramebuffer(const gl::BlendStateExt &blendStateExt,
const bool disableAlpha)
{ … }
void StateManagerGL::setDitherEnabled(bool enabled)
{ … }
void StateManagerGL::setMultisamplingStateEnabled(bool enabled)
{ … }
void StateManagerGL::setSampleAlphaToOneStateEnabled(bool enabled)
{ … }
void StateManagerGL::setCoverageModulation(GLenum components)
{ … }
void StateManagerGL::setProvokingVertex(GLenum mode)
{ … }
void StateManagerGL::setClipDistancesEnable(const gl::ClipDistanceEnableBits &enables)
{ … }
void StateManagerGL::setLogicOpEnabled(bool enabled)
{ … }
void StateManagerGL::setLogicOp(gl::LogicalOperation opcode)
{ … }
void StateManagerGL::setTextureCubemapSeamlessEnabled(bool enabled)
{ … }
angle::Result StateManagerGL::propagateProgramToVAO(const gl::Context *context,
const gl::ProgramExecutable *executable,
VertexArrayGL *vao)
{ … }
void StateManagerGL::updateMultiviewBaseViewLayerIndexUniformImpl(
const gl::ProgramExecutable *executable,
const gl::FramebufferState &drawFramebufferState) const
{ … }
void StateManagerGL::updateEmulatedClipDistanceState(const gl::ProgramExecutable *executable,
const gl::ClipDistanceEnableBits enables) const
{ … }
void StateManagerGL::syncSamplersState(const gl::Context *context)
{ … }
void StateManagerGL::syncTransformFeedbackState(const gl::Context *context)
{ … }
GLuint StateManagerGL::getDefaultVAO() const
{ … }
VertexArrayStateGL *StateManagerGL::getDefaultVAOState()
{ … }
void StateManagerGL::validateState() const
{ … }
template <>
void StateManagerGL::get(GLenum name, GLboolean *value)
{ … }
template <>
void StateManagerGL::get(GLenum name, bool *value)
{ … }
template <>
void StateManagerGL::get(GLenum name, std::array<bool, 4> *values)
{ … }
template <>
void StateManagerGL::get(GLenum name, GLint *value)
{ … }
template <>
void StateManagerGL::get(GLenum name, GLenum *value)
{ … }
template <>
void StateManagerGL::get(GLenum name, gl::Rectangle *rect)
{ … }
template <>
void StateManagerGL::get(GLenum name, GLfloat *value)
{ … }
template <>
void StateManagerGL::get(GLenum name, gl::ColorF *color)
{ … }
void StateManagerGL::syncFromNativeContext(const gl::Extensions &extensions,
ExternalContextState *state)
{ … }
void StateManagerGL::restoreNativeContext(const gl::Extensions &extensions,
const ExternalContextState *state)
{ … }
void StateManagerGL::syncBlendFromNativeContext(const gl::Extensions &extensions,
ExternalContextState *state)
{ … }
void StateManagerGL::restoreBlendNativeContext(const gl::Extensions &extensions,
const ExternalContextState *state)
{ … }
void StateManagerGL::syncFramebufferFromNativeContext(const gl::Extensions &extensions,
ExternalContextState *state)
{ … }
void StateManagerGL::restoreFramebufferNativeContext(const gl::Extensions &extensions,
const ExternalContextState *state)
{ … }
void StateManagerGL::syncPixelPackUnpackFromNativeContext(const gl::Extensions &extensions,
ExternalContextState *state)
{ … }
void StateManagerGL::restorePixelPackUnpackNativeContext(const gl::Extensions &extensions,
const ExternalContextState *state)
{ … }
void StateManagerGL::syncStencilFromNativeContext(const gl::Extensions &extensions,
ExternalContextState *state)
{ … }
void StateManagerGL::restoreStencilNativeContext(const gl::Extensions &extensions,
const ExternalContextState *state)
{ … }
void StateManagerGL::syncBufferBindingsFromNativeContext(const gl::Extensions &extensions,
ExternalContextState *state)
{ … }
void StateManagerGL::restoreBufferBindingsNativeContext(const gl::Extensions &extensions,
const ExternalContextState *state)
{ … }
void StateManagerGL::syncTextureUnitsFromNativeContext(const gl::Extensions &extensions,
ExternalContextState *state)
{ … }
void StateManagerGL::restoreTextureUnitsNativeContext(const gl::Extensions &extensions,
const ExternalContextState *state)
{ … }
void StateManagerGL::syncVertexArraysFromNativeContext(const gl::Extensions &extensions,
ExternalContextState *state)
{ … }
void StateManagerGL::restoreVertexArraysNativeContext(const gl::Extensions &extensions,
const ExternalContextState *state)
{ … }
void StateManagerGL::setDefaultVAOStateDirty()
{ … }
}