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 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <list> | 10 #include <list> |
(...skipping 14 matching lines...) Expand all Loading... | |
25 #include "base/string_number_conversions.h" | 25 #include "base/string_number_conversions.h" |
26 #include "build/build_config.h" | 26 #include "build/build_config.h" |
27 #define GLES2_GPU_SERVICE 1 | 27 #define GLES2_GPU_SERVICE 1 |
28 #include "gpu/command_buffer/common/gles2_cmd_format.h" | 28 #include "gpu/command_buffer/common/gles2_cmd_format.h" |
29 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 29 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
30 #include "gpu/command_buffer/common/debug_marker_manager.h" | 30 #include "gpu/command_buffer/common/debug_marker_manager.h" |
31 #include "gpu/command_buffer/common/id_allocator.h" | 31 #include "gpu/command_buffer/common/id_allocator.h" |
32 #include "gpu/command_buffer/service/buffer_manager.h" | 32 #include "gpu/command_buffer/service/buffer_manager.h" |
33 #include "gpu/command_buffer/service/cmd_buffer_engine.h" | 33 #include "gpu/command_buffer/service/cmd_buffer_engine.h" |
34 #include "gpu/command_buffer/service/context_group.h" | 34 #include "gpu/command_buffer/service/context_group.h" |
35 #include "gpu/command_buffer/service/context_state.h" | |
35 #include "gpu/command_buffer/service/feature_info.h" | 36 #include "gpu/command_buffer/service/feature_info.h" |
36 #include "gpu/command_buffer/service/framebuffer_manager.h" | 37 #include "gpu/command_buffer/service/framebuffer_manager.h" |
37 #include "gpu/command_buffer/service/gl_utils.h" | 38 #include "gpu/command_buffer/service/gl_utils.h" |
38 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h" | 39 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h" |
39 #include "gpu/command_buffer/service/gles2_cmd_validation.h" | 40 #include "gpu/command_buffer/service/gles2_cmd_validation.h" |
40 #include "gpu/command_buffer/service/gpu_switches.h" | 41 #include "gpu/command_buffer/service/gpu_switches.h" |
41 #include "gpu/command_buffer/service/mailbox_manager.h" | 42 #include "gpu/command_buffer/service/mailbox_manager.h" |
42 #include "gpu/command_buffer/service/memory_tracking.h" | 43 #include "gpu/command_buffer/service/memory_tracking.h" |
43 #include "gpu/command_buffer/service/program_manager.h" | 44 #include "gpu/command_buffer/service/program_manager.h" |
44 #include "gpu/command_buffer/service/query_manager.h" | 45 #include "gpu/command_buffer/service/query_manager.h" |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
560 virtual error::ContextLostReason GetContextLostReason() OVERRIDE; | 561 virtual error::ContextLostReason GetContextLostReason() OVERRIDE; |
561 | 562 |
562 private: | 563 private: |
563 friend class ScopedGLErrorSuppressor; | 564 friend class ScopedGLErrorSuppressor; |
564 friend class ScopedResolvedFrameBufferBinder; | 565 friend class ScopedResolvedFrameBufferBinder; |
565 friend class ScopedTextureUploadTimer; | 566 friend class ScopedTextureUploadTimer; |
566 friend class Texture; | 567 friend class Texture; |
567 friend class RenderBuffer; | 568 friend class RenderBuffer; |
568 friend class FrameBuffer; | 569 friend class FrameBuffer; |
569 | 570 |
570 // State associated with each texture unit. | |
571 struct TextureUnit { | |
572 TextureUnit() : bind_target(GL_TEXTURE_2D) { } | |
573 | |
574 // The last target that was bound to this texture unit. | |
575 GLenum bind_target; | |
576 | |
577 // texture currently bound to this unit's GL_TEXTURE_2D with glBindTexture | |
578 TextureManager::TextureInfo::Ref bound_texture_2d; | |
579 | |
580 // texture currently bound to this unit's GL_TEXTURE_CUBE_MAP with | |
581 // glBindTexture | |
582 TextureManager::TextureInfo::Ref bound_texture_cube_map; | |
583 | |
584 // texture currently bound to this unit's GL_TEXTURE_EXTERNAL_OES with | |
585 // glBindTexture | |
586 TextureManager::TextureInfo::Ref bound_texture_external_oes; | |
587 | |
588 // texture currently bound to this unit's GL_TEXTURE_RECTANGLE_ARB with | |
589 // glBindTexture | |
590 TextureManager::TextureInfo::Ref bound_texture_rectangle_arb; | |
591 | |
592 TextureManager::TextureInfo::Ref GetInfoForSamplerType(GLenum type) { | |
593 DCHECK(type == GL_SAMPLER_2D || type == GL_SAMPLER_CUBE || | |
594 type == GL_SAMPLER_EXTERNAL_OES || type == GL_SAMPLER_2D_RECT_ARB); | |
595 switch (type) { | |
596 case GL_SAMPLER_2D: | |
597 return bound_texture_2d; | |
598 case GL_SAMPLER_CUBE: | |
599 return bound_texture_cube_map; | |
600 case GL_SAMPLER_EXTERNAL_OES: | |
601 return bound_texture_external_oes; | |
602 case GL_SAMPLER_2D_RECT_ARB: | |
603 return bound_texture_rectangle_arb; | |
604 } | |
605 | |
606 NOTREACHED(); | |
607 return NULL; | |
608 } | |
609 | |
610 void Unbind(TextureManager::TextureInfo* texture) { | |
611 if (bound_texture_2d == texture) { | |
612 bound_texture_2d = NULL; | |
613 } | |
614 if (bound_texture_cube_map == texture) { | |
615 bound_texture_cube_map = NULL; | |
616 } | |
617 if (bound_texture_external_oes == texture) { | |
618 bound_texture_external_oes = NULL; | |
619 } | |
620 } | |
621 }; | |
622 | |
623 // Initialize or re-initialize the shader translator. | 571 // Initialize or re-initialize the shader translator. |
624 bool InitializeShaderTranslator(); | 572 bool InitializeShaderTranslator(); |
625 | 573 |
626 void UpdateCapabilities(); | 574 void UpdateCapabilities(); |
627 | 575 |
628 // Helpers for the glGen and glDelete functions. | 576 // Helpers for the glGen and glDelete functions. |
629 bool GenTexturesHelper(GLsizei n, const GLuint* client_ids); | 577 bool GenTexturesHelper(GLsizei n, const GLuint* client_ids); |
630 void DeleteTexturesHelper(GLsizei n, const GLuint* client_ids); | 578 void DeleteTexturesHelper(GLsizei n, const GLuint* client_ids); |
631 bool GenBuffersHelper(GLsizei n, const GLuint* client_ids); | 579 bool GenBuffersHelper(GLsizei n, const GLuint* client_ids); |
632 void DeleteBuffersHelper(GLsizei n, const GLuint* client_ids); | 580 void DeleteBuffersHelper(GLsizei n, const GLuint* client_ids); |
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1277 GLsizei primcount); | 1225 GLsizei primcount); |
1278 error::Error DoDrawElements( | 1226 error::Error DoDrawElements( |
1279 const char* function_name, | 1227 const char* function_name, |
1280 bool instanced, GLenum mode, GLsizei count, GLenum type, | 1228 bool instanced, GLenum mode, GLsizei count, GLenum type, |
1281 int32 offset, GLsizei primcount); | 1229 int32 offset, GLsizei primcount); |
1282 | 1230 |
1283 // Gets the buffer id for a given target. | 1231 // Gets the buffer id for a given target. |
1284 BufferManager::BufferInfo* GetBufferInfoForTarget(GLenum target) { | 1232 BufferManager::BufferInfo* GetBufferInfoForTarget(GLenum target) { |
1285 DCHECK(target == GL_ARRAY_BUFFER || target == GL_ELEMENT_ARRAY_BUFFER); | 1233 DCHECK(target == GL_ARRAY_BUFFER || target == GL_ELEMENT_ARRAY_BUFFER); |
1286 if (target == GL_ARRAY_BUFFER) { | 1234 if (target == GL_ARRAY_BUFFER) { |
1287 return bound_array_buffer_; | 1235 return state_.bound_array_buffer; |
1288 } else { | 1236 } else { |
1289 return vertex_attrib_manager_->element_array_buffer(); | 1237 return state_.vertex_attrib_manager->element_array_buffer(); |
1290 } | 1238 } |
1291 } | 1239 } |
1292 | 1240 |
1293 // Gets the texture id for a given target. | 1241 // Gets the texture id for a given target. |
1294 TextureManager::TextureInfo* GetTextureInfoForTarget(GLenum target) { | 1242 TextureManager::TextureInfo* GetTextureInfoForTarget(GLenum target) { |
1295 TextureUnit& unit = texture_units_[active_texture_unit_]; | 1243 TextureUnit& unit = state_.texture_units[state_.active_texture_unit]; |
1296 TextureManager::TextureInfo* info = NULL; | 1244 TextureManager::TextureInfo* info = NULL; |
1297 switch (target) { | 1245 switch (target) { |
1298 case GL_TEXTURE_2D: | 1246 case GL_TEXTURE_2D: |
1299 info = unit.bound_texture_2d; | 1247 info = unit.bound_texture_2d; |
1300 break; | 1248 break; |
1301 case GL_TEXTURE_CUBE_MAP: | 1249 case GL_TEXTURE_CUBE_MAP: |
1302 case GL_TEXTURE_CUBE_MAP_POSITIVE_X: | 1250 case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
1303 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: | 1251 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
1304 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: | 1252 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
1305 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: | 1253 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1338 return 0; | 1286 return 0; |
1339 } | 1287 } |
1340 | 1288 |
1341 // Gets the framebuffer info for a particular target. | 1289 // Gets the framebuffer info for a particular target. |
1342 FramebufferManager::FramebufferInfo* GetFramebufferInfoForTarget( | 1290 FramebufferManager::FramebufferInfo* GetFramebufferInfoForTarget( |
1343 GLenum target) { | 1291 GLenum target) { |
1344 FramebufferManager::FramebufferInfo* info = NULL; | 1292 FramebufferManager::FramebufferInfo* info = NULL; |
1345 switch (target) { | 1293 switch (target) { |
1346 case GL_FRAMEBUFFER: | 1294 case GL_FRAMEBUFFER: |
1347 case GL_DRAW_FRAMEBUFFER_EXT: | 1295 case GL_DRAW_FRAMEBUFFER_EXT: |
1348 info = bound_draw_framebuffer_; | 1296 info = state_.bound_draw_framebuffer; |
1349 break; | 1297 break; |
1350 case GL_READ_FRAMEBUFFER_EXT: | 1298 case GL_READ_FRAMEBUFFER_EXT: |
1351 info = bound_read_framebuffer_; | 1299 info = state_.bound_read_framebuffer; |
1352 break; | 1300 break; |
1353 default: | 1301 default: |
1354 NOTREACHED(); | 1302 NOTREACHED(); |
1355 break; | 1303 break; |
1356 } | 1304 } |
1357 return info; | 1305 return info; |
1358 } | 1306 } |
1359 | 1307 |
1360 RenderbufferManager::RenderbufferInfo* GetRenderbufferInfoForTarget( | 1308 RenderbufferManager::RenderbufferInfo* GetRenderbufferInfoForTarget( |
1361 GLenum target) { | 1309 GLenum target) { |
1362 RenderbufferManager::RenderbufferInfo* info = NULL; | 1310 RenderbufferManager::RenderbufferInfo* info = NULL; |
1363 switch (target) { | 1311 switch (target) { |
1364 case GL_RENDERBUFFER: | 1312 case GL_RENDERBUFFER: |
1365 info = bound_renderbuffer_; | 1313 info = state_.bound_renderbuffer; |
1366 break; | 1314 break; |
1367 default: | 1315 default: |
1368 NOTREACHED(); | 1316 NOTREACHED(); |
1369 break; | 1317 break; |
1370 } | 1318 } |
1371 return info; | 1319 return info; |
1372 } | 1320 } |
1373 | 1321 |
1374 // Validates the program and location for a glGetUniform call and returns | 1322 // Validates the program and location for a glGetUniform call and returns |
1375 // a SizeResult setup to receive the result. Returns true if glGetUniform | 1323 // a SizeResult setup to receive the result. Returns true if glGetUniform |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1410 GLsizei width, GLsizei height, GLenum format, | 1358 GLsizei width, GLsizei height, GLenum format, |
1411 TextureManager::TextureInfo* texture); | 1359 TextureManager::TextureInfo* texture); |
1412 | 1360 |
1413 void LogMessage(const std::string& msg); | 1361 void LogMessage(const std::string& msg); |
1414 void RenderWarning(const std::string& msg); | 1362 void RenderWarning(const std::string& msg); |
1415 void PerformanceWarning(const std::string& msg); | 1363 void PerformanceWarning(const std::string& msg); |
1416 const std::string& GetLogPrefix() const; | 1364 const std::string& GetLogPrefix() const; |
1417 | 1365 |
1418 bool ShouldDeferDraws() { | 1366 bool ShouldDeferDraws() { |
1419 return !offscreen_target_frame_buffer_.get() && | 1367 return !offscreen_target_frame_buffer_.get() && |
1420 bound_draw_framebuffer_ == NULL && | 1368 state_.bound_draw_framebuffer == NULL && |
1421 surface_->DeferDraws(); | 1369 surface_->DeferDraws(); |
1422 } | 1370 } |
1423 | 1371 |
1424 void ForceCompileShaderIfPending(ShaderManager::ShaderInfo* info); | 1372 void ForceCompileShaderIfPending(ShaderManager::ShaderInfo* info); |
1425 | 1373 |
1426 // Generate a member function prototype for each command in an automated and | 1374 // Generate a member function prototype for each command in an automated and |
1427 // typesafe way. | 1375 // typesafe way. |
1428 #define GLES2_CMD_OP(name) \ | 1376 #define GLES2_CMD_OP(name) \ |
1429 Error Handle ## name( \ | 1377 Error Handle ## name( \ |
1430 uint32 immediate_data_size, \ | 1378 uint32 immediate_data_size, \ |
1431 const gles2::name& args); \ | 1379 const gles2::name& args); \ |
1432 | 1380 |
1433 GLES2_COMMAND_LIST(GLES2_CMD_OP) | 1381 GLES2_COMMAND_LIST(GLES2_CMD_OP) |
1434 | 1382 |
1435 #undef GLES2_CMD_OP | 1383 #undef GLES2_CMD_OP |
1436 | 1384 |
1437 // The GL context this decoder renders to on behalf of the client. | 1385 // The GL context this decoder renders to on behalf of the client. |
1438 scoped_refptr<gfx::GLSurface> surface_; | 1386 scoped_refptr<gfx::GLSurface> surface_; |
1439 scoped_refptr<gfx::GLContext> context_; | 1387 scoped_refptr<gfx::GLContext> context_; |
1440 | 1388 |
1441 // The ContextGroup for this decoder uses to track resources. | 1389 // The ContextGroup for this decoder uses to track resources. |
1442 ContextGroup::Ref group_; | 1390 ContextGroup::Ref group_; |
1443 | 1391 |
1392 // All the state for this context. | |
1393 ContextState state_; | |
1394 | |
1444 // A parent decoder can access this decoders saved offscreen frame buffer. | 1395 // A parent decoder can access this decoders saved offscreen frame buffer. |
1445 // The parent pointer is reset if the parent is destroyed. | 1396 // The parent pointer is reset if the parent is destroyed. |
1446 base::WeakPtr<GLES2DecoderImpl> parent_; | 1397 base::WeakPtr<GLES2DecoderImpl> parent_; |
1447 | 1398 |
1448 // Current width and height of the offscreen frame buffer. | 1399 // Current width and height of the offscreen frame buffer. |
1449 gfx::Size offscreen_size_; | 1400 gfx::Size offscreen_size_; |
1450 | 1401 |
1451 // Current GL error bits. | 1402 // Current GL error bits. |
1452 uint32 error_bits_; | 1403 uint32 error_bits_; |
1453 | 1404 |
1454 // Util to help with GL. | 1405 // Util to help with GL. |
1455 GLES2Util util_; | 1406 GLES2Util util_; |
1456 | 1407 |
1457 // pack alignment as last set by glPixelStorei | |
1458 GLint pack_alignment_; | |
1459 | |
1460 // unpack alignment as last set by glPixelStorei | |
1461 GLint unpack_alignment_; | |
1462 | |
1463 // unpack flip y as last set by glPixelStorei | 1408 // unpack flip y as last set by glPixelStorei |
1464 bool unpack_flip_y_; | 1409 bool unpack_flip_y_; |
1465 | 1410 |
1466 // unpack (un)premultiply alpha as last set by glPixelStorei | 1411 // unpack (un)premultiply alpha as last set by glPixelStorei |
1467 bool unpack_premultiply_alpha_; | 1412 bool unpack_premultiply_alpha_; |
1468 bool unpack_unpremultiply_alpha_; | 1413 bool unpack_unpremultiply_alpha_; |
1469 | 1414 |
1470 // The currently bound array buffer. If this is 0 it is illegal to call | |
1471 // glVertexAttribPointer. | |
1472 BufferManager::BufferInfo::Ref bound_array_buffer_; | |
1473 | |
1474 // Class that manages vertex attribs. | |
1475 VertexAttribManager::Ref vertex_attrib_manager_; | |
1476 | |
1477 // Default vertex attribs manager, used when no VAOs are bound. | 1415 // Default vertex attribs manager, used when no VAOs are bound. |
1478 VertexAttribManager::Ref default_vertex_attrib_manager_; | 1416 VertexAttribManager::Ref default_vertex_attrib_manager_; |
bajones
2012/10/12 21:02:54
I think the default_vertex_attrib_manager_ should
greggman
2012/10/12 21:14:04
It seems like GLES2CmdDecoder assigns default_vert
| |
1479 | 1417 |
1480 // The buffer we bind to attrib 0 since OpenGL requires it (ES does not). | 1418 // The buffer we bind to attrib 0 since OpenGL requires it (ES does not). |
1481 GLuint attrib_0_buffer_id_; | 1419 GLuint attrib_0_buffer_id_; |
1482 | 1420 |
1483 // The value currently in attrib_0. | 1421 // The value currently in attrib_0. |
1484 VertexAttribManager::VertexAttribInfo::Vec4 attrib_0_value_; | 1422 VertexAttribManager::VertexAttribInfo::Vec4 attrib_0_value_; |
1485 | 1423 |
1486 // Whether or not the attrib_0 buffer holds the attrib_0_value. | 1424 // Whether or not the attrib_0 buffer holds the attrib_0_value. |
1487 bool attrib_0_buffer_matches_value_; | 1425 bool attrib_0_buffer_matches_value_; |
1488 | 1426 |
1489 // The size of attrib 0. | 1427 // The size of attrib 0. |
1490 GLsizei attrib_0_size_; | 1428 GLsizei attrib_0_size_; |
1491 | 1429 |
1492 // The buffer used to simulate GL_FIXED attribs. | 1430 // The buffer used to simulate GL_FIXED attribs. |
1493 GLuint fixed_attrib_buffer_id_; | 1431 GLuint fixed_attrib_buffer_id_; |
1494 | 1432 |
1495 // The size of fiixed attrib buffer. | 1433 // The size of fiixed attrib buffer. |
1496 GLsizei fixed_attrib_buffer_size_; | 1434 GLsizei fixed_attrib_buffer_size_; |
1497 | 1435 |
1498 // Current active texture by 0 - n index. | |
1499 // In other words, if we call glActiveTexture(GL_TEXTURE2) this value would | |
1500 // be 2. | |
1501 GLuint active_texture_unit_; | |
1502 | |
1503 // Which textures are bound to texture units through glActiveTexture. | |
1504 scoped_array<TextureUnit> texture_units_; | |
1505 | |
1506 // state saved for clearing so we can clear render buffers and then | 1436 // state saved for clearing so we can clear render buffers and then |
1507 // restore to these values. | 1437 // restore to these values. |
1508 GLclampf clear_red_; | |
1509 GLclampf clear_green_; | |
1510 GLclampf clear_blue_; | |
1511 GLclampf clear_alpha_; | |
1512 GLboolean mask_red_; | |
1513 GLboolean mask_green_; | |
1514 GLboolean mask_blue_; | |
1515 GLboolean mask_alpha_; | |
1516 GLint clear_stencil_; | |
1517 GLuint mask_stencil_front_; | |
1518 GLuint mask_stencil_back_; | |
1519 GLclampf clear_depth_; | |
1520 GLboolean mask_depth_; | |
1521 bool enable_blend_; | |
1522 bool enable_cull_face_; | |
1523 bool enable_scissor_test_; | |
1524 bool enable_depth_test_; | |
1525 bool enable_stencil_test_; | |
1526 bool state_dirty_; | 1438 bool state_dirty_; |
1527 | 1439 |
1528 // The program in use by glUseProgram | |
1529 ProgramManager::ProgramInfo::Ref current_program_; | |
1530 | |
1531 // The currently bound framebuffers | |
1532 FramebufferManager::FramebufferInfo::Ref bound_read_framebuffer_; | |
1533 FramebufferManager::FramebufferInfo::Ref bound_draw_framebuffer_; | |
1534 | |
1535 // The currently bound renderbuffer | |
1536 RenderbufferManager::RenderbufferInfo::Ref bound_renderbuffer_; | |
1537 | |
1538 // The offscreen frame buffer that the client renders to. With EGL, the | 1440 // The offscreen frame buffer that the client renders to. With EGL, the |
1539 // depth and stencil buffers are separate. With regular GL there is a single | 1441 // depth and stencil buffers are separate. With regular GL there is a single |
1540 // packed depth stencil buffer in offscreen_target_depth_render_buffer_. | 1442 // packed depth stencil buffer in offscreen_target_depth_render_buffer_. |
1541 // offscreen_target_stencil_render_buffer_ is unused. | 1443 // offscreen_target_stencil_render_buffer_ is unused. |
1542 scoped_ptr<FrameBuffer> offscreen_target_frame_buffer_; | 1444 scoped_ptr<FrameBuffer> offscreen_target_frame_buffer_; |
1543 scoped_ptr<Texture> offscreen_target_color_texture_; | 1445 scoped_ptr<Texture> offscreen_target_color_texture_; |
1544 scoped_ptr<RenderBuffer> offscreen_target_color_render_buffer_; | 1446 scoped_ptr<RenderBuffer> offscreen_target_color_render_buffer_; |
1545 scoped_ptr<RenderBuffer> offscreen_target_depth_render_buffer_; | 1447 scoped_ptr<RenderBuffer> offscreen_target_depth_render_buffer_; |
1546 scoped_ptr<RenderBuffer> offscreen_target_stencil_render_buffer_; | 1448 scoped_ptr<RenderBuffer> offscreen_target_stencil_render_buffer_; |
1547 GLenum offscreen_target_color_format_; | 1449 GLenum offscreen_target_color_format_; |
1548 GLenum offscreen_target_depth_format_; | 1450 GLenum offscreen_target_depth_format_; |
1549 GLenum offscreen_target_stencil_format_; | 1451 GLenum offscreen_target_stencil_format_; |
1550 GLsizei offscreen_target_samples_; | 1452 GLsizei offscreen_target_samples_; |
1551 GLboolean offscreen_target_buffer_preserved_; | 1453 GLboolean offscreen_target_buffer_preserved_; |
1552 | 1454 |
1553 // The copy that is saved when SwapBuffers is called. | 1455 // The copy that is saved when SwapBuffers is called. |
1554 scoped_ptr<FrameBuffer> offscreen_saved_frame_buffer_; | 1456 scoped_ptr<FrameBuffer> offscreen_saved_frame_buffer_; |
1555 scoped_ptr<Texture> offscreen_saved_color_texture_; | 1457 scoped_ptr<Texture> offscreen_saved_color_texture_; |
1556 TextureManager::TextureInfo::Ref offscreen_saved_color_texture_info_; | 1458 TextureManager::TextureInfo::Ref offscreen_saved_color_texture_info_; |
1557 | 1459 |
1558 // The copy that is used as the destination for multi-sample resolves. | 1460 // The copy that is used as the destination for multi-sample resolves. |
1559 scoped_ptr<FrameBuffer> offscreen_resolved_frame_buffer_; | 1461 scoped_ptr<FrameBuffer> offscreen_resolved_frame_buffer_; |
1560 scoped_ptr<Texture> offscreen_resolved_color_texture_; | 1462 scoped_ptr<Texture> offscreen_resolved_color_texture_; |
1561 GLenum offscreen_saved_color_format_; | 1463 GLenum offscreen_saved_color_format_; |
1562 | 1464 |
1563 scoped_ptr<QueryManager> query_manager_; | 1465 scoped_ptr<QueryManager> query_manager_; |
1564 QueryManager::Query::Ref current_query_; | |
1565 | 1466 |
1566 scoped_ptr<VertexArrayManager> vertex_array_manager_; | 1467 scoped_ptr<VertexArrayManager> vertex_array_manager_; |
1567 | 1468 |
1568 base::Callback<void(gfx::Size)> resize_callback_; | 1469 base::Callback<void(gfx::Size)> resize_callback_; |
1569 | 1470 |
1570 MsgCallback msg_callback_; | 1471 MsgCallback msg_callback_; |
1571 | 1472 |
1572 StreamTextureManager* stream_texture_manager_; | 1473 StreamTextureManager* stream_texture_manager_; |
1573 | 1474 |
1574 // The format of the back buffer_ | 1475 // The format of the back buffer_ |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1624 #if defined(OS_MACOSX) | 1525 #if defined(OS_MACOSX) |
1625 typedef std::map<GLuint, CFTypeRef> TextureToIOSurfaceMap; | 1526 typedef std::map<GLuint, CFTypeRef> TextureToIOSurfaceMap; |
1626 TextureToIOSurfaceMap texture_to_io_surface_map_; | 1527 TextureToIOSurfaceMap texture_to_io_surface_map_; |
1627 #endif | 1528 #endif |
1628 | 1529 |
1629 typedef std::vector<GLES2DecoderImpl*> ChildList; | 1530 typedef std::vector<GLES2DecoderImpl*> ChildList; |
1630 ChildList children_; | 1531 ChildList children_; |
1631 | 1532 |
1632 scoped_ptr<CopyTextureCHROMIUMResourceManager> copy_texture_CHROMIUM_; | 1533 scoped_ptr<CopyTextureCHROMIUMResourceManager> copy_texture_CHROMIUM_; |
1633 | 1534 |
1634 // Cached values of the currently assigned viewport dimensions. | |
1635 GLint viewport_x_, viewport_y_; | |
1636 GLsizei viewport_width_, viewport_height_; | |
1637 GLsizei viewport_max_width_, viewport_max_height_; | |
1638 | |
1639 // Command buffer stats. | 1535 // Command buffer stats. |
1640 int texture_upload_count_; | 1536 int texture_upload_count_; |
1641 base::TimeDelta total_texture_upload_time_; | 1537 base::TimeDelta total_texture_upload_time_; |
1642 base::TimeDelta total_processing_commands_time_; | 1538 base::TimeDelta total_processing_commands_time_; |
1643 | 1539 |
1644 DISALLOW_COPY_AND_ASSIGN(GLES2DecoderImpl); | 1540 DISALLOW_COPY_AND_ASSIGN(GLES2DecoderImpl); |
1645 }; | 1541 }; |
1646 | 1542 |
1647 ScopedGLErrorSuppressor::ScopedGLErrorSuppressor(GLES2DecoderImpl* decoder) | 1543 ScopedGLErrorSuppressor::ScopedGLErrorSuppressor(GLES2DecoderImpl* decoder) |
1648 : decoder_(decoder) { | 1544 : decoder_(decoder) { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1691 ScopedFrameBufferBinder::~ScopedFrameBufferBinder() { | 1587 ScopedFrameBufferBinder::~ScopedFrameBufferBinder() { |
1692 ScopedGLErrorSuppressor suppressor(decoder_); | 1588 ScopedGLErrorSuppressor suppressor(decoder_); |
1693 decoder_->RestoreCurrentFramebufferBindings(); | 1589 decoder_->RestoreCurrentFramebufferBindings(); |
1694 } | 1590 } |
1695 | 1591 |
1696 ScopedResolvedFrameBufferBinder::ScopedResolvedFrameBufferBinder( | 1592 ScopedResolvedFrameBufferBinder::ScopedResolvedFrameBufferBinder( |
1697 GLES2DecoderImpl* decoder, bool enforce_internal_framebuffer, bool internal) | 1593 GLES2DecoderImpl* decoder, bool enforce_internal_framebuffer, bool internal) |
1698 : decoder_(decoder) { | 1594 : decoder_(decoder) { |
1699 resolve_and_bind_ = (decoder_->offscreen_target_frame_buffer_.get() && | 1595 resolve_and_bind_ = (decoder_->offscreen_target_frame_buffer_.get() && |
1700 decoder_->IsOffscreenBufferMultisampled() && | 1596 decoder_->IsOffscreenBufferMultisampled() && |
1701 (!decoder_->bound_read_framebuffer_.get() || | 1597 (!decoder_->state_.bound_read_framebuffer.get() || |
1702 enforce_internal_framebuffer)); | 1598 enforce_internal_framebuffer)); |
1703 if (!resolve_and_bind_) | 1599 if (!resolve_and_bind_) |
1704 return; | 1600 return; |
1705 | 1601 |
1706 ScopedGLErrorSuppressor suppressor(decoder_); | 1602 ScopedGLErrorSuppressor suppressor(decoder_); |
1707 glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, | 1603 glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, |
1708 decoder_->offscreen_target_frame_buffer_->id()); | 1604 decoder_->offscreen_target_frame_buffer_->id()); |
1709 GLuint targetid; | 1605 GLuint targetid; |
1710 if (internal) { | 1606 if (internal) { |
1711 if (!decoder_->offscreen_resolved_frame_buffer_.get()) { | 1607 if (!decoder_->offscreen_resolved_frame_buffer_.get()) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1744 } | 1640 } |
1745 glBindFramebufferEXT(GL_FRAMEBUFFER, targetid); | 1641 glBindFramebufferEXT(GL_FRAMEBUFFER, targetid); |
1746 } | 1642 } |
1747 | 1643 |
1748 ScopedResolvedFrameBufferBinder::~ScopedResolvedFrameBufferBinder() { | 1644 ScopedResolvedFrameBufferBinder::~ScopedResolvedFrameBufferBinder() { |
1749 if (!resolve_and_bind_) | 1645 if (!resolve_and_bind_) |
1750 return; | 1646 return; |
1751 | 1647 |
1752 ScopedGLErrorSuppressor suppressor(decoder_); | 1648 ScopedGLErrorSuppressor suppressor(decoder_); |
1753 decoder_->RestoreCurrentFramebufferBindings(); | 1649 decoder_->RestoreCurrentFramebufferBindings(); |
1754 if (decoder_->enable_scissor_test_) { | 1650 if (decoder_->state_.enable_scissor_test) { |
1755 glEnable(GL_SCISSOR_TEST); | 1651 glEnable(GL_SCISSOR_TEST); |
1756 } | 1652 } |
1757 } | 1653 } |
1758 | 1654 |
1759 ScopedTextureUploadTimer::ScopedTextureUploadTimer(GLES2DecoderImpl* decoder) | 1655 ScopedTextureUploadTimer::ScopedTextureUploadTimer(GLES2DecoderImpl* decoder) |
1760 : decoder_(decoder), | 1656 : decoder_(decoder), |
1761 begin_time_(base::TimeTicks::HighResNow()) { | 1657 begin_time_(base::TimeTicks::HighResNow()) { |
1762 } | 1658 } |
1763 | 1659 |
1764 ScopedTextureUploadTimer::~ScopedTextureUploadTimer() { | 1660 ScopedTextureUploadTimer::~ScopedTextureUploadTimer() { |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1982 } | 1878 } |
1983 | 1879 |
1984 GLES2Decoder* GLES2Decoder::Create(ContextGroup* group) { | 1880 GLES2Decoder* GLES2Decoder::Create(ContextGroup* group) { |
1985 return new GLES2DecoderImpl(group); | 1881 return new GLES2DecoderImpl(group); |
1986 } | 1882 } |
1987 | 1883 |
1988 GLES2DecoderImpl::GLES2DecoderImpl(ContextGroup* group) | 1884 GLES2DecoderImpl::GLES2DecoderImpl(ContextGroup* group) |
1989 : GLES2Decoder(), | 1885 : GLES2Decoder(), |
1990 group_(group), | 1886 group_(group), |
1991 error_bits_(0), | 1887 error_bits_(0), |
1992 pack_alignment_(4), | |
1993 unpack_alignment_(4), | |
1994 unpack_flip_y_(false), | 1888 unpack_flip_y_(false), |
1995 unpack_premultiply_alpha_(false), | 1889 unpack_premultiply_alpha_(false), |
1996 unpack_unpremultiply_alpha_(false), | 1890 unpack_unpremultiply_alpha_(false), |
1997 attrib_0_buffer_id_(0), | 1891 attrib_0_buffer_id_(0), |
1998 attrib_0_buffer_matches_value_(true), | 1892 attrib_0_buffer_matches_value_(true), |
1999 attrib_0_size_(0), | 1893 attrib_0_size_(0), |
2000 fixed_attrib_buffer_id_(0), | 1894 fixed_attrib_buffer_id_(0), |
2001 fixed_attrib_buffer_size_(0), | 1895 fixed_attrib_buffer_size_(0), |
2002 active_texture_unit_(0), | |
2003 clear_red_(0), | |
2004 clear_green_(0), | |
2005 clear_blue_(0), | |
2006 clear_alpha_(0), | |
2007 mask_red_(true), | |
2008 mask_green_(true), | |
2009 mask_blue_(true), | |
2010 mask_alpha_(true), | |
2011 clear_stencil_(0), | |
2012 mask_stencil_front_(-1), | |
2013 mask_stencil_back_(-1), | |
2014 clear_depth_(1.0f), | |
2015 mask_depth_(true), | |
2016 enable_blend_(false), | |
2017 enable_cull_face_(false), | |
2018 enable_scissor_test_(false), | |
2019 enable_depth_test_(false), | |
2020 enable_stencil_test_(false), | |
2021 state_dirty_(true), | 1896 state_dirty_(true), |
2022 offscreen_target_color_format_(0), | 1897 offscreen_target_color_format_(0), |
2023 offscreen_target_depth_format_(0), | 1898 offscreen_target_depth_format_(0), |
2024 offscreen_target_stencil_format_(0), | 1899 offscreen_target_stencil_format_(0), |
2025 offscreen_target_samples_(0), | 1900 offscreen_target_samples_(0), |
2026 offscreen_target_buffer_preserved_(true), | 1901 offscreen_target_buffer_preserved_(true), |
2027 offscreen_saved_color_format_(0), | 1902 offscreen_saved_color_format_(0), |
2028 stream_texture_manager_(NULL), | 1903 stream_texture_manager_(NULL), |
2029 back_buffer_color_format_(0), | 1904 back_buffer_color_format_(0), |
2030 back_buffer_has_depth_(false), | 1905 back_buffer_has_depth_(false), |
2031 back_buffer_has_stencil_(false), | 1906 back_buffer_has_stencil_(false), |
2032 teximage2d_faster_than_texsubimage2d_(true), | 1907 teximage2d_faster_than_texsubimage2d_(true), |
2033 log_message_count_(0), | 1908 log_message_count_(0), |
2034 current_decoder_error_(error::kNoError), | 1909 current_decoder_error_(error::kNoError), |
2035 use_shader_translator_(true), | 1910 use_shader_translator_(true), |
2036 validators_(group_->feature_info()->validators()), | 1911 validators_(group_->feature_info()->validators()), |
2037 feature_info_(group_->feature_info()), | 1912 feature_info_(group_->feature_info()), |
2038 tex_image_2d_failed_(false), | 1913 tex_image_2d_failed_(false), |
2039 frame_number_(0), | 1914 frame_number_(0), |
2040 has_robustness_extension_(false), | 1915 has_robustness_extension_(false), |
2041 reset_status_(GL_NO_ERROR), | 1916 reset_status_(GL_NO_ERROR), |
2042 needs_mac_nvidia_driver_workaround_(false), | 1917 needs_mac_nvidia_driver_workaround_(false), |
2043 needs_glsl_built_in_function_emulation_(false), | 1918 needs_glsl_built_in_function_emulation_(false), |
2044 force_webgl_glsl_validation_(false), | 1919 force_webgl_glsl_validation_(false), |
2045 derivatives_explicitly_enabled_(false), | 1920 derivatives_explicitly_enabled_(false), |
2046 compile_shader_always_succeeds_(false), | 1921 compile_shader_always_succeeds_(false), |
2047 viewport_x_(0), | |
2048 viewport_y_(0), | |
2049 viewport_width_(0), | |
2050 viewport_height_(0), | |
2051 viewport_max_width_(0), | |
2052 viewport_max_height_(0), | |
2053 texture_upload_count_(0) { | 1922 texture_upload_count_(0) { |
2054 DCHECK(group); | 1923 DCHECK(group); |
2055 | 1924 |
2056 GLES2DecoderImpl* this_temp = this; | 1925 GLES2DecoderImpl* this_temp = this; |
2057 this_in_hex_ = HexEncode(&this_temp, sizeof(this_temp)); | 1926 this_in_hex_ = HexEncode(&this_temp, sizeof(this_temp)); |
2058 | 1927 |
2059 attrib_0_value_.v[0] = 0.0f; | 1928 attrib_0_value_.v[0] = 0.0f; |
2060 attrib_0_value_.v[1] = 0.0f; | 1929 attrib_0_value_.v[1] = 0.0f; |
2061 attrib_0_value_.v[2] = 0.0f; | 1930 attrib_0_value_.v[2] = 0.0f; |
2062 attrib_0_value_.v[3] = 1.0f; | 1931 attrib_0_value_.v[3] = 1.0f; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2144 // We have to enable vertex array 0 on OpenGL or it won't render. Note that | 2013 // We have to enable vertex array 0 on OpenGL or it won't render. Note that |
2145 // OpenGL ES 2.0 does not have this issue. | 2014 // OpenGL ES 2.0 does not have this issue. |
2146 glEnableVertexAttribArray(0); | 2015 glEnableVertexAttribArray(0); |
2147 } | 2016 } |
2148 glGenBuffersARB(1, &attrib_0_buffer_id_); | 2017 glGenBuffersARB(1, &attrib_0_buffer_id_); |
2149 glBindBuffer(GL_ARRAY_BUFFER, attrib_0_buffer_id_); | 2018 glBindBuffer(GL_ARRAY_BUFFER, attrib_0_buffer_id_); |
2150 glVertexAttribPointer(0, 1, GL_FLOAT, GL_FALSE, 0, NULL); | 2019 glVertexAttribPointer(0, 1, GL_FLOAT, GL_FALSE, 0, NULL); |
2151 glBindBuffer(GL_ARRAY_BUFFER, 0); | 2020 glBindBuffer(GL_ARRAY_BUFFER, 0); |
2152 glGenBuffersARB(1, &fixed_attrib_buffer_id_); | 2021 glGenBuffersARB(1, &fixed_attrib_buffer_id_); |
2153 | 2022 |
2154 texture_units_.reset( | 2023 state_.texture_units.reset( |
2155 new TextureUnit[group_->max_texture_units()]); | 2024 new TextureUnit[group_->max_texture_units()]); |
2156 for (uint32 tt = 0; tt < group_->max_texture_units(); ++tt) { | 2025 for (uint32 tt = 0; tt < group_->max_texture_units(); ++tt) { |
2157 glActiveTexture(GL_TEXTURE0 + tt); | 2026 glActiveTexture(GL_TEXTURE0 + tt); |
2158 // We want the last bind to be 2D. | 2027 // We want the last bind to be 2D. |
2159 TextureManager::TextureInfo* info; | 2028 TextureManager::TextureInfo* info; |
2160 if (feature_info_->feature_flags().oes_egl_image_external) { | 2029 if (feature_info_->feature_flags().oes_egl_image_external) { |
2161 info = texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_EXTERNAL_OES); | 2030 info = texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_EXTERNAL_OES); |
2162 texture_units_[tt].bound_texture_external_oes = info; | 2031 state_.texture_units[tt].bound_texture_external_oes = info; |
2163 glBindTexture(GL_TEXTURE_EXTERNAL_OES, info->service_id()); | 2032 glBindTexture(GL_TEXTURE_EXTERNAL_OES, info->service_id()); |
2164 } | 2033 } |
2165 if (feature_info_->feature_flags().arb_texture_rectangle) { | 2034 if (feature_info_->feature_flags().arb_texture_rectangle) { |
2166 info = texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_RECTANGLE_ARB); | 2035 info = texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_RECTANGLE_ARB); |
2167 texture_units_[tt].bound_texture_rectangle_arb = info; | 2036 state_.texture_units[tt].bound_texture_rectangle_arb = info; |
2168 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, info->service_id()); | 2037 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, info->service_id()); |
2169 } | 2038 } |
2170 info = texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_CUBE_MAP); | 2039 info = texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_CUBE_MAP); |
2171 texture_units_[tt].bound_texture_cube_map = info; | 2040 state_.texture_units[tt].bound_texture_cube_map = info; |
2172 glBindTexture(GL_TEXTURE_CUBE_MAP, info->service_id()); | 2041 glBindTexture(GL_TEXTURE_CUBE_MAP, info->service_id()); |
2173 info = texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_2D); | 2042 info = texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_2D); |
2174 texture_units_[tt].bound_texture_2d = info; | 2043 state_.texture_units[tt].bound_texture_2d = info; |
2175 glBindTexture(GL_TEXTURE_2D, info->service_id()); | 2044 glBindTexture(GL_TEXTURE_2D, info->service_id()); |
2176 } | 2045 } |
2177 glActiveTexture(GL_TEXTURE0); | 2046 glActiveTexture(GL_TEXTURE0); |
2178 CHECK_GL_ERROR(); | 2047 CHECK_GL_ERROR(); |
2179 | 2048 |
2180 ContextCreationAttribParser attrib_parser; | 2049 ContextCreationAttribParser attrib_parser; |
2181 if (!attrib_parser.Parse(attribs)) | 2050 if (!attrib_parser.Parse(attribs)) |
2182 return false; | 2051 return false; |
2183 | 2052 |
2184 // These are NOT if the back buffer has these proprorties. They are | 2053 // These are NOT if the back buffer has these proprorties. They are |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2341 feature_info_->feature_flags().is_nvidia; | 2210 feature_info_->feature_flags().is_nvidia; |
2342 needs_glsl_built_in_function_emulation_ = | 2211 needs_glsl_built_in_function_emulation_ = |
2343 feature_info_->feature_flags().is_amd; | 2212 feature_info_->feature_flags().is_amd; |
2344 #endif | 2213 #endif |
2345 } | 2214 } |
2346 | 2215 |
2347 if (!InitializeShaderTranslator()) { | 2216 if (!InitializeShaderTranslator()) { |
2348 return false; | 2217 return false; |
2349 } | 2218 } |
2350 | 2219 |
2351 viewport_width_ = size.width(); | 2220 state_.viewport_width = size.width(); |
2352 viewport_height_ = size.height(); | 2221 state_.viewport_height = size.height(); |
2353 glViewport(viewport_x_, viewport_y_, viewport_width_, viewport_height_); | 2222 glViewport( |
2223 state_.viewport_x, state_.viewport_y, | |
2224 state_.viewport_width, state_.viewport_height); | |
2354 | 2225 |
2355 GLint viewport_params[4] = { 0 }; | 2226 GLint viewport_params[4] = { 0 }; |
2356 glGetIntegerv(GL_MAX_VIEWPORT_DIMS, viewport_params); | 2227 glGetIntegerv(GL_MAX_VIEWPORT_DIMS, viewport_params); |
2357 viewport_max_width_ = viewport_params[0]; | 2228 state_.viewport_max_width = viewport_params[0]; |
2358 viewport_max_height_ = viewport_params[1]; | 2229 state_.viewport_max_height = viewport_params[1]; |
2359 | 2230 |
2360 // Set all the default state because some GL drivers get it wrong. | 2231 // Set all the default state because some GL drivers get it wrong. |
2361 glActiveTexture(GL_TEXTURE0 + active_texture_unit_); | 2232 glActiveTexture(GL_TEXTURE0 + state_.active_texture_unit); |
2362 glLineWidth(1.0); | 2233 glLineWidth(1.0); |
2363 EnableDisable(GL_BLEND, enable_blend_); | 2234 EnableDisable(GL_BLEND, state_.enable_blend); |
2364 glBlendColor(0.0f, 0.0, 0.0f, 0.0f); | 2235 glBlendColor(0.0f, 0.0, 0.0f, 0.0f); |
2365 glBlendFunc(GL_ONE, GL_ZERO); | 2236 glBlendFunc(GL_ONE, GL_ZERO); |
2366 glBlendEquation(GL_FUNC_ADD); | 2237 glBlendEquation(GL_FUNC_ADD); |
2367 glBlendFuncSeparate(GL_ONE, GL_ZERO, GL_ONE, GL_ZERO); | 2238 glBlendFuncSeparate(GL_ONE, GL_ZERO, GL_ONE, GL_ZERO); |
2368 glClearColor(clear_red_, clear_green_, clear_blue_, clear_alpha_); | 2239 glClearColor( |
2369 glColorMask(mask_red_, mask_green_, mask_blue_, mask_alpha_); | 2240 state_.color_clear_red, state_.color_clear_green, state_.color_clear_blue, |
2370 EnableDisable(GL_CULL_FACE, enable_cull_face_); | 2241 state_.color_clear_alpha); |
2242 glColorMask( | |
2243 state_.color_mask_red, state_.color_mask_green, state_.color_mask_blue, | |
2244 state_.color_mask_alpha); | |
2245 EnableDisable(GL_CULL_FACE, state_.enable_cull_face); | |
2371 glCullFace(GL_BACK); | 2246 glCullFace(GL_BACK); |
2372 glClearDepth(clear_depth_); | 2247 glClearDepth(state_.depth_clear); |
2373 glDepthFunc(GL_LESS); | 2248 glDepthFunc(GL_LESS); |
2374 glDepthRange(0.0f, 1.0f); | 2249 glDepthRange(0.0f, 1.0f); |
2375 EnableDisable(GL_DEPTH_TEST, enable_depth_test_); | 2250 EnableDisable(GL_DEPTH_TEST, state_.enable_depth_test); |
2376 glEnable(GL_DITHER); | 2251 glEnable(GL_DITHER); |
2377 glFrontFace(GL_CCW); | 2252 glFrontFace(GL_CCW); |
2378 glHint(GL_GENERATE_MIPMAP_HINT, GL_DONT_CARE); | 2253 glHint(GL_GENERATE_MIPMAP_HINT, GL_DONT_CARE); |
2379 glLineWidth(1.0f); | 2254 glLineWidth(1.0f); |
2380 glPixelStorei(GL_PACK_ALIGNMENT, pack_alignment_); | 2255 glPixelStorei(GL_PACK_ALIGNMENT, state_.pack_alignment); |
2381 glPolygonOffset(0.0f, 0.0f); | 2256 glPolygonOffset(0.0f, 0.0f); |
2382 glDisable(GL_POLYGON_OFFSET_FILL); | 2257 glDisable(GL_POLYGON_OFFSET_FILL); |
2383 glSampleCoverage(1.0, false); | 2258 glSampleCoverage(1.0, false); |
2384 glScissor(viewport_x_, viewport_y_, viewport_width_, viewport_height_); | 2259 glScissor( |
2385 EnableDisable(GL_SCISSOR_TEST, enable_scissor_test_); | 2260 state_.viewport_x, state_.viewport_y, |
2386 EnableDisable(GL_STENCIL_TEST, enable_stencil_test_); | 2261 state_.viewport_width, state_.viewport_height); |
2387 glClearStencil(clear_stencil_); | 2262 EnableDisable(GL_SCISSOR_TEST, state_.enable_scissor_test); |
2263 EnableDisable(GL_STENCIL_TEST, state_.enable_stencil_test); | |
2264 glClearStencil(state_.stencil_clear); | |
2388 glStencilFunc(GL_ALWAYS, 0, 0xFFFFFFFFU); | 2265 glStencilFunc(GL_ALWAYS, 0, 0xFFFFFFFFU); |
2389 glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); | 2266 glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); |
2390 glStencilMaskSeparate(GL_FRONT, mask_stencil_front_); | 2267 glStencilMaskSeparate(GL_FRONT, state_.stencil_mask_front); |
2391 glStencilMaskSeparate(GL_BACK, mask_stencil_back_); | 2268 glStencilMaskSeparate(GL_BACK, state_.stencil_mask_back); |
2392 glPixelStorei(GL_UNPACK_ALIGNMENT, unpack_alignment_); | 2269 glPixelStorei(GL_UNPACK_ALIGNMENT, state_.unpack_alignment); |
2393 | 2270 |
2394 DoBindBuffer(GL_ARRAY_BUFFER, 0); | 2271 DoBindBuffer(GL_ARRAY_BUFFER, 0); |
2395 DoBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); | 2272 DoBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); |
2396 DoBindFramebuffer(GL_FRAMEBUFFER, 0); | 2273 DoBindFramebuffer(GL_FRAMEBUFFER, 0); |
2397 DoBindRenderbuffer(GL_RENDERBUFFER, 0); | 2274 DoBindRenderbuffer(GL_RENDERBUFFER, 0); |
2398 | 2275 |
2399 // AMD and Intel drivers on Mac OS apparently get gl_PointCoord | 2276 // AMD and Intel drivers on Mac OS apparently get gl_PointCoord |
2400 // backward from the spec and this setting makes them work | 2277 // backward from the spec and this setting makes them work |
2401 // correctly. rdar://problem/11883495 | 2278 // correctly. rdar://problem/11883495 |
2402 #if defined(OS_MACOSX) | 2279 #if defined(OS_MACOSX) |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2544 CreateTextureInfo(client_ids[ii], service_ids[ii]); | 2421 CreateTextureInfo(client_ids[ii], service_ids[ii]); |
2545 } | 2422 } |
2546 return true; | 2423 return true; |
2547 } | 2424 } |
2548 | 2425 |
2549 void GLES2DecoderImpl::DeleteBuffersHelper( | 2426 void GLES2DecoderImpl::DeleteBuffersHelper( |
2550 GLsizei n, const GLuint* client_ids) { | 2427 GLsizei n, const GLuint* client_ids) { |
2551 for (GLsizei ii = 0; ii < n; ++ii) { | 2428 for (GLsizei ii = 0; ii < n; ++ii) { |
2552 BufferManager::BufferInfo* buffer = GetBufferInfo(client_ids[ii]); | 2429 BufferManager::BufferInfo* buffer = GetBufferInfo(client_ids[ii]); |
2553 if (buffer && !buffer->IsDeleted()) { | 2430 if (buffer && !buffer->IsDeleted()) { |
2554 vertex_attrib_manager_->Unbind(buffer); | 2431 state_.vertex_attrib_manager->Unbind(buffer); |
2555 if (bound_array_buffer_ == buffer) { | 2432 if (state_.bound_array_buffer == buffer) { |
2556 bound_array_buffer_ = NULL; | 2433 state_.bound_array_buffer = NULL; |
2557 } | 2434 } |
2558 RemoveBufferInfo(client_ids[ii]); | 2435 RemoveBufferInfo(client_ids[ii]); |
2559 } | 2436 } |
2560 } | 2437 } |
2561 } | 2438 } |
2562 | 2439 |
2563 void GLES2DecoderImpl::DeleteFramebuffersHelper( | 2440 void GLES2DecoderImpl::DeleteFramebuffersHelper( |
2564 GLsizei n, const GLuint* client_ids) { | 2441 GLsizei n, const GLuint* client_ids) { |
2565 bool supports_separate_framebuffer_binds = | 2442 bool supports_separate_framebuffer_binds = |
2566 feature_info_->feature_flags().chromium_framebuffer_multisample; | 2443 feature_info_->feature_flags().chromium_framebuffer_multisample; |
2567 | 2444 |
2568 for (GLsizei ii = 0; ii < n; ++ii) { | 2445 for (GLsizei ii = 0; ii < n; ++ii) { |
2569 FramebufferManager::FramebufferInfo* framebuffer = | 2446 FramebufferManager::FramebufferInfo* framebuffer = |
2570 GetFramebufferInfo(client_ids[ii]); | 2447 GetFramebufferInfo(client_ids[ii]); |
2571 if (framebuffer && !framebuffer->IsDeleted()) { | 2448 if (framebuffer && !framebuffer->IsDeleted()) { |
2572 if (framebuffer == bound_draw_framebuffer_) { | 2449 if (framebuffer == state_.bound_draw_framebuffer) { |
2573 bound_draw_framebuffer_ = NULL; | 2450 state_.bound_draw_framebuffer = NULL; |
2574 state_dirty_ = true; | 2451 state_dirty_ = true; |
2575 GLenum target = supports_separate_framebuffer_binds ? | 2452 GLenum target = supports_separate_framebuffer_binds ? |
2576 GL_DRAW_FRAMEBUFFER_EXT : GL_FRAMEBUFFER; | 2453 GL_DRAW_FRAMEBUFFER_EXT : GL_FRAMEBUFFER; |
2577 glBindFramebufferEXT(target, GetBackbufferServiceId()); | 2454 glBindFramebufferEXT(target, GetBackbufferServiceId()); |
2578 } | 2455 } |
2579 if (framebuffer == bound_read_framebuffer_) { | 2456 if (framebuffer == state_.bound_read_framebuffer) { |
2580 bound_read_framebuffer_ = NULL; | 2457 state_.bound_read_framebuffer = NULL; |
2581 GLenum target = supports_separate_framebuffer_binds ? | 2458 GLenum target = supports_separate_framebuffer_binds ? |
2582 GL_READ_FRAMEBUFFER_EXT : GL_FRAMEBUFFER; | 2459 GL_READ_FRAMEBUFFER_EXT : GL_FRAMEBUFFER; |
2583 glBindFramebufferEXT(target, GetBackbufferServiceId()); | 2460 glBindFramebufferEXT(target, GetBackbufferServiceId()); |
2584 } | 2461 } |
2585 RemoveFramebufferInfo(client_ids[ii]); | 2462 RemoveFramebufferInfo(client_ids[ii]); |
2586 } | 2463 } |
2587 } | 2464 } |
2588 } | 2465 } |
2589 | 2466 |
2590 void GLES2DecoderImpl::DeleteRenderbuffersHelper( | 2467 void GLES2DecoderImpl::DeleteRenderbuffersHelper( |
2591 GLsizei n, const GLuint* client_ids) { | 2468 GLsizei n, const GLuint* client_ids) { |
2592 bool supports_separate_framebuffer_binds = | 2469 bool supports_separate_framebuffer_binds = |
2593 feature_info_->feature_flags().chromium_framebuffer_multisample; | 2470 feature_info_->feature_flags().chromium_framebuffer_multisample; |
2594 for (GLsizei ii = 0; ii < n; ++ii) { | 2471 for (GLsizei ii = 0; ii < n; ++ii) { |
2595 RenderbufferManager::RenderbufferInfo* renderbuffer = | 2472 RenderbufferManager::RenderbufferInfo* renderbuffer = |
2596 GetRenderbufferInfo(client_ids[ii]); | 2473 GetRenderbufferInfo(client_ids[ii]); |
2597 if (renderbuffer && !renderbuffer->IsDeleted()) { | 2474 if (renderbuffer && !renderbuffer->IsDeleted()) { |
2598 if (bound_renderbuffer_ == renderbuffer) { | 2475 if (state_.bound_renderbuffer == renderbuffer) { |
2599 bound_renderbuffer_ = NULL; | 2476 state_.bound_renderbuffer = NULL; |
2600 } | 2477 } |
2601 // Unbind from current framebuffers. | 2478 // Unbind from current framebuffers. |
2602 if (supports_separate_framebuffer_binds) { | 2479 if (supports_separate_framebuffer_binds) { |
2603 if (bound_read_framebuffer_) { | 2480 if (state_.bound_read_framebuffer) { |
2604 bound_read_framebuffer_->UnbindRenderbuffer( | 2481 state_.bound_read_framebuffer->UnbindRenderbuffer( |
2605 GL_READ_FRAMEBUFFER_EXT, renderbuffer); | 2482 GL_READ_FRAMEBUFFER_EXT, renderbuffer); |
2606 } | 2483 } |
2607 if (bound_draw_framebuffer_) { | 2484 if (state_.bound_draw_framebuffer) { |
2608 bound_draw_framebuffer_->UnbindRenderbuffer( | 2485 state_.bound_draw_framebuffer->UnbindRenderbuffer( |
2609 GL_DRAW_FRAMEBUFFER_EXT, renderbuffer); | 2486 GL_DRAW_FRAMEBUFFER_EXT, renderbuffer); |
2610 } | 2487 } |
2611 } else { | 2488 } else { |
2612 if (bound_draw_framebuffer_) { | 2489 if (state_.bound_draw_framebuffer) { |
2613 bound_draw_framebuffer_->UnbindRenderbuffer( | 2490 state_.bound_draw_framebuffer->UnbindRenderbuffer( |
2614 GL_FRAMEBUFFER, renderbuffer); | 2491 GL_FRAMEBUFFER, renderbuffer); |
2615 } | 2492 } |
2616 } | 2493 } |
2617 state_dirty_ = true; | 2494 state_dirty_ = true; |
2618 RemoveRenderbufferInfo(client_ids[ii]); | 2495 RemoveRenderbufferInfo(client_ids[ii]); |
2619 } | 2496 } |
2620 } | 2497 } |
2621 } | 2498 } |
2622 | 2499 |
2623 void GLES2DecoderImpl::DeleteTexturesHelper( | 2500 void GLES2DecoderImpl::DeleteTexturesHelper( |
2624 GLsizei n, const GLuint* client_ids) { | 2501 GLsizei n, const GLuint* client_ids) { |
2625 bool supports_separate_framebuffer_binds = | 2502 bool supports_separate_framebuffer_binds = |
2626 feature_info_->feature_flags().chromium_framebuffer_multisample; | 2503 feature_info_->feature_flags().chromium_framebuffer_multisample; |
2627 for (GLsizei ii = 0; ii < n; ++ii) { | 2504 for (GLsizei ii = 0; ii < n; ++ii) { |
2628 TextureManager::TextureInfo* texture = GetTextureInfo(client_ids[ii]); | 2505 TextureManager::TextureInfo* texture = GetTextureInfo(client_ids[ii]); |
2629 if (texture && !texture->IsDeleted()) { | 2506 if (texture && !texture->IsDeleted()) { |
2630 if (texture->IsAttachedToFramebuffer()) { | 2507 if (texture->IsAttachedToFramebuffer()) { |
2631 state_dirty_ = true; | 2508 state_dirty_ = true; |
2632 } | 2509 } |
2633 // Unbind texture from texture units. | 2510 // Unbind texture from texture units. |
2634 for (size_t jj = 0; jj < group_->max_texture_units(); ++jj) { | 2511 for (size_t jj = 0; jj < group_->max_texture_units(); ++jj) { |
2635 texture_units_[jj].Unbind(texture); | 2512 state_.texture_units[jj].Unbind(texture); |
2636 } | 2513 } |
2637 // Unbind from current framebuffers. | 2514 // Unbind from current framebuffers. |
2638 if (supports_separate_framebuffer_binds) { | 2515 if (supports_separate_framebuffer_binds) { |
2639 if (bound_read_framebuffer_) { | 2516 if (state_.bound_read_framebuffer) { |
2640 bound_read_framebuffer_->UnbindTexture( | 2517 state_.bound_read_framebuffer->UnbindTexture( |
2641 GL_READ_FRAMEBUFFER_EXT, texture); | 2518 GL_READ_FRAMEBUFFER_EXT, texture); |
2642 } | 2519 } |
2643 if (bound_draw_framebuffer_) { | 2520 if (state_.bound_draw_framebuffer) { |
2644 bound_draw_framebuffer_->UnbindTexture( | 2521 state_.bound_draw_framebuffer->UnbindTexture( |
2645 GL_DRAW_FRAMEBUFFER_EXT, texture); | 2522 GL_DRAW_FRAMEBUFFER_EXT, texture); |
2646 } | 2523 } |
2647 } else { | 2524 } else { |
2648 if (bound_draw_framebuffer_) { | 2525 if (state_.bound_draw_framebuffer) { |
2649 bound_draw_framebuffer_->UnbindTexture(GL_FRAMEBUFFER, texture); | 2526 state_.bound_draw_framebuffer->UnbindTexture(GL_FRAMEBUFFER, texture); |
2650 } | 2527 } |
2651 } | 2528 } |
2652 GLuint service_id = texture->service_id(); | 2529 GLuint service_id = texture->service_id(); |
2653 if (texture->IsStreamTexture() && stream_texture_manager_) { | 2530 if (texture->IsStreamTexture() && stream_texture_manager_) { |
2654 stream_texture_manager_->DestroyStreamTexture(service_id); | 2531 stream_texture_manager_->DestroyStreamTexture(service_id); |
2655 } | 2532 } |
2656 #if defined(OS_MACOSX) | 2533 #if defined(OS_MACOSX) |
2657 if (texture->target() == GL_TEXTURE_RECTANGLE_ARB) { | 2534 if (texture->target() == GL_TEXTURE_RECTANGLE_ARB) { |
2658 ReleaseIOSurfaceForTexture(service_id); | 2535 ReleaseIOSurfaceForTexture(service_id); |
2659 } | 2536 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2701 | 2578 |
2702 glBindFramebufferEXT(target, framebuffer_id); | 2579 glBindFramebufferEXT(target, framebuffer_id); |
2703 } | 2580 } |
2704 | 2581 |
2705 void GLES2DecoderImpl::RestoreCurrentFramebufferBindings() { | 2582 void GLES2DecoderImpl::RestoreCurrentFramebufferBindings() { |
2706 state_dirty_ = true; | 2583 state_dirty_ = true; |
2707 | 2584 |
2708 if (!feature_info_->feature_flags().chromium_framebuffer_multisample) { | 2585 if (!feature_info_->feature_flags().chromium_framebuffer_multisample) { |
2709 RebindCurrentFramebuffer( | 2586 RebindCurrentFramebuffer( |
2710 GL_FRAMEBUFFER, | 2587 GL_FRAMEBUFFER, |
2711 bound_draw_framebuffer_.get(), | 2588 state_.bound_draw_framebuffer.get(), |
2712 GetBackbufferServiceId()); | 2589 GetBackbufferServiceId()); |
2713 } else { | 2590 } else { |
2714 RebindCurrentFramebuffer( | 2591 RebindCurrentFramebuffer( |
2715 GL_READ_FRAMEBUFFER_EXT, | 2592 GL_READ_FRAMEBUFFER_EXT, |
2716 bound_read_framebuffer_.get(), | 2593 state_.bound_read_framebuffer.get(), |
2717 GetBackbufferServiceId()); | 2594 GetBackbufferServiceId()); |
2718 RebindCurrentFramebuffer( | 2595 RebindCurrentFramebuffer( |
2719 GL_DRAW_FRAMEBUFFER_EXT, | 2596 GL_DRAW_FRAMEBUFFER_EXT, |
2720 bound_draw_framebuffer_.get(), | 2597 state_.bound_draw_framebuffer.get(), |
2721 GetBackbufferServiceId()); | 2598 GetBackbufferServiceId()); |
2722 } | 2599 } |
2723 } | 2600 } |
2724 | 2601 |
2725 void GLES2DecoderImpl::RestoreCurrentTexture2DBindings() { | 2602 void GLES2DecoderImpl::RestoreCurrentTexture2DBindings() { |
2726 GLES2DecoderImpl::TextureUnit& info = texture_units_[0]; | 2603 TextureUnit& info = state_.texture_units[0]; |
2727 GLuint last_id; | 2604 GLuint last_id; |
2728 if (info.bound_texture_2d) { | 2605 if (info.bound_texture_2d) { |
2729 last_id = info.bound_texture_2d->service_id(); | 2606 last_id = info.bound_texture_2d->service_id(); |
2730 } else { | 2607 } else { |
2731 last_id = 0; | 2608 last_id = 0; |
2732 } | 2609 } |
2733 | 2610 |
2734 glBindTexture(GL_TEXTURE_2D, last_id); | 2611 glBindTexture(GL_TEXTURE_2D, last_id); |
2735 glActiveTexture(GL_TEXTURE0 + active_texture_unit_); | 2612 glActiveTexture(GL_TEXTURE0 + state_.active_texture_unit); |
2736 } | 2613 } |
2737 | 2614 |
2738 bool GLES2DecoderImpl::CheckFramebufferValid( | 2615 bool GLES2DecoderImpl::CheckFramebufferValid( |
2739 FramebufferManager::FramebufferInfo* framebuffer, | 2616 FramebufferManager::FramebufferInfo* framebuffer, |
2740 GLenum target, const char* func_name) { | 2617 GLenum target, const char* func_name) { |
2741 if (!framebuffer) { | 2618 if (!framebuffer) { |
2742 return true; | 2619 return true; |
2743 } | 2620 } |
2744 | 2621 |
2745 if (framebuffer_manager()->IsComplete(framebuffer)) { | 2622 if (framebuffer_manager()->IsComplete(framebuffer)) { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2779 } | 2656 } |
2780 | 2657 |
2781 // NOTE: At this point we don't know if the framebuffer is complete but | 2658 // NOTE: At this point we don't know if the framebuffer is complete but |
2782 // we DO know that everything that needs to be cleared has been cleared. | 2659 // we DO know that everything that needs to be cleared has been cleared. |
2783 return true; | 2660 return true; |
2784 } | 2661 } |
2785 | 2662 |
2786 bool GLES2DecoderImpl::CheckBoundFramebuffersValid(const char* func_name) { | 2663 bool GLES2DecoderImpl::CheckBoundFramebuffersValid(const char* func_name) { |
2787 if (!feature_info_->feature_flags().chromium_framebuffer_multisample) { | 2664 if (!feature_info_->feature_flags().chromium_framebuffer_multisample) { |
2788 return CheckFramebufferValid( | 2665 return CheckFramebufferValid( |
2789 bound_draw_framebuffer_, GL_FRAMEBUFFER_EXT, func_name); | 2666 state_.bound_draw_framebuffer, GL_FRAMEBUFFER_EXT, func_name); |
2790 } | 2667 } |
2791 return CheckFramebufferValid( | 2668 return CheckFramebufferValid( |
2792 bound_draw_framebuffer_, GL_DRAW_FRAMEBUFFER_EXT, func_name) && | 2669 state_.bound_draw_framebuffer, |
2670 GL_DRAW_FRAMEBUFFER_EXT, func_name) && | |
2793 CheckFramebufferValid( | 2671 CheckFramebufferValid( |
2794 bound_read_framebuffer_, GL_READ_FRAMEBUFFER_EXT, func_name); | 2672 state_.bound_read_framebuffer, |
2673 GL_READ_FRAMEBUFFER_EXT, func_name); | |
2795 } | 2674 } |
2796 | 2675 |
2797 gfx::Size GLES2DecoderImpl::GetBoundReadFrameBufferSize() { | 2676 gfx::Size GLES2DecoderImpl::GetBoundReadFrameBufferSize() { |
2798 FramebufferManager::FramebufferInfo* framebuffer = | 2677 FramebufferManager::FramebufferInfo* framebuffer = |
2799 GetFramebufferInfoForTarget(GL_READ_FRAMEBUFFER_EXT); | 2678 GetFramebufferInfoForTarget(GL_READ_FRAMEBUFFER_EXT); |
2800 if (framebuffer != NULL) { | 2679 if (framebuffer != NULL) { |
2801 const FramebufferManager::FramebufferInfo::Attachment* attachment = | 2680 const FramebufferManager::FramebufferInfo::Attachment* attachment = |
2802 framebuffer->GetAttachment(GL_COLOR_ATTACHMENT0); | 2681 framebuffer->GetAttachment(GL_COLOR_ATTACHMENT0); |
2803 if (attachment) { | 2682 if (attachment) { |
2804 return gfx::Size(attachment->width(), attachment->height()); | 2683 return gfx::Size(attachment->width(), attachment->height()); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2917 void GLES2DecoderImpl::Destroy(bool have_context) { | 2796 void GLES2DecoderImpl::Destroy(bool have_context) { |
2918 DCHECK(!have_context || context_->IsCurrent(NULL)); | 2797 DCHECK(!have_context || context_->IsCurrent(NULL)); |
2919 | 2798 |
2920 ChildList children = children_; | 2799 ChildList children = children_; |
2921 for (ChildList::iterator it = children.begin(); it != children.end(); ++it) | 2800 for (ChildList::iterator it = children.begin(); it != children.end(); ++it) |
2922 (*it)->SetParent(NULL, 0); | 2801 (*it)->SetParent(NULL, 0); |
2923 DCHECK(children_.empty()); | 2802 DCHECK(children_.empty()); |
2924 SetParent(NULL, 0); | 2803 SetParent(NULL, 0); |
2925 | 2804 |
2926 // Unbind everything. | 2805 // Unbind everything. |
2927 vertex_attrib_manager_ = NULL; | 2806 state_.vertex_attrib_manager = NULL; |
2928 default_vertex_attrib_manager_ = NULL; | 2807 default_vertex_attrib_manager_ = NULL; |
2929 texture_units_.reset(); | 2808 state_.texture_units.reset(); |
2930 bound_array_buffer_ = NULL; | 2809 state_.bound_array_buffer = NULL; |
2931 current_query_ = NULL; | 2810 state_.current_query = NULL; |
2932 current_program_ = NULL; | 2811 state_.current_program = NULL; |
2933 bound_read_framebuffer_ = NULL; | 2812 state_.bound_read_framebuffer = NULL; |
2934 bound_draw_framebuffer_ = NULL; | 2813 state_.bound_draw_framebuffer = NULL; |
2935 bound_renderbuffer_ = NULL; | 2814 state_.bound_renderbuffer = NULL; |
2936 | 2815 |
2937 if (have_context) { | 2816 if (have_context) { |
2938 if (copy_texture_CHROMIUM_.get()) { | 2817 if (copy_texture_CHROMIUM_.get()) { |
2939 copy_texture_CHROMIUM_->Destroy(); | 2818 copy_texture_CHROMIUM_->Destroy(); |
2940 copy_texture_CHROMIUM_.reset(); | 2819 copy_texture_CHROMIUM_.reset(); |
2941 } | 2820 } |
2942 | 2821 |
2943 if (current_program_) { | 2822 if (state_.current_program) { |
2944 program_manager()->UnuseProgram(shader_manager(), current_program_); | 2823 program_manager()->UnuseProgram(shader_manager(), state_.current_program); |
2945 current_program_ = NULL; | 2824 state_.current_program = NULL; |
2946 } | 2825 } |
2947 | 2826 |
2948 if (attrib_0_buffer_id_) { | 2827 if (attrib_0_buffer_id_) { |
2949 glDeleteBuffersARB(1, &attrib_0_buffer_id_); | 2828 glDeleteBuffersARB(1, &attrib_0_buffer_id_); |
2950 } | 2829 } |
2951 if (fixed_attrib_buffer_id_) { | 2830 if (fixed_attrib_buffer_id_) { |
2952 glDeleteBuffersARB(1, &fixed_attrib_buffer_id_); | 2831 glDeleteBuffersARB(1, &fixed_attrib_buffer_id_); |
2953 } | 2832 } |
2954 | 2833 |
2955 if (offscreen_target_frame_buffer_.get()) | 2834 if (offscreen_target_frame_buffer_.get()) |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3379 ProcessPendingQueries(); | 3258 ProcessPendingQueries(); |
3380 } | 3259 } |
3381 | 3260 |
3382 void GLES2DecoderImpl::DoActiveTexture(GLenum texture_unit) { | 3261 void GLES2DecoderImpl::DoActiveTexture(GLenum texture_unit) { |
3383 GLuint texture_index = texture_unit - GL_TEXTURE0; | 3262 GLuint texture_index = texture_unit - GL_TEXTURE0; |
3384 if (texture_index >= group_->max_texture_units()) { | 3263 if (texture_index >= group_->max_texture_units()) { |
3385 SetGLErrorInvalidEnum( | 3264 SetGLErrorInvalidEnum( |
3386 "glActiveTexture", texture_unit, "texture_unit"); | 3265 "glActiveTexture", texture_unit, "texture_unit"); |
3387 return; | 3266 return; |
3388 } | 3267 } |
3389 active_texture_unit_ = texture_index; | 3268 state_.active_texture_unit = texture_index; |
3390 glActiveTexture(texture_unit); | 3269 glActiveTexture(texture_unit); |
3391 } | 3270 } |
3392 | 3271 |
3393 void GLES2DecoderImpl::DoBindBuffer(GLenum target, GLuint client_id) { | 3272 void GLES2DecoderImpl::DoBindBuffer(GLenum target, GLuint client_id) { |
3394 BufferManager::BufferInfo* info = NULL; | 3273 BufferManager::BufferInfo* info = NULL; |
3395 GLuint service_id = 0; | 3274 GLuint service_id = 0; |
3396 if (client_id != 0) { | 3275 if (client_id != 0) { |
3397 info = GetBufferInfo(client_id); | 3276 info = GetBufferInfo(client_id); |
3398 if (!info) { | 3277 if (!info) { |
3399 if (!group_->bind_generates_resource()) { | 3278 if (!group_->bind_generates_resource()) { |
(...skipping 14 matching lines...) Expand all Loading... | |
3414 if (info) { | 3293 if (info) { |
3415 if (!buffer_manager()->SetTarget(info, target)) { | 3294 if (!buffer_manager()->SetTarget(info, target)) { |
3416 SetGLError(GL_INVALID_OPERATION, | 3295 SetGLError(GL_INVALID_OPERATION, |
3417 "glBindBuffer", "buffer bound to more than 1 target"); | 3296 "glBindBuffer", "buffer bound to more than 1 target"); |
3418 return; | 3297 return; |
3419 } | 3298 } |
3420 service_id = info->service_id(); | 3299 service_id = info->service_id(); |
3421 } | 3300 } |
3422 switch (target) { | 3301 switch (target) { |
3423 case GL_ARRAY_BUFFER: | 3302 case GL_ARRAY_BUFFER: |
3424 bound_array_buffer_ = info; | 3303 state_.bound_array_buffer = info; |
3425 break; | 3304 break; |
3426 case GL_ELEMENT_ARRAY_BUFFER: | 3305 case GL_ELEMENT_ARRAY_BUFFER: |
3427 vertex_attrib_manager_->SetElementArrayBuffer(info); | 3306 state_.vertex_attrib_manager->SetElementArrayBuffer(info); |
3428 break; | 3307 break; |
3429 default: | 3308 default: |
3430 NOTREACHED(); // Validation should prevent us getting here. | 3309 NOTREACHED(); // Validation should prevent us getting here. |
3431 break; | 3310 break; |
3432 } | 3311 } |
3433 glBindBuffer(target, service_id); | 3312 glBindBuffer(target, service_id); |
3434 } | 3313 } |
3435 | 3314 |
3436 bool GLES2DecoderImpl::BoundFramebufferHasColorAttachmentWithAlpha() { | 3315 bool GLES2DecoderImpl::BoundFramebufferHasColorAttachmentWithAlpha() { |
3437 return (GLES2Util::GetChannelsForFormat( | 3316 return (GLES2Util::GetChannelsForFormat( |
(...skipping 21 matching lines...) Expand all Loading... | |
3459 if (offscreen_target_frame_buffer_.get()) { | 3338 if (offscreen_target_frame_buffer_.get()) { |
3460 return offscreen_target_stencil_format_ != 0 || | 3339 return offscreen_target_stencil_format_ != 0 || |
3461 offscreen_target_depth_format_ == GL_DEPTH24_STENCIL8; | 3340 offscreen_target_depth_format_ == GL_DEPTH24_STENCIL8; |
3462 } | 3341 } |
3463 return back_buffer_has_stencil_; | 3342 return back_buffer_has_stencil_; |
3464 } | 3343 } |
3465 | 3344 |
3466 void GLES2DecoderImpl::ApplyDirtyState() { | 3345 void GLES2DecoderImpl::ApplyDirtyState() { |
3467 if (state_dirty_) { | 3346 if (state_dirty_) { |
3468 glColorMask( | 3347 glColorMask( |
3469 mask_red_, mask_green_, mask_blue_, | 3348 state_.color_mask_red, state_.color_mask_green, state_.color_mask_blue, |
3470 mask_alpha_ && BoundFramebufferHasColorAttachmentWithAlpha()); | 3349 state_.color_mask_alpha && |
3350 BoundFramebufferHasColorAttachmentWithAlpha()); | |
3471 bool have_depth = BoundFramebufferHasDepthAttachment(); | 3351 bool have_depth = BoundFramebufferHasDepthAttachment(); |
3472 glDepthMask(mask_depth_ && have_depth); | 3352 glDepthMask(state_.depth_mask && have_depth); |
3473 EnableDisable(GL_DEPTH_TEST, enable_depth_test_ && have_depth); | 3353 EnableDisable(GL_DEPTH_TEST, state_.enable_depth_test && have_depth); |
3474 bool have_stencil = BoundFramebufferHasStencilAttachment(); | 3354 bool have_stencil = BoundFramebufferHasStencilAttachment(); |
3475 glStencilMaskSeparate(GL_FRONT, have_stencil ? mask_stencil_front_ : 0); | 3355 glStencilMaskSeparate( |
3476 glStencilMaskSeparate(GL_BACK, have_stencil ? mask_stencil_back_ : 0); | 3356 GL_FRONT, have_stencil ? state_.stencil_mask_front : 0); |
3477 EnableDisable(GL_STENCIL_TEST, enable_stencil_test_ && have_stencil); | 3357 glStencilMaskSeparate( |
3478 EnableDisable(GL_CULL_FACE, enable_cull_face_); | 3358 GL_BACK, have_stencil ? state_.stencil_mask_back : 0); |
3479 EnableDisable(GL_SCISSOR_TEST, enable_scissor_test_); | 3359 EnableDisable(GL_STENCIL_TEST, state_.enable_stencil_test && have_stencil); |
3480 EnableDisable(GL_BLEND, enable_blend_); | 3360 EnableDisable(GL_CULL_FACE, state_.enable_cull_face); |
3361 EnableDisable(GL_SCISSOR_TEST, state_.enable_scissor_test); | |
3362 EnableDisable(GL_BLEND, state_.enable_blend); | |
3481 state_dirty_ = false; | 3363 state_dirty_ = false; |
3482 } | 3364 } |
3483 } | 3365 } |
3484 | 3366 |
3485 void GLES2DecoderImpl::BindAndApplyTextureParameters( | 3367 void GLES2DecoderImpl::BindAndApplyTextureParameters( |
3486 TextureManager::TextureInfo* info) { | 3368 TextureManager::TextureInfo* info) { |
3487 glBindTexture(info->target(), info->service_id()); | 3369 glBindTexture(info->target(), info->service_id()); |
3488 glTexParameteri(info->target(), GL_TEXTURE_MIN_FILTER, info->min_filter()); | 3370 glTexParameteri(info->target(), GL_TEXTURE_MIN_FILTER, info->min_filter()); |
3489 glTexParameteri(info->target(), GL_TEXTURE_MAG_FILTER, info->mag_filter()); | 3371 glTexParameteri(info->target(), GL_TEXTURE_MAG_FILTER, info->mag_filter()); |
3490 glTexParameteri(info->target(), GL_TEXTURE_WRAP_S, info->wrap_s()); | 3372 glTexParameteri(info->target(), GL_TEXTURE_WRAP_S, info->wrap_s()); |
(...skipping 26 matching lines...) Expand all Loading... | |
3517 IdAllocatorInterface* id_allocator = | 3399 IdAllocatorInterface* id_allocator = |
3518 group_->GetIdAllocator(id_namespaces::kFramebuffers); | 3400 group_->GetIdAllocator(id_namespaces::kFramebuffers); |
3519 id_allocator->MarkAsUsed(client_id); | 3401 id_allocator->MarkAsUsed(client_id); |
3520 } else { | 3402 } else { |
3521 service_id = info->service_id(); | 3403 service_id = info->service_id(); |
3522 } | 3404 } |
3523 info->MarkAsValid(); | 3405 info->MarkAsValid(); |
3524 } | 3406 } |
3525 | 3407 |
3526 if (target == GL_FRAMEBUFFER || target == GL_DRAW_FRAMEBUFFER_EXT) { | 3408 if (target == GL_FRAMEBUFFER || target == GL_DRAW_FRAMEBUFFER_EXT) { |
3527 bound_draw_framebuffer_ = info; | 3409 state_.bound_draw_framebuffer = info; |
3528 } | 3410 } |
3529 if (target == GL_FRAMEBUFFER || target == GL_READ_FRAMEBUFFER_EXT) { | 3411 if (target == GL_FRAMEBUFFER || target == GL_READ_FRAMEBUFFER_EXT) { |
3530 bound_read_framebuffer_ = info; | 3412 state_.bound_read_framebuffer = info; |
3531 } | 3413 } |
3532 | 3414 |
3533 state_dirty_ = true; | 3415 state_dirty_ = true; |
3534 | 3416 |
3535 // If we are rendering to the backbuffer get the FBO id for any simulated | 3417 // If we are rendering to the backbuffer get the FBO id for any simulated |
3536 // backbuffer. | 3418 // backbuffer. |
3537 if (info == NULL) { | 3419 if (info == NULL) { |
3538 service_id = GetBackbufferServiceId(); | 3420 service_id = GetBackbufferServiceId(); |
3539 } | 3421 } |
3540 | 3422 |
(...skipping 18 matching lines...) Expand all Loading... | |
3559 CreateRenderbufferInfo(client_id, service_id); | 3441 CreateRenderbufferInfo(client_id, service_id); |
3560 info = GetRenderbufferInfo(client_id); | 3442 info = GetRenderbufferInfo(client_id); |
3561 IdAllocatorInterface* id_allocator = | 3443 IdAllocatorInterface* id_allocator = |
3562 group_->GetIdAllocator(id_namespaces::kRenderbuffers); | 3444 group_->GetIdAllocator(id_namespaces::kRenderbuffers); |
3563 id_allocator->MarkAsUsed(client_id); | 3445 id_allocator->MarkAsUsed(client_id); |
3564 } else { | 3446 } else { |
3565 service_id = info->service_id(); | 3447 service_id = info->service_id(); |
3566 } | 3448 } |
3567 info->MarkAsValid(); | 3449 info->MarkAsValid(); |
3568 } | 3450 } |
3569 bound_renderbuffer_ = info; | 3451 state_.bound_renderbuffer = info; |
3570 glBindRenderbufferEXT(target, service_id); | 3452 glBindRenderbufferEXT(target, service_id); |
3571 } | 3453 } |
3572 | 3454 |
3573 void GLES2DecoderImpl::DoBindTexture(GLenum target, GLuint client_id) { | 3455 void GLES2DecoderImpl::DoBindTexture(GLenum target, GLuint client_id) { |
3574 TextureManager::TextureInfo* info = NULL; | 3456 TextureManager::TextureInfo* info = NULL; |
3575 GLuint service_id = 0; | 3457 GLuint service_id = 0; |
3576 if (client_id != 0) { | 3458 if (client_id != 0) { |
3577 info = GetTextureInfo(client_id); | 3459 info = GetTextureInfo(client_id); |
3578 if (!info) { | 3460 if (!info) { |
3579 if (!group_->bind_generates_resource()) { | 3461 if (!group_->bind_generates_resource()) { |
(...skipping 24 matching lines...) Expand all Loading... | |
3604 } | 3486 } |
3605 if (info->IsStreamTexture() && target != GL_TEXTURE_EXTERNAL_OES) { | 3487 if (info->IsStreamTexture() && target != GL_TEXTURE_EXTERNAL_OES) { |
3606 SetGLError(GL_INVALID_OPERATION, | 3488 SetGLError(GL_INVALID_OPERATION, |
3607 "glBindTexture", "illegal target for stream texture."); | 3489 "glBindTexture", "illegal target for stream texture."); |
3608 return; | 3490 return; |
3609 } | 3491 } |
3610 if (info->target() == 0) { | 3492 if (info->target() == 0) { |
3611 texture_manager()->SetInfoTarget(info, target); | 3493 texture_manager()->SetInfoTarget(info, target); |
3612 } | 3494 } |
3613 glBindTexture(target, info->service_id()); | 3495 glBindTexture(target, info->service_id()); |
3614 TextureUnit& unit = texture_units_[active_texture_unit_]; | 3496 TextureUnit& unit = state_.texture_units[state_.active_texture_unit]; |
3615 unit.bind_target = target; | 3497 unit.bind_target = target; |
3616 switch (target) { | 3498 switch (target) { |
3617 case GL_TEXTURE_2D: | 3499 case GL_TEXTURE_2D: |
3618 unit.bound_texture_2d = info; | 3500 unit.bound_texture_2d = info; |
3619 break; | 3501 break; |
3620 case GL_TEXTURE_CUBE_MAP: | 3502 case GL_TEXTURE_CUBE_MAP: |
3621 unit.bound_texture_cube_map = info; | 3503 unit.bound_texture_cube_map = info; |
3622 break; | 3504 break; |
3623 case GL_TEXTURE_EXTERNAL_OES: | 3505 case GL_TEXTURE_EXTERNAL_OES: |
3624 unit.bound_texture_external_oes = info; | 3506 unit.bound_texture_external_oes = info; |
3625 if (info->IsStreamTexture()) { | 3507 if (info->IsStreamTexture()) { |
3626 DCHECK(stream_texture_manager_); | 3508 DCHECK(stream_texture_manager_); |
3627 StreamTexture* stream_tex = | 3509 StreamTexture* stream_tex = |
3628 stream_texture_manager_->LookupStreamTexture(info->service_id()); | 3510 stream_texture_manager_->LookupStreamTexture(info->service_id()); |
3629 if (stream_tex) | 3511 if (stream_tex) |
3630 stream_tex->Update(); | 3512 stream_tex->Update(); |
3631 } | 3513 } |
3632 break; | 3514 break; |
3633 case GL_TEXTURE_RECTANGLE_ARB: | 3515 case GL_TEXTURE_RECTANGLE_ARB: |
3634 unit.bound_texture_rectangle_arb = info; | 3516 unit.bound_texture_rectangle_arb = info; |
3635 break; | 3517 break; |
3636 default: | 3518 default: |
3637 NOTREACHED(); // Validation should prevent us getting here. | 3519 NOTREACHED(); // Validation should prevent us getting here. |
3638 break; | 3520 break; |
3639 } | 3521 } |
3640 } | 3522 } |
3641 | 3523 |
3642 void GLES2DecoderImpl::DoDisableVertexAttribArray(GLuint index) { | 3524 void GLES2DecoderImpl::DoDisableVertexAttribArray(GLuint index) { |
3643 if (vertex_attrib_manager_->Enable(index, false)) { | 3525 if (state_.vertex_attrib_manager->Enable(index, false)) { |
3644 if (index != 0 || | 3526 if (index != 0 || |
3645 gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2) { | 3527 gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2) { |
3646 glDisableVertexAttribArray(index); | 3528 glDisableVertexAttribArray(index); |
3647 } | 3529 } |
3648 } else { | 3530 } else { |
3649 SetGLError(GL_INVALID_VALUE, | 3531 SetGLError(GL_INVALID_VALUE, |
3650 "glDisableVertexAttribArray", "index out of range"); | 3532 "glDisableVertexAttribArray", "index out of range"); |
3651 } | 3533 } |
3652 } | 3534 } |
3653 | 3535 |
3654 void GLES2DecoderImpl::DoEnableVertexAttribArray(GLuint index) { | 3536 void GLES2DecoderImpl::DoEnableVertexAttribArray(GLuint index) { |
3655 if (vertex_attrib_manager_->Enable(index, true)) { | 3537 if (state_.vertex_attrib_manager->Enable(index, true)) { |
3656 glEnableVertexAttribArray(index); | 3538 glEnableVertexAttribArray(index); |
3657 } else { | 3539 } else { |
3658 SetGLError(GL_INVALID_VALUE, | 3540 SetGLError(GL_INVALID_VALUE, |
3659 "glEnableVertexAttribArray", "index out of range"); | 3541 "glEnableVertexAttribArray", "index out of range"); |
3660 } | 3542 } |
3661 } | 3543 } |
3662 | 3544 |
3663 void GLES2DecoderImpl::DoGenerateMipmap(GLenum target) { | 3545 void GLES2DecoderImpl::DoGenerateMipmap(GLenum target) { |
3664 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); | 3546 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); |
3665 if (!info || | 3547 if (!info || |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3762 return true; | 3644 return true; |
3763 case GL_MAX_CUBE_MAP_TEXTURE_SIZE: | 3645 case GL_MAX_CUBE_MAP_TEXTURE_SIZE: |
3764 *num_written = 1; | 3646 *num_written = 1; |
3765 if (params) { | 3647 if (params) { |
3766 params[0] = texture_manager()->MaxSizeForTarget(GL_TEXTURE_CUBE_MAP); | 3648 params[0] = texture_manager()->MaxSizeForTarget(GL_TEXTURE_CUBE_MAP); |
3767 } | 3649 } |
3768 return true; | 3650 return true; |
3769 case GL_COLOR_WRITEMASK: | 3651 case GL_COLOR_WRITEMASK: |
3770 *num_written = 4; | 3652 *num_written = 4; |
3771 if (params) { | 3653 if (params) { |
3772 params[0] = mask_red_; | 3654 params[0] = state_.color_mask_red; |
3773 params[1] = mask_green_; | 3655 params[1] = state_.color_mask_green; |
3774 params[2] = mask_blue_; | 3656 params[2] = state_.color_mask_blue; |
3775 params[3] = mask_alpha_; | 3657 params[3] = state_.color_mask_alpha; |
3776 } | 3658 } |
3777 return true; | 3659 return true; |
3778 case GL_DEPTH_WRITEMASK: | 3660 case GL_DEPTH_WRITEMASK: |
3779 *num_written = 1; | 3661 *num_written = 1; |
3780 if (params) { | 3662 if (params) { |
3781 params[0] = mask_depth_; | 3663 params[0] = state_.depth_mask; |
3782 } | 3664 } |
3783 return true; | 3665 return true; |
3784 case GL_STENCIL_BACK_WRITEMASK: | 3666 case GL_STENCIL_BACK_WRITEMASK: |
3785 *num_written = 1; | 3667 *num_written = 1; |
3786 if (params) { | 3668 if (params) { |
3787 params[0] = mask_stencil_back_; | 3669 params[0] = state_.stencil_mask_back; |
3788 } | 3670 } |
3789 return true; | 3671 return true; |
3790 case GL_STENCIL_WRITEMASK: | 3672 case GL_STENCIL_WRITEMASK: |
3791 *num_written = 1; | 3673 *num_written = 1; |
3792 if (params) { | 3674 if (params) { |
3793 params[0] = mask_stencil_front_; | 3675 params[0] = state_.stencil_mask_front; |
3794 } | 3676 } |
3795 return true; | 3677 return true; |
3796 case GL_DEPTH_TEST: | 3678 case GL_DEPTH_TEST: |
3797 *num_written = 1; | 3679 *num_written = 1; |
3798 if (params) { | 3680 if (params) { |
3799 params[0] = enable_depth_test_; | 3681 params[0] = state_.enable_depth_test; |
3800 } | 3682 } |
3801 return true; | 3683 return true; |
3802 case GL_STENCIL_TEST: | 3684 case GL_STENCIL_TEST: |
3803 *num_written = 1; | 3685 *num_written = 1; |
3804 if (params) { | 3686 if (params) { |
3805 params[0] = enable_stencil_test_; | 3687 params[0] = state_.enable_stencil_test; |
3806 } | 3688 } |
3807 return true; | 3689 return true; |
3808 case GL_ALPHA_BITS: | 3690 case GL_ALPHA_BITS: |
3809 *num_written = 1; | 3691 *num_written = 1; |
3810 if (params) { | 3692 if (params) { |
3811 GLint v = 0; | 3693 GLint v = 0; |
3812 glGetIntegerv(GL_ALPHA_BITS, &v); | 3694 glGetIntegerv(GL_ALPHA_BITS, &v); |
3813 params[0] = BoundFramebufferHasColorAttachmentWithAlpha() ? v : 0; | 3695 params[0] = BoundFramebufferHasColorAttachmentWithAlpha() ? v : 0; |
3814 } | 3696 } |
3815 return true; | 3697 return true; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3859 return true; | 3741 return true; |
3860 case GL_SHADER_COMPILER: | 3742 case GL_SHADER_COMPILER: |
3861 *num_written = 1; | 3743 *num_written = 1; |
3862 if (params) { | 3744 if (params) { |
3863 *params = GL_TRUE; | 3745 *params = GL_TRUE; |
3864 } | 3746 } |
3865 return true; | 3747 return true; |
3866 case GL_ARRAY_BUFFER_BINDING: | 3748 case GL_ARRAY_BUFFER_BINDING: |
3867 *num_written = 1; | 3749 *num_written = 1; |
3868 if (params) { | 3750 if (params) { |
3869 if (bound_array_buffer_) { | 3751 if (state_.bound_array_buffer) { |
3870 GLuint client_id = 0; | 3752 GLuint client_id = 0; |
3871 buffer_manager()->GetClientId(bound_array_buffer_->service_id(), | 3753 buffer_manager()->GetClientId(state_.bound_array_buffer->service_id(), |
3872 &client_id); | 3754 &client_id); |
3873 *params = client_id; | 3755 *params = client_id; |
3874 } else { | 3756 } else { |
3875 *params = 0; | 3757 *params = 0; |
3876 } | 3758 } |
3877 } | 3759 } |
3878 return true; | 3760 return true; |
3879 case GL_ELEMENT_ARRAY_BUFFER_BINDING: | 3761 case GL_ELEMENT_ARRAY_BUFFER_BINDING: |
3880 *num_written = 1; | 3762 *num_written = 1; |
3881 if (params) { | 3763 if (params) { |
3882 if (vertex_attrib_manager_->element_array_buffer()) { | 3764 if (state_.vertex_attrib_manager->element_array_buffer()) { |
3883 GLuint client_id = 0; | 3765 GLuint client_id = 0; |
3884 buffer_manager()->GetClientId( | 3766 buffer_manager()->GetClientId( |
3885 vertex_attrib_manager_->element_array_buffer()->service_id(), | 3767 state_.vertex_attrib_manager->element_array_buffer( |
3886 &client_id); | 3768 )->service_id(), &client_id); |
3887 *params = client_id; | 3769 *params = client_id; |
3888 } else { | 3770 } else { |
3889 *params = 0; | 3771 *params = 0; |
3890 } | 3772 } |
3891 } | 3773 } |
3892 return true; | 3774 return true; |
3893 case GL_FRAMEBUFFER_BINDING: | 3775 case GL_FRAMEBUFFER_BINDING: |
3894 // case GL_DRAW_FRAMEBUFFER_BINDING_EXT: (same as GL_FRAMEBUFFER_BINDING) | 3776 // case GL_DRAW_FRAMEBUFFER_BINDING_EXT: (same as GL_FRAMEBUFFER_BINDING) |
3895 *num_written = 1; | 3777 *num_written = 1; |
3896 if (params) { | 3778 if (params) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3932 renderbuffer->service_id(), &client_id); | 3814 renderbuffer->service_id(), &client_id); |
3933 *params = client_id; | 3815 *params = client_id; |
3934 } else { | 3816 } else { |
3935 *params = 0; | 3817 *params = 0; |
3936 } | 3818 } |
3937 } | 3819 } |
3938 return true; | 3820 return true; |
3939 case GL_CURRENT_PROGRAM: | 3821 case GL_CURRENT_PROGRAM: |
3940 *num_written = 1; | 3822 *num_written = 1; |
3941 if (params) { | 3823 if (params) { |
3942 if (current_program_) { | 3824 if (state_.current_program) { |
3943 GLuint client_id = 0; | 3825 GLuint client_id = 0; |
3944 program_manager()->GetClientId( | 3826 program_manager()->GetClientId( |
3945 current_program_->service_id(), &client_id); | 3827 state_.current_program->service_id(), &client_id); |
3946 *params = client_id; | 3828 *params = client_id; |
3947 } else { | 3829 } else { |
3948 *params = 0; | 3830 *params = 0; |
3949 } | 3831 } |
3950 } | 3832 } |
3951 return true; | 3833 return true; |
3952 case GL_TEXTURE_BINDING_2D: | 3834 case GL_TEXTURE_BINDING_2D: |
3953 *num_written = 1; | 3835 *num_written = 1; |
3954 if (params) { | 3836 if (params) { |
3955 TextureUnit& unit = texture_units_[active_texture_unit_]; | 3837 TextureUnit& unit = state_.texture_units[state_.active_texture_unit]; |
3956 if (unit.bound_texture_2d) { | 3838 if (unit.bound_texture_2d) { |
3957 GLuint client_id = 0; | 3839 GLuint client_id = 0; |
3958 texture_manager()->GetClientId( | 3840 texture_manager()->GetClientId( |
3959 unit.bound_texture_2d->service_id(), &client_id); | 3841 unit.bound_texture_2d->service_id(), &client_id); |
3960 *params = client_id; | 3842 *params = client_id; |
3961 } else { | 3843 } else { |
3962 *params = 0; | 3844 *params = 0; |
3963 } | 3845 } |
3964 } | 3846 } |
3965 return true; | 3847 return true; |
3966 case GL_TEXTURE_BINDING_CUBE_MAP: | 3848 case GL_TEXTURE_BINDING_CUBE_MAP: |
3967 *num_written = 1; | 3849 *num_written = 1; |
3968 if (params) { | 3850 if (params) { |
3969 TextureUnit& unit = texture_units_[active_texture_unit_]; | 3851 TextureUnit& unit = state_.texture_units[state_.active_texture_unit]; |
3970 if (unit.bound_texture_cube_map) { | 3852 if (unit.bound_texture_cube_map) { |
3971 GLuint client_id = 0; | 3853 GLuint client_id = 0; |
3972 texture_manager()->GetClientId( | 3854 texture_manager()->GetClientId( |
3973 unit.bound_texture_cube_map->service_id(), &client_id); | 3855 unit.bound_texture_cube_map->service_id(), &client_id); |
3974 *params = client_id; | 3856 *params = client_id; |
3975 } else { | 3857 } else { |
3976 *params = 0; | 3858 *params = 0; |
3977 } | 3859 } |
3978 } | 3860 } |
3979 return true; | 3861 return true; |
3980 case GL_TEXTURE_BINDING_EXTERNAL_OES: | 3862 case GL_TEXTURE_BINDING_EXTERNAL_OES: |
3981 *num_written = 1; | 3863 *num_written = 1; |
3982 if (params) { | 3864 if (params) { |
3983 TextureUnit& unit = texture_units_[active_texture_unit_]; | 3865 TextureUnit& unit = state_.texture_units[state_.active_texture_unit]; |
3984 if (unit.bound_texture_external_oes) { | 3866 if (unit.bound_texture_external_oes) { |
3985 GLuint client_id = 0; | 3867 GLuint client_id = 0; |
3986 texture_manager()->GetClientId( | 3868 texture_manager()->GetClientId( |
3987 unit.bound_texture_external_oes->service_id(), &client_id); | 3869 unit.bound_texture_external_oes->service_id(), &client_id); |
3988 *params = client_id; | 3870 *params = client_id; |
3989 } else { | 3871 } else { |
3990 *params = 0; | 3872 *params = 0; |
3991 } | 3873 } |
3992 } | 3874 } |
3993 return true; | 3875 return true; |
3994 case GL_TEXTURE_BINDING_RECTANGLE_ARB: | 3876 case GL_TEXTURE_BINDING_RECTANGLE_ARB: |
3995 *num_written = 1; | 3877 *num_written = 1; |
3996 if (params) { | 3878 if (params) { |
3997 TextureUnit& unit = texture_units_[active_texture_unit_]; | 3879 TextureUnit& unit = state_.texture_units[state_.active_texture_unit]; |
3998 if (unit.bound_texture_rectangle_arb) { | 3880 if (unit.bound_texture_rectangle_arb) { |
3999 GLuint client_id = 0; | 3881 GLuint client_id = 0; |
4000 texture_manager()->GetClientId( | 3882 texture_manager()->GetClientId( |
4001 unit.bound_texture_rectangle_arb->service_id(), &client_id); | 3883 unit.bound_texture_rectangle_arb->service_id(), &client_id); |
4002 *params = client_id; | 3884 *params = client_id; |
4003 } else { | 3885 } else { |
4004 *params = 0; | 3886 *params = 0; |
4005 } | 3887 } |
4006 } | 3888 } |
4007 return true; | 3889 return true; |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4360 return error::kOutOfBounds; | 4242 return error::kOutOfBounds; |
4361 } | 4243 } |
4362 DoRegisterSharedIdsCHROMIUM(namespace_id, n, ids); | 4244 DoRegisterSharedIdsCHROMIUM(namespace_id, n, ids); |
4363 return error::kNoError; | 4245 return error::kNoError; |
4364 } | 4246 } |
4365 | 4247 |
4366 error::Error GLES2DecoderImpl::DoClear(GLbitfield mask) { | 4248 error::Error GLES2DecoderImpl::DoClear(GLbitfield mask) { |
4367 if (ShouldDeferDraws()) | 4249 if (ShouldDeferDraws()) |
4368 return error::kDeferCommandUntilLater; | 4250 return error::kDeferCommandUntilLater; |
4369 if (CheckBoundFramebuffersValid("glClear")) { | 4251 if (CheckBoundFramebuffersValid("glClear")) { |
4370 UNSHIPPED_TRACE_EVENT_INSTANT2("test_gpu", "DoClear", "red", clear_red_, | 4252 UNSHIPPED_TRACE_EVENT_INSTANT2( |
4371 "green", clear_green_); | 4253 "test_gpu", "DoClear", |
4254 "red", state_.color_clear_red, | |
4255 "green", state_.color_clear_green); | |
4372 ApplyDirtyState(); | 4256 ApplyDirtyState(); |
4373 glClear(mask); | 4257 glClear(mask); |
4374 } | 4258 } |
4375 return error::kNoError; | 4259 return error::kNoError; |
4376 } | 4260 } |
4377 | 4261 |
4378 error::Error GLES2DecoderImpl::HandleClear( | 4262 error::Error GLES2DecoderImpl::HandleClear( |
4379 uint32 immediate_data_size, const gles2::Clear& c) { | 4263 uint32 immediate_data_size, const gles2::Clear& c) { |
4380 GLbitfield mask = static_cast<GLbitfield>(c.mask); | 4264 GLbitfield mask = static_cast<GLbitfield>(c.mask); |
4381 return DoClear(mask); | 4265 return DoClear(mask); |
(...skipping 20 matching lines...) Expand all Loading... | |
4402 } | 4286 } |
4403 service_id = info->service_id(); | 4287 service_id = info->service_id(); |
4404 } | 4288 } |
4405 CopyRealGLErrorsToWrapper(); | 4289 CopyRealGLErrorsToWrapper(); |
4406 glFramebufferRenderbufferEXT( | 4290 glFramebufferRenderbufferEXT( |
4407 target, attachment, renderbuffertarget, service_id); | 4291 target, attachment, renderbuffertarget, service_id); |
4408 GLenum error = PeekGLError(); | 4292 GLenum error = PeekGLError(); |
4409 if (error == GL_NO_ERROR) { | 4293 if (error == GL_NO_ERROR) { |
4410 framebuffer_info->AttachRenderbuffer(attachment, info); | 4294 framebuffer_info->AttachRenderbuffer(attachment, info); |
4411 } | 4295 } |
4412 if (framebuffer_info == bound_draw_framebuffer_) { | 4296 if (framebuffer_info == state_.bound_draw_framebuffer) { |
4413 state_dirty_ = true; | 4297 state_dirty_ = true; |
4414 } | 4298 } |
4415 } | 4299 } |
4416 | 4300 |
4417 bool GLES2DecoderImpl::SetCapabilityState(GLenum cap, bool enabled) { | 4301 bool GLES2DecoderImpl::SetCapabilityState(GLenum cap, bool enabled) { |
4418 switch (cap) { | 4302 switch (cap) { |
4419 case GL_BLEND: | 4303 case GL_BLEND: |
4420 enable_blend_ = enabled; | 4304 state_.enable_blend = enabled; |
4421 return true; | 4305 return true; |
4422 case GL_CULL_FACE: | 4306 case GL_CULL_FACE: |
4423 enable_cull_face_ = enabled; | 4307 state_.enable_cull_face = enabled; |
4424 return true; | 4308 return true; |
4425 case GL_SCISSOR_TEST: | 4309 case GL_SCISSOR_TEST: |
4426 enable_scissor_test_ = enabled; | 4310 state_.enable_scissor_test = enabled; |
4427 return true; | 4311 return true; |
4428 case GL_DEPTH_TEST: { | 4312 case GL_DEPTH_TEST: { |
4429 if (enable_depth_test_ != enabled) { | 4313 if (state_.enable_depth_test != enabled) { |
4430 enable_depth_test_ = enabled; | 4314 state_.enable_depth_test = enabled; |
4431 state_dirty_ = true; | 4315 state_dirty_ = true; |
4432 } | 4316 } |
4433 return false; | 4317 return false; |
4434 } | 4318 } |
4435 case GL_STENCIL_TEST: | 4319 case GL_STENCIL_TEST: |
4436 if (enable_stencil_test_ != enabled) { | 4320 if (state_.enable_stencil_test != enabled) { |
4437 enable_stencil_test_ = enabled; | 4321 state_.enable_stencil_test = enabled; |
4438 state_dirty_ = true; | 4322 state_dirty_ = true; |
4439 } | 4323 } |
4440 return false; | 4324 return false; |
4441 default: | 4325 default: |
4442 return true; | 4326 return true; |
4443 } | 4327 } |
4444 } | 4328 } |
4445 | 4329 |
4446 void GLES2DecoderImpl::DoDisable(GLenum cap) { | 4330 void GLES2DecoderImpl::DoDisable(GLenum cap) { |
4447 if (SetCapabilityState(cap, false)) { | 4331 if (SetCapabilityState(cap, false)) { |
4448 glDisable(cap); | 4332 glDisable(cap); |
4449 } | 4333 } |
4450 } | 4334 } |
4451 | 4335 |
4452 void GLES2DecoderImpl::DoEnable(GLenum cap) { | 4336 void GLES2DecoderImpl::DoEnable(GLenum cap) { |
4453 if (SetCapabilityState(cap, true)) { | 4337 if (SetCapabilityState(cap, true)) { |
4454 glEnable(cap); | 4338 glEnable(cap); |
4455 } | 4339 } |
4456 } | 4340 } |
4457 | 4341 |
4458 bool GLES2DecoderImpl::DoIsEnabled(GLenum cap) { | 4342 bool GLES2DecoderImpl::DoIsEnabled(GLenum cap) { |
4459 switch (cap) { | 4343 switch (cap) { |
4460 case GL_BLEND: | 4344 case GL_BLEND: |
4461 return enable_blend_; | 4345 return state_.enable_blend; |
4462 case GL_CULL_FACE: | 4346 case GL_CULL_FACE: |
4463 return enable_cull_face_; | 4347 return state_.enable_cull_face; |
4464 case GL_SCISSOR_TEST: | 4348 case GL_SCISSOR_TEST: |
4465 return enable_scissor_test_; | 4349 return state_.enable_scissor_test; |
4466 case GL_DEPTH_TEST: | 4350 case GL_DEPTH_TEST: |
4467 return enable_depth_test_; | 4351 return state_.enable_depth_test; |
4468 case GL_STENCIL_TEST: | 4352 case GL_STENCIL_TEST: |
4469 return enable_stencil_test_; | 4353 return state_.enable_stencil_test; |
4470 default: | 4354 default: |
4471 return glIsEnabled(cap) != 0; | 4355 return glIsEnabled(cap) != 0; |
4472 } | 4356 } |
4473 } | 4357 } |
4474 | 4358 |
4475 void GLES2DecoderImpl::DoClearColor( | 4359 void GLES2DecoderImpl::DoClearColor( |
4476 GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) { | 4360 GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) { |
4477 clear_red_ = red; | 4361 state_.color_clear_red = red; |
4478 clear_green_ = green; | 4362 state_.color_clear_green = green; |
4479 clear_blue_ = blue; | 4363 state_.color_clear_blue = blue; |
4480 clear_alpha_ = alpha; | 4364 state_.color_clear_alpha = alpha; |
4481 glClearColor(red, green, blue, alpha); | 4365 glClearColor(red, green, blue, alpha); |
4482 } | 4366 } |
4483 | 4367 |
4484 void GLES2DecoderImpl::DoClearDepthf(GLclampf depth) { | 4368 void GLES2DecoderImpl::DoClearDepthf(GLclampf depth) { |
4485 clear_depth_ = depth; | 4369 state_.depth_clear = depth; |
4486 glClearDepth(depth); | 4370 glClearDepth(depth); |
4487 } | 4371 } |
4488 | 4372 |
4489 void GLES2DecoderImpl::DoClearStencil(GLint s) { | 4373 void GLES2DecoderImpl::DoClearStencil(GLint s) { |
4490 clear_stencil_ = s; | 4374 state_.stencil_clear = s; |
4491 glClearStencil(s); | 4375 glClearStencil(s); |
4492 } | 4376 } |
4493 | 4377 |
4494 void GLES2DecoderImpl::DoColorMask( | 4378 void GLES2DecoderImpl::DoColorMask( |
4495 GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) { | 4379 GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) { |
4496 mask_red_ = red; | 4380 state_.color_mask_red = red; |
4497 mask_green_ = green; | 4381 state_.color_mask_green = green; |
4498 mask_blue_ = blue; | 4382 state_.color_mask_blue = blue; |
4499 mask_alpha_ = alpha; | 4383 state_.color_mask_alpha = alpha; |
4500 state_dirty_ = true; | 4384 state_dirty_ = true; |
4501 } | 4385 } |
4502 | 4386 |
4503 void GLES2DecoderImpl::DoDepthMask(GLboolean depth) { | 4387 void GLES2DecoderImpl::DoDepthMask(GLboolean depth) { |
4504 mask_depth_ = depth; | 4388 state_.depth_mask = depth; |
4505 state_dirty_ = true; | 4389 state_dirty_ = true; |
4506 } | 4390 } |
4507 | 4391 |
4508 void GLES2DecoderImpl::DoStencilMask(GLuint mask) { | 4392 void GLES2DecoderImpl::DoStencilMask(GLuint mask) { |
4509 mask_stencil_front_ = mask; | 4393 state_.stencil_mask_front = mask; |
4510 mask_stencil_back_ = mask; | 4394 state_.stencil_mask_back = mask; |
4511 state_dirty_ = true; | 4395 state_dirty_ = true; |
4512 } | 4396 } |
4513 | 4397 |
4514 void GLES2DecoderImpl::DoStencilMaskSeparate(GLenum face, GLuint mask) { | 4398 void GLES2DecoderImpl::DoStencilMaskSeparate(GLenum face, GLuint mask) { |
4515 if (face == GL_FRONT || face == GL_FRONT_AND_BACK) { | 4399 if (face == GL_FRONT || face == GL_FRONT_AND_BACK) { |
4516 mask_stencil_front_ = mask; | 4400 state_.stencil_mask_front = mask; |
4517 } | 4401 } |
4518 if (face == GL_BACK || face == GL_FRONT_AND_BACK) { | 4402 if (face == GL_BACK || face == GL_FRONT_AND_BACK) { |
4519 mask_stencil_back_ = mask; | 4403 state_.stencil_mask_back = mask; |
4520 } | 4404 } |
4521 state_dirty_ = true; | 4405 state_dirty_ = true; |
4522 } | 4406 } |
4523 | 4407 |
4524 // Assumes framebuffer is complete. | 4408 // Assumes framebuffer is complete. |
4525 void GLES2DecoderImpl::ClearUnclearedAttachments( | 4409 void GLES2DecoderImpl::ClearUnclearedAttachments( |
4526 GLenum target, FramebufferManager::FramebufferInfo* info) { | 4410 GLenum target, FramebufferManager::FramebufferInfo* info) { |
4527 if (target == GL_READ_FRAMEBUFFER_EXT) { | 4411 if (target == GL_READ_FRAMEBUFFER_EXT) { |
4528 // bind this to the DRAW point, clear then bind back to READ | 4412 // bind this to the DRAW point, clear then bind back to READ |
4529 // TODO(gman): I don't think there is any guarantee that an FBO that | 4413 // TODO(gman): I don't think there is any guarantee that an FBO that |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4569 FramebufferManager::FramebufferInfo* framebuffer = | 4453 FramebufferManager::FramebufferInfo* framebuffer = |
4570 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT); | 4454 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT); |
4571 GLuint service_id = | 4455 GLuint service_id = |
4572 framebuffer ? framebuffer->service_id() : GetBackbufferServiceId(); | 4456 framebuffer ? framebuffer->service_id() : GetBackbufferServiceId(); |
4573 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, service_id); | 4457 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, service_id); |
4574 } | 4458 } |
4575 } | 4459 } |
4576 | 4460 |
4577 void GLES2DecoderImpl::RestoreClearState() { | 4461 void GLES2DecoderImpl::RestoreClearState() { |
4578 state_dirty_ = true; | 4462 state_dirty_ = true; |
4579 glClearColor(clear_red_, clear_green_, clear_blue_, clear_alpha_); | 4463 glClearColor( |
4580 glClearStencil(clear_stencil_); | 4464 state_.color_clear_red, state_.color_clear_green, state_.color_clear_blue, |
4581 glClearDepth(clear_depth_); | 4465 state_.color_clear_alpha); |
4582 if (enable_scissor_test_) { | 4466 glClearStencil(state_.stencil_clear); |
4467 glClearDepth(state_.depth_clear); | |
4468 if (state_.enable_scissor_test) { | |
4583 glEnable(GL_SCISSOR_TEST); | 4469 glEnable(GL_SCISSOR_TEST); |
4584 } | 4470 } |
4585 } | 4471 } |
4586 | 4472 |
4587 GLenum GLES2DecoderImpl::DoCheckFramebufferStatus(GLenum target) { | 4473 GLenum GLES2DecoderImpl::DoCheckFramebufferStatus(GLenum target) { |
4588 FramebufferManager::FramebufferInfo* framebuffer = | 4474 FramebufferManager::FramebufferInfo* framebuffer = |
4589 GetFramebufferInfoForTarget(target); | 4475 GetFramebufferInfoForTarget(target); |
4590 if (!framebuffer) { | 4476 if (!framebuffer) { |
4591 return GL_FRAMEBUFFER_COMPLETE; | 4477 return GL_FRAMEBUFFER_COMPLETE; |
4592 } | 4478 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4624 "glFramebufferTexture2D", "level out of range"); | 4510 "glFramebufferTexture2D", "level out of range"); |
4625 return; | 4511 return; |
4626 } | 4512 } |
4627 | 4513 |
4628 CopyRealGLErrorsToWrapper(); | 4514 CopyRealGLErrorsToWrapper(); |
4629 glFramebufferTexture2DEXT(target, attachment, textarget, service_id, level); | 4515 glFramebufferTexture2DEXT(target, attachment, textarget, service_id, level); |
4630 GLenum error = PeekGLError(); | 4516 GLenum error = PeekGLError(); |
4631 if (error == GL_NO_ERROR) { | 4517 if (error == GL_NO_ERROR) { |
4632 framebuffer_info->AttachTexture(attachment, info, textarget, level); | 4518 framebuffer_info->AttachTexture(attachment, info, textarget, level); |
4633 } | 4519 } |
4634 if (framebuffer_info == bound_draw_framebuffer_) { | 4520 if (framebuffer_info == state_.bound_draw_framebuffer) { |
4635 state_dirty_ = true; | 4521 state_dirty_ = true; |
4636 } | 4522 } |
4637 } | 4523 } |
4638 | 4524 |
4639 void GLES2DecoderImpl::DoGetFramebufferAttachmentParameteriv( | 4525 void GLES2DecoderImpl::DoGetFramebufferAttachmentParameteriv( |
4640 GLenum target, GLenum attachment, GLenum pname, GLint* params) { | 4526 GLenum target, GLenum attachment, GLenum pname, GLint* params) { |
4641 FramebufferManager::FramebufferInfo* framebuffer_info = | 4527 FramebufferManager::FramebufferInfo* framebuffer_info = |
4642 GetFramebufferInfoForTarget(target); | 4528 GetFramebufferInfoForTarget(target); |
4643 if (!framebuffer_info) { | 4529 if (!framebuffer_info) { |
4644 SetGLError(GL_INVALID_OPERATION, | 4530 SetGLError(GL_INVALID_OPERATION, |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4830 ShaderTranslator* vertex_translator = NULL; | 4716 ShaderTranslator* vertex_translator = NULL; |
4831 ShaderTranslator* fragment_translator = NULL; | 4717 ShaderTranslator* fragment_translator = NULL; |
4832 if (use_shader_translator_) { | 4718 if (use_shader_translator_) { |
4833 vertex_translator = vertex_translator_; | 4719 vertex_translator = vertex_translator_; |
4834 fragment_translator = fragment_translator_; | 4720 fragment_translator = fragment_translator_; |
4835 } | 4721 } |
4836 if (info->Link(shader_manager(), | 4722 if (info->Link(shader_manager(), |
4837 vertex_translator, | 4723 vertex_translator, |
4838 fragment_translator, | 4724 fragment_translator, |
4839 feature_info_)) { | 4725 feature_info_)) { |
4840 if (info == current_program_.get()) { | 4726 if (info == state_.current_program.get()) { |
4841 program_manager()->ClearUniforms(info); | 4727 program_manager()->ClearUniforms(info); |
4842 } | 4728 } |
4843 } | 4729 } |
4844 }; | 4730 }; |
4845 | 4731 |
4846 void GLES2DecoderImpl::DoTexParameterf( | 4732 void GLES2DecoderImpl::DoTexParameterf( |
4847 GLenum target, GLenum pname, GLfloat param) { | 4733 GLenum target, GLenum pname, GLfloat param) { |
4848 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); | 4734 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); |
4849 if (!info) { | 4735 if (!info) { |
4850 SetGLError(GL_INVALID_VALUE, "glTexParameterf", "unknown texture"); | 4736 SetGLError(GL_INVALID_VALUE, "glTexParameterf", "unknown texture"); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4899 } | 4785 } |
4900 | 4786 |
4901 if (!texture_manager()->SetParameter(info, pname, *params)) { | 4787 if (!texture_manager()->SetParameter(info, pname, *params)) { |
4902 SetGLErrorInvalidEnum("glTexParameteriv", pname, "pname"); | 4788 SetGLErrorInvalidEnum("glTexParameteriv", pname, "pname"); |
4903 return; | 4789 return; |
4904 } | 4790 } |
4905 glTexParameteriv(target, pname, params); | 4791 glTexParameteriv(target, pname, params); |
4906 } | 4792 } |
4907 | 4793 |
4908 bool GLES2DecoderImpl::CheckCurrentProgram(const char* function_name) { | 4794 bool GLES2DecoderImpl::CheckCurrentProgram(const char* function_name) { |
4909 if (!current_program_) { | 4795 if (!state_.current_program) { |
4910 // The program does not exist. | 4796 // The program does not exist. |
4911 SetGLError(GL_INVALID_OPERATION, function_name, "no program in use"); | 4797 SetGLError(GL_INVALID_OPERATION, function_name, "no program in use"); |
4912 return false; | 4798 return false; |
4913 } | 4799 } |
4914 if (!current_program_->InUse()) { | 4800 if (!state_.current_program->InUse()) { |
4915 SetGLError(GL_INVALID_OPERATION, function_name, "program not linked"); | 4801 SetGLError(GL_INVALID_OPERATION, function_name, "program not linked"); |
4916 return false; | 4802 return false; |
4917 } | 4803 } |
4918 return true; | 4804 return true; |
4919 } | 4805 } |
4920 | 4806 |
4921 bool GLES2DecoderImpl::CheckCurrentProgramForUniform( | 4807 bool GLES2DecoderImpl::CheckCurrentProgramForUniform( |
4922 GLint location, const char* function_name) { | 4808 GLint location, const char* function_name) { |
4923 if (!CheckCurrentProgram(function_name)) { | 4809 if (!CheckCurrentProgram(function_name)) { |
4924 return false; | 4810 return false; |
4925 } | 4811 } |
4926 return location != -1; | 4812 return location != -1; |
4927 } | 4813 } |
4928 | 4814 |
4929 bool GLES2DecoderImpl::PrepForSetUniformByLocation( | 4815 bool GLES2DecoderImpl::PrepForSetUniformByLocation( |
4930 GLint fake_location, const char* function_name, | 4816 GLint fake_location, const char* function_name, |
4931 GLint* real_location, GLenum* type, GLsizei* count) { | 4817 GLint* real_location, GLenum* type, GLsizei* count) { |
4932 DCHECK(type); | 4818 DCHECK(type); |
4933 DCHECK(count); | 4819 DCHECK(count); |
4934 DCHECK(real_location); | 4820 DCHECK(real_location); |
4935 if (!CheckCurrentProgramForUniform(fake_location, function_name)) { | 4821 if (!CheckCurrentProgramForUniform(fake_location, function_name)) { |
4936 return false; | 4822 return false; |
4937 } | 4823 } |
4938 GLint array_index = -1; | 4824 GLint array_index = -1; |
4939 const ProgramManager::ProgramInfo::UniformInfo* info = | 4825 const ProgramManager::ProgramInfo::UniformInfo* info = |
4940 current_program_->GetUniformInfoByFakeLocation( | 4826 state_.current_program->GetUniformInfoByFakeLocation( |
4941 fake_location, real_location, &array_index); | 4827 fake_location, real_location, &array_index); |
4942 if (!info) { | 4828 if (!info) { |
4943 SetGLError(GL_INVALID_OPERATION, function_name, "unknown location"); | 4829 SetGLError(GL_INVALID_OPERATION, function_name, "unknown location"); |
4944 return false; | 4830 return false; |
4945 } | 4831 } |
4946 if (*count > 1 && !info->is_array) { | 4832 if (*count > 1 && !info->is_array) { |
4947 SetGLError( | 4833 SetGLError( |
4948 GL_INVALID_OPERATION, function_name, "count > 1 for non-array"); | 4834 GL_INVALID_OPERATION, function_name, "count > 1 for non-array"); |
4949 return false; | 4835 return false; |
4950 } | 4836 } |
4951 *count = std::min(info->size - array_index, *count); | 4837 *count = std::min(info->size - array_index, *count); |
4952 if (*count <= 0) { | 4838 if (*count <= 0) { |
4953 return false; | 4839 return false; |
4954 } | 4840 } |
4955 *type = info->type; | 4841 *type = info->type; |
4956 return true; | 4842 return true; |
4957 } | 4843 } |
4958 | 4844 |
4959 void GLES2DecoderImpl::DoUniform1i(GLint fake_location, GLint v0) { | 4845 void GLES2DecoderImpl::DoUniform1i(GLint fake_location, GLint v0) { |
4960 GLenum type = 0; | 4846 GLenum type = 0; |
4961 GLsizei count = 1; | 4847 GLsizei count = 1; |
4962 GLint real_location = -1; | 4848 GLint real_location = -1; |
4963 if (!PrepForSetUniformByLocation( | 4849 if (!PrepForSetUniformByLocation( |
4964 fake_location, "glUniform1iv", &real_location, &type, &count)) { | 4850 fake_location, "glUniform1iv", &real_location, &type, &count)) { |
4965 return; | 4851 return; |
4966 } | 4852 } |
4967 if (!current_program_->SetSamplers( | 4853 if (!state_.current_program->SetSamplers( |
4968 group_->max_texture_units(), fake_location, 1, &v0)) { | 4854 group_->max_texture_units(), fake_location, 1, &v0)) { |
4969 SetGLError(GL_INVALID_VALUE, "glUniform1i", "texture unit out of range"); | 4855 SetGLError(GL_INVALID_VALUE, "glUniform1i", "texture unit out of range"); |
4970 return; | 4856 return; |
4971 } | 4857 } |
4972 glUniform1i(real_location, v0); | 4858 glUniform1i(real_location, v0); |
4973 } | 4859 } |
4974 | 4860 |
4975 void GLES2DecoderImpl::DoUniform1iv( | 4861 void GLES2DecoderImpl::DoUniform1iv( |
4976 GLint fake_location, GLsizei count, const GLint *value) { | 4862 GLint fake_location, GLsizei count, const GLint *value) { |
4977 GLenum type = 0; | 4863 GLenum type = 0; |
4978 GLint real_location = -1; | 4864 GLint real_location = -1; |
4979 if (!PrepForSetUniformByLocation( | 4865 if (!PrepForSetUniformByLocation( |
4980 fake_location, "glUniform1iv", &real_location, &type, &count)) { | 4866 fake_location, "glUniform1iv", &real_location, &type, &count)) { |
4981 return; | 4867 return; |
4982 } | 4868 } |
4983 if (type == GL_SAMPLER_2D || type == GL_SAMPLER_2D_RECT_ARB || | 4869 if (type == GL_SAMPLER_2D || type == GL_SAMPLER_2D_RECT_ARB || |
4984 type == GL_SAMPLER_CUBE || type == GL_SAMPLER_EXTERNAL_OES) { | 4870 type == GL_SAMPLER_CUBE || type == GL_SAMPLER_EXTERNAL_OES) { |
4985 if (!current_program_->SetSamplers( | 4871 if (!state_.current_program->SetSamplers( |
4986 group_->max_texture_units(), fake_location, count, value)) { | 4872 group_->max_texture_units(), fake_location, count, value)) { |
4987 SetGLError(GL_INVALID_VALUE, "glUniform1iv", "texture unit out of range"); | 4873 SetGLError(GL_INVALID_VALUE, "glUniform1iv", "texture unit out of range"); |
4988 return; | 4874 return; |
4989 } | 4875 } |
4990 } | 4876 } |
4991 glUniform1iv(real_location, count, value); | 4877 glUniform1iv(real_location, count, value); |
4992 } | 4878 } |
4993 | 4879 |
4994 void GLES2DecoderImpl::DoUniform1fv( | 4880 void GLES2DecoderImpl::DoUniform1fv( |
4995 GLint fake_location, GLsizei count, const GLfloat* value) { | 4881 GLint fake_location, GLsizei count, const GLfloat* value) { |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5147 if (!info) { | 5033 if (!info) { |
5148 return; | 5034 return; |
5149 } | 5035 } |
5150 if (!info->IsValid()) { | 5036 if (!info->IsValid()) { |
5151 // Program was not linked successfully. (ie, glLinkProgram) | 5037 // Program was not linked successfully. (ie, glLinkProgram) |
5152 SetGLError(GL_INVALID_OPERATION, "glUseProgram", "program not linked"); | 5038 SetGLError(GL_INVALID_OPERATION, "glUseProgram", "program not linked"); |
5153 return; | 5039 return; |
5154 } | 5040 } |
5155 service_id = info->service_id(); | 5041 service_id = info->service_id(); |
5156 } | 5042 } |
5157 if (current_program_) { | 5043 if (state_.current_program) { |
5158 program_manager()->UnuseProgram(shader_manager(), current_program_); | 5044 program_manager()->UnuseProgram(shader_manager(), state_.current_program); |
5159 } | 5045 } |
5160 current_program_ = info; | 5046 state_.current_program = info; |
5161 glUseProgram(service_id); | 5047 glUseProgram(service_id); |
5162 if (current_program_) { | 5048 if (state_.current_program) { |
5163 program_manager()->UseProgram(current_program_); | 5049 program_manager()->UseProgram(state_.current_program); |
5164 } | 5050 } |
5165 } | 5051 } |
5166 | 5052 |
5167 uint32 GLES2DecoderImpl::GetGLError() { | 5053 uint32 GLES2DecoderImpl::GetGLError() { |
5168 // Check the GL error first, then our wrapped error. | 5054 // Check the GL error first, then our wrapped error. |
5169 GLenum error = glGetError(); | 5055 GLenum error = glGetError(); |
5170 if (error == GL_NO_ERROR && error_bits_ != 0) { | 5056 if (error == GL_NO_ERROR && error_bits_ != 0) { |
5171 for (uint32 mask = 1; mask != 0; mask = mask << 1) { | 5057 for (uint32 mask = 1; mask != 0; mask = mask << 1) { |
5172 if ((error_bits_ & mask) != 0) { | 5058 if ((error_bits_ & mask) != 0) { |
5173 error = GLES2Util::GLErrorBitToGLError(mask); | 5059 error = GLES2Util::GLErrorBitToGLError(mask); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5242 } | 5128 } |
5243 | 5129 |
5244 void GLES2DecoderImpl::PerformanceWarning(const std::string& msg) { | 5130 void GLES2DecoderImpl::PerformanceWarning(const std::string& msg) { |
5245 LogMessage(std::string("PERFORMANCE WARNING: ") + msg); | 5131 LogMessage(std::string("PERFORMANCE WARNING: ") + msg); |
5246 } | 5132 } |
5247 | 5133 |
5248 void GLES2DecoderImpl::ForceCompileShaderIfPending( | 5134 void GLES2DecoderImpl::ForceCompileShaderIfPending( |
5249 ShaderManager::ShaderInfo* info) { | 5135 ShaderManager::ShaderInfo* info) { |
5250 if (info->compilation_status() == | 5136 if (info->compilation_status() == |
5251 ShaderManager::ShaderInfo::PENDING_DEFERRED_COMPILE) { | 5137 ShaderManager::ShaderInfo::PENDING_DEFERRED_COMPILE) { |
5252 | |
5253 ShaderTranslator* translator = NULL; | 5138 ShaderTranslator* translator = NULL; |
5254 if (use_shader_translator_) { | 5139 if (use_shader_translator_) { |
5255 translator = info->shader_type() == GL_VERTEX_SHADER ? | 5140 translator = info->shader_type() == GL_VERTEX_SHADER ? |
5256 vertex_translator_.get() : fragment_translator_.get(); | 5141 vertex_translator_.get() : fragment_translator_.get(); |
5257 } | 5142 } |
5258 // We know there will be no errors, because we only defer compilation on | 5143 // We know there will be no errors, because we only defer compilation on |
5259 // shaders that were previously compiled successfully. | 5144 // shaders that were previously compiled successfully. |
5260 program_manager()->ForceCompileShader(info->deferred_compilation_source(), | 5145 program_manager()->ForceCompileShader(info->deferred_compilation_source(), |
5261 info, | 5146 info, |
5262 translator, | 5147 translator, |
(...skipping 12 matching lines...) Expand all Loading... | |
5275 GLenum error; | 5160 GLenum error; |
5276 while ((error = glGetError()) != GL_NO_ERROR) { | 5161 while ((error = glGetError()) != GL_NO_ERROR) { |
5277 if (error != GL_OUT_OF_MEMORY) { | 5162 if (error != GL_OUT_OF_MEMORY) { |
5278 // GL_OUT_OF_MEMORY can legally happen on lost device. | 5163 // GL_OUT_OF_MEMORY can legally happen on lost device. |
5279 NOTREACHED() << "GL error " << error << " was unhandled."; | 5164 NOTREACHED() << "GL error " << error << " was unhandled."; |
5280 } | 5165 } |
5281 } | 5166 } |
5282 } | 5167 } |
5283 | 5168 |
5284 bool GLES2DecoderImpl::SetBlackTextureForNonRenderableTextures() { | 5169 bool GLES2DecoderImpl::SetBlackTextureForNonRenderableTextures() { |
5285 DCHECK(current_program_); | 5170 DCHECK(state_.current_program); |
5286 // Only check if there are some unrenderable textures. | 5171 // Only check if there are some unrenderable textures. |
5287 if (!texture_manager()->HaveUnrenderableTextures()) { | 5172 if (!texture_manager()->HaveUnrenderableTextures()) { |
5288 return false; | 5173 return false; |
5289 } | 5174 } |
5290 bool textures_set = false; | 5175 bool textures_set = false; |
5291 const ProgramManager::ProgramInfo::SamplerIndices& sampler_indices = | 5176 const ProgramManager::ProgramInfo::SamplerIndices& sampler_indices = |
5292 current_program_->sampler_indices(); | 5177 state_.current_program->sampler_indices(); |
5293 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) { | 5178 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) { |
5294 const ProgramManager::ProgramInfo::UniformInfo* uniform_info = | 5179 const ProgramManager::ProgramInfo::UniformInfo* uniform_info = |
5295 current_program_->GetUniformInfo(sampler_indices[ii]); | 5180 state_.current_program->GetUniformInfo(sampler_indices[ii]); |
5296 DCHECK(uniform_info); | 5181 DCHECK(uniform_info); |
5297 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) { | 5182 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) { |
5298 GLuint texture_unit_index = uniform_info->texture_units[jj]; | 5183 GLuint texture_unit_index = uniform_info->texture_units[jj]; |
5299 if (texture_unit_index < group_->max_texture_units()) { | 5184 if (texture_unit_index < group_->max_texture_units()) { |
5300 TextureUnit& texture_unit = texture_units_[texture_unit_index]; | 5185 TextureUnit& texture_unit = state_.texture_units[texture_unit_index]; |
5301 TextureManager::TextureInfo* texture_info = | 5186 TextureManager::TextureInfo* texture_info = |
5302 texture_unit.GetInfoForSamplerType(uniform_info->type); | 5187 texture_unit.GetInfoForSamplerType(uniform_info->type); |
5303 if (!texture_info || !texture_manager()->CanRender(texture_info)) { | 5188 if (!texture_info || !texture_manager()->CanRender(texture_info)) { |
5304 textures_set = true; | 5189 textures_set = true; |
5305 glActiveTexture(GL_TEXTURE0 + texture_unit_index); | 5190 glActiveTexture(GL_TEXTURE0 + texture_unit_index); |
5306 glBindTexture( | 5191 glBindTexture( |
5307 GetBindTargetForSamplerType(uniform_info->type), | 5192 GetBindTargetForSamplerType(uniform_info->type), |
5308 texture_manager()->black_texture_id(uniform_info->type)); | 5193 texture_manager()->black_texture_id(uniform_info->type)); |
5309 RenderWarning( | 5194 RenderWarning( |
5310 std::string("texture bound to texture unit ") + | 5195 std::string("texture bound to texture unit ") + |
5311 base::IntToString(texture_unit_index) + | 5196 base::IntToString(texture_unit_index) + |
5312 " is not renderable. It maybe non-power-of-2 and have " | 5197 " is not renderable. It maybe non-power-of-2 and have " |
5313 " incompatible texture filtering or is not " | 5198 " incompatible texture filtering or is not " |
5314 "'texture complete'"); | 5199 "'texture complete'"); |
5315 } | 5200 } |
5316 } | 5201 } |
5317 // else: should this be an error? | 5202 // else: should this be an error? |
5318 } | 5203 } |
5319 } | 5204 } |
5320 return textures_set; | 5205 return textures_set; |
5321 } | 5206 } |
5322 | 5207 |
5323 void GLES2DecoderImpl::RestoreStateForNonRenderableTextures() { | 5208 void GLES2DecoderImpl::RestoreStateForNonRenderableTextures() { |
5324 DCHECK(current_program_); | 5209 DCHECK(state_.current_program); |
5325 const ProgramManager::ProgramInfo::SamplerIndices& sampler_indices = | 5210 const ProgramManager::ProgramInfo::SamplerIndices& sampler_indices = |
5326 current_program_->sampler_indices(); | 5211 state_.current_program->sampler_indices(); |
5327 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) { | 5212 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) { |
5328 const ProgramManager::ProgramInfo::UniformInfo* uniform_info = | 5213 const ProgramManager::ProgramInfo::UniformInfo* uniform_info = |
5329 current_program_->GetUniformInfo(sampler_indices[ii]); | 5214 state_.current_program->GetUniformInfo(sampler_indices[ii]); |
5330 DCHECK(uniform_info); | 5215 DCHECK(uniform_info); |
5331 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) { | 5216 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) { |
5332 GLuint texture_unit_index = uniform_info->texture_units[jj]; | 5217 GLuint texture_unit_index = uniform_info->texture_units[jj]; |
5333 if (texture_unit_index < group_->max_texture_units()) { | 5218 if (texture_unit_index < group_->max_texture_units()) { |
5334 TextureUnit& texture_unit = texture_units_[texture_unit_index]; | 5219 TextureUnit& texture_unit = state_.texture_units[texture_unit_index]; |
5335 TextureManager::TextureInfo* texture_info = | 5220 TextureManager::TextureInfo* texture_info = |
5336 uniform_info->type == GL_SAMPLER_2D ? | 5221 uniform_info->type == GL_SAMPLER_2D ? |
5337 texture_unit.bound_texture_2d : | 5222 texture_unit.bound_texture_2d : |
5338 texture_unit.bound_texture_cube_map; | 5223 texture_unit.bound_texture_cube_map; |
5339 if (!texture_info || !texture_manager()->CanRender(texture_info)) { | 5224 if (!texture_info || !texture_manager()->CanRender(texture_info)) { |
5340 glActiveTexture(GL_TEXTURE0 + texture_unit_index); | 5225 glActiveTexture(GL_TEXTURE0 + texture_unit_index); |
5341 // Get the texture info that was previously bound here. | 5226 // Get the texture info that was previously bound here. |
5342 texture_info = texture_unit.bind_target == GL_TEXTURE_2D ? | 5227 texture_info = texture_unit.bind_target == GL_TEXTURE_2D ? |
5343 texture_unit.bound_texture_2d : | 5228 texture_unit.bound_texture_2d : |
5344 texture_unit.bound_texture_cube_map; | 5229 texture_unit.bound_texture_cube_map; |
5345 glBindTexture(texture_unit.bind_target, | 5230 glBindTexture(texture_unit.bind_target, |
5346 texture_info ? texture_info->service_id() : 0); | 5231 texture_info ? texture_info->service_id() : 0); |
5347 } | 5232 } |
5348 } | 5233 } |
5349 } | 5234 } |
5350 } | 5235 } |
5351 // Set the active texture back to whatever the user had it as. | 5236 // Set the active texture back to whatever the user had it as. |
5352 glActiveTexture(GL_TEXTURE0 + active_texture_unit_); | 5237 glActiveTexture(GL_TEXTURE0 + state_.active_texture_unit); |
5353 } | 5238 } |
5354 | 5239 |
5355 bool GLES2DecoderImpl::ClearUnclearedTextures() { | 5240 bool GLES2DecoderImpl::ClearUnclearedTextures() { |
5356 // Only check if there are some uncleared textures. | 5241 // Only check if there are some uncleared textures. |
5357 if (!texture_manager()->HaveUnsafeTextures()) { | 5242 if (!texture_manager()->HaveUnsafeTextures()) { |
5358 return true; | 5243 return true; |
5359 } | 5244 } |
5360 | 5245 |
5361 // 1: Check all textures we are about to render with. | 5246 // 1: Check all textures we are about to render with. |
5362 if (current_program_) { | 5247 if (state_.current_program) { |
5363 const ProgramManager::ProgramInfo::SamplerIndices& sampler_indices = | 5248 const ProgramManager::ProgramInfo::SamplerIndices& sampler_indices = |
5364 current_program_->sampler_indices(); | 5249 state_.current_program->sampler_indices(); |
5365 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) { | 5250 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) { |
5366 const ProgramManager::ProgramInfo::UniformInfo* uniform_info = | 5251 const ProgramManager::ProgramInfo::UniformInfo* uniform_info = |
5367 current_program_->GetUniformInfo(sampler_indices[ii]); | 5252 state_.current_program->GetUniformInfo(sampler_indices[ii]); |
5368 DCHECK(uniform_info); | 5253 DCHECK(uniform_info); |
5369 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) { | 5254 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) { |
5370 GLuint texture_unit_index = uniform_info->texture_units[jj]; | 5255 GLuint texture_unit_index = uniform_info->texture_units[jj]; |
5371 if (texture_unit_index < group_->max_texture_units()) { | 5256 if (texture_unit_index < group_->max_texture_units()) { |
5372 TextureUnit& texture_unit = texture_units_[texture_unit_index]; | 5257 TextureUnit& texture_unit = state_.texture_units[texture_unit_index]; |
5373 TextureManager::TextureInfo* texture_info = | 5258 TextureManager::TextureInfo* texture_info = |
5374 texture_unit.GetInfoForSamplerType(uniform_info->type); | 5259 texture_unit.GetInfoForSamplerType(uniform_info->type); |
5375 if (texture_info && !texture_info->SafeToRenderFrom()) { | 5260 if (texture_info && !texture_info->SafeToRenderFrom()) { |
5376 if (!texture_manager()->ClearRenderableLevels(this, texture_info)) { | 5261 if (!texture_manager()->ClearRenderableLevels(this, texture_info)) { |
5377 return false; | 5262 return false; |
5378 } | 5263 } |
5379 } | 5264 } |
5380 } | 5265 } |
5381 } | 5266 } |
5382 } | 5267 } |
5383 } | 5268 } |
5384 return true; | 5269 return true; |
5385 } | 5270 } |
5386 | 5271 |
5387 bool GLES2DecoderImpl::IsDrawValid( | 5272 bool GLES2DecoderImpl::IsDrawValid( |
5388 const char* function_name, GLuint max_vertex_accessed, GLsizei primcount) { | 5273 const char* function_name, GLuint max_vertex_accessed, GLsizei primcount) { |
5389 // NOTE: We specifically do not check current_program->IsValid() because | 5274 // NOTE: We specifically do not check current_program->IsValid() because |
5390 // it could never be invalid since glUseProgram would have failed. While | 5275 // it could never be invalid since glUseProgram would have failed. While |
5391 // glLinkProgram could later mark the program as invalid the previous | 5276 // glLinkProgram could later mark the program as invalid the previous |
5392 // valid program will still function if it is still the current program. | 5277 // valid program will still function if it is still the current program. |
5393 if (!current_program_) { | 5278 if (!state_.current_program) { |
5394 // The program does not exist. | 5279 // The program does not exist. |
5395 // But GL says no ERROR. | 5280 // But GL says no ERROR. |
5396 RenderWarning("Drawing with no current shader program."); | 5281 RenderWarning("Drawing with no current shader program."); |
5397 return false; | 5282 return false; |
5398 } | 5283 } |
5399 | 5284 |
5400 // true if any enabled, used divisor is zero | 5285 // true if any enabled, used divisor is zero |
5401 bool divisor0 = false; | 5286 bool divisor0 = false; |
5402 // Validate all attribs currently enabled. If they are used by the current | 5287 // Validate all attribs currently enabled. If they are used by the current |
5403 // program then check that they have enough elements to handle the draw call. | 5288 // program then check that they have enough elements to handle the draw call. |
5404 // If they are not used by the current program check that they have a buffer | 5289 // If they are not used by the current program check that they have a buffer |
5405 // assigned. | 5290 // assigned. |
5406 const VertexAttribManager::VertexAttribInfoList& infos = | 5291 const VertexAttribManager::VertexAttribInfoList& infos = |
5407 vertex_attrib_manager_->GetEnabledVertexAttribInfos(); | 5292 state_.vertex_attrib_manager->GetEnabledVertexAttribInfos(); |
5408 for (VertexAttribManager::VertexAttribInfoList::const_iterator it = | 5293 for (VertexAttribManager::VertexAttribInfoList::const_iterator it = |
5409 infos.begin(); it != infos.end(); ++it) { | 5294 infos.begin(); it != infos.end(); ++it) { |
5410 const VertexAttribManager::VertexAttribInfo* info = *it; | 5295 const VertexAttribManager::VertexAttribInfo* info = *it; |
5411 const ProgramManager::ProgramInfo::VertexAttribInfo* attrib_info = | 5296 const ProgramManager::ProgramInfo::VertexAttribInfo* attrib_info = |
5412 current_program_->GetAttribInfoByLocation(info->index()); | 5297 state_.current_program->GetAttribInfoByLocation(info->index()); |
5413 if (attrib_info) { | 5298 if (attrib_info) { |
5414 divisor0 |= (info->divisor() == 0); | 5299 divisor0 |= (info->divisor() == 0); |
5415 GLuint count = info->MaxVertexAccessed(primcount, max_vertex_accessed); | 5300 GLuint count = info->MaxVertexAccessed(primcount, max_vertex_accessed); |
5416 // This attrib is used in the current program. | 5301 // This attrib is used in the current program. |
5417 if (!info->CanAccess(count)) { | 5302 if (!info->CanAccess(count)) { |
5418 SetGLError( | 5303 SetGLError( |
5419 GL_INVALID_OPERATION, function_name, | 5304 GL_INVALID_OPERATION, function_name, |
5420 (std::string( | 5305 (std::string( |
5421 "attempt to access out of range vertices in attribute ") + | 5306 "attempt to access out of range vertices in attribute ") + |
5422 base::IntToString(info->index())).c_str()); | 5307 base::IntToString(info->index())).c_str()); |
(...skipping 26 matching lines...) Expand all Loading... | |
5449 | 5334 |
5450 bool GLES2DecoderImpl::SimulateAttrib0( | 5335 bool GLES2DecoderImpl::SimulateAttrib0( |
5451 const char* function_name, GLuint max_vertex_accessed, bool* simulated) { | 5336 const char* function_name, GLuint max_vertex_accessed, bool* simulated) { |
5452 DCHECK(simulated); | 5337 DCHECK(simulated); |
5453 *simulated = false; | 5338 *simulated = false; |
5454 | 5339 |
5455 if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2) | 5340 if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2) |
5456 return true; | 5341 return true; |
5457 | 5342 |
5458 const VertexAttribManager::VertexAttribInfo* info = | 5343 const VertexAttribManager::VertexAttribInfo* info = |
5459 vertex_attrib_manager_->GetVertexAttribInfo(0); | 5344 state_.vertex_attrib_manager->GetVertexAttribInfo(0); |
5460 // If it's enabled or it's not used then we don't need to do anything. | 5345 // If it's enabled or it's not used then we don't need to do anything. |
5461 bool attrib_0_used = current_program_->GetAttribInfoByLocation(0) != NULL; | 5346 bool attrib_0_used = |
5347 state_.current_program->GetAttribInfoByLocation(0) != NULL; | |
5462 if (info->enabled() && attrib_0_used) { | 5348 if (info->enabled() && attrib_0_used) { |
5463 return true; | 5349 return true; |
5464 } | 5350 } |
5465 | 5351 |
5466 // Make a buffer with a single repeated vec4 value enough to | 5352 // Make a buffer with a single repeated vec4 value enough to |
5467 // simulate the constant value that is supposed to be here. | 5353 // simulate the constant value that is supposed to be here. |
5468 // This is required to emulate GLES2 on GL. | 5354 // This is required to emulate GLES2 on GL. |
5469 typedef VertexAttribManager::VertexAttribInfo::Vec4 Vec4; | 5355 typedef VertexAttribManager::VertexAttribInfo::Vec4 Vec4; |
5470 | 5356 |
5471 GLuint num_vertices = max_vertex_accessed + 1; | 5357 GLuint num_vertices = max_vertex_accessed + 1; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5511 | 5397 |
5512 if (info->divisor()) | 5398 if (info->divisor()) |
5513 glVertexAttribDivisorANGLE(0, 0); | 5399 glVertexAttribDivisorANGLE(0, 0); |
5514 | 5400 |
5515 *simulated = true; | 5401 *simulated = true; |
5516 return true; | 5402 return true; |
5517 } | 5403 } |
5518 | 5404 |
5519 void GLES2DecoderImpl::RestoreStateForAttrib(GLuint attrib) { | 5405 void GLES2DecoderImpl::RestoreStateForAttrib(GLuint attrib) { |
5520 const VertexAttribManager::VertexAttribInfo* info = | 5406 const VertexAttribManager::VertexAttribInfo* info = |
5521 vertex_attrib_manager_->GetVertexAttribInfo(attrib); | 5407 state_.vertex_attrib_manager->GetVertexAttribInfo(attrib); |
5522 const void* ptr = reinterpret_cast<const void*>(info->offset()); | 5408 const void* ptr = reinterpret_cast<const void*>(info->offset()); |
5523 BufferManager::BufferInfo* buffer_info = info->buffer(); | 5409 BufferManager::BufferInfo* buffer_info = info->buffer(); |
5524 glBindBuffer(GL_ARRAY_BUFFER, buffer_info ? buffer_info->service_id() : 0); | 5410 glBindBuffer(GL_ARRAY_BUFFER, buffer_info ? buffer_info->service_id() : 0); |
5525 glVertexAttribPointer( | 5411 glVertexAttribPointer( |
5526 attrib, info->size(), info->type(), info->normalized(), info->gl_stride(), | 5412 attrib, info->size(), info->type(), info->normalized(), info->gl_stride(), |
5527 ptr); | 5413 ptr); |
5528 if (info->divisor()) | 5414 if (info->divisor()) |
5529 glVertexAttribDivisorANGLE(attrib, info->divisor()); | 5415 glVertexAttribDivisorANGLE(attrib, info->divisor()); |
5530 glBindBuffer(GL_ARRAY_BUFFER, | 5416 glBindBuffer( |
5531 bound_array_buffer_ ? bound_array_buffer_->service_id() : 0); | 5417 GL_ARRAY_BUFFER, |
5418 state_.bound_array_buffer ? state_.bound_array_buffer->service_id() : 0); | |
5532 | 5419 |
5533 // Never touch vertex attribute 0's state (in particular, never | 5420 // Never touch vertex attribute 0's state (in particular, never |
5534 // disable it) when running on desktop GL because it will never be | 5421 // disable it) when running on desktop GL because it will never be |
5535 // re-enabled. | 5422 // re-enabled. |
5536 if (attrib != 0 || | 5423 if (attrib != 0 || |
5537 gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2) { | 5424 gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2) { |
5538 if (info->enabled()) { | 5425 if (info->enabled()) { |
5539 glEnableVertexAttribArray(attrib); | 5426 glEnableVertexAttribArray(attrib); |
5540 } else { | 5427 } else { |
5541 glDisableVertexAttribArray(attrib); | 5428 glDisableVertexAttribArray(attrib); |
5542 } | 5429 } |
5543 } | 5430 } |
5544 } | 5431 } |
5545 | 5432 |
5546 bool GLES2DecoderImpl::SimulateFixedAttribs( | 5433 bool GLES2DecoderImpl::SimulateFixedAttribs( |
5547 const char* function_name, | 5434 const char* function_name, |
5548 GLuint max_vertex_accessed, bool* simulated, GLsizei primcount) { | 5435 GLuint max_vertex_accessed, bool* simulated, GLsizei primcount) { |
5549 DCHECK(simulated); | 5436 DCHECK(simulated); |
5550 *simulated = false; | 5437 *simulated = false; |
5551 if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2) | 5438 if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2) |
5552 return true; | 5439 return true; |
5553 | 5440 |
5554 if (!vertex_attrib_manager_->HaveFixedAttribs()) { | 5441 if (!state_.vertex_attrib_manager->HaveFixedAttribs()) { |
5555 return true; | 5442 return true; |
5556 } | 5443 } |
5557 | 5444 |
5558 PerformanceWarning( | 5445 PerformanceWarning( |
5559 "GL_FIXED attributes have a signficant performance penalty"); | 5446 "GL_FIXED attributes have a signficant performance penalty"); |
5560 | 5447 |
5561 // NOTE: we could be smart and try to check if a buffer is used | 5448 // NOTE: we could be smart and try to check if a buffer is used |
5562 // twice in 2 different attribs, find the overlapping parts and therefore | 5449 // twice in 2 different attribs, find the overlapping parts and therefore |
5563 // duplicate the minimum amount of data but this whole code path is not meant | 5450 // duplicate the minimum amount of data but this whole code path is not meant |
5564 // to be used normally. It's just here to pass that OpenGL ES 2.0 conformance | 5451 // to be used normally. It's just here to pass that OpenGL ES 2.0 conformance |
5565 // tests so we just add to the buffer attrib used. | 5452 // tests so we just add to the buffer attrib used. |
5566 | 5453 |
5567 GLuint elements_needed = 0; | 5454 GLuint elements_needed = 0; |
5568 const VertexAttribManager::VertexAttribInfoList& infos = | 5455 const VertexAttribManager::VertexAttribInfoList& infos = |
5569 vertex_attrib_manager_->GetEnabledVertexAttribInfos(); | 5456 state_.vertex_attrib_manager->GetEnabledVertexAttribInfos(); |
5570 for (VertexAttribManager::VertexAttribInfoList::const_iterator it = | 5457 for (VertexAttribManager::VertexAttribInfoList::const_iterator it = |
5571 infos.begin(); it != infos.end(); ++it) { | 5458 infos.begin(); it != infos.end(); ++it) { |
5572 const VertexAttribManager::VertexAttribInfo* info = *it; | 5459 const VertexAttribManager::VertexAttribInfo* info = *it; |
5573 const ProgramManager::ProgramInfo::VertexAttribInfo* attrib_info = | 5460 const ProgramManager::ProgramInfo::VertexAttribInfo* attrib_info = |
5574 current_program_->GetAttribInfoByLocation(info->index()); | 5461 state_.current_program->GetAttribInfoByLocation(info->index()); |
5575 GLuint max_accessed = info->MaxVertexAccessed(primcount, | 5462 GLuint max_accessed = info->MaxVertexAccessed(primcount, |
5576 max_vertex_accessed); | 5463 max_vertex_accessed); |
5577 GLuint num_vertices = max_accessed + 1; | 5464 GLuint num_vertices = max_accessed + 1; |
5578 if (num_vertices == 0) { | 5465 if (num_vertices == 0) { |
5579 SetGLError(GL_OUT_OF_MEMORY, function_name, "Simulating attrib 0"); | 5466 SetGLError(GL_OUT_OF_MEMORY, function_name, "Simulating attrib 0"); |
5580 return false; | 5467 return false; |
5581 } | 5468 } |
5582 if (attrib_info && | 5469 if (attrib_info && |
5583 info->CanAccess(max_accessed) && | 5470 info->CanAccess(max_accessed) && |
5584 info->type() == GL_FIXED) { | 5471 info->type() == GL_FIXED) { |
(...skipping 27 matching lines...) Expand all Loading... | |
5612 return false; | 5499 return false; |
5613 } | 5500 } |
5614 } | 5501 } |
5615 | 5502 |
5616 // Copy the elements and convert to float | 5503 // Copy the elements and convert to float |
5617 GLintptr offset = 0; | 5504 GLintptr offset = 0; |
5618 for (VertexAttribManager::VertexAttribInfoList::const_iterator it = | 5505 for (VertexAttribManager::VertexAttribInfoList::const_iterator it = |
5619 infos.begin(); it != infos.end(); ++it) { | 5506 infos.begin(); it != infos.end(); ++it) { |
5620 const VertexAttribManager::VertexAttribInfo* info = *it; | 5507 const VertexAttribManager::VertexAttribInfo* info = *it; |
5621 const ProgramManager::ProgramInfo::VertexAttribInfo* attrib_info = | 5508 const ProgramManager::ProgramInfo::VertexAttribInfo* attrib_info = |
5622 current_program_->GetAttribInfoByLocation(info->index()); | 5509 state_.current_program->GetAttribInfoByLocation(info->index()); |
5623 GLuint max_accessed = info->MaxVertexAccessed(primcount, | 5510 GLuint max_accessed = info->MaxVertexAccessed(primcount, |
5624 max_vertex_accessed); | 5511 max_vertex_accessed); |
5625 GLuint num_vertices = max_accessed + 1; | 5512 GLuint num_vertices = max_accessed + 1; |
5626 if (num_vertices == 0) { | 5513 if (num_vertices == 0) { |
5627 SetGLError(GL_OUT_OF_MEMORY, function_name, "Simulating attrib 0"); | 5514 SetGLError(GL_OUT_OF_MEMORY, function_name, "Simulating attrib 0"); |
5628 return false; | 5515 return false; |
5629 } | 5516 } |
5630 if (attrib_info && | 5517 if (attrib_info && |
5631 info->CanAccess(max_accessed) && | 5518 info->CanAccess(max_accessed) && |
5632 info->type() == GL_FIXED) { | 5519 info->type() == GL_FIXED) { |
(...skipping 14 matching lines...) Expand all Loading... | |
5647 offset += size; | 5534 offset += size; |
5648 } | 5535 } |
5649 } | 5536 } |
5650 *simulated = true; | 5537 *simulated = true; |
5651 return true; | 5538 return true; |
5652 } | 5539 } |
5653 | 5540 |
5654 void GLES2DecoderImpl::RestoreStateForSimulatedFixedAttribs() { | 5541 void GLES2DecoderImpl::RestoreStateForSimulatedFixedAttribs() { |
5655 // There's no need to call glVertexAttribPointer because we shadow all the | 5542 // There's no need to call glVertexAttribPointer because we shadow all the |
5656 // settings and passing GL_FIXED to it will not work. | 5543 // settings and passing GL_FIXED to it will not work. |
5657 glBindBuffer(GL_ARRAY_BUFFER, | 5544 glBindBuffer( |
5658 bound_array_buffer_ ? bound_array_buffer_->service_id() : 0); | 5545 GL_ARRAY_BUFFER, |
5546 state_.bound_array_buffer ? state_.bound_array_buffer->service_id() : 0); | |
5659 } | 5547 } |
5660 | 5548 |
5661 error::Error GLES2DecoderImpl::DoDrawArrays( | 5549 error::Error GLES2DecoderImpl::DoDrawArrays( |
5662 const char* function_name, | 5550 const char* function_name, |
5663 bool instanced, | 5551 bool instanced, |
5664 GLenum mode, | 5552 GLenum mode, |
5665 GLint first, | 5553 GLint first, |
5666 GLsizei count, | 5554 GLsizei count, |
5667 GLsizei primcount) { | 5555 GLsizei primcount) { |
5668 if (ShouldDeferDraws()) | 5556 if (ShouldDeferDraws()) |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5763 error::Error GLES2DecoderImpl::DoDrawElements( | 5651 error::Error GLES2DecoderImpl::DoDrawElements( |
5764 const char* function_name, | 5652 const char* function_name, |
5765 bool instanced, | 5653 bool instanced, |
5766 GLenum mode, | 5654 GLenum mode, |
5767 GLsizei count, | 5655 GLsizei count, |
5768 GLenum type, | 5656 GLenum type, |
5769 int32 offset, | 5657 int32 offset, |
5770 GLsizei primcount) { | 5658 GLsizei primcount) { |
5771 if (ShouldDeferDraws()) | 5659 if (ShouldDeferDraws()) |
5772 return error::kDeferCommandUntilLater; | 5660 return error::kDeferCommandUntilLater; |
5773 if (!vertex_attrib_manager_->element_array_buffer()) { | 5661 if (!state_.vertex_attrib_manager->element_array_buffer()) { |
5774 SetGLError(GL_INVALID_OPERATION, | 5662 SetGLError(GL_INVALID_OPERATION, |
5775 function_name, "No element array buffer bound"); | 5663 function_name, "No element array buffer bound"); |
5776 return error::kNoError; | 5664 return error::kNoError; |
5777 } | 5665 } |
5778 | 5666 |
5779 if (count < 0) { | 5667 if (count < 0) { |
5780 SetGLError(GL_INVALID_VALUE, function_name, "count < 0"); | 5668 SetGLError(GL_INVALID_VALUE, function_name, "count < 0"); |
5781 return error::kNoError; | 5669 return error::kNoError; |
5782 } | 5670 } |
5783 if (offset < 0) { | 5671 if (offset < 0) { |
(...skipping 15 matching lines...) Expand all Loading... | |
5799 | 5687 |
5800 if (!CheckBoundFramebuffersValid(function_name)) { | 5688 if (!CheckBoundFramebuffersValid(function_name)) { |
5801 return error::kNoError; | 5689 return error::kNoError; |
5802 } | 5690 } |
5803 | 5691 |
5804 if (count == 0 || (instanced && primcount == 0)) { | 5692 if (count == 0 || (instanced && primcount == 0)) { |
5805 return error::kNoError; | 5693 return error::kNoError; |
5806 } | 5694 } |
5807 | 5695 |
5808 GLuint max_vertex_accessed; | 5696 GLuint max_vertex_accessed; |
5809 if (!vertex_attrib_manager_->element_array_buffer()->GetMaxValueForRange( | 5697 if (!state_.vertex_attrib_manager->element_array_buffer( |
5810 offset, count, type, &max_vertex_accessed)) { | 5698 )->GetMaxValueForRange(offset, count, type, &max_vertex_accessed)) { |
5811 SetGLError(GL_INVALID_OPERATION, | 5699 SetGLError(GL_INVALID_OPERATION, |
5812 function_name, "range out of bounds for buffer"); | 5700 function_name, "range out of bounds for buffer"); |
5813 return error::kNoError; | 5701 return error::kNoError; |
5814 } | 5702 } |
5815 | 5703 |
5816 if (IsDrawValid(function_name, max_vertex_accessed, primcount)) { | 5704 if (IsDrawValid(function_name, max_vertex_accessed, primcount)) { |
5817 if (!ClearUnclearedTextures()) { | 5705 if (!ClearUnclearedTextures()) { |
5818 SetGLError(GL_INVALID_VALUE, function_name, "out of memory"); | 5706 SetGLError(GL_INVALID_VALUE, function_name, "out of memory"); |
5819 return error::kNoError; | 5707 return error::kNoError; |
5820 } | 5708 } |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6142 program_client_id, "glValidateProgram"); | 6030 program_client_id, "glValidateProgram"); |
6143 if (!info) { | 6031 if (!info) { |
6144 return; | 6032 return; |
6145 } | 6033 } |
6146 info->Validate(); | 6034 info->Validate(); |
6147 } | 6035 } |
6148 | 6036 |
6149 void GLES2DecoderImpl::DoGetVertexAttribfv( | 6037 void GLES2DecoderImpl::DoGetVertexAttribfv( |
6150 GLuint index, GLenum pname, GLfloat* params) { | 6038 GLuint index, GLenum pname, GLfloat* params) { |
6151 VertexAttribManager::VertexAttribInfo* info = | 6039 VertexAttribManager::VertexAttribInfo* info = |
6152 vertex_attrib_manager_->GetVertexAttribInfo(index); | 6040 state_.vertex_attrib_manager->GetVertexAttribInfo(index); |
6153 if (!info) { | 6041 if (!info) { |
6154 SetGLError(GL_INVALID_VALUE, "glGetVertexAttribfv", "index out of range"); | 6042 SetGLError(GL_INVALID_VALUE, "glGetVertexAttribfv", "index out of range"); |
6155 return; | 6043 return; |
6156 } | 6044 } |
6157 switch (pname) { | 6045 switch (pname) { |
6158 case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: { | 6046 case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: { |
6159 BufferManager::BufferInfo* buffer = info->buffer(); | 6047 BufferManager::BufferInfo* buffer = info->buffer(); |
6160 if (buffer && !buffer->IsDeleted()) { | 6048 if (buffer && !buffer->IsDeleted()) { |
6161 GLuint client_id; | 6049 GLuint client_id; |
6162 buffer_manager()->GetClientId(buffer->service_id(), &client_id); | 6050 buffer_manager()->GetClientId(buffer->service_id(), &client_id); |
(...skipping 27 matching lines...) Expand all Loading... | |
6190 break; | 6078 break; |
6191 default: | 6079 default: |
6192 NOTREACHED(); | 6080 NOTREACHED(); |
6193 break; | 6081 break; |
6194 } | 6082 } |
6195 } | 6083 } |
6196 | 6084 |
6197 void GLES2DecoderImpl::DoGetVertexAttribiv( | 6085 void GLES2DecoderImpl::DoGetVertexAttribiv( |
6198 GLuint index, GLenum pname, GLint* params) { | 6086 GLuint index, GLenum pname, GLint* params) { |
6199 VertexAttribManager::VertexAttribInfo* info = | 6087 VertexAttribManager::VertexAttribInfo* info = |
6200 vertex_attrib_manager_->GetVertexAttribInfo(index); | 6088 state_.vertex_attrib_manager->GetVertexAttribInfo(index); |
6201 if (!info) { | 6089 if (!info) { |
6202 SetGLError(GL_INVALID_VALUE, "glGetVertexAttribiv", "index out of range"); | 6090 SetGLError(GL_INVALID_VALUE, "glGetVertexAttribiv", "index out of range"); |
6203 return; | 6091 return; |
6204 } | 6092 } |
6205 switch (pname) { | 6093 switch (pname) { |
6206 case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: { | 6094 case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: { |
6207 BufferManager::BufferInfo* buffer = info->buffer(); | 6095 BufferManager::BufferInfo* buffer = info->buffer(); |
6208 if (buffer && !buffer->IsDeleted()) { | 6096 if (buffer && !buffer->IsDeleted()) { |
6209 GLuint client_id; | 6097 GLuint client_id; |
6210 buffer_manager()->GetClientId(buffer->service_id(), &client_id); | 6098 buffer_manager()->GetClientId(buffer->service_id(), &client_id); |
(...skipping 26 matching lines...) Expand all Loading... | |
6237 params[3] = static_cast<GLint>(info->value().v[3]); | 6125 params[3] = static_cast<GLint>(info->value().v[3]); |
6238 break; | 6126 break; |
6239 default: | 6127 default: |
6240 NOTREACHED(); | 6128 NOTREACHED(); |
6241 break; | 6129 break; |
6242 } | 6130 } |
6243 } | 6131 } |
6244 | 6132 |
6245 void GLES2DecoderImpl::DoVertexAttrib1f(GLuint index, GLfloat v0) { | 6133 void GLES2DecoderImpl::DoVertexAttrib1f(GLuint index, GLfloat v0) { |
6246 VertexAttribManager::VertexAttribInfo* info = | 6134 VertexAttribManager::VertexAttribInfo* info = |
6247 vertex_attrib_manager_->GetVertexAttribInfo(index); | 6135 state_.vertex_attrib_manager->GetVertexAttribInfo(index); |
6248 if (!info) { | 6136 if (!info) { |
6249 SetGLError(GL_INVALID_VALUE, "glVertexAttrib1f", "index out of range"); | 6137 SetGLError(GL_INVALID_VALUE, "glVertexAttrib1f", "index out of range"); |
6250 return; | 6138 return; |
6251 } | 6139 } |
6252 VertexAttribManager::VertexAttribInfo::Vec4 value; | 6140 VertexAttribManager::VertexAttribInfo::Vec4 value; |
6253 value.v[0] = v0; | 6141 value.v[0] = v0; |
6254 value.v[1] = 0.0f; | 6142 value.v[1] = 0.0f; |
6255 value.v[2] = 0.0f; | 6143 value.v[2] = 0.0f; |
6256 value.v[3] = 1.0f; | 6144 value.v[3] = 1.0f; |
6257 info->set_value(value); | 6145 info->set_value(value); |
6258 glVertexAttrib1f(index, v0); | 6146 glVertexAttrib1f(index, v0); |
6259 } | 6147 } |
6260 | 6148 |
6261 void GLES2DecoderImpl::DoVertexAttrib2f(GLuint index, GLfloat v0, GLfloat v1) { | 6149 void GLES2DecoderImpl::DoVertexAttrib2f(GLuint index, GLfloat v0, GLfloat v1) { |
6262 VertexAttribManager::VertexAttribInfo* info = | 6150 VertexAttribManager::VertexAttribInfo* info = |
6263 vertex_attrib_manager_->GetVertexAttribInfo(index); | 6151 state_.vertex_attrib_manager->GetVertexAttribInfo(index); |
6264 if (!info) { | 6152 if (!info) { |
6265 SetGLError(GL_INVALID_VALUE, "glVertexAttrib2f", "index out of range"); | 6153 SetGLError(GL_INVALID_VALUE, "glVertexAttrib2f", "index out of range"); |
6266 return; | 6154 return; |
6267 } | 6155 } |
6268 VertexAttribManager::VertexAttribInfo::Vec4 value; | 6156 VertexAttribManager::VertexAttribInfo::Vec4 value; |
6269 value.v[0] = v0; | 6157 value.v[0] = v0; |
6270 value.v[1] = v1; | 6158 value.v[1] = v1; |
6271 value.v[2] = 0.0f; | 6159 value.v[2] = 0.0f; |
6272 value.v[3] = 1.0f; | 6160 value.v[3] = 1.0f; |
6273 info->set_value(value); | 6161 info->set_value(value); |
6274 glVertexAttrib2f(index, v0, v1); | 6162 glVertexAttrib2f(index, v0, v1); |
6275 } | 6163 } |
6276 | 6164 |
6277 void GLES2DecoderImpl::DoVertexAttrib3f( | 6165 void GLES2DecoderImpl::DoVertexAttrib3f( |
6278 GLuint index, GLfloat v0, GLfloat v1, GLfloat v2) { | 6166 GLuint index, GLfloat v0, GLfloat v1, GLfloat v2) { |
6279 VertexAttribManager::VertexAttribInfo* info = | 6167 VertexAttribManager::VertexAttribInfo* info = |
6280 vertex_attrib_manager_->GetVertexAttribInfo(index); | 6168 state_.vertex_attrib_manager->GetVertexAttribInfo(index); |
6281 if (!info) { | 6169 if (!info) { |
6282 SetGLError(GL_INVALID_VALUE, "glVertexAttrib3f", "index out of range"); | 6170 SetGLError(GL_INVALID_VALUE, "glVertexAttrib3f", "index out of range"); |
6283 return; | 6171 return; |
6284 } | 6172 } |
6285 VertexAttribManager::VertexAttribInfo::Vec4 value; | 6173 VertexAttribManager::VertexAttribInfo::Vec4 value; |
6286 value.v[0] = v0; | 6174 value.v[0] = v0; |
6287 value.v[1] = v1; | 6175 value.v[1] = v1; |
6288 value.v[2] = v2; | 6176 value.v[2] = v2; |
6289 value.v[3] = 1.0f; | 6177 value.v[3] = 1.0f; |
6290 info->set_value(value); | 6178 info->set_value(value); |
6291 glVertexAttrib3f(index, v0, v1, v2); | 6179 glVertexAttrib3f(index, v0, v1, v2); |
6292 } | 6180 } |
6293 | 6181 |
6294 void GLES2DecoderImpl::DoVertexAttrib4f( | 6182 void GLES2DecoderImpl::DoVertexAttrib4f( |
6295 GLuint index, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) { | 6183 GLuint index, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) { |
6296 VertexAttribManager::VertexAttribInfo* info = | 6184 VertexAttribManager::VertexAttribInfo* info = |
6297 vertex_attrib_manager_->GetVertexAttribInfo(index); | 6185 state_.vertex_attrib_manager->GetVertexAttribInfo(index); |
6298 if (!info) { | 6186 if (!info) { |
6299 SetGLError(GL_INVALID_VALUE, "glVertexAttrib4f", "index out of range"); | 6187 SetGLError(GL_INVALID_VALUE, "glVertexAttrib4f", "index out of range"); |
6300 return; | 6188 return; |
6301 } | 6189 } |
6302 VertexAttribManager::VertexAttribInfo::Vec4 value; | 6190 VertexAttribManager::VertexAttribInfo::Vec4 value; |
6303 value.v[0] = v0; | 6191 value.v[0] = v0; |
6304 value.v[1] = v1; | 6192 value.v[1] = v1; |
6305 value.v[2] = v2; | 6193 value.v[2] = v2; |
6306 value.v[3] = v3; | 6194 value.v[3] = v3; |
6307 info->set_value(value); | 6195 info->set_value(value); |
6308 glVertexAttrib4f(index, v0, v1, v2, v3); | 6196 glVertexAttrib4f(index, v0, v1, v2, v3); |
6309 } | 6197 } |
6310 | 6198 |
6311 void GLES2DecoderImpl::DoVertexAttrib1fv(GLuint index, const GLfloat* v) { | 6199 void GLES2DecoderImpl::DoVertexAttrib1fv(GLuint index, const GLfloat* v) { |
6312 VertexAttribManager::VertexAttribInfo* info = | 6200 VertexAttribManager::VertexAttribInfo* info = |
6313 vertex_attrib_manager_->GetVertexAttribInfo(index); | 6201 state_.vertex_attrib_manager->GetVertexAttribInfo(index); |
6314 if (!info) { | 6202 if (!info) { |
6315 SetGLError(GL_INVALID_VALUE, "glVertexAttrib1fv", "index out of range"); | 6203 SetGLError(GL_INVALID_VALUE, "glVertexAttrib1fv", "index out of range"); |
6316 return; | 6204 return; |
6317 } | 6205 } |
6318 VertexAttribManager::VertexAttribInfo::Vec4 value; | 6206 VertexAttribManager::VertexAttribInfo::Vec4 value; |
6319 value.v[0] = v[0]; | 6207 value.v[0] = v[0]; |
6320 value.v[1] = 0.0f; | 6208 value.v[1] = 0.0f; |
6321 value.v[2] = 0.0f; | 6209 value.v[2] = 0.0f; |
6322 value.v[3] = 1.0f; | 6210 value.v[3] = 1.0f; |
6323 info->set_value(value); | 6211 info->set_value(value); |
6324 glVertexAttrib1fv(index, v); | 6212 glVertexAttrib1fv(index, v); |
6325 } | 6213 } |
6326 | 6214 |
6327 void GLES2DecoderImpl::DoVertexAttrib2fv(GLuint index, const GLfloat* v) { | 6215 void GLES2DecoderImpl::DoVertexAttrib2fv(GLuint index, const GLfloat* v) { |
6328 VertexAttribManager::VertexAttribInfo* info = | 6216 VertexAttribManager::VertexAttribInfo* info = |
6329 vertex_attrib_manager_->GetVertexAttribInfo(index); | 6217 state_.vertex_attrib_manager->GetVertexAttribInfo(index); |
6330 if (!info) { | 6218 if (!info) { |
6331 SetGLError(GL_INVALID_VALUE, "glVertexAttrib2fv", "index out of range"); | 6219 SetGLError(GL_INVALID_VALUE, "glVertexAttrib2fv", "index out of range"); |
6332 return; | 6220 return; |
6333 } | 6221 } |
6334 VertexAttribManager::VertexAttribInfo::Vec4 value; | 6222 VertexAttribManager::VertexAttribInfo::Vec4 value; |
6335 value.v[0] = v[0]; | 6223 value.v[0] = v[0]; |
6336 value.v[1] = v[1]; | 6224 value.v[1] = v[1]; |
6337 value.v[2] = 0.0f; | 6225 value.v[2] = 0.0f; |
6338 value.v[3] = 1.0f; | 6226 value.v[3] = 1.0f; |
6339 info->set_value(value); | 6227 info->set_value(value); |
6340 glVertexAttrib2fv(index, v); | 6228 glVertexAttrib2fv(index, v); |
6341 } | 6229 } |
6342 | 6230 |
6343 void GLES2DecoderImpl::DoVertexAttrib3fv(GLuint index, const GLfloat* v) { | 6231 void GLES2DecoderImpl::DoVertexAttrib3fv(GLuint index, const GLfloat* v) { |
6344 VertexAttribManager::VertexAttribInfo* info = | 6232 VertexAttribManager::VertexAttribInfo* info = |
6345 vertex_attrib_manager_->GetVertexAttribInfo(index); | 6233 state_.vertex_attrib_manager->GetVertexAttribInfo(index); |
6346 if (!info) { | 6234 if (!info) { |
6347 SetGLError(GL_INVALID_VALUE, "glVertexAttrib3fv", "index out of range"); | 6235 SetGLError(GL_INVALID_VALUE, "glVertexAttrib3fv", "index out of range"); |
6348 return; | 6236 return; |
6349 } | 6237 } |
6350 VertexAttribManager::VertexAttribInfo::Vec4 value; | 6238 VertexAttribManager::VertexAttribInfo::Vec4 value; |
6351 value.v[0] = v[0]; | 6239 value.v[0] = v[0]; |
6352 value.v[1] = v[1]; | 6240 value.v[1] = v[1]; |
6353 value.v[2] = v[2]; | 6241 value.v[2] = v[2]; |
6354 value.v[3] = 1.0f; | 6242 value.v[3] = 1.0f; |
6355 info->set_value(value); | 6243 info->set_value(value); |
6356 glVertexAttrib3fv(index, v); | 6244 glVertexAttrib3fv(index, v); |
6357 } | 6245 } |
6358 | 6246 |
6359 void GLES2DecoderImpl::DoVertexAttrib4fv(GLuint index, const GLfloat* v) { | 6247 void GLES2DecoderImpl::DoVertexAttrib4fv(GLuint index, const GLfloat* v) { |
6360 VertexAttribManager::VertexAttribInfo* info = | 6248 VertexAttribManager::VertexAttribInfo* info = |
6361 vertex_attrib_manager_->GetVertexAttribInfo(index); | 6249 state_.vertex_attrib_manager->GetVertexAttribInfo(index); |
6362 if (!info) { | 6250 if (!info) { |
6363 SetGLError(GL_INVALID_VALUE, "glVertexAttrib4fv", "index out of range"); | 6251 SetGLError(GL_INVALID_VALUE, "glVertexAttrib4fv", "index out of range"); |
6364 return; | 6252 return; |
6365 } | 6253 } |
6366 VertexAttribManager::VertexAttribInfo::Vec4 value; | 6254 VertexAttribManager::VertexAttribInfo::Vec4 value; |
6367 value.v[0] = v[0]; | 6255 value.v[0] = v[0]; |
6368 value.v[1] = v[1]; | 6256 value.v[1] = v[1]; |
6369 value.v[2] = v[2]; | 6257 value.v[2] = v[2]; |
6370 value.v[3] = v[3]; | 6258 value.v[3] = v[3]; |
6371 info->set_value(value); | 6259 info->set_value(value); |
6372 glVertexAttrib4fv(index, v); | 6260 glVertexAttrib4fv(index, v); |
6373 } | 6261 } |
6374 | 6262 |
6375 error::Error GLES2DecoderImpl::HandleVertexAttribPointer( | 6263 error::Error GLES2DecoderImpl::HandleVertexAttribPointer( |
6376 uint32 immediate_data_size, const gles2::VertexAttribPointer& c) { | 6264 uint32 immediate_data_size, const gles2::VertexAttribPointer& c) { |
6377 | 6265 |
6378 if (!bound_array_buffer_ || bound_array_buffer_->IsDeleted()) { | 6266 if (!state_.bound_array_buffer || state_.bound_array_buffer->IsDeleted()) { |
6379 if (vertex_attrib_manager_ == default_vertex_attrib_manager_) { | 6267 if (state_.vertex_attrib_manager == default_vertex_attrib_manager_) { |
6380 SetGLError(GL_INVALID_VALUE, | 6268 SetGLError(GL_INVALID_VALUE, |
6381 "glVertexAttribPointer", "no array buffer bound"); | 6269 "glVertexAttribPointer", "no array buffer bound"); |
6382 return error::kNoError; | 6270 return error::kNoError; |
6383 } else if (c.offset != 0) { | 6271 } else if (c.offset != 0) { |
6384 SetGLError(GL_INVALID_VALUE, | 6272 SetGLError(GL_INVALID_VALUE, |
6385 "glVertexAttribPointer", "client side arrays are not allowed"); | 6273 "glVertexAttribPointer", "client side arrays are not allowed"); |
6386 return error::kNoError; | 6274 return error::kNoError; |
6387 } | 6275 } |
6388 } | 6276 } |
6389 | 6277 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6427 if (offset % component_size > 0) { | 6315 if (offset % component_size > 0) { |
6428 SetGLError(GL_INVALID_OPERATION, | 6316 SetGLError(GL_INVALID_OPERATION, |
6429 "glVertexAttribPointer", "offset not valid for type"); | 6317 "glVertexAttribPointer", "offset not valid for type"); |
6430 return error::kNoError; | 6318 return error::kNoError; |
6431 } | 6319 } |
6432 if (stride % component_size > 0) { | 6320 if (stride % component_size > 0) { |
6433 SetGLError(GL_INVALID_OPERATION, | 6321 SetGLError(GL_INVALID_OPERATION, |
6434 "glVertexAttribPointer", "stride not valid for type"); | 6322 "glVertexAttribPointer", "stride not valid for type"); |
6435 return error::kNoError; | 6323 return error::kNoError; |
6436 } | 6324 } |
6437 vertex_attrib_manager_->SetAttribInfo( | 6325 state_.vertex_attrib_manager->SetAttribInfo( |
6438 indx, | 6326 indx, |
6439 bound_array_buffer_, | 6327 state_.bound_array_buffer, |
6440 size, | 6328 size, |
6441 type, | 6329 type, |
6442 normalized, | 6330 normalized, |
6443 stride, | 6331 stride, |
6444 stride != 0 ? stride : component_size * size, | 6332 stride != 0 ? stride : component_size * size, |
6445 offset); | 6333 offset); |
6446 if (type != GL_FIXED) { | 6334 if (type != GL_FIXED) { |
6447 glVertexAttribPointer(indx, size, type, normalized, stride, ptr); | 6335 glVertexAttribPointer(indx, size, type, normalized, stride, ptr); |
6448 } | 6336 } |
6449 return error::kNoError; | 6337 return error::kNoError; |
6450 } | 6338 } |
6451 | 6339 |
6452 void GLES2DecoderImpl::DoViewport(GLint x, GLint y, GLsizei width, | 6340 void GLES2DecoderImpl::DoViewport(GLint x, GLint y, GLsizei width, |
6453 GLsizei height) { | 6341 GLsizei height) { |
6454 viewport_x_ = x; | 6342 state_.viewport_x = x; |
6455 viewport_y_ = y; | 6343 state_.viewport_y = y; |
6456 viewport_width_ = std::min(width, viewport_max_width_); | 6344 state_.viewport_width = std::min(width, state_.viewport_max_width); |
6457 viewport_height_ = std::min(height, viewport_max_height_); | 6345 state_.viewport_height = std::min(height, state_.viewport_max_height); |
6458 glViewport(x, y, width, height); | 6346 glViewport(x, y, width, height); |
6459 } | 6347 } |
6460 | 6348 |
6461 error::Error GLES2DecoderImpl::HandleVertexAttribDivisorANGLE( | 6349 error::Error GLES2DecoderImpl::HandleVertexAttribDivisorANGLE( |
6462 uint32 immediate_data_size, const gles2::VertexAttribDivisorANGLE& c) { | 6350 uint32 immediate_data_size, const gles2::VertexAttribDivisorANGLE& c) { |
6463 if (!feature_info_->feature_flags().angle_instanced_arrays) { | 6351 if (!feature_info_->feature_flags().angle_instanced_arrays) { |
6464 SetGLError(GL_INVALID_OPERATION, | 6352 SetGLError(GL_INVALID_OPERATION, |
6465 "glVertexAttribDivisorANGLE", "function not available"); | 6353 "glVertexAttribDivisorANGLE", "function not available"); |
6466 } | 6354 } |
6467 GLuint index = c.index; | 6355 GLuint index = c.index; |
6468 GLuint divisor = c.divisor; | 6356 GLuint divisor = c.divisor; |
6469 if (index >= group_->max_vertex_attribs()) { | 6357 if (index >= group_->max_vertex_attribs()) { |
6470 SetGLError(GL_INVALID_VALUE, | 6358 SetGLError(GL_INVALID_VALUE, |
6471 "glVertexAttribDivisorANGLE", "index out of range"); | 6359 "glVertexAttribDivisorANGLE", "index out of range"); |
6472 return error::kNoError; | 6360 return error::kNoError; |
6473 } | 6361 } |
6474 | 6362 |
6475 vertex_attrib_manager_->SetDivisor( | 6363 state_.vertex_attrib_manager->SetDivisor( |
6476 index, | 6364 index, |
6477 divisor); | 6365 divisor); |
6478 glVertexAttribDivisorANGLE(index, divisor); | 6366 glVertexAttribDivisorANGLE(index, divisor); |
6479 return error::kNoError; | 6367 return error::kNoError; |
6480 } | 6368 } |
6481 | 6369 |
6482 error::Error GLES2DecoderImpl::HandleReadPixels( | 6370 error::Error GLES2DecoderImpl::HandleReadPixels( |
6483 uint32 immediate_data_size, const gles2::ReadPixels& c) { | 6371 uint32 immediate_data_size, const gles2::ReadPixels& c) { |
6484 GLint x = c.x; | 6372 GLint x = c.x; |
6485 GLint y = c.y; | 6373 GLint y = c.y; |
6486 GLsizei width = c.width; | 6374 GLsizei width = c.width; |
6487 GLsizei height = c.height; | 6375 GLsizei height = c.height; |
6488 GLenum format = c.format; | 6376 GLenum format = c.format; |
6489 GLenum type = c.type; | 6377 GLenum type = c.type; |
6490 if (width < 0 || height < 0) { | 6378 if (width < 0 || height < 0) { |
6491 SetGLError(GL_INVALID_VALUE, "glReadPixels", "dimensions < 0"); | 6379 SetGLError(GL_INVALID_VALUE, "glReadPixels", "dimensions < 0"); |
6492 return error::kNoError; | 6380 return error::kNoError; |
6493 } | 6381 } |
6494 typedef gles2::ReadPixels::Result Result; | 6382 typedef gles2::ReadPixels::Result Result; |
6495 uint32 pixels_size; | 6383 uint32 pixels_size; |
6496 if (!GLES2Util::ComputeImageDataSizes( | 6384 if (!GLES2Util::ComputeImageDataSizes( |
6497 width, height, format, type, pack_alignment_, &pixels_size, NULL, NULL)) { | 6385 width, height, format, type, state_.pack_alignment, &pixels_size, |
6386 NULL, NULL)) { | |
6498 return error::kOutOfBounds; | 6387 return error::kOutOfBounds; |
6499 } | 6388 } |
6500 void* pixels = GetSharedMemoryAs<void*>( | 6389 void* pixels = GetSharedMemoryAs<void*>( |
6501 c.pixels_shm_id, c.pixels_shm_offset, pixels_size); | 6390 c.pixels_shm_id, c.pixels_shm_offset, pixels_size); |
6502 Result* result = GetSharedMemoryAs<Result*>( | 6391 Result* result = GetSharedMemoryAs<Result*>( |
6503 c.result_shm_id, c.result_shm_offset, sizeof(*result)); | 6392 c.result_shm_id, c.result_shm_offset, sizeof(*result)); |
6504 if (!pixels || !result) { | 6393 if (!pixels || !result) { |
6505 return error::kOutOfBounds; | 6394 return error::kOutOfBounds; |
6506 } | 6395 } |
6507 | 6396 |
(...skipping 27 matching lines...) Expand all Loading... | |
6535 | 6424 |
6536 ScopedResolvedFrameBufferBinder binder(this, false, true); | 6425 ScopedResolvedFrameBufferBinder binder(this, false, true); |
6537 | 6426 |
6538 if (x < 0 || y < 0 || max_x > max_size.width() || max_y > max_size.height()) { | 6427 if (x < 0 || y < 0 || max_x > max_size.width() || max_y > max_size.height()) { |
6539 // The user requested an out of range area. Get the results 1 line | 6428 // The user requested an out of range area. Get the results 1 line |
6540 // at a time. | 6429 // at a time. |
6541 uint32 temp_size; | 6430 uint32 temp_size; |
6542 uint32 unpadded_row_size; | 6431 uint32 unpadded_row_size; |
6543 uint32 padded_row_size; | 6432 uint32 padded_row_size; |
6544 if (!GLES2Util::ComputeImageDataSizes( | 6433 if (!GLES2Util::ComputeImageDataSizes( |
6545 width, 2, format, type, pack_alignment_, &temp_size, | 6434 width, 2, format, type, state_.pack_alignment, &temp_size, |
6546 &unpadded_row_size, &padded_row_size)) { | 6435 &unpadded_row_size, &padded_row_size)) { |
6547 SetGLError(GL_INVALID_VALUE, "glReadPixels", "dimensions out of range"); | 6436 SetGLError(GL_INVALID_VALUE, "glReadPixels", "dimensions out of range"); |
6548 return error::kNoError; | 6437 return error::kNoError; |
6549 } | 6438 } |
6550 | 6439 |
6551 GLint dest_x_offset = std::max(-x, 0); | 6440 GLint dest_x_offset = std::max(-x, 0); |
6552 uint32 dest_row_offset; | 6441 uint32 dest_row_offset; |
6553 if (!GLES2Util::ComputeImageDataSizes( | 6442 if (!GLES2Util::ComputeImageDataSizes( |
6554 dest_x_offset, 1, format, type, pack_alignment_, &dest_row_offset, NULL, | 6443 dest_x_offset, 1, format, type, state_.pack_alignment, &dest_row_offset, |
6555 NULL)) { | 6444 NULL, NULL)) { |
6556 SetGLError(GL_INVALID_VALUE, "glReadPixels", "dimensions out of range"); | 6445 SetGLError(GL_INVALID_VALUE, "glReadPixels", "dimensions out of range"); |
6557 return error::kNoError; | 6446 return error::kNoError; |
6558 } | 6447 } |
6559 | 6448 |
6560 // Copy each row into the larger dest rect. | 6449 // Copy each row into the larger dest rect. |
6561 int8* dst = static_cast<int8*>(pixels); | 6450 int8* dst = static_cast<int8*>(pixels); |
6562 GLint read_x = std::max(0, x); | 6451 GLint read_x = std::max(0, x); |
6563 GLint read_end_x = std::max(0, std::min(max_size.width(), max_x)); | 6452 GLint read_end_x = std::max(0, std::min(max_size.width(), max_x)); |
6564 GLint read_width = read_end_x - read_x; | 6453 GLint read_width = read_end_x - read_x; |
6565 for (GLint yy = 0; yy < height; ++yy) { | 6454 for (GLint yy = 0; yy < height; ++yy) { |
(...skipping 19 matching lines...) Expand all Loading... | |
6585 GLenum read_format = GetBoundReadFrameBufferInternalFormat(); | 6474 GLenum read_format = GetBoundReadFrameBufferInternalFormat(); |
6586 uint32 channels_exist = GLES2Util::GetChannelsForFormat(read_format); | 6475 uint32 channels_exist = GLES2Util::GetChannelsForFormat(read_format); |
6587 if ((channels_exist & 0x0008) == 0 && | 6476 if ((channels_exist & 0x0008) == 0 && |
6588 !feature_info_->feature_flags().disable_workarounds) { | 6477 !feature_info_->feature_flags().disable_workarounds) { |
6589 // Set the alpha to 255 because some drivers are buggy in this regard. | 6478 // Set the alpha to 255 because some drivers are buggy in this regard. |
6590 uint32 temp_size; | 6479 uint32 temp_size; |
6591 | 6480 |
6592 uint32 unpadded_row_size; | 6481 uint32 unpadded_row_size; |
6593 uint32 padded_row_size; | 6482 uint32 padded_row_size; |
6594 if (!GLES2Util::ComputeImageDataSizes( | 6483 if (!GLES2Util::ComputeImageDataSizes( |
6595 width, 2, format, type, pack_alignment_, &temp_size, | 6484 width, 2, format, type, state_.pack_alignment, &temp_size, |
6596 &unpadded_row_size, &padded_row_size)) { | 6485 &unpadded_row_size, &padded_row_size)) { |
6597 SetGLError(GL_INVALID_VALUE, "glReadPixels", "dimensions out of range"); | 6486 SetGLError(GL_INVALID_VALUE, "glReadPixels", "dimensions out of range"); |
6598 return error::kNoError; | 6487 return error::kNoError; |
6599 } | 6488 } |
6600 // NOTE: Assumes the type is GL_UNSIGNED_BYTE which was true at the time | 6489 // NOTE: Assumes the type is GL_UNSIGNED_BYTE which was true at the time |
6601 // of this implementation. | 6490 // of this implementation. |
6602 if (type != GL_UNSIGNED_BYTE) { | 6491 if (type != GL_UNSIGNED_BYTE) { |
6603 SetGLError( | 6492 SetGLError( |
6604 GL_INVALID_OPERATION, "glReadPixels", | 6493 GL_INVALID_OPERATION, "glReadPixels", |
6605 "unsupported readPixel format"); | 6494 "unsupported readPixel format"); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6655 return error::kNoError; | 6544 return error::kNoError; |
6656 case GL_UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM: | 6545 case GL_UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM: |
6657 unpack_unpremultiply_alpha_ = (param != 0); | 6546 unpack_unpremultiply_alpha_ = (param != 0); |
6658 return error::kNoError; | 6547 return error::kNoError; |
6659 default: | 6548 default: |
6660 break; | 6549 break; |
6661 } | 6550 } |
6662 glPixelStorei(pname, param); | 6551 glPixelStorei(pname, param); |
6663 switch (pname) { | 6552 switch (pname) { |
6664 case GL_PACK_ALIGNMENT: | 6553 case GL_PACK_ALIGNMENT: |
6665 pack_alignment_ = param; | 6554 state_.pack_alignment = param; |
6666 break; | 6555 break; |
6667 case GL_PACK_REVERSE_ROW_ORDER_ANGLE: | 6556 case GL_PACK_REVERSE_ROW_ORDER_ANGLE: |
6668 break; | 6557 break; |
6669 case GL_UNPACK_ALIGNMENT: | 6558 case GL_UNPACK_ALIGNMENT: |
6670 unpack_alignment_ = param; | 6559 state_.unpack_alignment = param; |
6671 break; | 6560 break; |
6672 default: | 6561 default: |
6673 // Validation should have prevented us from getting here. | 6562 // Validation should have prevented us from getting here. |
6674 NOTREACHED(); | 6563 NOTREACHED(); |
6675 break; | 6564 break; |
6676 } | 6565 } |
6677 return error::kNoError; | 6566 return error::kNoError; |
6678 } | 6567 } |
6679 | 6568 |
6680 error::Error GLES2DecoderImpl::HandlePostSubBufferCHROMIUM( | 6569 error::Error GLES2DecoderImpl::HandlePostSubBufferCHROMIUM( |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7018 framebuffer ? framebuffer->service_id() : GetBackbufferServiceId(); | 6907 framebuffer ? framebuffer->service_id() : GetBackbufferServiceId(); |
7019 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, fb_service_id); | 6908 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, fb_service_id); |
7020 return true; | 6909 return true; |
7021 } | 6910 } |
7022 | 6911 |
7023 static const uint32 kMaxZeroSize = 1024 * 1024 * 4; | 6912 static const uint32 kMaxZeroSize = 1024 * 1024 * 4; |
7024 | 6913 |
7025 uint32 size; | 6914 uint32 size; |
7026 uint32 padded_row_size; | 6915 uint32 padded_row_size; |
7027 if (!GLES2Util::ComputeImageDataSizes( | 6916 if (!GLES2Util::ComputeImageDataSizes( |
7028 width, height, format, type, unpack_alignment_, &size, | 6917 width, height, format, type, state_.unpack_alignment, &size, |
7029 NULL, &padded_row_size)) { | 6918 NULL, &padded_row_size)) { |
7030 return false; | 6919 return false; |
7031 } | 6920 } |
7032 | 6921 |
7033 TRACE_EVENT1("gpu", "GLES2DecoderImpl::ClearLevel", "size", size); | 6922 TRACE_EVENT1("gpu", "GLES2DecoderImpl::ClearLevel", "size", size); |
7034 | 6923 |
7035 int tile_height; | 6924 int tile_height; |
7036 | 6925 |
7037 if (size > kMaxZeroSize) { | 6926 if (size > kMaxZeroSize) { |
7038 if (kMaxZeroSize < padded_row_size) { | 6927 if (kMaxZeroSize < padded_row_size) { |
7039 // That'd be an awfully large texture. | 6928 // That'd be an awfully large texture. |
7040 return false; | 6929 return false; |
7041 } | 6930 } |
7042 // We should never have a large total size with a zero row size. | 6931 // We should never have a large total size with a zero row size. |
7043 DCHECK_GT(padded_row_size, 0U); | 6932 DCHECK_GT(padded_row_size, 0U); |
7044 tile_height = kMaxZeroSize / padded_row_size; | 6933 tile_height = kMaxZeroSize / padded_row_size; |
7045 if (!GLES2Util::ComputeImageDataSizes( | 6934 if (!GLES2Util::ComputeImageDataSizes( |
7046 width, tile_height, format, type, unpack_alignment_, &size, NULL, | 6935 width, tile_height, format, type, state_.unpack_alignment, &size, |
7047 NULL)) { | 6936 NULL, NULL)) { |
7048 return false; | 6937 return false; |
7049 } | 6938 } |
7050 } else { | 6939 } else { |
7051 tile_height = height; | 6940 tile_height = height; |
7052 } | 6941 } |
7053 | 6942 |
7054 // Assumes the size has already been checked. | 6943 // Assumes the size has already been checked. |
7055 scoped_array<char> zero(new char[size]); | 6944 scoped_array<char> zero(new char[size]); |
7056 memset(zero.get(), 0, size); | 6945 memset(zero.get(), 0, size); |
7057 glBindTexture(bind_target, service_id); | 6946 glBindTexture(bind_target, service_id); |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7534 GLint internal_format = static_cast<GLint>(c.internalformat); | 7423 GLint internal_format = static_cast<GLint>(c.internalformat); |
7535 GLsizei width = static_cast<GLsizei>(c.width); | 7424 GLsizei width = static_cast<GLsizei>(c.width); |
7536 GLsizei height = static_cast<GLsizei>(c.height); | 7425 GLsizei height = static_cast<GLsizei>(c.height); |
7537 GLint border = static_cast<GLint>(c.border); | 7426 GLint border = static_cast<GLint>(c.border); |
7538 GLenum format = static_cast<GLenum>(c.format); | 7427 GLenum format = static_cast<GLenum>(c.format); |
7539 GLenum type = static_cast<GLenum>(c.type); | 7428 GLenum type = static_cast<GLenum>(c.type); |
7540 uint32 pixels_shm_id = static_cast<uint32>(c.pixels_shm_id); | 7429 uint32 pixels_shm_id = static_cast<uint32>(c.pixels_shm_id); |
7541 uint32 pixels_shm_offset = static_cast<uint32>(c.pixels_shm_offset); | 7430 uint32 pixels_shm_offset = static_cast<uint32>(c.pixels_shm_offset); |
7542 uint32 pixels_size; | 7431 uint32 pixels_size; |
7543 if (!GLES2Util::ComputeImageDataSizes( | 7432 if (!GLES2Util::ComputeImageDataSizes( |
7544 width, height, format, type, unpack_alignment_, &pixels_size, NULL, | 7433 width, height, format, type, state_.unpack_alignment, &pixels_size, NULL, |
7545 NULL)) { | 7434 NULL)) { |
7546 return error::kOutOfBounds; | 7435 return error::kOutOfBounds; |
7547 } | 7436 } |
7548 const void* pixels = NULL; | 7437 const void* pixels = NULL; |
7549 if (pixels_shm_id != 0 || pixels_shm_offset != 0) { | 7438 if (pixels_shm_id != 0 || pixels_shm_offset != 0) { |
7550 pixels = GetSharedMemoryAs<const void*>( | 7439 pixels = GetSharedMemoryAs<const void*>( |
7551 pixels_shm_id, pixels_shm_offset, pixels_size); | 7440 pixels_shm_id, pixels_shm_offset, pixels_size); |
7552 if (!pixels) { | 7441 if (!pixels) { |
7553 return error::kOutOfBounds; | 7442 return error::kOutOfBounds; |
7554 } | 7443 } |
7555 } | 7444 } |
7556 return DoTexImage2D( | 7445 return DoTexImage2D( |
7557 target, level, internal_format, width, height, border, format, type, | 7446 target, level, internal_format, width, height, border, format, type, |
7558 pixels, pixels_size); | 7447 pixels, pixels_size); |
7559 } | 7448 } |
7560 | 7449 |
7561 error::Error GLES2DecoderImpl::HandleTexImage2DImmediate( | 7450 error::Error GLES2DecoderImpl::HandleTexImage2DImmediate( |
7562 uint32 immediate_data_size, const gles2::TexImage2DImmediate& c) { | 7451 uint32 immediate_data_size, const gles2::TexImage2DImmediate& c) { |
7563 GLenum target = static_cast<GLenum>(c.target); | 7452 GLenum target = static_cast<GLenum>(c.target); |
7564 GLint level = static_cast<GLint>(c.level); | 7453 GLint level = static_cast<GLint>(c.level); |
7565 GLint internal_format = static_cast<GLint>(c.internalformat); | 7454 GLint internal_format = static_cast<GLint>(c.internalformat); |
7566 GLsizei width = static_cast<GLsizei>(c.width); | 7455 GLsizei width = static_cast<GLsizei>(c.width); |
7567 GLsizei height = static_cast<GLsizei>(c.height); | 7456 GLsizei height = static_cast<GLsizei>(c.height); |
7568 GLint border = static_cast<GLint>(c.border); | 7457 GLint border = static_cast<GLint>(c.border); |
7569 GLenum format = static_cast<GLenum>(c.format); | 7458 GLenum format = static_cast<GLenum>(c.format); |
7570 GLenum type = static_cast<GLenum>(c.type); | 7459 GLenum type = static_cast<GLenum>(c.type); |
7571 uint32 size; | 7460 uint32 size; |
7572 if (!GLES2Util::ComputeImageDataSizes( | 7461 if (!GLES2Util::ComputeImageDataSizes( |
7573 width, height, format, type, unpack_alignment_, &size, NULL, NULL)) { | 7462 width, height, format, type, state_.unpack_alignment, &size, |
7463 NULL, NULL)) { | |
7574 return error::kOutOfBounds; | 7464 return error::kOutOfBounds; |
7575 } | 7465 } |
7576 const void* pixels = GetImmediateDataAs<const void*>( | 7466 const void* pixels = GetImmediateDataAs<const void*>( |
7577 c, size, immediate_data_size); | 7467 c, size, immediate_data_size); |
7578 if (!pixels) { | 7468 if (!pixels) { |
7579 return error::kOutOfBounds; | 7469 return error::kOutOfBounds; |
7580 } | 7470 } |
7581 DoTexImage2D( | 7471 DoTexImage2D( |
7582 target, level, internal_format, width, height, border, format, type, | 7472 target, level, internal_format, width, height, border, format, type, |
7583 pixels, size); | 7473 pixels, size); |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7819 return; | 7709 return; |
7820 } | 7710 } |
7821 | 7711 |
7822 if (copyX != x || | 7712 if (copyX != x || |
7823 copyY != y || | 7713 copyY != y || |
7824 copyWidth != width || | 7714 copyWidth != width || |
7825 copyHeight != height) { | 7715 copyHeight != height) { |
7826 // some part was clipped so clear the sub rect. | 7716 // some part was clipped so clear the sub rect. |
7827 uint32 pixels_size = 0; | 7717 uint32 pixels_size = 0; |
7828 if (!GLES2Util::ComputeImageDataSizes( | 7718 if (!GLES2Util::ComputeImageDataSizes( |
7829 width, height, format, type, unpack_alignment_, &pixels_size, NULL, | 7719 width, height, format, type, state_.unpack_alignment, &pixels_size, |
7830 NULL)) { | 7720 NULL, NULL)) { |
7831 SetGLError( | 7721 SetGLError( |
7832 GL_INVALID_VALUE, "glCopyTexSubImage2D", "dimensions too large"); | 7722 GL_INVALID_VALUE, "glCopyTexSubImage2D", "dimensions too large"); |
7833 return; | 7723 return; |
7834 } | 7724 } |
7835 scoped_array<char> zero(new char[pixels_size]); | 7725 scoped_array<char> zero(new char[pixels_size]); |
7836 memset(zero.get(), 0, pixels_size); | 7726 memset(zero.get(), 0, pixels_size); |
7837 glTexSubImage2D( | 7727 glTexSubImage2D( |
7838 target, level, xoffset, yoffset, width, height, | 7728 target, level, xoffset, yoffset, width, height, |
7839 format, type, zero.get()); | 7729 format, type, zero.get()); |
7840 } | 7730 } |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7938 GLenum target = static_cast<GLenum>(c.target); | 7828 GLenum target = static_cast<GLenum>(c.target); |
7939 GLint level = static_cast<GLint>(c.level); | 7829 GLint level = static_cast<GLint>(c.level); |
7940 GLint xoffset = static_cast<GLint>(c.xoffset); | 7830 GLint xoffset = static_cast<GLint>(c.xoffset); |
7941 GLint yoffset = static_cast<GLint>(c.yoffset); | 7831 GLint yoffset = static_cast<GLint>(c.yoffset); |
7942 GLsizei width = static_cast<GLsizei>(c.width); | 7832 GLsizei width = static_cast<GLsizei>(c.width); |
7943 GLsizei height = static_cast<GLsizei>(c.height); | 7833 GLsizei height = static_cast<GLsizei>(c.height); |
7944 GLenum format = static_cast<GLenum>(c.format); | 7834 GLenum format = static_cast<GLenum>(c.format); |
7945 GLenum type = static_cast<GLenum>(c.type); | 7835 GLenum type = static_cast<GLenum>(c.type); |
7946 uint32 data_size; | 7836 uint32 data_size; |
7947 if (!GLES2Util::ComputeImageDataSizes( | 7837 if (!GLES2Util::ComputeImageDataSizes( |
7948 width, height, format, type, unpack_alignment_, &data_size, NULL, NULL)) { | 7838 width, height, format, type, state_.unpack_alignment, &data_size, |
7839 NULL, NULL)) { | |
7949 return error::kOutOfBounds; | 7840 return error::kOutOfBounds; |
7950 } | 7841 } |
7951 const void* pixels = GetSharedMemoryAs<const void*>( | 7842 const void* pixels = GetSharedMemoryAs<const void*>( |
7952 c.pixels_shm_id, c.pixels_shm_offset, data_size); | 7843 c.pixels_shm_id, c.pixels_shm_offset, data_size); |
7953 if (!validators_->texture_target.IsValid(target)) { | 7844 if (!validators_->texture_target.IsValid(target)) { |
7954 SetGLErrorInvalidEnum("glTexSubImage2D", target, "target"); | 7845 SetGLErrorInvalidEnum("glTexSubImage2D", target, "target"); |
7955 return error::kNoError; | 7846 return error::kNoError; |
7956 } | 7847 } |
7957 if (width < 0) { | 7848 if (width < 0) { |
7958 SetGLError(GL_INVALID_VALUE, "glTexSubImage2D", "width < 0"); | 7849 SetGLError(GL_INVALID_VALUE, "glTexSubImage2D", "width < 0"); |
(...skipping 28 matching lines...) Expand all Loading... | |
7987 GLenum target = static_cast<GLenum>(c.target); | 7878 GLenum target = static_cast<GLenum>(c.target); |
7988 GLint level = static_cast<GLint>(c.level); | 7879 GLint level = static_cast<GLint>(c.level); |
7989 GLint xoffset = static_cast<GLint>(c.xoffset); | 7880 GLint xoffset = static_cast<GLint>(c.xoffset); |
7990 GLint yoffset = static_cast<GLint>(c.yoffset); | 7881 GLint yoffset = static_cast<GLint>(c.yoffset); |
7991 GLsizei width = static_cast<GLsizei>(c.width); | 7882 GLsizei width = static_cast<GLsizei>(c.width); |
7992 GLsizei height = static_cast<GLsizei>(c.height); | 7883 GLsizei height = static_cast<GLsizei>(c.height); |
7993 GLenum format = static_cast<GLenum>(c.format); | 7884 GLenum format = static_cast<GLenum>(c.format); |
7994 GLenum type = static_cast<GLenum>(c.type); | 7885 GLenum type = static_cast<GLenum>(c.type); |
7995 uint32 data_size; | 7886 uint32 data_size; |
7996 if (!GLES2Util::ComputeImageDataSizes( | 7887 if (!GLES2Util::ComputeImageDataSizes( |
7997 width, height, format, type, unpack_alignment_, &data_size, NULL, NULL)) { | 7888 width, height, format, type, state_.unpack_alignment, &data_size, |
7889 NULL, NULL)) { | |
7998 return error::kOutOfBounds; | 7890 return error::kOutOfBounds; |
7999 } | 7891 } |
8000 const void* pixels = GetImmediateDataAs<const void*>( | 7892 const void* pixels = GetImmediateDataAs<const void*>( |
8001 c, data_size, immediate_data_size); | 7893 c, data_size, immediate_data_size); |
8002 if (!validators_->texture_target.IsValid(target)) { | 7894 if (!validators_->texture_target.IsValid(target)) { |
8003 SetGLErrorInvalidEnum("glTexSubImage2D", target, "target"); | 7895 SetGLErrorInvalidEnum("glTexSubImage2D", target, "target"); |
8004 return error::kNoError; | 7896 return error::kNoError; |
8005 } | 7897 } |
8006 if (width < 0) { | 7898 if (width < 0) { |
8007 SetGLError(GL_INVALID_VALUE, "glTexSubImage2D", "width < 0"); | 7899 SetGLError(GL_INVALID_VALUE, "glTexSubImage2D", "width < 0"); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8045 SetGLErrorInvalidEnum("glGetVertexAttribPointerv", pname, "pname"); | 7937 SetGLErrorInvalidEnum("glGetVertexAttribPointerv", pname, "pname"); |
8046 return error::kNoError; | 7938 return error::kNoError; |
8047 } | 7939 } |
8048 if (index >= group_->max_vertex_attribs()) { | 7940 if (index >= group_->max_vertex_attribs()) { |
8049 SetGLError(GL_INVALID_VALUE, | 7941 SetGLError(GL_INVALID_VALUE, |
8050 "glGetVertexAttribPointerv", "index out of range."); | 7942 "glGetVertexAttribPointerv", "index out of range."); |
8051 return error::kNoError; | 7943 return error::kNoError; |
8052 } | 7944 } |
8053 result->SetNumResults(1); | 7945 result->SetNumResults(1); |
8054 *result->GetData() = | 7946 *result->GetData() = |
8055 vertex_attrib_manager_->GetVertexAttribInfo(index)->offset(); | 7947 state_.vertex_attrib_manager->GetVertexAttribInfo(index)->offset(); |
8056 return error::kNoError; | 7948 return error::kNoError; |
8057 } | 7949 } |
8058 | 7950 |
8059 bool GLES2DecoderImpl::GetUniformSetup( | 7951 bool GLES2DecoderImpl::GetUniformSetup( |
8060 GLuint program, GLint fake_location, | 7952 GLuint program, GLint fake_location, |
8061 uint32 shm_id, uint32 shm_offset, | 7953 uint32 shm_id, uint32 shm_offset, |
8062 error::Error* error, GLint* real_location, | 7954 error::Error* error, GLint* real_location, |
8063 GLuint* service_id, void** result_pointer, GLenum* result_type) { | 7955 GLuint* service_id, void** result_pointer, GLenum* result_type) { |
8064 DCHECK(error); | 7956 DCHECK(error); |
8065 DCHECK(service_id); | 7957 DCHECK(service_id); |
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8697 } | 8589 } |
8698 // NOTE: We don't generate Query objects here. Only in BeginQueryEXT | 8590 // NOTE: We don't generate Query objects here. Only in BeginQueryEXT |
8699 return true; | 8591 return true; |
8700 } | 8592 } |
8701 | 8593 |
8702 void GLES2DecoderImpl::DeleteQueriesEXTHelper( | 8594 void GLES2DecoderImpl::DeleteQueriesEXTHelper( |
8703 GLsizei n, const GLuint* client_ids) { | 8595 GLsizei n, const GLuint* client_ids) { |
8704 for (GLsizei ii = 0; ii < n; ++ii) { | 8596 for (GLsizei ii = 0; ii < n; ++ii) { |
8705 QueryManager::Query* query = query_manager_->GetQuery(client_ids[ii]); | 8597 QueryManager::Query* query = query_manager_->GetQuery(client_ids[ii]); |
8706 if (query && !query->IsDeleted()) { | 8598 if (query && !query->IsDeleted()) { |
8707 if (query == current_query_) { | 8599 if (query == state_.current_query) { |
8708 current_query_ = NULL; | 8600 state_.current_query = NULL; |
8709 } | 8601 } |
8710 query->Destroy(true); | 8602 query->Destroy(true); |
8711 query_manager_->RemoveQuery(client_ids[ii]); | 8603 query_manager_->RemoveQuery(client_ids[ii]); |
8712 } | 8604 } |
8713 } | 8605 } |
8714 } | 8606 } |
8715 | 8607 |
8716 bool GLES2DecoderImpl::ProcessPendingQueries() { | 8608 bool GLES2DecoderImpl::ProcessPendingQueries() { |
8717 if (query_manager_.get() == NULL) { | 8609 if (query_manager_.get() == NULL) { |
8718 return false; | 8610 return false; |
(...skipping 15 matching lines...) Expand all Loading... | |
8734 case GL_COMMANDS_ISSUED_CHROMIUM: | 8626 case GL_COMMANDS_ISSUED_CHROMIUM: |
8735 break; | 8627 break; |
8736 default: | 8628 default: |
8737 if (!feature_info_->feature_flags().occlusion_query_boolean) { | 8629 if (!feature_info_->feature_flags().occlusion_query_boolean) { |
8738 SetGLError(GL_INVALID_OPERATION, "glBeginQueryEXT", "not enabled"); | 8630 SetGLError(GL_INVALID_OPERATION, "glBeginQueryEXT", "not enabled"); |
8739 return error::kNoError; | 8631 return error::kNoError; |
8740 } | 8632 } |
8741 break; | 8633 break; |
8742 } | 8634 } |
8743 | 8635 |
8744 if (current_query_) { | 8636 if (state_.current_query) { |
8745 SetGLError( | 8637 SetGLError( |
8746 GL_INVALID_OPERATION, "glBeginQueryEXT", "query already in progress"); | 8638 GL_INVALID_OPERATION, "glBeginQueryEXT", "query already in progress"); |
8747 return error::kNoError; | 8639 return error::kNoError; |
8748 } | 8640 } |
8749 | 8641 |
8750 if (client_id == 0) { | 8642 if (client_id == 0) { |
8751 SetGLError(GL_INVALID_OPERATION, "glBeginQueryEXT", "id is 0"); | 8643 SetGLError(GL_INVALID_OPERATION, "glBeginQueryEXT", "id is 0"); |
8752 return error::kNoError; | 8644 return error::kNoError; |
8753 } | 8645 } |
8754 | 8646 |
(...skipping 27 matching lines...) Expand all Loading... | |
8782 } else if (query->shm_id() != sync_shm_id || | 8674 } else if (query->shm_id() != sync_shm_id || |
8783 query->shm_offset() != sync_shm_offset) { | 8675 query->shm_offset() != sync_shm_offset) { |
8784 DLOG(ERROR) << "Shared memory used by query not the same as before"; | 8676 DLOG(ERROR) << "Shared memory used by query not the same as before"; |
8785 return error::kInvalidArguments; | 8677 return error::kInvalidArguments; |
8786 } | 8678 } |
8787 | 8679 |
8788 if (!query_manager_->BeginQuery(query)) { | 8680 if (!query_manager_->BeginQuery(query)) { |
8789 return error::kOutOfBounds; | 8681 return error::kOutOfBounds; |
8790 } | 8682 } |
8791 | 8683 |
8792 current_query_ = query; | 8684 state_.current_query = query; |
8793 return error::kNoError; | 8685 return error::kNoError; |
8794 } | 8686 } |
8795 | 8687 |
8796 error::Error GLES2DecoderImpl::HandleEndQueryEXT( | 8688 error::Error GLES2DecoderImpl::HandleEndQueryEXT( |
8797 uint32 immediate_data_size, const gles2::EndQueryEXT& c) { | 8689 uint32 immediate_data_size, const gles2::EndQueryEXT& c) { |
8798 GLenum target = static_cast<GLenum>(c.target); | 8690 GLenum target = static_cast<GLenum>(c.target); |
8799 uint32 submit_count = static_cast<GLuint>(c.submit_count); | 8691 uint32 submit_count = static_cast<GLuint>(c.submit_count); |
8800 | 8692 |
8801 if (!current_query_) { | 8693 if (!state_.current_query) { |
8802 SetGLError(GL_INVALID_OPERATION, "glEndQueryEXT", "No active query"); | 8694 SetGLError(GL_INVALID_OPERATION, "glEndQueryEXT", "No active query"); |
8803 return error::kNoError; | 8695 return error::kNoError; |
8804 } | 8696 } |
8805 if (current_query_->target() != target) { | 8697 if (state_.current_query->target() != target) { |
8806 SetGLError(GL_INVALID_OPERATION, | 8698 SetGLError(GL_INVALID_OPERATION, |
8807 "glEndQueryEXT", "target does not match active query"); | 8699 "glEndQueryEXT", "target does not match active query"); |
8808 return error::kNoError; | 8700 return error::kNoError; |
8809 } | 8701 } |
8810 | 8702 |
8811 if (!query_manager_->EndQuery(current_query_, submit_count)) { | 8703 if (!query_manager_->EndQuery(state_.current_query, submit_count)) { |
8812 return error::kOutOfBounds; | 8704 return error::kOutOfBounds; |
8813 } | 8705 } |
8814 | 8706 |
8815 current_query_ = NULL; | 8707 state_.current_query = NULL; |
8816 return error::kNoError; | 8708 return error::kNoError; |
8817 } | 8709 } |
8818 | 8710 |
8819 bool GLES2DecoderImpl::GenVertexArraysOESHelper( | 8711 bool GLES2DecoderImpl::GenVertexArraysOESHelper( |
8820 GLsizei n, const GLuint* client_ids) { | 8712 GLsizei n, const GLuint* client_ids) { |
8821 for (GLsizei ii = 0; ii < n; ++ii) { | 8713 for (GLsizei ii = 0; ii < n; ++ii) { |
8822 if (GetVertexAttribManager(client_ids[ii])) { | 8714 if (GetVertexAttribManager(client_ids[ii])) { |
8823 return false; | 8715 return false; |
8824 } | 8716 } |
8825 } | 8717 } |
(...skipping 14 matching lines...) Expand all Loading... | |
8840 | 8732 |
8841 return true; | 8733 return true; |
8842 } | 8734 } |
8843 | 8735 |
8844 void GLES2DecoderImpl::DeleteVertexArraysOESHelper( | 8736 void GLES2DecoderImpl::DeleteVertexArraysOESHelper( |
8845 GLsizei n, const GLuint* client_ids) { | 8737 GLsizei n, const GLuint* client_ids) { |
8846 for (GLsizei ii = 0; ii < n; ++ii) { | 8738 for (GLsizei ii = 0; ii < n; ++ii) { |
8847 VertexAttribManager* vao = | 8739 VertexAttribManager* vao = |
8848 GetVertexAttribManager(client_ids[ii]); | 8740 GetVertexAttribManager(client_ids[ii]); |
8849 if (vao && !vao->IsDeleted()) { | 8741 if (vao && !vao->IsDeleted()) { |
8850 if (vertex_attrib_manager_ == vao) { | 8742 if (state_.vertex_attrib_manager == vao) { |
8851 vertex_attrib_manager_ = default_vertex_attrib_manager_; | 8743 state_.vertex_attrib_manager = default_vertex_attrib_manager_; |
8852 } | 8744 } |
8853 RemoveVertexAttribManager(client_ids[ii]); | 8745 RemoveVertexAttribManager(client_ids[ii]); |
8854 } | 8746 } |
8855 } | 8747 } |
8856 } | 8748 } |
8857 | 8749 |
8858 void GLES2DecoderImpl::DoBindVertexArrayOES(GLuint client_id) { | 8750 void GLES2DecoderImpl::DoBindVertexArrayOES(GLuint client_id) { |
8859 VertexAttribManager* vao = NULL; | 8751 VertexAttribManager* vao = NULL; |
8860 GLuint service_id = 0; | 8752 GLuint service_id = 0; |
8861 if (client_id != 0) { | 8753 if (client_id != 0) { |
8862 vao = GetVertexAttribManager(client_id); | 8754 vao = GetVertexAttribManager(client_id); |
8863 if (!vao) { | 8755 if (!vao) { |
8864 // Unlike most Bind* methods, the spec explicitly states that VertexArray | 8756 // Unlike most Bind* methods, the spec explicitly states that VertexArray |
8865 // only allows names that have been previously generated. As such, we do | 8757 // only allows names that have been previously generated. As such, we do |
8866 // not generate new names here. | 8758 // not generate new names here. |
8867 SetGLError(GL_INVALID_OPERATION, | 8759 SetGLError(GL_INVALID_OPERATION, |
8868 "glBindVertexArrayOES", "" | 8760 "glBindVertexArrayOES", "" |
8869 "bad vertex array id."); | 8761 "bad vertex array id."); |
8870 current_decoder_error_ = error::kNoError; | 8762 current_decoder_error_ = error::kNoError; |
8871 return; | 8763 return; |
8872 } else { | 8764 } else { |
8873 service_id = vao->service_id(); | 8765 service_id = vao->service_id(); |
8874 } | 8766 } |
8875 } else { | 8767 } else { |
8876 vao = default_vertex_attrib_manager_; | 8768 vao = default_vertex_attrib_manager_; |
8877 } | 8769 } |
8878 | 8770 |
8879 // Only set the VAO state if it's changed | 8771 // Only set the VAO state if it's changed |
8880 if (vertex_attrib_manager_ != vao) { | 8772 if (state_.vertex_attrib_manager != vao) { |
8881 vertex_attrib_manager_ = vao; | 8773 state_.vertex_attrib_manager = vao; |
8882 if (!feature_info_->feature_flags().native_vertex_array_object_) { | 8774 if (!feature_info_->feature_flags().native_vertex_array_object_) { |
8883 EmulateVertexArrayState(); | 8775 EmulateVertexArrayState(); |
8884 } else { | 8776 } else { |
8885 glBindVertexArrayOES(service_id); | 8777 glBindVertexArrayOES(service_id); |
8886 } | 8778 } |
8887 } | 8779 } |
8888 } | 8780 } |
8889 | 8781 |
8890 // Used when OES_vertex_array_object isn't natively supported | 8782 // Used when OES_vertex_array_object isn't natively supported |
8891 void GLES2DecoderImpl::EmulateVertexArrayState() { | 8783 void GLES2DecoderImpl::EmulateVertexArrayState() { |
8892 // Setup the Vertex attribute state | 8784 // Setup the Vertex attribute state |
8893 for (uint32 vv = 0; vv < group_->max_vertex_attribs(); ++vv) { | 8785 for (uint32 vv = 0; vv < group_->max_vertex_attribs(); ++vv) { |
8894 RestoreStateForAttrib(vv); | 8786 RestoreStateForAttrib(vv); |
8895 } | 8787 } |
8896 | 8788 |
8897 // Setup the element buffer | 8789 // Setup the element buffer |
8898 BufferManager::BufferInfo* element_array_buffer = | 8790 BufferManager::BufferInfo* element_array_buffer = |
8899 vertex_attrib_manager_->element_array_buffer(); | 8791 state_.vertex_attrib_manager->element_array_buffer(); |
8900 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, | 8792 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, |
8901 element_array_buffer ? element_array_buffer->service_id() : 0); | 8793 element_array_buffer ? element_array_buffer->service_id() : 0); |
8902 } | 8794 } |
8903 | 8795 |
8904 bool GLES2DecoderImpl::DoIsVertexArrayOES(GLuint client_id) { | 8796 bool GLES2DecoderImpl::DoIsVertexArrayOES(GLuint client_id) { |
8905 const VertexAttribManager* vao = | 8797 const VertexAttribManager* vao = |
8906 GetVertexAttribManager(client_id); | 8798 GetVertexAttribManager(client_id); |
8907 return vao && vao->IsValid() && !vao->IsDeleted(); | 8799 return vao && vao->IsValid() && !vao->IsDeleted(); |
8908 } | 8800 } |
8909 | 8801 |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9228 texture_manager()->SetLevelCleared(dest_info, GL_TEXTURE_2D, level); | 9120 texture_manager()->SetLevelCleared(dest_info, GL_TEXTURE_2D, level); |
9229 } | 9121 } |
9230 | 9122 |
9231 state_dirty_ = true; | 9123 state_dirty_ = true; |
9232 glViewport(0, 0, source_width, source_height); | 9124 glViewport(0, 0, source_width, source_height); |
9233 copy_texture_CHROMIUM_->DoCopyTexture(target, source_info->service_id(), | 9125 copy_texture_CHROMIUM_->DoCopyTexture(target, source_info->service_id(), |
9234 dest_info->service_id(), level, | 9126 dest_info->service_id(), level, |
9235 unpack_flip_y_, | 9127 unpack_flip_y_, |
9236 unpack_premultiply_alpha_, | 9128 unpack_premultiply_alpha_, |
9237 unpack_unpremultiply_alpha_); | 9129 unpack_unpremultiply_alpha_); |
9238 glViewport(viewport_x_, viewport_y_, viewport_width_, viewport_height_); | 9130 glViewport( |
9131 state_.viewport_x, state_.viewport_y, | |
9132 state_.viewport_width, state_.viewport_height); | |
9239 | 9133 |
9240 // Restore all of the state touched by the extension. | 9134 // Restore all of the state touched by the extension. |
9241 if (current_program_) | 9135 if (state_.current_program) |
9242 glUseProgram(current_program_->service_id()); | 9136 glUseProgram(state_.current_program->service_id()); |
9243 else | 9137 else |
9244 glUseProgram(0); | 9138 glUseProgram(0); |
9245 | 9139 |
9246 RestoreCurrentFramebufferBindings(); | 9140 RestoreCurrentFramebufferBindings(); |
9247 RestoreCurrentTexture2DBindings(); | 9141 RestoreCurrentTexture2DBindings(); |
9248 RestoreStateForAttrib( | 9142 RestoreStateForAttrib( |
9249 CopyTextureCHROMIUMResourceManager::kVertexPositionAttrib); | 9143 CopyTextureCHROMIUMResourceManager::kVertexPositionAttrib); |
9250 RestoreStateForAttrib( | 9144 RestoreStateForAttrib( |
9251 CopyTextureCHROMIUMResourceManager::kVertexTextureAttrib); | 9145 CopyTextureCHROMIUMResourceManager::kVertexTextureAttrib); |
9252 | 9146 |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9440 } | 9334 } |
9441 | 9335 |
9442 | 9336 |
9443 // Include the auto-generated part of this file. We split this because it means | 9337 // Include the auto-generated part of this file. We split this because it means |
9444 // we can easily edit the non-auto generated parts right here in this file | 9338 // we can easily edit the non-auto generated parts right here in this file |
9445 // instead of having to edit some template or the code generator. | 9339 // instead of having to edit some template or the code generator. |
9446 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 9340 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
9447 | 9341 |
9448 } // namespace gles2 | 9342 } // namespace gles2 |
9449 } // namespace gpu | 9343 } // namespace gpu |
OLD | NEW |