More blitFramebuffer fixes

A few minor adjustments:
- The validity of blit operations with the same bounds on source
  and destination buffer also extends to color buffers
- Renderbuffers, whether GL_RENDERBUFFER or GL_FRAMEBUFFER_DEFAULT
  are considered of the same type for the purpose of blitting

Change-Id: I0de7c19aa8b07fa57ed33b98be4a4ab609e6e115
Reviewed-on: https://swiftshader-review.googlesource.com/8213
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
diff --git a/src/OpenGL/libGLESv2/Context.cpp b/src/OpenGL/libGLESv2/Context.cpp
index 7ccfc9d..47feec6 100644
--- a/src/OpenGL/libGLESv2/Context.cpp
+++ b/src/OpenGL/libGLESv2/Context.cpp
@@ -4047,6 +4047,7 @@
 		partialBufferCopy = true;
 	}
 
+	bool sameBounds = (srcX0 == dstX0 && srcY0 == dstY0 && srcX1 == dstX1 && srcY1 == dstY1);
 	bool blitRenderTarget = false;
 	bool blitDepth = false;
 	bool blitStencil = false;
@@ -4062,7 +4063,7 @@
 			return error(GL_INVALID_OPERATION);
 		}
 
-		if(partialBufferCopy && readBufferSamples > 1)
+		if(partialBufferCopy && readBufferSamples > 1 && !sameBounds)
 		{
 			return error(GL_INVALID_OPERATION);
 		}
@@ -4079,7 +4080,10 @@
 		{
 			if(readFramebuffer->getDepthbuffer() && drawFramebuffer->getDepthbuffer())
 			{
-				if(readFramebuffer->getDepthbufferType() != drawFramebuffer->getDepthbufferType())
+				GLenum readDepthBufferType = readFramebuffer->getDepthbufferType();
+				GLenum drawDepthBufferType = drawFramebuffer->getDepthbufferType();
+				if((readDepthBufferType != drawDepthBufferType) &&
+				   !(Framebuffer::IsRenderbuffer(readDepthBufferType) && Framebuffer::IsRenderbuffer(drawDepthBufferType)))
 				{
 					return error(GL_INVALID_OPERATION);
 				}
@@ -4094,7 +4098,10 @@
 		{
 			if(readFramebuffer->getStencilbuffer() && drawFramebuffer->getStencilbuffer())
 			{
-				if(readFramebuffer->getStencilbufferType() != drawFramebuffer->getStencilbufferType())
+				GLenum readStencilBufferType = readFramebuffer->getStencilbufferType();
+				GLenum drawStencilBufferType = drawFramebuffer->getStencilbufferType();
+				if((readStencilBufferType != drawStencilBufferType) &&
+				   !(Framebuffer::IsRenderbuffer(readStencilBufferType) && Framebuffer::IsRenderbuffer(drawStencilBufferType)))
 				{
 					return error(GL_INVALID_OPERATION);
 				}
@@ -4119,8 +4126,7 @@
 		// INVALID_OPERATION error is generated.
 		if((drawDSBuffer && drawDSBuffer->getSamples() > 1) ||
 		   ((readDSBuffer && readDSBuffer->getSamples() > 1) &&
-		    ((srcX0 != dstX0 || srcY0 != dstY0 || srcX1 != dstX1 || srcY1 != dstY1) ||
-		     (drawDSBuffer->getFormat() != readDSBuffer->getFormat()))))
+		    (!sameBounds || (drawDSBuffer->getFormat() != readDSBuffer->getFormat()))))
 		{
 			return error(GL_INVALID_OPERATION);
 		}