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

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder_passthrough_doers.cc

Issue 2770713005: Implement most of the remaining entry points in the passthrough cmd decoder. (Closed)
Patch Set: Always check the length parameter. Created 3 years, 9 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
OLDNEW
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "gpu/command_buffer/service/gles2_cmd_decoder_passthrough.h" 5 #include "gpu/command_buffer/service/gles2_cmd_decoder_passthrough.h"
6 6
7 #include "base/strings/string_number_conversions.h" 7 #include "base/strings/string_number_conversions.h"
8 #include "ui/gl/gl_version_info.h" 8 #include "ui/gl/gl_version_info.h"
9 9
10 namespace gpu { 10 namespace gpu {
(...skipping 997 matching lines...) Expand 10 before | Expand all | Expand 10 after
1008 GLint* params) { 1008 GLint* params) {
1009 glGetActiveUniformBlockivRobustANGLE(GetProgramServiceID(program, resources_), 1009 glGetActiveUniformBlockivRobustANGLE(GetProgramServiceID(program, resources_),
1010 index, pname, bufSize, length, params); 1010 index, pname, bufSize, length, params);
1011 return error::kNoError; 1011 return error::kNoError;
1012 } 1012 }
1013 1013
1014 error::Error GLES2DecoderPassthroughImpl::DoGetActiveUniformBlockName( 1014 error::Error GLES2DecoderPassthroughImpl::DoGetActiveUniformBlockName(
1015 GLuint program, 1015 GLuint program,
1016 GLuint index, 1016 GLuint index,
1017 std::string* name) { 1017 std::string* name) {
1018 NOTIMPLEMENTED(); 1018 FlushErrors();
1019
1020 GLuint program_service_id = GetProgramServiceID(program, resources_);
1021 GLint max_name_length = 0;
1022 glGetProgramiv(program_service_id, GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH,
1023 &max_name_length);
1024
1025 if (FlushErrors()) {
1026 return error::kNoError;
1027 }
1028
1029 std::vector<GLchar> buffer(max_name_length, 0);
1030 GLsizei length = 0;
1031 glGetActiveUniformBlockName(program_service_id, index, max_name_length,
1032 &length, buffer.data());
1033 DCHECK(length <= max_name_length);
1034 *name = length > 0 ? std::string(buffer.data(), length) : std::string();
1035
1019 return error::kNoError; 1036 return error::kNoError;
1020 } 1037 }
1021 1038
1022 error::Error GLES2DecoderPassthroughImpl::DoGetActiveUniformsiv( 1039 error::Error GLES2DecoderPassthroughImpl::DoGetActiveUniformsiv(
1023 GLuint program, 1040 GLuint program,
1024 GLsizei count, 1041 GLsizei count,
1025 const GLuint* indices, 1042 const GLuint* indices,
1026 GLenum pname, 1043 GLenum pname,
1027 GLsizei bufSize,
1028 GLsizei* length,
1029 GLint* params) { 1044 GLint* params) {
1030 NOTIMPLEMENTED(); 1045 glGetActiveUniformsiv(GetProgramServiceID(program, resources_), count,
1046 indices, pname, params);
1031 return error::kNoError; 1047 return error::kNoError;
1032 } 1048 }
1033 1049
1034 error::Error GLES2DecoderPassthroughImpl::DoGetAttachedShaders( 1050 error::Error GLES2DecoderPassthroughImpl::DoGetAttachedShaders(
1035 GLuint program, 1051 GLuint program,
1036 GLsizei maxcount, 1052 GLsizei maxcount,
1037 GLsizei* count, 1053 GLsizei* count,
1038 GLuint* shaders) { 1054 GLuint* shaders) {
1039 NOTIMPLEMENTED(); 1055 glGetAttachedShaders(GetProgramServiceID(program, resources_), maxcount,
1056 count, shaders);
1040 return error::kNoError; 1057 return error::kNoError;
1041 } 1058 }
1042 1059
1043 error::Error GLES2DecoderPassthroughImpl::DoGetAttribLocation(GLuint program, 1060 error::Error GLES2DecoderPassthroughImpl::DoGetAttribLocation(GLuint program,
1044 const char* name, 1061 const char* name,
1045 GLint* result) { 1062 GLint* result) {
1046 *result = glGetAttribLocation(GetProgramServiceID(program, resources_), name); 1063 *result = glGetAttribLocation(GetProgramServiceID(program, resources_), name);
1047 return error::kNoError; 1064 return error::kNoError;
1048 } 1065 }
1049 1066
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
1207 GLsizei* length, 1224 GLsizei* length,
1208 GLint* params) { 1225 GLint* params) {
1209 glGetProgramivRobustANGLE(GetProgramServiceID(program, resources_), pname, 1226 glGetProgramivRobustANGLE(GetProgramServiceID(program, resources_), pname,
1210 bufsize, length, params); 1227 bufsize, length, params);
1211 return error::kNoError; 1228 return error::kNoError;
1212 } 1229 }
1213 1230
1214 error::Error GLES2DecoderPassthroughImpl::DoGetProgramInfoLog( 1231 error::Error GLES2DecoderPassthroughImpl::DoGetProgramInfoLog(
1215 GLuint program, 1232 GLuint program,
1216 std::string* infolog) { 1233 std::string* infolog) {
1234 FlushErrors();
1217 GLint info_log_len = 0; 1235 GLint info_log_len = 0;
1218 glGetProgramiv(GetProgramServiceID(program, resources_), GL_INFO_LOG_LENGTH, 1236 glGetProgramiv(GetProgramServiceID(program, resources_), GL_INFO_LOG_LENGTH,
1219 &info_log_len); 1237 &info_log_len);
1220 1238
1239 if (FlushErrors()) {
1240 return error::kNoError;
1241 }
1242
1221 std::vector<char> buffer(info_log_len, 0); 1243 std::vector<char> buffer(info_log_len, 0);
1244 GLsizei length = 0;
1222 glGetProgramInfoLog(GetProgramServiceID(program, resources_), info_log_len, 1245 glGetProgramInfoLog(GetProgramServiceID(program, resources_), info_log_len,
1223 nullptr, buffer.data()); 1246 &length, buffer.data());
1224 *infolog = info_log_len > 0 ? std::string(buffer.data()) : std::string(); 1247 DCHECK(length <= info_log_len);
1248 *infolog = length > 0 ? std::string(buffer.data(), length) : std::string();
1225 return error::kNoError; 1249 return error::kNoError;
1226 } 1250 }
1227 1251
1228 error::Error GLES2DecoderPassthroughImpl::DoGetRenderbufferParameteriv( 1252 error::Error GLES2DecoderPassthroughImpl::DoGetRenderbufferParameteriv(
1229 GLenum target, 1253 GLenum target,
1230 GLenum pname, 1254 GLenum pname,
1231 GLsizei bufsize, 1255 GLsizei bufsize,
1232 GLsizei* length, 1256 GLsizei* length,
1233 GLint* params) { 1257 GLint* params) {
1234 glGetRenderbufferParameterivRobustANGLE(target, pname, bufsize, length, 1258 glGetRenderbufferParameterivRobustANGLE(target, pname, bufsize, length,
(...skipping 28 matching lines...) Expand all
1263 GLsizei* length, 1287 GLsizei* length,
1264 GLint* params) { 1288 GLint* params) {
1265 glGetShaderivRobustANGLE(GetShaderServiceID(shader, resources_), pname, 1289 glGetShaderivRobustANGLE(GetShaderServiceID(shader, resources_), pname,
1266 bufsize, length, params); 1290 bufsize, length, params);
1267 return error::kNoError; 1291 return error::kNoError;
1268 } 1292 }
1269 1293
1270 error::Error GLES2DecoderPassthroughImpl::DoGetShaderInfoLog( 1294 error::Error GLES2DecoderPassthroughImpl::DoGetShaderInfoLog(
1271 GLuint shader, 1295 GLuint shader,
1272 std::string* infolog) { 1296 std::string* infolog) {
1297 FlushErrors();
1298
1273 GLuint service_id = GetShaderServiceID(shader, resources_); 1299 GLuint service_id = GetShaderServiceID(shader, resources_);
1274 GLint info_log_len = 0; 1300 GLint info_log_len = 0;
1275 glGetShaderiv(service_id, GL_INFO_LOG_LENGTH, &info_log_len); 1301 glGetShaderiv(service_id, GL_INFO_LOG_LENGTH, &info_log_len);
1302 if (FlushErrors()) {
1303 return error::kNoError;
1304 }
1305
1276 std::vector<char> buffer(info_log_len, 0); 1306 std::vector<char> buffer(info_log_len, 0);
1277 glGetShaderInfoLog(service_id, info_log_len, nullptr, buffer.data()); 1307 GLsizei length = 0;
1278 *infolog = info_log_len > 0 ? std::string(buffer.data()) : std::string(); 1308 glGetShaderInfoLog(service_id, info_log_len, &length, buffer.data());
1309 DCHECK(length <= info_log_len);
1310 *infolog = length > 0 ? std::string(buffer.data(), length) : std::string();
1279 return error::kNoError; 1311 return error::kNoError;
1280 } 1312 }
1281 1313
1282 error::Error GLES2DecoderPassthroughImpl::DoGetShaderPrecisionFormat( 1314 error::Error GLES2DecoderPassthroughImpl::DoGetShaderPrecisionFormat(
1283 GLenum shadertype, 1315 GLenum shadertype,
1284 GLenum precisiontype, 1316 GLenum precisiontype,
1285 GLint* range, 1317 GLint* range,
1286 GLint* precision, 1318 GLint* precision,
1287 int32_t* success) { 1319 int32_t* success) {
1288 FlushErrors(); 1320 FlushErrors();
1289 glGetShaderPrecisionFormat(shadertype, precisiontype, range, precision); 1321 glGetShaderPrecisionFormat(shadertype, precisiontype, range, precision);
1290 *success = FlushErrors() ? 0 : 1; 1322 *success = FlushErrors() ? 0 : 1;
1291 return error::kNoError; 1323 return error::kNoError;
1292 } 1324 }
1293 1325
1294 error::Error GLES2DecoderPassthroughImpl::DoGetShaderSource( 1326 error::Error GLES2DecoderPassthroughImpl::DoGetShaderSource(
1295 GLuint shader, 1327 GLuint shader,
1296 std::string* source) { 1328 std::string* source) {
1297 NOTIMPLEMENTED(); 1329 FlushErrors();
1330
1331 GLuint shader_service_id = GetShaderServiceID(shader, resources_);
1332 GLint shader_source_length = 0;
1333 glGetShaderiv(shader_service_id, GL_SHADER_SOURCE_LENGTH,
1334 &shader_source_length);
1335 if (FlushErrors()) {
1336 return error::kNoError;
1337 }
1338
1339 std::vector<char> buffer(shader_source_length, 0);
1340 GLsizei length = 0;
1341 glGetShaderSource(shader_service_id, shader_source_length, &length,
1342 buffer.data());
1343 DCHECK(length <= shader_source_length);
1344 *source = shader_source_length > 0 ? std::string(buffer.data(), length)
1345 : std::string();
1298 return error::kNoError; 1346 return error::kNoError;
1299 } 1347 }
1300 1348
1301 error::Error GLES2DecoderPassthroughImpl::DoGetString(GLenum name, 1349 error::Error GLES2DecoderPassthroughImpl::DoGetString(GLenum name,
1302 const char** result) { 1350 const char** result) {
1303 switch (name) { 1351 switch (name) {
1304 case GL_VERSION: 1352 case GL_VERSION:
1305 *result = GetServiceVersionString(feature_info_.get()); 1353 *result = GetServiceVersionString(feature_info_.get());
1306 break; 1354 break;
1307 case GL_SHADING_LANGUAGE_VERSION: 1355 case GL_SHADING_LANGUAGE_VERSION:
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1369 size, type, name_buffer.data()); 1417 size, type, name_buffer.data());
1370 *name = std::string(name_buffer.data()); 1418 *name = std::string(name_buffer.data());
1371 *success = FlushErrors() ? 0 : 1; 1419 *success = FlushErrors() ? 0 : 1;
1372 return error::kNoError; 1420 return error::kNoError;
1373 } 1421 }
1374 1422
1375 error::Error GLES2DecoderPassthroughImpl::DoGetUniformBlockIndex( 1423 error::Error GLES2DecoderPassthroughImpl::DoGetUniformBlockIndex(
1376 GLuint program, 1424 GLuint program,
1377 const char* name, 1425 const char* name,
1378 GLint* index) { 1426 GLint* index) {
1379 NOTIMPLEMENTED(); 1427 *index =
1428 glGetUniformBlockIndex(GetProgramServiceID(program, resources_), name);
1380 return error::kNoError; 1429 return error::kNoError;
1381 } 1430 }
1382 1431
1383 error::Error GLES2DecoderPassthroughImpl::DoGetUniformfv(GLuint program, 1432 error::Error GLES2DecoderPassthroughImpl::DoGetUniformfv(GLuint program,
1384 GLint location, 1433 GLint location,
1385 GLsizei bufsize, 1434 GLsizei bufsize,
1386 GLsizei* length, 1435 GLsizei* length,
1387 GLfloat* params) { 1436 GLfloat* params) {
1388 // GetUniform*RobustANGLE entry points expect bufsize in bytes like the entry 1437 // GetUniform*RobustANGLE entry points expect bufsize in bytes like the entry
1389 // points in GL_EXT_robustness 1438 // points in GL_EXT_robustness
(...skipping 24 matching lines...) Expand all
1414 glGetUniformuivRobustANGLE(GetProgramServiceID(program, resources_), location, 1463 glGetUniformuivRobustANGLE(GetProgramServiceID(program, resources_), location,
1415 bufsize * sizeof(*params), length, params); 1464 bufsize * sizeof(*params), length, params);
1416 return error::kNoError; 1465 return error::kNoError;
1417 } 1466 }
1418 1467
1419 error::Error GLES2DecoderPassthroughImpl::DoGetUniformIndices( 1468 error::Error GLES2DecoderPassthroughImpl::DoGetUniformIndices(
1420 GLuint program, 1469 GLuint program,
1421 GLsizei count, 1470 GLsizei count,
1422 const char* const* names, 1471 const char* const* names,
1423 GLsizei bufSize, 1472 GLsizei bufSize,
1424 GLsizei* length,
1425 GLuint* indices) { 1473 GLuint* indices) {
1426 NOTIMPLEMENTED(); 1474 glGetUniformIndices(GetProgramServiceID(program, resources_), count, names,
1475 indices);
1427 return error::kNoError; 1476 return error::kNoError;
1428 } 1477 }
1429 1478
1430 error::Error GLES2DecoderPassthroughImpl::DoGetUniformLocation( 1479 error::Error GLES2DecoderPassthroughImpl::DoGetUniformLocation(
1431 GLuint program, 1480 GLuint program,
1432 const char* name, 1481 const char* name,
1433 GLint* location) { 1482 GLint* location) {
1434 *location = 1483 *location =
1435 glGetUniformLocation(GetProgramServiceID(program, resources_), name); 1484 glGetUniformLocation(GetProgramServiceID(program, resources_), name);
1436 return error::kNoError; 1485 return error::kNoError;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
1528 return error::kNoError; 1577 return error::kNoError;
1529 } 1578 }
1530 std::vector<GLenum> attachments_copy(attachments, attachments + count); 1579 std::vector<GLenum> attachments_copy(attachments, attachments + count);
1531 glInvalidateSubFramebuffer(target, count, attachments_copy.data(), x, y, 1580 glInvalidateSubFramebuffer(target, count, attachments_copy.data(), x, y,
1532 width, height); 1581 width, height);
1533 return error::kNoError; 1582 return error::kNoError;
1534 } 1583 }
1535 1584
1536 error::Error GLES2DecoderPassthroughImpl::DoIsBuffer(GLuint buffer, 1585 error::Error GLES2DecoderPassthroughImpl::DoIsBuffer(GLuint buffer,
1537 uint32_t* result) { 1586 uint32_t* result) {
1538 NOTIMPLEMENTED();
1539 *result = glIsBuffer(GetBufferServiceID(buffer, resources_, false)); 1587 *result = glIsBuffer(GetBufferServiceID(buffer, resources_, false));
1540 return error::kNoError; 1588 return error::kNoError;
1541 } 1589 }
1542 1590
1543 error::Error GLES2DecoderPassthroughImpl::DoIsEnabled(GLenum cap, 1591 error::Error GLES2DecoderPassthroughImpl::DoIsEnabled(GLenum cap,
1544 uint32_t* result) { 1592 uint32_t* result) {
1545 *result = glIsEnabled(cap); 1593 *result = glIsEnabled(cap);
1546 return error::kNoError; 1594 return error::kNoError;
1547 } 1595 }
1548 1596
1549 error::Error GLES2DecoderPassthroughImpl::DoIsFramebuffer(GLuint framebuffer, 1597 error::Error GLES2DecoderPassthroughImpl::DoIsFramebuffer(GLuint framebuffer,
1550 uint32_t* result) { 1598 uint32_t* result) {
1551 *result = glIsFramebufferEXT( 1599 *result = glIsFramebufferEXT(
1552 GetFramebufferServiceID(framebuffer, &framebuffer_id_map_, false)); 1600 GetFramebufferServiceID(framebuffer, &framebuffer_id_map_, false));
1553 return error::kNoError; 1601 return error::kNoError;
1554 } 1602 }
1555 1603
1556 error::Error GLES2DecoderPassthroughImpl::DoIsProgram(GLuint program, 1604 error::Error GLES2DecoderPassthroughImpl::DoIsProgram(GLuint program,
1557 uint32_t* result) { 1605 uint32_t* result) {
1558 *result = glIsProgram(GetProgramServiceID(program, resources_)); 1606 *result = glIsProgram(GetProgramServiceID(program, resources_));
1559 return error::kNoError; 1607 return error::kNoError;
1560 } 1608 }
1561 1609
1562 error::Error GLES2DecoderPassthroughImpl::DoIsRenderbuffer(GLuint renderbuffer, 1610 error::Error GLES2DecoderPassthroughImpl::DoIsRenderbuffer(GLuint renderbuffer,
1563 uint32_t* result) { 1611 uint32_t* result) {
1564 NOTIMPLEMENTED();
1565 *result = glIsRenderbufferEXT( 1612 *result = glIsRenderbufferEXT(
1566 GetRenderbufferServiceID(renderbuffer, resources_, false)); 1613 GetRenderbufferServiceID(renderbuffer, resources_, false));
1567 return error::kNoError; 1614 return error::kNoError;
1568 } 1615 }
1569 1616
1570 error::Error GLES2DecoderPassthroughImpl::DoIsSampler(GLuint sampler, 1617 error::Error GLES2DecoderPassthroughImpl::DoIsSampler(GLuint sampler,
1571 uint32_t* result) { 1618 uint32_t* result) {
1572 *result = glIsSampler(GetSamplerServiceID(sampler, resources_)); 1619 *result = glIsSampler(GetSamplerServiceID(sampler, resources_));
1573 return error::kNoError; 1620 return error::kNoError;
1574 } 1621 }
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
1715 GLsizei height) { 1762 GLsizei height) {
1716 glScissor(x, y, width, height); 1763 glScissor(x, y, width, height);
1717 return error::kNoError; 1764 return error::kNoError;
1718 } 1765 }
1719 1766
1720 error::Error GLES2DecoderPassthroughImpl::DoShaderBinary(GLsizei n, 1767 error::Error GLES2DecoderPassthroughImpl::DoShaderBinary(GLsizei n,
1721 const GLuint* shaders, 1768 const GLuint* shaders,
1722 GLenum binaryformat, 1769 GLenum binaryformat,
1723 const void* binary, 1770 const void* binary,
1724 GLsizei length) { 1771 GLsizei length) {
1725 NOTIMPLEMENTED(); 1772 std::vector<GLuint> service_shaders(n, 0);
1773 for (GLsizei i = 0; i < n; i++) {
1774 service_shaders[i] = GetShaderServiceID(shaders[i], resources_);
1775 }
1776 glShaderBinary(n, service_shaders.data(), binaryformat, binary, length);
1726 return error::kNoError; 1777 return error::kNoError;
1727 } 1778 }
1728 1779
1729 error::Error GLES2DecoderPassthroughImpl::DoShaderSource(GLuint shader, 1780 error::Error GLES2DecoderPassthroughImpl::DoShaderSource(GLuint shader,
1730 GLsizei count, 1781 GLsizei count,
1731 const char** string, 1782 const char** string,
1732 const GLint* length) { 1783 const GLint* length) {
1733 glShaderSource(GetShaderServiceID(shader, resources_), count, string, length); 1784 glShaderSource(GetShaderServiceID(shader, resources_), count, string, length);
1734 return error::kNoError; 1785 return error::kNoError;
1735 } 1786 }
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
2373 return error::kNoError; 2424 return error::kNoError;
2374 } 2425 }
2375 2426
2376 error::Error GLES2DecoderPassthroughImpl::DoFramebufferTexture2DMultisampleEXT( 2427 error::Error GLES2DecoderPassthroughImpl::DoFramebufferTexture2DMultisampleEXT(
2377 GLenum target, 2428 GLenum target,
2378 GLenum attachment, 2429 GLenum attachment,
2379 GLenum textarget, 2430 GLenum textarget,
2380 GLuint texture, 2431 GLuint texture,
2381 GLint level, 2432 GLint level,
2382 GLsizei samples) { 2433 GLsizei samples) {
2383 NOTIMPLEMENTED(); 2434 glFramebufferTexture2DMultisampleEXT(
2435 target, attachment, textarget,
2436 GetTextureServiceID(texture, resources_, false), level, samples);
2384 return error::kNoError; 2437 return error::kNoError;
2385 } 2438 }
2386 2439
2387 error::Error GLES2DecoderPassthroughImpl::DoTexStorage2DEXT( 2440 error::Error GLES2DecoderPassthroughImpl::DoTexStorage2DEXT(
2388 GLenum target, 2441 GLenum target,
2389 GLsizei levels, 2442 GLsizei levels,
2390 GLenum internalFormat, 2443 GLenum internalFormat,
2391 GLsizei width, 2444 GLsizei width,
2392 GLsizei height) { 2445 GLsizei height) {
2393 glTexStorage2DEXT(target, levels, internalFormat, width, height); 2446 glTexStorage2DEXT(target, levels, internalFormat, width, height);
(...skipping 1514 matching lines...) Expand 10 before | Expand all | Expand 10 after
3908 } 3961 }
3909 3962
3910 error::Error GLES2DecoderPassthroughImpl::DoSetEnableDCLayersCHROMIUM( 3963 error::Error GLES2DecoderPassthroughImpl::DoSetEnableDCLayersCHROMIUM(
3911 GLboolean enable) { 3964 GLboolean enable) {
3912 NOTIMPLEMENTED(); 3965 NOTIMPLEMENTED();
3913 return error::kNoError; 3966 return error::kNoError;
3914 } 3967 }
3915 3968
3916 } // namespace gles2 3969 } // namespace gles2
3917 } // namespace gpu 3970 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698