Commit 02032bda by Olli Etuaho Committed by Commit Bot

Generate an error if no XFB varyings are in use

GLES specifies an error if BeginTransformFeedback is called when no binding points would be used. BUG=angleproject:2184 TEST=angle_end2end_tests Change-Id: Ie4489b5ba63885e718dafdcdaacc02b603959be3 Reviewed-on: https://chromium-review.googlesource.com/719136Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
parent cbcb96fc
...@@ -125,6 +125,8 @@ ERRMSG(NegativeSize, "Cannot have negative height or width."); ...@@ -125,6 +125,8 @@ ERRMSG(NegativeSize, "Cannot have negative height or width.");
ERRMSG(NegativeStart, "Cannot have negative start."); ERRMSG(NegativeStart, "Cannot have negative start.");
ERRMSG(NegativeStride, "Cannot have negative stride."); ERRMSG(NegativeStride, "Cannot have negative stride.");
ERRMSG(NoSuchPath, "No such path object."); ERRMSG(NoSuchPath, "No such path object.");
ERRMSG(NoTransformFeedbackOutputVariables,
"The active program has specified no output variables to record.");
ERRMSG(NoZeroDivisor, "At least one enabled attribute must have a divisor of zero."); ERRMSG(NoZeroDivisor, "At least one enabled attribute must have a divisor of zero.");
ERRMSG(ObjectNotGenerated, "Object cannot be used because it has not been generated."); ERRMSG(ObjectNotGenerated, "Object cannot be used because it has not been generated.");
ERRMSG(OffsetMustBeMultipleOfType, "Offset must be a multiple of the passed in datatype."); ERRMSG(OffsetMustBeMultipleOfType, "Offset must be a multiple of the passed in datatype.");
......
...@@ -2139,6 +2139,20 @@ bool ValidateBeginTransformFeedback(Context *context, GLenum primitiveMode) ...@@ -2139,6 +2139,20 @@ bool ValidateBeginTransformFeedback(Context *context, GLenum primitiveMode)
} }
} }
auto program = context->getGLState().getProgram();
if (!program)
{
ANGLE_VALIDATION_ERR(context, InvalidOperation(), ProgramNotBound);
return false;
}
if (program->getTransformFeedbackVaryingCount() == 0)
{
ANGLE_VALIDATION_ERR(context, InvalidOperation(), NoTransformFeedbackOutputVariables);
return false;
}
return true; return true;
} }
......
...@@ -1321,6 +1321,52 @@ TEST_P(TransformFeedbackTest, VaryingReservedOpenGLName) ...@@ -1321,6 +1321,52 @@ TEST_P(TransformFeedbackTest, VaryingReservedOpenGLName)
ASSERT_GL_NO_ERROR(); ASSERT_GL_NO_ERROR();
} }
// Test that calling BeginTransformFeedback when no program is currentwill generate an
// INVALID_OPERATION error.
TEST_P(TransformFeedbackTest, NoCurrentProgram)
{
glUseProgram(0);
glBeginTransformFeedback(GL_TRIANGLES);
// GLES 3.0.5 section 2.15.2: "The error INVALID_OPERATION is also generated by
// BeginTransformFeedback if no binding points would be used, either because no program object
// is active or because the active program object has specified no output variables to record."
EXPECT_GL_ERROR(GL_INVALID_OPERATION);
}
// Test that calling BeginTransformFeedback when no transform feedback varyings are in use will
// generate an INVALID_OPERATION error.
TEST_P(TransformFeedbackTest, NoTransformFeedbackVaryingsInUse)
{
const std::string &vertexShaderSource =
"#version 300 es\n"
"in vec4 a_position;\n"
"void main()\n"
"{\n"
" gl_Position = a_position;\n"
"}\n";
const std::string &fragmentShaderSource =
"#version 300 es\n"
"precision mediump float;\n"
"out vec4 fragColor;\n"
"void main()\n"
"{\n"
" fragColor = vec4(0);\n"
"}\n";
ANGLE_GL_PROGRAM(program, vertexShaderSource, fragmentShaderSource);
glUseProgram(program);
glBeginTransformFeedback(GL_TRIANGLES);
// GLES 3.0.5 section 2.15.2: "The error INVALID_OPERATION is also generated by
// BeginTransformFeedback if no binding points would be used, either because no program object
// is active or because the active program object has specified no output variables to record."
EXPECT_GL_ERROR(GL_INVALID_OPERATION);
}
// Use this to select which configurations (e.g. which renderer, which GLES major version) these // Use this to select which configurations (e.g. which renderer, which GLES major version) these
// tests should be run against. // tests should be run against.
ANGLE_INSTANTIATE_TEST(TransformFeedbackTest, ES3_D3D11(), ES3_OPENGL(), ES3_OPENGLES()); ANGLE_INSTANTIATE_TEST(TransformFeedbackTest, ES3_D3D11(), ES3_OPENGL(), ES3_OPENGLES());
......
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