Hash :
d221cf40
        
        Author :
  
        
        Date :
2025-04-24T00:00:00
        
      
Adjust EXT_base_instance emulation conditions * EXT_base_instance may be emulated only on the GL backend. Other backends either support it directly or do not support at all. * EXT_base_instance is never exposed to WebGL. Bug: angleproject:355645824 Change-Id: I1edea83d83b1e6865eee8022c7110b05ea37d989 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6527730 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Alexey Knyazev <lexa.knyazev@gmail.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 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629
//
// Copyright 2020 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.
//
// DrawBaseVertexVariantsTest: Tests variants of drawElements*BaseVertex* call from different
// extensions
#include "gpu_info_util/SystemInfo.h"
#include "test_utils/ANGLETest.h"
#include "test_utils/gl_raii.h"
#include <numeric>
using namespace angle;
namespace
{
// Create a kWidth * kHeight canvas equally split into kCountX * kCountY tiles
// each containing a quad partially covering each tile
constexpr uint32_t kWidth                   = 256;
constexpr uint32_t kHeight                  = 256;
constexpr uint32_t kCountX                  = 8;
constexpr uint32_t kCountY                  = 8;
constexpr int kBoxCount                     = kCountX * kCountY;
constexpr uint32_t kIndexPatternRepeatCount = 3;
constexpr std::array<GLfloat, 2> kTileSize  = {
    1.f / static_cast<GLfloat>(kCountX),
    1.f / static_cast<GLfloat>(kCountY),
};
constexpr std::array<uint32_t, 2> kTilePixelSize  = {kWidth / kCountX, kHeight / kCountY};
constexpr std::array<GLfloat, 2> kQuadRadius      = {0.25f * kTileSize[0], 0.25f * kTileSize[1]};
constexpr std::array<uint32_t, 2> kPixelCheckSize = {
    static_cast<uint32_t>(kQuadRadius[0] * kWidth),
    static_cast<uint32_t>(kQuadRadius[1] * kHeight)};
constexpr GLenum kBufferDataUsage[] = {GL_STATIC_DRAW, GL_DYNAMIC_DRAW, GL_STREAM_DRAW};
constexpr std::array<GLfloat, 2> GetTileCenter(uint32_t x, uint32_t y)
{
    return {
        kTileSize[0] * (0.5f + static_cast<GLfloat>(x)),
        kTileSize[1] * (0.5f + static_cast<GLfloat>(y)),
    };
}
constexpr std::array<std::array<GLfloat, 2>, 4> GetQuadVertices(uint32_t x, uint32_t y)
{
    const auto center = GetTileCenter(x, y);
    return {
        std::array<GLfloat, 2>{center[0] - kQuadRadius[0], center[1] - kQuadRadius[1]},
        std::array<GLfloat, 2>{center[0] + kQuadRadius[0], center[1] - kQuadRadius[1]},
        std::array<GLfloat, 2>{center[0] + kQuadRadius[0], center[1] + kQuadRadius[1]},
        std::array<GLfloat, 2>{center[0] - kQuadRadius[0], center[1] + kQuadRadius[1]},
    };
}
enum class DrawCallVariants
{
    DrawElementsBaseVertexEXT,
    DrawElementsBaseVertexOES,
    DrawElementsInstancedBaseVertexEXT,
    DrawElementsInstancedBaseVertexOES,
    DrawRangeElementsBaseVertexEXT,
    DrawRangeElementsBaseVertexOES,
    DrawElementsInstancedBaseVertexBaseInstanceEXT,
    DrawElementsInstancedBaseVertexBaseInstanceANGLE
};
using DrawBaseVertexVariantsTestParams = std::tuple<angle::PlatformParameters, GLenum>;
std::string DrawBaseVertexVariantsTestPrint(
    const ::testing::TestParamInfo<DrawBaseVertexVariantsTestParams> ¶msInfo)
{
    const DrawBaseVertexVariantsTestParams ¶ms = paramsInfo.param;
    std::ostringstream out;
    out << std::get<0>(params) << "__";
    switch (std::get<1>(params))
    {
        case GL_STATIC_DRAW:
            out << "STATIC_DRAW";
            break;
        case GL_DYNAMIC_DRAW:
            out << "DYNAMIC_DRAW";
            break;
        case GL_STREAM_DRAW:
            out << "STREAM_DRAW";
            break;
        default:
            out << "UPDATE_THIS_SWITCH";
            break;
    }
    return out.str();
}
// These tests check correctness of variants of baseVertex draw calls from different extensions
class DrawBaseVertexVariantsTest : public ANGLETest<DrawBaseVertexVariantsTestParams>
{
  protected:
    DrawBaseVertexVariantsTest()
    {
        setWindowWidth(kWidth);
        setWindowHeight(kHeight);
        setConfigRedBits(8);
        setConfigGreenBits(8);
        setConfigBlueBits(8);
        setConfigAlphaBits(8);
        setExtensionsEnabled(false);
        std::array<GLushort, 6> indices = {0, 1, 2, 0, 2, 3};
        mIndices.resize(indices.size() * kIndexPatternRepeatCount);
        for (uint32_t i = 0; i < kIndexPatternRepeatCount; i++)
        {
            size_t o  = i * indices.size();
            size_t vo = i * 4;  // each quad has 4 vertices, index offset by 4
            for (size_t j = 0; j < indices.size(); j++)
            {
                mIndices[o + j] = vo + indices[j];
            }
        }
        mColorPalette = {GLColor(0x7f, 0x7f, 0x7f, 0xff),
                         GLColor::red,
                         GLColor::green,
                         GLColor::yellow,
                         GLColor::blue,
                         GLColor::magenta,
                         GLColor::cyan,
                         GLColor::white};
        for (uint32_t y = 0; y < kCountY; ++y)
        {
            for (uint32_t x = 0; x < kCountX; ++x)
            {
                // v3 ---- v2
                // |       |
                // |       |
                // v0 ---- v1
                const auto vs = ::GetQuadVertices(x, y);
                for (const auto &v : vs)
                {
                    mVertices.insert(mVertices.end(), v.begin(), v.end());
                }
                const auto &colorPicked = mColorPalette[(x + y) % mColorPalette.size()];
                for (int i = 0; i < 4; ++i)
                {
                    mVertexColors.push_back(colorPicked.R);
                    mVertexColors.push_back(colorPicked.G);
                    mVertexColors.push_back(colorPicked.B);
                    mVertexColors.push_back(colorPicked.A);
                }
            }
        }
        mRegularIndices.resize(kCountY * kCountX * mIndices.size());
        for (uint32_t y = 0; y < kCountY; y++)
        {
            for (uint32_t x = 0; x < kCountX; x++)
            {
                uint32_t i  = x + y * kCountX;
                uint32_t oi = 6 * i;
                uint32_t ov = 4 * i;
                for (uint32_t j = 0; j < 6; j++)
                {
                    mRegularIndices[oi + j] = mIndices[j] + ov;
                }
            }
        }
    }
    void setupProgram(GLProgram &program)
    {
        constexpr char vs[] = R"(
precision mediump float;
attribute vec2 vPosition;
attribute vec4 vColor;
varying vec4 color;
void main()
{
    gl_Position = vec4(vec3(vPosition, 1.0) * 2.0 - 1.0, 1.0);
    color = vColor;
})";
        constexpr char fs[] = R"(
precision mediump float;
varying vec4 color;
void main()
{
    gl_FragColor = color;
})";
        program.makeRaster(vs, fs);
        EXPECT_GL_NO_ERROR();
        ASSERT_TRUE(program.valid());
        glUseProgram(program);
        mPositionLoc = glGetAttribLocation(program, "vPosition");
        ASSERT_NE(-1, mPositionLoc);
        mColorLoc = glGetAttribLocation(program, "vColor");
        ASSERT_NE(-1, mColorLoc);
    }
    void setupIndexedBuffers(GLBuffer &vertexPositionBuffer,
                             GLBuffer &vertexColorBuffer,
                             GLBuffer &indexBuffer)
    {
        GLenum usage = std::get<1>(GetParam());
        glBindBuffer(GL_ARRAY_BUFFER, vertexColorBuffer);
        glBufferData(GL_ARRAY_BUFFER, sizeof(GLubyte) * mVertexColors.size(), mVertexColors.data(),
                     usage);
        glEnableVertexAttribArray(mColorLoc);
        glVertexAttribPointer(mColorLoc, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, 0);
        glBindBuffer(GL_ARRAY_BUFFER, vertexPositionBuffer);
        glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * mVertices.size(), mVertices.data(), usage);
        glEnableVertexAttribArray(mPositionLoc);
        glVertexAttribPointer(mPositionLoc, 2, GL_FLOAT, GL_FALSE, 0, 0);
        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer);
        glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(GLushort) * mIndices.size(), mIndices.data(),
                     usage);
        ASSERT_GL_NO_ERROR();
    }
    void doDrawElementsBaseVertex(DrawCallVariants drawCallType,
                                  GLenum mode,
                                  GLsizei count,
                                  GLenum type,
                                  const void *indices,
                                  GLint basevertex)
    {
        switch (drawCallType)
        {
            case DrawCallVariants::DrawElementsBaseVertexEXT:
                glDrawElementsBaseVertexEXT(mode, count, type, indices, basevertex);
                break;
            case DrawCallVariants::DrawElementsBaseVertexOES:
                glDrawElementsBaseVertexOES(mode, count, type, indices, basevertex);
                break;
            default:
                UNREACHABLE();
                break;
        }
    }
    void doDrawElementsInstancedBaseVertex(DrawCallVariants drawCallType,
                                           GLenum mode,
                                           GLsizei count,
                                           GLenum type,
                                           const void *indices,
                                           GLsizei instancecount,
                                           GLint basevertex)
    {
        switch (drawCallType)
        {
            case DrawCallVariants::DrawElementsInstancedBaseVertexEXT:
                glDrawElementsInstancedBaseVertexEXT(mode, count, type, indices, instancecount,
                                                     basevertex);
                break;
            case DrawCallVariants::DrawElementsInstancedBaseVertexOES:
                glDrawElementsInstancedBaseVertexOES(mode, count, type, indices, instancecount,
                                                     basevertex);
                break;
            default:
                UNREACHABLE();
                break;
        }
    }
    void doDrawRangeElementsBaseVertex(DrawCallVariants drawCallType,
                                       GLenum mode,
                                       GLuint start,
                                       GLuint end,
                                       GLsizei count,
                                       GLenum type,
                                       const void *indices,
                                       GLint basevertex)
    {
        switch (drawCallType)
        {
            case DrawCallVariants::DrawRangeElementsBaseVertexEXT:
                glDrawRangeElementsBaseVertexEXT(mode, start, end, count, type, indices,
                                                 basevertex);
                break;
            case DrawCallVariants::DrawRangeElementsBaseVertexOES:
                glDrawRangeElementsBaseVertexOES(mode, start, end, count, type, indices,
                                                 basevertex);
                break;
            default:
                UNREACHABLE();
                break;
        }
    }
    void doDrawElementsInstancedBaseVertexBaseInstance(DrawCallVariants drawCallType,
                                                       GLenum mode,
                                                       GLsizei count,
                                                       GLenum type,
                                                       const void *indices,
                                                       GLsizei instancecount,
                                                       GLint basevertex,
                                                       GLuint baseinstance)
    {
        switch (drawCallType)
        {
            case DrawCallVariants::DrawElementsInstancedBaseVertexBaseInstanceEXT:
                glDrawElementsInstancedBaseVertexBaseInstanceEXT(
                    mode, count, type, indices, instancecount, basevertex, baseinstance);
                break;
            case DrawCallVariants::DrawElementsInstancedBaseVertexBaseInstanceANGLE:
                glDrawElementsInstancedBaseVertexBaseInstanceANGLE(
                    mode, count, type, indices, instancecount, basevertex, baseinstance);
                break;
            default:
                UNREACHABLE();
                break;
        }
    }
    void doDrawElementsBaseVertexVariants(DrawCallVariants drawCallType)
    {
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        int baseRepetition = 0;
        int i              = 0;
        // Start at various repetitions within the patterned index buffer to exercise base
        // index.
        static_assert(kIndexPatternRepeatCount >= 3, "Repeat pattern count should be at least 3");
        while (i < kBoxCount)
        {
            int repetitionCount = std::min(3 - baseRepetition, kBoxCount - i);
            updateVertexColorData(i, repetitionCount);
            switch (drawCallType)
            {
                case DrawCallVariants::DrawElementsInstancedBaseVertexBaseInstanceEXT:
                case DrawCallVariants::DrawElementsInstancedBaseVertexBaseInstanceANGLE:
                    doDrawElementsInstancedBaseVertexBaseInstance(
                        drawCallType, GL_TRIANGLES, repetitionCount * 6, GL_UNSIGNED_SHORT,
                        reinterpret_cast<GLvoid *>(
                            static_cast<uintptr_t>(baseRepetition * 6 * sizeof(GLushort))),
                        1, (i - baseRepetition) * 4, 0);
                    break;
                case DrawCallVariants::DrawElementsBaseVertexEXT:
                case DrawCallVariants::DrawElementsBaseVertexOES:
                    doDrawElementsBaseVertex(
                        drawCallType, GL_TRIANGLES, repetitionCount * 6, GL_UNSIGNED_SHORT,
                        reinterpret_cast<GLvoid *>(
                            static_cast<uintptr_t>(baseRepetition * 6 * sizeof(GLushort))),
                        (i - baseRepetition) * 4);
                    break;
                case DrawCallVariants::DrawElementsInstancedBaseVertexEXT:
                case DrawCallVariants::DrawElementsInstancedBaseVertexOES:
                    doDrawElementsInstancedBaseVertex(
                        drawCallType, GL_TRIANGLES, repetitionCount * 6, GL_UNSIGNED_SHORT,
                        reinterpret_cast<GLvoid *>(
                            static_cast<uintptr_t>(baseRepetition * 6 * sizeof(GLushort))),
                        1, (i - baseRepetition) * 4);
                    break;
                case DrawCallVariants::DrawRangeElementsBaseVertexEXT:
                case DrawCallVariants::DrawRangeElementsBaseVertexOES:
                    doDrawRangeElementsBaseVertex(drawCallType, GL_TRIANGLES, baseRepetition * 4,
                                                  (baseRepetition + repetitionCount) * 4 - 1,
                                                  repetitionCount * 6, GL_UNSIGNED_SHORT,
                                                  reinterpret_cast<GLvoid *>(static_cast<uintptr_t>(
                                                      baseRepetition * 6 * sizeof(GLushort))),
                                                  (i - baseRepetition) * 4);
                    break;
                default:
                    EXPECT_TRUE(false);
                    break;
            }
            baseRepetition = (baseRepetition + 1) % 3;
            i += repetitionCount;
        }
        EXPECT_GL_NO_ERROR();
        checkDrawResult();
    }
    void updateVertexColorData(GLint drawnQuadCount, GLint toDrawQuadCount)
    {
        // update the vertex color of the next [count] of quads to draw
        if (std::get<1>(GetParam()) == GL_STATIC_DRAW)
        {
            return;
        }
        GLint offset = sizeof(GLubyte) * drawnQuadCount * 4 * sizeof(GLColor);
        for (GLint i = 0; i < toDrawQuadCount; i++)
        {
            const GLColor &color = mColorPalette[(drawnQuadCount + i) % mColorPalette.size()];
            for (GLint j = 0; j < 4; j++)
            {
                glBufferSubData(GL_ARRAY_BUFFER, offset, sizeof(GLColor), color.data());
                offset += sizeof(GLColor);
            }
        }
    }
    void checkDrawResult()
    {
        bool dynamicLayout = std::get<1>(GetParam()) == GL_STATIC_DRAW ? false : true;
        for (uint32_t y = 0; y < kCountY; ++y)
        {
            for (uint32_t x = 0; x < kCountX; ++x)
            {
                uint32_t center_x = x * kTilePixelSize[0] + kTilePixelSize[0] / 2;
                uint32_t center_y = y * kTilePixelSize[1] + kTilePixelSize[1] / 2;
                const auto &color =
                    mColorPalette[(dynamicLayout ? x : x + y) % mColorPalette.size()];
                EXPECT_PIXEL_NEAR(center_x - kPixelCheckSize[0] / 2,
                                  center_y - kPixelCheckSize[1] / 2, color[0], color[1], color[2],
                                  color[3], 1);
            }
        }
    }
    bool requestAngleBaseVertexBaseInstanceExtensions()
    {
        if (getClientMajorVersion() <= 2)
        {
            if (!EnsureGLExtensionEnabled("GL_ANGLE_instanced_arrays"))
            {
                return false;
            }
        }
        if (!EnsureGLExtensionEnabled("GL_ANGLE_base_vertex_base_instance"))
        {
            return false;
        }
        return EnsureGLExtensionEnabled("GL_ANGLE_base_vertex_base_instance_shader_builtin");
    }
    std::vector<GLushort> mIndices;
    std::vector<GLfloat> mVertices;
    std::vector<GLubyte> mVertexColors;
    std::vector<GLColor> mColorPalette;
    std::vector<GLushort> mRegularIndices;
    GLint mPositionLoc;
    GLint mColorLoc;
};
// Test drawElementsBaseVertex from EXT_draw_elements_base_vertex
TEST_P(DrawBaseVertexVariantsTest, DrawElementsBaseVertexEXT)
{
    ANGLE_SKIP_TEST_IF(!EnsureGLExtensionEnabled("GL_EXT_draw_elements_base_vertex"));
    GLProgram program;
    setupProgram(program);
    GLBuffer indexBuffer;
    GLBuffer vertexPositionBuffer;
    GLBuffer vertexColorBuffer;
    setupIndexedBuffers(vertexPositionBuffer, vertexColorBuffer, indexBuffer);
    // for potential update vertex color later
    glBindBuffer(GL_ARRAY_BUFFER, vertexColorBuffer);
    doDrawElementsBaseVertexVariants(DrawCallVariants::DrawElementsBaseVertexEXT);
}
// Test drawElementsBaseVertex from OES_draw_elements_base_vertex
TEST_P(DrawBaseVertexVariantsTest, DrawElementsBaseVertexOES)
{
    ANGLE_SKIP_TEST_IF(!EnsureGLExtensionEnabled("GL_OES_draw_elements_base_vertex"));
    GLProgram program;
    setupProgram(program);
    GLBuffer indexBuffer;
    GLBuffer vertexPositionBuffer;
    GLBuffer vertexColorBuffer;
    setupIndexedBuffers(vertexPositionBuffer, vertexColorBuffer, indexBuffer);
    // for potential update vertex color later
    glBindBuffer(GL_ARRAY_BUFFER, vertexColorBuffer);
    doDrawElementsBaseVertexVariants(DrawCallVariants::DrawElementsBaseVertexOES);
}
// Test drawElementsInstancedBaseVertex from EXT_draw_elements_base_vertex
TEST_P(DrawBaseVertexVariantsTest, DrawElementsInstancedBaseVertexEXT)
{
    ANGLE_SKIP_TEST_IF(!EnsureGLExtensionEnabled("GL_EXT_draw_elements_base_vertex"));
    GLProgram program;
    setupProgram(program);
    GLBuffer indexBuffer;
    GLBuffer vertexPositionBuffer;
    GLBuffer vertexColorBuffer;
    setupIndexedBuffers(vertexPositionBuffer, vertexColorBuffer, indexBuffer);
    // for potential update vertex color later
    glBindBuffer(GL_ARRAY_BUFFER, vertexColorBuffer);
    doDrawElementsBaseVertexVariants(DrawCallVariants::DrawElementsInstancedBaseVertexEXT);
}
// Test drawElementsInstancedBaseVertex from OES_draw_elements_base_vertex
TEST_P(DrawBaseVertexVariantsTest, DrawElementsInstancedBaseVertexOES)
{
    ANGLE_SKIP_TEST_IF(!EnsureGLExtensionEnabled("GL_OES_draw_elements_base_vertex"));
    GLProgram program;
    setupProgram(program);
    GLBuffer indexBuffer;
    GLBuffer vertexPositionBuffer;
    GLBuffer vertexColorBuffer;
    setupIndexedBuffers(vertexPositionBuffer, vertexColorBuffer, indexBuffer);
    // for potential update vertex color later
    glBindBuffer(GL_ARRAY_BUFFER, vertexColorBuffer);
    doDrawElementsBaseVertexVariants(DrawCallVariants::DrawElementsInstancedBaseVertexOES);
}
// Test drawRangeElementsBaseVertex from EXT_draw_elements_base_vertex
TEST_P(DrawBaseVertexVariantsTest, DrawRangeElementsBaseVertexEXT)
{
    ANGLE_SKIP_TEST_IF(!EnsureGLExtensionEnabled("GL_EXT_draw_elements_base_vertex"));
    GLProgram program;
    setupProgram(program);
    GLBuffer indexBuffer;
    GLBuffer vertexPositionBuffer;
    GLBuffer vertexColorBuffer;
    setupIndexedBuffers(vertexPositionBuffer, vertexColorBuffer, indexBuffer);
    // for potential update vertex color later
    glBindBuffer(GL_ARRAY_BUFFER, vertexColorBuffer);
    doDrawElementsBaseVertexVariants(DrawCallVariants::DrawRangeElementsBaseVertexEXT);
}
// Test drawRangeElementsBaseVertex from OES_draw_elements_base_vertex
TEST_P(DrawBaseVertexVariantsTest, DrawRangeElementsBaseVertexOES)
{
    ANGLE_SKIP_TEST_IF(!EnsureGLExtensionEnabled("GL_OES_draw_elements_base_vertex"));
    GLProgram program;
    setupProgram(program);
    GLBuffer indexBuffer;
    GLBuffer vertexPositionBuffer;
    GLBuffer vertexColorBuffer;
    setupIndexedBuffers(vertexPositionBuffer, vertexColorBuffer, indexBuffer);
    // for potential update vertex color later
    glBindBuffer(GL_ARRAY_BUFFER, vertexColorBuffer);
    doDrawElementsBaseVertexVariants(DrawCallVariants::DrawRangeElementsBaseVertexOES);
}
// Test drawElementsInstancedBaseVertexBaseInstance from EXT_base_instance
TEST_P(DrawBaseVertexVariantsTest, DrawElementsInstancedBaseVertexBaseInstanceEXT)
{
    ANGLE_SKIP_TEST_IF(!EnsureGLExtensionEnabled("GL_EXT_base_instance") ||
                       !EnsureGLExtensionEnabled("GL_EXT_draw_elements_base_vertex"));
    GLProgram program;
    setupProgram(program);
    GLBuffer indexBuffer;
    GLBuffer vertexPositionBuffer;
    GLBuffer vertexColorBuffer;
    setupIndexedBuffers(vertexPositionBuffer, vertexColorBuffer, indexBuffer);
    // for potential update vertex color later
    glBindBuffer(GL_ARRAY_BUFFER, vertexColorBuffer);
    doDrawElementsBaseVertexVariants(
        DrawCallVariants::DrawElementsInstancedBaseVertexBaseInstanceEXT);
}
// Test drawElementsInstancedBaseVertexBaseInstance from ANGLE_base_vertex_base_instance
TEST_P(DrawBaseVertexVariantsTest, DrawElementsInstancedBaseVertexBaseInstanceANGLE)
{
    ANGLE_SKIP_TEST_IF(!requestAngleBaseVertexBaseInstanceExtensions());
    GLProgram program;
    setupProgram(program);
    GLBuffer indexBuffer;
    GLBuffer vertexPositionBuffer;
    GLBuffer vertexColorBuffer;
    setupIndexedBuffers(vertexPositionBuffer, vertexColorBuffer, indexBuffer);
    // for potential update vertex color later
    glBindBuffer(GL_ARRAY_BUFFER, vertexColorBuffer);
    doDrawElementsBaseVertexVariants(
        DrawCallVariants::DrawElementsInstancedBaseVertexBaseInstanceANGLE);
}
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(DrawBaseVertexVariantsTest);
ANGLE_INSTANTIATE_TEST_COMBINE_1(
    DrawBaseVertexVariantsTest,
    DrawBaseVertexVariantsTestPrint,
    testing::ValuesIn(kBufferDataUsage),
    ES3_D3D11(),
    ES3_METAL(),
    ES3_OPENGL().enable(Feature::AlwaysEnableEmulatedMultidrawExtensions),
    ES3_OPENGLES().enable(Feature::AlwaysEnableEmulatedMultidrawExtensions),
    ES3_VULKAN());
}  // namespace