Commit 667ab103 by Nicolas Capens Committed by Nicolas Capens

Support more glCopyTexImage unsized formats.

Convert packed types to the next greater non-packed component type. Specifically, when the red component has fewer than 8 bits, use the corresponding sized internal format with 8-bit components. Note that this is still not fully compliant. The OpenGL ES 3.0 spec section 3.8.5 states that: If internalformat is unsized, the internal format of the new texel array is determined by the following rules, applied in order. If an effective internal format exists that has 1. the same component sizes as, 2. component sizes greater than or equal to, or 3. component sizes smaller than or equal to those of the source buffer’s effective internal format (for all matching components in internalformat), that format is chosen for the new image array, and this is also the new texel array’s effective internal format. This means that in theory when copying an RGBA4 framebuffer into an RGB texture, the effective internal format should be RGB565, not RGB8. However, dEQP does not enforce this, and ANGLE always assumes UNSIGNED_BYTE components. Change-Id: Id243b963779108e205c275499ddfb6e041a873d6 Reviewed-on: https://swiftshader-review.googlesource.com/17969Tested-by: 's avatarNicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com>
parent 894858a5
......@@ -842,12 +842,13 @@ void CopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x,
return error(GL_INVALID_FRAMEBUFFER_OPERATION_OES);
}
if(context->getFramebufferName() != 0 && framebuffer->getColorbuffer()->getSamples() > 1)
es1::Renderbuffer *source = framebuffer->getColorbuffer();
if(!source || source->getSamples() > 1)
{
return error(GL_INVALID_OPERATION);
}
es1::Renderbuffer *source = framebuffer->getColorbuffer();
GLenum colorbufferFormat = source->getFormat();
// [OpenGL ES 1.1.12] table 3.9
......@@ -902,7 +903,7 @@ void CopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x,
{
internalformat = colorbufferFormat;
}
else if(GetRedSize(colorbufferFormat) == 8)
else if(GetRedSize(colorbufferFormat) <= 8)
{
internalformat = gl::GetSizedInternalFormat(internalformat, GL_UNSIGNED_BYTE);
}
......
......@@ -977,10 +977,25 @@ void CopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x,
{
internalformat = colorbufferFormat;
}
else if(GetRedSize(colorbufferFormat) == 8)
else if(GetColorComponentType(colorbufferFormat) == GL_UNSIGNED_NORMALIZED && GetRedSize(colorbufferFormat) <= 8)
{
// TODO: Convert to the smallest format that fits all components.
// e.g. Copying RGBA4 to RGB should result in RGB565, not RGB8.
internalformat = gl::GetSizedInternalFormat(internalformat, GL_UNSIGNED_BYTE);
}
else if(GetColorComponentType(colorbufferFormat) == GL_INT)
{
internalformat = gl::GetSizedInternalFormat(internalformat, GL_INT);
}
else if(GetColorComponentType(colorbufferFormat) == GL_UNSIGNED_INT)
{
internalformat = gl::GetSizedInternalFormat(internalformat, GL_UNSIGNED_INT);
}
else if(GetColorComponentType(colorbufferFormat) == GL_FLOAT && GetRedSize(colorbufferFormat) == 16) // GL_EXT_color_buffer_half_float
{
internalformat = gl::GetSizedInternalFormat(internalformat, GL_HALF_FLOAT_OES);
}
else
{
UNIMPLEMENTED();
......
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