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> |
| (...skipping 1527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1538 // Wrapper for glGetFramebufferAttachmentParameteriv. | 1538 // Wrapper for glGetFramebufferAttachmentParameteriv. |
| 1539 void DoGetFramebufferAttachmentParameteriv( | 1539 void DoGetFramebufferAttachmentParameteriv( |
| 1540 GLenum target, GLenum attachment, GLenum pname, GLint* params); | 1540 GLenum target, GLenum attachment, GLenum pname, GLint* params); |
| 1541 | 1541 |
| 1542 // Wrapper for glGetInteger64v. | 1542 // Wrapper for glGetInteger64v. |
| 1543 void DoGetInteger64v(GLenum pname, GLint64* params); | 1543 void DoGetInteger64v(GLenum pname, GLint64* params); |
| 1544 | 1544 |
| 1545 // Wrapper for glGetIntegerv. | 1545 // Wrapper for glGetIntegerv. |
| 1546 void DoGetIntegerv(GLenum pname, GLint* params); | 1546 void DoGetIntegerv(GLenum pname, GLint* params); |
| 1547 | 1547 |
| 1548 // Helper for DoGetIntegeri_v and DoGetInteger64i_v. | |
| 1549 template <typename TYPE> | |
| 1550 void GetIndexedIntegerImpl( | |
| 1551 const char* function_name, GLenum target, GLuint index, TYPE* data); | |
| 1552 | |
| 1553 // Wrapper for glGetIntegeri_v. | |
| 1554 void DoGetIntegeri_v(GLenum target, GLuint index, GLint* data); | |
| 1555 | |
| 1556 // Wrapper for glGetInteger64i_v. | |
| 1557 void DoGetInteger64i_v(GLenum target, GLuint index, GLint64* data); | |
| 1558 | |
| 1548 // Gets the max value in a range in a buffer. | 1559 // Gets the max value in a range in a buffer. |
| 1549 GLuint DoGetMaxValueInBufferCHROMIUM( | 1560 GLuint DoGetMaxValueInBufferCHROMIUM( |
| 1550 GLuint buffer_id, GLsizei count, GLenum type, GLuint offset); | 1561 GLuint buffer_id, GLsizei count, GLenum type, GLuint offset); |
| 1551 | 1562 |
| 1552 // Wrapper for glGetBufferParameteri64v. | 1563 // Wrapper for glGetBufferParameteri64v. |
| 1553 void DoGetBufferParameteri64v( | 1564 void DoGetBufferParameteri64v( |
| 1554 GLenum target, GLenum pname, GLint64* params); | 1565 GLenum target, GLenum pname, GLint64* params); |
| 1555 | 1566 |
| 1556 // Wrapper for glGetBufferParameteriv. | 1567 // Wrapper for glGetBufferParameteriv. |
| 1557 void DoGetBufferParameteriv( | 1568 void DoGetBufferParameteriv( |
| (...skipping 1236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2794 | 2805 |
| 2795 // Create a fake default transform feedback and bind to it. | 2806 // Create a fake default transform feedback and bind to it. |
| 2796 GLuint default_transform_feedback = 0; | 2807 GLuint default_transform_feedback = 0; |
| 2797 glGenTransformFeedbacks(1, &default_transform_feedback); | 2808 glGenTransformFeedbacks(1, &default_transform_feedback); |
| 2798 state_.default_transform_feedback = | 2809 state_.default_transform_feedback = |
| 2799 transform_feedback_manager_->CreateTransformFeedback( | 2810 transform_feedback_manager_->CreateTransformFeedback( |
| 2800 0, default_transform_feedback); | 2811 0, default_transform_feedback); |
| 2801 glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, default_transform_feedback); | 2812 glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, default_transform_feedback); |
| 2802 state_.bound_transform_feedback = state_.default_transform_feedback.get(); | 2813 state_.bound_transform_feedback = state_.default_transform_feedback.get(); |
| 2803 } | 2814 } |
| 2815 state_.indexed_uniform_buffer_bindings = new IndexedBufferBindingHost( | |
| 2816 group_->max_uniform_buffer_bindings(), needs_emulation); | |
| 2804 | 2817 |
| 2805 state_.attrib_values.resize(group_->max_vertex_attribs()); | 2818 state_.attrib_values.resize(group_->max_vertex_attribs()); |
| 2806 vertex_array_manager_.reset(new VertexArrayManager()); | 2819 vertex_array_manager_.reset(new VertexArrayManager()); |
| 2807 | 2820 |
| 2808 GLuint default_vertex_attrib_service_id = 0; | 2821 GLuint default_vertex_attrib_service_id = 0; |
| 2809 if (features().native_vertex_array_object) { | 2822 if (features().native_vertex_array_object) { |
| 2810 glGenVertexArraysOES(1, &default_vertex_attrib_service_id); | 2823 glGenVertexArraysOES(1, &default_vertex_attrib_service_id); |
| 2811 glBindVertexArrayOES(default_vertex_attrib_service_id); | 2824 glBindVertexArrayOES(default_vertex_attrib_service_id); |
| 2812 } | 2825 } |
| 2813 | 2826 |
| (...skipping 1905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4719 } | 4732 } |
| 4720 case GL_UNIFORM_BUFFER: { | 4733 case GL_UNIFORM_BUFFER: { |
| 4721 if (index >= group_->max_uniform_buffer_bindings()) { | 4734 if (index >= group_->max_uniform_buffer_bindings()) { |
| 4722 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, | 4735 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, |
| 4723 "index out of range"); | 4736 "index out of range"); |
| 4724 return; | 4737 return; |
| 4725 } | 4738 } |
| 4726 break; | 4739 break; |
| 4727 } | 4740 } |
| 4728 default: | 4741 default: |
| 4729 LOCAL_SET_GL_ERROR_INVALID_ENUM(function_name, target, "invalid target"); | 4742 NOTREACHED(); |
| 4730 return; | 4743 break; |
| 4731 } | 4744 } |
| 4732 | 4745 |
| 4733 if (function_type == kBindBufferRange) { | 4746 if (function_type == kBindBufferRange) { |
| 4734 switch (target) { | 4747 switch (target) { |
| 4735 case GL_TRANSFORM_FEEDBACK_BUFFER: | 4748 case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 4736 if ((size % 4 != 0) || (offset % 4 != 0)) { | 4749 if ((size % 4 != 0) || (offset % 4 != 0)) { |
| 4737 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, | 4750 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, |
| 4738 "size or offset are not multiples of 4"); | 4751 "size or offset are not multiples of 4"); |
| 4739 return; | 4752 return; |
| 4740 } | 4753 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4778 // It's a new id so make a buffer for it. | 4791 // It's a new id so make a buffer for it. |
| 4779 glGenBuffersARB(1, &service_id); | 4792 glGenBuffersARB(1, &service_id); |
| 4780 CreateBuffer(client_id, service_id); | 4793 CreateBuffer(client_id, service_id); |
| 4781 buffer = GetBuffer(client_id); | 4794 buffer = GetBuffer(client_id); |
| 4782 DCHECK(buffer); | 4795 DCHECK(buffer); |
| 4783 } | 4796 } |
| 4784 service_id = buffer->service_id(); | 4797 service_id = buffer->service_id(); |
| 4785 } | 4798 } |
| 4786 LogClientServiceForInfo(buffer, client_id, function_name); | 4799 LogClientServiceForInfo(buffer, client_id, function_name); |
| 4787 | 4800 |
| 4801 scoped_refptr<IndexedBufferBindingHost> bindings; | |
| 4788 switch (target) { | 4802 switch (target) { |
| 4789 case GL_TRANSFORM_FEEDBACK_BUFFER: | 4803 case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 4790 DCHECK(state_.bound_transform_feedback.get()); | 4804 bindings = state_.bound_transform_feedback.get(); |
| 4791 switch (function_type) { | |
| 4792 case kBindBufferBase: | |
| 4793 state_.bound_transform_feedback->DoBindBufferBase( | |
| 4794 target, index, buffer); | |
| 4795 break; | |
| 4796 case kBindBufferRange: | |
| 4797 state_.bound_transform_feedback->DoBindBufferRange( | |
| 4798 target, index, buffer, offset, size); | |
| 4799 break; | |
| 4800 } | |
| 4801 break; | 4805 break; |
| 4802 case GL_UNIFORM_BUFFER: | 4806 case GL_UNIFORM_BUFFER: |
| 4803 // TODO(zmo): emulate Desktop GL 4.1 or lower behavior and keep track of | 4807 bindings = state_.indexed_uniform_buffer_bindings.get(); |
| 4804 // indexed buffer bindings. | |
| 4805 switch (function_type) { | |
| 4806 case kBindBufferBase: | |
| 4807 glBindBufferBase(target, index, service_id); | |
| 4808 break; | |
| 4809 case kBindBufferRange: | |
| 4810 glBindBufferRange(target, index, service_id, offset, size); | |
| 4811 break; | |
| 4812 } | |
| 4813 break; | 4808 break; |
| 4814 default: | 4809 default: |
| 4815 NOTREACHED(); | 4810 NOTREACHED(); |
| 4811 break; | |
| 4812 } | |
| 4813 DCHECK(bindings.get()); | |
|
piman
2016/05/05 21:27:39
nit: DCHECK(bindings)
Zhenyao Mo
2016/05/05 21:33:10
Done.
| |
| 4814 switch (function_type) { | |
| 4815 case kBindBufferBase: | |
| 4816 bindings->DoBindBufferBase(target, index, buffer); | |
| 4817 break; | |
| 4818 case kBindBufferRange: | |
| 4819 bindings->DoBindBufferRange(target, index, buffer, offset, size); | |
| 4820 break; | |
| 4821 default: | |
| 4822 NOTREACHED(); | |
| 4816 break; | 4823 break; |
| 4817 } | 4824 } |
| 4818 } | 4825 } |
| 4819 | 4826 |
| 4820 void GLES2DecoderImpl::DoBindBufferBase(GLenum target, GLuint index, | 4827 void GLES2DecoderImpl::DoBindBufferBase(GLenum target, GLuint index, |
| 4821 GLuint client_id) { | 4828 GLuint client_id) { |
| 4822 BindIndexedBufferImpl(target, index, client_id, 0, 0, | 4829 BindIndexedBufferImpl(target, index, client_id, 0, 0, |
| 4823 kBindBufferBase, "glBindBufferBase"); | 4830 kBindBufferBase, "glBindBufferBase"); |
| 4824 } | 4831 } |
| 4825 | 4832 |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5136 } else { | 5143 } else { |
| 5137 glBindSampler(unit, 0); | 5144 glBindSampler(unit, 0); |
| 5138 } | 5145 } |
| 5139 | 5146 |
| 5140 state_.sampler_units[unit] = sampler; | 5147 state_.sampler_units[unit] = sampler; |
| 5141 } | 5148 } |
| 5142 | 5149 |
| 5143 void GLES2DecoderImpl::DoBindTransformFeedback( | 5150 void GLES2DecoderImpl::DoBindTransformFeedback( |
| 5144 GLenum target, GLuint client_id) { | 5151 GLenum target, GLuint client_id) { |
| 5145 const char* function_name = "glBindTransformFeedback"; | 5152 const char* function_name = "glBindTransformFeedback"; |
| 5146 if (!validators_->transform_feedback_bind_target.IsValid(target)) { | |
| 5147 LOCAL_SET_GL_ERROR_INVALID_ENUM(function_name, target, "target"); | |
| 5148 return; | |
| 5149 } | |
| 5150 | 5153 |
| 5151 TransformFeedback* transform_feedback = nullptr; | 5154 TransformFeedback* transform_feedback = nullptr; |
| 5152 if (client_id != 0) { | 5155 if (client_id != 0) { |
| 5153 transform_feedback = GetTransformFeedback(client_id); | 5156 transform_feedback = GetTransformFeedback(client_id); |
| 5154 if (!transform_feedback) { | 5157 if (!transform_feedback) { |
| 5155 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, | 5158 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, |
| 5156 "id not generated by glGenTransformFeedbacks"); | 5159 "id not generated by glGenTransformFeedbacks"); |
| 5157 return; | 5160 return; |
| 5158 } | 5161 } |
| 5159 } else { | 5162 } else { |
| 5160 transform_feedback = state_.default_transform_feedback.get(); | 5163 transform_feedback = state_.default_transform_feedback.get(); |
| 5161 } | 5164 } |
| 5162 DCHECK(transform_feedback); | 5165 DCHECK(transform_feedback); |
| 5163 if (transform_feedback == state_.bound_transform_feedback.get()) | 5166 if (transform_feedback == state_.bound_transform_feedback.get()) |
| 5164 return; | 5167 return; |
| 5165 if (state_.bound_transform_feedback->active() && | 5168 if (state_.bound_transform_feedback->active() && |
| 5166 !state_.bound_transform_feedback->paused()) { | 5169 !state_.bound_transform_feedback->paused()) { |
| 5167 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, | 5170 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, |
| 5168 "currently bound transform feedback is active"); | 5171 "currently bound transform feedback is active"); |
| 5169 return; | 5172 return; |
| 5170 } | 5173 } |
| 5171 LogClientServiceForInfo(transform_feedback, client_id, function_name); | 5174 LogClientServiceForInfo(transform_feedback, client_id, function_name); |
| 5172 transform_feedback->DoBindTransformFeedback(target); | 5175 transform_feedback->DoBindTransformFeedback(target); |
| 5173 state_.bound_transform_feedback = transform_feedback; | 5176 state_.bound_transform_feedback = transform_feedback; |
| 5174 } | 5177 } |
| 5175 | 5178 |
| 5176 void GLES2DecoderImpl::DoBeginTransformFeedback(GLenum primitive_mode) { | 5179 void GLES2DecoderImpl::DoBeginTransformFeedback(GLenum primitive_mode) { |
| 5177 const char* function_name = "glBeginTransformFeedback"; | 5180 const char* function_name = "glBeginTransformFeedback"; |
| 5178 DCHECK(state_.bound_transform_feedback.get()); | 5181 DCHECK(state_.bound_transform_feedback.get()); |
| 5179 if (!validators_->transform_feedback_primitive_mode.IsValid(primitive_mode)) { | |
| 5180 LOCAL_SET_GL_ERROR_INVALID_ENUM( | |
| 5181 function_name, primitive_mode, "primitiveMode"); | |
| 5182 return; | |
| 5183 } | |
| 5184 if (state_.bound_transform_feedback->active()) { | 5182 if (state_.bound_transform_feedback->active()) { |
| 5185 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, | 5183 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, |
| 5186 "transform feedback is already active"); | 5184 "transform feedback is already active"); |
| 5187 return; | 5185 return; |
| 5188 } | 5186 } |
| 5189 state_.bound_transform_feedback->DoBeginTransformFeedback(primitive_mode); | 5187 state_.bound_transform_feedback->DoBeginTransformFeedback(primitive_mode); |
| 5190 } | 5188 } |
| 5191 | 5189 |
| 5192 void GLES2DecoderImpl::DoEndTransformFeedback() { | 5190 void GLES2DecoderImpl::DoEndTransformFeedback() { |
| 5193 const char* function_name = "glEndTransformFeedback"; | 5191 const char* function_name = "glEndTransformFeedback"; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5232 LOCAL_SET_GL_ERROR( | 5230 LOCAL_SET_GL_ERROR( |
| 5233 GL_INVALID_VALUE, | 5231 GL_INVALID_VALUE, |
| 5234 "glDisableVertexAttribArray", "index out of range"); | 5232 "glDisableVertexAttribArray", "index out of range"); |
| 5235 } | 5233 } |
| 5236 } | 5234 } |
| 5237 | 5235 |
| 5238 void GLES2DecoderImpl::InvalidateFramebufferImpl( | 5236 void GLES2DecoderImpl::InvalidateFramebufferImpl( |
| 5239 GLenum target, GLsizei count, const GLenum* attachments, | 5237 GLenum target, GLsizei count, const GLenum* attachments, |
| 5240 GLint x, GLint y, GLsizei width, GLsizei height, | 5238 GLint x, GLint y, GLsizei width, GLsizei height, |
| 5241 const char* function_name, FramebufferOperation op) { | 5239 const char* function_name, FramebufferOperation op) { |
| 5242 if (!validators_->frame_buffer_target.IsValid(target)) { | |
| 5243 LOCAL_SET_GL_ERROR_INVALID_ENUM(function_name, target, "target"); | |
| 5244 return; | |
| 5245 } | |
| 5246 Framebuffer* framebuffer = GetFramebufferInfoForTarget(GL_FRAMEBUFFER); | 5240 Framebuffer* framebuffer = GetFramebufferInfoForTarget(GL_FRAMEBUFFER); |
| 5247 | 5241 |
| 5248 // Validates the attachments. If one of them fails, the whole command fails. | 5242 // Validates the attachments. If one of them fails, the whole command fails. |
| 5249 GLenum thresh0 = GL_COLOR_ATTACHMENT0 + group_->max_color_attachments(); | 5243 GLenum thresh0 = GL_COLOR_ATTACHMENT0 + group_->max_color_attachments(); |
| 5250 GLenum thresh1 = GL_COLOR_ATTACHMENT15; | 5244 GLenum thresh1 = GL_COLOR_ATTACHMENT15; |
| 5251 for (GLsizei i = 0; i < count; ++i) { | 5245 for (GLsizei i = 0; i < count; ++i) { |
| 5252 if (framebuffer) { | 5246 if (framebuffer) { |
| 5253 if (attachments[i] >= thresh0 && attachments[i] <= thresh1) { | 5247 if (attachments[i] >= thresh0 && attachments[i] <= thresh1) { |
| 5254 LOCAL_SET_GL_ERROR( | 5248 LOCAL_SET_GL_ERROR( |
| 5255 GL_INVALID_OPERATION, function_name, "invalid attachment"); | 5249 GL_INVALID_OPERATION, function_name, "invalid attachment"); |
| (...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6019 void GLES2DecoderImpl::DoGetIntegerv(GLenum pname, GLint* params) { | 6013 void GLES2DecoderImpl::DoGetIntegerv(GLenum pname, GLint* params) { |
| 6020 DCHECK(params); | 6014 DCHECK(params); |
| 6021 GLsizei num_written; | 6015 GLsizei num_written; |
| 6022 if (!state_.GetStateAsGLint(pname, params, &num_written) && | 6016 if (!state_.GetStateAsGLint(pname, params, &num_written) && |
| 6023 !GetHelper(pname, params, &num_written)) { | 6017 !GetHelper(pname, params, &num_written)) { |
| 6024 pname = AdjustGetPname(pname); | 6018 pname = AdjustGetPname(pname); |
| 6025 glGetIntegerv(pname, params); | 6019 glGetIntegerv(pname, params); |
| 6026 } | 6020 } |
| 6027 } | 6021 } |
| 6028 | 6022 |
| 6023 template <typename TYPE> | |
| 6024 void GLES2DecoderImpl::GetIndexedIntegerImpl( | |
| 6025 const char* function_name, GLenum target, GLuint index, TYPE* data) { | |
| 6026 DCHECK(data); | |
| 6027 scoped_refptr<IndexedBufferBindingHost> binding; | |
| 6028 switch (target) { | |
| 6029 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: | |
| 6030 case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE: | |
| 6031 case GL_TRANSFORM_FEEDBACK_BUFFER_START: | |
| 6032 if (index >= group_->max_transform_feedback_separate_attribs()) { | |
| 6033 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "invalid index"); | |
| 6034 return; | |
| 6035 } | |
| 6036 binding = state_.bound_transform_feedback.get(); | |
| 6037 break; | |
| 6038 case GL_UNIFORM_BUFFER_BINDING: | |
| 6039 case GL_UNIFORM_BUFFER_SIZE: | |
| 6040 case GL_UNIFORM_BUFFER_START: | |
| 6041 if (index >= group_->max_uniform_buffer_bindings()) { | |
| 6042 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "invalid index"); | |
| 6043 return; | |
| 6044 } | |
| 6045 binding = state_.indexed_uniform_buffer_bindings.get(); | |
| 6046 break; | |
| 6047 default: | |
| 6048 NOTREACHED(); | |
| 6049 break; | |
| 6050 } | |
| 6051 DCHECK(binding.get()); | |
| 6052 switch (target) { | |
| 6053 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: | |
| 6054 case GL_UNIFORM_BUFFER_BINDING: | |
| 6055 { | |
| 6056 Buffer* buffer = binding->GetBufferBinding(index); | |
| 6057 *data = static_cast<TYPE>(buffer ? buffer->service_id() : 0); | |
| 6058 } | |
| 6059 break; | |
| 6060 case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE: | |
| 6061 case GL_UNIFORM_BUFFER_SIZE: | |
| 6062 *data = static_cast<TYPE>(binding->GetBufferSize(index)); | |
| 6063 break; | |
| 6064 case GL_TRANSFORM_FEEDBACK_BUFFER_START: | |
| 6065 case GL_UNIFORM_BUFFER_START: | |
| 6066 *data = static_cast<TYPE>(binding->GetBufferStart(index)); | |
| 6067 break; | |
| 6068 default: | |
| 6069 NOTREACHED(); | |
| 6070 break; | |
| 6071 } | |
| 6072 } | |
| 6073 | |
| 6074 void GLES2DecoderImpl::DoGetIntegeri_v( | |
| 6075 GLenum target, GLuint index, GLint* data) { | |
| 6076 GetIndexedIntegerImpl<GLint>("glGetIntegeri_v", target, index, data); | |
| 6077 } | |
| 6078 | |
| 6079 void GLES2DecoderImpl::DoGetInteger64i_v( | |
| 6080 GLenum target, GLuint index, GLint64* data) { | |
| 6081 GetIndexedIntegerImpl<GLint64>("glGetInteger64i_v", target, index, data); | |
| 6082 } | |
| 6083 | |
| 6029 void GLES2DecoderImpl::DoGetProgramiv( | 6084 void GLES2DecoderImpl::DoGetProgramiv( |
| 6030 GLuint program_id, GLenum pname, GLint* params) { | 6085 GLuint program_id, GLenum pname, GLint* params) { |
| 6031 Program* program = GetProgramInfoNotShader(program_id, "glGetProgramiv"); | 6086 Program* program = GetProgramInfoNotShader(program_id, "glGetProgramiv"); |
| 6032 if (!program) { | 6087 if (!program) { |
| 6033 return; | 6088 return; |
| 6034 } | 6089 } |
| 6035 program->GetProgramiv(pname, params); | 6090 program->GetProgramiv(pname, params); |
| 6036 } | 6091 } |
| 6037 | 6092 |
| 6038 void GLES2DecoderImpl::DoGetBufferParameteri64v( | 6093 void GLES2DecoderImpl::DoGetBufferParameteri64v( |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6320 return error::kNoError; | 6375 return error::kNoError; |
| 6321 } | 6376 } |
| 6322 | 6377 |
| 6323 void GLES2DecoderImpl::DoClearBufferiv( | 6378 void GLES2DecoderImpl::DoClearBufferiv( |
| 6324 GLenum buffer, GLint drawbuffer, const GLint* value) { | 6379 GLenum buffer, GLint drawbuffer, const GLint* value) { |
| 6325 // TODO(zmo): Set clear_uncleared_images=true once crbug.com/584059 is fixed. | 6380 // TODO(zmo): Set clear_uncleared_images=true once crbug.com/584059 is fixed. |
| 6326 if (!CheckBoundDrawFramebufferValid(false, "glClearBufferiv")) | 6381 if (!CheckBoundDrawFramebufferValid(false, "glClearBufferiv")) |
| 6327 return; | 6382 return; |
| 6328 ApplyDirtyState(); | 6383 ApplyDirtyState(); |
| 6329 | 6384 |
| 6330 switch (buffer) { | |
| 6331 case GL_COLOR: | |
| 6332 case GL_STENCIL: | |
| 6333 break; | |
| 6334 default: | |
| 6335 LOCAL_SET_GL_ERROR( | |
| 6336 GL_INVALID_ENUM, "glClearBufferiv", "invalid buffer"); | |
| 6337 return; | |
| 6338 } | |
| 6339 if (buffer == GL_COLOR) { | 6385 if (buffer == GL_COLOR) { |
| 6340 if (drawbuffer < 0 || | 6386 if (drawbuffer < 0 || |
| 6341 drawbuffer >= static_cast<GLint>(group_->max_draw_buffers())) { | 6387 drawbuffer >= static_cast<GLint>(group_->max_draw_buffers())) { |
| 6342 LOCAL_SET_GL_ERROR( | 6388 LOCAL_SET_GL_ERROR( |
| 6343 GL_INVALID_VALUE, "glClearBufferiv", "invalid drawBuffer"); | 6389 GL_INVALID_VALUE, "glClearBufferiv", "invalid drawBuffer"); |
| 6344 return; | 6390 return; |
| 6345 } | 6391 } |
| 6346 GLenum internal_format = | 6392 GLenum internal_format = |
| 6347 GetBoundColorDrawBufferInternalFormat(drawbuffer); | 6393 GetBoundColorDrawBufferInternalFormat(drawbuffer); |
| 6348 if (!GLES2Util::IsSignedIntegerFormat(internal_format)) { | 6394 if (!GLES2Util::IsSignedIntegerFormat(internal_format)) { |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 6364 glClearBufferiv(buffer, drawbuffer, value); | 6410 glClearBufferiv(buffer, drawbuffer, value); |
| 6365 } | 6411 } |
| 6366 | 6412 |
| 6367 void GLES2DecoderImpl::DoClearBufferuiv( | 6413 void GLES2DecoderImpl::DoClearBufferuiv( |
| 6368 GLenum buffer, GLint drawbuffer, const GLuint* value) { | 6414 GLenum buffer, GLint drawbuffer, const GLuint* value) { |
| 6369 // TODO(zmo): Set clear_uncleared_images=true once crbug.com/584059 is fixed. | 6415 // TODO(zmo): Set clear_uncleared_images=true once crbug.com/584059 is fixed. |
| 6370 if (!CheckBoundDrawFramebufferValid(false, "glClearBufferuiv")) | 6416 if (!CheckBoundDrawFramebufferValid(false, "glClearBufferuiv")) |
| 6371 return; | 6417 return; |
| 6372 ApplyDirtyState(); | 6418 ApplyDirtyState(); |
| 6373 | 6419 |
| 6374 switch (buffer) { | |
| 6375 case GL_COLOR: | |
| 6376 break; | |
| 6377 default: | |
| 6378 LOCAL_SET_GL_ERROR( | |
| 6379 GL_INVALID_ENUM, "glClearBufferuiv", "invalid buffer"); | |
| 6380 return; | |
| 6381 } | |
| 6382 if (drawbuffer < 0 || | 6420 if (drawbuffer < 0 || |
| 6383 drawbuffer >= static_cast<GLint>(group_->max_draw_buffers())) { | 6421 drawbuffer >= static_cast<GLint>(group_->max_draw_buffers())) { |
| 6384 LOCAL_SET_GL_ERROR( | 6422 LOCAL_SET_GL_ERROR( |
| 6385 GL_INVALID_VALUE, "glClearBufferuiv", "invalid drawBuffer"); | 6423 GL_INVALID_VALUE, "glClearBufferuiv", "invalid drawBuffer"); |
| 6386 return; | 6424 return; |
| 6387 } | 6425 } |
| 6388 GLenum internal_format = | 6426 GLenum internal_format = |
| 6389 GetBoundColorDrawBufferInternalFormat(drawbuffer); | 6427 GetBoundColorDrawBufferInternalFormat(drawbuffer); |
| 6390 if (!GLES2Util::IsUnsignedIntegerFormat(internal_format)) { | 6428 if (!GLES2Util::IsUnsignedIntegerFormat(internal_format)) { |
| 6391 // To avoid undefined results, return without calling the gl function. | 6429 // To avoid undefined results, return without calling the gl function. |
| 6392 return; | 6430 return; |
| 6393 } | 6431 } |
| 6394 MarkDrawBufferAsCleared(buffer, drawbuffer); | 6432 MarkDrawBufferAsCleared(buffer, drawbuffer); |
| 6395 glClearBufferuiv(buffer, drawbuffer, value); | 6433 glClearBufferuiv(buffer, drawbuffer, value); |
| 6396 } | 6434 } |
| 6397 | 6435 |
| 6398 void GLES2DecoderImpl::DoClearBufferfv( | 6436 void GLES2DecoderImpl::DoClearBufferfv( |
| 6399 GLenum buffer, GLint drawbuffer, const GLfloat* value) { | 6437 GLenum buffer, GLint drawbuffer, const GLfloat* value) { |
| 6400 // TODO(zmo): Set clear_uncleared_images=true once crbug.com/584059 is fixed. | 6438 // TODO(zmo): Set clear_uncleared_images=true once crbug.com/584059 is fixed. |
| 6401 if (!CheckBoundDrawFramebufferValid(false, "glClearBufferfv")) | 6439 if (!CheckBoundDrawFramebufferValid(false, "glClearBufferfv")) |
| 6402 return; | 6440 return; |
| 6403 ApplyDirtyState(); | 6441 ApplyDirtyState(); |
| 6404 | 6442 |
| 6405 switch (buffer) { | |
| 6406 case GL_COLOR: | |
| 6407 case GL_DEPTH: | |
| 6408 break; | |
| 6409 default: | |
| 6410 LOCAL_SET_GL_ERROR( | |
| 6411 GL_INVALID_ENUM, "glClearBufferfv", "invalid buffer"); | |
| 6412 return; | |
| 6413 } | |
| 6414 if (buffer == GL_COLOR) { | 6443 if (buffer == GL_COLOR) { |
| 6415 if (drawbuffer < 0 || | 6444 if (drawbuffer < 0 || |
| 6416 drawbuffer >= static_cast<GLint>(group_->max_draw_buffers())) { | 6445 drawbuffer >= static_cast<GLint>(group_->max_draw_buffers())) { |
| 6417 LOCAL_SET_GL_ERROR( | 6446 LOCAL_SET_GL_ERROR( |
| 6418 GL_INVALID_VALUE, "glClearBufferfv", "invalid drawBuffer"); | 6447 GL_INVALID_VALUE, "glClearBufferfv", "invalid drawBuffer"); |
| 6419 return; | 6448 return; |
| 6420 } | 6449 } |
| 6421 GLenum internal_format = | 6450 GLenum internal_format = |
| 6422 GetBoundColorDrawBufferInternalFormat(drawbuffer); | 6451 GetBoundColorDrawBufferInternalFormat(drawbuffer); |
| 6423 if (GLES2Util::IsIntegerFormat(internal_format)) { | 6452 if (GLES2Util::IsIntegerFormat(internal_format)) { |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 6439 glClearBufferfv(buffer, drawbuffer, value); | 6468 glClearBufferfv(buffer, drawbuffer, value); |
| 6440 } | 6469 } |
| 6441 | 6470 |
| 6442 void GLES2DecoderImpl::DoClearBufferfi( | 6471 void GLES2DecoderImpl::DoClearBufferfi( |
| 6443 GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) { | 6472 GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) { |
| 6444 // TODO(zmo): Set clear_uncleared_images=true once crbug.com/584059 is fixed. | 6473 // TODO(zmo): Set clear_uncleared_images=true once crbug.com/584059 is fixed. |
| 6445 if (!CheckBoundDrawFramebufferValid(false, "glClearBufferfi")) | 6474 if (!CheckBoundDrawFramebufferValid(false, "glClearBufferfi")) |
| 6446 return; | 6475 return; |
| 6447 ApplyDirtyState(); | 6476 ApplyDirtyState(); |
| 6448 | 6477 |
| 6449 switch (buffer) { | |
| 6450 case GL_DEPTH_STENCIL: | |
| 6451 break; | |
| 6452 default: | |
| 6453 LOCAL_SET_GL_ERROR( | |
| 6454 GL_INVALID_ENUM, "glClearBufferfi", "invalid buffer"); | |
| 6455 return; | |
| 6456 } | |
| 6457 if (drawbuffer != 0) { | 6478 if (drawbuffer != 0) { |
| 6458 LOCAL_SET_GL_ERROR( | 6479 LOCAL_SET_GL_ERROR( |
| 6459 GL_INVALID_VALUE, "glClearBufferfi", "invalid drawBuffer"); | 6480 GL_INVALID_VALUE, "glClearBufferfi", "invalid drawBuffer"); |
| 6460 return; | 6481 return; |
| 6461 } | 6482 } |
| 6462 if (!BoundFramebufferHasDepthAttachment() && | 6483 if (!BoundFramebufferHasDepthAttachment() && |
| 6463 !BoundFramebufferHasStencilAttachment()) { | 6484 !BoundFramebufferHasStencilAttachment()) { |
| 6464 return; | 6485 return; |
| 6465 } | 6486 } |
| 6466 MarkDrawBufferAsCleared(GL_DEPTH, drawbuffer); | 6487 MarkDrawBufferAsCleared(GL_DEPTH, drawbuffer); |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6742 if (framebuffer == framebuffer_state_.bound_draw_framebuffer.get()) { | 6763 if (framebuffer == framebuffer_state_.bound_draw_framebuffer.get()) { |
| 6743 framebuffer_state_.clear_state_dirty = true; | 6764 framebuffer_state_.clear_state_dirty = true; |
| 6744 } | 6765 } |
| 6745 | 6766 |
| 6746 OnFboChanged(); | 6767 OnFboChanged(); |
| 6747 } | 6768 } |
| 6748 | 6769 |
| 6749 void GLES2DecoderImpl::DoFramebufferTextureLayer( | 6770 void GLES2DecoderImpl::DoFramebufferTextureLayer( |
| 6750 GLenum target, GLenum attachment, GLuint client_texture_id, | 6771 GLenum target, GLenum attachment, GLuint client_texture_id, |
| 6751 GLint level, GLint layer) { | 6772 GLint level, GLint layer) { |
| 6752 // TODO(zmo): Add full validation. | 6773 const char* function_name = "glFramebufferTextureLayer"; |
| 6753 GLuint service_id = 0; | 6774 |
| 6754 TextureRef* texture_ref = NULL; | 6775 TextureRef* texture_ref = nullptr; |
| 6755 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target); | 6776 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target); |
| 6756 if (!framebuffer) { | 6777 if (!framebuffer) { |
| 6757 LOCAL_SET_GL_ERROR( | 6778 LOCAL_SET_GL_ERROR( |
| 6758 GL_INVALID_OPERATION, | 6779 GL_INVALID_OPERATION, function_name, "no framebuffer bound."); |
| 6759 "glFramebufferTextureLayer", "no framebuffer bound."); | |
| 6760 return; | 6780 return; |
| 6761 } | 6781 } |
| 6782 GLuint service_id = 0; | |
| 6783 GLenum texture_target = 0; | |
| 6762 if (client_texture_id) { | 6784 if (client_texture_id) { |
| 6763 texture_ref = GetTexture(client_texture_id); | 6785 texture_ref = GetTexture(client_texture_id); |
| 6764 if (!texture_ref) { | 6786 if (!texture_ref) { |
| 6765 LOCAL_SET_GL_ERROR( | 6787 LOCAL_SET_GL_ERROR( |
| 6766 GL_INVALID_OPERATION, | 6788 GL_INVALID_VALUE, function_name, "unknown texture"); |
| 6767 "glFramebufferTextureLayer", "unknown texture_ref"); | |
| 6768 return; | 6789 return; |
| 6769 } | 6790 } |
| 6770 service_id = texture_ref->service_id(); | 6791 service_id = texture_ref->service_id(); |
| 6792 | |
| 6793 texture_target = texture_ref->texture()->target(); | |
| 6794 switch (texture_target) { | |
| 6795 case GL_TEXTURE_3D: | |
| 6796 case GL_TEXTURE_2D_ARRAY: | |
| 6797 break; | |
| 6798 default: | |
| 6799 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, | |
| 6800 "texture is neither TEXTURE_3D nor TEXTURE_2D_ARRAY"); | |
| 6801 return; | |
| 6802 } | |
| 6803 if (!texture_manager()->ValidForTarget(texture_target, level, | |
| 6804 0, 0, layer)) { | |
| 6805 LOCAL_SET_GL_ERROR( | |
| 6806 GL_INVALID_VALUE, function_name, "invalid level or layer"); | |
| 6807 return; | |
| 6808 } | |
| 6771 } | 6809 } |
| 6772 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glFramebufferTextureLayer"); | |
| 6773 glFramebufferTextureLayer(target, attachment, service_id, level, layer); | 6810 glFramebufferTextureLayer(target, attachment, service_id, level, layer); |
| 6774 GLenum error = LOCAL_PEEK_GL_ERROR("glFramebufferTextureLayer"); | 6811 framebuffer->AttachTextureLayer( |
| 6775 if (error == GL_NO_ERROR) { | 6812 attachment, texture_ref, texture_target, level, layer); |
| 6776 framebuffer->AttachTextureLayer(attachment, texture_ref, | |
| 6777 texture_ref ? texture_ref->texture()->target() : 0, | |
| 6778 level, layer); | |
| 6779 } | |
| 6780 if (framebuffer == framebuffer_state_.bound_draw_framebuffer.get()) { | 6813 if (framebuffer == framebuffer_state_.bound_draw_framebuffer.get()) { |
| 6781 framebuffer_state_.clear_state_dirty = true; | 6814 framebuffer_state_.clear_state_dirty = true; |
| 6782 } | 6815 } |
| 6783 } | 6816 } |
| 6784 | 6817 |
| 6785 void GLES2DecoderImpl::DoGetFramebufferAttachmentParameteriv( | 6818 void GLES2DecoderImpl::DoGetFramebufferAttachmentParameteriv( |
| 6786 GLenum target, GLenum attachment, GLenum pname, GLint* params) { | 6819 GLenum target, GLenum attachment, GLenum pname, GLint* params) { |
| 6787 const char kFunctionName[] = "glGetFramebufferAttachmentParameteriv"; | 6820 const char kFunctionName[] = "glGetFramebufferAttachmentParameteriv"; |
| 6788 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target); | 6821 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target); |
| 6789 if (!framebuffer) { | 6822 if (!framebuffer) { |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7268 program_manager()->ClearUniforms(program); | 7301 program_manager()->ClearUniforms(program); |
| 7269 } | 7302 } |
| 7270 } | 7303 } |
| 7271 | 7304 |
| 7272 // LinkProgram can be very slow. Exit command processing to allow for | 7305 // LinkProgram can be very slow. Exit command processing to allow for |
| 7273 // context preemption and GPU watchdog checks. | 7306 // context preemption and GPU watchdog checks. |
| 7274 ExitCommandProcessingEarly(); | 7307 ExitCommandProcessingEarly(); |
| 7275 } | 7308 } |
| 7276 | 7309 |
| 7277 void GLES2DecoderImpl::DoReadBuffer(GLenum src) { | 7310 void GLES2DecoderImpl::DoReadBuffer(GLenum src) { |
| 7278 switch (src) { | |
| 7279 case GL_NONE: | |
| 7280 case GL_BACK: | |
| 7281 break; | |
| 7282 default: | |
| 7283 { | |
| 7284 GLenum upper_limit = static_cast<GLenum>( | |
| 7285 group_->max_color_attachments() + GL_COLOR_ATTACHMENT0); | |
| 7286 if (src < GL_COLOR_ATTACHMENT0 || src >= upper_limit) { | |
| 7287 LOCAL_SET_GL_ERROR( | |
| 7288 GL_INVALID_ENUM, "glReadBuffer", "invalid enum for src"); | |
| 7289 return; | |
| 7290 } | |
| 7291 } | |
| 7292 break; | |
| 7293 } | |
| 7294 | |
| 7295 Framebuffer* framebuffer = GetFramebufferInfoForTarget(GL_READ_FRAMEBUFFER); | 7311 Framebuffer* framebuffer = GetFramebufferInfoForTarget(GL_READ_FRAMEBUFFER); |
| 7296 if (framebuffer) { | 7312 if (framebuffer) { |
| 7297 if (src == GL_BACK) { | 7313 if (src == GL_BACK) { |
| 7298 LOCAL_SET_GL_ERROR( | 7314 LOCAL_SET_GL_ERROR( |
| 7299 GL_INVALID_ENUM, "glReadBuffer", | 7315 GL_INVALID_ENUM, "glReadBuffer", |
| 7300 "invalid src for a named framebuffer"); | 7316 "invalid src for a named framebuffer"); |
| 7301 return; | 7317 return; |
| 7302 } | 7318 } |
| 7303 framebuffer->set_read_buffer(src); | 7319 framebuffer->set_read_buffer(src); |
| 7304 } else { | 7320 } else { |
| (...skipping 1146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8451 if (!CheckBoundDrawFramebufferValid(true, function_name)) { | 8467 if (!CheckBoundDrawFramebufferValid(true, function_name)) { |
| 8452 return error::kNoError; | 8468 return error::kNoError; |
| 8453 } | 8469 } |
| 8454 // We have to check this here because the prototype for glDrawArrays | 8470 // We have to check this here because the prototype for glDrawArrays |
| 8455 // is GLint not GLsizei. | 8471 // is GLint not GLsizei. |
| 8456 if (first < 0) { | 8472 if (first < 0) { |
| 8457 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "first < 0"); | 8473 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "first < 0"); |
| 8458 return error::kNoError; | 8474 return error::kNoError; |
| 8459 } | 8475 } |
| 8460 | 8476 |
| 8477 if (state_.bound_transform_feedback.get() && | |
| 8478 state_.bound_transform_feedback->active() && | |
| 8479 !state_.bound_transform_feedback->paused() && | |
| 8480 mode != state_.bound_transform_feedback->primitive_mode()) { | |
| 8481 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, | |
| 8482 "mode is not identical with active transformfeedback's primitiveMode"); | |
| 8483 return error::kNoError; | |
| 8484 } | |
| 8485 | |
| 8461 if (count == 0 || primcount == 0) { | 8486 if (count == 0 || primcount == 0) { |
| 8462 LOCAL_RENDER_WARNING("Render count or primcount is 0."); | 8487 LOCAL_RENDER_WARNING("Render count or primcount is 0."); |
| 8463 return error::kNoError; | 8488 return error::kNoError; |
| 8464 } | 8489 } |
| 8465 | 8490 |
| 8466 GLuint max_vertex_accessed = first + count - 1; | 8491 GLuint max_vertex_accessed = first + count - 1; |
| 8467 if (IsDrawValid(function_name, max_vertex_accessed, instanced, primcount)) { | 8492 if (IsDrawValid(function_name, max_vertex_accessed, instanced, primcount)) { |
| 8468 if (!ClearUnclearedTextures()) { | 8493 if (!ClearUnclearedTextures()) { |
| 8469 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "out of memory"); | 8494 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "out of memory"); |
| 8470 return error::kNoError; | 8495 return error::kNoError; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8564 } | 8589 } |
| 8565 if (primcount < 0) { | 8590 if (primcount < 0) { |
| 8566 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "primcount < 0"); | 8591 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "primcount < 0"); |
| 8567 return error::kNoError; | 8592 return error::kNoError; |
| 8568 } | 8593 } |
| 8569 | 8594 |
| 8570 if (!CheckBoundDrawFramebufferValid(true, function_name)) { | 8595 if (!CheckBoundDrawFramebufferValid(true, function_name)) { |
| 8571 return error::kNoError; | 8596 return error::kNoError; |
| 8572 } | 8597 } |
| 8573 | 8598 |
| 8599 if (state_.bound_transform_feedback.get() && | |
| 8600 state_.bound_transform_feedback->active() && | |
| 8601 !state_.bound_transform_feedback->paused()) { | |
| 8602 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, | |
| 8603 "transformfeedback is active and not paused"); | |
| 8604 return error::kNoError; | |
| 8605 } | |
| 8606 | |
| 8574 if (count == 0 || primcount == 0) { | 8607 if (count == 0 || primcount == 0) { |
| 8575 return error::kNoError; | 8608 return error::kNoError; |
| 8576 } | 8609 } |
| 8577 | 8610 |
| 8578 GLuint max_vertex_accessed; | 8611 GLuint max_vertex_accessed; |
| 8579 Buffer* element_array_buffer = | 8612 Buffer* element_array_buffer = |
| 8580 state_.vertex_attrib_manager->element_array_buffer(); | 8613 state_.vertex_attrib_manager->element_array_buffer(); |
| 8581 | 8614 |
| 8582 if (!element_array_buffer->GetMaxValueForRange( | 8615 if (!element_array_buffer->GetMaxValueForRange( |
| 8583 offset, count, type, | 8616 offset, count, type, |
| (...skipping 2976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 11560 } | 11593 } |
| 11561 } | 11594 } |
| 11562 return DoCompressedTexImage3D(target, level, internal_format, width, height, | 11595 return DoCompressedTexImage3D(target, level, internal_format, width, height, |
| 11563 depth, border, imageSize, data); | 11596 depth, border, imageSize, data); |
| 11564 } | 11597 } |
| 11565 | 11598 |
| 11566 void GLES2DecoderImpl::DoCompressedTexSubImage3D( | 11599 void GLES2DecoderImpl::DoCompressedTexSubImage3D( |
| 11567 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, | 11600 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, |
| 11568 GLsizei width, GLsizei height, GLsizei depth, GLenum format, | 11601 GLsizei width, GLsizei height, GLsizei depth, GLenum format, |
| 11569 GLsizei image_size, const void* data) { | 11602 GLsizei image_size, const void* data) { |
| 11570 if (!validators_->texture_3_d_target.IsValid(target)) { | |
| 11571 LOCAL_SET_GL_ERROR( | |
| 11572 GL_INVALID_ENUM, "glCompressedTexSubImage3D", "target"); | |
| 11573 return; | |
| 11574 } | |
| 11575 if (!validators_->compressed_texture_format.IsValid(format)) { | |
| 11576 LOCAL_SET_GL_ERROR_INVALID_ENUM( | |
| 11577 "glCompressedTexSubImage3D", format, "format"); | |
| 11578 return; | |
| 11579 } | |
| 11580 if (!texture_manager()->ValidForTarget(target, level, width, height, depth)) { | 11603 if (!texture_manager()->ValidForTarget(target, level, width, height, depth)) { |
| 11581 LOCAL_SET_GL_ERROR( | 11604 LOCAL_SET_GL_ERROR( |
| 11582 GL_INVALID_VALUE, | 11605 GL_INVALID_VALUE, |
| 11583 "glCompressedTexSubImage3D", "dimensions out of range"); | 11606 "glCompressedTexSubImage3D", "dimensions out of range"); |
| 11584 return; | 11607 return; |
| 11585 } | 11608 } |
| 11586 if (image_size < 0) { | 11609 if (image_size < 0) { |
| 11587 LOCAL_SET_GL_ERROR( | 11610 LOCAL_SET_GL_ERROR( |
| 11588 GL_INVALID_VALUE, "glCompressedTexSubImage3D", "imageSize < 0"); | 11611 GL_INVALID_VALUE, "glCompressedTexSubImage3D", "imageSize < 0"); |
| 11589 return; | 11612 return; |
| (...skipping 2996 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 14586 this, source_texture->target(), source_texture->service_id(), | 14609 this, source_texture->target(), source_texture->service_id(), |
| 14587 source_internal_format, dest_texture->target(), | 14610 source_internal_format, dest_texture->target(), |
| 14588 dest_texture->service_id(), GL_RGBA, source_width, source_height, false, | 14611 dest_texture->service_id(), GL_RGBA, source_width, source_height, false, |
| 14589 false, false); | 14612 false, false); |
| 14590 } | 14613 } |
| 14591 | 14614 |
| 14592 void GLES2DecoderImpl::TexStorageImpl( | 14615 void GLES2DecoderImpl::TexStorageImpl( |
| 14593 GLenum target, GLint levels, GLenum internal_format, | 14616 GLenum target, GLint levels, GLenum internal_format, |
| 14594 GLsizei width, GLsizei height, GLsizei depth, | 14617 GLsizei width, GLsizei height, GLsizei depth, |
| 14595 ContextState::Dimension dimension, const char* function_name) { | 14618 ContextState::Dimension dimension, const char* function_name) { |
| 14596 if (dimension == ContextState::k2D) { | |
| 14597 if (!validators_->texture_bind_target.IsValid(target)) { | |
| 14598 LOCAL_SET_GL_ERROR_INVALID_ENUM(function_name, target, "target"); | |
| 14599 return; | |
| 14600 } | |
| 14601 } else { | |
| 14602 if (!validators_->texture_3_d_target.IsValid(target)) { | |
| 14603 LOCAL_SET_GL_ERROR_INVALID_ENUM(function_name, target, "target"); | |
| 14604 return; | |
| 14605 } | |
| 14606 } | |
| 14607 if (levels <= 0) { | 14619 if (levels <= 0) { |
| 14608 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "levels <= 0"); | 14620 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "levels <= 0"); |
| 14609 return; | 14621 return; |
| 14610 } | 14622 } |
| 14611 if (!validators_->texture_internal_format_storage.IsValid(internal_format)) { | |
| 14612 LOCAL_SET_GL_ERROR_INVALID_ENUM( | |
| 14613 function_name, internal_format, "internal_format"); | |
| 14614 return; | |
| 14615 } | |
| 14616 bool is_compressed_format = IsCompressedTextureFormat(internal_format); | 14623 bool is_compressed_format = IsCompressedTextureFormat(internal_format); |
| 14617 if (is_compressed_format && target == GL_TEXTURE_3D) { | 14624 if (is_compressed_format && target == GL_TEXTURE_3D) { |
| 14618 LOCAL_SET_GL_ERROR( | 14625 LOCAL_SET_GL_ERROR( |
| 14619 GL_INVALID_OPERATION, function_name, "target invalid for format"); | 14626 GL_INVALID_OPERATION, function_name, "target invalid for format"); |
| 14620 return; | 14627 return; |
| 14621 } | 14628 } |
| 14622 if (!texture_manager()->ValidForTarget(target, 0, width, height, depth) || | 14629 if (!texture_manager()->ValidForTarget(target, 0, width, height, depth) || |
| 14623 TextureManager::ComputeMipMapCount( | 14630 TextureManager::ComputeMipMapCount( |
| 14624 target, width, height, depth) < levels) { | 14631 target, width, height, depth) < levels) { |
| 14625 LOCAL_SET_GL_ERROR( | 14632 LOCAL_SET_GL_ERROR( |
| (...skipping 2018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 16644 } | 16651 } |
| 16645 | 16652 |
| 16646 // Include the auto-generated part of this file. We split this because it means | 16653 // Include the auto-generated part of this file. We split this because it means |
| 16647 // we can easily edit the non-auto generated parts right here in this file | 16654 // we can easily edit the non-auto generated parts right here in this file |
| 16648 // instead of having to edit some template or the code generator. | 16655 // instead of having to edit some template or the code generator. |
| 16649 #include "base/macros.h" | 16656 #include "base/macros.h" |
| 16650 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 16657 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 16651 | 16658 |
| 16652 } // namespace gles2 | 16659 } // namespace gles2 |
| 16653 } // namespace gpu | 16660 } // namespace gpu |
| OLD | NEW |