Commit e92a3546 by Jamie Madill

Remove redundant FBO query methods.

Several query methods simply wrapped a NULL check with a default return value. Most of these safety checks were unnecessary. BUG=angle:660 Change-Id: I0ac6897f06be082c8efab8721920d1b51ba999ee Reviewed-on: https://chromium-review.googlesource.com/205606Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 55ec3b11
...@@ -2594,7 +2594,7 @@ void Context::clear(GLbitfield mask) ...@@ -2594,7 +2594,7 @@ void Context::clear(GLbitfield mask)
if (mask & GL_DEPTH_BUFFER_BIT) if (mask & GL_DEPTH_BUFFER_BIT)
{ {
if (mState.depthStencil.depthMask && framebufferObject->getDepthbufferType() != GL_NONE) if (mState.depthStencil.depthMask && framebufferObject->getDepthbuffer() != NULL)
{ {
clearParams.clearDepth = true; clearParams.clearDepth = true;
} }
...@@ -2602,7 +2602,7 @@ void Context::clear(GLbitfield mask) ...@@ -2602,7 +2602,7 @@ void Context::clear(GLbitfield mask)
if (mask & GL_STENCIL_BUFFER_BIT) if (mask & GL_STENCIL_BUFFER_BIT)
{ {
if (framebufferObject->getStencilbufferType() != GL_NONE) if (framebufferObject->getStencilbuffer() != NULL)
{ {
rx::RenderTarget *depthStencil = framebufferObject->getStencilbuffer()->getDepthStencil(); rx::RenderTarget *depthStencil = framebufferObject->getStencilbuffer()->getDepthStencil();
if (!depthStencil) if (!depthStencil)
......
...@@ -271,88 +271,27 @@ FramebufferAttachment *Framebuffer::getFirstColorbuffer() const ...@@ -271,88 +271,27 @@ FramebufferAttachment *Framebuffer::getFirstColorbuffer() const
return NULL; return NULL;
} }
GLenum Framebuffer::getColorbufferType(unsigned int colorAttachment) const FramebufferAttachment *Framebuffer::getAttachment(GLenum attachment) const
{ {
ASSERT(colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS); if (attachment >= GL_COLOR_ATTACHMENT0 && attachment <= GL_COLOR_ATTACHMENT15)
return (mColorbuffers[colorAttachment] ? mColorbuffers[colorAttachment]->type() : GL_NONE); {
} return getColorbuffer(attachment - GL_COLOR_ATTACHMENT0);
}
GLenum Framebuffer::getDepthbufferType() const else
{ {
return (mDepthbuffer ? mDepthbuffer->type() : GL_NONE); switch (attachment)
} {
case GL_DEPTH_ATTACHMENT:
GLenum Framebuffer::getStencilbufferType() const return getDepthbuffer();
{ case GL_STENCIL_ATTACHMENT:
return (mStencilbuffer ? mStencilbuffer->type() : GL_NONE); return getStencilbuffer();
} case GL_DEPTH_STENCIL_ATTACHMENT:
return getDepthStencilBuffer();
GLenum Framebuffer::getDepthStencilbufferType() const default:
{ UNREACHABLE();
return (hasValidDepthStencil() ? mDepthbuffer->type() : GL_NONE); return NULL;
} }
}
GLuint Framebuffer::getColorbufferHandle(unsigned int colorAttachment) const
{
ASSERT(colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS);
return (mColorbuffers[colorAttachment] ? mColorbuffers[colorAttachment]->id() : 0);
}
GLuint Framebuffer::getDepthbufferHandle() const
{
return (mDepthbuffer ? mDepthbuffer->id() : 0);
}
GLuint Framebuffer::getStencilbufferHandle() const
{
return (mStencilbuffer ? mStencilbuffer->id() : 0);
}
GLuint Framebuffer::getDepthStencilbufferHandle() const
{
return (hasValidDepthStencil() ? mDepthbuffer->id() : 0);
}
GLint Framebuffer::getColorbufferMipLevel(unsigned int colorAttachment) const
{
ASSERT(colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS);
return (mColorbuffers[colorAttachment] ? mColorbuffers[colorAttachment]->mipLevel() : 0);
}
GLint Framebuffer::getDepthbufferMipLevel() const
{
return (mDepthbuffer ? mDepthbuffer->mipLevel() : 0);
}
GLint Framebuffer::getStencilbufferMipLevel() const
{
return (mStencilbuffer ? mStencilbuffer->mipLevel() : 0);
}
GLint Framebuffer::getDepthStencilbufferMipLevel() const
{
return (hasValidDepthStencil() ? mDepthbuffer->mipLevel() : 0);
}
GLint Framebuffer::getColorbufferLayer(unsigned int colorAttachment) const
{
ASSERT(colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS);
return (mColorbuffers[colorAttachment] ? mColorbuffers[colorAttachment]->layer() : 0);
}
GLint Framebuffer::getDepthbufferLayer() const
{
return (mDepthbuffer ? mDepthbuffer->layer() : 0);
}
GLint Framebuffer::getStencilbufferLayer() const
{
return (mStencilbuffer ? mStencilbuffer->layer() : 0);
}
GLint Framebuffer::getDepthStencilbufferLayer() const
{
return (hasValidDepthStencil() ? mDepthbuffer->layer() : 0);
} }
GLenum Framebuffer::getDrawBufferState(unsigned int colorAttachment) const GLenum Framebuffer::getDrawBufferState(unsigned int colorAttachment) const
...@@ -472,8 +411,11 @@ GLenum Framebuffer::completeness() const ...@@ -472,8 +411,11 @@ GLenum Framebuffer::completeness() const
// D3D11 does not allow for overlapping RenderTargetViews, so ensure uniqueness // D3D11 does not allow for overlapping RenderTargetViews, so ensure uniqueness
for (unsigned int previousColorAttachment = 0; previousColorAttachment < colorAttachment; previousColorAttachment++) for (unsigned int previousColorAttachment = 0; previousColorAttachment < colorAttachment; previousColorAttachment++)
{ {
if (colorbuffer->id() == getColorbufferHandle(previousColorAttachment) && const FramebufferAttachment *previousAttachment = mColorbuffers[previousColorAttachment];
colorbuffer->type() == getColorbufferType(previousColorAttachment))
if (previousAttachment &&
(colorbuffer->id() == previousAttachment->id() &&
colorbuffer->type() == previousAttachment->type()))
{ {
return GL_FRAMEBUFFER_UNSUPPORTED; return GL_FRAMEBUFFER_UNSUPPORTED;
} }
...@@ -666,4 +608,22 @@ GLenum DefaultFramebuffer::completeness() const ...@@ -666,4 +608,22 @@ GLenum DefaultFramebuffer::completeness() const
return GL_FRAMEBUFFER_COMPLETE; return GL_FRAMEBUFFER_COMPLETE;
} }
FramebufferAttachment *DefaultFramebuffer::getAttachment(GLenum attachment) const
{
switch (attachment)
{
case GL_BACK:
return getColorbuffer(0);
case GL_DEPTH:
return getDepthbuffer();
case GL_STENCIL:
return getStencilbuffer();
case GL_DEPTH_STENCIL:
return getDepthStencilBuffer();
default:
UNREACHABLE();
return NULL;
}
}
} }
...@@ -51,25 +51,7 @@ class Framebuffer ...@@ -51,25 +51,7 @@ class Framebuffer
GLenum getReadColorbufferType() const; GLenum getReadColorbufferType() const;
FramebufferAttachment *getFirstColorbuffer() const; FramebufferAttachment *getFirstColorbuffer() const;
GLenum getColorbufferType(unsigned int colorAttachment) const; virtual FramebufferAttachment *getAttachment(GLenum attachment) const;
GLenum getDepthbufferType() const;
GLenum getStencilbufferType() const;
GLenum getDepthStencilbufferType() const;
GLuint getColorbufferHandle(unsigned int colorAttachment) const;
GLuint getDepthbufferHandle() const;
GLuint getStencilbufferHandle() const;
GLuint getDepthStencilbufferHandle() const;
GLint getColorbufferMipLevel(unsigned int colorAttachment) const;
GLint getDepthbufferMipLevel() const;
GLint getStencilbufferMipLevel() const;
GLint getDepthStencilbufferMipLevel() const;
GLint getColorbufferLayer(unsigned int colorAttachment) const;
GLint getDepthbufferLayer() const;
GLint getStencilbufferLayer() const;
GLint getDepthStencilbufferLayer() const;
GLenum getDrawBufferState(unsigned int colorAttachment) const; GLenum getDrawBufferState(unsigned int colorAttachment) const;
void setDrawBufferState(unsigned int colorAttachment, GLenum drawBuffer); void setDrawBufferState(unsigned int colorAttachment, GLenum drawBuffer);
...@@ -81,6 +63,7 @@ class Framebuffer ...@@ -81,6 +63,7 @@ class Framebuffer
bool usingExtendedDrawBuffers() const; bool usingExtendedDrawBuffers() const;
virtual GLenum completeness() const; virtual GLenum completeness() const;
bool hasValidDepthStencil() const;
protected: protected:
rx::Renderer *mRenderer; rx::Renderer *mRenderer;
...@@ -92,8 +75,6 @@ class Framebuffer ...@@ -92,8 +75,6 @@ class Framebuffer
FramebufferAttachment *mDepthbuffer; FramebufferAttachment *mDepthbuffer;
FramebufferAttachment *mStencilbuffer; FramebufferAttachment *mStencilbuffer;
bool hasValidDepthStencil() const;
private: private:
DISALLOW_COPY_AND_ASSIGN(Framebuffer); DISALLOW_COPY_AND_ASSIGN(Framebuffer);
...@@ -106,6 +87,7 @@ class DefaultFramebuffer : public Framebuffer ...@@ -106,6 +87,7 @@ class DefaultFramebuffer : public Framebuffer
DefaultFramebuffer(rx::Renderer *Renderer, Colorbuffer *colorbuffer, DepthStencilbuffer *depthStencil); DefaultFramebuffer(rx::Renderer *Renderer, Colorbuffer *colorbuffer, DepthStencilbuffer *depthStencil);
virtual GLenum completeness() const; virtual GLenum completeness() const;
virtual FramebufferAttachment *getAttachment(GLenum attachment) const;
private: private:
DISALLOW_COPY_AND_ASSIGN(DefaultFramebuffer); DISALLOW_COPY_AND_ASSIGN(DefaultFramebuffer);
......
...@@ -199,7 +199,7 @@ rx::ShaderExecutable *ProgramBinary::getPixelExecutableForFramebuffer(const Fram ...@@ -199,7 +199,7 @@ rx::ShaderExecutable *ProgramBinary::getPixelExecutableForFramebuffer(const Fram
std::vector<GLenum> outputs(IMPLEMENTATION_MAX_DRAW_BUFFERS); std::vector<GLenum> outputs(IMPLEMENTATION_MAX_DRAW_BUFFERS);
for (size_t outputIndex = 0; outputIndex < IMPLEMENTATION_MAX_DRAW_BUFFERS; outputIndex++) for (size_t outputIndex = 0; outputIndex < IMPLEMENTATION_MAX_DRAW_BUFFERS; outputIndex++)
{ {
if (fbo->getColorbufferType(outputIndex) != GL_NONE) if (fbo->getColorbuffer(outputIndex) != NULL)
{ {
// Always output floats for now // Always output floats for now
outputs[outputIndex] = GL_FLOAT; outputs[outputIndex] = GL_FLOAT;
......
...@@ -2606,12 +2606,6 @@ void __stdcall glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attac ...@@ -2606,12 +2606,6 @@ void __stdcall glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attac
ASSERT(framebufferHandle != GL_INVALID_INDEX); ASSERT(framebufferHandle != GL_INVALID_INDEX);
gl::Framebuffer *framebuffer = context->getFramebuffer(framebufferHandle); gl::Framebuffer *framebuffer = context->getFramebuffer(framebufferHandle);
GLenum attachmentType;
GLuint attachmentHandle;
GLuint attachmentLevel;
GLuint attachmentLayer;
const gl::FramebufferAttachment *attachmentObject;
if (framebufferHandle == 0) if (framebufferHandle == 0)
{ {
if (clientVersion < 3) if (clientVersion < 3)
...@@ -2622,25 +2616,8 @@ void __stdcall glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attac ...@@ -2622,25 +2616,8 @@ void __stdcall glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attac
switch (attachment) switch (attachment)
{ {
case GL_BACK: case GL_BACK:
attachmentType = framebuffer->getColorbufferType(0);
attachmentHandle = framebuffer->getColorbufferHandle(0);
attachmentLevel = framebuffer->getColorbufferMipLevel(0);
attachmentLayer = framebuffer->getColorbufferLayer(0);
attachmentObject = framebuffer->getColorbuffer(0);
break;
case GL_DEPTH: case GL_DEPTH:
attachmentType = framebuffer->getDepthbufferType();
attachmentHandle = framebuffer->getDepthbufferHandle();
attachmentLevel = framebuffer->getDepthbufferMipLevel();
attachmentLayer = framebuffer->getDepthbufferLayer();
attachmentObject = framebuffer->getDepthbuffer();
break;
case GL_STENCIL: case GL_STENCIL:
attachmentType = framebuffer->getStencilbufferType();
attachmentHandle = framebuffer->getStencilbufferHandle();
attachmentLevel = framebuffer->getStencilbufferMipLevel();
attachmentLayer = framebuffer->getStencilbufferLayer();
attachmentObject = framebuffer->getStencilbuffer();
break; break;
default: default:
return gl::error(GL_INVALID_OPERATION); return gl::error(GL_INVALID_OPERATION);
...@@ -2650,41 +2627,20 @@ void __stdcall glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attac ...@@ -2650,41 +2627,20 @@ void __stdcall glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attac
{ {
if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
{ {
const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT); // Valid attachment query
attachmentType = framebuffer->getColorbufferType(colorAttachment);
attachmentHandle = framebuffer->getColorbufferHandle(colorAttachment);
attachmentLevel = framebuffer->getColorbufferMipLevel(colorAttachment);
attachmentLayer = framebuffer->getColorbufferLayer(colorAttachment);
attachmentObject = framebuffer->getColorbuffer(colorAttachment);
} }
else else
{ {
switch (attachment) switch (attachment)
{ {
case GL_DEPTH_ATTACHMENT: case GL_DEPTH_ATTACHMENT:
attachmentType = framebuffer->getDepthbufferType();
attachmentHandle = framebuffer->getDepthbufferHandle();
attachmentLevel = framebuffer->getDepthbufferMipLevel();
attachmentLayer = framebuffer->getDepthbufferLayer();
attachmentObject = framebuffer->getDepthbuffer();
break;
case GL_STENCIL_ATTACHMENT: case GL_STENCIL_ATTACHMENT:
attachmentType = framebuffer->getStencilbufferType();
attachmentHandle = framebuffer->getStencilbufferHandle();
attachmentLevel = framebuffer->getStencilbufferMipLevel();
attachmentLayer = framebuffer->getStencilbufferLayer();
attachmentObject = framebuffer->getStencilbuffer();
break; break;
case GL_DEPTH_STENCIL_ATTACHMENT: case GL_DEPTH_STENCIL_ATTACHMENT:
if (framebuffer->getDepthbufferHandle() != framebuffer->getStencilbufferHandle()) if (framebuffer->hasValidDepthStencil())
{ {
return gl::error(GL_INVALID_OPERATION); return gl::error(GL_INVALID_OPERATION);
} }
attachmentType = framebuffer->getDepthStencilbufferType();
attachmentHandle = framebuffer->getDepthStencilbufferHandle();
attachmentLevel = framebuffer->getDepthStencilbufferMipLevel();
attachmentLayer = framebuffer->getDepthStencilbufferLayer();
attachmentObject = framebuffer->getDepthStencilBuffer();
break; break;
default: default:
return gl::error(GL_INVALID_OPERATION); return gl::error(GL_INVALID_OPERATION);
...@@ -2692,6 +2648,21 @@ void __stdcall glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attac ...@@ -2692,6 +2648,21 @@ void __stdcall glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attac
} }
} }
GLenum attachmentType = GL_NONE;
GLuint attachmentHandle = 0;
GLuint attachmentLevel = 0;
GLuint attachmentLayer = 0;
const gl::FramebufferAttachment *attachmentObject = framebuffer->getAttachment(attachment);
if (attachmentObject)
{
attachmentType = attachmentObject->type();
attachmentHandle = attachmentObject->id();
attachmentLevel = attachmentObject->mipLevel();
attachmentLayer = attachmentObject->layer();
}
GLenum attachmentObjectType; // Type category GLenum attachmentObjectType; // Type category
if (framebufferHandle == 0) if (framebufferHandle == 0)
{ {
......
...@@ -816,20 +816,13 @@ bool Renderer11::applyRenderTarget(gl::Framebuffer *framebuffer) ...@@ -816,20 +816,13 @@ bool Renderer11::applyRenderTarget(gl::Framebuffer *framebuffer)
for (unsigned int colorAttachment = 0; colorAttachment < gl::IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++) for (unsigned int colorAttachment = 0; colorAttachment < gl::IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++)
{ {
const GLenum drawBufferState = framebuffer->getDrawBufferState(colorAttachment); const GLenum drawBufferState = framebuffer->getDrawBufferState(colorAttachment);
gl::FramebufferAttachment *colorbuffer = framebuffer->getColorbuffer(colorAttachment);
if (framebuffer->getColorbufferType(colorAttachment) != GL_NONE && drawBufferState != GL_NONE) if (colorbuffer && drawBufferState != GL_NONE)
{ {
// the draw buffer must be either "none", "back" for the default buffer or the same index as this color (in order) // the draw buffer must be either "none", "back" for the default buffer or the same index as this color (in order)
ASSERT(drawBufferState == GL_BACK || drawBufferState == (GL_COLOR_ATTACHMENT0_EXT + colorAttachment)); ASSERT(drawBufferState == GL_BACK || drawBufferState == (GL_COLOR_ATTACHMENT0_EXT + colorAttachment));
gl::FramebufferAttachment *colorbuffer = framebuffer->getColorbuffer(colorAttachment);
if (!colorbuffer)
{
ERR("render target pointer unexpectedly null.");
return false;
}
// check for zero-sized default framebuffer, which is a special case. // check for zero-sized default framebuffer, which is a special case.
// in this case we do not wish to modify any state and just silently return false. // in this case we do not wish to modify any state and just silently return false.
// this will not report any gl error but will cause the calling method to return. // this will not report any gl error but will cause the calling method to return.
...@@ -869,31 +862,16 @@ bool Renderer11::applyRenderTarget(gl::Framebuffer *framebuffer) ...@@ -869,31 +862,16 @@ bool Renderer11::applyRenderTarget(gl::Framebuffer *framebuffer)
} }
// Get the depth stencil render buffer and serials // Get the depth stencil render buffer and serials
gl::FramebufferAttachment *depthStencil = NULL; gl::FramebufferAttachment *depthStencil = framebuffer->getDepthbuffer();
unsigned int depthbufferSerial = 0; unsigned int depthbufferSerial = 0;
unsigned int stencilbufferSerial = 0; unsigned int stencilbufferSerial = 0;
if (framebuffer->getDepthbufferType() != GL_NONE) if (depthStencil)
{ {
depthStencil = framebuffer->getDepthbuffer();
if (!depthStencil)
{
ERR("Depth stencil pointer unexpectedly null.");
SafeRelease(framebufferRTVs);
return false;
}
depthbufferSerial = depthStencil->getSerial(); depthbufferSerial = depthStencil->getSerial();
} }
else if (framebuffer->getStencilbufferType() != GL_NONE) else if (framebuffer->getStencilbuffer())
{ {
depthStencil = framebuffer->getStencilbuffer(); depthStencil = framebuffer->getStencilbuffer();
if (!depthStencil)
{
ERR("Depth stencil pointer unexpectedly null.");
SafeRelease(framebufferRTVs);
return false;
}
stencilbufferSerial = depthStencil->getSerial(); stencilbufferSerial = depthStencil->getSerial();
} }
...@@ -3349,20 +3327,20 @@ void Renderer11::invalidateFramebufferSwizzles(gl::Framebuffer *framebuffer) ...@@ -3349,20 +3327,20 @@ void Renderer11::invalidateFramebufferSwizzles(gl::Framebuffer *framebuffer)
gl::FramebufferAttachment *attachment = framebuffer->getColorbuffer(colorAttachment); gl::FramebufferAttachment *attachment = framebuffer->getColorbuffer(colorAttachment);
if (attachment && attachment->isTexture()) if (attachment && attachment->isTexture())
{ {
invalidateFBOAttachmentSwizzles(attachment, framebuffer->getColorbufferMipLevel(colorAttachment)); invalidateFBOAttachmentSwizzles(attachment, attachment->mipLevel());
} }
} }
gl::FramebufferAttachment *depthAttachment = framebuffer->getDepthbuffer(); gl::FramebufferAttachment *depthAttachment = framebuffer->getDepthbuffer();
if (depthAttachment && depthAttachment->isTexture()) if (depthAttachment && depthAttachment->isTexture())
{ {
invalidateFBOAttachmentSwizzles(depthAttachment, framebuffer->getDepthbufferMipLevel()); invalidateFBOAttachmentSwizzles(depthAttachment, depthAttachment->mipLevel());
} }
gl::FramebufferAttachment *stencilAttachment = framebuffer->getStencilbuffer(); gl::FramebufferAttachment *stencilAttachment = framebuffer->getStencilbuffer();
if (stencilAttachment && stencilAttachment->isTexture()) if (stencilAttachment && stencilAttachment->isTexture())
{ {
invalidateFBOAttachmentSwizzles(stencilAttachment, framebuffer->getStencilbufferMipLevel()); invalidateFBOAttachmentSwizzles(stencilAttachment, stencilAttachment->mipLevel());
} }
} }
......
...@@ -1151,29 +1151,25 @@ bool Renderer9::applyRenderTarget(gl::Framebuffer *framebuffer) ...@@ -1151,29 +1151,25 @@ bool Renderer9::applyRenderTarget(gl::Framebuffer *framebuffer)
{ {
// if there is no color attachment we must synthesize a NULL colorattachment // if there is no color attachment we must synthesize a NULL colorattachment
// to keep the D3D runtime happy. This should only be possible if depth texturing. // to keep the D3D runtime happy. This should only be possible if depth texturing.
gl::FramebufferAttachment *renderbufferObject = NULL; gl::FramebufferAttachment *attachment = framebuffer->getColorbuffer(0);
if (framebuffer->getColorbufferType(0) != GL_NONE) if (!attachment)
{ {
renderbufferObject = framebuffer->getColorbuffer(0); attachment = getNullColorbuffer(framebuffer->getDepthbuffer());
} }
else if (!attachment)
{
renderbufferObject = getNullColorbuffer(framebuffer->getDepthbuffer());
}
if (!renderbufferObject)
{ {
ERR("unable to locate renderbuffer for FBO."); ERR("unable to locate renderbuffer for FBO.");
return false; return false;
} }
bool renderTargetChanged = false; bool renderTargetChanged = false;
unsigned int renderTargetSerial = renderbufferObject->getSerial(); unsigned int renderTargetSerial = attachment->getSerial();
if (renderTargetSerial != mAppliedRenderTargetSerial) if (renderTargetSerial != mAppliedRenderTargetSerial)
{ {
// Apply the render target on the device // Apply the render target on the device
IDirect3DSurface9 *renderTargetSurface = NULL; IDirect3DSurface9 *renderTargetSurface = NULL;
RenderTarget *renderTarget = renderbufferObject->getRenderTarget(); RenderTarget *renderTarget = attachment->getRenderTarget();
if (renderTarget) if (renderTarget)
{ {
renderTargetSurface = RenderTarget9::makeRenderTarget9(renderTarget)->getSurface(); renderTargetSurface = RenderTarget9::makeRenderTarget9(renderTarget)->getSurface();
...@@ -1192,29 +1188,16 @@ bool Renderer9::applyRenderTarget(gl::Framebuffer *framebuffer) ...@@ -1192,29 +1188,16 @@ bool Renderer9::applyRenderTarget(gl::Framebuffer *framebuffer)
renderTargetChanged = true; renderTargetChanged = true;
} }
gl::FramebufferAttachment *depthStencil = NULL; gl::FramebufferAttachment *depthStencil = framebuffer->getDepthbuffer();
unsigned int depthbufferSerial = 0; unsigned int depthbufferSerial = 0;
unsigned int stencilbufferSerial = 0; unsigned int stencilbufferSerial = 0;
if (framebuffer->getDepthbufferType() != GL_NONE) if (depthStencil)
{ {
depthStencil = framebuffer->getDepthbuffer();
if (!depthStencil)
{
ERR("Depth stencil pointer unexpectedly null.");
return false;
}
depthbufferSerial = depthStencil->getSerial(); depthbufferSerial = depthStencil->getSerial();
} }
else if (framebuffer->getStencilbufferType() != GL_NONE) else if (framebuffer->getStencilbuffer())
{ {
depthStencil = framebuffer->getStencilbuffer(); depthStencil = framebuffer->getStencilbuffer();
if (!depthStencil)
{
ERR("Depth stencil pointer unexpectedly null.");
return false;
}
stencilbufferSerial = depthStencil->getSerial(); stencilbufferSerial = depthStencil->getSerial();
} }
...@@ -1276,9 +1259,9 @@ bool Renderer9::applyRenderTarget(gl::Framebuffer *framebuffer) ...@@ -1276,9 +1259,9 @@ bool Renderer9::applyRenderTarget(gl::Framebuffer *framebuffer)
mForceSetViewport = true; mForceSetViewport = true;
mForceSetBlendState = true; mForceSetBlendState = true;
mRenderTargetDesc.width = renderbufferObject->getWidth(); mRenderTargetDesc.width = attachment->getWidth();
mRenderTargetDesc.height = renderbufferObject->getHeight(); mRenderTargetDesc.height = attachment->getHeight();
mRenderTargetDesc.format = renderbufferObject->getActualFormat(); mRenderTargetDesc.format = attachment->getActualFormat();
mRenderTargetDescInitialized = true; mRenderTargetDescInitialized = true;
} }
......
...@@ -542,13 +542,15 @@ bool ValidateBlitFramebufferParameters(gl::Context *context, GLint srcX0, GLint ...@@ -542,13 +542,15 @@ bool ValidateBlitFramebufferParameters(gl::Context *context, GLint srcX0, GLint
{ {
if (drawFramebuffer->isEnabledColorAttachment(colorAttachment)) if (drawFramebuffer->isEnabledColorAttachment(colorAttachment))
{ {
if (drawFramebuffer->getColorbufferType(colorAttachment) != GL_TEXTURE_2D && FramebufferAttachment *attachment = drawFramebuffer->getColorbuffer(colorAttachment);
drawFramebuffer->getColorbufferType(colorAttachment) != GL_RENDERBUFFER) ASSERT(attachment);
if (attachment->type() != GL_TEXTURE_2D && attachment->type() != GL_RENDERBUFFER)
{ {
return gl::error(GL_INVALID_OPERATION, false); return gl::error(GL_INVALID_OPERATION, false);
} }
if (drawFramebuffer->getColorbuffer(colorAttachment)->getActualFormat() != readColorBuffer->getActualFormat()) if (attachment->getActualFormat() != readColorBuffer->getActualFormat())
{ {
return gl::error(GL_INVALID_OPERATION, false); return gl::error(GL_INVALID_OPERATION, false);
} }
......
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