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

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

Issue 255713008: Change glimage to accept a type. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Build Created 6 years, 7 months 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 | Annotate | Revision Log
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 <algorithm> 9 #include <algorithm>
10 #include <map> 10 #include <map>
(...skipping 3930 matching lines...) Expand 10 before | Expand all | Expand 10 after
3941 CheckGLError(); 3941 CheckGLError();
3942 } 3942 }
3943 3943
3944 GLuint GLES2Implementation::InsertSyncPointCHROMIUM() { 3944 GLuint GLES2Implementation::InsertSyncPointCHROMIUM() {
3945 GPU_CLIENT_SINGLE_THREAD_CHECK(); 3945 GPU_CLIENT_SINGLE_THREAD_CHECK();
3946 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glInsertSyncPointCHROMIUM"); 3946 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glInsertSyncPointCHROMIUM");
3947 helper_->CommandBufferHelper::Flush(); 3947 helper_->CommandBufferHelper::Flush();
3948 return gpu_control_->InsertSyncPoint(); 3948 return gpu_control_->InsertSyncPoint();
3949 } 3949 }
3950 3950
3951 GLuint GLES2Implementation::CreateImageCHROMIUMHelper( 3951 GLuint GLES2Implementation::CreateImageCHROMIUMHelper(GLsizei width,
3952 GLsizei width, GLsizei height, GLenum internalformat) { 3952 GLsizei height,
3953 GLenum internalformat,
3954 GLenum usage) {
3953 if (width <= 0) { 3955 if (width <= 0) {
3954 SetGLError(GL_INVALID_VALUE, "glCreateImageCHROMIUM", "width <= 0"); 3956 SetGLError(GL_INVALID_VALUE, "glCreateImageCHROMIUM", "width <= 0");
3955 return 0; 3957 return 0;
3956 } 3958 }
3957 3959
3958 if (height <= 0) { 3960 if (height <= 0) {
3959 SetGLError(GL_INVALID_VALUE, "glCreateImageCHROMIUM", "height <= 0"); 3961 SetGLError(GL_INVALID_VALUE, "glCreateImageCHROMIUM", "height <= 0");
3960 return 0; 3962 return 0;
3961 } 3963 }
3962 // Flush the command stream to ensure ordering in case the newly 3964 // Flush the command stream to ensure ordering in case the newly
3963 // returned image_id has recently been in use with a different buffer. 3965 // returned image_id has recently been in use with a different buffer.
3964 helper_->CommandBufferHelper::Flush(); 3966 helper_->CommandBufferHelper::Flush();
3965 3967
3966 // Create new buffer. 3968 // Create new buffer.
3967 GLuint buffer_id = gpu_memory_buffer_tracker_->CreateBuffer( 3969 GLuint buffer_id = gpu_memory_buffer_tracker_->CreateBuffer(
3968 width, height, internalformat); 3970 width, height, internalformat, usage);
3969 if (buffer_id == 0) { 3971 if (buffer_id == 0) {
3970 SetGLError(GL_OUT_OF_MEMORY, "glCreateImageCHROMIUM", "out of GPU memory."); 3972 SetGLError(GL_OUT_OF_MEMORY, "glCreateImageCHROMIUM", "out of GPU memory.");
3971 return 0; 3973 return 0;
3972 } 3974 }
3973 return buffer_id; 3975 return buffer_id;
3974 } 3976 }
3975 3977
3976 GLuint GLES2Implementation::CreateImageCHROMIUM( 3978 GLuint GLES2Implementation::CreateImageCHROMIUM(GLsizei width,
3977 GLsizei width, GLsizei height, GLenum internalformat) { 3979 GLsizei height,
3980 GLenum internalformat,
3981 GLenum usage) {
3978 GPU_CLIENT_SINGLE_THREAD_CHECK(); 3982 GPU_CLIENT_SINGLE_THREAD_CHECK();
3979 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glCreateImageCHROMIUM(" 3983 GPU_CLIENT_LOG(
3980 << width << ", " 3984 "[" << GetLogPrefix() << "] glCreateImageCHROMIUM(" << width << ", "
3981 << height << ", " 3985 << height << ", "
3982 << GLES2Util::GetStringTextureInternalFormat(internalformat) << ")"); 3986 << GLES2Util::GetStringTextureInternalFormat(internalformat) << ", "
3983 GLuint image_id = CreateImageCHROMIUMHelper(width, height, internalformat); 3987 << GLES2Util::GetStringTextureInternalFormat(usage) << ")");
3988 GLuint image_id =
3989 CreateImageCHROMIUMHelper(width, height, internalformat, usage);
3984 CheckGLError(); 3990 CheckGLError();
3985 return image_id; 3991 return image_id;
3986 } 3992 }
3987 3993
3988 void GLES2Implementation::DestroyImageCHROMIUMHelper(GLuint image_id) { 3994 void GLES2Implementation::DestroyImageCHROMIUMHelper(GLuint image_id) {
3989 gfx::GpuMemoryBuffer* gpu_buffer = gpu_memory_buffer_tracker_->GetBuffer( 3995 gfx::GpuMemoryBuffer* gpu_buffer = gpu_memory_buffer_tracker_->GetBuffer(
3990 image_id); 3996 image_id);
3991 if (!gpu_buffer) { 3997 if (!gpu_buffer) {
3992 SetGLError(GL_INVALID_OPERATION, "glDestroyImageCHROMIUM", "invalid image"); 3998 SetGLError(GL_INVALID_OPERATION, "glDestroyImageCHROMIUM", "invalid image");
3993 return; 3999 return;
(...skipping 30 matching lines...) Expand all
4024 4030
4025 void GLES2Implementation::UnmapImageCHROMIUM(GLuint image_id) { 4031 void GLES2Implementation::UnmapImageCHROMIUM(GLuint image_id) {
4026 GPU_CLIENT_SINGLE_THREAD_CHECK(); 4032 GPU_CLIENT_SINGLE_THREAD_CHECK();
4027 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glUnmapImageCHROMIUM(" 4033 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glUnmapImageCHROMIUM("
4028 << image_id << ")"); 4034 << image_id << ")");
4029 4035
4030 UnmapImageCHROMIUMHelper(image_id); 4036 UnmapImageCHROMIUMHelper(image_id);
4031 CheckGLError(); 4037 CheckGLError();
4032 } 4038 }
4033 4039
4034 void* GLES2Implementation::MapImageCHROMIUMHelper(GLuint image_id, 4040 void* GLES2Implementation::MapImageCHROMIUMHelper(GLuint image_id) {
4035 GLenum access) {
4036 gfx::GpuMemoryBuffer* gpu_buffer = gpu_memory_buffer_tracker_->GetBuffer( 4041 gfx::GpuMemoryBuffer* gpu_buffer = gpu_memory_buffer_tracker_->GetBuffer(
4037 image_id); 4042 image_id);
4038 if (!gpu_buffer) { 4043 if (!gpu_buffer) {
4039 SetGLError(GL_INVALID_OPERATION, "glMapImageCHROMIUM", "invalid image"); 4044 SetGLError(GL_INVALID_OPERATION, "glMapImageCHROMIUM", "invalid image");
4040 return NULL; 4045 return NULL;
4041 } 4046 }
4042 gfx::GpuMemoryBuffer::AccessMode mode;
4043 switch(access) {
4044 case GL_WRITE_ONLY:
4045 mode = gfx::GpuMemoryBuffer::WRITE_ONLY;
4046 break;
4047 case GL_READ_ONLY:
4048 mode = gfx::GpuMemoryBuffer::READ_ONLY;
4049 break;
4050 case GL_READ_WRITE:
4051 mode = gfx::GpuMemoryBuffer::READ_WRITE;
4052 break;
4053 default:
4054 SetGLError(GL_INVALID_ENUM, "glMapImageCHROMIUM",
4055 "invalid GPU access mode");
4056 return NULL;
4057 }
4058 4047
4059 if (gpu_buffer->IsMapped()) { 4048 if (gpu_buffer->IsMapped()) {
4060 SetGLError(GL_INVALID_OPERATION, "glMapImageCHROMIUM", "already mapped"); 4049 SetGLError(GL_INVALID_OPERATION, "glMapImageCHROMIUM", "already mapped");
4061 return NULL; 4050 return NULL;
4062 } 4051 }
4063 4052
4064 return gpu_buffer->Map(mode); 4053 return gpu_buffer->Map();
4065 } 4054 }
4066 4055
4067 void* GLES2Implementation::MapImageCHROMIUM( 4056 void* GLES2Implementation::MapImageCHROMIUM(GLuint image_id) {
4068 GLuint image_id, GLenum access) {
4069 GPU_CLIENT_SINGLE_THREAD_CHECK(); 4057 GPU_CLIENT_SINGLE_THREAD_CHECK();
4070 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glMapImageCHROMIUM(" 4058 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glMapImageCHROMIUM(" << image_id
4071 << image_id << ", " 4059 << ")");
4072 << GLES2Util::GetStringEnum(access) << ")");
4073 4060
4074 void* mapped = MapImageCHROMIUMHelper(image_id, access); 4061 void* mapped = MapImageCHROMIUMHelper(image_id);
4075 CheckGLError(); 4062 CheckGLError();
4076 return mapped; 4063 return mapped;
4077 } 4064 }
4078 4065
4079 void GLES2Implementation::GetImageParameterivCHROMIUMHelper( 4066 void GLES2Implementation::GetImageParameterivCHROMIUMHelper(
4080 GLuint image_id, GLenum pname, GLint* params) { 4067 GLuint image_id, GLenum pname, GLint* params) {
4081 if (pname != GL_IMAGE_ROWBYTES_CHROMIUM) { 4068 if (pname != GL_IMAGE_ROWBYTES_CHROMIUM) {
4082 SetGLError(GL_INVALID_ENUM, "glGetImageParameterivCHROMIUM", 4069 SetGLError(GL_INVALID_ENUM, "glGetImageParameterivCHROMIUM",
4083 "invalid parameter"); 4070 "invalid parameter");
4084 return; 4071 return;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
4137 return true; 4124 return true;
4138 } 4125 }
4139 4126
4140 // Include the auto-generated part of this file. We split this because it means 4127 // Include the auto-generated part of this file. We split this because it means
4141 // we can easily edit the non-auto generated parts right here in this file 4128 // we can easily edit the non-auto generated parts right here in this file
4142 // instead of having to edit some template or the code generator. 4129 // instead of having to edit some template or the code generator.
4143 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" 4130 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h"
4144 4131
4145 } // namespace gles2 4132 } // namespace gles2
4146 } // namespace gpu 4133 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698