OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // 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 <algorithm> | 9 #include <algorithm> |
10 #include <map> | 10 #include <map> |
(...skipping 1179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1190 } | 1190 } |
1191 | 1191 |
1192 GPU_DCHECK_EQ(total_size, offset); | 1192 GPU_DCHECK_EQ(total_size, offset); |
1193 | 1193 |
1194 helper_->ShaderSourceBucket(shader, kResultBucketId); | 1194 helper_->ShaderSourceBucket(shader, kResultBucketId); |
1195 helper_->SetBucketSize(kResultBucketId, 0); | 1195 helper_->SetBucketSize(kResultBucketId, 0); |
1196 } | 1196 } |
1197 | 1197 |
1198 void GLES2Implementation::BufferDataHelper( | 1198 void GLES2Implementation::BufferDataHelper( |
1199 GLenum target, GLsizeiptr size, const void* data, GLenum usage) { | 1199 GLenum target, GLsizeiptr size, const void* data, GLenum usage) { |
1200 if (size == 0) { | |
greggman
2012/11/30 09:13:15
this removal I understand
| |
1201 return; | |
1202 } | |
1203 | |
1204 if (size < 0) { | 1200 if (size < 0) { |
1205 SetGLError(GL_INVALID_VALUE, "glBufferData", "size < 0"); | 1201 SetGLError(GL_INVALID_VALUE, "glBufferData", "size < 0"); |
1206 return; | 1202 return; |
1207 } | 1203 } |
1208 | 1204 |
1209 if (target == GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM) { | 1205 if (target == GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM) { |
1210 GLuint buffer_id = bound_pixel_unpack_transfer_buffer_id_; | 1206 GLuint buffer_id = bound_pixel_unpack_transfer_buffer_id_; |
1211 if (!buffer_id) { | 1207 if (!buffer_id) { |
1212 SetGLError(GL_INVALID_VALUE, "glBufferData", "unknown buffer"); | 1208 SetGLError(GL_INVALID_VALUE, "glBufferData", "unknown buffer"); |
1213 return; | 1209 return; |
1214 } | 1210 } |
1215 | 1211 |
1216 BufferTracker::Buffer* buffer = buffer_tracker_->GetBuffer(buffer_id); | 1212 BufferTracker::Buffer* buffer = buffer_tracker_->GetBuffer(buffer_id); |
1217 if (buffer) { | 1213 if (buffer) { |
1218 // Free buffer memory, pending the passage of a token. | 1214 // Free buffer memory, pending the passage of a token. |
1219 buffer_tracker_->FreePendingToken(buffer, helper_->InsertToken()); | 1215 buffer_tracker_->FreePendingToken(buffer, helper_->InsertToken()); |
1220 | 1216 |
1221 // Remove old buffer. | 1217 // Remove old buffer. |
1222 buffer_tracker_->RemoveBuffer(buffer_id); | 1218 buffer_tracker_->RemoveBuffer(buffer_id); |
1223 } | 1219 } |
1224 | 1220 |
1225 // Create new buffer. | 1221 if (size) { |
greggman
2012/11/30 09:13:15
this addition I don't understand. It seems like yo
reveman
2012/11/30 09:30:33
Yes, I think you're right. I might need to update
| |
1226 buffer = buffer_tracker_->CreateBuffer(buffer_id, size); | 1222 // Create new buffer. |
1227 GPU_DCHECK(buffer); | 1223 buffer = buffer_tracker_->CreateBuffer(buffer_id, size); |
1228 if (data) | 1224 GPU_DCHECK(buffer); |
1229 memcpy(buffer->address(), data, size); | 1225 if (data) |
1226 memcpy(buffer->address(), data, size); | |
1227 } | |
1230 return; | 1228 return; |
1231 } | 1229 } |
1232 | 1230 |
1231 if (size == 0) { | |
1232 return; | |
1233 } | |
1234 | |
1233 // If there is no data just send BufferData | 1235 // If there is no data just send BufferData |
1234 if (!data) { | 1236 if (!data) { |
1235 helper_->BufferData(target, size, 0, 0, usage); | 1237 helper_->BufferData(target, size, 0, 0, usage); |
1236 return; | 1238 return; |
1237 } | 1239 } |
1238 | 1240 |
1239 // See if we can send all at once. | 1241 // See if we can send all at once. |
1240 ScopedTransferBufferPtr buffer(size, helper_, transfer_buffer_); | 1242 ScopedTransferBufferPtr buffer(size, helper_, transfer_buffer_); |
1241 if (!buffer.valid()) { | 1243 if (!buffer.valid()) { |
1242 return; | 1244 return; |
(...skipping 1957 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3200 return true; | 3202 return true; |
3201 } | 3203 } |
3202 | 3204 |
3203 // Include the auto-generated part of this file. We split this because it means | 3205 // Include the auto-generated part of this file. We split this because it means |
3204 // we can easily edit the non-auto generated parts right here in this file | 3206 // we can easily edit the non-auto generated parts right here in this file |
3205 // instead of having to edit some template or the code generator. | 3207 // instead of having to edit some template or the code generator. |
3206 #include "../client/gles2_implementation_impl_autogen.h" | 3208 #include "../client/gles2_implementation_impl_autogen.h" |
3207 | 3209 |
3208 } // namespace gles2 | 3210 } // namespace gles2 |
3209 } // namespace gpu | 3211 } // namespace gpu |
OLD | NEW |