| 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 InitGenericAttribs(GLuint max_vertex_attribs) { | 246 void InitGenericAttribBaseType(GLuint max_vertex_attribs) { |
| 247 attrib_values.resize(max_vertex_attribs); | 247 max_vertex_attribs_ = 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_LT(index, attrib_values.size()); | 259 DCHECK(index < max_vertex_attribs_); |
| 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 const std::vector<uint32_t>& generic_attrib_base_type_mask() const { | 265 // Return 16 attributes' base types, in which the generic attribute |
| 266 return generic_attrib_base_type_mask_; | 266 // specified by argument 'index' located. |
| 267 uint32_t GetGenericVertexAttribBaseTypeMask(GLuint index) { |
| 268 DCHECK(index < max_vertex_attribs_); |
| 269 return generic_attrib_base_type_mask_[index / 16]; |
| 267 } | 270 } |
| 268 | 271 |
| 269 void UnbindTexture(TextureRef* texture); | 272 void UnbindTexture(TextureRef* texture); |
| 270 void UnbindSampler(Sampler* sampler); | 273 void UnbindSampler(Sampler* sampler); |
| 271 | 274 |
| 272 PixelStoreParams GetPackParams(); | 275 PixelStoreParams GetPackParams(); |
| 273 PixelStoreParams GetUnpackParams(Dimension dimension); | 276 PixelStoreParams GetUnpackParams(Dimension dimension); |
| 274 | 277 |
| 275 void EnableDisableFramebufferSRGB(bool enable); | 278 void EnableDisableFramebufferSRGB(bool enable); |
| 276 | 279 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 // user values; otherwise, set them to 0. | 339 // user values; otherwise, set them to 0. |
| 337 void UpdatePackParameters() const; | 340 void UpdatePackParameters() const; |
| 338 // If a buffer object is bound to PIXEL_UNPACK_BUFFER, set all unpack | 341 // If a buffer object is bound to PIXEL_UNPACK_BUFFER, set all unpack |
| 339 // parameters user values; otherwise, set them to 0. | 342 // parameters user values; otherwise, set them to 0. |
| 340 void UpdateUnpackParameters() const; | 343 void UpdateUnpackParameters() const; |
| 341 | 344 |
| 342 void InitStateManual(const ContextState* prev_state) const; | 345 void InitStateManual(const ContextState* prev_state) const; |
| 343 | 346 |
| 344 bool framebuffer_srgb_; | 347 bool framebuffer_srgb_; |
| 345 | 348 |
| 349 uint32_t max_vertex_attribs_; |
| 346 // Generic vertex attrib base types: FLOAT, INT, or UINT. | 350 // Generic vertex attrib base types: FLOAT, INT, or UINT. |
| 347 // Each base type is encoded into 2 bits, the lowest 2 bits for location 0, | 351 // Each base type is encoded into 2 bits, the lowest 2 bits for location 0, |
| 348 // the highest 2 bits for location (max_vertex_attribs - 1). | 352 // the highest 2 bits for location (max_vertex_attribs_ - 1). |
| 349 std::vector<uint32_t> generic_attrib_base_type_mask_; | 353 std::vector<uint32_t> generic_attrib_base_type_mask_; |
| 350 | 354 |
| 351 FeatureInfo* feature_info_; | 355 FeatureInfo* feature_info_; |
| 352 std::unique_ptr<ErrorState> error_state_; | 356 std::unique_ptr<ErrorState> error_state_; |
| 353 }; | 357 }; |
| 354 | 358 |
| 355 } // namespace gles2 | 359 } // namespace gles2 |
| 356 } // namespace gpu | 360 } // namespace gpu |
| 357 | 361 |
| 358 #endif // GPU_COMMAND_BUFFER_SERVICE_CONTEXT_STATE_H_ | 362 #endif // GPU_COMMAND_BUFFER_SERVICE_CONTEXT_STATE_H_ |
| 359 | 363 |
| OLD | NEW |