Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(281)

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

Issue 851503003: Update from https://crrev.com/311076 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <list> 10 #include <list>
(...skipping 2111 matching lines...) Expand 10 before | Expand all | Expand 10 after
2122 } 2122 }
2123 2123
2124 bool BackTexture::AllocateStorage( 2124 bool BackTexture::AllocateStorage(
2125 const gfx::Size& size, GLenum format, bool zero) { 2125 const gfx::Size& size, GLenum format, bool zero) {
2126 DCHECK_NE(id_, 0u); 2126 DCHECK_NE(id_, 0u);
2127 ScopedGLErrorSuppressor suppressor("BackTexture::AllocateStorage", 2127 ScopedGLErrorSuppressor suppressor("BackTexture::AllocateStorage",
2128 state_->GetErrorState()); 2128 state_->GetErrorState());
2129 ScopedTextureBinder binder(state_, id_, GL_TEXTURE_2D); 2129 ScopedTextureBinder binder(state_, id_, GL_TEXTURE_2D);
2130 uint32 image_size = 0; 2130 uint32 image_size = 0;
2131 GLES2Util::ComputeImageDataSizes( 2131 GLES2Util::ComputeImageDataSizes(
2132 size.width(), size.height(), format, GL_UNSIGNED_BYTE, 8, &image_size, 2132 size.width(), size.height(), 1, format, GL_UNSIGNED_BYTE, 8, &image_size,
2133 NULL, NULL); 2133 NULL, NULL);
2134 2134
2135 if (!memory_tracker_.EnsureGPUMemoryAvailable(image_size)) { 2135 if (!memory_tracker_.EnsureGPUMemoryAvailable(image_size)) {
2136 return false; 2136 return false;
2137 } 2137 }
2138 2138
2139 scoped_ptr<char[]> zero_data; 2139 scoped_ptr<char[]> zero_data;
2140 if (zero) { 2140 if (zero) {
2141 zero_data.reset(new char[image_size]); 2141 zero_data.reset(new char[image_size]);
2142 memset(zero_data.get(), 0, image_size); 2142 memset(zero_data.get(), 0, image_size);
(...skipping 5532 matching lines...) Expand 10 before | Expand all | Expand 10 after
7675 result = GetSharedMemoryAs<Result*>( 7675 result = GetSharedMemoryAs<Result*>(
7676 c.result_shm_id, c.result_shm_offset, sizeof(*result)); 7676 c.result_shm_id, c.result_shm_offset, sizeof(*result));
7677 if (!result) { 7677 if (!result) {
7678 if (buffer != 0) { 7678 if (buffer != 0) {
7679 glDeleteBuffersARB(1, &buffer); 7679 glDeleteBuffersARB(1, &buffer);
7680 } 7680 }
7681 return; 7681 return;
7682 } 7682 }
7683 } 7683 }
7684 GLES2Util::ComputeImageDataSizes( 7684 GLES2Util::ComputeImageDataSizes(
7685 width, height, format, type, state_.pack_alignment, &pixels_size, 7685 width, height, 1, format, type, state_.pack_alignment, &pixels_size,
7686 NULL, NULL); 7686 NULL, NULL);
7687 void* pixels = GetSharedMemoryAs<void*>( 7687 void* pixels = GetSharedMemoryAs<void*>(
7688 c.pixels_shm_id, c.pixels_shm_offset, pixels_size); 7688 c.pixels_shm_id, c.pixels_shm_offset, pixels_size);
7689 if (!pixels) { 7689 if (!pixels) {
7690 if (buffer != 0) { 7690 if (buffer != 0) {
7691 glDeleteBuffersARB(1, &buffer); 7691 glDeleteBuffersARB(1, &buffer);
7692 } 7692 }
7693 return; 7693 return;
7694 } 7694 }
7695 7695
(...skipping 26 matching lines...) Expand all
7722 GLenum read_format = GetBoundReadFrameBufferInternalFormat(); 7722 GLenum read_format = GetBoundReadFrameBufferInternalFormat();
7723 uint32 channels_exist = GLES2Util::GetChannelsForFormat(read_format); 7723 uint32 channels_exist = GLES2Util::GetChannelsForFormat(read_format);
7724 if ((channels_exist & 0x0008) == 0 && 7724 if ((channels_exist & 0x0008) == 0 &&
7725 workarounds().clear_alpha_in_readpixels) { 7725 workarounds().clear_alpha_in_readpixels) {
7726 // Set the alpha to 255 because some drivers are buggy in this regard. 7726 // Set the alpha to 255 because some drivers are buggy in this regard.
7727 uint32 temp_size; 7727 uint32 temp_size;
7728 7728
7729 uint32 unpadded_row_size; 7729 uint32 unpadded_row_size;
7730 uint32 padded_row_size; 7730 uint32 padded_row_size;
7731 if (!GLES2Util::ComputeImageDataSizes( 7731 if (!GLES2Util::ComputeImageDataSizes(
7732 width, 2, format, type, state_.pack_alignment, &temp_size, 7732 width, 2, 1, format, type, state_.pack_alignment, &temp_size,
7733 &unpadded_row_size, &padded_row_size)) { 7733 &unpadded_row_size, &padded_row_size)) {
7734 return; 7734 return;
7735 } 7735 }
7736 7736
7737 uint32 channel_count = 0; 7737 uint32 channel_count = 0;
7738 uint32 alpha_channel = 0; 7738 uint32 alpha_channel = 0;
7739 switch (format) { 7739 switch (format) {
7740 case GL_RGBA: 7740 case GL_RGBA:
7741 case GL_BGRA_EXT: 7741 case GL_BGRA_EXT:
7742 channel_count = 4; 7742 channel_count = 4;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
7785 GLenum format = c.format; 7785 GLenum format = c.format;
7786 GLenum type = c.type; 7786 GLenum type = c.type;
7787 GLboolean async = static_cast<GLboolean>(c.async); 7787 GLboolean async = static_cast<GLboolean>(c.async);
7788 if (width < 0 || height < 0) { 7788 if (width < 0 || height < 0) {
7789 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glReadPixels", "dimensions < 0"); 7789 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glReadPixels", "dimensions < 0");
7790 return error::kNoError; 7790 return error::kNoError;
7791 } 7791 }
7792 typedef cmds::ReadPixels::Result Result; 7792 typedef cmds::ReadPixels::Result Result;
7793 uint32 pixels_size; 7793 uint32 pixels_size;
7794 if (!GLES2Util::ComputeImageDataSizes( 7794 if (!GLES2Util::ComputeImageDataSizes(
7795 width, height, format, type, state_.pack_alignment, &pixels_size, 7795 width, height, 1, format, type, state_.pack_alignment, &pixels_size,
7796 NULL, NULL)) { 7796 NULL, NULL)) {
7797 return error::kOutOfBounds; 7797 return error::kOutOfBounds;
7798 } 7798 }
7799 void* pixels = GetSharedMemoryAs<void*>( 7799 void* pixels = GetSharedMemoryAs<void*>(
7800 c.pixels_shm_id, c.pixels_shm_offset, pixels_size); 7800 c.pixels_shm_id, c.pixels_shm_offset, pixels_size);
7801 if (!pixels) { 7801 if (!pixels) {
7802 return error::kOutOfBounds; 7802 return error::kOutOfBounds;
7803 } 7803 }
7804 Result* result = NULL; 7804 Result* result = NULL;
7805 if (c.result_shm_id != 0) { 7805 if (c.result_shm_id != 0) {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
7861 7861
7862 ScopedResolvedFrameBufferBinder binder(this, false, true); 7862 ScopedResolvedFrameBufferBinder binder(this, false, true);
7863 7863
7864 if (x < 0 || y < 0 || max_x > max_size.width() || max_y > max_size.height()) { 7864 if (x < 0 || y < 0 || max_x > max_size.width() || max_y > max_size.height()) {
7865 // The user requested an out of range area. Get the results 1 line 7865 // The user requested an out of range area. Get the results 1 line
7866 // at a time. 7866 // at a time.
7867 uint32 temp_size; 7867 uint32 temp_size;
7868 uint32 unpadded_row_size; 7868 uint32 unpadded_row_size;
7869 uint32 padded_row_size; 7869 uint32 padded_row_size;
7870 if (!GLES2Util::ComputeImageDataSizes( 7870 if (!GLES2Util::ComputeImageDataSizes(
7871 width, 2, format, type, state_.pack_alignment, &temp_size, 7871 width, 2, 1, format, type, state_.pack_alignment, &temp_size,
7872 &unpadded_row_size, &padded_row_size)) { 7872 &unpadded_row_size, &padded_row_size)) {
7873 LOCAL_SET_GL_ERROR( 7873 LOCAL_SET_GL_ERROR(
7874 GL_INVALID_VALUE, "glReadPixels", "dimensions out of range"); 7874 GL_INVALID_VALUE, "glReadPixels", "dimensions out of range");
7875 return error::kNoError; 7875 return error::kNoError;
7876 } 7876 }
7877 7877
7878 GLint dest_x_offset = std::max(-x, 0); 7878 GLint dest_x_offset = std::max(-x, 0);
7879 uint32 dest_row_offset; 7879 uint32 dest_row_offset;
7880 if (!GLES2Util::ComputeImageDataSizes( 7880 if (!GLES2Util::ComputeImageDataSizes(
7881 dest_x_offset, 1, format, type, state_.pack_alignment, &dest_row_offset, 7881 dest_x_offset, 1, 1, format, type, state_.pack_alignment,
7882 NULL, NULL)) { 7882 &dest_row_offset, NULL, NULL)) {
7883 LOCAL_SET_GL_ERROR( 7883 LOCAL_SET_GL_ERROR(
7884 GL_INVALID_VALUE, "glReadPixels", "dimensions out of range"); 7884 GL_INVALID_VALUE, "glReadPixels", "dimensions out of range");
7885 return error::kNoError; 7885 return error::kNoError;
7886 } 7886 }
7887 7887
7888 // Copy each row into the larger dest rect. 7888 // Copy each row into the larger dest rect.
7889 int8* dst = static_cast<int8*>(pixels); 7889 int8* dst = static_cast<int8*>(pixels);
7890 GLint read_x = std::max(0, x); 7890 GLint read_x = std::max(0, x);
7891 GLint read_end_x = std::max(0, std::min(max_size.width(), max_x)); 7891 GLint read_end_x = std::max(0, std::min(max_size.width(), max_x));
7892 GLint read_width = read_end_x - read_x; 7892 GLint read_width = read_end_x - read_x;
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
8314 framebuffer ? framebuffer->service_id() : GetBackbufferServiceId(); 8314 framebuffer ? framebuffer->service_id() : GetBackbufferServiceId();
8315 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, fb_service_id); 8315 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, fb_service_id);
8316 return true; 8316 return true;
8317 } 8317 }
8318 8318
8319 static const uint32 kMaxZeroSize = 1024 * 1024 * 4; 8319 static const uint32 kMaxZeroSize = 1024 * 1024 * 4;
8320 8320
8321 uint32 size; 8321 uint32 size;
8322 uint32 padded_row_size; 8322 uint32 padded_row_size;
8323 if (!GLES2Util::ComputeImageDataSizes( 8323 if (!GLES2Util::ComputeImageDataSizes(
8324 width, height, format, type, state_.unpack_alignment, &size, 8324 width, height, 1, format, type, state_.unpack_alignment, &size,
8325 NULL, &padded_row_size)) { 8325 NULL, &padded_row_size)) {
8326 return false; 8326 return false;
8327 } 8327 }
8328 8328
8329 TRACE_EVENT1("gpu", "GLES2DecoderImpl::ClearLevel", "size", size); 8329 TRACE_EVENT1("gpu", "GLES2DecoderImpl::ClearLevel", "size", size);
8330 8330
8331 int tile_height; 8331 int tile_height;
8332 8332
8333 if (size > kMaxZeroSize) { 8333 if (size > kMaxZeroSize) {
8334 if (kMaxZeroSize < padded_row_size) { 8334 if (kMaxZeroSize < padded_row_size) {
8335 // That'd be an awfully large texture. 8335 // That'd be an awfully large texture.
8336 return false; 8336 return false;
8337 } 8337 }
8338 // We should never have a large total size with a zero row size. 8338 // We should never have a large total size with a zero row size.
8339 DCHECK_GT(padded_row_size, 0U); 8339 DCHECK_GT(padded_row_size, 0U);
8340 tile_height = kMaxZeroSize / padded_row_size; 8340 tile_height = kMaxZeroSize / padded_row_size;
8341 if (!GLES2Util::ComputeImageDataSizes( 8341 if (!GLES2Util::ComputeImageDataSizes(
8342 width, tile_height, format, type, state_.unpack_alignment, &size, 8342 width, tile_height, 1, format, type, state_.unpack_alignment, &size,
8343 NULL, NULL)) { 8343 NULL, NULL)) {
8344 return false; 8344 return false;
8345 } 8345 }
8346 } else { 8346 } else {
8347 tile_height = height; 8347 tile_height = height;
8348 } 8348 }
8349 8349
8350 // Assumes the size has already been checked. 8350 // Assumes the size has already been checked.
8351 scoped_ptr<char[]> zero(new char[size]); 8351 scoped_ptr<char[]> zero(new char[size]);
8352 memset(zero.get(), 0, size); 8352 memset(zero.get(), 0, size);
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
8768 GLenum internal_format = static_cast<GLenum>(c.internalformat); 8768 GLenum internal_format = static_cast<GLenum>(c.internalformat);
8769 GLsizei width = static_cast<GLsizei>(c.width); 8769 GLsizei width = static_cast<GLsizei>(c.width);
8770 GLsizei height = static_cast<GLsizei>(c.height); 8770 GLsizei height = static_cast<GLsizei>(c.height);
8771 GLint border = static_cast<GLint>(c.border); 8771 GLint border = static_cast<GLint>(c.border);
8772 GLenum format = static_cast<GLenum>(c.format); 8772 GLenum format = static_cast<GLenum>(c.format);
8773 GLenum type = static_cast<GLenum>(c.type); 8773 GLenum type = static_cast<GLenum>(c.type);
8774 uint32 pixels_shm_id = static_cast<uint32>(c.pixels_shm_id); 8774 uint32 pixels_shm_id = static_cast<uint32>(c.pixels_shm_id);
8775 uint32 pixels_shm_offset = static_cast<uint32>(c.pixels_shm_offset); 8775 uint32 pixels_shm_offset = static_cast<uint32>(c.pixels_shm_offset);
8776 uint32 pixels_size; 8776 uint32 pixels_size;
8777 if (!GLES2Util::ComputeImageDataSizes( 8777 if (!GLES2Util::ComputeImageDataSizes(
8778 width, height, format, type, state_.unpack_alignment, &pixels_size, NULL, 8778 width, height, 1, format, type, state_.unpack_alignment, &pixels_size,
8779 NULL)) { 8779 NULL, NULL)) {
8780 return error::kOutOfBounds; 8780 return error::kOutOfBounds;
8781 } 8781 }
8782 const void* pixels = NULL; 8782 const void* pixels = NULL;
8783 if (pixels_shm_id != 0 || pixels_shm_offset != 0) { 8783 if (pixels_shm_id != 0 || pixels_shm_offset != 0) {
8784 pixels = GetSharedMemoryAs<const void*>( 8784 pixels = GetSharedMemoryAs<const void*>(
8785 pixels_shm_id, pixels_shm_offset, pixels_size); 8785 pixels_shm_id, pixels_shm_offset, pixels_size);
8786 if (!pixels) { 8786 if (!pixels) {
8787 return error::kOutOfBounds; 8787 return error::kOutOfBounds;
8788 } 8788 }
8789 } 8789 }
8790 8790
8791 TextureManager::DoTextImage2DArguments args = { 8791 TextureManager::DoTextImage2DArguments args = {
8792 target, level, internal_format, width, height, border, format, type, 8792 target, level, internal_format, width, height, border, format, type,
8793 pixels, pixels_size}; 8793 pixels, pixels_size};
8794 texture_manager()->ValidateAndDoTexImage2D( 8794 texture_manager()->ValidateAndDoTexImage2D(
8795 &texture_state_, &state_, &framebuffer_state_, args); 8795 &texture_state_, &state_, &framebuffer_state_, args);
8796 8796
8797 // This may be a slow command. Exit command processing to allow for 8797 // This may be a slow command. Exit command processing to allow for
8798 // context preemption and GPU watchdog checks. 8798 // context preemption and GPU watchdog checks.
8799 ExitCommandProcessingEarly(); 8799 ExitCommandProcessingEarly();
8800 return error::kNoError; 8800 return error::kNoError;
8801 } 8801 }
8802 8802
8803 error::Error GLES2DecoderImpl::HandleTexImage3D(uint32 immediate_data_size,
8804 const void* cmd_data) {
8805 // TODO(zmo): Unsafe ES3 API.
8806 if (!unsafe_es3_apis_enabled())
8807 return error::kUnknownCommand;
8808
8809 const gles2::cmds::TexImage3D& c =
8810 *static_cast<const gles2::cmds::TexImage3D*>(cmd_data);
8811 TRACE_EVENT2("gpu", "GLES2DecoderImpl::HandleTexImage3D",
8812 "widthXheight", c.width * c.height, "depth", c.depth);
8813 GLenum target = static_cast<GLenum>(c.target);
8814 GLint level = static_cast<GLint>(c.level);
8815 GLenum internal_format = static_cast<GLenum>(c.internalformat);
8816 GLsizei width = static_cast<GLsizei>(c.width);
8817 GLsizei height = static_cast<GLsizei>(c.height);
8818 GLsizei depth = static_cast<GLsizei>(c.depth);
8819 GLint border = static_cast<GLint>(c.border);
8820 GLenum format = static_cast<GLenum>(c.format);
8821 GLenum type = static_cast<GLenum>(c.type);
8822 uint32 pixels_shm_id = static_cast<uint32>(c.pixels_shm_id);
8823 uint32 pixels_shm_offset = static_cast<uint32>(c.pixels_shm_offset);
8824 uint32 pixels_size;
8825 if (!GLES2Util::ComputeImageDataSizes(
8826 width, height, depth, format, type, state_.unpack_alignment, &pixels_size,
8827 NULL, NULL)) {
8828 return error::kOutOfBounds;
8829 }
8830 const void* pixels = NULL;
8831 if (pixels_shm_id != 0 || pixels_shm_offset != 0) {
8832 pixels = GetSharedMemoryAs<const void*>(
8833 pixels_shm_id, pixels_shm_offset, pixels_size);
8834 if (!pixels) {
8835 return error::kOutOfBounds;
8836 }
8837 }
8838
8839 glTexImage3D(target, level, internal_format, width, height, depth, border,
8840 format, type, pixels);
8841
8842 // This may be a slow command. Exit command processing to allow for
8843 // context preemption and GPU watchdog checks.
8844 ExitCommandProcessingEarly();
8845 return error::kNoError;
8846 }
8847
8803 void GLES2DecoderImpl::DoCompressedTexSubImage2D( 8848 void GLES2DecoderImpl::DoCompressedTexSubImage2D(
8804 GLenum target, 8849 GLenum target,
8805 GLint level, 8850 GLint level,
8806 GLint xoffset, 8851 GLint xoffset,
8807 GLint yoffset, 8852 GLint yoffset,
8808 GLsizei width, 8853 GLsizei width,
8809 GLsizei height, 8854 GLsizei height,
8810 GLenum format, 8855 GLenum format,
8811 GLsizei image_size, 8856 GLsizei image_size,
8812 const void * data) { 8857 const void * data) {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
8927 8972
8928 if ((channels_needed & (GLES2Util::kDepth | GLES2Util::kStencil)) != 0) { 8973 if ((channels_needed & (GLES2Util::kDepth | GLES2Util::kStencil)) != 0) {
8929 LOCAL_SET_GL_ERROR( 8974 LOCAL_SET_GL_ERROR(
8930 GL_INVALID_OPERATION, 8975 GL_INVALID_OPERATION,
8931 "glCopyTexImage2D", "can not be used with depth or stencil textures"); 8976 "glCopyTexImage2D", "can not be used with depth or stencil textures");
8932 return; 8977 return;
8933 } 8978 }
8934 8979
8935 uint32 estimated_size = 0; 8980 uint32 estimated_size = 0;
8936 if (!GLES2Util::ComputeImageDataSizes( 8981 if (!GLES2Util::ComputeImageDataSizes(
8937 width, height, internal_format, GL_UNSIGNED_BYTE, state_.unpack_alignment, 8982 width, height, 1, internal_format, GL_UNSIGNED_BYTE,
8938 &estimated_size, NULL, NULL)) { 8983 state_.unpack_alignment, &estimated_size, NULL, NULL)) {
8939 LOCAL_SET_GL_ERROR( 8984 LOCAL_SET_GL_ERROR(
8940 GL_OUT_OF_MEMORY, "glCopyTexImage2D", "dimensions too large"); 8985 GL_OUT_OF_MEMORY, "glCopyTexImage2D", "dimensions too large");
8941 return; 8986 return;
8942 } 8987 }
8943 8988
8944 if (!EnsureGPUMemoryAvailable(estimated_size)) { 8989 if (!EnsureGPUMemoryAvailable(estimated_size)) {
8945 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, "glCopyTexImage2D", "out of memory"); 8990 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, "glCopyTexImage2D", "out of memory");
8946 return; 8991 return;
8947 } 8992 }
8948 8993
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
9101 return; 9146 return;
9102 } 9147 }
9103 9148
9104 if (copyX != x || 9149 if (copyX != x ||
9105 copyY != y || 9150 copyY != y ||
9106 copyWidth != width || 9151 copyWidth != width ||
9107 copyHeight != height) { 9152 copyHeight != height) {
9108 // some part was clipped so clear the sub rect. 9153 // some part was clipped so clear the sub rect.
9109 uint32 pixels_size = 0; 9154 uint32 pixels_size = 0;
9110 if (!GLES2Util::ComputeImageDataSizes( 9155 if (!GLES2Util::ComputeImageDataSizes(
9111 width, height, format, type, state_.unpack_alignment, &pixels_size, 9156 width, height, 1, format, type, state_.unpack_alignment, &pixels_size,
9112 NULL, NULL)) { 9157 NULL, NULL)) {
9113 LOCAL_SET_GL_ERROR( 9158 LOCAL_SET_GL_ERROR(
9114 GL_INVALID_VALUE, "glCopyTexSubImage2D", "dimensions too large"); 9159 GL_INVALID_VALUE, "glCopyTexSubImage2D", "dimensions too large");
9115 return; 9160 return;
9116 } 9161 }
9117 scoped_ptr<char[]> zero(new char[pixels_size]); 9162 scoped_ptr<char[]> zero(new char[pixels_size]);
9118 memset(zero.get(), 0, pixels_size); 9163 memset(zero.get(), 0, pixels_size);
9119 ScopedModifyPixels modify(texture_ref); 9164 ScopedModifyPixels modify(texture_ref);
9120 glTexSubImage2D( 9165 glTexSubImage2D(
9121 target, level, xoffset, yoffset, width, height, 9166 target, level, xoffset, yoffset, width, height,
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
9286 GLenum target = static_cast<GLenum>(c.target); 9331 GLenum target = static_cast<GLenum>(c.target);
9287 GLint level = static_cast<GLint>(c.level); 9332 GLint level = static_cast<GLint>(c.level);
9288 GLint xoffset = static_cast<GLint>(c.xoffset); 9333 GLint xoffset = static_cast<GLint>(c.xoffset);
9289 GLint yoffset = static_cast<GLint>(c.yoffset); 9334 GLint yoffset = static_cast<GLint>(c.yoffset);
9290 GLsizei width = static_cast<GLsizei>(c.width); 9335 GLsizei width = static_cast<GLsizei>(c.width);
9291 GLsizei height = static_cast<GLsizei>(c.height); 9336 GLsizei height = static_cast<GLsizei>(c.height);
9292 GLenum format = static_cast<GLenum>(c.format); 9337 GLenum format = static_cast<GLenum>(c.format);
9293 GLenum type = static_cast<GLenum>(c.type); 9338 GLenum type = static_cast<GLenum>(c.type);
9294 uint32 data_size; 9339 uint32 data_size;
9295 if (!GLES2Util::ComputeImageDataSizes( 9340 if (!GLES2Util::ComputeImageDataSizes(
9296 width, height, format, type, state_.unpack_alignment, &data_size, 9341 width, height, 1, format, type, state_.unpack_alignment, &data_size,
9297 NULL, NULL)) { 9342 NULL, NULL)) {
9298 return error::kOutOfBounds; 9343 return error::kOutOfBounds;
9299 } 9344 }
9300 const void* pixels = GetSharedMemoryAs<const void*>( 9345 const void* pixels = GetSharedMemoryAs<const void*>(
9301 c.pixels_shm_id, c.pixels_shm_offset, data_size); 9346 c.pixels_shm_id, c.pixels_shm_offset, data_size);
9302 return DoTexSubImage2D( 9347 return DoTexSubImage2D(
9303 target, level, xoffset, yoffset, width, height, format, type, pixels); 9348 target, level, xoffset, yoffset, width, height, format, type, pixels);
9304 } 9349 }
9305 9350
9351 // TODO(zmo): Remove the below stub once we add the real function binding.
9352 // Currently it's missing due to a gmock limitation.
9353 static void glTexSubImage3D(
9354 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset,
9355 GLsizei height, GLsizei width, GLsizei depth, GLenum format, GLenum type,
9356 const void* pixels) {
9357 NOTIMPLEMENTED();
9358 }
9359
9360 error::Error GLES2DecoderImpl::HandleTexSubImage3D(uint32 immediate_data_size,
9361 const void* cmd_data) {
9362 // TODO(zmo): Unsafe ES3 API.
9363 if (!unsafe_es3_apis_enabled())
9364 return error::kUnknownCommand;
9365
9366 const gles2::cmds::TexSubImage3D& c =
9367 *static_cast<const gles2::cmds::TexSubImage3D*>(cmd_data);
9368 TRACE_EVENT2("gpu", "GLES2DecoderImpl::HandleTexSubImage3D",
9369 "widthXheight", c.width * c.height, "depth", c.depth);
9370 GLenum target = static_cast<GLenum>(c.target);
9371 GLint level = static_cast<GLint>(c.level);
9372 GLint xoffset = static_cast<GLint>(c.xoffset);
9373 GLint yoffset = static_cast<GLint>(c.yoffset);
9374 GLint zoffset = static_cast<GLint>(c.zoffset);
9375 GLsizei width = static_cast<GLsizei>(c.width);
9376 GLsizei height = static_cast<GLsizei>(c.height);
9377 GLsizei depth = static_cast<GLsizei>(c.depth);
9378 GLenum format = static_cast<GLenum>(c.format);
9379 GLenum type = static_cast<GLenum>(c.type);
9380 uint32 data_size;
9381 if (!GLES2Util::ComputeImageDataSizes(
9382 width, height, depth, format, type, state_.unpack_alignment, &data_size,
9383 NULL, NULL)) {
9384 return error::kOutOfBounds;
9385 }
9386 const void* pixels = GetSharedMemoryAs<const void*>(
9387 c.pixels_shm_id, c.pixels_shm_offset, data_size);
9388 glTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height,
9389 depth, format, type, pixels);
9390 return error::kNoError;
9391 }
9392
9306 error::Error GLES2DecoderImpl::HandleGetVertexAttribPointerv( 9393 error::Error GLES2DecoderImpl::HandleGetVertexAttribPointerv(
9307 uint32 immediate_data_size, 9394 uint32 immediate_data_size,
9308 const void* cmd_data) { 9395 const void* cmd_data) {
9309 const gles2::cmds::GetVertexAttribPointerv& c = 9396 const gles2::cmds::GetVertexAttribPointerv& c =
9310 *static_cast<const gles2::cmds::GetVertexAttribPointerv*>(cmd_data); 9397 *static_cast<const gles2::cmds::GetVertexAttribPointerv*>(cmd_data);
9311 GLuint index = static_cast<GLuint>(c.index); 9398 GLuint index = static_cast<GLuint>(c.index);
9312 GLenum pname = static_cast<GLenum>(c.pname); 9399 GLenum pname = static_cast<GLenum>(c.pname);
9313 typedef cmds::GetVertexAttribPointerv::Result Result; 9400 typedef cmds::GetVertexAttribPointerv::Result Result;
9314 Result* result = GetSharedMemoryAs<Result*>( 9401 Result* result = GetSharedMemoryAs<Result*>(
9315 c.pointer_shm_id, c.pointer_shm_offset, Result::ComputeSize(1)); 9402 c.pointer_shm_id, c.pointer_shm_offset, Result::ComputeSize(1));
(...skipping 1379 matching lines...) Expand 10 before | Expand all | Expand 10 after
10695 GLenum format = ExtractFormatFromStorageFormat(internal_format); 10782 GLenum format = ExtractFormatFromStorageFormat(internal_format);
10696 GLenum type = ExtractTypeFromStorageFormat(internal_format); 10783 GLenum type = ExtractTypeFromStorageFormat(internal_format);
10697 10784
10698 { 10785 {
10699 GLsizei level_width = width; 10786 GLsizei level_width = width;
10700 GLsizei level_height = height; 10787 GLsizei level_height = height;
10701 uint32 estimated_size = 0; 10788 uint32 estimated_size = 0;
10702 for (int ii = 0; ii < levels; ++ii) { 10789 for (int ii = 0; ii < levels; ++ii) {
10703 uint32 level_size = 0; 10790 uint32 level_size = 0;
10704 if (!GLES2Util::ComputeImageDataSizes( 10791 if (!GLES2Util::ComputeImageDataSizes(
10705 level_width, level_height, format, type, state_.unpack_alignment, 10792 level_width, level_height, 1, format, type, state_.unpack_alignment,
10706 &estimated_size, NULL, NULL) || 10793 &estimated_size, NULL, NULL) ||
10707 !SafeAddUint32(estimated_size, level_size, &estimated_size)) { 10794 !SafeAddUint32(estimated_size, level_size, &estimated_size)) {
10708 LOCAL_SET_GL_ERROR( 10795 LOCAL_SET_GL_ERROR(
10709 GL_OUT_OF_MEMORY, "glTexStorage2DEXT", "dimensions too large"); 10796 GL_OUT_OF_MEMORY, "glTexStorage2DEXT", "dimensions too large");
10710 return; 10797 return;
10711 } 10798 }
10712 level_width = std::max(1, level_width >> 1); 10799 level_width = std::max(1, level_width >> 1);
10713 level_height = std::max(1, level_height >> 1); 10800 level_height = std::max(1, level_height >> 1);
10714 } 10801 }
10715 if (!EnsureGPUMemoryAvailable(estimated_size)) { 10802 if (!EnsureGPUMemoryAvailable(estimated_size)) {
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after
11310 sync_data_shm_offset); 11397 sync_data_shm_offset);
11311 if (completion_closure.is_null()) 11398 if (completion_closure.is_null())
11312 return error::kInvalidArguments; 11399 return error::kInvalidArguments;
11313 11400
11314 scoped_completion_callback.Reset(completion_closure); 11401 scoped_completion_callback.Reset(completion_closure);
11315 } 11402 }
11316 11403
11317 // TODO(epenner): Move this and copies of this memory validation 11404 // TODO(epenner): Move this and copies of this memory validation
11318 // into ValidateTexImage2D step. 11405 // into ValidateTexImage2D step.
11319 if (!GLES2Util::ComputeImageDataSizes( 11406 if (!GLES2Util::ComputeImageDataSizes(
11320 width, height, format, type, state_.unpack_alignment, &pixels_size, NULL, 11407 width, height, 1, format, type, state_.unpack_alignment, &pixels_size,
11321 NULL)) { 11408 NULL, NULL)) {
11322 return error::kOutOfBounds; 11409 return error::kOutOfBounds;
11323 } 11410 }
11324 const void* pixels = NULL; 11411 const void* pixels = NULL;
11325 if (pixels_shm_id != 0 || pixels_shm_offset != 0) { 11412 if (pixels_shm_id != 0 || pixels_shm_offset != 0) {
11326 pixels = GetSharedMemoryAs<const void*>( 11413 pixels = GetSharedMemoryAs<const void*>(
11327 pixels_shm_id, pixels_shm_offset, pixels_size); 11414 pixels_shm_id, pixels_shm_offset, pixels_size);
11328 if (!pixels) { 11415 if (!pixels) {
11329 return error::kOutOfBounds; 11416 return error::kOutOfBounds;
11330 } 11417 }
11331 } 11418 }
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
11415 if (completion_closure.is_null()) 11502 if (completion_closure.is_null())
11416 return error::kInvalidArguments; 11503 return error::kInvalidArguments;
11417 11504
11418 scoped_completion_callback.Reset(completion_closure); 11505 scoped_completion_callback.Reset(completion_closure);
11419 } 11506 }
11420 11507
11421 // TODO(epenner): Move this and copies of this memory validation 11508 // TODO(epenner): Move this and copies of this memory validation
11422 // into ValidateTexSubImage2D step. 11509 // into ValidateTexSubImage2D step.
11423 uint32 data_size; 11510 uint32 data_size;
11424 if (!GLES2Util::ComputeImageDataSizes( 11511 if (!GLES2Util::ComputeImageDataSizes(
11425 width, height, format, type, state_.unpack_alignment, &data_size, 11512 width, height, 1, format, type, state_.unpack_alignment, &data_size,
11426 NULL, NULL)) { 11513 NULL, NULL)) {
11427 return error::kOutOfBounds; 11514 return error::kOutOfBounds;
11428 } 11515 }
11429 const void* pixels = GetSharedMemoryAs<const void*>( 11516 const void* pixels = GetSharedMemoryAs<const void*>(
11430 c.data_shm_id, c.data_shm_offset, data_size); 11517 c.data_shm_id, c.data_shm_offset, data_size);
11431 11518
11432 // All the normal glTexSubImage2D validation. 11519 // All the normal glTexSubImage2D validation.
11433 error::Error error = error::kNoError; 11520 error::Error error = error::kNoError;
11434 if (!ValidateTexSubImage2D(&error, "glAsyncTexSubImage2DCHROMIUM", 11521 if (!ValidateTexSubImage2D(&error, "glAsyncTexSubImage2DCHROMIUM",
11435 target, level, xoffset, yoffset, width, height, format, type, pixels)) { 11522 target, level, xoffset, yoffset, width, height, format, type, pixels)) {
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
11548 } 11635 }
11549 } 11636 }
11550 11637
11551 // Include the auto-generated part of this file. We split this because it means 11638 // Include the auto-generated part of this file. We split this because it means
11552 // we can easily edit the non-auto generated parts right here in this file 11639 // we can easily edit the non-auto generated parts right here in this file
11553 // instead of having to edit some template or the code generator. 11640 // instead of having to edit some template or the code generator.
11554 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 11641 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
11555 11642
11556 } // namespace gles2 11643 } // namespace gles2
11557 } // namespace gpu 11644 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_clear_framebuffer.cc ('k') | gpu/command_buffer/service/gles2_cmd_decoder_autogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698