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/205606
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Tested-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libGLESv2/renderer/d3d/d3d11/Renderer11.cpp b/src/libGLESv2/renderer/d3d/d3d11/Renderer11.cpp
index b9e7404..646bd9b 100644
--- a/src/libGLESv2/renderer/d3d/d3d11/Renderer11.cpp
+++ b/src/libGLESv2/renderer/d3d/d3d11/Renderer11.cpp
@@ -816,20 +816,13 @@
for (unsigned int colorAttachment = 0; colorAttachment < gl::IMPLEMENTATION_MAX_DRAW_BUFFERS; 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)
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.
// 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.
@@ -869,31 +862,16 @@
}
// Get the depth stencil render buffer and serials
- gl::FramebufferAttachment *depthStencil = NULL;
+ gl::FramebufferAttachment *depthStencil = framebuffer->getDepthbuffer();
unsigned int depthbufferSerial = 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();
}
- else if (framebuffer->getStencilbufferType() != GL_NONE)
+ else if (framebuffer->getStencilbuffer())
{
depthStencil = framebuffer->getStencilbuffer();
- if (!depthStencil)
- {
- ERR("Depth stencil pointer unexpectedly null.");
- SafeRelease(framebufferRTVs);
- return false;
- }
-
stencilbufferSerial = depthStencil->getSerial();
}
@@ -3349,20 +3327,20 @@
gl::FramebufferAttachment *attachment = framebuffer->getColorbuffer(colorAttachment);
if (attachment && attachment->isTexture())
{
- invalidateFBOAttachmentSwizzles(attachment, framebuffer->getColorbufferMipLevel(colorAttachment));
+ invalidateFBOAttachmentSwizzles(attachment, attachment->mipLevel());
}
}
gl::FramebufferAttachment *depthAttachment = framebuffer->getDepthbuffer();
if (depthAttachment && depthAttachment->isTexture())
{
- invalidateFBOAttachmentSwizzles(depthAttachment, framebuffer->getDepthbufferMipLevel());
+ invalidateFBOAttachmentSwizzles(depthAttachment, depthAttachment->mipLevel());
}
gl::FramebufferAttachment *stencilAttachment = framebuffer->getStencilbuffer();
if (stencilAttachment && stencilAttachment->isTexture())
{
- invalidateFBOAttachmentSwizzles(stencilAttachment, framebuffer->getStencilbufferMipLevel());
+ invalidateFBOAttachmentSwizzles(stencilAttachment, stencilAttachment->mipLevel());
}
}
diff --git a/src/libGLESv2/renderer/d3d/d3d9/Renderer9.cpp b/src/libGLESv2/renderer/d3d/d3d9/Renderer9.cpp
index c8dffe0..c7d66c5 100644
--- a/src/libGLESv2/renderer/d3d/d3d9/Renderer9.cpp
+++ b/src/libGLESv2/renderer/d3d/d3d9/Renderer9.cpp
@@ -1151,29 +1151,25 @@
{
// 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.
- gl::FramebufferAttachment *renderbufferObject = NULL;
- if (framebuffer->getColorbufferType(0) != GL_NONE)
+ gl::FramebufferAttachment *attachment = framebuffer->getColorbuffer(0);
+ if (!attachment)
{
- renderbufferObject = framebuffer->getColorbuffer(0);
+ attachment = getNullColorbuffer(framebuffer->getDepthbuffer());
}
- else
- {
- renderbufferObject = getNullColorbuffer(framebuffer->getDepthbuffer());
- }
- if (!renderbufferObject)
+ if (!attachment)
{
ERR("unable to locate renderbuffer for FBO.");
return false;
}
bool renderTargetChanged = false;
- unsigned int renderTargetSerial = renderbufferObject->getSerial();
+ unsigned int renderTargetSerial = attachment->getSerial();
if (renderTargetSerial != mAppliedRenderTargetSerial)
{
// Apply the render target on the device
IDirect3DSurface9 *renderTargetSurface = NULL;
- RenderTarget *renderTarget = renderbufferObject->getRenderTarget();
+ RenderTarget *renderTarget = attachment->getRenderTarget();
if (renderTarget)
{
renderTargetSurface = RenderTarget9::makeRenderTarget9(renderTarget)->getSurface();
@@ -1192,29 +1188,16 @@
renderTargetChanged = true;
}
- gl::FramebufferAttachment *depthStencil = NULL;
+ gl::FramebufferAttachment *depthStencil = framebuffer->getDepthbuffer();
unsigned int depthbufferSerial = 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();
}
- else if (framebuffer->getStencilbufferType() != GL_NONE)
+ else if (framebuffer->getStencilbuffer())
{
depthStencil = framebuffer->getStencilbuffer();
- if (!depthStencil)
- {
- ERR("Depth stencil pointer unexpectedly null.");
- return false;
- }
-
stencilbufferSerial = depthStencil->getSerial();
}
@@ -1276,9 +1259,9 @@
mForceSetViewport = true;
mForceSetBlendState = true;
- mRenderTargetDesc.width = renderbufferObject->getWidth();
- mRenderTargetDesc.height = renderbufferObject->getHeight();
- mRenderTargetDesc.format = renderbufferObject->getActualFormat();
+ mRenderTargetDesc.width = attachment->getWidth();
+ mRenderTargetDesc.height = attachment->getHeight();
+ mRenderTargetDesc.format = attachment->getActualFormat();
mRenderTargetDescInitialized = true;
}