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 949 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
960 GLenum internal_format, | 960 GLenum internal_format, |
961 GLsizei width, | 961 GLsizei width, |
962 GLsizei height); | 962 GLsizei height); |
963 | 963 |
964 void DoProduceTextureCHROMIUM(GLenum target, const GLbyte* key); | 964 void DoProduceTextureCHROMIUM(GLenum target, const GLbyte* key); |
965 void DoProduceTextureDirectCHROMIUM(GLuint texture, GLenum target, | 965 void DoProduceTextureDirectCHROMIUM(GLuint texture, GLenum target, |
966 const GLbyte* key); | 966 const GLbyte* key); |
967 void ProduceTextureRef(std::string func_name, TextureRef* texture_ref, | 967 void ProduceTextureRef(std::string func_name, TextureRef* texture_ref, |
968 GLenum target, const GLbyte* data); | 968 GLenum target, const GLbyte* data); |
969 | 969 |
970 void EnsureTextureForClientId(GLuint client_id); | |
970 void DoConsumeTextureCHROMIUM(GLenum target, const GLbyte* key); | 971 void DoConsumeTextureCHROMIUM(GLenum target, const GLbyte* key); |
971 void DoCreateAndConsumeTextureCHROMIUM(GLenum target, const GLbyte* key, | 972 void DoCreateAndConsumeTextureCHROMIUM(GLenum target, const GLbyte* key, |
972 GLuint client_id); | 973 GLuint client_id); |
973 | 974 |
974 bool DoIsValuebufferCHROMIUM(GLuint client_id); | 975 bool DoIsValuebufferCHROMIUM(GLuint client_id); |
975 void DoBindValueBufferCHROMIUM(GLenum target, GLuint valuebuffer); | 976 void DoBindValueBufferCHROMIUM(GLenum target, GLuint valuebuffer); |
976 void DoSubscribeValueCHROMIUM(GLenum target, GLenum subscription); | 977 void DoSubscribeValueCHROMIUM(GLenum target, GLenum subscription); |
977 void DoPopulateSubscribedValuesCHROMIUM(GLenum target); | 978 void DoPopulateSubscribedValuesCHROMIUM(GLenum target); |
978 void DoUniformValueBufferCHROMIUM(GLint location, | 979 void DoUniformValueBufferCHROMIUM(GLint location, |
979 GLenum target, | 980 GLenum target, |
(...skipping 10692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
11672 break; | 11673 break; |
11673 case GL_TEXTURE_RECTANGLE_ARB: | 11674 case GL_TEXTURE_RECTANGLE_ARB: |
11674 unit.bound_texture_rectangle_arb = texture_ref; | 11675 unit.bound_texture_rectangle_arb = texture_ref; |
11675 break; | 11676 break; |
11676 default: | 11677 default: |
11677 NOTREACHED(); // Validation should prevent us getting here. | 11678 NOTREACHED(); // Validation should prevent us getting here. |
11678 break; | 11679 break; |
11679 } | 11680 } |
11680 } | 11681 } |
11681 | 11682 |
11683 void GLES2DecoderImpl::EnsureTextureForClientId(GLuint client_id) { | |
11684 TextureRef* texture_ref = GetTexture(client_id); | |
11685 if (!texture_ref) { | |
11686 GLuint service_id; | |
11687 glGenTextures(1, &service_id); | |
11688 DCHECK_NE(0u, service_id); | |
11689 CreateTexture(client_id, service_id); | |
piman
2015/04/03 18:17:14
I think we also want to do the texture_manager()->
| |
11690 } | |
11691 } | |
11692 | |
11693 // If CreateAndConsumeTexture fails we still need to ensure that the client_id | |
11694 // provided is associated with a service_id/TextureRef for consistency, even if | |
11695 // the resulting texture is incomplete. | |
11682 error::Error GLES2DecoderImpl::HandleCreateAndConsumeTextureCHROMIUMImmediate( | 11696 error::Error GLES2DecoderImpl::HandleCreateAndConsumeTextureCHROMIUMImmediate( |
11683 uint32_t immediate_data_size, | 11697 uint32_t immediate_data_size, |
11684 const void* cmd_data) { | 11698 const void* cmd_data) { |
11685 const gles2::cmds::CreateAndConsumeTextureCHROMIUMImmediate& c = | 11699 const gles2::cmds::CreateAndConsumeTextureCHROMIUMImmediate& c = |
11686 *static_cast< | 11700 *static_cast< |
11687 const gles2::cmds::CreateAndConsumeTextureCHROMIUMImmediate*>( | 11701 const gles2::cmds::CreateAndConsumeTextureCHROMIUMImmediate*>( |
11688 cmd_data); | 11702 cmd_data); |
11689 GLenum target = static_cast<GLenum>(c.target); | 11703 GLenum target = static_cast<GLenum>(c.target); |
11704 uint32_t client_id = c.client_id; | |
11690 uint32_t data_size; | 11705 uint32_t data_size; |
11691 if (!ComputeDataSize(1, sizeof(GLbyte), 64, &data_size)) { | 11706 if (!ComputeDataSize(1, sizeof(GLbyte), 64, &data_size)) { |
11707 EnsureTextureForClientId(client_id); | |
piman
2015/04/03 18:17:14
I think it's ok to skip here. We're losing the con
| |
11692 return error::kOutOfBounds; | 11708 return error::kOutOfBounds; |
11693 } | 11709 } |
11694 if (data_size > immediate_data_size) { | 11710 if (data_size > immediate_data_size) { |
11711 EnsureTextureForClientId(client_id); | |
piman
2015/04/03 18:17:15
Here too.
| |
11695 return error::kOutOfBounds; | 11712 return error::kOutOfBounds; |
11696 } | 11713 } |
11697 const GLbyte* mailbox = | 11714 const GLbyte* mailbox = |
11698 GetImmediateDataAs<const GLbyte*>(c, data_size, immediate_data_size); | 11715 GetImmediateDataAs<const GLbyte*>(c, data_size, immediate_data_size); |
11699 if (!validators_->texture_bind_target.IsValid(target)) { | 11716 if (!validators_->texture_bind_target.IsValid(target)) { |
11717 EnsureTextureForClientId(client_id); | |
piman
2015/04/03 18:17:14
Here too. Because we don't have a valid target, af
| |
11700 LOCAL_SET_GL_ERROR_INVALID_ENUM( | 11718 LOCAL_SET_GL_ERROR_INVALID_ENUM( |
11701 "glCreateAndConsumeTextureCHROMIUM", target, "target"); | 11719 "glCreateAndConsumeTextureCHROMIUM", target, "target"); |
11702 return error::kNoError; | 11720 return error::kNoError; |
11703 } | 11721 } |
11704 if (mailbox == NULL) { | 11722 if (mailbox == NULL) { |
11723 EnsureTextureForClientId(client_id); | |
piman
2015/04/03 18:17:14
Here too.
| |
11705 return error::kOutOfBounds; | 11724 return error::kOutOfBounds; |
11706 } | 11725 } |
11707 uint32_t client_id = c.client_id; | |
11708 DoCreateAndConsumeTextureCHROMIUM(target, mailbox, client_id); | 11726 DoCreateAndConsumeTextureCHROMIUM(target, mailbox, client_id); |
11709 return error::kNoError; | 11727 return error::kNoError; |
11710 } | 11728 } |
11711 | 11729 |
11712 void GLES2DecoderImpl::DoCreateAndConsumeTextureCHROMIUM(GLenum target, | 11730 void GLES2DecoderImpl::DoCreateAndConsumeTextureCHROMIUM(GLenum target, |
11713 const GLbyte* data, GLuint client_id) { | 11731 const GLbyte* data, GLuint client_id) { |
11714 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoCreateAndConsumeTextureCHROMIUM", | 11732 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoCreateAndConsumeTextureCHROMIUM", |
11715 "context", logger_.GetLogPrefix(), | 11733 "context", logger_.GetLogPrefix(), |
11716 "mailbox[0]", static_cast<unsigned char>(data[0])); | 11734 "mailbox[0]", static_cast<unsigned char>(data[0])); |
11717 const Mailbox& mailbox = *reinterpret_cast<const Mailbox*>(data); | 11735 const Mailbox& mailbox = *reinterpret_cast<const Mailbox*>(data); |
11718 DLOG_IF(ERROR, !mailbox.Verify()) << "CreateAndConsumeTextureCHROMIUM was " | 11736 DLOG_IF(ERROR, !mailbox.Verify()) << "CreateAndConsumeTextureCHROMIUM was " |
11719 "passed a mailbox that was not " | 11737 "passed a mailbox that was not " |
11720 "generated by GenMailboxCHROMIUM."; | 11738 "generated by GenMailboxCHROMIUM."; |
11721 | 11739 |
11722 TextureRef* texture_ref = GetTexture(client_id); | 11740 TextureRef* texture_ref = GetTexture(client_id); |
11723 if (texture_ref) { | 11741 if (texture_ref) { |
11742 // No need to call EnsureTextureForClientId here, the client_id already has | |
11743 // an associated texture. | |
11724 LOCAL_SET_GL_ERROR( | 11744 LOCAL_SET_GL_ERROR( |
11725 GL_INVALID_OPERATION, | 11745 GL_INVALID_OPERATION, |
11726 "glCreateAndConsumeTextureCHROMIUM", "client id already in use"); | 11746 "glCreateAndConsumeTextureCHROMIUM", "client id already in use"); |
11727 return; | 11747 return; |
11728 } | 11748 } |
11729 Texture* texture = group_->mailbox_manager()->ConsumeTexture(mailbox); | 11749 Texture* texture = group_->mailbox_manager()->ConsumeTexture(mailbox); |
11730 if (!texture) { | 11750 if (!texture) { |
11751 EnsureTextureForClientId(client_id); | |
11731 LOCAL_SET_GL_ERROR( | 11752 LOCAL_SET_GL_ERROR( |
11732 GL_INVALID_OPERATION, | 11753 GL_INVALID_OPERATION, |
11733 "glCreateAndConsumeTextureCHROMIUM", "invalid mailbox name"); | 11754 "glCreateAndConsumeTextureCHROMIUM", "invalid mailbox name"); |
11734 return; | 11755 return; |
11735 } | 11756 } |
11757 | |
11736 if (texture->target() != target) { | 11758 if (texture->target() != target) { |
11759 EnsureTextureForClientId(client_id); | |
11737 LOCAL_SET_GL_ERROR( | 11760 LOCAL_SET_GL_ERROR( |
11738 GL_INVALID_OPERATION, | 11761 GL_INVALID_OPERATION, |
11739 "glCreateAndConsumeTextureCHROMIUM", "invalid target"); | 11762 "glCreateAndConsumeTextureCHROMIUM", "invalid target"); |
11740 return; | 11763 return; |
11741 } | 11764 } |
11742 | 11765 |
11743 texture_ref = texture_manager()->Consume(client_id, texture); | 11766 texture_ref = texture_manager()->Consume(client_id, texture); |
11744 } | 11767 } |
11745 | 11768 |
11746 bool GLES2DecoderImpl::DoIsValuebufferCHROMIUM(GLuint client_id) { | 11769 bool GLES2DecoderImpl::DoIsValuebufferCHROMIUM(GLuint client_id) { |
(...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
12543 } | 12566 } |
12544 } | 12567 } |
12545 | 12568 |
12546 // Include the auto-generated part of this file. We split this because it means | 12569 // Include the auto-generated part of this file. We split this because it means |
12547 // we can easily edit the non-auto generated parts right here in this file | 12570 // we can easily edit the non-auto generated parts right here in this file |
12548 // instead of having to edit some template or the code generator. | 12571 // instead of having to edit some template or the code generator. |
12549 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 12572 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
12550 | 12573 |
12551 } // namespace gles2 | 12574 } // namespace gles2 |
12552 } // namespace gpu | 12575 } // namespace gpu |
OLD | NEW |