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 2376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2387 | 2387 |
2388 state_.texture_units.resize(group_->max_texture_units()); | 2388 state_.texture_units.resize(group_->max_texture_units()); |
2389 for (uint32 tt = 0; tt < state_.texture_units.size(); ++tt) { | 2389 for (uint32 tt = 0; tt < state_.texture_units.size(); ++tt) { |
2390 glActiveTexture(GL_TEXTURE0 + tt); | 2390 glActiveTexture(GL_TEXTURE0 + tt); |
2391 // We want the last bind to be 2D. | 2391 // We want the last bind to be 2D. |
2392 TextureRef* ref; | 2392 TextureRef* ref; |
2393 if (features().oes_egl_image_external) { | 2393 if (features().oes_egl_image_external) { |
2394 ref = texture_manager()->GetDefaultTextureInfo( | 2394 ref = texture_manager()->GetDefaultTextureInfo( |
2395 GL_TEXTURE_EXTERNAL_OES); | 2395 GL_TEXTURE_EXTERNAL_OES); |
2396 state_.texture_units[tt].bound_texture_external_oes = ref; | 2396 state_.texture_units[tt].bound_texture_external_oes = ref; |
2397 glBindTexture(GL_TEXTURE_EXTERNAL_OES, ref->service_id()); | 2397 glBindTexture(GL_TEXTURE_EXTERNAL_OES, ref ? ref->service_id() : 0); |
2398 } | 2398 } |
2399 if (features().arb_texture_rectangle) { | 2399 if (features().arb_texture_rectangle) { |
2400 ref = texture_manager()->GetDefaultTextureInfo( | 2400 ref = texture_manager()->GetDefaultTextureInfo( |
2401 GL_TEXTURE_RECTANGLE_ARB); | 2401 GL_TEXTURE_RECTANGLE_ARB); |
2402 state_.texture_units[tt].bound_texture_rectangle_arb = ref; | 2402 state_.texture_units[tt].bound_texture_rectangle_arb = ref; |
2403 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, ref->service_id()); | 2403 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, ref ? ref->service_id() : 0); |
2404 } | 2404 } |
2405 ref = texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_CUBE_MAP); | 2405 ref = texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_CUBE_MAP); |
2406 state_.texture_units[tt].bound_texture_cube_map = ref; | 2406 state_.texture_units[tt].bound_texture_cube_map = ref; |
2407 glBindTexture(GL_TEXTURE_CUBE_MAP, ref->service_id()); | 2407 glBindTexture(GL_TEXTURE_CUBE_MAP, ref ? ref->service_id() : 0); |
2408 ref = texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_2D); | 2408 ref = texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_2D); |
2409 state_.texture_units[tt].bound_texture_2d = ref; | 2409 state_.texture_units[tt].bound_texture_2d = ref; |
2410 glBindTexture(GL_TEXTURE_2D, ref->service_id()); | 2410 glBindTexture(GL_TEXTURE_2D, ref ? ref->service_id() : 0); |
2411 } | 2411 } |
2412 glActiveTexture(GL_TEXTURE0); | 2412 glActiveTexture(GL_TEXTURE0); |
2413 CHECK_GL_ERROR(); | 2413 CHECK_GL_ERROR(); |
2414 | 2414 |
2415 if (offscreen) { | 2415 if (offscreen) { |
2416 if (attrib_parser.samples_ > 0 && attrib_parser.sample_buffers_ > 0 && | 2416 if (attrib_parser.samples_ > 0 && attrib_parser.sample_buffers_ > 0 && |
2417 features().chromium_framebuffer_multisample) { | 2417 features().chromium_framebuffer_multisample) { |
2418 // Per ext_framebuffer_multisample spec, need max bound on sample count. | 2418 // Per ext_framebuffer_multisample spec, need max bound on sample count. |
2419 // max_sample_count must be initialized to a sane value. If | 2419 // max_sample_count must be initialized to a sane value. If |
2420 // glGetIntegerv() throws a GL error, it leaves its argument unchanged. | 2420 // glGetIntegerv() throws a GL error, it leaves its argument unchanged. |
(...skipping 1613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4034 DCHECK_NE(0u, service_id); | 4034 DCHECK_NE(0u, service_id); |
4035 CreateTexture(client_id, service_id); | 4035 CreateTexture(client_id, service_id); |
4036 texture_ref = GetTexture(client_id); | 4036 texture_ref = GetTexture(client_id); |
4037 IdAllocatorInterface* id_allocator = | 4037 IdAllocatorInterface* id_allocator = |
4038 group_->GetIdAllocator(id_namespaces::kTextures); | 4038 group_->GetIdAllocator(id_namespaces::kTextures); |
4039 id_allocator->MarkAsUsed(client_id); | 4039 id_allocator->MarkAsUsed(client_id); |
4040 } | 4040 } |
4041 } else { | 4041 } else { |
4042 texture_ref = texture_manager()->GetDefaultTextureInfo(target); | 4042 texture_ref = texture_manager()->GetDefaultTextureInfo(target); |
4043 } | 4043 } |
4044 Texture* texture = texture_ref->texture(); | |
4045 | 4044 |
4046 // Check the texture exists | 4045 // Check the texture exists |
4047 // Check that we are not trying to bind it to a different target. | 4046 if (texture_ref) { |
4048 if (texture->target() != 0 && texture->target() != target) { | 4047 Texture* texture = texture_ref->texture(); |
4049 LOCAL_SET_GL_ERROR( | 4048 // Check that we are not trying to bind it to a different target. |
4050 GL_INVALID_OPERATION, | 4049 if (texture->target() != 0 && texture->target() != target) { |
4051 "glBindTexture", "texture bound to more than 1 target."); | 4050 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, |
4052 return; | 4051 "glBindTexture", |
| 4052 "texture bound to more than 1 target."); |
| 4053 return; |
| 4054 } |
| 4055 LogClientServiceForInfo(texture, client_id, "glBindTexture"); |
| 4056 if (texture->target() == 0) { |
| 4057 texture_manager()->SetTarget(texture_ref, target); |
| 4058 } |
| 4059 glBindTexture(target, texture->service_id()); |
| 4060 } else { |
| 4061 glBindTexture(target, 0); |
4053 } | 4062 } |
4054 LogClientServiceForInfo(texture, client_id, "glBindTexture"); | |
4055 if (texture->target() == 0) { | |
4056 texture_manager()->SetTarget(texture_ref, target); | |
4057 } | |
4058 glBindTexture(target, texture->service_id()); | |
4059 | 4063 |
4060 TextureUnit& unit = state_.texture_units[state_.active_texture_unit]; | 4064 TextureUnit& unit = state_.texture_units[state_.active_texture_unit]; |
4061 unit.bind_target = target; | 4065 unit.bind_target = target; |
4062 switch (target) { | 4066 switch (target) { |
4063 case GL_TEXTURE_2D: | 4067 case GL_TEXTURE_2D: |
4064 unit.bound_texture_2d = texture_ref; | 4068 unit.bound_texture_2d = texture_ref; |
4065 break; | 4069 break; |
4066 case GL_TEXTURE_CUBE_MAP: | 4070 case GL_TEXTURE_CUBE_MAP: |
4067 unit.bound_texture_cube_map = texture_ref; | 4071 unit.bound_texture_cube_map = texture_ref; |
4068 break; | 4072 break; |
(...skipping 6627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10696 } | 10700 } |
10697 } | 10701 } |
10698 | 10702 |
10699 // Include the auto-generated part of this file. We split this because it means | 10703 // Include the auto-generated part of this file. We split this because it means |
10700 // we can easily edit the non-auto generated parts right here in this file | 10704 // we can easily edit the non-auto generated parts right here in this file |
10701 // instead of having to edit some template or the code generator. | 10705 // instead of having to edit some template or the code generator. |
10702 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 10706 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
10703 | 10707 |
10704 } // namespace gles2 | 10708 } // namespace gles2 |
10705 } // namespace gpu | 10709 } // namespace gpu |
OLD | NEW |