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