Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(218)

Side by Side Diff: gpu/command_buffer/client/gles2_implementation.cc

Issue 10535073: Enforce compressed texture restrictions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 } 612 }
613 } 613 }
614 614
615 if (error != GL_NO_ERROR) { 615 if (error != GL_NO_ERROR) {
616 // There was an error, clear the corresponding wrapped error. 616 // There was an error, clear the corresponding wrapped error.
617 error_bits_ &= ~GLES2Util::GLErrorToErrorBit(error); 617 error_bits_ &= ~GLES2Util::GLErrorToErrorBit(error);
618 } 618 }
619 return error; 619 return error;
620 } 620 }
621 621
622 void GLES2Implementation::SetGLError(GLenum error, const char* msg) { 622 void GLES2Implementation::SetGLError(
623 GLenum error, const char* function_name, const char* msg) {
623 GPU_CLIENT_LOG("[" << this << "] Client Synthesized Error: " 624 GPU_CLIENT_LOG("[" << this << "] Client Synthesized Error: "
624 << GLES2Util::GetStringError(error) << ": " << msg); 625 << GLES2Util::GetStringError(error) << ": "
626 << function_name << ": " << msg);
625 if (msg) { 627 if (msg) {
626 last_error_ = msg; 628 last_error_ = msg;
627 } 629 }
628 if (error_message_callback_) { 630 if (error_message_callback_) {
629 std::string temp(GLES2Util::GetStringError(error) + " : " + 631 std::string temp(GLES2Util::GetStringError(error) + " : " +
630 (msg ? msg : "")); 632 function_name + ": " + (msg ? msg : ""));
631 error_message_callback_->OnErrorMessage(temp.c_str(), 0); 633 error_message_callback_->OnErrorMessage(temp.c_str(), 0);
632 } 634 }
633 error_bits_ |= GLES2Util::GLErrorToErrorBit(error); 635 error_bits_ |= GLES2Util::GLErrorToErrorBit(error);
634 } 636 }
635 637
636 bool GLES2Implementation::GetBucketContents(uint32 bucket_id, 638 bool GLES2Implementation::GetBucketContents(uint32 bucket_id,
637 std::vector<int8>* data) { 639 std::vector<int8>* data) {
638 TRACE_EVENT0("gpu", "GLES2::GetBucketContents"); 640 TRACE_EVENT0("gpu", "GLES2::GetBucketContents");
639 GPU_DCHECK(data); 641 GPU_DCHECK(data);
640 const uint32 kStartSize = 32 * 1024; 642 const uint32 kStartSize = 32 * 1024;
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
970 972
971 void GLES2Implementation::DrawElements( 973 void GLES2Implementation::DrawElements(
972 GLenum mode, GLsizei count, GLenum type, const void* indices) { 974 GLenum mode, GLsizei count, GLenum type, const void* indices) {
973 GPU_CLIENT_SINGLE_THREAD_CHECK(); 975 GPU_CLIENT_SINGLE_THREAD_CHECK();
974 GPU_CLIENT_LOG("[" << this << "] glDrawElements(" 976 GPU_CLIENT_LOG("[" << this << "] glDrawElements("
975 << GLES2Util::GetStringDrawMode(mode) << ", " 977 << GLES2Util::GetStringDrawMode(mode) << ", "
976 << count << ", " 978 << count << ", "
977 << GLES2Util::GetStringIndexType(type) << ", " 979 << GLES2Util::GetStringIndexType(type) << ", "
978 << static_cast<const void*>(indices) << ")"); 980 << static_cast<const void*>(indices) << ")");
979 if (count < 0) { 981 if (count < 0) {
980 SetGLError(GL_INVALID_VALUE, "glDrawElements: count less than 0."); 982 SetGLError(GL_INVALID_VALUE, "glDrawElements", "count less than 0.");
981 return; 983 return;
982 } 984 }
983 if (count == 0) { 985 if (count == 0) {
984 return; 986 return;
985 } 987 }
986 #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) 988 #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS)
987 bool have_client_side = 989 bool have_client_side =
988 client_side_buffer_helper_->HaveEnabledClientSideBuffers(); 990 client_side_buffer_helper_->HaveEnabledClientSideBuffers();
989 GLsizei num_elements = 0; 991 GLsizei num_elements = 0;
990 GLuint offset = ToGLuint(indices); 992 GLuint offset = ToGLuint(indices);
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
1185 GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]); 1187 GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]);
1186 } 1188 }
1187 }); 1189 });
1188 } 1190 }
1189 1191
1190 bool GLES2Implementation::DeleteProgramHelper(GLuint program) { 1192 bool GLES2Implementation::DeleteProgramHelper(GLuint program) {
1191 if (!GetIdHandler(id_namespaces::kProgramsAndShaders)->FreeIds( 1193 if (!GetIdHandler(id_namespaces::kProgramsAndShaders)->FreeIds(
1192 this, 1, &program, &GLES2Implementation::DeleteProgramStub)) { 1194 this, 1, &program, &GLES2Implementation::DeleteProgramStub)) {
1193 SetGLError( 1195 SetGLError(
1194 GL_INVALID_VALUE, 1196 GL_INVALID_VALUE,
1195 "glDeleteProgram: id not created by this context."); 1197 "glDeleteProgram", "id not created by this context.");
1196 return false; 1198 return false;
1197 } 1199 }
1198 return true; 1200 return true;
1199 } 1201 }
1200 1202
1201 void GLES2Implementation::DeleteProgramStub( 1203 void GLES2Implementation::DeleteProgramStub(
1202 GLsizei n, const GLuint* programs) { 1204 GLsizei n, const GLuint* programs) {
1203 GPU_DCHECK_EQ(1, n); 1205 GPU_DCHECK_EQ(1, n);
1204 share_group_->program_info_manager()->DeleteInfo(programs[0]); 1206 share_group_->program_info_manager()->DeleteInfo(programs[0]);
1205 helper_->DeleteProgram(programs[0]); 1207 helper_->DeleteProgram(programs[0]);
1206 } 1208 }
1207 1209
1208 bool GLES2Implementation::DeleteShaderHelper(GLuint shader) { 1210 bool GLES2Implementation::DeleteShaderHelper(GLuint shader) {
1209 if (!GetIdHandler(id_namespaces::kProgramsAndShaders)->FreeIds( 1211 if (!GetIdHandler(id_namespaces::kProgramsAndShaders)->FreeIds(
1210 this, 1, &shader, &GLES2Implementation::DeleteShaderStub)) { 1212 this, 1, &shader, &GLES2Implementation::DeleteShaderStub)) {
1211 SetGLError( 1213 SetGLError(
1212 GL_INVALID_VALUE, 1214 GL_INVALID_VALUE,
1213 "glDeleteShader: id not created by this context."); 1215 "glDeleteShader", "id not created by this context.");
1214 return false; 1216 return false;
1215 } 1217 }
1216 return true; 1218 return true;
1217 } 1219 }
1218 1220
1219 void GLES2Implementation::DeleteShaderStub( 1221 void GLES2Implementation::DeleteShaderStub(
1220 GLsizei n, const GLuint* shaders) { 1222 GLsizei n, const GLuint* shaders) {
1221 GPU_DCHECK_EQ(1, n); 1223 GPU_DCHECK_EQ(1, n);
1222 share_group_->program_info_manager()->DeleteInfo(shaders[0]); 1224 share_group_->program_info_manager()->DeleteInfo(shaders[0]);
1223 helper_->DeleteShader(shaders[0]); 1225 helper_->DeleteShader(shaders[0]);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1302 void GLES2Implementation::ShaderBinary( 1304 void GLES2Implementation::ShaderBinary(
1303 GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, 1305 GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary,
1304 GLsizei length) { 1306 GLsizei length) {
1305 GPU_CLIENT_SINGLE_THREAD_CHECK(); 1307 GPU_CLIENT_SINGLE_THREAD_CHECK();
1306 GPU_CLIENT_LOG("[" << this << "] glShaderBinary(" << n << ", " 1308 GPU_CLIENT_LOG("[" << this << "] glShaderBinary(" << n << ", "
1307 << static_cast<const void*>(shaders) << ", " 1309 << static_cast<const void*>(shaders) << ", "
1308 << GLES2Util::GetStringEnum(binaryformat) << ", " 1310 << GLES2Util::GetStringEnum(binaryformat) << ", "
1309 << static_cast<const void*>(binary) << ", " 1311 << static_cast<const void*>(binary) << ", "
1310 << length << ")"); 1312 << length << ")");
1311 if (n < 0) { 1313 if (n < 0) {
1312 SetGLError(GL_INVALID_VALUE, "glShaderBinary n < 0."); 1314 SetGLError(GL_INVALID_VALUE, "glShaderBinary", "n < 0.");
1313 return; 1315 return;
1314 } 1316 }
1315 if (length < 0) { 1317 if (length < 0) {
1316 SetGLError(GL_INVALID_VALUE, "glShaderBinary length < 0."); 1318 SetGLError(GL_INVALID_VALUE, "glShaderBinary", "length < 0.");
1317 return; 1319 return;
1318 } 1320 }
1319 // TODO(gman): ShaderBinary should use buckets. 1321 // TODO(gman): ShaderBinary should use buckets.
1320 unsigned int shader_id_size = n * sizeof(*shaders); 1322 unsigned int shader_id_size = n * sizeof(*shaders);
1321 ScopedTransferBufferArray<GLint> buffer( 1323 ScopedTransferBufferArray<GLint> buffer(
1322 shader_id_size + length, helper_, transfer_buffer_); 1324 shader_id_size + length, helper_, transfer_buffer_);
1323 if (!buffer.valid() || buffer.num_elements() != shader_id_size + length) { 1325 if (!buffer.valid() || buffer.num_elements() != shader_id_size + length) {
1324 SetGLError(GL_OUT_OF_MEMORY, "glShaderBinary: out of memory."); 1326 SetGLError(GL_OUT_OF_MEMORY, "glShaderBinary", "out of memory.");
1325 return; 1327 return;
1326 } 1328 }
1327 void* shader_ids = buffer.elements(); 1329 void* shader_ids = buffer.elements();
1328 void* shader_data = buffer.elements() + shader_id_size; 1330 void* shader_data = buffer.elements() + shader_id_size;
1329 memcpy(shader_ids, shaders, shader_id_size); 1331 memcpy(shader_ids, shaders, shader_id_size);
1330 memcpy(shader_data, binary, length); 1332 memcpy(shader_data, binary, length);
1331 helper_->ShaderBinary( 1333 helper_->ShaderBinary(
1332 n, 1334 n,
1333 buffer.shm_id(), 1335 buffer.shm_id(),
1334 buffer.offset(), 1336 buffer.offset(),
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1427 GPU_CLIENT_LOG(" " << ii << ": ---\n" << str << "\n---"); 1429 GPU_CLIENT_LOG(" " << ii << ": ---\n" << str << "\n---");
1428 } else { 1430 } else {
1429 GPU_CLIENT_LOG(" " << ii << ": ---\n" << source[ii] << "\n---"); 1431 GPU_CLIENT_LOG(" " << ii << ": ---\n" << source[ii] << "\n---");
1430 } 1432 }
1431 } else { 1433 } else {
1432 GPU_CLIENT_LOG(" " << ii << ": NULL"); 1434 GPU_CLIENT_LOG(" " << ii << ": NULL");
1433 } 1435 }
1434 } 1436 }
1435 }); 1437 });
1436 if (count < 0) { 1438 if (count < 0) {
1437 SetGLError(GL_INVALID_VALUE, "glShaderSource count < 0"); 1439 SetGLError(GL_INVALID_VALUE, "glShaderSource", "count < 0");
1438 return; 1440 return;
1439 } 1441 }
1440 if (shader == 0) { 1442 if (shader == 0) {
1441 SetGLError(GL_INVALID_VALUE, "glShaderSource shader == 0"); 1443 SetGLError(GL_INVALID_VALUE, "glShaderSource", "shader == 0");
1442 return; 1444 return;
1443 } 1445 }
1444 1446
1445 // Compute the total size. 1447 // Compute the total size.
1446 uint32 total_size = 1; 1448 uint32 total_size = 1;
1447 for (GLsizei ii = 0; ii < count; ++ii) { 1449 for (GLsizei ii = 0; ii < count; ++ii) {
1448 if (source[ii]) { 1450 if (source[ii]) {
1449 total_size += (length && length[ii] >= 0) ? 1451 total_size += (length && length[ii] >= 0) ?
1450 static_cast<size_t>(length[ii]) : strlen(source[ii]); 1452 static_cast<size_t>(length[ii]) : strlen(source[ii]);
1451 } 1453 }
(...skipping 28 matching lines...) Expand all
1480 helper_->SetBucketSize(kResultBucketId, 0); 1482 helper_->SetBucketSize(kResultBucketId, 0);
1481 } 1483 }
1482 1484
1483 void GLES2Implementation::BufferDataHelper( 1485 void GLES2Implementation::BufferDataHelper(
1484 GLenum target, GLsizeiptr size, const void* data, GLenum usage) { 1486 GLenum target, GLsizeiptr size, const void* data, GLenum usage) {
1485 if (size == 0) { 1487 if (size == 0) {
1486 return; 1488 return;
1487 } 1489 }
1488 1490
1489 if (size < 0) { 1491 if (size < 0) {
1490 SetGLError(GL_INVALID_VALUE, "glBufferData: size < 0"); 1492 SetGLError(GL_INVALID_VALUE, "glBufferData", "size < 0");
1491 return; 1493 return;
1492 } 1494 }
1493 1495
1494 // If there is no data just send BufferData 1496 // If there is no data just send BufferData
1495 if (!data) { 1497 if (!data) {
1496 helper_->BufferData(target, size, 0, 0, usage); 1498 helper_->BufferData(target, size, 0, 0, usage);
1497 return; 1499 return;
1498 } 1500 }
1499 1501
1500 // See if we can send all at once. 1502 // See if we can send all at once.
(...skipping 29 matching lines...) Expand all
1530 BufferDataHelper(target, size, data, usage); 1532 BufferDataHelper(target, size, data, usage);
1531 } 1533 }
1532 1534
1533 void GLES2Implementation::BufferSubDataHelper( 1535 void GLES2Implementation::BufferSubDataHelper(
1534 GLenum target, GLintptr offset, GLsizeiptr size, const void* data) { 1536 GLenum target, GLintptr offset, GLsizeiptr size, const void* data) {
1535 if (size == 0) { 1537 if (size == 0) {
1536 return; 1538 return;
1537 } 1539 }
1538 1540
1539 if (size < 0) { 1541 if (size < 0) {
1540 SetGLError(GL_INVALID_VALUE, "glBufferSubData: size < 0"); 1542 SetGLError(GL_INVALID_VALUE, "glBufferSubData", "size < 0");
1541 return; 1543 return;
1542 } 1544 }
1543 1545
1544 ScopedTransferBufferPtr buffer(size, helper_, transfer_buffer_); 1546 ScopedTransferBufferPtr buffer(size, helper_, transfer_buffer_);
1545 BufferSubDataHelperImpl(target, offset, size, data, &buffer); 1547 BufferSubDataHelperImpl(target, offset, size, data, &buffer);
1546 } 1548 }
1547 1549
1548 void GLES2Implementation::BufferSubDataHelperImpl( 1550 void GLES2Implementation::BufferSubDataHelperImpl(
1549 GLenum target, GLintptr offset, GLsizeiptr size, const void* data, 1551 GLenum target, GLintptr offset, GLsizeiptr size, const void* data,
1550 ScopedTransferBufferPtr* buffer) { 1552 ScopedTransferBufferPtr* buffer) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1584 GLsizei height, GLint border, GLsizei image_size, const void* data) { 1586 GLsizei height, GLint border, GLsizei image_size, const void* data) {
1585 GPU_CLIENT_SINGLE_THREAD_CHECK(); 1587 GPU_CLIENT_SINGLE_THREAD_CHECK();
1586 GPU_CLIENT_LOG("[" << this << "] glCompressedTexImage2D(" 1588 GPU_CLIENT_LOG("[" << this << "] glCompressedTexImage2D("
1587 << GLES2Util::GetStringTextureTarget(target) << ", " 1589 << GLES2Util::GetStringTextureTarget(target) << ", "
1588 << level << ", " 1590 << level << ", "
1589 << GLES2Util::GetStringCompressedTextureFormat(internalformat) << ", " 1591 << GLES2Util::GetStringCompressedTextureFormat(internalformat) << ", "
1590 << width << ", " << height << ", " << border << ", " 1592 << width << ", " << height << ", " << border << ", "
1591 << image_size << ", " 1593 << image_size << ", "
1592 << static_cast<const void*>(data) << ")"); 1594 << static_cast<const void*>(data) << ")");
1593 if (width < 0 || height < 0 || level < 0) { 1595 if (width < 0 || height < 0 || level < 0) {
1594 SetGLError(GL_INVALID_VALUE, "glCompressedTexImage2D dimension < 0"); 1596 SetGLError(GL_INVALID_VALUE, "glCompressedTexImage2D", "dimension < 0");
1595 return; 1597 return;
1596 } 1598 }
1597 if (height == 0 || width == 0) { 1599 if (height == 0 || width == 0) {
1598 return; 1600 return;
1599 } 1601 }
1600 SetBucketContents(kResultBucketId, data, image_size); 1602 SetBucketContents(kResultBucketId, data, image_size);
1601 helper_->CompressedTexImage2DBucket( 1603 helper_->CompressedTexImage2DBucket(
1602 target, level, internalformat, width, height, border, kResultBucketId); 1604 target, level, internalformat, width, height, border, kResultBucketId);
1603 // Free the bucket. This is not required but it does free up the memory. 1605 // Free the bucket. This is not required but it does free up the memory.
1604 // and we don't have to wait for the result so from the client's perspective 1606 // and we don't have to wait for the result so from the client's perspective
1605 // it's cheap. 1607 // it's cheap.
1606 helper_->SetBucketSize(kResultBucketId, 0); 1608 helper_->SetBucketSize(kResultBucketId, 0);
1607 } 1609 }
1608 1610
1609 void GLES2Implementation::CompressedTexSubImage2D( 1611 void GLES2Implementation::CompressedTexSubImage2D(
1610 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, 1612 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width,
1611 GLsizei height, GLenum format, GLsizei image_size, const void* data) { 1613 GLsizei height, GLenum format, GLsizei image_size, const void* data) {
1612 GPU_CLIENT_SINGLE_THREAD_CHECK(); 1614 GPU_CLIENT_SINGLE_THREAD_CHECK();
1613 GPU_CLIENT_LOG("[" << this << "] glCompressedTexSubImage2D(" 1615 GPU_CLIENT_LOG("[" << this << "] glCompressedTexSubImage2D("
1614 << GLES2Util::GetStringTextureTarget(target) << ", " 1616 << GLES2Util::GetStringTextureTarget(target) << ", "
1615 << level << ", " 1617 << level << ", "
1616 << xoffset << ", " << yoffset << ", " 1618 << xoffset << ", " << yoffset << ", "
1617 << width << ", " << height << ", " 1619 << width << ", " << height << ", "
1618 << GLES2Util::GetStringCompressedTextureFormat(format) << ", " 1620 << GLES2Util::GetStringCompressedTextureFormat(format) << ", "
1619 << image_size << ", " 1621 << image_size << ", "
1620 << static_cast<const void*>(data) << ")"); 1622 << static_cast<const void*>(data) << ")");
1621 if (width < 0 || height < 0 || level < 0) { 1623 if (width < 0 || height < 0 || level < 0) {
1622 SetGLError(GL_INVALID_VALUE, "glCompressedTexSubImage2D dimension < 0"); 1624 SetGLError(GL_INVALID_VALUE, "glCompressedTexSubImage2D", "dimension < 0");
1623 return; 1625 return;
1624 } 1626 }
1625 SetBucketContents(kResultBucketId, data, image_size); 1627 SetBucketContents(kResultBucketId, data, image_size);
1626 helper_->CompressedTexSubImage2DBucket( 1628 helper_->CompressedTexSubImage2DBucket(
1627 target, level, xoffset, yoffset, width, height, format, kResultBucketId); 1629 target, level, xoffset, yoffset, width, height, format, kResultBucketId);
1628 // Free the bucket. This is not required but it does free up the memory. 1630 // Free the bucket. This is not required but it does free up the memory.
1629 // and we don't have to wait for the result so from the client's perspective 1631 // and we don't have to wait for the result so from the client's perspective
1630 // it's cheap. 1632 // it's cheap.
1631 helper_->SetBucketSize(kResultBucketId, 0); 1633 helper_->SetBucketSize(kResultBucketId, 0);
1632 } 1634 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1673 GPU_CLIENT_SINGLE_THREAD_CHECK(); 1675 GPU_CLIENT_SINGLE_THREAD_CHECK();
1674 GPU_CLIENT_LOG("[" << this << "] glTexImage2D(" 1676 GPU_CLIENT_LOG("[" << this << "] glTexImage2D("
1675 << GLES2Util::GetStringTextureTarget(target) << ", " 1677 << GLES2Util::GetStringTextureTarget(target) << ", "
1676 << level << ", " 1678 << level << ", "
1677 << GLES2Util::GetStringTextureInternalFormat(internalformat) << ", " 1679 << GLES2Util::GetStringTextureInternalFormat(internalformat) << ", "
1678 << width << ", " << height << ", " << border << ", " 1680 << width << ", " << height << ", " << border << ", "
1679 << GLES2Util::GetStringTextureFormat(format) << ", " 1681 << GLES2Util::GetStringTextureFormat(format) << ", "
1680 << GLES2Util::GetStringPixelType(type) << ", " 1682 << GLES2Util::GetStringPixelType(type) << ", "
1681 << static_cast<const void*>(pixels) << ")"); 1683 << static_cast<const void*>(pixels) << ")");
1682 if (level < 0 || height < 0 || width < 0) { 1684 if (level < 0 || height < 0 || width < 0) {
1683 SetGLError(GL_INVALID_VALUE, "glTexImage2D dimension < 0"); 1685 SetGLError(GL_INVALID_VALUE, "glTexImage2D", "dimension < 0");
1684 return; 1686 return;
1685 } 1687 }
1686 uint32 size; 1688 uint32 size;
1687 uint32 unpadded_row_size; 1689 uint32 unpadded_row_size;
1688 uint32 padded_row_size; 1690 uint32 padded_row_size;
1689 if (!GLES2Util::ComputeImageDataSizes( 1691 if (!GLES2Util::ComputeImageDataSizes(
1690 width, height, format, type, unpack_alignment_, &size, 1692 width, height, format, type, unpack_alignment_, &size,
1691 &unpadded_row_size, &padded_row_size)) { 1693 &unpadded_row_size, &padded_row_size)) {
1692 SetGLError(GL_INVALID_VALUE, "glTexImage2D: image size too large"); 1694 SetGLError(GL_INVALID_VALUE, "glTexImage2D", "image size too large");
1693 return; 1695 return;
1694 } 1696 }
1695 1697
1696 // If there's no data just issue TexImage2D 1698 // If there's no data just issue TexImage2D
1697 if (!pixels) { 1699 if (!pixels) {
1698 helper_->TexImage2D( 1700 helper_->TexImage2D(
1699 target, level, internalformat, width, height, border, format, type, 1701 target, level, internalformat, width, height, border, format, type,
1700 0, 0); 1702 0, 0);
1701 return; 1703 return;
1702 } 1704 }
1703 1705
1704 // compute the advance bytes per row for the src pixels 1706 // compute the advance bytes per row for the src pixels
1705 uint32 src_padded_row_size; 1707 uint32 src_padded_row_size;
1706 if (unpack_row_length_ > 0) { 1708 if (unpack_row_length_ > 0) {
1707 if (!GLES2Util::ComputeImagePaddedRowSize( 1709 if (!GLES2Util::ComputeImagePaddedRowSize(
1708 unpack_row_length_, format, type, unpack_alignment_, 1710 unpack_row_length_, format, type, unpack_alignment_,
1709 &src_padded_row_size)) { 1711 &src_padded_row_size)) {
1710 SetGLError(GL_INVALID_VALUE, "glTexImage2D: unpack row length too large"); 1712 SetGLError(
1713 GL_INVALID_VALUE, "glTexImage2D", "unpack row length too large");
1711 return; 1714 return;
1712 } 1715 }
1713 } else { 1716 } else {
1714 src_padded_row_size = padded_row_size; 1717 src_padded_row_size = padded_row_size;
1715 } 1718 }
1716 1719
1717 // advance pixels pointer past the skip rows and skip pixels 1720 // advance pixels pointer past the skip rows and skip pixels
1718 pixels = reinterpret_cast<const int8*>(pixels) + 1721 pixels = reinterpret_cast<const int8*>(pixels) +
1719 unpack_skip_rows_ * src_padded_row_size; 1722 unpack_skip_rows_ * src_padded_row_size;
1720 if (unpack_skip_pixels_) { 1723 if (unpack_skip_pixels_) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1755 GPU_CLIENT_LOG("[" << this << "] glTexSubImage2D(" 1758 GPU_CLIENT_LOG("[" << this << "] glTexSubImage2D("
1756 << GLES2Util::GetStringTextureTarget(target) << ", " 1759 << GLES2Util::GetStringTextureTarget(target) << ", "
1757 << level << ", " 1760 << level << ", "
1758 << xoffset << ", " << yoffset << ", " 1761 << xoffset << ", " << yoffset << ", "
1759 << width << ", " << height << ", " 1762 << width << ", " << height << ", "
1760 << GLES2Util::GetStringTextureFormat(format) << ", " 1763 << GLES2Util::GetStringTextureFormat(format) << ", "
1761 << GLES2Util::GetStringPixelType(type) << ", " 1764 << GLES2Util::GetStringPixelType(type) << ", "
1762 << static_cast<const void*>(pixels) << ")"); 1765 << static_cast<const void*>(pixels) << ")");
1763 1766
1764 if (level < 0 || height < 0 || width < 0) { 1767 if (level < 0 || height < 0 || width < 0) {
1765 SetGLError(GL_INVALID_VALUE, "glTexSubImage2D dimension < 0"); 1768 SetGLError(GL_INVALID_VALUE, "glTexSubImage2D", "dimension < 0");
1766 return; 1769 return;
1767 } 1770 }
1768 if (height == 0 || width == 0) { 1771 if (height == 0 || width == 0) {
1769 return; 1772 return;
1770 } 1773 }
1771 1774
1772 uint32 temp_size; 1775 uint32 temp_size;
1773 uint32 unpadded_row_size; 1776 uint32 unpadded_row_size;
1774 uint32 padded_row_size; 1777 uint32 padded_row_size;
1775 if (!GLES2Util::ComputeImageDataSizes( 1778 if (!GLES2Util::ComputeImageDataSizes(
1776 width, height, format, type, unpack_alignment_, &temp_size, 1779 width, height, format, type, unpack_alignment_, &temp_size,
1777 &unpadded_row_size, &padded_row_size)) { 1780 &unpadded_row_size, &padded_row_size)) {
1778 SetGLError(GL_INVALID_VALUE, "glTexSubImage2D: size to large"); 1781 SetGLError(GL_INVALID_VALUE, "glTexSubImage2D", "size to large");
1779 return; 1782 return;
1780 } 1783 }
1781 1784
1782 // compute the advance bytes per row for the src pixels 1785 // compute the advance bytes per row for the src pixels
1783 uint32 src_padded_row_size; 1786 uint32 src_padded_row_size;
1784 if (unpack_row_length_ > 0) { 1787 if (unpack_row_length_ > 0) {
1785 if (!GLES2Util::ComputeImagePaddedRowSize( 1788 if (!GLES2Util::ComputeImagePaddedRowSize(
1786 unpack_row_length_, format, type, unpack_alignment_, 1789 unpack_row_length_, format, type, unpack_alignment_,
1787 &src_padded_row_size)) { 1790 &src_padded_row_size)) {
1788 SetGLError(GL_INVALID_VALUE, "glTexImage2D: unpack row length too large"); 1791 SetGLError(
1792 GL_INVALID_VALUE, "glTexImage2D", "unpack row length too large");
1789 return; 1793 return;
1790 } 1794 }
1791 } else { 1795 } else {
1792 src_padded_row_size = padded_row_size; 1796 src_padded_row_size = padded_row_size;
1793 } 1797 }
1794 1798
1795 // advance pixels pointer past the skip rows and skip pixels 1799 // advance pixels pointer past the skip rows and skip pixels
1796 pixels = reinterpret_cast<const int8*>(pixels) + 1800 pixels = reinterpret_cast<const int8*>(pixels) +
1797 unpack_skip_rows_ * src_padded_row_size; 1801 unpack_skip_rows_ * src_padded_row_size;
1798 if (unpack_skip_pixels_) { 1802 if (unpack_skip_pixels_) {
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1903 GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, 1907 GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size,
1904 GLenum* type, char* name) { 1908 GLenum* type, char* name) {
1905 GPU_CLIENT_SINGLE_THREAD_CHECK(); 1909 GPU_CLIENT_SINGLE_THREAD_CHECK();
1906 GPU_CLIENT_LOG("[" << this << "] glGetActiveAttrib(" 1910 GPU_CLIENT_LOG("[" << this << "] glGetActiveAttrib("
1907 << program << ", " << index << ", " << bufsize << ", " 1911 << program << ", " << index << ", " << bufsize << ", "
1908 << static_cast<const void*>(length) << ", " 1912 << static_cast<const void*>(length) << ", "
1909 << static_cast<const void*>(size) << ", " 1913 << static_cast<const void*>(size) << ", "
1910 << static_cast<const void*>(type) << ", " 1914 << static_cast<const void*>(type) << ", "
1911 << static_cast<const void*>(name) << ", "); 1915 << static_cast<const void*>(name) << ", ");
1912 if (bufsize < 0) { 1916 if (bufsize < 0) {
1913 SetGLError(GL_INVALID_VALUE, "glGetActiveAttrib: bufsize < 0"); 1917 SetGLError(GL_INVALID_VALUE, "glGetActiveAttrib", "bufsize < 0");
1914 return; 1918 return;
1915 } 1919 }
1916 TRACE_EVENT0("gpu", "GLES2::GetActiveAttrib"); 1920 TRACE_EVENT0("gpu", "GLES2::GetActiveAttrib");
1917 bool success = share_group_->program_info_manager()->GetActiveAttrib( 1921 bool success = share_group_->program_info_manager()->GetActiveAttrib(
1918 this, program, index, bufsize, length, size, type, name); 1922 this, program, index, bufsize, length, size, type, name);
1919 if (success) { 1923 if (success) {
1920 if (size) { 1924 if (size) {
1921 GPU_CLIENT_LOG(" size: " << *size); 1925 GPU_CLIENT_LOG(" size: " << *size);
1922 } 1926 }
1923 if (type) { 1927 if (type) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1973 GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, 1977 GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size,
1974 GLenum* type, char* name) { 1978 GLenum* type, char* name) {
1975 GPU_CLIENT_SINGLE_THREAD_CHECK(); 1979 GPU_CLIENT_SINGLE_THREAD_CHECK();
1976 GPU_CLIENT_LOG("[" << this << "] glGetActiveUniform(" 1980 GPU_CLIENT_LOG("[" << this << "] glGetActiveUniform("
1977 << program << ", " << index << ", " << bufsize << ", " 1981 << program << ", " << index << ", " << bufsize << ", "
1978 << static_cast<const void*>(length) << ", " 1982 << static_cast<const void*>(length) << ", "
1979 << static_cast<const void*>(size) << ", " 1983 << static_cast<const void*>(size) << ", "
1980 << static_cast<const void*>(type) << ", " 1984 << static_cast<const void*>(type) << ", "
1981 << static_cast<const void*>(name) << ", "); 1985 << static_cast<const void*>(name) << ", ");
1982 if (bufsize < 0) { 1986 if (bufsize < 0) {
1983 SetGLError(GL_INVALID_VALUE, "glGetActiveUniform: bufsize < 0"); 1987 SetGLError(GL_INVALID_VALUE, "glGetActiveUniform", "bufsize < 0");
1984 return; 1988 return;
1985 } 1989 }
1986 TRACE_EVENT0("gpu", "GLES2::GetActiveUniform"); 1990 TRACE_EVENT0("gpu", "GLES2::GetActiveUniform");
1987 bool success = share_group_->program_info_manager()->GetActiveUniform( 1991 bool success = share_group_->program_info_manager()->GetActiveUniform(
1988 this, program, index, bufsize, length, size, type, name); 1992 this, program, index, bufsize, length, size, type, name);
1989 if (success) { 1993 if (success) {
1990 if (size) { 1994 if (size) {
1991 GPU_CLIENT_LOG(" size: " << *size); 1995 GPU_CLIENT_LOG(" size: " << *size);
1992 } 1996 }
1993 if (type) { 1997 if (type) {
1994 GPU_CLIENT_LOG(" type: " << GLES2Util::GetStringEnum(*type)); 1998 GPU_CLIENT_LOG(" type: " << GLES2Util::GetStringEnum(*type));
1995 } 1999 }
1996 if (name) { 2000 if (name) {
1997 GPU_CLIENT_LOG(" name: " << name); 2001 GPU_CLIENT_LOG(" name: " << name);
1998 } 2002 }
1999 } 2003 }
2000 } 2004 }
2001 2005
2002 void GLES2Implementation::GetAttachedShaders( 2006 void GLES2Implementation::GetAttachedShaders(
2003 GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) { 2007 GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) {
2004 GPU_CLIENT_SINGLE_THREAD_CHECK(); 2008 GPU_CLIENT_SINGLE_THREAD_CHECK();
2005 GPU_CLIENT_LOG("[" << this << "] glGetAttachedShaders(" 2009 GPU_CLIENT_LOG("[" << this << "] glGetAttachedShaders("
2006 << program << ", " << maxcount << ", " 2010 << program << ", " << maxcount << ", "
2007 << static_cast<const void*>(count) << ", " 2011 << static_cast<const void*>(count) << ", "
2008 << static_cast<const void*>(shaders) << ", "); 2012 << static_cast<const void*>(shaders) << ", ");
2009 if (maxcount < 0) { 2013 if (maxcount < 0) {
2010 SetGLError(GL_INVALID_VALUE, "glGetAttachedShaders: maxcount < 0"); 2014 SetGLError(GL_INVALID_VALUE, "glGetAttachedShaders", "maxcount < 0");
2011 return; 2015 return;
2012 } 2016 }
2013 TRACE_EVENT0("gpu", "GLES2::GetAttachedShaders"); 2017 TRACE_EVENT0("gpu", "GLES2::GetAttachedShaders");
2014 typedef gles2::GetAttachedShaders::Result Result; 2018 typedef gles2::GetAttachedShaders::Result Result;
2015 uint32 size = Result::ComputeSize(maxcount); 2019 uint32 size = Result::ComputeSize(maxcount);
2016 Result* result = static_cast<Result*>(transfer_buffer_->Alloc(size)); 2020 Result* result = static_cast<Result*>(transfer_buffer_->Alloc(size));
2017 if (!result) { 2021 if (!result) {
2018 return; 2022 return;
2019 } 2023 }
2020 result->SetNumResults(0); 2024 result->SetNumResults(0);
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
2174 GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, 2178 GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format,
2175 GLenum type, void* pixels) { 2179 GLenum type, void* pixels) {
2176 GPU_CLIENT_SINGLE_THREAD_CHECK(); 2180 GPU_CLIENT_SINGLE_THREAD_CHECK();
2177 GPU_CLIENT_LOG("[" << this << "] glReadPixels(" 2181 GPU_CLIENT_LOG("[" << this << "] glReadPixels("
2178 << xoffset << ", " << yoffset << ", " 2182 << xoffset << ", " << yoffset << ", "
2179 << width << ", " << height << ", " 2183 << width << ", " << height << ", "
2180 << GLES2Util::GetStringReadPixelFormat(format) << ", " 2184 << GLES2Util::GetStringReadPixelFormat(format) << ", "
2181 << GLES2Util::GetStringPixelType(type) << ", " 2185 << GLES2Util::GetStringPixelType(type) << ", "
2182 << static_cast<const void*>(pixels) << ")"); 2186 << static_cast<const void*>(pixels) << ")");
2183 if (width < 0 || height < 0) { 2187 if (width < 0 || height < 0) {
2184 SetGLError(GL_INVALID_VALUE, "glReadPixels: dimensions < 0"); 2188 SetGLError(GL_INVALID_VALUE, "glReadPixels", "dimensions < 0");
2185 return; 2189 return;
2186 } 2190 }
2187 if (width == 0 || height == 0) { 2191 if (width == 0 || height == 0) {
2188 return; 2192 return;
2189 } 2193 }
2190 2194
2191 // glReadPixel pads the size of each row of pixels by an amount specified by 2195 // glReadPixel pads the size of each row of pixels by an amount specified by
2192 // glPixelStorei. So, we have to take that into account both in the fact that 2196 // glPixelStorei. So, we have to take that into account both in the fact that
2193 // the pixels returned from the ReadPixel command will include that padding 2197 // the pixels returned from the ReadPixel command will include that padding
2194 // and that when we copy the results to the user's buffer we need to not 2198 // and that when we copy the results to the user's buffer we need to not
2195 // write those padding bytes but leave them as they are. 2199 // write those padding bytes but leave them as they are.
2196 2200
2197 TRACE_EVENT0("gpu", "GLES2::ReadPixels"); 2201 TRACE_EVENT0("gpu", "GLES2::ReadPixels");
2198 typedef gles2::ReadPixels::Result Result; 2202 typedef gles2::ReadPixels::Result Result;
2199 2203
2200 int8* dest = reinterpret_cast<int8*>(pixels); 2204 int8* dest = reinterpret_cast<int8*>(pixels);
2201 uint32 temp_size; 2205 uint32 temp_size;
2202 uint32 unpadded_row_size; 2206 uint32 unpadded_row_size;
2203 uint32 padded_row_size; 2207 uint32 padded_row_size;
2204 if (!GLES2Util::ComputeImageDataSizes( 2208 if (!GLES2Util::ComputeImageDataSizes(
2205 width, 2, format, type, pack_alignment_, &temp_size, &unpadded_row_size, 2209 width, 2, format, type, pack_alignment_, &temp_size, &unpadded_row_size,
2206 &padded_row_size)) { 2210 &padded_row_size)) {
2207 SetGLError(GL_INVALID_VALUE, "glReadPixels: size too large."); 2211 SetGLError(GL_INVALID_VALUE, "glReadPixels", "size too large.");
2208 return; 2212 return;
2209 } 2213 }
2210 // Transfer by rows. 2214 // Transfer by rows.
2211 // The max rows we can transfer. 2215 // The max rows we can transfer.
2212 while (height) { 2216 while (height) {
2213 GLsizei desired_size = padded_row_size * height - 1 + unpadded_row_size; 2217 GLsizei desired_size = padded_row_size * height - 1 + unpadded_row_size;
2214 ScopedTransferBufferPtr buffer(desired_size, helper_, transfer_buffer_); 2218 ScopedTransferBufferPtr buffer(desired_size, helper_, transfer_buffer_);
2215 if (!buffer.valid()) { 2219 if (!buffer.valid()) {
2216 return; 2220 return;
2217 } 2221 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
2260 } 2264 }
2261 } 2265 }
2262 2266
2263 void GLES2Implementation::ActiveTexture(GLenum texture) { 2267 void GLES2Implementation::ActiveTexture(GLenum texture) {
2264 GPU_CLIENT_SINGLE_THREAD_CHECK(); 2268 GPU_CLIENT_SINGLE_THREAD_CHECK();
2265 GPU_CLIENT_LOG("[" << this << "] glActiveTexture(" 2269 GPU_CLIENT_LOG("[" << this << "] glActiveTexture("
2266 << GLES2Util::GetStringEnum(texture) << ")"); 2270 << GLES2Util::GetStringEnum(texture) << ")");
2267 GLuint texture_index = texture - GL_TEXTURE0; 2271 GLuint texture_index = texture - GL_TEXTURE0;
2268 if (texture_index >= static_cast<GLuint>( 2272 if (texture_index >= static_cast<GLuint>(
2269 gl_state_.int_state.max_combined_texture_image_units)) { 2273 gl_state_.int_state.max_combined_texture_image_units)) {
2270 SetGLError(GL_INVALID_ENUM, "glActiveTexture: texture_unit out of range."); 2274 SetGLError(
2275 GL_INVALID_ENUM, "glActiveTexture", "texture_unit out of range.");
2271 return; 2276 return;
2272 } 2277 }
2273 2278
2274 active_texture_unit_ = texture_index; 2279 active_texture_unit_ = texture_index;
2275 helper_->ActiveTexture(texture); 2280 helper_->ActiveTexture(texture);
2276 } 2281 }
2277 2282
2278 // NOTE #1: On old versions of OpenGL, calling glBindXXX with an unused id 2283 // NOTE #1: On old versions of OpenGL, calling glBindXXX with an unused id
2279 // generates a new resource. On newer versions of OpenGL they don't. The code 2284 // generates a new resource. On newer versions of OpenGL they don't. The code
2280 // related to binding below will need to change if we switch to the new OpenGL 2285 // related to binding below will need to change if we switch to the new OpenGL
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
2362 return false; 2367 return false;
2363 } 2368 }
2364 #endif 2369 #endif
2365 2370
2366 void GLES2Implementation::DeleteBuffersHelper( 2371 void GLES2Implementation::DeleteBuffersHelper(
2367 GLsizei n, const GLuint* buffers) { 2372 GLsizei n, const GLuint* buffers) {
2368 if (!GetIdHandler(id_namespaces::kBuffers)->FreeIds( 2373 if (!GetIdHandler(id_namespaces::kBuffers)->FreeIds(
2369 this, n, buffers, &GLES2Implementation::DeleteBuffersStub)) { 2374 this, n, buffers, &GLES2Implementation::DeleteBuffersStub)) {
2370 SetGLError( 2375 SetGLError(
2371 GL_INVALID_VALUE, 2376 GL_INVALID_VALUE,
2372 "glDeleteBuffers: id not created by this context."); 2377 "glDeleteBuffers", "id not created by this context.");
2373 return; 2378 return;
2374 } 2379 }
2375 for (GLsizei ii = 0; ii < n; ++ii) { 2380 for (GLsizei ii = 0; ii < n; ++ii) {
2376 if (buffers[ii] == bound_array_buffer_id_) { 2381 if (buffers[ii] == bound_array_buffer_id_) {
2377 bound_array_buffer_id_ = 0; 2382 bound_array_buffer_id_ = 0;
2378 } 2383 }
2379 if (buffers[ii] == bound_element_array_buffer_id_) { 2384 if (buffers[ii] == bound_element_array_buffer_id_) {
2380 bound_element_array_buffer_id_ = 0; 2385 bound_element_array_buffer_id_ = 0;
2381 } 2386 }
2382 } 2387 }
2383 } 2388 }
2384 2389
2385 void GLES2Implementation::DeleteBuffersStub( 2390 void GLES2Implementation::DeleteBuffersStub(
2386 GLsizei n, const GLuint* buffers) { 2391 GLsizei n, const GLuint* buffers) {
2387 helper_->DeleteBuffersImmediate(n, buffers); 2392 helper_->DeleteBuffersImmediate(n, buffers);
2388 } 2393 }
2389 2394
2390 2395
2391 void GLES2Implementation::DeleteFramebuffersHelper( 2396 void GLES2Implementation::DeleteFramebuffersHelper(
2392 GLsizei n, const GLuint* framebuffers) { 2397 GLsizei n, const GLuint* framebuffers) {
2393 if (!GetIdHandler(id_namespaces::kFramebuffers)->FreeIds( 2398 if (!GetIdHandler(id_namespaces::kFramebuffers)->FreeIds(
2394 this, n, framebuffers, &GLES2Implementation::DeleteFramebuffersStub)) { 2399 this, n, framebuffers, &GLES2Implementation::DeleteFramebuffersStub)) {
2395 SetGLError( 2400 SetGLError(
2396 GL_INVALID_VALUE, 2401 GL_INVALID_VALUE,
2397 "glDeleteFramebuffers: id not created by this context."); 2402 "glDeleteFramebuffers", "id not created by this context.");
2398 return; 2403 return;
2399 } 2404 }
2400 for (GLsizei ii = 0; ii < n; ++ii) { 2405 for (GLsizei ii = 0; ii < n; ++ii) {
2401 if (framebuffers[ii] == bound_framebuffer_) { 2406 if (framebuffers[ii] == bound_framebuffer_) {
2402 bound_framebuffer_ = 0; 2407 bound_framebuffer_ = 0;
2403 } 2408 }
2404 } 2409 }
2405 } 2410 }
2406 2411
2407 void GLES2Implementation::DeleteFramebuffersStub( 2412 void GLES2Implementation::DeleteFramebuffersStub(
2408 GLsizei n, const GLuint* framebuffers) { 2413 GLsizei n, const GLuint* framebuffers) {
2409 helper_->DeleteFramebuffersImmediate(n, framebuffers); 2414 helper_->DeleteFramebuffersImmediate(n, framebuffers);
2410 } 2415 }
2411 2416
2412 void GLES2Implementation::DeleteRenderbuffersHelper( 2417 void GLES2Implementation::DeleteRenderbuffersHelper(
2413 GLsizei n, const GLuint* renderbuffers) { 2418 GLsizei n, const GLuint* renderbuffers) {
2414 if (!GetIdHandler(id_namespaces::kRenderbuffers)->FreeIds( 2419 if (!GetIdHandler(id_namespaces::kRenderbuffers)->FreeIds(
2415 this, n, renderbuffers, &GLES2Implementation::DeleteRenderbuffersStub)) { 2420 this, n, renderbuffers, &GLES2Implementation::DeleteRenderbuffersStub)) {
2416 SetGLError( 2421 SetGLError(
2417 GL_INVALID_VALUE, 2422 GL_INVALID_VALUE,
2418 "glDeleteRenderbuffers: id not created by this context."); 2423 "glDeleteRenderbuffers", "id not created by this context.");
2419 return; 2424 return;
2420 } 2425 }
2421 for (GLsizei ii = 0; ii < n; ++ii) { 2426 for (GLsizei ii = 0; ii < n; ++ii) {
2422 if (renderbuffers[ii] == bound_renderbuffer_) { 2427 if (renderbuffers[ii] == bound_renderbuffer_) {
2423 bound_renderbuffer_ = 0; 2428 bound_renderbuffer_ = 0;
2424 } 2429 }
2425 } 2430 }
2426 } 2431 }
2427 2432
2428 void GLES2Implementation::DeleteRenderbuffersStub( 2433 void GLES2Implementation::DeleteRenderbuffersStub(
2429 GLsizei n, const GLuint* renderbuffers) { 2434 GLsizei n, const GLuint* renderbuffers) {
2430 helper_->DeleteRenderbuffersImmediate(n, renderbuffers); 2435 helper_->DeleteRenderbuffersImmediate(n, renderbuffers);
2431 } 2436 }
2432 2437
2433 void GLES2Implementation::DeleteTexturesHelper( 2438 void GLES2Implementation::DeleteTexturesHelper(
2434 GLsizei n, const GLuint* textures) { 2439 GLsizei n, const GLuint* textures) {
2435 if (!GetIdHandler(id_namespaces::kTextures)->FreeIds( 2440 if (!GetIdHandler(id_namespaces::kTextures)->FreeIds(
2436 this, n, textures, &GLES2Implementation::DeleteTexturesStub)) { 2441 this, n, textures, &GLES2Implementation::DeleteTexturesStub)) {
2437 SetGLError( 2442 SetGLError(
2438 GL_INVALID_VALUE, 2443 GL_INVALID_VALUE,
2439 "glDeleteTextures: id not created by this context."); 2444 "glDeleteTextures", "id not created by this context.");
2440 return; 2445 return;
2441 } 2446 }
2442 for (GLsizei ii = 0; ii < n; ++ii) { 2447 for (GLsizei ii = 0; ii < n; ++ii) {
2443 for (GLint tt = 0; 2448 for (GLint tt = 0;
2444 tt < gl_state_.int_state.max_combined_texture_image_units; 2449 tt < gl_state_.int_state.max_combined_texture_image_units;
2445 ++tt) { 2450 ++tt) {
2446 TextureUnit& unit = texture_units_[tt]; 2451 TextureUnit& unit = texture_units_[tt];
2447 if (textures[ii] == unit.bound_texture_2d) { 2452 if (textures[ii] == unit.bound_texture_2d) {
2448 unit.bound_texture_2d = 0; 2453 unit.bound_texture_2d = 0;
2449 } 2454 }
(...skipping 27 matching lines...) Expand all
2477 #endif 2482 #endif
2478 helper_->EnableVertexAttribArray(index); 2483 helper_->EnableVertexAttribArray(index);
2479 } 2484 }
2480 2485
2481 void GLES2Implementation::DrawArrays(GLenum mode, GLint first, GLsizei count) { 2486 void GLES2Implementation::DrawArrays(GLenum mode, GLint first, GLsizei count) {
2482 GPU_CLIENT_SINGLE_THREAD_CHECK(); 2487 GPU_CLIENT_SINGLE_THREAD_CHECK();
2483 GPU_CLIENT_LOG("[" << this << "] glDrawArrays(" 2488 GPU_CLIENT_LOG("[" << this << "] glDrawArrays("
2484 << GLES2Util::GetStringDrawMode(mode) << ", " 2489 << GLES2Util::GetStringDrawMode(mode) << ", "
2485 << first << ", " << count << ")"); 2490 << first << ", " << count << ")");
2486 if (count < 0) { 2491 if (count < 0) {
2487 SetGLError(GL_INVALID_VALUE, "glDrawArrays: count < 0"); 2492 SetGLError(GL_INVALID_VALUE, "glDrawArrays", "count < 0");
2488 return; 2493 return;
2489 } 2494 }
2490 #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) 2495 #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS)
2491 bool have_client_side = 2496 bool have_client_side =
2492 client_side_buffer_helper_->HaveEnabledClientSideBuffers(); 2497 client_side_buffer_helper_->HaveEnabledClientSideBuffers();
2493 if (have_client_side) { 2498 if (have_client_side) {
2494 client_side_buffer_helper_->SetupSimulatedClientSideBuffers( 2499 client_side_buffer_helper_->SetupSimulatedClientSideBuffers(
2495 this, helper_, first + count, 0); 2500 this, helper_, first + count, 0);
2496 } 2501 }
2497 #endif 2502 #endif
(...skipping 30 matching lines...) Expand all
2528 break; 2533 break;
2529 case GL_VERTEX_ATTRIB_ARRAY_TYPE: 2534 case GL_VERTEX_ATTRIB_ARRAY_TYPE:
2530 *param = info->type(); 2535 *param = info->type();
2531 break; 2536 break;
2532 case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED: 2537 case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED:
2533 *param = info->normalized(); 2538 *param = info->normalized();
2534 break; 2539 break;
2535 case GL_CURRENT_VERTEX_ATTRIB: 2540 case GL_CURRENT_VERTEX_ATTRIB:
2536 return false; // pass through to service side. 2541 return false; // pass through to service side.
2537 default: 2542 default:
2538 SetGLError(GL_INVALID_ENUM, "glGetVertexAttrib: invalid enum"); 2543 SetGLError(GL_INVALID_ENUM, "glGetVertexAttrib", "invalid enum");
2539 break; 2544 break;
2540 } 2545 }
2541 return true; 2546 return true;
2542 } 2547 }
2543 #endif // GLES2_SUPPORT_CLIENT_SIDE_ARRAYS 2548 #endif // GLES2_SUPPORT_CLIENT_SIDE_ARRAYS
2544 2549
2545 void GLES2Implementation::GetVertexAttribfv( 2550 void GLES2Implementation::GetVertexAttribfv(
2546 GLuint index, GLenum pname, GLfloat* params) { 2551 GLuint index, GLenum pname, GLfloat* params) {
2547 GPU_CLIENT_SINGLE_THREAD_CHECK(); 2552 GPU_CLIENT_SINGLE_THREAD_CHECK();
2548 GPU_CLIENT_LOG("[" << this << "] glGetVertexAttribfv(" 2553 GPU_CLIENT_LOG("[" << this << "] glGetVertexAttribfv("
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
2629 2634
2630 void* GLES2Implementation::MapBufferSubDataCHROMIUM( 2635 void* GLES2Implementation::MapBufferSubDataCHROMIUM(
2631 GLuint target, GLintptr offset, GLsizeiptr size, GLenum access) { 2636 GLuint target, GLintptr offset, GLsizeiptr size, GLenum access) {
2632 GPU_CLIENT_SINGLE_THREAD_CHECK(); 2637 GPU_CLIENT_SINGLE_THREAD_CHECK();
2633 GPU_CLIENT_LOG("[" << this << "] glMapBufferSubDataCHROMIUM(" 2638 GPU_CLIENT_LOG("[" << this << "] glMapBufferSubDataCHROMIUM("
2634 << target << ", " << offset << ", " << size << ", " 2639 << target << ", " << offset << ", " << size << ", "
2635 << GLES2Util::GetStringEnum(access) << ")"); 2640 << GLES2Util::GetStringEnum(access) << ")");
2636 // NOTE: target is NOT checked because the service will check it 2641 // NOTE: target is NOT checked because the service will check it
2637 // and we don't know what targets are valid. 2642 // and we don't know what targets are valid.
2638 if (access != GL_WRITE_ONLY) { 2643 if (access != GL_WRITE_ONLY) {
2639 SetGLError(GL_INVALID_ENUM, "MapBufferSubDataCHROMIUM: bad access mode"); 2644 SetGLError(
2645 GL_INVALID_ENUM, "glMapBufferSubDataCHROMIUM", "bad access mode");
2640 return NULL; 2646 return NULL;
2641 } 2647 }
2642 if (offset < 0 || size < 0) { 2648 if (offset < 0 || size < 0) {
2643 SetGLError(GL_INVALID_VALUE, "MapBufferSubDataCHROMIUM: bad range"); 2649 SetGLError(GL_INVALID_VALUE, "glMapBufferSubDataCHROMIUM", "bad range");
2644 return NULL; 2650 return NULL;
2645 } 2651 }
2646 int32 shm_id; 2652 int32 shm_id;
2647 unsigned int shm_offset; 2653 unsigned int shm_offset;
2648 void* mem = mapped_memory_->Alloc(size, &shm_id, &shm_offset); 2654 void* mem = mapped_memory_->Alloc(size, &shm_id, &shm_offset);
2649 if (!mem) { 2655 if (!mem) {
2650 SetGLError(GL_OUT_OF_MEMORY, "MapBufferSubDataCHROMIUM: out of memory"); 2656 SetGLError(GL_OUT_OF_MEMORY, "glMapBufferSubDataCHROMIUM", "out of memory");
2651 return NULL; 2657 return NULL;
2652 } 2658 }
2653 2659
2654 std::pair<MappedBufferMap::iterator, bool> result = 2660 std::pair<MappedBufferMap::iterator, bool> result =
2655 mapped_buffers_.insert(std::make_pair( 2661 mapped_buffers_.insert(std::make_pair(
2656 mem, 2662 mem,
2657 MappedBuffer( 2663 MappedBuffer(
2658 access, shm_id, mem, shm_offset, target, offset, size))); 2664 access, shm_id, mem, shm_offset, target, offset, size)));
2659 GPU_DCHECK(result.second); 2665 GPU_DCHECK(result.second);
2660 GPU_CLIENT_LOG(" returned " << mem); 2666 GPU_CLIENT_LOG(" returned " << mem);
2661 return mem; 2667 return mem;
2662 } 2668 }
2663 2669
2664 void GLES2Implementation::UnmapBufferSubDataCHROMIUM(const void* mem) { 2670 void GLES2Implementation::UnmapBufferSubDataCHROMIUM(const void* mem) {
2665 GPU_CLIENT_SINGLE_THREAD_CHECK(); 2671 GPU_CLIENT_SINGLE_THREAD_CHECK();
2666 GPU_CLIENT_LOG( 2672 GPU_CLIENT_LOG(
2667 "[" << this << "] glUnmapBufferSubDataCHROMIUM(" << mem << ")"); 2673 "[" << this << "] glUnmapBufferSubDataCHROMIUM(" << mem << ")");
2668 MappedBufferMap::iterator it = mapped_buffers_.find(mem); 2674 MappedBufferMap::iterator it = mapped_buffers_.find(mem);
2669 if (it == mapped_buffers_.end()) { 2675 if (it == mapped_buffers_.end()) {
2670 SetGLError( 2676 SetGLError(
2671 GL_INVALID_VALUE, "UnmapBufferSubDataCHROMIUM: buffer not mapped"); 2677 GL_INVALID_VALUE, "UnmapBufferSubDataCHROMIUM", "buffer not mapped");
2672 return; 2678 return;
2673 } 2679 }
2674 const MappedBuffer& mb = it->second; 2680 const MappedBuffer& mb = it->second;
2675 helper_->BufferSubData( 2681 helper_->BufferSubData(
2676 mb.target, mb.offset, mb.size, mb.shm_id, mb.shm_offset); 2682 mb.target, mb.offset, mb.size, mb.shm_id, mb.shm_offset);
2677 mapped_memory_->FreePendingToken(mb.shm_memory, helper_->InsertToken()); 2683 mapped_memory_->FreePendingToken(mb.shm_memory, helper_->InsertToken());
2678 // Flushing after unmap lets the service side start processing commands 2684 // Flushing after unmap lets the service side start processing commands
2679 // sooner. However, on lowend devices, the thread thrashing causes is 2685 // sooner. However, on lowend devices, the thread thrashing causes is
2680 // worse than the latency hit. 2686 // worse than the latency hit.
2681 #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) 2687 #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS)
(...skipping 14 matching lines...) Expand all
2696 GLenum access) { 2702 GLenum access) {
2697 GPU_CLIENT_SINGLE_THREAD_CHECK(); 2703 GPU_CLIENT_SINGLE_THREAD_CHECK();
2698 GPU_CLIENT_LOG("[" << this << "] glMapTexSubImage2DCHROMIUM(" 2704 GPU_CLIENT_LOG("[" << this << "] glMapTexSubImage2DCHROMIUM("
2699 << target << ", " << level << ", " 2705 << target << ", " << level << ", "
2700 << xoffset << ", " << yoffset << ", " 2706 << xoffset << ", " << yoffset << ", "
2701 << width << ", " << height << ", " 2707 << width << ", " << height << ", "
2702 << GLES2Util::GetStringTextureFormat(format) << ", " 2708 << GLES2Util::GetStringTextureFormat(format) << ", "
2703 << GLES2Util::GetStringPixelType(type) << ", " 2709 << GLES2Util::GetStringPixelType(type) << ", "
2704 << GLES2Util::GetStringEnum(access) << ")"); 2710 << GLES2Util::GetStringEnum(access) << ")");
2705 if (access != GL_WRITE_ONLY) { 2711 if (access != GL_WRITE_ONLY) {
2706 SetGLError(GL_INVALID_ENUM, "MapTexSubImage2DCHROMIUM: bad access mode"); 2712 SetGLError(
2713 GL_INVALID_ENUM, "glMapTexSubImage2DCHROMIUM", "bad access mode");
2707 return NULL; 2714 return NULL;
2708 } 2715 }
2709 // NOTE: target is NOT checked because the service will check it 2716 // NOTE: target is NOT checked because the service will check it
2710 // and we don't know what targets are valid. 2717 // and we don't know what targets are valid.
2711 if (level < 0 || xoffset < 0 || yoffset < 0 || width < 0 || height < 0) { 2718 if (level < 0 || xoffset < 0 || yoffset < 0 || width < 0 || height < 0) {
2712 SetGLError(GL_INVALID_VALUE, "MapTexSubImage2DCHROMIUM: bad dimensions"); 2719 SetGLError(
2720 GL_INVALID_VALUE, "glMapTexSubImage2DCHROMIUM", "bad dimensions");
2713 return NULL; 2721 return NULL;
2714 } 2722 }
2715 uint32 size; 2723 uint32 size;
2716 if (!GLES2Util::ComputeImageDataSizes( 2724 if (!GLES2Util::ComputeImageDataSizes(
2717 width, height, format, type, unpack_alignment_, &size, NULL, NULL)) { 2725 width, height, format, type, unpack_alignment_, &size, NULL, NULL)) {
2718 SetGLError( 2726 SetGLError(
2719 GL_INVALID_VALUE, "MapTexSubImage2DCHROMIUM: image size too large"); 2727 GL_INVALID_VALUE, "glMapTexSubImage2DCHROMIUM", "image size too large");
2720 return NULL; 2728 return NULL;
2721 } 2729 }
2722 int32 shm_id; 2730 int32 shm_id;
2723 unsigned int shm_offset; 2731 unsigned int shm_offset;
2724 void* mem = mapped_memory_->Alloc(size, &shm_id, &shm_offset); 2732 void* mem = mapped_memory_->Alloc(size, &shm_id, &shm_offset);
2725 if (!mem) { 2733 if (!mem) {
2726 SetGLError(GL_OUT_OF_MEMORY, "MapTexSubImage2DCHROMIUM: out of memory"); 2734 SetGLError(GL_OUT_OF_MEMORY, "glMapTexSubImage2DCHROMIUM", "out of memory");
2727 return NULL; 2735 return NULL;
2728 } 2736 }
2729 2737
2730 std::pair<MappedTextureMap::iterator, bool> result = 2738 std::pair<MappedTextureMap::iterator, bool> result =
2731 mapped_textures_.insert(std::make_pair( 2739 mapped_textures_.insert(std::make_pair(
2732 mem, 2740 mem,
2733 MappedTexture( 2741 MappedTexture(
2734 access, shm_id, mem, shm_offset, 2742 access, shm_id, mem, shm_offset,
2735 target, level, xoffset, yoffset, width, height, format, type))); 2743 target, level, xoffset, yoffset, width, height, format, type)));
2736 GPU_DCHECK(result.second); 2744 GPU_DCHECK(result.second);
2737 GPU_CLIENT_LOG(" returned " << mem); 2745 GPU_CLIENT_LOG(" returned " << mem);
2738 return mem; 2746 return mem;
2739 } 2747 }
2740 2748
2741 void GLES2Implementation::UnmapTexSubImage2DCHROMIUM(const void* mem) { 2749 void GLES2Implementation::UnmapTexSubImage2DCHROMIUM(const void* mem) {
2742 GPU_CLIENT_SINGLE_THREAD_CHECK(); 2750 GPU_CLIENT_SINGLE_THREAD_CHECK();
2743 GPU_CLIENT_LOG( 2751 GPU_CLIENT_LOG(
2744 "[" << this << "] glUnmapTexSubImage2DCHROMIUM(" << mem << ")"); 2752 "[" << this << "] glUnmapTexSubImage2DCHROMIUM(" << mem << ")");
2745 MappedTextureMap::iterator it = mapped_textures_.find(mem); 2753 MappedTextureMap::iterator it = mapped_textures_.find(mem);
2746 if (it == mapped_textures_.end()) { 2754 if (it == mapped_textures_.end()) {
2747 SetGLError( 2755 SetGLError(
2748 GL_INVALID_VALUE, "UnmapTexSubImage2DCHROMIUM: texture not mapped"); 2756 GL_INVALID_VALUE, "UnmapTexSubImage2DCHROMIUM", "texture not mapped");
2749 return; 2757 return;
2750 } 2758 }
2751 const MappedTexture& mt = it->second; 2759 const MappedTexture& mt = it->second;
2752 helper_->TexSubImage2D( 2760 helper_->TexSubImage2D(
2753 mt.target, mt.level, mt.xoffset, mt.yoffset, mt.width, mt.height, 2761 mt.target, mt.level, mt.xoffset, mt.yoffset, mt.width, mt.height,
2754 mt.format, mt.type, mt.shm_id, mt.shm_offset, GL_FALSE); 2762 mt.format, mt.type, mt.shm_id, mt.shm_offset, GL_FALSE);
2755 mapped_memory_->FreePendingToken(mt.shm_memory, helper_->InsertToken()); 2763 mapped_memory_->FreePendingToken(mt.shm_memory, helper_->InsertToken());
2756 #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) 2764 #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS)
2757 helper_->CommandBufferHelper::Flush(); 2765 helper_->CommandBufferHelper::Flush();
2758 #endif 2766 #endif
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
2829 GPU_CLIENT_LOG_CODE_BLOCK({ 2837 GPU_CLIENT_LOG_CODE_BLOCK({
2830 for (GLuint i = 0; i < count; ++i) { 2838 for (GLuint i = 0; i < count; ++i) {
2831 GPU_CLIENT_LOG( 2839 GPU_CLIENT_LOG(
2832 " " << i << ": " << GLES2Util::GetStringGLState(pnames[i])); 2840 " " << i << ": " << GLES2Util::GetStringGLState(pnames[i]));
2833 } 2841 }
2834 }); 2842 });
2835 int num_results = 0; 2843 int num_results = 0;
2836 for (GLuint ii = 0; ii < count; ++ii) { 2844 for (GLuint ii = 0; ii < count; ++ii) {
2837 int num = util_.GLGetNumValuesReturned(pnames[ii]); 2845 int num = util_.GLGetNumValuesReturned(pnames[ii]);
2838 if (!num) { 2846 if (!num) {
2839 SetGLError(GL_INVALID_ENUM, "glGetMultipleIntegervCHROMIUM: bad pname"); 2847 SetGLError(GL_INVALID_ENUM, "glGetMultipleIntegervCHROMIUM", "bad pname");
2840 return; 2848 return;
2841 } 2849 }
2842 num_results += num; 2850 num_results += num;
2843 } 2851 }
2844 if (static_cast<size_t>(size) != num_results * sizeof(GLint)) { 2852 if (static_cast<size_t>(size) != num_results * sizeof(GLint)) {
2845 SetGLError(GL_INVALID_VALUE, "glGetMultipleIntegervCHROMIUM: bad size"); 2853 SetGLError(GL_INVALID_VALUE, "glGetMultipleIntegervCHROMIUM", "bad size");
2846 return; 2854 return;
2847 } 2855 }
2848 for (int ii = 0; ii < num_results; ++ii) { 2856 for (int ii = 0; ii < num_results; ++ii) {
2849 if (results[ii] != 0) { 2857 if (results[ii] != 0) {
2850 SetGLError(GL_INVALID_VALUE, 2858 SetGLError(GL_INVALID_VALUE,
2851 "glGetMultipleIntegervCHROMIUM: results not set to zero."); 2859 "glGetMultipleIntegervCHROMIUM", "results not set to zero.");
2852 return; 2860 return;
2853 } 2861 }
2854 } 2862 }
2855 uint32 size_needed = 2863 uint32 size_needed =
2856 count * sizeof(pnames[0]) + num_results * sizeof(results[0]); 2864 count * sizeof(pnames[0]) + num_results * sizeof(results[0]);
2857 void* buffer = transfer_buffer_->Alloc(size_needed); 2865 void* buffer = transfer_buffer_->Alloc(size_needed);
2858 if (!buffer) { 2866 if (!buffer) {
2859 return; 2867 return;
2860 } 2868 }
2861 GLenum* pnames_buffer = static_cast<GLenum*>(buffer); 2869 GLenum* pnames_buffer = static_cast<GLenum*>(buffer);
(...skipping 25 matching lines...) Expand all
2887 // Clear the bucket so if the command fails nothing will be in it. 2895 // Clear the bucket so if the command fails nothing will be in it.
2888 helper_->SetBucketSize(kResultBucketId, 0); 2896 helper_->SetBucketSize(kResultBucketId, 0);
2889 helper_->GetProgramInfoCHROMIUM(program, kResultBucketId); 2897 helper_->GetProgramInfoCHROMIUM(program, kResultBucketId);
2890 GetBucketContents(kResultBucketId, result); 2898 GetBucketContents(kResultBucketId, result);
2891 } 2899 }
2892 2900
2893 void GLES2Implementation::GetProgramInfoCHROMIUM( 2901 void GLES2Implementation::GetProgramInfoCHROMIUM(
2894 GLuint program, GLsizei bufsize, GLsizei* size, void* info) { 2902 GLuint program, GLsizei bufsize, GLsizei* size, void* info) {
2895 GPU_CLIENT_SINGLE_THREAD_CHECK(); 2903 GPU_CLIENT_SINGLE_THREAD_CHECK();
2896 if (bufsize < 0) { 2904 if (bufsize < 0) {
2897 SetGLError(GL_INVALID_VALUE, "glProgramInfoCHROMIUM: bufsize less than 0."); 2905 SetGLError(
2906 GL_INVALID_VALUE, "glProgramInfoCHROMIUM", "bufsize less than 0.");
2898 return; 2907 return;
2899 } 2908 }
2900 if (size == NULL) { 2909 if (size == NULL) {
2901 SetGLError(GL_INVALID_VALUE, "glProgramInfoCHROMIUM: size is null."); 2910 SetGLError(GL_INVALID_VALUE, "glProgramInfoCHROMIUM", "size is null.");
2902 return; 2911 return;
2903 } 2912 }
2904 // Make sure they've set size to 0 else the value will be undefined on 2913 // Make sure they've set size to 0 else the value will be undefined on
2905 // lost context. 2914 // lost context.
2906 GPU_DCHECK(*size == 0); 2915 GPU_DCHECK(*size == 0);
2907 std::vector<int8> result; 2916 std::vector<int8> result;
2908 GetProgramInfoCHROMIUMHelper(program, &result); 2917 GetProgramInfoCHROMIUMHelper(program, &result);
2909 if (result.empty()) { 2918 if (result.empty()) {
2910 return; 2919 return;
2911 } 2920 }
2912 *size = result.size(); 2921 *size = result.size();
2913 if (!info) { 2922 if (!info) {
2914 return; 2923 return;
2915 } 2924 }
2916 if (static_cast<size_t>(bufsize) < result.size()) { 2925 if (static_cast<size_t>(bufsize) < result.size()) {
2917 SetGLError(GL_INVALID_OPERATION, 2926 SetGLError(GL_INVALID_OPERATION,
2918 "glProgramInfoCHROMIUM: bufsize is too small for result."); 2927 "glProgramInfoCHROMIUM", "bufsize is too small for result.");
2919 return; 2928 return;
2920 } 2929 }
2921 memcpy(info, &result[0], result.size()); 2930 memcpy(info, &result[0], result.size());
2922 } 2931 }
2923 2932
2924 GLuint GLES2Implementation::CreateStreamTextureCHROMIUM(GLuint texture) { 2933 GLuint GLES2Implementation::CreateStreamTextureCHROMIUM(GLuint texture) {
2925 GPU_CLIENT_SINGLE_THREAD_CHECK(); 2934 GPU_CLIENT_SINGLE_THREAD_CHECK();
2926 GPU_CLIENT_LOG("[" << this << "] CreateStreamTextureCHROMIUM(" 2935 GPU_CLIENT_LOG("[" << this << "] CreateStreamTextureCHROMIUM("
2927 << texture << ")"); 2936 << texture << ")");
2928 TRACE_EVENT0("gpu", "GLES2::CreateStreamTextureCHROMIUM"); 2937 TRACE_EVENT0("gpu", "GLES2::CreateStreamTextureCHROMIUM");
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
2966 } 2975 }
2967 } 2976 }
2968 2977
2969 void GLES2Implementation::DeleteQueriesEXTHelper( 2978 void GLES2Implementation::DeleteQueriesEXTHelper(
2970 GLsizei n, const GLuint* queries) { 2979 GLsizei n, const GLuint* queries) {
2971 // TODO(gman): Remove this as queries are not shared resources. 2980 // TODO(gman): Remove this as queries are not shared resources.
2972 if (!GetIdHandler(id_namespaces::kQueries)->FreeIds( 2981 if (!GetIdHandler(id_namespaces::kQueries)->FreeIds(
2973 this, n, queries, &GLES2Implementation::DeleteQueriesStub)) { 2982 this, n, queries, &GLES2Implementation::DeleteQueriesStub)) {
2974 SetGLError( 2983 SetGLError(
2975 GL_INVALID_VALUE, 2984 GL_INVALID_VALUE,
2976 "glDeleteTextures: id not created by this context."); 2985 "glDeleteTextures", "id not created by this context.");
2977 return; 2986 return;
2978 } 2987 }
2979 // When you delete a query you can't mark its memory as unused until it's 2988 // When you delete a query you can't mark its memory as unused until it's
2980 // completed. 2989 // completed.
2981 // Note: If you don't do this you won't mess up the service but you will mess 2990 // Note: If you don't do this you won't mess up the service but you will mess
2982 // up yourself. 2991 // up yourself.
2983 2992
2984 // TODO(gman): Consider making this faster by putting pending quereies 2993 // TODO(gman): Consider making this faster by putting pending quereies
2985 // on some queue to be removed when they are finished. 2994 // on some queue to be removed when they are finished.
2986 bool query_pending = false; 2995 bool query_pending = false;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
3023 3032
3024 void GLES2Implementation::BeginQueryEXT(GLenum target, GLuint id) { 3033 void GLES2Implementation::BeginQueryEXT(GLenum target, GLuint id) {
3025 GPU_CLIENT_SINGLE_THREAD_CHECK(); 3034 GPU_CLIENT_SINGLE_THREAD_CHECK();
3026 GPU_CLIENT_LOG("[" << this << "] BeginQueryEXT(" 3035 GPU_CLIENT_LOG("[" << this << "] BeginQueryEXT("
3027 << GLES2Util::GetStringQueryTarget(target) 3036 << GLES2Util::GetStringQueryTarget(target)
3028 << ", " << id << ")"); 3037 << ", " << id << ")");
3029 3038
3030 // if any outstanding queries INV_OP 3039 // if any outstanding queries INV_OP
3031 if (current_query_) { 3040 if (current_query_) {
3032 SetGLError( 3041 SetGLError(
3033 GL_INVALID_OPERATION, "glBeginQueryEXT: query already in progress"); 3042 GL_INVALID_OPERATION, "glBeginQueryEXT", "query already in progress");
3034 return; 3043 return;
3035 } 3044 }
3036 3045
3037 // id = 0 INV_OP 3046 // id = 0 INV_OP
3038 if (id == 0) { 3047 if (id == 0) {
3039 SetGLError(GL_INVALID_OPERATION, "glBeginQueryEXT: id is 0"); 3048 SetGLError(GL_INVALID_OPERATION, "glBeginQueryEXT", "id is 0");
3040 return; 3049 return;
3041 } 3050 }
3042 3051
3043 // TODO(gman) if id not GENned INV_OPERATION 3052 // TODO(gman) if id not GENned INV_OPERATION
3044 3053
3045 // if id does not have an object 3054 // if id does not have an object
3046 QueryTracker::Query* query = query_tracker_->GetQuery(id); 3055 QueryTracker::Query* query = query_tracker_->GetQuery(id);
3047 if (!query) { 3056 if (!query) {
3048 query = query_tracker_->CreateQuery(id, target); 3057 query = query_tracker_->CreateQuery(id, target);
3049 } else if (query->target() != target) { 3058 } else if (query->target() != target) {
3050 SetGLError(GL_INVALID_OPERATION, "glBeginQueryEXT: target does not match"); 3059 SetGLError(
3060 GL_INVALID_OPERATION, "glBeginQueryEXT", "target does not match");
3051 return; 3061 return;
3052 } 3062 }
3053 3063
3054 current_query_ = query; 3064 current_query_ = query;
3055 3065
3056 // init memory, inc count 3066 // init memory, inc count
3057 query->MarkAsActive(); 3067 query->MarkAsActive();
3058 3068
3059 // tell service about id, shared memory and count 3069 // tell service about id, shared memory and count
3060 helper_->BeginQueryEXT(target, id, query->shm_id(), query->shm_offset()); 3070 helper_->BeginQueryEXT(target, id, query->shm_id(), query->shm_offset());
3061 } 3071 }
3062 3072
3063 void GLES2Implementation::EndQueryEXT(GLenum target) { 3073 void GLES2Implementation::EndQueryEXT(GLenum target) {
3064 GPU_CLIENT_SINGLE_THREAD_CHECK(); 3074 GPU_CLIENT_SINGLE_THREAD_CHECK();
3065 GPU_CLIENT_LOG("[" << this << "] EndQueryEXT(" 3075 GPU_CLIENT_LOG("[" << this << "] EndQueryEXT("
3066 << GLES2Util::GetStringQueryTarget(target) << ")"); 3076 << GLES2Util::GetStringQueryTarget(target) << ")");
3067 3077
3068 if (!current_query_) { 3078 if (!current_query_) {
3069 SetGLError(GL_INVALID_OPERATION, "glEndQueryEXT: no active query"); 3079 SetGLError(GL_INVALID_OPERATION, "glEndQueryEXT", "no active query");
3070 return; 3080 return;
3071 } 3081 }
3072 3082
3073 if (current_query_->target() != target) { 3083 if (current_query_->target() != target) {
3074 SetGLError(GL_INVALID_OPERATION, 3084 SetGLError(GL_INVALID_OPERATION,
3075 "glEndQueryEXT: target does not match active query"); 3085 "glEndQueryEXT", "target does not match active query");
3076 return; 3086 return;
3077 } 3087 }
3078 3088
3079 helper_->EndQueryEXT(target, current_query_->submit_count()); 3089 helper_->EndQueryEXT(target, current_query_->submit_count());
3080 current_query_->MarkAsPending(helper_->InsertToken()); 3090 current_query_->MarkAsPending(helper_->InsertToken());
3081 current_query_ = NULL; 3091 current_query_ = NULL;
3082 } 3092 }
3083 3093
3084 void GLES2Implementation::GetQueryivEXT( 3094 void GLES2Implementation::GetQueryivEXT(
3085 GLenum target, GLenum pname, GLint* params) { 3095 GLenum target, GLenum pname, GLint* params) {
3086 GPU_CLIENT_SINGLE_THREAD_CHECK(); 3096 GPU_CLIENT_SINGLE_THREAD_CHECK();
3087 GPU_CLIENT_LOG("[" << this << "] GetQueryivEXT(" 3097 GPU_CLIENT_LOG("[" << this << "] GetQueryivEXT("
3088 << GLES2Util::GetStringQueryTarget(target) << ", " 3098 << GLES2Util::GetStringQueryTarget(target) << ", "
3089 << GLES2Util::GetStringQueryParameter(pname) << ", " 3099 << GLES2Util::GetStringQueryParameter(pname) << ", "
3090 << static_cast<const void*>(params) << ")"); 3100 << static_cast<const void*>(params) << ")");
3091 3101
3092 if (pname != GL_CURRENT_QUERY_EXT) { 3102 if (pname != GL_CURRENT_QUERY_EXT) {
3093 SetGLError(GL_INVALID_ENUM, "glGetQueryivEXT: invalid pname"); 3103 SetGLError(GL_INVALID_ENUM, "glGetQueryivEXT", "invalid pname");
3094 return; 3104 return;
3095 } 3105 }
3096 *params = (current_query_ && current_query_->target() == target) ? 3106 *params = (current_query_ && current_query_->target() == target) ?
3097 current_query_->id() : 0; 3107 current_query_->id() : 0;
3098 GPU_CLIENT_LOG(" " << *params); 3108 GPU_CLIENT_LOG(" " << *params);
3099 } 3109 }
3100 3110
3101 void GLES2Implementation::GetQueryObjectuivEXT( 3111 void GLES2Implementation::GetQueryObjectuivEXT(
3102 GLuint id, GLenum pname, GLuint* params) { 3112 GLuint id, GLenum pname, GLuint* params) {
3103 GPU_CLIENT_SINGLE_THREAD_CHECK(); 3113 GPU_CLIENT_SINGLE_THREAD_CHECK();
3104 GPU_CLIENT_LOG("[" << this << "] GetQueryivEXT(" << id << ", " 3114 GPU_CLIENT_LOG("[" << this << "] GetQueryivEXT(" << id << ", "
3105 << GLES2Util::GetStringQueryObjectParameter(pname) << ", " 3115 << GLES2Util::GetStringQueryObjectParameter(pname) << ", "
3106 << static_cast<const void*>(params) << ")"); 3116 << static_cast<const void*>(params) << ")");
3107 3117
3108 QueryTracker::Query* query = query_tracker_->GetQuery(id); 3118 QueryTracker::Query* query = query_tracker_->GetQuery(id);
3109 if (!query) { 3119 if (!query) {
3110 SetGLError(GL_INVALID_OPERATION, "glQueryObjectuivEXT: unknown query id"); 3120 SetGLError(GL_INVALID_OPERATION, "glQueryObjectuivEXT", "unknown query id");
3111 return; 3121 return;
3112 } 3122 }
3113 3123
3114 if (query == current_query_) { 3124 if (query == current_query_) {
3115 SetGLError( 3125 SetGLError(
3116 GL_INVALID_OPERATION, 3126 GL_INVALID_OPERATION,
3117 "glQueryObjectuivEXT: query active. Did you to call glEndQueryEXT?"); 3127 "glQueryObjectuivEXT", "query active. Did you to call glEndQueryEXT?");
3118 return; 3128 return;
3119 } 3129 }
3120 3130
3121 if (query->NeverUsed()) { 3131 if (query->NeverUsed()) {
3122 SetGLError( 3132 SetGLError(
3123 GL_INVALID_OPERATION, 3133 GL_INVALID_OPERATION,
3124 "glQueryObjectuivEXT: Never used. Did you call glBeginQueryEXT?"); 3134 "glQueryObjectuivEXT", "Never used. Did you call glBeginQueryEXT?");
3125 return; 3135 return;
3126 } 3136 }
3127 3137
3128 switch (pname) { 3138 switch (pname) {
3129 case GL_QUERY_RESULT_EXT: 3139 case GL_QUERY_RESULT_EXT:
3130 if (!query->CheckResultsAvailable(helper_)) { 3140 if (!query->CheckResultsAvailable(helper_)) {
3131 helper_->WaitForToken(query->token()); 3141 helper_->WaitForToken(query->token());
3132 if (!query->CheckResultsAvailable(helper_)) { 3142 if (!query->CheckResultsAvailable(helper_)) {
3133 // TODO(gman): Speed this up. 3143 // TODO(gman): Speed this up.
3134 Finish(); 3144 Finish();
3135 GPU_CHECK(query->CheckResultsAvailable(helper_)); 3145 GPU_CHECK(query->CheckResultsAvailable(helper_));
3136 } 3146 }
3137 } 3147 }
3138 *params = query->GetResult(); 3148 *params = query->GetResult();
3139 break; 3149 break;
3140 case GL_QUERY_RESULT_AVAILABLE_EXT: 3150 case GL_QUERY_RESULT_AVAILABLE_EXT:
3141 *params = query->CheckResultsAvailable(helper_); 3151 *params = query->CheckResultsAvailable(helper_);
3142 break; 3152 break;
3143 default: 3153 default:
3144 SetGLError(GL_INVALID_ENUM, "glQueryObjectuivEXT: unknown pname"); 3154 SetGLError(GL_INVALID_ENUM, "glQueryObjectuivEXT", "unknown pname");
3145 break; 3155 break;
3146 } 3156 }
3147 GPU_CLIENT_LOG(" " << *params); 3157 GPU_CLIENT_LOG(" " << *params);
3148 } 3158 }
3149 3159
3150 void GLES2Implementation::DrawArraysInstancedANGLE( 3160 void GLES2Implementation::DrawArraysInstancedANGLE(
3151 GLenum mode, GLint first, GLsizei count, GLsizei primcount) { 3161 GLenum mode, GLint first, GLsizei count, GLsizei primcount) {
3152 GPU_CLIENT_SINGLE_THREAD_CHECK(); 3162 GPU_CLIENT_SINGLE_THREAD_CHECK();
3153 GPU_CLIENT_LOG("[" << this << "] glDrawArraysInstancedANGLE(" 3163 GPU_CLIENT_LOG("[" << this << "] glDrawArraysInstancedANGLE("
3154 << GLES2Util::GetStringDrawMode(mode) << ", " 3164 << GLES2Util::GetStringDrawMode(mode) << ", "
3155 << first << ", " << count << ", " << primcount << ")"); 3165 << first << ", " << count << ", " << primcount << ")");
3156 if (count < 0) { 3166 if (count < 0) {
3157 SetGLError(GL_INVALID_VALUE, "glDrawArraysInstancedANGLE: count < 0"); 3167 SetGLError(GL_INVALID_VALUE, "glDrawArraysInstancedANGLE", "count < 0");
3158 return; 3168 return;
3159 } 3169 }
3160 if (primcount < 0) { 3170 if (primcount < 0) {
3161 SetGLError(GL_INVALID_VALUE, "glDrawArraysInstancedANGLE: primcount < 0"); 3171 SetGLError(GL_INVALID_VALUE, "glDrawArraysInstancedANGLE", "primcount < 0");
3162 return; 3172 return;
3163 } 3173 }
3164 if (primcount == 0) { 3174 if (primcount == 0) {
3165 return; 3175 return;
3166 } 3176 }
3167 #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) 3177 #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS)
3168 bool have_client_side = 3178 bool have_client_side =
3169 client_side_buffer_helper_->HaveEnabledClientSideBuffers(); 3179 client_side_buffer_helper_->HaveEnabledClientSideBuffers();
3170 if (have_client_side) { 3180 if (have_client_side) {
3171 client_side_buffer_helper_->SetupSimulatedClientSideBuffers( 3181 client_side_buffer_helper_->SetupSimulatedClientSideBuffers(
(...skipping 14 matching lines...) Expand all
3186 GLsizei primcount) { 3196 GLsizei primcount) {
3187 GPU_CLIENT_SINGLE_THREAD_CHECK(); 3197 GPU_CLIENT_SINGLE_THREAD_CHECK();
3188 GPU_CLIENT_LOG("[" << this << "] glDrawElementsInstancedANGLE(" 3198 GPU_CLIENT_LOG("[" << this << "] glDrawElementsInstancedANGLE("
3189 << GLES2Util::GetStringDrawMode(mode) << ", " 3199 << GLES2Util::GetStringDrawMode(mode) << ", "
3190 << count << ", " 3200 << count << ", "
3191 << GLES2Util::GetStringIndexType(type) << ", " 3201 << GLES2Util::GetStringIndexType(type) << ", "
3192 << static_cast<const void*>(indices) << ", " 3202 << static_cast<const void*>(indices) << ", "
3193 << primcount << ")"); 3203 << primcount << ")");
3194 if (count < 0) { 3204 if (count < 0) {
3195 SetGLError(GL_INVALID_VALUE, 3205 SetGLError(GL_INVALID_VALUE,
3196 "glDrawElementsInstancedANGLE: count less than 0."); 3206 "glDrawElementsInstancedANGLE", "count less than 0.");
3197 return; 3207 return;
3198 } 3208 }
3199 if (count == 0) { 3209 if (count == 0) {
3200 return; 3210 return;
3201 } 3211 }
3202 if (primcount < 0) { 3212 if (primcount < 0) {
3203 SetGLError(GL_INVALID_VALUE, 3213 SetGLError(GL_INVALID_VALUE,
3204 "glDrawElementsInstancedANGLE: primcount < 0"); 3214 "glDrawElementsInstancedANGLE", "primcount < 0");
3205 return; 3215 return;
3206 } 3216 }
3207 if (primcount == 0) { 3217 if (primcount == 0) {
3208 return; 3218 return;
3209 } 3219 }
3210 #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS) 3220 #if defined(GLES2_SUPPORT_CLIENT_SIDE_ARRAYS)
3211 bool have_client_side = 3221 bool have_client_side =
3212 client_side_buffer_helper_->HaveEnabledClientSideBuffers(); 3222 client_side_buffer_helper_->HaveEnabledClientSideBuffers();
3213 GLsizei num_elements = 0; 3223 GLsizei num_elements = 0;
3214 GLuint offset = ToGLuint(indices); 3224 GLuint offset = ToGLuint(indices);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
3257 helper_->GenMailboxCHROMIUM(kResultBucketId); 3267 helper_->GenMailboxCHROMIUM(kResultBucketId);
3258 3268
3259 std::vector<GLbyte> result; 3269 std::vector<GLbyte> result;
3260 GetBucketContents(kResultBucketId, &result); 3270 GetBucketContents(kResultBucketId, &result);
3261 3271
3262 std::copy(result.begin(), result.end(), mailbox); 3272 std::copy(result.begin(), result.end(), mailbox);
3263 } 3273 }
3264 3274
3265 } // namespace gles2 3275 } // namespace gles2
3266 } // namespace gpu 3276 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/gles2_implementation.h ('k') | gpu/command_buffer/client/gles2_implementation_autogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698