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 852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
863 | 863 |
864 void DoBindTexImage2DCHROMIUM( | 864 void DoBindTexImage2DCHROMIUM( |
865 GLenum target, | 865 GLenum target, |
866 GLint image_id); | 866 GLint image_id); |
867 void DoReleaseTexImage2DCHROMIUM( | 867 void DoReleaseTexImage2DCHROMIUM( |
868 GLenum target, | 868 GLenum target, |
869 GLint image_id); | 869 GLint image_id); |
870 | 870 |
871 void DoTraceEndCHROMIUM(void); | 871 void DoTraceEndCHROMIUM(void); |
872 | 872 |
873 void DoDrawBuffersEXT(GLsizei count, const GLenum* bufs); | |
874 | |
873 // Creates a Program for the given program. | 875 // Creates a Program for the given program. |
874 Program* CreateProgram( | 876 Program* CreateProgram( |
875 GLuint client_id, GLuint service_id) { | 877 GLuint client_id, GLuint service_id) { |
876 return program_manager()->CreateProgram(client_id, service_id); | 878 return program_manager()->CreateProgram(client_id, service_id); |
877 } | 879 } |
878 | 880 |
879 // Gets the program info for the given program. Returns NULL if none exists. | 881 // Gets the program info for the given program. Returns NULL if none exists. |
880 Program* GetProgram(GLuint client_id) { | 882 Program* GetProgram(GLuint client_id) { |
881 return program_manager()->GetProgram(client_id); | 883 return program_manager()->GetProgram(client_id); |
882 } | 884 } |
(...skipping 1628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2511 resources.MaxVertexAttribs = group_->max_vertex_attribs(); | 2513 resources.MaxVertexAttribs = group_->max_vertex_attribs(); |
2512 resources.MaxVertexUniformVectors = | 2514 resources.MaxVertexUniformVectors = |
2513 group_->max_vertex_uniform_vectors(); | 2515 group_->max_vertex_uniform_vectors(); |
2514 resources.MaxVaryingVectors = group_->max_varying_vectors(); | 2516 resources.MaxVaryingVectors = group_->max_varying_vectors(); |
2515 resources.MaxVertexTextureImageUnits = | 2517 resources.MaxVertexTextureImageUnits = |
2516 group_->max_vertex_texture_image_units(); | 2518 group_->max_vertex_texture_image_units(); |
2517 resources.MaxCombinedTextureImageUnits = group_->max_texture_units(); | 2519 resources.MaxCombinedTextureImageUnits = group_->max_texture_units(); |
2518 resources.MaxTextureImageUnits = group_->max_texture_image_units(); | 2520 resources.MaxTextureImageUnits = group_->max_texture_image_units(); |
2519 resources.MaxFragmentUniformVectors = | 2521 resources.MaxFragmentUniformVectors = |
2520 group_->max_fragment_uniform_vectors(); | 2522 group_->max_fragment_uniform_vectors(); |
2521 resources.MaxDrawBuffers = 1; | 2523 resources.MaxDrawBuffers = group_->max_draw_buffers(); |
2522 | 2524 |
2523 #if (ANGLE_SH_VERSION >= 110) | 2525 #if (ANGLE_SH_VERSION >= 110) |
2524 resources.FragmentPrecisionHigh = 1; | 2526 resources.FragmentPrecisionHigh = 1; |
2525 #endif | 2527 #endif |
2526 | 2528 |
2527 if (force_webgl_glsl_validation_) { | 2529 if (force_webgl_glsl_validation_) { |
2528 resources.OES_standard_derivatives = derivatives_explicitly_enabled_; | 2530 resources.OES_standard_derivatives = derivatives_explicitly_enabled_; |
2529 } else { | 2531 } else { |
2530 resources.OES_standard_derivatives = | 2532 resources.OES_standard_derivatives = |
2531 features().oes_standard_derivatives ? 1 : 0; | 2533 features().oes_standard_derivatives ? 1 : 0; |
2532 resources.ARB_texture_rectangle = | 2534 resources.ARB_texture_rectangle = |
2533 features().arb_texture_rectangle ? 1 : 0; | 2535 features().arb_texture_rectangle ? 1 : 0; |
2534 resources.OES_EGL_image_external = | 2536 resources.OES_EGL_image_external = |
2535 features().oes_egl_image_external ? 1 : 0; | 2537 features().oes_egl_image_external ? 1 : 0; |
2538 resources.EXT_draw_buffers = | |
2539 features().ext_draw_buffers ? 1 : 0; | |
2536 } | 2540 } |
2537 | 2541 |
2538 ShShaderSpec shader_spec = force_webgl_glsl_validation_ || | 2542 ShShaderSpec shader_spec = force_webgl_glsl_validation_ || |
2539 force_webgl_glsl_validation_ ? SH_WEBGL_SPEC : SH_GLES2_SPEC; | 2543 force_webgl_glsl_validation_ ? SH_WEBGL_SPEC : SH_GLES2_SPEC; |
2540 if (shader_spec == SH_WEBGL_SPEC && features().enable_shader_name_hashing) | 2544 if (shader_spec == SH_WEBGL_SPEC && features().enable_shader_name_hashing) |
2541 #if !defined(ANGLE_SH_VERSION) || ANGLE_SH_VERSION < 108 | 2545 #if !defined(ANGLE_SH_VERSION) || ANGLE_SH_VERSION < 108 |
2542 resources.HashFunction = &CityHashForAngle; | 2546 resources.HashFunction = &CityHashForAngle; |
2543 #else | 2547 #else |
2544 resources.HashFunction = &CityHash64; | 2548 resources.HashFunction = &CityHash64; |
2545 #endif | 2549 #endif |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2870 if (framebuffer_manager()->IsComplete(framebuffer)) { | 2874 if (framebuffer_manager()->IsComplete(framebuffer)) { |
2871 return true; | 2875 return true; |
2872 } | 2876 } |
2873 | 2877 |
2874 GLenum completeness = framebuffer->IsPossiblyComplete(); | 2878 GLenum completeness = framebuffer->IsPossiblyComplete(); |
2875 if (completeness != GL_FRAMEBUFFER_COMPLETE) { | 2879 if (completeness != GL_FRAMEBUFFER_COMPLETE) { |
2876 SetGLError( | 2880 SetGLError( |
2877 GL_INVALID_FRAMEBUFFER_OPERATION, func_name, "framebuffer incomplete"); | 2881 GL_INVALID_FRAMEBUFFER_OPERATION, func_name, "framebuffer incomplete"); |
2878 return false; | 2882 return false; |
2879 } | 2883 } |
2880 | 2884 |
greggman
2013/03/08 21:48:28
It seems like you need some code here to work arou
Zhenyao Mo
2013/03/13 01:22:02
Plan to do the workaround in a separate CL. Easy t
| |
2881 // Are all the attachments cleared? | 2885 // Are all the attachments cleared? |
2882 if (renderbuffer_manager()->HaveUnclearedRenderbuffers() || | 2886 if (renderbuffer_manager()->HaveUnclearedRenderbuffers() || |
2883 texture_manager()->HaveUnclearedMips()) { | 2887 texture_manager()->HaveUnclearedMips()) { |
2884 if (!framebuffer->IsCleared()) { | 2888 if (!framebuffer->IsCleared()) { |
2885 // Can we clear them? | 2889 // Can we clear them? |
2886 if (framebuffer->GetStatus(texture_manager(), target) != | 2890 if (framebuffer->GetStatus(texture_manager(), target) != |
2887 GL_FRAMEBUFFER_COMPLETE) { | 2891 GL_FRAMEBUFFER_COMPLETE) { |
2888 SetGLError( | 2892 SetGLError( |
2889 GL_INVALID_FRAMEBUFFER_OPERATION, func_name, | 2893 GL_INVALID_FRAMEBUFFER_OPERATION, func_name, |
2890 "framebuffer incomplete (clear)"); | 2894 "framebuffer incomplete (clear)"); |
(...skipping 1124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4015 if (params) { | 4019 if (params) { |
4016 params[0] = texture_manager()->MaxSizeForTarget(GL_TEXTURE_2D); | 4020 params[0] = texture_manager()->MaxSizeForTarget(GL_TEXTURE_2D); |
4017 } | 4021 } |
4018 return true; | 4022 return true; |
4019 case GL_MAX_CUBE_MAP_TEXTURE_SIZE: | 4023 case GL_MAX_CUBE_MAP_TEXTURE_SIZE: |
4020 *num_written = 1; | 4024 *num_written = 1; |
4021 if (params) { | 4025 if (params) { |
4022 params[0] = texture_manager()->MaxSizeForTarget(GL_TEXTURE_CUBE_MAP); | 4026 params[0] = texture_manager()->MaxSizeForTarget(GL_TEXTURE_CUBE_MAP); |
4023 } | 4027 } |
4024 return true; | 4028 return true; |
4029 case GL_MAX_COLOR_ATTACHMENTS_EXT: | |
4030 *num_written = 1; | |
4031 if (params) { | |
4032 params[0] = group_->max_color_attachments(); | |
4033 } | |
4034 return true; | |
4035 case GL_MAX_DRAW_BUFFERS_ARB: | |
4036 *num_written = 1; | |
4037 if (params) { | |
4038 params[0] = group_->max_draw_buffers(); | |
4039 } | |
4040 return true; | |
4041 case GL_DRAW_BUFFER0_ARB: | |
greggman
2013/03/08 21:48:28
If we're making this forward compatible it seems l
Zhenyao Mo
2013/03/13 01:22:02
Done.
| |
4042 case GL_DRAW_BUFFER1_ARB: | |
4043 case GL_DRAW_BUFFER2_ARB: | |
4044 case GL_DRAW_BUFFER3_ARB: | |
4045 case GL_DRAW_BUFFER4_ARB: | |
4046 case GL_DRAW_BUFFER5_ARB: | |
4047 case GL_DRAW_BUFFER6_ARB: | |
4048 case GL_DRAW_BUFFER7_ARB: | |
4049 case GL_DRAW_BUFFER8_ARB: | |
4050 case GL_DRAW_BUFFER9_ARB: | |
4051 case GL_DRAW_BUFFER10_ARB: | |
4052 case GL_DRAW_BUFFER11_ARB: | |
4053 case GL_DRAW_BUFFER12_ARB: | |
4054 case GL_DRAW_BUFFER13_ARB: | |
4055 case GL_DRAW_BUFFER14_ARB: | |
4056 case GL_DRAW_BUFFER15_ARB: | |
4057 *num_written = 1; | |
4058 if (params) { | |
4059 Framebuffer* framebuffer = | |
4060 GetFramebufferInfoForTarget(GL_FRAMEBUFFER); | |
4061 if (framebuffer) | |
4062 params[0] = framebuffer->GetDrawBuffer(pname); | |
4063 else | |
4064 NOTREACHED(); | |
4065 } | |
4066 return true; | |
4025 case GL_ALPHA_BITS: | 4067 case GL_ALPHA_BITS: |
4026 *num_written = 1; | 4068 *num_written = 1; |
4027 if (params) { | 4069 if (params) { |
4028 GLint v = 0; | 4070 GLint v = 0; |
4029 glGetIntegerv(GL_ALPHA_BITS, &v); | 4071 glGetIntegerv(GL_ALPHA_BITS, &v); |
4030 params[0] = BoundFramebufferHasColorAttachmentWithAlpha() ? v : 0; | 4072 params[0] = BoundFramebufferHasColorAttachmentWithAlpha() ? v : 0; |
4031 } | 4073 } |
4032 return true; | 4074 return true; |
4033 case GL_DEPTH_BITS: | 4075 case GL_DEPTH_BITS: |
4034 *num_written = 1; | 4076 *num_written = 1; |
(...skipping 5912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9947 void GLES2DecoderImpl::DoTraceEndCHROMIUM() { | 9989 void GLES2DecoderImpl::DoTraceEndCHROMIUM() { |
9948 if (gpu_tracer_->CurrentName().empty()) { | 9990 if (gpu_tracer_->CurrentName().empty()) { |
9949 SetGLError(GL_INVALID_OPERATION, | 9991 SetGLError(GL_INVALID_OPERATION, |
9950 "glTraceEndCHROMIUM", "no trace begin found"); | 9992 "glTraceEndCHROMIUM", "no trace begin found"); |
9951 return; | 9993 return; |
9952 } | 9994 } |
9953 TRACE_EVENT_COPY_ASYNC_END0("gpu", gpu_tracer_->CurrentName().c_str(), this); | 9995 TRACE_EVENT_COPY_ASYNC_END0("gpu", gpu_tracer_->CurrentName().c_str(), this); |
9954 gpu_tracer_->End(); | 9996 gpu_tracer_->End(); |
9955 } | 9997 } |
9956 | 9998 |
9999 void GLES2DecoderImpl::DoDrawBuffersEXT( | |
10000 GLsizei count, const GLenum* bufs) { | |
10001 Framebuffer* framebuffer = GetFramebufferInfoForTarget(GL_FRAMEBUFFER); | |
10002 if (framebuffer) { | |
greggman
2013/03/08 21:48:28
framebuffer will be NULL if the current target is
Zhenyao Mo
2013/03/13 01:22:02
Done.
| |
10003 if (count > static_cast<GLsizei>(group_->max_draw_buffers())) { | |
10004 SetGLError(GL_INVALID_VALUE, | |
10005 "glDrawBuffersEXT", "greater than GL_MAX_DRAW_BUFFERS_EXT"); | |
10006 return; | |
10007 } | |
10008 for (GLsizei i = 0; i < count; ++i) { | |
10009 if (bufs[i] != static_cast<GLenum>(GL_COLOR_ATTACHMENT0 + i) && | |
10010 bufs[i] != GL_NONE) { | |
10011 SetGLError(GL_INVALID_OPERATION, | |
10012 "glDrawBuffersEXT", | |
10013 "bufs[i] not GL_NONE or GL_COLOR_ATTACHMENTi_EXT"); | |
10014 return; | |
10015 } | |
10016 } | |
10017 framebuffer->SetDrawBuffers(count, bufs); | |
10018 glDrawBuffersARB(count, bufs); | |
10019 } else { | |
10020 NOTREACHED(); | |
10021 } | |
10022 } | |
10023 | |
9957 bool GLES2DecoderImpl::ValidateAsyncTransfer( | 10024 bool GLES2DecoderImpl::ValidateAsyncTransfer( |
9958 const char* function_name, | 10025 const char* function_name, |
9959 Texture* info, | 10026 Texture* info, |
9960 GLenum target, | 10027 GLenum target, |
9961 GLint level, | 10028 GLint level, |
9962 const void * data) { | 10029 const void * data) { |
9963 // We only support async uploads to 2D textures for now. | 10030 // We only support async uploads to 2D textures for now. |
9964 if (GL_TEXTURE_2D != target) { | 10031 if (GL_TEXTURE_2D != target) { |
9965 SetGLErrorInvalidEnum(function_name, target, "target"); | 10032 SetGLErrorInvalidEnum(function_name, target, "target"); |
9966 return false; | 10033 return false; |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10172 return error::kNoError; | 10239 return error::kNoError; |
10173 } | 10240 } |
10174 | 10241 |
10175 // Include the auto-generated part of this file. We split this because it means | 10242 // Include the auto-generated part of this file. We split this because it means |
10176 // we can easily edit the non-auto generated parts right here in this file | 10243 // we can easily edit the non-auto generated parts right here in this file |
10177 // instead of having to edit some template or the code generator. | 10244 // instead of having to edit some template or the code generator. |
10178 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 10245 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
10179 | 10246 |
10180 } // namespace gles2 | 10247 } // namespace gles2 |
10181 } // namespace gpu | 10248 } // namespace gpu |
OLD | NEW |