Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
| 6 | 6 |
| 7 #include <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 Loading... | |
| 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 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 744 bool GenRenderbuffersHelper(GLsizei n, const GLuint* client_ids); | 745 bool GenRenderbuffersHelper(GLsizei n, const GLuint* client_ids); |
| 745 void DeleteRenderbuffersHelper(GLsizei n, const GLuint* client_ids); | 746 void DeleteRenderbuffersHelper(GLsizei n, const GLuint* client_ids); |
| 746 bool GenQueriesEXTHelper(GLsizei n, const GLuint* client_ids); | 747 bool GenQueriesEXTHelper(GLsizei n, const GLuint* client_ids); |
| 747 void DeleteQueriesEXTHelper(GLsizei n, const GLuint* client_ids); | 748 void DeleteQueriesEXTHelper(GLsizei n, const GLuint* client_ids); |
| 748 bool GenVertexArraysOESHelper(GLsizei n, const GLuint* client_ids); | 749 bool GenVertexArraysOESHelper(GLsizei n, const GLuint* client_ids); |
| 749 void DeleteVertexArraysOESHelper(GLsizei n, const GLuint* client_ids); | 750 void DeleteVertexArraysOESHelper(GLsizei n, const GLuint* client_ids); |
| 750 bool GenPathsCHROMIUMHelper(GLuint first_client_id, GLsizei range); | 751 bool GenPathsCHROMIUMHelper(GLuint first_client_id, GLsizei range); |
| 751 bool DeletePathsCHROMIUMHelper(GLuint first_client_id, GLsizei range); | 752 bool DeletePathsCHROMIUMHelper(GLuint first_client_id, GLsizei range); |
| 752 bool GenSamplersHelper(GLsizei n, const GLuint* client_ids); | 753 bool GenSamplersHelper(GLsizei n, const GLuint* client_ids); |
| 753 void DeleteSamplersHelper(GLsizei n, const GLuint* client_ids); | 754 void DeleteSamplersHelper(GLsizei n, const GLuint* client_ids); |
| 755 bool GenTransformFeedbacksHelper(GLsizei n, const GLuint* client_ids); | |
| 756 void DeleteTransformFeedbacksHelper(GLsizei n, const GLuint* client_ids); | |
| 754 | 757 |
| 755 // Workarounds | 758 // Workarounds |
| 756 void OnFboChanged() const; | 759 void OnFboChanged() const; |
| 757 void OnUseFramebuffer() const; | 760 void OnUseFramebuffer() const; |
| 758 | 761 |
| 759 error::ContextLostReason GetContextLostReasonFromResetStatus( | 762 error::ContextLostReason GetContextLostReasonFromResetStatus( |
| 760 GLenum reset_status) const; | 763 GLenum reset_status) const; |
| 761 | 764 |
| 762 // TODO(gman): Cache these pointers? | 765 // TODO(gman): Cache these pointers? |
| 763 BufferManager* buffer_manager() { | 766 BufferManager* buffer_manager() { |
| 764 return group_->buffer_manager(); | 767 return group_->buffer_manager(); |
| 765 } | 768 } |
| 766 | 769 |
| 767 RenderbufferManager* renderbuffer_manager() { | 770 RenderbufferManager* renderbuffer_manager() { |
| 768 return group_->renderbuffer_manager(); | 771 return group_->renderbuffer_manager(); |
| 769 } | 772 } |
| 770 | 773 |
| 771 FramebufferManager* framebuffer_manager() { | 774 FramebufferManager* framebuffer_manager() { |
| 772 return group_->framebuffer_manager(); | 775 return group_->framebuffer_manager(); |
| 773 } | 776 } |
| 774 | 777 |
| 775 ProgramManager* program_manager() { | 778 ProgramManager* program_manager() { |
| 776 return group_->program_manager(); | 779 return group_->program_manager(); |
| 777 } | 780 } |
| 778 | 781 |
| 779 SamplerManager* sampler_manager() { | 782 SamplerManager* sampler_manager() { |
| 780 return group_->sampler_manager(); | 783 return group_->sampler_manager(); |
| 781 } | 784 } |
| 782 | 785 |
| 786 TransformFeedbackManager* transform_feedback_manager() { | |
| 787 return group_->transform_feedback_manager(); | |
| 788 } | |
| 789 | |
| 783 ShaderManager* shader_manager() { | 790 ShaderManager* shader_manager() { |
| 784 return group_->shader_manager(); | 791 return group_->shader_manager(); |
| 785 } | 792 } |
| 786 | 793 |
| 787 ShaderTranslatorCache* shader_translator_cache() { | 794 ShaderTranslatorCache* shader_translator_cache() { |
| 788 return group_->shader_translator_cache(); | 795 return group_->shader_translator_cache(); |
| 789 } | 796 } |
| 790 | 797 |
| 791 const TextureManager* texture_manager() const { | 798 const TextureManager* texture_manager() const { |
| 792 return group_->texture_manager(); | 799 return group_->texture_manager(); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 847 // 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. |
| 848 Sampler* GetSampler(GLuint client_id) { | 855 Sampler* GetSampler(GLuint client_id) { |
| 849 return sampler_manager()->GetSampler(client_id); | 856 return sampler_manager()->GetSampler(client_id); |
| 850 } | 857 } |
| 851 | 858 |
| 852 // Deletes the sampler info for the given sampler. | 859 // Deletes the sampler info for the given sampler. |
| 853 void RemoveSampler(GLuint client_id) { | 860 void RemoveSampler(GLuint client_id) { |
| 854 sampler_manager()->RemoveSampler(client_id); | 861 sampler_manager()->RemoveSampler(client_id); |
| 855 } | 862 } |
| 856 | 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 | |
| 857 // 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 |
| 858 // or regular back buffer). | 883 // or regular back buffer). |
| 859 gfx::Size GetBoundReadFrameBufferSize(); | 884 gfx::Size GetBoundReadFrameBufferSize(); |
| 860 | 885 |
| 861 // 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 |
| 862 // regular back buffer). | 887 // regular back buffer). |
| 863 // If the color image is a renderbuffer, returns 0 for type. | 888 // If the color image is a renderbuffer, returns 0 for type. |
| 864 GLenum GetBoundReadFrameBufferTextureType(); | 889 GLenum GetBoundReadFrameBufferTextureType(); |
| 865 GLenum GetBoundReadFrameBufferInternalFormat(); | 890 GLenum GetBoundReadFrameBufferInternalFormat(); |
| 866 | 891 |
| (...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1364 | 1389 |
| 1365 // Wrapper for glBindRenderbuffer since we need to track the current targets. | 1390 // Wrapper for glBindRenderbuffer since we need to track the current targets. |
| 1366 void DoBindRenderbuffer(GLenum target, GLuint renderbuffer); | 1391 void DoBindRenderbuffer(GLenum target, GLuint renderbuffer); |
| 1367 | 1392 |
| 1368 // Wrapper for glBindTexture since we need to track the current targets. | 1393 // Wrapper for glBindTexture since we need to track the current targets. |
| 1369 void DoBindTexture(GLenum target, GLuint texture); | 1394 void DoBindTexture(GLenum target, GLuint texture); |
| 1370 | 1395 |
| 1371 // Wrapper for glBindSampler since we need to track the current targets. | 1396 // Wrapper for glBindSampler since we need to track the current targets. |
| 1372 void DoBindSampler(GLuint unit, GLuint sampler); | 1397 void DoBindSampler(GLuint unit, GLuint sampler); |
| 1373 | 1398 |
| 1399 // Wrapper for glBindTransformFeedback since we need to emulate ES3 behaviors | |
| 1400 // for BindBufferRange on Desktop GL lower than 4.2. | |
| 1401 void DoBindTransformFeedback(GLenum target, GLuint transform_feedback); | |
| 1402 | |
| 1403 // Wrapper for glBeginTransformFeedback. | |
| 1404 void DoBeginTransformFeedback(GLenum primitive_mode); | |
| 1405 | |
| 1406 // Wrapper for glEndTransformFeedback. | |
| 1407 void DoEndTransformFeedback(); | |
| 1408 | |
| 1409 // Wrapper for glPauseTransformFeedback. | |
| 1410 void DoPauseTransformFeedback(); | |
| 1411 | |
| 1412 // Wrapper for glResumeTransformFeedback. | |
| 1413 void DoResumeTransformFeedback(); | |
| 1414 | |
| 1374 // Wrapper for glBindVertexArrayOES | 1415 // Wrapper for glBindVertexArrayOES |
| 1375 void DoBindVertexArrayOES(GLuint array); | 1416 void DoBindVertexArrayOES(GLuint array); |
| 1376 void EmulateVertexArrayState(); | 1417 void EmulateVertexArrayState(); |
| 1377 | 1418 |
| 1378 // Wrapper for glBlitFramebufferCHROMIUM. | 1419 // Wrapper for glBlitFramebufferCHROMIUM. |
| 1379 void DoBlitFramebufferCHROMIUM( | 1420 void DoBlitFramebufferCHROMIUM( |
| 1380 GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, | 1421 GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, |
| 1381 GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, | 1422 GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, |
| 1382 GLbitfield mask, GLenum filter); | 1423 GLbitfield mask, GLenum filter); |
| 1383 | 1424 |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1539 | 1580 |
| 1540 // Wrappers for glIsXXX functions. | 1581 // Wrappers for glIsXXX functions. |
| 1541 bool DoIsEnabled(GLenum cap); | 1582 bool DoIsEnabled(GLenum cap); |
| 1542 bool DoIsBuffer(GLuint client_id); | 1583 bool DoIsBuffer(GLuint client_id); |
| 1543 bool DoIsFramebuffer(GLuint client_id); | 1584 bool DoIsFramebuffer(GLuint client_id); |
| 1544 bool DoIsProgram(GLuint client_id); | 1585 bool DoIsProgram(GLuint client_id); |
| 1545 bool DoIsRenderbuffer(GLuint client_id); | 1586 bool DoIsRenderbuffer(GLuint client_id); |
| 1546 bool DoIsShader(GLuint client_id); | 1587 bool DoIsShader(GLuint client_id); |
| 1547 bool DoIsTexture(GLuint client_id); | 1588 bool DoIsTexture(GLuint client_id); |
| 1548 bool DoIsSampler(GLuint client_id); | 1589 bool DoIsSampler(GLuint client_id); |
| 1590 bool DoIsTransformFeedback(GLuint client_id); | |
| 1549 bool DoIsVertexArrayOES(GLuint client_id); | 1591 bool DoIsVertexArrayOES(GLuint client_id); |
| 1550 bool DoIsPathCHROMIUM(GLuint client_id); | 1592 bool DoIsPathCHROMIUM(GLuint client_id); |
| 1551 | 1593 |
| 1552 void DoLineWidth(GLfloat width); | 1594 void DoLineWidth(GLfloat width); |
| 1553 | 1595 |
| 1554 // Wrapper for glLinkProgram | 1596 // Wrapper for glLinkProgram |
| 1555 void DoLinkProgram(GLuint program); | 1597 void DoLinkProgram(GLuint program); |
| 1556 | 1598 |
| 1557 // Wrapper for glReadBuffer | 1599 // Wrapper for glReadBuffer |
| 1558 void DoReadBuffer(GLenum src); | 1600 void DoReadBuffer(GLenum src); |
| (...skipping 1164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2723 LOG(ERROR) << "Underlying driver does not support ES3."; | 2765 LOG(ERROR) << "Underlying driver does not support ES3."; |
| 2724 Destroy(true); | 2766 Destroy(true); |
| 2725 return false; | 2767 return false; |
| 2726 } | 2768 } |
| 2727 feature_info_->EnableES3Validators(); | 2769 feature_info_->EnableES3Validators(); |
| 2728 set_unsafe_es3_apis_enabled(true); | 2770 set_unsafe_es3_apis_enabled(true); |
| 2729 | 2771 |
| 2730 frag_depth_explicitly_enabled_ = true; | 2772 frag_depth_explicitly_enabled_ = true; |
| 2731 draw_buffers_explicitly_enabled_ = true; | 2773 draw_buffers_explicitly_enabled_ = true; |
| 2732 // TODO(zmo): Look into shader_texture_lod_explicitly_enabled_ situation. | 2774 // TODO(zmo): Look into shader_texture_lod_explicitly_enabled_ situation. |
| 2775 | |
| 2776 // Create a fake default transform feedback and bind to it. | |
| 2777 GLuint default_transform_feedback = 0; | |
| 2778 glGenTransformFeedbacks(1, &default_transform_feedback); | |
| 2779 state_.default_transform_feedback = new TransformFeedback( | |
| 2780 group_->transform_feedback_manager(), default_transform_feedback); | |
| 2781 glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, default_transform_feedback); | |
| 2782 state_.bound_transform_feedback = state_.default_transform_feedback.get(); | |
| 2733 } | 2783 } |
| 2734 | 2784 |
| 2735 state_.attrib_values.resize(group_->max_vertex_attribs()); | 2785 state_.attrib_values.resize(group_->max_vertex_attribs()); |
| 2736 vertex_array_manager_.reset(new VertexArrayManager()); | 2786 vertex_array_manager_.reset(new VertexArrayManager()); |
| 2737 | 2787 |
| 2738 GLuint default_vertex_attrib_service_id = 0; | 2788 GLuint default_vertex_attrib_service_id = 0; |
| 2739 if (features().native_vertex_array_object) { | 2789 if (features().native_vertex_array_object) { |
| 2740 glGenVertexArraysOES(1, &default_vertex_attrib_service_id); | 2790 glGenVertexArraysOES(1, &default_vertex_attrib_service_id); |
| 2741 glBindVertexArrayOES(default_vertex_attrib_service_id); | 2791 glBindVertexArrayOES(default_vertex_attrib_service_id); |
| 2742 } | 2792 } |
| (...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3466 } | 3516 } |
| 3467 } | 3517 } |
| 3468 std::unique_ptr<GLuint[]> service_ids(new GLuint[n]); | 3518 std::unique_ptr<GLuint[]> service_ids(new GLuint[n]); |
| 3469 glGenSamplers(n, service_ids.get()); | 3519 glGenSamplers(n, service_ids.get()); |
| 3470 for (GLsizei ii = 0; ii < n; ++ii) { | 3520 for (GLsizei ii = 0; ii < n; ++ii) { |
| 3471 CreateSampler(client_ids[ii], service_ids[ii]); | 3521 CreateSampler(client_ids[ii], service_ids[ii]); |
| 3472 } | 3522 } |
| 3473 return true; | 3523 return true; |
| 3474 } | 3524 } |
| 3475 | 3525 |
| 3526 bool GLES2DecoderImpl::GenTransformFeedbacksHelper( | |
| 3527 GLsizei n, const GLuint* client_ids) { | |
| 3528 for (GLsizei ii = 0; ii < n; ++ii) { | |
| 3529 if (GetTransformFeedback(client_ids[ii])) { | |
| 3530 return false; | |
| 3531 } | |
| 3532 } | |
| 3533 std::unique_ptr<GLuint[]> service_ids(new GLuint[n]); | |
| 3534 glGenTransformFeedbacks(n, service_ids.get()); | |
| 3535 for (GLsizei ii = 0; ii < n; ++ii) { | |
| 3536 CreateTransformFeedback(client_ids[ii], service_ids[ii]); | |
| 3537 } | |
| 3538 return true; | |
| 3539 } | |
| 3540 | |
| 3476 bool GLES2DecoderImpl::GenPathsCHROMIUMHelper(GLuint first_client_id, | 3541 bool GLES2DecoderImpl::GenPathsCHROMIUMHelper(GLuint first_client_id, |
| 3477 GLsizei range) { | 3542 GLsizei range) { |
| 3478 GLuint last_client_id; | 3543 GLuint last_client_id; |
| 3479 if (!SafeAddUint32(first_client_id, range - 1, &last_client_id)) | 3544 if (!SafeAddUint32(first_client_id, range - 1, &last_client_id)) |
| 3480 return false; | 3545 return false; |
| 3481 | 3546 |
| 3482 if (path_manager()->HasPathsInRange(first_client_id, last_client_id)) | 3547 if (path_manager()->HasPathsInRange(first_client_id, last_client_id)) |
| 3483 return false; | 3548 return false; |
| 3484 | 3549 |
| 3485 GLuint first_service_id = glGenPathsNV(range); | 3550 GLuint first_service_id = glGenPathsNV(range); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 3509 return true; | 3574 return true; |
| 3510 } | 3575 } |
| 3511 | 3576 |
| 3512 void GLES2DecoderImpl::DeleteBuffersHelper( | 3577 void GLES2DecoderImpl::DeleteBuffersHelper( |
| 3513 GLsizei n, const GLuint* client_ids) { | 3578 GLsizei n, const GLuint* client_ids) { |
| 3514 for (GLsizei ii = 0; ii < n; ++ii) { | 3579 for (GLsizei ii = 0; ii < n; ++ii) { |
| 3515 Buffer* buffer = GetBuffer(client_ids[ii]); | 3580 Buffer* buffer = GetBuffer(client_ids[ii]); |
| 3516 if (buffer && !buffer->IsDeleted()) { | 3581 if (buffer && !buffer->IsDeleted()) { |
| 3517 buffer->RemoveMappedRange(); | 3582 buffer->RemoveMappedRange(); |
| 3518 state_.RemoveBoundBuffer(buffer); | 3583 state_.RemoveBoundBuffer(buffer); |
| 3584 if (transform_feedback_manager()) { | |
|
piman
2016/04/28 01:38:47
nit: transform_feedback_manager() is always non-nu
Zhenyao Mo
2016/04/29 21:07:54
Done.
| |
| 3585 transform_feedback_manager()->RemoveBoundBuffer(buffer); | |
| 3586 } | |
| 3519 RemoveBuffer(client_ids[ii]); | 3587 RemoveBuffer(client_ids[ii]); |
| 3520 } | 3588 } |
| 3521 } | 3589 } |
| 3522 } | 3590 } |
| 3523 | 3591 |
| 3524 void GLES2DecoderImpl::DeleteFramebuffersHelper( | 3592 void GLES2DecoderImpl::DeleteFramebuffersHelper( |
| 3525 GLsizei n, const GLuint* client_ids) { | 3593 GLsizei n, const GLuint* client_ids) { |
| 3526 bool supports_separate_framebuffer_binds = | 3594 bool supports_separate_framebuffer_binds = |
| 3527 features().chromium_framebuffer_multisample; | 3595 features().chromium_framebuffer_multisample; |
| 3528 | 3596 |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3634 Sampler* sampler = GetSampler(client_ids[ii]); | 3702 Sampler* sampler = GetSampler(client_ids[ii]); |
| 3635 if (sampler && !sampler->IsDeleted()) { | 3703 if (sampler && !sampler->IsDeleted()) { |
| 3636 // Unbind from current sampler units. | 3704 // Unbind from current sampler units. |
| 3637 state_.UnbindSampler(sampler); | 3705 state_.UnbindSampler(sampler); |
| 3638 | 3706 |
| 3639 RemoveSampler(client_ids[ii]); | 3707 RemoveSampler(client_ids[ii]); |
| 3640 } | 3708 } |
| 3641 } | 3709 } |
| 3642 } | 3710 } |
| 3643 | 3711 |
| 3644 // } // anonymous namespace | 3712 void GLES2DecoderImpl::DeleteTransformFeedbacksHelper( |
| 3713 GLsizei n, const GLuint* client_ids) { | |
| 3714 for (GLsizei ii = 0; ii < n; ++ii) { | |
| 3715 TransformFeedback* transform_feedback = GetTransformFeedback( | |
| 3716 client_ids[ii]); | |
| 3717 if (transform_feedback && !transform_feedback->deleted()) { | |
|
piman
2016/04/28 01:38:47
nit: because the transform feedback objects are no
Zhenyao Mo
2016/04/29 21:07:54
Done.
| |
| 3718 if (state_.bound_transform_feedback.get() == transform_feedback) { | |
| 3719 // Bind to the default transform feedback. | |
| 3720 DCHECK(state_.default_transform_feedback.get()); | |
| 3721 state_.default_transform_feedback->DoBindTransformFeedback( | |
| 3722 feature_info_->gl_version_info(), GL_TRANSFORM_FEEDBACK); | |
| 3723 state_.bound_transform_feedback = | |
| 3724 state_.default_transform_feedback.get(); | |
| 3725 } | |
| 3726 | |
| 3727 RemoveTransformFeedback(client_ids[ii]); | |
| 3728 } | |
| 3729 } | |
| 3730 } | |
| 3645 | 3731 |
| 3646 bool GLES2DecoderImpl::MakeCurrent() { | 3732 bool GLES2DecoderImpl::MakeCurrent() { |
| 3647 if (!context_.get()) | 3733 if (!context_.get()) |
| 3648 return false; | 3734 return false; |
| 3649 | 3735 |
| 3650 if (WasContextLost()) { | 3736 if (WasContextLost()) { |
| 3651 LOG(ERROR) << " GLES2DecoderImpl: Trying to make lost context current."; | 3737 LOG(ERROR) << " GLES2DecoderImpl: Trying to make lost context current."; |
| 3652 return false; | 3738 return false; |
| 3653 } | 3739 } |
| 3654 | 3740 |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4035 } | 4121 } |
| 4036 | 4122 |
| 4037 void GLES2DecoderImpl::AddProcessingCommandsTime(base::TimeDelta time) { | 4123 void GLES2DecoderImpl::AddProcessingCommandsTime(base::TimeDelta time) { |
| 4038 total_processing_commands_time_ += time; | 4124 total_processing_commands_time_ += time; |
| 4039 } | 4125 } |
| 4040 | 4126 |
| 4041 void GLES2DecoderImpl::Destroy(bool have_context) { | 4127 void GLES2DecoderImpl::Destroy(bool have_context) { |
| 4042 if (!initialized()) | 4128 if (!initialized()) |
| 4043 return; | 4129 return; |
| 4044 | 4130 |
| 4045 DCHECK(!have_context || context_->IsCurrent(NULL)); | 4131 DCHECK(!have_context || context_->IsCurrent(nullptr)); |
| 4046 | 4132 |
| 4047 // Unbind everything. | 4133 // Unbind everything. |
| 4048 state_.vertex_attrib_manager = NULL; | 4134 state_.vertex_attrib_manager = nullptr; |
| 4049 state_.default_vertex_attrib_manager = NULL; | 4135 state_.default_vertex_attrib_manager = nullptr; |
| 4050 state_.texture_units.clear(); | 4136 state_.texture_units.clear(); |
| 4051 state_.sampler_units.clear(); | 4137 state_.sampler_units.clear(); |
| 4052 state_.bound_array_buffer = NULL; | 4138 state_.bound_array_buffer = nullptr; |
| 4053 state_.bound_copy_read_buffer = NULL; | 4139 state_.bound_copy_read_buffer = nullptr; |
| 4054 state_.bound_copy_write_buffer = NULL; | 4140 state_.bound_copy_write_buffer = nullptr; |
| 4055 state_.bound_pixel_pack_buffer = NULL; | 4141 state_.bound_pixel_pack_buffer = nullptr; |
| 4056 state_.bound_pixel_unpack_buffer = NULL; | 4142 state_.bound_pixel_unpack_buffer = nullptr; |
| 4057 state_.bound_transform_feedback_buffer = NULL; | 4143 state_.bound_transform_feedback_buffer = nullptr; |
| 4058 state_.bound_uniform_buffer = NULL; | 4144 state_.bound_uniform_buffer = nullptr; |
| 4059 framebuffer_state_.bound_read_framebuffer = NULL; | 4145 framebuffer_state_.bound_read_framebuffer = nullptr; |
| 4060 framebuffer_state_.bound_draw_framebuffer = NULL; | 4146 framebuffer_state_.bound_draw_framebuffer = nullptr; |
| 4061 state_.bound_renderbuffer = NULL; | 4147 state_.bound_renderbuffer = nullptr; |
| 4148 state_.bound_transform_feedback = nullptr; | |
| 4149 state_.default_transform_feedback = nullptr; | |
| 4062 | 4150 |
| 4063 if (offscreen_saved_color_texture_info_.get()) { | 4151 if (offscreen_saved_color_texture_info_.get()) { |
| 4064 DCHECK(offscreen_target_color_texture_); | 4152 DCHECK(offscreen_target_color_texture_); |
| 4065 DCHECK_EQ(offscreen_saved_color_texture_info_->service_id(), | 4153 DCHECK_EQ(offscreen_saved_color_texture_info_->service_id(), |
| 4066 offscreen_saved_color_texture_->id()); | 4154 offscreen_saved_color_texture_->id()); |
| 4067 offscreen_saved_color_texture_->Invalidate(); | 4155 offscreen_saved_color_texture_->Invalidate(); |
| 4068 offscreen_saved_color_texture_info_ = NULL; | 4156 offscreen_saved_color_texture_info_ = NULL; |
| 4069 } | 4157 } |
| 4070 if (have_context) { | 4158 if (have_context) { |
| 4071 if (copy_texture_CHROMIUM_.get()) { | 4159 if (copy_texture_CHROMIUM_.get()) { |
| (...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4588 GLenum target, GLuint index, GLuint client_id, | 4676 GLenum target, GLuint index, GLuint client_id, |
| 4589 GLintptr offset, GLsizeiptr size, | 4677 GLintptr offset, GLsizeiptr size, |
| 4590 BindIndexedBufferFunctionType function_type, const char* function_name) { | 4678 BindIndexedBufferFunctionType function_type, const char* function_name) { |
| 4591 switch (target) { | 4679 switch (target) { |
| 4592 case GL_TRANSFORM_FEEDBACK_BUFFER: { | 4680 case GL_TRANSFORM_FEEDBACK_BUFFER: { |
| 4593 if (index >= group_->max_transform_feedback_separate_attribs()) { | 4681 if (index >= group_->max_transform_feedback_separate_attribs()) { |
| 4594 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, | 4682 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, |
| 4595 "index out of range"); | 4683 "index out of range"); |
| 4596 return; | 4684 return; |
| 4597 } | 4685 } |
| 4598 // TODO(zmo): Check transform feedback isn't currently active. | 4686 DCHECK(state_.bound_transform_feedback.get()); |
| 4687 if (state_.bound_transform_feedback->active()) { | |
| 4688 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, | |
| 4689 "bound transform feedback is active"); | |
| 4690 return; | |
| 4691 } | |
| 4599 break; | 4692 break; |
| 4600 } | 4693 } |
| 4601 case GL_UNIFORM_BUFFER: { | 4694 case GL_UNIFORM_BUFFER: { |
| 4602 if (index >= group_->max_uniform_buffer_bindings()) { | 4695 if (index >= group_->max_uniform_buffer_bindings()) { |
| 4603 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, | 4696 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, |
| 4604 "index out of range"); | 4697 "index out of range"); |
| 4605 return; | 4698 return; |
| 4606 } | 4699 } |
| 4607 break; | 4700 break; |
| 4608 } | 4701 } |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4659 // It's a new id so make a buffer for it. | 4752 // It's a new id so make a buffer for it. |
| 4660 glGenBuffersARB(1, &service_id); | 4753 glGenBuffersARB(1, &service_id); |
| 4661 CreateBuffer(client_id, service_id); | 4754 CreateBuffer(client_id, service_id); |
| 4662 buffer = GetBuffer(client_id); | 4755 buffer = GetBuffer(client_id); |
| 4663 DCHECK(buffer); | 4756 DCHECK(buffer); |
| 4664 } | 4757 } |
| 4665 service_id = buffer->service_id(); | 4758 service_id = buffer->service_id(); |
| 4666 } | 4759 } |
| 4667 LogClientServiceForInfo(buffer, client_id, function_name); | 4760 LogClientServiceForInfo(buffer, client_id, function_name); |
| 4668 | 4761 |
| 4669 switch (function_type) { | 4762 switch (target) { |
| 4670 case kBindBufferBase: | 4763 case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 4671 glBindBufferBase(target, index, service_id); | 4764 DCHECK(state_.bound_transform_feedback.get()); |
| 4765 switch (function_type) { | |
| 4766 case kBindBufferBase: | |
| 4767 state_.bound_transform_feedback->DoBindBufferBase( | |
| 4768 target, index, buffer); | |
| 4769 break; | |
| 4770 case kBindBufferRange: | |
| 4771 state_.bound_transform_feedback->DoBindBufferRange( | |
| 4772 feature_info_->gl_version_info(), | |
| 4773 target, index, buffer, offset, size); | |
| 4774 break; | |
| 4775 } | |
| 4672 break; | 4776 break; |
| 4673 case kBindBufferRange: | 4777 case GL_UNIFORM_BUFFER: |
| 4674 // TODO(zmo): On Desktop GL 4.1 or lower, clamp the offset/size not to | 4778 // TODO(zmo): emulate Desktop GL 4.1 or lower behavior and keep track of |
| 4675 // exceed the size of the buffer. crbug.com/604436. | 4779 // indexed buffer bindings. |
| 4676 glBindBufferRange(target, index, service_id, offset, size); | 4780 switch (function_type) { |
| 4781 case kBindBufferBase: | |
| 4782 glBindBufferBase(target, index, service_id); | |
| 4783 break; | |
| 4784 case kBindBufferRange: | |
| 4785 glBindBufferRange(target, index, service_id, offset, size); | |
| 4786 break; | |
| 4787 } | |
| 4788 break; | |
| 4789 default: | |
| 4790 NOTREACHED(); | |
| 4677 break; | 4791 break; |
| 4678 } | 4792 } |
| 4679 // TODO(kbr): track indexed bound buffers. | |
| 4680 } | 4793 } |
| 4681 | 4794 |
| 4682 void GLES2DecoderImpl::DoBindBufferBase(GLenum target, GLuint index, | 4795 void GLES2DecoderImpl::DoBindBufferBase(GLenum target, GLuint index, |
| 4683 GLuint client_id) { | 4796 GLuint client_id) { |
| 4684 BindIndexedBufferImpl(target, index, client_id, 0, 0, | 4797 BindIndexedBufferImpl(target, index, client_id, 0, 0, |
| 4685 kBindBufferBase, "glBindBufferBase"); | 4798 kBindBufferBase, "glBindBufferBase"); |
| 4686 } | 4799 } |
| 4687 | 4800 |
| 4688 void GLES2DecoderImpl::DoBindBufferRange(GLenum target, GLuint index, | 4801 void GLES2DecoderImpl::DoBindBufferRange(GLenum target, GLuint index, |
| 4689 GLuint client_id, | 4802 GLuint client_id, |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5003 if (sampler) { | 5116 if (sampler) { |
| 5004 LogClientServiceForInfo(sampler, client_id, "glBindSampler"); | 5117 LogClientServiceForInfo(sampler, client_id, "glBindSampler"); |
| 5005 glBindSampler(unit, sampler->service_id()); | 5118 glBindSampler(unit, sampler->service_id()); |
| 5006 } else { | 5119 } else { |
| 5007 glBindSampler(unit, 0); | 5120 glBindSampler(unit, 0); |
| 5008 } | 5121 } |
| 5009 | 5122 |
| 5010 state_.sampler_units[unit] = sampler; | 5123 state_.sampler_units[unit] = sampler; |
| 5011 } | 5124 } |
| 5012 | 5125 |
| 5126 void GLES2DecoderImpl::DoBindTransformFeedback( | |
| 5127 GLenum target, GLuint client_id) { | |
| 5128 const char* function_name = "glBindTransformFeedback"; | |
| 5129 if (!validators_->transform_feedback_bind_target.IsValid(target)) { | |
| 5130 LOCAL_SET_GL_ERROR_INVALID_ENUM(function_name, target, "target"); | |
| 5131 return; | |
| 5132 } | |
|
piman
2016/04/28 01:38:47
If the currently bound transform feedback is activ
Zhenyao Mo
2016/04/29 21:07:54
Done.
| |
| 5133 | |
| 5134 TransformFeedback* transform_feedback = nullptr; | |
| 5135 if (client_id != 0) { | |
| 5136 transform_feedback = GetTransformFeedback(client_id); | |
| 5137 if (!transform_feedback) { | |
| 5138 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, | |
| 5139 "id not generated by glGenTransformFeedbacks"); | |
| 5140 return; | |
| 5141 } | |
| 5142 } else { | |
| 5143 transform_feedback = state_.default_transform_feedback.get(); | |
| 5144 } | |
| 5145 DCHECK(transform_feedback); | |
| 5146 LogClientServiceForInfo(transform_feedback, client_id, function_name); | |
| 5147 transform_feedback->DoBindTransformFeedback( | |
| 5148 feature_info_->gl_version_info(), target); | |
| 5149 state_.bound_transform_feedback = transform_feedback; | |
| 5150 } | |
| 5151 | |
| 5152 void GLES2DecoderImpl::DoBeginTransformFeedback(GLenum primitive_mode) { | |
| 5153 const char* function_name = "glBeginTransformFeedback"; | |
| 5154 DCHECK(state_.bound_transform_feedback.get()); | |
| 5155 if (!validators_->transform_feedback_primitive_mode.IsValid(primitive_mode)) { | |
| 5156 LOCAL_SET_GL_ERROR_INVALID_ENUM( | |
| 5157 function_name, primitive_mode, "primitiveMode"); | |
| 5158 return; | |
| 5159 } | |
| 5160 if (state_.bound_transform_feedback->active()) { | |
| 5161 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, | |
| 5162 "transform feedback is already active"); | |
| 5163 return; | |
| 5164 } | |
| 5165 state_.bound_transform_feedback->DoBeginTransformFeedback(primitive_mode); | |
| 5166 } | |
| 5167 | |
| 5168 void GLES2DecoderImpl::DoEndTransformFeedback() { | |
| 5169 const char* function_name = "glEndTransformFeedback"; | |
| 5170 DCHECK(state_.bound_transform_feedback.get()); | |
| 5171 if (!state_.bound_transform_feedback->active()) { | |
| 5172 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, | |
| 5173 "transform feedback is not active"); | |
| 5174 return; | |
| 5175 } | |
| 5176 // TODO(zmo): Validate binding points. | |
| 5177 state_.bound_transform_feedback->DoEndTransformFeedback(); | |
| 5178 } | |
| 5179 | |
| 5180 void GLES2DecoderImpl::DoPauseTransformFeedback() { | |
| 5181 DCHECK(state_.bound_transform_feedback.get()); | |
| 5182 if (!state_.bound_transform_feedback->active() || | |
| 5183 state_.bound_transform_feedback->paused()) { | |
| 5184 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glPauseTransformFeedback", | |
| 5185 "transform feedback is not active or already paused"); | |
| 5186 return; | |
| 5187 } | |
| 5188 state_.bound_transform_feedback->DoPauseTransformFeedback(); | |
| 5189 } | |
| 5190 | |
| 5191 void GLES2DecoderImpl::DoResumeTransformFeedback() { | |
| 5192 DCHECK(state_.bound_transform_feedback.get()); | |
| 5193 if (!state_.bound_transform_feedback->active() || | |
| 5194 !state_.bound_transform_feedback->paused()) { | |
| 5195 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glResumeTransformFeedback", | |
| 5196 "transform feedback is not active or not paused"); | |
| 5197 return; | |
| 5198 } | |
| 5199 state_.bound_transform_feedback->DoResumeTransformFeedback(); | |
| 5200 } | |
| 5201 | |
| 5013 void GLES2DecoderImpl::DoDisableVertexAttribArray(GLuint index) { | 5202 void GLES2DecoderImpl::DoDisableVertexAttribArray(GLuint index) { |
| 5014 if (state_.vertex_attrib_manager->Enable(index, false)) { | 5203 if (state_.vertex_attrib_manager->Enable(index, false)) { |
| 5015 if (index != 0 || feature_info_->gl_version_info().BehavesLikeGLES()) { | 5204 if (index != 0 || feature_info_->gl_version_info().BehavesLikeGLES()) { |
| 5016 glDisableVertexAttribArray(index); | 5205 glDisableVertexAttribArray(index); |
| 5017 } | 5206 } |
| 5018 } else { | 5207 } else { |
| 5019 LOCAL_SET_GL_ERROR( | 5208 LOCAL_SET_GL_ERROR( |
| 5020 GL_INVALID_VALUE, | 5209 GL_INVALID_VALUE, |
| 5021 "glDisableVertexAttribArray", "index out of range"); | 5210 "glDisableVertexAttribArray", "index out of range"); |
| 5022 } | 5211 } |
| (...skipping 3680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8703 bool GLES2DecoderImpl::DoIsTexture(GLuint client_id) { | 8892 bool GLES2DecoderImpl::DoIsTexture(GLuint client_id) { |
| 8704 const TextureRef* texture_ref = GetTexture(client_id); | 8893 const TextureRef* texture_ref = GetTexture(client_id); |
| 8705 return texture_ref && texture_ref->texture()->IsValid(); | 8894 return texture_ref && texture_ref->texture()->IsValid(); |
| 8706 } | 8895 } |
| 8707 | 8896 |
| 8708 bool GLES2DecoderImpl::DoIsSampler(GLuint client_id) { | 8897 bool GLES2DecoderImpl::DoIsSampler(GLuint client_id) { |
| 8709 const Sampler* sampler = GetSampler(client_id); | 8898 const Sampler* sampler = GetSampler(client_id); |
| 8710 return sampler && !sampler->IsDeleted(); | 8899 return sampler && !sampler->IsDeleted(); |
| 8711 } | 8900 } |
| 8712 | 8901 |
| 8902 bool GLES2DecoderImpl::DoIsTransformFeedback(GLuint client_id) { | |
| 8903 const TransformFeedback* transform_feedback = | |
| 8904 GetTransformFeedback(client_id); | |
| 8905 return transform_feedback && !transform_feedback->deleted(); | |
|
piman
2016/04/28 01:38:47
Also, technically, IsTransformFeedback should only
piman
2016/04/28 01:38:47
nit: same as above, I don't think deleted() is pos
Zhenyao Mo
2016/04/29 21:07:54
Done.
Zhenyao Mo
2016/04/29 21:07:54
Done.
| |
| 8906 } | |
| 8907 | |
| 8713 void GLES2DecoderImpl::DoAttachShader( | 8908 void GLES2DecoderImpl::DoAttachShader( |
| 8714 GLuint program_client_id, GLint shader_client_id) { | 8909 GLuint program_client_id, GLint shader_client_id) { |
| 8715 Program* program = GetProgramInfoNotShader( | 8910 Program* program = GetProgramInfoNotShader( |
| 8716 program_client_id, "glAttachShader"); | 8911 program_client_id, "glAttachShader"); |
| 8717 if (!program) { | 8912 if (!program) { |
| 8718 return; | 8913 return; |
| 8719 } | 8914 } |
| 8720 Shader* shader = GetShaderInfoNotProgram(shader_client_id, "glAttachShader"); | 8915 Shader* shader = GetShaderInfoNotProgram(shader_client_id, "glAttachShader"); |
| 8721 if (!shader) { | 8916 if (!shader) { |
| 8722 return; | 8917 return; |
| (...skipping 7634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 16357 } | 16552 } |
| 16358 | 16553 |
| 16359 // Include the auto-generated part of this file. We split this because it means | 16554 // Include the auto-generated part of this file. We split this because it means |
| 16360 // we can easily edit the non-auto generated parts right here in this file | 16555 // we can easily edit the non-auto generated parts right here in this file |
| 16361 // instead of having to edit some template or the code generator. | 16556 // instead of having to edit some template or the code generator. |
| 16362 #include "base/macros.h" | 16557 #include "base/macros.h" |
| 16363 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 16558 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 16364 | 16559 |
| 16365 } // namespace gles2 | 16560 } // namespace gles2 |
| 16366 } // namespace gpu | 16561 } // namespace gpu |
| OLD | NEW |