| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <set> | 9 #include <set> |
| 10 #include <queue> | 10 #include <queue> |
| (...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 596 return buffer_id_; | 596 return buffer_id_; |
| 597 } | 597 } |
| 598 | 598 |
| 599 #if !defined(_MSC_VER) | 599 #if !defined(_MSC_VER) |
| 600 const size_t GLES2Implementation::kMaxSizeOfSimpleResult; | 600 const size_t GLES2Implementation::kMaxSizeOfSimpleResult; |
| 601 #endif | 601 #endif |
| 602 | 602 |
| 603 COMPILE_ASSERT(gpu::kInvalidResource == 0, | 603 COMPILE_ASSERT(gpu::kInvalidResource == 0, |
| 604 INVALID_RESOURCE_NOT_0_AS_GL_EXPECTS); | 604 INVALID_RESOURCE_NOT_0_AS_GL_EXPECTS); |
| 605 | 605 |
| 606 GLES2Implementation::SingleThreadChecker::SingleThreadChecker( |
| 607 GLES2Implementation* gles2_implementation) |
| 608 : gles2_implementation_(gles2_implementation) { |
| 609 GPU_CHECK_EQ(0, gles2_implementation_->use_count_); |
| 610 ++gles2_implementation_->use_count_; |
| 611 } |
| 612 |
| 613 GLES2Implementation::SingleThreadChecker::~SingleThreadChecker() { |
| 614 --gles2_implementation_->use_count_; |
| 615 GPU_CHECK_EQ(0, gles2_implementation_->use_count_); |
| 616 } |
| 617 |
| 606 GLES2Implementation::GLES2Implementation( | 618 GLES2Implementation::GLES2Implementation( |
| 607 GLES2CmdHelper* helper, | 619 GLES2CmdHelper* helper, |
| 608 size_t transfer_buffer_size, | 620 size_t transfer_buffer_size, |
| 609 void* transfer_buffer, | 621 void* transfer_buffer, |
| 610 int32 transfer_buffer_id, | 622 int32 transfer_buffer_id, |
| 611 bool share_resources, | 623 bool share_resources, |
| 612 bool bind_generates_resource) | 624 bool bind_generates_resource) |
| 613 : helper_(helper), | 625 : helper_(helper), |
| 614 transfer_buffer_( | 626 transfer_buffer_( |
| 615 helper, | 627 helper, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 626 active_texture_unit_(0), | 638 active_texture_unit_(0), |
| 627 bound_framebuffer_(0), | 639 bound_framebuffer_(0), |
| 628 bound_renderbuffer_(0), | 640 bound_renderbuffer_(0), |
| 629 bound_array_buffer_id_(0), | 641 bound_array_buffer_id_(0), |
| 630 bound_element_array_buffer_id_(0), | 642 bound_element_array_buffer_id_(0), |
| 631 client_side_array_id_(0), | 643 client_side_array_id_(0), |
| 632 client_side_element_array_id_(0), | 644 client_side_element_array_id_(0), |
| 633 error_bits_(0), | 645 error_bits_(0), |
| 634 debug_(false), | 646 debug_(false), |
| 635 sharing_resources_(share_resources), | 647 sharing_resources_(share_resources), |
| 636 bind_generates_resource_(bind_generates_resource) { | 648 bind_generates_resource_(bind_generates_resource), |
| 649 use_count_(0) { |
| 637 GPU_CLIENT_LOG_CODE_BLOCK({ | 650 GPU_CLIENT_LOG_CODE_BLOCK({ |
| 638 debug_ = CommandLine::ForCurrentProcess()->HasSwitch( | 651 debug_ = CommandLine::ForCurrentProcess()->HasSwitch( |
| 639 switches::kEnableGPUClientLogging); | 652 switches::kEnableGPUClientLogging); |
| 640 }); | 653 }); |
| 641 | 654 |
| 642 memset(&reserved_ids_, 0, sizeof(reserved_ids_)); | 655 memset(&reserved_ids_, 0, sizeof(reserved_ids_)); |
| 643 | 656 |
| 644 mapped_memory_.reset(new MappedMemoryManager(helper_)); | 657 mapped_memory_.reset(new MappedMemoryManager(helper_)); |
| 645 SetSharedMemoryChunkSizeMultiple(1024 * 1024 * 2); | 658 SetSharedMemoryChunkSizeMultiple(1024 * 1024 * 2); |
| 646 | 659 |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 angle_pack_reverse_row_order_status = kAvailableExtensionStatus; | 773 angle_pack_reverse_row_order_status = kAvailableExtensionStatus; |
| 761 return true; | 774 return true; |
| 762 } else { | 775 } else { |
| 763 angle_pack_reverse_row_order_status = kUnavailableExtensionStatus; | 776 angle_pack_reverse_row_order_status = kUnavailableExtensionStatus; |
| 764 return false; | 777 return false; |
| 765 } | 778 } |
| 766 } | 779 } |
| 767 } | 780 } |
| 768 | 781 |
| 769 GLenum GLES2Implementation::GetError() { | 782 GLenum GLES2Implementation::GetError() { |
| 783 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 770 GPU_CLIENT_LOG("[" << this << "] glGetError()"); | 784 GPU_CLIENT_LOG("[" << this << "] glGetError()"); |
| 771 GLenum err = GetGLError(); | 785 GLenum err = GetGLError(); |
| 772 GPU_CLIENT_LOG("returned " << GLES2Util::GetStringError(err)); | 786 GPU_CLIENT_LOG("returned " << GLES2Util::GetStringError(err)); |
| 773 return err; | 787 return err; |
| 774 } | 788 } |
| 775 | 789 |
| 776 GLenum GLES2Implementation::GetGLError() { | 790 GLenum GLES2Implementation::GetGLError() { |
| 777 TRACE_EVENT0("gpu", "GLES2::GetGLError"); | 791 TRACE_EVENT0("gpu", "GLES2::GetGLError"); |
| 778 // Check the GL error first, then our wrapped error. | 792 // Check the GL error first, then our wrapped error. |
| 779 typedef gles2::GetError::Result Result; | 793 typedef gles2::GetError::Result Result; |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 998 *params = static_cast<GLfloat>(value); | 1012 *params = static_cast<GLfloat>(value); |
| 999 return true; | 1013 return true; |
| 1000 } | 1014 } |
| 1001 | 1015 |
| 1002 bool GLES2Implementation::GetIntegervHelper(GLenum pname, GLint* params) { | 1016 bool GLES2Implementation::GetIntegervHelper(GLenum pname, GLint* params) { |
| 1003 return GetHelper(pname, params); | 1017 return GetHelper(pname, params); |
| 1004 } | 1018 } |
| 1005 | 1019 |
| 1006 void GLES2Implementation::DrawElements( | 1020 void GLES2Implementation::DrawElements( |
| 1007 GLenum mode, GLsizei count, GLenum type, const void* indices) { | 1021 GLenum mode, GLsizei count, GLenum type, const void* indices) { |
| 1022 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 1008 GPU_CLIENT_LOG("[" << this << "] glDrawElements(" | 1023 GPU_CLIENT_LOG("[" << this << "] glDrawElements(" |
| 1009 << GLES2Util::GetStringDrawMode(mode) << ", " | 1024 << GLES2Util::GetStringDrawMode(mode) << ", " |
| 1010 << count << ", " | 1025 << count << ", " |
| 1011 << GLES2Util::GetStringIndexType(type) << ", " | 1026 << GLES2Util::GetStringIndexType(type) << ", " |
| 1012 << static_cast<const void*>(indices) << ")"); | 1027 << static_cast<const void*>(indices) << ")"); |
| 1013 if (count < 0) { | 1028 if (count < 0) { |
| 1014 SetGLError(GL_INVALID_VALUE, "glDrawElements: count less than 0."); | 1029 SetGLError(GL_INVALID_VALUE, "glDrawElements: count less than 0."); |
| 1015 return; | 1030 return; |
| 1016 } | 1031 } |
| 1017 if (count == 0) { | 1032 if (count == 0) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1050 if (bound_element_array_buffer_id_ == 0) { | 1065 if (bound_element_array_buffer_id_ == 0) { |
| 1051 // Restore the element array binding. | 1066 // Restore the element array binding. |
| 1052 helper_->BindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); | 1067 helper_->BindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); |
| 1053 } | 1068 } |
| 1054 #else | 1069 #else |
| 1055 helper_->DrawElements(mode, count, type, ToGLuint(indices)); | 1070 helper_->DrawElements(mode, count, type, ToGLuint(indices)); |
| 1056 #endif | 1071 #endif |
| 1057 } | 1072 } |
| 1058 | 1073 |
| 1059 void GLES2Implementation::Flush() { | 1074 void GLES2Implementation::Flush() { |
| 1075 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 1060 GPU_CLIENT_LOG("[" << this << "] glFlush()"); | 1076 GPU_CLIENT_LOG("[" << this << "] glFlush()"); |
| 1061 // Insert the cmd to call glFlush | 1077 // Insert the cmd to call glFlush |
| 1062 helper_->Flush(); | 1078 helper_->Flush(); |
| 1063 // Flush our command buffer | 1079 // Flush our command buffer |
| 1064 // (tell the service to execute up to the flush cmd.) | 1080 // (tell the service to execute up to the flush cmd.) |
| 1065 helper_->CommandBufferHelper::Flush(); | 1081 helper_->CommandBufferHelper::Flush(); |
| 1066 } | 1082 } |
| 1067 | 1083 |
| 1068 void GLES2Implementation::Finish() { | 1084 void GLES2Implementation::Finish() { |
| 1085 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 1069 GPU_CLIENT_LOG("[" << this << "] glFinish()"); | 1086 GPU_CLIENT_LOG("[" << this << "] glFinish()"); |
| 1070 TRACE_EVENT0("gpu", "GLES2::Finish"); | 1087 TRACE_EVENT0("gpu", "GLES2::Finish"); |
| 1071 // Insert the cmd to call glFinish | 1088 // Insert the cmd to call glFinish |
| 1072 helper_->Finish(); | 1089 helper_->Finish(); |
| 1073 // Finish our command buffer | 1090 // Finish our command buffer |
| 1074 // (tell the service to execute up to the Finish cmd and wait for it to | 1091 // (tell the service to execute up to the Finish cmd and wait for it to |
| 1075 // execute.) | 1092 // execute.) |
| 1076 helper_->CommandBufferHelper::Finish(); | 1093 helper_->CommandBufferHelper::Finish(); |
| 1077 } | 1094 } |
| 1078 | 1095 |
| 1079 void GLES2Implementation::SwapBuffers() { | 1096 void GLES2Implementation::SwapBuffers() { |
| 1097 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 1080 GPU_CLIENT_LOG("[" << this << "] glSwapBuffers()"); | 1098 GPU_CLIENT_LOG("[" << this << "] glSwapBuffers()"); |
| 1081 // TODO(piman): Strictly speaking we'd want to insert the token after the | 1099 // TODO(piman): Strictly speaking we'd want to insert the token after the |
| 1082 // swap, but the state update with the updated token might not have happened | 1100 // swap, but the state update with the updated token might not have happened |
| 1083 // by the time the SwapBuffer callback gets called, forcing us to synchronize | 1101 // by the time the SwapBuffer callback gets called, forcing us to synchronize |
| 1084 // with the GPU process more than needed. So instead, make it happen before. | 1102 // with the GPU process more than needed. So instead, make it happen before. |
| 1085 // All it means is that we could be slightly looser on the kMaxSwapBuffers | 1103 // All it means is that we could be slightly looser on the kMaxSwapBuffers |
| 1086 // semantics if the client doesn't use the callback mechanism, and by chance | 1104 // semantics if the client doesn't use the callback mechanism, and by chance |
| 1087 // the scheduler yields between the InsertToken and the SwapBuffers. | 1105 // the scheduler yields between the InsertToken and the SwapBuffers. |
| 1088 swap_buffers_tokens_.push(helper_->InsertToken()); | 1106 swap_buffers_tokens_.push(helper_->InsertToken()); |
| 1089 helper_->SwapBuffers(); | 1107 helper_->SwapBuffers(); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1178 transfer_buffer->GetOffset(id_buffer)); | 1196 transfer_buffer->GetOffset(id_buffer)); |
| 1179 WaitForCmd(); | 1197 WaitForCmd(); |
| 1180 transfer_buffer->FreePendingToken(id_buffer, helper_->InsertToken()); | 1198 transfer_buffer->FreePendingToken(id_buffer, helper_->InsertToken()); |
| 1181 n -= num; | 1199 n -= num; |
| 1182 ids += num; | 1200 ids += num; |
| 1183 } | 1201 } |
| 1184 } | 1202 } |
| 1185 | 1203 |
| 1186 void GLES2Implementation::BindAttribLocation( | 1204 void GLES2Implementation::BindAttribLocation( |
| 1187 GLuint program, GLuint index, const char* name) { | 1205 GLuint program, GLuint index, const char* name) { |
| 1206 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 1188 GPU_CLIENT_LOG("[" << this << "] glBindAttribLocation(" << program << ", " | 1207 GPU_CLIENT_LOG("[" << this << "] glBindAttribLocation(" << program << ", " |
| 1189 << index << ", " << name << ")"); | 1208 << index << ", " << name << ")"); |
| 1190 SetBucketAsString(kResultBucketId, name); | 1209 SetBucketAsString(kResultBucketId, name); |
| 1191 helper_->BindAttribLocationBucket(program, index, kResultBucketId); | 1210 helper_->BindAttribLocationBucket(program, index, kResultBucketId); |
| 1192 helper_->SetBucketSize(kResultBucketId, 0); | 1211 helper_->SetBucketSize(kResultBucketId, 0); |
| 1193 } | 1212 } |
| 1194 | 1213 |
| 1195 void GLES2Implementation::GetVertexAttribPointerv( | 1214 void GLES2Implementation::GetVertexAttribPointerv( |
| 1196 GLuint index, GLenum pname, void** ptr) { | 1215 GLuint index, GLenum pname, void** ptr) { |
| 1216 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 1197 GPU_CLIENT_LOG("[" << this << "] glGetVertexAttribPointer(" << index << ", " | 1217 GPU_CLIENT_LOG("[" << this << "] glGetVertexAttribPointer(" << index << ", " |
| 1198 << GLES2Util::GetStringVertexPointer(pname) << ", " | 1218 << GLES2Util::GetStringVertexPointer(pname) << ", " |
| 1199 << static_cast<void*>(ptr) << ")"); | 1219 << static_cast<void*>(ptr) << ")"); |
| 1200 | 1220 |
| 1201 #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) | 1221 #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) |
| 1202 // If it's a client side buffer the client has the data. | 1222 // If it's a client side buffer the client has the data. |
| 1203 if (client_side_buffer_helper_->GetAttribPointer(index, pname, ptr)) { | 1223 if (client_side_buffer_helper_->GetAttribPointer(index, pname, ptr)) { |
| 1204 return; | 1224 return; |
| 1205 } | 1225 } |
| 1206 #endif // defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) | 1226 #endif // defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1252 SetBucketAsCString(kResultBucketId, name); | 1272 SetBucketAsCString(kResultBucketId, name); |
| 1253 helper_->GetAttribLocationBucket( | 1273 helper_->GetAttribLocationBucket( |
| 1254 program, kResultBucketId, GetResultShmId(), GetResultShmOffset()); | 1274 program, kResultBucketId, GetResultShmId(), GetResultShmOffset()); |
| 1255 WaitForCmd(); | 1275 WaitForCmd(); |
| 1256 helper_->SetBucketSize(kResultBucketId, 0); | 1276 helper_->SetBucketSize(kResultBucketId, 0); |
| 1257 return *result; | 1277 return *result; |
| 1258 } | 1278 } |
| 1259 | 1279 |
| 1260 GLint GLES2Implementation::GetAttribLocation( | 1280 GLint GLES2Implementation::GetAttribLocation( |
| 1261 GLuint program, const char* name) { | 1281 GLuint program, const char* name) { |
| 1282 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 1262 GPU_CLIENT_LOG("[" << this << "] glGetAttribLocation(" << program | 1283 GPU_CLIENT_LOG("[" << this << "] glGetAttribLocation(" << program |
| 1263 << ", " << name << ")"); | 1284 << ", " << name << ")"); |
| 1264 TRACE_EVENT0("gpu", "GLES2::GetAttribLocation"); | 1285 TRACE_EVENT0("gpu", "GLES2::GetAttribLocation"); |
| 1265 GLint loc = program_info_manager_->GetAttribLocation(this, program, name); | 1286 GLint loc = program_info_manager_->GetAttribLocation(this, program, name); |
| 1266 GPU_CLIENT_LOG("returned " << loc); | 1287 GPU_CLIENT_LOG("returned " << loc); |
| 1267 return loc; | 1288 return loc; |
| 1268 } | 1289 } |
| 1269 | 1290 |
| 1270 GLint GLES2Implementation::GetUniformLocationHelper( | 1291 GLint GLES2Implementation::GetUniformLocationHelper( |
| 1271 GLuint program, const char* name) { | 1292 GLuint program, const char* name) { |
| 1272 typedef GetUniformLocationBucket::Result Result; | 1293 typedef GetUniformLocationBucket::Result Result; |
| 1273 Result* result = GetResultAs<Result*>(); | 1294 Result* result = GetResultAs<Result*>(); |
| 1274 *result = -1; | 1295 *result = -1; |
| 1275 SetBucketAsCString(kResultBucketId, name); | 1296 SetBucketAsCString(kResultBucketId, name); |
| 1276 helper_->GetUniformLocationBucket(program, kResultBucketId, | 1297 helper_->GetUniformLocationBucket(program, kResultBucketId, |
| 1277 GetResultShmId(), GetResultShmOffset()); | 1298 GetResultShmId(), GetResultShmOffset()); |
| 1278 WaitForCmd(); | 1299 WaitForCmd(); |
| 1279 helper_->SetBucketSize(kResultBucketId, 0); | 1300 helper_->SetBucketSize(kResultBucketId, 0); |
| 1280 return *result; | 1301 return *result; |
| 1281 } | 1302 } |
| 1282 | 1303 |
| 1283 GLint GLES2Implementation::GetUniformLocation( | 1304 GLint GLES2Implementation::GetUniformLocation( |
| 1284 GLuint program, const char* name) { | 1305 GLuint program, const char* name) { |
| 1306 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 1285 GPU_CLIENT_LOG("[" << this << "] glGetUniformLocation(" << program | 1307 GPU_CLIENT_LOG("[" << this << "] glGetUniformLocation(" << program |
| 1286 << ", " << name << ")"); | 1308 << ", " << name << ")"); |
| 1287 TRACE_EVENT0("gpu", "GLES2::GetUniformLocation"); | 1309 TRACE_EVENT0("gpu", "GLES2::GetUniformLocation"); |
| 1288 GLint loc = program_info_manager_->GetUniformLocation(this, program, name); | 1310 GLint loc = program_info_manager_->GetUniformLocation(this, program, name); |
| 1289 GPU_CLIENT_LOG("returned " << loc); | 1311 GPU_CLIENT_LOG("returned " << loc); |
| 1290 return loc; | 1312 return loc; |
| 1291 } | 1313 } |
| 1292 | 1314 |
| 1293 bool GLES2Implementation::GetProgramivHelper( | 1315 bool GLES2Implementation::GetProgramivHelper( |
| 1294 GLuint program, GLenum pname, GLint* params) { | 1316 GLuint program, GLenum pname, GLint* params) { |
| 1295 return program_info_manager_->GetProgramiv(this, program, pname, params); | 1317 return program_info_manager_->GetProgramiv(this, program, pname, params); |
| 1296 } | 1318 } |
| 1297 | 1319 |
| 1298 void GLES2Implementation::LinkProgram(GLuint program) { | 1320 void GLES2Implementation::LinkProgram(GLuint program) { |
| 1321 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 1299 GPU_CLIENT_LOG("[" << this << "] glLinkProgram(" << program << ")"); | 1322 GPU_CLIENT_LOG("[" << this << "] glLinkProgram(" << program << ")"); |
| 1300 helper_->LinkProgram(program); | 1323 helper_->LinkProgram(program); |
| 1301 program_info_manager_->CreateInfo(program); | 1324 program_info_manager_->CreateInfo(program); |
| 1302 } | 1325 } |
| 1303 | 1326 |
| 1304 void GLES2Implementation::ShaderBinary( | 1327 void GLES2Implementation::ShaderBinary( |
| 1305 GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, | 1328 GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, |
| 1306 GLsizei length) { | 1329 GLsizei length) { |
| 1330 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 1307 GPU_CLIENT_LOG("[" << this << "] glShaderBinary(" << n << ", " | 1331 GPU_CLIENT_LOG("[" << this << "] glShaderBinary(" << n << ", " |
| 1308 << static_cast<const void*>(shaders) << ", " | 1332 << static_cast<const void*>(shaders) << ", " |
| 1309 << GLES2Util::GetStringEnum(binaryformat) << ", " | 1333 << GLES2Util::GetStringEnum(binaryformat) << ", " |
| 1310 << static_cast<const void*>(binary) << ", " | 1334 << static_cast<const void*>(binary) << ", " |
| 1311 << length << ")"); | 1335 << length << ")"); |
| 1312 if (n < 0) { | 1336 if (n < 0) { |
| 1313 SetGLError(GL_INVALID_VALUE, "glShaderBinary n < 0."); | 1337 SetGLError(GL_INVALID_VALUE, "glShaderBinary n < 0."); |
| 1314 return; | 1338 return; |
| 1315 } | 1339 } |
| 1316 if (length < 0) { | 1340 if (length < 0) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1329 transfer_buffer->GetShmId(), | 1353 transfer_buffer->GetShmId(), |
| 1330 transfer_buffer->GetOffset(shader_ids), | 1354 transfer_buffer->GetOffset(shader_ids), |
| 1331 binaryformat, | 1355 binaryformat, |
| 1332 transfer_buffer->GetShmId(), | 1356 transfer_buffer->GetShmId(), |
| 1333 transfer_buffer->GetOffset(shader_data), | 1357 transfer_buffer->GetOffset(shader_data), |
| 1334 length); | 1358 length); |
| 1335 transfer_buffer->FreePendingToken(buffer, helper_->InsertToken()); | 1359 transfer_buffer->FreePendingToken(buffer, helper_->InsertToken()); |
| 1336 } | 1360 } |
| 1337 | 1361 |
| 1338 void GLES2Implementation::PixelStorei(GLenum pname, GLint param) { | 1362 void GLES2Implementation::PixelStorei(GLenum pname, GLint param) { |
| 1363 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 1339 GPU_CLIENT_LOG("[" << this << "] glPixelStorei(" | 1364 GPU_CLIENT_LOG("[" << this << "] glPixelStorei(" |
| 1340 << GLES2Util::GetStringPixelStore(pname) << ", " | 1365 << GLES2Util::GetStringPixelStore(pname) << ", " |
| 1341 << param << ")"); | 1366 << param << ")"); |
| 1342 switch (pname) { | 1367 switch (pname) { |
| 1343 case GL_PACK_ALIGNMENT: | 1368 case GL_PACK_ALIGNMENT: |
| 1344 pack_alignment_ = param; | 1369 pack_alignment_ = param; |
| 1345 break; | 1370 break; |
| 1346 case GL_UNPACK_ALIGNMENT: | 1371 case GL_UNPACK_ALIGNMENT: |
| 1347 unpack_alignment_ = param; | 1372 unpack_alignment_ = param; |
| 1348 break; | 1373 break; |
| 1349 case GL_UNPACK_FLIP_Y_CHROMIUM: | 1374 case GL_UNPACK_FLIP_Y_CHROMIUM: |
| 1350 unpack_flip_y_ = (param != 0); | 1375 unpack_flip_y_ = (param != 0); |
| 1351 return; | 1376 return; |
| 1352 case GL_PACK_REVERSE_ROW_ORDER_ANGLE: | 1377 case GL_PACK_REVERSE_ROW_ORDER_ANGLE: |
| 1353 pack_reverse_row_order_ = | 1378 pack_reverse_row_order_ = |
| 1354 IsAnglePackReverseRowOrderAvailable() ? (param != 0) : false; | 1379 IsAnglePackReverseRowOrderAvailable() ? (param != 0) : false; |
| 1355 break; | 1380 break; |
| 1356 default: | 1381 default: |
| 1357 break; | 1382 break; |
| 1358 } | 1383 } |
| 1359 helper_->PixelStorei(pname, param); | 1384 helper_->PixelStorei(pname, param); |
| 1360 } | 1385 } |
| 1361 | 1386 |
| 1362 | 1387 |
| 1363 void GLES2Implementation::VertexAttribPointer( | 1388 void GLES2Implementation::VertexAttribPointer( |
| 1364 GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, | 1389 GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, |
| 1365 const void* ptr) { | 1390 const void* ptr) { |
| 1391 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 1366 GPU_CLIENT_LOG("[" << this << "] glVertexAttribPointer(" | 1392 GPU_CLIENT_LOG("[" << this << "] glVertexAttribPointer(" |
| 1367 << index << ", " | 1393 << index << ", " |
| 1368 << size << ", " | 1394 << size << ", " |
| 1369 << GLES2Util::GetStringVertexAttribType(type) << ", " | 1395 << GLES2Util::GetStringVertexAttribType(type) << ", " |
| 1370 << GLES2Util::GetStringBool(normalized) << ", " | 1396 << GLES2Util::GetStringBool(normalized) << ", " |
| 1371 << stride << ", " | 1397 << stride << ", " |
| 1372 << static_cast<const void*>(ptr) << ")"); | 1398 << static_cast<const void*>(ptr) << ")"); |
| 1373 #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) | 1399 #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) |
| 1374 // Record the info on the client side. | 1400 // Record the info on the client side. |
| 1375 client_side_buffer_helper_->SetAttribPointer( | 1401 client_side_buffer_helper_->SetAttribPointer( |
| 1376 bound_array_buffer_id_, index, size, type, normalized, stride, ptr); | 1402 bound_array_buffer_id_, index, size, type, normalized, stride, ptr); |
| 1377 if (bound_array_buffer_id_ != 0) { | 1403 if (bound_array_buffer_id_ != 0) { |
| 1378 // Only report NON client side buffers to the service. | 1404 // Only report NON client side buffers to the service. |
| 1379 helper_->VertexAttribPointer(index, size, type, normalized, stride, | 1405 helper_->VertexAttribPointer(index, size, type, normalized, stride, |
| 1380 ToGLuint(ptr)); | 1406 ToGLuint(ptr)); |
| 1381 } | 1407 } |
| 1382 #else // !defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) | 1408 #else // !defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) |
| 1383 helper_->VertexAttribPointer(index, size, type, normalized, stride, | 1409 helper_->VertexAttribPointer(index, size, type, normalized, stride, |
| 1384 ToGLuint(ptr)); | 1410 ToGLuint(ptr)); |
| 1385 #endif // !defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) | 1411 #endif // !defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) |
| 1386 } | 1412 } |
| 1387 | 1413 |
| 1388 void GLES2Implementation::ShaderSource( | 1414 void GLES2Implementation::ShaderSource( |
| 1389 GLuint shader, GLsizei count, const char** source, const GLint* length) { | 1415 GLuint shader, GLsizei count, const char** source, const GLint* length) { |
| 1416 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 1390 GPU_CLIENT_LOG("[" << this << "] glShaderSource(" | 1417 GPU_CLIENT_LOG("[" << this << "] glShaderSource(" |
| 1391 << shader << ", " << count << ", " | 1418 << shader << ", " << count << ", " |
| 1392 << static_cast<const void*>(source) << ", " | 1419 << static_cast<const void*>(source) << ", " |
| 1393 << static_cast<const void*>(length) << ")"); | 1420 << static_cast<const void*>(length) << ")"); |
| 1394 GPU_CLIENT_LOG_CODE_BLOCK({ | 1421 GPU_CLIENT_LOG_CODE_BLOCK({ |
| 1395 for (GLsizei ii = 0; ii < count; ++ii) { | 1422 for (GLsizei ii = 0; ii < count; ++ii) { |
| 1396 if (source[ii]) { | 1423 if (source[ii]) { |
| 1397 if (length && length[ii] >= 0) { | 1424 if (length && length[ii] >= 0) { |
| 1398 std::string str(source[ii], length[ii]); | 1425 std::string str(source[ii], length[ii]); |
| 1399 GPU_CLIENT_LOG(" " << ii << ": ---\n" << str << "\n---"); | 1426 GPU_CLIENT_LOG(" " << ii << ": ---\n" << str << "\n---"); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1449 } | 1476 } |
| 1450 | 1477 |
| 1451 GPU_DCHECK_EQ(total_size, offset); | 1478 GPU_DCHECK_EQ(total_size, offset); |
| 1452 | 1479 |
| 1453 helper_->ShaderSourceBucket(shader, kResultBucketId); | 1480 helper_->ShaderSourceBucket(shader, kResultBucketId); |
| 1454 helper_->SetBucketSize(kResultBucketId, 0); | 1481 helper_->SetBucketSize(kResultBucketId, 0); |
| 1455 } | 1482 } |
| 1456 | 1483 |
| 1457 void GLES2Implementation::BufferData( | 1484 void GLES2Implementation::BufferData( |
| 1458 GLenum target, GLsizeiptr size, const void* data, GLenum usage) { | 1485 GLenum target, GLsizeiptr size, const void* data, GLenum usage) { |
| 1486 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 1459 GPU_CLIENT_LOG("[" << this << "] glBufferData(" | 1487 GPU_CLIENT_LOG("[" << this << "] glBufferData(" |
| 1460 << GLES2Util::GetStringBufferTarget(target) << ", " | 1488 << GLES2Util::GetStringBufferTarget(target) << ", " |
| 1461 << size << ", " | 1489 << size << ", " |
| 1462 << static_cast<const void*>(data) << ", " | 1490 << static_cast<const void*>(data) << ", " |
| 1463 << GLES2Util::GetStringBufferUsage(usage) << ")"); | 1491 << GLES2Util::GetStringBufferUsage(usage) << ")"); |
| 1464 AlignedRingBuffer* transfer_buffer = transfer_buffer_.GetBuffer(); | 1492 AlignedRingBuffer* transfer_buffer = transfer_buffer_.GetBuffer(); |
| 1465 GLsizeiptr max_size = transfer_buffer->GetLargestFreeOrPendingSize(); | 1493 GLsizeiptr max_size = transfer_buffer->GetLargestFreeOrPendingSize(); |
| 1466 if (size > max_size || !data) { | 1494 if (size > max_size || !data) { |
| 1467 helper_->BufferData(target, size, 0, 0, usage); | 1495 helper_->BufferData(target, size, 0, 0, usage); |
| 1468 if (data != NULL) { | 1496 if (data != NULL) { |
| 1469 BufferSubData(target, 0, size, data); | 1497 BufferSubData(target, 0, size, data); |
| 1470 } | 1498 } |
| 1471 return; | 1499 return; |
| 1472 } | 1500 } |
| 1473 | 1501 |
| 1474 void* buffer = transfer_buffer->Alloc(size); | 1502 void* buffer = transfer_buffer->Alloc(size); |
| 1475 memcpy(buffer, data, size); | 1503 memcpy(buffer, data, size); |
| 1476 helper_->BufferData( | 1504 helper_->BufferData( |
| 1477 target, | 1505 target, |
| 1478 size, | 1506 size, |
| 1479 transfer_buffer->GetShmId(), | 1507 transfer_buffer->GetShmId(), |
| 1480 transfer_buffer->GetOffset(buffer), | 1508 transfer_buffer->GetOffset(buffer), |
| 1481 usage); | 1509 usage); |
| 1482 transfer_buffer->FreePendingToken(buffer, helper_->InsertToken()); | 1510 transfer_buffer->FreePendingToken(buffer, helper_->InsertToken()); |
| 1483 } | 1511 } |
| 1484 | 1512 |
| 1485 void GLES2Implementation::BufferSubData( | 1513 void GLES2Implementation::BufferSubData( |
| 1486 GLenum target, GLintptr offset, GLsizeiptr size, const void* data) { | 1514 GLenum target, GLintptr offset, GLsizeiptr size, const void* data) { |
| 1515 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 1487 GPU_CLIENT_LOG("[" << this << "] glBufferSubData(" | 1516 GPU_CLIENT_LOG("[" << this << "] glBufferSubData(" |
| 1488 << GLES2Util::GetStringBufferTarget(target) << ", " | 1517 << GLES2Util::GetStringBufferTarget(target) << ", " |
| 1489 << offset << ", " << size << ", " | 1518 << offset << ", " << size << ", " |
| 1490 << static_cast<const void*>(data) << ")"); | 1519 << static_cast<const void*>(data) << ")"); |
| 1491 if (size == 0) { | 1520 if (size == 0) { |
| 1492 return; | 1521 return; |
| 1493 } | 1522 } |
| 1494 | 1523 |
| 1495 if (size < 0) { | 1524 if (size < 0) { |
| 1496 SetGLError(GL_INVALID_VALUE, "glBufferSubData: size < 0"); | 1525 SetGLError(GL_INVALID_VALUE, "glBufferSubData: size < 0"); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1510 transfer_buffer->FreePendingToken(buffer, helper_->InsertToken()); | 1539 transfer_buffer->FreePendingToken(buffer, helper_->InsertToken()); |
| 1511 offset += part_size; | 1540 offset += part_size; |
| 1512 source += part_size; | 1541 source += part_size; |
| 1513 size -= part_size; | 1542 size -= part_size; |
| 1514 } | 1543 } |
| 1515 } | 1544 } |
| 1516 | 1545 |
| 1517 void GLES2Implementation::CompressedTexImage2D( | 1546 void GLES2Implementation::CompressedTexImage2D( |
| 1518 GLenum target, GLint level, GLenum internalformat, GLsizei width, | 1547 GLenum target, GLint level, GLenum internalformat, GLsizei width, |
| 1519 GLsizei height, GLint border, GLsizei image_size, const void* data) { | 1548 GLsizei height, GLint border, GLsizei image_size, const void* data) { |
| 1549 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 1520 GPU_CLIENT_LOG("[" << this << "] glCompressedTexImage2D(" | 1550 GPU_CLIENT_LOG("[" << this << "] glCompressedTexImage2D(" |
| 1521 << GLES2Util::GetStringTextureTarget(target) << ", " | 1551 << GLES2Util::GetStringTextureTarget(target) << ", " |
| 1522 << level << ", " | 1552 << level << ", " |
| 1523 << GLES2Util::GetStringCompressedTextureFormat(internalformat) << ", " | 1553 << GLES2Util::GetStringCompressedTextureFormat(internalformat) << ", " |
| 1524 << width << ", " << height << ", " << border << ", " | 1554 << width << ", " << height << ", " << border << ", " |
| 1525 << image_size << ", " | 1555 << image_size << ", " |
| 1526 << static_cast<const void*>(data) << ")"); | 1556 << static_cast<const void*>(data) << ")"); |
| 1527 if (width < 0 || height < 0 || level < 0) { | 1557 if (width < 0 || height < 0 || level < 0) { |
| 1528 SetGLError(GL_INVALID_VALUE, "glCompressedTexImage2D dimension < 0"); | 1558 SetGLError(GL_INVALID_VALUE, "glCompressedTexImage2D dimension < 0"); |
| 1529 return; | 1559 return; |
| 1530 } | 1560 } |
| 1531 if (height == 0 || width == 0) { | 1561 if (height == 0 || width == 0) { |
| 1532 return; | 1562 return; |
| 1533 } | 1563 } |
| 1534 SetBucketContents(kResultBucketId, data, image_size); | 1564 SetBucketContents(kResultBucketId, data, image_size); |
| 1535 helper_->CompressedTexImage2DBucket( | 1565 helper_->CompressedTexImage2DBucket( |
| 1536 target, level, internalformat, width, height, border, kResultBucketId); | 1566 target, level, internalformat, width, height, border, kResultBucketId); |
| 1537 // Free the bucket. This is not required but it does free up the memory. | 1567 // Free the bucket. This is not required but it does free up the memory. |
| 1538 // and we don't have to wait for the result so from the client's perspective | 1568 // and we don't have to wait for the result so from the client's perspective |
| 1539 // it's cheap. | 1569 // it's cheap. |
| 1540 helper_->SetBucketSize(kResultBucketId, 0); | 1570 helper_->SetBucketSize(kResultBucketId, 0); |
| 1541 } | 1571 } |
| 1542 | 1572 |
| 1543 void GLES2Implementation::CompressedTexSubImage2D( | 1573 void GLES2Implementation::CompressedTexSubImage2D( |
| 1544 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, | 1574 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, |
| 1545 GLsizei height, GLenum format, GLsizei image_size, const void* data) { | 1575 GLsizei height, GLenum format, GLsizei image_size, const void* data) { |
| 1576 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 1546 GPU_CLIENT_LOG("[" << this << "] glCompressedTexSubImage2D(" | 1577 GPU_CLIENT_LOG("[" << this << "] glCompressedTexSubImage2D(" |
| 1547 << GLES2Util::GetStringTextureTarget(target) << ", " | 1578 << GLES2Util::GetStringTextureTarget(target) << ", " |
| 1548 << level << ", " | 1579 << level << ", " |
| 1549 << xoffset << ", " << yoffset << ", " | 1580 << xoffset << ", " << yoffset << ", " |
| 1550 << width << ", " << height << ", " | 1581 << width << ", " << height << ", " |
| 1551 << GLES2Util::GetStringCompressedTextureFormat(format) << ", " | 1582 << GLES2Util::GetStringCompressedTextureFormat(format) << ", " |
| 1552 << image_size << ", " | 1583 << image_size << ", " |
| 1553 << static_cast<const void*>(data) << ")"); | 1584 << static_cast<const void*>(data) << ")"); |
| 1554 if (width < 0 || height < 0 || level < 0) { | 1585 if (width < 0 || height < 0 || level < 0) { |
| 1555 SetGLError(GL_INVALID_VALUE, "glCompressedTexSubImage2D dimension < 0"); | 1586 SetGLError(GL_INVALID_VALUE, "glCompressedTexSubImage2D dimension < 0"); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1600 dest -= padded_row_size; | 1631 dest -= padded_row_size; |
| 1601 source += padded_row_size; | 1632 source += padded_row_size; |
| 1602 } | 1633 } |
| 1603 return true; | 1634 return true; |
| 1604 } | 1635 } |
| 1605 | 1636 |
| 1606 void GLES2Implementation::TexImage2D( | 1637 void GLES2Implementation::TexImage2D( |
| 1607 GLenum target, GLint level, GLint internalformat, GLsizei width, | 1638 GLenum target, GLint level, GLint internalformat, GLsizei width, |
| 1608 GLsizei height, GLint border, GLenum format, GLenum type, | 1639 GLsizei height, GLint border, GLenum format, GLenum type, |
| 1609 const void* pixels) { | 1640 const void* pixels) { |
| 1641 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 1610 GPU_CLIENT_LOG("[" << this << "] glTexImage2D(" | 1642 GPU_CLIENT_LOG("[" << this << "] glTexImage2D(" |
| 1611 << GLES2Util::GetStringTextureTarget(target) << ", " | 1643 << GLES2Util::GetStringTextureTarget(target) << ", " |
| 1612 << level << ", " | 1644 << level << ", " |
| 1613 << GLES2Util::GetStringTextureInternalFormat(internalformat) << ", " | 1645 << GLES2Util::GetStringTextureInternalFormat(internalformat) << ", " |
| 1614 << width << ", " << height << ", " << border << ", " | 1646 << width << ", " << height << ", " << border << ", " |
| 1615 << GLES2Util::GetStringTextureFormat(format) << ", " | 1647 << GLES2Util::GetStringTextureFormat(format) << ", " |
| 1616 << GLES2Util::GetStringPixelType(type) << ", " | 1648 << GLES2Util::GetStringPixelType(type) << ", " |
| 1617 << static_cast<const void*>(pixels) << ")"); | 1649 << static_cast<const void*>(pixels) << ")"); |
| 1618 if (level < 0 || height < 0 || width < 0) { | 1650 if (level < 0 || height < 0 || width < 0) { |
| 1619 SetGLError(GL_INVALID_VALUE, "glTexImage2D dimension < 0"); | 1651 SetGLError(GL_INVALID_VALUE, "glTexImage2D dimension < 0"); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1654 helper_->TexImage2D( | 1686 helper_->TexImage2D( |
| 1655 target, level, internalformat, width, height, border, format, type, | 1687 target, level, internalformat, width, height, border, format, type, |
| 1656 transfer_buffer->GetShmId(), transfer_buffer->GetOffset(buffer)); | 1688 transfer_buffer->GetShmId(), transfer_buffer->GetOffset(buffer)); |
| 1657 } | 1689 } |
| 1658 transfer_buffer->FreePendingToken(buffer, helper_->InsertToken()); | 1690 transfer_buffer->FreePendingToken(buffer, helper_->InsertToken()); |
| 1659 } | 1691 } |
| 1660 | 1692 |
| 1661 void GLES2Implementation::TexSubImage2D( | 1693 void GLES2Implementation::TexSubImage2D( |
| 1662 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, | 1694 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, |
| 1663 GLsizei height, GLenum format, GLenum type, const void* pixels) { | 1695 GLsizei height, GLenum format, GLenum type, const void* pixels) { |
| 1696 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 1664 GPU_CLIENT_LOG("[" << this << "] glTexSubImage2D(" | 1697 GPU_CLIENT_LOG("[" << this << "] glTexSubImage2D(" |
| 1665 << GLES2Util::GetStringTextureTarget(target) << ", " | 1698 << GLES2Util::GetStringTextureTarget(target) << ", " |
| 1666 << level << ", " | 1699 << level << ", " |
| 1667 << xoffset << ", " << yoffset << ", " | 1700 << xoffset << ", " << yoffset << ", " |
| 1668 << width << ", " << height << ", " | 1701 << width << ", " << height << ", " |
| 1669 << GLES2Util::GetStringTextureFormat(format) << ", " | 1702 << GLES2Util::GetStringTextureFormat(format) << ", " |
| 1670 << GLES2Util::GetStringPixelType(type) << ", " | 1703 << GLES2Util::GetStringPixelType(type) << ", " |
| 1671 << static_cast<const void*>(pixels) << ")"); | 1704 << static_cast<const void*>(pixels) << ")"); |
| 1672 TexSubImage2DImpl( | 1705 TexSubImage2DImpl( |
| 1673 target, level, xoffset, yoffset, width, height, format, type, pixels, | 1706 target, level, xoffset, yoffset, width, height, format, type, pixels, |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1801 name[max_size] = '\0'; | 1834 name[max_size] = '\0'; |
| 1802 } | 1835 } |
| 1803 } | 1836 } |
| 1804 } | 1837 } |
| 1805 return result->success != 0; | 1838 return result->success != 0; |
| 1806 } | 1839 } |
| 1807 | 1840 |
| 1808 void GLES2Implementation::GetActiveAttrib( | 1841 void GLES2Implementation::GetActiveAttrib( |
| 1809 GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, | 1842 GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, |
| 1810 GLenum* type, char* name) { | 1843 GLenum* type, char* name) { |
| 1844 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 1811 GPU_CLIENT_LOG("[" << this << "] glGetActiveAttrib(" | 1845 GPU_CLIENT_LOG("[" << this << "] glGetActiveAttrib(" |
| 1812 << program << ", " << index << ", " << bufsize << ", " | 1846 << program << ", " << index << ", " << bufsize << ", " |
| 1813 << static_cast<const void*>(length) << ", " | 1847 << static_cast<const void*>(length) << ", " |
| 1814 << static_cast<const void*>(size) << ", " | 1848 << static_cast<const void*>(size) << ", " |
| 1815 << static_cast<const void*>(type) << ", " | 1849 << static_cast<const void*>(type) << ", " |
| 1816 << static_cast<const void*>(name) << ", "); | 1850 << static_cast<const void*>(name) << ", "); |
| 1817 if (bufsize < 0) { | 1851 if (bufsize < 0) { |
| 1818 SetGLError(GL_INVALID_VALUE, "glGetActiveAttrib: bufsize < 0"); | 1852 SetGLError(GL_INVALID_VALUE, "glGetActiveAttrib: bufsize < 0"); |
| 1819 return; | 1853 return; |
| 1820 } | 1854 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1867 name[max_size] = '\0'; | 1901 name[max_size] = '\0'; |
| 1868 } | 1902 } |
| 1869 } | 1903 } |
| 1870 } | 1904 } |
| 1871 return result->success != 0; | 1905 return result->success != 0; |
| 1872 } | 1906 } |
| 1873 | 1907 |
| 1874 void GLES2Implementation::GetActiveUniform( | 1908 void GLES2Implementation::GetActiveUniform( |
| 1875 GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, | 1909 GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, |
| 1876 GLenum* type, char* name) { | 1910 GLenum* type, char* name) { |
| 1911 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 1877 GPU_CLIENT_LOG("[" << this << "] glGetActiveUniform(" | 1912 GPU_CLIENT_LOG("[" << this << "] glGetActiveUniform(" |
| 1878 << program << ", " << index << ", " << bufsize << ", " | 1913 << program << ", " << index << ", " << bufsize << ", " |
| 1879 << static_cast<const void*>(length) << ", " | 1914 << static_cast<const void*>(length) << ", " |
| 1880 << static_cast<const void*>(size) << ", " | 1915 << static_cast<const void*>(size) << ", " |
| 1881 << static_cast<const void*>(type) << ", " | 1916 << static_cast<const void*>(type) << ", " |
| 1882 << static_cast<const void*>(name) << ", "); | 1917 << static_cast<const void*>(name) << ", "); |
| 1883 if (bufsize < 0) { | 1918 if (bufsize < 0) { |
| 1884 SetGLError(GL_INVALID_VALUE, "glGetActiveUniform: bufsize < 0"); | 1919 SetGLError(GL_INVALID_VALUE, "glGetActiveUniform: bufsize < 0"); |
| 1885 return; | 1920 return; |
| 1886 } | 1921 } |
| 1887 TRACE_EVENT0("gpu", "GLES2::GetActiveUniform"); | 1922 TRACE_EVENT0("gpu", "GLES2::GetActiveUniform"); |
| 1888 bool success = program_info_manager_->GetActiveUniform( | 1923 bool success = program_info_manager_->GetActiveUniform( |
| 1889 this, program, index, bufsize, length, size, type, name); | 1924 this, program, index, bufsize, length, size, type, name); |
| 1890 if (success) { | 1925 if (success) { |
| 1891 if (size) { | 1926 if (size) { |
| 1892 GPU_CLIENT_LOG(" size: " << *size); | 1927 GPU_CLIENT_LOG(" size: " << *size); |
| 1893 } | 1928 } |
| 1894 if (type) { | 1929 if (type) { |
| 1895 GPU_CLIENT_LOG(" type: " << GLES2Util::GetStringEnum(*type)); | 1930 GPU_CLIENT_LOG(" type: " << GLES2Util::GetStringEnum(*type)); |
| 1896 } | 1931 } |
| 1897 if (name) { | 1932 if (name) { |
| 1898 GPU_CLIENT_LOG(" name: " << name); | 1933 GPU_CLIENT_LOG(" name: " << name); |
| 1899 } | 1934 } |
| 1900 } | 1935 } |
| 1901 } | 1936 } |
| 1902 | 1937 |
| 1903 void GLES2Implementation::GetAttachedShaders( | 1938 void GLES2Implementation::GetAttachedShaders( |
| 1904 GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) { | 1939 GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) { |
| 1940 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 1905 GPU_CLIENT_LOG("[" << this << "] glGetAttachedShaders(" | 1941 GPU_CLIENT_LOG("[" << this << "] glGetAttachedShaders(" |
| 1906 << program << ", " << maxcount << ", " | 1942 << program << ", " << maxcount << ", " |
| 1907 << static_cast<const void*>(count) << ", " | 1943 << static_cast<const void*>(count) << ", " |
| 1908 << static_cast<const void*>(shaders) << ", "); | 1944 << static_cast<const void*>(shaders) << ", "); |
| 1909 if (maxcount < 0) { | 1945 if (maxcount < 0) { |
| 1910 SetGLError(GL_INVALID_VALUE, "glGetAttachedShaders: maxcount < 0"); | 1946 SetGLError(GL_INVALID_VALUE, "glGetAttachedShaders: maxcount < 0"); |
| 1911 return; | 1947 return; |
| 1912 } | 1948 } |
| 1913 TRACE_EVENT0("gpu", "GLES2::GetAttachedShaders"); | 1949 TRACE_EVENT0("gpu", "GLES2::GetAttachedShaders"); |
| 1914 typedef gles2::GetAttachedShaders::Result Result; | 1950 typedef gles2::GetAttachedShaders::Result Result; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1930 GPU_CLIENT_LOG_CODE_BLOCK({ | 1966 GPU_CLIENT_LOG_CODE_BLOCK({ |
| 1931 for (int32 i = 0; i < result->GetNumResults(); ++i) { | 1967 for (int32 i = 0; i < result->GetNumResults(); ++i) { |
| 1932 GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]); | 1968 GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]); |
| 1933 } | 1969 } |
| 1934 }); | 1970 }); |
| 1935 transfer_buffer->FreePendingToken(result, token); | 1971 transfer_buffer->FreePendingToken(result, token); |
| 1936 } | 1972 } |
| 1937 | 1973 |
| 1938 void GLES2Implementation::GetShaderPrecisionFormat( | 1974 void GLES2Implementation::GetShaderPrecisionFormat( |
| 1939 GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) { | 1975 GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) { |
| 1976 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 1940 GPU_CLIENT_LOG("[" << this << "] glGetShaderPrecisionFormat(" | 1977 GPU_CLIENT_LOG("[" << this << "] glGetShaderPrecisionFormat(" |
| 1941 << GLES2Util::GetStringShaderType(shadertype) << ", " | 1978 << GLES2Util::GetStringShaderType(shadertype) << ", " |
| 1942 << GLES2Util::GetStringShaderPrecision(precisiontype) << ", " | 1979 << GLES2Util::GetStringShaderPrecision(precisiontype) << ", " |
| 1943 << static_cast<const void*>(range) << ", " | 1980 << static_cast<const void*>(range) << ", " |
| 1944 << static_cast<const void*>(precision) << ", "); | 1981 << static_cast<const void*>(precision) << ", "); |
| 1945 TRACE_EVENT0("gpu", "GLES2::GetShaderPrecisionFormat"); | 1982 TRACE_EVENT0("gpu", "GLES2::GetShaderPrecisionFormat"); |
| 1946 typedef gles2::GetShaderPrecisionFormat::Result Result; | 1983 typedef gles2::GetShaderPrecisionFormat::Result Result; |
| 1947 Result* result = GetResultAs<Result*>(); | 1984 Result* result = GetResultAs<Result*>(); |
| 1948 result->success = false; | 1985 result->success = false; |
| 1949 helper_->GetShaderPrecisionFormat( | 1986 helper_->GetShaderPrecisionFormat( |
| 1950 shadertype, precisiontype, GetResultShmId(), GetResultShmOffset()); | 1987 shadertype, precisiontype, GetResultShmId(), GetResultShmOffset()); |
| 1951 WaitForCmd(); | 1988 WaitForCmd(); |
| 1952 if (result->success) { | 1989 if (result->success) { |
| 1953 if (range) { | 1990 if (range) { |
| 1954 range[0] = result->min_range; | 1991 range[0] = result->min_range; |
| 1955 range[1] = result->max_range; | 1992 range[1] = result->max_range; |
| 1956 GPU_CLIENT_LOG(" min_range: " << range[0]); | 1993 GPU_CLIENT_LOG(" min_range: " << range[0]); |
| 1957 GPU_CLIENT_LOG(" min_range: " << range[1]); | 1994 GPU_CLIENT_LOG(" min_range: " << range[1]); |
| 1958 } | 1995 } |
| 1959 if (precision) { | 1996 if (precision) { |
| 1960 precision[0] = result->precision; | 1997 precision[0] = result->precision; |
| 1961 GPU_CLIENT_LOG(" min_range: " << precision[0]); | 1998 GPU_CLIENT_LOG(" min_range: " << precision[0]); |
| 1962 } | 1999 } |
| 1963 } | 2000 } |
| 1964 } | 2001 } |
| 1965 | 2002 |
| 1966 const GLubyte* GLES2Implementation::GetString(GLenum name) { | 2003 const GLubyte* GLES2Implementation::GetString(GLenum name) { |
| 2004 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 1967 GPU_CLIENT_LOG("[" << this << "] glGetString(" | 2005 GPU_CLIENT_LOG("[" << this << "] glGetString(" |
| 1968 << GLES2Util::GetStringStringType(name) << ")"); | 2006 << GLES2Util::GetStringStringType(name) << ")"); |
| 1969 const char* result = NULL; | 2007 const char* result = NULL; |
| 1970 // Clears the bucket so if the command fails nothing will be in it. | 2008 // Clears the bucket so if the command fails nothing will be in it. |
| 1971 helper_->SetBucketSize(kResultBucketId, 0); | 2009 helper_->SetBucketSize(kResultBucketId, 0); |
| 1972 helper_->GetString(name, kResultBucketId); | 2010 helper_->GetString(name, kResultBucketId); |
| 1973 std::string str; | 2011 std::string str; |
| 1974 if (GetBucketAsString(kResultBucketId, &str)) { | 2012 if (GetBucketAsString(kResultBucketId, &str)) { |
| 1975 // Adds extensions implemented on client side only. | 2013 // Adds extensions implemented on client side only. |
| 1976 switch (name) { | 2014 switch (name) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 2004 GPU_DCHECK(insert_result.second); | 2042 GPU_DCHECK(insert_result.second); |
| 2005 result = insert_result.first->c_str(); | 2043 result = insert_result.first->c_str(); |
| 2006 } | 2044 } |
| 2007 } | 2045 } |
| 2008 GPU_CLIENT_LOG(" returned " << static_cast<const char*>(result)); | 2046 GPU_CLIENT_LOG(" returned " << static_cast<const char*>(result)); |
| 2009 return reinterpret_cast<const GLubyte*>(result); | 2047 return reinterpret_cast<const GLubyte*>(result); |
| 2010 } | 2048 } |
| 2011 | 2049 |
| 2012 void GLES2Implementation::GetUniformfv( | 2050 void GLES2Implementation::GetUniformfv( |
| 2013 GLuint program, GLint location, GLfloat* params) { | 2051 GLuint program, GLint location, GLfloat* params) { |
| 2052 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 2014 GPU_CLIENT_LOG("[" << this << "] glGetUniformfv(" | 2053 GPU_CLIENT_LOG("[" << this << "] glGetUniformfv(" |
| 2015 << program << ", " << location << ", " | 2054 << program << ", " << location << ", " |
| 2016 << static_cast<const void*>(params) << ")"); | 2055 << static_cast<const void*>(params) << ")"); |
| 2017 TRACE_EVENT0("gpu", "GLES2::GetUniformfv"); | 2056 TRACE_EVENT0("gpu", "GLES2::GetUniformfv"); |
| 2018 typedef gles2::GetUniformfv::Result Result; | 2057 typedef gles2::GetUniformfv::Result Result; |
| 2019 Result* result = GetResultAs<Result*>(); | 2058 Result* result = GetResultAs<Result*>(); |
| 2020 result->SetNumResults(0); | 2059 result->SetNumResults(0); |
| 2021 helper_->GetUniformfv( | 2060 helper_->GetUniformfv( |
| 2022 program, location, GetResultShmId(), GetResultShmOffset()); | 2061 program, location, GetResultShmId(), GetResultShmOffset()); |
| 2023 WaitForCmd(); | 2062 WaitForCmd(); |
| 2024 result->CopyResult(params); | 2063 result->CopyResult(params); |
| 2025 GPU_CLIENT_LOG_CODE_BLOCK({ | 2064 GPU_CLIENT_LOG_CODE_BLOCK({ |
| 2026 for (int32 i = 0; i < result->GetNumResults(); ++i) { | 2065 for (int32 i = 0; i < result->GetNumResults(); ++i) { |
| 2027 GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]); | 2066 GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]); |
| 2028 } | 2067 } |
| 2029 }); | 2068 }); |
| 2030 } | 2069 } |
| 2031 | 2070 |
| 2032 void GLES2Implementation::GetUniformiv( | 2071 void GLES2Implementation::GetUniformiv( |
| 2033 GLuint program, GLint location, GLint* params) { | 2072 GLuint program, GLint location, GLint* params) { |
| 2073 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 2034 GPU_CLIENT_LOG("[" << this << "] glGetUniformiv(" | 2074 GPU_CLIENT_LOG("[" << this << "] glGetUniformiv(" |
| 2035 << program << ", " << location << ", " | 2075 << program << ", " << location << ", " |
| 2036 << static_cast<const void*>(params) << ")"); | 2076 << static_cast<const void*>(params) << ")"); |
| 2037 TRACE_EVENT0("gpu", "GLES2::GetUniformiv"); | 2077 TRACE_EVENT0("gpu", "GLES2::GetUniformiv"); |
| 2038 typedef gles2::GetUniformiv::Result Result; | 2078 typedef gles2::GetUniformiv::Result Result; |
| 2039 Result* result = GetResultAs<Result*>(); | 2079 Result* result = GetResultAs<Result*>(); |
| 2040 result->SetNumResults(0); | 2080 result->SetNumResults(0); |
| 2041 helper_->GetUniformiv( | 2081 helper_->GetUniformiv( |
| 2042 program, location, GetResultShmId(), GetResultShmOffset()); | 2082 program, location, GetResultShmId(), GetResultShmOffset()); |
| 2043 WaitForCmd(); | 2083 WaitForCmd(); |
| 2044 GetResultAs<gles2::GetUniformfv::Result*>()->CopyResult(params); | 2084 GetResultAs<gles2::GetUniformfv::Result*>()->CopyResult(params); |
| 2045 GPU_CLIENT_LOG_CODE_BLOCK({ | 2085 GPU_CLIENT_LOG_CODE_BLOCK({ |
| 2046 for (int32 i = 0; i < result->GetNumResults(); ++i) { | 2086 for (int32 i = 0; i < result->GetNumResults(); ++i) { |
| 2047 GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]); | 2087 GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]); |
| 2048 } | 2088 } |
| 2049 }); | 2089 }); |
| 2050 } | 2090 } |
| 2051 | 2091 |
| 2052 void GLES2Implementation::ReadPixels( | 2092 void GLES2Implementation::ReadPixels( |
| 2053 GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, | 2093 GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, |
| 2054 GLenum type, void* pixels) { | 2094 GLenum type, void* pixels) { |
| 2095 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 2055 GPU_CLIENT_LOG("[" << this << "] glReadPixels(" | 2096 GPU_CLIENT_LOG("[" << this << "] glReadPixels(" |
| 2056 << xoffset << ", " << yoffset << ", " | 2097 << xoffset << ", " << yoffset << ", " |
| 2057 << width << ", " << height << ", " | 2098 << width << ", " << height << ", " |
| 2058 << GLES2Util::GetStringReadPixelFormat(format) << ", " | 2099 << GLES2Util::GetStringReadPixelFormat(format) << ", " |
| 2059 << GLES2Util::GetStringPixelType(type) << ", " | 2100 << GLES2Util::GetStringPixelType(type) << ", " |
| 2060 << static_cast<const void*>(pixels) << ")"); | 2101 << static_cast<const void*>(pixels) << ")"); |
| 2061 if (width < 0 || height < 0) { | 2102 if (width < 0 || height < 0) { |
| 2062 SetGLError(GL_INVALID_VALUE, "glReadPixels: dimensions < 0"); | 2103 SetGLError(GL_INVALID_VALUE, "glReadPixels: dimensions < 0"); |
| 2063 return; | 2104 return; |
| 2064 } | 2105 } |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2182 temp_xoffset += num_pixels; | 2223 temp_xoffset += num_pixels; |
| 2183 temp_width -= num_pixels; | 2224 temp_width -= num_pixels; |
| 2184 } | 2225 } |
| 2185 ++yoffset; | 2226 ++yoffset; |
| 2186 dest += pack_reverse_row_order_ ? -padded_row_size : padded_row_size; | 2227 dest += pack_reverse_row_order_ ? -padded_row_size : padded_row_size; |
| 2187 } | 2228 } |
| 2188 } | 2229 } |
| 2189 } | 2230 } |
| 2190 | 2231 |
| 2191 void GLES2Implementation::ActiveTexture(GLenum texture) { | 2232 void GLES2Implementation::ActiveTexture(GLenum texture) { |
| 2233 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 2192 GPU_CLIENT_LOG("[" << this << "] glActiveTexture(" | 2234 GPU_CLIENT_LOG("[" << this << "] glActiveTexture(" |
| 2193 << GLES2Util::GetStringEnum(texture) << ")"); | 2235 << GLES2Util::GetStringEnum(texture) << ")"); |
| 2194 GLuint texture_index = texture - GL_TEXTURE0; | 2236 GLuint texture_index = texture - GL_TEXTURE0; |
| 2195 if (texture_index >= | 2237 if (texture_index >= |
| 2196 static_cast<GLuint>(gl_state_.max_combined_texture_image_units)) { | 2238 static_cast<GLuint>(gl_state_.max_combined_texture_image_units)) { |
| 2197 SetGLError(GL_INVALID_ENUM, "glActiveTexture: texture_unit out of range."); | 2239 SetGLError(GL_INVALID_ENUM, "glActiveTexture: texture_unit out of range."); |
| 2198 return; | 2240 return; |
| 2199 } | 2241 } |
| 2200 | 2242 |
| 2201 active_texture_unit_ = texture_index; | 2243 active_texture_unit_ = texture_index; |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2357 } | 2399 } |
| 2358 if (textures[ii] == unit.bound_texture_cube_map) { | 2400 if (textures[ii] == unit.bound_texture_cube_map) { |
| 2359 unit.bound_texture_cube_map = 0; | 2401 unit.bound_texture_cube_map = 0; |
| 2360 } | 2402 } |
| 2361 } | 2403 } |
| 2362 } | 2404 } |
| 2363 helper_->DeleteTexturesImmediate(n, textures); | 2405 helper_->DeleteTexturesImmediate(n, textures); |
| 2364 } | 2406 } |
| 2365 | 2407 |
| 2366 void GLES2Implementation::DisableVertexAttribArray(GLuint index) { | 2408 void GLES2Implementation::DisableVertexAttribArray(GLuint index) { |
| 2409 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 2367 GPU_CLIENT_LOG( | 2410 GPU_CLIENT_LOG( |
| 2368 "[" << this << "] glDisableVertexAttribArray(" << index << ")"); | 2411 "[" << this << "] glDisableVertexAttribArray(" << index << ")"); |
| 2369 #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) | 2412 #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) |
| 2370 client_side_buffer_helper_->SetAttribEnable(index, false); | 2413 client_side_buffer_helper_->SetAttribEnable(index, false); |
| 2371 #endif | 2414 #endif |
| 2372 helper_->DisableVertexAttribArray(index); | 2415 helper_->DisableVertexAttribArray(index); |
| 2373 } | 2416 } |
| 2374 | 2417 |
| 2375 void GLES2Implementation::EnableVertexAttribArray(GLuint index) { | 2418 void GLES2Implementation::EnableVertexAttribArray(GLuint index) { |
| 2419 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 2376 GPU_CLIENT_LOG("[" << this << "] glEnableVertexAttribArray(" << index << ")"); | 2420 GPU_CLIENT_LOG("[" << this << "] glEnableVertexAttribArray(" << index << ")"); |
| 2377 #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) | 2421 #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) |
| 2378 client_side_buffer_helper_->SetAttribEnable(index, true); | 2422 client_side_buffer_helper_->SetAttribEnable(index, true); |
| 2379 #endif | 2423 #endif |
| 2380 helper_->EnableVertexAttribArray(index); | 2424 helper_->EnableVertexAttribArray(index); |
| 2381 } | 2425 } |
| 2382 | 2426 |
| 2383 void GLES2Implementation::DrawArrays(GLenum mode, GLint first, GLsizei count) { | 2427 void GLES2Implementation::DrawArrays(GLenum mode, GLint first, GLsizei count) { |
| 2428 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 2384 GPU_CLIENT_LOG("[" << this << "] glDrawArrays(" | 2429 GPU_CLIENT_LOG("[" << this << "] glDrawArrays(" |
| 2385 << GLES2Util::GetStringDrawMode(mode) << ", " | 2430 << GLES2Util::GetStringDrawMode(mode) << ", " |
| 2386 << first << ", " << count << ")"); | 2431 << first << ", " << count << ")"); |
| 2387 if (count < 0) { | 2432 if (count < 0) { |
| 2388 SetGLError(GL_INVALID_VALUE, "glDrawArrays: count < 0"); | 2433 SetGLError(GL_INVALID_VALUE, "glDrawArrays: count < 0"); |
| 2389 return; | 2434 return; |
| 2390 } | 2435 } |
| 2391 #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) | 2436 #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) |
| 2392 bool have_client_side = | 2437 bool have_client_side = |
| 2393 client_side_buffer_helper_->HaveEnabledClientSideBuffers(); | 2438 client_side_buffer_helper_->HaveEnabledClientSideBuffers(); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2438 default: | 2483 default: |
| 2439 SetGLError(GL_INVALID_ENUM, "glGetVertexAttrib: invalid enum"); | 2484 SetGLError(GL_INVALID_ENUM, "glGetVertexAttrib: invalid enum"); |
| 2440 break; | 2485 break; |
| 2441 } | 2486 } |
| 2442 return true; | 2487 return true; |
| 2443 } | 2488 } |
| 2444 #endif // GLES2_SUPPORT_CLIENT_SIDE_ARRAYS | 2489 #endif // GLES2_SUPPORT_CLIENT_SIDE_ARRAYS |
| 2445 | 2490 |
| 2446 void GLES2Implementation::GetVertexAttribfv( | 2491 void GLES2Implementation::GetVertexAttribfv( |
| 2447 GLuint index, GLenum pname, GLfloat* params) { | 2492 GLuint index, GLenum pname, GLfloat* params) { |
| 2493 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 2448 GPU_CLIENT_LOG("[" << this << "] glGetVertexAttribfv(" | 2494 GPU_CLIENT_LOG("[" << this << "] glGetVertexAttribfv(" |
| 2449 << index << ", " | 2495 << index << ", " |
| 2450 << GLES2Util::GetStringVertexAttribute(pname) << ", " | 2496 << GLES2Util::GetStringVertexAttribute(pname) << ", " |
| 2451 << static_cast<const void*>(params) << ")"); | 2497 << static_cast<const void*>(params) << ")"); |
| 2452 #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) | 2498 #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) |
| 2453 uint32 value = 0; | 2499 uint32 value = 0; |
| 2454 if (GetVertexAttribHelper(index, pname, &value)) { | 2500 if (GetVertexAttribHelper(index, pname, &value)) { |
| 2455 *params = static_cast<float>(value); | 2501 *params = static_cast<float>(value); |
| 2456 return; | 2502 return; |
| 2457 } | 2503 } |
| 2458 #endif | 2504 #endif |
| 2459 TRACE_EVENT0("gpu", "GLES2::GetVertexAttribfv"); | 2505 TRACE_EVENT0("gpu", "GLES2::GetVertexAttribfv"); |
| 2460 typedef GetVertexAttribfv::Result Result; | 2506 typedef GetVertexAttribfv::Result Result; |
| 2461 Result* result = GetResultAs<Result*>(); | 2507 Result* result = GetResultAs<Result*>(); |
| 2462 result->SetNumResults(0); | 2508 result->SetNumResults(0); |
| 2463 helper_->GetVertexAttribfv( | 2509 helper_->GetVertexAttribfv( |
| 2464 index, pname, GetResultShmId(), GetResultShmOffset()); | 2510 index, pname, GetResultShmId(), GetResultShmOffset()); |
| 2465 WaitForCmd(); | 2511 WaitForCmd(); |
| 2466 result->CopyResult(params); | 2512 result->CopyResult(params); |
| 2467 GPU_CLIENT_LOG_CODE_BLOCK({ | 2513 GPU_CLIENT_LOG_CODE_BLOCK({ |
| 2468 for (int32 i = 0; i < result->GetNumResults(); ++i) { | 2514 for (int32 i = 0; i < result->GetNumResults(); ++i) { |
| 2469 GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]); | 2515 GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]); |
| 2470 } | 2516 } |
| 2471 }); | 2517 }); |
| 2472 } | 2518 } |
| 2473 | 2519 |
| 2474 void GLES2Implementation::GetVertexAttribiv( | 2520 void GLES2Implementation::GetVertexAttribiv( |
| 2475 GLuint index, GLenum pname, GLint* params) { | 2521 GLuint index, GLenum pname, GLint* params) { |
| 2522 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 2476 GPU_CLIENT_LOG("[" << this << "] glGetVertexAttribiv(" | 2523 GPU_CLIENT_LOG("[" << this << "] glGetVertexAttribiv(" |
| 2477 << index << ", " | 2524 << index << ", " |
| 2478 << GLES2Util::GetStringVertexAttribute(pname) << ", " | 2525 << GLES2Util::GetStringVertexAttribute(pname) << ", " |
| 2479 << static_cast<const void*>(params) << ")"); | 2526 << static_cast<const void*>(params) << ")"); |
| 2480 #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) | 2527 #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) |
| 2481 uint32 value = 0; | 2528 uint32 value = 0; |
| 2482 if (GetVertexAttribHelper(index, pname, &value)) { | 2529 if (GetVertexAttribHelper(index, pname, &value)) { |
| 2483 *params = value; | 2530 *params = value; |
| 2484 return; | 2531 return; |
| 2485 } | 2532 } |
| 2486 #endif | 2533 #endif |
| 2487 TRACE_EVENT0("gpu", "GLES2::GetVertexAttribiv"); | 2534 TRACE_EVENT0("gpu", "GLES2::GetVertexAttribiv"); |
| 2488 typedef GetVertexAttribiv::Result Result; | 2535 typedef GetVertexAttribiv::Result Result; |
| 2489 Result* result = GetResultAs<Result*>(); | 2536 Result* result = GetResultAs<Result*>(); |
| 2490 result->SetNumResults(0); | 2537 result->SetNumResults(0); |
| 2491 helper_->GetVertexAttribiv( | 2538 helper_->GetVertexAttribiv( |
| 2492 index, pname, GetResultShmId(), GetResultShmOffset()); | 2539 index, pname, GetResultShmId(), GetResultShmOffset()); |
| 2493 WaitForCmd(); | 2540 WaitForCmd(); |
| 2494 result->CopyResult(params); | 2541 result->CopyResult(params); |
| 2495 GPU_CLIENT_LOG_CODE_BLOCK({ | 2542 GPU_CLIENT_LOG_CODE_BLOCK({ |
| 2496 for (int32 i = 0; i < result->GetNumResults(); ++i) { | 2543 for (int32 i = 0; i < result->GetNumResults(); ++i) { |
| 2497 GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]); | 2544 GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]); |
| 2498 } | 2545 } |
| 2499 }); | 2546 }); |
| 2500 } | 2547 } |
| 2501 | 2548 |
| 2502 GLboolean GLES2Implementation::EnableFeatureCHROMIUM( | 2549 GLboolean GLES2Implementation::EnableFeatureCHROMIUM( |
| 2503 const char* feature) { | 2550 const char* feature) { |
| 2551 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 2504 GPU_CLIENT_LOG("[" << this << "] glEnableFeatureCHROMIUM(" | 2552 GPU_CLIENT_LOG("[" << this << "] glEnableFeatureCHROMIUM(" |
| 2505 << feature << ")"); | 2553 << feature << ")"); |
| 2506 TRACE_EVENT0("gpu", "GLES2::EnableFeatureCHROMIUM"); | 2554 TRACE_EVENT0("gpu", "GLES2::EnableFeatureCHROMIUM"); |
| 2507 typedef EnableFeatureCHROMIUM::Result Result; | 2555 typedef EnableFeatureCHROMIUM::Result Result; |
| 2508 Result* result = GetResultAs<Result*>(); | 2556 Result* result = GetResultAs<Result*>(); |
| 2509 *result = 0; | 2557 *result = 0; |
| 2510 SetBucketAsCString(kResultBucketId, feature); | 2558 SetBucketAsCString(kResultBucketId, feature); |
| 2511 helper_->EnableFeatureCHROMIUM( | 2559 helper_->EnableFeatureCHROMIUM( |
| 2512 kResultBucketId, GetResultShmId(), GetResultShmOffset()); | 2560 kResultBucketId, GetResultShmId(), GetResultShmOffset()); |
| 2513 WaitForCmd(); | 2561 WaitForCmd(); |
| 2514 helper_->SetBucketSize(kResultBucketId, 0); | 2562 helper_->SetBucketSize(kResultBucketId, 0); |
| 2515 GPU_CLIENT_LOG(" returned " << GLES2Util::GetStringBool(*result)); | 2563 GPU_CLIENT_LOG(" returned " << GLES2Util::GetStringBool(*result)); |
| 2516 return *result; | 2564 return *result; |
| 2517 } | 2565 } |
| 2518 | 2566 |
| 2519 void* GLES2Implementation::MapBufferSubDataCHROMIUM( | 2567 void* GLES2Implementation::MapBufferSubDataCHROMIUM( |
| 2520 GLuint target, GLintptr offset, GLsizeiptr size, GLenum access) { | 2568 GLuint target, GLintptr offset, GLsizeiptr size, GLenum access) { |
| 2569 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 2521 GPU_CLIENT_LOG("[" << this << "] glMapBufferSubDataCHROMIUM(" | 2570 GPU_CLIENT_LOG("[" << this << "] glMapBufferSubDataCHROMIUM(" |
| 2522 << target << ", " << offset << ", " << size << ", " | 2571 << target << ", " << offset << ", " << size << ", " |
| 2523 << GLES2Util::GetStringEnum(access) << ")"); | 2572 << GLES2Util::GetStringEnum(access) << ")"); |
| 2524 // NOTE: target is NOT checked because the service will check it | 2573 // NOTE: target is NOT checked because the service will check it |
| 2525 // and we don't know what targets are valid. | 2574 // and we don't know what targets are valid. |
| 2526 if (access != GL_WRITE_ONLY) { | 2575 if (access != GL_WRITE_ONLY) { |
| 2527 SetGLError(GL_INVALID_ENUM, "MapBufferSubDataCHROMIUM: bad access mode"); | 2576 SetGLError(GL_INVALID_ENUM, "MapBufferSubDataCHROMIUM: bad access mode"); |
| 2528 return NULL; | 2577 return NULL; |
| 2529 } | 2578 } |
| 2530 if (offset < 0 || size < 0) { | 2579 if (offset < 0 || size < 0) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2543 mapped_buffers_.insert(std::make_pair( | 2592 mapped_buffers_.insert(std::make_pair( |
| 2544 mem, | 2593 mem, |
| 2545 MappedBuffer( | 2594 MappedBuffer( |
| 2546 access, shm_id, mem, shm_offset, target, offset, size))); | 2595 access, shm_id, mem, shm_offset, target, offset, size))); |
| 2547 GPU_DCHECK(result.second); | 2596 GPU_DCHECK(result.second); |
| 2548 GPU_CLIENT_LOG(" returned " << mem); | 2597 GPU_CLIENT_LOG(" returned " << mem); |
| 2549 return mem; | 2598 return mem; |
| 2550 } | 2599 } |
| 2551 | 2600 |
| 2552 void GLES2Implementation::UnmapBufferSubDataCHROMIUM(const void* mem) { | 2601 void GLES2Implementation::UnmapBufferSubDataCHROMIUM(const void* mem) { |
| 2602 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 2553 GPU_CLIENT_LOG( | 2603 GPU_CLIENT_LOG( |
| 2554 "[" << this << "] glUnmapBufferSubDataCHROMIUM(" << mem << ")"); | 2604 "[" << this << "] glUnmapBufferSubDataCHROMIUM(" << mem << ")"); |
| 2555 MappedBufferMap::iterator it = mapped_buffers_.find(mem); | 2605 MappedBufferMap::iterator it = mapped_buffers_.find(mem); |
| 2556 if (it == mapped_buffers_.end()) { | 2606 if (it == mapped_buffers_.end()) { |
| 2557 SetGLError( | 2607 SetGLError( |
| 2558 GL_INVALID_VALUE, "UnmapBufferSubDataCHROMIUM: buffer not mapped"); | 2608 GL_INVALID_VALUE, "UnmapBufferSubDataCHROMIUM: buffer not mapped"); |
| 2559 return; | 2609 return; |
| 2560 } | 2610 } |
| 2561 const MappedBuffer& mb = it->second; | 2611 const MappedBuffer& mb = it->second; |
| 2562 helper_->BufferSubData( | 2612 helper_->BufferSubData( |
| 2563 mb.target, mb.offset, mb.size, mb.shm_id, mb.shm_offset); | 2613 mb.target, mb.offset, mb.size, mb.shm_id, mb.shm_offset); |
| 2564 mapped_memory_->FreePendingToken(mb.shm_memory, helper_->InsertToken()); | 2614 mapped_memory_->FreePendingToken(mb.shm_memory, helper_->InsertToken()); |
| 2565 helper_->CommandBufferHelper::Flush(); | 2615 helper_->CommandBufferHelper::Flush(); |
| 2566 mapped_buffers_.erase(it); | 2616 mapped_buffers_.erase(it); |
| 2567 } | 2617 } |
| 2568 | 2618 |
| 2569 void* GLES2Implementation::MapTexSubImage2DCHROMIUM( | 2619 void* GLES2Implementation::MapTexSubImage2DCHROMIUM( |
| 2570 GLenum target, | 2620 GLenum target, |
| 2571 GLint level, | 2621 GLint level, |
| 2572 GLint xoffset, | 2622 GLint xoffset, |
| 2573 GLint yoffset, | 2623 GLint yoffset, |
| 2574 GLsizei width, | 2624 GLsizei width, |
| 2575 GLsizei height, | 2625 GLsizei height, |
| 2576 GLenum format, | 2626 GLenum format, |
| 2577 GLenum type, | 2627 GLenum type, |
| 2578 GLenum access) { | 2628 GLenum access) { |
| 2629 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 2579 GPU_CLIENT_LOG("[" << this << "] glMapTexSubImage2DCHROMIUM(" | 2630 GPU_CLIENT_LOG("[" << this << "] glMapTexSubImage2DCHROMIUM(" |
| 2580 << target << ", " << level << ", " | 2631 << target << ", " << level << ", " |
| 2581 << xoffset << ", " << yoffset << ", " | 2632 << xoffset << ", " << yoffset << ", " |
| 2582 << width << ", " << height << ", " | 2633 << width << ", " << height << ", " |
| 2583 << GLES2Util::GetStringTextureFormat(format) << ", " | 2634 << GLES2Util::GetStringTextureFormat(format) << ", " |
| 2584 << GLES2Util::GetStringPixelType(type) << ", " | 2635 << GLES2Util::GetStringPixelType(type) << ", " |
| 2585 << GLES2Util::GetStringEnum(access) << ")"); | 2636 << GLES2Util::GetStringEnum(access) << ")"); |
| 2586 if (access != GL_WRITE_ONLY) { | 2637 if (access != GL_WRITE_ONLY) { |
| 2587 SetGLError(GL_INVALID_ENUM, "MapTexSubImage2DCHROMIUM: bad access mode"); | 2638 SetGLError(GL_INVALID_ENUM, "MapTexSubImage2DCHROMIUM: bad access mode"); |
| 2588 return NULL; | 2639 return NULL; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 2613 mem, | 2664 mem, |
| 2614 MappedTexture( | 2665 MappedTexture( |
| 2615 access, shm_id, mem, shm_offset, | 2666 access, shm_id, mem, shm_offset, |
| 2616 target, level, xoffset, yoffset, width, height, format, type))); | 2667 target, level, xoffset, yoffset, width, height, format, type))); |
| 2617 GPU_DCHECK(result.second); | 2668 GPU_DCHECK(result.second); |
| 2618 GPU_CLIENT_LOG(" returned " << mem); | 2669 GPU_CLIENT_LOG(" returned " << mem); |
| 2619 return mem; | 2670 return mem; |
| 2620 } | 2671 } |
| 2621 | 2672 |
| 2622 void GLES2Implementation::UnmapTexSubImage2DCHROMIUM(const void* mem) { | 2673 void GLES2Implementation::UnmapTexSubImage2DCHROMIUM(const void* mem) { |
| 2674 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 2623 GPU_CLIENT_LOG( | 2675 GPU_CLIENT_LOG( |
| 2624 "[" << this << "] glUnmapTexSubImage2DCHROMIUM(" << mem << ")"); | 2676 "[" << this << "] glUnmapTexSubImage2DCHROMIUM(" << mem << ")"); |
| 2625 MappedTextureMap::iterator it = mapped_textures_.find(mem); | 2677 MappedTextureMap::iterator it = mapped_textures_.find(mem); |
| 2626 if (it == mapped_textures_.end()) { | 2678 if (it == mapped_textures_.end()) { |
| 2627 SetGLError( | 2679 SetGLError( |
| 2628 GL_INVALID_VALUE, "UnmapTexSubImage2DCHROMIUM: texture not mapped"); | 2680 GL_INVALID_VALUE, "UnmapTexSubImage2DCHROMIUM: texture not mapped"); |
| 2629 return; | 2681 return; |
| 2630 } | 2682 } |
| 2631 const MappedTexture& mt = it->second; | 2683 const MappedTexture& mt = it->second; |
| 2632 helper_->TexSubImage2D( | 2684 helper_->TexSubImage2D( |
| 2633 mt.target, mt.level, mt.xoffset, mt.yoffset, mt.width, mt.height, | 2685 mt.target, mt.level, mt.xoffset, mt.yoffset, mt.width, mt.height, |
| 2634 mt.format, mt.type, mt.shm_id, mt.shm_offset, GL_FALSE); | 2686 mt.format, mt.type, mt.shm_id, mt.shm_offset, GL_FALSE); |
| 2635 mapped_memory_->FreePendingToken(mt.shm_memory, helper_->InsertToken()); | 2687 mapped_memory_->FreePendingToken(mt.shm_memory, helper_->InsertToken()); |
| 2636 helper_->CommandBufferHelper::Flush(); | 2688 helper_->CommandBufferHelper::Flush(); |
| 2637 mapped_textures_.erase(it); | 2689 mapped_textures_.erase(it); |
| 2638 } | 2690 } |
| 2639 | 2691 |
| 2640 void GLES2Implementation::ResizeCHROMIUM(GLuint width, GLuint height) { | 2692 void GLES2Implementation::ResizeCHROMIUM(GLuint width, GLuint height) { |
| 2693 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 2641 GPU_CLIENT_LOG("[" << this << "] glResizeCHROMIUM(" | 2694 GPU_CLIENT_LOG("[" << this << "] glResizeCHROMIUM(" |
| 2642 << width << ", " << height << ")"); | 2695 << width << ", " << height << ")"); |
| 2643 helper_->ResizeCHROMIUM(width, height); | 2696 helper_->ResizeCHROMIUM(width, height); |
| 2644 } | 2697 } |
| 2645 | 2698 |
| 2646 const GLchar* GLES2Implementation::GetRequestableExtensionsCHROMIUM() { | 2699 const GLchar* GLES2Implementation::GetRequestableExtensionsCHROMIUM() { |
| 2700 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 2647 GPU_CLIENT_LOG("[" << this << "] glGetRequestableExtensionsCHROMIUM()"); | 2701 GPU_CLIENT_LOG("[" << this << "] glGetRequestableExtensionsCHROMIUM()"); |
| 2648 TRACE_EVENT0("gpu", | 2702 TRACE_EVENT0("gpu", |
| 2649 "GLES2Implementation::GetRequestableExtensionsCHROMIUM()"); | 2703 "GLES2Implementation::GetRequestableExtensionsCHROMIUM()"); |
| 2650 const char* result = NULL; | 2704 const char* result = NULL; |
| 2651 // Clear the bucket so if the command fails nothing will be in it. | 2705 // Clear the bucket so if the command fails nothing will be in it. |
| 2652 helper_->SetBucketSize(kResultBucketId, 0); | 2706 helper_->SetBucketSize(kResultBucketId, 0); |
| 2653 helper_->GetRequestableExtensionsCHROMIUM(kResultBucketId); | 2707 helper_->GetRequestableExtensionsCHROMIUM(kResultBucketId); |
| 2654 std::string str; | 2708 std::string str; |
| 2655 if (GetBucketAsString(kResultBucketId, &str)) { | 2709 if (GetBucketAsString(kResultBucketId, &str)) { |
| 2656 // The set of requestable extensions shrinks as we enable | 2710 // The set of requestable extensions shrinks as we enable |
| 2657 // them. Because we don't know when the client will stop referring | 2711 // them. Because we don't know when the client will stop referring |
| 2658 // to a previous one it queries (see GetString) we need to cache | 2712 // to a previous one it queries (see GetString) we need to cache |
| 2659 // the unique results. | 2713 // the unique results. |
| 2660 std::set<std::string>::const_iterator sit = | 2714 std::set<std::string>::const_iterator sit = |
| 2661 requestable_extensions_set_.find(str); | 2715 requestable_extensions_set_.find(str); |
| 2662 if (sit != requestable_extensions_set_.end()) { | 2716 if (sit != requestable_extensions_set_.end()) { |
| 2663 result = sit->c_str(); | 2717 result = sit->c_str(); |
| 2664 } else { | 2718 } else { |
| 2665 std::pair<std::set<std::string>::const_iterator, bool> insert_result = | 2719 std::pair<std::set<std::string>::const_iterator, bool> insert_result = |
| 2666 requestable_extensions_set_.insert(str); | 2720 requestable_extensions_set_.insert(str); |
| 2667 GPU_DCHECK(insert_result.second); | 2721 GPU_DCHECK(insert_result.second); |
| 2668 result = insert_result.first->c_str(); | 2722 result = insert_result.first->c_str(); |
| 2669 } | 2723 } |
| 2670 } | 2724 } |
| 2671 GPU_CLIENT_LOG(" returned " << result); | 2725 GPU_CLIENT_LOG(" returned " << result); |
| 2672 return reinterpret_cast<const GLchar*>(result); | 2726 return reinterpret_cast<const GLchar*>(result); |
| 2673 } | 2727 } |
| 2674 | 2728 |
| 2675 void GLES2Implementation::RequestExtensionCHROMIUM(const char* extension) { | 2729 void GLES2Implementation::RequestExtensionCHROMIUM(const char* extension) { |
| 2730 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 2676 GPU_CLIENT_LOG("[" << this << "] glRequestExtensionCHROMIUM(" | 2731 GPU_CLIENT_LOG("[" << this << "] glRequestExtensionCHROMIUM(" |
| 2677 << extension << ")"); | 2732 << extension << ")"); |
| 2678 SetBucketAsCString(kResultBucketId, extension); | 2733 SetBucketAsCString(kResultBucketId, extension); |
| 2679 helper_->RequestExtensionCHROMIUM(kResultBucketId); | 2734 helper_->RequestExtensionCHROMIUM(kResultBucketId); |
| 2680 helper_->SetBucketSize(kResultBucketId, 0); | 2735 helper_->SetBucketSize(kResultBucketId, 0); |
| 2681 if (kUnavailableExtensionStatus == angle_pack_reverse_row_order_status && | 2736 if (kUnavailableExtensionStatus == angle_pack_reverse_row_order_status && |
| 2682 !strcmp(extension, "GL_ANGLE_pack_reverse_row_order")) { | 2737 !strcmp(extension, "GL_ANGLE_pack_reverse_row_order")) { |
| 2683 angle_pack_reverse_row_order_status = kUnknownExtensionStatus; | 2738 angle_pack_reverse_row_order_status = kUnknownExtensionStatus; |
| 2684 } | 2739 } |
| 2685 } | 2740 } |
| 2686 | 2741 |
| 2687 void GLES2Implementation::RateLimitOffscreenContextCHROMIUM() { | 2742 void GLES2Implementation::RateLimitOffscreenContextCHROMIUM() { |
| 2743 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 2688 GPU_CLIENT_LOG("[" << this << "] glRateLimitOffscreenCHROMIUM()"); | 2744 GPU_CLIENT_LOG("[" << this << "] glRateLimitOffscreenCHROMIUM()"); |
| 2689 // Wait if this would add too many rate limit tokens. | 2745 // Wait if this would add too many rate limit tokens. |
| 2690 if (rate_limit_tokens_.size() == kMaxSwapBuffers) { | 2746 if (rate_limit_tokens_.size() == kMaxSwapBuffers) { |
| 2691 helper_->WaitForToken(rate_limit_tokens_.front()); | 2747 helper_->WaitForToken(rate_limit_tokens_.front()); |
| 2692 rate_limit_tokens_.pop(); | 2748 rate_limit_tokens_.pop(); |
| 2693 } | 2749 } |
| 2694 rate_limit_tokens_.push(helper_->InsertToken()); | 2750 rate_limit_tokens_.push(helper_->InsertToken()); |
| 2695 } | 2751 } |
| 2696 | 2752 |
| 2697 void GLES2Implementation::GetMultipleIntegervCHROMIUM( | 2753 void GLES2Implementation::GetMultipleIntegervCHROMIUM( |
| 2698 const GLenum* pnames, GLuint count, GLint* results, GLsizeiptr size) { | 2754 const GLenum* pnames, GLuint count, GLint* results, GLsizeiptr size) { |
| 2755 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 2699 GPU_CLIENT_LOG("[" << this << "] glGetMultipleIntegervCHROMIUM(" | 2756 GPU_CLIENT_LOG("[" << this << "] glGetMultipleIntegervCHROMIUM(" |
| 2700 << static_cast<const void*>(pnames) << ", " | 2757 << static_cast<const void*>(pnames) << ", " |
| 2701 << count << ", " << results << ", " << size << ")"); | 2758 << count << ", " << results << ", " << size << ")"); |
| 2702 GPU_CLIENT_LOG_CODE_BLOCK({ | 2759 GPU_CLIENT_LOG_CODE_BLOCK({ |
| 2703 for (GLuint i = 0; i < count; ++i) { | 2760 for (GLuint i = 0; i < count; ++i) { |
| 2704 GPU_CLIENT_LOG( | 2761 GPU_CLIENT_LOG( |
| 2705 " " << i << ": " << GLES2Util::GetStringGLState(pnames[i])); | 2762 " " << i << ": " << GLES2Util::GetStringGLState(pnames[i])); |
| 2706 } | 2763 } |
| 2707 }); | 2764 }); |
| 2708 int num_results = 0; | 2765 int num_results = 0; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2756 GLuint program, std::vector<int8>* result) { | 2813 GLuint program, std::vector<int8>* result) { |
| 2757 GPU_DCHECK(result); | 2814 GPU_DCHECK(result); |
| 2758 // Clear the bucket so if the command fails nothing will be in it. | 2815 // Clear the bucket so if the command fails nothing will be in it. |
| 2759 helper_->SetBucketSize(kResultBucketId, 0); | 2816 helper_->SetBucketSize(kResultBucketId, 0); |
| 2760 helper_->GetProgramInfoCHROMIUM(program, kResultBucketId); | 2817 helper_->GetProgramInfoCHROMIUM(program, kResultBucketId); |
| 2761 GetBucketContents(kResultBucketId, result); | 2818 GetBucketContents(kResultBucketId, result); |
| 2762 } | 2819 } |
| 2763 | 2820 |
| 2764 void GLES2Implementation::GetProgramInfoCHROMIUM( | 2821 void GLES2Implementation::GetProgramInfoCHROMIUM( |
| 2765 GLuint program, GLsizei bufsize, GLsizei* size, void* info) { | 2822 GLuint program, GLsizei bufsize, GLsizei* size, void* info) { |
| 2823 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 2766 if (bufsize < 0) { | 2824 if (bufsize < 0) { |
| 2767 SetGLError(GL_INVALID_VALUE, "glProgramInfoCHROMIUM: bufsize less than 0."); | 2825 SetGLError(GL_INVALID_VALUE, "glProgramInfoCHROMIUM: bufsize less than 0."); |
| 2768 return; | 2826 return; |
| 2769 } | 2827 } |
| 2770 if (size == NULL) { | 2828 if (size == NULL) { |
| 2771 SetGLError(GL_INVALID_VALUE, "glProgramInfoCHROMIUM: size is null."); | 2829 SetGLError(GL_INVALID_VALUE, "glProgramInfoCHROMIUM: size is null."); |
| 2772 return; | 2830 return; |
| 2773 } | 2831 } |
| 2774 // Make sure they've set size to 0 else the value will be undefined on | 2832 // Make sure they've set size to 0 else the value will be undefined on |
| 2775 // lost context. | 2833 // lost context. |
| 2776 GPU_DCHECK(*size == 0); | 2834 GPU_DCHECK(*size == 0); |
| 2777 std::vector<int8> result; | 2835 std::vector<int8> result; |
| 2778 GetProgramInfoCHROMIUMHelper(program, &result); | 2836 GetProgramInfoCHROMIUMHelper(program, &result); |
| 2779 if (result.empty()) { | 2837 if (result.empty()) { |
| 2780 return; | 2838 return; |
| 2781 } | 2839 } |
| 2782 *size = result.size(); | 2840 *size = result.size(); |
| 2783 if (!info) { | 2841 if (!info) { |
| 2784 return; | 2842 return; |
| 2785 } | 2843 } |
| 2786 if (static_cast<size_t>(bufsize) < result.size()) { | 2844 if (static_cast<size_t>(bufsize) < result.size()) { |
| 2787 SetGLError(GL_INVALID_OPERATION, | 2845 SetGLError(GL_INVALID_OPERATION, |
| 2788 "glProgramInfoCHROMIUM: bufsize is too small for result."); | 2846 "glProgramInfoCHROMIUM: bufsize is too small for result."); |
| 2789 return; | 2847 return; |
| 2790 } | 2848 } |
| 2791 memcpy(info, &result[0], result.size()); | 2849 memcpy(info, &result[0], result.size()); |
| 2792 } | 2850 } |
| 2793 | 2851 |
| 2794 GLuint GLES2Implementation::CreateStreamTextureCHROMIUM(GLuint texture) { | 2852 GLuint GLES2Implementation::CreateStreamTextureCHROMIUM(GLuint texture) { |
| 2853 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 2795 GPU_CLIENT_LOG("[" << this << "] CreateStreamTextureCHROMIUM(" | 2854 GPU_CLIENT_LOG("[" << this << "] CreateStreamTextureCHROMIUM(" |
| 2796 << texture << ")"); | 2855 << texture << ")"); |
| 2797 TRACE_EVENT0("gpu", "GLES2::CreateStreamTextureCHROMIUM"); | 2856 TRACE_EVENT0("gpu", "GLES2::CreateStreamTextureCHROMIUM"); |
| 2798 typedef CreateStreamTextureCHROMIUM::Result Result; | 2857 typedef CreateStreamTextureCHROMIUM::Result Result; |
| 2799 Result* result = GetResultAs<Result*>(); | 2858 Result* result = GetResultAs<Result*>(); |
| 2800 *result = GL_ZERO; | 2859 *result = GL_ZERO; |
| 2801 | 2860 |
| 2802 helper_->CreateStreamTextureCHROMIUM(texture, | 2861 helper_->CreateStreamTextureCHROMIUM(texture, |
| 2803 GetResultShmId(), | 2862 GetResultShmId(), |
| 2804 GetResultShmOffset()); | 2863 GetResultShmOffset()); |
| 2805 WaitForCmd(); | 2864 WaitForCmd(); |
| 2806 | 2865 |
| 2807 return *result; | 2866 return *result; |
| 2808 } | 2867 } |
| 2809 | 2868 |
| 2810 void GLES2Implementation::DestroyStreamTextureCHROMIUM(GLuint texture) { | 2869 void GLES2Implementation::DestroyStreamTextureCHROMIUM(GLuint texture) { |
| 2870 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 2811 GPU_CLIENT_LOG("[" << this << "] DestroyStreamTextureCHROMIUM(" | 2871 GPU_CLIENT_LOG("[" << this << "] DestroyStreamTextureCHROMIUM(" |
| 2812 << texture << ")"); | 2872 << texture << ")"); |
| 2813 TRACE_EVENT0("gpu", "GLES2::DestroyStreamTextureCHROMIUM"); | 2873 TRACE_EVENT0("gpu", "GLES2::DestroyStreamTextureCHROMIUM"); |
| 2814 helper_->DestroyStreamTextureCHROMIUM(texture); | 2874 helper_->DestroyStreamTextureCHROMIUM(texture); |
| 2815 } | 2875 } |
| 2816 | 2876 |
| 2817 void GLES2Implementation::PostSubBufferCHROMIUM( | 2877 void GLES2Implementation::PostSubBufferCHROMIUM( |
| 2818 GLint x, GLint y, GLint width, GLint height) { | 2878 GLint x, GLint y, GLint width, GLint height) { |
| 2879 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 2819 GPU_CLIENT_LOG("[" << this << "] PostSubBufferCHROMIUM(" | 2880 GPU_CLIENT_LOG("[" << this << "] PostSubBufferCHROMIUM(" |
| 2820 << x << ", " << y << ", " << width << ", " << height << ")"); | 2881 << x << ", " << y << ", " << width << ", " << height << ")"); |
| 2821 TRACE_EVENT0("gpu", "GLES2::PostSubBufferCHROMIUM"); | 2882 TRACE_EVENT0("gpu", "GLES2::PostSubBufferCHROMIUM"); |
| 2822 | 2883 |
| 2823 // Same flow control as GLES2Implementation::SwapBuffers (see comments there). | 2884 // Same flow control as GLES2Implementation::SwapBuffers (see comments there). |
| 2824 swap_buffers_tokens_.push(helper_->InsertToken()); | 2885 swap_buffers_tokens_.push(helper_->InsertToken()); |
| 2825 helper_->PostSubBufferCHROMIUM(x, y, width, height); | 2886 helper_->PostSubBufferCHROMIUM(x, y, width, height); |
| 2826 helper_->CommandBufferHelper::Flush(); | 2887 helper_->CommandBufferHelper::Flush(); |
| 2827 if (swap_buffers_tokens_.size() > kMaxSwapBuffers + 1) { | 2888 if (swap_buffers_tokens_.size() > kMaxSwapBuffers + 1) { |
| 2828 helper_->WaitForToken(swap_buffers_tokens_.front()); | 2889 helper_->WaitForToken(swap_buffers_tokens_.front()); |
| 2829 swap_buffers_tokens_.pop(); | 2890 swap_buffers_tokens_.pop(); |
| 2830 } | 2891 } |
| 2831 } | 2892 } |
| 2832 | 2893 |
| 2833 } // namespace gles2 | 2894 } // namespace gles2 |
| 2834 } // namespace gpu | 2895 } // namespace gpu |
| OLD | NEW |