Hash :
3efa290d
Author :
Date :
2020-11-19T14:36:16
EGL: Auto-generate validation header. This is a first step towards auto-generating more EGL code. It includes format handling for all the EGL parameter types, type reinterpretation for EGL types using the "packed enum" handling, and code refactoring to support the new consistent validation entry point pattern. Bug: angleproject:2621 Change-Id: I2740e82928db311aa934825cbe74bd75bf49c33c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2552976 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Cody Northrop <cnorthrop@google.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
//
// 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.
//
// validationEGL.h: Validation functions for generic EGL entry point parameters
#ifndef LIBANGLE_VALIDATIONEGL_H_
#define LIBANGLE_VALIDATIONEGL_H_
#include "common/PackedEnums.h"
#include "libANGLE/Error.h"
#include "libANGLE/Texture.h"
#include <EGL/egl.h>
#include <EGL/eglext.h>
namespace gl
{
class Context;
}
namespace egl
{
class AttributeMap;
struct ClientExtensions;
struct Config;
class Device;
class Display;
class Image;
class Stream;
class Surface;
class Sync;
class Thread;
class LabeledObject;
struct ValidationContext
{
ValidationContext(Thread *threadIn, const char *entryPointIn, const LabeledObject *objectIn)
: eglThread(threadIn), entryPoint(entryPointIn), labeledObject(objectIn)
{}
// We should remove the message-less overload once we have messages for all EGL errors.
void setError(EGLint error) const;
void setError(EGLint error, const char *message...) const;
Thread *eglThread;
const char *entryPoint;
const LabeledObject *labeledObject;
};
// Object validation
bool ValidateDisplay(const ValidationContext *val, const Display *display);
bool ValidateSurface(const ValidationContext *val, const Display *display, const Surface *surface);
bool ValidateConfig(const ValidationContext *val, const Display *display, const Config *config);
bool ValidateContext(const ValidationContext *val,
const Display *display,
const gl::Context *context);
bool ValidateImage(const ValidationContext *val, const Display *display, const Image *image);
bool ValidateDevice(const ValidationContext *val, const Device *device);
bool ValidateSync(const ValidationContext *val, const Display *display, const Sync *sync);
// Return the requested object only if it is valid (otherwise nullptr)
const Thread *GetThreadIfValid(const Thread *thread);
const Display *GetDisplayIfValid(const Display *display);
const Surface *GetSurfaceIfValid(const Display *display, const Surface *surface);
const Image *GetImageIfValid(const Display *display, const Image *image);
const Stream *GetStreamIfValid(const Display *display, const Stream *stream);
const gl::Context *GetContextIfValid(const Display *display, const gl::Context *context);
const Device *GetDeviceIfValid(const Device *device);
const Sync *GetSyncIfValid(const Display *display, const Sync *sync);
LabeledObject *GetLabeledObjectIfValid(Thread *thread,
const Display *display,
ObjectType objectType,
EGLObjectKHR object);
} // namespace egl
#define ANGLE_EGL_VALIDATE(THREAD, EP, OBJ, RETVAL, ...) \
do \
{ \
const char *epname = "egl" #EP; \
ValidationContext vctx(THREAD, epname, OBJ); \
auto ANGLE_LOCAL_VAR = (Validate##EP(&vctx, ##__VA_ARGS__)); \
if (!ANGLE_LOCAL_VAR) \
{ \
return RETVAL; \
} \
} while (0)
#define ANGLE_EGL_VALIDATE_VOID(THREAD, EP, OBJ, ...) \
do \
{ \
const char *epname = "egl" #EP; \
ValidationContext vctx(THREAD, epname, OBJ); \
auto ANGLE_LOCAL_VAR = (Validate##EP(&vctx, ##__VA_ARGS__)); \
if (!ANGLE_LOCAL_VAR) \
{ \
return; \
} \
} while (0)
#define ANGLE_EGL_TRY(THREAD, EXPR, FUNCNAME, LABELOBJECT) \
do \
{ \
auto ANGLE_LOCAL_VAR = (EXPR); \
if (ANGLE_LOCAL_VAR.isError()) \
return THREAD->setError(ANGLE_LOCAL_VAR, FUNCNAME, LABELOBJECT); \
} while (0)
#define ANGLE_EGL_TRY_RETURN(THREAD, EXPR, FUNCNAME, LABELOBJECT, RETVAL) \
do \
{ \
auto ANGLE_LOCAL_VAR = (EXPR); \
if (ANGLE_LOCAL_VAR.isError()) \
{ \
THREAD->setError(ANGLE_LOCAL_VAR, FUNCNAME, LABELOBJECT); \
return RETVAL; \
} \
} while (0)
#endif // LIBANGLE_VALIDATIONEGL_H_