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 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
701 bool GenRenderbuffersHelper(GLsizei n, const GLuint* client_ids); | 702 bool GenRenderbuffersHelper(GLsizei n, const GLuint* client_ids); |
702 void DeleteRenderbuffersHelper(GLsizei n, const GLuint* client_ids); | 703 void DeleteRenderbuffersHelper(GLsizei n, const GLuint* client_ids); |
703 bool GenValuebuffersCHROMIUMHelper(GLsizei n, const GLuint* client_ids); | 704 bool GenValuebuffersCHROMIUMHelper(GLsizei n, const GLuint* client_ids); |
704 void DeleteValuebuffersCHROMIUMHelper(GLsizei n, const GLuint* client_ids); | 705 void DeleteValuebuffersCHROMIUMHelper(GLsizei n, const GLuint* client_ids); |
705 bool GenQueriesEXTHelper(GLsizei n, const GLuint* client_ids); | 706 bool GenQueriesEXTHelper(GLsizei n, const GLuint* client_ids); |
706 void DeleteQueriesEXTHelper(GLsizei n, const GLuint* client_ids); | 707 void DeleteQueriesEXTHelper(GLsizei n, const GLuint* client_ids); |
707 bool GenVertexArraysOESHelper(GLsizei n, const GLuint* client_ids); | 708 bool GenVertexArraysOESHelper(GLsizei n, const GLuint* client_ids); |
708 void DeleteVertexArraysOESHelper(GLsizei n, const GLuint* client_ids); | 709 void DeleteVertexArraysOESHelper(GLsizei n, const GLuint* client_ids); |
709 bool GenPathsCHROMIUMHelper(GLuint first_client_id, GLsizei range); | 710 bool GenPathsCHROMIUMHelper(GLuint first_client_id, GLsizei range); |
710 bool DeletePathsCHROMIUMHelper(GLuint first_client_id, GLsizei range); | 711 bool DeletePathsCHROMIUMHelper(GLuint first_client_id, GLsizei range); |
| 712 bool GenSamplersHelper(GLsizei n, const GLuint* client_ids); |
| 713 void DeleteSamplersHelper(GLsizei n, const GLuint* client_ids); |
711 | 714 |
712 // Workarounds | 715 // Workarounds |
713 void OnFboChanged() const; | 716 void OnFboChanged() const; |
714 void OnUseFramebuffer() const; | 717 void OnUseFramebuffer() const; |
715 | 718 |
716 error::ContextLostReason GetContextLostReasonFromResetStatus( | 719 error::ContextLostReason GetContextLostReasonFromResetStatus( |
717 GLenum reset_status) const; | 720 GLenum reset_status) const; |
718 | 721 |
719 // TODO(gman): Cache these pointers? | 722 // TODO(gman): Cache these pointers? |
720 BufferManager* buffer_manager() { | 723 BufferManager* buffer_manager() { |
721 return group_->buffer_manager(); | 724 return group_->buffer_manager(); |
722 } | 725 } |
723 | 726 |
724 RenderbufferManager* renderbuffer_manager() { | 727 RenderbufferManager* renderbuffer_manager() { |
725 return group_->renderbuffer_manager(); | 728 return group_->renderbuffer_manager(); |
726 } | 729 } |
727 | 730 |
728 FramebufferManager* framebuffer_manager() { | 731 FramebufferManager* framebuffer_manager() { |
729 return group_->framebuffer_manager(); | 732 return group_->framebuffer_manager(); |
730 } | 733 } |
731 | 734 |
732 ValuebufferManager* valuebuffer_manager() { | 735 ValuebufferManager* valuebuffer_manager() { |
733 return group_->valuebuffer_manager(); | 736 return group_->valuebuffer_manager(); |
734 } | 737 } |
735 | 738 |
736 ProgramManager* program_manager() { | 739 ProgramManager* program_manager() { |
737 return group_->program_manager(); | 740 return group_->program_manager(); |
738 } | 741 } |
739 | 742 |
| 743 SamplerManager* sampler_manager() { |
| 744 return group_->sampler_manager(); |
| 745 } |
| 746 |
740 ShaderManager* shader_manager() { | 747 ShaderManager* shader_manager() { |
741 return group_->shader_manager(); | 748 return group_->shader_manager(); |
742 } | 749 } |
743 | 750 |
744 ShaderTranslatorCache* shader_translator_cache() { | 751 ShaderTranslatorCache* shader_translator_cache() { |
745 return group_->shader_translator_cache(); | 752 return group_->shader_translator_cache(); |
746 } | 753 } |
747 | 754 |
748 const TextureManager* texture_manager() const { | 755 const TextureManager* texture_manager() const { |
749 return group_->texture_manager(); | 756 return group_->texture_manager(); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
788 // Gets the texture info for the given texture. Returns NULL if none exists. | 795 // Gets the texture info for the given texture. Returns NULL if none exists. |
789 TextureRef* GetTexture(GLuint client_id) const { | 796 TextureRef* GetTexture(GLuint client_id) const { |
790 return texture_manager()->GetTexture(client_id); | 797 return texture_manager()->GetTexture(client_id); |
791 } | 798 } |
792 | 799 |
793 // Deletes the texture info for the given texture. | 800 // Deletes the texture info for the given texture. |
794 void RemoveTexture(GLuint client_id) { | 801 void RemoveTexture(GLuint client_id) { |
795 texture_manager()->RemoveTexture(client_id); | 802 texture_manager()->RemoveTexture(client_id); |
796 } | 803 } |
797 | 804 |
| 805 // Creates a Sampler for the given sampler. |
| 806 Sampler* CreateSampler( |
| 807 GLuint client_id, GLuint service_id) { |
| 808 return sampler_manager()->CreateSampler(client_id, service_id); |
| 809 } |
| 810 |
| 811 // Gets the sampler info for the given sampler. Returns NULL if none exists. |
| 812 Sampler* GetSampler(GLuint client_id) { |
| 813 return sampler_manager()->GetSampler(client_id); |
| 814 } |
| 815 |
| 816 // Deletes the sampler info for the given sampler. |
| 817 void RemoveSampler(GLuint client_id) { |
| 818 sampler_manager()->RemoveSampler(client_id); |
| 819 } |
| 820 |
798 // Get the size (in pixels) of the currently bound frame buffer (either FBO | 821 // Get the size (in pixels) of the currently bound frame buffer (either FBO |
799 // or regular back buffer). | 822 // or regular back buffer). |
800 gfx::Size GetBoundReadFrameBufferSize(); | 823 gfx::Size GetBoundReadFrameBufferSize(); |
801 | 824 |
802 // Get the format/type of the currently bound frame buffer (either FBO or | 825 // Get the format/type of the currently bound frame buffer (either FBO or |
803 // regular back buffer). | 826 // regular back buffer). |
804 // If the color image is a renderbuffer, returns 0 for type. | 827 // If the color image is a renderbuffer, returns 0 for type. |
805 GLenum GetBoundReadFrameBufferTextureType(); | 828 GLenum GetBoundReadFrameBufferTextureType(); |
806 GLenum GetBoundReadFrameBufferInternalFormat(); | 829 GLenum GetBoundReadFrameBufferInternalFormat(); |
807 | 830 |
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1366 | 1389 |
1367 // Wrapper for glBindFramebuffer since we need to track the current targets. | 1390 // Wrapper for glBindFramebuffer since we need to track the current targets. |
1368 void DoBindFramebuffer(GLenum target, GLuint framebuffer); | 1391 void DoBindFramebuffer(GLenum target, GLuint framebuffer); |
1369 | 1392 |
1370 // Wrapper for glBindRenderbuffer since we need to track the current targets. | 1393 // Wrapper for glBindRenderbuffer since we need to track the current targets. |
1371 void DoBindRenderbuffer(GLenum target, GLuint renderbuffer); | 1394 void DoBindRenderbuffer(GLenum target, GLuint renderbuffer); |
1372 | 1395 |
1373 // Wrapper for glBindTexture since we need to track the current targets. | 1396 // Wrapper for glBindTexture since we need to track the current targets. |
1374 void DoBindTexture(GLenum target, GLuint texture); | 1397 void DoBindTexture(GLenum target, GLuint texture); |
1375 | 1398 |
| 1399 // Wrapper for glBindSampler since we need to track the current targets. |
| 1400 void DoBindSampler(GLuint unit, GLuint sampler); |
| 1401 |
1376 // Wrapper for glBindVertexArrayOES | 1402 // Wrapper for glBindVertexArrayOES |
1377 void DoBindVertexArrayOES(GLuint array); | 1403 void DoBindVertexArrayOES(GLuint array); |
1378 void EmulateVertexArrayState(); | 1404 void EmulateVertexArrayState(); |
1379 | 1405 |
1380 // Wrapper for glBlitFramebufferCHROMIUM. | 1406 // Wrapper for glBlitFramebufferCHROMIUM. |
1381 void DoBlitFramebufferCHROMIUM( | 1407 void DoBlitFramebufferCHROMIUM( |
1382 GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, | 1408 GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, |
1383 GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, | 1409 GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, |
1384 GLbitfield mask, GLenum filter); | 1410 GLbitfield mask, GLenum filter); |
1385 | 1411 |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1497 GLenum target, GLenum pname, GLint* params); | 1523 GLenum target, GLenum pname, GLint* params); |
1498 | 1524 |
1499 // Wrapper for glGetProgramiv. | 1525 // Wrapper for glGetProgramiv. |
1500 void DoGetProgramiv( | 1526 void DoGetProgramiv( |
1501 GLuint program_id, GLenum pname, GLint* params); | 1527 GLuint program_id, GLenum pname, GLint* params); |
1502 | 1528 |
1503 // Wrapper for glRenderbufferParameteriv. | 1529 // Wrapper for glRenderbufferParameteriv. |
1504 void DoGetRenderbufferParameteriv( | 1530 void DoGetRenderbufferParameteriv( |
1505 GLenum target, GLenum pname, GLint* params); | 1531 GLenum target, GLenum pname, GLint* params); |
1506 | 1532 |
| 1533 // Wrappers for glGetSamplerParameter. |
| 1534 void DoGetSamplerParameterfv(GLuint client_id, GLenum pname, GLfloat* params); |
| 1535 void DoGetSamplerParameteriv(GLuint client_id, GLenum pname, GLint* params); |
| 1536 |
1507 // Wrapper for glGetShaderiv | 1537 // Wrapper for glGetShaderiv |
1508 void DoGetShaderiv(GLuint shader, GLenum pname, GLint* params); | 1538 void DoGetShaderiv(GLuint shader, GLenum pname, GLint* params); |
1509 | 1539 |
1510 // Wrappers for glGetTexParameter. | 1540 // Wrappers for glGetTexParameter. |
1511 void DoGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params); | 1541 void DoGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params); |
1512 void DoGetTexParameteriv(GLenum target, GLenum pname, GLint* params); | 1542 void DoGetTexParameteriv(GLenum target, GLenum pname, GLint* params); |
1513 void InitTextureMaxAnisotropyIfNeeded(GLenum target, GLenum pname); | 1543 void InitTextureMaxAnisotropyIfNeeded(GLenum target, GLenum pname); |
1514 | 1544 |
1515 // Wrappers for glGetVertexAttrib. | 1545 // Wrappers for glGetVertexAttrib. |
1516 template <typename T> | 1546 template <typename T> |
1517 void DoGetVertexAttribImpl(GLuint index, GLenum pname, T* params); | 1547 void DoGetVertexAttribImpl(GLuint index, GLenum pname, T* params); |
1518 void DoGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params); | 1548 void DoGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params); |
1519 void DoGetVertexAttribiv(GLuint index, GLenum pname, GLint* params); | 1549 void DoGetVertexAttribiv(GLuint index, GLenum pname, GLint* params); |
1520 void DoGetVertexAttribIiv(GLuint index, GLenum pname, GLint* params); | 1550 void DoGetVertexAttribIiv(GLuint index, GLenum pname, GLint* params); |
1521 void DoGetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params); | 1551 void DoGetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params); |
1522 | 1552 |
1523 // Wrappers for glIsXXX functions. | 1553 // Wrappers for glIsXXX functions. |
1524 bool DoIsEnabled(GLenum cap); | 1554 bool DoIsEnabled(GLenum cap); |
1525 bool DoIsBuffer(GLuint client_id); | 1555 bool DoIsBuffer(GLuint client_id); |
1526 bool DoIsFramebuffer(GLuint client_id); | 1556 bool DoIsFramebuffer(GLuint client_id); |
1527 bool DoIsProgram(GLuint client_id); | 1557 bool DoIsProgram(GLuint client_id); |
1528 bool DoIsRenderbuffer(GLuint client_id); | 1558 bool DoIsRenderbuffer(GLuint client_id); |
1529 bool DoIsShader(GLuint client_id); | 1559 bool DoIsShader(GLuint client_id); |
1530 bool DoIsTexture(GLuint client_id); | 1560 bool DoIsTexture(GLuint client_id); |
| 1561 bool DoIsSampler(GLuint client_id); |
1531 bool DoIsVertexArrayOES(GLuint client_id); | 1562 bool DoIsVertexArrayOES(GLuint client_id); |
1532 bool DoIsPathCHROMIUM(GLuint client_id); | 1563 bool DoIsPathCHROMIUM(GLuint client_id); |
1533 | 1564 |
1534 void DoLineWidth(GLfloat width); | 1565 void DoLineWidth(GLfloat width); |
1535 | 1566 |
1536 // Wrapper for glLinkProgram | 1567 // Wrapper for glLinkProgram |
1537 void DoLinkProgram(GLuint program); | 1568 void DoLinkProgram(GLuint program); |
1538 | 1569 |
1539 // Wrapper for glReadBuffer | 1570 // Wrapper for glReadBuffer |
1540 void DoReadBuffer(GLenum src); | 1571 void DoReadBuffer(GLenum src); |
(...skipping 21 matching lines...) Expand all Loading... |
1562 | 1593 |
1563 // Verifies that the currently bound multisample renderbuffer is valid | 1594 // Verifies that the currently bound multisample renderbuffer is valid |
1564 // Very slow! Only done on platforms with driver bugs that return invalid | 1595 // Very slow! Only done on platforms with driver bugs that return invalid |
1565 // buffers under memory pressure | 1596 // buffers under memory pressure |
1566 bool VerifyMultisampleRenderbufferIntegrity( | 1597 bool VerifyMultisampleRenderbufferIntegrity( |
1567 GLuint renderbuffer, GLenum format); | 1598 GLuint renderbuffer, GLenum format); |
1568 | 1599 |
1569 // Wrapper for glReleaseShaderCompiler. | 1600 // Wrapper for glReleaseShaderCompiler. |
1570 void DoReleaseShaderCompiler() { } | 1601 void DoReleaseShaderCompiler() { } |
1571 | 1602 |
1572 // Wrappers for glSamplerParameter*v functions. | 1603 // Wrappers for glSamplerParameter functions. |
| 1604 void DoSamplerParameterf(GLuint client_id, GLenum pname, GLfloat param); |
| 1605 void DoSamplerParameteri(GLuint client_id, GLenum pname, GLint param); |
1573 void DoSamplerParameterfv( | 1606 void DoSamplerParameterfv( |
1574 GLuint sampler, GLenum pname, const GLfloat* params); | 1607 GLuint client_id, GLenum pname, const GLfloat* params); |
1575 void DoSamplerParameteriv(GLuint sampler, GLenum pname, const GLint* params); | 1608 void DoSamplerParameteriv( |
| 1609 GLuint client_id, GLenum pname, const GLint* params); |
1576 | 1610 |
1577 // Wrappers for glTexParameter functions. | 1611 // Wrappers for glTexParameter functions. |
1578 void DoTexParameterf(GLenum target, GLenum pname, GLfloat param); | 1612 void DoTexParameterf(GLenum target, GLenum pname, GLfloat param); |
1579 void DoTexParameteri(GLenum target, GLenum pname, GLint param); | 1613 void DoTexParameteri(GLenum target, GLenum pname, GLint param); |
1580 void DoTexParameterfv(GLenum target, GLenum pname, const GLfloat* params); | 1614 void DoTexParameterfv(GLenum target, GLenum pname, const GLfloat* params); |
1581 void DoTexParameteriv(GLenum target, GLenum pname, const GLint* params); | 1615 void DoTexParameteriv(GLenum target, GLenum pname, const GLint* params); |
1582 | 1616 |
1583 // Wrappers for glUniform1i and glUniform1iv as according to the GLES2 | 1617 // Wrappers for glUniform1i and glUniform1iv as according to the GLES2 |
1584 // spec only these 2 functions can be used to set sampler uniforms. | 1618 // spec only these 2 functions can be used to set sampler uniforms. |
1585 void DoUniform1i(GLint fake_location, GLint v0); | 1619 void DoUniform1i(GLint fake_location, GLint v0); |
(...skipping 1115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2701 // OpenGL ES 2.0 does not have this issue. | 2735 // OpenGL ES 2.0 does not have this issue. |
2702 glEnableVertexAttribArray(0); | 2736 glEnableVertexAttribArray(0); |
2703 } | 2737 } |
2704 glGenBuffersARB(1, &attrib_0_buffer_id_); | 2738 glGenBuffersARB(1, &attrib_0_buffer_id_); |
2705 glBindBuffer(GL_ARRAY_BUFFER, attrib_0_buffer_id_); | 2739 glBindBuffer(GL_ARRAY_BUFFER, attrib_0_buffer_id_); |
2706 glVertexAttribPointer(0, 1, GL_FLOAT, GL_FALSE, 0, NULL); | 2740 glVertexAttribPointer(0, 1, GL_FLOAT, GL_FALSE, 0, NULL); |
2707 glBindBuffer(GL_ARRAY_BUFFER, 0); | 2741 glBindBuffer(GL_ARRAY_BUFFER, 0); |
2708 glGenBuffersARB(1, &fixed_attrib_buffer_id_); | 2742 glGenBuffersARB(1, &fixed_attrib_buffer_id_); |
2709 | 2743 |
2710 state_.texture_units.resize(group_->max_texture_units()); | 2744 state_.texture_units.resize(group_->max_texture_units()); |
| 2745 state_.sampler_units.resize(group_->max_texture_units()); |
2711 for (uint32 tt = 0; tt < state_.texture_units.size(); ++tt) { | 2746 for (uint32 tt = 0; tt < state_.texture_units.size(); ++tt) { |
2712 glActiveTexture(GL_TEXTURE0 + tt); | 2747 glActiveTexture(GL_TEXTURE0 + tt); |
2713 // We want the last bind to be 2D. | 2748 // We want the last bind to be 2D. |
2714 TextureRef* ref; | 2749 TextureRef* ref; |
2715 if (features().oes_egl_image_external) { | 2750 if (features().oes_egl_image_external) { |
2716 ref = texture_manager()->GetDefaultTextureInfo( | 2751 ref = texture_manager()->GetDefaultTextureInfo( |
2717 GL_TEXTURE_EXTERNAL_OES); | 2752 GL_TEXTURE_EXTERNAL_OES); |
2718 state_.texture_units[tt].bound_texture_external_oes = ref; | 2753 state_.texture_units[tt].bound_texture_external_oes = ref; |
2719 glBindTexture(GL_TEXTURE_EXTERNAL_OES, ref ? ref->service_id() : 0); | 2754 glBindTexture(GL_TEXTURE_EXTERNAL_OES, ref ? ref->service_id() : 0); |
2720 } | 2755 } |
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3369 } | 3404 } |
3370 } | 3405 } |
3371 scoped_ptr<GLuint[]> service_ids(new GLuint[n]); | 3406 scoped_ptr<GLuint[]> service_ids(new GLuint[n]); |
3372 glGenTextures(n, service_ids.get()); | 3407 glGenTextures(n, service_ids.get()); |
3373 for (GLsizei ii = 0; ii < n; ++ii) { | 3408 for (GLsizei ii = 0; ii < n; ++ii) { |
3374 CreateTexture(client_ids[ii], service_ids[ii]); | 3409 CreateTexture(client_ids[ii], service_ids[ii]); |
3375 } | 3410 } |
3376 return true; | 3411 return true; |
3377 } | 3412 } |
3378 | 3413 |
| 3414 bool GLES2DecoderImpl::GenSamplersHelper(GLsizei n, const GLuint* client_ids) { |
| 3415 for (GLsizei ii = 0; ii < n; ++ii) { |
| 3416 if (GetSampler(client_ids[ii])) { |
| 3417 return false; |
| 3418 } |
| 3419 } |
| 3420 scoped_ptr<GLuint[]> service_ids(new GLuint[n]); |
| 3421 glGenSamplers(n, service_ids.get()); |
| 3422 for (GLsizei ii = 0; ii < n; ++ii) { |
| 3423 CreateSampler(client_ids[ii], service_ids[ii]); |
| 3424 } |
| 3425 return true; |
| 3426 } |
| 3427 |
3379 bool GLES2DecoderImpl::GenPathsCHROMIUMHelper(GLuint first_client_id, | 3428 bool GLES2DecoderImpl::GenPathsCHROMIUMHelper(GLuint first_client_id, |
3380 GLsizei range) { | 3429 GLsizei range) { |
3381 GLuint last_client_id; | 3430 GLuint last_client_id; |
3382 if (!SafeAddUint32(first_client_id, range - 1, &last_client_id)) | 3431 if (!SafeAddUint32(first_client_id, range - 1, &last_client_id)) |
3383 return false; | 3432 return false; |
3384 | 3433 |
3385 if (path_manager()->HasPathsInRange(first_client_id, last_client_id)) | 3434 if (path_manager()->HasPathsInRange(first_client_id, last_client_id)) |
3386 return false; | 3435 return false; |
3387 | 3436 |
3388 GLuint first_service_id = glGenPathsNV(range); | 3437 GLuint first_service_id = glGenPathsNV(range); |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3538 GLuint service_id = texture->service_id(); | 3587 GLuint service_id = texture->service_id(); |
3539 if (texture->target() == GL_TEXTURE_RECTANGLE_ARB) { | 3588 if (texture->target() == GL_TEXTURE_RECTANGLE_ARB) { |
3540 ReleaseIOSurfaceForTexture(service_id); | 3589 ReleaseIOSurfaceForTexture(service_id); |
3541 } | 3590 } |
3542 #endif | 3591 #endif |
3543 RemoveTexture(client_ids[ii]); | 3592 RemoveTexture(client_ids[ii]); |
3544 } | 3593 } |
3545 } | 3594 } |
3546 } | 3595 } |
3547 | 3596 |
| 3597 void GLES2DecoderImpl::DeleteSamplersHelper( |
| 3598 GLsizei n, const GLuint* client_ids) { |
| 3599 for (GLsizei ii = 0; ii < n; ++ii) { |
| 3600 Sampler* sampler = GetSampler(client_ids[ii]); |
| 3601 if (sampler && !sampler->IsDeleted()) { |
| 3602 // Unbind from current sampler units. |
| 3603 state_.UnbindSampler(sampler); |
| 3604 |
| 3605 RemoveSampler(client_ids[ii]); |
| 3606 } |
| 3607 } |
| 3608 } |
| 3609 |
3548 // } // anonymous namespace | 3610 // } // anonymous namespace |
3549 | 3611 |
3550 bool GLES2DecoderImpl::MakeCurrent() { | 3612 bool GLES2DecoderImpl::MakeCurrent() { |
3551 if (!context_.get()) | 3613 if (!context_.get()) |
3552 return false; | 3614 return false; |
3553 | 3615 |
3554 if (WasContextLost()) { | 3616 if (WasContextLost()) { |
3555 LOG(ERROR) << " GLES2DecoderImpl: Trying to make lost context current."; | 3617 LOG(ERROR) << " GLES2DecoderImpl: Trying to make lost context current."; |
3556 return false; | 3618 return false; |
3557 } | 3619 } |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3981 void GLES2DecoderImpl::Destroy(bool have_context) { | 4043 void GLES2DecoderImpl::Destroy(bool have_context) { |
3982 if (!initialized()) | 4044 if (!initialized()) |
3983 return; | 4045 return; |
3984 | 4046 |
3985 DCHECK(!have_context || context_->IsCurrent(NULL)); | 4047 DCHECK(!have_context || context_->IsCurrent(NULL)); |
3986 | 4048 |
3987 // Unbind everything. | 4049 // Unbind everything. |
3988 state_.vertex_attrib_manager = NULL; | 4050 state_.vertex_attrib_manager = NULL; |
3989 state_.default_vertex_attrib_manager = NULL; | 4051 state_.default_vertex_attrib_manager = NULL; |
3990 state_.texture_units.clear(); | 4052 state_.texture_units.clear(); |
| 4053 state_.sampler_units.clear(); |
3991 state_.bound_array_buffer = NULL; | 4054 state_.bound_array_buffer = NULL; |
3992 state_.bound_copy_read_buffer = NULL; | 4055 state_.bound_copy_read_buffer = NULL; |
3993 state_.bound_copy_write_buffer = NULL; | 4056 state_.bound_copy_write_buffer = NULL; |
3994 state_.bound_pixel_pack_buffer = NULL; | 4057 state_.bound_pixel_pack_buffer = NULL; |
3995 state_.bound_pixel_unpack_buffer = NULL; | 4058 state_.bound_pixel_unpack_buffer = NULL; |
3996 state_.bound_transform_feedback_buffer = NULL; | 4059 state_.bound_transform_feedback_buffer = NULL; |
3997 state_.bound_uniform_buffer = NULL; | 4060 state_.bound_uniform_buffer = NULL; |
3998 framebuffer_state_.bound_read_framebuffer = NULL; | 4061 framebuffer_state_.bound_read_framebuffer = NULL; |
3999 framebuffer_state_.bound_draw_framebuffer = NULL; | 4062 framebuffer_state_.bound_draw_framebuffer = NULL; |
4000 state_.bound_renderbuffer = NULL; | 4063 state_.bound_renderbuffer = NULL; |
(...skipping 882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4883 break; | 4946 break; |
4884 case GL_TEXTURE_2D_ARRAY: | 4947 case GL_TEXTURE_2D_ARRAY: |
4885 unit.bound_texture_2d_array = texture_ref; | 4948 unit.bound_texture_2d_array = texture_ref; |
4886 break; | 4949 break; |
4887 default: | 4950 default: |
4888 NOTREACHED(); // Validation should prevent us getting here. | 4951 NOTREACHED(); // Validation should prevent us getting here. |
4889 break; | 4952 break; |
4890 } | 4953 } |
4891 } | 4954 } |
4892 | 4955 |
| 4956 void GLES2DecoderImpl::DoBindSampler(GLuint unit, GLuint client_id) { |
| 4957 Sampler* sampler = nullptr; |
| 4958 if (client_id != 0) { |
| 4959 sampler = GetSampler(client_id); |
| 4960 if (!sampler) { |
| 4961 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, |
| 4962 "glBindSampler", |
| 4963 "id not generated by glGenSamplers"); |
| 4964 return; |
| 4965 } |
| 4966 } |
| 4967 |
| 4968 // Check the sampler exists |
| 4969 if (sampler) { |
| 4970 LogClientServiceForInfo(sampler, client_id, "glBindSampler"); |
| 4971 glBindSampler(unit, sampler->service_id()); |
| 4972 } else { |
| 4973 glBindSampler(unit, 0); |
| 4974 } |
| 4975 |
| 4976 state_.sampler_units[unit] = sampler; |
| 4977 } |
| 4978 |
4893 void GLES2DecoderImpl::DoDisableVertexAttribArray(GLuint index) { | 4979 void GLES2DecoderImpl::DoDisableVertexAttribArray(GLuint index) { |
4894 if (state_.vertex_attrib_manager->Enable(index, false)) { | 4980 if (state_.vertex_attrib_manager->Enable(index, false)) { |
4895 if (index != 0 || | 4981 if (index != 0 || |
4896 gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2) { | 4982 gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2) { |
4897 glDisableVertexAttribArray(index); | 4983 glDisableVertexAttribArray(index); |
4898 } | 4984 } |
4899 } else { | 4985 } else { |
4900 LOCAL_SET_GL_ERROR( | 4986 LOCAL_SET_GL_ERROR( |
4901 GL_INVALID_VALUE, | 4987 GL_INVALID_VALUE, |
4902 "glDisableVertexAttribArray", "index out of range"); | 4988 "glDisableVertexAttribArray", "index out of range"); |
(...skipping 1940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6843 "invalid src for the default framebuffer"); | 6929 "invalid src for the default framebuffer"); |
6844 return; | 6930 return; |
6845 } | 6931 } |
6846 back_buffer_read_buffer_ = src; | 6932 back_buffer_read_buffer_ = src; |
6847 if (GetBackbufferServiceId() && src == GL_BACK) | 6933 if (GetBackbufferServiceId() && src == GL_BACK) |
6848 src = GL_COLOR_ATTACHMENT0; | 6934 src = GL_COLOR_ATTACHMENT0; |
6849 } | 6935 } |
6850 glReadBuffer(src); | 6936 glReadBuffer(src); |
6851 } | 6937 } |
6852 | 6938 |
| 6939 void GLES2DecoderImpl::DoSamplerParameterf( |
| 6940 GLuint client_id, GLenum pname, GLfloat param) { |
| 6941 Sampler* sampler = GetSampler(client_id); |
| 6942 if (!sampler) { |
| 6943 LOCAL_SET_GL_ERROR( |
| 6944 GL_INVALID_VALUE, "glSamplerParameterf", "unknown sampler"); |
| 6945 return; |
| 6946 } |
| 6947 sampler_manager()->SetParameterf( |
| 6948 "glSamplerParameterf", GetErrorState(), sampler, pname, param); |
| 6949 } |
| 6950 |
| 6951 void GLES2DecoderImpl::DoSamplerParameteri( |
| 6952 GLuint client_id, GLenum pname, GLint param) { |
| 6953 Sampler* sampler = GetSampler(client_id); |
| 6954 if (!sampler) { |
| 6955 LOCAL_SET_GL_ERROR( |
| 6956 GL_INVALID_VALUE, "glSamplerParameteri", "unknown sampler"); |
| 6957 return; |
| 6958 } |
| 6959 sampler_manager()->SetParameteri( |
| 6960 "glSamplerParameteri", GetErrorState(), sampler, pname, param); |
| 6961 } |
| 6962 |
6853 void GLES2DecoderImpl::DoSamplerParameterfv( | 6963 void GLES2DecoderImpl::DoSamplerParameterfv( |
6854 GLuint sampler, GLenum pname, const GLfloat* params) { | 6964 GLuint client_id, GLenum pname, const GLfloat* params) { |
6855 DCHECK(params); | 6965 DCHECK(params); |
6856 glSamplerParameterf(sampler, pname, params[0]); | 6966 Sampler* sampler = GetSampler(client_id); |
| 6967 if (!sampler) { |
| 6968 LOCAL_SET_GL_ERROR( |
| 6969 GL_INVALID_VALUE, "glSamplerParameterfv", "unknown sampler"); |
| 6970 return; |
| 6971 } |
| 6972 sampler_manager()->SetParameterf( |
| 6973 "glSamplerParameterfv", GetErrorState(), sampler, pname, params[0]); |
6857 } | 6974 } |
6858 | 6975 |
6859 void GLES2DecoderImpl::DoSamplerParameteriv( | 6976 void GLES2DecoderImpl::DoSamplerParameteriv( |
6860 GLuint sampler, GLenum pname, const GLint* params) { | 6977 GLuint client_id, GLenum pname, const GLint* params) { |
6861 DCHECK(params); | 6978 DCHECK(params); |
6862 glSamplerParameteri(sampler, pname, params[0]); | 6979 Sampler* sampler = GetSampler(client_id); |
| 6980 if (!sampler) { |
| 6981 LOCAL_SET_GL_ERROR( |
| 6982 GL_INVALID_VALUE, "glSamplerParameteriv", "unknown sampler"); |
| 6983 return; |
| 6984 } |
| 6985 sampler_manager()->SetParameteri( |
| 6986 "glSamplerParameteriv", GetErrorState(), sampler, pname, params[0]); |
6863 } | 6987 } |
6864 | 6988 |
6865 void GLES2DecoderImpl::DoTexParameterf( | 6989 void GLES2DecoderImpl::DoTexParameterf( |
6866 GLenum target, GLenum pname, GLfloat param) { | 6990 GLenum target, GLenum pname, GLfloat param) { |
6867 TextureRef* texture = texture_manager()->GetTextureInfoForTarget( | 6991 TextureRef* texture = texture_manager()->GetTextureInfoForTarget( |
6868 &state_, target); | 6992 &state_, target); |
6869 if (!texture) { | 6993 if (!texture) { |
6870 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glTexParameterf", "unknown texture"); | 6994 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glTexParameterf", "unknown texture"); |
6871 return; | 6995 return; |
6872 } | 6996 } |
(...skipping 1519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8392 // are deleted and not attached to any programs. | 8516 // are deleted and not attached to any programs. |
8393 const Shader* shader = GetShader(client_id); | 8517 const Shader* shader = GetShader(client_id); |
8394 return shader != NULL && !shader->IsDeleted(); | 8518 return shader != NULL && !shader->IsDeleted(); |
8395 } | 8519 } |
8396 | 8520 |
8397 bool GLES2DecoderImpl::DoIsTexture(GLuint client_id) { | 8521 bool GLES2DecoderImpl::DoIsTexture(GLuint client_id) { |
8398 const TextureRef* texture_ref = GetTexture(client_id); | 8522 const TextureRef* texture_ref = GetTexture(client_id); |
8399 return texture_ref && texture_ref->texture()->IsValid(); | 8523 return texture_ref && texture_ref->texture()->IsValid(); |
8400 } | 8524 } |
8401 | 8525 |
| 8526 bool GLES2DecoderImpl::DoIsSampler(GLuint client_id) { |
| 8527 const Sampler* sampler = GetSampler(client_id); |
| 8528 return sampler && !sampler->IsDeleted(); |
| 8529 } |
| 8530 |
8402 void GLES2DecoderImpl::DoAttachShader( | 8531 void GLES2DecoderImpl::DoAttachShader( |
8403 GLuint program_client_id, GLint shader_client_id) { | 8532 GLuint program_client_id, GLint shader_client_id) { |
8404 Program* program = GetProgramInfoNotShader( | 8533 Program* program = GetProgramInfoNotShader( |
8405 program_client_id, "glAttachShader"); | 8534 program_client_id, "glAttachShader"); |
8406 if (!program) { | 8535 if (!program) { |
8407 return; | 8536 return; |
8408 } | 8537 } |
8409 Shader* shader = GetShaderInfoNotProgram(shader_client_id, "glAttachShader"); | 8538 Shader* shader = GetShaderInfoNotProgram(shader_client_id, "glAttachShader"); |
8410 if (!shader) { | 8539 if (!shader) { |
8411 return; | 8540 return; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8482 break; | 8611 break; |
8483 case GL_VERTEX_ATTRIB_ARRAY_INTEGER: | 8612 case GL_VERTEX_ATTRIB_ARRAY_INTEGER: |
8484 *params = attrib->integer(); | 8613 *params = attrib->integer(); |
8485 break; | 8614 break; |
8486 default: | 8615 default: |
8487 NOTREACHED(); | 8616 NOTREACHED(); |
8488 break; | 8617 break; |
8489 } | 8618 } |
8490 } | 8619 } |
8491 | 8620 |
| 8621 void GLES2DecoderImpl::DoGetSamplerParameterfv( |
| 8622 GLuint client_id, GLenum pname, GLfloat* params) { |
| 8623 Sampler* sampler = GetSampler(client_id); |
| 8624 if (!sampler) { |
| 8625 LOCAL_SET_GL_ERROR( |
| 8626 GL_INVALID_OPERATION, "glGetSamplerParamterfv", "unknown sampler"); |
| 8627 return; |
| 8628 } |
| 8629 glGetSamplerParameterfv(sampler->service_id(), pname, params); |
| 8630 } |
| 8631 |
| 8632 void GLES2DecoderImpl::DoGetSamplerParameteriv( |
| 8633 GLuint client_id, GLenum pname, GLint* params) { |
| 8634 Sampler* sampler = GetSampler(client_id); |
| 8635 if (!sampler) { |
| 8636 LOCAL_SET_GL_ERROR( |
| 8637 GL_INVALID_OPERATION, "glGetSamplerParamteriv", "unknown sampler"); |
| 8638 return; |
| 8639 } |
| 8640 glGetSamplerParameteriv(sampler->service_id(), pname, params); |
| 8641 } |
| 8642 |
8492 void GLES2DecoderImpl::DoGetTexParameterfv( | 8643 void GLES2DecoderImpl::DoGetTexParameterfv( |
8493 GLenum target, GLenum pname, GLfloat* params) { | 8644 GLenum target, GLenum pname, GLfloat* params) { |
8494 InitTextureMaxAnisotropyIfNeeded(target, pname); | 8645 InitTextureMaxAnisotropyIfNeeded(target, pname); |
8495 glGetTexParameterfv(target, pname, params); | 8646 glGetTexParameterfv(target, pname, params); |
8496 } | 8647 } |
8497 | 8648 |
8498 void GLES2DecoderImpl::DoGetTexParameteriv( | 8649 void GLES2DecoderImpl::DoGetTexParameteriv( |
8499 GLenum target, GLenum pname, GLint* params) { | 8650 GLenum target, GLenum pname, GLint* params) { |
8500 InitTextureMaxAnisotropyIfNeeded(target, pname); | 8651 InitTextureMaxAnisotropyIfNeeded(target, pname); |
8501 glGetTexParameteriv(target, pname, params); | 8652 glGetTexParameteriv(target, pname, params); |
(...skipping 7126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15628 return error::kNoError; | 15779 return error::kNoError; |
15629 } | 15780 } |
15630 | 15781 |
15631 // Include the auto-generated part of this file. We split this because it means | 15782 // Include the auto-generated part of this file. We split this because it means |
15632 // we can easily edit the non-auto generated parts right here in this file | 15783 // we can easily edit the non-auto generated parts right here in this file |
15633 // instead of having to edit some template or the code generator. | 15784 // instead of having to edit some template or the code generator. |
15634 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 15785 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
15635 | 15786 |
15636 } // namespace gles2 | 15787 } // namespace gles2 |
15637 } // namespace gpu | 15788 } // namespace gpu |
OLD | NEW |