OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <list> | 10 #include <list> |
(...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
918 | 918 |
919 void DoBindTexImage2DCHROMIUM( | 919 void DoBindTexImage2DCHROMIUM( |
920 GLenum target, | 920 GLenum target, |
921 GLint image_id); | 921 GLint image_id); |
922 void DoReleaseTexImage2DCHROMIUM( | 922 void DoReleaseTexImage2DCHROMIUM( |
923 GLenum target, | 923 GLenum target, |
924 GLint image_id); | 924 GLint image_id); |
925 | 925 |
926 void DoTraceEndCHROMIUM(void); | 926 void DoTraceEndCHROMIUM(void); |
927 | 927 |
928 void DoDrawBuffersEXT(GLsizei count, const GLenum* bufs); | |
929 | |
928 // Creates a Program for the given program. | 930 // Creates a Program for the given program. |
929 Program* CreateProgram( | 931 Program* CreateProgram( |
930 GLuint client_id, GLuint service_id) { | 932 GLuint client_id, GLuint service_id) { |
931 return program_manager()->CreateProgram(client_id, service_id); | 933 return program_manager()->CreateProgram(client_id, service_id); |
932 } | 934 } |
933 | 935 |
934 // Gets the program info for the given program. Returns NULL if none exists. | 936 // Gets the program info for the given program. Returns NULL if none exists. |
935 Program* GetProgram(GLuint client_id) { | 937 Program* GetProgram(GLuint client_id) { |
936 return program_manager()->GetProgram(client_id); | 938 return program_manager()->GetProgram(client_id); |
937 } | 939 } |
(...skipping 1652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2590 resources.MaxVertexAttribs = group_->max_vertex_attribs(); | 2592 resources.MaxVertexAttribs = group_->max_vertex_attribs(); |
2591 resources.MaxVertexUniformVectors = | 2593 resources.MaxVertexUniformVectors = |
2592 group_->max_vertex_uniform_vectors(); | 2594 group_->max_vertex_uniform_vectors(); |
2593 resources.MaxVaryingVectors = group_->max_varying_vectors(); | 2595 resources.MaxVaryingVectors = group_->max_varying_vectors(); |
2594 resources.MaxVertexTextureImageUnits = | 2596 resources.MaxVertexTextureImageUnits = |
2595 group_->max_vertex_texture_image_units(); | 2597 group_->max_vertex_texture_image_units(); |
2596 resources.MaxCombinedTextureImageUnits = group_->max_texture_units(); | 2598 resources.MaxCombinedTextureImageUnits = group_->max_texture_units(); |
2597 resources.MaxTextureImageUnits = group_->max_texture_image_units(); | 2599 resources.MaxTextureImageUnits = group_->max_texture_image_units(); |
2598 resources.MaxFragmentUniformVectors = | 2600 resources.MaxFragmentUniformVectors = |
2599 group_->max_fragment_uniform_vectors(); | 2601 group_->max_fragment_uniform_vectors(); |
2600 resources.MaxDrawBuffers = 1; | 2602 resources.MaxDrawBuffers = group_->max_draw_buffers(); |
2601 | 2603 |
2602 #if (ANGLE_SH_VERSION >= 110) | 2604 #if (ANGLE_SH_VERSION >= 110) |
2603 GLint range[2]; | 2605 GLint range[2]; |
2604 GLint precision = 0; | 2606 GLint precision = 0; |
2605 GetShaderPrecisionFormatImpl(GL_FRAGMENT_SHADER, GL_HIGH_FLOAT, | 2607 GetShaderPrecisionFormatImpl(GL_FRAGMENT_SHADER, GL_HIGH_FLOAT, |
2606 range, &precision); | 2608 range, &precision); |
2607 resources.FragmentPrecisionHigh = ((range[0] >= 62) && | 2609 resources.FragmentPrecisionHigh = ((range[0] >= 62) && |
2608 (range[1] >= 62) && | 2610 (range[1] >= 62) && |
2609 (precision >= 16)); | 2611 (precision >= 16)); |
2610 #endif | 2612 #endif |
2611 | 2613 |
2612 if (force_webgl_glsl_validation_) { | 2614 if (force_webgl_glsl_validation_) { |
2613 resources.OES_standard_derivatives = derivatives_explicitly_enabled_; | 2615 resources.OES_standard_derivatives = derivatives_explicitly_enabled_; |
2614 } else { | 2616 } else { |
2615 resources.OES_standard_derivatives = | 2617 resources.OES_standard_derivatives = |
2616 features().oes_standard_derivatives ? 1 : 0; | 2618 features().oes_standard_derivatives ? 1 : 0; |
2617 resources.ARB_texture_rectangle = | 2619 resources.ARB_texture_rectangle = |
2618 features().arb_texture_rectangle ? 1 : 0; | 2620 features().arb_texture_rectangle ? 1 : 0; |
2619 resources.OES_EGL_image_external = | 2621 resources.OES_EGL_image_external = |
2620 features().oes_egl_image_external ? 1 : 0; | 2622 features().oes_egl_image_external ? 1 : 0; |
2623 resources.EXT_draw_buffers = | |
2624 features().ext_draw_buffers ? 1 : 0; | |
2621 } | 2625 } |
2622 | 2626 |
2623 ShShaderSpec shader_spec = force_webgl_glsl_validation_ || | 2627 ShShaderSpec shader_spec = force_webgl_glsl_validation_ || |
2624 force_webgl_glsl_validation_ ? SH_WEBGL_SPEC : SH_GLES2_SPEC; | 2628 force_webgl_glsl_validation_ ? SH_WEBGL_SPEC : SH_GLES2_SPEC; |
2625 if (shader_spec == SH_WEBGL_SPEC && features().enable_shader_name_hashing) | 2629 if (shader_spec == SH_WEBGL_SPEC && features().enable_shader_name_hashing) |
2626 #if !defined(ANGLE_SH_VERSION) || ANGLE_SH_VERSION < 108 | 2630 #if !defined(ANGLE_SH_VERSION) || ANGLE_SH_VERSION < 108 |
2627 resources.HashFunction = &CityHashForAngle; | 2631 resources.HashFunction = &CityHashForAngle; |
2628 #else | 2632 #else |
2629 resources.HashFunction = &CityHash64; | 2633 resources.HashFunction = &CityHash64; |
2630 #endif | 2634 #endif |
(...skipping 1489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4120 if (params) { | 4124 if (params) { |
4121 params[0] = texture_manager()->MaxSizeForTarget(GL_TEXTURE_2D); | 4125 params[0] = texture_manager()->MaxSizeForTarget(GL_TEXTURE_2D); |
4122 } | 4126 } |
4123 return true; | 4127 return true; |
4124 case GL_MAX_CUBE_MAP_TEXTURE_SIZE: | 4128 case GL_MAX_CUBE_MAP_TEXTURE_SIZE: |
4125 *num_written = 1; | 4129 *num_written = 1; |
4126 if (params) { | 4130 if (params) { |
4127 params[0] = texture_manager()->MaxSizeForTarget(GL_TEXTURE_CUBE_MAP); | 4131 params[0] = texture_manager()->MaxSizeForTarget(GL_TEXTURE_CUBE_MAP); |
4128 } | 4132 } |
4129 return true; | 4133 return true; |
4134 case GL_MAX_COLOR_ATTACHMENTS_EXT: | |
4135 *num_written = 1; | |
4136 if (params) { | |
4137 params[0] = group_->max_color_attachments(); | |
4138 } | |
4139 return true; | |
4140 case GL_MAX_DRAW_BUFFERS_ARB: | |
4141 *num_written = 1; | |
4142 if (params) { | |
4143 params[0] = group_->max_draw_buffers(); | |
4144 } | |
4145 return true; | |
4130 case GL_ALPHA_BITS: | 4146 case GL_ALPHA_BITS: |
4131 *num_written = 1; | 4147 *num_written = 1; |
4132 if (params) { | 4148 if (params) { |
4133 GLint v = 0; | 4149 GLint v = 0; |
4134 glGetIntegerv(GL_ALPHA_BITS, &v); | 4150 glGetIntegerv(GL_ALPHA_BITS, &v); |
4135 params[0] = BoundFramebufferHasColorAttachmentWithAlpha() ? v : 0; | 4151 params[0] = BoundFramebufferHasColorAttachmentWithAlpha() ? v : 0; |
4136 } | 4152 } |
4137 return true; | 4153 return true; |
4138 case GL_DEPTH_BITS: | 4154 case GL_DEPTH_BITS: |
4139 *num_written = 1; | 4155 *num_written = 1; |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4352 params[0] = unpack_premultiply_alpha_; | 4368 params[0] = unpack_premultiply_alpha_; |
4353 } | 4369 } |
4354 return true; | 4370 return true; |
4355 case GL_UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM: | 4371 case GL_UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM: |
4356 *num_written = 1; | 4372 *num_written = 1; |
4357 if (params) { | 4373 if (params) { |
4358 params[0] = unpack_unpremultiply_alpha_; | 4374 params[0] = unpack_unpremultiply_alpha_; |
4359 } | 4375 } |
4360 return true; | 4376 return true; |
4361 default: | 4377 default: |
4378 if (pname >= GL_DRAW_BUFFER0_ARB && | |
4379 pname < GL_DRAW_BUFFER0_ARB + group_->max_draw_buffers()) { | |
4380 *num_written = 1; | |
4381 if (params) { | |
4382 Framebuffer* framebuffer = | |
4383 GetFramebufferInfoForTarget(GL_FRAMEBUFFER); | |
4384 if (framebuffer) { | |
4385 params[0] = framebuffer->GetDrawBuffer(pname); | |
4386 } else { // backbuffer | |
4387 params[0] = group_->GetDrawBuffer(pname); | |
4388 if (params[0] == static_cast<GLint>( | |
4389 pname - GL_DRAW_BUFFER0_ARB + GL_COLOR_ATTACHMENT0)) { | |
4390 params[0] = GL_BACK; | |
4391 } else { | |
4392 DCHECK(params[0] == GL_NONE); | |
4393 } | |
4394 } | |
4395 } | |
4396 return true; | |
4397 } | |
4362 *num_written = util_.GLGetNumValuesReturned(pname); | 4398 *num_written = util_.GLGetNumValuesReturned(pname); |
4363 return false; | 4399 return false; |
4364 } | 4400 } |
4365 } | 4401 } |
4366 | 4402 |
4367 bool GLES2DecoderImpl::GetNumValuesReturnedForGLGet( | 4403 bool GLES2DecoderImpl::GetNumValuesReturnedForGLGet( |
4368 GLenum pname, GLsizei* num_values) { | 4404 GLenum pname, GLsizei* num_values) { |
4369 if (state_.GetStateAsGLint(pname, NULL, num_values)) { | 4405 if (state_.GetStateAsGLint(pname, NULL, num_values)) { |
4370 return true; | 4406 return true; |
4371 } | 4407 } |
(...skipping 5735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10107 if (gpu_tracer_->CurrentName().empty()) { | 10143 if (gpu_tracer_->CurrentName().empty()) { |
10108 LOCAL_SET_GL_ERROR( | 10144 LOCAL_SET_GL_ERROR( |
10109 GL_INVALID_OPERATION, | 10145 GL_INVALID_OPERATION, |
10110 "glTraceEndCHROMIUM", "no trace begin found"); | 10146 "glTraceEndCHROMIUM", "no trace begin found"); |
10111 return; | 10147 return; |
10112 } | 10148 } |
10113 TRACE_EVENT_COPY_ASYNC_END0("gpu", gpu_tracer_->CurrentName().c_str(), this); | 10149 TRACE_EVENT_COPY_ASYNC_END0("gpu", gpu_tracer_->CurrentName().c_str(), this); |
10114 gpu_tracer_->End(); | 10150 gpu_tracer_->End(); |
10115 } | 10151 } |
10116 | 10152 |
10153 void GLES2DecoderImpl::DoDrawBuffersEXT( | |
10154 GLsizei count, const GLenum* bufs) { | |
10155 if (count > static_cast<GLsizei>(group_->max_draw_buffers())) { | |
10156 LOCAL_SET_GL_ERROR( | |
10157 GL_INVALID_VALUE, | |
10158 "glDrawBuffersEXT", "greater than GL_MAX_DRAW_BUFFERS_EXT"); | |
10159 return; | |
10160 } | |
10161 | |
10162 Framebuffer* framebuffer = GetFramebufferInfoForTarget(GL_FRAMEBUFFER); | |
10163 if (framebuffer) { | |
10164 for (GLsizei i = 0; i < count; ++i) { | |
10165 if (bufs[i] != static_cast<GLenum>(GL_COLOR_ATTACHMENT0 + i) && | |
10166 bufs[i] != GL_NONE) { | |
10167 LOCAL_SET_GL_ERROR( | |
10168 GL_INVALID_OPERATION, | |
10169 "glDrawBuffersEXT", | |
10170 "bufs[i] not GL_NONE or GL_COLOR_ATTACHMENTi_EXT"); | |
10171 return; | |
10172 } | |
10173 } | |
10174 glDrawBuffersARB(count, bufs); | |
10175 framebuffer->SetDrawBuffers(count, bufs); | |
10176 } else { // backbuffer | |
10177 for (GLsizei i = 0; i < count; ++i) { | |
10178 if (bufs[i] != GL_BACK && bufs[i] != GL_NONE) { | |
10179 LOCAL_SET_GL_ERROR( | |
10180 GL_INVALID_OPERATION, | |
10181 "glDrawBuffersEXT", "bufs[i] not GL_NONE or GL_BACK"); | |
10182 return; | |
10183 } | |
10184 } | |
10185 scoped_array<GLenum> mapped_bufs; | |
10186 const GLenum* my_bufs = bufs; | |
10187 if (GetBackbufferServiceId() != 0) { // emulated backbuffer | |
10188 mapped_bufs.reset(new GLenum(count)); | |
10189 my_bufs = mapped_bufs.get(); | |
10190 for (GLsizei i = 0; i < count; ++i) { | |
10191 if (bufs[i] == GL_BACK) | |
greggman
2013/03/14 00:51:10
It's this correct. I thought the only valid values
Zhenyao Mo
2013/03/14 01:49:34
Done.
| |
10192 mapped_bufs[i] = static_cast<GLenum>(GL_COLOR_ATTACHMENT0 + i); | |
10193 else | |
10194 mapped_bufs[i] = bufs[i]; | |
10195 } | |
10196 } | |
10197 glDrawBuffersARB(count, my_bufs); | |
10198 group_->SetDrawBuffers(count, bufs); | |
10199 } | |
10200 } | |
10201 | |
10117 bool GLES2DecoderImpl::ValidateAsyncTransfer( | 10202 bool GLES2DecoderImpl::ValidateAsyncTransfer( |
10118 const char* function_name, | 10203 const char* function_name, |
10119 Texture* texture, | 10204 Texture* texture, |
10120 GLenum target, | 10205 GLenum target, |
10121 GLint level, | 10206 GLint level, |
10122 const void * data) { | 10207 const void * data) { |
10123 // We only support async uploads to 2D textures for now. | 10208 // We only support async uploads to 2D textures for now. |
10124 if (GL_TEXTURE_2D != target) { | 10209 if (GL_TEXTURE_2D != target) { |
10125 LOCAL_SET_GL_ERROR_INVALID_ENUM(function_name, target, "target"); | 10210 LOCAL_SET_GL_ERROR_INVALID_ENUM(function_name, target, "target"); |
10126 return false; | 10211 return false; |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10339 return error::kNoError; | 10424 return error::kNoError; |
10340 } | 10425 } |
10341 | 10426 |
10342 // Include the auto-generated part of this file. We split this because it means | 10427 // Include the auto-generated part of this file. We split this because it means |
10343 // we can easily edit the non-auto generated parts right here in this file | 10428 // we can easily edit the non-auto generated parts right here in this file |
10344 // instead of having to edit some template or the code generator. | 10429 // instead of having to edit some template or the code generator. |
10345 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 10430 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
10346 | 10431 |
10347 } // namespace gles2 | 10432 } // namespace gles2 |
10348 } // namespace gpu | 10433 } // namespace gpu |
OLD | NEW |