| 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 // A class to emulate GLES2 over command buffers. | 5 // A class to emulate GLES2 over command buffers. |
| 6 | 6 |
| 7 #include "../client/gles2_implementation.h" | 7 #include "../client/gles2_implementation.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 scoped_array<int8> collection_buffer_; | 384 scoped_array<int8> collection_buffer_; |
| 385 | 385 |
| 386 DISALLOW_COPY_AND_ASSIGN(ClientSideBufferHelper); | 386 DISALLOW_COPY_AND_ASSIGN(ClientSideBufferHelper); |
| 387 }; | 387 }; |
| 388 | 388 |
| 389 #if !defined(_MSC_VER) | 389 #if !defined(_MSC_VER) |
| 390 const size_t GLES2Implementation::kMaxSizeOfSimpleResult; | 390 const size_t GLES2Implementation::kMaxSizeOfSimpleResult; |
| 391 const unsigned int GLES2Implementation::kStartingOffset; | 391 const unsigned int GLES2Implementation::kStartingOffset; |
| 392 #endif | 392 #endif |
| 393 | 393 |
| 394 GLES2Implementation::GLCachedState::IntState::IntState() | 394 GLES2Implementation::GLStaticState::IntState::IntState() |
| 395 : max_combined_texture_image_units(0), | 395 : max_combined_texture_image_units(0), |
| 396 max_cube_map_texture_size(0), | 396 max_cube_map_texture_size(0), |
| 397 max_fragment_uniform_vectors(0), | 397 max_fragment_uniform_vectors(0), |
| 398 max_renderbuffer_size(0), | 398 max_renderbuffer_size(0), |
| 399 max_texture_image_units(0), | 399 max_texture_image_units(0), |
| 400 max_texture_size(0), | 400 max_texture_size(0), |
| 401 max_varying_vectors(0), | 401 max_varying_vectors(0), |
| 402 max_vertex_attribs(0), | 402 max_vertex_attribs(0), |
| 403 max_vertex_texture_image_units(0), | 403 max_vertex_texture_image_units(0), |
| 404 max_vertex_uniform_vectors(0), | 404 max_vertex_uniform_vectors(0), |
| (...skipping 25 matching lines...) Expand all Loading... |
| 430 pack_alignment_(4), | 430 pack_alignment_(4), |
| 431 unpack_alignment_(4), | 431 unpack_alignment_(4), |
| 432 unpack_flip_y_(false), | 432 unpack_flip_y_(false), |
| 433 unpack_row_length_(0), | 433 unpack_row_length_(0), |
| 434 unpack_skip_rows_(0), | 434 unpack_skip_rows_(0), |
| 435 unpack_skip_pixels_(0), | 435 unpack_skip_pixels_(0), |
| 436 pack_reverse_row_order_(false), | 436 pack_reverse_row_order_(false), |
| 437 active_texture_unit_(0), | 437 active_texture_unit_(0), |
| 438 bound_framebuffer_(0), | 438 bound_framebuffer_(0), |
| 439 bound_renderbuffer_(0), | 439 bound_renderbuffer_(0), |
| 440 current_program_(0), |
| 440 bound_array_buffer_id_(0), | 441 bound_array_buffer_id_(0), |
| 441 bound_element_array_buffer_id_(0), | 442 bound_element_array_buffer_id_(0), |
| 442 client_side_array_id_(0), | 443 client_side_array_id_(0), |
| 443 client_side_element_array_id_(0), | 444 client_side_element_array_id_(0), |
| 444 bound_vertex_array_id_(0), | 445 bound_vertex_array_id_(0), |
| 445 error_bits_(0), | 446 error_bits_(0), |
| 446 debug_(false), | 447 debug_(false), |
| 447 use_count_(0), | 448 use_count_(0), |
| 448 current_query_(NULL), | 449 current_query_(NULL), |
| 449 error_message_callback_(NULL) { | 450 error_message_callback_(NULL) { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 GL_MAX_VARYING_VECTORS, | 497 GL_MAX_VARYING_VECTORS, |
| 497 GL_MAX_VERTEX_ATTRIBS, | 498 GL_MAX_VERTEX_ATTRIBS, |
| 498 GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, | 499 GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, |
| 499 GL_MAX_VERTEX_UNIFORM_VECTORS, | 500 GL_MAX_VERTEX_UNIFORM_VECTORS, |
| 500 GL_NUM_COMPRESSED_TEXTURE_FORMATS, | 501 GL_NUM_COMPRESSED_TEXTURE_FORMATS, |
| 501 GL_NUM_SHADER_BINARY_FORMATS, | 502 GL_NUM_SHADER_BINARY_FORMATS, |
| 502 }; | 503 }; |
| 503 | 504 |
| 504 GetMultipleIntegervCHROMIUM( | 505 GetMultipleIntegervCHROMIUM( |
| 505 pnames, arraysize(pnames), | 506 pnames, arraysize(pnames), |
| 506 &gl_state_.int_state.max_combined_texture_image_units, | 507 &static_state_.int_state.max_combined_texture_image_units, |
| 507 sizeof(gl_state_.int_state)); | 508 sizeof(static_state_.int_state)); |
| 508 | 509 |
| 509 util_.set_num_compressed_texture_formats( | 510 util_.set_num_compressed_texture_formats( |
| 510 gl_state_.int_state.num_compressed_texture_formats); | 511 static_state_.int_state.num_compressed_texture_formats); |
| 511 util_.set_num_shader_binary_formats( | 512 util_.set_num_shader_binary_formats( |
| 512 gl_state_.int_state.num_shader_binary_formats); | 513 static_state_.int_state.num_shader_binary_formats); |
| 513 | 514 |
| 514 texture_units_.reset( | 515 texture_units_.reset( |
| 515 new TextureUnit[gl_state_.int_state.max_combined_texture_image_units]); | 516 new TextureUnit[ |
| 517 static_state_.int_state.max_combined_texture_image_units]); |
| 516 | 518 |
| 517 query_tracker_.reset(new QueryTracker(mapped_memory_.get())); | 519 query_tracker_.reset(new QueryTracker(mapped_memory_.get())); |
| 518 | 520 |
| 519 #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) | 521 #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) |
| 520 GetIdHandler(id_namespaces::kBuffers)->MakeIds( | 522 GetIdHandler(id_namespaces::kBuffers)->MakeIds( |
| 521 this, kClientSideArrayId, arraysize(reserved_ids_), &reserved_ids_[0]); | 523 this, kClientSideArrayId, arraysize(reserved_ids_), &reserved_ids_[0]); |
| 522 | 524 |
| 523 client_side_buffer_helper_.reset(new ClientSideBufferHelper( | 525 client_side_buffer_helper_.reset(new ClientSideBufferHelper( |
| 524 gl_state_.int_state.max_vertex_attribs, | 526 static_state_.int_state.max_vertex_attribs, |
| 525 reserved_ids_[0], | 527 reserved_ids_[0], |
| 526 reserved_ids_[1])); | 528 reserved_ids_[1])); |
| 527 #endif | 529 #endif |
| 528 | 530 |
| 529 return true; | 531 return true; |
| 530 } | 532 } |
| 531 | 533 |
| 532 GLES2Implementation::~GLES2Implementation() { | 534 GLES2Implementation::~GLES2Implementation() { |
| 533 // Make sure the queries are finished otherwise we'll delete the | 535 // Make sure the queries are finished otherwise we'll delete the |
| 534 // shared memory (mapped_memory_) which will free the memory used | 536 // shared memory (mapped_memory_) which will free the memory used |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 803 return true; | 805 return true; |
| 804 } | 806 } |
| 805 | 807 |
| 806 void GLES2Implementation::SetBucketAsString( | 808 void GLES2Implementation::SetBucketAsString( |
| 807 uint32 bucket_id, const std::string& str) { | 809 uint32 bucket_id, const std::string& str) { |
| 808 // NOTE: strings are passed NULL terminated. That means the empty | 810 // NOTE: strings are passed NULL terminated. That means the empty |
| 809 // string will have a size of 1 and no-string will have a size of 0 | 811 // string will have a size of 1 and no-string will have a size of 0 |
| 810 SetBucketContents(bucket_id, str.c_str(), str.size() + 1); | 812 SetBucketContents(bucket_id, str.c_str(), str.size() + 1); |
| 811 } | 813 } |
| 812 | 814 |
| 813 bool GLES2Implementation::SetCapabilityState(GLenum cap, bool enabled) { | |
| 814 switch (cap) { | |
| 815 case GL_DITHER: | |
| 816 gl_state_.enable_state.dither = enabled; | |
| 817 return true; | |
| 818 case GL_BLEND: | |
| 819 gl_state_.enable_state.blend = enabled; | |
| 820 return true; | |
| 821 case GL_CULL_FACE: | |
| 822 gl_state_.enable_state.cull_face = enabled; | |
| 823 return true; | |
| 824 case GL_DEPTH_TEST: | |
| 825 gl_state_.enable_state.depth_test = enabled; | |
| 826 return true; | |
| 827 case GL_POLYGON_OFFSET_FILL: | |
| 828 gl_state_.enable_state.polygon_offset_fill = enabled; | |
| 829 return true; | |
| 830 case GL_SAMPLE_ALPHA_TO_COVERAGE: | |
| 831 gl_state_.enable_state.sample_alpha_to_coverage = enabled; | |
| 832 return true; | |
| 833 case GL_SAMPLE_COVERAGE: | |
| 834 gl_state_.enable_state.sample_coverage = enabled; | |
| 835 return true; | |
| 836 case GL_SCISSOR_TEST: | |
| 837 gl_state_.enable_state.scissor_test = enabled; | |
| 838 return true; | |
| 839 case GL_STENCIL_TEST: | |
| 840 gl_state_.enable_state.stencil_test = enabled; | |
| 841 return true; | |
| 842 default: | |
| 843 return false; | |
| 844 } | |
| 845 } | |
| 846 | |
| 847 void GLES2Implementation::Disable(GLenum cap) { | 815 void GLES2Implementation::Disable(GLenum cap) { |
| 848 GPU_CLIENT_SINGLE_THREAD_CHECK(); | 816 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 849 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glDisable(" | 817 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glDisable(" |
| 850 << GLES2Util::GetStringCapability(cap) << ")"); | 818 << GLES2Util::GetStringCapability(cap) << ")"); |
| 851 SetCapabilityState(cap, false); | 819 bool changed = false; |
| 852 helper_->Disable(cap); | 820 if (!state_.SetCapabilityState(cap, false, &changed) || changed) { |
| 821 helper_->Disable(cap); |
| 822 } |
| 853 } | 823 } |
| 854 | 824 |
| 855 void GLES2Implementation::Enable(GLenum cap) { | 825 void GLES2Implementation::Enable(GLenum cap) { |
| 856 GPU_CLIENT_SINGLE_THREAD_CHECK(); | 826 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 857 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glEnable(" | 827 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glEnable(" |
| 858 << GLES2Util::GetStringCapability(cap) << ")"); | 828 << GLES2Util::GetStringCapability(cap) << ")"); |
| 859 SetCapabilityState(cap, true); | 829 bool changed = false; |
| 860 helper_->Enable(cap); | 830 if (!state_.SetCapabilityState(cap, true, &changed) || changed) { |
| 831 helper_->Enable(cap); |
| 832 } |
| 861 } | 833 } |
| 862 | 834 |
| 863 GLboolean GLES2Implementation::IsEnabled(GLenum cap) { | 835 GLboolean GLES2Implementation::IsEnabled(GLenum cap) { |
| 864 GPU_CLIENT_SINGLE_THREAD_CHECK(); | 836 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 865 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glIsEnabled(" | 837 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glIsEnabled(" |
| 866 << GLES2Util::GetStringCapability(cap) << ")"); | 838 << GLES2Util::GetStringCapability(cap) << ")"); |
| 867 bool state = false; | 839 bool state = false; |
| 868 switch (cap) { | 840 if (!state_.GetEnabled(cap, &state)) { |
| 869 case GL_DITHER: | 841 typedef IsEnabled::Result Result; |
| 870 state = gl_state_.enable_state.dither; | 842 Result* result = GetResultAs<Result*>(); |
| 871 break; | 843 if (!result) { |
| 872 case GL_BLEND: | 844 return GL_FALSE; |
| 873 state = gl_state_.enable_state.blend; | |
| 874 break; | |
| 875 case GL_CULL_FACE: | |
| 876 state = gl_state_.enable_state.cull_face; | |
| 877 break; | |
| 878 case GL_DEPTH_TEST: | |
| 879 state = gl_state_.enable_state.depth_test; | |
| 880 break; | |
| 881 case GL_POLYGON_OFFSET_FILL: | |
| 882 state = gl_state_.enable_state.polygon_offset_fill; | |
| 883 break; | |
| 884 case GL_SAMPLE_ALPHA_TO_COVERAGE: | |
| 885 state = gl_state_.enable_state.sample_alpha_to_coverage; | |
| 886 break; | |
| 887 case GL_SAMPLE_COVERAGE: | |
| 888 state = gl_state_.enable_state.sample_coverage; | |
| 889 break; | |
| 890 case GL_SCISSOR_TEST: | |
| 891 state = gl_state_.enable_state.scissor_test; | |
| 892 break; | |
| 893 case GL_STENCIL_TEST: | |
| 894 state = gl_state_.enable_state.stencil_test; | |
| 895 break; | |
| 896 default: { | |
| 897 typedef IsEnabled::Result Result; | |
| 898 Result* result = GetResultAs<Result*>(); | |
| 899 if (!result) { | |
| 900 return GL_FALSE; | |
| 901 } | |
| 902 *result = 0; | |
| 903 helper_->IsEnabled(cap, GetResultShmId(), GetResultShmOffset()); | |
| 904 WaitForCmd(); | |
| 905 state = (*result) != 0; | |
| 906 break; | |
| 907 } | 845 } |
| 846 *result = 0; |
| 847 helper_->IsEnabled(cap, GetResultShmId(), GetResultShmOffset()); |
| 848 WaitForCmd(); |
| 849 state = (*result) != 0; |
| 908 } | 850 } |
| 851 |
| 909 GPU_CLIENT_LOG("returned " << state); | 852 GPU_CLIENT_LOG("returned " << state); |
| 910 return state; | 853 return state; |
| 911 } | 854 } |
| 912 | 855 |
| 913 bool GLES2Implementation::GetHelper(GLenum pname, GLint* params) { | 856 bool GLES2Implementation::GetHelper(GLenum pname, GLint* params) { |
| 914 switch (pname) { | 857 switch (pname) { |
| 915 case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS: | 858 case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS: |
| 916 *params = gl_state_.int_state.max_combined_texture_image_units; | 859 *params = static_state_.int_state.max_combined_texture_image_units; |
| 917 return true; | 860 return true; |
| 918 case GL_MAX_CUBE_MAP_TEXTURE_SIZE: | 861 case GL_MAX_CUBE_MAP_TEXTURE_SIZE: |
| 919 *params = gl_state_.int_state.max_cube_map_texture_size; | 862 *params = static_state_.int_state.max_cube_map_texture_size; |
| 920 return true; | 863 return true; |
| 921 case GL_MAX_FRAGMENT_UNIFORM_VECTORS: | 864 case GL_MAX_FRAGMENT_UNIFORM_VECTORS: |
| 922 *params = gl_state_.int_state.max_fragment_uniform_vectors; | 865 *params = static_state_.int_state.max_fragment_uniform_vectors; |
| 923 return true; | 866 return true; |
| 924 case GL_MAX_RENDERBUFFER_SIZE: | 867 case GL_MAX_RENDERBUFFER_SIZE: |
| 925 *params = gl_state_.int_state.max_renderbuffer_size; | 868 *params = static_state_.int_state.max_renderbuffer_size; |
| 926 return true; | 869 return true; |
| 927 case GL_MAX_TEXTURE_IMAGE_UNITS: | 870 case GL_MAX_TEXTURE_IMAGE_UNITS: |
| 928 *params = gl_state_.int_state.max_texture_image_units; | 871 *params = static_state_.int_state.max_texture_image_units; |
| 929 return true; | 872 return true; |
| 930 case GL_MAX_TEXTURE_SIZE: | 873 case GL_MAX_TEXTURE_SIZE: |
| 931 *params = gl_state_.int_state.max_texture_size; | 874 *params = static_state_.int_state.max_texture_size; |
| 932 return true; | 875 return true; |
| 933 case GL_MAX_VARYING_VECTORS: | 876 case GL_MAX_VARYING_VECTORS: |
| 934 *params = gl_state_.int_state.max_varying_vectors; | 877 *params = static_state_.int_state.max_varying_vectors; |
| 935 return true; | 878 return true; |
| 936 case GL_MAX_VERTEX_ATTRIBS: | 879 case GL_MAX_VERTEX_ATTRIBS: |
| 937 *params = gl_state_.int_state.max_vertex_attribs; | 880 *params = static_state_.int_state.max_vertex_attribs; |
| 938 return true; | 881 return true; |
| 939 case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS: | 882 case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS: |
| 940 *params = gl_state_.int_state.max_vertex_texture_image_units; | 883 *params = static_state_.int_state.max_vertex_texture_image_units; |
| 941 return true; | 884 return true; |
| 942 case GL_MAX_VERTEX_UNIFORM_VECTORS: | 885 case GL_MAX_VERTEX_UNIFORM_VECTORS: |
| 943 *params = gl_state_.int_state.max_vertex_uniform_vectors; | 886 *params = static_state_.int_state.max_vertex_uniform_vectors; |
| 944 return true; | 887 return true; |
| 945 case GL_NUM_COMPRESSED_TEXTURE_FORMATS: | 888 case GL_NUM_COMPRESSED_TEXTURE_FORMATS: |
| 946 *params = gl_state_.int_state.num_compressed_texture_formats; | 889 *params = static_state_.int_state.num_compressed_texture_formats; |
| 947 return true; | 890 return true; |
| 948 case GL_NUM_SHADER_BINARY_FORMATS: | 891 case GL_NUM_SHADER_BINARY_FORMATS: |
| 949 *params = gl_state_.int_state.num_shader_binary_formats; | 892 *params = static_state_.int_state.num_shader_binary_formats; |
| 950 return true; | 893 return true; |
| 951 case GL_ARRAY_BUFFER_BINDING: | 894 case GL_ARRAY_BUFFER_BINDING: |
| 952 if (share_group_->bind_generates_resource()) { | 895 if (share_group_->bind_generates_resource()) { |
| 953 *params = bound_array_buffer_id_; | 896 *params = bound_array_buffer_id_; |
| 954 return true; | 897 return true; |
| 955 } | 898 } |
| 956 return false; | 899 return false; |
| 957 case GL_ELEMENT_ARRAY_BUFFER_BINDING: | 900 case GL_ELEMENT_ARRAY_BUFFER_BINDING: |
| 958 if (share_group_->bind_generates_resource()) { | 901 if (share_group_->bind_generates_resource()) { |
| 959 *params = bound_element_array_buffer_id_; | 902 *params = bound_element_array_buffer_id_; |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1309 } | 1252 } |
| 1310 | 1253 |
| 1311 bool GLES2Implementation::DeleteProgramHelper(GLuint program) { | 1254 bool GLES2Implementation::DeleteProgramHelper(GLuint program) { |
| 1312 if (!GetIdHandler(id_namespaces::kProgramsAndShaders)->FreeIds( | 1255 if (!GetIdHandler(id_namespaces::kProgramsAndShaders)->FreeIds( |
| 1313 this, 1, &program, &GLES2Implementation::DeleteProgramStub)) { | 1256 this, 1, &program, &GLES2Implementation::DeleteProgramStub)) { |
| 1314 SetGLError( | 1257 SetGLError( |
| 1315 GL_INVALID_VALUE, | 1258 GL_INVALID_VALUE, |
| 1316 "glDeleteProgram", "id not created by this context."); | 1259 "glDeleteProgram", "id not created by this context."); |
| 1317 return false; | 1260 return false; |
| 1318 } | 1261 } |
| 1262 if (program == current_program_) { |
| 1263 current_program_ = 0; |
| 1264 } |
| 1319 return true; | 1265 return true; |
| 1320 } | 1266 } |
| 1321 | 1267 |
| 1322 void GLES2Implementation::DeleteProgramStub( | 1268 void GLES2Implementation::DeleteProgramStub( |
| 1323 GLsizei n, const GLuint* programs) { | 1269 GLsizei n, const GLuint* programs) { |
| 1324 GPU_DCHECK_EQ(1, n); | 1270 GPU_DCHECK_EQ(1, n); |
| 1325 share_group_->program_info_manager()->DeleteInfo(programs[0]); | 1271 share_group_->program_info_manager()->DeleteInfo(programs[0]); |
| 1326 helper_->DeleteProgram(programs[0]); | 1272 helper_->DeleteProgram(programs[0]); |
| 1327 } | 1273 } |
| 1328 | 1274 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1394 GPU_CLIENT_SINGLE_THREAD_CHECK(); | 1340 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 1395 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetUniformLocation(" << program | 1341 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetUniformLocation(" << program |
| 1396 << ", " << name << ")"); | 1342 << ", " << name << ")"); |
| 1397 TRACE_EVENT0("gpu", "GLES2::GetUniformLocation"); | 1343 TRACE_EVENT0("gpu", "GLES2::GetUniformLocation"); |
| 1398 GLint loc = share_group_->program_info_manager()->GetUniformLocation( | 1344 GLint loc = share_group_->program_info_manager()->GetUniformLocation( |
| 1399 this, program, name); | 1345 this, program, name); |
| 1400 GPU_CLIENT_LOG("returned " << loc); | 1346 GPU_CLIENT_LOG("returned " << loc); |
| 1401 return loc; | 1347 return loc; |
| 1402 } | 1348 } |
| 1403 | 1349 |
| 1350 void GLES2Implementation::UseProgram(GLuint program) { |
| 1351 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 1352 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glUseProgram(" << program << ")"); |
| 1353 if (current_program_ != program) { |
| 1354 current_program_ = program; |
| 1355 helper_->UseProgram(program); |
| 1356 } |
| 1357 } |
| 1358 |
| 1404 bool GLES2Implementation::GetProgramivHelper( | 1359 bool GLES2Implementation::GetProgramivHelper( |
| 1405 GLuint program, GLenum pname, GLint* params) { | 1360 GLuint program, GLenum pname, GLint* params) { |
| 1406 bool got_value = share_group_->program_info_manager()->GetProgramiv( | 1361 bool got_value = share_group_->program_info_manager()->GetProgramiv( |
| 1407 this, program, pname, params); | 1362 this, program, pname, params); |
| 1408 GPU_CLIENT_LOG_CODE_BLOCK({ | 1363 GPU_CLIENT_LOG_CODE_BLOCK({ |
| 1409 if (got_value) { | 1364 if (got_value) { |
| 1410 GPU_CLIENT_LOG(" 0: " << *params); | 1365 GPU_CLIENT_LOG(" 0: " << *params); |
| 1411 } | 1366 } |
| 1412 }); | 1367 }); |
| 1413 return got_value; | 1368 return got_value; |
| (...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2383 height -= num_rows; | 2338 height -= num_rows; |
| 2384 } | 2339 } |
| 2385 } | 2340 } |
| 2386 | 2341 |
| 2387 void GLES2Implementation::ActiveTexture(GLenum texture) { | 2342 void GLES2Implementation::ActiveTexture(GLenum texture) { |
| 2388 GPU_CLIENT_SINGLE_THREAD_CHECK(); | 2343 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 2389 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glActiveTexture(" | 2344 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glActiveTexture(" |
| 2390 << GLES2Util::GetStringEnum(texture) << ")"); | 2345 << GLES2Util::GetStringEnum(texture) << ")"); |
| 2391 GLuint texture_index = texture - GL_TEXTURE0; | 2346 GLuint texture_index = texture - GL_TEXTURE0; |
| 2392 if (texture_index >= static_cast<GLuint>( | 2347 if (texture_index >= static_cast<GLuint>( |
| 2393 gl_state_.int_state.max_combined_texture_image_units)) { | 2348 static_state_.int_state.max_combined_texture_image_units)) { |
| 2394 SetGLErrorInvalidEnum( | 2349 SetGLErrorInvalidEnum( |
| 2395 "glActiveTexture", texture, "texture"); | 2350 "glActiveTexture", texture, "texture"); |
| 2396 return; | 2351 return; |
| 2397 } | 2352 } |
| 2398 | 2353 |
| 2399 active_texture_unit_ = texture_index; | 2354 active_texture_unit_ = texture_index; |
| 2400 helper_->ActiveTexture(texture); | 2355 helper_->ActiveTexture(texture); |
| 2401 } | 2356 } |
| 2402 | 2357 |
| 2403 // NOTE #1: On old versions of OpenGL, calling glBindXXX with an unused id | 2358 // NOTE #1: On old versions of OpenGL, calling glBindXXX with an unused id |
| 2404 // generates a new resource. On newer versions of OpenGL they don't. The code | 2359 // generates a new resource. On newer versions of OpenGL they don't. The code |
| 2405 // related to binding below will need to change if we switch to the new OpenGL | 2360 // related to binding below will need to change if we switch to the new OpenGL |
| 2406 // model. Specifically it assumes a bind will succeed which is always true in | 2361 // model. Specifically it assumes a bind will succeed which is always true in |
| 2407 // the old model but possibly not true in the new model if another context has | 2362 // the old model but possibly not true in the new model if another context has |
| 2408 // deleted the resource. | 2363 // deleted the resource. |
| 2409 | 2364 |
| 2410 void GLES2Implementation::BindBufferHelper( | 2365 bool GLES2Implementation::BindBufferHelper( |
| 2411 GLenum target, GLuint buffer) { | 2366 GLenum target, GLuint buffer) { |
| 2412 // TODO(gman): See note #1 above. | 2367 // TODO(gman): See note #1 above. |
| 2368 bool changed = false; |
| 2413 switch (target) { | 2369 switch (target) { |
| 2414 case GL_ARRAY_BUFFER: | 2370 case GL_ARRAY_BUFFER: |
| 2415 bound_array_buffer_id_ = buffer; | 2371 if (bound_array_buffer_id_ != buffer) { |
| 2372 bound_array_buffer_id_ = buffer; |
| 2373 changed = true; |
| 2374 } |
| 2416 break; | 2375 break; |
| 2417 case GL_ELEMENT_ARRAY_BUFFER: | 2376 case GL_ELEMENT_ARRAY_BUFFER: |
| 2418 bound_element_array_buffer_id_ = buffer; | 2377 if (bound_element_array_buffer_id_ != buffer) { |
| 2378 bound_element_array_buffer_id_ = buffer; |
| 2379 changed = true; |
| 2380 } |
| 2419 break; | 2381 break; |
| 2420 default: | 2382 default: |
| 2383 changed = true; |
| 2421 break; | 2384 break; |
| 2422 } | 2385 } |
| 2423 // TODO(gman): There's a bug here. If the target is invalid the ID will not be | 2386 // TODO(gman): There's a bug here. If the target is invalid the ID will not be |
| 2424 // used even though it's marked it as used here. | 2387 // used even though it's marked it as used here. |
| 2425 GetIdHandler(id_namespaces::kBuffers)->MarkAsUsedForBind(buffer); | 2388 GetIdHandler(id_namespaces::kBuffers)->MarkAsUsedForBind(buffer); |
| 2389 return changed; |
| 2426 } | 2390 } |
| 2427 | 2391 |
| 2428 void GLES2Implementation::BindFramebufferHelper( | 2392 bool GLES2Implementation::BindFramebufferHelper( |
| 2429 GLenum target, GLuint framebuffer) { | 2393 GLenum target, GLuint framebuffer) { |
| 2430 // TODO(gman): See note #1 above. | 2394 // TODO(gman): See note #1 above. |
| 2395 bool changed = false; |
| 2431 switch (target) { | 2396 switch (target) { |
| 2432 case GL_FRAMEBUFFER: | 2397 case GL_FRAMEBUFFER: |
| 2433 bound_framebuffer_ = framebuffer; | 2398 if (bound_framebuffer_ != framebuffer) { |
| 2399 bound_framebuffer_ = framebuffer; |
| 2400 changed = true; |
| 2401 } |
| 2434 break; | 2402 break; |
| 2435 default: | 2403 default: |
| 2404 changed = true; |
| 2436 break; | 2405 break; |
| 2437 } | 2406 } |
| 2438 // TODO(gman): There's a bug here. If the target is invalid the ID will not be | 2407 // TODO(gman): There's a bug here. If the target is invalid the ID will not be |
| 2439 // used even though it's marked it as used here. | 2408 // used even though it's marked it as used here. |
| 2440 GetIdHandler(id_namespaces::kFramebuffers)->MarkAsUsedForBind(framebuffer); | 2409 GetIdHandler(id_namespaces::kFramebuffers)->MarkAsUsedForBind(framebuffer); |
| 2410 return changed; |
| 2441 } | 2411 } |
| 2442 | 2412 |
| 2443 void GLES2Implementation::BindRenderbufferHelper( | 2413 bool GLES2Implementation::BindRenderbufferHelper( |
| 2444 GLenum target, GLuint renderbuffer) { | 2414 GLenum target, GLuint renderbuffer) { |
| 2445 // TODO(gman): See note #1 above. | 2415 // TODO(gman): See note #1 above. |
| 2416 bool changed = false; |
| 2446 switch (target) { | 2417 switch (target) { |
| 2447 case GL_RENDERBUFFER: | 2418 case GL_RENDERBUFFER: |
| 2448 bound_renderbuffer_ = renderbuffer; | 2419 if (bound_renderbuffer_ != renderbuffer) { |
| 2420 bound_renderbuffer_ = renderbuffer; |
| 2421 changed = true; |
| 2422 } |
| 2449 break; | 2423 break; |
| 2450 default: | 2424 default: |
| 2425 changed = true; |
| 2451 break; | 2426 break; |
| 2452 } | 2427 } |
| 2453 // TODO(gman): There's a bug here. If the target is invalid the ID will not be | 2428 // TODO(gman): There's a bug here. If the target is invalid the ID will not be |
| 2454 // used even though it's marked it as used here. | 2429 // used even though it's marked it as used here. |
| 2455 GetIdHandler(id_namespaces::kRenderbuffers)->MarkAsUsedForBind(renderbuffer); | 2430 GetIdHandler(id_namespaces::kRenderbuffers)->MarkAsUsedForBind(renderbuffer); |
| 2431 return changed; |
| 2456 } | 2432 } |
| 2457 | 2433 |
| 2458 void GLES2Implementation::BindTextureHelper(GLenum target, GLuint texture) { | 2434 bool GLES2Implementation::BindTextureHelper(GLenum target, GLuint texture) { |
| 2459 // TODO(gman): See note #1 above. | 2435 // TODO(gman): See note #1 above. |
| 2436 bool changed = false; |
| 2460 TextureUnit& unit = texture_units_[active_texture_unit_]; | 2437 TextureUnit& unit = texture_units_[active_texture_unit_]; |
| 2461 switch (target) { | 2438 switch (target) { |
| 2462 case GL_TEXTURE_2D: | 2439 case GL_TEXTURE_2D: |
| 2463 unit.bound_texture_2d = texture; | 2440 if (unit.bound_texture_2d != texture) { |
| 2441 unit.bound_texture_2d = texture; |
| 2442 changed = true; |
| 2443 } |
| 2464 break; | 2444 break; |
| 2465 case GL_TEXTURE_CUBE_MAP: | 2445 case GL_TEXTURE_CUBE_MAP: |
| 2466 unit.bound_texture_cube_map = texture; | 2446 if (unit.bound_texture_cube_map != texture) { |
| 2447 unit.bound_texture_cube_map = texture; |
| 2448 changed = true; |
| 2449 } |
| 2467 break; | 2450 break; |
| 2468 default: | 2451 default: |
| 2452 changed = true; |
| 2469 break; | 2453 break; |
| 2470 } | 2454 } |
| 2471 // TODO(gman): There's a bug here. If the target is invalid the ID will not be | 2455 // TODO(gman): There's a bug here. If the target is invalid the ID will not be |
| 2472 // used. even though it's marked it as used here. | 2456 // used. even though it's marked it as used here. |
| 2473 GetIdHandler(id_namespaces::kTextures)->MarkAsUsedForBind(texture); | 2457 GetIdHandler(id_namespaces::kTextures)->MarkAsUsedForBind(texture); |
| 2458 return changed; |
| 2474 } | 2459 } |
| 2475 | 2460 |
| 2476 void GLES2Implementation::BindVertexArrayHelper(GLuint array) { | 2461 bool GLES2Implementation::BindVertexArrayHelper(GLuint array) { |
| 2477 // TODO(gman): See note #1 above. | 2462 // TODO(gman): See note #1 above. |
| 2478 bound_vertex_array_id_ = array; | 2463 bool changed = false; |
| 2479 | 2464 if (bound_vertex_array_id_ != array) { |
| 2465 bound_vertex_array_id_ = array; |
| 2466 changed = true; |
| 2467 } |
| 2480 GetIdHandler(id_namespaces::kVertexArrays)->MarkAsUsedForBind(array); | 2468 GetIdHandler(id_namespaces::kVertexArrays)->MarkAsUsedForBind(array); |
| 2469 return changed; |
| 2481 } | 2470 } |
| 2482 | 2471 |
| 2483 #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) | 2472 #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) |
| 2484 bool GLES2Implementation::IsBufferReservedId(GLuint id) { | 2473 bool GLES2Implementation::IsBufferReservedId(GLuint id) { |
| 2485 for (size_t ii = 0; ii < arraysize(reserved_ids_); ++ii) { | 2474 for (size_t ii = 0; ii < arraysize(reserved_ids_); ++ii) { |
| 2486 if (id == reserved_ids_[ii]) { | 2475 if (id == reserved_ids_[ii]) { |
| 2487 return true; | 2476 return true; |
| 2488 } | 2477 } |
| 2489 } | 2478 } |
| 2490 return false; | 2479 return false; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2566 GLsizei n, const GLuint* textures) { | 2555 GLsizei n, const GLuint* textures) { |
| 2567 if (!GetIdHandler(id_namespaces::kTextures)->FreeIds( | 2556 if (!GetIdHandler(id_namespaces::kTextures)->FreeIds( |
| 2568 this, n, textures, &GLES2Implementation::DeleteTexturesStub)) { | 2557 this, n, textures, &GLES2Implementation::DeleteTexturesStub)) { |
| 2569 SetGLError( | 2558 SetGLError( |
| 2570 GL_INVALID_VALUE, | 2559 GL_INVALID_VALUE, |
| 2571 "glDeleteTextures", "id not created by this context."); | 2560 "glDeleteTextures", "id not created by this context."); |
| 2572 return; | 2561 return; |
| 2573 } | 2562 } |
| 2574 for (GLsizei ii = 0; ii < n; ++ii) { | 2563 for (GLsizei ii = 0; ii < n; ++ii) { |
| 2575 for (GLint tt = 0; | 2564 for (GLint tt = 0; |
| 2576 tt < gl_state_.int_state.max_combined_texture_image_units; | 2565 tt < static_state_.int_state.max_combined_texture_image_units; |
| 2577 ++tt) { | 2566 ++tt) { |
| 2578 TextureUnit& unit = texture_units_[tt]; | 2567 TextureUnit& unit = texture_units_[tt]; |
| 2579 if (textures[ii] == unit.bound_texture_2d) { | 2568 if (textures[ii] == unit.bound_texture_2d) { |
| 2580 unit.bound_texture_2d = 0; | 2569 unit.bound_texture_2d = 0; |
| 2581 } | 2570 } |
| 2582 if (textures[ii] == unit.bound_texture_cube_map) { | 2571 if (textures[ii] == unit.bound_texture_cube_map) { |
| 2583 unit.bound_texture_cube_map = 0; | 2572 unit.bound_texture_cube_map = 0; |
| 2584 } | 2573 } |
| 2585 } | 2574 } |
| 2586 } | 2575 } |
| (...skipping 883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3470 debug_marker_manager_.PopGroup(); | 3459 debug_marker_manager_.PopGroup(); |
| 3471 } | 3460 } |
| 3472 | 3461 |
| 3473 // Include the auto-generated part of this file. We split this because it means | 3462 // Include the auto-generated part of this file. We split this because it means |
| 3474 // we can easily edit the non-auto generated parts right here in this file | 3463 // we can easily edit the non-auto generated parts right here in this file |
| 3475 // instead of having to edit some template or the code generator. | 3464 // instead of having to edit some template or the code generator. |
| 3476 #include "../client/gles2_implementation_impl_autogen.h" | 3465 #include "../client/gles2_implementation_impl_autogen.h" |
| 3477 | 3466 |
| 3478 } // namespace gles2 | 3467 } // namespace gles2 |
| 3479 } // namespace gpu | 3468 } // namespace gpu |
| OLD | NEW |