src/third_party/angle/src/tests/gl_tests/UniformBufferTest.cpp
// Tests that active uniforms have the right names.
Tests that active uniforms have the right names.
Tests that active uniforms have the right names .
TEST_P(UniformBufferTest, ActiveUniformNames)
{
    constexpr char kVS[] =
        "#version 300 es\n"
        "in vec2 position;\n"
        "out vec2 v;\n"
        "uniform blockName1 {\n"
        "  float f1;\n"
        "} instanceName1;\n"
        "uniform blockName2 {\n"
        "  float f2;\n"
        "} instanceName2[1];\n"
        "void main() {\n"
        "  v = vec2(instanceName1.f1, instanceName2[0].f2);\n"
        "  gl_Position = vec4(position, 0, 1);\n"
        "}";
    constexpr char kFS[] =
        "#version 300 es\n"
        "precision highp float;\n"
        "in vec2 v;\n"
        "out vec4 color;\n"
        "void main() {\n"
        "  color = vec4(v, 0, 1);\n"
        "}";
    ANGLE_GL_PROGRAM(program, kVS, kFS);
    GLint activeUniformBlocks;
    glGetProgramiv(program, GL_ACTIVE_UNIFORM_BLOCKS, &activeUniformBlocks);
    ASSERT_EQ(2, activeUniformBlocks);
    GLuint index = glGetUniformBlockIndex(program, "blockName1");
    EXPECT_NE(GL_INVALID_INDEX, index);
    ASSERT_GL_NO_ERROR();
    index = glGetUniformBlockIndex(program, "blockName2[0]");
    EXPECT_NE(GL_INVALID_INDEX, index);
    ASSERT_GL_NO_ERROR();
    GLint activeUniforms;
    glGetProgramiv(program, GL_ACTIVE_UNIFORMS, &activeUniforms);
    ASSERT_EQ(2, activeUniforms);
    GLint size;
    GLenum type;
    GLint maxLength;
    GLsizei length;
    glGetProgramiv(program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &maxLength);
    std::vector<GLchar> strUniformNameBuffer(maxLength + 1, 0);
    const GLchar *uniformNames[1];
    uniformNames[0] = "blockName1.f1";
    glGetUniformIndices(program, 1, uniformNames, &index);
    EXPECT_NE(GL_INVALID_INDEX, index);
    ASSERT_GL_NO_ERROR();
    glGetActiveUniform(program, index, maxLength, &length, &size, &type, &strUniformNameBuffer[0]);
    EXPECT_EQ(1, size);
    EXPECT_GLENUM_EQ(GL_FLOAT, type);
    EXPECT_EQ("blockName1.f1", std::string(&strUniformNameBuffer[0]));
    uniformNames[0] = "blockName2.f2";
    glGetUniformIndices(program, 1, uniformNames, &index);
    EXPECT_NE(GL_INVALID_INDEX, index);
    ASSERT_GL_NO_ERROR();
    glGetActiveUniform(program, index, maxLength, &length, &size, &type, &strUniformNameBuffer[0]);
    EXPECT_EQ(1, size);
    EXPECT_GLENUM_EQ(GL_FLOAT, type);
    EXPECT_EQ("blockName2.f2", std::string(&strUniformNameBuffer[0]));
}
TEST_P ( UniformBufferTest , ActiveUniformNames ) { constexpr char kVS [ ] = " \n " " \n " " \n " " \n " " \n " " \n " " \n " " \n " " \n " " \n " " \n " " \n " " " ; constexpr char kFS [ ] = " \n " " \n " " \n " " \n " " \n " " \n " " " ; ANGLE_GL_PROGRAM ( program , kVS , kFS ) ; GLint activeUniformBlocks ; glGetProgramiv ( program , GL_ACTIVE_UNIFORM_BLOCKS , & activeUniformBlocks ) ; ASSERT_EQ ( 2 , activeUniformBlocks ) ; GLuint index = glGetUniformBlockIndex ( program , " " ) ; EXPECT_NE ( GL_INVALID_INDEX , index ) ; ASSERT_GL_NO_ERROR ( ) ; index = glGetUniformBlockIndex ( program , " " ) ; EXPECT_NE ( GL_INVALID_INDEX , index ) ; ASSERT_GL_NO_ERROR ( ) ; GLint activeUniforms ; glGetProgramiv ( program , GL_ACTIVE_UNIFORMS , & activeUniforms ) ; ASSERT_EQ ( 2 , activeUniforms ) ; GLint size ; GLenum type ; GLint maxLength ; GLsizei length ; glGetProgramiv ( program , GL_ACTIVE_UNIFORM_MAX_LENGTH , & maxLength ) ; std :: vector < GLchar > strUniformNameBuffer ( maxLength + 1 , 0 ) ; const GLchar * uniformNames [ 1 ] ; uniformNames [ 0 ] = " " ; glGetUniformIndices ( program , 1 , uniformNames , & index ) ; EXPECT_NE ( GL_INVALID_INDEX , index ) ; ASSERT_GL_NO_ERROR ( ) ; glGetActiveUniform ( program , index , maxLength , & length , & size , & type , & strUniformNameBuffer [ 0 ] ) ; EXPECT_EQ ( 1 , size ) ; EXPECT_GLENUM_EQ ( GL_FLOAT , type ) ; EXPECT_EQ ( " " , std :: string ( & strUniformNameBuffer [ 0 ] ) ) ; uniformNames [ 0 ] = " " ; glGetUniformIndices ( program , 1 , uniformNames , & index ) ; EXPECT_NE ( GL_INVALID_INDEX , index ) ; ASSERT_GL_NO_ERROR ( ) ; glGetActiveUniform ( program , index , maxLength , & length , & size , & type , & strUniformNameBuffer [ 0 ] ) ; EXPECT_EQ ( 1 , size ) ; EXPECT_GLENUM_EQ ( GL_FLOAT , type ) ; EXPECT_EQ ( " " , std :: string ( & strUniformNameBuffer [ 0 ] ) ) ; }
Tests that active uniforms have the right names.
Tests that active uniforms have the right names .