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 18 matching lines...) Expand all Loading... |
29 #include "gpu/command_buffer/common/id_allocator.h" | 29 #include "gpu/command_buffer/common/id_allocator.h" |
30 #include "gpu/command_buffer/service/buffer_manager.h" | 30 #include "gpu/command_buffer/service/buffer_manager.h" |
31 #include "gpu/command_buffer/service/cmd_buffer_engine.h" | 31 #include "gpu/command_buffer/service/cmd_buffer_engine.h" |
32 #include "gpu/command_buffer/service/context_group.h" | 32 #include "gpu/command_buffer/service/context_group.h" |
33 #include "gpu/command_buffer/service/feature_info.h" | 33 #include "gpu/command_buffer/service/feature_info.h" |
34 #include "gpu/command_buffer/service/framebuffer_manager.h" | 34 #include "gpu/command_buffer/service/framebuffer_manager.h" |
35 #include "gpu/command_buffer/service/gl_utils.h" | 35 #include "gpu/command_buffer/service/gl_utils.h" |
36 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h" | 36 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h" |
37 #include "gpu/command_buffer/service/gles2_cmd_validation.h" | 37 #include "gpu/command_buffer/service/gles2_cmd_validation.h" |
38 #include "gpu/command_buffer/service/gpu_switches.h" | 38 #include "gpu/command_buffer/service/gpu_switches.h" |
| 39 #include "gpu/command_buffer/service/mailbox_manager.h" |
39 #include "gpu/command_buffer/service/program_manager.h" | 40 #include "gpu/command_buffer/service/program_manager.h" |
40 #include "gpu/command_buffer/service/query_manager.h" | 41 #include "gpu/command_buffer/service/query_manager.h" |
41 #include "gpu/command_buffer/service/renderbuffer_manager.h" | 42 #include "gpu/command_buffer/service/renderbuffer_manager.h" |
42 #include "gpu/command_buffer/service/shader_manager.h" | 43 #include "gpu/command_buffer/service/shader_manager.h" |
43 #include "gpu/command_buffer/service/shader_translator.h" | 44 #include "gpu/command_buffer/service/shader_translator.h" |
44 #include "gpu/command_buffer/service/stream_texture.h" | 45 #include "gpu/command_buffer/service/stream_texture.h" |
45 #include "gpu/command_buffer/service/stream_texture_manager.h" | 46 #include "gpu/command_buffer/service/stream_texture_manager.h" |
| 47 #include "gpu/command_buffer/service/texture_definition.h" |
46 #include "gpu/command_buffer/service/texture_manager.h" | 48 #include "gpu/command_buffer/service/texture_manager.h" |
47 #include "gpu/command_buffer/service/vertex_attrib_manager.h" | 49 #include "gpu/command_buffer/service/vertex_attrib_manager.h" |
48 #include "ui/gfx/gl/gl_context.h" | 50 #include "ui/gfx/gl/gl_context.h" |
49 #include "ui/gfx/gl/gl_implementation.h" | 51 #include "ui/gfx/gl/gl_implementation.h" |
50 #include "ui/gfx/gl/gl_surface.h" | 52 #include "ui/gfx/gl/gl_surface.h" |
51 #if defined(OS_MACOSX) | 53 #if defined(OS_MACOSX) |
52 #include "ui/gfx/surface/io_surface_support_mac.h" | 54 #include "ui/gfx/surface/io_surface_support_mac.h" |
53 #endif | 55 #endif |
54 | 56 |
55 #if !defined(GL_DEPTH24_STENCIL8) | 57 #if !defined(GL_DEPTH24_STENCIL8) |
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 uint32* service_texture_id); | 503 uint32* service_texture_id); |
502 | 504 |
503 // Restores the current state to the user's settings. | 505 // Restores the current state to the user's settings. |
504 void RestoreCurrentFramebufferBindings(); | 506 void RestoreCurrentFramebufferBindings(); |
505 void RestoreCurrentRenderbufferBindings(); | 507 void RestoreCurrentRenderbufferBindings(); |
506 void RestoreCurrentTexture2DBindings(); | 508 void RestoreCurrentTexture2DBindings(); |
507 | 509 |
508 // Sets DEPTH_TEST, STENCIL_TEST and color mask for the current framebuffer. | 510 // Sets DEPTH_TEST, STENCIL_TEST and color mask for the current framebuffer. |
509 void ApplyDirtyState(); | 511 void ApplyDirtyState(); |
510 | 512 |
| 513 // Reapply the texture parameters to the given texture. |
| 514 void BindAndApplyTextureParameters(TextureManager::TextureInfo* info); |
| 515 |
511 // These check the state of the currently bound framebuffer or the | 516 // These check the state of the currently bound framebuffer or the |
512 // backbuffer if no framebuffer is bound. | 517 // backbuffer if no framebuffer is bound. |
513 bool BoundFramebufferHasColorAttachmentWithAlpha(); | 518 bool BoundFramebufferHasColorAttachmentWithAlpha(); |
514 bool BoundFramebufferHasDepthAttachment(); | 519 bool BoundFramebufferHasDepthAttachment(); |
515 bool BoundFramebufferHasStencilAttachment(); | 520 bool BoundFramebufferHasStencilAttachment(); |
516 | 521 |
517 virtual error::ContextLostReason GetContextLostReason(); | 522 virtual error::ContextLostReason GetContextLostReason(); |
518 | 523 |
519 private: | 524 private: |
520 friend class ScopedGLErrorSuppressor; | 525 friend class ScopedGLErrorSuppressor; |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 } | 616 } |
612 | 617 |
613 ShaderManager* shader_manager() { | 618 ShaderManager* shader_manager() { |
614 return group_->shader_manager(); | 619 return group_->shader_manager(); |
615 } | 620 } |
616 | 621 |
617 TextureManager* texture_manager() { | 622 TextureManager* texture_manager() { |
618 return group_->texture_manager(); | 623 return group_->texture_manager(); |
619 } | 624 } |
620 | 625 |
| 626 MailboxManager* mailbox_manager() { |
| 627 return group_->mailbox_manager(); |
| 628 } |
| 629 |
621 bool IsOffscreenBufferMultisampled() const { | 630 bool IsOffscreenBufferMultisampled() const { |
622 return offscreen_target_samples_ > 1; | 631 return offscreen_target_samples_ > 1; |
623 } | 632 } |
624 | 633 |
625 // Creates a TextureInfo for the given texture. | 634 // Creates a TextureInfo for the given texture. |
626 TextureManager::TextureInfo* CreateTextureInfo( | 635 TextureManager::TextureInfo* CreateTextureInfo( |
627 GLuint client_id, GLuint service_id) { | 636 GLuint client_id, GLuint service_id) { |
628 return texture_manager()->CreateTextureInfo(client_id, service_id); | 637 return texture_manager()->CreateTextureInfo(client_id, service_id); |
629 } | 638 } |
630 | 639 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
734 GLint level); | 743 GLint level); |
735 | 744 |
736 // Wrapper for TexStorage2DEXT. | 745 // Wrapper for TexStorage2DEXT. |
737 void DoTexStorage2DEXT( | 746 void DoTexStorage2DEXT( |
738 GLenum target, | 747 GLenum target, |
739 GLint levels, | 748 GLint levels, |
740 GLenum internal_format, | 749 GLenum internal_format, |
741 GLsizei width, | 750 GLsizei width, |
742 GLsizei height); | 751 GLsizei height); |
743 | 752 |
| 753 void DoProduceTextureCHROMIUM(GLenum target, const GLbyte* key); |
| 754 void DoConsumeTextureCHROMIUM(GLenum target, const GLbyte* key); |
| 755 |
744 // Creates a ProgramInfo for the given program. | 756 // Creates a ProgramInfo for the given program. |
745 ProgramManager::ProgramInfo* CreateProgramInfo( | 757 ProgramManager::ProgramInfo* CreateProgramInfo( |
746 GLuint client_id, GLuint service_id) { | 758 GLuint client_id, GLuint service_id) { |
747 return program_manager()->CreateProgramInfo(client_id, service_id); | 759 return program_manager()->CreateProgramInfo(client_id, service_id); |
748 } | 760 } |
749 | 761 |
750 // Gets the program info for the given program. Returns NULL if none exists. | 762 // Gets the program info for the given program. Returns NULL if none exists. |
751 ProgramManager::ProgramInfo* GetProgramInfo(GLuint client_id) { | 763 ProgramManager::ProgramInfo* GetProgramInfo(GLuint client_id) { |
752 return program_manager()->GetProgramInfo(client_id); | 764 return program_manager()->GetProgramInfo(client_id); |
753 } | 765 } |
(...skipping 2502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3256 bool have_stencil = BoundFramebufferHasStencilAttachment(); | 3268 bool have_stencil = BoundFramebufferHasStencilAttachment(); |
3257 glStencilMaskSeparate(GL_FRONT, have_stencil ? mask_stencil_front_ : 0); | 3269 glStencilMaskSeparate(GL_FRONT, have_stencil ? mask_stencil_front_ : 0); |
3258 glStencilMaskSeparate(GL_BACK, have_stencil ? mask_stencil_back_ : 0); | 3270 glStencilMaskSeparate(GL_BACK, have_stencil ? mask_stencil_back_ : 0); |
3259 EnableDisable(GL_STENCIL_TEST, enable_stencil_test_ && have_stencil); | 3271 EnableDisable(GL_STENCIL_TEST, enable_stencil_test_ && have_stencil); |
3260 EnableDisable(GL_CULL_FACE, enable_cull_face_); | 3272 EnableDisable(GL_CULL_FACE, enable_cull_face_); |
3261 EnableDisable(GL_SCISSOR_TEST, enable_scissor_test_); | 3273 EnableDisable(GL_SCISSOR_TEST, enable_scissor_test_); |
3262 state_dirty_ = false; | 3274 state_dirty_ = false; |
3263 } | 3275 } |
3264 } | 3276 } |
3265 | 3277 |
| 3278 void GLES2DecoderImpl::BindAndApplyTextureParameters( |
| 3279 TextureManager::TextureInfo* info) { |
| 3280 glBindTexture(info->target(), info->service_id()); |
| 3281 glTexParameteri(info->target(), GL_TEXTURE_MIN_FILTER, info->min_filter()); |
| 3282 glTexParameteri(info->target(), GL_TEXTURE_MAG_FILTER, info->mag_filter()); |
| 3283 glTexParameteri(info->target(), GL_TEXTURE_WRAP_S, info->wrap_s()); |
| 3284 glTexParameteri(info->target(), GL_TEXTURE_WRAP_T, info->wrap_t()); |
| 3285 } |
| 3286 |
3266 GLuint GLES2DecoderImpl::GetBackbufferServiceId() { | 3287 GLuint GLES2DecoderImpl::GetBackbufferServiceId() { |
3267 return (offscreen_target_frame_buffer_.get()) ? | 3288 return (offscreen_target_frame_buffer_.get()) ? |
3268 offscreen_target_frame_buffer_->id() : | 3289 offscreen_target_frame_buffer_->id() : |
3269 surface_->GetBackingFrameBufferObject(); | 3290 surface_->GetBackingFrameBufferObject(); |
3270 } | 3291 } |
3271 | 3292 |
3272 void GLES2DecoderImpl::DoBindFramebuffer(GLenum target, GLuint client_id) { | 3293 void GLES2DecoderImpl::DoBindFramebuffer(GLenum target, GLuint client_id) { |
3273 FramebufferManager::FramebufferInfo* info = NULL; | 3294 FramebufferManager::FramebufferInfo* info = NULL; |
3274 GLuint service_id = 0; | 3295 GLuint service_id = 0; |
3275 if (client_id != 0) { | 3296 if (client_id != 0) { |
(...skipping 5219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8495 texture_manager()->SetLevelInfo( | 8516 texture_manager()->SetLevelInfo( |
8496 info, target, 0, format, level_width, level_height, 1, 0, format, | 8517 info, target, 0, format, level_width, level_height, 1, 0, format, |
8497 type, false); | 8518 type, false); |
8498 level_width = std::max(1, level_width >> 1); | 8519 level_width = std::max(1, level_width >> 1); |
8499 level_height = std::max(1, level_height >> 1); | 8520 level_height = std::max(1, level_height >> 1); |
8500 } | 8521 } |
8501 info->SetImmutable(true); | 8522 info->SetImmutable(true); |
8502 } | 8523 } |
8503 } | 8524 } |
8504 | 8525 |
| 8526 error::Error GLES2DecoderImpl::HandleGenMailboxCHROMIUM( |
| 8527 uint32 immediate_data_size, const gles2::GenMailboxCHROMIUM& c) { |
| 8528 MailboxName name; |
| 8529 mailbox_manager()->GenerateMailboxName(&name); |
| 8530 uint32 bucket_id = static_cast<uint32>(c.bucket_id); |
| 8531 Bucket* bucket = CreateBucket(bucket_id); |
| 8532 |
| 8533 bucket->SetSize(GL_MAILBOX_SIZE_CHROMIUM); |
| 8534 bucket->SetData(&name, 0, GL_MAILBOX_SIZE_CHROMIUM); |
| 8535 |
| 8536 return error::kNoError; |
| 8537 } |
| 8538 |
| 8539 void GLES2DecoderImpl::DoProduceTextureCHROMIUM(GLenum target, |
| 8540 const GLbyte* mailbox) { |
| 8541 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); |
| 8542 if (!info) { |
| 8543 SetGLError(GL_INVALID_OPERATION, |
| 8544 "glProduceTextureCHROMIUM: unknown texture for target"); |
| 8545 return; |
| 8546 } |
| 8547 |
| 8548 TextureDefinition* definition = texture_manager()->Save(info); |
| 8549 if (!definition) { |
| 8550 SetGLError(GL_INVALID_OPERATION, |
| 8551 "glProduceTextureCHROMIUM: invalid texture"); |
| 8552 return; |
| 8553 } |
| 8554 |
| 8555 if (!group_->mailbox_manager()->ProduceTexture( |
| 8556 target, |
| 8557 *reinterpret_cast<const MailboxName*>(mailbox), |
| 8558 definition, |
| 8559 texture_manager())) { |
| 8560 bool success = texture_manager()->Restore(info, definition); |
| 8561 DCHECK(success); |
| 8562 SetGLError(GL_INVALID_OPERATION, |
| 8563 "glProduceTextureCHROMIUM: invalid mailbox name"); |
| 8564 return; |
| 8565 } |
| 8566 |
| 8567 BindAndApplyTextureParameters(info); |
| 8568 } |
| 8569 |
| 8570 void GLES2DecoderImpl::DoConsumeTextureCHROMIUM(GLenum target, |
| 8571 const GLbyte* mailbox) { |
| 8572 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); |
| 8573 if (!info) { |
| 8574 SetGLError(GL_INVALID_OPERATION, |
| 8575 "glConsumeTextureCHROMIUM: unknown texture for target"); |
| 8576 return; |
| 8577 } |
| 8578 |
| 8579 scoped_ptr<TextureDefinition> definition( |
| 8580 group_->mailbox_manager()->ConsumeTexture( |
| 8581 target, |
| 8582 *reinterpret_cast<const MailboxName*>(mailbox))); |
| 8583 if (!definition.get()) { |
| 8584 SetGLError(GL_INVALID_OPERATION, |
| 8585 "glConsumeTextureCHROMIUM: invalid mailbox name"); |
| 8586 return; |
| 8587 } |
| 8588 |
| 8589 if (!texture_manager()->Restore(info, definition.release())) { |
| 8590 SetGLError(GL_INVALID_OPERATION, |
| 8591 "glConsumeTextureCHROMIUM: invalid texture"); |
| 8592 return; |
| 8593 } |
| 8594 |
| 8595 BindAndApplyTextureParameters(info); |
| 8596 } |
| 8597 |
8505 // Include the auto-generated part of this file. We split this because it means | 8598 // Include the auto-generated part of this file. We split this because it means |
8506 // we can easily edit the non-auto generated parts right here in this file | 8599 // we can easily edit the non-auto generated parts right here in this file |
8507 // instead of having to edit some template or the code generator. | 8600 // instead of having to edit some template or the code generator. |
8508 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 8601 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
8509 | 8602 |
8510 } // namespace gles2 | 8603 } // namespace gles2 |
8511 } // namespace gpu | 8604 } // namespace gpu |
OLD | NEW |