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 <stdio.h> | 7 #include <stdio.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <list> | 10 #include <list> |
11 #include <map> | 11 #include <map> |
| 12 #include <queue> |
12 #include <stack> | 13 #include <stack> |
13 #include <string> | 14 #include <string> |
14 #include <vector> | 15 #include <vector> |
15 | 16 |
16 #include "base/at_exit.h" | 17 #include "base/at_exit.h" |
17 #include "base/bind.h" | 18 #include "base/bind.h" |
18 #include "base/callback_helpers.h" | 19 #include "base/callback_helpers.h" |
19 #include "base/command_line.h" | 20 #include "base/command_line.h" |
20 #include "base/memory/scoped_ptr.h" | 21 #include "base/memory/scoped_ptr.h" |
21 #include "base/numerics/safe_math.h" | 22 #include "base/numerics/safe_math.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 0.0f, 0.0f, 0.0f, 1.0f}; | 92 0.0f, 0.0f, 0.0f, 1.0f}; |
92 | 93 |
93 static bool PrecisionMeetsSpecForHighpFloat(GLint rangeMin, | 94 static bool PrecisionMeetsSpecForHighpFloat(GLint rangeMin, |
94 GLint rangeMax, | 95 GLint rangeMax, |
95 GLint precision) { | 96 GLint precision) { |
96 return (rangeMin >= 62) && (rangeMax >= 62) && (precision >= 16); | 97 return (rangeMin >= 62) && (rangeMax >= 62) && (precision >= 16); |
97 } | 98 } |
98 | 99 |
99 static void GetShaderPrecisionFormatImpl(GLenum shader_type, | 100 static void GetShaderPrecisionFormatImpl(GLenum shader_type, |
100 GLenum precision_type, | 101 GLenum precision_type, |
101 GLint *range, GLint *precision) { | 102 GLint* range, GLint* precision) { |
102 switch (precision_type) { | 103 switch (precision_type) { |
103 case GL_LOW_INT: | 104 case GL_LOW_INT: |
104 case GL_MEDIUM_INT: | 105 case GL_MEDIUM_INT: |
105 case GL_HIGH_INT: | 106 case GL_HIGH_INT: |
106 // These values are for a 32-bit twos-complement integer format. | 107 // These values are for a 32-bit twos-complement integer format. |
107 range[0] = 31; | 108 range[0] = 31; |
108 range[1] = 30; | 109 range[1] = 30; |
109 *precision = 0; | 110 *precision = 0; |
110 break; | 111 break; |
111 case GL_LOW_FLOAT: | 112 case GL_LOW_FLOAT: |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 return id_; | 496 return id_; |
496 } | 497 } |
497 | 498 |
498 private: | 499 private: |
499 GLES2DecoderImpl* decoder_; | 500 GLES2DecoderImpl* decoder_; |
500 GLuint id_; | 501 GLuint id_; |
501 DISALLOW_COPY_AND_ASSIGN(BackFramebuffer); | 502 DISALLOW_COPY_AND_ASSIGN(BackFramebuffer); |
502 }; | 503 }; |
503 | 504 |
504 struct FenceCallback { | 505 struct FenceCallback { |
505 explicit FenceCallback() | 506 FenceCallback() |
506 : fence(gfx::GLFence::Create()) { | 507 : fence(gfx::GLFence::Create()) { |
507 DCHECK(fence); | 508 DCHECK(fence); |
508 } | 509 } |
509 std::vector<base::Closure> callbacks; | 510 std::vector<base::Closure> callbacks; |
510 scoped_ptr<gfx::GLFence> fence; | 511 scoped_ptr<gfx::GLFence> fence; |
511 }; | 512 }; |
512 | 513 |
513 class AsyncUploadTokenCompletionObserver | 514 class AsyncUploadTokenCompletionObserver |
514 : public AsyncPixelTransferCompletionObserver { | 515 : public AsyncPixelTransferCompletionObserver { |
515 public: | 516 public: |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
751 base::Closure AsyncUploadTokenCompletionClosure(uint32 async_upload_token, | 752 base::Closure AsyncUploadTokenCompletionClosure(uint32 async_upload_token, |
752 uint32 sync_data_shm_id, | 753 uint32 sync_data_shm_id, |
753 uint32 sync_data_shm_offset); | 754 uint32 sync_data_shm_offset); |
754 | 755 |
755 | 756 |
756 | 757 |
757 // Workarounds | 758 // Workarounds |
758 void OnFboChanged() const; | 759 void OnFboChanged() const; |
759 void OnUseFramebuffer() const; | 760 void OnUseFramebuffer() const; |
760 | 761 |
| 762 error::ContextLostReason GetContextLostReasonFromResetStatus( |
| 763 GLenum reset_status) const; |
| 764 |
761 // TODO(gman): Cache these pointers? | 765 // TODO(gman): Cache these pointers? |
762 BufferManager* buffer_manager() { | 766 BufferManager* buffer_manager() { |
763 return group_->buffer_manager(); | 767 return group_->buffer_manager(); |
764 } | 768 } |
765 | 769 |
766 RenderbufferManager* renderbuffer_manager() { | 770 RenderbufferManager* renderbuffer_manager() { |
767 return group_->renderbuffer_manager(); | 771 return group_->renderbuffer_manager(); |
768 } | 772 } |
769 | 773 |
770 FramebufferManager* framebuffer_manager() { | 774 FramebufferManager* framebuffer_manager() { |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
959 GLenum internal_format, | 963 GLenum internal_format, |
960 GLsizei width, | 964 GLsizei width, |
961 GLsizei height); | 965 GLsizei height); |
962 | 966 |
963 void DoProduceTextureCHROMIUM(GLenum target, const GLbyte* key); | 967 void DoProduceTextureCHROMIUM(GLenum target, const GLbyte* key); |
964 void DoProduceTextureDirectCHROMIUM(GLuint texture, GLenum target, | 968 void DoProduceTextureDirectCHROMIUM(GLuint texture, GLenum target, |
965 const GLbyte* key); | 969 const GLbyte* key); |
966 void ProduceTextureRef(std::string func_name, TextureRef* texture_ref, | 970 void ProduceTextureRef(std::string func_name, TextureRef* texture_ref, |
967 GLenum target, const GLbyte* data); | 971 GLenum target, const GLbyte* data); |
968 | 972 |
| 973 void EnsureTextureForClientId(GLenum target, GLuint client_id); |
969 void DoConsumeTextureCHROMIUM(GLenum target, const GLbyte* key); | 974 void DoConsumeTextureCHROMIUM(GLenum target, const GLbyte* key); |
970 void DoCreateAndConsumeTextureCHROMIUM(GLenum target, const GLbyte* key, | 975 void DoCreateAndConsumeTextureCHROMIUM(GLenum target, const GLbyte* key, |
971 GLuint client_id); | 976 GLuint client_id); |
972 | 977 |
973 bool DoIsValuebufferCHROMIUM(GLuint client_id); | 978 bool DoIsValuebufferCHROMIUM(GLuint client_id); |
974 void DoBindValueBufferCHROMIUM(GLenum target, GLuint valuebuffer); | 979 void DoBindValueBufferCHROMIUM(GLenum target, GLuint valuebuffer); |
975 void DoSubscribeValueCHROMIUM(GLenum target, GLenum subscription); | 980 void DoSubscribeValueCHROMIUM(GLenum target, GLenum subscription); |
976 void DoPopulateSubscribedValuesCHROMIUM(GLenum target); | 981 void DoPopulateSubscribedValuesCHROMIUM(GLenum target); |
977 void DoUniformValueBufferCHROMIUM(GLint location, | 982 void DoUniformValueBufferCHROMIUM(GLint location, |
978 GLenum target, | 983 GLenum target, |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1402 // Wrapper for DoGetBooleanv. | 1407 // Wrapper for DoGetBooleanv. |
1403 void DoGetBooleanv(GLenum pname, GLboolean* params); | 1408 void DoGetBooleanv(GLenum pname, GLboolean* params); |
1404 | 1409 |
1405 // Wrapper for DoGetFloatv. | 1410 // Wrapper for DoGetFloatv. |
1406 void DoGetFloatv(GLenum pname, GLfloat* params); | 1411 void DoGetFloatv(GLenum pname, GLfloat* params); |
1407 | 1412 |
1408 // Wrapper for glGetFramebufferAttachmentParameteriv. | 1413 // Wrapper for glGetFramebufferAttachmentParameteriv. |
1409 void DoGetFramebufferAttachmentParameteriv( | 1414 void DoGetFramebufferAttachmentParameteriv( |
1410 GLenum target, GLenum attachment, GLenum pname, GLint* params); | 1415 GLenum target, GLenum attachment, GLenum pname, GLint* params); |
1411 | 1416 |
| 1417 // Wrapper for glGetInteger64v. |
| 1418 void DoGetInteger64v(GLenum pname, GLint64* params); |
| 1419 |
1412 // Wrapper for glGetIntegerv. | 1420 // Wrapper for glGetIntegerv. |
1413 void DoGetIntegerv(GLenum pname, GLint* params); | 1421 void DoGetIntegerv(GLenum pname, GLint* params); |
1414 | 1422 |
1415 // Gets the max value in a range in a buffer. | 1423 // Gets the max value in a range in a buffer. |
1416 GLuint DoGetMaxValueInBufferCHROMIUM( | 1424 GLuint DoGetMaxValueInBufferCHROMIUM( |
1417 GLuint buffer_id, GLsizei count, GLenum type, GLuint offset); | 1425 GLuint buffer_id, GLsizei count, GLenum type, GLuint offset); |
1418 | 1426 |
1419 // Wrapper for glGetBufferParameteriv. | 1427 // Wrapper for glGetBufferParameteriv. |
1420 void DoGetBufferParameteriv( | 1428 void DoGetBufferParameteriv( |
1421 GLenum target, GLenum pname, GLint* params); | 1429 GLenum target, GLenum pname, GLint* params); |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1644 GLint fake_location, | 1652 GLint fake_location, |
1645 uint32 shm_id, | 1653 uint32 shm_id, |
1646 uint32 shm_offset, | 1654 uint32 shm_offset, |
1647 error::Error* error, | 1655 error::Error* error, |
1648 GLint* real_location, | 1656 GLint* real_location, |
1649 GLuint* service_id, | 1657 GLuint* service_id, |
1650 void** result, | 1658 void** result, |
1651 GLenum* result_type, | 1659 GLenum* result_type, |
1652 GLsizei* result_size); | 1660 GLsizei* result_size); |
1653 | 1661 |
1654 void MaybeExitOnContextLost(); | 1662 bool WasContextLost() const override; |
1655 bool WasContextLost() override; | 1663 bool WasContextLostByRobustnessExtension() const override; |
1656 bool WasContextLostByRobustnessExtension() override; | 1664 void MarkContextLost(error::ContextLostReason reason) override; |
1657 void LoseContext(uint32 reset_status) override; | 1665 bool CheckResetStatus(); |
1658 | 1666 |
1659 #if defined(OS_MACOSX) | 1667 #if defined(OS_MACOSX) |
1660 void ReleaseIOSurfaceForTexture(GLuint texture_id); | 1668 void ReleaseIOSurfaceForTexture(GLuint texture_id); |
1661 #endif | 1669 #endif |
1662 | 1670 |
1663 bool ValidateCompressedTexDimensions( | 1671 bool ValidateCompressedTexDimensions( |
1664 const char* function_name, | 1672 const char* function_name, |
1665 GLint level, GLsizei width, GLsizei height, GLenum format); | 1673 GLint level, GLsizei width, GLsizei height, GLenum format); |
1666 bool ValidateCompressedTexFuncData( | 1674 bool ValidateCompressedTexFuncData( |
1667 const char* function_name, | 1675 const char* function_name, |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1850 // Cached from ContextGroup | 1858 // Cached from ContextGroup |
1851 const Validators* validators_; | 1859 const Validators* validators_; |
1852 scoped_refptr<FeatureInfo> feature_info_; | 1860 scoped_refptr<FeatureInfo> feature_info_; |
1853 | 1861 |
1854 int frame_number_; | 1862 int frame_number_; |
1855 | 1863 |
1856 // Number of commands remaining to be processed in DoCommands(). | 1864 // Number of commands remaining to be processed in DoCommands(). |
1857 int commands_to_process_; | 1865 int commands_to_process_; |
1858 | 1866 |
1859 bool has_robustness_extension_; | 1867 bool has_robustness_extension_; |
1860 GLenum reset_status_; | 1868 error::ContextLostReason context_lost_reason_; |
| 1869 bool context_was_lost_; |
1861 bool reset_by_robustness_extension_; | 1870 bool reset_by_robustness_extension_; |
1862 bool supports_post_sub_buffer_; | 1871 bool supports_post_sub_buffer_; |
1863 | 1872 |
1864 // These flags are used to override the state of the shared feature_info_ | 1873 // These flags are used to override the state of the shared feature_info_ |
1865 // member. Because the same FeatureInfo instance may be shared among many | 1874 // member. Because the same FeatureInfo instance may be shared among many |
1866 // contexts, the assumptions on the availablity of extensions in WebGL | 1875 // contexts, the assumptions on the availablity of extensions in WebGL |
1867 // contexts may be broken. These flags override the shared state to preserve | 1876 // contexts may be broken. These flags override the shared state to preserve |
1868 // WebGL semantics. | 1877 // WebGL semantics. |
1869 bool force_webgl_glsl_validation_; | 1878 bool force_webgl_glsl_validation_; |
1870 bool derivatives_explicitly_enabled_; | 1879 bool derivatives_explicitly_enabled_; |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2392 back_buffer_has_depth_(false), | 2401 back_buffer_has_depth_(false), |
2393 back_buffer_has_stencil_(false), | 2402 back_buffer_has_stencil_(false), |
2394 surfaceless_(false), | 2403 surfaceless_(false), |
2395 backbuffer_needs_clear_bits_(0), | 2404 backbuffer_needs_clear_bits_(0), |
2396 current_decoder_error_(error::kNoError), | 2405 current_decoder_error_(error::kNoError), |
2397 use_shader_translator_(true), | 2406 use_shader_translator_(true), |
2398 validators_(group_->feature_info()->validators()), | 2407 validators_(group_->feature_info()->validators()), |
2399 feature_info_(group_->feature_info()), | 2408 feature_info_(group_->feature_info()), |
2400 frame_number_(0), | 2409 frame_number_(0), |
2401 has_robustness_extension_(false), | 2410 has_robustness_extension_(false), |
2402 reset_status_(GL_NO_ERROR), | 2411 context_lost_reason_(error::kUnknown), |
| 2412 context_was_lost_(false), |
2403 reset_by_robustness_extension_(false), | 2413 reset_by_robustness_extension_(false), |
2404 supports_post_sub_buffer_(false), | 2414 supports_post_sub_buffer_(false), |
2405 force_webgl_glsl_validation_(false), | 2415 force_webgl_glsl_validation_(false), |
2406 derivatives_explicitly_enabled_(false), | 2416 derivatives_explicitly_enabled_(false), |
2407 frag_depth_explicitly_enabled_(false), | 2417 frag_depth_explicitly_enabled_(false), |
2408 draw_buffers_explicitly_enabled_(false), | 2418 draw_buffers_explicitly_enabled_(false), |
2409 shader_texture_lod_explicitly_enabled_(false), | 2419 shader_texture_lod_explicitly_enabled_(false), |
2410 compile_shader_always_succeeds_(false), | 2420 compile_shader_always_succeeds_(false), |
2411 lose_context_when_out_of_memory_(false), | 2421 lose_context_when_out_of_memory_(false), |
2412 service_logging_(base::CommandLine::ForCurrentProcess()->HasSwitch( | 2422 service_logging_(base::CommandLine::ForCurrentProcess()->HasSwitch( |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2866 DoGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, | 2876 DoGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, |
2867 &caps.max_vertex_texture_image_units); | 2877 &caps.max_vertex_texture_image_units); |
2868 DoGetIntegerv(GL_MAX_VERTEX_UNIFORM_VECTORS, | 2878 DoGetIntegerv(GL_MAX_VERTEX_UNIFORM_VECTORS, |
2869 &caps.max_vertex_uniform_vectors); | 2879 &caps.max_vertex_uniform_vectors); |
2870 DoGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, | 2880 DoGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, |
2871 &caps.num_compressed_texture_formats); | 2881 &caps.num_compressed_texture_formats); |
2872 DoGetIntegerv(GL_NUM_SHADER_BINARY_FORMATS, &caps.num_shader_binary_formats); | 2882 DoGetIntegerv(GL_NUM_SHADER_BINARY_FORMATS, &caps.num_shader_binary_formats); |
2873 DoGetIntegerv(GL_BIND_GENERATES_RESOURCE_CHROMIUM, | 2883 DoGetIntegerv(GL_BIND_GENERATES_RESOURCE_CHROMIUM, |
2874 &caps.bind_generates_resource_chromium); | 2884 &caps.bind_generates_resource_chromium); |
2875 if (unsafe_es3_apis_enabled()) { | 2885 if (unsafe_es3_apis_enabled()) { |
| 2886 // TODO(zmo): Note that some parameter values could be more than 32-bit, |
| 2887 // but for now we clamp them to 32-bit max. |
| 2888 DoGetIntegerv(GL_MAX_3D_TEXTURE_SIZE, &caps.max_3d_texture_size); |
| 2889 DoGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &caps.max_array_texture_layers); |
| 2890 DoGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, &caps.max_color_attachments); |
| 2891 DoGetIntegerv(GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS, |
| 2892 &caps.max_combined_fragment_uniform_components); |
| 2893 DoGetIntegerv(GL_MAX_COMBINED_UNIFORM_BLOCKS, |
| 2894 &caps.max_combined_uniform_blocks); |
| 2895 DoGetIntegerv(GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS, |
| 2896 &caps.max_combined_vertex_uniform_components); |
| 2897 DoGetIntegerv(GL_MAX_DRAW_BUFFERS, &caps.max_draw_buffers); |
| 2898 DoGetIntegerv(GL_MAX_ELEMENT_INDEX, &caps.max_element_index); |
| 2899 DoGetIntegerv(GL_MAX_ELEMENTS_INDICES, &caps.max_elements_indices); |
| 2900 DoGetIntegerv(GL_MAX_ELEMENTS_VERTICES, &caps.max_elements_vertices); |
| 2901 DoGetIntegerv(GL_MAX_FRAGMENT_INPUT_COMPONENTS, |
| 2902 &caps.max_fragment_input_components); |
| 2903 DoGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_BLOCKS, |
| 2904 &caps.max_fragment_uniform_blocks); |
| 2905 DoGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, |
| 2906 &caps.max_fragment_uniform_components); |
| 2907 DoGetIntegerv(GL_MAX_PROGRAM_TEXEL_OFFSET, |
| 2908 &caps.max_program_texel_offset); |
| 2909 DoGetIntegerv(GL_MAX_SAMPLES, &caps.max_samples); |
| 2910 DoGetIntegerv(GL_MAX_SERVER_WAIT_TIMEOUT, &caps.max_server_wait_timeout); |
| 2911 DoGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS, |
| 2912 &caps.max_transform_feedback_interleaved_components); |
2876 DoGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, | 2913 DoGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, |
2877 &caps.max_transform_feedback_separate_attribs); | 2914 &caps.max_transform_feedback_separate_attribs); |
| 2915 DoGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS, |
| 2916 &caps.max_transform_feedback_separate_components); |
| 2917 DoGetIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE, &caps.max_uniform_block_size); |
2878 DoGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, | 2918 DoGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, |
2879 &caps.max_uniform_buffer_bindings); | 2919 &caps.max_uniform_buffer_bindings); |
| 2920 DoGetIntegerv(GL_MAX_VARYING_COMPONENTS, &caps.max_varying_components); |
| 2921 DoGetIntegerv(GL_MAX_VERTEX_OUTPUT_COMPONENTS, |
| 2922 &caps.max_vertex_output_components); |
| 2923 DoGetIntegerv(GL_MAX_VERTEX_UNIFORM_BLOCKS, |
| 2924 &caps.max_vertex_uniform_blocks); |
| 2925 DoGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS, |
| 2926 &caps.max_vertex_uniform_components); |
| 2927 DoGetIntegerv(GL_MIN_PROGRAM_TEXEL_OFFSET, &caps.min_program_texel_offset); |
| 2928 DoGetIntegerv(GL_NUM_EXTENSIONS, &caps.num_extensions); |
| 2929 DoGetIntegerv(GL_NUM_PROGRAM_BINARY_FORMATS, |
| 2930 &caps.num_program_binary_formats); |
2880 DoGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, | 2931 DoGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, |
2881 &caps.uniform_buffer_offset_alignment); | 2932 &caps.uniform_buffer_offset_alignment); |
| 2933 // TODO(zmo): once we switch to MANGLE, we should query version numbers. |
| 2934 caps.major_version = 3; |
| 2935 caps.minor_version = 0; |
2882 } | 2936 } |
2883 | 2937 |
2884 caps.egl_image_external = | 2938 caps.egl_image_external = |
2885 feature_info_->feature_flags().oes_egl_image_external; | 2939 feature_info_->feature_flags().oes_egl_image_external; |
2886 caps.texture_format_atc = | 2940 caps.texture_format_atc = |
2887 feature_info_->feature_flags().ext_texture_format_atc; | 2941 feature_info_->feature_flags().ext_texture_format_atc; |
2888 caps.texture_format_bgra8888 = | 2942 caps.texture_format_bgra8888 = |
2889 feature_info_->feature_flags().ext_texture_format_bgra8888; | 2943 feature_info_->feature_flags().ext_texture_format_bgra8888; |
2890 caps.texture_format_dxt1 = | 2944 caps.texture_format_dxt1 = |
2891 feature_info_->feature_flags().ext_texture_format_dxt1; | 2945 feature_info_->feature_flags().ext_texture_format_dxt1; |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3248 } | 3302 } |
3249 } | 3303 } |
3250 } | 3304 } |
3251 | 3305 |
3252 // } // anonymous namespace | 3306 // } // anonymous namespace |
3253 | 3307 |
3254 bool GLES2DecoderImpl::MakeCurrent() { | 3308 bool GLES2DecoderImpl::MakeCurrent() { |
3255 if (!context_.get()) | 3309 if (!context_.get()) |
3256 return false; | 3310 return false; |
3257 | 3311 |
3258 if (!context_->MakeCurrent(surface_.get()) || WasContextLost()) { | 3312 if (WasContextLost()) { |
3259 LOG(ERROR) << " GLES2DecoderImpl: Context lost during MakeCurrent."; | 3313 LOG(ERROR) << " GLES2DecoderImpl: Trying to make lost context current."; |
3260 | |
3261 MaybeExitOnContextLost(); | |
3262 | |
3263 return false; | 3314 return false; |
3264 } | 3315 } |
3265 | 3316 |
| 3317 if (!context_->MakeCurrent(surface_.get())) { |
| 3318 LOG(ERROR) << " GLES2DecoderImpl: Context lost during MakeCurrent."; |
| 3319 MarkContextLost(error::kMakeCurrentFailed); |
| 3320 group_->LoseContexts(error::kUnknown); |
| 3321 return false; |
| 3322 } |
| 3323 |
| 3324 if (CheckResetStatus()) { |
| 3325 LOG(ERROR) |
| 3326 << " GLES2DecoderImpl: Context reset detected after MakeCurrent."; |
| 3327 group_->LoseContexts(error::kUnknown); |
| 3328 return false; |
| 3329 } |
| 3330 |
3266 ProcessFinishedAsyncTransfers(); | 3331 ProcessFinishedAsyncTransfers(); |
3267 | 3332 |
3268 // Rebind the FBO if it was unbound by the context. | 3333 // Rebind the FBO if it was unbound by the context. |
3269 if (workarounds().unbind_fbo_on_context_switch) | 3334 if (workarounds().unbind_fbo_on_context_switch) |
3270 RestoreFramebufferBindings(); | 3335 RestoreFramebufferBindings(); |
3271 | 3336 |
3272 framebuffer_state_.clear_state_dirty = true; | 3337 framebuffer_state_.clear_state_dirty = true; |
3273 | 3338 |
3274 return true; | 3339 return true; |
3275 } | 3340 } |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3747 | 3812 |
3748 // Need to release these before releasing |group_| which may own the | 3813 // Need to release these before releasing |group_| which may own the |
3749 // ShaderTranslatorCache. | 3814 // ShaderTranslatorCache. |
3750 fragment_translator_ = NULL; | 3815 fragment_translator_ = NULL; |
3751 vertex_translator_ = NULL; | 3816 vertex_translator_ = NULL; |
3752 | 3817 |
3753 // Should destroy the transfer manager before the texture manager held | 3818 // Should destroy the transfer manager before the texture manager held |
3754 // by the context group. | 3819 // by the context group. |
3755 async_pixel_transfer_manager_.reset(); | 3820 async_pixel_transfer_manager_.reset(); |
3756 | 3821 |
| 3822 // Destroy the GPU Tracer which may own some in process GPU Timings. |
| 3823 if (gpu_tracer_) { |
| 3824 gpu_tracer_->Destroy(have_context); |
| 3825 gpu_tracer_.reset(); |
| 3826 } |
| 3827 |
3757 if (group_.get()) { | 3828 if (group_.get()) { |
3758 framebuffer_manager()->RemoveObserver(this); | 3829 framebuffer_manager()->RemoveObserver(this); |
3759 group_->Destroy(this, have_context); | 3830 group_->Destroy(this, have_context); |
3760 group_ = NULL; | 3831 group_ = NULL; |
3761 } | 3832 } |
3762 | 3833 |
3763 if (context_.get()) { | 3834 if (context_.get()) { |
3764 context_->ReleaseCurrent(NULL); | 3835 context_->ReleaseCurrent(NULL); |
3765 context_ = NULL; | 3836 context_ = NULL; |
3766 } | 3837 } |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4288 } | 4359 } |
4289 } | 4360 } |
4290 | 4361 |
4291 void GLES2DecoderImpl::ClearAllAttributes() const { | 4362 void GLES2DecoderImpl::ClearAllAttributes() const { |
4292 // Must use native VAO 0, as RestoreAllAttributes can't fully restore | 4363 // Must use native VAO 0, as RestoreAllAttributes can't fully restore |
4293 // other VAOs. | 4364 // other VAOs. |
4294 if (feature_info_->feature_flags().native_vertex_array_object) | 4365 if (feature_info_->feature_flags().native_vertex_array_object) |
4295 glBindVertexArrayOES(0); | 4366 glBindVertexArrayOES(0); |
4296 | 4367 |
4297 for (uint32 i = 0; i < group_->max_vertex_attribs(); ++i) { | 4368 for (uint32 i = 0; i < group_->max_vertex_attribs(); ++i) { |
4298 if (i != 0) // Never disable attribute 0 | 4369 if (i != 0) // Never disable attribute 0 |
4299 glDisableVertexAttribArray(i); | 4370 glDisableVertexAttribArray(i); |
4300 if(features().angle_instanced_arrays) | 4371 if (features().angle_instanced_arrays) |
4301 glVertexAttribDivisorANGLE(i, 0); | 4372 glVertexAttribDivisorANGLE(i, 0); |
4302 } | 4373 } |
4303 } | 4374 } |
4304 | 4375 |
4305 void GLES2DecoderImpl::RestoreAllAttributes() const { | 4376 void GLES2DecoderImpl::RestoreAllAttributes() const { |
4306 state_.RestoreVertexAttribs(); | 4377 state_.RestoreVertexAttribs(); |
4307 } | 4378 } |
4308 | 4379 |
4309 void GLES2DecoderImpl::SetIgnoreCachedStateForTest(bool ignore) { | 4380 void GLES2DecoderImpl::SetIgnoreCachedStateForTest(bool ignore) { |
4310 state_.SetIgnoreCachedStateForTest(ignore); | 4381 state_.SetIgnoreCachedStateForTest(ignore); |
4311 } | 4382 } |
4312 | 4383 |
4313 void GLES2DecoderImpl::OnFboChanged() const { | 4384 void GLES2DecoderImpl::OnFboChanged() const { |
4314 if (workarounds().restore_scissor_on_fbo_change) | 4385 if (workarounds().restore_scissor_on_fbo_change) |
4315 state_.fbo_binding_for_scissor_workaround_dirty_ = true; | 4386 state_.fbo_binding_for_scissor_workaround_dirty = true; |
4316 | 4387 |
4317 if (workarounds().gl_begin_gl_end_on_fbo_change_to_backbuffer) { | 4388 if (workarounds().gl_begin_gl_end_on_fbo_change_to_backbuffer) { |
4318 GLint bound_fbo_unsigned = -1; | 4389 GLint bound_fbo_unsigned = -1; |
4319 glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &bound_fbo_unsigned); | 4390 glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &bound_fbo_unsigned); |
4320 GLuint bound_fbo = static_cast<GLuint>(bound_fbo_unsigned); | 4391 GLuint bound_fbo = static_cast<GLuint>(bound_fbo_unsigned); |
4321 if (surface_ && surface_->GetBackingFrameBufferObject() == bound_fbo) | 4392 if (surface_ && surface_->GetBackingFrameBufferObject() == bound_fbo) |
4322 surface_->NotifyWasBound(); | 4393 surface_->NotifyWasBound(); |
4323 } | 4394 } |
4324 } | 4395 } |
4325 | 4396 |
4326 // Called after the FBO is checked for completeness. | 4397 // Called after the FBO is checked for completeness. |
4327 void GLES2DecoderImpl::OnUseFramebuffer() const { | 4398 void GLES2DecoderImpl::OnUseFramebuffer() const { |
4328 if (state_.fbo_binding_for_scissor_workaround_dirty_) { | 4399 if (state_.fbo_binding_for_scissor_workaround_dirty) { |
4329 state_.fbo_binding_for_scissor_workaround_dirty_ = false; | 4400 state_.fbo_binding_for_scissor_workaround_dirty = false; |
4330 // The driver forgets the correct scissor when modifying the FBO binding. | 4401 // The driver forgets the correct scissor when modifying the FBO binding. |
4331 glScissor(state_.scissor_x, | 4402 glScissor(state_.scissor_x, |
4332 state_.scissor_y, | 4403 state_.scissor_y, |
4333 state_.scissor_width, | 4404 state_.scissor_width, |
4334 state_.scissor_height); | 4405 state_.scissor_height); |
4335 | 4406 |
4336 // crbug.com/222018 - Also on QualComm, the flush here avoids flicker, | 4407 // crbug.com/222018 - Also on QualComm, the flush here avoids flicker, |
4337 // it's unclear how this bug works. | 4408 // it's unclear how this bug works. |
4338 glFlush(); | 4409 glFlush(); |
4339 } | 4410 } |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4484 } else { | 4555 } else { |
4485 LOCAL_SET_GL_ERROR( | 4556 LOCAL_SET_GL_ERROR( |
4486 GL_INVALID_VALUE, | 4557 GL_INVALID_VALUE, |
4487 "glDisableVertexAttribArray", "index out of range"); | 4558 "glDisableVertexAttribArray", "index out of range"); |
4488 } | 4559 } |
4489 } | 4560 } |
4490 | 4561 |
4491 void GLES2DecoderImpl::DoDiscardFramebufferEXT(GLenum target, | 4562 void GLES2DecoderImpl::DoDiscardFramebufferEXT(GLenum target, |
4492 GLsizei numAttachments, | 4563 GLsizei numAttachments, |
4493 const GLenum* attachments) { | 4564 const GLenum* attachments) { |
| 4565 if (workarounds().disable_discard_framebuffer) |
| 4566 return; |
| 4567 |
4494 Framebuffer* framebuffer = | 4568 Framebuffer* framebuffer = |
4495 GetFramebufferInfoForTarget(GL_FRAMEBUFFER); | 4569 GetFramebufferInfoForTarget(GL_FRAMEBUFFER); |
4496 | 4570 |
4497 // Validates the attachments. If one of them fails | 4571 // Validates the attachments. If one of them fails |
4498 // the whole command fails. | 4572 // the whole command fails. |
4499 for (GLsizei i = 0; i < numAttachments; ++i) { | 4573 for (GLsizei i = 0; i < numAttachments; ++i) { |
4500 if ((framebuffer && | 4574 if ((framebuffer && |
4501 !validators_->attachment.IsValid(attachments[i])) || | 4575 !validators_->attachment.IsValid(attachments[i])) || |
4502 (!framebuffer && | 4576 (!framebuffer && |
4503 !validators_->backbuffer_attachment.IsValid(attachments[i]))) { | 4577 !validators_->backbuffer_attachment.IsValid(attachments[i]))) { |
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5024 for (GLsizei ii = 0; ii < num_written; ++ii) { | 5098 for (GLsizei ii = 0; ii < num_written; ++ii) { |
5025 params[ii] = static_cast<GLfloat>(values[ii]); | 5099 params[ii] = static_cast<GLfloat>(values[ii]); |
5026 } | 5100 } |
5027 } else { | 5101 } else { |
5028 pname = AdjustGetPname(pname); | 5102 pname = AdjustGetPname(pname); |
5029 glGetFloatv(pname, params); | 5103 glGetFloatv(pname, params); |
5030 } | 5104 } |
5031 } | 5105 } |
5032 } | 5106 } |
5033 | 5107 |
| 5108 void GLES2DecoderImpl::DoGetInteger64v(GLenum pname, GLint64* params) { |
| 5109 DCHECK(params); |
| 5110 pname = AdjustGetPname(pname); |
| 5111 glGetInteger64v(pname, params); |
| 5112 } |
| 5113 |
5034 void GLES2DecoderImpl::DoGetIntegerv(GLenum pname, GLint* params) { | 5114 void GLES2DecoderImpl::DoGetIntegerv(GLenum pname, GLint* params) { |
5035 DCHECK(params); | 5115 DCHECK(params); |
5036 GLsizei num_written; | 5116 GLsizei num_written; |
5037 if (!state_.GetStateAsGLint(pname, params, &num_written) && | 5117 if (!state_.GetStateAsGLint(pname, params, &num_written) && |
5038 !GetHelper(pname, params, &num_written)) { | 5118 !GetHelper(pname, params, &num_written)) { |
5039 pname = AdjustGetPname(pname); | 5119 pname = AdjustGetPname(pname); |
5040 glGetIntegerv(pname, params); | 5120 glGetIntegerv(pname, params); |
5041 } | 5121 } |
5042 } | 5122 } |
5043 | 5123 |
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5658 GLenum impl_format = | 5738 GLenum impl_format = |
5659 renderbuffer_manager()->InternalRenderbufferFormatToImplFormat( | 5739 renderbuffer_manager()->InternalRenderbufferFormatToImplFormat( |
5660 internalformat); | 5740 internalformat); |
5661 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER( | 5741 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER( |
5662 "glRenderbufferStorageMultisampleCHROMIUM"); | 5742 "glRenderbufferStorageMultisampleCHROMIUM"); |
5663 RenderbufferStorageMultisampleHelper( | 5743 RenderbufferStorageMultisampleHelper( |
5664 feature_info_.get(), target, samples, impl_format, width, height); | 5744 feature_info_.get(), target, samples, impl_format, width, height); |
5665 GLenum error = | 5745 GLenum error = |
5666 LOCAL_PEEK_GL_ERROR("glRenderbufferStorageMultisampleCHROMIUM"); | 5746 LOCAL_PEEK_GL_ERROR("glRenderbufferStorageMultisampleCHROMIUM"); |
5667 if (error == GL_NO_ERROR) { | 5747 if (error == GL_NO_ERROR) { |
5668 | |
5669 if (workarounds().validate_multisample_buffer_allocation) { | 5748 if (workarounds().validate_multisample_buffer_allocation) { |
5670 if (!VerifyMultisampleRenderbufferIntegrity( | 5749 if (!VerifyMultisampleRenderbufferIntegrity( |
5671 renderbuffer->service_id(), impl_format)) { | 5750 renderbuffer->service_id(), impl_format)) { |
5672 LOCAL_SET_GL_ERROR( | 5751 LOCAL_SET_GL_ERROR( |
5673 GL_OUT_OF_MEMORY, | 5752 GL_OUT_OF_MEMORY, |
5674 "glRenderbufferStorageMultisampleCHROMIUM", "out of memory"); | 5753 "glRenderbufferStorageMultisampleCHROMIUM", "out of memory"); |
5675 return; | 5754 return; |
5676 } | 5755 } |
5677 } | 5756 } |
5678 | 5757 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5726 // This function validates the allocation of a multisampled renderbuffer | 5805 // This function validates the allocation of a multisampled renderbuffer |
5727 // by clearing it to a key color, blitting the contents to a texture, and | 5806 // by clearing it to a key color, blitting the contents to a texture, and |
5728 // reading back the color to ensure it matches the key. | 5807 // reading back the color to ensure it matches the key. |
5729 bool GLES2DecoderImpl::VerifyMultisampleRenderbufferIntegrity( | 5808 bool GLES2DecoderImpl::VerifyMultisampleRenderbufferIntegrity( |
5730 GLuint renderbuffer, GLenum format) { | 5809 GLuint renderbuffer, GLenum format) { |
5731 | 5810 |
5732 // Only validate color buffers. | 5811 // Only validate color buffers. |
5733 // These formats have been selected because they are very common or are known | 5812 // These formats have been selected because they are very common or are known |
5734 // to be used by the WebGL backbuffer. If problems are observed with other | 5813 // to be used by the WebGL backbuffer. If problems are observed with other |
5735 // color formats they can be added here. | 5814 // color formats they can be added here. |
5736 switch(format) { | 5815 switch (format) { |
5737 case GL_RGB: | 5816 case GL_RGB: |
5738 case GL_RGB8: | 5817 case GL_RGB8: |
5739 case GL_RGBA: | 5818 case GL_RGBA: |
5740 case GL_RGBA8: | 5819 case GL_RGBA8: |
5741 break; | 5820 break; |
5742 default: | 5821 default: |
5743 return true; | 5822 return true; |
5744 } | 5823 } |
5745 | 5824 |
5746 GLint draw_framebuffer, read_framebuffer; | 5825 GLint draw_framebuffer, read_framebuffer; |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5892 if (workarounds().use_current_program_after_successful_link) | 5971 if (workarounds().use_current_program_after_successful_link) |
5893 glUseProgram(program->service_id()); | 5972 glUseProgram(program->service_id()); |
5894 if (workarounds().clear_uniforms_before_first_program_use) | 5973 if (workarounds().clear_uniforms_before_first_program_use) |
5895 program_manager()->ClearUniforms(program); | 5974 program_manager()->ClearUniforms(program); |
5896 } | 5975 } |
5897 } | 5976 } |
5898 | 5977 |
5899 // LinkProgram can be very slow. Exit command processing to allow for | 5978 // LinkProgram can be very slow. Exit command processing to allow for |
5900 // context preemption and GPU watchdog checks. | 5979 // context preemption and GPU watchdog checks. |
5901 ExitCommandProcessingEarly(); | 5980 ExitCommandProcessingEarly(); |
5902 }; | 5981 } |
5903 | 5982 |
5904 void GLES2DecoderImpl::DoSamplerParameterfv( | 5983 void GLES2DecoderImpl::DoSamplerParameterfv( |
5905 GLuint sampler, GLenum pname, const GLfloat* params) { | 5984 GLuint sampler, GLenum pname, const GLfloat* params) { |
5906 DCHECK(params); | 5985 DCHECK(params); |
5907 glSamplerParameterf(sampler, pname, params[0]); | 5986 glSamplerParameterf(sampler, pname, params[0]); |
5908 } | 5987 } |
5909 | 5988 |
5910 void GLES2DecoderImpl::DoSamplerParameteriv( | 5989 void GLES2DecoderImpl::DoSamplerParameteriv( |
5911 GLuint sampler, GLenum pname, const GLint* params) { | 5990 GLuint sampler, GLenum pname, const GLint* params) { |
5912 DCHECK(params); | 5991 DCHECK(params); |
(...skipping 980 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6893 // it in each draw call, and attrib 0 generic data queries use cached | 6972 // it in each draw call, and attrib 0 generic data queries use cached |
6894 // values instead of passing down to the underlying driver. | 6973 // values instead of passing down to the underlying driver. |
6895 RestoreStateForAttrib(0, false); | 6974 RestoreStateForAttrib(0, false); |
6896 } | 6975 } |
6897 } | 6976 } |
6898 return error::kNoError; | 6977 return error::kNoError; |
6899 } | 6978 } |
6900 | 6979 |
6901 error::Error GLES2DecoderImpl::HandleDrawArrays(uint32 immediate_data_size, | 6980 error::Error GLES2DecoderImpl::HandleDrawArrays(uint32 immediate_data_size, |
6902 const void* cmd_data) { | 6981 const void* cmd_data) { |
| 6982 // TODO(zmo): crbug.com/481184 |
| 6983 // On Desktop GL with versions lower than 4.3, we need to emulate |
| 6984 // GL_PRIMITIVE_RESTART_FIXED_INDEX using glPrimitiveRestartIndex(). |
6903 const cmds::DrawArrays& c = *static_cast<const cmds::DrawArrays*>(cmd_data); | 6985 const cmds::DrawArrays& c = *static_cast<const cmds::DrawArrays*>(cmd_data); |
6904 return DoDrawArrays("glDrawArrays", | 6986 return DoDrawArrays("glDrawArrays", |
6905 false, | 6987 false, |
6906 static_cast<GLenum>(c.mode), | 6988 static_cast<GLenum>(c.mode), |
6907 static_cast<GLint>(c.first), | 6989 static_cast<GLint>(c.first), |
6908 static_cast<GLsizei>(c.count), | 6990 static_cast<GLsizei>(c.count), |
6909 1); | 6991 1); |
6910 } | 6992 } |
6911 | 6993 |
6912 error::Error GLES2DecoderImpl::HandleDrawArraysInstancedANGLE( | 6994 error::Error GLES2DecoderImpl::HandleDrawArraysInstancedANGLE( |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7036 // it in each draw call, and attrib 0 generic data queries use cached | 7118 // it in each draw call, and attrib 0 generic data queries use cached |
7037 // values instead of passing down to the underlying driver. | 7119 // values instead of passing down to the underlying driver. |
7038 RestoreStateForAttrib(0, false); | 7120 RestoreStateForAttrib(0, false); |
7039 } | 7121 } |
7040 } | 7122 } |
7041 return error::kNoError; | 7123 return error::kNoError; |
7042 } | 7124 } |
7043 | 7125 |
7044 error::Error GLES2DecoderImpl::HandleDrawElements(uint32 immediate_data_size, | 7126 error::Error GLES2DecoderImpl::HandleDrawElements(uint32 immediate_data_size, |
7045 const void* cmd_data) { | 7127 const void* cmd_data) { |
| 7128 // TODO(zmo): crbug.com/481184 |
| 7129 // On Desktop GL with versions lower than 4.3, we need to emulate |
| 7130 // GL_PRIMITIVE_RESTART_FIXED_INDEX using glPrimitiveRestartIndex(). |
7046 const gles2::cmds::DrawElements& c = | 7131 const gles2::cmds::DrawElements& c = |
7047 *static_cast<const gles2::cmds::DrawElements*>(cmd_data); | 7132 *static_cast<const gles2::cmds::DrawElements*>(cmd_data); |
7048 return DoDrawElements("glDrawElements", | 7133 return DoDrawElements("glDrawElements", |
7049 false, | 7134 false, |
7050 static_cast<GLenum>(c.mode), | 7135 static_cast<GLenum>(c.mode), |
7051 static_cast<GLsizei>(c.count), | 7136 static_cast<GLsizei>(c.count), |
7052 static_cast<GLenum>(c.type), | 7137 static_cast<GLenum>(c.type), |
7053 static_cast<int32>(c.index_offset), | 7138 static_cast<int32>(c.index_offset), |
7054 1); | 7139 1); |
7055 } | 7140 } |
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7541 | 7626 |
7542 void GLES2DecoderImpl::DoVertexAttrib4fv(GLuint index, const GLfloat* v) { | 7627 void GLES2DecoderImpl::DoVertexAttrib4fv(GLuint index, const GLfloat* v) { |
7543 if (SetVertexAttribValue("glVertexAttrib4fv", index, v)) { | 7628 if (SetVertexAttribValue("glVertexAttrib4fv", index, v)) { |
7544 glVertexAttrib4fv(index, v); | 7629 glVertexAttrib4fv(index, v); |
7545 } | 7630 } |
7546 } | 7631 } |
7547 | 7632 |
7548 error::Error GLES2DecoderImpl::HandleVertexAttribIPointer( | 7633 error::Error GLES2DecoderImpl::HandleVertexAttribIPointer( |
7549 uint32 immediate_data_size, | 7634 uint32 immediate_data_size, |
7550 const void* cmd_data) { | 7635 const void* cmd_data) { |
7551 // TODO(zmo): Unsafe ES3 API, missing states update. | |
7552 if (!unsafe_es3_apis_enabled()) | 7636 if (!unsafe_es3_apis_enabled()) |
7553 return error::kUnknownCommand; | 7637 return error::kUnknownCommand; |
7554 const gles2::cmds::VertexAttribIPointer& c = | 7638 const gles2::cmds::VertexAttribIPointer& c = |
7555 *static_cast<const gles2::cmds::VertexAttribIPointer*>(cmd_data); | 7639 *static_cast<const gles2::cmds::VertexAttribIPointer*>(cmd_data); |
| 7640 |
| 7641 if (!state_.bound_array_buffer.get() || |
| 7642 state_.bound_array_buffer->IsDeleted()) { |
| 7643 if (state_.vertex_attrib_manager.get() == |
| 7644 state_.default_vertex_attrib_manager.get()) { |
| 7645 LOCAL_SET_GL_ERROR( |
| 7646 GL_INVALID_VALUE, "glVertexAttribIPointer", "no array buffer bound"); |
| 7647 return error::kNoError; |
| 7648 } else if (c.offset != 0) { |
| 7649 LOCAL_SET_GL_ERROR( |
| 7650 GL_INVALID_VALUE, |
| 7651 "glVertexAttribIPointer", "client side arrays are not allowed"); |
| 7652 return error::kNoError; |
| 7653 } |
| 7654 } |
| 7655 |
7556 GLuint indx = c.indx; | 7656 GLuint indx = c.indx; |
7557 GLint size = c.size; | 7657 GLint size = c.size; |
7558 GLenum type = c.type; | 7658 GLenum type = c.type; |
7559 GLsizei stride = c.stride; | 7659 GLsizei stride = c.stride; |
7560 GLsizei offset = c.offset; | 7660 GLsizei offset = c.offset; |
7561 const void* ptr = reinterpret_cast<const void*>(offset); | 7661 const void* ptr = reinterpret_cast<const void*>(offset); |
| 7662 if (!validators_->vertex_attrib_i_type.IsValid(type)) { |
| 7663 LOCAL_SET_GL_ERROR_INVALID_ENUM("glVertexAttribIPointer", type, "type"); |
| 7664 return error::kNoError; |
| 7665 } |
| 7666 if (!validators_->vertex_attrib_size.IsValid(size)) { |
| 7667 LOCAL_SET_GL_ERROR( |
| 7668 GL_INVALID_VALUE, "glVertexAttribIPointer", "size GL_INVALID_VALUE"); |
| 7669 return error::kNoError; |
| 7670 } |
| 7671 if (indx >= group_->max_vertex_attribs()) { |
| 7672 LOCAL_SET_GL_ERROR( |
| 7673 GL_INVALID_VALUE, "glVertexAttribIPointer", "index out of range"); |
| 7674 return error::kNoError; |
| 7675 } |
| 7676 if (stride < 0) { |
| 7677 LOCAL_SET_GL_ERROR( |
| 7678 GL_INVALID_VALUE, "glVertexAttribIPointer", "stride < 0"); |
| 7679 return error::kNoError; |
| 7680 } |
| 7681 if (stride > 255) { |
| 7682 LOCAL_SET_GL_ERROR( |
| 7683 GL_INVALID_VALUE, "glVertexAttribIPointer", "stride > 255"); |
| 7684 return error::kNoError; |
| 7685 } |
| 7686 if (offset < 0) { |
| 7687 LOCAL_SET_GL_ERROR( |
| 7688 GL_INVALID_VALUE, "glVertexAttribIPointer", "offset < 0"); |
| 7689 return error::kNoError; |
| 7690 } |
| 7691 GLsizei component_size = |
| 7692 GLES2Util::GetGLTypeSizeForTexturesAndBuffers(type); |
| 7693 // component_size must be a power of two to use & as optimized modulo. |
| 7694 DCHECK(GLES2Util::IsPOT(component_size)); |
| 7695 if (offset & (component_size - 1)) { |
| 7696 LOCAL_SET_GL_ERROR( |
| 7697 GL_INVALID_OPERATION, |
| 7698 "glVertexAttribIPointer", "offset not valid for type"); |
| 7699 return error::kNoError; |
| 7700 } |
| 7701 if (stride & (component_size - 1)) { |
| 7702 LOCAL_SET_GL_ERROR( |
| 7703 GL_INVALID_OPERATION, |
| 7704 "glVertexAttribIPointer", "stride not valid for type"); |
| 7705 return error::kNoError; |
| 7706 } |
| 7707 state_.vertex_attrib_manager |
| 7708 ->SetAttribInfo(indx, |
| 7709 state_.bound_array_buffer.get(), |
| 7710 size, |
| 7711 type, |
| 7712 GL_FALSE, |
| 7713 stride, |
| 7714 stride != 0 ? stride : component_size * size, |
| 7715 offset); |
7562 glVertexAttribIPointer(indx, size, type, stride, ptr); | 7716 glVertexAttribIPointer(indx, size, type, stride, ptr); |
7563 return error::kNoError; | 7717 return error::kNoError; |
7564 } | 7718 } |
7565 | 7719 |
7566 error::Error GLES2DecoderImpl::HandleVertexAttribPointer( | 7720 error::Error GLES2DecoderImpl::HandleVertexAttribPointer( |
7567 uint32 immediate_data_size, | 7721 uint32 immediate_data_size, |
7568 const void* cmd_data) { | 7722 const void* cmd_data) { |
7569 const gles2::cmds::VertexAttribPointer& c = | 7723 const gles2::cmds::VertexAttribPointer& c = |
7570 *static_cast<const gles2::cmds::VertexAttribPointer*>(cmd_data); | 7724 *static_cast<const gles2::cmds::VertexAttribPointer*>(cmd_data); |
7571 | 7725 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7638 } | 7792 } |
7639 state_.vertex_attrib_manager | 7793 state_.vertex_attrib_manager |
7640 ->SetAttribInfo(indx, | 7794 ->SetAttribInfo(indx, |
7641 state_.bound_array_buffer.get(), | 7795 state_.bound_array_buffer.get(), |
7642 size, | 7796 size, |
7643 type, | 7797 type, |
7644 normalized, | 7798 normalized, |
7645 stride, | 7799 stride, |
7646 stride != 0 ? stride : component_size * size, | 7800 stride != 0 ? stride : component_size * size, |
7647 offset); | 7801 offset); |
7648 if (type != GL_FIXED) { | 7802 // We support GL_FIXED natively on EGL/GLES2 implementations |
| 7803 if (type != GL_FIXED || feature_info_->gl_version_info().is_es) { |
7649 glVertexAttribPointer(indx, size, type, normalized, stride, ptr); | 7804 glVertexAttribPointer(indx, size, type, normalized, stride, ptr); |
7650 } | 7805 } |
7651 return error::kNoError; | 7806 return error::kNoError; |
7652 } | 7807 } |
7653 | 7808 |
7654 void GLES2DecoderImpl::DoViewport(GLint x, GLint y, GLsizei width, | 7809 void GLES2DecoderImpl::DoViewport(GLint x, GLint y, GLsizei width, |
7655 GLsizei height) { | 7810 GLsizei height) { |
7656 state_.viewport_x = x; | 7811 state_.viewport_x = x; |
7657 state_.viewport_y = y; | 7812 state_.viewport_y = y; |
7658 state_.viewport_width = std::min(width, viewport_max_width_); | 7813 state_.viewport_width = std::min(width, viewport_max_width_); |
(...skipping 23 matching lines...) Expand all Loading... |
7682 | 7837 |
7683 state_.vertex_attrib_manager->SetDivisor( | 7838 state_.vertex_attrib_manager->SetDivisor( |
7684 index, | 7839 index, |
7685 divisor); | 7840 divisor); |
7686 glVertexAttribDivisorANGLE(index, divisor); | 7841 glVertexAttribDivisorANGLE(index, divisor); |
7687 return error::kNoError; | 7842 return error::kNoError; |
7688 } | 7843 } |
7689 | 7844 |
7690 template <typename pixel_data_type> | 7845 template <typename pixel_data_type> |
7691 static void WriteAlphaData( | 7846 static void WriteAlphaData( |
7692 void *pixels, uint32 row_count, uint32 channel_count, | 7847 void* pixels, uint32 row_count, uint32 channel_count, |
7693 uint32 alpha_channel_index, uint32 unpadded_row_size, | 7848 uint32 alpha_channel_index, uint32 unpadded_row_size, |
7694 uint32 padded_row_size, pixel_data_type alpha_value) { | 7849 uint32 padded_row_size, pixel_data_type alpha_value) { |
7695 DCHECK_GT(channel_count, 0U); | 7850 DCHECK_GT(channel_count, 0U); |
7696 DCHECK_EQ(unpadded_row_size % sizeof(pixel_data_type), 0U); | 7851 DCHECK_EQ(unpadded_row_size % sizeof(pixel_data_type), 0U); |
7697 uint32 unpadded_row_size_in_elements = | 7852 uint32 unpadded_row_size_in_elements = |
7698 unpadded_row_size / sizeof(pixel_data_type); | 7853 unpadded_row_size / sizeof(pixel_data_type); |
7699 DCHECK_EQ(padded_row_size % sizeof(pixel_data_type), 0U); | 7854 DCHECK_EQ(padded_row_size % sizeof(pixel_data_type), 0U); |
7700 uint32 padded_row_size_in_elements = | 7855 uint32 padded_row_size_in_elements = |
7701 padded_row_size / sizeof(pixel_data_type); | 7856 padded_row_size / sizeof(pixel_data_type); |
7702 pixel_data_type* dst = | 7857 pixel_data_type* dst = |
(...skipping 2426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10129 offscreen_saved_color_texture_->AllocateStorage( | 10284 offscreen_saved_color_texture_->AllocateStorage( |
10130 offscreen_size_, offscreen_saved_color_format_, false); | 10285 offscreen_size_, offscreen_saved_color_format_, false); |
10131 | 10286 |
10132 offscreen_saved_frame_buffer_->AttachRenderTexture( | 10287 offscreen_saved_frame_buffer_->AttachRenderTexture( |
10133 offscreen_saved_color_texture_.get()); | 10288 offscreen_saved_color_texture_.get()); |
10134 if (offscreen_size_.width() != 0 && offscreen_size_.height() != 0) { | 10289 if (offscreen_size_.width() != 0 && offscreen_size_.height() != 0) { |
10135 if (offscreen_saved_frame_buffer_->CheckStatus() != | 10290 if (offscreen_saved_frame_buffer_->CheckStatus() != |
10136 GL_FRAMEBUFFER_COMPLETE) { | 10291 GL_FRAMEBUFFER_COMPLETE) { |
10137 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed " | 10292 LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFrameBuffer failed " |
10138 << "because offscreen saved FBO was incomplete."; | 10293 << "because offscreen saved FBO was incomplete."; |
10139 LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB); | 10294 MarkContextLost(error::kUnknown); |
| 10295 group_->LoseContexts(error::kUnknown); |
10140 return; | 10296 return; |
10141 } | 10297 } |
10142 | 10298 |
10143 // Clear the offscreen color texture. | 10299 // Clear the offscreen color texture. |
10144 // TODO(piman): Is this still necessary? | 10300 // TODO(piman): Is this still necessary? |
10145 { | 10301 { |
10146 ScopedFrameBufferBinder binder(this, | 10302 ScopedFrameBufferBinder binder(this, |
10147 offscreen_saved_frame_buffer_->id()); | 10303 offscreen_saved_frame_buffer_->id()); |
10148 glClearColor(0, 0, 0, 0); | 10304 glClearColor(0, 0, 0, 0); |
10149 state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); | 10305 state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10186 | 10342 |
10187 // Ensure the side effects of the copy are visible to the parent | 10343 // Ensure the side effects of the copy are visible to the parent |
10188 // context. There is no need to do this for ANGLE because it uses a | 10344 // context. There is no need to do this for ANGLE because it uses a |
10189 // single D3D device for all contexts. | 10345 // single D3D device for all contexts. |
10190 if (!feature_info_->gl_version_info().is_angle) | 10346 if (!feature_info_->gl_version_info().is_angle) |
10191 glFlush(); | 10347 glFlush(); |
10192 } | 10348 } |
10193 } else { | 10349 } else { |
10194 if (!surface_->SwapBuffers()) { | 10350 if (!surface_->SwapBuffers()) { |
10195 LOG(ERROR) << "Context lost because SwapBuffers failed."; | 10351 LOG(ERROR) << "Context lost because SwapBuffers failed."; |
10196 LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB); | 10352 if (!CheckResetStatus()) { |
| 10353 MarkContextLost(error::kUnknown); |
| 10354 group_->LoseContexts(error::kUnknown); |
| 10355 } |
10197 } | 10356 } |
10198 } | 10357 } |
10199 | 10358 |
10200 // This may be a slow command. Exit command processing to allow for | 10359 // This may be a slow command. Exit command processing to allow for |
10201 // context preemption and GPU watchdog checks. | 10360 // context preemption and GPU watchdog checks. |
10202 ExitCommandProcessingEarly(); | 10361 ExitCommandProcessingEarly(); |
10203 } | 10362 } |
10204 | 10363 |
10205 void GLES2DecoderImpl::DoSwapInterval(int interval) | 10364 void GLES2DecoderImpl::DoSwapInterval(int interval) { |
10206 { | |
10207 context_->SetSwapInterval(interval); | 10365 context_->SetSwapInterval(interval); |
10208 } | 10366 } |
10209 | 10367 |
10210 error::Error GLES2DecoderImpl::HandleEnableFeatureCHROMIUM( | 10368 error::Error GLES2DecoderImpl::HandleEnableFeatureCHROMIUM( |
10211 uint32 immediate_data_size, | 10369 uint32 immediate_data_size, |
10212 const void* cmd_data) { | 10370 const void* cmd_data) { |
10213 const gles2::cmds::EnableFeatureCHROMIUM& c = | 10371 const gles2::cmds::EnableFeatureCHROMIUM& c = |
10214 *static_cast<const gles2::cmds::EnableFeatureCHROMIUM*>(cmd_data); | 10372 *static_cast<const gles2::cmds::EnableFeatureCHROMIUM*>(cmd_data); |
10215 Bucket* bucket = GetBucket(c.bucket_id); | 10373 Bucket* bucket = GetBucket(c.bucket_id); |
10216 if (!bucket || bucket->size() == 0) { | 10374 if (!bucket || bucket->size() == 0) { |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10447 Program* program = NULL; | 10605 Program* program = NULL; |
10448 program = GetProgram(program_id); | 10606 program = GetProgram(program_id); |
10449 if (!program || !program->IsValid()) { | 10607 if (!program || !program->IsValid()) { |
10450 return error::kNoError; | 10608 return error::kNoError; |
10451 } | 10609 } |
10452 program->GetTransformFeedbackVaryings(bucket); | 10610 program->GetTransformFeedbackVaryings(bucket); |
10453 return error::kNoError; | 10611 return error::kNoError; |
10454 } | 10612 } |
10455 | 10613 |
10456 error::ContextLostReason GLES2DecoderImpl::GetContextLostReason() { | 10614 error::ContextLostReason GLES2DecoderImpl::GetContextLostReason() { |
10457 switch (reset_status_) { | 10615 return context_lost_reason_; |
| 10616 } |
| 10617 |
| 10618 error::ContextLostReason GLES2DecoderImpl::GetContextLostReasonFromResetStatus( |
| 10619 GLenum reset_status) const { |
| 10620 switch (reset_status) { |
10458 case GL_NO_ERROR: | 10621 case GL_NO_ERROR: |
10459 // TODO(kbr): improve the precision of the error code in this case. | 10622 // TODO(kbr): improve the precision of the error code in this case. |
10460 // Consider delegating to context for error code if MakeCurrent fails. | 10623 // Consider delegating to context for error code if MakeCurrent fails. |
10461 return error::kUnknown; | 10624 return error::kUnknown; |
10462 case GL_GUILTY_CONTEXT_RESET_ARB: | 10625 case GL_GUILTY_CONTEXT_RESET_ARB: |
10463 return error::kGuilty; | 10626 return error::kGuilty; |
10464 case GL_INNOCENT_CONTEXT_RESET_ARB: | 10627 case GL_INNOCENT_CONTEXT_RESET_ARB: |
10465 return error::kInnocent; | 10628 return error::kInnocent; |
10466 case GL_UNKNOWN_CONTEXT_RESET_ARB: | 10629 case GL_UNKNOWN_CONTEXT_RESET_ARB: |
10467 return error::kUnknown; | 10630 return error::kUnknown; |
10468 } | 10631 } |
10469 | 10632 |
10470 NOTREACHED(); | 10633 NOTREACHED(); |
10471 return error::kUnknown; | 10634 return error::kUnknown; |
10472 } | 10635 } |
10473 | 10636 |
10474 void GLES2DecoderImpl::MaybeExitOnContextLost() { | 10637 bool GLES2DecoderImpl::WasContextLost() const { |
| 10638 return context_was_lost_; |
| 10639 } |
| 10640 |
| 10641 bool GLES2DecoderImpl::WasContextLostByRobustnessExtension() const { |
| 10642 return WasContextLost() && reset_by_robustness_extension_; |
| 10643 } |
| 10644 |
| 10645 void GLES2DecoderImpl::MarkContextLost(error::ContextLostReason reason) { |
| 10646 // Only lose the context once. |
| 10647 if (WasContextLost()) |
| 10648 return; |
| 10649 |
| 10650 // Don't make GL calls in here, the context might not be current. |
| 10651 context_lost_reason_ = reason; |
| 10652 current_decoder_error_ = error::kLostContext; |
| 10653 context_was_lost_ = true; |
| 10654 |
10475 // Some D3D drivers cannot recover from device lost in the GPU process | 10655 // Some D3D drivers cannot recover from device lost in the GPU process |
10476 // sandbox. Allow a new GPU process to launch. | 10656 // sandbox. Allow a new GPU process to launch. |
10477 if (workarounds().exit_on_context_lost) { | 10657 if (workarounds().exit_on_context_lost) { |
10478 LOG(ERROR) << "Exiting GPU process because some drivers cannot reset" | 10658 LOG(ERROR) << "Exiting GPU process because some drivers cannot reset" |
10479 << " a D3D device in the Chrome GPU process sandbox."; | 10659 << " a D3D device in the Chrome GPU process sandbox."; |
10480 #if defined(OS_WIN) | 10660 #if defined(OS_WIN) |
10481 base::win::SetShouldCrashOnProcessDetach(false); | 10661 base::win::SetShouldCrashOnProcessDetach(false); |
10482 #endif | 10662 #endif |
10483 exit(0); | 10663 exit(0); |
10484 } | 10664 } |
10485 } | 10665 } |
10486 | 10666 |
10487 bool GLES2DecoderImpl::WasContextLost() { | 10667 bool GLES2DecoderImpl::CheckResetStatus() { |
10488 if (reset_status_ != GL_NO_ERROR) { | 10668 DCHECK(!WasContextLost()); |
10489 MaybeExitOnContextLost(); | 10669 DCHECK(context_->IsCurrent(NULL)); |
| 10670 |
| 10671 if (IsRobustnessSupported()) { |
| 10672 // If the reason for the call was a GL error, we can try to determine the |
| 10673 // reset status more accurately. |
| 10674 GLenum driver_status = glGetGraphicsResetStatusARB(); |
| 10675 if (driver_status == GL_NO_ERROR) |
| 10676 return false; |
| 10677 |
| 10678 LOG(ERROR) << (surface_->IsOffscreen() ? "Offscreen" : "Onscreen") |
| 10679 << " context lost via ARB/EXT_robustness. Reset status = " |
| 10680 << GLES2Util::GetStringEnum(driver_status); |
| 10681 |
| 10682 // Don't pretend we know which client was responsible. |
| 10683 if (workarounds().use_virtualized_gl_contexts) |
| 10684 driver_status = GL_UNKNOWN_CONTEXT_RESET_ARB; |
| 10685 |
| 10686 switch (driver_status) { |
| 10687 case GL_GUILTY_CONTEXT_RESET_ARB: |
| 10688 MarkContextLost(error::kGuilty); |
| 10689 break; |
| 10690 case GL_INNOCENT_CONTEXT_RESET_ARB: |
| 10691 MarkContextLost(error::kInnocent); |
| 10692 break; |
| 10693 case GL_UNKNOWN_CONTEXT_RESET_ARB: |
| 10694 MarkContextLost(error::kUnknown); |
| 10695 break; |
| 10696 default: |
| 10697 NOTREACHED(); |
| 10698 return false; |
| 10699 } |
| 10700 reset_by_robustness_extension_ = true; |
10490 return true; | 10701 return true; |
10491 } | 10702 } |
10492 if (IsRobustnessSupported()) { | |
10493 GLenum status = glGetGraphicsResetStatusARB(); | |
10494 if (status != GL_NO_ERROR) { | |
10495 // The graphics card was reset. Signal a lost context to the application. | |
10496 reset_status_ = status; | |
10497 reset_by_robustness_extension_ = true; | |
10498 LOG(ERROR) << (surface_->IsOffscreen() ? "Offscreen" : "Onscreen") | |
10499 << " context lost via ARB/EXT_robustness. Reset status = " | |
10500 << GLES2Util::GetStringEnum(status); | |
10501 MaybeExitOnContextLost(); | |
10502 return true; | |
10503 } | |
10504 } | |
10505 return false; | 10703 return false; |
10506 } | 10704 } |
10507 | 10705 |
10508 bool GLES2DecoderImpl::WasContextLostByRobustnessExtension() { | |
10509 return WasContextLost() && reset_by_robustness_extension_; | |
10510 } | |
10511 | |
10512 void GLES2DecoderImpl::LoseContext(uint32 reset_status) { | |
10513 // Only loses the context once. | |
10514 if (reset_status_ != GL_NO_ERROR) { | |
10515 return; | |
10516 } | |
10517 | |
10518 if (workarounds().use_virtualized_gl_contexts) { | |
10519 // If the context is virtual, the real context being guilty does not ensure | |
10520 // that the virtual context is guilty. | |
10521 if (reset_status == GL_GUILTY_CONTEXT_RESET_ARB) { | |
10522 reset_status = GL_UNKNOWN_CONTEXT_RESET_ARB; | |
10523 } | |
10524 } else if (reset_status == GL_UNKNOWN_CONTEXT_RESET_ARB && | |
10525 IsRobustnessSupported()) { | |
10526 // If the reason for the call was a GL error, we can try to determine the | |
10527 // reset status more accurately. | |
10528 GLenum driver_status = glGetGraphicsResetStatusARB(); | |
10529 if (driver_status == GL_GUILTY_CONTEXT_RESET_ARB || | |
10530 driver_status == GL_INNOCENT_CONTEXT_RESET_ARB) { | |
10531 reset_status = driver_status; | |
10532 } | |
10533 } | |
10534 | |
10535 // Marks this context as lost. | |
10536 reset_status_ = reset_status; | |
10537 current_decoder_error_ = error::kLostContext; | |
10538 } | |
10539 | |
10540 error::Error GLES2DecoderImpl::HandleInsertSyncPointCHROMIUM( | 10706 error::Error GLES2DecoderImpl::HandleInsertSyncPointCHROMIUM( |
10541 uint32 immediate_data_size, | 10707 uint32 immediate_data_size, |
10542 const void* cmd_data) { | 10708 const void* cmd_data) { |
10543 return error::kUnknownCommand; | 10709 return error::kUnknownCommand; |
10544 } | 10710 } |
10545 | 10711 |
10546 error::Error GLES2DecoderImpl::HandleWaitSyncPointCHROMIUM( | 10712 error::Error GLES2DecoderImpl::HandleWaitSyncPointCHROMIUM( |
10547 uint32 immediate_data_size, | 10713 uint32 immediate_data_size, |
10548 const void* cmd_data) { | 10714 const void* cmd_data) { |
10549 const gles2::cmds::WaitSyncPointCHROMIUM& c = | 10715 const gles2::cmds::WaitSyncPointCHROMIUM& c = |
(...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11559 break; | 11725 break; |
11560 case GL_TEXTURE_RECTANGLE_ARB: | 11726 case GL_TEXTURE_RECTANGLE_ARB: |
11561 unit.bound_texture_rectangle_arb = texture_ref; | 11727 unit.bound_texture_rectangle_arb = texture_ref; |
11562 break; | 11728 break; |
11563 default: | 11729 default: |
11564 NOTREACHED(); // Validation should prevent us getting here. | 11730 NOTREACHED(); // Validation should prevent us getting here. |
11565 break; | 11731 break; |
11566 } | 11732 } |
11567 } | 11733 } |
11568 | 11734 |
| 11735 void GLES2DecoderImpl::EnsureTextureForClientId( |
| 11736 GLenum target, |
| 11737 GLuint client_id) { |
| 11738 TextureRef* texture_ref = GetTexture(client_id); |
| 11739 if (!texture_ref) { |
| 11740 GLuint service_id; |
| 11741 glGenTextures(1, &service_id); |
| 11742 DCHECK_NE(0u, service_id); |
| 11743 texture_ref = CreateTexture(client_id, service_id); |
| 11744 texture_manager()->SetTarget(texture_ref, target); |
| 11745 glBindTexture(target, service_id); |
| 11746 RestoreCurrentTextureBindings(&state_, target); |
| 11747 } |
| 11748 } |
| 11749 |
| 11750 // If CreateAndConsumeTexture fails we still need to ensure that the client_id |
| 11751 // provided is associated with a service_id/TextureRef for consistency, even if |
| 11752 // the resulting texture is incomplete. |
11569 error::Error GLES2DecoderImpl::HandleCreateAndConsumeTextureCHROMIUMImmediate( | 11753 error::Error GLES2DecoderImpl::HandleCreateAndConsumeTextureCHROMIUMImmediate( |
11570 uint32_t immediate_data_size, | 11754 uint32_t immediate_data_size, |
11571 const void* cmd_data) { | 11755 const void* cmd_data) { |
11572 const gles2::cmds::CreateAndConsumeTextureCHROMIUMImmediate& c = | 11756 const gles2::cmds::CreateAndConsumeTextureCHROMIUMImmediate& c = |
11573 *static_cast< | 11757 *static_cast< |
11574 const gles2::cmds::CreateAndConsumeTextureCHROMIUMImmediate*>( | 11758 const gles2::cmds::CreateAndConsumeTextureCHROMIUMImmediate*>( |
11575 cmd_data); | 11759 cmd_data); |
11576 GLenum target = static_cast<GLenum>(c.target); | 11760 GLenum target = static_cast<GLenum>(c.target); |
11577 uint32_t data_size; | 11761 uint32_t data_size; |
11578 if (!ComputeDataSize(1, sizeof(GLbyte), 64, &data_size)) { | 11762 if (!ComputeDataSize(1, sizeof(GLbyte), 64, &data_size)) { |
(...skipping 22 matching lines...) Expand all Loading... |
11601 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoCreateAndConsumeTextureCHROMIUM", | 11785 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoCreateAndConsumeTextureCHROMIUM", |
11602 "context", logger_.GetLogPrefix(), | 11786 "context", logger_.GetLogPrefix(), |
11603 "mailbox[0]", static_cast<unsigned char>(data[0])); | 11787 "mailbox[0]", static_cast<unsigned char>(data[0])); |
11604 const Mailbox& mailbox = *reinterpret_cast<const Mailbox*>(data); | 11788 const Mailbox& mailbox = *reinterpret_cast<const Mailbox*>(data); |
11605 DLOG_IF(ERROR, !mailbox.Verify()) << "CreateAndConsumeTextureCHROMIUM was " | 11789 DLOG_IF(ERROR, !mailbox.Verify()) << "CreateAndConsumeTextureCHROMIUM was " |
11606 "passed a mailbox that was not " | 11790 "passed a mailbox that was not " |
11607 "generated by GenMailboxCHROMIUM."; | 11791 "generated by GenMailboxCHROMIUM."; |
11608 | 11792 |
11609 TextureRef* texture_ref = GetTexture(client_id); | 11793 TextureRef* texture_ref = GetTexture(client_id); |
11610 if (texture_ref) { | 11794 if (texture_ref) { |
| 11795 // No need to call EnsureTextureForClientId here, the client_id already has |
| 11796 // an associated texture. |
11611 LOCAL_SET_GL_ERROR( | 11797 LOCAL_SET_GL_ERROR( |
11612 GL_INVALID_OPERATION, | 11798 GL_INVALID_OPERATION, |
11613 "glCreateAndConsumeTextureCHROMIUM", "client id already in use"); | 11799 "glCreateAndConsumeTextureCHROMIUM", "client id already in use"); |
11614 return; | 11800 return; |
11615 } | 11801 } |
11616 Texture* texture = group_->mailbox_manager()->ConsumeTexture(mailbox); | 11802 Texture* texture = group_->mailbox_manager()->ConsumeTexture(mailbox); |
11617 if (!texture) { | 11803 if (!texture) { |
| 11804 EnsureTextureForClientId(target, client_id); |
11618 LOCAL_SET_GL_ERROR( | 11805 LOCAL_SET_GL_ERROR( |
11619 GL_INVALID_OPERATION, | 11806 GL_INVALID_OPERATION, |
11620 "glCreateAndConsumeTextureCHROMIUM", "invalid mailbox name"); | 11807 "glCreateAndConsumeTextureCHROMIUM", "invalid mailbox name"); |
11621 return; | 11808 return; |
11622 } | 11809 } |
| 11810 |
11623 if (texture->target() != target) { | 11811 if (texture->target() != target) { |
| 11812 EnsureTextureForClientId(target, client_id); |
11624 LOCAL_SET_GL_ERROR( | 11813 LOCAL_SET_GL_ERROR( |
11625 GL_INVALID_OPERATION, | 11814 GL_INVALID_OPERATION, |
11626 "glCreateAndConsumeTextureCHROMIUM", "invalid target"); | 11815 "glCreateAndConsumeTextureCHROMIUM", "invalid target"); |
11627 return; | 11816 return; |
11628 } | 11817 } |
11629 | 11818 |
11630 texture_ref = texture_manager()->Consume(client_id, texture); | 11819 texture_ref = texture_manager()->Consume(client_id, texture); |
11631 } | 11820 } |
11632 | 11821 |
11633 bool GLES2DecoderImpl::DoIsValuebufferCHROMIUM(GLuint client_id) { | 11822 bool GLES2DecoderImpl::DoIsValuebufferCHROMIUM(GLuint client_id) { |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11880 if (GetBackbufferServiceId() != 0 && // emulated backbuffer | 12069 if (GetBackbufferServiceId() != 0 && // emulated backbuffer |
11881 bufs[0] == GL_BACK) { | 12070 bufs[0] == GL_BACK) { |
11882 mapped_buf = GL_COLOR_ATTACHMENT0; | 12071 mapped_buf = GL_COLOR_ATTACHMENT0; |
11883 } | 12072 } |
11884 glDrawBuffersARB(count, &mapped_buf); | 12073 glDrawBuffersARB(count, &mapped_buf); |
11885 group_->set_draw_buffer(bufs[0]); | 12074 group_->set_draw_buffer(bufs[0]); |
11886 } | 12075 } |
11887 } | 12076 } |
11888 | 12077 |
11889 void GLES2DecoderImpl::DoLoseContextCHROMIUM(GLenum current, GLenum other) { | 12078 void GLES2DecoderImpl::DoLoseContextCHROMIUM(GLenum current, GLenum other) { |
11890 group_->LoseContexts(other); | 12079 MarkContextLost(GetContextLostReasonFromResetStatus(current)); |
11891 reset_status_ = current; | 12080 group_->LoseContexts(GetContextLostReasonFromResetStatus(other)); |
11892 current_decoder_error_ = error::kLostContext; | 12081 reset_by_robustness_extension_ = true; |
11893 } | 12082 } |
11894 | 12083 |
11895 void GLES2DecoderImpl::DoMatrixLoadfCHROMIUM(GLenum matrix_mode, | 12084 void GLES2DecoderImpl::DoMatrixLoadfCHROMIUM(GLenum matrix_mode, |
11896 const GLfloat* matrix) { | 12085 const GLfloat* matrix) { |
11897 DCHECK(matrix_mode == GL_PATH_PROJECTION_CHROMIUM || | 12086 DCHECK(matrix_mode == GL_PATH_PROJECTION_CHROMIUM || |
11898 matrix_mode == GL_PATH_MODELVIEW_CHROMIUM); | 12087 matrix_mode == GL_PATH_MODELVIEW_CHROMIUM); |
11899 if (!features().chromium_path_rendering) { | 12088 if (!features().chromium_path_rendering) { |
11900 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, | 12089 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, |
11901 "glMatrixLoadfCHROMIUM", | 12090 "glMatrixLoadfCHROMIUM", |
11902 "function not available"); | 12091 "function not available"); |
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12400 } | 12589 } |
12401 buffer->RemoveMappedRange(); | 12590 buffer->RemoveMappedRange(); |
12402 GLboolean rt = glUnmapBuffer(target); | 12591 GLboolean rt = glUnmapBuffer(target); |
12403 if (rt == GL_FALSE) { | 12592 if (rt == GL_FALSE) { |
12404 // At this point, we have already done the necessary validation, so | 12593 // At this point, we have already done the necessary validation, so |
12405 // GL_FALSE indicates data corruption. | 12594 // GL_FALSE indicates data corruption. |
12406 // TODO(zmo): We could redo the map / copy data / unmap to recover, but | 12595 // TODO(zmo): We could redo the map / copy data / unmap to recover, but |
12407 // the second unmap could still return GL_FALSE. For now, we simply lose | 12596 // the second unmap could still return GL_FALSE. For now, we simply lose |
12408 // the contexts in the share group. | 12597 // the contexts in the share group. |
12409 LOG(ERROR) << "glUnmapBuffer unexpectedly returned GL_FALSE"; | 12598 LOG(ERROR) << "glUnmapBuffer unexpectedly returned GL_FALSE"; |
12410 group_->LoseContexts(GL_INNOCENT_CONTEXT_RESET_ARB); | 12599 // Need to lose current context before broadcasting! |
12411 reset_status_ = GL_GUILTY_CONTEXT_RESET_ARB; | 12600 MarkContextLost(error::kGuilty); |
| 12601 group_->LoseContexts(error::kInnocent); |
12412 return error::kLostContext; | 12602 return error::kLostContext; |
12413 } | 12603 } |
12414 return error::kNoError; | 12604 return error::kNoError; |
12415 } | 12605 } |
12416 | 12606 |
12417 void GLES2DecoderImpl::OnTextureRefDetachedFromFramebuffer( | 12607 void GLES2DecoderImpl::OnTextureRefDetachedFromFramebuffer( |
12418 TextureRef* texture_ref) { | 12608 TextureRef* texture_ref) { |
12419 Texture* texture = texture_ref->texture(); | 12609 Texture* texture = texture_ref->texture(); |
12420 DoDidUseTexImageIfNeeded(texture, texture->target()); | 12610 DoDidUseTexImageIfNeeded(texture, texture->target()); |
12421 } | 12611 } |
12422 | 12612 |
| 12613 // Note that GL_LOST_CONTEXT is specific to GLES. |
| 12614 // For desktop GL we have to query the reset status proactively. |
12423 void GLES2DecoderImpl::OnContextLostError() { | 12615 void GLES2DecoderImpl::OnContextLostError() { |
12424 group_->LoseContexts(GL_UNKNOWN_CONTEXT_RESET_ARB); | 12616 if (!WasContextLost()) { |
| 12617 // Need to lose current context before broadcasting! |
| 12618 CheckResetStatus(); |
| 12619 group_->LoseContexts(error::kUnknown); |
| 12620 reset_by_robustness_extension_ = true; |
| 12621 } |
12425 } | 12622 } |
12426 | 12623 |
12427 void GLES2DecoderImpl::OnOutOfMemoryError() { | 12624 void GLES2DecoderImpl::OnOutOfMemoryError() { |
12428 if (lose_context_when_out_of_memory_) { | 12625 if (lose_context_when_out_of_memory_ && !WasContextLost()) { |
12429 group_->LoseContexts(GL_UNKNOWN_CONTEXT_RESET_ARB); | 12626 error::ContextLostReason other = error::kOutOfMemory; |
| 12627 if (CheckResetStatus()) { |
| 12628 other = error::kUnknown; |
| 12629 } else { |
| 12630 // Need to lose current context before broadcasting! |
| 12631 MarkContextLost(error::kOutOfMemory); |
| 12632 } |
| 12633 group_->LoseContexts(other); |
12430 } | 12634 } |
12431 } | 12635 } |
12432 | 12636 |
12433 // Include the auto-generated part of this file. We split this because it means | 12637 // Include the auto-generated part of this file. We split this because it means |
12434 // we can easily edit the non-auto generated parts right here in this file | 12638 // we can easily edit the non-auto generated parts right here in this file |
12435 // instead of having to edit some template or the code generator. | 12639 // instead of having to edit some template or the code generator. |
12436 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 12640 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
12437 | 12641 |
12438 } // namespace gles2 | 12642 } // namespace gles2 |
12439 } // namespace gpu | 12643 } // namespace gpu |
OLD | NEW |