Commit 5b772312 by Jamie Madill Committed by Commit Bot

Nuke ValidationContext.

This pattern never really took off. It was intended to be used to unit-test our Validation logic, but it become so complex because of interactions with Framebuffer::syncState that we could never really make use of it. Nuke it entirely and simplify the Context class. Bug: angleproject:2372 Change-Id: I40b9d46ce7706511a210da496ee19192cf609366 Reviewed-on: https://chromium-review.googlesource.com/954291Reviewed-by: 's avatarLuc Ferron <lucferron@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent d4fff506
...@@ -61,7 +61,7 @@ class VertexArray; ...@@ -61,7 +61,7 @@ class VertexArray;
struct VertexAttribute; struct VertexAttribute;
class ProgramPipeline; class ProgramPipeline;
class Context final : public ValidationContext class Context final : angle::NonCopyable
{ {
public: public:
Context(rx::EGLImplFactory *implFactory, Context(rx::EGLImplFactory *implFactory,
...@@ -73,7 +73,7 @@ class Context final : public ValidationContext ...@@ -73,7 +73,7 @@ class Context final : public ValidationContext
const egl::DisplayExtensions &displayExtensions); const egl::DisplayExtensions &displayExtensions);
egl::Error onDestroy(const egl::Display *display); egl::Error onDestroy(const egl::Display *display);
~Context() override; ~Context();
egl::Error makeCurrent(egl::Display *display, egl::Surface *surface); egl::Error makeCurrent(egl::Display *display, egl::Surface *surface);
egl::Error releaseSurface(const egl::Display *display); egl::Error releaseSurface(const egl::Display *display);
...@@ -1121,7 +1121,7 @@ class Context final : public ValidationContext ...@@ -1121,7 +1121,7 @@ class Context final : public ValidationContext
void memoryBarrierByRegion(GLbitfield barriers); void memoryBarrierByRegion(GLbitfield barriers);
// Consumes the error. // Consumes the error.
void handleError(const Error &error) override; void handleError(const Error &error);
GLenum getError(); GLenum getError();
void markContextLost(); void markContextLost();
...@@ -1167,6 +1167,43 @@ class Context final : public ValidationContext ...@@ -1167,6 +1167,43 @@ class Context final : public ValidationContext
bool isCurrentTransformFeedback(const TransformFeedback *tf) const; bool isCurrentTransformFeedback(const TransformFeedback *tf) const;
bool isCurrentVertexArray(const VertexArray *va) const; bool isCurrentVertexArray(const VertexArray *va) const;
const ContextState &getContextState() const { return mState; }
GLint getClientMajorVersion() const { return mState.getClientMajorVersion(); }
GLint getClientMinorVersion() const { return mState.getClientMinorVersion(); }
const Version &getClientVersion() const { return mState.getClientVersion(); }
const State &getGLState() const { return mState.getState(); }
const Caps &getCaps() const { return mState.getCaps(); }
const TextureCapsMap &getTextureCaps() const { return mState.getTextureCaps(); }
const Extensions &getExtensions() const { return mState.getExtensions(); }
const Limitations &getLimitations() const { return mState.getLimitations(); }
bool skipValidation() const { return mSkipValidation; }
// Specific methods needed for validation.
bool getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *numParams);
bool getIndexedQueryParameterInfo(GLenum target, GLenum *type, unsigned int *numParams);
Program *getProgram(GLuint handle) const;
Shader *getShader(GLuint handle) const;
bool isTextureGenerated(GLuint texture) const;
bool isBufferGenerated(GLuint buffer) const;
bool isRenderbufferGenerated(GLuint renderbuffer) const;
bool isFramebufferGenerated(GLuint framebuffer) const;
bool isProgramPipelineGenerated(GLuint pipeline) const;
bool usingDisplayTextureShareGroup() const;
// Hack for the special WebGL 1 "DEPTH_STENCIL" internal format.
GLenum getConvertedRenderbufferFormat(GLenum internalformat) const;
bool isWebGL() const { return mState.isWebGL(); }
bool isWebGL1() const { return mState.isWebGL1(); }
template <typename T>
const T &getParams() const;
bool isValidBufferBinding(BufferBinding binding) const { return mValidBufferBindings[binding]; }
private: private:
Error prepareForDraw(); Error prepareForDraw();
Error prepareForClear(GLbitfield mask); Error prepareForClear(GLbitfield mask);
...@@ -1204,6 +1241,18 @@ class Context final : public ValidationContext ...@@ -1204,6 +1241,18 @@ class Context final : public ValidationContext
LabeledObject *getLabeledObject(GLenum identifier, GLuint name) const; LabeledObject *getLabeledObject(GLenum identifier, GLuint name) const;
LabeledObject *getLabeledObjectFromPtr(const void *ptr) const; LabeledObject *getLabeledObjectFromPtr(const void *ptr) const;
ContextState mState;
bool mSkipValidation;
bool mDisplayTextureShareGroup;
// Stores for each buffer binding type whether is it allowed to be used in this context.
angle::PackedEnumBitSet<BufferBinding> mValidBufferBindings;
// Caches entry point parameters and values re-used between layers.
mutable const ParamTypeInfo *mSavedArgsType;
static constexpr size_t kParamsBufferSize = 64u;
mutable std::array<uint8_t, kParamsBufferSize> mParamsBuffer;
std::unique_ptr<rx::ContextImpl> mImplementation; std::unique_ptr<rx::ContextImpl> mImplementation;
// Caps to use for validation // Caps to use for validation
...@@ -1277,6 +1326,14 @@ class Context final : public ValidationContext ...@@ -1277,6 +1326,14 @@ class Context final : public ValidationContext
mutable angle::ScratchBuffer mZeroFilledBuffer; mutable angle::ScratchBuffer mZeroFilledBuffer;
}; };
template <typename T>
const T &Context::getParams() const
{
const T *params = reinterpret_cast<T *>(mParamsBuffer.data());
ASSERT(mSavedArgsType->hasDynamicType(T::TypeInfo));
return *params;
}
template <EntryPoint EP, typename... ArgsT> template <EntryPoint EP, typename... ArgsT>
ANGLE_INLINE void Context::gatherParams(ArgsT &&... args) ANGLE_INLINE void Context::gatherParams(ArgsT &&... args)
{ {
......
...@@ -27,7 +27,6 @@ class SamplerManager; ...@@ -27,7 +27,6 @@ class SamplerManager;
class ShaderProgramManager; class ShaderProgramManager;
class SyncManager; class SyncManager;
class TextureManager; class TextureManager;
class ValidationContext;
static constexpr Version ES_2_0 = Version(2, 0); static constexpr Version ES_2_0 = Version(2, 0);
static constexpr Version ES_3_0 = Version(3, 0); static constexpr Version ES_3_0 = Version(3, 0);
...@@ -61,14 +60,11 @@ class ContextState final : angle::NonCopyable ...@@ -61,14 +60,11 @@ class ContextState final : angle::NonCopyable
const TextureCaps &getTextureCap(GLenum internalFormat) const; const TextureCaps &getTextureCap(GLenum internalFormat) const;
bool usingDisplayTextureShareGroup() const;
bool isWebGL() const; bool isWebGL() const;
bool isWebGL1() const; bool isWebGL1() const;
private: private:
friend class Context; friend class Context;
friend class ValidationContext;
Version mClientVersion; Version mClientVersion;
ContextID mContext; ContextID mContext;
...@@ -89,81 +85,6 @@ class ContextState final : angle::NonCopyable ...@@ -89,81 +85,6 @@ class ContextState final : angle::NonCopyable
ProgramPipelineManager *mPipelines; ProgramPipelineManager *mPipelines;
}; };
class ValidationContext : angle::NonCopyable
{
public:
ValidationContext(const ValidationContext *shareContext,
TextureManager *shareTextures,
const Version &clientVersion,
State *state,
const Caps &caps,
const TextureCapsMap &textureCaps,
const Extensions &extensions,
const Limitations &limitations,
bool skipValidation);
virtual ~ValidationContext();
virtual void handleError(const Error &error) = 0;
const ContextState &getContextState() const { return mState; }
GLint getClientMajorVersion() const { return mState.getClientMajorVersion(); }
GLint getClientMinorVersion() const { return mState.getClientMinorVersion(); }
const Version &getClientVersion() const { return mState.getClientVersion(); }
const State &getGLState() const { return mState.getState(); }
const Caps &getCaps() const { return mState.getCaps(); }
const TextureCapsMap &getTextureCaps() const { return mState.getTextureCaps(); }
const Extensions &getExtensions() const { return mState.getExtensions(); }
const Limitations &getLimitations() const { return mState.getLimitations(); }
bool skipValidation() const { return mSkipValidation; }
// Specific methods needed for validation.
bool getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *numParams);
bool getIndexedQueryParameterInfo(GLenum target, GLenum *type, unsigned int *numParams);
Program *getProgram(GLuint handle) const;
Shader *getShader(GLuint handle) const;
bool isTextureGenerated(GLuint texture) const;
bool isBufferGenerated(GLuint buffer) const;
bool isRenderbufferGenerated(GLuint renderbuffer) const;
bool isFramebufferGenerated(GLuint framebuffer) const;
bool isProgramPipelineGenerated(GLuint pipeline) const;
bool usingDisplayTextureShareGroup() const;
// Hack for the special WebGL 1 "DEPTH_STENCIL" internal format.
GLenum getConvertedRenderbufferFormat(GLenum internalformat) const;
bool isWebGL() const { return mState.isWebGL(); }
bool isWebGL1() const { return mState.isWebGL1(); }
template <typename T>
const T &getParams() const;
bool isValidBufferBinding(BufferBinding binding) const { return mValidBufferBindings[binding]; }
protected:
ContextState mState;
bool mSkipValidation;
bool mDisplayTextureShareGroup;
// Stores for each buffer binding type whether is it allowed to be used in this context.
angle::PackedEnumBitSet<BufferBinding> mValidBufferBindings;
// Caches entry point parameters and values re-used between layers.
mutable const ParamTypeInfo *mSavedArgsType;
static constexpr size_t kParamsBufferSize = 64u;
mutable std::array<uint8_t, kParamsBufferSize> mParamsBuffer;
};
template <typename T>
const T &ValidationContext::getParams() const
{
const T *params = reinterpret_cast<T *>(mParamsBuffer.data());
ASSERT(mSavedArgsType->hasDynamicType(T::TypeInfo));
return *params;
}
} // namespace gl } // namespace gl
#endif // LIBANGLE_CONTEXTSTATE_H_ #endif // LIBANGLE_CONTEXTSTATE_H_
...@@ -162,7 +162,7 @@ class ANGLE_NO_DISCARD Error final ...@@ -162,7 +162,7 @@ class ANGLE_NO_DISCARD Error final
// automatic error type conversion // automatic error type conversion
inline Error(gl::Error &&glErr); inline Error(gl::Error &&glErr);
inline Error(gl::Error glErr); inline Error(const gl::Error &glErr);
inline Error &operator=(const Error &other); inline Error &operator=(const Error &other);
inline Error &operator=(Error &&other); inline Error &operator=(Error &&other);
......
...@@ -134,10 +134,10 @@ Error::Error(gl::Error &&glErr) ...@@ -134,10 +134,10 @@ Error::Error(gl::Error &&glErr)
{ {
} }
Error::Error(gl::Error glErr) Error::Error(const gl::Error &glErr)
: mCode(EGL_BAD_ACCESS), : mCode(EGL_BAD_ACCESS),
mID(0), mID(0),
mMessage(std::move(glErr.mMessage)) mMessage(glErr.mMessage.get())
{ {
} }
......
...@@ -1437,6 +1437,8 @@ int Framebuffer::getSamples(const Context *context) ...@@ -1437,6 +1437,8 @@ int Framebuffer::getSamples(const Context *context)
int Framebuffer::getCachedSamples(const Context *context) int Framebuffer::getCachedSamples(const Context *context)
{ {
ASSERT(mCachedStatus.valid() && mCachedStatus.value() == GL_FRAMEBUFFER_COMPLETE);
// For a complete framebuffer, all attachments must have the same sample count. // For a complete framebuffer, all attachments must have the same sample count.
// In this case return the first nonzero sample size. // In this case return the first nonzero sample size.
const auto *firstNonNullAttachment = mState.getFirstNonNullAttachment(); const auto *firstNonNullAttachment = mState.getFirstNonNullAttachment();
...@@ -1791,11 +1793,6 @@ bool Framebuffer::complete(const Context *context) ...@@ -1791,11 +1793,6 @@ bool Framebuffer::complete(const Context *context)
return (checkStatus(context) == GL_FRAMEBUFFER_COMPLETE); return (checkStatus(context) == GL_FRAMEBUFFER_COMPLETE);
} }
bool Framebuffer::cachedComplete() const
{
return (mCachedStatus.valid() && mCachedStatus == GL_FRAMEBUFFER_COMPLETE);
}
bool Framebuffer::formsRenderingFeedbackLoopWith(const State &state) const bool Framebuffer::formsRenderingFeedbackLoopWith(const State &state) const
{ {
const Program *program = state.getProgram(); const Program *program = state.getProgram();
...@@ -1924,17 +1921,6 @@ void Framebuffer::setDefaultFixedSampleLocations(bool defaultFixedSampleLocation ...@@ -1924,17 +1921,6 @@ void Framebuffer::setDefaultFixedSampleLocations(bool defaultFixedSampleLocation
mDirtyBits.set(DIRTY_BIT_DEFAULT_FIXED_SAMPLE_LOCATIONS); mDirtyBits.set(DIRTY_BIT_DEFAULT_FIXED_SAMPLE_LOCATIONS);
} }
// TODO(jmadill): Remove this kludge.
GLenum Framebuffer::checkStatus(const ValidationContext *context)
{
return checkStatus(static_cast<const Context *>(context));
}
int Framebuffer::getSamples(const ValidationContext *context)
{
return getSamples(static_cast<const Context *>(context));
}
GLsizei Framebuffer::getNumViews() const GLsizei Framebuffer::getNumViews() const
{ {
return mState.getNumViews(); return mState.getNumViews();
......
...@@ -44,7 +44,6 @@ class Renderbuffer; ...@@ -44,7 +44,6 @@ class Renderbuffer;
class State; class State;
class Texture; class Texture;
class TextureCapsMap; class TextureCapsMap;
class ValidationContext;
struct Caps; struct Caps;
struct Extensions; struct Extensions;
struct ImageIndex; struct ImageIndex;
...@@ -232,16 +231,11 @@ class Framebuffer final : public angle::ObserverInterface, public LabeledObject ...@@ -232,16 +231,11 @@ class Framebuffer final : public angle::ObserverInterface, public LabeledObject
GLenum checkStatus(const Context *context); GLenum checkStatus(const Context *context);
// TODO(jmadill): Remove this kludge.
GLenum checkStatus(const ValidationContext *context);
int getSamples(const ValidationContext *context);
// For when we don't want to check completeness in getSamples(). // For when we don't want to check completeness in getSamples().
int getCachedSamples(const Context *context); int getCachedSamples(const Context *context);
// Helper for checkStatus == GL_FRAMEBUFFER_COMPLETE. // Helper for checkStatus == GL_FRAMEBUFFER_COMPLETE.
bool complete(const Context *context); bool complete(const Context *context);
bool cachedComplete() const;
bool hasValidDepthStencil() const; bool hasValidDepthStencil() const;
......
...@@ -1747,7 +1747,7 @@ gl::Error StateManager11::syncFramebuffer(const gl::Context *context, gl::Frameb ...@@ -1747,7 +1747,7 @@ gl::Error StateManager11::syncFramebuffer(const gl::Context *context, gl::Frameb
// Applies the render target surface, depth stencil surface, viewport rectangle and // Applies the render target surface, depth stencil surface, viewport rectangle and
// scissor rectangle to the renderer // scissor rectangle to the renderer
ASSERT(framebuffer && !framebuffer->hasAnyDirtyBit() && framebuffer->cachedComplete()); ASSERT(framebuffer && !framebuffer->hasAnyDirtyBit());
// Check for zero-sized default framebuffer, which is a special case. // Check for zero-sized default framebuffer, which is a special case.
// in this case we do not wish to modify any state and just silently return false. // in this case we do not wish to modify any state and just silently return false.
......
...@@ -1041,7 +1041,7 @@ gl::Error Renderer9::updateState(const gl::Context *context, GLenum drawMode) ...@@ -1041,7 +1041,7 @@ gl::Error Renderer9::updateState(const gl::Context *context, GLenum drawMode)
// Applies the render target surface, depth stencil surface, viewport rectangle and // Applies the render target surface, depth stencil surface, viewport rectangle and
// scissor rectangle to the renderer // scissor rectangle to the renderer
gl::Framebuffer *framebuffer = glState.getDrawFramebuffer(); gl::Framebuffer *framebuffer = glState.getDrawFramebuffer();
ASSERT(framebuffer && !framebuffer->hasAnyDirtyBit() && framebuffer->cachedComplete()); ASSERT(framebuffer && !framebuffer->hasAnyDirtyBit());
Framebuffer9 *framebuffer9 = GetImplAs<Framebuffer9>(framebuffer); Framebuffer9 *framebuffer9 = GetImplAs<Framebuffer9>(framebuffer);
......
...@@ -781,7 +781,7 @@ static bool IsValidES3CopyTexImageCombination(const InternalFormat &textureForma ...@@ -781,7 +781,7 @@ static bool IsValidES3CopyTexImageCombination(const InternalFormat &textureForma
// conversion between these formats. // conversion between these formats.
} }
bool ValidateES3CopyTexImageParametersBase(ValidationContext *context, bool ValidateES3CopyTexImageParametersBase(Context *context,
TextureTarget target, TextureTarget target,
GLint level, GLint level,
GLenum internalformat, GLenum internalformat,
...@@ -847,7 +847,7 @@ bool ValidateES3CopyTexImageParametersBase(ValidationContext *context, ...@@ -847,7 +847,7 @@ bool ValidateES3CopyTexImageParametersBase(ValidationContext *context,
return (width > 0 && height > 0); return (width > 0 && height > 0);
} }
bool ValidateES3CopyTexImage2DParameters(ValidationContext *context, bool ValidateES3CopyTexImage2DParameters(Context *context,
TextureTarget target, TextureTarget target,
GLint level, GLint level,
GLenum internalformat, GLenum internalformat,
...@@ -872,7 +872,7 @@ bool ValidateES3CopyTexImage2DParameters(ValidationContext *context, ...@@ -872,7 +872,7 @@ bool ValidateES3CopyTexImage2DParameters(ValidationContext *context,
border); border);
} }
bool ValidateES3CopyTexImage3DParameters(ValidationContext *context, bool ValidateES3CopyTexImage3DParameters(Context *context,
TextureType target, TextureType target,
GLint level, GLint level,
GLenum internalformat, GLenum internalformat,
...@@ -1238,7 +1238,7 @@ bool ValidateInvalidateSubFramebuffer(Context *context, ...@@ -1238,7 +1238,7 @@ bool ValidateInvalidateSubFramebuffer(Context *context,
return ValidateInvalidateFramebuffer(context, target, numAttachments, attachments); return ValidateInvalidateFramebuffer(context, target, numAttachments, attachments);
} }
bool ValidateClearBuffer(ValidationContext *context) bool ValidateClearBuffer(Context *context)
{ {
if (context->getClientMajorVersion() < 3) if (context->getClientMajorVersion() < 3)
{ {
...@@ -1727,10 +1727,7 @@ bool ValidateBlitFramebuffer(Context *context, ...@@ -1727,10 +1727,7 @@ bool ValidateBlitFramebuffer(Context *context,
dstX1, dstY1, mask, filter); dstX1, dstY1, mask, filter);
} }
bool ValidateClearBufferiv(ValidationContext *context, bool ValidateClearBufferiv(Context *context, GLenum buffer, GLint drawbuffer, const GLint *value)
GLenum buffer,
GLint drawbuffer,
const GLint *value)
{ {
switch (buffer) switch (buffer)
{ {
...@@ -1768,10 +1765,7 @@ bool ValidateClearBufferiv(ValidationContext *context, ...@@ -1768,10 +1765,7 @@ bool ValidateClearBufferiv(ValidationContext *context,
return ValidateClearBuffer(context); return ValidateClearBuffer(context);
} }
bool ValidateClearBufferuiv(ValidationContext *context, bool ValidateClearBufferuiv(Context *context, GLenum buffer, GLint drawbuffer, const GLuint *value)
GLenum buffer,
GLint drawbuffer,
const GLuint *value)
{ {
switch (buffer) switch (buffer)
{ {
...@@ -1801,10 +1795,7 @@ bool ValidateClearBufferuiv(ValidationContext *context, ...@@ -1801,10 +1795,7 @@ bool ValidateClearBufferuiv(ValidationContext *context,
return ValidateClearBuffer(context); return ValidateClearBuffer(context);
} }
bool ValidateClearBufferfv(ValidationContext *context, bool ValidateClearBufferfv(Context *context, GLenum buffer, GLint drawbuffer, const GLfloat *value)
GLenum buffer,
GLint drawbuffer,
const GLfloat *value)
{ {
switch (buffer) switch (buffer)
{ {
...@@ -1843,7 +1834,7 @@ bool ValidateClearBufferfv(ValidationContext *context, ...@@ -1843,7 +1834,7 @@ bool ValidateClearBufferfv(ValidationContext *context,
return ValidateClearBuffer(context); return ValidateClearBuffer(context);
} }
bool ValidateClearBufferfi(ValidationContext *context, bool ValidateClearBufferfi(Context *context,
GLenum buffer, GLenum buffer,
GLint drawbuffer, GLint drawbuffer,
GLfloat depth, GLfloat depth,
...@@ -1867,7 +1858,7 @@ bool ValidateClearBufferfi(ValidationContext *context, ...@@ -1867,7 +1858,7 @@ bool ValidateClearBufferfi(ValidationContext *context,
return ValidateClearBuffer(context); return ValidateClearBuffer(context);
} }
bool ValidateDrawBuffers(ValidationContext *context, GLsizei n, const GLenum *bufs) bool ValidateDrawBuffers(Context *context, GLsizei n, const GLenum *bufs)
{ {
if (context->getClientMajorVersion() < 3) if (context->getClientMajorVersion() < 3)
{ {
...@@ -2262,10 +2253,7 @@ bool ValidateFlushMappedBufferRange(Context *context, ...@@ -2262,10 +2253,7 @@ bool ValidateFlushMappedBufferRange(Context *context,
return ValidateFlushMappedBufferRangeBase(context, target, offset, length); return ValidateFlushMappedBufferRangeBase(context, target, offset, length);
} }
bool ValidateIndexedStateQuery(ValidationContext *context, bool ValidateIndexedStateQuery(Context *context, GLenum pname, GLuint index, GLsizei *length)
GLenum pname,
GLuint index,
GLsizei *length)
{ {
if (length) if (length)
{ {
...@@ -2411,7 +2399,7 @@ bool ValidateIndexedStateQuery(ValidationContext *context, ...@@ -2411,7 +2399,7 @@ bool ValidateIndexedStateQuery(ValidationContext *context,
return true; return true;
} }
bool ValidateGetIntegeri_v(ValidationContext *context, GLenum target, GLuint index, GLint *data) bool ValidateGetIntegeri_v(Context *context, GLenum target, GLuint index, GLint *data)
{ {
if (context->getClientVersion() < ES_3_0) if (context->getClientVersion() < ES_3_0)
{ {
...@@ -2421,7 +2409,7 @@ bool ValidateGetIntegeri_v(ValidationContext *context, GLenum target, GLuint ind ...@@ -2421,7 +2409,7 @@ bool ValidateGetIntegeri_v(ValidationContext *context, GLenum target, GLuint ind
return ValidateIndexedStateQuery(context, target, index, nullptr); return ValidateIndexedStateQuery(context, target, index, nullptr);
} }
bool ValidateGetIntegeri_vRobustANGLE(ValidationContext *context, bool ValidateGetIntegeri_vRobustANGLE(Context *context,
GLenum target, GLenum target,
GLuint index, GLuint index,
GLsizei bufSize, GLsizei bufSize,
...@@ -2452,7 +2440,7 @@ bool ValidateGetIntegeri_vRobustANGLE(ValidationContext *context, ...@@ -2452,7 +2440,7 @@ bool ValidateGetIntegeri_vRobustANGLE(ValidationContext *context,
return true; return true;
} }
bool ValidateGetInteger64i_v(ValidationContext *context, GLenum target, GLuint index, GLint64 *data) bool ValidateGetInteger64i_v(Context *context, GLenum target, GLuint index, GLint64 *data)
{ {
if (context->getClientVersion() < ES_3_0) if (context->getClientVersion() < ES_3_0)
{ {
...@@ -2462,7 +2450,7 @@ bool ValidateGetInteger64i_v(ValidationContext *context, GLenum target, GLuint i ...@@ -2462,7 +2450,7 @@ bool ValidateGetInteger64i_v(ValidationContext *context, GLenum target, GLuint i
return ValidateIndexedStateQuery(context, target, index, nullptr); return ValidateIndexedStateQuery(context, target, index, nullptr);
} }
bool ValidateGetInteger64i_vRobustANGLE(ValidationContext *context, bool ValidateGetInteger64i_vRobustANGLE(Context *context,
GLenum target, GLenum target,
GLuint index, GLuint index,
GLsizei bufSize, GLsizei bufSize,
...@@ -2493,7 +2481,7 @@ bool ValidateGetInteger64i_vRobustANGLE(ValidationContext *context, ...@@ -2493,7 +2481,7 @@ bool ValidateGetInteger64i_vRobustANGLE(ValidationContext *context,
return true; return true;
} }
bool ValidateCopyBufferSubData(ValidationContext *context, bool ValidateCopyBufferSubData(Context *context,
BufferBinding readTarget, BufferBinding readTarget,
BufferBinding writeTarget, BufferBinding writeTarget,
GLintptr readOffset, GLintptr readOffset,
...@@ -2630,7 +2618,7 @@ bool ValidateGetStringi(Context *context, GLenum name, GLuint index) ...@@ -2630,7 +2618,7 @@ bool ValidateGetStringi(Context *context, GLenum name, GLuint index)
return true; return true;
} }
bool ValidateRenderbufferStorageMultisample(ValidationContext *context, bool ValidateRenderbufferStorageMultisample(Context *context,
GLenum target, GLenum target,
GLsizei samples, GLsizei samples,
GLenum internalformat, GLenum internalformat,
...@@ -2676,7 +2664,7 @@ bool ValidateRenderbufferStorageMultisample(ValidationContext *context, ...@@ -2676,7 +2664,7 @@ bool ValidateRenderbufferStorageMultisample(ValidationContext *context,
return true; return true;
} }
bool ValidateVertexAttribIPointer(ValidationContext *context, bool ValidateVertexAttribIPointer(Context *context,
GLuint index, GLuint index,
GLint size, GLint size,
GLenum type, GLenum type,
...@@ -2787,7 +2775,7 @@ bool ValidateGetSynciv(Context *context, ...@@ -2787,7 +2775,7 @@ bool ValidateGetSynciv(Context *context,
return true; return true;
} }
bool ValidateDrawElementsInstanced(ValidationContext *context, bool ValidateDrawElementsInstanced(Context *context,
GLenum mode, GLenum mode,
GLsizei count, GLsizei count,
GLenum type, GLenum type,
...@@ -3689,7 +3677,7 @@ bool ValidateTexStorage3D(Context *context, ...@@ -3689,7 +3677,7 @@ bool ValidateTexStorage3D(Context *context,
return true; return true;
} }
bool ValidateGetBufferParameteri64v(ValidationContext *context, bool ValidateGetBufferParameteri64v(Context *context,
BufferBinding target, BufferBinding target,
GLenum pname, GLenum pname,
GLint64 *params) GLint64 *params)
......
...@@ -17,9 +17,8 @@ namespace gl ...@@ -17,9 +17,8 @@ namespace gl
{ {
class Context; class Context;
struct IndexRange; struct IndexRange;
class ValidationContext;
bool ValidateES3TexImageParametersBase(ValidationContext *context, bool ValidateES3TexImageParametersBase(Context *context,
GLenum target, GLenum target,
GLint level, GLint level,
GLenum internalformat, GLenum internalformat,
...@@ -81,7 +80,7 @@ bool ValidateES3TexImage3DParameters(Context *context, ...@@ -81,7 +80,7 @@ bool ValidateES3TexImage3DParameters(Context *context,
GLsizei bufSize, GLsizei bufSize,
const void *pixels); const void *pixels);
bool ValidateES3CopyTexImageParametersBase(ValidationContext *context, bool ValidateES3CopyTexImageParametersBase(Context *context,
GLenum target, GLenum target,
GLint level, GLint level,
GLenum internalformat, GLenum internalformat,
...@@ -95,7 +94,7 @@ bool ValidateES3CopyTexImageParametersBase(ValidationContext *context, ...@@ -95,7 +94,7 @@ bool ValidateES3CopyTexImageParametersBase(ValidationContext *context,
GLsizei height, GLsizei height,
GLint border); GLint border);
bool ValidateES3CopyTexImage2DParameters(ValidationContext *context, bool ValidateES3CopyTexImage2DParameters(Context *context,
TextureTarget target, TextureTarget target,
GLint level, GLint level,
GLenum internalformat, GLenum internalformat,
...@@ -109,7 +108,7 @@ bool ValidateES3CopyTexImage2DParameters(ValidationContext *context, ...@@ -109,7 +108,7 @@ bool ValidateES3CopyTexImage2DParameters(ValidationContext *context,
GLsizei height, GLsizei height,
GLint border); GLint border);
bool ValidateES3CopyTexImage3DParameters(ValidationContext *context, bool ValidateES3CopyTexImage3DParameters(Context *context,
TextureType target, TextureType target,
GLint level, GLint level,
GLenum internalformat, GLenum internalformat,
...@@ -176,7 +175,7 @@ bool ValidateInvalidateSubFramebuffer(Context *context, ...@@ -176,7 +175,7 @@ bool ValidateInvalidateSubFramebuffer(Context *context,
GLsizei width, GLsizei width,
GLsizei height); GLsizei height);
bool ValidateClearBuffer(ValidationContext *context); bool ValidateClearBuffer(Context *context);
bool ValidateDrawRangeElements(Context *context, bool ValidateDrawRangeElements(Context *context,
GLenum mode, GLenum mode,
...@@ -246,24 +245,15 @@ bool ValidateBlitFramebuffer(Context *context, ...@@ -246,24 +245,15 @@ bool ValidateBlitFramebuffer(Context *context,
GLint dstY1, GLint dstY1,
GLbitfield mask, GLbitfield mask,
GLenum filter); GLenum filter);
bool ValidateClearBufferiv(ValidationContext *context, bool ValidateClearBufferiv(Context *context, GLenum buffer, GLint drawbuffer, const GLint *value);
GLenum buffer, bool ValidateClearBufferuiv(Context *context, GLenum buffer, GLint drawbuffer, const GLuint *value);
GLint drawbuffer, bool ValidateClearBufferfv(Context *context, GLenum buffer, GLint drawbuffer, const GLfloat *value);
const GLint *value); bool ValidateClearBufferfi(Context *context,
bool ValidateClearBufferuiv(ValidationContext *context,
GLenum buffer,
GLint drawbuffer,
const GLuint *value);
bool ValidateClearBufferfv(ValidationContext *context,
GLenum buffer,
GLint drawbuffer,
const GLfloat *value);
bool ValidateClearBufferfi(ValidationContext *context,
GLenum buffer, GLenum buffer,
GLint drawbuffer, GLint drawbuffer,
GLfloat depth, GLfloat depth,
GLint stencil); GLint stencil);
bool ValidateDrawBuffers(ValidationContext *context, GLsizei n, const GLenum *bufs); bool ValidateDrawBuffers(Context *context, GLsizei n, const GLenum *bufs);
bool ValidateCopyTexSubImage3D(Context *context, bool ValidateCopyTexSubImage3D(Context *context,
TextureType target, TextureType target,
GLint level, GLint level,
...@@ -377,29 +367,23 @@ bool ValidateFlushMappedBufferRange(Context *context, ...@@ -377,29 +367,23 @@ bool ValidateFlushMappedBufferRange(Context *context,
GLintptr offset, GLintptr offset,
GLsizeiptr length); GLsizeiptr length);
bool ValidateIndexedStateQuery(ValidationContext *context, bool ValidateIndexedStateQuery(Context *context, GLenum pname, GLuint index, GLsizei *length);
GLenum pname, bool ValidateGetIntegeri_v(Context *context, GLenum target, GLuint index, GLint *data);
GLuint index, bool ValidateGetIntegeri_vRobustANGLE(Context *context,
GLsizei *length);
bool ValidateGetIntegeri_v(ValidationContext *context, GLenum target, GLuint index, GLint *data);
bool ValidateGetIntegeri_vRobustANGLE(ValidationContext *context,
GLenum target, GLenum target,
GLuint index, GLuint index,
GLsizei bufSize, GLsizei bufSize,
GLsizei *length, GLsizei *length,
GLint *data); GLint *data);
bool ValidateGetInteger64i_v(ValidationContext *context, bool ValidateGetInteger64i_v(Context *context, GLenum target, GLuint index, GLint64 *data);
GLenum target, bool ValidateGetInteger64i_vRobustANGLE(Context *context,
GLuint index,
GLint64 *data);
bool ValidateGetInteger64i_vRobustANGLE(ValidationContext *context,
GLenum target, GLenum target,
GLuint index, GLuint index,
GLsizei bufSize, GLsizei bufSize,
GLsizei *length, GLsizei *length,
GLint64 *data); GLint64 *data);
bool ValidateCopyBufferSubData(ValidationContext *context, bool ValidateCopyBufferSubData(Context *context,
BufferBinding readTarget, BufferBinding readTarget,
BufferBinding writeTarget, BufferBinding writeTarget,
GLintptr readOffset, GLintptr readOffset,
...@@ -407,14 +391,14 @@ bool ValidateCopyBufferSubData(ValidationContext *context, ...@@ -407,14 +391,14 @@ bool ValidateCopyBufferSubData(ValidationContext *context,
GLsizeiptr size); GLsizeiptr size);
bool ValidateGetStringi(Context *context, GLenum name, GLuint index); bool ValidateGetStringi(Context *context, GLenum name, GLuint index);
bool ValidateRenderbufferStorageMultisample(ValidationContext *context, bool ValidateRenderbufferStorageMultisample(Context *context,
GLenum target, GLenum target,
GLsizei samples, GLsizei samples,
GLenum internalformat, GLenum internalformat,
GLsizei width, GLsizei width,
GLsizei height); GLsizei height);
bool ValidateVertexAttribIPointer(ValidationContext *context, bool ValidateVertexAttribIPointer(Context *context,
GLuint index, GLuint index,
GLint size, GLint size,
GLenum type, GLenum type,
...@@ -428,7 +412,7 @@ bool ValidateGetSynciv(Context *context, ...@@ -428,7 +412,7 @@ bool ValidateGetSynciv(Context *context,
GLsizei *length, GLsizei *length,
GLint *values); GLint *values);
bool ValidateDrawElementsInstanced(ValidationContext *context, bool ValidateDrawElementsInstanced(Context *context,
GLenum mode, GLenum mode,
GLsizei count, GLsizei count,
GLenum type, GLenum type,
...@@ -586,7 +570,7 @@ bool ValidateTexStorage3D(Context *context, ...@@ -586,7 +570,7 @@ bool ValidateTexStorage3D(Context *context,
bool ValidateGetVertexAttribIiv(Context *context, GLuint index, GLenum pname, GLint *params); bool ValidateGetVertexAttribIiv(Context *context, GLuint index, GLenum pname, GLint *params);
bool ValidateGetVertexAttribIuiv(Context *context, GLuint index, GLenum pname, GLuint *params); bool ValidateGetVertexAttribIuiv(Context *context, GLuint index, GLenum pname, GLuint *params);
bool ValidateGetBufferParameteri64v(ValidationContext *context, bool ValidateGetBufferParameteri64v(Context *context,
BufferBinding target, BufferBinding target,
GLenum pname, GLenum pname,
GLint64 *params); GLint64 *params);
......
...@@ -281,7 +281,7 @@ bool ValidateProgramResourceIndex(const Program *programObject, ...@@ -281,7 +281,7 @@ bool ValidateProgramResourceIndex(const Program *programObject,
} }
} }
bool ValidateProgramUniform(gl::Context *context, bool ValidateProgramUniform(Context *context,
GLenum valueType, GLenum valueType,
GLuint program, GLuint program,
GLint location, GLint location,
...@@ -295,12 +295,12 @@ bool ValidateProgramUniform(gl::Context *context, ...@@ -295,12 +295,12 @@ bool ValidateProgramUniform(gl::Context *context,
} }
const LinkedUniform *uniform = nullptr; const LinkedUniform *uniform = nullptr;
gl::Program *programObject = GetValidProgram(context, program); Program *programObject = GetValidProgram(context, program);
return ValidateUniformCommonBase(context, programObject, location, count, &uniform) && return ValidateUniformCommonBase(context, programObject, location, count, &uniform) &&
ValidateUniformValue(context, valueType, uniform->type); ValidateUniformValue(context, valueType, uniform->type);
} }
bool ValidateProgramUniformMatrix(gl::Context *context, bool ValidateProgramUniformMatrix(Context *context,
GLenum valueType, GLenum valueType,
GLuint program, GLuint program,
GLint location, GLint location,
...@@ -315,12 +315,12 @@ bool ValidateProgramUniformMatrix(gl::Context *context, ...@@ -315,12 +315,12 @@ bool ValidateProgramUniformMatrix(gl::Context *context,
} }
const LinkedUniform *uniform = nullptr; const LinkedUniform *uniform = nullptr;
gl::Program *programObject = GetValidProgram(context, program); Program *programObject = GetValidProgram(context, program);
return ValidateUniformCommonBase(context, programObject, location, count, &uniform) && return ValidateUniformCommonBase(context, programObject, location, count, &uniform) &&
ValidateUniformMatrixValue(context, valueType, uniform->type); ValidateUniformMatrixValue(context, valueType, uniform->type);
} }
bool ValidateVertexAttribFormatCommon(ValidationContext *context, bool ValidateVertexAttribFormatCommon(Context *context,
GLuint attribIndex, GLuint attribIndex,
GLint size, GLint size,
GLenum type, GLenum type,
...@@ -426,7 +426,7 @@ bool ValidateDrawIndirectBase(Context *context, GLenum mode, const void *indirec ...@@ -426,7 +426,7 @@ bool ValidateDrawIndirectBase(Context *context, GLenum mode, const void *indirec
return false; return false;
} }
gl::Buffer *drawIndirectBuffer = state.getTargetBuffer(BufferBinding::DrawIndirect); Buffer *drawIndirectBuffer = state.getTargetBuffer(BufferBinding::DrawIndirect);
if (!drawIndirectBuffer) if (!drawIndirectBuffer)
{ {
context->handleError(InvalidOperation() << "zero is bound to DRAW_INDIRECT_BUFFER"); context->handleError(InvalidOperation() << "zero is bound to DRAW_INDIRECT_BUFFER");
...@@ -463,7 +463,7 @@ bool ValidateDrawIndirectBase(Context *context, GLenum mode, const void *indirec ...@@ -463,7 +463,7 @@ bool ValidateDrawIndirectBase(Context *context, GLenum mode, const void *indirec
bool ValidateDrawArraysIndirect(Context *context, GLenum mode, const void *indirect) bool ValidateDrawArraysIndirect(Context *context, GLenum mode, const void *indirect)
{ {
const State &state = context->getGLState(); const State &state = context->getGLState();
gl::TransformFeedback *curTransformFeedback = state.getCurrentTransformFeedback(); TransformFeedback *curTransformFeedback = state.getCurrentTransformFeedback();
if (curTransformFeedback && curTransformFeedback->isActive() && if (curTransformFeedback && curTransformFeedback->isActive() &&
!curTransformFeedback->isPaused()) !curTransformFeedback->isPaused())
{ {
...@@ -475,7 +475,7 @@ bool ValidateDrawArraysIndirect(Context *context, GLenum mode, const void *indir ...@@ -475,7 +475,7 @@ bool ValidateDrawArraysIndirect(Context *context, GLenum mode, const void *indir
if (!ValidateDrawIndirectBase(context, mode, indirect)) if (!ValidateDrawIndirectBase(context, mode, indirect))
return false; return false;
gl::Buffer *drawIndirectBuffer = state.getTargetBuffer(BufferBinding::DrawIndirect); Buffer *drawIndirectBuffer = state.getTargetBuffer(BufferBinding::DrawIndirect);
CheckedNumeric<size_t> checkedOffset(reinterpret_cast<size_t>(indirect)); CheckedNumeric<size_t> checkedOffset(reinterpret_cast<size_t>(indirect));
// In OpenGL ES3.1 spec, session 10.5, it defines the struct of DrawArraysIndirectCommand // In OpenGL ES3.1 spec, session 10.5, it defines the struct of DrawArraysIndirectCommand
// which's size is 4 * sizeof(uint). // which's size is 4 * sizeof(uint).
...@@ -499,7 +499,7 @@ bool ValidateDrawElementsIndirect(Context *context, GLenum mode, GLenum type, co ...@@ -499,7 +499,7 @@ bool ValidateDrawElementsIndirect(Context *context, GLenum mode, GLenum type, co
const State &state = context->getGLState(); const State &state = context->getGLState();
const VertexArray *vao = state.getVertexArray(); const VertexArray *vao = state.getVertexArray();
gl::Buffer *elementArrayBuffer = vao->getElementArrayBuffer().get(); Buffer *elementArrayBuffer = vao->getElementArrayBuffer().get();
if (!elementArrayBuffer) if (!elementArrayBuffer)
{ {
context->handleError(InvalidOperation() << "zero is bound to ELEMENT_ARRAY_BUFFER"); context->handleError(InvalidOperation() << "zero is bound to ELEMENT_ARRAY_BUFFER");
...@@ -509,7 +509,7 @@ bool ValidateDrawElementsIndirect(Context *context, GLenum mode, GLenum type, co ...@@ -509,7 +509,7 @@ bool ValidateDrawElementsIndirect(Context *context, GLenum mode, GLenum type, co
if (!ValidateDrawIndirectBase(context, mode, indirect)) if (!ValidateDrawIndirectBase(context, mode, indirect))
return false; return false;
gl::Buffer *drawIndirectBuffer = state.getTargetBuffer(BufferBinding::DrawIndirect); Buffer *drawIndirectBuffer = state.getTargetBuffer(BufferBinding::DrawIndirect);
CheckedNumeric<size_t> checkedOffset(reinterpret_cast<size_t>(indirect)); CheckedNumeric<size_t> checkedOffset(reinterpret_cast<size_t>(indirect));
// In OpenGL ES3.1 spec, session 10.5, it defines the struct of DrawElementsIndirectCommand // In OpenGL ES3.1 spec, session 10.5, it defines the struct of DrawElementsIndirectCommand
// which's size is 5 * sizeof(uint). // which's size is 5 * sizeof(uint).
...@@ -650,7 +650,7 @@ bool ValidateProgramUniform1iv(Context *context, ...@@ -650,7 +650,7 @@ bool ValidateProgramUniform1iv(Context *context,
} }
const LinkedUniform *uniform = nullptr; const LinkedUniform *uniform = nullptr;
gl::Program *programObject = GetValidProgram(context, program); Program *programObject = GetValidProgram(context, program);
return ValidateUniformCommonBase(context, programObject, location, count, &uniform) && return ValidateUniformCommonBase(context, programObject, location, count, &uniform) &&
ValidateUniform1ivValue(context, uniform->type, count, value); ValidateUniform1ivValue(context, uniform->type, count, value);
} }
...@@ -1195,7 +1195,7 @@ bool ValidateGetProgramResourceIndex(Context *context, ...@@ -1195,7 +1195,7 @@ bool ValidateGetProgramResourceIndex(Context *context,
return true; return true;
} }
bool ValidateBindVertexBuffer(ValidationContext *context, bool ValidateBindVertexBuffer(Context *context,
GLuint bindingIndex, GLuint bindingIndex,
GLuint buffer, GLuint buffer,
GLintptr offset, GLintptr offset,
...@@ -1245,7 +1245,7 @@ bool ValidateBindVertexBuffer(ValidationContext *context, ...@@ -1245,7 +1245,7 @@ bool ValidateBindVertexBuffer(ValidationContext *context,
return true; return true;
} }
bool ValidateVertexBindingDivisor(ValidationContext *context, GLuint bindingIndex, GLuint divisor) bool ValidateVertexBindingDivisor(Context *context, GLuint bindingIndex, GLuint divisor)
{ {
if (context->getClientVersion() < ES_3_1) if (context->getClientVersion() < ES_3_1)
{ {
...@@ -1272,7 +1272,7 @@ bool ValidateVertexBindingDivisor(ValidationContext *context, GLuint bindingInde ...@@ -1272,7 +1272,7 @@ bool ValidateVertexBindingDivisor(ValidationContext *context, GLuint bindingInde
return true; return true;
} }
bool ValidateVertexAttribFormat(ValidationContext *context, bool ValidateVertexAttribFormat(Context *context,
GLuint attribindex, GLuint attribindex,
GLint size, GLint size,
GLenum type, GLenum type,
...@@ -1283,7 +1283,7 @@ bool ValidateVertexAttribFormat(ValidationContext *context, ...@@ -1283,7 +1283,7 @@ bool ValidateVertexAttribFormat(ValidationContext *context,
false); false);
} }
bool ValidateVertexAttribIFormat(ValidationContext *context, bool ValidateVertexAttribIFormat(Context *context,
GLuint attribindex, GLuint attribindex,
GLint size, GLint size,
GLenum type, GLenum type,
...@@ -1292,9 +1292,7 @@ bool ValidateVertexAttribIFormat(ValidationContext *context, ...@@ -1292,9 +1292,7 @@ bool ValidateVertexAttribIFormat(ValidationContext *context,
return ValidateVertexAttribFormatCommon(context, attribindex, size, type, relativeoffset, true); return ValidateVertexAttribFormatCommon(context, attribindex, size, type, relativeoffset, true);
} }
bool ValidateVertexAttribBinding(ValidationContext *context, bool ValidateVertexAttribBinding(Context *context, GLuint attribIndex, GLuint bindingIndex)
GLuint attribIndex,
GLuint bindingIndex)
{ {
if (context->getClientVersion() < ES_3_1) if (context->getClientVersion() < ES_3_1)
{ {
...@@ -1444,7 +1442,7 @@ bool ValidateDispatchComputeIndirect(Context *context, GLintptr indirect) ...@@ -1444,7 +1442,7 @@ bool ValidateDispatchComputeIndirect(Context *context, GLintptr indirect)
return false; return false;
} }
gl::Buffer *dispatchIndirectBuffer = state.getTargetBuffer(BufferBinding::DispatchIndirect); Buffer *dispatchIndirectBuffer = state.getTargetBuffer(BufferBinding::DispatchIndirect);
if (!dispatchIndirectBuffer) if (!dispatchIndirectBuffer)
{ {
ANGLE_VALIDATION_ERR(context, InvalidOperation(), DispatchIndirectBufferNotBound); ANGLE_VALIDATION_ERR(context, InvalidOperation(), DispatchIndirectBufferNotBound);
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
namespace gl namespace gl
{ {
class Context; class Context;
class ValidationContext;
bool ValidateGetBooleani_v(Context *context, GLenum target, GLuint index, GLboolean *data); bool ValidateGetBooleani_v(Context *context, GLenum target, GLuint index, GLboolean *data);
bool ValidateGetBooleani_vRobustANGLE(Context *context, bool ValidateGetBooleani_vRobustANGLE(Context *context,
...@@ -263,26 +262,24 @@ bool ValidateGetProgramInterfaceiv(Context *context, ...@@ -263,26 +262,24 @@ bool ValidateGetProgramInterfaceiv(Context *context,
GLenum pname, GLenum pname,
GLint *params); GLint *params);
bool ValidateBindVertexBuffer(ValidationContext *context, bool ValidateBindVertexBuffer(Context *context,
GLuint bindingIndex, GLuint bindingIndex,
GLuint buffer, GLuint buffer,
GLintptr offset, GLintptr offset,
GLsizei stride); GLsizei stride);
bool ValidateVertexAttribFormat(ValidationContext *context, bool ValidateVertexAttribFormat(Context *context,
GLuint attribindex, GLuint attribindex,
GLint size, GLint size,
GLenum type, GLenum type,
GLboolean normalized, GLboolean normalized,
GLuint relativeoffset); GLuint relativeoffset);
bool ValidateVertexAttribIFormat(ValidationContext *context, bool ValidateVertexAttribIFormat(Context *context,
GLuint attribindex, GLuint attribindex,
GLint size, GLint size,
GLenum type, GLenum type,
GLuint relativeoffset); GLuint relativeoffset);
bool ValidateVertexAttribBinding(ValidationContext *context, bool ValidateVertexAttribBinding(Context *context, GLuint attribIndex, GLuint bindingIndex);
GLuint attribIndex, bool ValidateVertexBindingDivisor(Context *context, GLuint bindingIndex, GLuint divisor);
GLuint bindingIndex);
bool ValidateVertexBindingDivisor(ValidationContext *context, GLuint bindingIndex, GLuint divisor);
bool ValidateDispatchCompute(Context *context, bool ValidateDispatchCompute(Context *context,
GLuint numGroupsX, GLuint numGroupsX,
......
//
// Copyright 2015 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.
//
// validationES unit tests:
// Unit tests for general ES validation functions.
//
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include "libANGLE/ContextState.h"
#include "libANGLE/ErrorStrings.h"
#include "libANGLE/VaryingPacking.h"
#include "libANGLE/renderer/FramebufferImpl_mock.h"
#include "libANGLE/renderer/ProgramImpl_mock.h"
#include "libANGLE/renderer/TextureImpl_mock.h"
#include "libANGLE/validationES.h"
#include "tests/angle_unittests_utils.h"
using namespace gl;
using namespace rx;
using testing::_;
using testing::NiceMock;
using testing::Return;
namespace
{
class MockValidationContext : public ValidationContext
{
public:
MockValidationContext(const ValidationContext *shareContext,
TextureManager *shareTextures,
const Version &version,
State *state,
const Caps &caps,
const TextureCapsMap &textureCaps,
const Extensions &extensions,
const Limitations &limitations,
bool skipValidation)
: ValidationContext(shareContext,
shareTextures,
version,
state,
caps,
textureCaps,
extensions,
limitations,
skipValidation)
{
}
MOCK_METHOD1(handleError, void(const Error &));
};
// Test that ANGLE generates an INVALID_OPERATION when validating index data that uses a value
// larger than MAX_ELEMENT_INDEX and robust access is not enabled. Not specified in the GLES 3 spec,
// it's undefined behaviour, but we want a test to ensure we maintain this behaviour. TODO(jmadill):
// Re-enable when framebuffer sync state doesn't happen in validation. Also broken because of change
// of api of the state initialize method.
TEST(ValidationESTest, DISABLED_DrawElementsWithMaxIndexGivesError)
{
auto framebufferImpl = MakeFramebufferMock();
auto programImpl = MakeProgramMock();
// TODO(jmadill): Generalize some of this code so we can re-use it for other tests.
NiceMock<MockGLFactory> mockFactory;
EXPECT_CALL(mockFactory, createFramebuffer(_)).WillOnce(Return(framebufferImpl));
EXPECT_CALL(mockFactory, createProgram(_)).WillOnce(Return(programImpl));
EXPECT_CALL(mockFactory, createVertexArray(_)).WillOnce(Return(nullptr));
State state;
Caps caps;
TextureCapsMap textureCaps;
Extensions extensions;
Limitations limitations;
// Set some basic caps.
caps.maxElementIndex = 100;
caps.maxDrawBuffers = 1;
caps.maxColorAttachments = 1;
state.initialize(nullptr, false, true, true, false, false);
NiceMock<MockTextureImpl> *textureImpl = new NiceMock<MockTextureImpl>();
EXPECT_CALL(mockFactory, createTexture(_)).WillOnce(Return(textureImpl));
EXPECT_CALL(*textureImpl, setStorage(_, _, _, _, _)).WillOnce(Return(gl::NoError()));
EXPECT_CALL(*textureImpl, destructor()).Times(1).RetiresOnSaturation();
Texture *texture = new Texture(&mockFactory, 0, TextureType::_2D);
texture->addRef();
EXPECT_FALSE(
texture->setStorage(nullptr, TextureType::_2D, 1, GL_RGBA8, Extents(1, 1, 0)).isError());
VertexArray *vertexArray = new VertexArray(&mockFactory, 0, 1, 1);
Framebuffer *framebuffer = new Framebuffer(caps, &mockFactory, 1);
framebuffer->setAttachment(nullptr, GL_FRAMEBUFFER_DEFAULT, GL_BACK, ImageIndex::Make2D(0),
texture);
Program *program = new Program(&mockFactory, nullptr, 1);
state.setVertexArrayBinding(vertexArray);
state.setDrawFramebufferBinding(framebuffer);
state.setProgram(nullptr, program);
NiceMock<MockValidationContext> testContext(nullptr, nullptr, Version(3, 0), &state, caps,
textureCaps, extensions, limitations, false);
// Set the expectation for the validation error here.
Error expectedError(gl::InvalidOperation() << kErrorExceedsMaxElement);
EXPECT_CALL(testContext, handleError(expectedError)).Times(1);
// Call once with maximum index, and once with an excessive index.
GLuint indexData[] = {0, 1, static_cast<GLuint>(caps.maxElementIndex - 1),
3, 4, static_cast<GLuint>(caps.maxElementIndex)};
EXPECT_TRUE(
ValidateDrawElementsCommon(&testContext, GL_TRIANGLES, 3, GL_UNSIGNED_INT, indexData, 1));
if (!testContext.getExtensions().robustBufferAccessBehavior)
{
EXPECT_FALSE(ValidateDrawElementsCommon(&testContext, GL_TRIANGLES, 6, GL_UNSIGNED_INT,
indexData, 2));
}
texture->release(nullptr);
state.setVertexArrayBinding(nullptr);
state.setDrawFramebufferBinding(nullptr);
state.setProgram(nullptr, nullptr);
vertexArray->onDestroy(nullptr);
framebuffer->onDestroy(nullptr);
program->onDestroy(nullptr);
}
} // anonymous namespace
...@@ -47,7 +47,6 @@ ...@@ -47,7 +47,6 @@
'<(angle_path)/src/libANGLE/renderer/ImageImpl_mock.h', '<(angle_path)/src/libANGLE/renderer/ImageImpl_mock.h',
'<(angle_path)/src/libANGLE/renderer/TextureImpl_mock.h', '<(angle_path)/src/libANGLE/renderer/TextureImpl_mock.h',
'<(angle_path)/src/libANGLE/renderer/TransformFeedbackImpl_mock.h', '<(angle_path)/src/libANGLE/renderer/TransformFeedbackImpl_mock.h',
'<(angle_path)/src/libANGLE/validationES_unittest.cpp',
'<(angle_path)/src/tests/angle_unittests_utils.h', '<(angle_path)/src/tests/angle_unittests_utils.h',
'<(angle_path)/src/tests/compiler_tests/API_test.cpp', '<(angle_path)/src/tests/compiler_tests/API_test.cpp',
'<(angle_path)/src/tests/compiler_tests/AppendixALimitations_test.cpp', '<(angle_path)/src/tests/compiler_tests/AppendixALimitations_test.cpp',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment