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

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: Rebase. 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 void 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;
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;
3228 }
3229
3230 // If there's no data/buffer just issue the AsyncTexImage2D
3231 if (!pixels && !bound_pixel_unpack_transfer_buffer_id_) {
3232 helper_->AsyncTexImage2DCHROMIUM(
3233 target, level, internalformat, width, height, border, format, type,
3234 0, 0);
3235 return;
3236 }
3237
3238 // Otherwise, async uploads require a transfer buffer to be bound.
3239 GLuint offset = ToGLuint(pixels);
3240 BufferTracker::Buffer* buffer = GetBoundPixelUnpackTransferBufferIfValid(
3241 "glAsyncTexImage2DCHROMIUM", offset, size);
3242 if (!buffer)
3243 return;
3244
3245 helper_->AsyncTexImage2DCHROMIUM(
3246 target, level, internalformat, width, height, border, format, type,
3247 buffer->shm_id(), buffer->shm_offset() + offset);
3248 return;
3249 }
3250
3251 void GLES2Implementation::AsyncTexSubImage2DCHROMIUM(
3252 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width,
3253 GLsizei height, GLenum format, GLenum type, const void* pixels) {
3254 GPU_CLIENT_SINGLE_THREAD_CHECK();
3255 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glAsyncTexSubImage2DCHROMIUM("
3256 << GLES2Util::GetStringTextureTarget(target) << ", "
3257 << level << ", "
3258 << xoffset << ", " << yoffset << ", "
3259 << width << ", " << height << ", "
3260 << GLES2Util::GetStringTextureFormat(format) << ", "
3261 << GLES2Util::GetStringPixelType(type) << ", "
3262 << static_cast<const void*>(pixels) << ")");
3263 if (level < 0 || height < 0 || width < 0) {
3264 SetGLError(
3265 GL_INVALID_VALUE, "glAsyncTexSubImage2DCHROMIUM", "dimension < 0");
3266 return;
3267 }
3268
3269 uint32 size;
3270 uint32 unpadded_row_size;
3271 uint32 padded_row_size;
3272 if (!GLES2Util::ComputeImageDataSizes(
3273 width, height, format, type, unpack_alignment_, &size,
3274 &unpadded_row_size, &padded_row_size)) {
3275 SetGLError(
3276 GL_INVALID_VALUE, "glAsyncTexSubImage2DCHROMIUM", "size to large");
3277 return;
3278 }
3279
3280 // Async uploads require a transfer buffer to be bound.
3281 GLuint offset = ToGLuint(pixels);
3282 BufferTracker::Buffer* buffer = GetBoundPixelUnpackTransferBufferIfValid(
3283 "glAsyncTexSubImage2DCHROMIUM", offset, size);
3284 if (!buffer)
3285 return;
3286
3287 helper_->AsyncTexSubImage2DCHROMIUM(
3288 target, level, xoffset, yoffset, width, height, format, type,
3289 buffer->shm_id(), buffer->shm_offset() + offset);
3290 return;
3291 }
3292
3203 // Include the auto-generated part of this file. We split this because it means 3293 // 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 3294 // 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. 3295 // instead of having to edit some template or the code generator.
3206 #include "../client/gles2_implementation_impl_autogen.h" 3296 #include "../client/gles2_implementation_impl_autogen.h"
3207 3297
3208 } // namespace gles2 3298 } // namespace gles2
3209 } // namespace gpu 3299 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/gles2_cmd_helper_autogen.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