| Index: gpu/command_buffer/service/texture_manager.cc
|
| diff --git a/gpu/command_buffer/service/texture_manager.cc b/gpu/command_buffer/service/texture_manager.cc
|
| index 8297c6d04556fbdee6806487b6a81552810637e3..a4b09bc2a56fb2db1e5c865c05b5c7d4f2db205a 100644
|
| --- a/gpu/command_buffer/service/texture_manager.cc
|
| +++ b/gpu/command_buffer/service/texture_manager.cc
|
| @@ -2332,9 +2332,12 @@ void TextureManager::ValidateAndDoTexImage(
|
| }
|
| }
|
|
|
| - if (texture_state->unpack_alignment_workaround_with_unpack_buffer && buffer) {
|
| + if (texture_state->unpack_parameters_workaround_with_unpack_buffer &&
|
| + buffer) {
|
| uint32_t buffer_size = static_cast<uint32_t>(buffer->size());
|
| - if (buffer_size - args.pixels_size - ToGLuint(args.pixels) < args.padding) {
|
| + if (buffer_size - args.pixels_size - ToGLuint(args.pixels) < args.padding ||
|
| + (state->unpack_row_length != 0 &&
|
| + state->unpack_row_length != args.width)) {
|
| // In ValidateTexImage(), we already made sure buffer size is no less
|
| // than offset + pixels_size.
|
| glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
|
| @@ -2353,7 +2356,7 @@ void TextureManager::ValidateAndDoTexImage(
|
| args.command_type == DoTexImageArguments::kTexImage3D ?
|
| DoTexSubImageArguments::kTexSubImage3D :
|
| DoTexSubImageArguments::kTexSubImage2D};
|
| - DoTexSubImageWithAlignmentWorkaround(texture_state, state, sub_args);
|
| + DoTexSubImageWithUnpackParamsWorkaround(texture_state, state, sub_args);
|
|
|
| SetLevelCleared(texture_ref, args.target, args.level, true);
|
| return;
|
| @@ -2508,10 +2511,13 @@ void TextureManager::ValidateAndDoTexSubImage(
|
| }
|
|
|
| Buffer* buffer = state->bound_pixel_unpack_buffer.get();
|
| - if (texture_state->unpack_alignment_workaround_with_unpack_buffer && buffer) {
|
| + if (texture_state->unpack_parameters_workaround_with_unpack_buffer &&
|
| + buffer) {
|
| uint32_t buffer_size = static_cast<uint32_t>(buffer->size());
|
| - if (buffer_size - args.pixels_size - ToGLuint(args.pixels) < args.padding) {
|
| - DoTexSubImageWithAlignmentWorkaround(texture_state, state, args);
|
| + if (buffer_size - args.pixels_size - ToGLuint(args.pixels) < args.padding ||
|
| + (state->unpack_row_length != 0 &&
|
| + state->unpack_row_length != args.width)) {
|
| + DoTexSubImageWithUnpackParamsWorkaround(texture_state, state, args);
|
| return;
|
| }
|
| }
|
| @@ -2548,7 +2554,7 @@ void TextureManager::ValidateAndDoTexSubImage(
|
| }
|
| }
|
|
|
| -void TextureManager::DoTexSubImageWithAlignmentWorkaround(
|
| +void TextureManager::DoTexSubImageWithUnpackParamsWorkaround(
|
| DecoderTextureState* texture_state,
|
| ContextState* state,
|
| const DoTexSubImageArguments& args) {
|
| @@ -2578,12 +2584,24 @@ void TextureManager::DoTexSubImageWithAlignmentWorkaround(
|
| // Last row should be padded, not unpadded.
|
| offset += size + padding;
|
| }
|
| - glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
| + if (state->unpack_alignment != 1) {
|
| + glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
| + }
|
| + if (state->unpack_row_length != 0 &&
|
| + state->unpack_row_length != args.width) {
|
| + glPixelStorei(GL_UNPACK_ROW_LENGTH, args.width);
|
| + }
|
| glTexSubImage2D(args.target, args.level, args.xoffset,
|
| args.yoffset + args.height - 1,
|
| args.width, 1, AdjustTexFormat(args.format), args.type,
|
| reinterpret_cast<const void *>(offset));
|
| - glPixelStorei(GL_UNPACK_ALIGNMENT, state->unpack_alignment);
|
| + if (state->unpack_alignment != 1) {
|
| + glPixelStorei(GL_UNPACK_ALIGNMENT, state->unpack_alignment);
|
| + }
|
| + if (state->unpack_row_length != 0 &&
|
| + state->unpack_row_length != args.width) {
|
| + glPixelStorei(GL_UNPACK_ROW_LENGTH, state->unpack_row_length);
|
| + }
|
| {
|
| uint32_t size;
|
| GLES2Util::ComputeImageDataSizesES3(args.width, 1, 1,
|
| @@ -2635,13 +2653,25 @@ void TextureManager::DoTexSubImageWithAlignmentWorkaround(
|
| // Last row should be padded, not unpadded.
|
| offset += size + padding;
|
| }
|
| - glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
| + if (state->unpack_alignment != 1) {
|
| + glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
| + }
|
| + if (state->unpack_row_length != 0 &&
|
| + state->unpack_row_length != args.width) {
|
| + glPixelStorei(GL_UNPACK_ROW_LENGTH, args.width);
|
| + }
|
| glTexSubImage3D(args.target, args.level, args.xoffset,
|
| args.yoffset + args.height - 1,
|
| args.zoffset + args.depth - 1,
|
| args.width, 1, 1, AdjustTexFormat(args.format), args.type,
|
| reinterpret_cast<const void *>(offset));
|
| - glPixelStorei(GL_UNPACK_ALIGNMENT, state->unpack_alignment);
|
| + if (state->unpack_alignment != 1) {
|
| + glPixelStorei(GL_UNPACK_ALIGNMENT, state->unpack_alignment);
|
| + }
|
| + if (state->unpack_row_length != 0 &&
|
| + state->unpack_row_length != args.width) {
|
| + glPixelStorei(GL_UNPACK_ROW_LENGTH, state->unpack_row_length);
|
| + }
|
| {
|
| uint32_t size;
|
| GLES2Util::ComputeImageDataSizesES3(args.width, 1, 1,
|
|
|