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

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

Issue 1136713003: Add ES3 commands GetVertexAttribI{u}iv to GPU command buffer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use overloading functions instead of template Created 5 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/context_state.h" 5 #include "gpu/command_buffer/service/context_state.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "gpu/command_buffer/common/gles2_cmd_utils.h" 9 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
10 #include "gpu/command_buffer/service/buffer_manager.h" 10 #include "gpu/command_buffer/service/buffer_manager.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 74
75 } // anonymous namespace. 75 } // anonymous namespace.
76 76
77 TextureUnit::TextureUnit() 77 TextureUnit::TextureUnit()
78 : bind_target(GL_TEXTURE_2D) { 78 : bind_target(GL_TEXTURE_2D) {
79 } 79 }
80 80
81 TextureUnit::~TextureUnit() { 81 TextureUnit::~TextureUnit() {
82 } 82 }
83 83
84 bool Vec4::Equal(const Vec4& other) const {
85 if (type_ != other.type_)
86 return false;
87 switch (type_) {
88 case kFloat:
89 for (size_t ii = 0; ii < 4; ++ii) {
90 if (v_[ii].float_value != other.v_[ii].float_value)
91 return false;
92 }
93 break;
94 case kInt:
95 for (size_t ii = 0; ii < 4; ++ii) {
96 if (v_[ii].int_value != other.v_[ii].int_value)
97 return false;
98 }
99 break;
100 case kUInt:
101 for (size_t ii = 0; ii < 4; ++ii) {
102 if (v_[ii].uint_value != other.v_[ii].uint_value)
103 return false;
104 }
105 break;
106 }
107 return true;
108 }
109
110 void Vec4::GetValues(GLfloat* values) const {
111 DCHECK(values);
112 switch (type_) {
113 case kFloat:
114 for (size_t ii = 0; ii < 4; ++ii)
115 values[ii] = v_[ii].float_value;
116 break;
117 case kInt:
118 for (size_t ii = 0; ii < 4; ++ii)
119 values[ii] = static_cast<GLfloat>(v_[ii].int_value);
120 break;
121 case kUInt:
122 for (size_t ii = 0; ii < 4; ++ii)
123 values[ii] = static_cast<GLfloat>(v_[ii].uint_value);
124 break;
125 }
126 }
127
128 void Vec4::GetValues(GLint* values) const {
129 DCHECK(values);
130 switch (type_) {
131 case kFloat:
132 for (size_t ii = 0; ii < 4; ++ii)
133 values[ii] = static_cast<GLint>(v_[ii].float_value);
134 break;
135 case kInt:
136 for (size_t ii = 0; ii < 4; ++ii)
137 values[ii] = v_[ii].int_value;
138 break;
139 case kUInt:
140 for (size_t ii = 0; ii < 4; ++ii)
141 values[ii] = static_cast<GLint>(v_[ii].uint_value);
142 break;
143 }
144 }
145
146 void Vec4::GetValues(GLuint* values) const {
147 DCHECK(values);
148 switch (type_) {
149 case kFloat:
150 for (size_t ii = 0; ii < 4; ++ii)
151 values[ii] = static_cast<GLuint>(v_[ii].float_value);
152 break;
153 case kInt:
154 for (size_t ii = 0; ii < 4; ++ii)
155 values[ii] = static_cast<GLuint>(v_[ii].int_value);
156 break;
157 case kUInt:
158 for (size_t ii = 0; ii < 4; ++ii)
159 values[ii] = v_[ii].uint_value;
160 break;
161 }
162 }
163
164 void Vec4::SetValues(const GLfloat* values) {
165 DCHECK(values);
166 for (size_t ii = 0; ii < 4; ++ii)
167 v_[ii].float_value = values[ii];
168 type_ = kFloat;
169 }
170
171 void Vec4::SetValues(const GLint* values) {
172 DCHECK(values);
173 for (size_t ii = 0; ii < 4; ++ii)
174 v_[ii].int_value = values[ii];
175 type_ = kInt;
176 }
177
178 void Vec4::SetValues(const GLuint* values) {
179 DCHECK(values);
180 for (size_t ii = 0; ii < 4; ++ii)
181 v_[ii].uint_value = values[ii];
182 type_ = kUInt;
183 }
184
84 ContextState::ContextState(FeatureInfo* feature_info, 185 ContextState::ContextState(FeatureInfo* feature_info,
85 ErrorStateClient* error_state_client, 186 ErrorStateClient* error_state_client,
86 Logger* logger) 187 Logger* logger)
87 : active_texture_unit(0), 188 : active_texture_unit(0),
88 bound_renderbuffer_valid(false), 189 bound_renderbuffer_valid(false),
89 pack_reverse_row_order(false), 190 pack_reverse_row_order(false),
90 ignore_cached_state(false), 191 ignore_cached_state(false),
91 fbo_binding_for_scissor_workaround_dirty(false), 192 fbo_binding_for_scissor_workaround_dirty(false),
92 feature_info_(feature_info), 193 feature_info_(feature_info),
93 error_state_(ErrorState::Create(error_state_client, logger)) { 194 error_state_(ErrorState::Create(error_state_client, logger)) {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 void ContextState::RestoreActiveTextureUnitBinding(unsigned int target) const { 279 void ContextState::RestoreActiveTextureUnitBinding(unsigned int target) const {
179 DCHECK_LT(active_texture_unit, texture_units.size()); 280 DCHECK_LT(active_texture_unit, texture_units.size());
180 const TextureUnit& texture_unit = texture_units[active_texture_unit]; 281 const TextureUnit& texture_unit = texture_units[active_texture_unit];
181 if (TargetIsSupported(feature_info_, target)) 282 if (TargetIsSupported(feature_info_, target))
182 glBindTexture(target, GetServiceId(texture_unit, target)); 283 glBindTexture(target, GetServiceId(texture_unit, target));
183 } 284 }
184 285
185 void ContextState::RestoreVertexAttribValues() const { 286 void ContextState::RestoreVertexAttribValues() const {
186 for (size_t attrib = 0; attrib < vertex_attrib_manager->num_attribs(); 287 for (size_t attrib = 0; attrib < vertex_attrib_manager->num_attribs();
187 ++attrib) { 288 ++attrib) {
188 glVertexAttrib4fv(attrib, attrib_values[attrib].v); 289 switch (attrib_values[attrib].type()) {
290 case Vec4::kFloat:
291 {
292 GLfloat v[4];
293 attrib_values[attrib].GetValues(v);
294 glVertexAttrib4fv(attrib, v);
295 }
296 break;
297 case Vec4::kInt:
298 {
299 GLint v[4];
300 attrib_values[attrib].GetValues(v);
301 glVertexAttribI4iv(attrib, v);
302 }
303 break;
304 case Vec4::kUInt:
305 {
306 GLuint v[4];
307 attrib_values[attrib].GetValues(v);
308 glVertexAttribI4uiv(attrib, v);
309 }
310 break;
311 }
189 } 312 }
190 } 313 }
191 314
192 void ContextState::RestoreVertexAttribArrays( 315 void ContextState::RestoreVertexAttribArrays(
193 const scoped_refptr<VertexAttribManager> attrib_manager) const { 316 const scoped_refptr<VertexAttribManager> attrib_manager) const {
194 // This is expected to be called only for VAO with service_id 0, 317 // This is expected to be called only for VAO with service_id 0,
195 // either to restore the default VAO or a virtual VAO with service_id 0. 318 // either to restore the default VAO or a virtual VAO with service_id 0.
196 GLuint vao_service_id = attrib_manager->service_id(); 319 GLuint vao_service_id = attrib_manager->service_id();
197 DCHECK(vao_service_id == 0); 320 DCHECK(vao_service_id == 0);
198 321
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 420
298 // Include the auto-generated part of this file. We split this because it means 421 // Include the auto-generated part of this file. We split this because it means
299 // we can easily edit the non-auto generated parts right here in this file 422 // we can easily edit the non-auto generated parts right here in this file
300 // instead of having to edit some template or the code generator. 423 // instead of having to edit some template or the code generator.
301 #include "gpu/command_buffer/service/context_state_impl_autogen.h" 424 #include "gpu/command_buffer/service/context_state_impl_autogen.h"
302 425
303 } // namespace gles2 426 } // namespace gles2
304 } // namespace gpu 427 } // namespace gpu
305 428
306 429
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698