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

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

Issue 2264253003: Command buffers: ensure we only read immediate data once (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
6 6
7 #include <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
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
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
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* value) {
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 GLint safe_value = *value;
8260 if (type == GL_SAMPLER_2D || type == GL_SAMPLER_2D_RECT_ARB || 8273 if (type == GL_SAMPLER_2D || type == GL_SAMPLER_2D_RECT_ARB ||
8261 type == GL_SAMPLER_CUBE || type == GL_SAMPLER_EXTERNAL_OES) { 8274 type == GL_SAMPLER_CUBE || type == GL_SAMPLER_EXTERNAL_OES) {
8262 if (!state_.current_program->SetSamplers( 8275 if (!state_.current_program->SetSamplers(
8263 state_.texture_units.size(), fake_location, count, value)) { 8276 state_.texture_units.size(), fake_location, count, &safe_value)) {
8264 LOCAL_SET_GL_ERROR( 8277 LOCAL_SET_GL_ERROR(
8265 GL_INVALID_VALUE, "glUniform1iv", "texture unit out of range"); 8278 GL_INVALID_VALUE, "glUniform1iv", "texture unit out of range");
8266 return; 8279 return;
8267 } 8280 }
8268 } 8281 }
8269 glUniform1iv(real_location, count, value); 8282 glUniform1iv(real_location, count, &safe_value);
8270 } 8283 }
8271 8284
8272 void GLES2DecoderImpl::DoUniform1uiv( 8285 void GLES2DecoderImpl::DoUniform1uiv(
8273 GLint fake_location, GLsizei count, const GLuint *value) { 8286 GLint fake_location, GLsizei count, const GLuint *value) {
8274 GLenum type = 0; 8287 GLenum type = 0;
8275 GLint real_location = -1; 8288 GLint real_location = -1;
8276 if (!PrepForSetUniformByLocation(fake_location, 8289 if (!PrepForSetUniformByLocation(fake_location,
8277 "glUniform1uiv", 8290 "glUniform1uiv",
8278 Program::kUniform1ui, 8291 Program::kUniform1ui,
8279 &real_location, 8292 &real_location,
(...skipping 1710 matching lines...) Expand 10 before | Expand all | Expand 10 after
9990 index, SHADER_VARIABLE_FLOAT); 10003 index, SHADER_VARIABLE_FLOAT);
9991 glVertexAttrib4f(index, v0, v1, v2, v3); 10004 glVertexAttrib4f(index, v0, v1, v2, v3);
9992 } 10005 }
9993 } 10006 }
9994 10007
9995 void GLES2DecoderImpl::DoVertexAttrib1fv(GLuint index, const GLfloat* v) { 10008 void GLES2DecoderImpl::DoVertexAttrib1fv(GLuint index, const GLfloat* v) {
9996 GLfloat t[4] = { v[0], 0.0f, 0.0f, 1.0f, }; 10009 GLfloat t[4] = { v[0], 0.0f, 0.0f, 1.0f, };
9997 if (SetVertexAttribValue("glVertexAttrib1fv", index, t)) { 10010 if (SetVertexAttribValue("glVertexAttrib1fv", index, t)) {
9998 state_.SetGenericVertexAttribBaseType( 10011 state_.SetGenericVertexAttribBaseType(
9999 index, SHADER_VARIABLE_FLOAT); 10012 index, SHADER_VARIABLE_FLOAT);
10000 glVertexAttrib1fv(index, v); 10013 glVertexAttrib1fv(index, t);
10001 } 10014 }
10002 } 10015 }
10003 10016
10004 void GLES2DecoderImpl::DoVertexAttrib2fv(GLuint index, const GLfloat* v) { 10017 void GLES2DecoderImpl::DoVertexAttrib2fv(GLuint index, const GLfloat* v) {
10005 GLfloat t[4] = { v[0], v[1], 0.0f, 1.0f, }; 10018 GLfloat t[4] = { v[0], v[1], 0.0f, 1.0f, };
10006 if (SetVertexAttribValue("glVertexAttrib2fv", index, t)) { 10019 if (SetVertexAttribValue("glVertexAttrib2fv", index, t)) {
10007 state_.SetGenericVertexAttribBaseType( 10020 state_.SetGenericVertexAttribBaseType(
10008 index, SHADER_VARIABLE_FLOAT); 10021 index, SHADER_VARIABLE_FLOAT);
10009 glVertexAttrib2fv(index, v); 10022 glVertexAttrib2fv(index, t);
10010 } 10023 }
10011 } 10024 }
10012 10025
10013 void GLES2DecoderImpl::DoVertexAttrib3fv(GLuint index, const GLfloat* v) { 10026 void GLES2DecoderImpl::DoVertexAttrib3fv(GLuint index, const GLfloat* v) {
10014 GLfloat t[4] = { v[0], v[1], v[2], 1.0f, }; 10027 GLfloat t[4] = { v[0], v[1], v[2], 1.0f, };
10015 if (SetVertexAttribValue("glVertexAttrib3fv", index, t)) { 10028 if (SetVertexAttribValue("glVertexAttrib3fv", index, t)) {
10016 state_.SetGenericVertexAttribBaseType( 10029 state_.SetGenericVertexAttribBaseType(
10017 index, SHADER_VARIABLE_FLOAT); 10030 index, SHADER_VARIABLE_FLOAT);
10018 glVertexAttrib3fv(index, v); 10031 glVertexAttrib3fv(index, t);
10019 } 10032 }
10020 } 10033 }
10021 10034
10022 void GLES2DecoderImpl::DoVertexAttrib4fv(GLuint index, const GLfloat* v) { 10035 void GLES2DecoderImpl::DoVertexAttrib4fv(GLuint index, const GLfloat* v) {
10023 if (SetVertexAttribValue("glVertexAttrib4fv", index, v)) { 10036 GLfloat t[4] = {v[0], v[1], v[2], v[3]};
10037 if (SetVertexAttribValue("glVertexAttrib4fv", index, t)) {
10024 state_.SetGenericVertexAttribBaseType( 10038 state_.SetGenericVertexAttribBaseType(
10025 index, SHADER_VARIABLE_FLOAT); 10039 index, SHADER_VARIABLE_FLOAT);
10026 glVertexAttrib4fv(index, v); 10040 glVertexAttrib4fv(index, t);
10027 } 10041 }
10028 } 10042 }
10029 10043
10030 void GLES2DecoderImpl::DoVertexAttribI4i( 10044 void GLES2DecoderImpl::DoVertexAttribI4i(
10031 GLuint index, GLint v0, GLint v1, GLint v2, GLint v3) { 10045 GLuint index, GLint v0, GLint v1, GLint v2, GLint v3) {
10032 GLint v[4] = { v0, v1, v2, v3 }; 10046 GLint v[4] = { v0, v1, v2, v3 };
10033 if (SetVertexAttribValue("glVertexAttribI4i", index, v)) { 10047 if (SetVertexAttribValue("glVertexAttribI4i", index, v)) {
10034 state_.SetGenericVertexAttribBaseType( 10048 state_.SetGenericVertexAttribBaseType(
10035 index, SHADER_VARIABLE_INT); 10049 index, SHADER_VARIABLE_INT);
10036 glVertexAttribI4i(index, v0, v1, v2, v3); 10050 glVertexAttribI4i(index, v0, v1, v2, v3);
10037 } 10051 }
10038 } 10052 }
10039 10053
10040 void GLES2DecoderImpl::DoVertexAttribI4iv(GLuint index, const GLint* v) { 10054 void GLES2DecoderImpl::DoVertexAttribI4iv(GLuint index, const GLint* v) {
10041 if (SetVertexAttribValue("glVertexAttribI4iv", index, v)) { 10055 GLint t[4] = {v[0], v[1], v[2], v[3]};
10056 if (SetVertexAttribValue("glVertexAttribI4iv", index, t)) {
10042 state_.SetGenericVertexAttribBaseType( 10057 state_.SetGenericVertexAttribBaseType(
10043 index, SHADER_VARIABLE_INT); 10058 index, SHADER_VARIABLE_INT);
10044 glVertexAttribI4iv(index, v); 10059 glVertexAttribI4iv(index, t);
10045 } 10060 }
10046 } 10061 }
10047 10062
10048 void GLES2DecoderImpl::DoVertexAttribI4ui( 10063 void GLES2DecoderImpl::DoVertexAttribI4ui(
10049 GLuint index, GLuint v0, GLuint v1, GLuint v2, GLuint v3) { 10064 GLuint index, GLuint v0, GLuint v1, GLuint v2, GLuint v3) {
10050 GLuint v[4] = { v0, v1, v2, v3 }; 10065 GLuint v[4] = { v0, v1, v2, v3 };
10051 if (SetVertexAttribValue("glVertexAttribI4ui", index, v)) { 10066 if (SetVertexAttribValue("glVertexAttribI4ui", index, v)) {
10052 state_.SetGenericVertexAttribBaseType( 10067 state_.SetGenericVertexAttribBaseType(
10053 index, SHADER_VARIABLE_UINT); 10068 index, SHADER_VARIABLE_UINT);
10054 glVertexAttribI4ui(index, v0, v1, v2, v3); 10069 glVertexAttribI4ui(index, v0, v1, v2, v3);
10055 } 10070 }
10056 } 10071 }
10057 10072
10058 void GLES2DecoderImpl::DoVertexAttribI4uiv(GLuint index, const GLuint* v) { 10073 void GLES2DecoderImpl::DoVertexAttribI4uiv(GLuint index, const GLuint* v) {
10059 if (SetVertexAttribValue("glVertexAttribI4uiv", index, v)) { 10074 GLuint t[4] = {v[0], v[1], v[2], v[3]};
10075 if (SetVertexAttribValue("glVertexAttribI4uiv", index, t)) {
10060 state_.SetGenericVertexAttribBaseType( 10076 state_.SetGenericVertexAttribBaseType(
10061 index, SHADER_VARIABLE_UINT); 10077 index, SHADER_VARIABLE_UINT);
10062 glVertexAttribI4uiv(index, v); 10078 glVertexAttribI4uiv(index, t);
10063 } 10079 }
10064 } 10080 }
10065 10081
10066 error::Error GLES2DecoderImpl::HandleVertexAttribIPointer( 10082 error::Error GLES2DecoderImpl::HandleVertexAttribIPointer(
10067 uint32_t immediate_data_size, 10083 uint32_t immediate_data_size,
10068 const void* cmd_data) { 10084 const void* cmd_data) {
10069 if (!unsafe_es3_apis_enabled()) 10085 if (!unsafe_es3_apis_enabled())
10070 return error::kUnknownCommand; 10086 return error::kUnknownCommand;
10071 const gles2::cmds::VertexAttribIPointer& c = 10087 const gles2::cmds::VertexAttribIPointer& c =
10072 *static_cast<const gles2::cmds::VertexAttribIPointer*>(cmd_data); 10088 *static_cast<const gles2::cmds::VertexAttribIPointer*>(cmd_data);
(...skipping 4518 matching lines...) Expand 10 before | Expand all | Expand 10 after
14591 GLsizei n, const GLuint* client_ids) { 14607 GLsizei n, const GLuint* client_ids) {
14592 for (GLsizei ii = 0; ii < n; ++ii) { 14608 for (GLsizei ii = 0; ii < n; ++ii) {
14593 if (query_manager_->IsValidQuery(client_ids[ii])) { 14609 if (query_manager_->IsValidQuery(client_ids[ii])) {
14594 return false; 14610 return false;
14595 } 14611 }
14596 } 14612 }
14597 query_manager_->GenQueries(n, client_ids); 14613 query_manager_->GenQueries(n, client_ids);
14598 return true; 14614 return true;
14599 } 14615 }
14600 14616
14601 void GLES2DecoderImpl::DeleteQueriesEXTHelper( 14617 void GLES2DecoderImpl::DeleteQueriesEXTHelper(GLsizei n,
14602 GLsizei n, const GLuint* client_ids) { 14618 const GLuint* client_ids) {
14603 for (GLsizei ii = 0; ii < n; ++ii) { 14619 for (GLsizei ii = 0; ii < n; ++ii) {
14604 query_manager_->RemoveQuery(client_ids[ii]); 14620 GLuint client_id = client_ids[ii];
14621 query_manager_->RemoveQuery(client_id);
14605 } 14622 }
14606 } 14623 }
14607 14624
14608 bool GLES2DecoderImpl::HasPendingQueries() const { 14625 bool GLES2DecoderImpl::HasPendingQueries() const {
14609 return query_manager_.get() && query_manager_->HavePendingQueries(); 14626 return query_manager_.get() && query_manager_->HavePendingQueries();
14610 } 14627 }
14611 14628
14612 void GLES2DecoderImpl::ProcessPendingQueries(bool did_finish) { 14629 void GLES2DecoderImpl::ProcessPendingQueries(bool did_finish) {
14613 if (!query_manager_.get()) 14630 if (!query_manager_.get())
14614 return; 14631 return;
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
14865 14882
14866 glGenVertexArraysOES(n, service_ids.get()); 14883 glGenVertexArraysOES(n, service_ids.get());
14867 for (GLsizei ii = 0; ii < n; ++ii) { 14884 for (GLsizei ii = 0; ii < n; ++ii) {
14868 CreateVertexAttribManager(client_ids[ii], service_ids[ii], true); 14885 CreateVertexAttribManager(client_ids[ii], service_ids[ii], true);
14869 } 14886 }
14870 } 14887 }
14871 14888
14872 return true; 14889 return true;
14873 } 14890 }
14874 14891
14875 void GLES2DecoderImpl::DeleteVertexArraysOESHelper( 14892 void GLES2DecoderImpl::DeleteVertexArraysOESHelper(GLsizei n,
14876 GLsizei n, const GLuint* client_ids) { 14893 const GLuint* client_ids) {
14877 for (GLsizei ii = 0; ii < n; ++ii) { 14894 for (GLsizei ii = 0; ii < n; ++ii) {
14878 VertexAttribManager* vao = 14895 GLuint client_id = client_ids[ii];
14879 GetVertexAttribManager(client_ids[ii]); 14896 VertexAttribManager* vao = GetVertexAttribManager(client_id);
14880 if (vao && !vao->IsDeleted()) { 14897 if (vao && !vao->IsDeleted()) {
14881 if (state_.vertex_attrib_manager.get() == vao) { 14898 if (state_.vertex_attrib_manager.get() == vao) {
14882 DoBindVertexArrayOES(0); 14899 DoBindVertexArrayOES(0);
14883 } 14900 }
14884 RemoveVertexAttribManager(client_ids[ii]); 14901 RemoveVertexAttribManager(client_id);
14885 } 14902 }
14886 } 14903 }
14887 } 14904 }
14888 14905
14889 void GLES2DecoderImpl::DoBindVertexArrayOES(GLuint client_id) { 14906 void GLES2DecoderImpl::DoBindVertexArrayOES(GLuint client_id) {
14890 VertexAttribManager* vao = NULL; 14907 VertexAttribManager* vao = NULL;
14891 if (client_id != 0) { 14908 if (client_id != 0) {
14892 vao = GetVertexAttribManager(client_id); 14909 vao = GetVertexAttribManager(client_id);
14893 if (!vao) { 14910 if (!vao) {
14894 // Unlike most Bind* methods, the spec explicitly states that VertexArray 14911 // Unlike most Bind* methods, the spec explicitly states that VertexArray
(...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after
15782 15799
15783 ProduceTextureRef("glProduceTextureDirectCHROMIUM", !client_id, 15800 ProduceTextureRef("glProduceTextureDirectCHROMIUM", !client_id,
15784 GetTexture(client_id), target, data); 15801 GetTexture(client_id), target, data);
15785 } 15802 }
15786 15803
15787 void GLES2DecoderImpl::ProduceTextureRef(const char* func_name, 15804 void GLES2DecoderImpl::ProduceTextureRef(const char* func_name,
15788 bool clear, 15805 bool clear,
15789 TextureRef* texture_ref, 15806 TextureRef* texture_ref,
15790 GLenum target, 15807 GLenum target,
15791 const GLbyte* data) { 15808 const GLbyte* data) {
15792 const Mailbox mailbox = *reinterpret_cast<const Mailbox*>(data); 15809 Mailbox mailbox = *reinterpret_cast<const Mailbox*>(data);
15793 DLOG_IF(ERROR, !mailbox.Verify()) << func_name << " was passed a " 15810 DLOG_IF(ERROR, !mailbox.Verify()) << func_name << " was passed a "
15794 "mailbox that was not generated by " 15811 "mailbox that was not generated by "
15795 "GenMailboxCHROMIUM."; 15812 "GenMailboxCHROMIUM.";
15796 15813
15797 if (clear) { 15814 if (clear) {
15798 DCHECK(!texture_ref); 15815 DCHECK(!texture_ref);
15799 15816
15800 group_->mailbox_manager()->ProduceTexture(mailbox, nullptr); 15817 group_->mailbox_manager()->ProduceTexture(mailbox, nullptr);
15801 return; 15818 return;
15802 } 15819 }
(...skipping 18 matching lines...) Expand all
15821 } 15838 }
15822 15839
15823 group_->mailbox_manager()->ProduceTexture(mailbox, produced); 15840 group_->mailbox_manager()->ProduceTexture(mailbox, produced);
15824 } 15841 }
15825 15842
15826 void GLES2DecoderImpl::DoConsumeTextureCHROMIUM(GLenum target, 15843 void GLES2DecoderImpl::DoConsumeTextureCHROMIUM(GLenum target,
15827 const GLbyte* data) { 15844 const GLbyte* data) {
15828 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoConsumeTextureCHROMIUM", 15845 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoConsumeTextureCHROMIUM",
15829 "context", logger_.GetLogPrefix(), 15846 "context", logger_.GetLogPrefix(),
15830 "mailbox[0]", static_cast<unsigned char>(data[0])); 15847 "mailbox[0]", static_cast<unsigned char>(data[0]));
15831 const Mailbox& mailbox = *reinterpret_cast<const Mailbox*>(data); 15848 Mailbox mailbox = *reinterpret_cast<const Mailbox*>(data);
15832 DLOG_IF(ERROR, !mailbox.Verify()) << "ConsumeTextureCHROMIUM was passed a " 15849 DLOG_IF(ERROR, !mailbox.Verify()) << "ConsumeTextureCHROMIUM was passed a "
15833 "mailbox that was not generated by " 15850 "mailbox that was not generated by "
15834 "GenMailboxCHROMIUM."; 15851 "GenMailboxCHROMIUM.";
15835 15852
15836 scoped_refptr<TextureRef> texture_ref = 15853 scoped_refptr<TextureRef> texture_ref =
15837 texture_manager()->GetTextureInfoForTargetUnlessDefault(&state_, target); 15854 texture_manager()->GetTextureInfoForTargetUnlessDefault(&state_, target);
15838 if (!texture_ref.get()) { 15855 if (!texture_ref.get()) {
15839 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, 15856 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION,
15840 "glConsumeTextureCHROMIUM", 15857 "glConsumeTextureCHROMIUM",
15841 "unknown texture for target"); 15858 "unknown texture for target");
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
15885 RestoreCurrentTextureBindings(&state_, target); 15902 RestoreCurrentTextureBindings(&state_, target);
15886 } 15903 }
15887 } 15904 }
15888 15905
15889 void GLES2DecoderImpl::DoCreateAndConsumeTextureINTERNAL(GLenum target, 15906 void GLES2DecoderImpl::DoCreateAndConsumeTextureINTERNAL(GLenum target,
15890 GLuint client_id, 15907 GLuint client_id,
15891 const GLbyte* data) { 15908 const GLbyte* data) {
15892 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoCreateAndConsumeTextureINTERNAL", 15909 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoCreateAndConsumeTextureINTERNAL",
15893 "context", logger_.GetLogPrefix(), 15910 "context", logger_.GetLogPrefix(),
15894 "mailbox[0]", static_cast<unsigned char>(data[0])); 15911 "mailbox[0]", static_cast<unsigned char>(data[0]));
15895 const Mailbox& mailbox = *reinterpret_cast<const Mailbox*>(data); 15912 Mailbox mailbox = *reinterpret_cast<const Mailbox*>(data);
15896 DLOG_IF(ERROR, !mailbox.Verify()) << "CreateAndConsumeTextureCHROMIUM was " 15913 DLOG_IF(ERROR, !mailbox.Verify()) << "CreateAndConsumeTextureCHROMIUM was "
15897 "passed a mailbox that was not " 15914 "passed a mailbox that was not "
15898 "generated by GenMailboxCHROMIUM."; 15915 "generated by GenMailboxCHROMIUM.";
15899 15916
15900 TextureRef* texture_ref = GetTexture(client_id); 15917 TextureRef* texture_ref = GetTexture(client_id);
15901 if (texture_ref) { 15918 if (texture_ref) {
15902 // No need to call EnsureTextureForClientId here, the client_id already has 15919 // No need to call EnsureTextureForClientId here, the client_id already has
15903 // an associated texture. 15920 // an associated texture.
15904 LOCAL_SET_GL_ERROR( 15921 LOCAL_SET_GL_ERROR(
15905 GL_INVALID_OPERATION, 15922 GL_INVALID_OPERATION,
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
16095 debug_marker_manager_.PopGroup(); 16112 debug_marker_manager_.PopGroup();
16096 if (!gpu_tracer_->End(kTraceCHROMIUM)) { 16113 if (!gpu_tracer_->End(kTraceCHROMIUM)) {
16097 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, 16114 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION,
16098 "glTraceEndCHROMIUM", "no trace begin found"); 16115 "glTraceEndCHROMIUM", "no trace begin found");
16099 return; 16116 return;
16100 } 16117 }
16101 } 16118 }
16102 16119
16103 void GLES2DecoderImpl::DoDrawBuffersEXT( 16120 void GLES2DecoderImpl::DoDrawBuffersEXT(
16104 GLsizei count, const GLenum* bufs) { 16121 GLsizei count, const GLenum* bufs) {
16122 DCHECK_LE(group_->max_draw_buffers(), 16u);
16105 if (count > static_cast<GLsizei>(group_->max_draw_buffers())) { 16123 if (count > static_cast<GLsizei>(group_->max_draw_buffers())) {
16106 LOCAL_SET_GL_ERROR( 16124 LOCAL_SET_GL_ERROR(
16107 GL_INVALID_VALUE, 16125 GL_INVALID_VALUE,
16108 "glDrawBuffersEXT", "greater than GL_MAX_DRAW_BUFFERS_EXT"); 16126 "glDrawBuffersEXT", "greater than GL_MAX_DRAW_BUFFERS_EXT");
16109 return; 16127 return;
16110 } 16128 }
16111 16129
16112 Framebuffer* framebuffer = GetFramebufferInfoForTarget(GL_FRAMEBUFFER); 16130 Framebuffer* framebuffer = GetFramebufferInfoForTarget(GL_FRAMEBUFFER);
16113 if (framebuffer) { 16131 if (framebuffer) {
16132 GLenum safe_bufs[16];
16114 for (GLsizei i = 0; i < count; ++i) { 16133 for (GLsizei i = 0; i < count; ++i) {
16115 if (bufs[i] != static_cast<GLenum>(GL_COLOR_ATTACHMENT0 + i) && 16134 GLenum buf = bufs[i];
16116 bufs[i] != GL_NONE) { 16135 if (buf != static_cast<GLenum>(GL_COLOR_ATTACHMENT0 + i) &&
16136 buf != GL_NONE) {
16117 LOCAL_SET_GL_ERROR( 16137 LOCAL_SET_GL_ERROR(
16118 GL_INVALID_OPERATION, 16138 GL_INVALID_OPERATION,
16119 "glDrawBuffersEXT", 16139 "glDrawBuffersEXT",
16120 "bufs[i] not GL_NONE or GL_COLOR_ATTACHMENTi_EXT"); 16140 "bufs[i] not GL_NONE or GL_COLOR_ATTACHMENTi_EXT");
16121 return; 16141 return;
16122 } 16142 }
16143 safe_bufs[i] = buf;
16123 } 16144 }
16124 glDrawBuffersARB(count, bufs); 16145 glDrawBuffersARB(count, safe_bufs);
16125 framebuffer->SetDrawBuffers(count, bufs); 16146 framebuffer->SetDrawBuffers(count, safe_bufs);
16126 } else { // backbuffer 16147 } else { // backbuffer
16127 if (count != 1 || 16148 if (count != 1) {
16128 (bufs[0] != GL_BACK && bufs[0] != GL_NONE)) { 16149 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glDrawBuffersEXT",
16129 LOCAL_SET_GL_ERROR( 16150 "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; 16151 return;
16134 } 16152 }
16135 GLenum mapped_buf = bufs[0]; 16153 GLenum buf = bufs[0];
16136 if (GetBackbufferServiceId() != 0 && // emulated backbuffer 16154 if (buf != GL_BACK && buf != GL_NONE) {
16137 bufs[0] == GL_BACK) { 16155 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glDrawBuffersEXT",
16138 mapped_buf = GL_COLOR_ATTACHMENT0; 16156 "buffer is not GL_NONE or GL_BACK");
16157 return;
16139 } 16158 }
16140 glDrawBuffersARB(count, &mapped_buf); 16159 if (buf == GL_BACK && GetBackbufferServiceId() != 0) // emulated backbuffer
16141 back_buffer_draw_buffer_ = bufs[0]; 16160 buf = GL_COLOR_ATTACHMENT0;
16161 glDrawBuffersARB(count, &buf);
16162 back_buffer_draw_buffer_ = buf;
16142 } 16163 }
16143 } 16164 }
16144 16165
16145 void GLES2DecoderImpl::DoLoseContextCHROMIUM(GLenum current, GLenum other) { 16166 void GLES2DecoderImpl::DoLoseContextCHROMIUM(GLenum current, GLenum other) {
16146 MarkContextLost(GetContextLostReasonFromResetStatus(current)); 16167 MarkContextLost(GetContextLostReasonFromResetStatus(current));
16147 group_->LoseContexts(GetContextLostReasonFromResetStatus(other)); 16168 group_->LoseContexts(GetContextLostReasonFromResetStatus(other));
16148 reset_by_robustness_extension_ = true; 16169 reset_by_robustness_extension_ = true;
16149 } 16170 }
16150 16171
16151 void GLES2DecoderImpl::DoFlushDriverCachesCHROMIUM(void) { 16172 void GLES2DecoderImpl::DoFlushDriverCachesCHROMIUM(void) {
16152 // On Adreno Android devices we need to use a workaround to force caches to 16173 // On Adreno Android devices we need to use a workaround to force caches to
16153 // clear. 16174 // clear.
16154 if (feature_info_->workarounds().unbind_egl_context_to_flush_driver_caches) { 16175 if (feature_info_->workarounds().unbind_egl_context_to_flush_driver_caches) {
16155 context_->ReleaseCurrent(nullptr); 16176 context_->ReleaseCurrent(nullptr);
16156 context_->MakeCurrent(surface_.get()); 16177 context_->MakeCurrent(surface_.get());
16157 } 16178 }
16158 } 16179 }
16159 16180
16160 void GLES2DecoderImpl::DoMatrixLoadfCHROMIUM(GLenum matrix_mode, 16181 void GLES2DecoderImpl::DoMatrixLoadfCHROMIUM(GLenum matrix_mode,
16161 const GLfloat* matrix) { 16182 const GLfloat* matrix) {
16162 DCHECK(matrix_mode == GL_PATH_PROJECTION_CHROMIUM || 16183 DCHECK(matrix_mode == GL_PATH_PROJECTION_CHROMIUM ||
16163 matrix_mode == GL_PATH_MODELVIEW_CHROMIUM); 16184 matrix_mode == GL_PATH_MODELVIEW_CHROMIUM);
16164 16185
16165 GLfloat* target_matrix = matrix_mode == GL_PATH_PROJECTION_CHROMIUM 16186 GLfloat* target_matrix = matrix_mode == GL_PATH_PROJECTION_CHROMIUM
16166 ? state_.projection_matrix 16187 ? state_.projection_matrix
16167 : state_.modelview_matrix; 16188 : state_.modelview_matrix;
16168 memcpy(target_matrix, matrix, sizeof(GLfloat) * 16); 16189 memcpy(target_matrix, matrix, sizeof(GLfloat) * 16);
16169 // The matrix_mode is either GL_PATH_MODELVIEW_NV or GL_PATH_PROJECTION_NV 16190 // 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. 16191 // since the values of the _NV and _CHROMIUM tokens match.
16171 glMatrixLoadfEXT(matrix_mode, matrix); 16192 glMatrixLoadfEXT(matrix_mode, target_matrix);
16172 } 16193 }
16173 16194
16174 void GLES2DecoderImpl::DoMatrixLoadIdentityCHROMIUM(GLenum matrix_mode) { 16195 void GLES2DecoderImpl::DoMatrixLoadIdentityCHROMIUM(GLenum matrix_mode) {
16175 DCHECK(matrix_mode == GL_PATH_PROJECTION_CHROMIUM || 16196 DCHECK(matrix_mode == GL_PATH_PROJECTION_CHROMIUM ||
16176 matrix_mode == GL_PATH_MODELVIEW_CHROMIUM); 16197 matrix_mode == GL_PATH_MODELVIEW_CHROMIUM);
16177 16198
16178 GLfloat* target_matrix = matrix_mode == GL_PATH_PROJECTION_CHROMIUM 16199 GLfloat* target_matrix = matrix_mode == GL_PATH_PROJECTION_CHROMIUM
16179 ? state_.projection_matrix 16200 ? state_.projection_matrix
16180 : state_.modelview_matrix; 16201 : state_.modelview_matrix;
16181 memcpy(target_matrix, kIdentityMatrix, sizeof(kIdentityMatrix)); 16202 memcpy(target_matrix, kIdentityMatrix, sizeof(kIdentityMatrix));
(...skipping 1512 matching lines...) Expand 10 before | Expand all | Expand 10 after
17694 } 17715 }
17695 17716
17696 // Include the auto-generated part of this file. We split this because it means 17717 // 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 17718 // 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. 17719 // instead of having to edit some template or the code generator.
17699 #include "base/macros.h" 17720 #include "base/macros.h"
17700 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 17721 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
17701 17722
17702 } // namespace gles2 17723 } // namespace gles2
17703 } // namespace gpu 17724 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698