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

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

Issue 659903002: Add subscribeUniform extension pipeline (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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>
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 #include "gpu/command_buffer/service/image_manager.h" 49 #include "gpu/command_buffer/service/image_manager.h"
50 #include "gpu/command_buffer/service/mailbox_manager.h" 50 #include "gpu/command_buffer/service/mailbox_manager.h"
51 #include "gpu/command_buffer/service/memory_tracking.h" 51 #include "gpu/command_buffer/service/memory_tracking.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/shader_manager.h" 55 #include "gpu/command_buffer/service/shader_manager.h"
56 #include "gpu/command_buffer/service/shader_translator.h" 56 #include "gpu/command_buffer/service/shader_translator.h"
57 #include "gpu/command_buffer/service/shader_translator_cache.h" 57 #include "gpu/command_buffer/service/shader_translator_cache.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/uniform_subscription_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/gl/gl_fence.h" 63 #include "ui/gl/gl_fence.h"
63 #include "ui/gl/gl_image.h" 64 #include "ui/gl/gl_image.h"
64 #include "ui/gl/gl_implementation.h" 65 #include "ui/gl/gl_implementation.h"
65 #include "ui/gl/gl_surface.h" 66 #include "ui/gl/gl_surface.h"
66 67
67 #if defined(OS_MACOSX) 68 #if defined(OS_MACOSX)
68 #include <IOSurface/IOSurfaceAPI.h> 69 #include <IOSurface/IOSurfaceAPI.h>
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 TextureManager* texture_manager() { 790 TextureManager* texture_manager() {
790 return group_->texture_manager(); 791 return group_->texture_manager();
791 } 792 }
792 793
793 MailboxManager* mailbox_manager() { 794 MailboxManager* mailbox_manager() {
794 return group_->mailbox_manager(); 795 return group_->mailbox_manager();
795 } 796 }
796 797
797 ImageManager* image_manager() { return image_manager_.get(); } 798 ImageManager* image_manager() { return image_manager_.get(); }
798 799
800 UniformSubscriptionManager* uniform_subscription_manager() {
801 return uniform_subscription_manager_.get();
802 }
803
804 // Populate uniforms the program is currently subscribed too
805 void PopulateUniformSubscriptions();
piman 2014/10/16 02:39:18 When is this called?
orglofch 2014/10/21 04:19:38 It wasn't it was meant as a placeholder. Updated i
806
799 VertexArrayManager* vertex_array_manager() { 807 VertexArrayManager* vertex_array_manager() {
800 return vertex_array_manager_.get(); 808 return vertex_array_manager_.get();
801 } 809 }
802 810
803 MemoryTracker* memory_tracker() { 811 MemoryTracker* memory_tracker() {
804 return group_->memory_tracker(); 812 return group_->memory_tracker();
805 } 813 }
806 814
807 bool EnsureGPUMemoryAvailable(size_t estimated_size) { 815 bool EnsureGPUMemoryAvailable(size_t estimated_size) {
808 MemoryTracker* tracker = memory_tracker(); 816 MemoryTracker* tracker = memory_tracker();
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 void DoProduceTextureCHROMIUM(GLenum target, const GLbyte* key); 959 void DoProduceTextureCHROMIUM(GLenum target, const GLbyte* key);
952 void DoProduceTextureDirectCHROMIUM(GLuint texture, GLenum target, 960 void DoProduceTextureDirectCHROMIUM(GLuint texture, GLenum target,
953 const GLbyte* key); 961 const GLbyte* key);
954 void ProduceTextureRef(std::string func_name, TextureRef* texture_ref, 962 void ProduceTextureRef(std::string func_name, TextureRef* texture_ref,
955 GLenum target, const GLbyte* data); 963 GLenum target, const GLbyte* data);
956 964
957 void DoConsumeTextureCHROMIUM(GLenum target, const GLbyte* key); 965 void DoConsumeTextureCHROMIUM(GLenum target, const GLbyte* key);
958 void DoCreateAndConsumeTextureCHROMIUM(GLenum target, const GLbyte* key, 966 void DoCreateAndConsumeTextureCHROMIUM(GLenum target, const GLbyte* key,
959 GLuint client_id); 967 GLuint client_id);
960 968
969 void DoSubscribeUniformCHROMIUM(GLenum target, const GLchar* name);
970
961 void DoBindTexImage2DCHROMIUM( 971 void DoBindTexImage2DCHROMIUM(
962 GLenum target, 972 GLenum target,
963 GLint image_id); 973 GLint image_id);
964 void DoReleaseTexImage2DCHROMIUM( 974 void DoReleaseTexImage2DCHROMIUM(
965 GLenum target, 975 GLenum target,
966 GLint image_id); 976 GLint image_id);
967 977
968 void DoTraceEndCHROMIUM(void); 978 void DoTraceEndCHROMIUM(void);
969 979
970 void DoDrawBuffersEXT(GLsizei count, const GLenum* bufs); 980 void DoDrawBuffersEXT(GLsizei count, const GLenum* bufs);
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after
1720 scoped_ptr<BackFramebuffer> offscreen_resolved_frame_buffer_; 1730 scoped_ptr<BackFramebuffer> offscreen_resolved_frame_buffer_;
1721 scoped_ptr<BackTexture> offscreen_resolved_color_texture_; 1731 scoped_ptr<BackTexture> offscreen_resolved_color_texture_;
1722 GLenum offscreen_saved_color_format_; 1732 GLenum offscreen_saved_color_format_;
1723 1733
1724 scoped_ptr<QueryManager> query_manager_; 1734 scoped_ptr<QueryManager> query_manager_;
1725 1735
1726 scoped_ptr<VertexArrayManager> vertex_array_manager_; 1736 scoped_ptr<VertexArrayManager> vertex_array_manager_;
1727 1737
1728 scoped_ptr<ImageManager> image_manager_; 1738 scoped_ptr<ImageManager> image_manager_;
1729 1739
1740 scoped_ptr<UniformSubscriptionManager> uniform_subscription_manager_;
1741
1730 base::Callback<void(gfx::Size, float)> resize_callback_; 1742 base::Callback<void(gfx::Size, float)> resize_callback_;
1731 1743
1732 WaitSyncPointCallback wait_sync_point_callback_; 1744 WaitSyncPointCallback wait_sync_point_callback_;
1733 1745
1734 ShaderCacheCallback shader_cache_callback_; 1746 ShaderCacheCallback shader_cache_callback_;
1735 1747
1736 scoped_ptr<AsyncPixelTransferManager> async_pixel_transfer_manager_; 1748 scoped_ptr<AsyncPixelTransferManager> async_pixel_transfer_manager_;
1737 1749
1738 // The format of the back buffer_ 1750 // The format of the back buffer_
1739 GLenum back_buffer_color_format_; 1751 GLenum back_buffer_color_format_;
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
2433 group_->max_vertex_attribs(), 2445 group_->max_vertex_attribs(),
2434 feature_info_->workarounds().init_vertex_attributes); 2446 feature_info_->workarounds().init_vertex_attributes);
2435 2447
2436 // vertex_attrib_manager is set to default_vertex_attrib_manager by this call 2448 // vertex_attrib_manager is set to default_vertex_attrib_manager by this call
2437 DoBindVertexArrayOES(0); 2449 DoBindVertexArrayOES(0);
2438 2450
2439 query_manager_.reset(new QueryManager(this, feature_info_.get())); 2451 query_manager_.reset(new QueryManager(this, feature_info_.get()));
2440 2452
2441 image_manager_.reset(new ImageManager); 2453 image_manager_.reset(new ImageManager);
2442 2454
2455 uniform_subscription_manager_.reset(new UniformSubscriptionManager);
2456
2443 util_.set_num_compressed_texture_formats( 2457 util_.set_num_compressed_texture_formats(
2444 validators_->compressed_texture_format.GetValues().size()); 2458 validators_->compressed_texture_format.GetValues().size());
2445 2459
2446 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { 2460 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) {
2447 // We have to enable vertex array 0 on OpenGL or it won't render. Note that 2461 // We have to enable vertex array 0 on OpenGL or it won't render. Note that
2448 // OpenGL ES 2.0 does not have this issue. 2462 // OpenGL ES 2.0 does not have this issue.
2449 glEnableVertexAttribArray(0); 2463 glEnableVertexAttribArray(0);
2450 } 2464 }
2451 glGenBuffersARB(1, &attrib_0_buffer_id_); 2465 glGenBuffersARB(1, &attrib_0_buffer_id_);
2452 glBindBuffer(GL_ARRAY_BUFFER, attrib_0_buffer_id_); 2466 glBindBuffer(GL_ARRAY_BUFFER, attrib_0_buffer_id_);
(...skipping 1073 matching lines...) Expand 10 before | Expand all | Expand 10 after
3526 if (vertex_array_manager_ .get()) { 3540 if (vertex_array_manager_ .get()) {
3527 vertex_array_manager_->Destroy(have_context); 3541 vertex_array_manager_->Destroy(have_context);
3528 vertex_array_manager_.reset(); 3542 vertex_array_manager_.reset();
3529 } 3543 }
3530 3544
3531 if (image_manager_.get()) { 3545 if (image_manager_.get()) {
3532 image_manager_->Destroy(have_context); 3546 image_manager_->Destroy(have_context);
3533 image_manager_.reset(); 3547 image_manager_.reset();
3534 } 3548 }
3535 3549
3550 if (uniform_subscription_manager_.get()) {
3551 uniform_subscription_manager_->Destroy(have_context);
3552 uniform_subscription_manager_.reset();
3553 }
3554
3536 offscreen_target_frame_buffer_.reset(); 3555 offscreen_target_frame_buffer_.reset();
3537 offscreen_target_color_texture_.reset(); 3556 offscreen_target_color_texture_.reset();
3538 offscreen_target_color_render_buffer_.reset(); 3557 offscreen_target_color_render_buffer_.reset();
3539 offscreen_target_depth_render_buffer_.reset(); 3558 offscreen_target_depth_render_buffer_.reset();
3540 offscreen_target_stencil_render_buffer_.reset(); 3559 offscreen_target_stencil_render_buffer_.reset();
3541 offscreen_saved_frame_buffer_.reset(); 3560 offscreen_saved_frame_buffer_.reset();
3542 offscreen_saved_color_texture_.reset(); 3561 offscreen_saved_color_texture_.reset();
3543 offscreen_resolved_frame_buffer_.reset(); 3562 offscreen_resolved_frame_buffer_.reset();
3544 offscreen_resolved_color_texture_.reset(); 3563 offscreen_resolved_color_texture_.reset();
3545 3564
(...skipping 5760 matching lines...) Expand 10 before | Expand all | Expand 10 after
9306 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glShaderBinary", "unknown shader"); 9325 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glShaderBinary", "unknown shader");
9307 return error::kNoError; 9326 return error::kNoError;
9308 } 9327 }
9309 service_ids[ii] = shader->service_id(); 9328 service_ids[ii] = shader->service_id();
9310 } 9329 }
9311 // TODO(gman): call glShaderBinary 9330 // TODO(gman): call glShaderBinary
9312 return error::kNoError; 9331 return error::kNoError;
9313 #endif 9332 #endif
9314 } 9333 }
9315 9334
9335 void GLES2DecoderImpl::PopulateUniformSubscriptions() {
9336 const UniformSubscriptionManager::SubscriptionMap& subscriptions =
9337 uniform_subscription_manager()->subscriptions();
9338 for (UniformSubscriptionManager::SubscriptionMap::const_iterator it =
9339 subscriptions.begin();
9340 it != subscriptions.end();
9341 ++it) {
9342 if (state_.current_program.get()) {
piman 2014/10/16 02:39:18 This is a loop invariant. Early out instead?
orglofch 2014/10/21 04:19:38 Acknowledged. No longer in the API.
9343 GLint location =
9344 state_.current_program.get()->GetUniformFakeLocation(it->second);
piman 2014/10/16 02:39:18 This seems pretty costly to do string parsing and
orglofch 2014/10/21 04:19:38 Acknowledged. No longer in the API.
9345 if (location != -1) {
9346 // TODO(orglofch): Populate uniform based on it->first type
9347 }
9348 }
9349 }
9350 }
9351
9316 void GLES2DecoderImpl::DoSwapBuffers() { 9352 void GLES2DecoderImpl::DoSwapBuffers() {
9317 bool is_offscreen = !!offscreen_target_frame_buffer_.get(); 9353 bool is_offscreen = !!offscreen_target_frame_buffer_.get();
9318 9354
9319 int this_frame_number = frame_number_++; 9355 int this_frame_number = frame_number_++;
9320 // TRACE_EVENT for gpu tests: 9356 // TRACE_EVENT for gpu tests:
9321 TRACE_EVENT_INSTANT2("test_gpu", "SwapBuffersLatency", 9357 TRACE_EVENT_INSTANT2("test_gpu", "SwapBuffersLatency",
9322 TRACE_EVENT_SCOPE_THREAD, 9358 TRACE_EVENT_SCOPE_THREAD,
9323 "GLImpl", static_cast<int>(gfx::GetGLImplementation()), 9359 "GLImpl", static_cast<int>(gfx::GetGLImplementation()),
9324 "width", (is_offscreen ? offscreen_size_.width() : 9360 "width", (is_offscreen ? offscreen_size_.width() :
9325 surface_->GetSize().width())); 9361 surface_->GetSize().width()));
(...skipping 1301 matching lines...) Expand 10 before | Expand all | Expand 10 after
10627 if (texture->target() != target) { 10663 if (texture->target() != target) {
10628 LOCAL_SET_GL_ERROR( 10664 LOCAL_SET_GL_ERROR(
10629 GL_INVALID_OPERATION, 10665 GL_INVALID_OPERATION,
10630 "glCreateAndConsumeTextureCHROMIUM", "invalid target"); 10666 "glCreateAndConsumeTextureCHROMIUM", "invalid target");
10631 return; 10667 return;
10632 } 10668 }
10633 10669
10634 texture_ref = texture_manager()->Consume(client_id, texture); 10670 texture_ref = texture_manager()->Consume(client_id, texture);
10635 } 10671 }
10636 10672
10673 error::Error GLES2DecoderImpl::HandleSubscribeUniformCHROMIUM(
10674 uint32_t immediate_data_size,
10675 const void* cmd_data) {
10676 const gles2::cmds::SubscribeUniformCHROMIUM& c =
10677 *static_cast<const gles2::cmds::SubscribeUniformCHROMIUM*>(cmd_data);
10678 GLenum target = static_cast<GLenum>(c.target);
piman 2014/10/16 02:39:18 Where do we validate target against valid values?
orglofch 2014/10/21 04:19:38 Done. Added to build_gles2_cmd_buffer.py.
10679 Bucket* bucket = GetBucket(c.bucket_id);
10680 if (!bucket || bucket->size() == 0) {
10681 return error::kInvalidArguments;
10682 }
10683 std::string name_str;
10684 if (!bucket->GetAsString(&name_str)) {
10685 return error::kInvalidArguments;
10686 }
10687 DoSubscribeUniformCHROMIUM(target, name_str.c_str());
10688 return error::kNoError;
10689 }
10690
10691 void GLES2DecoderImpl::DoSubscribeUniformCHROMIUM(GLenum target,
10692 const GLchar* name) {
10693 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoSubscribeUniformCHROMIUM");
10694 uniform_subscription_manager()->AddSubscription(target, name);
piman 2014/10/16 02:39:18 How do you remove entries?
orglofch 2014/10/21 04:19:38 There is no method for removing entries, is there
piman 2014/10/21 20:00:40 In the previous API, the entries were not linked t
orglofch 2014/10/22 23:10:21 Done. I've added an unsubscribe call to API.
10695 }
10696
10637 void GLES2DecoderImpl::DoInsertEventMarkerEXT( 10697 void GLES2DecoderImpl::DoInsertEventMarkerEXT(
10638 GLsizei length, const GLchar* marker) { 10698 GLsizei length, const GLchar* marker) {
10639 if (!marker) { 10699 if (!marker) {
10640 marker = ""; 10700 marker = "";
10641 } 10701 }
10642 debug_marker_manager_.SetMarker( 10702 debug_marker_manager_.SetMarker(
10643 length ? std::string(marker, length) : std::string(marker)); 10703 length ? std::string(marker, length) : std::string(marker));
10644 } 10704 }
10645 10705
10646 void GLES2DecoderImpl::DoPushGroupMarkerEXT( 10706 void GLES2DecoderImpl::DoPushGroupMarkerEXT(
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
11189 } 11249 }
11190 } 11250 }
11191 11251
11192 // Include the auto-generated part of this file. We split this because it means 11252 // Include the auto-generated part of this file. We split this because it means
11193 // we can easily edit the non-auto generated parts right here in this file 11253 // we can easily edit the non-auto generated parts right here in this file
11194 // instead of having to edit some template or the code generator. 11254 // instead of having to edit some template or the code generator.
11195 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 11255 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
11196 11256
11197 } // namespace gles2 11257 } // namespace gles2
11198 } // namespace gpu 11258 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698