mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-17 07:15:46 +00:00
Bug 1229210. Handle the new formats required by WebGL2 in ReadPixels. r=jgilbert
This is required for deqp/functional/gles3/builtinprecision00.html to pass on Linux
This commit is contained in:
parent
f7dbec6ee1
commit
9d9541f65f
@ -1339,6 +1339,24 @@ IsFormatAndTypeUnpackable(GLenum format, GLenum type)
|
||||
}
|
||||
}
|
||||
|
||||
static bool
|
||||
IsIntegerFormatAndTypeUnpackable(GLenum format, GLenum type)
|
||||
{
|
||||
switch (type) {
|
||||
case LOCAL_GL_UNSIGNED_INT:
|
||||
case LOCAL_GL_INT:
|
||||
switch (format) {
|
||||
case LOCAL_GL_RGBA_INTEGER:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CheckedUint32
|
||||
WebGLContext::GetPackSize(uint32_t width, uint32_t height, uint8_t bytesPerPixel,
|
||||
CheckedUint32* const out_startOffset,
|
||||
@ -1394,8 +1412,10 @@ WebGLContext::ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum
|
||||
if (pixels.IsNull())
|
||||
return ErrorInvalidValue("readPixels: null destination buffer");
|
||||
|
||||
if (!IsFormatAndTypeUnpackable(format, type))
|
||||
if (!(IsWebGL2() && IsIntegerFormatAndTypeUnpackable(format, type)) &&
|
||||
!IsFormatAndTypeUnpackable(format, type)) {
|
||||
return ErrorInvalidEnum("readPixels: Bad format or type.");
|
||||
}
|
||||
|
||||
int channels = 0;
|
||||
|
||||
@ -1408,6 +1428,7 @@ WebGLContext::ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum
|
||||
channels = 3;
|
||||
break;
|
||||
case LOCAL_GL_RGBA:
|
||||
case LOCAL_GL_RGBA_INTEGER:
|
||||
channels = 4;
|
||||
break;
|
||||
default:
|
||||
@ -1431,6 +1452,16 @@ WebGLContext::ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum
|
||||
requiredDataType = js::Scalar::Uint16;
|
||||
break;
|
||||
|
||||
case LOCAL_GL_UNSIGNED_INT:
|
||||
bytesPerPixel = 4;
|
||||
requiredDataType = js::Scalar::Uint32;
|
||||
break;
|
||||
|
||||
case LOCAL_GL_INT:
|
||||
bytesPerPixel = 4;
|
||||
requiredDataType = js::Scalar::Int32;
|
||||
break;
|
||||
|
||||
case LOCAL_GL_FLOAT:
|
||||
bytesPerPixel = 4*channels;
|
||||
requiredDataType = js::Scalar::Float32;
|
||||
|
Loading…
Reference in New Issue
Block a user