Refactor pixel storage modes.
Change-Id: Ida0a270c1e0ab0900109b7d3bce90dfee9a01960
Reviewed-on: https://swiftshader-review.googlesource.com/17091
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/OpenGL/libGLESv2/libGLESv3.cpp b/src/OpenGL/libGLESv2/libGLESv3.cpp
index 0526254..0af7b65 100644
--- a/src/OpenGL/libGLESv2/libGLESv3.cpp
+++ b/src/OpenGL/libGLESv2/libGLESv3.cpp
@@ -633,7 +633,7 @@
}
GLenum sizedInternalFormat = GetSizedInternalFormat(internalformat, type);
- texture->setImage(context, level, width, height, depth, sizedInternalFormat, format, type, context->getUnpackInfo(), data);
+ texture->setImage(context, level, width, height, depth, sizedInternalFormat, format, type, context->getUnpackParameters(), data);
}
}
@@ -686,7 +686,7 @@
return error(validationError);
}
- texture->subImage(context, level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getUnpackInfo(), data);
+ texture->subImage(context, level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getUnpackParameters(), data);
}
}
@@ -3869,41 +3869,41 @@
{
case GL_TEXTURE_2D:
case GL_TEXTURE_RECTANGLE_ARB:
- {
- es2::Texture2D *texture = context->getTexture2D(target);
- if(!texture || texture->name == 0 || texture->getImmutableFormat() == GL_TRUE)
{
- return error(GL_INVALID_OPERATION);
- }
-
+ es2::Texture2D *texture = context->getTexture2D(target);
+ if(!texture || texture->name == 0 || texture->getImmutableFormat() == GL_TRUE)
+ {
+ return error(GL_INVALID_OPERATION);
+ }
+
for(int level = 0; level < levels; level++)
- {
- texture->setImage(context, level, width, height, sizedInternalFormat, sizedInternalFormat, type, context->getUnpackInfo(), nullptr);
- width = std::max(1, (width / 2));
- height = std::max(1, (height / 2));
+ {
+ texture->setImage(context, level, width, height, sizedInternalFormat, sizedInternalFormat, type, context->getUnpackParameters(), nullptr);
+ width = std::max(1, (width / 2));
+ height = std::max(1, (height / 2));
+ }
+ texture->makeImmutable(levels);
}
- texture->makeImmutable(levels);
- }
break;
case GL_TEXTURE_CUBE_MAP:
- {
- es2::TextureCubeMap *texture = context->getTextureCubeMap();
- if(!texture || texture->name == 0 || texture->getImmutableFormat())
{
- return error(GL_INVALID_OPERATION);
- }
-
- for(int level = 0; level < levels; level++)
- {
- for(int face = GL_TEXTURE_CUBE_MAP_POSITIVE_X; face <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z; face++)
+ es2::TextureCubeMap *texture = context->getTextureCubeMap();
+ if(!texture || texture->name == 0 || texture->getImmutableFormat())
{
- texture->setImage(context, face, level, width, height, sizedInternalFormat, sizedInternalFormat, type, context->getUnpackInfo(), nullptr);
+ return error(GL_INVALID_OPERATION);
}
- width = std::max(1, (width / 2));
- height = std::max(1, (height / 2));
+
+ for(int level = 0; level < levels; level++)
+ {
+ for(int face = GL_TEXTURE_CUBE_MAP_POSITIVE_X; face <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z; face++)
+ {
+ texture->setImage(context, face, level, width, height, sizedInternalFormat, sizedInternalFormat, type, context->getUnpackParameters(), nullptr);
+ }
+ width = std::max(1, (width / 2));
+ height = std::max(1, (height / 2));
+ }
+ texture->makeImmutable(levels);
}
- texture->makeImmutable(levels);
- }
break;
default:
return error(GL_INVALID_ENUM);
@@ -3935,52 +3935,52 @@
switch(target)
{
case GL_TEXTURE_3D:
- {
- if(levels > es2::IMPLEMENTATION_MAX_TEXTURE_LEVELS || levels > (log2(std::max(std::max(width, height), depth)) + 1))
{
- return error(GL_INVALID_OPERATION);
- }
-
- es2::Texture3D *texture = context->getTexture3D();
- if(!texture || texture->name == 0 || texture->getImmutableFormat() == GL_TRUE)
- {
- return error(GL_INVALID_OPERATION);
- }
-
+ if(levels > es2::IMPLEMENTATION_MAX_TEXTURE_LEVELS || levels > (log2(std::max(std::max(width, height), depth)) + 1))
+ {
+ return error(GL_INVALID_OPERATION);
+ }
+
+ es2::Texture3D *texture = context->getTexture3D();
+ if(!texture || texture->name == 0 || texture->getImmutableFormat() == GL_TRUE)
+ {
+ return error(GL_INVALID_OPERATION);
+ }
+
for(int level = 0; level < levels; level++)
- {
- texture->setImage(context, level, width, height, depth, sizedInternalFormat, sizedInternalFormat, type, context->getUnpackInfo(), nullptr);
- width = std::max(1, (width / 2));
- height = std::max(1, (height / 2));
- depth = std::max(1, (depth / 2));
+ {
+ texture->setImage(context, level, width, height, depth, sizedInternalFormat, sizedInternalFormat, type, context->getUnpackParameters(), nullptr);
+ width = std::max(1, (width / 2));
+ height = std::max(1, (height / 2));
+ depth = std::max(1, (depth / 2));
+ }
+ texture->makeImmutable(levels);
}
- texture->makeImmutable(levels);
- }
break;
case GL_TEXTURE_2D_ARRAY:
- {
- if(levels > es2::IMPLEMENTATION_MAX_TEXTURE_LEVELS || levels > (log2(std::max(width, height)) + 1))
{
- return error(GL_INVALID_OPERATION);
- }
-
- es2::Texture3D *texture = context->getTexture2DArray();
- if(!texture || texture->name == 0 || texture->getImmutableFormat())
- {
- return error(GL_INVALID_OPERATION);
- }
-
- for(int level = 0; level < levels; level++)
- {
- for(int face = GL_TEXTURE_CUBE_MAP_POSITIVE_X; face <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z; face++)
+ if(levels > es2::IMPLEMENTATION_MAX_TEXTURE_LEVELS || levels > (log2(std::max(width, height)) + 1))
{
- texture->setImage(context, level, width, height, depth, sizedInternalFormat, sizedInternalFormat, type, context->getUnpackInfo(), nullptr);
+ return error(GL_INVALID_OPERATION);
}
- width = std::max(1, (width / 2));
- height = std::max(1, (height / 2));
+
+ es2::Texture3D *texture = context->getTexture2DArray();
+ if(!texture || texture->name == 0 || texture->getImmutableFormat())
+ {
+ return error(GL_INVALID_OPERATION);
+ }
+
+ for(int level = 0; level < levels; level++)
+ {
+ for(int face = GL_TEXTURE_CUBE_MAP_POSITIVE_X; face <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z; face++)
+ {
+ texture->setImage(context, level, width, height, depth, sizedInternalFormat, sizedInternalFormat, type, context->getUnpackParameters(), nullptr);
+ }
+ width = std::max(1, (width / 2));
+ height = std::max(1, (height / 2));
+ }
+ texture->makeImmutable(levels);
}
- texture->makeImmutable(levels);
- }
break;
default:
return error(GL_INVALID_ENUM);