Skip to content

Commit

Permalink
Cherry-pick bce91c8033e3. <bug>
Browse files Browse the repository at this point in the history
    WebGL fails to compile shaders with out variables that are arrays and start with underscore
    rdar://126944294

    Reviewed by Chris Dumez.

    Integrates upstream commit:
    commit e0e91b8cbb2e096d2d009cd0d1fbe20d785f2263
    Author: Kimmo Kinnunen <kkinnunen@apple.com>
    Date:   Mon Apr 22 18:11:30 2024 -0700
    Metal: Fix rewritten out variables with underscores

    Fix compilation in case of output variables start with underscores.
    Make name emission always emit MSL name ANGLE_{name}, so that GLSL `_e`
    and `e` cannot clash. This regressed in angleproject:8558.

    Bug: b/335744344
    Change-Id: Ibae4dba4a24888acc1461582e69d48218ba11176
    Canonical link: https://commits.webkit.org/272448.959@safari-7618-branch

    Canonical link: https://commits.webkit.org/272448.958@safari-7618.2.12.10-branch

Canonical link: https://commits.webkit.org/274313.250@webkitglib/2.44
  • Loading branch information
kkinnunen-apple authored and aperezdc committed May 13, 2024
1 parent 203ecc0 commit 5a9234b
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions Source/ThirdParty/ANGLE/src/tests/gl_tests/GLSLTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18765,6 +18765,66 @@ void main()
verifyAttachment2DColor(3, textures[3], GL_TEXTURE_2D, 0, GLColor::white);
}

// Test that underscores in array names work with out arrays.
TEST_P(GLSLTest_ES3, UnderscoresWorkWithOutArrays)
{
GLuint fbo;
glGenFramebuffers(1, &fbo);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo);

GLuint textures[4];
glGenTextures(4, textures);

for (size_t texIndex = 0; texIndex < ArraySize(textures); texIndex++)
{
glBindTexture(GL_TEXTURE_2D, textures[texIndex]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, getWindowWidth(), getWindowHeight(), 0, GL_RGBA,
GL_UNSIGNED_BYTE, nullptr);
}

GLint maxDrawBuffers;
glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
ASSERT_GE(maxDrawBuffers, 4);

GLuint readFramebuffer;
glGenFramebuffers(1, &readFramebuffer);
glBindFramebuffer(GL_READ_FRAMEBUFFER, readFramebuffer);

constexpr char kFS[] = R"(#version 300 es
precision highp float;
out vec4 _e[4];
void main()
{
_e[0] = vec4(1.0, 0.0, 0.0, 1.0);
_e[1] = vec4(0.0, 1.0, 0.0, 1.0);
_e[2] = vec4(0.0, 0.0, 1.0, 1.0);
_e[3] = vec4(1.0, 1.0, 1.0, 1.0);
}
)";
ANGLE_GL_PROGRAM(program, essl3_shaders::vs::Simple(), kFS);
GLenum allBufs[4] = {GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2,
GL_COLOR_ATTACHMENT3};
constexpr GLuint kMaxBuffers = 4;
// Enable all draw buffers.
for (GLuint texIndex = 0; texIndex < kMaxBuffers; texIndex++)
{
glBindTexture(GL_TEXTURE_2D, textures[texIndex]);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + texIndex, GL_TEXTURE_2D,
textures[texIndex], 0);
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + texIndex, GL_TEXTURE_2D,
textures[texIndex], 0);
}
glDrawBuffers(kMaxBuffers, allBufs);

// Draw with simple program.
drawQuad(program, essl3_shaders::PositionAttrib(), 0.5f, 1.0f, true);
ASSERT_GL_NO_ERROR();
verifyAttachment2DColor(0, textures[0], GL_TEXTURE_2D, 0, GLColor::red);
verifyAttachment2DColor(1, textures[1], GL_TEXTURE_2D, 0, GLColor::green);
verifyAttachment2DColor(2, textures[2], GL_TEXTURE_2D, 0, GLColor::blue);
verifyAttachment2DColor(3, textures[3], GL_TEXTURE_2D, 0, GLColor::white);
}

} // anonymous namespace

ANGLE_INSTANTIATE_TEST_ES2_AND_ES3_AND(
Expand Down

0 comments on commit 5a9234b

Please sign in to comment.