| 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 20 matching lines...) Expand all Loading... |
| 31 #include "gpu/command_buffer/common/id_allocator.h" | 31 #include "gpu/command_buffer/common/id_allocator.h" |
| 32 #include "gpu/command_buffer/service/buffer_manager.h" | 32 #include "gpu/command_buffer/service/buffer_manager.h" |
| 33 #include "gpu/command_buffer/service/cmd_buffer_engine.h" | 33 #include "gpu/command_buffer/service/cmd_buffer_engine.h" |
| 34 #include "gpu/command_buffer/service/context_group.h" | 34 #include "gpu/command_buffer/service/context_group.h" |
| 35 #include "gpu/command_buffer/service/feature_info.h" | 35 #include "gpu/command_buffer/service/feature_info.h" |
| 36 #include "gpu/command_buffer/service/framebuffer_manager.h" | 36 #include "gpu/command_buffer/service/framebuffer_manager.h" |
| 37 #include "gpu/command_buffer/service/gl_utils.h" | 37 #include "gpu/command_buffer/service/gl_utils.h" |
| 38 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h" | 38 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h" |
| 39 #include "gpu/command_buffer/service/gles2_cmd_validation.h" | 39 #include "gpu/command_buffer/service/gles2_cmd_validation.h" |
| 40 #include "gpu/command_buffer/service/gpu_switches.h" | 40 #include "gpu/command_buffer/service/gpu_switches.h" |
| 41 #include "gpu/command_buffer/service/image_manager.h" |
| 41 #include "gpu/command_buffer/service/mailbox_manager.h" | 42 #include "gpu/command_buffer/service/mailbox_manager.h" |
| 42 #include "gpu/command_buffer/service/memory_tracking.h" | 43 #include "gpu/command_buffer/service/memory_tracking.h" |
| 43 #include "gpu/command_buffer/service/program_manager.h" | 44 #include "gpu/command_buffer/service/program_manager.h" |
| 44 #include "gpu/command_buffer/service/query_manager.h" | 45 #include "gpu/command_buffer/service/query_manager.h" |
| 45 #include "gpu/command_buffer/service/renderbuffer_manager.h" | 46 #include "gpu/command_buffer/service/renderbuffer_manager.h" |
| 46 #include "gpu/command_buffer/service/shader_manager.h" | 47 #include "gpu/command_buffer/service/shader_manager.h" |
| 47 #include "gpu/command_buffer/service/shader_translator.h" | 48 #include "gpu/command_buffer/service/shader_translator.h" |
| 48 #include "gpu/command_buffer/service/shader_translator_cache.h" | 49 #include "gpu/command_buffer/service/shader_translator_cache.h" |
| 49 #include "gpu/command_buffer/service/stream_texture.h" | 50 #include "gpu/command_buffer/service/stream_texture.h" |
| 50 #include "gpu/command_buffer/service/stream_texture_manager.h" | 51 #include "gpu/command_buffer/service/stream_texture_manager.h" |
| 51 #include "gpu/command_buffer/service/texture_definition.h" | 52 #include "gpu/command_buffer/service/texture_definition.h" |
| 52 #include "gpu/command_buffer/service/texture_manager.h" | 53 #include "gpu/command_buffer/service/texture_manager.h" |
| 53 #include "gpu/command_buffer/service/vertex_attrib_manager.h" | 54 #include "gpu/command_buffer/service/vertex_attrib_manager.h" |
| 54 #include "gpu/command_buffer/service/vertex_array_manager.h" | 55 #include "gpu/command_buffer/service/vertex_array_manager.h" |
| 55 #include "ui/gl/gl_context.h" | 56 #include "ui/gl/gl_context.h" |
| 57 #include "ui/gl/gl_image.h" |
| 56 #include "ui/gl/gl_implementation.h" | 58 #include "ui/gl/gl_implementation.h" |
| 57 #include "ui/gl/gl_surface.h" | 59 #include "ui/gl/gl_surface.h" |
| 58 #if defined(OS_MACOSX) | 60 #if defined(OS_MACOSX) |
| 59 #include "ui/surface/io_surface_support_mac.h" | 61 #include "ui/surface/io_surface_support_mac.h" |
| 60 #endif | 62 #endif |
| 61 | 63 |
| 62 #if !defined(GL_DEPTH24_STENCIL8) | 64 #if !defined(GL_DEPTH24_STENCIL8) |
| 63 #define GL_DEPTH24_STENCIL8 0x88F0 | 65 #define GL_DEPTH24_STENCIL8 0x88F0 |
| 64 #endif | 66 #endif |
| 65 | 67 |
| (...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 661 } | 663 } |
| 662 | 664 |
| 663 TextureManager* texture_manager() { | 665 TextureManager* texture_manager() { |
| 664 return group_->texture_manager(); | 666 return group_->texture_manager(); |
| 665 } | 667 } |
| 666 | 668 |
| 667 MailboxManager* mailbox_manager() { | 669 MailboxManager* mailbox_manager() { |
| 668 return group_->mailbox_manager(); | 670 return group_->mailbox_manager(); |
| 669 } | 671 } |
| 670 | 672 |
| 673 ImageManager* image_manager() { |
| 674 return group_->image_manager(); |
| 675 } |
| 676 |
| 671 VertexArrayManager* vertex_array_manager() { | 677 VertexArrayManager* vertex_array_manager() { |
| 672 return vertex_array_manager_.get(); | 678 return vertex_array_manager_.get(); |
| 673 } | 679 } |
| 674 | 680 |
| 675 bool IsOffscreenBufferMultisampled() const { | 681 bool IsOffscreenBufferMultisampled() const { |
| 676 return offscreen_target_samples_ > 1; | 682 return offscreen_target_samples_ > 1; |
| 677 } | 683 } |
| 678 | 684 |
| 679 // Creates a TextureInfo for the given texture. | 685 // Creates a TextureInfo for the given texture. |
| 680 TextureManager::TextureInfo* CreateTextureInfo( | 686 TextureManager::TextureInfo* CreateTextureInfo( |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 792 void DoTexStorage2DEXT( | 798 void DoTexStorage2DEXT( |
| 793 GLenum target, | 799 GLenum target, |
| 794 GLint levels, | 800 GLint levels, |
| 795 GLenum internal_format, | 801 GLenum internal_format, |
| 796 GLsizei width, | 802 GLsizei width, |
| 797 GLsizei height); | 803 GLsizei height); |
| 798 | 804 |
| 799 void DoProduceTextureCHROMIUM(GLenum target, const GLbyte* key); | 805 void DoProduceTextureCHROMIUM(GLenum target, const GLbyte* key); |
| 800 void DoConsumeTextureCHROMIUM(GLenum target, const GLbyte* key); | 806 void DoConsumeTextureCHROMIUM(GLenum target, const GLbyte* key); |
| 801 | 807 |
| 808 void DoBindTexImage2DCHROMIUM( |
| 809 GLenum target, |
| 810 GLint image_id); |
| 811 void DoReleaseTexImage2DCHROMIUM( |
| 812 GLenum target, |
| 813 GLint image_id); |
| 814 |
| 802 // Creates a ProgramInfo for the given program. | 815 // Creates a ProgramInfo for the given program. |
| 803 ProgramManager::ProgramInfo* CreateProgramInfo( | 816 ProgramManager::ProgramInfo* CreateProgramInfo( |
| 804 GLuint client_id, GLuint service_id) { | 817 GLuint client_id, GLuint service_id) { |
| 805 return program_manager()->CreateProgramInfo(client_id, service_id); | 818 return program_manager()->CreateProgramInfo(client_id, service_id); |
| 806 } | 819 } |
| 807 | 820 |
| 808 // Gets the program info for the given program. Returns NULL if none exists. | 821 // Gets the program info for the given program. Returns NULL if none exists. |
| 809 ProgramManager::ProgramInfo* GetProgramInfo(GLuint client_id) { | 822 ProgramManager::ProgramInfo* GetProgramInfo(GLuint client_id) { |
| 810 return program_manager()->GetProgramInfo(client_id); | 823 return program_manager()->GetProgramInfo(client_id); |
| 811 } | 824 } |
| (...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1313 case GL_TEXTURE_RECTANGLE_ARB: | 1326 case GL_TEXTURE_RECTANGLE_ARB: |
| 1314 info = unit.bound_texture_rectangle_arb; | 1327 info = unit.bound_texture_rectangle_arb; |
| 1315 break; | 1328 break; |
| 1316 default: | 1329 default: |
| 1317 NOTREACHED(); | 1330 NOTREACHED(); |
| 1318 return NULL; | 1331 return NULL; |
| 1319 } | 1332 } |
| 1320 return info; | 1333 return info; |
| 1321 } | 1334 } |
| 1322 | 1335 |
| 1336 TextureManager::TextureInfo* GetTextureInfoForTargetUnlessDefault( |
| 1337 GLenum target) { |
| 1338 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); |
| 1339 if (!info) |
| 1340 return NULL; |
| 1341 if (info == texture_manager()->GetDefaultTextureInfo(target)) |
| 1342 return NULL; |
| 1343 return info; |
| 1344 } |
| 1345 |
| 1323 GLenum GetBindTargetForSamplerType(GLenum type) { | 1346 GLenum GetBindTargetForSamplerType(GLenum type) { |
| 1324 DCHECK(type == GL_SAMPLER_2D || type == GL_SAMPLER_CUBE || | 1347 DCHECK(type == GL_SAMPLER_2D || type == GL_SAMPLER_CUBE || |
| 1325 type == GL_SAMPLER_EXTERNAL_OES || type == GL_SAMPLER_2D_RECT_ARB); | 1348 type == GL_SAMPLER_EXTERNAL_OES || type == GL_SAMPLER_2D_RECT_ARB); |
| 1326 switch (type) { | 1349 switch (type) { |
| 1327 case GL_SAMPLER_2D: | 1350 case GL_SAMPLER_2D: |
| 1328 return GL_TEXTURE_2D; | 1351 return GL_TEXTURE_2D; |
| 1329 case GL_SAMPLER_CUBE: | 1352 case GL_SAMPLER_CUBE: |
| 1330 return GL_TEXTURE_CUBE_MAP; | 1353 return GL_TEXTURE_CUBE_MAP; |
| 1331 case GL_SAMPLER_EXTERNAL_OES: | 1354 case GL_SAMPLER_EXTERNAL_OES: |
| 1332 return GL_TEXTURE_EXTERNAL_OES; | 1355 return GL_TEXTURE_EXTERNAL_OES; |
| (...skipping 7690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9023 // support for binding an IOSurface to a NPOT TEXTURE_2D texture, we | 9046 // support for binding an IOSurface to a NPOT TEXTURE_2D texture, we |
| 9024 // could delete a lot of code. For now, perform strict validation so we | 9047 // could delete a lot of code. For now, perform strict validation so we |
| 9025 // know what's going on. | 9048 // know what's going on. |
| 9026 SetGLError( | 9049 SetGLError( |
| 9027 GL_INVALID_OPERATION, | 9050 GL_INVALID_OPERATION, |
| 9028 "glTexImageIOSurface2DCHROMIUM", | 9051 "glTexImageIOSurface2DCHROMIUM", |
| 9029 "requires TEXTURE_RECTANGLE_ARB target"); | 9052 "requires TEXTURE_RECTANGLE_ARB target"); |
| 9030 return; | 9053 return; |
| 9031 } | 9054 } |
| 9032 | 9055 |
| 9033 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); | 9056 // Default target might be conceptually valid, but disallow it to avoid |
| 9057 // accidents. |
| 9058 TextureManager::TextureInfo* info = GetTextureInfoForTargetUnlessDefault( |
| 9059 target); |
| 9034 if (!info) { | 9060 if (!info) { |
| 9035 SetGLError(GL_INVALID_OPERATION, | 9061 SetGLError(GL_INVALID_OPERATION, |
| 9036 "glTexImageIOSurface2DCHROMIUM", "no rectangle texture bound"); | 9062 "glTexImageIOSurface2DCHROMIUM", "no rectangle texture bound"); |
| 9037 return; | 9063 return; |
| 9038 } | 9064 } |
| 9039 if (info == texture_manager()->GetDefaultTextureInfo(target)) { | |
| 9040 // Maybe this is conceptually valid, but disallow it to avoid accidents. | |
| 9041 SetGLError(GL_INVALID_OPERATION, | |
| 9042 "glTexImageIOSurface2DCHROMIUM", "can't bind default texture"); | |
| 9043 return; | |
| 9044 } | |
| 9045 | 9065 |
| 9046 // Look up the new IOSurface. Note that because of asynchrony | 9066 // Look up the new IOSurface. Note that because of asynchrony |
| 9047 // between processes this might fail; during live resizing the | 9067 // between processes this might fail; during live resizing the |
| 9048 // plugin process might allocate and release an IOSurface before | 9068 // plugin process might allocate and release an IOSurface before |
| 9049 // this process gets a chance to look it up. Hold on to any old | 9069 // this process gets a chance to look it up. Hold on to any old |
| 9050 // IOSurface in this case. | 9070 // IOSurface in this case. |
| 9051 CFTypeRef surface = surface_support->IOSurfaceLookup(io_surface_id); | 9071 CFTypeRef surface = surface_support->IOSurfaceLookup(io_surface_id); |
| 9052 if (!surface) { | 9072 if (!surface) { |
| 9053 SetGLError( | 9073 SetGLError( |
| 9054 GL_INVALID_OPERATION, | 9074 GL_INVALID_OPERATION, |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9432 marker = ""; | 9452 marker = ""; |
| 9433 } | 9453 } |
| 9434 debug_marker_manager_.PushGroup( | 9454 debug_marker_manager_.PushGroup( |
| 9435 length ? std::string(marker, length) : std::string(marker)); | 9455 length ? std::string(marker, length) : std::string(marker)); |
| 9436 } | 9456 } |
| 9437 | 9457 |
| 9438 void GLES2DecoderImpl::DoPopGroupMarkerEXT(void) { | 9458 void GLES2DecoderImpl::DoPopGroupMarkerEXT(void) { |
| 9439 debug_marker_manager_.PopGroup(); | 9459 debug_marker_manager_.PopGroup(); |
| 9440 } | 9460 } |
| 9441 | 9461 |
| 9462 void GLES2DecoderImpl::DoBindTexImage2DCHROMIUM( |
| 9463 GLenum target, GLint image_id) { |
| 9464 if (target != GL_TEXTURE_2D) { |
| 9465 // This might be supported in the future. |
| 9466 SetGLError( |
| 9467 GL_INVALID_OPERATION, |
| 9468 "glBindTexImage2DCHROMIUM", "requires TEXTURE_2D target"); |
| 9469 return; |
| 9470 } |
| 9471 |
| 9472 // Default target might be conceptually valid, but disallow it to avoid |
| 9473 // accidents. |
| 9474 TextureManager::TextureInfo* info = GetTextureInfoForTargetUnlessDefault( |
| 9475 target); |
| 9476 if (!info) { |
| 9477 SetGLError(GL_INVALID_OPERATION, |
| 9478 "glBindTexImage2DCHROMIUM", "no texture bound"); |
| 9479 return; |
| 9480 } |
| 9481 |
| 9482 scoped_refptr<gfx::GLImage> gl_image = |
| 9483 image_manager()->LookupImage(image_id); |
| 9484 if (!gl_image) { |
| 9485 SetGLError(GL_INVALID_OPERATION, |
| 9486 "glBindTexImage2DCHROMIUM", |
| 9487 "no image found with the given ID"); |
| 9488 return; |
| 9489 } |
| 9490 |
| 9491 if (!gl_image->BindTexImage()) { |
| 9492 SetGLError(GL_INVALID_OPERATION, |
| 9493 "glBindTexImage2DCHROMIUM", |
| 9494 "fail to bind image with the given ID"); |
| 9495 return; |
| 9496 } |
| 9497 |
| 9498 gfx::Size size = gl_image->GetSize(); |
| 9499 texture_manager()->SetLevelInfo( |
| 9500 info, target, 0, GL_RGBA, size.width(), size.height(), 1, 0, |
| 9501 GL_RGBA, GL_UNSIGNED_BYTE, true); |
| 9502 texture_manager()->SetLevelImage(info, target, 0, gl_image); |
| 9503 } |
| 9504 |
| 9505 void GLES2DecoderImpl::DoReleaseTexImage2DCHROMIUM( |
| 9506 GLenum target, GLint image_id) { |
| 9507 if (target != GL_TEXTURE_2D) { |
| 9508 // This might be supported in the future. |
| 9509 SetGLError( |
| 9510 GL_INVALID_OPERATION, |
| 9511 "glReleaseTexImage2DCHROMIUM", "requires TEXTURE_2D target"); |
| 9512 return; |
| 9513 } |
| 9514 |
| 9515 // Default target might be conceptually valid, but disallow it to avoid |
| 9516 // accidents. |
| 9517 TextureManager::TextureInfo* info = GetTextureInfoForTargetUnlessDefault( |
| 9518 target); |
| 9519 if (!info) { |
| 9520 SetGLError(GL_INVALID_OPERATION, |
| 9521 "glReleaseTexImage2DCHROMIUM", "no texture bound"); |
| 9522 return; |
| 9523 } |
| 9524 |
| 9525 scoped_refptr<gfx::GLImage> gl_image = |
| 9526 image_manager()->LookupImage(image_id); |
| 9527 if (!gl_image) { |
| 9528 SetGLError(GL_INVALID_OPERATION, |
| 9529 "glReleaseTexImage2DCHROMIUM", |
| 9530 "no image found with the given ID"); |
| 9531 return; |
| 9532 } |
| 9533 |
| 9534 // Do nothing when image is not currently bound. |
| 9535 if (info->GetLevelImage(target, 0) != gl_image) |
| 9536 return; |
| 9537 |
| 9538 gl_image->ReleaseTexImage(); |
| 9539 |
| 9540 texture_manager()->SetLevelInfo( |
| 9541 info, target, 0, GL_RGBA, 0, 0, 1, 0, |
| 9542 GL_RGBA, GL_UNSIGNED_BYTE, false); |
| 9543 } |
| 9442 | 9544 |
| 9443 // Include the auto-generated part of this file. We split this because it means | 9545 // Include the auto-generated part of this file. We split this because it means |
| 9444 // we can easily edit the non-auto generated parts right here in this file | 9546 // we can easily edit the non-auto generated parts right here in this file |
| 9445 // instead of having to edit some template or the code generator. | 9547 // instead of having to edit some template or the code generator. |
| 9446 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 9548 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 9447 | 9549 |
| 9448 } // namespace gles2 | 9550 } // namespace gles2 |
| 9449 } // namespace gpu | 9551 } // namespace gpu |
| OLD | NEW |