src/third_party/angle/src/tests/gl_tests/UniformBufferTest.cpp
// Test uniform blocks used as instanced array take next binding point for each subsequent element.
Test uniform blocks used as instanced array take next binding point for each subsequent element.
Test uniform blocks used as instanced array take next binding point for each subsequent element .
TEST_P(UniformBufferTest31, ConsecutiveBindingsForBlockArray)
{
    constexpr char kFS[] =
        "#version 310 es\n"
        "precision highp float;\n"
        "layout(binding = 2) uniform uni {\n"
        "    vec4 color;\n"
        "} blocks[2];\n"
        "out vec4 fragColor;\n"
        "void main()\n"
        "{\n"
        "    fragColor = blocks[0].color + blocks[1].color;\n"
        "}";
    ANGLE_GL_PROGRAM(program, essl31_shaders::vs::Simple(), kFS);
    std::array<GLBuffer, 2> uniformBuffers;
    int px = getWindowWidth() / 2;
    int py = getWindowHeight() / 2;
    ASSERT_GL_NO_ERROR();
    GLuint vec4Size = 4 * sizeof(float);
    std::vector<char> v(vec4Size);
    float *first = reinterpret_cast<float *>(v.data());
    first[0] = 10.f / 255.f;
    first[1] = 20.f / 255.f;
    first[2] = 30.f / 255.f;
    first[3] = 40.f / 255.f;
    glBindBuffer(GL_UNIFORM_BUFFER, uniformBuffers[0].get());
    glBufferData(GL_UNIFORM_BUFFER, vec4Size, v.data(), GL_STATIC_DRAW);
    EXPECT_GL_NO_ERROR();
    glBindBufferBase(GL_UNIFORM_BUFFER, 2, uniformBuffers[0].get());
    ASSERT_GL_NO_ERROR();
    glBindBuffer(GL_UNIFORM_BUFFER, uniformBuffers[1].get());
    glBufferData(GL_UNIFORM_BUFFER, vec4Size, v.data(), GL_STATIC_DRAW);
    EXPECT_GL_NO_ERROR();
    glBindBufferBase(GL_UNIFORM_BUFFER, 3, uniformBuffers[1].get());
    drawQuad(program, essl31_shaders::PositionAttrib(), 0.5f);
    EXPECT_GL_NO_ERROR();
    EXPECT_PIXEL_EQ(px, py, 20, 40, 60, 80);
}
TEST_P ( UniformBufferTest31 , ConsecutiveBindingsForBlockArray ) { constexpr char kFS [ ] = " \n " " \n " " \n " " \n " " \n " " \n " " \n " " \n " " \n " " " ; ANGLE_GL_PROGRAM ( program , essl31_shaders :: vs :: Simple ( ) , kFS ) ; std :: array < GLBuffer , 2 > uniformBuffers ; int px = getWindowWidth ( ) / 2 ; int py = getWindowHeight ( ) / 2 ; ASSERT_GL_NO_ERROR ( ) ; GLuint vec4Size = 4 * sizeof ( float ) ; std :: vector < char > v ( vec4Size ) ; float * first = reinterpret_cast < float * > ( v . data ( ) ) ; first [ 0 ] = 10.f / 255.f ; first [ 1 ] = 20.f / 255.f ; first [ 2 ] = 30.f / 255.f ; first [ 3 ] = 40.f / 255.f ; glBindBuffer ( GL_UNIFORM_BUFFER , uniformBuffers [ 0 ] . get ( ) ) ; glBufferData ( GL_UNIFORM_BUFFER , vec4Size , v . data ( ) , GL_STATIC_DRAW ) ; EXPECT_GL_NO_ERROR ( ) ; glBindBufferBase ( GL_UNIFORM_BUFFER , 2 , uniformBuffers [ 0 ] . get ( ) ) ; ASSERT_GL_NO_ERROR ( ) ; glBindBuffer ( GL_UNIFORM_BUFFER , uniformBuffers [ 1 ] . get ( ) ) ; glBufferData ( GL_UNIFORM_BUFFER , vec4Size , v . data ( ) , GL_STATIC_DRAW ) ; EXPECT_GL_NO_ERROR ( ) ; glBindBufferBase ( GL_UNIFORM_BUFFER , 3 , uniformBuffers [ 1 ] . get ( ) ) ; drawQuad ( program , essl31_shaders :: PositionAttrib ( ) , 0.5f ) ; EXPECT_GL_NO_ERROR ( ) ; EXPECT_PIXEL_EQ ( px , py , 20 , 40 , 60 , 80 ) ; }
Test uniform blocks used as instanced array take next binding point for each subsequent element.
Test uniform blocks used as instanced array take next binding point for each subsequent element .
// Let's create a buffer which contains one vec4.