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 // This file contains the ContextState class. | 5 // This file contains the ContextState class. |
6 | 6 |
7 #ifndef GPU_COMMAND_BUFFER_SERVICE_CONTEXT_STATE_H_ | 7 #ifndef GPU_COMMAND_BUFFER_SERVICE_CONTEXT_STATE_H_ |
8 #define GPU_COMMAND_BUFFER_SERVICE_CONTEXT_STATE_H_ | 8 #define GPU_COMMAND_BUFFER_SERVICE_CONTEXT_STATE_H_ |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 return; | 236 return; |
237 } | 237 } |
238 glStencilMaskSeparate(op, mask); | 238 glStencilMaskSeparate(op, mask); |
239 } | 239 } |
240 | 240 |
241 ErrorState* GetErrorState(); | 241 ErrorState* GetErrorState(); |
242 | 242 |
243 void SetBoundBuffer(GLenum target, Buffer* buffer); | 243 void SetBoundBuffer(GLenum target, Buffer* buffer); |
244 void RemoveBoundBuffer(Buffer* buffer); | 244 void RemoveBoundBuffer(Buffer* buffer); |
245 | 245 |
246 void InitGenericAttribBaseType(GLuint max_vertex_attribs) { | 246 void InitGenericAttribs(GLuint max_vertex_attribs) { |
247 max_vertex_attribs_ = max_vertex_attribs; | 247 attrib_values.resize(max_vertex_attribs); |
248 | 248 |
249 uint32_t packed_size = max_vertex_attribs_ / 16; | 249 uint32_t packed_size = max_vertex_attribs / 16; |
250 packed_size += (max_vertex_attribs_ % 16 == 0) ? 0 : 1; | 250 packed_size += (max_vertex_attribs % 16 == 0) ? 0 : 1; |
251 generic_attrib_base_type_mask_.resize(packed_size); | 251 generic_attrib_base_type_mask_.resize(packed_size); |
252 for (uint32_t i = 0; i < packed_size; ++i) { | 252 for (uint32_t i = 0; i < packed_size; ++i) { |
253 // All generic attribs are float type by default. | 253 // All generic attribs are float type by default. |
254 generic_attrib_base_type_mask_[i] = 0x55555555u * SHADER_VARIABLE_FLOAT; | 254 generic_attrib_base_type_mask_[i] = 0x55555555u * SHADER_VARIABLE_FLOAT; |
255 } | 255 } |
256 } | 256 } |
257 | 257 |
258 void SetGenericVertexAttribBaseType(GLuint index, GLenum base_type) { | 258 void SetGenericVertexAttribBaseType(GLuint index, GLenum base_type) { |
259 DCHECK(index < max_vertex_attribs_); | 259 DCHECK_LT(index, attrib_values.size()); |
260 int shift_bits = (index % 16) * 2; | 260 int shift_bits = (index % 16) * 2; |
261 generic_attrib_base_type_mask_[index / 16] &= ~(0x3 << shift_bits); | 261 generic_attrib_base_type_mask_[index / 16] &= ~(0x3 << shift_bits); |
262 generic_attrib_base_type_mask_[index / 16] |= (base_type << shift_bits); | 262 generic_attrib_base_type_mask_[index / 16] |= (base_type << shift_bits); |
263 } | 263 } |
264 | 264 |
265 // Return 16 attributes' base types, in which the generic attribute | 265 const std::vector<uint32_t>& generic_attrib_base_type_mask() const { |
266 // specified by argument 'index' located. | 266 return generic_attrib_base_type_mask_; |
267 uint32_t GetGenericVertexAttribBaseTypeMask(GLuint index) { | |
268 DCHECK(index < max_vertex_attribs_); | |
269 return generic_attrib_base_type_mask_[index / 16]; | |
270 } | 267 } |
271 | 268 |
272 void UnbindTexture(TextureRef* texture); | 269 void UnbindTexture(TextureRef* texture); |
273 void UnbindSampler(Sampler* sampler); | 270 void UnbindSampler(Sampler* sampler); |
274 | 271 |
275 PixelStoreParams GetPackParams(); | 272 PixelStoreParams GetPackParams(); |
276 PixelStoreParams GetUnpackParams(Dimension dimension); | 273 PixelStoreParams GetUnpackParams(Dimension dimension); |
277 | 274 |
278 void EnableDisableFramebufferSRGB(bool enable); | 275 void EnableDisableFramebufferSRGB(bool enable); |
279 | 276 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 // user values; otherwise, set them to 0. | 336 // user values; otherwise, set them to 0. |
340 void UpdatePackParameters() const; | 337 void UpdatePackParameters() const; |
341 // If a buffer object is bound to PIXEL_UNPACK_BUFFER, set all unpack | 338 // If a buffer object is bound to PIXEL_UNPACK_BUFFER, set all unpack |
342 // parameters user values; otherwise, set them to 0. | 339 // parameters user values; otherwise, set them to 0. |
343 void UpdateUnpackParameters() const; | 340 void UpdateUnpackParameters() const; |
344 | 341 |
345 void InitStateManual(const ContextState* prev_state) const; | 342 void InitStateManual(const ContextState* prev_state) const; |
346 | 343 |
347 bool framebuffer_srgb_; | 344 bool framebuffer_srgb_; |
348 | 345 |
349 uint32_t max_vertex_attribs_; | |
350 // Generic vertex attrib base types: FLOAT, INT, or UINT. | 346 // Generic vertex attrib base types: FLOAT, INT, or UINT. |
351 // Each base type is encoded into 2 bits, the lowest 2 bits for location 0, | 347 // Each base type is encoded into 2 bits, the lowest 2 bits for location 0, |
352 // the highest 2 bits for location (max_vertex_attribs_ - 1). | 348 // the highest 2 bits for location (max_vertex_attribs - 1). |
353 std::vector<uint32_t> generic_attrib_base_type_mask_; | 349 std::vector<uint32_t> generic_attrib_base_type_mask_; |
354 | 350 |
355 FeatureInfo* feature_info_; | 351 FeatureInfo* feature_info_; |
356 std::unique_ptr<ErrorState> error_state_; | 352 std::unique_ptr<ErrorState> error_state_; |
357 }; | 353 }; |
358 | 354 |
359 } // namespace gles2 | 355 } // namespace gles2 |
360 } // namespace gpu | 356 } // namespace gpu |
361 | 357 |
362 #endif // GPU_COMMAND_BUFFER_SERVICE_CONTEXT_STATE_H_ | 358 #endif // GPU_COMMAND_BUFFER_SERVICE_CONTEXT_STATE_H_ |
363 | 359 |
OLD | NEW |