src/third_party/angle/src/tests/gl_tests/UniformBufferTest.cpp
// Tests the detaching shaders from the program and using uniform blocks works.
// This covers a bug in ANGLE's D3D back-end.
Tests the detaching shaders from the program and using uniform blocks works.
This covers a bug in ANGLE's D3D back-end.
Tests the detaching shaders from the program and using uniform blocks works . This covers a bug in ANGLE ' s D3D back - end .
TEST_P(UniformBufferTest, DetachShaders)
{
    GLuint vertexShader = CompileShader(GL_VERTEX_SHADER, essl3_shaders::vs::Simple());
    ASSERT_NE(0u, vertexShader);
    GLuint kFS = CompileShader(GL_FRAGMENT_SHADER, mkFS);
    ASSERT_NE(0u, kFS);
    GLuint program = glCreateProgram();
    glAttachShader(program, vertexShader);
    glAttachShader(program, kFS);
    ASSERT_TRUE(LinkAttachedProgram(program));
    glDetachShader(program, vertexShader);
    glDetachShader(program, kFS);
    glDeleteShader(vertexShader);
    glDeleteShader(kFS);
    glClear(GL_COLOR_BUFFER_BIT);
    float floatData[4] = {0.5f, 0.75f, 0.25f, 1.0f};
    glBindBuffer(GL_UNIFORM_BUFFER, mUniformBuffer);
    glBufferData(GL_UNIFORM_BUFFER, sizeof(float) * 4, floatData, GL_STATIC_DRAW);
    glBindBufferBase(GL_UNIFORM_BUFFER, 0, mUniformBuffer);
    GLint uniformBufferIndex = glGetUniformBlockIndex(mProgram, "uni");
    ASSERT_NE(uniformBufferIndex, -1);
    glUniformBlockBinding(program, uniformBufferIndex, 0);
    drawQuad(program, essl3_shaders::PositionAttrib(), 0.5f);
    ASSERT_GL_NO_ERROR();
    EXPECT_PIXEL_NEAR(0, 0, 128, 191, 64, 255, 1);
    glDeleteProgram(program);
}
TEST_P ( UniformBufferTest , DetachShaders ) { GLuint vertexShader = CompileShader ( GL_VERTEX_SHADER , essl3_shaders :: vs :: Simple ( ) ) ; ASSERT_NE ( 0u , vertexShader ) ; GLuint kFS = CompileShader ( GL_FRAGMENT_SHADER , mkFS ) ; ASSERT_NE ( 0u , kFS ) ; GLuint program = glCreateProgram ( ) ; glAttachShader ( program , vertexShader ) ; glAttachShader ( program , kFS ) ; ASSERT_TRUE ( LinkAttachedProgram ( program ) ) ; glDetachShader ( program , vertexShader ) ; glDetachShader ( program , kFS ) ; glDeleteShader ( vertexShader ) ; glDeleteShader ( kFS ) ; glClear ( GL_COLOR_BUFFER_BIT ) ; float floatData [ 4 ] = { 0.5f , 0.75f , 0.25f , 1.0f } ; glBindBuffer ( GL_UNIFORM_BUFFER , mUniformBuffer ) ; glBufferData ( GL_UNIFORM_BUFFER , sizeof ( float ) * 4 , floatData , GL_STATIC_DRAW ) ; glBindBufferBase ( GL_UNIFORM_BUFFER , 0 , mUniformBuffer ) ; GLint uniformBufferIndex = glGetUniformBlockIndex ( mProgram , " " ) ; ASSERT_NE ( uniformBufferIndex , -1 ) ; glUniformBlockBinding ( program , uniformBufferIndex , 0 ) ; drawQuad ( program , essl3_shaders :: PositionAttrib ( ) , 0.5f ) ; ASSERT_GL_NO_ERROR ( ) ; EXPECT_PIXEL_NEAR ( 0 , 0 , 128 , 191 , 64 , 255 , 1 ) ; glDeleteProgram ( program ) ; }
Tests the detaching shaders from the program and using uniform blocks works.
Tests the detaching shaders from the program and using uniform blocks works .