GLsizei inputWidth = (mState.unpackInfo.rowLength == 0) ? width : mState.unpackInfo.rowLength;
GLsizei inputPitch = egl::ComputePitch(inputWidth, format, type, mState.unpackInfo.alignment);
GLsizei inputHeight = (mState.unpackInfo.imageHeight == 0) ? height : mState.unpackInfo.imageHeight;
- size_t offset = egl::ComputePackingOffset(format, type, inputWidth, inputHeight, mState.unpackInfo.alignment, mState.unpackInfo.skipImages, mState.unpackInfo.skipRows, mState.unpackInfo.skipPixels);
- return inputPitch * inputHeight * depth + static_cast<GLsizei>(offset);
+ return inputPitch * inputHeight * depth;
}
-GLenum Context::getPixels(const GLvoid **data, GLsizei imageSize) const
+GLenum Context::getPixels(const GLvoid **data, GLenum type, GLsizei imageSize) const
{
if(mState.pixelUnpackBuffer)
{
{
if(mState.pixelUnpackBuffer->isMapped() ||
(mState.pixelUnpackBuffer->size() < static_cast<size_t>(imageSize)) ||
- ((*data) && (imageSize % static_cast<GLsizei>((ptrdiff_t)(*data)))))
+ (static_cast<GLsizei>((ptrdiff_t)(*data)) % GetTypeSize(type)))
{
return GL_INVALID_OPERATION;
}
Buffer *getPixelUnpackBuffer() const;
Buffer *getGenericUniformBuffer() const;
GLsizei getRequiredBufferSize(GLsizei width, GLsizei height, GLsizei depth, GLint internalformat, GLenum type) const;
- GLenum getPixels(const GLvoid **data, GLsizei imageSize) const;
+ GLenum getPixels(const GLvoid **data, GLenum type, GLsizei imageSize) const;
bool getBuffer(GLenum target, es2::Buffer **buffer) const;
Program *getCurrentProgram() const;
Texture2D *getTexture2D() const;
return error(GL_INVALID_OPERATION);
}
- GLenum validationError = context->getPixels(&data, imageSize);
+ GLenum validationError = context->getPixels(&data, texture->getType(target, level), imageSize);
if(validationError != GL_NONE)
{
return error(validationError);
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
{
- GLenum validationError = context->getPixels(&data, imageSize);
+ GLenum validationError = context->getPixels(&data, texture->getType(target, level), imageSize);
if(validationError != GL_NONE)
{
return error(validationError);
if(validationError == GL_NONE)
{
- validationError = context->getPixels(&data, imageSize);
+ validationError = context->getPixels(&data, texture->getType(target, level), imageSize);
}
if(validationError == GL_NONE)
if(validationError == GL_NONE)
{
- validationError = context->getPixels(&data, imageSize);
+ validationError = context->getPixels(&data, texture->getType(target, level), imageSize);
}
if(validationError == GL_NONE)
GLenum sizedInternalFormat = GetSizedInternalFormat(format, type);
- validationError = context->getPixels(&data, context->getRequiredBufferSize(width, height, 1, sizedInternalFormat, type));
+ validationError = context->getPixels(&data, type, context->getRequiredBufferSize(width, height, 1, sizedInternalFormat, type));
if(validationError != GL_NONE)
{
return error(validationError);
{
GLenum sizedInternalFormat = GetSizedInternalFormat(format, type);
- GLenum validationError = context->getPixels(&data, context->getRequiredBufferSize(width, height, 1, sizedInternalFormat, type));
+ GLenum validationError = context->getPixels(&data, type, context->getRequiredBufferSize(width, height, 1, sizedInternalFormat, type));
if(validationError != GL_NONE)
{
return error(validationError);
}
GLenum sizedInternalFormat = GetSizedInternalFormat(internalformat, type);
- GLenum validationError = context->getPixels(&data, context->getRequiredBufferSize(width, height, depth, sizedInternalFormat, type));
+ GLenum validationError = context->getPixels(&data, type, context->getRequiredBufferSize(width, height, depth, sizedInternalFormat, type));
if(validationError != GL_NONE)
{
return error(validationError);
if(validationError == GL_NONE)
{
- validationError = context->getPixels(&data, context->getRequiredBufferSize(width, height, depth, sizedInternalFormat, type));
+ validationError = context->getPixels(&data, type, context->getRequiredBufferSize(width, height, depth, sizedInternalFormat, type));
}
if(validationError == GL_NONE)
return error(GL_INVALID_OPERATION);
}
- GLenum validationError = context->getPixels(&data, imageSize);
+ GLenum validationError = context->getPixels(&data, texture->getType(target, level), imageSize);
if(validationError != GL_NONE)
{
return error(GL_INVALID_OPERATION);
}
- GLenum validationError = context->getPixels(&data, imageSize);
+ GLenum validationError = context->getPixels(&data, texture->getType(target, level), imageSize);
if(validationError != GL_NONE)
{
GLenum sizedInternalFormat = GetSizedInternalFormat(internalformat, type);
- GLenum validationError = context->getPixels(&data, context->getRequiredBufferSize(width, height, depth, sizedInternalFormat, type));
+ GLenum validationError = context->getPixels(&data, type, context->getRequiredBufferSize(width, height, depth, sizedInternalFormat, type));
if(validationError != GL_NONE)
{
return error(validationError);
GLenum validationError = ValidateSubImageParams(false, width, height, depth, xoffset, yoffset, zoffset, target, level, sizedInternalFormat, texture);
if(validationError == GL_NONE)
{
- GLenum validationError = context->getPixels(&data, context->getRequiredBufferSize(width, height, depth, sizedInternalFormat, type));
+ GLenum validationError = context->getPixels(&data, type, context->getRequiredBufferSize(width, height, depth, sizedInternalFormat, type));
if(validationError != GL_NONE)
{
return error(validationError);
return error(GL_INVALID_OPERATION);
}
- GLenum validationError = context->getPixels(&data, imageSize);
+ GLenum validationError = context->getPixels(&data, texture->getType(target, level), imageSize);
if(validationError != GL_NONE)
{
return error(validationError);
return error(GL_INVALID_OPERATION);
}
- GLenum validationError = context->getPixels(&data, imageSize);
+ GLenum validationError = context->getPixels(&data, texture->getType(target, level), imageSize);
if(validationError != GL_NONE)
{
return error(validationError);
return true;
}
+ GLsizei GetTypeSize(GLenum type)
+ {
+ switch(type)
+ {
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ return 1;
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_5_6_5:
+ case GL_HALF_FLOAT_OES:
+ case GL_UNSIGNED_SHORT:
+ case GL_SHORT:
+ case GL_HALF_FLOAT:
+ return 2;
+ case GL_FLOAT:
+ case GL_UNSIGNED_INT_24_8:
+ case GL_UNSIGNED_INT:
+ case GL_INT:
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ case GL_UNSIGNED_INT_10F_11F_11F_REV:
+ case GL_UNSIGNED_INT_5_9_9_9_REV:
+ case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
+ return 4;
+ default:
+ UNREACHABLE(type);
+ break;
+ }
+
+ return 1;
+ }
+
bool IsColorRenderable(GLenum internalformat, GLint clientVersion, bool isTexture)
{
switch(internalformat)
int CubeFaceIndex(GLenum cubeTarget);
bool IsTextureTarget(GLenum target);
bool ValidateTextureFormatType(GLenum format, GLenum type, GLint internalformat, GLint clientVersion);
+ GLsizei GetTypeSize(GLenum type);
bool IsColorRenderable(GLenum internalformat, GLint clientVersion, bool isTexture);
bool IsDepthRenderable(GLenum internalformat, GLint clientVersion);