Commit d90d388c by Geoff Lang Committed by Commit Bot

Make sure the default framebuffer has enough draw buffer states.

Querying the draw buffer states of the default framebuffer would lead to crashes because it only had one state. The spec says that all non-zero attachments default to GL_NONE and makes no mention of special cased errors for querying the default framebuffer. Also fix the validation to check for extensions and ES version when querying draw buffer state. BUG=703508 Change-Id: I7db5443141c65a3f9c638f07ba90f78d76e4e7b4 Reviewed-on: https://chromium-review.googlesource.com/457524 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 86904b81
...@@ -133,13 +133,6 @@ ValidationContext::ValidationContext(const ValidationContext *shareContext, ...@@ -133,13 +133,6 @@ ValidationContext::ValidationContext(const ValidationContext *shareContext,
bool ValidationContext::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *numParams) bool ValidationContext::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *numParams)
{ {
if (pname >= GL_DRAW_BUFFER0_EXT && pname <= GL_DRAW_BUFFER15_EXT)
{
*type = GL_INT;
*numParams = 1;
return true;
}
// Please note: the query type returned for DEPTH_CLEAR_VALUE in this implementation // Please note: the query type returned for DEPTH_CLEAR_VALUE in this implementation
// is FLOAT rather than INT, as would be suggested by the GL ES 2.0 spec. This is due // is FLOAT rather than INT, as would be suggested by the GL ES 2.0 spec. This is due
// to the fact that it is stored internally as a float, and so would require conversion // to the fact that it is stored internally as a float, and so would require conversion
...@@ -495,6 +488,17 @@ bool ValidationContext::getQueryParameterInfo(GLenum pname, GLenum *type, unsign ...@@ -495,6 +488,17 @@ bool ValidationContext::getQueryParameterInfo(GLenum pname, GLenum *type, unsign
} }
} }
if (pname >= GL_DRAW_BUFFER0_EXT && pname <= GL_DRAW_BUFFER15_EXT)
{
if ((getClientVersion() < Version(3, 0)) && !getExtensions().drawBuffers)
{
return false;
}
*type = GL_INT;
*numParams = 1;
return true;
}
if (getClientVersion() < Version(3, 0)) if (getClientVersion() < Version(3, 0))
{ {
return false; return false;
......
...@@ -45,7 +45,7 @@ void BindResourceChannel(ChannelBinding *binding, FramebufferAttachmentObject *r ...@@ -45,7 +45,7 @@ void BindResourceChannel(ChannelBinding *binding, FramebufferAttachmentObject *r
FramebufferState::FramebufferState() FramebufferState::FramebufferState()
: mLabel(), : mLabel(),
mColorAttachments(1), mColorAttachments(1),
mDrawBufferStates(1, GL_BACK), mDrawBufferStates(IMPLEMENTATION_MAX_DRAW_BUFFERS, GL_NONE),
mReadBufferState(GL_BACK), mReadBufferState(GL_BACK),
mDefaultWidth(0), mDefaultWidth(0),
mDefaultHeight(0), mDefaultHeight(0),
...@@ -53,6 +53,8 @@ FramebufferState::FramebufferState() ...@@ -53,6 +53,8 @@ FramebufferState::FramebufferState()
mDefaultFixedSampleLocations(GL_FALSE), mDefaultFixedSampleLocations(GL_FALSE),
mWebGLDepthStencilConsistent(true) mWebGLDepthStencilConsistent(true)
{ {
ASSERT(mDrawBufferStates.size() > 0);
mDrawBufferStates[0] = GL_BACK;
mEnabledDrawBuffers.set(0); mEnabledDrawBuffers.set(0);
} }
......
...@@ -200,7 +200,7 @@ gl::Error Clear11::clearFramebuffer(const ClearParameters &clearParams, ...@@ -200,7 +200,7 @@ gl::Error Clear11::clearFramebuffer(const ClearParameters &clearParams,
const auto *depthAttachment = fboData.getDepthAttachment(); const auto *depthAttachment = fboData.getDepthAttachment();
const auto *stencilAttachment = fboData.getStencilAttachment(); const auto *stencilAttachment = fboData.getStencilAttachment();
ASSERT(colorAttachments.size() == drawBufferStates.size()); ASSERT(colorAttachments.size() <= drawBufferStates.size());
// Iterate over the color buffers which require clearing and determine if they can be // Iterate over the color buffers which require clearing and determine if they can be
// cleared with ID3D11DeviceContext::ClearRenderTargetView or ID3D11DeviceContext1::ClearView. // cleared with ID3D11DeviceContext::ClearRenderTargetView or ID3D11DeviceContext1::ClearView.
......
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