Commit 7a0b3044 by Shao Committed by Commit Bot

Reland "ES31: Add test on large strides"

In OpenGL 4.3 there is no limit on the maximum value of stride. This patch choose an emulated value for OpenGL 4.3 to fix the fyi failure on Linux AMD. BUG=angleproject:1593 Change-Id: I83cecc2ed1a3734dc8b8df3edb48ecc16039ba6e Reviewed-on: https://chromium-review.googlesource.com/452746Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarYuly Novikov <ynovikov@chromium.org> Commit-Queue: Yuly Novikov <ynovikov@chromium.org>
parent b78707c8
...@@ -443,7 +443,7 @@ struct Caps ...@@ -443,7 +443,7 @@ struct Caps
GLuint64 maxServerWaitTimeout; GLuint64 maxServerWaitTimeout;
// ES 3.1 (April 29, 2015) Table 20.41: Implementation dependent values (cont.) // ES 3.1 (April 29, 2015) Table 20.41: Implementation dependent values (cont.)
GLuint maxVertexAttribRelativeOffset; GLint maxVertexAttribRelativeOffset;
GLuint maxVertexAttribBindings; GLuint maxVertexAttribBindings;
GLint maxVertexAttribStride; GLint maxVertexAttribStride;
GLuint maxElementsIndices; GLuint maxElementsIndices;
......
...@@ -1224,8 +1224,12 @@ void GenerateCaps(ID3D11Device *device, ID3D11DeviceContext *deviceContext, cons ...@@ -1224,8 +1224,12 @@ void GenerateCaps(ID3D11Device *device, ID3D11DeviceContext *deviceContext, cons
static_cast<GLuint>(GetMaximumVertexOutputVectors(featureLevel)) * 4; static_cast<GLuint>(GetMaximumVertexOutputVectors(featureLevel)) * 4;
caps->maxVertexTextureImageUnits = caps->maxVertexTextureImageUnits =
static_cast<GLuint>(GetMaximumVertexTextureUnits(featureLevel)); static_cast<GLuint>(GetMaximumVertexTextureUnits(featureLevel));
// Vertex Attrib Bindings not supported.
// Vertex Attribute Bindings are emulated on D3D11.
caps->maxVertexAttribBindings = caps->maxVertexAttributes; caps->maxVertexAttribBindings = caps->maxVertexAttributes;
// Experimental testing confirmed 2048 is the maximum stride that D3D11 can support on all
// platforms.
caps->maxVertexAttribStride = 2048;
// Fragment shader limits // Fragment shader limits
caps->maxFragmentUniformComponents = caps->maxFragmentUniformComponents =
......
...@@ -631,7 +631,17 @@ void GenerateCaps(const FunctionsGL *functions, gl::Caps *caps, gl::TextureCapsM ...@@ -631,7 +631,17 @@ void GenerateCaps(const FunctionsGL *functions, gl::Caps *caps, gl::TextureCapsM
caps->maxVertexAttribRelativeOffset = caps->maxVertexAttribRelativeOffset =
QuerySingleGLInt(functions, GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET); QuerySingleGLInt(functions, GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET);
caps->maxVertexAttribBindings = QuerySingleGLInt(functions, GL_MAX_VERTEX_ATTRIB_BINDINGS); caps->maxVertexAttribBindings = QuerySingleGLInt(functions, GL_MAX_VERTEX_ATTRIB_BINDINGS);
caps->maxVertexAttribStride = QuerySingleGLInt(functions, GL_MAX_VERTEX_ATTRIB_STRIDE);
// OpenGL 4.3 has no limit on maximum value of stride.
// [OpenGL 4.3 (Core Profile) - February 14, 2013] Chapter 10.3.1 Page 298
if (functions->standard == STANDARD_GL_DESKTOP && functions->version == gl::Version(4, 3))
{
caps->maxVertexAttribStride = 2048;
}
else
{
caps->maxVertexAttribStride = QuerySingleGLInt(functions, GL_MAX_VERTEX_ATTRIB_STRIDE);
}
} }
else else
{ {
......
...@@ -612,6 +612,90 @@ TEST_P(VertexAttributeTest, DrawArraysWithBufferOffset) ...@@ -612,6 +612,90 @@ TEST_P(VertexAttributeTest, DrawArraysWithBufferOffset)
EXPECT_GL_NO_ERROR(); EXPECT_GL_NO_ERROR();
} }
class VertexAttributeTestES31 : public VertexAttributeTestES3
{
protected:
VertexAttributeTestES31() {}
void drawArraysWithStrideAndOffset(GLint stride, GLsizeiptr offset)
{
GLint floatStride = stride ? (stride / TypeStride(GL_FLOAT)) : 1;
GLsizeiptr floatOffset = offset / TypeStride(GL_FLOAT);
size_t floatCount = static_cast<size_t>(floatOffset) + mVertexCount * floatStride;
GLsizeiptr inputSize = static_cast<GLsizeiptr>(floatCount) * TypeStride(GL_FLOAT);
initBasicProgram();
glUseProgram(mProgram);
std::vector<GLfloat> inputData(floatCount);
GLfloat expectedData[mVertexCount];
for (size_t count = 0; count < mVertexCount; ++count)
{
inputData[floatOffset + count * floatStride] = static_cast<GLfloat>(count);
expectedData[count] = static_cast<GLfloat>(count);
}
auto quadVertices = GetQuadVertices();
GLsizeiptr quadVerticesSize =
static_cast<GLsizeiptr>(quadVertices.size() * sizeof(quadVertices[0]));
glGenBuffers(1, &mQuadBuffer);
glBindBuffer(GL_ARRAY_BUFFER, mQuadBuffer);
glBufferData(GL_ARRAY_BUFFER, quadVerticesSize, nullptr, GL_DYNAMIC_DRAW);
glBufferSubData(GL_ARRAY_BUFFER, 0, quadVerticesSize, quadVertices.data());
GLint positionLocation = glGetAttribLocation(mProgram, "position");
ASSERT_NE(-1, positionLocation);
glVertexAttribPointer(positionLocation, 3, GL_FLOAT, GL_FALSE, 0, nullptr);
glEnableVertexAttribArray(positionLocation);
// Ensure inputSize, inputStride and inputOffset are multiples of TypeStride(GL_FLOAT).
GLsizei inputStride = stride ? floatStride * TypeStride(GL_FLOAT) : 0;
GLsizeiptr inputOffset = floatOffset * TypeStride(GL_FLOAT);
glBindBuffer(GL_ARRAY_BUFFER, mBuffer);
glBufferData(GL_ARRAY_BUFFER, inputSize, nullptr, GL_STATIC_DRAW);
glBufferSubData(GL_ARRAY_BUFFER, 0, inputSize, &inputData[0]);
glVertexAttribPointer(mTestAttrib, 1, GL_FLOAT, GL_FALSE, inputStride,
reinterpret_cast<const GLvoid *>(inputOffset));
glEnableVertexAttribArray(mTestAttrib);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glVertexAttribPointer(mExpectedAttrib, 1, GL_FLOAT, GL_FALSE, 0, expectedData);
glEnableVertexAttribArray(mExpectedAttrib);
glDrawArrays(GL_TRIANGLES, 0, 6);
checkPixels();
EXPECT_GL_NO_ERROR();
}
// Set the maximum value for stride if the stride is too large.
const GLint MAX_STRIDE_FOR_TEST = 4095;
};
// Verify that MAX_VERTEX_ATTRIB_STRIDE is no less than the minimum required value (2048) in ES3.1.
TEST_P(VertexAttributeTestES31, MaxVertexAttribStride)
{
GLint maxStride;
glGetIntegerv(GL_MAX_VERTEX_ATTRIB_STRIDE, &maxStride);
ASSERT_GL_NO_ERROR();
EXPECT_GE(maxStride, 2048);
}
// Verify using MAX_VERTEX_ATTRIB_STRIDE as stride doesn't mess up the draw.
// Use default value if the value of MAX_VERTEX_ATTRIB_STRIDE is too large for this test.
TEST_P(VertexAttributeTestES31, DrawArraysWithLargeStride)
{
GLint maxStride;
glGetIntegerv(GL_MAX_VERTEX_ATTRIB_STRIDE, &maxStride);
ASSERT_GL_NO_ERROR();
GLint largeStride = (maxStride < MAX_STRIDE_FOR_TEST) ? maxStride : MAX_STRIDE_FOR_TEST;
drawArraysWithStrideAndOffset(largeStride, 0);
}
class VertexAttributeCachingTest : public VertexAttributeTest class VertexAttributeCachingTest : public VertexAttributeTest
{ {
protected: protected:
...@@ -885,6 +969,8 @@ ANGLE_INSTANTIATE_TEST(VertexAttributeTest, ...@@ -885,6 +969,8 @@ ANGLE_INSTANTIATE_TEST(VertexAttributeTest,
ANGLE_INSTANTIATE_TEST(VertexAttributeTestES3, ES3_D3D11(), ES3_OPENGL(), ES3_OPENGLES()); ANGLE_INSTANTIATE_TEST(VertexAttributeTestES3, ES3_D3D11(), ES3_OPENGL(), ES3_OPENGLES());
ANGLE_INSTANTIATE_TEST(VertexAttributeTestES31, ES31_D3D11(), ES31_OPENGL(), ES31_OPENGLES());
ANGLE_INSTANTIATE_TEST(VertexAttributeCachingTest, ANGLE_INSTANTIATE_TEST(VertexAttributeCachingTest,
ES2_D3D9(), ES2_D3D9(),
ES2_D3D11(), ES2_D3D11(),
......
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