Vulkan: Don't attempt to convert vertices in empty buffers

Bug: chromium:1271671
Change-Id: I869f30fd9c8a52c07263bb7a72978a31f2aceb9a
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3297026
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
This commit is contained in:
Shahbaz Youssefi 2021-11-22 16:25:11 -05:00 коммит произвёл Angle LUCI CQ
Родитель ce6f9c8f00
Коммит 4ae30a63fd
2 изменённых файлов: 32 добавлений и 2 удалений

Просмотреть файл

@ -601,7 +601,7 @@ angle::Result VertexArrayVk::syncDirtyAttrib(ContextVk *contextVk,
mContentsObservers->disableForBuffer(bufferGL, static_cast<uint32_t>(attribIndex));
}
if (!isStreamingVertexAttrib)
if (!isStreamingVertexAttrib && bufferGL->getSize() > 0)
{
BufferVk *bufferVk = vk::GetImpl(bufferGL);
const angle::Format &intendedFormat = vertexFormat.getIntendedFormat();

Просмотреть файл

@ -3720,7 +3720,6 @@ void main()
// Test that aliasing attribute locations work with differing precisions.
TEST_P(VertexAttributeTest, AliasingVectorAttribLocationsDifferingPrecisions)
{
swapBuffers();
// http://anglebug.com/5180
ANGLE_SKIP_TEST_IF(IsAndroid() && IsOpenGL());
@ -3824,6 +3823,37 @@ void main()
}
}
// Test that unsupported vertex format specified on non-existing attribute doesn't crash.
TEST_P(VertexAttributeTest, VertexFormatConversionOfNonExistingAttribute)
{
constexpr char kVS[] = R"(precision highp float;
attribute vec3 attr1;
void main(void) {
gl_Position = vec4(attr1, 1.0);
})";
constexpr char kFS[] = R"(precision highp float;
void main(void) {
gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
})";
GLBuffer emptyBuffer;
glBindBuffer(GL_ARRAY_BUFFER, emptyBuffer);
ANGLE_GL_PROGRAM(program, kVS, kFS);
glBindAttribLocation(program, 0, "attr1");
glLinkProgram(program);
ASSERT_TRUE(CheckLinkStatusAndReturnProgram(program, true));
glUseProgram(program);
// Use the RGB8 format for non-existing attribute 1.
glEnableVertexAttribArray(1);
glVertexAttribPointer(1, 3, GL_UNSIGNED_BYTE, false, 1, 0);
glDrawArrays(GL_TRIANGLES, 0, 3);
EXPECT_GL_NO_ERROR();
}
// VAO emulation fails on Mac but is not used on Mac in the wild. http://anglebug.com/5577
#if !defined(__APPLE__)
# define EMULATED_VAO_CONFIGS \