Commit 7ad7f6d7 authored by cwallez's avatar cwallez Committed by Commit bot

Passthrough CmdDecoder: Reset unpack state on some TexImage

The command buffer client handles all the unpack parameters but
alignment for non-compressed texture uploads from client data.
Resetting the unpack state was handled transparently on the
service-side. This implements the resetting in the passthrough cmd
decoder too.

This makes the following tests pass with the passthrough command buffer:
 - conformance2/textures/misc/tex-unpack-params
 - deqp/functional/gles3/texturespecification/teximage2d_unpack_params
 - deqp/functional/gles3/texturespecification/teximage3d_unpack_params
 - deqp/functional/gles3/texturespecification/texsubimage2d_unpack_params
 - deqp/functional/gles3/texturespecification/texsubimage3d_unpack_params

BUG=chromium:602688
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel

Review-Url: https://codereview.chromium.org/2844393004
Cr-Commit-Position: refs/heads/master@{#468322}
parent 7938b191
...@@ -473,7 +473,7 @@ error::Error DoTexImage2D(GLenum target, ...@@ -473,7 +473,7 @@ error::Error DoTexImage2D(GLenum target,
GLint border, GLint border,
GLenum format, GLenum format,
GLenum type, GLenum type,
GLsizei imagesize, GLsizei image_size,
const void* pixels); const void* pixels);
error::Error DoTexImage3D(GLenum target, error::Error DoTexImage3D(GLenum target,
GLint level, GLint level,
...@@ -484,7 +484,7 @@ error::Error DoTexImage3D(GLenum target, ...@@ -484,7 +484,7 @@ error::Error DoTexImage3D(GLenum target,
GLint border, GLint border,
GLenum format, GLenum format,
GLenum type, GLenum type,
GLsizei imagesize, GLsizei image_size,
const void* pixels); const void* pixels);
error::Error DoTexParameterf(GLenum target, GLenum pname, GLfloat param); error::Error DoTexParameterf(GLenum target, GLenum pname, GLfloat param);
error::Error DoTexParameterfv(GLenum target, error::Error DoTexParameterfv(GLenum target,
...@@ -508,7 +508,7 @@ error::Error DoTexSubImage2D(GLenum target, ...@@ -508,7 +508,7 @@ error::Error DoTexSubImage2D(GLenum target,
GLsizei height, GLsizei height,
GLenum format, GLenum format,
GLenum type, GLenum type,
GLsizei imagesize, GLsizei image_size,
const void* pixels); const void* pixels);
error::Error DoTexSubImage3D(GLenum target, error::Error DoTexSubImage3D(GLenum target,
GLint level, GLint level,
...@@ -520,7 +520,7 @@ error::Error DoTexSubImage3D(GLenum target, ...@@ -520,7 +520,7 @@ error::Error DoTexSubImage3D(GLenum target,
GLsizei depth, GLsizei depth,
GLenum format, GLenum format,
GLenum type, GLenum type,
GLsizei imagesize, GLsizei image_size,
const void* pixels); const void* pixels);
error::Error DoTransformFeedbackVaryings(GLuint program, error::Error DoTransformFeedbackVaryings(GLuint program,
GLsizei count, GLsizei count,
......
...@@ -193,6 +193,62 @@ void AppendStringToBuffer(std::vector<uint8_t>* data, ...@@ -193,6 +193,62 @@ void AppendStringToBuffer(std::vector<uint8_t>* data,
memcpy(data->data() + old_size.ValueOrDie(), str, len); memcpy(data->data() + old_size.ValueOrDie(), str, len);
} }
// In order to minimize the amount of data copied, the command buffer client
// unpack pixels before sending the glTex[Sub]Image[2|3]D calls. The only
// parameter it doesn't handle is the alignment. Resetting the unpack state is
// not needed when uploading from a PBO and for compressed formats which the
// client sends untouched. This class handles resetting and restoring the unpack
// state.
// TODO(cwallez@chromium.org) it would be nicer to handle the resetting /
// restoring on the client side.
class ScopedUnpackStateButAlignmentReset {
public:
ScopedUnpackStateButAlignmentReset(bool enable, bool is_3d) {
if (!enable) {
return;
}
glGetIntegerv(GL_UNPACK_SKIP_PIXELS, &skip_pixels_);
glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
glGetIntegerv(GL_UNPACK_SKIP_ROWS, &skip_rows_);
glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
glGetIntegerv(GL_UNPACK_ROW_LENGTH, &row_length_);
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
if (is_3d) {
glGetIntegerv(GL_UNPACK_SKIP_IMAGES, &skip_images_);
glPixelStorei(GL_UNPACK_SKIP_IMAGES, 0);
glGetIntegerv(GL_UNPACK_IMAGE_HEIGHT, &image_height_);
glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, 0);
}
}
~ScopedUnpackStateButAlignmentReset() {
if (skip_pixels_ != 0) {
glPixelStorei(GL_UNPACK_SKIP_PIXELS, skip_pixels_);
}
if (skip_rows_ != 0) {
glPixelStorei(GL_UNPACK_SKIP_ROWS, skip_rows_);
}
if (skip_images_ != 0) {
glPixelStorei(GL_UNPACK_SKIP_IMAGES, skip_images_);
}
if (row_length_ != 0) {
glPixelStorei(GL_UNPACK_ROW_LENGTH, row_length_);
}
if (image_height_ != 0) {
glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, image_height_);
}
}
private:
GLint skip_pixels_ = 0;
GLint skip_rows_ = 0;
GLint skip_images_ = 0;
GLint row_length_ = 0;
GLint image_height_ = 0;
};
} // anonymous namespace } // anonymous namespace
// Implementations of commands // Implementations of commands
...@@ -1845,10 +1901,12 @@ error::Error GLES2DecoderPassthroughImpl::DoTexImage2D(GLenum target, ...@@ -1845,10 +1901,12 @@ error::Error GLES2DecoderPassthroughImpl::DoTexImage2D(GLenum target,
GLint border, GLint border,
GLenum format, GLenum format,
GLenum type, GLenum type,
GLsizei imagesize, GLsizei image_size,
const void* pixels) { const void* pixels) {
ScopedUnpackStateButAlignmentReset reset_unpack(
image_size != 0 && feature_info_->gl_version_info().is_es3, false);
glTexImage2DRobustANGLE(target, level, internalformat, width, height, border, glTexImage2DRobustANGLE(target, level, internalformat, width, height, border,
format, type, imagesize, pixels); format, type, image_size, pixels);
return error::kNoError; return error::kNoError;
} }
...@@ -1861,10 +1919,12 @@ error::Error GLES2DecoderPassthroughImpl::DoTexImage3D(GLenum target, ...@@ -1861,10 +1919,12 @@ error::Error GLES2DecoderPassthroughImpl::DoTexImage3D(GLenum target,
GLint border, GLint border,
GLenum format, GLenum format,
GLenum type, GLenum type,
GLsizei imagesize, GLsizei image_size,
const void* pixels) { const void* pixels) {
ScopedUnpackStateButAlignmentReset reset_unpack(
image_size != 0 && feature_info_->gl_version_info().is_es3, true);
glTexImage3DRobustANGLE(target, level, internalformat, width, height, depth, glTexImage3DRobustANGLE(target, level, internalformat, width, height, depth,
border, format, type, imagesize, pixels); border, format, type, image_size, pixels);
return error::kNoError; return error::kNoError;
} }
...@@ -1922,10 +1982,12 @@ error::Error GLES2DecoderPassthroughImpl::DoTexSubImage2D(GLenum target, ...@@ -1922,10 +1982,12 @@ error::Error GLES2DecoderPassthroughImpl::DoTexSubImage2D(GLenum target,
GLsizei height, GLsizei height,
GLenum format, GLenum format,
GLenum type, GLenum type,
GLsizei imagesize, GLsizei image_size,
const void* pixels) { const void* pixels) {
ScopedUnpackStateButAlignmentReset reset_unpack(
image_size != 0 && feature_info_->gl_version_info().is_es3, false);
glTexSubImage2DRobustANGLE(target, level, xoffset, yoffset, width, height, glTexSubImage2DRobustANGLE(target, level, xoffset, yoffset, width, height,
format, type, imagesize, pixels); format, type, image_size, pixels);
return error::kNoError; return error::kNoError;
} }
...@@ -1939,10 +2001,12 @@ error::Error GLES2DecoderPassthroughImpl::DoTexSubImage3D(GLenum target, ...@@ -1939,10 +2001,12 @@ error::Error GLES2DecoderPassthroughImpl::DoTexSubImage3D(GLenum target,
GLsizei depth, GLsizei depth,
GLenum format, GLenum format,
GLenum type, GLenum type,
GLsizei imagesize, GLsizei image_size,
const void* pixels) { const void* pixels) {
ScopedUnpackStateButAlignmentReset reset_unpack(
image_size != 0 && feature_info_->gl_version_info().is_es3, true);
glTexSubImage3DRobustANGLE(target, level, xoffset, yoffset, zoffset, width, glTexSubImage3DRobustANGLE(target, level, xoffset, yoffset, zoffset, width,
height, depth, format, type, imagesize, pixels); height, depth, format, type, image_size, pixels);
return error::kNoError; return error::kNoError;
} }
......
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