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 <cmath> | 10 #include <cmath> |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
43 #include "gpu/command_buffer/service/gpu_switches.h" | 43 #include "gpu/command_buffer/service/gpu_switches.h" |
44 #include "gpu/command_buffer/service/gpu_tracer.h" | 44 #include "gpu/command_buffer/service/gpu_tracer.h" |
45 #include "gpu/command_buffer/service/image_manager.h" | 45 #include "gpu/command_buffer/service/image_manager.h" |
46 #include "gpu/command_buffer/service/logger.h" | 46 #include "gpu/command_buffer/service/logger.h" |
47 #include "gpu/command_buffer/service/mailbox_manager.h" | 47 #include "gpu/command_buffer/service/mailbox_manager.h" |
48 #include "gpu/command_buffer/service/memory_tracking.h" | 48 #include "gpu/command_buffer/service/memory_tracking.h" |
49 #include "gpu/command_buffer/service/path_manager.h" | 49 #include "gpu/command_buffer/service/path_manager.h" |
50 #include "gpu/command_buffer/service/program_manager.h" | 50 #include "gpu/command_buffer/service/program_manager.h" |
51 #include "gpu/command_buffer/service/query_manager.h" | 51 #include "gpu/command_buffer/service/query_manager.h" |
52 #include "gpu/command_buffer/service/renderbuffer_manager.h" | 52 #include "gpu/command_buffer/service/renderbuffer_manager.h" |
53 #include "gpu/command_buffer/service/sampler_manager.h" | |
53 #include "gpu/command_buffer/service/shader_manager.h" | 54 #include "gpu/command_buffer/service/shader_manager.h" |
54 #include "gpu/command_buffer/service/shader_translator.h" | 55 #include "gpu/command_buffer/service/shader_translator.h" |
55 #include "gpu/command_buffer/service/texture_manager.h" | 56 #include "gpu/command_buffer/service/texture_manager.h" |
56 #include "gpu/command_buffer/service/valuebuffer_manager.h" | 57 #include "gpu/command_buffer/service/valuebuffer_manager.h" |
57 #include "gpu/command_buffer/service/vertex_array_manager.h" | 58 #include "gpu/command_buffer/service/vertex_array_manager.h" |
58 #include "gpu/command_buffer/service/vertex_attrib_manager.h" | 59 #include "gpu/command_buffer/service/vertex_attrib_manager.h" |
59 #include "third_party/smhasher/src/City.h" | 60 #include "third_party/smhasher/src/City.h" |
60 #include "ui/gfx/geometry/point.h" | 61 #include "ui/gfx/geometry/point.h" |
61 #include "ui/gfx/geometry/rect.h" | 62 #include "ui/gfx/geometry/rect.h" |
62 #include "ui/gfx/geometry/size.h" | 63 #include "ui/gfx/geometry/size.h" |
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
704 bool GenRenderbuffersHelper(GLsizei n, const GLuint* client_ids); | 705 bool GenRenderbuffersHelper(GLsizei n, const GLuint* client_ids); |
705 void DeleteRenderbuffersHelper(GLsizei n, const GLuint* client_ids); | 706 void DeleteRenderbuffersHelper(GLsizei n, const GLuint* client_ids); |
706 bool GenValuebuffersCHROMIUMHelper(GLsizei n, const GLuint* client_ids); | 707 bool GenValuebuffersCHROMIUMHelper(GLsizei n, const GLuint* client_ids); |
707 void DeleteValuebuffersCHROMIUMHelper(GLsizei n, const GLuint* client_ids); | 708 void DeleteValuebuffersCHROMIUMHelper(GLsizei n, const GLuint* client_ids); |
708 bool GenQueriesEXTHelper(GLsizei n, const GLuint* client_ids); | 709 bool GenQueriesEXTHelper(GLsizei n, const GLuint* client_ids); |
709 void DeleteQueriesEXTHelper(GLsizei n, const GLuint* client_ids); | 710 void DeleteQueriesEXTHelper(GLsizei n, const GLuint* client_ids); |
710 bool GenVertexArraysOESHelper(GLsizei n, const GLuint* client_ids); | 711 bool GenVertexArraysOESHelper(GLsizei n, const GLuint* client_ids); |
711 void DeleteVertexArraysOESHelper(GLsizei n, const GLuint* client_ids); | 712 void DeleteVertexArraysOESHelper(GLsizei n, const GLuint* client_ids); |
712 bool GenPathsCHROMIUMHelper(GLuint first_client_id, GLsizei range); | 713 bool GenPathsCHROMIUMHelper(GLuint first_client_id, GLsizei range); |
713 bool DeletePathsCHROMIUMHelper(GLuint first_client_id, GLsizei range); | 714 bool DeletePathsCHROMIUMHelper(GLuint first_client_id, GLsizei range); |
715 bool GenSamplersHelper(GLsizei n, const GLuint* client_ids); | |
716 void DeleteSamplersHelper(GLsizei n, const GLuint* client_ids); | |
714 | 717 |
715 // Workarounds | 718 // Workarounds |
716 void OnFboChanged() const; | 719 void OnFboChanged() const; |
717 void OnUseFramebuffer() const; | 720 void OnUseFramebuffer() const; |
718 | 721 |
719 error::ContextLostReason GetContextLostReasonFromResetStatus( | 722 error::ContextLostReason GetContextLostReasonFromResetStatus( |
720 GLenum reset_status) const; | 723 GLenum reset_status) const; |
721 | 724 |
722 // TODO(gman): Cache these pointers? | 725 // TODO(gman): Cache these pointers? |
723 BufferManager* buffer_manager() { | 726 BufferManager* buffer_manager() { |
724 return group_->buffer_manager(); | 727 return group_->buffer_manager(); |
725 } | 728 } |
726 | 729 |
727 RenderbufferManager* renderbuffer_manager() { | 730 RenderbufferManager* renderbuffer_manager() { |
728 return group_->renderbuffer_manager(); | 731 return group_->renderbuffer_manager(); |
729 } | 732 } |
730 | 733 |
731 FramebufferManager* framebuffer_manager() { | 734 FramebufferManager* framebuffer_manager() { |
732 return group_->framebuffer_manager(); | 735 return group_->framebuffer_manager(); |
733 } | 736 } |
734 | 737 |
735 ValuebufferManager* valuebuffer_manager() { | 738 ValuebufferManager* valuebuffer_manager() { |
736 return group_->valuebuffer_manager(); | 739 return group_->valuebuffer_manager(); |
737 } | 740 } |
738 | 741 |
739 ProgramManager* program_manager() { | 742 ProgramManager* program_manager() { |
740 return group_->program_manager(); | 743 return group_->program_manager(); |
741 } | 744 } |
742 | 745 |
746 SamplerManager* sampler_manager() { | |
747 return group_->sampler_manager(); | |
748 } | |
749 | |
743 ShaderManager* shader_manager() { | 750 ShaderManager* shader_manager() { |
744 return group_->shader_manager(); | 751 return group_->shader_manager(); |
745 } | 752 } |
746 | 753 |
747 ShaderTranslatorCache* shader_translator_cache() { | 754 ShaderTranslatorCache* shader_translator_cache() { |
748 return group_->shader_translator_cache(); | 755 return group_->shader_translator_cache(); |
749 } | 756 } |
750 | 757 |
751 const TextureManager* texture_manager() const { | 758 const TextureManager* texture_manager() const { |
752 return group_->texture_manager(); | 759 return group_->texture_manager(); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
791 // Gets the texture info for the given texture. Returns NULL if none exists. | 798 // Gets the texture info for the given texture. Returns NULL if none exists. |
792 TextureRef* GetTexture(GLuint client_id) const { | 799 TextureRef* GetTexture(GLuint client_id) const { |
793 return texture_manager()->GetTexture(client_id); | 800 return texture_manager()->GetTexture(client_id); |
794 } | 801 } |
795 | 802 |
796 // Deletes the texture info for the given texture. | 803 // Deletes the texture info for the given texture. |
797 void RemoveTexture(GLuint client_id) { | 804 void RemoveTexture(GLuint client_id) { |
798 texture_manager()->RemoveTexture(client_id); | 805 texture_manager()->RemoveTexture(client_id); |
799 } | 806 } |
800 | 807 |
808 // Creates a Sampler for the given sampler. | |
809 Sampler* CreateSampler( | |
810 GLuint client_id, GLuint service_id) { | |
811 return sampler_manager()->CreateSampler(client_id, service_id); | |
812 } | |
813 | |
814 // Gets the sampler info for the given sampler. Returns NULL if none exists. | |
815 Sampler* GetSampler(GLuint client_id) { | |
816 return sampler_manager()->GetSampler(client_id); | |
817 } | |
818 | |
819 // Deletes the sampler info for the given sampler. | |
820 void RemoveSampler(GLuint client_id) { | |
821 sampler_manager()->RemoveSampler(client_id); | |
822 } | |
823 | |
801 // Get the size (in pixels) of the currently bound frame buffer (either FBO | 824 // Get the size (in pixels) of the currently bound frame buffer (either FBO |
802 // or regular back buffer). | 825 // or regular back buffer). |
803 gfx::Size GetBoundReadFrameBufferSize(); | 826 gfx::Size GetBoundReadFrameBufferSize(); |
804 | 827 |
805 // Get the format/type of the currently bound frame buffer (either FBO or | 828 // Get the format/type of the currently bound frame buffer (either FBO or |
806 // regular back buffer). | 829 // regular back buffer). |
807 // If the color image is a renderbuffer, returns 0 for type. | 830 // If the color image is a renderbuffer, returns 0 for type. |
808 GLenum GetBoundReadFrameBufferTextureType(); | 831 GLenum GetBoundReadFrameBufferTextureType(); |
809 GLenum GetBoundReadFrameBufferInternalFormat(); | 832 GLenum GetBoundReadFrameBufferInternalFormat(); |
810 | 833 |
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1351 | 1374 |
1352 // Wrapper for glBindFramebuffer since we need to track the current targets. | 1375 // Wrapper for glBindFramebuffer since we need to track the current targets. |
1353 void DoBindFramebuffer(GLenum target, GLuint framebuffer); | 1376 void DoBindFramebuffer(GLenum target, GLuint framebuffer); |
1354 | 1377 |
1355 // Wrapper for glBindRenderbuffer since we need to track the current targets. | 1378 // Wrapper for glBindRenderbuffer since we need to track the current targets. |
1356 void DoBindRenderbuffer(GLenum target, GLuint renderbuffer); | 1379 void DoBindRenderbuffer(GLenum target, GLuint renderbuffer); |
1357 | 1380 |
1358 // Wrapper for glBindTexture since we need to track the current targets. | 1381 // Wrapper for glBindTexture since we need to track the current targets. |
1359 void DoBindTexture(GLenum target, GLuint texture); | 1382 void DoBindTexture(GLenum target, GLuint texture); |
1360 | 1383 |
1384 // Wrapper for glBindSampler since we need to track the current targets. | |
1385 void DoBindSampler(GLuint unit, GLuint sampler); | |
1386 | |
1361 // Wrapper for glBindVertexArrayOES | 1387 // Wrapper for glBindVertexArrayOES |
1362 void DoBindVertexArrayOES(GLuint array); | 1388 void DoBindVertexArrayOES(GLuint array); |
1363 void EmulateVertexArrayState(); | 1389 void EmulateVertexArrayState(); |
1364 | 1390 |
1365 // Wrapper for glBlitFramebufferCHROMIUM. | 1391 // Wrapper for glBlitFramebufferCHROMIUM. |
1366 void DoBlitFramebufferCHROMIUM( | 1392 void DoBlitFramebufferCHROMIUM( |
1367 GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, | 1393 GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, |
1368 GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, | 1394 GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, |
1369 GLbitfield mask, GLenum filter); | 1395 GLbitfield mask, GLenum filter); |
1370 | 1396 |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1482 GLenum target, GLenum pname, GLint* params); | 1508 GLenum target, GLenum pname, GLint* params); |
1483 | 1509 |
1484 // Wrapper for glGetProgramiv. | 1510 // Wrapper for glGetProgramiv. |
1485 void DoGetProgramiv( | 1511 void DoGetProgramiv( |
1486 GLuint program_id, GLenum pname, GLint* params); | 1512 GLuint program_id, GLenum pname, GLint* params); |
1487 | 1513 |
1488 // Wrapper for glRenderbufferParameteriv. | 1514 // Wrapper for glRenderbufferParameteriv. |
1489 void DoGetRenderbufferParameteriv( | 1515 void DoGetRenderbufferParameteriv( |
1490 GLenum target, GLenum pname, GLint* params); | 1516 GLenum target, GLenum pname, GLint* params); |
1491 | 1517 |
1518 // Wrappers for glGetSamplerParameter. | |
1519 void DoGetSamplerParameterfv(GLuint client_id, GLenum pname, GLfloat* params); | |
1520 void DoGetSamplerParameteriv(GLuint client_id, GLenum pname, GLint* params); | |
1521 | |
1492 // Wrapper for glGetShaderiv | 1522 // Wrapper for glGetShaderiv |
1493 void DoGetShaderiv(GLuint shader, GLenum pname, GLint* params); | 1523 void DoGetShaderiv(GLuint shader, GLenum pname, GLint* params); |
1494 | 1524 |
1495 // Wrappers for glGetTexParameter. | 1525 // Wrappers for glGetTexParameter. |
1496 void DoGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params); | 1526 void DoGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params); |
1497 void DoGetTexParameteriv(GLenum target, GLenum pname, GLint* params); | 1527 void DoGetTexParameteriv(GLenum target, GLenum pname, GLint* params); |
1498 void InitTextureMaxAnisotropyIfNeeded(GLenum target, GLenum pname); | 1528 void InitTextureMaxAnisotropyIfNeeded(GLenum target, GLenum pname); |
1499 | 1529 |
1500 // Wrappers for glGetVertexAttrib. | 1530 // Wrappers for glGetVertexAttrib. |
1501 template <typename T> | 1531 template <typename T> |
1502 void DoGetVertexAttribImpl(GLuint index, GLenum pname, T* params); | 1532 void DoGetVertexAttribImpl(GLuint index, GLenum pname, T* params); |
1503 void DoGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params); | 1533 void DoGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params); |
1504 void DoGetVertexAttribiv(GLuint index, GLenum pname, GLint* params); | 1534 void DoGetVertexAttribiv(GLuint index, GLenum pname, GLint* params); |
1505 void DoGetVertexAttribIiv(GLuint index, GLenum pname, GLint* params); | 1535 void DoGetVertexAttribIiv(GLuint index, GLenum pname, GLint* params); |
1506 void DoGetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params); | 1536 void DoGetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params); |
1507 | 1537 |
1508 // Wrappers for glIsXXX functions. | 1538 // Wrappers for glIsXXX functions. |
1509 bool DoIsEnabled(GLenum cap); | 1539 bool DoIsEnabled(GLenum cap); |
1510 bool DoIsBuffer(GLuint client_id); | 1540 bool DoIsBuffer(GLuint client_id); |
1511 bool DoIsFramebuffer(GLuint client_id); | 1541 bool DoIsFramebuffer(GLuint client_id); |
1512 bool DoIsProgram(GLuint client_id); | 1542 bool DoIsProgram(GLuint client_id); |
1513 bool DoIsRenderbuffer(GLuint client_id); | 1543 bool DoIsRenderbuffer(GLuint client_id); |
1514 bool DoIsShader(GLuint client_id); | 1544 bool DoIsShader(GLuint client_id); |
1515 bool DoIsTexture(GLuint client_id); | 1545 bool DoIsTexture(GLuint client_id); |
1546 bool DoIsSampler(GLuint client_id); | |
1516 bool DoIsVertexArrayOES(GLuint client_id); | 1547 bool DoIsVertexArrayOES(GLuint client_id); |
1517 bool DoIsPathCHROMIUM(GLuint client_id); | 1548 bool DoIsPathCHROMIUM(GLuint client_id); |
1518 | 1549 |
1519 void DoLineWidth(GLfloat width); | 1550 void DoLineWidth(GLfloat width); |
1520 | 1551 |
1521 // Wrapper for glLinkProgram | 1552 // Wrapper for glLinkProgram |
1522 void DoLinkProgram(GLuint program); | 1553 void DoLinkProgram(GLuint program); |
1523 | 1554 |
1524 // Wrapper for glReadBuffer | 1555 // Wrapper for glReadBuffer |
1525 void DoReadBuffer(GLenum src); | 1556 void DoReadBuffer(GLenum src); |
(...skipping 21 matching lines...) Expand all Loading... | |
1547 | 1578 |
1548 // Verifies that the currently bound multisample renderbuffer is valid | 1579 // Verifies that the currently bound multisample renderbuffer is valid |
1549 // Very slow! Only done on platforms with driver bugs that return invalid | 1580 // Very slow! Only done on platforms with driver bugs that return invalid |
1550 // buffers under memory pressure | 1581 // buffers under memory pressure |
1551 bool VerifyMultisampleRenderbufferIntegrity( | 1582 bool VerifyMultisampleRenderbufferIntegrity( |
1552 GLuint renderbuffer, GLenum format); | 1583 GLuint renderbuffer, GLenum format); |
1553 | 1584 |
1554 // Wrapper for glReleaseShaderCompiler. | 1585 // Wrapper for glReleaseShaderCompiler. |
1555 void DoReleaseShaderCompiler() { } | 1586 void DoReleaseShaderCompiler() { } |
1556 | 1587 |
1557 // Wrappers for glSamplerParameter*v functions. | 1588 // Wrappers for glSamplerParameter functions. |
1589 void DoSamplerParameterf(GLuint client_id, GLenum pname, GLfloat param); | |
1590 void DoSamplerParameteri(GLuint client_id, GLenum pname, GLint param); | |
1558 void DoSamplerParameterfv( | 1591 void DoSamplerParameterfv( |
1559 GLuint sampler, GLenum pname, const GLfloat* params); | 1592 GLuint client_id, GLenum pname, const GLfloat* params); |
1560 void DoSamplerParameteriv(GLuint sampler, GLenum pname, const GLint* params); | 1593 void DoSamplerParameteriv( |
1594 GLuint client_id, GLenum pname, const GLint* params); | |
1561 | 1595 |
1562 // Wrappers for glTexParameter functions. | 1596 // Wrappers for glTexParameter functions. |
1563 void DoTexParameterf(GLenum target, GLenum pname, GLfloat param); | 1597 void DoTexParameterf(GLenum target, GLenum pname, GLfloat param); |
1564 void DoTexParameteri(GLenum target, GLenum pname, GLint param); | 1598 void DoTexParameteri(GLenum target, GLenum pname, GLint param); |
1565 void DoTexParameterfv(GLenum target, GLenum pname, const GLfloat* params); | 1599 void DoTexParameterfv(GLenum target, GLenum pname, const GLfloat* params); |
1566 void DoTexParameteriv(GLenum target, GLenum pname, const GLint* params); | 1600 void DoTexParameteriv(GLenum target, GLenum pname, const GLint* params); |
1567 | 1601 |
1568 // Wrappers for glUniform1i and glUniform1iv as according to the GLES2 | 1602 // Wrappers for glUniform1i and glUniform1iv as according to the GLES2 |
1569 // spec only these 2 functions can be used to set sampler uniforms. | 1603 // spec only these 2 functions can be used to set sampler uniforms. |
1570 void DoUniform1i(GLint fake_location, GLint v0); | 1604 void DoUniform1i(GLint fake_location, GLint v0); |
(...skipping 1114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2685 // OpenGL ES 2.0 does not have this issue. | 2719 // OpenGL ES 2.0 does not have this issue. |
2686 glEnableVertexAttribArray(0); | 2720 glEnableVertexAttribArray(0); |
2687 } | 2721 } |
2688 glGenBuffersARB(1, &attrib_0_buffer_id_); | 2722 glGenBuffersARB(1, &attrib_0_buffer_id_); |
2689 glBindBuffer(GL_ARRAY_BUFFER, attrib_0_buffer_id_); | 2723 glBindBuffer(GL_ARRAY_BUFFER, attrib_0_buffer_id_); |
2690 glVertexAttribPointer(0, 1, GL_FLOAT, GL_FALSE, 0, NULL); | 2724 glVertexAttribPointer(0, 1, GL_FLOAT, GL_FALSE, 0, NULL); |
2691 glBindBuffer(GL_ARRAY_BUFFER, 0); | 2725 glBindBuffer(GL_ARRAY_BUFFER, 0); |
2692 glGenBuffersARB(1, &fixed_attrib_buffer_id_); | 2726 glGenBuffersARB(1, &fixed_attrib_buffer_id_); |
2693 | 2727 |
2694 state_.texture_units.resize(group_->max_texture_units()); | 2728 state_.texture_units.resize(group_->max_texture_units()); |
2729 state_.sampler_units.resize(group_->max_texture_units()); | |
2695 for (uint32 tt = 0; tt < state_.texture_units.size(); ++tt) { | 2730 for (uint32 tt = 0; tt < state_.texture_units.size(); ++tt) { |
2696 glActiveTexture(GL_TEXTURE0 + tt); | 2731 glActiveTexture(GL_TEXTURE0 + tt); |
2697 // We want the last bind to be 2D. | 2732 // We want the last bind to be 2D. |
2698 TextureRef* ref; | 2733 TextureRef* ref; |
2699 if (features().oes_egl_image_external) { | 2734 if (features().oes_egl_image_external) { |
2700 ref = texture_manager()->GetDefaultTextureInfo( | 2735 ref = texture_manager()->GetDefaultTextureInfo( |
2701 GL_TEXTURE_EXTERNAL_OES); | 2736 GL_TEXTURE_EXTERNAL_OES); |
2702 state_.texture_units[tt].bound_texture_external_oes = ref; | 2737 state_.texture_units[tt].bound_texture_external_oes = ref; |
2703 glBindTexture(GL_TEXTURE_EXTERNAL_OES, ref ? ref->service_id() : 0); | 2738 glBindTexture(GL_TEXTURE_EXTERNAL_OES, ref ? ref->service_id() : 0); |
2704 } | 2739 } |
2705 if (features().arb_texture_rectangle) { | 2740 if (features().arb_texture_rectangle) { |
2706 ref = texture_manager()->GetDefaultTextureInfo( | 2741 ref = texture_manager()->GetDefaultTextureInfo( |
2707 GL_TEXTURE_RECTANGLE_ARB); | 2742 GL_TEXTURE_RECTANGLE_ARB); |
2708 state_.texture_units[tt].bound_texture_rectangle_arb = ref; | 2743 state_.texture_units[tt].bound_texture_rectangle_arb = ref; |
2709 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, ref ? ref->service_id() : 0); | 2744 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, ref ? ref->service_id() : 0); |
2710 } | 2745 } |
2711 ref = texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_CUBE_MAP); | 2746 ref = texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_CUBE_MAP); |
2712 state_.texture_units[tt].bound_texture_cube_map = ref; | 2747 state_.texture_units[tt].bound_texture_cube_map = ref; |
2713 glBindTexture(GL_TEXTURE_CUBE_MAP, ref ? ref->service_id() : 0); | 2748 glBindTexture(GL_TEXTURE_CUBE_MAP, ref ? ref->service_id() : 0); |
2714 ref = texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_2D); | 2749 ref = texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_2D); |
2715 state_.texture_units[tt].bound_texture_2d = ref; | 2750 state_.texture_units[tt].bound_texture_2d = ref; |
2716 glBindTexture(GL_TEXTURE_2D, ref ? ref->service_id() : 0); | 2751 glBindTexture(GL_TEXTURE_2D, ref ? ref->service_id() : 0); |
2752 | |
2753 if (features().enable_samplers) | |
2754 glBindSampler(tt, 0); | |
piman
2015/12/05 02:45:19
nit: is it needed? it's the default state.
piman
2015/12/07 19:35:59
ping
| |
2717 } | 2755 } |
2718 glActiveTexture(GL_TEXTURE0); | 2756 glActiveTexture(GL_TEXTURE0); |
2719 CHECK_GL_ERROR(); | 2757 CHECK_GL_ERROR(); |
2720 | 2758 |
2721 // cache ALPHA_BITS result for re-use with clear behaviour | 2759 // cache ALPHA_BITS result for re-use with clear behaviour |
2722 GLint alpha_bits = 0; | 2760 GLint alpha_bits = 0; |
2723 | 2761 |
2724 if (offscreen) { | 2762 if (offscreen) { |
2725 if (attrib_parser.samples > 0 && attrib_parser.sample_buffers > 0 && | 2763 if (attrib_parser.samples > 0 && attrib_parser.sample_buffers > 0 && |
2726 features().chromium_framebuffer_multisample) { | 2764 features().chromium_framebuffer_multisample) { |
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3350 } | 3388 } |
3351 } | 3389 } |
3352 scoped_ptr<GLuint[]> service_ids(new GLuint[n]); | 3390 scoped_ptr<GLuint[]> service_ids(new GLuint[n]); |
3353 glGenTextures(n, service_ids.get()); | 3391 glGenTextures(n, service_ids.get()); |
3354 for (GLsizei ii = 0; ii < n; ++ii) { | 3392 for (GLsizei ii = 0; ii < n; ++ii) { |
3355 CreateTexture(client_ids[ii], service_ids[ii]); | 3393 CreateTexture(client_ids[ii], service_ids[ii]); |
3356 } | 3394 } |
3357 return true; | 3395 return true; |
3358 } | 3396 } |
3359 | 3397 |
3398 bool GLES2DecoderImpl::GenSamplersHelper(GLsizei n, const GLuint* client_ids) { | |
3399 for (GLsizei ii = 0; ii < n; ++ii) { | |
3400 if (GetSampler(client_ids[ii])) { | |
3401 return false; | |
3402 } | |
3403 } | |
3404 scoped_ptr<GLuint[]> service_ids(new GLuint[n]); | |
3405 glGenSamplers(n, service_ids.get()); | |
3406 for (GLsizei ii = 0; ii < n; ++ii) { | |
3407 CreateSampler(client_ids[ii], service_ids[ii]); | |
3408 } | |
3409 return true; | |
3410 } | |
3411 | |
3360 bool GLES2DecoderImpl::GenPathsCHROMIUMHelper(GLuint first_client_id, | 3412 bool GLES2DecoderImpl::GenPathsCHROMIUMHelper(GLuint first_client_id, |
3361 GLsizei range) { | 3413 GLsizei range) { |
3362 GLuint last_client_id; | 3414 GLuint last_client_id; |
3363 if (!SafeAddUint32(first_client_id, range - 1, &last_client_id)) | 3415 if (!SafeAddUint32(first_client_id, range - 1, &last_client_id)) |
3364 return false; | 3416 return false; |
3365 | 3417 |
3366 if (path_manager()->HasPathsInRange(first_client_id, last_client_id)) | 3418 if (path_manager()->HasPathsInRange(first_client_id, last_client_id)) |
3367 return false; | 3419 return false; |
3368 | 3420 |
3369 GLuint first_service_id = glGenPathsNV(range); | 3421 GLuint first_service_id = glGenPathsNV(range); |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3519 GLuint service_id = texture->service_id(); | 3571 GLuint service_id = texture->service_id(); |
3520 if (texture->target() == GL_TEXTURE_RECTANGLE_ARB) { | 3572 if (texture->target() == GL_TEXTURE_RECTANGLE_ARB) { |
3521 ReleaseIOSurfaceForTexture(service_id); | 3573 ReleaseIOSurfaceForTexture(service_id); |
3522 } | 3574 } |
3523 #endif | 3575 #endif |
3524 RemoveTexture(client_ids[ii]); | 3576 RemoveTexture(client_ids[ii]); |
3525 } | 3577 } |
3526 } | 3578 } |
3527 } | 3579 } |
3528 | 3580 |
3581 void GLES2DecoderImpl::DeleteSamplersHelper( | |
3582 GLsizei n, const GLuint* client_ids) { | |
3583 for (GLsizei ii = 0; ii < n; ++ii) { | |
3584 Sampler* sampler = GetSampler(client_ids[ii]); | |
3585 if (sampler && !sampler->IsDeleted()) { | |
3586 // Unbind from current sampler units. | |
3587 state_.UnbindSampler(sampler); | |
3588 | |
3589 RemoveSampler(client_ids[ii]); | |
3590 } | |
3591 } | |
3592 } | |
3593 | |
3529 // } // anonymous namespace | 3594 // } // anonymous namespace |
3530 | 3595 |
3531 bool GLES2DecoderImpl::MakeCurrent() { | 3596 bool GLES2DecoderImpl::MakeCurrent() { |
3532 if (!context_.get()) | 3597 if (!context_.get()) |
3533 return false; | 3598 return false; |
3534 | 3599 |
3535 if (WasContextLost()) { | 3600 if (WasContextLost()) { |
3536 LOG(ERROR) << " GLES2DecoderImpl: Trying to make lost context current."; | 3601 LOG(ERROR) << " GLES2DecoderImpl: Trying to make lost context current."; |
3537 return false; | 3602 return false; |
3538 } | 3603 } |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3962 void GLES2DecoderImpl::Destroy(bool have_context) { | 4027 void GLES2DecoderImpl::Destroy(bool have_context) { |
3963 if (!initialized()) | 4028 if (!initialized()) |
3964 return; | 4029 return; |
3965 | 4030 |
3966 DCHECK(!have_context || context_->IsCurrent(NULL)); | 4031 DCHECK(!have_context || context_->IsCurrent(NULL)); |
3967 | 4032 |
3968 // Unbind everything. | 4033 // Unbind everything. |
3969 state_.vertex_attrib_manager = NULL; | 4034 state_.vertex_attrib_manager = NULL; |
3970 state_.default_vertex_attrib_manager = NULL; | 4035 state_.default_vertex_attrib_manager = NULL; |
3971 state_.texture_units.clear(); | 4036 state_.texture_units.clear(); |
4037 state_.sampler_units.clear(); | |
3972 state_.bound_array_buffer = NULL; | 4038 state_.bound_array_buffer = NULL; |
3973 state_.bound_copy_read_buffer = NULL; | 4039 state_.bound_copy_read_buffer = NULL; |
3974 state_.bound_copy_write_buffer = NULL; | 4040 state_.bound_copy_write_buffer = NULL; |
3975 state_.bound_pixel_pack_buffer = NULL; | 4041 state_.bound_pixel_pack_buffer = NULL; |
3976 state_.bound_pixel_unpack_buffer = NULL; | 4042 state_.bound_pixel_unpack_buffer = NULL; |
3977 state_.bound_transform_feedback_buffer = NULL; | 4043 state_.bound_transform_feedback_buffer = NULL; |
3978 state_.bound_uniform_buffer = NULL; | 4044 state_.bound_uniform_buffer = NULL; |
3979 framebuffer_state_.bound_read_framebuffer = NULL; | 4045 framebuffer_state_.bound_read_framebuffer = NULL; |
3980 framebuffer_state_.bound_draw_framebuffer = NULL; | 4046 framebuffer_state_.bound_draw_framebuffer = NULL; |
3981 state_.bound_renderbuffer = NULL; | 4047 state_.bound_renderbuffer = NULL; |
(...skipping 882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4864 break; | 4930 break; |
4865 case GL_TEXTURE_2D_ARRAY: | 4931 case GL_TEXTURE_2D_ARRAY: |
4866 unit.bound_texture_2d_array = texture_ref; | 4932 unit.bound_texture_2d_array = texture_ref; |
4867 break; | 4933 break; |
4868 default: | 4934 default: |
4869 NOTREACHED(); // Validation should prevent us getting here. | 4935 NOTREACHED(); // Validation should prevent us getting here. |
4870 break; | 4936 break; |
4871 } | 4937 } |
4872 } | 4938 } |
4873 | 4939 |
4940 void GLES2DecoderImpl::DoBindSampler(GLuint unit, GLuint client_id) { | |
4941 Sampler* sampler = NULL; | |
4942 GLuint service_id = 0; | |
4943 if (client_id != 0) { | |
4944 sampler = GetSampler(client_id); | |
4945 if (!sampler) { | |
4946 if (!group_->bind_generates_resource()) { | |
piman
2015/12/05 02:45:19
Unlike textures or buffers, samplers are not impli
| |
4947 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, | |
4948 "glBindSampler", | |
4949 "id not generated by glGenSamplers"); | |
4950 return; | |
4951 } | |
4952 | |
4953 // It's a new id so make a texture texture for it. | |
4954 glGenSamplers(1, &service_id); | |
4955 DCHECK_NE(0u, service_id); | |
4956 sampler = CreateSampler(client_id, service_id); | |
4957 } | |
4958 } | |
4959 | |
4960 // Check the sampler exists | |
4961 if (sampler) { | |
4962 LogClientServiceForInfo(sampler, client_id, "glBindSampler"); | |
4963 glBindSampler(unit, sampler->service_id()); | |
4964 } else { | |
4965 glBindSampler(unit, 0); | |
4966 } | |
4967 | |
4968 state_.sampler_units[unit] = sampler; | |
4969 } | |
4970 | |
4874 void GLES2DecoderImpl::DoDisableVertexAttribArray(GLuint index) { | 4971 void GLES2DecoderImpl::DoDisableVertexAttribArray(GLuint index) { |
4875 if (state_.vertex_attrib_manager->Enable(index, false)) { | 4972 if (state_.vertex_attrib_manager->Enable(index, false)) { |
4876 if (index != 0 || | 4973 if (index != 0 || |
4877 gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2) { | 4974 gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2) { |
4878 glDisableVertexAttribArray(index); | 4975 glDisableVertexAttribArray(index); |
4879 } | 4976 } |
4880 } else { | 4977 } else { |
4881 LOCAL_SET_GL_ERROR( | 4978 LOCAL_SET_GL_ERROR( |
4882 GL_INVALID_VALUE, | 4979 GL_INVALID_VALUE, |
4883 "glDisableVertexAttribArray", "index out of range"); | 4980 "glDisableVertexAttribArray", "index out of range"); |
(...skipping 1831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6715 "invalid src for the default framebuffer"); | 6812 "invalid src for the default framebuffer"); |
6716 return; | 6813 return; |
6717 } | 6814 } |
6718 back_buffer_read_buffer_ = src; | 6815 back_buffer_read_buffer_ = src; |
6719 if (GetBackbufferServiceId() && src == GL_BACK) | 6816 if (GetBackbufferServiceId() && src == GL_BACK) |
6720 src = GL_COLOR_ATTACHMENT0; | 6817 src = GL_COLOR_ATTACHMENT0; |
6721 } | 6818 } |
6722 glReadBuffer(src); | 6819 glReadBuffer(src); |
6723 } | 6820 } |
6724 | 6821 |
6822 void GLES2DecoderImpl::DoSamplerParameterf( | |
6823 GLuint client_id, GLenum pname, GLfloat param) { | |
6824 Sampler* sampler = GetSampler(client_id); | |
6825 if (!sampler) { | |
6826 LOCAL_SET_GL_ERROR( | |
6827 GL_INVALID_VALUE, "glSamplerParameterf", "unknown sampler"); | |
6828 return; | |
6829 } | |
6830 sampler_manager()->SetParameterf( | |
6831 "glSamplerParameterf", GetErrorState(), sampler, pname, param); | |
6832 } | |
6833 | |
6834 void GLES2DecoderImpl::DoSamplerParameteri( | |
6835 GLuint client_id, GLenum pname, GLint param) { | |
6836 Sampler* sampler = GetSampler(client_id); | |
6837 if (!sampler) { | |
6838 LOCAL_SET_GL_ERROR( | |
6839 GL_INVALID_VALUE, "glSamplerParameteri", "unknown sampler"); | |
6840 return; | |
6841 } | |
6842 sampler_manager()->SetParameteri( | |
6843 "glSamplerParameteri", GetErrorState(), sampler, pname, param); | |
6844 } | |
6845 | |
6725 void GLES2DecoderImpl::DoSamplerParameterfv( | 6846 void GLES2DecoderImpl::DoSamplerParameterfv( |
6726 GLuint sampler, GLenum pname, const GLfloat* params) { | 6847 GLuint client_id, GLenum pname, const GLfloat* params) { |
6727 DCHECK(params); | 6848 DCHECK(params); |
6728 glSamplerParameterf(sampler, pname, params[0]); | 6849 Sampler* sampler = GetSampler(client_id); |
6850 if (!sampler) { | |
6851 LOCAL_SET_GL_ERROR( | |
6852 GL_INVALID_VALUE, "glSamplerParameterfv", "unknown sampler"); | |
6853 return; | |
6854 } | |
6855 sampler_manager()->SetParameterf( | |
6856 "glSamplerParameterfv", GetErrorState(), sampler, pname, params[0]); | |
6729 } | 6857 } |
6730 | 6858 |
6731 void GLES2DecoderImpl::DoSamplerParameteriv( | 6859 void GLES2DecoderImpl::DoSamplerParameteriv( |
6732 GLuint sampler, GLenum pname, const GLint* params) { | 6860 GLuint client_id, GLenum pname, const GLint* params) { |
6733 DCHECK(params); | 6861 DCHECK(params); |
6734 glSamplerParameteri(sampler, pname, params[0]); | 6862 Sampler* sampler = GetSampler(client_id); |
6863 if (!sampler) { | |
6864 LOCAL_SET_GL_ERROR( | |
6865 GL_INVALID_VALUE, "glSamplerParameteriv", "unknown sampler"); | |
6866 return; | |
6867 } | |
6868 sampler_manager()->SetParameteri( | |
6869 "glSamplerParameteriv", GetErrorState(), sampler, pname, params[0]); | |
6735 } | 6870 } |
6736 | 6871 |
6737 void GLES2DecoderImpl::DoTexParameterf( | 6872 void GLES2DecoderImpl::DoTexParameterf( |
6738 GLenum target, GLenum pname, GLfloat param) { | 6873 GLenum target, GLenum pname, GLfloat param) { |
6739 TextureRef* texture = texture_manager()->GetTextureInfoForTarget( | 6874 TextureRef* texture = texture_manager()->GetTextureInfoForTarget( |
6740 &state_, target); | 6875 &state_, target); |
6741 if (!texture) { | 6876 if (!texture) { |
6742 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glTexParameterf", "unknown texture"); | 6877 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glTexParameterf", "unknown texture"); |
6743 return; | 6878 return; |
6744 } | 6879 } |
(...skipping 1519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8264 // are deleted and not attached to any programs. | 8399 // are deleted and not attached to any programs. |
8265 const Shader* shader = GetShader(client_id); | 8400 const Shader* shader = GetShader(client_id); |
8266 return shader != NULL && !shader->IsDeleted(); | 8401 return shader != NULL && !shader->IsDeleted(); |
8267 } | 8402 } |
8268 | 8403 |
8269 bool GLES2DecoderImpl::DoIsTexture(GLuint client_id) { | 8404 bool GLES2DecoderImpl::DoIsTexture(GLuint client_id) { |
8270 const TextureRef* texture_ref = GetTexture(client_id); | 8405 const TextureRef* texture_ref = GetTexture(client_id); |
8271 return texture_ref && texture_ref->texture()->IsValid(); | 8406 return texture_ref && texture_ref->texture()->IsValid(); |
8272 } | 8407 } |
8273 | 8408 |
8409 bool GLES2DecoderImpl::DoIsSampler(GLuint client_id) { | |
8410 const Sampler* sampler = GetSampler(client_id); | |
8411 return sampler && !sampler->IsDeleted(); | |
8412 } | |
8413 | |
8274 void GLES2DecoderImpl::DoAttachShader( | 8414 void GLES2DecoderImpl::DoAttachShader( |
8275 GLuint program_client_id, GLint shader_client_id) { | 8415 GLuint program_client_id, GLint shader_client_id) { |
8276 Program* program = GetProgramInfoNotShader( | 8416 Program* program = GetProgramInfoNotShader( |
8277 program_client_id, "glAttachShader"); | 8417 program_client_id, "glAttachShader"); |
8278 if (!program) { | 8418 if (!program) { |
8279 return; | 8419 return; |
8280 } | 8420 } |
8281 Shader* shader = GetShaderInfoNotProgram(shader_client_id, "glAttachShader"); | 8421 Shader* shader = GetShaderInfoNotProgram(shader_client_id, "glAttachShader"); |
8282 if (!shader) { | 8422 if (!shader) { |
8283 return; | 8423 return; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8354 break; | 8494 break; |
8355 case GL_VERTEX_ATTRIB_ARRAY_INTEGER: | 8495 case GL_VERTEX_ATTRIB_ARRAY_INTEGER: |
8356 *params = attrib->integer(); | 8496 *params = attrib->integer(); |
8357 break; | 8497 break; |
8358 default: | 8498 default: |
8359 NOTREACHED(); | 8499 NOTREACHED(); |
8360 break; | 8500 break; |
8361 } | 8501 } |
8362 } | 8502 } |
8363 | 8503 |
8504 void GLES2DecoderImpl::DoGetSamplerParameterfv( | |
8505 GLuint client_id, GLenum pname, GLfloat* params) { | |
8506 Sampler* sampler = GetSampler(client_id); | |
8507 if (!sampler) { | |
8508 LOCAL_SET_GL_ERROR( | |
8509 GL_INVALID_OPERATION, "glGetSamplerParamterfv", "unknown sampler"); | |
8510 return; | |
8511 } | |
8512 glGetSamplerParameterfv(sampler->service_id(), pname, params); | |
8513 } | |
8514 | |
8515 void GLES2DecoderImpl::DoGetSamplerParameteriv( | |
8516 GLuint client_id, GLenum pname, GLint* params) { | |
8517 Sampler* sampler = GetSampler(client_id); | |
8518 if (!sampler) { | |
8519 LOCAL_SET_GL_ERROR( | |
8520 GL_INVALID_OPERATION, "glGetSamplerParamteriv", "unknown sampler"); | |
8521 return; | |
8522 } | |
8523 glGetSamplerParameteriv(sampler->service_id(), pname, params); | |
8524 } | |
8525 | |
8364 void GLES2DecoderImpl::DoGetTexParameterfv( | 8526 void GLES2DecoderImpl::DoGetTexParameterfv( |
8365 GLenum target, GLenum pname, GLfloat* params) { | 8527 GLenum target, GLenum pname, GLfloat* params) { |
8366 InitTextureMaxAnisotropyIfNeeded(target, pname); | 8528 InitTextureMaxAnisotropyIfNeeded(target, pname); |
8367 glGetTexParameterfv(target, pname, params); | 8529 glGetTexParameterfv(target, pname, params); |
8368 } | 8530 } |
8369 | 8531 |
8370 void GLES2DecoderImpl::DoGetTexParameteriv( | 8532 void GLES2DecoderImpl::DoGetTexParameteriv( |
8371 GLenum target, GLenum pname, GLint* params) { | 8533 GLenum target, GLenum pname, GLint* params) { |
8372 InitTextureMaxAnisotropyIfNeeded(target, pname); | 8534 InitTextureMaxAnisotropyIfNeeded(target, pname); |
8373 glGetTexParameteriv(target, pname, params); | 8535 glGetTexParameteriv(target, pname, params); |
(...skipping 7070 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
15444 return error::kNoError; | 15606 return error::kNoError; |
15445 } | 15607 } |
15446 | 15608 |
15447 // Include the auto-generated part of this file. We split this because it means | 15609 // Include the auto-generated part of this file. We split this because it means |
15448 // we can easily edit the non-auto generated parts right here in this file | 15610 // we can easily edit the non-auto generated parts right here in this file |
15449 // instead of having to edit some template or the code generator. | 15611 // instead of having to edit some template or the code generator. |
15450 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 15612 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
15451 | 15613 |
15452 } // namespace gles2 | 15614 } // namespace gles2 |
15453 } // namespace gpu | 15615 } // namespace gpu |
OLD | NEW |