Commit 91beb8d4 by Nicolas Capens Committed by Nicolas Capens

Prevent crashing when no current program is set.

This fixes a regression caused by https://swiftshader-review.googlesource.com/14489 Context::applyVertexBuffer() expects a valid program, so we need to check for it sooner. Not having a current program is not an error and makes the draw call a no-op, but dEQP-GLES3.functional.negative_api.vertex_array.* still expects validation to happen before leaving the function. In particular, the framebuffer completeness check has to be performed. Note that ConvertPrimitiveType() should never return an error because we already check the primitive type in the entry function, sampler validation can only be done when we have a valid program, and likewise applyVertexBuffer() requires a program, so these validations can still happen after the early-out. Change-Id: I7036ca59d37ea0385f79bf87afd1eeeb9728f7af Reviewed-on: https://swiftshader-review.googlesource.com/17228Tested-by: 's avatarNicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarLingfeng Yang <lfy@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent d0b5f1bc
......@@ -15,7 +15,7 @@
#define MAJOR_VERSION 4
#define MINOR_VERSION 0
#define BUILD_VERSION 0
#define BUILD_REVISION 0
#define BUILD_REVISION 1
#define STRINGIFY(x) #x
#define MACRO_STRINGIFY(x) STRINGIFY(x)
......
......@@ -3465,6 +3465,16 @@ void Context::clearStencilBuffer(const GLint value)
void Context::drawArrays(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount)
{
if(!applyRenderTarget())
{
return;
}
if(mState.currentProgram == 0)
{
return; // Nothing to process.
}
sw::DrawType primitiveType;
int primitiveCount;
int verticesPerPrimitive;
......@@ -3474,11 +3484,6 @@ void Context::drawArrays(GLenum mode, GLint first, GLsizei count, GLsizei instan
return error(GL_INVALID_ENUM);
}
if(!applyRenderTarget())
{
return;
}
applyState(mode);
for(int i = 0; i < instanceCount; ++i)
......@@ -3491,11 +3496,6 @@ void Context::drawArrays(GLenum mode, GLint first, GLsizei count, GLsizei instan
return error(err);
}
if(!mState.currentProgram)
{
return;
}
applyShaders();
applyTextures();
......@@ -3523,6 +3523,16 @@ void Context::drawArrays(GLenum mode, GLint first, GLsizei count, GLsizei instan
void Context::drawElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLsizei instanceCount)
{
if(!applyRenderTarget())
{
return;
}
if(mState.currentProgram == 0)
{
return; // Nothing to process.
}
if(!indices && !getCurrentVertexArray()->getElementArrayBuffer())
{
return error(GL_INVALID_OPERATION);
......@@ -3555,11 +3565,6 @@ void Context::drawElements(GLenum mode, GLuint start, GLuint end, GLsizei count,
return error(GL_INVALID_ENUM);
}
if(!applyRenderTarget())
{
return;
}
TranslatedIndexData indexInfo(primitiveCount);
GLenum err = applyIndexBuffer(indices, start, end, count, mode, type, &indexInfo);
if(err != GL_NO_ERROR)
......@@ -3580,11 +3585,6 @@ void Context::drawElements(GLenum mode, GLuint start, GLuint end, GLsizei count,
return error(err);
}
if(!mState.currentProgram)
{
return;
}
applyShaders();
applyTextures();
......
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