Chromium Code Reviews| 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> |
| 11 | 11 |
| 12 #include <algorithm> | 12 #include <algorithm> |
| 13 #include <cmath> | 13 #include <cmath> |
| 14 #include <list> | 14 #include <list> |
| 15 #include <map> | 15 #include <map> |
| 16 #include <memory> | 16 #include <memory> |
| 17 #include <queue> | 17 #include <queue> |
| 18 | 18 |
| 19 #include "base/callback.h" | 19 #include "base/callback.h" |
| 20 #include "base/callback_helpers.h" | 20 #include "base/callback_helpers.h" |
| 21 #include "base/logging.h" | 21 #include "base/logging.h" |
| 22 #include "base/memory/ptr_util.h" | |
| 22 #include "base/metrics/histogram_macros.h" | 23 #include "base/metrics/histogram_macros.h" |
| 23 #include "base/numerics/safe_math.h" | 24 #include "base/numerics/safe_math.h" |
| 24 #include "base/strings/string_number_conversions.h" | 25 #include "base/strings/string_number_conversions.h" |
| 25 #include "base/strings/stringprintf.h" | 26 #include "base/strings/stringprintf.h" |
| 26 #include "base/trace_event/trace_event.h" | 27 #include "base/trace_event/trace_event.h" |
| 27 #include "base/trace_event/trace_event_synthetic_delay.h" | 28 #include "base/trace_event/trace_event_synthetic_delay.h" |
| 28 #include "build/build_config.h" | 29 #include "build/build_config.h" |
| 29 #include "gpu/command_buffer/common/debug_marker_manager.h" | 30 #include "gpu/command_buffer/common/debug_marker_manager.h" |
| 30 #include "gpu/command_buffer/common/gles2_cmd_format.h" | 31 #include "gpu/command_buffer/common/gles2_cmd_format.h" |
| 31 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 32 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
| (...skipping 3835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3867 bool GLES2DecoderImpl::DeletePathsCHROMIUMHelper(GLuint first_client_id, | 3868 bool GLES2DecoderImpl::DeletePathsCHROMIUMHelper(GLuint first_client_id, |
| 3868 GLsizei range) { | 3869 GLsizei range) { |
| 3869 GLuint last_client_id; | 3870 GLuint last_client_id; |
| 3870 if (!SafeAddUint32(first_client_id, range - 1, &last_client_id)) | 3871 if (!SafeAddUint32(first_client_id, range - 1, &last_client_id)) |
| 3871 return false; | 3872 return false; |
| 3872 | 3873 |
| 3873 path_manager()->RemovePaths(first_client_id, last_client_id); | 3874 path_manager()->RemovePaths(first_client_id, last_client_id); |
| 3874 return true; | 3875 return true; |
| 3875 } | 3876 } |
| 3876 | 3877 |
| 3877 void GLES2DecoderImpl::DeleteBuffersHelper( | 3878 void GLES2DecoderImpl::DeleteBuffersHelper(GLsizei n, |
| 3878 GLsizei n, const GLuint* client_ids) { | 3879 const GLuint* client_ids) { |
| 3879 for (GLsizei ii = 0; ii < n; ++ii) { | 3880 for (GLsizei ii = 0; ii < n; ++ii) { |
| 3880 Buffer* buffer = GetBuffer(client_ids[ii]); | 3881 GLuint client_id = client_ids[ii]; |
| 3882 Buffer* buffer = GetBuffer(client_id); | |
| 3881 if (buffer && !buffer->IsDeleted()) { | 3883 if (buffer && !buffer->IsDeleted()) { |
| 3882 buffer->RemoveMappedRange(); | 3884 buffer->RemoveMappedRange(); |
| 3883 state_.RemoveBoundBuffer(buffer); | 3885 state_.RemoveBoundBuffer(buffer); |
| 3884 transform_feedback_manager_->RemoveBoundBuffer(buffer); | 3886 transform_feedback_manager_->RemoveBoundBuffer(buffer); |
| 3885 RemoveBuffer(client_ids[ii]); | 3887 RemoveBuffer(client_id); |
| 3886 } | 3888 } |
| 3887 } | 3889 } |
| 3888 } | 3890 } |
| 3889 | 3891 |
| 3890 void GLES2DecoderImpl::DeleteFramebuffersHelper( | 3892 void GLES2DecoderImpl::DeleteFramebuffersHelper(GLsizei n, |
| 3891 GLsizei n, const GLuint* client_ids) { | 3893 const GLuint* client_ids) { |
| 3892 bool supports_separate_framebuffer_binds = | 3894 bool supports_separate_framebuffer_binds = |
| 3893 features().chromium_framebuffer_multisample; | 3895 features().chromium_framebuffer_multisample; |
| 3894 | 3896 |
| 3895 for (GLsizei ii = 0; ii < n; ++ii) { | 3897 for (GLsizei ii = 0; ii < n; ++ii) { |
| 3896 Framebuffer* framebuffer = | 3898 GLuint client_id = client_ids[ii]; |
| 3897 GetFramebuffer(client_ids[ii]); | 3899 Framebuffer* framebuffer = GetFramebuffer(client_id); |
| 3898 if (framebuffer && !framebuffer->IsDeleted()) { | 3900 if (framebuffer && !framebuffer->IsDeleted()) { |
| 3899 if (framebuffer == framebuffer_state_.bound_draw_framebuffer.get()) { | 3901 if (framebuffer == framebuffer_state_.bound_draw_framebuffer.get()) { |
| 3900 GLenum target = supports_separate_framebuffer_binds ? | 3902 GLenum target = supports_separate_framebuffer_binds ? |
| 3901 GL_DRAW_FRAMEBUFFER_EXT : GL_FRAMEBUFFER; | 3903 GL_DRAW_FRAMEBUFFER_EXT : GL_FRAMEBUFFER; |
| 3902 | 3904 |
| 3903 // Unbind attachments on FBO before deletion. | 3905 // Unbind attachments on FBO before deletion. |
| 3904 if (workarounds().unbind_attachments_on_bound_render_fbo_delete) | 3906 if (workarounds().unbind_attachments_on_bound_render_fbo_delete) |
| 3905 framebuffer->DoUnbindGLAttachmentsForWorkaround(target); | 3907 framebuffer->DoUnbindGLAttachmentsForWorkaround(target); |
| 3906 | 3908 |
| 3907 glBindFramebufferEXT(target, GetBackbufferServiceId()); | 3909 glBindFramebufferEXT(target, GetBackbufferServiceId()); |
| 3908 framebuffer_state_.bound_draw_framebuffer = NULL; | 3910 framebuffer_state_.bound_draw_framebuffer = NULL; |
| 3909 framebuffer_state_.clear_state_dirty = true; | 3911 framebuffer_state_.clear_state_dirty = true; |
| 3910 } | 3912 } |
| 3911 if (framebuffer == framebuffer_state_.bound_read_framebuffer.get()) { | 3913 if (framebuffer == framebuffer_state_.bound_read_framebuffer.get()) { |
| 3912 framebuffer_state_.bound_read_framebuffer = NULL; | 3914 framebuffer_state_.bound_read_framebuffer = NULL; |
| 3913 GLenum target = supports_separate_framebuffer_binds ? | 3915 GLenum target = supports_separate_framebuffer_binds ? |
| 3914 GL_READ_FRAMEBUFFER_EXT : GL_FRAMEBUFFER; | 3916 GL_READ_FRAMEBUFFER_EXT : GL_FRAMEBUFFER; |
| 3915 glBindFramebufferEXT(target, GetBackbufferServiceId()); | 3917 glBindFramebufferEXT(target, GetBackbufferServiceId()); |
| 3916 } | 3918 } |
| 3917 OnFboChanged(); | 3919 OnFboChanged(); |
| 3918 RemoveFramebuffer(client_ids[ii]); | 3920 RemoveFramebuffer(client_id); |
| 3919 } | 3921 } |
| 3920 } | 3922 } |
| 3921 } | 3923 } |
| 3922 | 3924 |
| 3923 void GLES2DecoderImpl::DeleteRenderbuffersHelper( | 3925 void GLES2DecoderImpl::DeleteRenderbuffersHelper(GLsizei n, |
| 3924 GLsizei n, const GLuint* client_ids) { | 3926 const GLuint* client_ids) { |
| 3925 bool supports_separate_framebuffer_binds = | 3927 bool supports_separate_framebuffer_binds = |
| 3926 features().chromium_framebuffer_multisample; | 3928 features().chromium_framebuffer_multisample; |
| 3927 for (GLsizei ii = 0; ii < n; ++ii) { | 3929 for (GLsizei ii = 0; ii < n; ++ii) { |
| 3928 Renderbuffer* renderbuffer = | 3930 GLuint client_id = client_ids[ii]; |
| 3929 GetRenderbuffer(client_ids[ii]); | 3931 Renderbuffer* renderbuffer = GetRenderbuffer(client_id); |
| 3930 if (renderbuffer && !renderbuffer->IsDeleted()) { | 3932 if (renderbuffer && !renderbuffer->IsDeleted()) { |
| 3931 if (state_.bound_renderbuffer.get() == renderbuffer) { | 3933 if (state_.bound_renderbuffer.get() == renderbuffer) { |
| 3932 state_.bound_renderbuffer = NULL; | 3934 state_.bound_renderbuffer = NULL; |
| 3933 } | 3935 } |
| 3934 // Unbind from current framebuffers. | 3936 // Unbind from current framebuffers. |
| 3935 if (supports_separate_framebuffer_binds) { | 3937 if (supports_separate_framebuffer_binds) { |
| 3936 if (framebuffer_state_.bound_read_framebuffer.get()) { | 3938 if (framebuffer_state_.bound_read_framebuffer.get()) { |
| 3937 framebuffer_state_.bound_read_framebuffer | 3939 framebuffer_state_.bound_read_framebuffer |
| 3938 ->UnbindRenderbuffer(GL_READ_FRAMEBUFFER_EXT, renderbuffer); | 3940 ->UnbindRenderbuffer(GL_READ_FRAMEBUFFER_EXT, renderbuffer); |
| 3939 } | 3941 } |
| 3940 if (framebuffer_state_.bound_draw_framebuffer.get()) { | 3942 if (framebuffer_state_.bound_draw_framebuffer.get()) { |
| 3941 framebuffer_state_.bound_draw_framebuffer | 3943 framebuffer_state_.bound_draw_framebuffer |
| 3942 ->UnbindRenderbuffer(GL_DRAW_FRAMEBUFFER_EXT, renderbuffer); | 3944 ->UnbindRenderbuffer(GL_DRAW_FRAMEBUFFER_EXT, renderbuffer); |
| 3943 } | 3945 } |
| 3944 } else { | 3946 } else { |
| 3945 if (framebuffer_state_.bound_draw_framebuffer.get()) { | 3947 if (framebuffer_state_.bound_draw_framebuffer.get()) { |
| 3946 framebuffer_state_.bound_draw_framebuffer | 3948 framebuffer_state_.bound_draw_framebuffer |
| 3947 ->UnbindRenderbuffer(GL_FRAMEBUFFER, renderbuffer); | 3949 ->UnbindRenderbuffer(GL_FRAMEBUFFER, renderbuffer); |
| 3948 } | 3950 } |
| 3949 } | 3951 } |
| 3950 framebuffer_state_.clear_state_dirty = true; | 3952 framebuffer_state_.clear_state_dirty = true; |
| 3951 RemoveRenderbuffer(client_ids[ii]); | 3953 RemoveRenderbuffer(client_id); |
| 3952 } | 3954 } |
| 3953 } | 3955 } |
| 3954 } | 3956 } |
| 3955 | 3957 |
| 3956 void GLES2DecoderImpl::DeleteTexturesHelper( | 3958 void GLES2DecoderImpl::DeleteTexturesHelper(GLsizei n, |
| 3957 GLsizei n, const GLuint* client_ids) { | 3959 const GLuint* client_ids) { |
| 3958 bool supports_separate_framebuffer_binds = | 3960 bool supports_separate_framebuffer_binds = |
| 3959 features().chromium_framebuffer_multisample; | 3961 features().chromium_framebuffer_multisample; |
| 3960 for (GLsizei ii = 0; ii < n; ++ii) { | 3962 for (GLsizei ii = 0; ii < n; ++ii) { |
| 3961 TextureRef* texture_ref = GetTexture(client_ids[ii]); | 3963 GLuint client_id = client_ids[ii]; |
| 3964 TextureRef* texture_ref = GetTexture(client_id); | |
| 3962 if (texture_ref) { | 3965 if (texture_ref) { |
| 3963 Texture* texture = texture_ref->texture(); | 3966 Texture* texture = texture_ref->texture(); |
| 3964 if (texture->IsAttachedToFramebuffer()) { | 3967 if (texture->IsAttachedToFramebuffer()) { |
| 3965 framebuffer_state_.clear_state_dirty = true; | 3968 framebuffer_state_.clear_state_dirty = true; |
| 3966 } | 3969 } |
| 3967 // Unbind texture_ref from texture_ref units. | 3970 // Unbind texture_ref from texture_ref units. |
| 3968 state_.UnbindTexture(texture_ref); | 3971 state_.UnbindTexture(texture_ref); |
| 3969 | 3972 |
| 3970 // Unbind from current framebuffers. | 3973 // Unbind from current framebuffers. |
| 3971 if (supports_separate_framebuffer_binds) { | 3974 if (supports_separate_framebuffer_binds) { |
| 3972 if (framebuffer_state_.bound_read_framebuffer.get()) { | 3975 if (framebuffer_state_.bound_read_framebuffer.get()) { |
| 3973 framebuffer_state_.bound_read_framebuffer | 3976 framebuffer_state_.bound_read_framebuffer |
| 3974 ->UnbindTexture(GL_READ_FRAMEBUFFER_EXT, texture_ref); | 3977 ->UnbindTexture(GL_READ_FRAMEBUFFER_EXT, texture_ref); |
| 3975 } | 3978 } |
| 3976 if (framebuffer_state_.bound_draw_framebuffer.get()) { | 3979 if (framebuffer_state_.bound_draw_framebuffer.get()) { |
| 3977 framebuffer_state_.bound_draw_framebuffer | 3980 framebuffer_state_.bound_draw_framebuffer |
| 3978 ->UnbindTexture(GL_DRAW_FRAMEBUFFER_EXT, texture_ref); | 3981 ->UnbindTexture(GL_DRAW_FRAMEBUFFER_EXT, texture_ref); |
| 3979 } | 3982 } |
| 3980 } else { | 3983 } else { |
| 3981 if (framebuffer_state_.bound_draw_framebuffer.get()) { | 3984 if (framebuffer_state_.bound_draw_framebuffer.get()) { |
| 3982 framebuffer_state_.bound_draw_framebuffer | 3985 framebuffer_state_.bound_draw_framebuffer |
| 3983 ->UnbindTexture(GL_FRAMEBUFFER, texture_ref); | 3986 ->UnbindTexture(GL_FRAMEBUFFER, texture_ref); |
| 3984 } | 3987 } |
| 3985 } | 3988 } |
| 3986 RemoveTexture(client_ids[ii]); | 3989 RemoveTexture(client_id); |
| 3987 } | 3990 } |
| 3988 } | 3991 } |
| 3989 } | 3992 } |
| 3990 | 3993 |
| 3991 void GLES2DecoderImpl::DeleteSamplersHelper( | 3994 void GLES2DecoderImpl::DeleteSamplersHelper(GLsizei n, |
| 3992 GLsizei n, const GLuint* client_ids) { | 3995 const GLuint* client_ids) { |
| 3993 for (GLsizei ii = 0; ii < n; ++ii) { | 3996 for (GLsizei ii = 0; ii < n; ++ii) { |
| 3994 Sampler* sampler = GetSampler(client_ids[ii]); | 3997 GLuint client_id = client_ids[ii]; |
| 3998 Sampler* sampler = GetSampler(client_id); | |
| 3995 if (sampler && !sampler->IsDeleted()) { | 3999 if (sampler && !sampler->IsDeleted()) { |
| 3996 // Unbind from current sampler units. | 4000 // Unbind from current sampler units. |
| 3997 state_.UnbindSampler(sampler); | 4001 state_.UnbindSampler(sampler); |
| 3998 | 4002 |
| 3999 RemoveSampler(client_ids[ii]); | 4003 RemoveSampler(client_id); |
| 4000 } | 4004 } |
| 4001 } | 4005 } |
| 4002 } | 4006 } |
| 4003 | 4007 |
| 4004 void GLES2DecoderImpl::DeleteTransformFeedbacksHelper( | 4008 void GLES2DecoderImpl::DeleteTransformFeedbacksHelper( |
| 4005 GLsizei n, const GLuint* client_ids) { | 4009 GLsizei n, |
| 4010 const GLuint* client_ids) { | |
| 4006 for (GLsizei ii = 0; ii < n; ++ii) { | 4011 for (GLsizei ii = 0; ii < n; ++ii) { |
| 4007 TransformFeedback* transform_feedback = GetTransformFeedback( | 4012 GLuint client_id = client_ids[ii]; |
| 4008 client_ids[ii]); | 4013 TransformFeedback* transform_feedback = GetTransformFeedback(client_id); |
| 4009 if (transform_feedback) { | 4014 if (transform_feedback) { |
| 4010 if (transform_feedback->active()) { | 4015 if (transform_feedback->active()) { |
| 4011 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glDeleteTransformFeedbacks", | 4016 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glDeleteTransformFeedbacks", |
| 4012 "Deleting transform feedback is active"); | 4017 "Deleting transform feedback is active"); |
| 4013 return; | 4018 return; |
| 4014 } | 4019 } |
| 4015 if (state_.bound_transform_feedback.get() == transform_feedback) { | 4020 if (state_.bound_transform_feedback.get() == transform_feedback) { |
| 4016 // Bind to the default transform feedback. | 4021 // Bind to the default transform feedback. |
| 4017 DCHECK(state_.default_transform_feedback.get()); | 4022 DCHECK(state_.default_transform_feedback.get()); |
| 4018 state_.default_transform_feedback->DoBindTransformFeedback( | 4023 state_.default_transform_feedback->DoBindTransformFeedback( |
| 4019 GL_TRANSFORM_FEEDBACK); | 4024 GL_TRANSFORM_FEEDBACK); |
| 4020 state_.bound_transform_feedback = | 4025 state_.bound_transform_feedback = |
| 4021 state_.default_transform_feedback.get(); | 4026 state_.default_transform_feedback.get(); |
| 4022 } | 4027 } |
| 4023 RemoveTransformFeedback(client_ids[ii]); | 4028 RemoveTransformFeedback(client_id); |
| 4024 } | 4029 } |
| 4025 } | 4030 } |
| 4026 } | 4031 } |
| 4027 | 4032 |
| 4028 void GLES2DecoderImpl::DeleteSyncHelper(GLuint sync) { | 4033 void GLES2DecoderImpl::DeleteSyncHelper(GLuint sync) { |
| 4029 GLsync service_id = 0; | 4034 GLsync service_id = 0; |
| 4030 if (group_->GetSyncServiceId(sync, &service_id)) { | 4035 if (group_->GetSyncServiceId(sync, &service_id)) { |
| 4031 glDeleteSync(service_id); | 4036 glDeleteSync(service_id); |
| 4032 group_->RemoveSyncId(sync); | 4037 group_->RemoveSyncId(sync); |
| 4033 } else if (sync != 0) { | 4038 } else if (sync != 0) { |
| (...skipping 1650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5684 if (index != 0 || gl_version_info().BehavesLikeGLES()) { | 5689 if (index != 0 || gl_version_info().BehavesLikeGLES()) { |
| 5685 glDisableVertexAttribArray(index); | 5690 glDisableVertexAttribArray(index); |
| 5686 } | 5691 } |
| 5687 } else { | 5692 } else { |
| 5688 LOCAL_SET_GL_ERROR( | 5693 LOCAL_SET_GL_ERROR( |
| 5689 GL_INVALID_VALUE, | 5694 GL_INVALID_VALUE, |
| 5690 "glDisableVertexAttribArray", "index out of range"); | 5695 "glDisableVertexAttribArray", "index out of range"); |
| 5691 } | 5696 } |
| 5692 } | 5697 } |
| 5693 | 5698 |
| 5694 void GLES2DecoderImpl::InvalidateFramebufferImpl( | 5699 void GLES2DecoderImpl::InvalidateFramebufferImpl(GLenum target, |
| 5695 GLenum target, GLsizei count, const GLenum* attachments, | 5700 GLsizei count, |
| 5696 GLint x, GLint y, GLsizei width, GLsizei height, | 5701 const GLenum* attachments, |
| 5697 const char* function_name, FramebufferOperation op) { | 5702 GLint x, |
| 5703 GLint y, | |
| 5704 GLsizei width, | |
| 5705 GLsizei height, | |
| 5706 const char* function_name, | |
| 5707 FramebufferOperation op) { | |
| 5698 Framebuffer* framebuffer = GetFramebufferInfoForTarget(GL_FRAMEBUFFER); | 5708 Framebuffer* framebuffer = GetFramebufferInfoForTarget(GL_FRAMEBUFFER); |
| 5699 | 5709 |
| 5700 // Because of performance issues, no-op if the format of the attachment is | 5710 // Because of performance issues, no-op if the format of the attachment is |
| 5701 // DEPTH_STENCIL and only one part is intended to be invalidated. | 5711 // DEPTH_STENCIL and only one part is intended to be invalidated. |
| 5702 bool has_depth_stencil_format = framebuffer && | 5712 bool has_depth_stencil_format = framebuffer && |
| 5703 framebuffer->HasDepthStencilFormatAttachment(); | 5713 framebuffer->HasDepthStencilFormatAttachment(); |
| 5704 bool invalidate_depth = false; | 5714 bool invalidate_depth = false; |
| 5705 bool invalidate_stencil = false; | 5715 bool invalidate_stencil = false; |
| 5706 std::unique_ptr<GLenum[]> validated_attachments(new GLenum[count]); | 5716 std::unique_ptr<GLenum[]> validated_attachments(new GLenum[count]); |
| 5707 GLsizei validated_count = 0; | 5717 GLsizei validated_count = 0; |
| 5708 | 5718 |
| 5709 // Validates the attachments. If one of them fails, the whole command fails. | 5719 // Validates the attachments. If one of them fails, the whole command fails. |
| 5710 GLenum thresh0 = GL_COLOR_ATTACHMENT0 + group_->max_color_attachments(); | 5720 GLenum thresh0 = GL_COLOR_ATTACHMENT0 + group_->max_color_attachments(); |
| 5711 GLenum thresh1 = GL_COLOR_ATTACHMENT15; | 5721 GLenum thresh1 = GL_COLOR_ATTACHMENT15; |
| 5712 for (GLsizei i = 0; i < count; ++i) { | 5722 for (GLsizei i = 0; i < count; ++i) { |
| 5723 GLenum attachment = attachments[i]; | |
| 5713 if (framebuffer) { | 5724 if (framebuffer) { |
| 5714 if (attachments[i] >= thresh0 && attachments[i] <= thresh1) { | 5725 if (attachment >= thresh0 && attachment <= thresh1) { |
| 5715 LOCAL_SET_GL_ERROR( | 5726 LOCAL_SET_GL_ERROR( |
| 5716 GL_INVALID_OPERATION, function_name, "invalid attachment"); | 5727 GL_INVALID_OPERATION, function_name, "invalid attachment"); |
| 5717 return; | 5728 return; |
| 5718 } | 5729 } |
| 5719 if (!validators_->attachment.IsValid(attachments[i])) { | 5730 if (!validators_->attachment.IsValid(attachment)) { |
| 5720 LOCAL_SET_GL_ERROR_INVALID_ENUM( | 5731 LOCAL_SET_GL_ERROR_INVALID_ENUM(function_name, attachment, |
| 5721 function_name, attachments[i], "attachments"); | 5732 "attachments"); |
| 5722 return; | 5733 return; |
| 5723 } | 5734 } |
| 5724 if (has_depth_stencil_format) { | 5735 if (has_depth_stencil_format) { |
| 5725 switch(attachments[i]) { | 5736 switch (attachment) { |
| 5726 case GL_DEPTH_ATTACHMENT: | 5737 case GL_DEPTH_ATTACHMENT: |
| 5727 invalidate_depth = true; | 5738 invalidate_depth = true; |
| 5728 continue; | 5739 continue; |
| 5729 case GL_STENCIL_ATTACHMENT: | 5740 case GL_STENCIL_ATTACHMENT: |
| 5730 invalidate_stencil = true; | 5741 invalidate_stencil = true; |
| 5731 continue; | 5742 continue; |
| 5732 case GL_DEPTH_STENCIL_ATTACHMENT: | 5743 case GL_DEPTH_STENCIL_ATTACHMENT: |
| 5733 invalidate_depth = true; | 5744 invalidate_depth = true; |
| 5734 invalidate_stencil = true; | 5745 invalidate_stencil = true; |
| 5735 continue; | 5746 continue; |
| 5736 } | 5747 } |
| 5737 } | 5748 } |
| 5738 } else { | 5749 } else { |
| 5739 if (!validators_->backbuffer_attachment.IsValid(attachments[i])) { | 5750 if (!validators_->backbuffer_attachment.IsValid(attachment)) { |
| 5740 LOCAL_SET_GL_ERROR_INVALID_ENUM( | 5751 LOCAL_SET_GL_ERROR_INVALID_ENUM(function_name, attachment, |
| 5741 function_name, attachments[i], "attachments"); | 5752 "attachments"); |
| 5742 return; | 5753 return; |
| 5743 } | 5754 } |
| 5744 } | 5755 } |
| 5745 validated_attachments[validated_count++] = attachments[i]; | 5756 validated_attachments[validated_count++] = attachment; |
| 5746 } | 5757 } |
| 5747 if (invalidate_depth && invalidate_stencil) { | 5758 if (invalidate_depth && invalidate_stencil) { |
| 5748 validated_attachments[validated_count++] = GL_DEPTH_STENCIL_ATTACHMENT; | 5759 validated_attachments[validated_count++] = GL_DEPTH_STENCIL_ATTACHMENT; |
| 5749 } | 5760 } |
| 5750 | 5761 |
| 5751 // If the default framebuffer is bound but we are still rendering to an | 5762 // If the default framebuffer is bound but we are still rendering to an |
| 5752 // FBO, translate attachment names that refer to default framebuffer | 5763 // FBO, translate attachment names that refer to default framebuffer |
| 5753 // channels to corresponding framebuffer attachments. | 5764 // channels to corresponding framebuffer attachments. |
| 5754 std::unique_ptr<GLenum[]> translated_attachments(new GLenum[validated_count]); | 5765 std::unique_ptr<GLenum[]> translated_attachments(new GLenum[validated_count]); |
| 5755 for (GLsizei i = 0; i < validated_count; ++i) { | 5766 for (GLsizei i = 0; i < validated_count; ++i) { |
| (...skipping 2482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8238 } | 8249 } |
| 8239 if (!state_.current_program->SetSamplers( | 8250 if (!state_.current_program->SetSamplers( |
| 8240 state_.texture_units.size(), fake_location, 1, &v0)) { | 8251 state_.texture_units.size(), fake_location, 1, &v0)) { |
| 8241 LOCAL_SET_GL_ERROR( | 8252 LOCAL_SET_GL_ERROR( |
| 8242 GL_INVALID_VALUE, "glUniform1i", "texture unit out of range"); | 8253 GL_INVALID_VALUE, "glUniform1i", "texture unit out of range"); |
| 8243 return; | 8254 return; |
| 8244 } | 8255 } |
| 8245 glUniform1i(real_location, v0); | 8256 glUniform1i(real_location, v0); |
| 8246 } | 8257 } |
| 8247 | 8258 |
| 8248 void GLES2DecoderImpl::DoUniform1iv( | 8259 void GLES2DecoderImpl::DoUniform1iv(GLint fake_location, |
| 8249 GLint fake_location, GLsizei count, const GLint *value) { | 8260 GLsizei count, |
| 8261 const GLint* values) { | |
| 8250 GLenum type = 0; | 8262 GLenum type = 0; |
| 8251 GLint real_location = -1; | 8263 GLint real_location = -1; |
| 8252 if (!PrepForSetUniformByLocation(fake_location, | 8264 if (!PrepForSetUniformByLocation(fake_location, |
| 8253 "glUniform1iv", | 8265 "glUniform1iv", |
| 8254 Program::kUniform1i, | 8266 Program::kUniform1i, |
| 8255 &real_location, | 8267 &real_location, |
| 8256 &type, | 8268 &type, |
| 8257 &count)) { | 8269 &count)) { |
| 8258 return; | 8270 return; |
| 8259 } | 8271 } |
| 8272 auto values_copy = base::MakeUnique<GLint[]>(count); | |
| 8273 GLint* safe_values = values_copy.get(); | |
| 8274 std::copy(values, values + count, safe_values); | |
| 8260 if (type == GL_SAMPLER_2D || type == GL_SAMPLER_2D_RECT_ARB || | 8275 if (type == GL_SAMPLER_2D || type == GL_SAMPLER_2D_RECT_ARB || |
| 8261 type == GL_SAMPLER_CUBE || type == GL_SAMPLER_EXTERNAL_OES) { | 8276 type == GL_SAMPLER_CUBE || type == GL_SAMPLER_EXTERNAL_OES) { |
| 8262 if (!state_.current_program->SetSamplers( | 8277 if (!state_.current_program->SetSamplers( |
| 8263 state_.texture_units.size(), fake_location, count, value)) { | 8278 state_.texture_units.size(), fake_location, count, safe_values)) { |
| 8264 LOCAL_SET_GL_ERROR( | 8279 LOCAL_SET_GL_ERROR( |
| 8265 GL_INVALID_VALUE, "glUniform1iv", "texture unit out of range"); | 8280 GL_INVALID_VALUE, "glUniform1iv", "texture unit out of range"); |
| 8266 return; | 8281 return; |
| 8267 } | 8282 } |
| 8268 } | 8283 } |
| 8269 glUniform1iv(real_location, count, value); | 8284 glUniform1iv(real_location, count, safe_values); |
| 8270 } | 8285 } |
| 8271 | 8286 |
| 8272 void GLES2DecoderImpl::DoUniform1uiv( | 8287 void GLES2DecoderImpl::DoUniform1uiv( |
| 8273 GLint fake_location, GLsizei count, const GLuint *value) { | 8288 GLint fake_location, GLsizei count, const GLuint *value) { |
| 8274 GLenum type = 0; | 8289 GLenum type = 0; |
| 8275 GLint real_location = -1; | 8290 GLint real_location = -1; |
| 8276 if (!PrepForSetUniformByLocation(fake_location, | 8291 if (!PrepForSetUniformByLocation(fake_location, |
| 8277 "glUniform1uiv", | 8292 "glUniform1uiv", |
| 8278 Program::kUniform1ui, | 8293 Program::kUniform1ui, |
| 8279 &real_location, | 8294 &real_location, |
| (...skipping 1710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9990 index, SHADER_VARIABLE_FLOAT); | 10005 index, SHADER_VARIABLE_FLOAT); |
| 9991 glVertexAttrib4f(index, v0, v1, v2, v3); | 10006 glVertexAttrib4f(index, v0, v1, v2, v3); |
| 9992 } | 10007 } |
| 9993 } | 10008 } |
| 9994 | 10009 |
| 9995 void GLES2DecoderImpl::DoVertexAttrib1fv(GLuint index, const GLfloat* v) { | 10010 void GLES2DecoderImpl::DoVertexAttrib1fv(GLuint index, const GLfloat* v) { |
| 9996 GLfloat t[4] = { v[0], 0.0f, 0.0f, 1.0f, }; | 10011 GLfloat t[4] = { v[0], 0.0f, 0.0f, 1.0f, }; |
| 9997 if (SetVertexAttribValue("glVertexAttrib1fv", index, t)) { | 10012 if (SetVertexAttribValue("glVertexAttrib1fv", index, t)) { |
| 9998 state_.SetGenericVertexAttribBaseType( | 10013 state_.SetGenericVertexAttribBaseType( |
| 9999 index, SHADER_VARIABLE_FLOAT); | 10014 index, SHADER_VARIABLE_FLOAT); |
| 10000 glVertexAttrib1fv(index, v); | 10015 glVertexAttrib1fv(index, t); |
| 10001 } | 10016 } |
| 10002 } | 10017 } |
| 10003 | 10018 |
| 10004 void GLES2DecoderImpl::DoVertexAttrib2fv(GLuint index, const GLfloat* v) { | 10019 void GLES2DecoderImpl::DoVertexAttrib2fv(GLuint index, const GLfloat* v) { |
| 10005 GLfloat t[4] = { v[0], v[1], 0.0f, 1.0f, }; | 10020 GLfloat t[4] = { v[0], v[1], 0.0f, 1.0f, }; |
| 10006 if (SetVertexAttribValue("glVertexAttrib2fv", index, t)) { | 10021 if (SetVertexAttribValue("glVertexAttrib2fv", index, t)) { |
| 10007 state_.SetGenericVertexAttribBaseType( | 10022 state_.SetGenericVertexAttribBaseType( |
| 10008 index, SHADER_VARIABLE_FLOAT); | 10023 index, SHADER_VARIABLE_FLOAT); |
| 10009 glVertexAttrib2fv(index, v); | 10024 glVertexAttrib2fv(index, t); |
| 10010 } | 10025 } |
| 10011 } | 10026 } |
| 10012 | 10027 |
| 10013 void GLES2DecoderImpl::DoVertexAttrib3fv(GLuint index, const GLfloat* v) { | 10028 void GLES2DecoderImpl::DoVertexAttrib3fv(GLuint index, const GLfloat* v) { |
| 10014 GLfloat t[4] = { v[0], v[1], v[2], 1.0f, }; | 10029 GLfloat t[4] = { v[0], v[1], v[2], 1.0f, }; |
| 10015 if (SetVertexAttribValue("glVertexAttrib3fv", index, t)) { | 10030 if (SetVertexAttribValue("glVertexAttrib3fv", index, t)) { |
| 10016 state_.SetGenericVertexAttribBaseType( | 10031 state_.SetGenericVertexAttribBaseType( |
| 10017 index, SHADER_VARIABLE_FLOAT); | 10032 index, SHADER_VARIABLE_FLOAT); |
| 10018 glVertexAttrib3fv(index, v); | 10033 glVertexAttrib3fv(index, t); |
| 10019 } | 10034 } |
| 10020 } | 10035 } |
| 10021 | 10036 |
| 10022 void GLES2DecoderImpl::DoVertexAttrib4fv(GLuint index, const GLfloat* v) { | 10037 void GLES2DecoderImpl::DoVertexAttrib4fv(GLuint index, const GLfloat* v) { |
| 10023 if (SetVertexAttribValue("glVertexAttrib4fv", index, v)) { | 10038 GLfloat t[4] = {v[0], v[1], v[2], v[3]}; |
| 10039 if (SetVertexAttribValue("glVertexAttrib4fv", index, t)) { | |
| 10024 state_.SetGenericVertexAttribBaseType( | 10040 state_.SetGenericVertexAttribBaseType( |
| 10025 index, SHADER_VARIABLE_FLOAT); | 10041 index, SHADER_VARIABLE_FLOAT); |
| 10026 glVertexAttrib4fv(index, v); | 10042 glVertexAttrib4fv(index, t); |
| 10027 } | 10043 } |
| 10028 } | 10044 } |
| 10029 | 10045 |
| 10030 void GLES2DecoderImpl::DoVertexAttribI4i( | 10046 void GLES2DecoderImpl::DoVertexAttribI4i( |
| 10031 GLuint index, GLint v0, GLint v1, GLint v2, GLint v3) { | 10047 GLuint index, GLint v0, GLint v1, GLint v2, GLint v3) { |
| 10032 GLint v[4] = { v0, v1, v2, v3 }; | 10048 GLint v[4] = { v0, v1, v2, v3 }; |
| 10033 if (SetVertexAttribValue("glVertexAttribI4i", index, v)) { | 10049 if (SetVertexAttribValue("glVertexAttribI4i", index, v)) { |
| 10034 state_.SetGenericVertexAttribBaseType( | 10050 state_.SetGenericVertexAttribBaseType( |
| 10035 index, SHADER_VARIABLE_INT); | 10051 index, SHADER_VARIABLE_INT); |
| 10036 glVertexAttribI4i(index, v0, v1, v2, v3); | 10052 glVertexAttribI4i(index, v0, v1, v2, v3); |
| 10037 } | 10053 } |
| 10038 } | 10054 } |
| 10039 | 10055 |
| 10040 void GLES2DecoderImpl::DoVertexAttribI4iv(GLuint index, const GLint* v) { | 10056 void GLES2DecoderImpl::DoVertexAttribI4iv(GLuint index, const GLint* v) { |
| 10041 if (SetVertexAttribValue("glVertexAttribI4iv", index, v)) { | 10057 GLint t[4] = {v[0], v[1], v[2], v[3]}; |
| 10058 if (SetVertexAttribValue("glVertexAttribI4iv", index, t)) { | |
| 10042 state_.SetGenericVertexAttribBaseType( | 10059 state_.SetGenericVertexAttribBaseType( |
| 10043 index, SHADER_VARIABLE_INT); | 10060 index, SHADER_VARIABLE_INT); |
| 10044 glVertexAttribI4iv(index, v); | 10061 glVertexAttribI4iv(index, t); |
| 10045 } | 10062 } |
| 10046 } | 10063 } |
| 10047 | 10064 |
| 10048 void GLES2DecoderImpl::DoVertexAttribI4ui( | 10065 void GLES2DecoderImpl::DoVertexAttribI4ui( |
| 10049 GLuint index, GLuint v0, GLuint v1, GLuint v2, GLuint v3) { | 10066 GLuint index, GLuint v0, GLuint v1, GLuint v2, GLuint v3) { |
| 10050 GLuint v[4] = { v0, v1, v2, v3 }; | 10067 GLuint v[4] = { v0, v1, v2, v3 }; |
| 10051 if (SetVertexAttribValue("glVertexAttribI4ui", index, v)) { | 10068 if (SetVertexAttribValue("glVertexAttribI4ui", index, v)) { |
| 10052 state_.SetGenericVertexAttribBaseType( | 10069 state_.SetGenericVertexAttribBaseType( |
| 10053 index, SHADER_VARIABLE_UINT); | 10070 index, SHADER_VARIABLE_UINT); |
| 10054 glVertexAttribI4ui(index, v0, v1, v2, v3); | 10071 glVertexAttribI4ui(index, v0, v1, v2, v3); |
| 10055 } | 10072 } |
| 10056 } | 10073 } |
| 10057 | 10074 |
| 10058 void GLES2DecoderImpl::DoVertexAttribI4uiv(GLuint index, const GLuint* v) { | 10075 void GLES2DecoderImpl::DoVertexAttribI4uiv(GLuint index, const GLuint* v) { |
| 10059 if (SetVertexAttribValue("glVertexAttribI4uiv", index, v)) { | 10076 GLuint t[4] = {v[0], v[1], v[2], v[3]}; |
| 10077 if (SetVertexAttribValue("glVertexAttribI4uiv", index, t)) { | |
| 10060 state_.SetGenericVertexAttribBaseType( | 10078 state_.SetGenericVertexAttribBaseType( |
| 10061 index, SHADER_VARIABLE_UINT); | 10079 index, SHADER_VARIABLE_UINT); |
| 10062 glVertexAttribI4uiv(index, v); | 10080 glVertexAttribI4uiv(index, t); |
| 10063 } | 10081 } |
| 10064 } | 10082 } |
| 10065 | 10083 |
| 10066 error::Error GLES2DecoderImpl::HandleVertexAttribIPointer( | 10084 error::Error GLES2DecoderImpl::HandleVertexAttribIPointer( |
| 10067 uint32_t immediate_data_size, | 10085 uint32_t immediate_data_size, |
| 10068 const void* cmd_data) { | 10086 const void* cmd_data) { |
| 10069 if (!unsafe_es3_apis_enabled()) | 10087 if (!unsafe_es3_apis_enabled()) |
| 10070 return error::kUnknownCommand; | 10088 return error::kUnknownCommand; |
| 10071 const gles2::cmds::VertexAttribIPointer& c = | 10089 const gles2::cmds::VertexAttribIPointer& c = |
| 10072 *static_cast<const gles2::cmds::VertexAttribIPointer*>(cmd_data); | 10090 *static_cast<const gles2::cmds::VertexAttribIPointer*>(cmd_data); |
| (...skipping 4518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 14591 GLsizei n, const GLuint* client_ids) { | 14609 GLsizei n, const GLuint* client_ids) { |
| 14592 for (GLsizei ii = 0; ii < n; ++ii) { | 14610 for (GLsizei ii = 0; ii < n; ++ii) { |
| 14593 if (query_manager_->IsValidQuery(client_ids[ii])) { | 14611 if (query_manager_->IsValidQuery(client_ids[ii])) { |
| 14594 return false; | 14612 return false; |
| 14595 } | 14613 } |
| 14596 } | 14614 } |
| 14597 query_manager_->GenQueries(n, client_ids); | 14615 query_manager_->GenQueries(n, client_ids); |
| 14598 return true; | 14616 return true; |
| 14599 } | 14617 } |
| 14600 | 14618 |
| 14601 void GLES2DecoderImpl::DeleteQueriesEXTHelper( | 14619 void GLES2DecoderImpl::DeleteQueriesEXTHelper(GLsizei n, |
| 14602 GLsizei n, const GLuint* client_ids) { | 14620 const GLuint* client_ids) { |
| 14603 for (GLsizei ii = 0; ii < n; ++ii) { | 14621 for (GLsizei ii = 0; ii < n; ++ii) { |
| 14604 query_manager_->RemoveQuery(client_ids[ii]); | 14622 GLuint client_id = client_ids[ii]; |
| 14623 query_manager_->RemoveQuery(client_id); | |
| 14605 } | 14624 } |
| 14606 } | 14625 } |
| 14607 | 14626 |
| 14608 bool GLES2DecoderImpl::HasPendingQueries() const { | 14627 bool GLES2DecoderImpl::HasPendingQueries() const { |
| 14609 return query_manager_.get() && query_manager_->HavePendingQueries(); | 14628 return query_manager_.get() && query_manager_->HavePendingQueries(); |
| 14610 } | 14629 } |
| 14611 | 14630 |
| 14612 void GLES2DecoderImpl::ProcessPendingQueries(bool did_finish) { | 14631 void GLES2DecoderImpl::ProcessPendingQueries(bool did_finish) { |
| 14613 if (!query_manager_.get()) | 14632 if (!query_manager_.get()) |
| 14614 return; | 14633 return; |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 14865 | 14884 |
| 14866 glGenVertexArraysOES(n, service_ids.get()); | 14885 glGenVertexArraysOES(n, service_ids.get()); |
| 14867 for (GLsizei ii = 0; ii < n; ++ii) { | 14886 for (GLsizei ii = 0; ii < n; ++ii) { |
| 14868 CreateVertexAttribManager(client_ids[ii], service_ids[ii], true); | 14887 CreateVertexAttribManager(client_ids[ii], service_ids[ii], true); |
| 14869 } | 14888 } |
| 14870 } | 14889 } |
| 14871 | 14890 |
| 14872 return true; | 14891 return true; |
| 14873 } | 14892 } |
| 14874 | 14893 |
| 14875 void GLES2DecoderImpl::DeleteVertexArraysOESHelper( | 14894 void GLES2DecoderImpl::DeleteVertexArraysOESHelper(GLsizei n, |
| 14876 GLsizei n, const GLuint* client_ids) { | 14895 const GLuint* client_ids) { |
| 14877 for (GLsizei ii = 0; ii < n; ++ii) { | 14896 for (GLsizei ii = 0; ii < n; ++ii) { |
| 14878 VertexAttribManager* vao = | 14897 GLuint client_id = client_ids[ii]; |
| 14879 GetVertexAttribManager(client_ids[ii]); | 14898 VertexAttribManager* vao = GetVertexAttribManager(client_id); |
| 14880 if (vao && !vao->IsDeleted()) { | 14899 if (vao && !vao->IsDeleted()) { |
| 14881 if (state_.vertex_attrib_manager.get() == vao) { | 14900 if (state_.vertex_attrib_manager.get() == vao) { |
| 14882 DoBindVertexArrayOES(0); | 14901 DoBindVertexArrayOES(0); |
| 14883 } | 14902 } |
| 14884 RemoveVertexAttribManager(client_ids[ii]); | 14903 RemoveVertexAttribManager(client_id); |
| 14885 } | 14904 } |
| 14886 } | 14905 } |
| 14887 } | 14906 } |
| 14888 | 14907 |
| 14889 void GLES2DecoderImpl::DoBindVertexArrayOES(GLuint client_id) { | 14908 void GLES2DecoderImpl::DoBindVertexArrayOES(GLuint client_id) { |
| 14890 VertexAttribManager* vao = NULL; | 14909 VertexAttribManager* vao = NULL; |
| 14891 if (client_id != 0) { | 14910 if (client_id != 0) { |
| 14892 vao = GetVertexAttribManager(client_id); | 14911 vao = GetVertexAttribManager(client_id); |
| 14893 if (!vao) { | 14912 if (!vao) { |
| 14894 // Unlike most Bind* methods, the spec explicitly states that VertexArray | 14913 // Unlike most Bind* methods, the spec explicitly states that VertexArray |
| (...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 15782 | 15801 |
| 15783 ProduceTextureRef("glProduceTextureDirectCHROMIUM", !client_id, | 15802 ProduceTextureRef("glProduceTextureDirectCHROMIUM", !client_id, |
| 15784 GetTexture(client_id), target, data); | 15803 GetTexture(client_id), target, data); |
| 15785 } | 15804 } |
| 15786 | 15805 |
| 15787 void GLES2DecoderImpl::ProduceTextureRef(const char* func_name, | 15806 void GLES2DecoderImpl::ProduceTextureRef(const char* func_name, |
| 15788 bool clear, | 15807 bool clear, |
| 15789 TextureRef* texture_ref, | 15808 TextureRef* texture_ref, |
| 15790 GLenum target, | 15809 GLenum target, |
| 15791 const GLbyte* data) { | 15810 const GLbyte* data) { |
| 15792 const Mailbox mailbox = *reinterpret_cast<const Mailbox*>(data); | 15811 Mailbox mailbox = *reinterpret_cast<const Mailbox*>(data); |
| 15793 DLOG_IF(ERROR, !mailbox.Verify()) << func_name << " was passed a " | 15812 DLOG_IF(ERROR, !mailbox.Verify()) << func_name << " was passed a " |
| 15794 "mailbox that was not generated by " | 15813 "mailbox that was not generated by " |
| 15795 "GenMailboxCHROMIUM."; | 15814 "GenMailboxCHROMIUM."; |
| 15796 | 15815 |
| 15797 if (clear) { | 15816 if (clear) { |
| 15798 DCHECK(!texture_ref); | 15817 DCHECK(!texture_ref); |
| 15799 | 15818 |
| 15800 group_->mailbox_manager()->ProduceTexture(mailbox, nullptr); | 15819 group_->mailbox_manager()->ProduceTexture(mailbox, nullptr); |
| 15801 return; | 15820 return; |
| 15802 } | 15821 } |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 15821 } | 15840 } |
| 15822 | 15841 |
| 15823 group_->mailbox_manager()->ProduceTexture(mailbox, produced); | 15842 group_->mailbox_manager()->ProduceTexture(mailbox, produced); |
| 15824 } | 15843 } |
| 15825 | 15844 |
| 15826 void GLES2DecoderImpl::DoConsumeTextureCHROMIUM(GLenum target, | 15845 void GLES2DecoderImpl::DoConsumeTextureCHROMIUM(GLenum target, |
| 15827 const GLbyte* data) { | 15846 const GLbyte* data) { |
| 15828 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoConsumeTextureCHROMIUM", | 15847 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoConsumeTextureCHROMIUM", |
| 15829 "context", logger_.GetLogPrefix(), | 15848 "context", logger_.GetLogPrefix(), |
| 15830 "mailbox[0]", static_cast<unsigned char>(data[0])); | 15849 "mailbox[0]", static_cast<unsigned char>(data[0])); |
| 15831 const Mailbox& mailbox = *reinterpret_cast<const Mailbox*>(data); | 15850 Mailbox mailbox = *reinterpret_cast<const Mailbox*>(data); |
| 15832 DLOG_IF(ERROR, !mailbox.Verify()) << "ConsumeTextureCHROMIUM was passed a " | 15851 DLOG_IF(ERROR, !mailbox.Verify()) << "ConsumeTextureCHROMIUM was passed a " |
| 15833 "mailbox that was not generated by " | 15852 "mailbox that was not generated by " |
| 15834 "GenMailboxCHROMIUM."; | 15853 "GenMailboxCHROMIUM."; |
| 15835 | 15854 |
| 15836 scoped_refptr<TextureRef> texture_ref = | 15855 scoped_refptr<TextureRef> texture_ref = |
| 15837 texture_manager()->GetTextureInfoForTargetUnlessDefault(&state_, target); | 15856 texture_manager()->GetTextureInfoForTargetUnlessDefault(&state_, target); |
| 15838 if (!texture_ref.get()) { | 15857 if (!texture_ref.get()) { |
| 15839 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, | 15858 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, |
| 15840 "glConsumeTextureCHROMIUM", | 15859 "glConsumeTextureCHROMIUM", |
| 15841 "unknown texture for target"); | 15860 "unknown texture for target"); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 15885 RestoreCurrentTextureBindings(&state_, target); | 15904 RestoreCurrentTextureBindings(&state_, target); |
| 15886 } | 15905 } |
| 15887 } | 15906 } |
| 15888 | 15907 |
| 15889 void GLES2DecoderImpl::DoCreateAndConsumeTextureINTERNAL(GLenum target, | 15908 void GLES2DecoderImpl::DoCreateAndConsumeTextureINTERNAL(GLenum target, |
| 15890 GLuint client_id, | 15909 GLuint client_id, |
| 15891 const GLbyte* data) { | 15910 const GLbyte* data) { |
| 15892 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoCreateAndConsumeTextureINTERNAL", | 15911 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoCreateAndConsumeTextureINTERNAL", |
| 15893 "context", logger_.GetLogPrefix(), | 15912 "context", logger_.GetLogPrefix(), |
| 15894 "mailbox[0]", static_cast<unsigned char>(data[0])); | 15913 "mailbox[0]", static_cast<unsigned char>(data[0])); |
| 15895 const Mailbox& mailbox = *reinterpret_cast<const Mailbox*>(data); | 15914 Mailbox mailbox = *reinterpret_cast<const Mailbox*>(data); |
| 15896 DLOG_IF(ERROR, !mailbox.Verify()) << "CreateAndConsumeTextureCHROMIUM was " | 15915 DLOG_IF(ERROR, !mailbox.Verify()) << "CreateAndConsumeTextureCHROMIUM was " |
| 15897 "passed a mailbox that was not " | 15916 "passed a mailbox that was not " |
| 15898 "generated by GenMailboxCHROMIUM."; | 15917 "generated by GenMailboxCHROMIUM."; |
| 15899 | 15918 |
| 15900 TextureRef* texture_ref = GetTexture(client_id); | 15919 TextureRef* texture_ref = GetTexture(client_id); |
| 15901 if (texture_ref) { | 15920 if (texture_ref) { |
| 15902 // No need to call EnsureTextureForClientId here, the client_id already has | 15921 // No need to call EnsureTextureForClientId here, the client_id already has |
| 15903 // an associated texture. | 15922 // an associated texture. |
| 15904 LOCAL_SET_GL_ERROR( | 15923 LOCAL_SET_GL_ERROR( |
| 15905 GL_INVALID_OPERATION, | 15924 GL_INVALID_OPERATION, |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 16095 debug_marker_manager_.PopGroup(); | 16114 debug_marker_manager_.PopGroup(); |
| 16096 if (!gpu_tracer_->End(kTraceCHROMIUM)) { | 16115 if (!gpu_tracer_->End(kTraceCHROMIUM)) { |
| 16097 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, | 16116 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, |
| 16098 "glTraceEndCHROMIUM", "no trace begin found"); | 16117 "glTraceEndCHROMIUM", "no trace begin found"); |
| 16099 return; | 16118 return; |
| 16100 } | 16119 } |
| 16101 } | 16120 } |
| 16102 | 16121 |
| 16103 void GLES2DecoderImpl::DoDrawBuffersEXT( | 16122 void GLES2DecoderImpl::DoDrawBuffersEXT( |
| 16104 GLsizei count, const GLenum* bufs) { | 16123 GLsizei count, const GLenum* bufs) { |
| 16124 DCHECK_LE(group_->max_draw_buffers(), 16u); | |
| 16105 if (count > static_cast<GLsizei>(group_->max_draw_buffers())) { | 16125 if (count > static_cast<GLsizei>(group_->max_draw_buffers())) { |
| 16106 LOCAL_SET_GL_ERROR( | 16126 LOCAL_SET_GL_ERROR( |
| 16107 GL_INVALID_VALUE, | 16127 GL_INVALID_VALUE, |
| 16108 "glDrawBuffersEXT", "greater than GL_MAX_DRAW_BUFFERS_EXT"); | 16128 "glDrawBuffersEXT", "greater than GL_MAX_DRAW_BUFFERS_EXT"); |
| 16109 return; | 16129 return; |
| 16110 } | 16130 } |
| 16111 | 16131 |
| 16112 Framebuffer* framebuffer = GetFramebufferInfoForTarget(GL_FRAMEBUFFER); | 16132 Framebuffer* framebuffer = GetFramebufferInfoForTarget(GL_FRAMEBUFFER); |
| 16113 if (framebuffer) { | 16133 if (framebuffer) { |
| 16134 GLenum safe_bufs[16]; | |
| 16114 for (GLsizei i = 0; i < count; ++i) { | 16135 for (GLsizei i = 0; i < count; ++i) { |
| 16115 if (bufs[i] != static_cast<GLenum>(GL_COLOR_ATTACHMENT0 + i) && | 16136 GLenum buf = bufs[i]; |
| 16116 bufs[i] != GL_NONE) { | 16137 if (buf != static_cast<GLenum>(GL_COLOR_ATTACHMENT0 + i) && |
| 16138 buf != GL_NONE) { | |
| 16117 LOCAL_SET_GL_ERROR( | 16139 LOCAL_SET_GL_ERROR( |
| 16118 GL_INVALID_OPERATION, | 16140 GL_INVALID_OPERATION, |
| 16119 "glDrawBuffersEXT", | 16141 "glDrawBuffersEXT", |
| 16120 "bufs[i] not GL_NONE or GL_COLOR_ATTACHMENTi_EXT"); | 16142 "bufs[i] not GL_NONE or GL_COLOR_ATTACHMENTi_EXT"); |
| 16121 return; | 16143 return; |
| 16122 } | 16144 } |
| 16145 safe_bufs[i] = buf; | |
| 16123 } | 16146 } |
| 16124 glDrawBuffersARB(count, bufs); | 16147 glDrawBuffersARB(count, safe_bufs); |
| 16125 framebuffer->SetDrawBuffers(count, bufs); | 16148 framebuffer->SetDrawBuffers(count, safe_bufs); |
| 16126 } else { // backbuffer | 16149 } else { // backbuffer |
| 16127 if (count != 1 || | 16150 if (count != 1) { |
| 16128 (bufs[0] != GL_BACK && bufs[0] != GL_NONE)) { | 16151 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glDrawBuffersEXT", |
| 16129 LOCAL_SET_GL_ERROR( | 16152 "invalid number of buffers"); |
| 16130 GL_INVALID_OPERATION, | |
| 16131 "glDrawBuffersEXT", | |
| 16132 "more than one buffer or bufs not GL_NONE or GL_BACK"); | |
| 16133 return; | 16153 return; |
| 16134 } | 16154 } |
| 16135 GLenum mapped_buf = bufs[0]; | 16155 GLenum buf = bufs[0]; |
| 16136 if (GetBackbufferServiceId() != 0 && // emulated backbuffer | 16156 if (buf != GL_BACK && buf != GL_NONE) { |
| 16137 bufs[0] == GL_BACK) { | 16157 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glDrawBuffersEXT", |
| 16138 mapped_buf = GL_COLOR_ATTACHMENT0; | 16158 "buffer is not GL_NONE or GL_BACK"); |
| 16159 return; | |
| 16139 } | 16160 } |
| 16140 glDrawBuffersARB(count, &mapped_buf); | 16161 if (buf == GL_BACK && GetBackbufferServiceId() != 0) // emulated backbuffer |
| 16141 back_buffer_draw_buffer_ = bufs[0]; | 16162 buf = GL_COLOR_ATTACHMENT0; |
| 16163 glDrawBuffersARB(count, &buf); | |
| 16164 back_buffer_draw_buffer_ = buf; | |
|
Zhenyao Mo
2016/08/23 23:53:06
Here we should store the user buffer, not the mapp
piman
2016/08/24 00:10:32
Thanks for the catch, done.
| |
| 16142 } | 16165 } |
| 16143 } | 16166 } |
| 16144 | 16167 |
| 16145 void GLES2DecoderImpl::DoLoseContextCHROMIUM(GLenum current, GLenum other) { | 16168 void GLES2DecoderImpl::DoLoseContextCHROMIUM(GLenum current, GLenum other) { |
| 16146 MarkContextLost(GetContextLostReasonFromResetStatus(current)); | 16169 MarkContextLost(GetContextLostReasonFromResetStatus(current)); |
| 16147 group_->LoseContexts(GetContextLostReasonFromResetStatus(other)); | 16170 group_->LoseContexts(GetContextLostReasonFromResetStatus(other)); |
| 16148 reset_by_robustness_extension_ = true; | 16171 reset_by_robustness_extension_ = true; |
| 16149 } | 16172 } |
| 16150 | 16173 |
| 16151 void GLES2DecoderImpl::DoFlushDriverCachesCHROMIUM(void) { | 16174 void GLES2DecoderImpl::DoFlushDriverCachesCHROMIUM(void) { |
| 16152 // On Adreno Android devices we need to use a workaround to force caches to | 16175 // On Adreno Android devices we need to use a workaround to force caches to |
| 16153 // clear. | 16176 // clear. |
| 16154 if (feature_info_->workarounds().unbind_egl_context_to_flush_driver_caches) { | 16177 if (feature_info_->workarounds().unbind_egl_context_to_flush_driver_caches) { |
| 16155 context_->ReleaseCurrent(nullptr); | 16178 context_->ReleaseCurrent(nullptr); |
| 16156 context_->MakeCurrent(surface_.get()); | 16179 context_->MakeCurrent(surface_.get()); |
| 16157 } | 16180 } |
| 16158 } | 16181 } |
| 16159 | 16182 |
| 16160 void GLES2DecoderImpl::DoMatrixLoadfCHROMIUM(GLenum matrix_mode, | 16183 void GLES2DecoderImpl::DoMatrixLoadfCHROMIUM(GLenum matrix_mode, |
| 16161 const GLfloat* matrix) { | 16184 const GLfloat* matrix) { |
| 16162 DCHECK(matrix_mode == GL_PATH_PROJECTION_CHROMIUM || | 16185 DCHECK(matrix_mode == GL_PATH_PROJECTION_CHROMIUM || |
| 16163 matrix_mode == GL_PATH_MODELVIEW_CHROMIUM); | 16186 matrix_mode == GL_PATH_MODELVIEW_CHROMIUM); |
| 16164 | 16187 |
| 16165 GLfloat* target_matrix = matrix_mode == GL_PATH_PROJECTION_CHROMIUM | 16188 GLfloat* target_matrix = matrix_mode == GL_PATH_PROJECTION_CHROMIUM |
| 16166 ? state_.projection_matrix | 16189 ? state_.projection_matrix |
| 16167 : state_.modelview_matrix; | 16190 : state_.modelview_matrix; |
| 16168 memcpy(target_matrix, matrix, sizeof(GLfloat) * 16); | 16191 memcpy(target_matrix, matrix, sizeof(GLfloat) * 16); |
| 16169 // The matrix_mode is either GL_PATH_MODELVIEW_NV or GL_PATH_PROJECTION_NV | 16192 // The matrix_mode is either GL_PATH_MODELVIEW_NV or GL_PATH_PROJECTION_NV |
| 16170 // since the values of the _NV and _CHROMIUM tokens match. | 16193 // since the values of the _NV and _CHROMIUM tokens match. |
| 16171 glMatrixLoadfEXT(matrix_mode, matrix); | 16194 glMatrixLoadfEXT(matrix_mode, target_matrix); |
| 16172 } | 16195 } |
| 16173 | 16196 |
| 16174 void GLES2DecoderImpl::DoMatrixLoadIdentityCHROMIUM(GLenum matrix_mode) { | 16197 void GLES2DecoderImpl::DoMatrixLoadIdentityCHROMIUM(GLenum matrix_mode) { |
| 16175 DCHECK(matrix_mode == GL_PATH_PROJECTION_CHROMIUM || | 16198 DCHECK(matrix_mode == GL_PATH_PROJECTION_CHROMIUM || |
| 16176 matrix_mode == GL_PATH_MODELVIEW_CHROMIUM); | 16199 matrix_mode == GL_PATH_MODELVIEW_CHROMIUM); |
| 16177 | 16200 |
| 16178 GLfloat* target_matrix = matrix_mode == GL_PATH_PROJECTION_CHROMIUM | 16201 GLfloat* target_matrix = matrix_mode == GL_PATH_PROJECTION_CHROMIUM |
| 16179 ? state_.projection_matrix | 16202 ? state_.projection_matrix |
| 16180 : state_.modelview_matrix; | 16203 : state_.modelview_matrix; |
| 16181 memcpy(target_matrix, kIdentityMatrix, sizeof(kIdentityMatrix)); | 16204 memcpy(target_matrix, kIdentityMatrix, sizeof(kIdentityMatrix)); |
| (...skipping 1512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 17694 } | 17717 } |
| 17695 | 17718 |
| 17696 // Include the auto-generated part of this file. We split this because it means | 17719 // Include the auto-generated part of this file. We split this because it means |
| 17697 // we can easily edit the non-auto generated parts right here in this file | 17720 // we can easily edit the non-auto generated parts right here in this file |
| 17698 // instead of having to edit some template or the code generator. | 17721 // instead of having to edit some template or the code generator. |
| 17699 #include "base/macros.h" | 17722 #include "base/macros.h" |
| 17700 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 17723 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 17701 | 17724 |
| 17702 } // namespace gles2 | 17725 } // namespace gles2 |
| 17703 } // namespace gpu | 17726 } // namespace gpu |
| OLD | NEW |