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) { | |
247 max_vertex_attribs_ = max_vertex_attribs; | |
248 | |
249 uint32_t packed_size = max_vertex_attribs_ / 16; | |
Zhenyao Mo
2016/07/22 14:36:47
nit: this can be ceil(), but your code is also cor
| |
250 packed_size += (max_vertex_attribs_ % 16 == 0) ? 0 : 1; | |
251 generic_attrib_base_type_mask_.resize(packed_size); | |
252 for (uint32_t i = 0; i < packed_size; ++i) { | |
253 generic_attrib_base_type_mask_[i] = 0xFFFFFFFF; | |
Zhenyao Mo
2016/07/22 14:36:47
set this to be 0x55555555 * SHADER_VARIABLE_FLOAT
| |
254 } | |
255 } | |
256 | |
257 void SetGenericVertexAttribBaseType(GLuint index, GLenum base_type) { | |
258 DCHECK(index < max_vertex_attribs_); | |
259 int shift_bits = (index % 16) * 2; | |
260 generic_attrib_base_type_mask_[index / 16] &= ~(0x3 << shift_bits); | |
261 generic_attrib_base_type_mask_[index / 16] |= (base_type << shift_bits); | |
262 } | |
263 | |
264 // Return 16 attributes' base types, in which the generic attribute | |
265 // specified by argument 'index' located. | |
266 uint32_t GetGenericVertexAttribBaseTypeMask(GLuint index) { | |
267 DCHECK(index < max_vertex_attribs_); | |
268 return generic_attrib_base_type_mask_[index / 16]; | |
269 } | |
270 | |
246 void UnbindTexture(TextureRef* texture); | 271 void UnbindTexture(TextureRef* texture); |
247 void UnbindSampler(Sampler* sampler); | 272 void UnbindSampler(Sampler* sampler); |
248 | 273 |
249 PixelStoreParams GetPackParams(); | 274 PixelStoreParams GetPackParams(); |
250 PixelStoreParams GetUnpackParams(Dimension dimension); | 275 PixelStoreParams GetUnpackParams(Dimension dimension); |
251 | 276 |
252 void EnableDisableFramebufferSRGB(bool enable); | 277 void EnableDisableFramebufferSRGB(bool enable); |
253 | 278 |
254 #include "gpu/command_buffer/service/context_state_autogen.h" | 279 #include "gpu/command_buffer/service/context_state_autogen.h" |
255 | 280 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
313 // user values; otherwise, set them to 0. | 338 // user values; otherwise, set them to 0. |
314 void UpdatePackParameters() const; | 339 void UpdatePackParameters() const; |
315 // If a buffer object is bound to PIXEL_UNPACK_BUFFER, set all unpack | 340 // If a buffer object is bound to PIXEL_UNPACK_BUFFER, set all unpack |
316 // parameters user values; otherwise, set them to 0. | 341 // parameters user values; otherwise, set them to 0. |
317 void UpdateUnpackParameters() const; | 342 void UpdateUnpackParameters() const; |
318 | 343 |
319 void InitStateManual(const ContextState* prev_state) const; | 344 void InitStateManual(const ContextState* prev_state) const; |
320 | 345 |
321 bool framebuffer_srgb_; | 346 bool framebuffer_srgb_; |
322 | 347 |
348 uint32_t max_vertex_attribs_; | |
349 // Generic vertex attrib base types: FLOAT, INT, or UINT. | |
350 // Each base type is encoded into 2 bits, the lowest 2 bits for location 0, | |
351 // the highest 2 bits for location (max_vertex_attribs_ - 1). | |
352 std::vector<uint32_t> generic_attrib_base_type_mask_; | |
353 | |
323 FeatureInfo* feature_info_; | 354 FeatureInfo* feature_info_; |
324 std::unique_ptr<ErrorState> error_state_; | 355 std::unique_ptr<ErrorState> error_state_; |
325 }; | 356 }; |
326 | 357 |
327 } // namespace gles2 | 358 } // namespace gles2 |
328 } // namespace gpu | 359 } // namespace gpu |
329 | 360 |
330 #endif // GPU_COMMAND_BUFFER_SERVICE_CONTEXT_STATE_H_ | 361 #endif // GPU_COMMAND_BUFFER_SERVICE_CONTEXT_STATE_H_ |
331 | 362 |
OLD | NEW |