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

Unified 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: Just a name change Created 8 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: gpu/command_buffer/client/gles2_implementation.cc
diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc
index 8fc6e752c3e4ba08e547a8de9510afaaaf6e810e..dcbaa3eee176dd120bc06cedc5b75b21898cb4f4 100644
--- a/gpu/command_buffer/client/gles2_implementation.cc
+++ b/gpu/command_buffer/client/gles2_implementation.cc
@@ -3659,6 +3659,105 @@ GLboolean GLES2Implementation::UnmapBufferCHROMIUM(GLuint target) {
return true;
}
+GLboolean GLES2Implementation::AsyncTexImage2DCHROMIUM(
+ GLenum target, GLint level, GLint internalformat, GLsizei width,
+ GLsizei height, GLint border, GLenum format, GLenum type,
+ const void* pixels) {
+ GPU_CLIENT_SINGLE_THREAD_CHECK();
+ GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glTexImage2D("
+ << GLES2Util::GetStringTextureTarget(target) << ", "
+ << level << ", "
+ << GLES2Util::GetStringTextureInternalFormat(internalformat) << ", "
+ << width << ", " << height << ", " << border << ", "
+ << GLES2Util::GetStringTextureFormat(format) << ", "
+ << GLES2Util::GetStringPixelType(type) << ", "
+ << static_cast<const void*>(pixels) << ")");
+ if (level < 0 || height < 0 || width < 0) {
+ SetGLError(GL_INVALID_VALUE, "glTexImage2D", "dimension < 0");
+ return false;
+ }
+ uint32 size;
+ uint32 unpadded_row_size;
+ uint32 padded_row_size;
+ if (!GLES2Util::ComputeImageDataSizes(
+ width, height, format, type, unpack_alignment_, &size,
+ &unpadded_row_size, &padded_row_size)) {
+ SetGLError(GL_INVALID_VALUE, "glTexImage2D", "image size too large");
+ return false;
+ }
+
+ // If there's no data just issue the AsyncTexImage2D.
+ if (!pixels) {
+ helper_->AsyncTexImage2DCHROMIUM(
greggman 2012/11/29 02:18:18 You can just issue texImage2DCHROMIUM here no?
+ target, level, internalformat, width, height, border, format, type,
+ 0, 0);
+ return true;
+ }
+
+ // Async uploads require a transfer buffer to be bound.
+ GLuint offset = ToGLuint(pixels);
+ BufferTracker::Buffer* buffer = GetBoundPixelUnpackTransferBufferIfValid(
+ "glAsyncTexImage2DCHROMIUM", offset, size);
+ if (!bound_pixel_unpack_transfer_buffer_id_ || !buffer) {
+ SetGLError(
+ GL_INVALID_VALUE, "glAsyncTexImage2DCHROMIUM", "invalid buffer");
+ return false;
+ }
+
+ helper_->AsyncTexImage2DCHROMIUM(
greggman 2012/11/29 02:18:18 You can just issue texImage2DCHROMIUM here no?
+ target, level, internalformat, width, height, border, format, type,
+ buffer->shm_id(), buffer->shm_offset() + offset);
+ return true;
+}
+
+GLboolean GLES2Implementation::AsyncTexSubImage2DCHROMIUM(
+ GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width,
+ GLsizei height, GLenum format, GLenum type, const void* pixels) {
+ GPU_CLIENT_SINGLE_THREAD_CHECK();
+ GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glAsyncTexSubImage2DCHROMIUM("
+ << GLES2Util::GetStringTextureTarget(target) << ", "
+ << level << ", "
+ << xoffset << ", " << yoffset << ", "
+ << width << ", " << height << ", "
+ << GLES2Util::GetStringTextureFormat(format) << ", "
+ << GLES2Util::GetStringPixelType(type) << ", "
+ << static_cast<const void*>(pixels) << ")");
+ if (level < 0 || height < 0 || width < 0) {
+ SetGLError(
+ GL_INVALID_VALUE, "glAsyncTexSubImage2DCHROMIUM", "dimension < 0");
+ return false;
+ }
+ if (height == 0 || width == 0) {
+ return false;
+ }
+
+ uint32 size;
+ uint32 unpadded_row_size;
+ uint32 padded_row_size;
+ if (!GLES2Util::ComputeImageDataSizes(
+ width, height, format, type, unpack_alignment_, &size,
+ &unpadded_row_size, &padded_row_size)) {
+ SetGLError(
+ GL_INVALID_VALUE, "glAsyncTexSubImage2DCHROMIUM", "size to large");
+ return false;
+ }
+
+ // Async uploads require a transfer buffer to be bound.
+ GLuint offset = ToGLuint(pixels);
+ BufferTracker::Buffer* buffer = GetBoundPixelUnpackTransferBufferIfValid(
+ "glAsyncTexSubImage2DCHROMIUM", offset, size);
+ if (!bound_pixel_unpack_transfer_buffer_id_ || !buffer) {
+ SetGLError(
+ GL_INVALID_VALUE, "glAsyncTexSubImage2DCHROMIUM", "invalid buffer");
+ return false;
+ }
+
+ helper_->AsyncTexSubImage2DCHROMIUM(
greggman 2012/11/29 02:18:18 You can just issue texSubImage2DCHROMIUM here no?
+ target, level, xoffset, yoffset, width, height, format, type,
+ buffer->shm_id(), buffer->shm_offset() + offset);
+ return true;
+}
+
// Include the auto-generated part of this file. We split this because it means
// we can easily edit the non-auto generated parts right here in this file
// instead of having to edit some template or the code generator.

Powered by Google App Engine
This is Rietveld 408576698