Commit b79fc9f9 by Nicolas Capens

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/3361Tested-by: 's avatarNicolas Capens <capn@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent e2b31f2f
...@@ -1190,8 +1190,6 @@ void APIENTRY glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLi ...@@ -1190,8 +1190,6 @@ void APIENTRY glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLi
return error(GL_INVALID_OPERATION); return error(GL_INVALID_OPERATION);
} }
gl::Renderbuffer *source = framebuffer->getColorbuffer();
GLenum colorbufferFormat = source->getFormat();
gl::Texture *texture = NULL; gl::Texture *texture = NULL;
if(target == GL_TEXTURE_2D) if(target == GL_TEXTURE_2D)
...@@ -1209,62 +1207,6 @@ void APIENTRY glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLi ...@@ -1209,62 +1207,6 @@ void APIENTRY glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLi
return; 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); texture->copySubImage(target, level, xoffset, yoffset, x, y, width, height, framebuffer);
} }
} }
......
...@@ -954,13 +954,13 @@ void CopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, ...@@ -954,13 +954,13 @@ void CopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
return error(GL_INVALID_FRAMEBUFFER_OPERATION_OES); 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); return error(GL_INVALID_OPERATION);
} }
es1::Renderbuffer *source = framebuffer->getColorbuffer();
GLenum colorbufferFormat = source->getFormat();
es1::Texture *texture = NULL; es1::Texture *texture = NULL;
if(target == GL_TEXTURE_2D) if(target == GL_TEXTURE_2D)
...@@ -974,62 +974,6 @@ void CopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, ...@@ -974,62 +974,6 @@ void CopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
return; 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); texture->copySubImage(target, level, xoffset, yoffset, x, y, width, height, framebuffer);
} }
} }
......
...@@ -1351,7 +1351,6 @@ void CopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, ...@@ -1351,7 +1351,6 @@ void CopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
return error(GL_INVALID_OPERATION); return error(GL_INVALID_OPERATION);
} }
GLenum colorbufferFormat = source->getFormat();
es2::Texture *texture = NULL; es2::Texture *texture = NULL;
if(target == GL_TEXTURE_2D) if(target == GL_TEXTURE_2D)
...@@ -1369,13 +1368,6 @@ void CopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, ...@@ -1369,13 +1368,6 @@ void CopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
return; return;
} }
GLenum textureFormat = texture->getFormat(target, level);
if(!validateColorBufferFormat(textureFormat, colorbufferFormat))
{
return;
}
texture->copySubImage(target, level, xoffset, yoffset, 0, x, y, width, height, framebuffer); texture->copySubImage(target, level, xoffset, yoffset, 0, x, y, width, height, framebuffer);
} }
} }
...@@ -6965,7 +6957,6 @@ void CopyTexSubImage3DOES(GLenum target, GLint level, GLint xoffset, GLint yoffs ...@@ -6965,7 +6957,6 @@ void CopyTexSubImage3DOES(GLenum target, GLint level, GLint xoffset, GLint yoffs
return error(GL_INVALID_OPERATION); return error(GL_INVALID_OPERATION);
} }
GLenum colorbufferFormat = source->getFormat();
es2::Texture3D *texture = context->getTexture3D(); es2::Texture3D *texture = context->getTexture3D();
if(!validateSubImageParams(false, width, height, 1, xoffset, yoffset, zoffset, target, level, GL_NONE, texture)) if(!validateSubImageParams(false, width, height, 1, xoffset, yoffset, zoffset, target, level, GL_NONE, texture))
...@@ -6973,13 +6964,6 @@ void CopyTexSubImage3DOES(GLenum target, GLint level, GLint xoffset, GLint yoffs ...@@ -6973,13 +6964,6 @@ void CopyTexSubImage3DOES(GLenum target, GLint level, GLint xoffset, GLint yoffs
return; return;
} }
GLenum textureFormat = texture->getFormat(target, level);
if(!validateColorBufferFormat(textureFormat, colorbufferFormat))
{
return;
}
texture->copySubImage(target, level, xoffset, yoffset, zoffset, x, y, width, height, framebuffer); texture->copySubImage(target, level, xoffset, yoffset, zoffset, x, y, width, height, framebuffer);
} }
} }
......
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