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

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

Issue 11275120: Virtual GL (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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 | Annotate | Revision Log
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/vertex_attrib_manager.h" 5 #include "gpu/command_buffer/service/vertex_attrib_manager.h"
6 6
7 #include <list> 7 #include <list>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 } 56 }
57 57
58 uint32 usable_size = buffer_size - offset_; 58 uint32 usable_size = buffer_size - offset_;
59 GLuint num_elements = usable_size / real_stride_ + 59 GLuint num_elements = usable_size / real_stride_ +
60 ((usable_size % real_stride_) >= 60 ((usable_size % real_stride_) >=
61 (GLES2Util::GetGLTypeSizeForTexturesAndBuffers(type_) * size_) ? 1 : 0); 61 (GLES2Util::GetGLTypeSizeForTexturesAndBuffers(type_) * size_) ? 1 : 0);
62 return index < num_elements; 62 return index < num_elements;
63 } 63 }
64 64
65 VertexAttribManager::VertexAttribManager() 65 VertexAttribManager::VertexAttribManager()
66 : max_vertex_attribs_(0), 66 : num_fixed_attribs_(0),
67 num_fixed_attribs_(0),
68 element_array_buffer_(NULL), 67 element_array_buffer_(NULL),
69 manager_(NULL), 68 manager_(NULL),
70 deleted_(false), 69 deleted_(false),
71 service_id_(0) { 70 service_id_(0) {
72 } 71 }
73 72
74 VertexAttribManager::VertexAttribManager( 73 VertexAttribManager::VertexAttribManager(
75 VertexArrayManager* manager, GLuint service_id, uint32 num_vertex_attribs) 74 VertexArrayManager* manager, GLuint service_id, uint32 num_vertex_attribs)
76 : max_vertex_attribs_(0), 75 : num_fixed_attribs_(0),
77 num_fixed_attribs_(0),
78 element_array_buffer_(NULL), 76 element_array_buffer_(NULL),
79 manager_(manager), 77 manager_(manager),
80 deleted_(false), 78 deleted_(false),
81 service_id_(service_id) { 79 service_id_(service_id) {
82 manager_->StartTracking(this); 80 manager_->StartTracking(this);
83 Initialize(num_vertex_attribs, false); 81 Initialize(num_vertex_attribs, false);
84 } 82 }
85 83
86 VertexAttribManager::~VertexAttribManager() { 84 VertexAttribManager::~VertexAttribManager() {
87 if (manager_) { 85 if (manager_) {
88 if (manager_->have_context_) { 86 if (manager_->have_context_) {
89 if (service_id_ != 0) // 0 indicates an emulated VAO 87 if (service_id_ != 0) // 0 indicates an emulated VAO
90 glDeleteVertexArraysOES(1, &service_id_); 88 glDeleteVertexArraysOES(1, &service_id_);
91 } 89 }
92 manager_->StopTracking(this); 90 manager_->StopTracking(this);
93 manager_ = NULL; 91 manager_ = NULL;
94 } 92 }
95 } 93 }
96 94
97 void VertexAttribManager::Initialize( 95 void VertexAttribManager::Initialize(
98 uint32 max_vertex_attribs, bool init_attribs) { 96 uint32 max_vertex_attribs, bool init_attribs) {
99 max_vertex_attribs_ = max_vertex_attribs; 97 vertex_attrib_infos_.resize(max_vertex_attribs);
100 vertex_attrib_infos_.reset(
101 new VertexAttribInfo[max_vertex_attribs]);
102 bool disable_workarounds = CommandLine::ForCurrentProcess()->HasSwitch( 98 bool disable_workarounds = CommandLine::ForCurrentProcess()->HasSwitch(
103 switches::kDisableGpuDriverBugWorkarounds); 99 switches::kDisableGpuDriverBugWorkarounds);
104 100
105 for (uint32 vv = 0; vv < max_vertex_attribs; ++vv) { 101 for (uint32 vv = 0; vv < vertex_attrib_infos_.size(); ++vv) {
106 vertex_attrib_infos_[vv].set_index(vv); 102 vertex_attrib_infos_[vv].set_index(vv);
107 vertex_attrib_infos_[vv].SetList(&disabled_vertex_attribs_); 103 vertex_attrib_infos_[vv].SetList(&disabled_vertex_attribs_);
108 104
109 if (!disable_workarounds && init_attribs) { 105 if (!disable_workarounds && init_attribs) {
110 glVertexAttrib4f(vv, 0.0f, 0.0f, 0.0f, 1.0f); 106 glVertexAttrib4f(vv, 0.0f, 0.0f, 0.0f, 1.0f);
111 } 107 }
112 } 108 }
113 } 109 }
114 110
115 bool VertexAttribManager::Enable(GLuint index, bool enable) { 111 bool VertexAttribManager::Enable(GLuint index, bool enable) {
116 if (index >= max_vertex_attribs_) { 112 if (index >= vertex_attrib_infos_.size()) {
117 return false; 113 return false;
118 } 114 }
119 VertexAttribInfo& info = vertex_attrib_infos_[index]; 115 VertexAttribInfo& info = vertex_attrib_infos_[index];
120 if (info.enabled() != enable) { 116 if (info.enabled() != enable) {
121 info.set_enabled(enable); 117 info.set_enabled(enable);
122 info.SetList(enable ? &enabled_vertex_attribs_ : &disabled_vertex_attribs_); 118 info.SetList(enable ? &enabled_vertex_attribs_ : &disabled_vertex_attribs_);
123 } 119 }
124 return true; 120 return true;
125 } 121 }
126 122
127 void VertexAttribManager::Unbind(BufferManager::BufferInfo* buffer) { 123 void VertexAttribManager::Unbind(BufferManager::BufferInfo* buffer) {
128 if (element_array_buffer_ == buffer) { 124 if (element_array_buffer_ == buffer) {
129 element_array_buffer_ = NULL; 125 element_array_buffer_ = NULL;
130 } 126 }
131 for (uint32 vv = 0; vv < max_vertex_attribs_; ++vv) { 127 for (uint32 vv = 0; vv < vertex_attrib_infos_.size(); ++vv) {
132 vertex_attrib_infos_[vv].Unbind(buffer); 128 vertex_attrib_infos_[vv].Unbind(buffer);
133 } 129 }
134 } 130 }
135 131
136 } // namespace gles2 132 } // namespace gles2
137 } // namespace gpu 133 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698