Commit 44b9579c by Mohan Maiya Committed by Commit Bot

Vulkan: Treat varyings in a separable program as active

When separable programs are linked, varyings at the separable program's boundary need to be treated as active. Bug: angleproject:5557 Test: ProgramPipelineTest31.VaryingIOBlockSeparableProgram* Change-Id: I28af2bdf6478a408b3a7155ab4376ed6a19192f4 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2742659 Commit-Queue: Mohan Maiya <m.maiya@samsung.com> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarTim Van Patten <timvp@google.com>
parent 43271b34
...@@ -851,9 +851,20 @@ bool VaryingPacking::collectAndPackUserVaryings(gl::InfoLog &infoLog, ...@@ -851,9 +851,20 @@ bool VaryingPacking::collectAndPackUserVaryings(gl::InfoLog &infoLog,
// not active. GLES specs are a bit vague on whether it's allowed to only pack active // not active. GLES specs are a bit vague on whether it's allowed to only pack active
// varyings, though GLES 3.1 spec section 11.1.2.1 says that "device-dependent // varyings, though GLES 3.1 spec section 11.1.2.1 says that "device-dependent
// optimizations" may be used to make vertex shader outputs fit. // optimizations" may be used to make vertex shader outputs fit.
if ((input && output && output->staticUse) || isActiveBuiltInInput || //
isActiveBuiltInOutput || // When separable programs are linked, varyings at the separable program's boundary are
(isSeparableProgram && ((input && input->active) || (output && output->active)))) // treated as active. See section 7.4.1 in
// https://www.khronos.org/registry/OpenGL/specs/es/3.2/es_spec_3.2.pdf
bool matchedInputOutputStaticUse = (input && output && output->staticUse);
bool activeBuiltIn = (isActiveBuiltInInput || isActiveBuiltInOutput);
// Separable program requirements
bool separableActiveInput = (input && (input->active || !output));
bool separableActiveOutput = (output && (output->active || !input));
bool separableActiveVarying =
(isSeparableProgram && (separableActiveInput || separableActiveOutput));
if (matchedInputOutputStaticUse || activeBuiltIn || separableActiveVarying)
{ {
const sh::ShaderVariable *varying = output ? output : input; const sh::ShaderVariable *varying = output ? output : input;
......
...@@ -650,6 +650,48 @@ void main() ...@@ -650,6 +650,48 @@ void main()
EXPECT_GL_ERROR(GL_INVALID_OPERATION); EXPECT_GL_ERROR(GL_INVALID_OPERATION);
} }
// Test that a shader IO block varying with separable program links
// successfully.
TEST_P(ProgramPipelineTest31, VaryingIOBlockSeparableProgram)
{
// Only the Vulkan backend supports PPOs
ANGLE_SKIP_TEST_IF(!IsVulkan());
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;
in Block_inout { vec4 value; } user_in;
void main()
{
color = vec4(1, 0, 0, 1);
})";
bindProgramPipeline(kVS, kFS);
drawQuadWithPPO("inputAttribute", 0.5f, 1.0f);
ASSERT_GL_NO_ERROR();
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::red);
}
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(ProgramPipelineTest); GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(ProgramPipelineTest);
ANGLE_INSTANTIATE_TEST_ES3_AND_ES31(ProgramPipelineTest); ANGLE_INSTANTIATE_TEST_ES3_AND_ES31(ProgramPipelineTest);
......
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