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

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

Issue 11412232: gpu: Add async upload functions. (Closed) Base URL: http://git.chromium.org/chromium/src.git@ASYNC_uploads
Patch Set: Add autogenerated code. Created 8 years 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 "../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 3182 matching lines...) Expand 10 before | Expand all | Expand 10 after
3193 } 3193 }
3194 if (!buffer->mapped()) { 3194 if (!buffer->mapped()) {
3195 SetGLError(GL_INVALID_OPERATION, "glMapBufferCHROMIUM", "not mapped"); 3195 SetGLError(GL_INVALID_OPERATION, "glMapBufferCHROMIUM", "not mapped");
3196 return false; 3196 return false;
3197 } 3197 }
3198 buffer->set_mapped(false); 3198 buffer->set_mapped(false);
3199 3199
3200 return true; 3200 return true;
3201 } 3201 }
3202 3202
3203 GLboolean GLES2Implementation::AsyncTexImage2DCHROMIUM(
3204 GLenum target, GLint level, GLint internalformat, GLsizei width,
3205 GLsizei height, GLint border, GLenum format, GLenum type,
3206 const void* pixels) {
3207 GPU_CLIENT_SINGLE_THREAD_CHECK();
3208 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glTexImage2D("
3209 << GLES2Util::GetStringTextureTarget(target) << ", "
3210 << level << ", "
3211 << GLES2Util::GetStringTextureInternalFormat(internalformat) << ", "
3212 << width << ", " << height << ", " << border << ", "
3213 << GLES2Util::GetStringTextureFormat(format) << ", "
3214 << GLES2Util::GetStringPixelType(type) << ", "
3215 << static_cast<const void*>(pixels) << ")");
3216 if (level < 0 || height < 0 || width < 0) {
3217 SetGLError(GL_INVALID_VALUE, "glTexImage2D", "dimension < 0");
3218 return false;
3219 }
3220 uint32 size;
3221 uint32 unpadded_row_size;
3222 uint32 padded_row_size;
3223 if (!GLES2Util::ComputeImageDataSizes(
3224 width, height, format, type, unpack_alignment_, &size,
3225 &unpadded_row_size, &padded_row_size)) {
3226 SetGLError(GL_INVALID_VALUE, "glTexImage2D", "image size too large");
3227 return false;
3228 }
3229
3230 GLuint offset = ToGLuint(pixels);
3231 BufferTracker::Buffer* buffer = GetBoundPixelUnpackTransferBufferIfValid(
greggman 2012/11/30 03:01:51 GetBoundPixelUnpackTransferBufferIfValid generates
epennerAtGoogle 2012/11/30 04:14:22 Done.
3232 "glAsyncTexImage2DCHROMIUM", offset, size);
3233 bool buffer_bound = bound_pixel_unpack_transfer_buffer_id_ && buffer;
3234
3235 // If there's no data/buffer just issue the AsyncTexImage2D
3236 if (!pixels && !buffer_bound) {
3237 helper_->AsyncTexImage2DCHROMIUM(
3238 target, level, internalformat, width, height, border, format, type,
3239 0, 0);
reveman 2012/11/30 03:10:20 GetBoundPixelUnpackTransferBufferIfValid above wil
epennerAtGoogle 2012/11/30 04:14:22 Done.
3240 return true;
3241 }
3242
3243 // Otherwise, async uploads require a transfer buffer to be bound
3244 if (!buffer_bound) {
3245 SetGLError(
reveman 2012/11/30 03:10:20 GetBoundPixelUnpackTransferBufferIfValid should al
epennerAtGoogle 2012/11/30 04:14:22 Done.
3246 GL_INVALID_VALUE, "glAsyncTexImage2DCHROMIUM", "invalid buffer");
3247 return false;
3248 }
3249
3250 helper_->AsyncTexImage2DCHROMIUM(
3251 target, level, internalformat, width, height, border, format, type,
3252 buffer->shm_id(), buffer->shm_offset() + offset);
3253 return true;
3254 }
3255
3256 GLboolean GLES2Implementation::AsyncTexSubImage2DCHROMIUM(
3257 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width,
3258 GLsizei height, GLenum format, GLenum type, const void* pixels) {
3259 GPU_CLIENT_SINGLE_THREAD_CHECK();
3260 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glAsyncTexSubImage2DCHROMIUM("
3261 << GLES2Util::GetStringTextureTarget(target) << ", "
3262 << level << ", "
3263 << xoffset << ", " << yoffset << ", "
3264 << width << ", " << height << ", "
3265 << GLES2Util::GetStringTextureFormat(format) << ", "
3266 << GLES2Util::GetStringPixelType(type) << ", "
3267 << static_cast<const void*>(pixels) << ")");
3268 if (level < 0 || height < 0 || width < 0) {
3269 SetGLError(
3270 GL_INVALID_VALUE, "glAsyncTexSubImage2DCHROMIUM", "dimension < 0");
3271 return false;
3272 }
3273 if (height == 0 || width == 0) {
3274 return false;
3275 }
3276
3277 uint32 size;
3278 uint32 unpadded_row_size;
3279 uint32 padded_row_size;
3280 if (!GLES2Util::ComputeImageDataSizes(
3281 width, height, format, type, unpack_alignment_, &size,
3282 &unpadded_row_size, &padded_row_size)) {
3283 SetGLError(
3284 GL_INVALID_VALUE, "glAsyncTexSubImage2DCHROMIUM", "size to large");
3285 return false;
3286 }
3287
3288 // Async uploads require a transfer buffer to be bound.
3289 GLuint offset = ToGLuint(pixels);
3290 BufferTracker::Buffer* buffer = GetBoundPixelUnpackTransferBufferIfValid(
3291 "glAsyncTexSubImage2DCHROMIUM", offset, size);
3292 if (!bound_pixel_unpack_transfer_buffer_id_ || !buffer) {
greggman 2012/11/30 03:01:51 same as above. If buffer is NULL errors have alrea
epennerAtGoogle 2012/11/30 04:14:22 Done.
3293 SetGLError(
reveman 2012/11/30 03:10:20 Same here. GetBoundPixelUnpackTransferBufferIfVali
epennerAtGoogle 2012/11/30 04:14:22 Done.
3294 GL_INVALID_VALUE, "glAsyncTexSubImage2DCHROMIUM", "invalid buffer");
3295 return false;
3296 }
3297
3298 helper_->AsyncTexSubImage2DCHROMIUM(
3299 target, level, xoffset, yoffset, width, height, format, type,
3300 buffer->shm_id(), buffer->shm_offset() + offset);
3301 return true;
3302 }
3303
3203 // Include the auto-generated part of this file. We split this because it means 3304 // 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 3305 // 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. 3306 // instead of having to edit some template or the code generator.
3206 #include "../client/gles2_implementation_impl_autogen.h" 3307 #include "../client/gles2_implementation_impl_autogen.h"
3207 3308
3208 } // namespace gles2 3309 } // namespace gles2
3209 } // namespace gpu 3310 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698