// GENERATED FILE - DO NOT EDIT.
// Generated by generate_entry_points.py using data from gl.xml.
//
// Copyright 2019 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.
//
// entry_points_gl_4_2_autogen.cpp:
//   Defines the GL 4.2 entry points.

#include "libGL/entry_points_gl_4_2_autogen.h"

#include "libANGLE/Context.h"
#include "libANGLE/Context.inl.h"
#include "libANGLE/entry_points_utils.h"
#include "libANGLE/validationEGL.h"
#include "libANGLE/validationES.h"
#include "libANGLE/validationES1.h"
#include "libANGLE/validationES2.h"
#include "libANGLE/validationES3.h"
#include "libANGLE/validationES31.h"
#include "libANGLE/validationESEXT.h"
#include "libANGLE/validationGL42_autogen.h"
#include "libGLESv2/global_state.h"

namespace gl
{
void GL_APIENTRY BindImageTexture(GLuint unit,
                                  GLuint texture,
                                  GLint level,
                                  GLboolean layered,
                                  GLint layer,
                                  GLenum access,
                                  GLenum format)
{
    EVENT(
        "(GLuint unit = %u, GLuint texture = %u, GLint level = %d, GLboolean layered = %u, GLint "
        "layer = %d, GLenum access = 0x%X, GLenum format = 0x%X)",
        unit, texture, level, layered, layer, access, format);

    Context *context = GetValidGlobalContext();
    if (context)
    {
        ANGLE_CAPTURE(BindImageTexture, context, unit, texture, level, layered, layer, access,
                      format);
        if (context->skipValidation() ||
            ValidateBindImageTexture(context, unit, texture, level, layered, layer, access, format))
        {
            context->bindImageTexture(unit, texture, level, layered, layer, access, format);
        }
    }
}

void GL_APIENTRY DrawArraysInstancedBaseInstance(GLenum mode,
                                                 GLint first,
                                                 GLsizei count,
                                                 GLsizei instancecount,
                                                 GLuint baseinstance)
{
    EVENT(
        "(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei instancecount = %d, "
        "GLuint baseinstance = %u)",
        mode, first, count, instancecount, baseinstance);

    Context *context = GetValidGlobalContext();
    if (context)
    {
        ANGLE_CAPTURE(DrawArraysInstancedBaseInstance, context, mode, first, count, instancecount,
                      baseinstance);
        if (context->skipValidation() ||
            ValidateDrawArraysInstancedBaseInstance(context, mode, first, count, instancecount,
                                                    baseinstance))
        {
            context->drawArraysInstancedBaseInstance(mode, first, count, instancecount,
                                                     baseinstance);
        }
    }
}

void GL_APIENTRY DrawElementsInstancedBaseInstance(GLenum mode,
                                                   GLsizei count,
                                                   GLenum type,
                                                   const void *indices,
                                                   GLsizei instancecount,
                                                   GLuint baseinstance)
{
    EVENT(
        "(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const void *indices = "
        "0x%016" PRIxPTR ", GLsizei instancecount = %d, GLuint baseinstance = %u)",
        mode, count, type, (uintptr_t)indices, instancecount, baseinstance);

    Context *context = GetValidGlobalContext();
    if (context)
    {
        ANGLE_CAPTURE(DrawElementsInstancedBaseInstance, context, mode, count, type, indices,
                      instancecount, baseinstance);
        if (context->skipValidation() ||
            ValidateDrawElementsInstancedBaseInstance(context, mode, count, type, indices,
                                                      instancecount, baseinstance))
        {
            context->drawElementsInstancedBaseInstance(mode, count, type, indices, instancecount,
                                                       baseinstance);
        }
    }
}

void GL_APIENTRY DrawElementsInstancedBaseVertexBaseInstance(GLenum mode,
                                                             GLsizei count,
                                                             GLenum type,
                                                             const void *indices,
                                                             GLsizei instancecount,
                                                             GLint basevertex,
                                                             GLuint baseinstance)
{
    EVENT(
        "(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const void *indices = "
        "0x%016" PRIxPTR
        ", GLsizei instancecount = %d, GLint basevertex = %d, GLuint baseinstance = %u)",
        mode, count, type, (uintptr_t)indices, instancecount, basevertex, baseinstance);

    Context *context = GetValidGlobalContext();
    if (context)
    {
        ANGLE_CAPTURE(DrawElementsInstancedBaseVertexBaseInstance, context, mode, count, type,
                      indices, instancecount, basevertex, baseinstance);
        if (context->skipValidation() ||
            ValidateDrawElementsInstancedBaseVertexBaseInstance(
                context, mode, count, type, indices, instancecount, basevertex, baseinstance))
        {
            context->drawElementsInstancedBaseVertexBaseInstance(
                mode, count, type, indices, instancecount, basevertex, baseinstance);
        }
    }
}

void GL_APIENTRY DrawTransformFeedbackInstanced(GLenum mode, GLuint id, GLsizei instancecount)
{
    EVENT("(GLenum mode = 0x%X, GLuint id = %u, GLsizei instancecount = %d)", mode, id,
          instancecount);

    Context *context = GetValidGlobalContext();
    if (context)
    {
        ANGLE_CAPTURE(DrawTransformFeedbackInstanced, context, mode, id, instancecount);
        if (context->skipValidation() ||
            ValidateDrawTransformFeedbackInstanced(context, mode, id, instancecount))
        {
            context->drawTransformFeedbackInstanced(mode, id, instancecount);
        }
    }
}

void GL_APIENTRY DrawTransformFeedbackStreamInstanced(GLenum mode,
                                                      GLuint id,
                                                      GLuint stream,
                                                      GLsizei instancecount)
{
    EVENT("(GLenum mode = 0x%X, GLuint id = %u, GLuint stream = %u, GLsizei instancecount = %d)",
          mode, id, stream, instancecount);

    Context *context = GetValidGlobalContext();
    if (context)
    {
        ANGLE_CAPTURE(DrawTransformFeedbackStreamInstanced, context, mode, id, stream,
                      instancecount);
        if (context->skipValidation() ||
            ValidateDrawTransformFeedbackStreamInstanced(context, mode, id, stream, instancecount))
        {
            context->drawTransformFeedbackStreamInstanced(mode, id, stream, instancecount);
        }
    }
}

void GL_APIENTRY GetActiveAtomicCounterBufferiv(GLuint program,
                                                GLuint bufferIndex,
                                                GLenum pname,
                                                GLint *params)
{
    EVENT(
        "(GLuint program = %u, GLuint bufferIndex = %u, GLenum pname = 0x%X, GLint *params = "
        "0x%016" PRIxPTR ")",
        program, bufferIndex, pname, (uintptr_t)params);

    Context *context = GetValidGlobalContext();
    if (context)
    {
        ANGLE_CAPTURE(GetActiveAtomicCounterBufferiv, context, program, bufferIndex, pname, params);
        if (context->skipValidation() ||
            ValidateGetActiveAtomicCounterBufferiv(context, program, bufferIndex, pname, params))
        {
            context->getActiveAtomicCounterBufferiv(program, bufferIndex, pname, params);
        }
    }
}

void GL_APIENTRY GetInternalformativ(GLenum target,
                                     GLenum internalformat,
                                     GLenum pname,
                                     GLsizei bufSize,
                                     GLint *params)
{
    EVENT(
        "(GLenum target = 0x%X, GLenum internalformat = 0x%X, GLenum pname = 0x%X, GLsizei bufSize "
        "= %d, GLint *params = 0x%016" PRIxPTR ")",
        target, internalformat, pname, bufSize, (uintptr_t)params);

    Context *context = GetValidGlobalContext();
    if (context)
    {
        ANGLE_CAPTURE(GetInternalformativ, context, target, internalformat, pname, bufSize, params);
        if (context->skipValidation() ||
            ValidateGetInternalformativ(context, target, internalformat, pname, bufSize, params))
        {
            context->getInternalformativ(target, internalformat, pname, bufSize, params);
        }
    }
}

void GL_APIENTRY MemoryBarrier(GLbitfield barriers)
{
    EVENT("(GLbitfield barriers = 0x%X)", barriers);

    Context *context = GetValidGlobalContext();
    if (context)
    {
        ANGLE_CAPTURE(MemoryBarrier, context, barriers);
        if (context->skipValidation() || ValidateMemoryBarrier(context, barriers))
        {
            context->memoryBarrier(barriers);
        }
    }
}

void GL_APIENTRY TexStorage1D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width)
{
    EVENT(
        "(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = "
        "%d)",
        target, levels, internalformat, width);

    Context *context = GetValidGlobalContext();
    if (context)
    {
        ANGLE_CAPTURE(TexStorage1D, context, target, levels, internalformat, width);
        if (context->skipValidation() ||
            ValidateTexStorage1D(context, target, levels, internalformat, width))
        {
            context->texStorage1D(target, levels, internalformat, width);
        }
    }
}

void GL_APIENTRY
TexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
{
    EVENT(
        "(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = "
        "%d, GLsizei height = %d)",
        target, levels, internalformat, width, height);

    Context *context = GetValidGlobalContext();
    if (context)
    {
        TextureType targetPacked = FromGLenum<TextureType>(target);
        ANGLE_CAPTURE(TexStorage2D, context, targetPacked, levels, internalformat, width, height);
        if (context->skipValidation() ||
            ValidateTexStorage2D(context, targetPacked, levels, internalformat, width, height))
        {
            context->texStorage2D(targetPacked, levels, internalformat, width, height);
        }
    }
}

void GL_APIENTRY TexStorage3D(GLenum target,
                              GLsizei levels,
                              GLenum internalformat,
                              GLsizei width,
                              GLsizei height,
                              GLsizei depth)
{
    EVENT(
        "(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = "
        "%d, GLsizei height = %d, GLsizei depth = %d)",
        target, levels, internalformat, width, height, depth);

    Context *context = GetValidGlobalContext();
    if (context)
    {
        TextureType targetPacked = FromGLenum<TextureType>(target);
        ANGLE_CAPTURE(TexStorage3D, context, targetPacked, levels, internalformat, width, height,
                      depth);
        if (context->skipValidation() || ValidateTexStorage3D(context, targetPacked, levels,
                                                              internalformat, width, height, depth))
        {
            context->texStorage3D(targetPacked, levels, internalformat, width, height, depth);
        }
    }
}
}  // namespace gl
