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

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

Issue 793693003: Tile Compression (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 "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>
(...skipping 3759 matching lines...) Expand 10 before | Expand all | Expand 10 after
3770 uint32 async_token = NextAsyncUploadToken(); 3770 uint32 async_token = NextAsyncUploadToken();
3771 buffer->set_last_async_upload_token(async_token); 3771 buffer->set_last_async_upload_token(async_token);
3772 helper_->AsyncTexSubImage2DCHROMIUM( 3772 helper_->AsyncTexSubImage2DCHROMIUM(
3773 target, level, xoffset, yoffset, width, height, format, type, 3773 target, level, xoffset, yoffset, width, height, format, type,
3774 buffer->shm_id(), buffer->shm_offset() + offset, 3774 buffer->shm_id(), buffer->shm_offset() + offset,
3775 async_token, 3775 async_token,
3776 async_upload_sync_shm_id_, async_upload_sync_shm_offset_); 3776 async_upload_sync_shm_id_, async_upload_sync_shm_offset_);
3777 } 3777 }
3778 } 3778 }
3779 3779
3780 void GLES2Implementation::AsyncCompressedTexImage2DCHROMIUM(
3781 GLenum target,
3782 GLint level,
3783 GLint internalformat,
3784 GLsizei width,
3785 GLsizei height,
3786 GLint border,
3787 GLsizei imagesize,
3788 const void* pixels) {
3789 GPU_CLIENT_SINGLE_THREAD_CHECK();
3790 GPU_CLIENT_LOG(
3791 "[" << GetLogPrefix() << "] glCompressedTexImage2D("
3792 << GLES2Util::GetStringTextureTarget(target) << ", " << level << ", "
3793 << GLES2Util::GetStringTextureInternalFormat(internalformat) << ", "
3794 << width << ", " << height << ", " << border << ", " << imagesize
3795 << ", " << static_cast<const void*>(pixels) << ")");
3796 if (level < 0 || height < 0 || width < 0) {
3797 SetGLError(GL_INVALID_VALUE, "glCompressedTexImage2D", "dimension < 0");
3798 return;
3799 }
3800 if (border != 0) {
3801 SetGLError(GL_INVALID_VALUE, "glCompressedTexImage2D", "border != 0");
3802 return;
3803 }
3804
3805 int calculated_imagesize = 0;
3806 if (!GLES2Util::ComputeCompressedImageSize(width, height, internalformat,
3807 &calculated_imagesize) ||
3808 calculated_imagesize != imagesize) {
3809 SetGLError(GL_INVALID_VALUE, "glCompressedTexImage2D",
3810 "imagesize is not consistent");
3811 return;
3812 }
3813
3814 // If there's no data/buffer just issue the AsyncTexImage2D
3815 if (!pixels && !bound_pixel_unpack_transfer_buffer_id_) {
3816 helper_->AsyncCompressedTexImage2DCHROMIUM(
3817 target, level, internalformat, width, height, imagesize, 0, 0, 0, 0, 0);
3818 return;
3819 }
3820
3821 if (!EnsureAsyncUploadSync()) {
3822 SetGLError(GL_OUT_OF_MEMORY, "glCompressedTexImage2D", "out of memory");
3823 return;
3824 }
3825
3826 // Otherwise, async uploads require a transfer buffer to be bound.
3827 // TODO(hubbe): Make MapBufferCHROMIUM block if someone tries to re-use
3828 // the buffer before the transfer is finished. (Currently such
3829 // synchronization has to be handled manually.)
3830 GLuint offset = ToGLuint(pixels);
3831 BufferTracker::Buffer* buffer = GetBoundPixelUnpackTransferBufferIfValid(
3832 bound_pixel_unpack_transfer_buffer_id_,
3833 "glAsyncCompressedTexImage2DCHROMIUM", offset, imagesize);
3834 if (buffer && buffer->shm_id() != -1) {
3835 uint32 async_token = NextAsyncUploadToken();
3836 buffer->set_last_async_upload_token(async_token);
3837 helper_->AsyncCompressedTexImage2DCHROMIUM(
3838 target, level, internalformat, width, height, imagesize,
3839 buffer->shm_id(), buffer->shm_offset() + offset, async_token,
3840 async_upload_sync_shm_id_, async_upload_sync_shm_offset_);
3841 }
3842 }
3843
3844 void GLES2Implementation::AsyncCompressedTexSubImage2DCHROMIUM(
3845 GLenum target,
3846 GLint level,
3847 GLint xoffset,
3848 GLint yoffset,
3849 GLsizei width,
3850 GLsizei height,
3851 GLenum format,
3852 GLsizei imagesize,
3853 const void* pixels) {
3854 GPU_CLIENT_SINGLE_THREAD_CHECK();
3855 GPU_CLIENT_LOG(
3856 "[" << GetLogPrefix() << "] glAsyncCompressedTexSubImage2DCHROMIUM("
3857 << GLES2Util::GetStringTextureTarget(target) << ", " << level << ", "
3858 << xoffset << ", " << yoffset << ", " << width << ", " << height
3859 << ", " << GLES2Util::GetStringTextureFormat(format) << ", "
3860 << imagesize << ", " << static_cast<const void*>(pixels) << ")");
3861 if (level < 0 || height < 0 || width < 0) {
3862 SetGLError(GL_INVALID_VALUE, "glAsyncCompressedTexSubImage2DCHROMIUM",
3863 "dimension < 0");
3864 return;
3865 }
3866
3867 int calculated_imagesize = 0;
3868 if (!GLES2Util::ComputeCompressedImageSize(width, height, format,
3869 &calculated_imagesize) ||
3870 calculated_imagesize != imagesize) {
3871 SetGLError(GL_INVALID_VALUE, "glCompressedTexSubImage2D",
3872 "imagesize is not consistent");
3873 return;
3874 }
3875
3876 if (!EnsureAsyncUploadSync()) {
3877 SetGLError(GL_OUT_OF_MEMORY, "glCompressedTexSubImage2D", "out of memory");
3878 return;
3879 }
3880
3881 // Async uploads require a transfer buffer to be bound.
3882 // TODO(hubbe): Make MapBufferCHROMIUM block if someone tries to re-use
3883 // the buffer before the transfer is finished. (Currently such
3884 // synchronization has to be handled manually.)
3885 GLuint offset = ToGLuint(pixels);
3886 BufferTracker::Buffer* buffer = GetBoundPixelUnpackTransferBufferIfValid(
3887 bound_pixel_unpack_transfer_buffer_id_,
3888 "glAsyncCompressedTexSubImage2DCHROMIUM", offset, imagesize);
3889 if (buffer && buffer->shm_id() != -1) {
3890 uint32 async_token = NextAsyncUploadToken();
3891 buffer->set_last_async_upload_token(async_token);
3892 helper_->AsyncCompressedTexSubImage2DCHROMIUM(
3893 target, level, xoffset, yoffset, width, height, format, imagesize,
3894 buffer->shm_id(), buffer->shm_offset() + offset, async_token,
3895 async_upload_sync_shm_id_, async_upload_sync_shm_offset_);
3896 }
3897 }
3898
3780 void GLES2Implementation::WaitAsyncTexImage2DCHROMIUM(GLenum target) { 3899 void GLES2Implementation::WaitAsyncTexImage2DCHROMIUM(GLenum target) {
3781 GPU_CLIENT_SINGLE_THREAD_CHECK(); 3900 GPU_CLIENT_SINGLE_THREAD_CHECK();
3782 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glWaitAsyncTexImage2DCHROMIUM(" 3901 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glWaitAsyncTexImage2DCHROMIUM("
3783 << GLES2Util::GetStringTextureTarget(target) << ")"); 3902 << GLES2Util::GetStringTextureTarget(target) << ")");
3784 helper_->WaitAsyncTexImage2DCHROMIUM(target); 3903 helper_->WaitAsyncTexImage2DCHROMIUM(target);
3785 CheckGLError(); 3904 CheckGLError();
3786 } 3905 }
3787 3906
3788 void GLES2Implementation::WaitAllAsyncTexImage2DCHROMIUM() { 3907 void GLES2Implementation::WaitAllAsyncTexImage2DCHROMIUM() {
3789 GPU_CLIENT_SINGLE_THREAD_CHECK(); 3908 GPU_CLIENT_SINGLE_THREAD_CHECK();
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
3985 return true; 4104 return true;
3986 } 4105 }
3987 4106
3988 // Include the auto-generated part of this file. We split this because it means 4107 // Include the auto-generated part of this file. We split this because it means
3989 // we can easily edit the non-auto generated parts right here in this file 4108 // we can easily edit the non-auto generated parts right here in this file
3990 // instead of having to edit some template or the code generator. 4109 // instead of having to edit some template or the code generator.
3991 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" 4110 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h"
3992 4111
3993 } // namespace gles2 4112 } // namespace gles2
3994 } // namespace gpu 4113 } // 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