Commit 9091de43 by Shahbaz Youssefi Committed by Commit Bot

Vulkan: Support vertex attribute aliasing for non-matrix types

Initial implementation that supports float and vecN types. In this case, every attribute occupies a single location. When two attributes alias, they are either the same size, or one is bigger than the other. Take the following example: attribute vec3 a; // location 0 attribute vec3 b; // location 0 attribute vec4 c; // location 1 attribute vec2 d; // location 1 The shader may access either a or b (but not both). Similarly, it can access either c or d (but not both). The shader can be modified such that: - f(b) is replaced with f(a). - g(d) is replaced with g(c.xy). - b and d are removed As a result, there are no longer any aliasing attributes. In other words, when attributes alias, the larger attribute can be retained and the other attributes can be replaced by selecting the appropriate number of components from the retained attribute. Bug: angleproject:4249 Change-Id: I7c5461f777d659c92977e2572091a8ce5e422704 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2482286 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarCourtney Goeltzenleuchter <courtneygo@google.com> Reviewed-by: 's avatarCharlie Lao <cclao@google.com>
parent 26cd1cc6
......@@ -88,6 +88,13 @@ struct ShaderInterfaceVariableInfo
bool useRelaxedPrecision = false;
// Indicate if varying is input or output
bool varyingIsOutput = false;
// For vertex attributes, this is the number of components. This is used by the vertex
// attribute aliasing transformation only.
uint8_t attributeComponentCount = 0;
// Indicate whether this is a vertex attribute of matrix type. This is temporarily used to
// avoid handling aliasing matrix vertex attributes as they are currently not supported.
// TODO: remove when support for aliasing matrix attributes is added. http://anglebug.com/4249
bool isMatrixAttribute = false;
};
// TODO: http://anglebug.com/4524: Need a different hash key than a string, since
......
......@@ -219,12 +219,14 @@ std::unique_ptr<rx::LinkEvent> ProgramExecutableVk::load(gl::BinaryInputStream *
info->location = stream->readInt<uint32_t>();
info->component = stream->readInt<uint32_t>();
// PackedEnumBitSet uses uint8_t
info->activeStages = gl::ShaderBitSet(stream->readInt<uint8_t>());
info->xfbBuffer = stream->readInt<uint32_t>();
info->xfbOffset = stream->readInt<uint32_t>();
info->xfbStride = stream->readInt<uint32_t>();
info->useRelaxedPrecision = stream->readBool();
info->varyingIsOutput = stream->readBool();
info->activeStages = gl::ShaderBitSet(stream->readInt<uint8_t>());
info->xfbBuffer = stream->readInt<uint32_t>();
info->xfbOffset = stream->readInt<uint32_t>();
info->xfbStride = stream->readInt<uint32_t>();
info->useRelaxedPrecision = stream->readBool();
info->varyingIsOutput = stream->readBool();
info->attributeComponentCount = stream->readInt<uint8_t>();
info->isMatrixAttribute = stream->readBool();
}
}
......@@ -250,6 +252,8 @@ void ProgramExecutableVk::save(gl::BinaryOutputStream *stream)
stream->writeInt<uint32_t>(it.second.xfbStride);
stream->writeInt<uint8_t>(it.second.useRelaxedPrecision);
stream->writeInt<uint8_t>(it.second.varyingIsOutput);
stream->writeInt<uint8_t>(it.second.attributeComponentCount);
stream->writeInt<uint8_t>(it.second.isMatrixAttribute);
}
}
}
......
......@@ -428,7 +428,7 @@
3748 VULKAN WIN NVIDIA : dEQP-GLES2.functional.fbo.render.repeated_clear.* = FAIL
// Vertex attribute aliasing generates invalid SPIRV
4249 VULKAN : dEQP-GLES2.functional.attribute_location.bind* = SKIP
4249 VULKAN : dEQP-GLES2.functional.attribute_location.bind_aliasing.*mat* = SKIP
// Fails on Metal, some of filtering tests fail when MSAA is off and pass when MSAA is on. Some
// tests are opposite. The filtering tests mostly fail on a few pixels.
......@@ -502,7 +502,7 @@
4853 METAL AMD : dEQP-GLES2.functional.draw.draw_arrays.line_loop.multiple_attributes = FAIL
// Vertex attribute aliasing generates invalid SPIRV
4249 METAL : dEQP-GLES2.functional.attribute_location.bind_aliasing.* = SKIP
4249 METAL : dEQP-GLES2.functional.attribute_location.bind_aliasing.*mat* = SKIP
// Globally disable Metal testing on Intel & NVIDIA for now
4235 METAL INTEL : dEQP-GLES2.* = SKIP
......
......@@ -3045,18 +3045,13 @@ void main()
// don't allow vertex attribute aliasing. This test excludes matrix types.
TEST_P(VertexAttributeTest, AliasingVectorAttribLocations)
{
// TODO(syoussefi): Support vertex attribute aliasing on Vulkan. The metal backend will
// automatically be fixed in the process. http://anglebug.com/4249
ANGLE_SKIP_TEST_IF(IsVulkan());
ANGLE_SKIP_TEST_IF(IsMetal());
// http://anglebug.com/5180
ANGLE_SKIP_TEST_IF(IsAndroid() && IsOpenGL());
// http://anglebug.com/5181
// http://anglebug.com/3466
ANGLE_SKIP_TEST_IF(IsOSX() && IsOpenGL());
// http://anglebug.com/5182
// http://anglebug.com/3467
ANGLE_SKIP_TEST_IF(IsD3D());
constexpr char kVS[] = R"(attribute vec4 position;
......@@ -3215,10 +3210,10 @@ TEST_P(VertexAttributeTest, AliasingMatrixAttribLocations)
// http://anglebug.com/5180
ANGLE_SKIP_TEST_IF(IsAndroid() && IsOpenGL());
// http://anglebug.com/5181
// http://anglebug.com/3466
ANGLE_SKIP_TEST_IF(IsOSX() && IsOpenGL());
// http://anglebug.com/5182
// http://anglebug.com/3467
ANGLE_SKIP_TEST_IF(IsD3D());
constexpr char kVS[] = R"(attribute vec4 position;
......
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