tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

validationES32.cpp (20809B)


      1 //
      2 // Copyright 2019 The ANGLE Project Authors. All rights reserved.
      3 // Use of this source code is governed by a BSD-style license that can be
      4 // found in the LICENSE file.
      5 //
      6 
      7 // validationES32.cpp: Validation functions for OpenGL ES 3.2 entry point parameters
      8 
      9 #include "libANGLE/validationES32_autogen.h"
     10 
     11 #include "libANGLE/Context.h"
     12 #include "libANGLE/ErrorStrings.h"
     13 #include "libANGLE/Framebuffer.h"
     14 #include "libANGLE/VertexArray.h"
     15 #include "libANGLE/validationES.h"
     16 #include "libANGLE/validationES2_autogen.h"
     17 #include "libANGLE/validationES31.h"
     18 #include "libANGLE/validationES31_autogen.h"
     19 #include "libANGLE/validationES3_autogen.h"
     20 
     21 #include "common/utilities.h"
     22 
     23 using namespace angle;
     24 
     25 namespace gl
     26 {
     27 using namespace err;
     28 
     29 bool ValidateBlendBarrier(const Context *context, angle::EntryPoint entryPoint)
     30 {
     31    return true;
     32 }
     33 
     34 bool ValidateBlendEquationSeparatei(const Context *context,
     35                                    angle::EntryPoint entryPoint,
     36                                    GLuint buf,
     37                                    GLenum modeRGB,
     38                                    GLenum modeAlpha)
     39 {
     40    if (buf >= static_cast<GLuint>(context->getCaps().maxDrawBuffers))
     41    {
     42        context->validationError(entryPoint, GL_INVALID_VALUE, kExceedsMaxDrawBuffers);
     43        return false;
     44    }
     45 
     46    if (!ValidateBlendEquationSeparate(context, entryPoint, modeRGB, modeAlpha))
     47    {
     48        // error already generated
     49        return false;
     50    }
     51 
     52    return true;
     53 }
     54 
     55 bool ValidateBlendEquationi(const Context *context,
     56                            angle::EntryPoint entryPoint,
     57                            GLuint buf,
     58                            GLenum mode)
     59 {
     60    if (buf >= static_cast<GLuint>(context->getCaps().maxDrawBuffers))
     61    {
     62        context->validationError(entryPoint, GL_INVALID_VALUE, kExceedsMaxDrawBuffers);
     63        return false;
     64    }
     65 
     66    if (!ValidateBlendEquation(context, entryPoint, mode))
     67    {
     68        // error already generated
     69        return false;
     70    }
     71 
     72    return true;
     73 }
     74 
     75 bool ValidateBlendFuncSeparatei(const Context *context,
     76                                angle::EntryPoint entryPoint,
     77                                GLuint buf,
     78                                GLenum srcRGB,
     79                                GLenum dstRGB,
     80                                GLenum srcAlpha,
     81                                GLenum dstAlpha)
     82 {
     83    if (buf >= static_cast<GLuint>(context->getCaps().maxDrawBuffers))
     84    {
     85        context->validationError(entryPoint, GL_INVALID_VALUE, kExceedsMaxDrawBuffers);
     86        return false;
     87    }
     88 
     89    if (!ValidateBlendFuncSeparate(context, entryPoint, srcRGB, dstRGB, srcAlpha, dstAlpha))
     90    {
     91        // error already generated
     92        return false;
     93    }
     94 
     95    return true;
     96 }
     97 
     98 bool ValidateBlendFunci(const Context *context,
     99                        angle::EntryPoint entryPoint,
    100                        GLuint buf,
    101                        GLenum src,
    102                        GLenum dst)
    103 {
    104    if (buf >= static_cast<GLuint>(context->getCaps().maxDrawBuffers))
    105    {
    106        context->validationError(entryPoint, GL_INVALID_VALUE, kExceedsMaxDrawBuffers);
    107        return false;
    108    }
    109 
    110    if (!ValidateBlendFunc(context, entryPoint, src, dst))
    111    {
    112        // error already generated
    113        return false;
    114    }
    115 
    116    return true;
    117 }
    118 
    119 bool ValidateColorMaski(const Context *context,
    120                        angle::EntryPoint entryPoint,
    121                        GLuint index,
    122                        GLboolean r,
    123                        GLboolean g,
    124                        GLboolean b,
    125                        GLboolean a)
    126 {
    127    if (index >= static_cast<GLuint>(context->getCaps().maxDrawBuffers))
    128    {
    129        context->validationError(entryPoint, GL_INVALID_VALUE, kIndexExceedsMaxDrawBuffer);
    130        return false;
    131    }
    132 
    133    return true;
    134 }
    135 
    136 bool ValidateCopyImageSubData(const Context *context,
    137                              angle::EntryPoint entryPoint,
    138                              GLuint srcName,
    139                              GLenum srcTarget,
    140                              GLint srcLevel,
    141                              GLint srcX,
    142                              GLint srcY,
    143                              GLint srcZ,
    144                              GLuint dstName,
    145                              GLenum dstTarget,
    146                              GLint dstLevel,
    147                              GLint dstX,
    148                              GLint dstY,
    149                              GLint dstZ,
    150                              GLsizei srcWidth,
    151                              GLsizei srcHeight,
    152                              GLsizei srcDepth)
    153 {
    154    if (context->getClientVersion() < ES_3_2)
    155    {
    156        context->validationError(entryPoint, GL_INVALID_OPERATION, kES32Required);
    157        return false;
    158    }
    159 
    160    return ValidateCopyImageSubDataBase(context, entryPoint, srcName, srcTarget, srcLevel, srcX,
    161                                        srcY, srcZ, dstName, dstTarget, dstLevel, dstX, dstY, dstZ,
    162                                        srcWidth, srcHeight, srcDepth);
    163 }
    164 
    165 bool ValidateDebugMessageCallback(const Context *context,
    166                                  angle::EntryPoint entryPoint,
    167                                  GLDEBUGPROC callback,
    168                                  const void *userParam)
    169 {
    170    return true;
    171 }
    172 
    173 bool ValidateDebugMessageControl(const Context *context,
    174                                 angle::EntryPoint entryPoint,
    175                                 GLenum source,
    176                                 GLenum type,
    177                                 GLenum severity,
    178                                 GLsizei count,
    179                                 const GLuint *ids,
    180                                 GLboolean enabled)
    181 {
    182    return true;
    183 }
    184 
    185 bool ValidateDebugMessageInsert(const Context *context,
    186                                angle::EntryPoint entryPoint,
    187                                GLenum source,
    188                                GLenum type,
    189                                GLuint id,
    190                                GLenum severity,
    191                                GLsizei length,
    192                                const GLchar *buf)
    193 {
    194    return true;
    195 }
    196 
    197 bool ValidateDisablei(const Context *context,
    198                      angle::EntryPoint entryPoint,
    199                      GLenum target,
    200                      GLuint index)
    201 {
    202    switch (target)
    203    {
    204        case GL_BLEND:
    205            if (index >= static_cast<GLuint>(context->getCaps().maxDrawBuffers))
    206            {
    207                context->validationError(entryPoint, GL_INVALID_VALUE, kIndexExceedsMaxDrawBuffer);
    208                return false;
    209            }
    210            break;
    211        default:
    212            context->validationErrorF(entryPoint, GL_INVALID_ENUM, kEnumNotSupported, target);
    213            return false;
    214    }
    215    return true;
    216 }
    217 
    218 bool ValidateDrawElementsBaseVertex(const Context *context,
    219                                    angle::EntryPoint entryPoint,
    220                                    PrimitiveMode mode,
    221                                    GLsizei count,
    222                                    DrawElementsType type,
    223                                    const void *indices,
    224                                    GLint basevertex)
    225 {
    226    return ValidateDrawElementsCommon(context, entryPoint, mode, count, type, indices, 1);
    227 }
    228 
    229 bool ValidateDrawElementsInstancedBaseVertex(const Context *context,
    230                                             angle::EntryPoint entryPoint,
    231                                             PrimitiveMode mode,
    232                                             GLsizei count,
    233                                             DrawElementsType type,
    234                                             const void *indices,
    235                                             GLsizei instancecount,
    236                                             GLint basevertex)
    237 {
    238    return ValidateDrawElementsInstancedBase(context, entryPoint, mode, count, type, indices,
    239                                             instancecount);
    240 }
    241 
    242 bool ValidateDrawRangeElementsBaseVertex(const Context *context,
    243                                         angle::EntryPoint entryPoint,
    244                                         PrimitiveMode mode,
    245                                         GLuint start,
    246                                         GLuint end,
    247                                         GLsizei count,
    248                                         DrawElementsType type,
    249                                         const void *indices,
    250                                         GLint basevertex)
    251 {
    252    if (end < start)
    253    {
    254        context->validationError(entryPoint, GL_INVALID_VALUE, kInvalidElementRange);
    255        return false;
    256    }
    257 
    258    if (!ValidateDrawElementsCommon(context, entryPoint, mode, count, type, indices, 0))
    259    {
    260        return false;
    261    }
    262 
    263    // Skip range checks for no-op calls.
    264    if (count <= 0)
    265    {
    266        return true;
    267    }
    268 
    269    return true;
    270 }
    271 
    272 bool ValidateEnablei(const Context *context,
    273                     angle::EntryPoint entryPoint,
    274                     GLenum target,
    275                     GLuint index)
    276 {
    277    switch (target)
    278    {
    279        case GL_BLEND:
    280            if (index >= static_cast<GLuint>(context->getCaps().maxDrawBuffers))
    281            {
    282                context->validationError(entryPoint, GL_INVALID_VALUE, kIndexExceedsMaxDrawBuffer);
    283                return false;
    284            }
    285            break;
    286        default:
    287            context->validationErrorF(entryPoint, GL_INVALID_ENUM, kEnumNotSupported, target);
    288            return false;
    289    }
    290    return true;
    291 }
    292 
    293 bool ValidateFramebufferTexture(const Context *context,
    294                                angle::EntryPoint entryPoint,
    295                                GLenum target,
    296                                GLenum attachment,
    297                                TextureID texture,
    298                                GLint level)
    299 {
    300    return true;
    301 }
    302 
    303 bool ValidateGetDebugMessageLog(const Context *context,
    304                                angle::EntryPoint entryPoint,
    305                                GLuint count,
    306                                GLsizei bufSize,
    307                                const GLenum *sources,
    308                                const GLenum *types,
    309                                const GLuint *ids,
    310                                const GLenum *severities,
    311                                const GLsizei *lengths,
    312                                const GLchar *messageLog)
    313 {
    314    return true;
    315 }
    316 
    317 bool ValidateGetGraphicsResetStatus(const Context *context, angle::EntryPoint entryPoint)
    318 {
    319    return true;
    320 }
    321 
    322 bool ValidateGetObjectLabel(const Context *context,
    323                            angle::EntryPoint entryPoint,
    324                            GLenum identifier,
    325                            GLuint name,
    326                            GLsizei bufSize,
    327                            const GLsizei *length,
    328                            const GLchar *label)
    329 {
    330    return true;
    331 }
    332 
    333 bool ValidateGetObjectPtrLabel(const Context *context,
    334                               angle::EntryPoint entryPoint,
    335                               const void *ptr,
    336                               GLsizei bufSize,
    337                               const GLsizei *length,
    338                               const GLchar *label)
    339 {
    340    return true;
    341 }
    342 
    343 bool ValidateGetPointerv(const Context *context,
    344                         angle::EntryPoint entryPoint,
    345                         GLenum pname,
    346                         void *const *params)
    347 {
    348    Version clientVersion = context->getClientVersion();
    349 
    350    if ((clientVersion == ES_1_0) || (clientVersion == ES_1_1))
    351    {
    352        switch (pname)
    353        {
    354            case GL_VERTEX_ARRAY_POINTER:
    355            case GL_NORMAL_ARRAY_POINTER:
    356            case GL_COLOR_ARRAY_POINTER:
    357            case GL_TEXTURE_COORD_ARRAY_POINTER:
    358            case GL_POINT_SIZE_ARRAY_POINTER_OES:
    359                return true;
    360            default:
    361                context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidPointerQuery);
    362                return false;
    363        }
    364    }
    365    else if (clientVersion == ES_3_2)
    366    {
    367        switch (pname)
    368        {
    369            case GL_DEBUG_CALLBACK_FUNCTION:
    370            case GL_DEBUG_CALLBACK_USER_PARAM:
    371                return true;
    372            default:
    373                context->validationError(entryPoint, GL_INVALID_ENUM, kInvalidPointerQuery);
    374                return false;
    375        }
    376    }
    377    else
    378    {
    379        context->validationError(entryPoint, GL_INVALID_OPERATION, kES1or32Required);
    380        return false;
    381    }
    382 }
    383 
    384 bool ValidateGetSamplerParameterIiv(const Context *context,
    385                                    angle::EntryPoint entryPoint,
    386                                    SamplerID sampler,
    387                                    GLenum pname,
    388                                    const GLint *params)
    389 {
    390    return true;
    391 }
    392 
    393 bool ValidateGetSamplerParameterIuiv(const Context *context,
    394                                     angle::EntryPoint entryPoint,
    395                                     SamplerID sampler,
    396                                     GLenum pname,
    397                                     const GLuint *params)
    398 {
    399    return true;
    400 }
    401 
    402 bool ValidateGetTexParameterIiv(const Context *context,
    403                                angle::EntryPoint entryPoint,
    404                                TextureType targetPacked,
    405                                GLenum pname,
    406                                const GLint *params)
    407 {
    408    return true;
    409 }
    410 
    411 bool ValidateGetTexParameterIuiv(const Context *context,
    412                                 angle::EntryPoint entryPoint,
    413                                 TextureType targetPacked,
    414                                 GLenum pname,
    415                                 const GLuint *params)
    416 {
    417    return true;
    418 }
    419 
    420 bool ValidateGetnUniformfv(const Context *context,
    421                           angle::EntryPoint entryPoint,
    422                           ShaderProgramID program,
    423                           UniformLocation location,
    424                           GLsizei bufSize,
    425                           const GLfloat *params)
    426 {
    427    return ValidateSizedGetUniform(context, entryPoint, program, location, bufSize, nullptr);
    428 }
    429 
    430 bool ValidateGetnUniformiv(const Context *context,
    431                           angle::EntryPoint entryPoint,
    432                           ShaderProgramID program,
    433                           UniformLocation location,
    434                           GLsizei bufSize,
    435                           const GLint *params)
    436 {
    437    return ValidateSizedGetUniform(context, entryPoint, program, location, bufSize, nullptr);
    438 }
    439 
    440 bool ValidateGetnUniformuiv(const Context *context,
    441                            angle::EntryPoint entryPoint,
    442                            ShaderProgramID program,
    443                            UniformLocation location,
    444                            GLsizei bufSize,
    445                            const GLuint *params)
    446 {
    447    return ValidateSizedGetUniform(context, entryPoint, program, location, bufSize, nullptr);
    448 }
    449 
    450 bool ValidateIsEnabledi(const Context *context,
    451                        angle::EntryPoint entryPoint,
    452                        GLenum target,
    453                        GLuint index)
    454 {
    455    switch (target)
    456    {
    457        case GL_BLEND:
    458            if (index >= static_cast<GLuint>(context->getCaps().maxDrawBuffers))
    459            {
    460                context->validationError(entryPoint, GL_INVALID_VALUE, kIndexExceedsMaxDrawBuffer);
    461                return false;
    462            }
    463            break;
    464        default:
    465            context->validationErrorF(entryPoint, GL_INVALID_ENUM, kEnumNotSupported, target);
    466            return false;
    467    }
    468    return true;
    469 }
    470 
    471 bool ValidateMinSampleShading(const Context *context, angle::EntryPoint entryPoint, GLfloat value)
    472 {
    473    return true;
    474 }
    475 
    476 bool ValidateObjectLabel(const Context *context,
    477                         angle::EntryPoint entryPoint,
    478                         GLenum identifier,
    479                         GLuint name,
    480                         GLsizei length,
    481                         const GLchar *label)
    482 {
    483    return true;
    484 }
    485 
    486 bool ValidateObjectPtrLabel(const Context *context,
    487                            angle::EntryPoint entryPoint,
    488                            const void *ptr,
    489                            GLsizei length,
    490                            const GLchar *label)
    491 {
    492    return true;
    493 }
    494 
    495 bool ValidatePatchParameteri(const Context *context,
    496                             angle::EntryPoint entryPoint,
    497                             GLenum pname,
    498                             GLint value)
    499 {
    500    return true;
    501 }
    502 
    503 bool ValidatePopDebugGroup(const Context *context, angle::EntryPoint entryPoint)
    504 {
    505    return true;
    506 }
    507 
    508 bool ValidatePrimitiveBoundingBox(const Context *context,
    509                                  angle::EntryPoint entryPoint,
    510                                  GLfloat minX,
    511                                  GLfloat minY,
    512                                  GLfloat minZ,
    513                                  GLfloat minW,
    514                                  GLfloat maxX,
    515                                  GLfloat maxY,
    516                                  GLfloat maxZ,
    517                                  GLfloat maxW)
    518 {
    519    return true;
    520 }
    521 
    522 bool ValidatePushDebugGroup(const Context *context,
    523                            angle::EntryPoint entryPoint,
    524                            GLenum source,
    525                            GLuint id,
    526                            GLsizei length,
    527                            const GLchar *message)
    528 {
    529    return true;
    530 }
    531 
    532 bool ValidateReadnPixels(const Context *context,
    533                         angle::EntryPoint entryPoint,
    534                         GLint x,
    535                         GLint y,
    536                         GLsizei width,
    537                         GLsizei height,
    538                         GLenum format,
    539                         GLenum type,
    540                         GLsizei bufSize,
    541                         const void *data)
    542 {
    543    return true;
    544 }
    545 
    546 bool ValidateSamplerParameterIiv(const Context *context,
    547                                 angle::EntryPoint entryPoint,
    548                                 SamplerID sampler,
    549                                 GLenum pname,
    550                                 const GLint *param)
    551 {
    552    return true;
    553 }
    554 
    555 bool ValidateSamplerParameterIuiv(const Context *context,
    556                                  angle::EntryPoint entryPoint,
    557                                  SamplerID sampler,
    558                                  GLenum pname,
    559                                  const GLuint *param)
    560 {
    561    return true;
    562 }
    563 
    564 bool ValidateTexBuffer(const Context *context,
    565                       angle::EntryPoint entryPoint,
    566                       TextureType target,
    567                       GLenum internalformat,
    568                       BufferID buffer)
    569 {
    570    if (context->getClientVersion() < ES_3_2)
    571    {
    572        context->validationError(entryPoint, GL_INVALID_OPERATION, kES32Required);
    573        return false;
    574    }
    575 
    576    return ValidateTexBufferBase(context, entryPoint, target, internalformat, buffer);
    577 }
    578 
    579 bool ValidateTexBufferRange(const Context *context,
    580                            angle::EntryPoint entryPoint,
    581                            TextureType target,
    582                            GLenum internalformat,
    583                            BufferID buffer,
    584                            GLintptr offset,
    585                            GLsizeiptr size)
    586 {
    587    if (context->getClientVersion() < ES_3_2)
    588    {
    589        context->validationError(entryPoint, GL_INVALID_OPERATION, kES32Required);
    590        return false;
    591    }
    592 
    593    return ValidateTexBufferRangeBase(context, entryPoint, target, internalformat, buffer, offset,
    594                                      size);
    595 }
    596 
    597 bool ValidateTexParameterIiv(const Context *context,
    598                             angle::EntryPoint entryPoint,
    599                             TextureType targetPacked,
    600                             GLenum pname,
    601                             const GLint *params)
    602 {
    603    return true;
    604 }
    605 
    606 bool ValidateTexParameterIuiv(const Context *context,
    607                              angle::EntryPoint entryPoint,
    608                              TextureType targetPacked,
    609                              GLenum pname,
    610                              const GLuint *params)
    611 {
    612    return true;
    613 }
    614 
    615 bool ValidateTexStorage3DMultisample(const Context *context,
    616                                     angle::EntryPoint entryPoint,
    617                                     TextureType targetPacked,
    618                                     GLsizei samples,
    619                                     GLenum internalformat,
    620                                     GLsizei width,
    621                                     GLsizei height,
    622                                     GLsizei depth,
    623                                     GLboolean fixedsamplelocations)
    624 {
    625    return true;
    626 }
    627 
    628 }  // namespace gl