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

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

Issue 14308014: Clean up of GLES2 Command Decoder by moving some of the error state into a separate class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed the remaining tests. Added mock ErrorState. Created 7 years, 8 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 <stdio.h> 7 #include <stdio.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <list> 10 #include <list>
11 #include <map> 11 #include <map>
12 #include <stack> 12 #include <stack>
13 #include <string> 13 #include <string>
14 #include <vector> 14 #include <vector>
15 15
16 #include "base/at_exit.h" 16 #include "base/at_exit.h"
17 #include "base/atomicops.h" 17 #include "base/atomicops.h"
18 #include "base/bind.h" 18 #include "base/bind.h"
19 #include "base/command_line.h" 19 #include "base/command_line.h"
20 #include "base/debug/trace_event.h" 20 #include "base/debug/trace_event.h"
21 #if defined(OS_MACOSX) 21 #if defined(OS_MACOSX)
22 #include "base/mac/scoped_cftyperef.h" 22 #include "base/mac/scoped_cftyperef.h"
23 #endif 23 #endif
24 #include "base/memory/scoped_ptr.h" 24 #include "base/memory/scoped_ptr.h"
25 #include "base/string_number_conversions.h" 25 #include "base/string_number_conversions.h"
26 #include "base/stringprintf.h"
27 #include "build/build_config.h" 26 #include "build/build_config.h"
28 #define GLES2_GPU_SERVICE 1 27 #define GLES2_GPU_SERVICE 1
29 #include "gpu/command_buffer/common/gles2_cmd_format.h" 28 #include "gpu/command_buffer/common/gles2_cmd_format.h"
30 #include "gpu/command_buffer/common/gles2_cmd_utils.h" 29 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
31 #include "gpu/command_buffer/common/debug_marker_manager.h" 30 #include "gpu/command_buffer/common/debug_marker_manager.h"
32 #include "gpu/command_buffer/common/id_allocator.h" 31 #include "gpu/command_buffer/common/id_allocator.h"
33 #include "gpu/command_buffer/service/buffer_manager.h" 32 #include "gpu/command_buffer/service/buffer_manager.h"
34 #include "gpu/command_buffer/service/cmd_buffer_engine.h" 33 #include "gpu/command_buffer/service/cmd_buffer_engine.h"
35 #include "gpu/command_buffer/service/context_group.h" 34 #include "gpu/command_buffer/service/context_group.h"
36 #include "gpu/command_buffer/service/context_state.h" 35 #include "gpu/command_buffer/service/context_state.h"
36 #include "gpu/command_buffer/service/error_state.h"
37 #include "gpu/command_buffer/service/feature_info.h" 37 #include "gpu/command_buffer/service/feature_info.h"
38 #include "gpu/command_buffer/service/framebuffer_manager.h" 38 #include "gpu/command_buffer/service/framebuffer_manager.h"
39 #include "gpu/command_buffer/service/gl_utils.h" 39 #include "gpu/command_buffer/service/gl_utils.h"
40 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h" 40 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h"
41 #include "gpu/command_buffer/service/gles2_cmd_validation.h" 41 #include "gpu/command_buffer/service/gles2_cmd_validation.h"
42 #include "gpu/command_buffer/service/gpu_switches.h" 42 #include "gpu/command_buffer/service/gpu_switches.h"
43 #include "gpu/command_buffer/service/gpu_tracer.h" 43 #include "gpu/command_buffer/service/gpu_tracer.h"
44 #include "gpu/command_buffer/service/image_manager.h" 44 #include "gpu/command_buffer/service/image_manager.h"
45 #include "gpu/command_buffer/service/logger.h"
46 #include "gpu/command_buffer/service/mailbox_manager.h" 45 #include "gpu/command_buffer/service/mailbox_manager.h"
47 #include "gpu/command_buffer/service/memory_tracking.h" 46 #include "gpu/command_buffer/service/memory_tracking.h"
48 #include "gpu/command_buffer/service/program_manager.h" 47 #include "gpu/command_buffer/service/program_manager.h"
49 #include "gpu/command_buffer/service/query_manager.h" 48 #include "gpu/command_buffer/service/query_manager.h"
50 #include "gpu/command_buffer/service/renderbuffer_manager.h" 49 #include "gpu/command_buffer/service/renderbuffer_manager.h"
51 #include "gpu/command_buffer/service/shader_manager.h" 50 #include "gpu/command_buffer/service/shader_manager.h"
52 #include "gpu/command_buffer/service/shader_translator.h" 51 #include "gpu/command_buffer/service/shader_translator.h"
53 #include "gpu/command_buffer/service/shader_translator_cache.h" 52 #include "gpu/command_buffer/service/shader_translator_cache.h"
54 #include "gpu/command_buffer/service/stream_texture.h" 53 #include "gpu/command_buffer/service/stream_texture.h"
55 #include "gpu/command_buffer/service/stream_texture_manager.h" 54 #include "gpu/command_buffer/service/stream_texture_manager.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 range, precision); 119 range, precision);
121 } 120 }
122 } 121 }
123 122
124 } // namespace 123 } // namespace
125 124
126 class GLES2DecoderImpl; 125 class GLES2DecoderImpl;
127 126
128 // Local versions of the SET_GL_ERROR macros 127 // Local versions of the SET_GL_ERROR macros
129 #define LOCAL_SET_GL_ERROR(error, function_name, msg) \ 128 #define LOCAL_SET_GL_ERROR(error, function_name, msg) \
130 GLESDECODER_SET_GL_ERROR(this, error, function_name, msg) 129 ERRORSTATE_SET_GL_ERROR(state_.GetErrorState(), error, function_name, msg)
131 #define LOCAL_SET_GL_ERROR_INVALID_ENUM(function_name, value, label) \ 130 #define LOCAL_SET_GL_ERROR_INVALID_ENUM(function_name, value, label) \
132 GLESDECODER_SET_GL_ERROR_INVALID_ENUM(this, function_name, value, label) 131 ERRORSTATE_SET_GL_ERROR_INVALID_ENUM(state_.GetErrorState(), \
132 function_name, value, label)
133 #define LOCAL_SET_GL_ERROR_INVALID_PARAM(error, function_name, pname) \ 133 #define LOCAL_SET_GL_ERROR_INVALID_PARAM(error, function_name, pname) \
134 GLESDECODER_SET_GL_ERROR_INVALID_PARAM(this, error, function_name, pname) 134 ERRORSTATE_SET_GL_ERROR_INVALID_PARAM(state_.GetErrorState(), error, \
135 function_name, pname)
135 #define LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(function_name) \ 136 #define LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(function_name) \
136 GLESDECODER_COPY_REAL_GL_ERRORS_TO_WRAPPER(this, function_name) 137 ERRORSTATE_COPY_REAL_GL_ERRORS_TO_WRAPPER(state_.GetErrorState(), \
138 function_name)
137 #define LOCAL_PEEK_GL_ERROR(function_name) \ 139 #define LOCAL_PEEK_GL_ERROR(function_name) \
138 GLESDECODER_PEEK_GL_ERROR(this, function_name) 140 ERRORSTATE_PEEK_GL_ERROR(state_.GetErrorState(), function_name)
139 #define LOCAL_CLEAR_REAL_GL_ERRORS(function_name) \ 141 #define LOCAL_CLEAR_REAL_GL_ERRORS(function_name) \
140 GLESDECODER_CLEARREAL_GL_ERRORS(this, function_name) 142 ERRORSTATE_CLEAR_REAL_GL_ERRORS(state_.GetErrorState(), function_name)
141 #define LOCAL_PERFORMANCE_WARNING(msg) \ 143 #define LOCAL_PERFORMANCE_WARNING(msg) \
142 PerformanceWarning(__FILE__, __LINE__, msg) 144 PerformanceWarning(__FILE__, __LINE__, msg)
143 #define LOCAL_RENDER_WARNING(msg) \ 145 #define LOCAL_RENDER_WARNING(msg) \
144 RenderWarning(__FILE__, __LINE__, msg) 146 RenderWarning(__FILE__, __LINE__, msg)
145 147
146 // Check that certain assumptions the code makes are true. There are places in 148 // Check that certain assumptions the code makes are true. There are places in
147 // the code where shared memory is passed direclty to GL. Example, glUniformiv, 149 // the code where shared memory is passed direclty to GL. Example, glUniformiv,
148 // glShaderSource. The command buffer code assumes GLint and GLsizei (and maybe 150 // glShaderSource. The command buffer code assumes GLint and GLsizei (and maybe
149 // a few others) are 32bits. If they are not 32bits the code will have to change 151 // a few others) are 32bits. If they are not 32bits the code will have to change
150 // to call those GL functions with service side memory and then copy the results 152 // to call those GL functions with service side memory and then copy the results
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2; 555 gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2;
554 #else 556 #else
555 return testing_force_is_angle_; 557 return testing_force_is_angle_;
556 #endif 558 #endif
557 } 559 }
558 560
559 // This class implements GLES2Decoder so we don't have to expose all the GLES2 561 // This class implements GLES2Decoder so we don't have to expose all the GLES2
560 // cmd stuff to outside this class. 562 // cmd stuff to outside this class.
561 class GLES2DecoderImpl : public GLES2Decoder { 563 class GLES2DecoderImpl : public GLES2Decoder {
562 public: 564 public:
563 static const int kMaxLogMessages = 256;
564
565 // Used by PrepForSetUniformByLocation to validate types. 565 // Used by PrepForSetUniformByLocation to validate types.
566 struct BaseUniformInfo { 566 struct BaseUniformInfo {
567 const GLenum* const valid_types; 567 const GLenum* const valid_types;
568 size_t num_valid_types; 568 size_t num_valid_types;
569 }; 569 };
570 570
571 explicit GLES2DecoderImpl(ContextGroup* group); 571 explicit GLES2DecoderImpl(ContextGroup* group);
572 virtual ~GLES2DecoderImpl(); 572 virtual ~GLES2DecoderImpl();
573 573
574 // Overridden from AsyncAPIInterface. 574 // Overridden from AsyncAPIInterface.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 return vertex_array_manager_.get(); 632 return vertex_array_manager_.get();
633 } 633 }
634 virtual bool ProcessPendingQueries() OVERRIDE; 634 virtual bool ProcessPendingQueries() OVERRIDE;
635 virtual bool HasMoreIdleWork() OVERRIDE; 635 virtual bool HasMoreIdleWork() OVERRIDE;
636 virtual void PerformIdleWork() OVERRIDE; 636 virtual void PerformIdleWork() OVERRIDE;
637 637
638 virtual void SetResizeCallback( 638 virtual void SetResizeCallback(
639 const base::Callback<void(gfx::Size)>& callback) OVERRIDE; 639 const base::Callback<void(gfx::Size)>& callback) OVERRIDE;
640 640
641 virtual Logger* GetLogger() OVERRIDE; 641 virtual Logger* GetLogger() OVERRIDE;
642 virtual ErrorState * GetErrorState() OVERRIDE;
greggman 2013/04/17 00:15:29 nit: no space before '*'
kloveless 2013/04/17 14:58:01 Done.
642 643
643 virtual void SetShaderCacheCallback( 644 virtual void SetShaderCacheCallback(
644 const ShaderCacheCallback& callback) OVERRIDE; 645 const ShaderCacheCallback& callback) OVERRIDE;
645 virtual void SetWaitSyncPointCallback( 646 virtual void SetWaitSyncPointCallback(
646 const WaitSyncPointCallback& callback) OVERRIDE; 647 const WaitSyncPointCallback& callback) OVERRIDE;
647 648
648 virtual void SetStreamTextureManager(StreamTextureManager* manager) OVERRIDE; 649 virtual void SetStreamTextureManager(StreamTextureManager* manager) OVERRIDE;
649 650
650 virtual gfx::AsyncPixelTransferDelegate* 651 virtual gfx::AsyncPixelTransferDelegate*
651 GetAsyncPixelTransferDelegate() OVERRIDE; 652 GetAsyncPixelTransferDelegate() OVERRIDE;
652 virtual void SetAsyncPixelTransferDelegate( 653 virtual void SetAsyncPixelTransferDelegate(
653 gfx::AsyncPixelTransferDelegate* delegate) OVERRIDE; 654 gfx::AsyncPixelTransferDelegate* delegate) OVERRIDE;
654 void ProcessFinishedAsyncTransfers(); 655 void ProcessFinishedAsyncTransfers();
655 656
656 virtual bool GetServiceTextureId(uint32 client_texture_id, 657 virtual bool GetServiceTextureId(uint32 client_texture_id,
657 uint32* service_texture_id) OVERRIDE; 658 uint32* service_texture_id) OVERRIDE;
658 659
659 virtual uint32 GetGLError() OVERRIDE;
660
661 virtual uint32 GetTextureUploadCount() OVERRIDE; 660 virtual uint32 GetTextureUploadCount() OVERRIDE;
662 virtual base::TimeDelta GetTotalTextureUploadTime() OVERRIDE; 661 virtual base::TimeDelta GetTotalTextureUploadTime() OVERRIDE;
663 virtual base::TimeDelta GetTotalProcessingCommandsTime() OVERRIDE; 662 virtual base::TimeDelta GetTotalProcessingCommandsTime() OVERRIDE;
664 virtual void AddProcessingCommandsTime(base::TimeDelta) OVERRIDE; 663 virtual void AddProcessingCommandsTime(base::TimeDelta) OVERRIDE;
665 664
666 // Restores the current state to the user's settings. 665 // Restores the current state to the user's settings.
667 void RestoreCurrentFramebufferBindings(); 666 void RestoreCurrentFramebufferBindings();
668 void RestoreCurrentRenderbufferBindings(); 667 void RestoreCurrentRenderbufferBindings();
669 void RestoreCurrentTexture2DBindings(); 668 void RestoreCurrentTexture2DBindings();
670 669
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after
1399 void DoValidateProgram(GLuint program_client_id); 1398 void DoValidateProgram(GLuint program_client_id);
1400 1399
1401 void DoInsertEventMarkerEXT(GLsizei length, const GLchar* marker); 1400 void DoInsertEventMarkerEXT(GLsizei length, const GLchar* marker);
1402 void DoPushGroupMarkerEXT(GLsizei length, const GLchar* group); 1401 void DoPushGroupMarkerEXT(GLsizei length, const GLchar* group);
1403 void DoPopGroupMarkerEXT(void); 1402 void DoPopGroupMarkerEXT(void);
1404 1403
1405 // Gets the number of values that will be returned by glGetXXX. Returns 1404 // Gets the number of values that will be returned by glGetXXX. Returns
1406 // false if pname is unknown. 1405 // false if pname is unknown.
1407 bool GetNumValuesReturnedForGLGet(GLenum pname, GLsizei* num_values); 1406 bool GetNumValuesReturnedForGLGet(GLenum pname, GLsizei* num_values);
1408 1407
1409 virtual void SetGLError(
1410 const char* filename,
1411 int line,
1412 unsigned error,
1413 const char* function_name,
1414 const char* msg) OVERRIDE;
1415 virtual void SetGLErrorInvalidEnum(
1416 const char* filename,
1417 int line,
1418 const char* function_name,
1419 unsigned value,
1420 const char* label) OVERRIDE;
1421 // Generates a GL error for a bad parameter.
1422 virtual void SetGLErrorInvalidParam(
1423 const char* filename,
1424 int line,
1425 unsigned error,
1426 const char* function_name,
1427 unsigned pname,
1428 int param) OVERRIDE;
1429
1430 virtual unsigned PeekGLError(
1431 const char* filename, int line, const char* function_name) OVERRIDE;
1432 virtual void CopyRealGLErrorsToWrapper(
1433 const char* filename, int line, const char* function_name) OVERRIDE;
1434 virtual void ClearRealGLErrors(
1435 const char* filename, int line, const char* function_name) OVERRIDE;
1436
1437 // Checks if the current program and vertex attributes are valid for drawing. 1408 // Checks if the current program and vertex attributes are valid for drawing.
1438 bool IsDrawValid( 1409 bool IsDrawValid(
1439 const char* function_name, GLuint max_vertex_accessed, GLsizei primcount); 1410 const char* function_name, GLuint max_vertex_accessed, GLsizei primcount);
1440 1411
1441 // Returns true if successful, simulated will be true if attrib0 was 1412 // Returns true if successful, simulated will be true if attrib0 was
1442 // simulated. 1413 // simulated.
1443 bool SimulateAttrib0( 1414 bool SimulateAttrib0(
1444 const char* function_name, GLuint max_vertex_accessed, bool* simulated); 1415 const char* function_name, GLuint max_vertex_accessed, bool* simulated);
1445 void RestoreStateForAttrib(GLuint attrib); 1416 void RestoreStateForAttrib(GLuint attrib);
1446 1417
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1654 // All the state for this context. 1625 // All the state for this context.
1655 ContextState state_; 1626 ContextState state_;
1656 1627
1657 // A parent decoder can access this decoders saved offscreen frame buffer. 1628 // A parent decoder can access this decoders saved offscreen frame buffer.
1658 // The parent pointer is reset if the parent is destroyed. 1629 // The parent pointer is reset if the parent is destroyed.
1659 base::WeakPtr<GLES2DecoderImpl> parent_; 1630 base::WeakPtr<GLES2DecoderImpl> parent_;
1660 1631
1661 // Current width and height of the offscreen frame buffer. 1632 // Current width and height of the offscreen frame buffer.
1662 gfx::Size offscreen_size_; 1633 gfx::Size offscreen_size_;
1663 1634
1664 // Current GL error bits.
1665 uint32 error_bits_;
1666
1667 // Util to help with GL. 1635 // Util to help with GL.
1668 GLES2Util util_; 1636 GLES2Util util_;
1669 1637
1670 // unpack flip y as last set by glPixelStorei 1638 // unpack flip y as last set by glPixelStorei
1671 bool unpack_flip_y_; 1639 bool unpack_flip_y_;
1672 1640
1673 // unpack (un)premultiply alpha as last set by glPixelStorei 1641 // unpack (un)premultiply alpha as last set by glPixelStorei
1674 bool unpack_premultiply_alpha_; 1642 bool unpack_premultiply_alpha_;
1675 bool unpack_unpremultiply_alpha_; 1643 bool unpack_unpremultiply_alpha_;
1676 1644
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1741 // The format of the back buffer_ 1709 // The format of the back buffer_
1742 GLenum back_buffer_color_format_; 1710 GLenum back_buffer_color_format_;
1743 bool back_buffer_has_depth_; 1711 bool back_buffer_has_depth_;
1744 bool back_buffer_has_stencil_; 1712 bool back_buffer_has_stencil_;
1745 1713
1746 // Backbuffer attachments that are currently undefined. 1714 // Backbuffer attachments that are currently undefined.
1747 uint32 backbuffer_needs_clear_bits_; 1715 uint32 backbuffer_needs_clear_bits_;
1748 1716
1749 bool teximage2d_faster_than_texsubimage2d_; 1717 bool teximage2d_faster_than_texsubimage2d_;
1750 1718
1751 // The last error message set.
1752 std::string last_error_;
1753
1754 // The current decoder error. 1719 // The current decoder error.
1755 error::Error current_decoder_error_; 1720 error::Error current_decoder_error_;
1756 1721
1757 bool use_shader_translator_; 1722 bool use_shader_translator_;
1758 scoped_refptr<ShaderTranslator> vertex_translator_; 1723 scoped_refptr<ShaderTranslator> vertex_translator_;
1759 scoped_refptr<ShaderTranslator> fragment_translator_; 1724 scoped_refptr<ShaderTranslator> fragment_translator_;
1760 1725
1761 DisallowedFeatures disallowed_features_; 1726 DisallowedFeatures disallowed_features_;
1762 1727
1763 // Cached from ContextGroup 1728 // Cached from ContextGroup
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1807 1772
1808 scoped_ptr<GPUTracer> gpu_tracer_; 1773 scoped_ptr<GPUTracer> gpu_tracer_;
1809 1774
1810 DISALLOW_COPY_AND_ASSIGN(GLES2DecoderImpl); 1775 DISALLOW_COPY_AND_ASSIGN(GLES2DecoderImpl);
1811 }; 1776 };
1812 1777
1813 ScopedGLErrorSuppressor::ScopedGLErrorSuppressor( 1778 ScopedGLErrorSuppressor::ScopedGLErrorSuppressor(
1814 const char* function_name, GLES2DecoderImpl* decoder) 1779 const char* function_name, GLES2DecoderImpl* decoder)
1815 : function_name_(function_name), 1780 : function_name_(function_name),
1816 decoder_(decoder) { 1781 decoder_(decoder) {
1817 GLESDECODER_COPY_REAL_GL_ERRORS_TO_WRAPPER(decoder_, function_name_); 1782 ERRORSTATE_COPY_REAL_GL_ERRORS_TO_WRAPPER(decoder_->GetErrorState(),
1783 function_name_);
1818 } 1784 }
1819 1785
1820 ScopedGLErrorSuppressor::~ScopedGLErrorSuppressor() { 1786 ScopedGLErrorSuppressor::~ScopedGLErrorSuppressor() {
1821 GLESDECODER_CLEAR_REAL_GL_ERRORS(decoder_, function_name_); 1787 ERRORSTATE_CLEAR_REAL_GL_ERRORS(decoder_->GetErrorState(), function_name_);
1822 } 1788 }
1823 1789
1824 ScopedTexture2DBinder::ScopedTexture2DBinder(GLES2DecoderImpl* decoder, 1790 ScopedTexture2DBinder::ScopedTexture2DBinder(GLES2DecoderImpl* decoder,
1825 GLuint id) 1791 GLuint id)
1826 : decoder_(decoder) { 1792 : decoder_(decoder) {
1827 ScopedGLErrorSuppressor suppressor( 1793 ScopedGLErrorSuppressor suppressor(
1828 "ScopedTexture2DBinder::ctor", decoder_); 1794 "ScopedTexture2DBinder::ctor", decoder_);
1829 1795
1830 // TODO(apatrick): Check if there are any other states that need to be reset 1796 // TODO(apatrick): Check if there are any other states that need to be reset
1831 // before binding a new texture. 1797 // before binding a new texture.
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
2194 } 2160 }
2195 2161
2196 GLES2Decoder* GLES2Decoder::Create(ContextGroup* group) { 2162 GLES2Decoder* GLES2Decoder::Create(ContextGroup* group) {
2197 return new GLES2DecoderImpl(group); 2163 return new GLES2DecoderImpl(group);
2198 } 2164 }
2199 2165
2200 GLES2DecoderImpl::GLES2DecoderImpl(ContextGroup* group) 2166 GLES2DecoderImpl::GLES2DecoderImpl(ContextGroup* group)
2201 : GLES2Decoder(), 2167 : GLES2Decoder(),
2202 group_(group), 2168 group_(group),
2203 logger_(&debug_marker_manager_), 2169 logger_(&debug_marker_manager_),
2204 state_(group_->feature_info()), 2170 state_(group_->feature_info(), &logger_),
2205 error_bits_(0),
2206 unpack_flip_y_(false), 2171 unpack_flip_y_(false),
2207 unpack_premultiply_alpha_(false), 2172 unpack_premultiply_alpha_(false),
2208 unpack_unpremultiply_alpha_(false), 2173 unpack_unpremultiply_alpha_(false),
2209 attrib_0_buffer_id_(0), 2174 attrib_0_buffer_id_(0),
2210 attrib_0_buffer_matches_value_(true), 2175 attrib_0_buffer_matches_value_(true),
2211 attrib_0_size_(0), 2176 attrib_0_size_(0),
2212 fixed_attrib_buffer_id_(0), 2177 fixed_attrib_buffer_id_(0),
2213 fixed_attrib_buffer_size_(0), 2178 fixed_attrib_buffer_size_(0),
2214 clear_state_dirty_(true), 2179 clear_state_dirty_(true),
2215 offscreen_target_color_format_(0), 2180 offscreen_target_color_format_(0),
(...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after
3081 GL_RGBA, 3046 GL_RGBA,
3082 offscreen_size_.width(), 3047 offscreen_size_.width(),
3083 offscreen_size_.height(), 3048 offscreen_size_.height(),
3084 1, // depth 3049 1, // depth
3085 0, // border 3050 0, // border
3086 GL_RGBA, 3051 GL_RGBA,
3087 GL_UNSIGNED_BYTE, 3052 GL_UNSIGNED_BYTE,
3088 true); 3053 true);
3089 parent_texture_manager->SetParameter( 3054 parent_texture_manager->SetParameter(
3090 "UpdateParentTextureInfo", 3055 "UpdateParentTextureInfo",
3091 this, 3056 GetErrorState(),
3092 offscreen_saved_color_texture_info_, 3057 offscreen_saved_color_texture_info_,
3093 GL_TEXTURE_MAG_FILTER, 3058 GL_TEXTURE_MAG_FILTER,
3094 GL_NEAREST); 3059 GL_NEAREST);
3095 parent_texture_manager->SetParameter( 3060 parent_texture_manager->SetParameter(
3096 "UpdateParentTextureInfo", 3061 "UpdateParentTextureInfo",
3097 this, 3062 GetErrorState(),
3098 offscreen_saved_color_texture_info_, 3063 offscreen_saved_color_texture_info_,
3099 GL_TEXTURE_MIN_FILTER, 3064 GL_TEXTURE_MIN_FILTER,
3100 GL_NEAREST); 3065 GL_NEAREST);
3101 parent_texture_manager->SetParameter( 3066 parent_texture_manager->SetParameter(
3102 "UpdateParentTextureInfo", 3067 "UpdateParentTextureInfo",
3103 this, 3068 GetErrorState(),
3104 offscreen_saved_color_texture_info_, 3069 offscreen_saved_color_texture_info_,
3105 GL_TEXTURE_WRAP_S, 3070 GL_TEXTURE_WRAP_S,
3106 GL_CLAMP_TO_EDGE); 3071 GL_CLAMP_TO_EDGE);
3107 parent_texture_manager->SetParameter( 3072 parent_texture_manager->SetParameter(
3108 "UpdateParentTextureInfo", 3073 "UpdateParentTextureInfo",
3109 this, 3074 GetErrorState(),
3110 offscreen_saved_color_texture_info_, 3075 offscreen_saved_color_texture_info_,
3111 GL_TEXTURE_WRAP_T, 3076 GL_TEXTURE_WRAP_T,
3112 GL_CLAMP_TO_EDGE); 3077 GL_CLAMP_TO_EDGE);
3113 } else { 3078 } else {
3114 offscreen_saved_color_texture_info_ = NULL; 3079 offscreen_saved_color_texture_info_ = NULL;
3115 } 3080 }
3116 } 3081 }
3117 3082
3118 void GLES2DecoderImpl::SetResizeCallback( 3083 void GLES2DecoderImpl::SetResizeCallback(
3119 const base::Callback<void(gfx::Size)>& callback) { 3084 const base::Callback<void(gfx::Size)>& callback) {
3120 resize_callback_ = callback; 3085 resize_callback_ = callback;
3121 } 3086 }
3122 3087
3123 Logger* GLES2DecoderImpl::GetLogger() { 3088 Logger* GLES2DecoderImpl::GetLogger() {
3124 return &logger_; 3089 return &logger_;
3125 } 3090 }
3126 3091
3092 ErrorState * GLES2DecoderImpl::GetErrorState() {
dsinclair 2013/04/17 00:39:09 nit: no space before *
kloveless 2013/04/17 14:58:01 Done.
3093 return state_.GetErrorState();
3094 }
3095
3127 void GLES2DecoderImpl::SetShaderCacheCallback( 3096 void GLES2DecoderImpl::SetShaderCacheCallback(
3128 const ShaderCacheCallback& callback) { 3097 const ShaderCacheCallback& callback) {
3129 shader_cache_callback_ = callback; 3098 shader_cache_callback_ = callback;
3130 } 3099 }
3131 3100
3132 void GLES2DecoderImpl::SetWaitSyncPointCallback( 3101 void GLES2DecoderImpl::SetWaitSyncPointCallback(
3133 const WaitSyncPointCallback& callback) { 3102 const WaitSyncPointCallback& callback) {
3134 wait_sync_point_callback_ = callback; 3103 wait_sync_point_callback_ = callback;
3135 } 3104 }
3136 3105
(...skipping 2101 matching lines...) Expand 10 before | Expand all | Expand 10 after
5238 5207
5239 void GLES2DecoderImpl::DoTexParameterf( 5208 void GLES2DecoderImpl::DoTexParameterf(
5240 GLenum target, GLenum pname, GLfloat param) { 5209 GLenum target, GLenum pname, GLfloat param) {
5241 Texture* texture = GetTextureInfoForTarget(target); 5210 Texture* texture = GetTextureInfoForTarget(target);
5242 if (!texture) { 5211 if (!texture) {
5243 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glTexParameterf", "unknown texture"); 5212 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glTexParameterf", "unknown texture");
5244 return; 5213 return;
5245 } 5214 }
5246 5215
5247 texture_manager()->SetParameter( 5216 texture_manager()->SetParameter(
5248 "glTexParameterf", this, texture, pname, static_cast<GLint>(param)); 5217 "glTexParameterf", GetErrorState(), texture, pname,
5218 static_cast<GLint>(param));
5249 } 5219 }
5250 5220
5251 void GLES2DecoderImpl::DoTexParameteri( 5221 void GLES2DecoderImpl::DoTexParameteri(
5252 GLenum target, GLenum pname, GLint param) { 5222 GLenum target, GLenum pname, GLint param) {
5253 Texture* texture = GetTextureInfoForTarget(target); 5223 Texture* texture = GetTextureInfoForTarget(target);
5254 if (!texture) { 5224 if (!texture) {
5255 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glTexParameteri", "unknown texture"); 5225 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glTexParameteri", "unknown texture");
5256 return; 5226 return;
5257 } 5227 }
5258 5228
5259 texture_manager()->SetParameter( 5229 texture_manager()->SetParameter(
5260 "glTexParameteri", this, texture, pname, param); 5230 "glTexParameteri", GetErrorState(), texture, pname, param);
5261 } 5231 }
5262 5232
5263 void GLES2DecoderImpl::DoTexParameterfv( 5233 void GLES2DecoderImpl::DoTexParameterfv(
5264 GLenum target, GLenum pname, const GLfloat* params) { 5234 GLenum target, GLenum pname, const GLfloat* params) {
5265 Texture* texture = GetTextureInfoForTarget(target); 5235 Texture* texture = GetTextureInfoForTarget(target);
5266 if (!texture) { 5236 if (!texture) {
5267 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glTexParameterfv", "unknown texture"); 5237 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glTexParameterfv", "unknown texture");
5268 return; 5238 return;
5269 } 5239 }
5270 5240
5271 texture_manager()->SetParameter( 5241 texture_manager()->SetParameter(
5272 "glTexParameterfv", this, texture, pname, static_cast<GLint>(params[0])); 5242 "glTexParameterfv", GetErrorState(), texture, pname,
5243 static_cast<GLint>(params[0]));
5273 } 5244 }
5274 5245
5275 void GLES2DecoderImpl::DoTexParameteriv( 5246 void GLES2DecoderImpl::DoTexParameteriv(
5276 GLenum target, GLenum pname, const GLint* params) { 5247 GLenum target, GLenum pname, const GLint* params) {
5277 Texture* texture = GetTextureInfoForTarget(target); 5248 Texture* texture = GetTextureInfoForTarget(target);
5278 if (!texture) { 5249 if (!texture) {
5279 LOCAL_SET_GL_ERROR( 5250 LOCAL_SET_GL_ERROR(
5280 GL_INVALID_VALUE, "glTexParameteriv", "unknown texture"); 5251 GL_INVALID_VALUE, "glTexParameteriv", "unknown texture");
5281 return; 5252 return;
5282 } 5253 }
5283 5254
5284 texture_manager()->SetParameter( 5255 texture_manager()->SetParameter(
5285 "glTexParameteriv", this, texture, pname, *params); 5256 "glTexParameteriv", GetErrorState(), texture, pname, *params);
5286 } 5257 }
5287 5258
5288 bool GLES2DecoderImpl::CheckCurrentProgram(const char* function_name) { 5259 bool GLES2DecoderImpl::CheckCurrentProgram(const char* function_name) {
5289 if (!state_.current_program) { 5260 if (!state_.current_program) {
5290 // The program does not exist. 5261 // The program does not exist.
5291 LOCAL_SET_GL_ERROR( 5262 LOCAL_SET_GL_ERROR(
5292 GL_INVALID_OPERATION, function_name, "no program in use"); 5263 GL_INVALID_OPERATION, function_name, "no program in use");
5293 return false; 5264 return false;
5294 } 5265 }
5295 if (!state_.current_program->InUse()) { 5266 if (!state_.current_program->InUse()) {
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
5686 program_manager()->UnuseProgram(shader_manager(), state_.current_program); 5657 program_manager()->UnuseProgram(shader_manager(), state_.current_program);
5687 } 5658 }
5688 state_.current_program = program; 5659 state_.current_program = program;
5689 LogClientServiceMapping("glUseProgram", program_id, service_id); 5660 LogClientServiceMapping("glUseProgram", program_id, service_id);
5690 glUseProgram(service_id); 5661 glUseProgram(service_id);
5691 if (state_.current_program) { 5662 if (state_.current_program) {
5692 program_manager()->UseProgram(state_.current_program); 5663 program_manager()->UseProgram(state_.current_program);
5693 } 5664 }
5694 } 5665 }
5695 5666
5696 uint32 GLES2DecoderImpl::GetGLError() {
5697 // Check the GL error first, then our wrapped error.
5698 GLenum error = glGetError();
5699 if (error == GL_NO_ERROR && error_bits_ != 0) {
5700 for (uint32 mask = 1; mask != 0; mask = mask << 1) {
5701 if ((error_bits_ & mask) != 0) {
5702 error = GLES2Util::GLErrorBitToGLError(mask);
5703 break;
5704 }
5705 }
5706 }
5707
5708 if (error != GL_NO_ERROR) {
5709 // There was an error, clear the corresponding wrapped error.
5710 error_bits_ &= ~GLES2Util::GLErrorToErrorBit(error);
5711 }
5712 return error;
5713 }
5714
5715 unsigned GLES2DecoderImpl::PeekGLError(
5716 const char* filename, int line, const char* function_name) {
5717 GLenum error = glGetError();
5718 if (error != GL_NO_ERROR) {
5719 SetGLError(filename, line, error, function_name, "");
5720 }
5721 return error;
5722 }
5723
5724 void GLES2DecoderImpl::SetGLError(
5725 const char* filename, int line,
5726 unsigned error, const char* function_name, const char* msg) {
5727 if (msg) {
5728 last_error_ = msg;
5729 logger_.LogMessage(filename, line,
5730 logger_.GetLogPrefix() + ": " + std::string("GL ERROR :") +
5731 GLES2Util::GetStringEnum(error) + " : " +
5732 function_name + ": " + msg);
5733 }
5734 error_bits_ |= GLES2Util::GLErrorToErrorBit(error);
5735 }
5736
5737 void GLES2DecoderImpl::SetGLErrorInvalidEnum(
5738 const char* filename, int line,
5739 const char* function_name, unsigned value, const char* label) {
5740 SetGLError(filename, line, GL_INVALID_ENUM, function_name,
5741 (std::string(label) + " was " +
5742 GLES2Util::GetStringEnum(value)).c_str());
5743 }
5744
5745 void GLES2DecoderImpl::SetGLErrorInvalidParam(
5746 const char* filename,
5747 int line,
5748 unsigned error,
5749 const char* function_name,
5750 unsigned pname,
5751 int param) {
5752 if (error == GL_INVALID_ENUM) {
5753 SetGLError(
5754 filename, line, GL_INVALID_ENUM, function_name,
5755 (std::string("trying to set ") +
5756 GLES2Util::GetStringEnum(pname) + " to " +
5757 GLES2Util::GetStringEnum(param)).c_str());
5758 } else {
5759 SetGLError(
5760 filename, line, error, function_name,
5761 (std::string("trying to set ") +
5762 GLES2Util::GetStringEnum(pname) + " to " +
5763 base::StringPrintf("%d", param)).c_str());
5764 }
5765 }
5766
5767 void GLES2DecoderImpl::RenderWarning( 5667 void GLES2DecoderImpl::RenderWarning(
5768 const char* filename, int line, const std::string& msg) { 5668 const char* filename, int line, const std::string& msg) {
5769 logger_.LogMessage(filename, line, std::string("RENDER WARNING: ") + msg); 5669 logger_.LogMessage(filename, line, std::string("RENDER WARNING: ") + msg);
5770 } 5670 }
5771 5671
5772 void GLES2DecoderImpl::PerformanceWarning( 5672 void GLES2DecoderImpl::PerformanceWarning(
5773 const char* filename, int line, const std::string& msg) { 5673 const char* filename, int line, const std::string& msg) {
5774 logger_.LogMessage(filename, line, std::string("PERFORMANCE WARNING: ") 5674 logger_.LogMessage(filename, line,
5775 + msg); 5675 std::string("PERFORMANCE WARNING: ") + msg);
5776 } 5676 }
5777 5677
5778 void GLES2DecoderImpl::ForceCompileShaderIfPending(Shader* shader) { 5678 void GLES2DecoderImpl::ForceCompileShaderIfPending(Shader* shader) {
5779 if (shader->compilation_status() == 5679 if (shader->compilation_status() ==
5780 Shader::PENDING_DEFERRED_COMPILE) { 5680 Shader::PENDING_DEFERRED_COMPILE) {
5781 ShaderTranslator* translator = NULL; 5681 ShaderTranslator* translator = NULL;
5782 if (use_shader_translator_) { 5682 if (use_shader_translator_) {
5783 translator = shader->shader_type() == GL_VERTEX_SHADER ? 5683 translator = shader->shader_type() == GL_VERTEX_SHADER ?
5784 vertex_translator_.get() : fragment_translator_.get(); 5684 vertex_translator_.get() : fragment_translator_.get();
5785 } 5685 }
5786 // We know there will be no errors, because we only defer compilation on 5686 // We know there will be no errors, because we only defer compilation on
5787 // shaders that were previously compiled successfully. 5687 // shaders that were previously compiled successfully.
5788 program_manager()->ForceCompileShader(shader->deferred_compilation_source(), 5688 program_manager()->ForceCompileShader(shader->deferred_compilation_source(),
5789 shader, 5689 shader,
5790 translator, 5690 translator,
5791 feature_info_); 5691 feature_info_);
5792 } 5692 }
5793 } 5693 }
5794 5694
5795 void GLES2DecoderImpl::CopyRealGLErrorsToWrapper(
5796 const char* filename, int line, const char* function_name) {
5797 GLenum error;
5798 while ((error = glGetError()) != GL_NO_ERROR) {
5799 SetGLError(filename, line, error, function_name,
5800 "<- error from previous GL command");
5801 }
5802 }
5803
5804 void GLES2DecoderImpl::ClearRealGLErrors(
5805 const char* filename, int line, const char* function_name) {
5806 GLenum error;
5807 while ((error = glGetError()) != GL_NO_ERROR) {
5808 if (error != GL_OUT_OF_MEMORY) {
5809 // GL_OUT_OF_MEMORY can legally happen on lost device.
5810 logger_.LogMessage(filename, line,
5811 logger_.GetLogPrefix() + ": " + std::string("GL ERROR :") +
5812 GLES2Util::GetStringEnum(error) + " : " +
5813 function_name + ": was unhandled");
5814 NOTREACHED() << "GL error " << error << " was unhandled.";
5815 }
5816 }
5817 }
5818
5819 bool GLES2DecoderImpl::SetBlackTextureForNonRenderableTextures() { 5695 bool GLES2DecoderImpl::SetBlackTextureForNonRenderableTextures() {
5820 DCHECK(state_.current_program); 5696 DCHECK(state_.current_program);
5821 // Only check if there are some unrenderable textures. 5697 // Only check if there are some unrenderable textures.
5822 if (!texture_manager()->HaveUnrenderableTextures()) { 5698 if (!texture_manager()->HaveUnrenderableTextures()) {
5823 return false; 5699 return false;
5824 } 5700 }
5825 bool textures_set = false; 5701 bool textures_set = false;
5826 const Program::SamplerIndices& sampler_indices = 5702 const Program::SamplerIndices& sampler_indices =
5827 state_.current_program->sampler_indices(); 5703 state_.current_program->sampler_indices();
5828 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) { 5704 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) {
(...skipping 1544 matching lines...) Expand 10 before | Expand all | Expand 10 after
7373 if (!buffer) { 7249 if (!buffer) {
7374 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glBufferData", "unknown buffer"); 7250 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glBufferData", "unknown buffer");
7375 return; 7251 return;
7376 } 7252 }
7377 7253
7378 if (!EnsureGPUMemoryAvailable(size)) { 7254 if (!EnsureGPUMemoryAvailable(size)) {
7379 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, "glBufferData", "out of memory"); 7255 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, "glBufferData", "out of memory");
7380 return; 7256 return;
7381 } 7257 }
7382 7258
7383 buffer_manager()->DoBufferData(this, buffer, size, usage, data); 7259 buffer_manager()->DoBufferData(GetErrorState(), buffer, size, usage, data);
7384 } 7260 }
7385 7261
7386 error::Error GLES2DecoderImpl::HandleBufferData( 7262 error::Error GLES2DecoderImpl::HandleBufferData(
7387 uint32 immediate_data_size, const cmds::BufferData& c) { 7263 uint32 immediate_data_size, const cmds::BufferData& c) {
7388 GLenum target = static_cast<GLenum>(c.target); 7264 GLenum target = static_cast<GLenum>(c.target);
7389 GLsizeiptr size = static_cast<GLsizeiptr>(c.size); 7265 GLsizeiptr size = static_cast<GLsizeiptr>(c.size);
7390 uint32 data_shm_id = static_cast<uint32>(c.data_shm_id); 7266 uint32 data_shm_id = static_cast<uint32>(c.data_shm_id);
7391 uint32 data_shm_offset = static_cast<uint32>(c.data_shm_offset); 7267 uint32 data_shm_offset = static_cast<uint32>(c.data_shm_offset);
7392 GLenum usage = static_cast<GLenum>(c.usage); 7268 GLenum usage = static_cast<GLenum>(c.usage);
7393 const void* data = NULL; 7269 const void* data = NULL;
(...skipping 22 matching lines...) Expand all
7416 } 7292 }
7417 7293
7418 void GLES2DecoderImpl::DoBufferSubData( 7294 void GLES2DecoderImpl::DoBufferSubData(
7419 GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid * data) { 7295 GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid * data) {
7420 Buffer* buffer = GetBufferInfoForTarget(target); 7296 Buffer* buffer = GetBufferInfoForTarget(target);
7421 if (!buffer) { 7297 if (!buffer) {
7422 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glBufferSubData", "unknown buffer"); 7298 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glBufferSubData", "unknown buffer");
7423 return; 7299 return;
7424 } 7300 }
7425 7301
7426 buffer_manager()->DoBufferSubData(this, buffer, offset, size, data); 7302 buffer_manager()->DoBufferSubData(GetErrorState(), buffer, offset, size,
7303 data);
7427 } 7304 }
7428 7305
7429 bool GLES2DecoderImpl::ClearLevel( 7306 bool GLES2DecoderImpl::ClearLevel(
7430 unsigned service_id, 7307 unsigned service_id,
7431 unsigned bind_target, 7308 unsigned bind_target,
7432 unsigned target, 7309 unsigned target,
7433 int level, 7310 int level,
7434 unsigned format, 7311 unsigned format,
7435 unsigned type, 7312 unsigned type,
7436 int width, 7313 int width,
(...skipping 3067 matching lines...) Expand 10 before | Expand all | Expand 10 after
10504 return error::kNoError; 10381 return error::kNoError;
10505 } 10382 }
10506 10383
10507 // Include the auto-generated part of this file. We split this because it means 10384 // Include the auto-generated part of this file. We split this because it means
10508 // we can easily edit the non-auto generated parts right here in this file 10385 // we can easily edit the non-auto generated parts right here in this file
10509 // instead of having to edit some template or the code generator. 10386 // instead of having to edit some template or the code generator.
10510 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 10387 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
10511 10388
10512 } // namespace gles2 10389 } // namespace gles2
10513 } // namespace gpu 10390 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698