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

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

Issue 863253002: Update from https://crrev.com/312600 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 11 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) 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 "gpu/command_buffer/client/gles2_implementation.h" 7 #include "gpu/command_buffer/client/gles2_implementation.h"
8 8
9 #include <GLES2/gl2ext.h> 9 #include <GLES2/gl2ext.h>
10 #include <GLES2/gl2extchromium.h> 10 #include <GLES2/gl2extchromium.h>
11 #include <GLES3/gl3.h> 11 #include <GLES3/gl3.h>
12 #include <algorithm> 12 #include <algorithm>
13 #include <limits> 13 #include <limits>
14 #include <map> 14 #include <map>
15 #include <queue> 15 #include <queue>
16 #include <set> 16 #include <set>
17 #include <sstream> 17 #include <sstream>
18 #include <string> 18 #include <string>
19 #include "base/bind.h" 19 #include "base/bind.h"
20 #include "base/numerics/safe_math.h"
20 #include "gpu/command_buffer/client/buffer_tracker.h" 21 #include "gpu/command_buffer/client/buffer_tracker.h"
21 #include "gpu/command_buffer/client/gpu_control.h" 22 #include "gpu/command_buffer/client/gpu_control.h"
22 #include "gpu/command_buffer/client/program_info_manager.h" 23 #include "gpu/command_buffer/client/program_info_manager.h"
23 #include "gpu/command_buffer/client/query_tracker.h" 24 #include "gpu/command_buffer/client/query_tracker.h"
24 #include "gpu/command_buffer/client/transfer_buffer.h" 25 #include "gpu/command_buffer/client/transfer_buffer.h"
25 #include "gpu/command_buffer/client/vertex_array_object_manager.h" 26 #include "gpu/command_buffer/client/vertex_array_object_manager.h"
26 #include "gpu/command_buffer/common/gles2_cmd_utils.h" 27 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
27 #include "gpu/command_buffer/common/trace_event.h" 28 #include "gpu/command_buffer/common/trace_event.h"
28 29
29 #if defined(GPU_CLIENT_DEBUG) 30 #if defined(GPU_CLIENT_DEBUG)
(...skipping 938 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 return true; 969 return true;
969 } 970 }
970 971
971 void GLES2Implementation::DeleteShaderStub( 972 void GLES2Implementation::DeleteShaderStub(
972 GLsizei n, const GLuint* shaders) { 973 GLsizei n, const GLuint* shaders) {
973 DCHECK_EQ(1, n); 974 DCHECK_EQ(1, n);
974 share_group_->program_info_manager()->DeleteInfo(shaders[0]); 975 share_group_->program_info_manager()->DeleteInfo(shaders[0]);
975 helper_->DeleteShader(shaders[0]); 976 helper_->DeleteShader(shaders[0]);
976 } 977 }
977 978
979 void GLES2Implementation::DeleteSyncHelper(GLsync sync) {
980 GLuint sync_uint = ToGLuint(sync);
981 if (!GetIdHandler(id_namespaces::kSyncs)->FreeIds(
982 this, 1, &sync_uint, &GLES2Implementation::DeleteSyncStub)) {
983 SetGLError(
984 GL_INVALID_VALUE,
985 "glDeleteSync", "id not created by this context.");
986 }
987 }
988
989 void GLES2Implementation::DeleteSyncStub(GLsizei n, const GLuint* syncs) {
990 DCHECK_EQ(1, n);
991 helper_->DeleteSync(syncs[0]);
992 }
978 993
979 GLint GLES2Implementation::GetAttribLocationHelper( 994 GLint GLES2Implementation::GetAttribLocationHelper(
980 GLuint program, const char* name) { 995 GLuint program, const char* name) {
981 typedef cmds::GetAttribLocation::Result Result; 996 typedef cmds::GetAttribLocation::Result Result;
982 Result* result = GetResultAs<Result*>(); 997 Result* result = GetResultAs<Result*>();
983 if (!result) { 998 if (!result) {
984 return -1; 999 return -1;
985 } 1000 }
986 *result = -1; 1001 *result = -1;
987 SetBucketAsCString(kResultBucketId, name); 1002 SetBucketAsCString(kResultBucketId, name);
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
1183 GPU_CLIENT_SINGLE_THREAD_CHECK(); 1198 GPU_CLIENT_SINGLE_THREAD_CHECK();
1184 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glVertexAttribDivisorANGLE(" 1199 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glVertexAttribDivisorANGLE("
1185 << index << ", " 1200 << index << ", "
1186 << divisor << ") "); 1201 << divisor << ") ");
1187 // Record the info on the client side. 1202 // Record the info on the client side.
1188 vertex_array_object_manager_->SetAttribDivisor(index, divisor); 1203 vertex_array_object_manager_->SetAttribDivisor(index, divisor);
1189 helper_->VertexAttribDivisorANGLE(index, divisor); 1204 helper_->VertexAttribDivisorANGLE(index, divisor);
1190 CheckGLError(); 1205 CheckGLError();
1191 } 1206 }
1192 1207
1193 void GLES2Implementation::ShaderSource(
1194 GLuint shader,
1195 GLsizei count,
1196 const GLchar* const* source,
1197 const GLint* length) {
1198 GPU_CLIENT_SINGLE_THREAD_CHECK();
1199 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glShaderSource("
1200 << shader << ", " << count << ", "
1201 << static_cast<const void*>(source) << ", "
1202 << static_cast<const void*>(length) << ")");
1203 GPU_CLIENT_LOG_CODE_BLOCK({
1204 for (GLsizei ii = 0; ii < count; ++ii) {
1205 if (source[ii]) {
1206 if (length && length[ii] >= 0) {
1207 std::string str(source[ii], length[ii]);
1208 GPU_CLIENT_LOG(" " << ii << ": ---\n" << str << "\n---");
1209 } else {
1210 GPU_CLIENT_LOG(" " << ii << ": ---\n" << source[ii] << "\n---");
1211 }
1212 } else {
1213 GPU_CLIENT_LOG(" " << ii << ": NULL");
1214 }
1215 }
1216 });
1217 if (count < 0) {
1218 SetGLError(GL_INVALID_VALUE, "glShaderSource", "count < 0");
1219 return;
1220 }
1221 if (shader == 0) {
1222 SetGLError(GL_INVALID_VALUE, "glShaderSource", "shader == 0");
1223 return;
1224 }
1225
1226 // Compute the total size.
1227 uint32 total_size = 1;
1228 for (GLsizei ii = 0; ii < count; ++ii) {
1229 if (source[ii]) {
1230 total_size += (length && length[ii] >= 0) ?
1231 static_cast<size_t>(length[ii]) : strlen(source[ii]);
1232 }
1233 }
1234
1235 // Concatenate all the strings in to a bucket on the service.
1236 helper_->SetBucketSize(kResultBucketId, total_size);
1237 uint32 offset = 0;
1238 for (GLsizei ii = 0; ii <= count; ++ii) {
1239 const char* src = ii < count ? source[ii] : "";
1240 if (src) {
1241 uint32 size = ii < count ?
1242 (length ? static_cast<size_t>(length[ii]) : strlen(src)) : 1;
1243 while (size) {
1244 ScopedTransferBufferPtr buffer(size, helper_, transfer_buffer_);
1245 if (!buffer.valid()) {
1246 return;
1247 }
1248 memcpy(buffer.address(), src, buffer.size());
1249 helper_->SetBucketData(kResultBucketId, offset, buffer.size(),
1250 buffer.shm_id(), buffer.offset());
1251 offset += buffer.size();
1252 src += buffer.size();
1253 size -= buffer.size();
1254 }
1255 }
1256 }
1257
1258 DCHECK_EQ(total_size, offset);
1259
1260 helper_->ShaderSourceBucket(shader, kResultBucketId);
1261 helper_->SetBucketSize(kResultBucketId, 0);
1262 CheckGLError();
1263 }
1264
1265 void GLES2Implementation::BufferDataHelper( 1208 void GLES2Implementation::BufferDataHelper(
1266 GLenum target, GLsizeiptr size, const void* data, GLenum usage) { 1209 GLenum target, GLsizeiptr size, const void* data, GLenum usage) {
1267 if (!ValidateSize("glBufferData", size)) 1210 if (!ValidateSize("glBufferData", size))
1268 return; 1211 return;
1269 1212
1270 GLuint buffer_id; 1213 GLuint buffer_id;
1271 if (GetBoundPixelTransferBuffer(target, "glBufferData", &buffer_id)) { 1214 if (GetBoundPixelTransferBuffer(target, "glBufferData", &buffer_id)) {
1272 if (!buffer_id) { 1215 if (!buffer_id) {
1273 return; 1216 return;
1274 } 1217 }
(...skipping 3126 matching lines...) Expand 10 before | Expand all | Expand 10 after
4401 return false; 4344 return false;
4402 } 4345 }
4403 4346
4404 // Include the auto-generated part of this file. We split this because it means 4347 // Include the auto-generated part of this file. We split this because it means
4405 // we can easily edit the non-auto generated parts right here in this file 4348 // we can easily edit the non-auto generated parts right here in this file
4406 // instead of having to edit some template or the code generator. 4349 // instead of having to edit some template or the code generator.
4407 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" 4350 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h"
4408 4351
4409 } // namespace gles2 4352 } // namespace gles2
4410 } // namespace gpu 4353 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698