OLD | NEW |
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 <limits.h> | 7 #include <limits.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 #include <stdio.h> | 10 #include <stdio.h> |
(...skipping 12838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12849 height, depth, format, image_size, data); | 12849 height, depth, format, image_size, data); |
12850 } | 12850 } |
12851 | 12851 |
12852 // This may be a slow command. Exit command processing to allow for | 12852 // This may be a slow command. Exit command processing to allow for |
12853 // context preemption and GPU watchdog checks. | 12853 // context preemption and GPU watchdog checks. |
12854 ExitCommandProcessingEarly(); | 12854 ExitCommandProcessingEarly(); |
12855 } | 12855 } |
12856 | 12856 |
12857 error::Error GLES2DecoderImpl::HandleTexImage2D(uint32_t immediate_data_size, | 12857 error::Error GLES2DecoderImpl::HandleTexImage2D(uint32_t immediate_data_size, |
12858 const volatile void* cmd_data) { | 12858 const volatile void* cmd_data) { |
| 12859 const char* func_name = "glTexImage2D"; |
12859 const volatile gles2::cmds::TexImage2D& c = | 12860 const volatile gles2::cmds::TexImage2D& c = |
12860 *static_cast<const volatile gles2::cmds::TexImage2D*>(cmd_data); | 12861 *static_cast<const volatile gles2::cmds::TexImage2D*>(cmd_data); |
12861 TRACE_EVENT2("gpu", "GLES2DecoderImpl::HandleTexImage2D", | 12862 TRACE_EVENT2("gpu", "GLES2DecoderImpl::HandleTexImage2D", |
12862 "width", c.width, "height", c.height); | 12863 "width", c.width, "height", c.height); |
12863 // Set as failed for now, but if it successed, this will be set to not failed. | 12864 // Set as failed for now, but if it successed, this will be set to not failed. |
12864 texture_state_.tex_image_failed = true; | 12865 texture_state_.tex_image_failed = true; |
12865 GLenum target = static_cast<GLenum>(c.target); | 12866 GLenum target = static_cast<GLenum>(c.target); |
12866 GLint level = static_cast<GLint>(c.level); | 12867 GLint level = static_cast<GLint>(c.level); |
12867 GLint internal_format = static_cast<GLint>(c.internalformat); | 12868 GLint internal_format = static_cast<GLint>(c.internalformat); |
12868 GLsizei width = static_cast<GLsizei>(c.width); | 12869 GLsizei width = static_cast<GLsizei>(c.width); |
12869 GLsizei height = static_cast<GLsizei>(c.height); | 12870 GLsizei height = static_cast<GLsizei>(c.height); |
12870 GLint border = static_cast<GLint>(c.border); | 12871 GLint border = static_cast<GLint>(c.border); |
12871 GLenum format = static_cast<GLenum>(c.format); | 12872 GLenum format = static_cast<GLenum>(c.format); |
12872 GLenum type = static_cast<GLenum>(c.type); | 12873 GLenum type = static_cast<GLenum>(c.type); |
12873 uint32_t pixels_shm_id = static_cast<uint32_t>(c.pixels_shm_id); | 12874 uint32_t pixels_shm_id = static_cast<uint32_t>(c.pixels_shm_id); |
12874 uint32_t pixels_shm_offset = static_cast<uint32_t>(c.pixels_shm_offset); | 12875 uint32_t pixels_shm_offset = static_cast<uint32_t>(c.pixels_shm_offset); |
12875 | 12876 |
12876 if (width < 0 || height < 0) { | 12877 if (width < 0 || height < 0) { |
12877 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glTexImage2D", "dimensions < 0"); | 12878 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, func_name, "dimensions < 0"); |
12878 return error::kNoError; | 12879 return error::kNoError; |
12879 } | 12880 } |
12880 | 12881 |
12881 PixelStoreParams params; | 12882 PixelStoreParams params; |
12882 if (state_.bound_pixel_unpack_buffer.get()) { | 12883 Buffer* buffer = state_.bound_pixel_unpack_buffer.get(); |
| 12884 if (buffer) { |
12883 if (pixels_shm_id) | 12885 if (pixels_shm_id) |
12884 return error::kInvalidArguments; | 12886 return error::kInvalidArguments; |
| 12887 if (buffer->GetMappedRange()) { |
| 12888 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, |
| 12889 "pixel unpack buffer should not be mapped to client memory"); |
| 12890 return error::kNoError; |
| 12891 } |
12885 params = state_.GetUnpackParams(ContextState::k2D); | 12892 params = state_.GetUnpackParams(ContextState::k2D); |
12886 } else { | 12893 } else { |
12887 if (!pixels_shm_id && pixels_shm_offset) | 12894 if (!pixels_shm_id && pixels_shm_offset) |
12888 return error::kInvalidArguments; | 12895 return error::kInvalidArguments; |
12889 // When reading from client buffer, the command buffer client side took | 12896 // When reading from client buffer, the command buffer client side took |
12890 // the responsibility to take the pixels from the client buffer and | 12897 // the responsibility to take the pixels from the client buffer and |
12891 // unpack them according to the full ES3 pack parameters as source, all | 12898 // unpack them according to the full ES3 pack parameters as source, all |
12892 // parameters for 0 (except for alignment) as destination mem for the | 12899 // parameters for 0 (except for alignment) as destination mem for the |
12893 // service side. | 12900 // service side. |
12894 params.alignment = state_.unpack_alignment; | 12901 params.alignment = state_.unpack_alignment; |
(...skipping 19 matching lines...) Expand all Loading... |
12914 pixels_shm_id, pixels_shm_offset, pixels_size); | 12921 pixels_shm_id, pixels_shm_offset, pixels_size); |
12915 if (!pixels) | 12922 if (!pixels) |
12916 return error::kOutOfBounds; | 12923 return error::kOutOfBounds; |
12917 } else { | 12924 } else { |
12918 pixels = reinterpret_cast<const void*>(pixels_shm_offset); | 12925 pixels = reinterpret_cast<const void*>(pixels_shm_offset); |
12919 } | 12926 } |
12920 | 12927 |
12921 // For testing only. Allows us to stress the ability to respond to OOM errors. | 12928 // For testing only. Allows us to stress the ability to respond to OOM errors. |
12922 if (workarounds().simulate_out_of_memory_on_large_textures && | 12929 if (workarounds().simulate_out_of_memory_on_large_textures && |
12923 (width * height >= 4096 * 4096)) { | 12930 (width * height >= 4096 * 4096)) { |
12924 LOCAL_SET_GL_ERROR( | 12931 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, func_name, "synthetic out of memory"); |
12925 GL_OUT_OF_MEMORY, | |
12926 "glTexImage2D", "synthetic out of memory"); | |
12927 return error::kNoError; | 12932 return error::kNoError; |
12928 } | 12933 } |
12929 | 12934 |
12930 TextureManager::DoTexImageArguments args = { | 12935 TextureManager::DoTexImageArguments args = { |
12931 target, level, internal_format, width, height, 1, border, format, type, | 12936 target, level, internal_format, width, height, 1, border, format, type, |
12932 pixels, pixels_size, padding, | 12937 pixels, pixels_size, padding, |
12933 TextureManager::DoTexImageArguments::kTexImage2D }; | 12938 TextureManager::DoTexImageArguments::kTexImage2D }; |
12934 texture_manager()->ValidateAndDoTexImage( | 12939 texture_manager()->ValidateAndDoTexImage( |
12935 &texture_state_, &state_, &framebuffer_state_, "glTexImage2D", args); | 12940 &texture_state_, &state_, &framebuffer_state_, func_name, args); |
12936 | 12941 |
12937 // This may be a slow command. Exit command processing to allow for | 12942 // This may be a slow command. Exit command processing to allow for |
12938 // context preemption and GPU watchdog checks. | 12943 // context preemption and GPU watchdog checks. |
12939 ExitCommandProcessingEarly(); | 12944 ExitCommandProcessingEarly(); |
12940 return error::kNoError; | 12945 return error::kNoError; |
12941 } | 12946 } |
12942 | 12947 |
12943 error::Error GLES2DecoderImpl::HandleTexImage3D(uint32_t immediate_data_size, | 12948 error::Error GLES2DecoderImpl::HandleTexImage3D(uint32_t immediate_data_size, |
12944 const volatile void* cmd_data) { | 12949 const volatile void* cmd_data) { |
12945 if (!unsafe_es3_apis_enabled()) | 12950 if (!unsafe_es3_apis_enabled()) |
12946 return error::kUnknownCommand; | 12951 return error::kUnknownCommand; |
12947 | 12952 |
| 12953 const char* func_name = "glTexImage3D"; |
12948 const volatile gles2::cmds::TexImage3D& c = | 12954 const volatile gles2::cmds::TexImage3D& c = |
12949 *static_cast<const volatile gles2::cmds::TexImage3D*>(cmd_data); | 12955 *static_cast<const volatile gles2::cmds::TexImage3D*>(cmd_data); |
12950 TRACE_EVENT2("gpu", "GLES2DecoderImpl::HandleTexImage3D", | 12956 TRACE_EVENT2("gpu", "GLES2DecoderImpl::HandleTexImage3D", |
12951 "widthXheight", c.width * c.height, "depth", c.depth); | 12957 "widthXheight", c.width * c.height, "depth", c.depth); |
12952 // Set as failed for now, but if it successed, this will be set to not failed. | 12958 // Set as failed for now, but if it successed, this will be set to not failed. |
12953 texture_state_.tex_image_failed = true; | 12959 texture_state_.tex_image_failed = true; |
12954 GLenum target = static_cast<GLenum>(c.target); | 12960 GLenum target = static_cast<GLenum>(c.target); |
12955 GLint level = static_cast<GLint>(c.level); | 12961 GLint level = static_cast<GLint>(c.level); |
12956 GLint internal_format = static_cast<GLint>(c.internalformat); | 12962 GLint internal_format = static_cast<GLint>(c.internalformat); |
12957 GLsizei width = static_cast<GLsizei>(c.width); | 12963 GLsizei width = static_cast<GLsizei>(c.width); |
12958 GLsizei height = static_cast<GLsizei>(c.height); | 12964 GLsizei height = static_cast<GLsizei>(c.height); |
12959 GLsizei depth = static_cast<GLsizei>(c.depth); | 12965 GLsizei depth = static_cast<GLsizei>(c.depth); |
12960 GLint border = static_cast<GLint>(c.border); | 12966 GLint border = static_cast<GLint>(c.border); |
12961 GLenum format = static_cast<GLenum>(c.format); | 12967 GLenum format = static_cast<GLenum>(c.format); |
12962 GLenum type = static_cast<GLenum>(c.type); | 12968 GLenum type = static_cast<GLenum>(c.type); |
12963 uint32_t pixels_shm_id = static_cast<uint32_t>(c.pixels_shm_id); | 12969 uint32_t pixels_shm_id = static_cast<uint32_t>(c.pixels_shm_id); |
12964 uint32_t pixels_shm_offset = static_cast<uint32_t>(c.pixels_shm_offset); | 12970 uint32_t pixels_shm_offset = static_cast<uint32_t>(c.pixels_shm_offset); |
12965 | 12971 |
12966 if (width < 0 || height < 0 || depth < 0) { | 12972 if (width < 0 || height < 0 || depth < 0) { |
12967 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glTexImage3D", "dimensions < 0"); | 12973 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, func_name, "dimensions < 0"); |
12968 return error::kNoError; | 12974 return error::kNoError; |
12969 } | 12975 } |
12970 | 12976 |
12971 PixelStoreParams params; | 12977 PixelStoreParams params; |
12972 if (state_.bound_pixel_unpack_buffer.get()) { | 12978 Buffer* buffer = state_.bound_pixel_unpack_buffer.get(); |
| 12979 if (buffer) { |
12973 if (pixels_shm_id) | 12980 if (pixels_shm_id) |
12974 return error::kInvalidArguments; | 12981 return error::kInvalidArguments; |
| 12982 if (buffer->GetMappedRange()) { |
| 12983 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, |
| 12984 "pixel unpack buffer should not be mapped to client memory"); |
| 12985 return error::kNoError; |
| 12986 } |
12975 params = state_.GetUnpackParams(ContextState::k3D); | 12987 params = state_.GetUnpackParams(ContextState::k3D); |
12976 } else { | 12988 } else { |
12977 if (!pixels_shm_id && pixels_shm_offset) | 12989 if (!pixels_shm_id && pixels_shm_offset) |
12978 return error::kInvalidArguments; | 12990 return error::kInvalidArguments; |
12979 // When reading from client buffer, the command buffer client side took | 12991 // When reading from client buffer, the command buffer client side took |
12980 // the responsibility to take the pixels from the client buffer and | 12992 // the responsibility to take the pixels from the client buffer and |
12981 // unpack them according to the full ES3 pack parameters as source, all | 12993 // unpack them according to the full ES3 pack parameters as source, all |
12982 // parameters for 0 (except for alignment) as destination mem for the | 12994 // parameters for 0 (except for alignment) as destination mem for the |
12983 // service side. | 12995 // service side. |
12984 params.alignment = state_.unpack_alignment; | 12996 params.alignment = state_.unpack_alignment; |
(...skipping 19 matching lines...) Expand all Loading... |
13004 pixels_shm_id, pixels_shm_offset, pixels_size); | 13016 pixels_shm_id, pixels_shm_offset, pixels_size); |
13005 if (!pixels) | 13017 if (!pixels) |
13006 return error::kOutOfBounds; | 13018 return error::kOutOfBounds; |
13007 } else { | 13019 } else { |
13008 pixels = reinterpret_cast<const void*>(pixels_shm_offset); | 13020 pixels = reinterpret_cast<const void*>(pixels_shm_offset); |
13009 } | 13021 } |
13010 | 13022 |
13011 // For testing only. Allows us to stress the ability to respond to OOM errors. | 13023 // For testing only. Allows us to stress the ability to respond to OOM errors. |
13012 if (workarounds().simulate_out_of_memory_on_large_textures && | 13024 if (workarounds().simulate_out_of_memory_on_large_textures && |
13013 (width * height * depth >= 4096 * 4096)) { | 13025 (width * height * depth >= 4096 * 4096)) { |
13014 LOCAL_SET_GL_ERROR( | 13026 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, func_name, "synthetic out of memory"); |
13015 GL_OUT_OF_MEMORY, | |
13016 "glTexImage3D", "synthetic out of memory"); | |
13017 return error::kNoError; | 13027 return error::kNoError; |
13018 } | 13028 } |
13019 | 13029 |
13020 TextureManager::DoTexImageArguments args = { | 13030 TextureManager::DoTexImageArguments args = { |
13021 target, level, internal_format, width, height, depth, border, format, type, | 13031 target, level, internal_format, width, height, depth, border, format, type, |
13022 pixels, pixels_size, padding, | 13032 pixels, pixels_size, padding, |
13023 TextureManager::DoTexImageArguments::kTexImage3D }; | 13033 TextureManager::DoTexImageArguments::kTexImage3D }; |
13024 texture_manager()->ValidateAndDoTexImage( | 13034 texture_manager()->ValidateAndDoTexImage( |
13025 &texture_state_, &state_, &framebuffer_state_, "glTexImage3D", args); | 13035 &texture_state_, &state_, &framebuffer_state_, func_name, args); |
13026 | 13036 |
13027 // This may be a slow command. Exit command processing to allow for | 13037 // This may be a slow command. Exit command processing to allow for |
13028 // context preemption and GPU watchdog checks. | 13038 // context preemption and GPU watchdog checks. |
13029 ExitCommandProcessingEarly(); | 13039 ExitCommandProcessingEarly(); |
13030 return error::kNoError; | 13040 return error::kNoError; |
13031 } | 13041 } |
13032 | 13042 |
13033 void GLES2DecoderImpl::DoCompressedTexSubImage2D( | 13043 void GLES2DecoderImpl::DoCompressedTexSubImage2D( |
13034 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, | 13044 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, |
13035 GLsizei height, GLenum format, GLsizei image_size, const void * data) { | 13045 GLsizei height, GLenum format, GLsizei image_size, const void * data) { |
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13618 copyX, copyY, copyWidth, copyHeight); | 13628 copyX, copyY, copyWidth, copyHeight); |
13619 } | 13629 } |
13620 } | 13630 } |
13621 | 13631 |
13622 // This may be a slow command. Exit command processing to allow for | 13632 // This may be a slow command. Exit command processing to allow for |
13623 // context preemption and GPU watchdog checks. | 13633 // context preemption and GPU watchdog checks. |
13624 ExitCommandProcessingEarly(); | 13634 ExitCommandProcessingEarly(); |
13625 } | 13635 } |
13626 | 13636 |
13627 error::Error GLES2DecoderImpl::HandleTexSubImage2D( | 13637 error::Error GLES2DecoderImpl::HandleTexSubImage2D( |
13628 uint32_t immediate_data_size, | 13638 uint32_t immediate_data_size, const volatile void* cmd_data) { |
13629 const volatile void* cmd_data) { | 13639 const char* func_name = "glTexSubImage2D"; |
13630 const volatile gles2::cmds::TexSubImage2D& c = | 13640 const volatile gles2::cmds::TexSubImage2D& c = |
13631 *static_cast<const volatile gles2::cmds::TexSubImage2D*>(cmd_data); | 13641 *static_cast<const volatile gles2::cmds::TexSubImage2D*>(cmd_data); |
13632 TRACE_EVENT2("gpu", "GLES2DecoderImpl::HandleTexSubImage2D", | 13642 TRACE_EVENT2("gpu", "GLES2DecoderImpl::HandleTexSubImage2D", |
13633 "width", c.width, "height", c.height); | 13643 "width", c.width, "height", c.height); |
13634 GLboolean internal = static_cast<GLboolean>(c.internal); | 13644 GLboolean internal = static_cast<GLboolean>(c.internal); |
13635 if (internal == GL_TRUE && texture_state_.tex_image_failed) | 13645 if (internal == GL_TRUE && texture_state_.tex_image_failed) |
13636 return error::kNoError; | 13646 return error::kNoError; |
13637 | 13647 |
13638 GLenum target = static_cast<GLenum>(c.target); | 13648 GLenum target = static_cast<GLenum>(c.target); |
13639 GLint level = static_cast<GLint>(c.level); | 13649 GLint level = static_cast<GLint>(c.level); |
13640 GLint xoffset = static_cast<GLint>(c.xoffset); | 13650 GLint xoffset = static_cast<GLint>(c.xoffset); |
13641 GLint yoffset = static_cast<GLint>(c.yoffset); | 13651 GLint yoffset = static_cast<GLint>(c.yoffset); |
13642 GLsizei width = static_cast<GLsizei>(c.width); | 13652 GLsizei width = static_cast<GLsizei>(c.width); |
13643 GLsizei height = static_cast<GLsizei>(c.height); | 13653 GLsizei height = static_cast<GLsizei>(c.height); |
13644 GLenum format = static_cast<GLenum>(c.format); | 13654 GLenum format = static_cast<GLenum>(c.format); |
13645 GLenum type = static_cast<GLenum>(c.type); | 13655 GLenum type = static_cast<GLenum>(c.type); |
13646 uint32_t pixels_shm_id = static_cast<uint32_t>(c.pixels_shm_id); | 13656 uint32_t pixels_shm_id = static_cast<uint32_t>(c.pixels_shm_id); |
13647 uint32_t pixels_shm_offset = static_cast<uint32_t>(c.pixels_shm_offset); | 13657 uint32_t pixels_shm_offset = static_cast<uint32_t>(c.pixels_shm_offset); |
13648 | 13658 |
13649 if (width < 0 || height < 0) { | 13659 if (width < 0 || height < 0) { |
13650 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glTexSubImage2D", "dimensions < 0"); | 13660 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, func_name, "dimensions < 0"); |
13651 return error::kNoError; | 13661 return error::kNoError; |
13652 } | 13662 } |
13653 | 13663 |
13654 PixelStoreParams params; | 13664 PixelStoreParams params; |
13655 if (state_.bound_pixel_unpack_buffer.get()) { | 13665 Buffer* buffer = state_.bound_pixel_unpack_buffer.get(); |
| 13666 if (buffer) { |
13656 if (pixels_shm_id) | 13667 if (pixels_shm_id) |
13657 return error::kInvalidArguments; | 13668 return error::kInvalidArguments; |
| 13669 if (buffer->GetMappedRange()) { |
| 13670 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, |
| 13671 "pixel unpack buffer should not be mapped to client memory"); |
| 13672 return error::kNoError; |
| 13673 } |
13658 params = state_.GetUnpackParams(ContextState::k2D); | 13674 params = state_.GetUnpackParams(ContextState::k2D); |
13659 } else { | 13675 } else { |
13660 // When reading from client buffer, the command buffer client side took | 13676 // When reading from client buffer, the command buffer client side took |
13661 // the responsibility to take the pixels from the client buffer and | 13677 // the responsibility to take the pixels from the client buffer and |
13662 // unpack them according to the full ES3 pack parameters as source, all | 13678 // unpack them according to the full ES3 pack parameters as source, all |
13663 // parameters for 0 (except for alignment) as destination mem for the | 13679 // parameters for 0 (except for alignment) as destination mem for the |
13664 // service side. | 13680 // service side. |
13665 params.alignment = state_.unpack_alignment; | 13681 params.alignment = state_.unpack_alignment; |
13666 } | 13682 } |
13667 uint32_t pixels_size; | 13683 uint32_t pixels_size; |
(...skipping 20 matching lines...) Expand all Loading... |
13688 } else { | 13704 } else { |
13689 pixels = reinterpret_cast<const void*>(pixels_shm_offset); | 13705 pixels = reinterpret_cast<const void*>(pixels_shm_offset); |
13690 } | 13706 } |
13691 | 13707 |
13692 TextureManager::DoTexSubImageArguments args = { | 13708 TextureManager::DoTexSubImageArguments args = { |
13693 target, level, xoffset, yoffset, 0, width, height, 1, | 13709 target, level, xoffset, yoffset, 0, width, height, 1, |
13694 format, type, pixels, pixels_size, padding, | 13710 format, type, pixels, pixels_size, padding, |
13695 TextureManager::DoTexSubImageArguments::kTexSubImage2D}; | 13711 TextureManager::DoTexSubImageArguments::kTexSubImage2D}; |
13696 texture_manager()->ValidateAndDoTexSubImage(this, &texture_state_, &state_, | 13712 texture_manager()->ValidateAndDoTexSubImage(this, &texture_state_, &state_, |
13697 &framebuffer_state_, | 13713 &framebuffer_state_, |
13698 "glTexSubImage2D", args); | 13714 func_name, args); |
13699 | 13715 |
13700 // This may be a slow command. Exit command processing to allow for | 13716 // This may be a slow command. Exit command processing to allow for |
13701 // context preemption and GPU watchdog checks. | 13717 // context preemption and GPU watchdog checks. |
13702 ExitCommandProcessingEarly(); | 13718 ExitCommandProcessingEarly(); |
13703 return error::kNoError; | 13719 return error::kNoError; |
13704 } | 13720 } |
13705 | 13721 |
13706 error::Error GLES2DecoderImpl::HandleTexSubImage3D( | 13722 error::Error GLES2DecoderImpl::HandleTexSubImage3D( |
13707 uint32_t immediate_data_size, | 13723 uint32_t immediate_data_size, |
13708 const volatile void* cmd_data) { | 13724 const volatile void* cmd_data) { |
13709 if (!unsafe_es3_apis_enabled()) | 13725 if (!unsafe_es3_apis_enabled()) |
13710 return error::kUnknownCommand; | 13726 return error::kUnknownCommand; |
13711 | 13727 |
| 13728 const char* func_name = "glTexSubImage3D"; |
13712 const volatile gles2::cmds::TexSubImage3D& c = | 13729 const volatile gles2::cmds::TexSubImage3D& c = |
13713 *static_cast<const volatile gles2::cmds::TexSubImage3D*>(cmd_data); | 13730 *static_cast<const volatile gles2::cmds::TexSubImage3D*>(cmd_data); |
13714 TRACE_EVENT2("gpu", "GLES2DecoderImpl::HandleTexSubImage3D", | 13731 TRACE_EVENT2("gpu", "GLES2DecoderImpl::HandleTexSubImage3D", |
13715 "widthXheight", c.width * c.height, "depth", c.depth); | 13732 "widthXheight", c.width * c.height, "depth", c.depth); |
13716 GLboolean internal = static_cast<GLboolean>(c.internal); | 13733 GLboolean internal = static_cast<GLboolean>(c.internal); |
13717 if (internal == GL_TRUE && texture_state_.tex_image_failed) | 13734 if (internal == GL_TRUE && texture_state_.tex_image_failed) |
13718 return error::kNoError; | 13735 return error::kNoError; |
13719 | 13736 |
13720 GLenum target = static_cast<GLenum>(c.target); | 13737 GLenum target = static_cast<GLenum>(c.target); |
13721 GLint level = static_cast<GLint>(c.level); | 13738 GLint level = static_cast<GLint>(c.level); |
13722 GLint xoffset = static_cast<GLint>(c.xoffset); | 13739 GLint xoffset = static_cast<GLint>(c.xoffset); |
13723 GLint yoffset = static_cast<GLint>(c.yoffset); | 13740 GLint yoffset = static_cast<GLint>(c.yoffset); |
13724 GLint zoffset = static_cast<GLint>(c.zoffset); | 13741 GLint zoffset = static_cast<GLint>(c.zoffset); |
13725 GLsizei width = static_cast<GLsizei>(c.width); | 13742 GLsizei width = static_cast<GLsizei>(c.width); |
13726 GLsizei height = static_cast<GLsizei>(c.height); | 13743 GLsizei height = static_cast<GLsizei>(c.height); |
13727 GLsizei depth = static_cast<GLsizei>(c.depth); | 13744 GLsizei depth = static_cast<GLsizei>(c.depth); |
13728 GLenum format = static_cast<GLenum>(c.format); | 13745 GLenum format = static_cast<GLenum>(c.format); |
13729 GLenum type = static_cast<GLenum>(c.type); | 13746 GLenum type = static_cast<GLenum>(c.type); |
13730 uint32_t pixels_shm_id = static_cast<uint32_t>(c.pixels_shm_id); | 13747 uint32_t pixels_shm_id = static_cast<uint32_t>(c.pixels_shm_id); |
13731 uint32_t pixels_shm_offset = static_cast<uint32_t>(c.pixels_shm_offset); | 13748 uint32_t pixels_shm_offset = static_cast<uint32_t>(c.pixels_shm_offset); |
13732 | 13749 |
13733 if (width < 0 || height < 0 || depth < 0) { | 13750 if (width < 0 || height < 0 || depth < 0) { |
13734 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glTexSubImage3D", "dimensions < 0"); | 13751 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, func_name, "dimensions < 0"); |
13735 return error::kNoError; | 13752 return error::kNoError; |
13736 } | 13753 } |
13737 | 13754 |
13738 PixelStoreParams params; | 13755 PixelStoreParams params; |
13739 if (state_.bound_pixel_unpack_buffer.get()) { | 13756 Buffer* buffer = state_.bound_pixel_unpack_buffer.get(); |
| 13757 if (buffer) { |
13740 if (pixels_shm_id) | 13758 if (pixels_shm_id) |
13741 return error::kInvalidArguments; | 13759 return error::kInvalidArguments; |
| 13760 if (buffer->GetMappedRange()) { |
| 13761 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, |
| 13762 "pixel unpack buffer should not be mapped to client memory"); |
| 13763 return error::kNoError; |
| 13764 } |
13742 params = state_.GetUnpackParams(ContextState::k3D); | 13765 params = state_.GetUnpackParams(ContextState::k3D); |
13743 } else { | 13766 } else { |
13744 // When reading from client buffer, the command buffer client side took | 13767 // When reading from client buffer, the command buffer client side took |
13745 // the responsibility to take the pixels from the client buffer and | 13768 // the responsibility to take the pixels from the client buffer and |
13746 // unpack them according to the full ES3 pack parameters as source, all | 13769 // unpack them according to the full ES3 pack parameters as source, all |
13747 // parameters for 0 (except for alignment) as destination mem for the | 13770 // parameters for 0 (except for alignment) as destination mem for the |
13748 // service side. | 13771 // service side. |
13749 params.alignment = state_.unpack_alignment; | 13772 params.alignment = state_.unpack_alignment; |
13750 } | 13773 } |
13751 uint32_t pixels_size; | 13774 uint32_t pixels_size; |
(...skipping 20 matching lines...) Expand all Loading... |
13772 } else { | 13795 } else { |
13773 pixels = reinterpret_cast<const void*>(pixels_shm_offset); | 13796 pixels = reinterpret_cast<const void*>(pixels_shm_offset); |
13774 } | 13797 } |
13775 | 13798 |
13776 TextureManager::DoTexSubImageArguments args = { | 13799 TextureManager::DoTexSubImageArguments args = { |
13777 target, level, xoffset, yoffset, zoffset, width, height, depth, | 13800 target, level, xoffset, yoffset, zoffset, width, height, depth, |
13778 format, type, pixels, pixels_size, padding, | 13801 format, type, pixels, pixels_size, padding, |
13779 TextureManager::DoTexSubImageArguments::kTexSubImage3D}; | 13802 TextureManager::DoTexSubImageArguments::kTexSubImage3D}; |
13780 texture_manager()->ValidateAndDoTexSubImage(this, &texture_state_, &state_, | 13803 texture_manager()->ValidateAndDoTexSubImage(this, &texture_state_, &state_, |
13781 &framebuffer_state_, | 13804 &framebuffer_state_, |
13782 "glTexSubImage3D", args); | 13805 func_name, args); |
13783 | 13806 |
13784 // This may be a slow command. Exit command processing to allow for | 13807 // This may be a slow command. Exit command processing to allow for |
13785 // context preemption and GPU watchdog checks. | 13808 // context preemption and GPU watchdog checks. |
13786 ExitCommandProcessingEarly(); | 13809 ExitCommandProcessingEarly(); |
13787 return error::kNoError; | 13810 return error::kNoError; |
13788 } | 13811 } |
13789 | 13812 |
13790 error::Error GLES2DecoderImpl::HandleGetVertexAttribPointerv( | 13813 error::Error GLES2DecoderImpl::HandleGetVertexAttribPointerv( |
13791 uint32_t immediate_data_size, | 13814 uint32_t immediate_data_size, |
13792 const volatile void* cmd_data) { | 13815 const volatile void* cmd_data) { |
(...skipping 2987 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16780 result->SetNumResults(num_values); | 16803 result->SetNumResults(num_values); |
16781 return error::kNoError; | 16804 return error::kNoError; |
16782 } | 16805 } |
16783 | 16806 |
16784 error::Error GLES2DecoderImpl::HandleMapBufferRange( | 16807 error::Error GLES2DecoderImpl::HandleMapBufferRange( |
16785 uint32_t immediate_data_size, | 16808 uint32_t immediate_data_size, |
16786 const volatile void* cmd_data) { | 16809 const volatile void* cmd_data) { |
16787 if (!unsafe_es3_apis_enabled()) { | 16810 if (!unsafe_es3_apis_enabled()) { |
16788 return error::kUnknownCommand; | 16811 return error::kUnknownCommand; |
16789 } | 16812 } |
| 16813 |
| 16814 const char* func_name = "glMapBufferRange"; |
16790 const volatile gles2::cmds::MapBufferRange& c = | 16815 const volatile gles2::cmds::MapBufferRange& c = |
16791 *static_cast<const volatile gles2::cmds::MapBufferRange*>(cmd_data); | 16816 *static_cast<const volatile gles2::cmds::MapBufferRange*>(cmd_data); |
16792 GLenum target = static_cast<GLenum>(c.target); | 16817 GLenum target = static_cast<GLenum>(c.target); |
16793 GLbitfield access = static_cast<GLbitfield>(c.access); | 16818 GLbitfield access = static_cast<GLbitfield>(c.access); |
16794 GLintptr offset = static_cast<GLintptr>(c.offset); | 16819 GLintptr offset = static_cast<GLintptr>(c.offset); |
16795 GLsizeiptr size = static_cast<GLsizeiptr>(c.size); | 16820 GLsizeiptr size = static_cast<GLsizeiptr>(c.size); |
16796 uint32_t data_shm_id = static_cast<uint32_t>(c.data_shm_id); | 16821 uint32_t data_shm_id = static_cast<uint32_t>(c.data_shm_id); |
| 16822 uint32_t data_shm_offset = static_cast<uint32_t>(c.data_shm_offset); |
16797 | 16823 |
16798 typedef cmds::MapBufferRange::Result Result; | 16824 typedef cmds::MapBufferRange::Result Result; |
16799 Result* result = GetSharedMemoryAs<Result*>( | 16825 Result* result = GetSharedMemoryAs<Result*>( |
16800 c.result_shm_id, c.result_shm_offset, sizeof(*result)); | 16826 c.result_shm_id, c.result_shm_offset, sizeof(*result)); |
16801 if (!result) { | 16827 if (!result) { |
16802 return error::kOutOfBounds; | 16828 return error::kOutOfBounds; |
16803 } | 16829 } |
16804 if (*result != 0) { | 16830 if (*result != 0) { |
16805 *result = 0; | 16831 *result = 0; |
16806 return error::kInvalidArguments; | 16832 return error::kInvalidArguments; |
16807 } | 16833 } |
16808 int8_t* mem = | 16834 int8_t* mem = |
16809 GetSharedMemoryAs<int8_t*>(data_shm_id, c.data_shm_offset, size); | 16835 GetSharedMemoryAs<int8_t*>(data_shm_id, data_shm_offset, size); |
16810 if (!mem) { | 16836 if (!mem) { |
16811 return error::kOutOfBounds; | 16837 return error::kOutOfBounds; |
16812 } | 16838 } |
16813 | 16839 |
16814 if (!validators_->buffer_target.IsValid(target)) { | 16840 if (!validators_->buffer_target.IsValid(target)) { |
16815 LOCAL_SET_GL_ERROR_INVALID_ENUM("glMapBufferRange", target, "target"); | 16841 LOCAL_SET_GL_ERROR_INVALID_ENUM(func_name, target, "target"); |
16816 return error::kNoError; | 16842 return error::kNoError; |
16817 } | 16843 } |
16818 | 16844 |
16819 GLbitfield mask = GL_MAP_INVALIDATE_BUFFER_BIT; | 16845 GLbitfield mask = GL_MAP_INVALIDATE_BUFFER_BIT; |
16820 if ((access & mask) == mask) { | 16846 if ((access & mask) == mask) { |
16821 // TODO(zmo): To be on the safe side, always map | 16847 // TODO(zmo): To be on the safe side, always map |
16822 // GL_MAP_INVALIDATE_BUFFER_BIT to GL_MAP_INVALIDATE_RANGE_BIT. | 16848 // GL_MAP_INVALIDATE_BUFFER_BIT to GL_MAP_INVALIDATE_RANGE_BIT. |
16823 access = (access & ~GL_MAP_INVALIDATE_BUFFER_BIT); | 16849 access = (access & ~GL_MAP_INVALIDATE_BUFFER_BIT); |
16824 access = (access | GL_MAP_INVALIDATE_RANGE_BIT); | 16850 access = (access | GL_MAP_INVALIDATE_RANGE_BIT); |
16825 } | 16851 } |
16826 // TODO(zmo): Always filter out GL_MAP_UNSYNCHRONIZED_BIT to get rid of | 16852 // TODO(zmo): Always filter out GL_MAP_UNSYNCHRONIZED_BIT to get rid of |
16827 // undefined behaviors. | 16853 // undefined behaviors. |
16828 mask = GL_MAP_READ_BIT | GL_MAP_UNSYNCHRONIZED_BIT; | 16854 mask = GL_MAP_READ_BIT | GL_MAP_UNSYNCHRONIZED_BIT; |
16829 if ((access & mask) == mask) { | 16855 if ((access & mask) == mask) { |
16830 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "MapBufferRange", | 16856 LOCAL_SET_GL_ERROR( |
16831 "incompatible access bits"); | 16857 GL_INVALID_OPERATION, func_name, "incompatible access bits"); |
16832 return error::kNoError; | 16858 return error::kNoError; |
16833 } | 16859 } |
16834 access = (access & ~GL_MAP_UNSYNCHRONIZED_BIT); | 16860 access = (access & ~GL_MAP_UNSYNCHRONIZED_BIT); |
16835 if ((access & GL_MAP_WRITE_BIT) == GL_MAP_WRITE_BIT && | 16861 if ((access & GL_MAP_WRITE_BIT) == GL_MAP_WRITE_BIT && |
16836 (access & GL_MAP_INVALIDATE_RANGE_BIT) == 0) { | 16862 (access & GL_MAP_INVALIDATE_RANGE_BIT) == 0) { |
16837 access = (access | GL_MAP_READ_BIT); | 16863 access = (access | GL_MAP_READ_BIT); |
16838 } | 16864 } |
16839 Buffer* buffer = buffer_manager()->GetBufferInfoForTarget(&state_, target); | 16865 Buffer* buffer = buffer_manager()->GetBufferInfoForTarget(&state_, target); |
16840 if (!buffer) { | 16866 if (!buffer) { |
16841 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "MapBufferRange", | 16867 LOCAL_SET_GL_ERROR( |
16842 "no buffer bound to target"); | 16868 GL_INVALID_OPERATION, func_name, "no buffer bound to target"); |
16843 return error::kNoError; | 16869 return error::kNoError; |
16844 } | 16870 } |
| 16871 if (buffer->GetMappedRange()) { |
| 16872 LOCAL_SET_GL_ERROR( |
| 16873 GL_INVALID_OPERATION, func_name, "buffer is already mapped"); |
| 16874 } |
16845 if (!buffer->CheckRange(offset, size)) { | 16875 if (!buffer->CheckRange(offset, size)) { |
16846 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "MapBufferRange", | 16876 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, func_name, "invalid range"); |
16847 "invalid range"); | |
16848 return error::kNoError; | 16877 return error::kNoError; |
16849 } | 16878 } |
16850 void* ptr = glMapBufferRange(target, offset, size, access); | 16879 void* ptr = glMapBufferRange(target, offset, size, access); |
16851 if (ptr == nullptr) { | 16880 if (ptr == nullptr) { |
16852 return error::kNoError; | 16881 return error::kNoError; |
16853 } | 16882 } |
16854 buffer->SetMappedRange(offset, size, access, ptr, | 16883 buffer->SetMappedRange(offset, size, access, ptr, |
16855 GetSharedMemoryBuffer(data_shm_id)); | 16884 GetSharedMemoryBuffer(data_shm_id), |
| 16885 static_cast<unsigned int>(data_shm_offset)); |
16856 if ((access & GL_MAP_INVALIDATE_RANGE_BIT) == 0) { | 16886 if ((access & GL_MAP_INVALIDATE_RANGE_BIT) == 0) { |
16857 memcpy(mem, ptr, size); | 16887 memcpy(mem, ptr, size); |
16858 } | 16888 } |
16859 *result = 1; | 16889 *result = 1; |
16860 return error::kNoError; | 16890 return error::kNoError; |
16861 } | 16891 } |
16862 | 16892 |
16863 error::Error GLES2DecoderImpl::HandleUnmapBuffer( | 16893 error::Error GLES2DecoderImpl::HandleUnmapBuffer( |
16864 uint32_t immediate_data_size, | 16894 uint32_t immediate_data_size, |
16865 const volatile void* cmd_data) { | 16895 const volatile void* cmd_data) { |
(...skipping 25 matching lines...) Expand all Loading... |
16891 GL_MAP_FLUSH_EXPLICIT_BIT) { | 16921 GL_MAP_FLUSH_EXPLICIT_BIT) { |
16892 // If we don't need to write back, or explict flush is required, no copying | 16922 // If we don't need to write back, or explict flush is required, no copying |
16893 // back is needed. | 16923 // back is needed. |
16894 } else { | 16924 } else { |
16895 void* mem = mapped_range->GetShmPointer(); | 16925 void* mem = mapped_range->GetShmPointer(); |
16896 if (!mem) { | 16926 if (!mem) { |
16897 return error::kOutOfBounds; | 16927 return error::kOutOfBounds; |
16898 } | 16928 } |
16899 DCHECK(mapped_range->pointer); | 16929 DCHECK(mapped_range->pointer); |
16900 memcpy(mapped_range->pointer, mem, mapped_range->size); | 16930 memcpy(mapped_range->pointer, mem, mapped_range->size); |
| 16931 if (buffer->shadowed()) { |
| 16932 bool success = buffer->SetRange( |
| 16933 mapped_range->offset, mapped_range->size, mem); |
| 16934 DCHECK(success); |
| 16935 } |
16901 } | 16936 } |
16902 buffer->RemoveMappedRange(); | 16937 buffer->RemoveMappedRange(); |
16903 GLboolean rt = glUnmapBuffer(target); | 16938 GLboolean rt = glUnmapBuffer(target); |
16904 if (rt == GL_FALSE) { | 16939 if (rt == GL_FALSE) { |
16905 // At this point, we have already done the necessary validation, so | 16940 // At this point, we have already done the necessary validation, so |
16906 // GL_FALSE indicates data corruption. | 16941 // GL_FALSE indicates data corruption. |
16907 // TODO(zmo): We could redo the map / copy data / unmap to recover, but | 16942 // TODO(zmo): We could redo the map / copy data / unmap to recover, but |
16908 // the second unmap could still return GL_FALSE. For now, we simply lose | 16943 // the second unmap could still return GL_FALSE. For now, we simply lose |
16909 // the contexts in the share group. | 16944 // the contexts in the share group. |
16910 LOG(ERROR) << "glUnmapBuffer unexpectedly returned GL_FALSE"; | 16945 LOG(ERROR) << "glUnmapBuffer unexpectedly returned GL_FALSE"; |
(...skipping 1198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
18109 } | 18144 } |
18110 | 18145 |
18111 // Include the auto-generated part of this file. We split this because it means | 18146 // Include the auto-generated part of this file. We split this because it means |
18112 // we can easily edit the non-auto generated parts right here in this file | 18147 // we can easily edit the non-auto generated parts right here in this file |
18113 // instead of having to edit some template or the code generator. | 18148 // instead of having to edit some template or the code generator. |
18114 #include "base/macros.h" | 18149 #include "base/macros.h" |
18115 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 18150 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
18116 | 18151 |
18117 } // namespace gles2 | 18152 } // namespace gles2 |
18118 } // namespace gpu | 18153 } // namespace gpu |
OLD | NEW |