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

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

Issue 1922633002: Implement TransformFeedbackManager in GPU command buffer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 <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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 #include "gpu/command_buffer/service/mailbox_manager.h" 49 #include "gpu/command_buffer/service/mailbox_manager.h"
50 #include "gpu/command_buffer/service/memory_tracking.h" 50 #include "gpu/command_buffer/service/memory_tracking.h"
51 #include "gpu/command_buffer/service/path_manager.h" 51 #include "gpu/command_buffer/service/path_manager.h"
52 #include "gpu/command_buffer/service/program_manager.h" 52 #include "gpu/command_buffer/service/program_manager.h"
53 #include "gpu/command_buffer/service/query_manager.h" 53 #include "gpu/command_buffer/service/query_manager.h"
54 #include "gpu/command_buffer/service/renderbuffer_manager.h" 54 #include "gpu/command_buffer/service/renderbuffer_manager.h"
55 #include "gpu/command_buffer/service/sampler_manager.h" 55 #include "gpu/command_buffer/service/sampler_manager.h"
56 #include "gpu/command_buffer/service/shader_manager.h" 56 #include "gpu/command_buffer/service/shader_manager.h"
57 #include "gpu/command_buffer/service/shader_translator.h" 57 #include "gpu/command_buffer/service/shader_translator.h"
58 #include "gpu/command_buffer/service/texture_manager.h" 58 #include "gpu/command_buffer/service/texture_manager.h"
59 #include "gpu/command_buffer/service/transform_feedback_manager.h"
59 #include "gpu/command_buffer/service/vertex_array_manager.h" 60 #include "gpu/command_buffer/service/vertex_array_manager.h"
60 #include "gpu/command_buffer/service/vertex_attrib_manager.h" 61 #include "gpu/command_buffer/service/vertex_attrib_manager.h"
61 #include "third_party/smhasher/src/City.h" 62 #include "third_party/smhasher/src/City.h"
62 #include "ui/gfx/geometry/point.h" 63 #include "ui/gfx/geometry/point.h"
63 #include "ui/gfx/geometry/rect.h" 64 #include "ui/gfx/geometry/rect.h"
64 #include "ui/gfx/geometry/size.h" 65 #include "ui/gfx/geometry/size.h"
65 #include "ui/gfx/overlay_transform.h" 66 #include "ui/gfx/overlay_transform.h"
66 #include "ui/gfx/transform.h" 67 #include "ui/gfx/transform.h"
67 #include "ui/gl/gl_bindings.h" 68 #include "ui/gl/gl_bindings.h"
68 #include "ui/gl/gl_context.h" 69 #include "ui/gl/gl_context.h"
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 state_.RestoreTextureUnitBindings(unit, NULL); 624 state_.RestoreTextureUnitBindings(unit, NULL);
624 } 625 }
625 void RestoreFramebufferBindings() const override; 626 void RestoreFramebufferBindings() const override;
626 void RestoreRenderbufferBindings() override; 627 void RestoreRenderbufferBindings() override;
627 void RestoreTextureState(unsigned service_id) const override; 628 void RestoreTextureState(unsigned service_id) const override;
628 629
629 void ClearAllAttributes() const override; 630 void ClearAllAttributes() const override;
630 void RestoreAllAttributes() const override; 631 void RestoreAllAttributes() const override;
631 632
632 QueryManager* GetQueryManager() override { return query_manager_.get(); } 633 QueryManager* GetQueryManager() override { return query_manager_.get(); }
634 TransformFeedbackManager* GetTransformFeedbackManager() override {
635 return transform_feedback_manager_.get();
636 }
633 VertexArrayManager* GetVertexArrayManager() override { 637 VertexArrayManager* GetVertexArrayManager() override {
634 return vertex_array_manager_.get(); 638 return vertex_array_manager_.get();
635 } 639 }
636 ImageManager* GetImageManager() override { return image_manager_.get(); } 640 ImageManager* GetImageManager() override { return image_manager_.get(); }
637 641
638 bool HasPendingQueries() const override; 642 bool HasPendingQueries() const override;
639 void ProcessPendingQueries(bool did_finish) override; 643 void ProcessPendingQueries(bool did_finish) override;
640 644
641 bool HasMoreIdleWork() const override; 645 bool HasMoreIdleWork() const override;
642 void PerformIdleWork() override; 646 void PerformIdleWork() override;
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 bool GenRenderbuffersHelper(GLsizei n, const GLuint* client_ids); 749 bool GenRenderbuffersHelper(GLsizei n, const GLuint* client_ids);
746 void DeleteRenderbuffersHelper(GLsizei n, const GLuint* client_ids); 750 void DeleteRenderbuffersHelper(GLsizei n, const GLuint* client_ids);
747 bool GenQueriesEXTHelper(GLsizei n, const GLuint* client_ids); 751 bool GenQueriesEXTHelper(GLsizei n, const GLuint* client_ids);
748 void DeleteQueriesEXTHelper(GLsizei n, const GLuint* client_ids); 752 void DeleteQueriesEXTHelper(GLsizei n, const GLuint* client_ids);
749 bool GenVertexArraysOESHelper(GLsizei n, const GLuint* client_ids); 753 bool GenVertexArraysOESHelper(GLsizei n, const GLuint* client_ids);
750 void DeleteVertexArraysOESHelper(GLsizei n, const GLuint* client_ids); 754 void DeleteVertexArraysOESHelper(GLsizei n, const GLuint* client_ids);
751 bool GenPathsCHROMIUMHelper(GLuint first_client_id, GLsizei range); 755 bool GenPathsCHROMIUMHelper(GLuint first_client_id, GLsizei range);
752 bool DeletePathsCHROMIUMHelper(GLuint first_client_id, GLsizei range); 756 bool DeletePathsCHROMIUMHelper(GLuint first_client_id, GLsizei range);
753 bool GenSamplersHelper(GLsizei n, const GLuint* client_ids); 757 bool GenSamplersHelper(GLsizei n, const GLuint* client_ids);
754 void DeleteSamplersHelper(GLsizei n, const GLuint* client_ids); 758 void DeleteSamplersHelper(GLsizei n, const GLuint* client_ids);
759 bool GenTransformFeedbacksHelper(GLsizei n, const GLuint* client_ids);
760 void DeleteTransformFeedbacksHelper(GLsizei n, const GLuint* client_ids);
755 761
756 // Workarounds 762 // Workarounds
757 void OnFboChanged() const; 763 void OnFboChanged() const;
758 void OnUseFramebuffer() const; 764 void OnUseFramebuffer() const;
759 765
760 error::ContextLostReason GetContextLostReasonFromResetStatus( 766 error::ContextLostReason GetContextLostReasonFromResetStatus(
761 GLenum reset_status) const; 767 GLenum reset_status) const;
762 768
763 // TODO(gman): Cache these pointers? 769 // TODO(gman): Cache these pointers?
764 BufferManager* buffer_manager() { 770 BufferManager* buffer_manager() {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 // Gets the sampler info for the given sampler. Returns NULL if none exists. 854 // Gets the sampler info for the given sampler. Returns NULL if none exists.
849 Sampler* GetSampler(GLuint client_id) { 855 Sampler* GetSampler(GLuint client_id) {
850 return sampler_manager()->GetSampler(client_id); 856 return sampler_manager()->GetSampler(client_id);
851 } 857 }
852 858
853 // Deletes the sampler info for the given sampler. 859 // Deletes the sampler info for the given sampler.
854 void RemoveSampler(GLuint client_id) { 860 void RemoveSampler(GLuint client_id) {
855 sampler_manager()->RemoveSampler(client_id); 861 sampler_manager()->RemoveSampler(client_id);
856 } 862 }
857 863
864 // Creates a TransformFeedback for the given transformfeedback.
865 TransformFeedback* CreateTransformFeedback(
866 GLuint client_id, GLuint service_id) {
867 return transform_feedback_manager_->CreateTransformFeedback(
868 client_id, service_id);
869 }
870
871 // Gets the TransformFeedback info for the given transformfeedback.
872 // Returns nullptr if none exists.
873 TransformFeedback* GetTransformFeedback(GLuint client_id) {
874 return transform_feedback_manager_->GetTransformFeedback(client_id);
875 }
876
877 // Deletes the TransformFeedback info for the given transformfeedback.
878 void RemoveTransformFeedback(GLuint client_id) {
879 transform_feedback_manager_->RemoveTransformFeedback(client_id);
880 }
881
858 // Get the size (in pixels) of the currently bound frame buffer (either FBO 882 // Get the size (in pixels) of the currently bound frame buffer (either FBO
859 // or regular back buffer). 883 // or regular back buffer).
860 gfx::Size GetBoundReadFrameBufferSize(); 884 gfx::Size GetBoundReadFrameBufferSize();
861 885
862 // Get the format/type of the currently bound frame buffer (either FBO or 886 // Get the format/type of the currently bound frame buffer (either FBO or
863 // regular back buffer). 887 // regular back buffer).
864 // If the color image is a renderbuffer, returns 0 for type. 888 // If the color image is a renderbuffer, returns 0 for type.
865 GLenum GetBoundReadFrameBufferTextureType(); 889 GLenum GetBoundReadFrameBufferTextureType();
866 GLenum GetBoundReadFrameBufferInternalFormat(); 890 GLenum GetBoundReadFrameBufferInternalFormat();
867 891
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
1368 1392
1369 // Wrapper for glBindRenderbuffer since we need to track the current targets. 1393 // Wrapper for glBindRenderbuffer since we need to track the current targets.
1370 void DoBindRenderbuffer(GLenum target, GLuint renderbuffer); 1394 void DoBindRenderbuffer(GLenum target, GLuint renderbuffer);
1371 1395
1372 // Wrapper for glBindTexture since we need to track the current targets. 1396 // Wrapper for glBindTexture since we need to track the current targets.
1373 void DoBindTexture(GLenum target, GLuint texture); 1397 void DoBindTexture(GLenum target, GLuint texture);
1374 1398
1375 // Wrapper for glBindSampler since we need to track the current targets. 1399 // Wrapper for glBindSampler since we need to track the current targets.
1376 void DoBindSampler(GLuint unit, GLuint sampler); 1400 void DoBindSampler(GLuint unit, GLuint sampler);
1377 1401
1402 // Wrapper for glBindTransformFeedback since we need to emulate ES3 behaviors
1403 // for BindBufferRange on Desktop GL lower than 4.2.
1404 void DoBindTransformFeedback(GLenum target, GLuint transform_feedback);
1405
1406 // Wrapper for glBeginTransformFeedback.
1407 void DoBeginTransformFeedback(GLenum primitive_mode);
1408
1409 // Wrapper for glEndTransformFeedback.
1410 void DoEndTransformFeedback();
1411
1412 // Wrapper for glPauseTransformFeedback.
1413 void DoPauseTransformFeedback();
1414
1415 // Wrapper for glResumeTransformFeedback.
1416 void DoResumeTransformFeedback();
1417
1378 // Wrapper for glBindVertexArrayOES 1418 // Wrapper for glBindVertexArrayOES
1379 void DoBindVertexArrayOES(GLuint array); 1419 void DoBindVertexArrayOES(GLuint array);
1380 void EmulateVertexArrayState(); 1420 void EmulateVertexArrayState();
1381 1421
1382 // Wrapper for glBlitFramebufferCHROMIUM. 1422 // Wrapper for glBlitFramebufferCHROMIUM.
1383 void DoBlitFramebufferCHROMIUM( 1423 void DoBlitFramebufferCHROMIUM(
1384 GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, 1424 GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
1385 GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, 1425 GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
1386 GLbitfield mask, GLenum filter); 1426 GLbitfield mask, GLenum filter);
1387 1427
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
1543 1583
1544 // Wrappers for glIsXXX functions. 1584 // Wrappers for glIsXXX functions.
1545 bool DoIsEnabled(GLenum cap); 1585 bool DoIsEnabled(GLenum cap);
1546 bool DoIsBuffer(GLuint client_id); 1586 bool DoIsBuffer(GLuint client_id);
1547 bool DoIsFramebuffer(GLuint client_id); 1587 bool DoIsFramebuffer(GLuint client_id);
1548 bool DoIsProgram(GLuint client_id); 1588 bool DoIsProgram(GLuint client_id);
1549 bool DoIsRenderbuffer(GLuint client_id); 1589 bool DoIsRenderbuffer(GLuint client_id);
1550 bool DoIsShader(GLuint client_id); 1590 bool DoIsShader(GLuint client_id);
1551 bool DoIsTexture(GLuint client_id); 1591 bool DoIsTexture(GLuint client_id);
1552 bool DoIsSampler(GLuint client_id); 1592 bool DoIsSampler(GLuint client_id);
1593 bool DoIsTransformFeedback(GLuint client_id);
1553 bool DoIsVertexArrayOES(GLuint client_id); 1594 bool DoIsVertexArrayOES(GLuint client_id);
1554 bool DoIsPathCHROMIUM(GLuint client_id); 1595 bool DoIsPathCHROMIUM(GLuint client_id);
1555 1596
1556 void DoLineWidth(GLfloat width); 1597 void DoLineWidth(GLfloat width);
1557 1598
1558 // Wrapper for glLinkProgram 1599 // Wrapper for glLinkProgram
1559 void DoLinkProgram(GLuint program); 1600 void DoLinkProgram(GLuint program);
1560 1601
1561 // Wrapper for glReadBuffer 1602 // Wrapper for glReadBuffer
1562 void DoReadBuffer(GLenum src); 1603 void DoReadBuffer(GLenum src);
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
1947 1988
1948 // The ContextGroup for this decoder uses to track resources. 1989 // The ContextGroup for this decoder uses to track resources.
1949 scoped_refptr<ContextGroup> group_; 1990 scoped_refptr<ContextGroup> group_;
1950 1991
1951 DebugMarkerManager debug_marker_manager_; 1992 DebugMarkerManager debug_marker_manager_;
1952 Logger logger_; 1993 Logger logger_;
1953 1994
1954 // All the state for this context. 1995 // All the state for this context.
1955 ContextState state_; 1996 ContextState state_;
1956 1997
1998 std::unique_ptr<TransformFeedbackManager> transform_feedback_manager_;
1999
1957 // Current width and height of the offscreen frame buffer. 2000 // Current width and height of the offscreen frame buffer.
1958 gfx::Size offscreen_size_; 2001 gfx::Size offscreen_size_;
1959 2002
1960 // Util to help with GL. 2003 // Util to help with GL.
1961 GLES2Util util_; 2004 GLES2Util util_;
1962 2005
1963 // The buffer we bind to attrib 0 since OpenGL requires it (ES does not). 2006 // The buffer we bind to attrib 0 since OpenGL requires it (ES does not).
1964 GLuint attrib_0_buffer_id_; 2007 GLuint attrib_0_buffer_id_;
1965 2008
1966 // The value currently in attrib_0. 2009 // The value currently in attrib_0.
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after
2742 return false; 2785 return false;
2743 } 2786 }
2744 2787
2745 if (!group_->Initialize(this, attrib_parser.context_type, 2788 if (!group_->Initialize(this, attrib_parser.context_type,
2746 disallowed_features)) { 2789 disallowed_features)) {
2747 group_ = NULL; // Must not destroy ContextGroup if it is not initialized. 2790 group_ = NULL; // Must not destroy ContextGroup if it is not initialized.
2748 Destroy(true); 2791 Destroy(true);
2749 return false; 2792 return false;
2750 } 2793 }
2751 CHECK_GL_ERROR(); 2794 CHECK_GL_ERROR();
2795
2796 bool needs_emulation = feature_info_->gl_version_info().IsLowerThanGL(4, 2);
2797 transform_feedback_manager_.reset(new TransformFeedbackManager(
2798 group_->max_transform_feedback_separate_attribs(), needs_emulation));
2799
2752 if (feature_info_->context_type() == CONTEXT_TYPE_WEBGL2 || 2800 if (feature_info_->context_type() == CONTEXT_TYPE_WEBGL2 ||
2753 feature_info_->context_type() == CONTEXT_TYPE_OPENGLES3) { 2801 feature_info_->context_type() == CONTEXT_TYPE_OPENGLES3) {
2754 if (!feature_info_->IsES3Capable()) { 2802 if (!feature_info_->IsES3Capable()) {
2755 LOG(ERROR) << "Underlying driver does not support ES3."; 2803 LOG(ERROR) << "Underlying driver does not support ES3.";
2756 Destroy(true); 2804 Destroy(true);
2757 return false; 2805 return false;
2758 } 2806 }
2759 feature_info_->EnableES3Validators(); 2807 feature_info_->EnableES3Validators();
2760 set_unsafe_es3_apis_enabled(true); 2808 set_unsafe_es3_apis_enabled(true);
2761 2809
2762 frag_depth_explicitly_enabled_ = true; 2810 frag_depth_explicitly_enabled_ = true;
2763 draw_buffers_explicitly_enabled_ = true; 2811 draw_buffers_explicitly_enabled_ = true;
2764 // TODO(zmo): Look into shader_texture_lod_explicitly_enabled_ situation. 2812 // TODO(zmo): Look into shader_texture_lod_explicitly_enabled_ situation.
2813
2814 // Create a fake default transform feedback and bind to it.
2815 GLuint default_transform_feedback = 0;
2816 glGenTransformFeedbacks(1, &default_transform_feedback);
2817 state_.default_transform_feedback =
2818 transform_feedback_manager_->CreateTransformFeedback(
2819 0, default_transform_feedback);
2820 glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, default_transform_feedback);
2821 state_.bound_transform_feedback = state_.default_transform_feedback.get();
2765 } 2822 }
2766 2823
2767 state_.attrib_values.resize(group_->max_vertex_attribs()); 2824 state_.attrib_values.resize(group_->max_vertex_attribs());
2768 vertex_array_manager_.reset(new VertexArrayManager()); 2825 vertex_array_manager_.reset(new VertexArrayManager());
2769 2826
2770 GLuint default_vertex_attrib_service_id = 0; 2827 GLuint default_vertex_attrib_service_id = 0;
2771 if (features().native_vertex_array_object) { 2828 if (features().native_vertex_array_object) {
2772 glGenVertexArraysOES(1, &default_vertex_attrib_service_id); 2829 glGenVertexArraysOES(1, &default_vertex_attrib_service_id);
2773 glBindVertexArrayOES(default_vertex_attrib_service_id); 2830 glBindVertexArrayOES(default_vertex_attrib_service_id);
2774 } 2831 }
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after
3498 } 3555 }
3499 } 3556 }
3500 std::unique_ptr<GLuint[]> service_ids(new GLuint[n]); 3557 std::unique_ptr<GLuint[]> service_ids(new GLuint[n]);
3501 glGenSamplers(n, service_ids.get()); 3558 glGenSamplers(n, service_ids.get());
3502 for (GLsizei ii = 0; ii < n; ++ii) { 3559 for (GLsizei ii = 0; ii < n; ++ii) {
3503 CreateSampler(client_ids[ii], service_ids[ii]); 3560 CreateSampler(client_ids[ii], service_ids[ii]);
3504 } 3561 }
3505 return true; 3562 return true;
3506 } 3563 }
3507 3564
3565 bool GLES2DecoderImpl::GenTransformFeedbacksHelper(
3566 GLsizei n, const GLuint* client_ids) {
3567 for (GLsizei ii = 0; ii < n; ++ii) {
3568 if (GetTransformFeedback(client_ids[ii])) {
3569 return false;
3570 }
3571 }
3572 std::unique_ptr<GLuint[]> service_ids(new GLuint[n]);
3573 glGenTransformFeedbacks(n, service_ids.get());
3574 for (GLsizei ii = 0; ii < n; ++ii) {
3575 CreateTransformFeedback(client_ids[ii], service_ids[ii]);
3576 }
3577 return true;
3578 }
3579
3508 bool GLES2DecoderImpl::GenPathsCHROMIUMHelper(GLuint first_client_id, 3580 bool GLES2DecoderImpl::GenPathsCHROMIUMHelper(GLuint first_client_id,
3509 GLsizei range) { 3581 GLsizei range) {
3510 GLuint last_client_id; 3582 GLuint last_client_id;
3511 if (!SafeAddUint32(first_client_id, range - 1, &last_client_id)) 3583 if (!SafeAddUint32(first_client_id, range - 1, &last_client_id))
3512 return false; 3584 return false;
3513 3585
3514 if (path_manager()->HasPathsInRange(first_client_id, last_client_id)) 3586 if (path_manager()->HasPathsInRange(first_client_id, last_client_id))
3515 return false; 3587 return false;
3516 3588
3517 GLuint first_service_id = glGenPathsNV(range); 3589 GLuint first_service_id = glGenPathsNV(range);
(...skipping 23 matching lines...) Expand all
3541 return true; 3613 return true;
3542 } 3614 }
3543 3615
3544 void GLES2DecoderImpl::DeleteBuffersHelper( 3616 void GLES2DecoderImpl::DeleteBuffersHelper(
3545 GLsizei n, const GLuint* client_ids) { 3617 GLsizei n, const GLuint* client_ids) {
3546 for (GLsizei ii = 0; ii < n; ++ii) { 3618 for (GLsizei ii = 0; ii < n; ++ii) {
3547 Buffer* buffer = GetBuffer(client_ids[ii]); 3619 Buffer* buffer = GetBuffer(client_ids[ii]);
3548 if (buffer && !buffer->IsDeleted()) { 3620 if (buffer && !buffer->IsDeleted()) {
3549 buffer->RemoveMappedRange(); 3621 buffer->RemoveMappedRange();
3550 state_.RemoveBoundBuffer(buffer); 3622 state_.RemoveBoundBuffer(buffer);
3623 transform_feedback_manager_->RemoveBoundBuffer(buffer);
3551 RemoveBuffer(client_ids[ii]); 3624 RemoveBuffer(client_ids[ii]);
3552 } 3625 }
3553 } 3626 }
3554 } 3627 }
3555 3628
3556 void GLES2DecoderImpl::DeleteFramebuffersHelper( 3629 void GLES2DecoderImpl::DeleteFramebuffersHelper(
3557 GLsizei n, const GLuint* client_ids) { 3630 GLsizei n, const GLuint* client_ids) {
3558 bool supports_separate_framebuffer_binds = 3631 bool supports_separate_framebuffer_binds =
3559 features().chromium_framebuffer_multisample; 3632 features().chromium_framebuffer_multisample;
3560 3633
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
3666 Sampler* sampler = GetSampler(client_ids[ii]); 3739 Sampler* sampler = GetSampler(client_ids[ii]);
3667 if (sampler && !sampler->IsDeleted()) { 3740 if (sampler && !sampler->IsDeleted()) {
3668 // Unbind from current sampler units. 3741 // Unbind from current sampler units.
3669 state_.UnbindSampler(sampler); 3742 state_.UnbindSampler(sampler);
3670 3743
3671 RemoveSampler(client_ids[ii]); 3744 RemoveSampler(client_ids[ii]);
3672 } 3745 }
3673 } 3746 }
3674 } 3747 }
3675 3748
3676 // } // anonymous namespace 3749 void GLES2DecoderImpl::DeleteTransformFeedbacksHelper(
3750 GLsizei n, const GLuint* client_ids) {
3751 for (GLsizei ii = 0; ii < n; ++ii) {
3752 TransformFeedback* transform_feedback = GetTransformFeedback(
3753 client_ids[ii]);
3754 if (transform_feedback) {
3755 if (state_.bound_transform_feedback.get() == transform_feedback) {
3756 // Bind to the default transform feedback.
3757 DCHECK(state_.default_transform_feedback.get());
3758 state_.default_transform_feedback->DoBindTransformFeedback(
3759 GL_TRANSFORM_FEEDBACK);
3760 state_.bound_transform_feedback =
3761 state_.default_transform_feedback.get();
3762 }
3763 RemoveTransformFeedback(client_ids[ii]);
3764 }
3765 }
3766 }
3677 3767
3678 bool GLES2DecoderImpl::MakeCurrent() { 3768 bool GLES2DecoderImpl::MakeCurrent() {
3679 if (!context_.get()) 3769 if (!context_.get())
3680 return false; 3770 return false;
3681 3771
3682 if (WasContextLost()) { 3772 if (WasContextLost()) {
3683 LOG(ERROR) << " GLES2DecoderImpl: Trying to make lost context current."; 3773 LOG(ERROR) << " GLES2DecoderImpl: Trying to make lost context current.";
3684 return false; 3774 return false;
3685 } 3775 }
3686 3776
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
4068 } 4158 }
4069 4159
4070 void GLES2DecoderImpl::AddProcessingCommandsTime(base::TimeDelta time) { 4160 void GLES2DecoderImpl::AddProcessingCommandsTime(base::TimeDelta time) {
4071 total_processing_commands_time_ += time; 4161 total_processing_commands_time_ += time;
4072 } 4162 }
4073 4163
4074 void GLES2DecoderImpl::Destroy(bool have_context) { 4164 void GLES2DecoderImpl::Destroy(bool have_context) {
4075 if (!initialized()) 4165 if (!initialized())
4076 return; 4166 return;
4077 4167
4078 DCHECK(!have_context || context_->IsCurrent(NULL)); 4168 DCHECK(!have_context || context_->IsCurrent(nullptr));
4079 4169
4080 // Unbind everything. 4170 // Unbind everything.
4081 state_.vertex_attrib_manager = NULL; 4171 state_.vertex_attrib_manager = nullptr;
4082 state_.default_vertex_attrib_manager = NULL; 4172 state_.default_vertex_attrib_manager = nullptr;
4083 state_.texture_units.clear(); 4173 state_.texture_units.clear();
4084 state_.sampler_units.clear(); 4174 state_.sampler_units.clear();
4085 state_.bound_array_buffer = NULL; 4175 state_.bound_array_buffer = nullptr;
4086 state_.bound_copy_read_buffer = NULL; 4176 state_.bound_copy_read_buffer = nullptr;
4087 state_.bound_copy_write_buffer = NULL; 4177 state_.bound_copy_write_buffer = nullptr;
4088 state_.bound_pixel_pack_buffer = NULL; 4178 state_.bound_pixel_pack_buffer = nullptr;
4089 state_.bound_pixel_unpack_buffer = NULL; 4179 state_.bound_pixel_unpack_buffer = nullptr;
4090 state_.bound_transform_feedback_buffer = NULL; 4180 state_.bound_transform_feedback_buffer = nullptr;
4091 state_.bound_uniform_buffer = NULL; 4181 state_.bound_uniform_buffer = nullptr;
4092 framebuffer_state_.bound_read_framebuffer = NULL; 4182 framebuffer_state_.bound_read_framebuffer = nullptr;
4093 framebuffer_state_.bound_draw_framebuffer = NULL; 4183 framebuffer_state_.bound_draw_framebuffer = nullptr;
4094 state_.bound_renderbuffer = NULL; 4184 state_.bound_renderbuffer = nullptr;
4185 state_.bound_transform_feedback = nullptr;
4186 state_.default_transform_feedback = nullptr;
4095 4187
4096 if (offscreen_saved_color_texture_info_.get()) { 4188 if (offscreen_saved_color_texture_info_.get()) {
4097 DCHECK(offscreen_target_color_texture_); 4189 DCHECK(offscreen_target_color_texture_);
4098 DCHECK_EQ(offscreen_saved_color_texture_info_->service_id(), 4190 DCHECK_EQ(offscreen_saved_color_texture_info_->service_id(),
4099 offscreen_saved_color_texture_->id()); 4191 offscreen_saved_color_texture_->id());
4100 offscreen_saved_color_texture_->Invalidate(); 4192 offscreen_saved_color_texture_->Invalidate();
4101 offscreen_saved_color_texture_info_ = NULL; 4193 offscreen_saved_color_texture_info_ = NULL;
4102 } 4194 }
4103 ReleaseAllBackTextures(); 4195 ReleaseAllBackTextures();
4104 if (have_context) { 4196 if (have_context) {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
4179 if (query_manager_.get()) { 4271 if (query_manager_.get()) {
4180 query_manager_->Destroy(have_context); 4272 query_manager_->Destroy(have_context);
4181 query_manager_.reset(); 4273 query_manager_.reset();
4182 } 4274 }
4183 4275
4184 if (vertex_array_manager_ .get()) { 4276 if (vertex_array_manager_ .get()) {
4185 vertex_array_manager_->Destroy(have_context); 4277 vertex_array_manager_->Destroy(have_context);
4186 vertex_array_manager_.reset(); 4278 vertex_array_manager_.reset();
4187 } 4279 }
4188 4280
4281 if (transform_feedback_manager_.get()) {
4282 if (!have_context) {
4283 transform_feedback_manager_->MarkContextLost();
4284 }
4285 transform_feedback_manager_->Destroy();
4286 transform_feedback_manager_.reset();
4287 }
4288
4189 if (image_manager_.get()) { 4289 if (image_manager_.get()) {
4190 image_manager_->Destroy(have_context); 4290 image_manager_->Destroy(have_context);
4191 image_manager_.reset(); 4291 image_manager_.reset();
4192 } 4292 }
4193 4293
4194 offscreen_target_frame_buffer_.reset(); 4294 offscreen_target_frame_buffer_.reset();
4195 offscreen_target_color_texture_.reset(); 4295 offscreen_target_color_texture_.reset();
4196 offscreen_target_color_render_buffer_.reset(); 4296 offscreen_target_color_render_buffer_.reset();
4197 offscreen_target_depth_render_buffer_.reset(); 4297 offscreen_target_depth_render_buffer_.reset();
4198 offscreen_target_stencil_render_buffer_.reset(); 4298 offscreen_target_stencil_render_buffer_.reset();
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
4707 GLenum target, GLuint index, GLuint client_id, 4807 GLenum target, GLuint index, GLuint client_id,
4708 GLintptr offset, GLsizeiptr size, 4808 GLintptr offset, GLsizeiptr size,
4709 BindIndexedBufferFunctionType function_type, const char* function_name) { 4809 BindIndexedBufferFunctionType function_type, const char* function_name) {
4710 switch (target) { 4810 switch (target) {
4711 case GL_TRANSFORM_FEEDBACK_BUFFER: { 4811 case GL_TRANSFORM_FEEDBACK_BUFFER: {
4712 if (index >= group_->max_transform_feedback_separate_attribs()) { 4812 if (index >= group_->max_transform_feedback_separate_attribs()) {
4713 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, 4813 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name,
4714 "index out of range"); 4814 "index out of range");
4715 return; 4815 return;
4716 } 4816 }
4717 // TODO(zmo): Check transform feedback isn't currently active. 4817 DCHECK(state_.bound_transform_feedback.get());
4818 if (state_.bound_transform_feedback->active()) {
4819 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name,
4820 "bound transform feedback is active");
4821 return;
4822 }
4718 break; 4823 break;
4719 } 4824 }
4720 case GL_UNIFORM_BUFFER: { 4825 case GL_UNIFORM_BUFFER: {
4721 if (index >= group_->max_uniform_buffer_bindings()) { 4826 if (index >= group_->max_uniform_buffer_bindings()) {
4722 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, 4827 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name,
4723 "index out of range"); 4828 "index out of range");
4724 return; 4829 return;
4725 } 4830 }
4726 break; 4831 break;
4727 } 4832 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
4778 // It's a new id so make a buffer for it. 4883 // It's a new id so make a buffer for it.
4779 glGenBuffersARB(1, &service_id); 4884 glGenBuffersARB(1, &service_id);
4780 CreateBuffer(client_id, service_id); 4885 CreateBuffer(client_id, service_id);
4781 buffer = GetBuffer(client_id); 4886 buffer = GetBuffer(client_id);
4782 DCHECK(buffer); 4887 DCHECK(buffer);
4783 } 4888 }
4784 service_id = buffer->service_id(); 4889 service_id = buffer->service_id();
4785 } 4890 }
4786 LogClientServiceForInfo(buffer, client_id, function_name); 4891 LogClientServiceForInfo(buffer, client_id, function_name);
4787 4892
4788 switch (function_type) { 4893 switch (target) {
4789 case kBindBufferBase: 4894 case GL_TRANSFORM_FEEDBACK_BUFFER:
4790 glBindBufferBase(target, index, service_id); 4895 DCHECK(state_.bound_transform_feedback.get());
4896 switch (function_type) {
4897 case kBindBufferBase:
4898 state_.bound_transform_feedback->DoBindBufferBase(
4899 target, index, buffer);
4900 break;
4901 case kBindBufferRange:
4902 state_.bound_transform_feedback->DoBindBufferRange(
4903 target, index, buffer, offset, size);
4904 break;
4905 }
4791 break; 4906 break;
4792 case kBindBufferRange: 4907 case GL_UNIFORM_BUFFER:
4793 // TODO(zmo): On Desktop GL 4.1 or lower, clamp the offset/size not to 4908 // TODO(zmo): emulate Desktop GL 4.1 or lower behavior and keep track of
4794 // exceed the size of the buffer. crbug.com/604436. 4909 // indexed buffer bindings.
4795 glBindBufferRange(target, index, service_id, offset, size); 4910 switch (function_type) {
4911 case kBindBufferBase:
4912 glBindBufferBase(target, index, service_id);
4913 break;
4914 case kBindBufferRange:
4915 glBindBufferRange(target, index, service_id, offset, size);
4916 break;
4917 }
4918 break;
4919 default:
4920 NOTREACHED();
4796 break; 4921 break;
4797 } 4922 }
4798 // TODO(kbr): track indexed bound buffers.
4799 } 4923 }
4800 4924
4801 void GLES2DecoderImpl::DoBindBufferBase(GLenum target, GLuint index, 4925 void GLES2DecoderImpl::DoBindBufferBase(GLenum target, GLuint index,
4802 GLuint client_id) { 4926 GLuint client_id) {
4803 BindIndexedBufferImpl(target, index, client_id, 0, 0, 4927 BindIndexedBufferImpl(target, index, client_id, 0, 0,
4804 kBindBufferBase, "glBindBufferBase"); 4928 kBindBufferBase, "glBindBufferBase");
4805 } 4929 }
4806 4930
4807 void GLES2DecoderImpl::DoBindBufferRange(GLenum target, GLuint index, 4931 void GLES2DecoderImpl::DoBindBufferRange(GLenum target, GLuint index,
4808 GLuint client_id, 4932 GLuint client_id,
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
5114 if (sampler) { 5238 if (sampler) {
5115 LogClientServiceForInfo(sampler, client_id, "glBindSampler"); 5239 LogClientServiceForInfo(sampler, client_id, "glBindSampler");
5116 glBindSampler(unit, sampler->service_id()); 5240 glBindSampler(unit, sampler->service_id());
5117 } else { 5241 } else {
5118 glBindSampler(unit, 0); 5242 glBindSampler(unit, 0);
5119 } 5243 }
5120 5244
5121 state_.sampler_units[unit] = sampler; 5245 state_.sampler_units[unit] = sampler;
5122 } 5246 }
5123 5247
5248 void GLES2DecoderImpl::DoBindTransformFeedback(
5249 GLenum target, GLuint client_id) {
5250 const char* function_name = "glBindTransformFeedback";
5251 if (!validators_->transform_feedback_bind_target.IsValid(target)) {
5252 LOCAL_SET_GL_ERROR_INVALID_ENUM(function_name, target, "target");
5253 return;
5254 }
5255
5256 TransformFeedback* transform_feedback = nullptr;
5257 if (client_id != 0) {
5258 transform_feedback = GetTransformFeedback(client_id);
5259 if (!transform_feedback) {
5260 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name,
5261 "id not generated by glGenTransformFeedbacks");
5262 return;
5263 }
5264 } else {
5265 transform_feedback = state_.default_transform_feedback.get();
5266 }
5267 DCHECK(transform_feedback);
5268 if (transform_feedback == state_.bound_transform_feedback.get())
5269 return;
5270 if (state_.bound_transform_feedback->active() &&
5271 !state_.bound_transform_feedback->paused()) {
5272 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name,
5273 "currently bound transform feedback is active");
5274 return;
5275 }
5276 LogClientServiceForInfo(transform_feedback, client_id, function_name);
5277 transform_feedback->DoBindTransformFeedback(target);
5278 state_.bound_transform_feedback = transform_feedback;
5279 }
5280
5281 void GLES2DecoderImpl::DoBeginTransformFeedback(GLenum primitive_mode) {
5282 const char* function_name = "glBeginTransformFeedback";
5283 DCHECK(state_.bound_transform_feedback.get());
5284 if (!validators_->transform_feedback_primitive_mode.IsValid(primitive_mode)) {
5285 LOCAL_SET_GL_ERROR_INVALID_ENUM(
5286 function_name, primitive_mode, "primitiveMode");
5287 return;
5288 }
5289 if (state_.bound_transform_feedback->active()) {
5290 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name,
5291 "transform feedback is already active");
5292 return;
5293 }
5294 state_.bound_transform_feedback->DoBeginTransformFeedback(primitive_mode);
5295 }
5296
5297 void GLES2DecoderImpl::DoEndTransformFeedback() {
5298 const char* function_name = "glEndTransformFeedback";
5299 DCHECK(state_.bound_transform_feedback.get());
5300 if (!state_.bound_transform_feedback->active()) {
5301 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name,
5302 "transform feedback is not active");
5303 return;
5304 }
5305 // TODO(zmo): Validate binding points.
5306 state_.bound_transform_feedback->DoEndTransformFeedback();
5307 }
5308
5309 void GLES2DecoderImpl::DoPauseTransformFeedback() {
5310 DCHECK(state_.bound_transform_feedback.get());
5311 if (!state_.bound_transform_feedback->active() ||
5312 state_.bound_transform_feedback->paused()) {
5313 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glPauseTransformFeedback",
5314 "transform feedback is not active or already paused");
5315 return;
5316 }
5317 state_.bound_transform_feedback->DoPauseTransformFeedback();
5318 }
5319
5320 void GLES2DecoderImpl::DoResumeTransformFeedback() {
5321 DCHECK(state_.bound_transform_feedback.get());
5322 if (!state_.bound_transform_feedback->active() ||
5323 !state_.bound_transform_feedback->paused()) {
5324 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glResumeTransformFeedback",
5325 "transform feedback is not active or not paused");
5326 return;
5327 }
5328 state_.bound_transform_feedback->DoResumeTransformFeedback();
5329 }
5330
5124 void GLES2DecoderImpl::DoDisableVertexAttribArray(GLuint index) { 5331 void GLES2DecoderImpl::DoDisableVertexAttribArray(GLuint index) {
5125 if (state_.vertex_attrib_manager->Enable(index, false)) { 5332 if (state_.vertex_attrib_manager->Enable(index, false)) {
5126 if (index != 0 || feature_info_->gl_version_info().BehavesLikeGLES()) { 5333 if (index != 0 || feature_info_->gl_version_info().BehavesLikeGLES()) {
5127 glDisableVertexAttribArray(index); 5334 glDisableVertexAttribArray(index);
5128 } 5335 }
5129 } else { 5336 } else {
5130 LOCAL_SET_GL_ERROR( 5337 LOCAL_SET_GL_ERROR(
5131 GL_INVALID_VALUE, 5338 GL_INVALID_VALUE,
5132 "glDisableVertexAttribArray", "index out of range"); 5339 "glDisableVertexAttribArray", "index out of range");
5133 } 5340 }
(...skipping 3683 matching lines...) Expand 10 before | Expand all | Expand 10 after
8817 bool GLES2DecoderImpl::DoIsTexture(GLuint client_id) { 9024 bool GLES2DecoderImpl::DoIsTexture(GLuint client_id) {
8818 const TextureRef* texture_ref = GetTexture(client_id); 9025 const TextureRef* texture_ref = GetTexture(client_id);
8819 return texture_ref && texture_ref->texture()->IsValid(); 9026 return texture_ref && texture_ref->texture()->IsValid();
8820 } 9027 }
8821 9028
8822 bool GLES2DecoderImpl::DoIsSampler(GLuint client_id) { 9029 bool GLES2DecoderImpl::DoIsSampler(GLuint client_id) {
8823 const Sampler* sampler = GetSampler(client_id); 9030 const Sampler* sampler = GetSampler(client_id);
8824 return sampler && !sampler->IsDeleted(); 9031 return sampler && !sampler->IsDeleted();
8825 } 9032 }
8826 9033
9034 bool GLES2DecoderImpl::DoIsTransformFeedback(GLuint client_id) {
9035 const TransformFeedback* transform_feedback =
9036 GetTransformFeedback(client_id);
9037 return transform_feedback && transform_feedback->has_been_bound();
9038 }
9039
8827 void GLES2DecoderImpl::DoAttachShader( 9040 void GLES2DecoderImpl::DoAttachShader(
8828 GLuint program_client_id, GLint shader_client_id) { 9041 GLuint program_client_id, GLint shader_client_id) {
8829 Program* program = GetProgramInfoNotShader( 9042 Program* program = GetProgramInfoNotShader(
8830 program_client_id, "glAttachShader"); 9043 program_client_id, "glAttachShader");
8831 if (!program) { 9044 if (!program) {
8832 return; 9045 return;
8833 } 9046 }
8834 Shader* shader = GetShaderInfoNotProgram(shader_client_id, "glAttachShader"); 9047 Shader* shader = GetShaderInfoNotProgram(shader_client_id, "glAttachShader");
8835 if (!shader) { 9048 if (!shader) {
8836 return; 9049 return;
(...skipping 4410 matching lines...) Expand 10 before | Expand all | Expand 10 after
13247 13460
13248 void GLES2DecoderImpl::MarkContextLost(error::ContextLostReason reason) { 13461 void GLES2DecoderImpl::MarkContextLost(error::ContextLostReason reason) {
13249 // Only lose the context once. 13462 // Only lose the context once.
13250 if (WasContextLost()) 13463 if (WasContextLost())
13251 return; 13464 return;
13252 13465
13253 // Don't make GL calls in here, the context might not be current. 13466 // Don't make GL calls in here, the context might not be current.
13254 context_lost_reason_ = reason; 13467 context_lost_reason_ = reason;
13255 current_decoder_error_ = error::kLostContext; 13468 current_decoder_error_ = error::kLostContext;
13256 context_was_lost_ = true; 13469 context_was_lost_ = true;
13470
13471 if (transform_feedback_manager_.get()) {
13472 transform_feedback_manager_->MarkContextLost();
13473 }
13257 } 13474 }
13258 13475
13259 bool GLES2DecoderImpl::CheckResetStatus() { 13476 bool GLES2DecoderImpl::CheckResetStatus() {
13260 DCHECK(!WasContextLost()); 13477 DCHECK(!WasContextLost());
13261 DCHECK(context_->IsCurrent(NULL)); 13478 DCHECK(context_->IsCurrent(NULL));
13262 13479
13263 if (IsRobustnessSupported()) { 13480 if (IsRobustnessSupported()) {
13264 // If the reason for the call was a GL error, we can try to determine the 13481 // If the reason for the call was a GL error, we can try to determine the
13265 // reset status more accurately. 13482 // reset status more accurately.
13266 GLenum driver_status = glGetGraphicsResetStatusARB(); 13483 GLenum driver_status = glGetGraphicsResetStatusARB();
(...skipping 3227 matching lines...) Expand 10 before | Expand all | Expand 10 after
16494 } 16711 }
16495 16712
16496 // Include the auto-generated part of this file. We split this because it means 16713 // Include the auto-generated part of this file. We split this because it means
16497 // we can easily edit the non-auto generated parts right here in this file 16714 // we can easily edit the non-auto generated parts right here in this file
16498 // instead of having to edit some template or the code generator. 16715 // instead of having to edit some template or the code generator.
16499 #include "base/macros.h" 16716 #include "base/macros.h"
16500 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 16717 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
16501 16718
16502 } // namespace gles2 16719 } // namespace gles2
16503 } // namespace gpu 16720 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder.h ('k') | gpu/command_buffer/service/gles2_cmd_decoder_autogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698