Commit 604d873e by Olli Etuaho Committed by Commit Bot

Fix multiview combined with flat interpolation

Declaring HLSL outputs with SV_* semantics after the ones with TEXCOORD* semantics makes multiview shaders that contain a flat varying run correctly. This is a workaround for what seems to be a bug in the DX runtime, reproducible on at least NVIDIA and Intel. This also adds another, clearer test case for flat interpolation used together with multiview. BUG=angleproject:2062 TEST=angle_end2end_tests Change-Id: I127b85497aa4fee58b74893165a980cbdd4444d6 Reviewed-on: https://chromium-review.googlesource.com/1146809Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
parent 18f7e503
......@@ -400,17 +400,6 @@ void DynamicHLSL::generateVaryingLinkHLSL(const VaryingPacking &varyingPacking,
<< ";\n";
}
if (builtins.glViewportIndex.enabled)
{
hlslStream << " nointerpolation uint gl_ViewportIndex : "
<< builtins.glViewportIndex.str() << ";\n";
}
if (builtins.glLayer.enabled)
{
hlslStream << " nointerpolation uint gl_Layer : " << builtins.glLayer.str() << ";\n";
}
std::string varyingSemantic =
GetVaryingSemantic(mRenderer->getMajorShaderModel(), programUsesPointSize);
......@@ -450,6 +439,20 @@ void DynamicHLSL::generateVaryingLinkHLSL(const VaryingPacking &varyingPacking,
hlslStream << " v" << registerIndex << " : " << varyingSemantic << registerIndex << ";\n";
}
// Note that the following outputs need to be declared after the others to make multiview
// shaders with a flat varying to work correctly. This is a workaround for a D3D bug.
if (builtins.glViewportIndex.enabled)
{
hlslStream << " nointerpolation uint gl_ViewportIndex : "
<< builtins.glViewportIndex.str() << ";\n";
}
if (builtins.glLayer.enabled)
{
hlslStream << " nointerpolation uint gl_Layer : " << builtins.glLayer.str() << ";\n";
}
hlslStream << "};\n";
}
......
......@@ -2023,13 +2023,6 @@ TEST_P(MultiviewRenderTest, FlatInterpolation)
return;
}
// Test failing on P400 graphics card (anglebug.com/2228)
ANGLE_SKIP_TEST_IF(IsWindows() && IsD3D11() && IsNVIDIA());
// TODO(mradev): Find out why this fails on Win10 Intel HD 630 D3D11
// (http://anglebug.com/2062)
ANGLE_SKIP_TEST_IF(IsWindows() && IsIntel() && IsD3D11());
const std::string vsSource =
"#version 300 es\n"
"#extension GL_OVR_multiview : require\n"
......@@ -2070,6 +2063,52 @@ TEST_P(MultiviewRenderTest, FlatInterpolation)
EXPECT_EQ(GLColor::green, GetViewColor(0, 0, 1));
}
// This test assigns gl_ViewID_OVR to a flat int varying and then sets the color based on that
// varying in the fragment shader.
TEST_P(MultiviewRenderTest, FlatInterpolation2)
{
if (!requestMultiviewExtension())
{
return;
}
const std::string vsSource =
"#version 300 es\n"
"#extension GL_OVR_multiview : require\n"
"layout(num_views = 2) in;\n"
"in vec3 vPosition;\n"
"flat out int flatVarying;\n"
"void main()\n"
"{\n"
" gl_Position = vec4(vPosition, 1.);\n"
" flatVarying = int(gl_ViewID_OVR);\n"
"}\n";
const std::string fsSource =
"#version 300 es\n"
"#extension GL_OVR_multiview : require\n"
"precision mediump float;\n"
"flat in int flatVarying;\n"
"out vec4 col;\n"
"void main()\n"
"{\n"
" if (flatVarying == 0) {\n"
" col = vec4(1,0,0,1);\n"
" } else {\n"
" col = vec4(0,1,0,1);\n"
" }\n"
"}\n";
createFBO(1, 1, 2);
ANGLE_GL_PROGRAM(program, vsSource, fsSource);
drawQuad(program, "vPosition", 0.0f, 1.0f, true);
ASSERT_GL_NO_ERROR();
EXPECT_EQ(GLColor::red, GetViewColor(0, 0, 0));
EXPECT_EQ(GLColor::green, GetViewColor(0, 0, 1));
}
// The test is added to cover a bug which resulted in the viewport/scissor and viewport offsets not
// being correctly applied.
TEST_P(MultiviewSideBySideRenderTest, ViewportOffsetsAppliedBugCoverage)
......
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