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/texture_manager.h" | 5 #include "gpu/command_buffer/service/texture_manager.h" |
6 #include "base/bits.h" | 6 #include "base/bits.h" |
7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
8 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 8 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
9 #include "gpu/command_buffer/service/context_state.h" | 9 #include "gpu/command_buffer/service/context_state.h" |
10 #include "gpu/command_buffer/service/error_state.h" | 10 #include "gpu/command_buffer/service/error_state.h" |
(...skipping 1318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1329 const char* function_name, | 1329 const char* function_name, |
1330 const DoTextImage2DArguments& args, | 1330 const DoTextImage2DArguments& args, |
1331 TextureRef** texture_ref) { | 1331 TextureRef** texture_ref) { |
1332 ErrorState* error_state = state->GetErrorState(); | 1332 ErrorState* error_state = state->GetErrorState(); |
1333 const Validators* validators = feature_info_->validators(); | 1333 const Validators* validators = feature_info_->validators(); |
1334 if (!validators->texture_target.IsValid(args.target)) { | 1334 if (!validators->texture_target.IsValid(args.target)) { |
1335 ERRORSTATE_SET_GL_ERROR_INVALID_ENUM( | 1335 ERRORSTATE_SET_GL_ERROR_INVALID_ENUM( |
1336 error_state, function_name, args.target, "target"); | 1336 error_state, function_name, args.target, "target"); |
1337 return false; | 1337 return false; |
1338 } | 1338 } |
1339 if (!validators->texture_format.IsValid(args.internal_format)) { | 1339 if (!validators->texture_internal_format.IsValid(args.internal_format)) { |
1340 ERRORSTATE_SET_GL_ERROR_INVALID_ENUM( | 1340 ERRORSTATE_SET_GL_ERROR_INVALID_ENUM( |
1341 error_state, function_name, args.internal_format, | 1341 error_state, function_name, args.internal_format, |
1342 "internal_format"); | 1342 "internalformat"); |
1343 return false; | 1343 return false; |
1344 } | 1344 } |
1345 if (!validators->texture_format.IsValid(args.format)) { | 1345 if (!validators->texture_format.IsValid(args.format)) { |
1346 ERRORSTATE_SET_GL_ERROR_INVALID_ENUM( | 1346 ERRORSTATE_SET_GL_ERROR_INVALID_ENUM( |
1347 error_state, function_name, args.format, "format"); | 1347 error_state, function_name, args.format, "format"); |
1348 return false; | 1348 return false; |
1349 } | 1349 } |
1350 if (!validators->pixel_type.IsValid(args.type)) { | 1350 if (!validators->pixel_type.IsValid(args.type)) { |
1351 ERRORSTATE_SET_GL_ERROR_INVALID_ENUM( | 1351 ERRORSTATE_SET_GL_ERROR_INVALID_ENUM( |
1352 error_state, function_name, args.type, "type"); | 1352 error_state, function_name, args.type, "type"); |
1353 return false; | 1353 return false; |
1354 } | 1354 } |
1355 if (args.format != args.internal_format) { | 1355 if (args.format != args.internal_format && |
| 1356 !((args.internal_format == GL_RGBA32F && args.format == GL_RGBA) || |
| 1357 (args.internal_format == GL_RGB32F && args.format == GL_RGB))) { |
1356 ERRORSTATE_SET_GL_ERROR( | 1358 ERRORSTATE_SET_GL_ERROR( |
1357 error_state, GL_INVALID_OPERATION, function_name, | 1359 error_state, GL_INVALID_OPERATION, function_name, |
1358 "format != internalFormat"); | 1360 "format != internalformat"); |
1359 return false; | 1361 return false; |
1360 } | 1362 } |
1361 if (!ValidateTextureParameters( | 1363 if (!ValidateTextureParameters( |
1362 error_state, function_name, args.target, args.format, args.type, | 1364 error_state, function_name, args.target, args.format, args.type, |
1363 args.level)) { | 1365 args.level)) { |
1364 return false; | 1366 return false; |
1365 } | 1367 } |
1366 if (!ValidForTarget(args.target, args.level, args.width, args.height, 1) || | 1368 if (!ValidForTarget(args.target, args.level, args.width, args.height, 1) || |
1367 args.border != 0) { | 1369 args.border != 0) { |
1368 ERRORSTATE_SET_GL_ERROR( | 1370 ERRORSTATE_SET_GL_ERROR( |
(...skipping 20 matching lines...) Expand all Loading... |
1389 ERRORSTATE_SET_GL_ERROR( | 1391 ERRORSTATE_SET_GL_ERROR( |
1390 error_state, GL_INVALID_OPERATION, function_name, | 1392 error_state, GL_INVALID_OPERATION, function_name, |
1391 "texture is immutable"); | 1393 "texture is immutable"); |
1392 return false; | 1394 return false; |
1393 } | 1395 } |
1394 | 1396 |
1395 // TODO - verify that using the managed vs unmanaged does not matter. | 1397 // TODO - verify that using the managed vs unmanaged does not matter. |
1396 // They both use the same MemoryTracker, and this call just re-routes | 1398 // They both use the same MemoryTracker, and this call just re-routes |
1397 // to it. | 1399 // to it. |
1398 if (!memory_tracker_managed_->EnsureGPUMemoryAvailable(args.pixels_size)) { | 1400 if (!memory_tracker_managed_->EnsureGPUMemoryAvailable(args.pixels_size)) { |
1399 ERRORSTATE_SET_GL_ERROR(error_state, GL_OUT_OF_MEMORY, "glTexImage2D", | 1401 ERRORSTATE_SET_GL_ERROR(error_state, GL_OUT_OF_MEMORY, function_name, |
1400 "out of memory"); | 1402 "out of memory"); |
1401 return false; | 1403 return false; |
1402 } | 1404 } |
1403 | 1405 |
1404 // Write the TextureReference since this is valid. | 1406 // Write the TextureReference since this is valid. |
1405 *texture_ref = local_texture_ref; | 1407 *texture_ref = local_texture_ref; |
1406 return true; | 1408 return true; |
1407 } | 1409 } |
1408 | 1410 |
1409 void TextureManager::ValidateAndDoTexImage2D( | 1411 void TextureManager::ValidateAndDoTexImage2D( |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1487 } | 1489 } |
1488 | 1490 |
1489 ScopedTextureUploadTimer::~ScopedTextureUploadTimer() { | 1491 ScopedTextureUploadTimer::~ScopedTextureUploadTimer() { |
1490 texture_state_->texture_upload_count++; | 1492 texture_state_->texture_upload_count++; |
1491 texture_state_->total_texture_upload_time += | 1493 texture_state_->total_texture_upload_time += |
1492 base::TimeTicks::HighResNow() - begin_time_; | 1494 base::TimeTicks::HighResNow() - begin_time_; |
1493 } | 1495 } |
1494 | 1496 |
1495 } // namespace gles2 | 1497 } // namespace gles2 |
1496 } // namespace gpu | 1498 } // namespace gpu |
OLD | NEW |