Don't restrict format combinations on CopyTexSubImage.
CopyTexSubImage does not have the format combination restriction
that CopyTexImage has. The destination may have components not
present in the source image.
Bug 21610276
Change-Id: I90f4c0679ceb1061b05a404aa6ca817205b5077f
Reviewed-on: https://swiftshader-review.googlesource.com/3361
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
diff --git a/src/OpenGL/libGL/libGL.cpp b/src/OpenGL/libGL/libGL.cpp
index 95ce8e1..60c456f 100644
--- a/src/OpenGL/libGL/libGL.cpp
+++ b/src/OpenGL/libGL/libGL.cpp
@@ -1190,8 +1190,6 @@
return error(GL_INVALID_OPERATION);
}
- gl::Renderbuffer *source = framebuffer->getColorbuffer();
- GLenum colorbufferFormat = source->getFormat();
gl::Texture *texture = NULL;
if(target == GL_TEXTURE_2D)
@@ -1209,62 +1207,6 @@
return;
}
- GLenum textureFormat = texture->getFormat(target, level);
-
- switch(textureFormat)
- {
- case GL_ALPHA:
- if(colorbufferFormat != GL_ALPHA &&
- colorbufferFormat != GL_RGBA &&
- colorbufferFormat != GL_RGBA4 &&
- colorbufferFormat != GL_RGB5_A1 &&
- colorbufferFormat != GL_RGBA8_EXT)
- {
- return error(GL_INVALID_OPERATION);
- }
- break;
- case GL_LUMINANCE:
- case GL_RGB:
- if(colorbufferFormat != GL_RGB &&
- colorbufferFormat != GL_RGB565 &&
- colorbufferFormat != GL_RGB8_EXT &&
- colorbufferFormat != GL_RGBA &&
- colorbufferFormat != GL_RGBA4 &&
- colorbufferFormat != GL_RGB5_A1 &&
- colorbufferFormat != GL_RGBA8_EXT)
- {
- return error(GL_INVALID_OPERATION);
- }
- break;
- case GL_LUMINANCE_ALPHA:
- case GL_RGBA:
- if(colorbufferFormat != GL_RGBA &&
- colorbufferFormat != GL_RGBA4 &&
- colorbufferFormat != GL_RGB5_A1 &&
- colorbufferFormat != GL_RGBA8_EXT)
- {
- return error(GL_INVALID_OPERATION);
- }
- break;
- case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
- case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
- case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
- case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
- return error(GL_INVALID_OPERATION);
- case GL_DEPTH_COMPONENT:
- case GL_DEPTH_STENCIL_EXT:
- return error(GL_INVALID_OPERATION);
- case GL_BGRA_EXT:
- if(colorbufferFormat != GL_RGB8)
- {
- UNIMPLEMENTED();
- return error(GL_INVALID_OPERATION);
- }
- break;
- default:
- return error(GL_INVALID_ENUM);
- }
-
texture->copySubImage(target, level, xoffset, yoffset, x, y, width, height, framebuffer);
}
}
diff --git a/src/OpenGL/libGLES_CM/libGLES_CM.cpp b/src/OpenGL/libGLES_CM/libGLES_CM.cpp
index 9ed8851..923deb9 100644
--- a/src/OpenGL/libGLES_CM/libGLES_CM.cpp
+++ b/src/OpenGL/libGLES_CM/libGLES_CM.cpp
@@ -954,13 +954,13 @@
return error(GL_INVALID_FRAMEBUFFER_OPERATION_OES);
}
- if(context->getFramebufferName() != 0 && framebuffer->getColorbuffer()->getSamples() > 1)
+ es1::Renderbuffer *source = framebuffer->getColorbuffer();
+
+ if(context->getFramebufferName() != 0 && (!source || source->getSamples() > 1))
{
return error(GL_INVALID_OPERATION);
}
- es1::Renderbuffer *source = framebuffer->getColorbuffer();
- GLenum colorbufferFormat = source->getFormat();
es1::Texture *texture = NULL;
if(target == GL_TEXTURE_2D)
@@ -974,62 +974,6 @@
return;
}
- GLenum textureFormat = texture->getFormat(target, level);
-
- // [OpenGL ES 2.0.24] table 3.9
- switch(textureFormat)
- {
- case GL_ALPHA:
- if(colorbufferFormat != GL_ALPHA &&
- colorbufferFormat != GL_RGBA &&
- colorbufferFormat != GL_RGBA4_OES &&
- colorbufferFormat != GL_RGB5_A1_OES &&
- colorbufferFormat != GL_RGBA8_OES)
- {
- return error(GL_INVALID_OPERATION);
- }
- break;
- case GL_LUMINANCE:
- case GL_RGB:
- if(colorbufferFormat != GL_RGB &&
- colorbufferFormat != GL_RGB565_OES &&
- colorbufferFormat != GL_RGB8_OES &&
- colorbufferFormat != GL_RGBA &&
- colorbufferFormat != GL_RGBA4_OES &&
- colorbufferFormat != GL_RGB5_A1_OES &&
- colorbufferFormat != GL_RGBA8_OES)
- {
- return error(GL_INVALID_OPERATION);
- }
- break;
- case GL_LUMINANCE_ALPHA:
- case GL_RGBA:
- if(colorbufferFormat != GL_RGBA &&
- colorbufferFormat != GL_RGBA4_OES &&
- colorbufferFormat != GL_RGB5_A1_OES &&
- colorbufferFormat != GL_RGBA8_OES)
- {
- return error(GL_INVALID_OPERATION);
- }
- break;
- case GL_ETC1_RGB8_OES:
- return error(GL_INVALID_OPERATION);
- case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
- case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
- if(S3TC_SUPPORT)
- {
- return error(GL_INVALID_OPERATION);
- }
- else
- {
- return error(GL_INVALID_ENUM);
- }
- case GL_DEPTH_STENCIL_OES:
- return error(GL_INVALID_OPERATION);
- default:
- return error(GL_INVALID_ENUM);
- }
-
texture->copySubImage(target, level, xoffset, yoffset, x, y, width, height, framebuffer);
}
}
diff --git a/src/OpenGL/libGLESv2/libGLESv2.cpp b/src/OpenGL/libGLESv2/libGLESv2.cpp
index e18022d..e458c43 100644
--- a/src/OpenGL/libGLESv2/libGLESv2.cpp
+++ b/src/OpenGL/libGLESv2/libGLESv2.cpp
@@ -1351,7 +1351,6 @@
return error(GL_INVALID_OPERATION);
}
- GLenum colorbufferFormat = source->getFormat();
es2::Texture *texture = NULL;
if(target == GL_TEXTURE_2D)
@@ -1369,13 +1368,6 @@
return;
}
- GLenum textureFormat = texture->getFormat(target, level);
-
- if(!validateColorBufferFormat(textureFormat, colorbufferFormat))
- {
- return;
- }
-
texture->copySubImage(target, level, xoffset, yoffset, 0, x, y, width, height, framebuffer);
}
}
@@ -6965,7 +6957,6 @@
return error(GL_INVALID_OPERATION);
}
- GLenum colorbufferFormat = source->getFormat();
es2::Texture3D *texture = context->getTexture3D();
if(!validateSubImageParams(false, width, height, 1, xoffset, yoffset, zoffset, target, level, GL_NONE, texture))
@@ -6973,13 +6964,6 @@
return;
}
- GLenum textureFormat = texture->getFormat(target, level);
-
- if(!validateColorBufferFormat(textureFormat, colorbufferFormat))
- {
- return;
- }
-
texture->copySubImage(target, level, xoffset, yoffset, zoffset, x, y, width, height, framebuffer);
}
}