Commit c935ba5b by Mohan Maiya Committed by Commit Bot

Vulkan: Collect inactive varyings by block name for I/O blocks

ANGLE only collects inactive varyings by instance name. The SPIR-V transformer expects I/O blocks to be identified by block name. If an I/O block is inactive, an assertion would fire because the block name is not in the shader variable info map. Bug: angleproject:5676 Test: GLSLTest_ES31.VaryingIOBlockNotDeclaredIn*Shader* Change-Id: I40e51c9770b03457e3896dcb2afa4e9525b098d8 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2742658Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Mohan Maiya <m.maiya@samsung.com>
parent 2eae90ab
......@@ -871,6 +871,11 @@ bool VaryingPacking::collectAndPackUserVaryings(gl::InfoLog &infoLog,
if (!output->isBuiltIn())
{
mInactiveVaryingMappedNames[ref.backShaderStage].push_back(output->mappedName);
if (output->isShaderIOBlock)
{
mInactiveVaryingMappedNames[ref.backShaderStage].push_back(
output->mappedStructOrBlockName);
}
}
continue;
}
......@@ -885,11 +890,21 @@ bool VaryingPacking::collectAndPackUserVaryings(gl::InfoLog &infoLog,
uniqueFullNames[ref.frontShaderStage].count(input->name) == 0)
{
mInactiveVaryingMappedNames[ref.frontShaderStage].push_back(input->mappedName);
if (input->isShaderIOBlock)
{
mInactiveVaryingMappedNames[ref.frontShaderStage].push_back(
input->mappedStructOrBlockName);
}
}
if (output && !output->isBuiltIn() &&
uniqueFullNames[ref.backShaderStage].count(output->name) == 0)
{
mInactiveVaryingMappedNames[ref.backShaderStage].push_back(output->mappedName);
if (output->isShaderIOBlock)
{
mInactiveVaryingMappedNames[ref.backShaderStage].push_back(
output->mappedStructOrBlockName);
}
}
}
......
......@@ -5205,6 +5205,82 @@ TEST_P(GLSLTest_ES3, VaryingStructNotStaticallyUsedInFragmentShader)
ANGLE_GL_PROGRAM(program, kVS, kFS);
}
// Test that a shader IO block varying that's not declared in the fragment shader links
// successfully.
TEST_P(GLSLTest_ES31, VaryingIOBlockNotDeclaredInFragmentShader)
{
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_shader_io_blocks"));
constexpr char kVS[] =
R"(#version 310 es
#extension GL_EXT_shader_io_blocks : require
precision highp float;
in vec4 inputAttribute;
out Block_inout { vec4 value; } user_out;
void main()
{
gl_Position = inputAttribute;
user_out.value = vec4(4.0, 5.0, 6.0, 7.0);
})";
constexpr char kFS[] =
R"(#version 310 es
#extension GL_EXT_shader_io_blocks : require
precision highp float;
layout(location = 0) out mediump vec4 color;
void main()
{
color = vec4(1, 0, 0, 1);
})";
ANGLE_GL_PROGRAM(program, kVS, kFS);
drawQuad(program.get(), "inputAttribute", 0.5f);
ASSERT_GL_NO_ERROR();
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::red);
}
// Test that a shader IO block varying that's not declared in the vertex shader links
// successfully.
TEST_P(GLSLTest_ES31, VaryingIOBlockNotDeclaredInVertexShader)
{
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_shader_io_blocks"));
constexpr char kVS[] =
R"(#version 310 es
#extension GL_EXT_shader_io_blocks : require
precision highp float;
in vec4 inputAttribute;
void main()
{
gl_Position = inputAttribute;
})";
constexpr char kFS[] =
R"(#version 310 es
#extension GL_EXT_shader_io_blocks : require
precision highp float;
in Block_inout { vec4 value; } user_in;
layout(location = 0) out mediump vec4 color;
void main()
{
color = vec4(1, 0, 0, 1);
})";
ANGLE_GL_PROGRAM(program, kVS, kFS);
drawQuad(program.get(), "inputAttribute", 0.5f);
ASSERT_GL_NO_ERROR();
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::red);
}
// Test that a varying struct that's not declared in the fragment shader links successfully.
// GLSL ES 3.00.6 section 4.3.10.
TEST_P(GLSLTest_ES3, VaryingStructNotDeclaredInFragmentShader)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment