diff --git a/src/libANGLE/Context.cpp b/src/libANGLE/Context.cpp index d9c948caf..afe51c810 100644 --- a/src/libANGLE/Context.cpp +++ b/src/libANGLE/Context.cpp @@ -130,17 +130,6 @@ angle::Result GetQueryObjectParameter(const Context *context, Query *query, GLen } } -ANGLE_INLINE void MarkTransformFeedbackBufferUsage(const Context *context, - GLsizei count, - GLsizei instanceCount) -{ - if (context->getStateCache().isTransformFeedbackActiveUnpaused()) - { - TransformFeedback *transformFeedback = context->getGLState().getCurrentTransformFeedback(); - transformFeedback->onVerticesDrawn(context, count, instanceCount); - } -} - // Attribute map queries. EGLint GetClientMajorVersion(const egl::AttributeMap &attribs) { @@ -254,20 +243,6 @@ void LimitCap(CapT *cap, MaxT maximum) *cap = std::min(*cap, static_cast(maximum)); } -constexpr angle::PackedEnumMap kMinimumPrimitiveCounts = {{ - {PrimitiveMode::Points, 1}, - {PrimitiveMode::Lines, 2}, - {PrimitiveMode::LineLoop, 2}, - {PrimitiveMode::LineStrip, 2}, - {PrimitiveMode::Triangles, 3}, - {PrimitiveMode::TriangleStrip, 3}, - {PrimitiveMode::TriangleFan, 3}, - {PrimitiveMode::LinesAdjacency, 2}, - {PrimitiveMode::LineStripAdjacency, 2}, - {PrimitiveMode::TrianglesAdjacency, 3}, - {PrimitiveMode::TriangleStripAdjacency, 3}, -}}; - // The rest default to false. constexpr angle::PackedEnumMap() + 1> kValidBasicDrawModes = {{ @@ -2201,19 +2176,6 @@ void Context::texParameterIuivRobust(TextureType target, UNIMPLEMENTED(); } -void Context::drawArrays(PrimitiveMode mode, GLint first, GLsizei count) -{ - // No-op if count draws no primitives for given mode - if (noopDraw(mode, count)) - { - return; - } - - ANGLE_CONTEXT_TRY(prepareForDraw(mode)); - ANGLE_CONTEXT_TRY(mImplementation->drawArrays(this, mode, first, count)); - MarkTransformFeedbackBufferUsage(this, count, 1); -} - void Context::drawArraysInstanced(PrimitiveMode mode, GLint first, GLsizei count, @@ -3478,14 +3440,6 @@ void Context::initWorkarounds() } } -// Return true if the draw is a no-op, else return false. -// A no-op draw occurs if the count of vertices is less than the minimum required to -// have a valid primitive for this mode (0 for points, 0-1 for lines, 0-2 for tris). -bool Context::noopDraw(PrimitiveMode mode, GLsizei count) -{ - return count < kMinimumPrimitiveCounts[mode]; -} - bool Context::noopDrawInstanced(PrimitiveMode mode, GLsizei count, GLsizei instanceCount) { return (instanceCount == 0) || noopDraw(mode, count); @@ -5107,13 +5061,6 @@ void Context::bindAttribLocation(GLuint program, GLuint index, const GLchar *nam programObject->bindAttributeLocation(index, name); } -void Context::bindBuffer(BufferBinding target, GLuint buffer) -{ - Buffer *bufferObject = mState.mBuffers->checkBufferAllocation(mImplementation.get(), buffer); - mGLState.setBufferBinding(this, target, bufferObject); - mStateCache.onBufferBindingChange(this); -} - void Context::bindBufferBase(BufferBinding target, GLuint index, GLuint buffer) { bindBufferRange(target, index, buffer, 0, 0); @@ -8319,12 +8266,6 @@ void StateCache::onUniformBufferStateChange(Context *context) updateBasicDrawStatesError(); } -void StateCache::onBufferBindingChange(Context *context) -{ - updateBasicDrawStatesError(); - updateBasicDrawElementsError(); -} - void StateCache::setValidDrawModes(bool pointsOK, bool linesOK, bool trisOK, diff --git a/src/libANGLE/Context.inl.h b/src/libANGLE/Context.inl.h index adb31c08d..117da6dbf 100644 --- a/src/libANGLE/Context.inl.h +++ b/src/libANGLE/Context.inl.h @@ -1,5 +1,5 @@ // -// Copyright (c) 2018 The ANGLE Project Authors. All rights reserved. +// Copyright 2018 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. // @@ -21,6 +21,38 @@ namespace gl { +constexpr angle::PackedEnumMap kMinimumPrimitiveCounts = {{ + {PrimitiveMode::Points, 1}, + {PrimitiveMode::Lines, 2}, + {PrimitiveMode::LineLoop, 2}, + {PrimitiveMode::LineStrip, 2}, + {PrimitiveMode::Triangles, 3}, + {PrimitiveMode::TriangleStrip, 3}, + {PrimitiveMode::TriangleFan, 3}, + {PrimitiveMode::LinesAdjacency, 2}, + {PrimitiveMode::LineStripAdjacency, 2}, + {PrimitiveMode::TrianglesAdjacency, 3}, + {PrimitiveMode::TriangleStripAdjacency, 3}, +}}; + +ANGLE_INLINE void MarkTransformFeedbackBufferUsage(const Context *context, + GLsizei count, + GLsizei instanceCount) +{ + if (context->getStateCache().isTransformFeedbackActiveUnpaused()) + { + TransformFeedback *transformFeedback = context->getGLState().getCurrentTransformFeedback(); + transformFeedback->onVerticesDrawn(context, count, instanceCount); + } +} + +// Return true if the draw is a no-op, else return false. +// A no-op draw occurs if the count of vertices is less than the minimum required to +// have a valid primitive for this mode (0 for points, 0-1 for lines, 0-2 for tris). +ANGLE_INLINE bool Context::noopDraw(PrimitiveMode mode, GLsizei count) +{ + return count < kMinimumPrimitiveCounts[mode]; +} ANGLE_INLINE angle::Result Context::syncDirtyBits() { @@ -56,6 +88,19 @@ ANGLE_INLINE angle::Result Context::prepareForDraw(PrimitiveMode mode) return syncDirtyBits(); } +ANGLE_INLINE void Context::drawArrays(PrimitiveMode mode, GLint first, GLsizei count) +{ + // No-op if count draws no primitives for given mode + if (noopDraw(mode, count)) + { + return; + } + + ANGLE_CONTEXT_TRY(prepareForDraw(mode)); + ANGLE_CONTEXT_TRY(mImplementation->drawArrays(this, mode, first, count)); + MarkTransformFeedbackBufferUsage(this, count, 1); +} + ANGLE_INLINE void Context::drawElements(PrimitiveMode mode, GLsizei count, DrawElementsType type, @@ -71,6 +116,19 @@ ANGLE_INLINE void Context::drawElements(PrimitiveMode mode, ANGLE_CONTEXT_TRY(mImplementation->drawElements(this, mode, count, type, indices)); } +ANGLE_INLINE void StateCache::onBufferBindingChange(Context *context) +{ + updateBasicDrawStatesError(); + updateBasicDrawElementsError(); +} + +ANGLE_INLINE void Context::bindBuffer(BufferBinding target, GLuint buffer) +{ + Buffer *bufferObject = mState.mBuffers->checkBufferAllocation(mImplementation.get(), buffer); + mGLState.setBufferBinding(this, target, bufferObject); + mStateCache.onBufferBindingChange(this); +} + } // namespace gl #endif // LIBANGLE_CONTEXT_INL_H_ diff --git a/src/libANGLE/GLES1Renderer.cpp b/src/libANGLE/GLES1Renderer.cpp index 3823488ae..4acc524d3 100644 --- a/src/libANGLE/GLES1Renderer.cpp +++ b/src/libANGLE/GLES1Renderer.cpp @@ -14,6 +14,7 @@ #include #include "libANGLE/Context.h" +#include "libANGLE/Context.inl.h" #include "libANGLE/Program.h" #include "libANGLE/ResourceManager.h" #include "libANGLE/Shader.h"