OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 unsigned int arg_count, | 454 unsigned int arg_count, |
455 const void* args); | 455 const void* args); |
456 | 456 |
457 // Overridden from AsyncAPIInterface. | 457 // Overridden from AsyncAPIInterface. |
458 virtual const char* GetCommandName(unsigned int command_id) const; | 458 virtual const char* GetCommandName(unsigned int command_id) const; |
459 | 459 |
460 // Overridden from GLES2Decoder. | 460 // Overridden from GLES2Decoder. |
461 virtual bool Initialize(const scoped_refptr<gfx::GLSurface>& surface, | 461 virtual bool Initialize(const scoped_refptr<gfx::GLSurface>& surface, |
462 const scoped_refptr<gfx::GLContext>& context, | 462 const scoped_refptr<gfx::GLContext>& context, |
463 const gfx::Size& size, | 463 const gfx::Size& size, |
464 const DisallowedExtensions& disallowed_extensions, | 464 const DisallowedFeatures& disallowed_features, |
465 const char* allowed_extensions, | 465 const char* allowed_extensions, |
466 const std::vector<int32>& attribs); | 466 const std::vector<int32>& attribs); |
467 virtual void Destroy(); | 467 virtual void Destroy(); |
468 virtual bool SetParent(GLES2Decoder* parent_decoder, | 468 virtual bool SetParent(GLES2Decoder* parent_decoder, |
469 uint32 parent_texture_id); | 469 uint32 parent_texture_id); |
470 virtual bool ResizeOffscreenFrameBuffer(const gfx::Size& size); | 470 virtual bool ResizeOffscreenFrameBuffer(const gfx::Size& size); |
471 void UpdateParentTextureInfo(); | 471 void UpdateParentTextureInfo(); |
472 virtual bool MakeCurrent(); | 472 virtual bool MakeCurrent(); |
473 virtual GLES2Util* GetGLES2Util() { return &util_; } | 473 virtual GLES2Util* GetGLES2Util() { return &util_; } |
474 virtual gfx::GLContext* GetGLContext() { return context_.get(); } | 474 virtual gfx::GLContext* GetGLContext() { return context_.get(); } |
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1299 // The last error message set. | 1299 // The last error message set. |
1300 std::string last_error_; | 1300 std::string last_error_; |
1301 | 1301 |
1302 // The current decoder error. | 1302 // The current decoder error. |
1303 error::Error current_decoder_error_; | 1303 error::Error current_decoder_error_; |
1304 | 1304 |
1305 bool use_shader_translator_; | 1305 bool use_shader_translator_; |
1306 scoped_ptr<ShaderTranslator> vertex_translator_; | 1306 scoped_ptr<ShaderTranslator> vertex_translator_; |
1307 scoped_ptr<ShaderTranslator> fragment_translator_; | 1307 scoped_ptr<ShaderTranslator> fragment_translator_; |
1308 | 1308 |
1309 DisallowedExtensions disallowed_extensions_; | 1309 DisallowedFeatures disallowed_features_; |
1310 | 1310 |
1311 // Cached from ContextGroup | 1311 // Cached from ContextGroup |
1312 const Validators* validators_; | 1312 const Validators* validators_; |
1313 FeatureInfo* feature_info_; | 1313 FeatureInfo* feature_info_; |
1314 | 1314 |
1315 // This indicates all the following texSubImage2D calls that are part of the | 1315 // This indicates all the following texSubImage2D calls that are part of the |
1316 // failed texImage2D call should be ignored. | 1316 // failed texImage2D call should be ignored. |
1317 bool tex_image_2d_failed_; | 1317 bool tex_image_2d_failed_; |
1318 | 1318 |
1319 int frame_number_; | 1319 int frame_number_; |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1709 if (IsAngle()) { | 1709 if (IsAngle()) { |
1710 teximage2d_faster_than_texsubimage2d_ = false; | 1710 teximage2d_faster_than_texsubimage2d_ = false; |
1711 bufferdata_faster_than_buffersubdata_ = false; | 1711 bufferdata_faster_than_buffersubdata_ = false; |
1712 } | 1712 } |
1713 } | 1713 } |
1714 | 1714 |
1715 bool GLES2DecoderImpl::Initialize( | 1715 bool GLES2DecoderImpl::Initialize( |
1716 const scoped_refptr<gfx::GLSurface>& surface, | 1716 const scoped_refptr<gfx::GLSurface>& surface, |
1717 const scoped_refptr<gfx::GLContext>& context, | 1717 const scoped_refptr<gfx::GLContext>& context, |
1718 const gfx::Size& size, | 1718 const gfx::Size& size, |
1719 const DisallowedExtensions& disallowed_extensions, | 1719 const DisallowedFeatures& disallowed_features, |
1720 const char* allowed_extensions, | 1720 const char* allowed_extensions, |
1721 const std::vector<int32>& attribs) { | 1721 const std::vector<int32>& attribs) { |
1722 DCHECK(context); | 1722 DCHECK(context); |
1723 DCHECK(!context_.get()); | 1723 DCHECK(!context_.get()); |
1724 | 1724 |
1725 // Take ownership of the GLSurface. TODO(apatrick): once the parent / child | 1725 // Take ownership of the GLSurface. TODO(apatrick): once the parent / child |
1726 // context is retired, the decoder should not take an initial surface as | 1726 // context is retired, the decoder should not take an initial surface as |
1727 // an argument to this function. | 1727 // an argument to this function. |
1728 // Maybe create a short lived offscreen GLSurface for the purpose of | 1728 // Maybe create a short lived offscreen GLSurface for the purpose of |
1729 // initializing the decoder's GLContext. | 1729 // initializing the decoder's GLContext. |
1730 surface_ = surface; | 1730 surface_ = surface; |
1731 | 1731 |
1732 // Take ownership of the GLContext. | 1732 // Take ownership of the GLContext. |
1733 context_ = context; | 1733 context_ = context; |
1734 | 1734 |
1735 if (!MakeCurrent()) { | 1735 if (!MakeCurrent()) { |
1736 LOG(ERROR) << "GLES2DecoderImpl::Initialize failed because " | 1736 LOG(ERROR) << "GLES2DecoderImpl::Initialize failed because " |
1737 << "MakeCurrent failed."; | 1737 << "MakeCurrent failed."; |
1738 Destroy(); | 1738 Destroy(); |
1739 return false; | 1739 return false; |
1740 } | 1740 } |
1741 | 1741 |
1742 if (!group_->Initialize(disallowed_extensions, allowed_extensions)) { | 1742 if (!group_->Initialize(disallowed_features, allowed_extensions)) { |
1743 LOG(ERROR) << "GpuScheduler::InitializeCommon failed because group " | 1743 LOG(ERROR) << "GpuScheduler::InitializeCommon failed because group " |
1744 << "failed to initialize."; | 1744 << "failed to initialize."; |
1745 Destroy(); | 1745 Destroy(); |
1746 return false; | 1746 return false; |
1747 } | 1747 } |
1748 | 1748 |
1749 CHECK_GL_ERROR(); | 1749 CHECK_GL_ERROR(); |
1750 disallowed_extensions_ = disallowed_extensions; | 1750 disallowed_features_ = disallowed_features; |
1751 | 1751 |
1752 vertex_attrib_manager_.Initialize(group_->max_vertex_attribs()); | 1752 vertex_attrib_manager_.Initialize(group_->max_vertex_attribs()); |
1753 | 1753 |
1754 util_.set_num_compressed_texture_formats( | 1754 util_.set_num_compressed_texture_formats( |
1755 validators_->compressed_texture_format.GetValues().size()); | 1755 validators_->compressed_texture_format.GetValues().size()); |
1756 | 1756 |
1757 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { | 1757 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { |
1758 // We have to enable vertex array 0 on OpenGL or it won't render. Note that | 1758 // We have to enable vertex array 0 on OpenGL or it won't render. Note that |
1759 // OpenGL ES 2.0 does not have this issue. | 1759 // OpenGL ES 2.0 does not have this issue. |
1760 glEnableVertexAttribArray(0); | 1760 glEnableVertexAttribArray(0); |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1931 // mailing list archives. It also implicitly enables the desktop GL | 1931 // mailing list archives. It also implicitly enables the desktop GL |
1932 // capability GL_POINT_SPRITE to provide access to the gl_PointCoord | 1932 // capability GL_POINT_SPRITE to provide access to the gl_PointCoord |
1933 // variable in fragment shaders. | 1933 // variable in fragment shaders. |
1934 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { | 1934 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { |
1935 glEnable(GL_VERTEX_PROGRAM_POINT_SIZE); | 1935 glEnable(GL_VERTEX_PROGRAM_POINT_SIZE); |
1936 glEnable(GL_POINT_SPRITE); | 1936 glEnable(GL_POINT_SPRITE); |
1937 } | 1937 } |
1938 | 1938 |
1939 has_arb_robustness_ = context->HasExtension("GL_ARB_robustness"); | 1939 has_arb_robustness_ = context->HasExtension("GL_ARB_robustness"); |
1940 | 1940 |
1941 if (!disallowed_extensions_.driver_bug_workarounds) { | 1941 if (!disallowed_features_.driver_bug_workarounds) { |
1942 #if defined(OS_MACOSX) | 1942 #if defined(OS_MACOSX) |
1943 const char* vendor_str = reinterpret_cast<const char*>( | 1943 const char* vendor_str = reinterpret_cast<const char*>( |
1944 glGetString(GL_VENDOR)); | 1944 glGetString(GL_VENDOR)); |
1945 needs_mac_nvidia_driver_workaround_ = | 1945 needs_mac_nvidia_driver_workaround_ = |
1946 vendor_str && strstr(vendor_str, "NVIDIA"); | 1946 vendor_str && strstr(vendor_str, "NVIDIA"); |
1947 needs_glsl_built_in_function_emulation_ = | 1947 needs_glsl_built_in_function_emulation_ = |
1948 vendor_str && (strstr(vendor_str, "ATI") || strstr(vendor_str, "AMD")); | 1948 vendor_str && (strstr(vendor_str, "ATI") || strstr(vendor_str, "AMD")); |
1949 #elif defined(OS_WIN) | 1949 #elif defined(OS_WIN) |
1950 if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2) | 1950 if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2) |
1951 needs_glsl_built_in_function_emulation_ = true; | 1951 needs_glsl_built_in_function_emulation_ = true; |
(...skipping 4767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6719 | 6719 |
6720 *result = 1; // true. | 6720 *result = 1; // true. |
6721 return error::kNoError; | 6721 return error::kNoError; |
6722 } | 6722 } |
6723 | 6723 |
6724 error::Error GLES2DecoderImpl::HandleGetRequestableExtensionsCHROMIUM( | 6724 error::Error GLES2DecoderImpl::HandleGetRequestableExtensionsCHROMIUM( |
6725 uint32 immediate_data_size, | 6725 uint32 immediate_data_size, |
6726 const gles2::GetRequestableExtensionsCHROMIUM& c) { | 6726 const gles2::GetRequestableExtensionsCHROMIUM& c) { |
6727 Bucket* bucket = CreateBucket(c.bucket_id); | 6727 Bucket* bucket = CreateBucket(c.bucket_id); |
6728 scoped_ptr<FeatureInfo> info(new FeatureInfo()); | 6728 scoped_ptr<FeatureInfo> info(new FeatureInfo()); |
6729 info->Initialize(disallowed_extensions_, NULL); | 6729 info->Initialize(disallowed_features_, NULL); |
6730 bucket->SetFromString(info->extensions().c_str()); | 6730 bucket->SetFromString(info->extensions().c_str()); |
6731 return error::kNoError; | 6731 return error::kNoError; |
6732 } | 6732 } |
6733 | 6733 |
6734 error::Error GLES2DecoderImpl::HandleRequestExtensionCHROMIUM( | 6734 error::Error GLES2DecoderImpl::HandleRequestExtensionCHROMIUM( |
6735 uint32 immediate_data_size, const gles2::RequestExtensionCHROMIUM& c) { | 6735 uint32 immediate_data_size, const gles2::RequestExtensionCHROMIUM& c) { |
6736 Bucket* bucket = GetBucket(c.bucket_id); | 6736 Bucket* bucket = GetBucket(c.bucket_id); |
6737 std::string feature_str; | 6737 std::string feature_str; |
6738 if (!bucket->GetAsString(&feature_str)) { | 6738 if (!bucket->GetAsString(&feature_str)) { |
6739 return error::kInvalidArguments; | 6739 return error::kInvalidArguments; |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6885 return false; | 6885 return false; |
6886 } | 6886 } |
6887 | 6887 |
6888 // Include the auto-generated part of this file. We split this because it means | 6888 // Include the auto-generated part of this file. We split this because it means |
6889 // we can easily edit the non-auto generated parts right here in this file | 6889 // we can easily edit the non-auto generated parts right here in this file |
6890 // instead of having to edit some template or the code generator. | 6890 // instead of having to edit some template or the code generator. |
6891 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 6891 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
6892 | 6892 |
6893 } // namespace gles2 | 6893 } // namespace gles2 |
6894 } // namespace gpu | 6894 } // namespace gpu |
OLD | NEW |