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

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

Issue 2443023002: gpu: Add CHROMIUM_copy_image extension.
Patch Set: rebase Created 4 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 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 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <stdio.h> 10 #include <stdio.h>
(...skipping 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after
1031 1031
1032 void EnsureTextureForClientId(GLenum target, GLuint client_id); 1032 void EnsureTextureForClientId(GLenum target, GLuint client_id);
1033 void DoConsumeTextureCHROMIUM(GLenum target, const volatile GLbyte* key); 1033 void DoConsumeTextureCHROMIUM(GLenum target, const volatile GLbyte* key);
1034 void DoCreateAndConsumeTextureINTERNAL(GLenum target, 1034 void DoCreateAndConsumeTextureINTERNAL(GLenum target,
1035 GLuint client_id, 1035 GLuint client_id,
1036 const volatile GLbyte* key); 1036 const volatile GLbyte* key);
1037 void DoApplyScreenSpaceAntialiasingCHROMIUM(); 1037 void DoApplyScreenSpaceAntialiasingCHROMIUM();
1038 1038
1039 void DoBindTexImage2DCHROMIUM(GLenum target, GLint image_id, GLint fence_id); 1039 void DoBindTexImage2DCHROMIUM(GLenum target, GLint image_id, GLint fence_id);
1040 void DoReleaseTexImage2DCHROMIUM(GLenum target, GLint image_id); 1040 void DoReleaseTexImage2DCHROMIUM(GLenum target, GLint image_id);
1041 void DoCopyImageSubDataCHROMIUM(GLint source_image_id,
1042 GLint dest_texture_id,
1043 GLint xoffset,
1044 GLint yoffset,
1045 GLint x,
1046 GLint y,
1047 GLsizei width,
1048 GLsizei height,
1049 GLint in_fence_id,
1050 GLint out_fence_id);
1041 1051
1042 void DoTraceEndCHROMIUM(void); 1052 void DoTraceEndCHROMIUM(void);
1043 1053
1044 void DoDrawBuffersEXT(GLsizei count, const volatile GLenum* bufs); 1054 void DoDrawBuffersEXT(GLsizei count, const volatile GLenum* bufs);
1045 1055
1046 void DoLoseContextCHROMIUM(GLenum current, GLenum other); 1056 void DoLoseContextCHROMIUM(GLenum current, GLenum other);
1047 1057
1048 void DoFlushDriverCachesCHROMIUM(void); 1058 void DoFlushDriverCachesCHROMIUM(void);
1049 1059
1050 void DoMatrixLoadfCHROMIUM(GLenum matrix_mode, 1060 void DoMatrixLoadfCHROMIUM(GLenum matrix_mode,
(...skipping 15876 matching lines...) Expand 10 before | Expand all | Expand 10 after
16927 16937
16928 image->ReleaseTexImage(target); 16938 image->ReleaseTexImage(target);
16929 texture_manager()->SetLevelInfo(texture_ref, target, 0, GL_RGBA, 0, 0, 1, 0, 16939 texture_manager()->SetLevelInfo(texture_ref, target, 0, GL_RGBA, 0, 0, 1, 0,
16930 GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect()); 16940 GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect());
16931 } 16941 }
16932 16942
16933 texture_manager()->SetLevelImage(texture_ref, target, 0, nullptr, 16943 texture_manager()->SetLevelImage(texture_ref, target, 0, nullptr,
16934 Texture::UNBOUND); 16944 Texture::UNBOUND);
16935 } 16945 }
16936 16946
16947 void GLES2DecoderImpl::DoCopyImageSubDataCHROMIUM(GLint source_image_id,
16948 GLint dest_texture_id,
16949 GLint xoffset,
16950 GLint yoffset,
16951 GLint x,
16952 GLint y,
16953 GLsizei width,
16954 GLsizei height,
16955 GLint in_fence_id,
16956 GLint out_fence_id) {
16957 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCopyImageSubDataCHROMIUM");
16958
16959 TextureRef* dest_texture_ref = GetTexture(dest_texture_id);
16960 Texture* dest_texture = dest_texture_ref->texture();
16961 GLenum dest_target = dest_texture->target();
16962 GLenum dest_type = 0;
16963 GLenum dest_internal_format = 0;
16964 bool dest_level_defined = dest_texture->GetLevelType(
16965 dest_target, 0, &dest_type, &dest_internal_format);
16966 if (!dest_level_defined) {
16967 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCopyImageSubDataCHROMIUM",
16968 "destination texture is not defined");
16969 return;
16970 }
16971 if (dest_target != GL_TEXTURE_2D) {
16972 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopyImageSubDataCHROMIUM",
16973 "destination texture bad target.");
16974 return;
16975 }
16976 if (!dest_texture->ValidForTexture(dest_target, 0, xoffset, yoffset, 0, width,
16977 height, 1)) {
16978 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopyImageSubDataCHROMIUM",
16979 "destination texture bad dimensions.");
16980 return;
16981 }
16982 int dest_width = 0;
16983 int dest_height = 0;
16984 bool ok = dest_texture->GetLevelSize(dest_target, 0, &dest_width,
16985 &dest_height, nullptr);
16986 DCHECK(ok);
16987 if (xoffset != 0 || yoffset != 0 || width != dest_width ||
16988 height != dest_height) {
16989 gfx::Rect cleared_rect;
16990 if (TextureManager::CombineAdjacentRects(
16991 dest_texture->GetLevelClearedRect(dest_target, 0),
16992 gfx::Rect(xoffset, yoffset, width, height), &cleared_rect)) {
16993 DCHECK_GE(
16994 cleared_rect.size().GetArea(),
16995 dest_texture->GetLevelClearedRect(dest_target, 0).size().GetArea());
16996 texture_manager()->SetLevelClearedRect(dest_texture_ref, dest_target, 0,
16997 cleared_rect);
16998 } else {
16999 // Otherwise clear part of texture level that is not already cleared.
17000 if (!texture_manager()->ClearTextureLevel(this, dest_texture_ref,
17001 dest_target, 0)) {
17002 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, "glCopyImageSubDataCHROMIUM",
17003 "destination texture dimensions too big");
17004 return;
17005 }
17006 }
17007 } else {
17008 texture_manager()->SetLevelCleared(dest_texture_ref, dest_target, 0, true);
17009 }
17010
17011 gl::GLImage* image = image_manager()->LookupImage(source_image_id);
17012 if (!image) {
17013 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCopyImageSubDataCHROMIUM",
17014 "no image found with the given ID");
17015 return;
17016 }
17017
17018 gl::GLFence* in_fence = nullptr;
17019 if (in_fence_id) {
17020 in_fence = fence_manager()->LookupFence(in_fence_id);
17021 if (!in_fence) {
17022 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCopyImageSubDataCHROMIUM",
17023 "no fence found with the given ID");
17024 return;
17025 }
17026 }
17027
17028 gl::GLFence* out_fence = nullptr;
17029 if (out_fence_id) {
17030 out_fence = fence_manager()->LookupFence(out_fence_id);
17031 if (!out_fence) {
17032 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCopyImageSubDataCHROMIUM",
17033 "no fence found with the given ID");
17034 return;
17035 }
17036 }
17037
17038 if (image->CopySubImageData(
17039 dest_texture->service_id(), gfx::Point(xoffset, yoffset),
17040 gfx::Rect(x, y, width, height), in_fence, out_fence)) {
17041 return;
17042 }
17043
17044 if (!InitializeCopyTextureCHROMIUM("glCopyImageSubDataCHROMIUM"))
17045 return;
17046
17047 // Output fence must have support for client side signaling.
17048 if (out_fence && !out_fence->SignalSupported()) {
17049 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCopyImageSubDataCHROMIUM",
17050 "bad output fence");
17051 return;
17052 }
17053
17054 if (!features().oes_egl_image_external) {
17055 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCopyImageSubDataCHROMIUM",
17056 "oes_egl_image_external missing");
17057 return;
17058 }
17059
17060 GLuint temp_texture = 0;
17061 glGenTextures(1, &temp_texture);
17062 ScopedTextureBinder binder(&state_, temp_texture, GL_TEXTURE_EXTERNAL_OES);
17063
17064 if (!image->BindTexImage(GL_TEXTURE_EXTERNAL_OES, in_fence)) {
17065 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCopyImageSubDataCHROMIUM",
17066 "BindTexImage failed");
17067 glDeleteTextures(1, &temp_texture);
17068 return;
17069 }
17070
17071 gfx::Size image_size = image->GetSize();
17072 copy_texture_CHROMIUM_->DoCopySubTexture(
17073 this, GL_TEXTURE_EXTERNAL_OES, temp_texture, image->GetInternalFormat(),
17074 dest_target, dest_texture->service_id(), dest_internal_format, xoffset,
17075 yoffset, x, y, width, height, dest_width, dest_height, image_size.width(),
17076 image_size.height(), false, false, false);
17077
17078 glDeleteTextures(1, &temp_texture);
17079
17080 if (out_fence) {
17081 gl::GLSurface* surface = gl::GLSurface::GetCurrent();
17082 if (surface->SupportsInsertFence()) {
17083 // Insert fence and forward signal to |out_fence|.
17084 surface->InsertFence(base::Bind(&gl::GLFence::Signal, out_fence));
17085 } else {
17086 LOG(WARNING) << "Fence support missing, using glFinish()";
17087 glFinish();
17088 out_fence->Signal();
17089 }
17090 }
17091 }
17092
16937 error::Error GLES2DecoderImpl::HandleTraceBeginCHROMIUM( 17093 error::Error GLES2DecoderImpl::HandleTraceBeginCHROMIUM(
16938 uint32_t immediate_data_size, 17094 uint32_t immediate_data_size,
16939 const volatile void* cmd_data) { 17095 const volatile void* cmd_data) {
16940 const volatile gles2::cmds::TraceBeginCHROMIUM& c = 17096 const volatile gles2::cmds::TraceBeginCHROMIUM& c =
16941 *static_cast<const volatile gles2::cmds::TraceBeginCHROMIUM*>(cmd_data); 17097 *static_cast<const volatile gles2::cmds::TraceBeginCHROMIUM*>(cmd_data);
16942 Bucket* category_bucket = GetBucket(c.category_bucket_id); 17098 Bucket* category_bucket = GetBucket(c.category_bucket_id);
16943 Bucket* name_bucket = GetBucket(c.name_bucket_id); 17099 Bucket* name_bucket = GetBucket(c.name_bucket_id);
16944 if (!category_bucket || category_bucket->size() == 0 || 17100 if (!category_bucket || category_bucket->size() == 0 ||
16945 !name_bucket || name_bucket->size() == 0) { 17101 !name_bucket || name_bucket->size() == 0) {
16946 return error::kInvalidArguments; 17102 return error::kInvalidArguments;
(...skipping 1741 matching lines...) Expand 10 before | Expand all | Expand 10 after
18688 } 18844 }
18689 18845
18690 // Include the auto-generated part of this file. We split this because it means 18846 // Include the auto-generated part of this file. We split this because it means
18691 // we can easily edit the non-auto generated parts right here in this file 18847 // we can easily edit the non-auto generated parts right here in this file
18692 // instead of having to edit some template or the code generator. 18848 // instead of having to edit some template or the code generator.
18693 #include "base/macros.h" 18849 #include "base/macros.h"
18694 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 18850 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
18695 18851
18696 } // namespace gles2 18852 } // namespace gles2
18697 } // namespace gpu 18853 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/common/gles2_cmd_ids_autogen.h ('k') | gpu/command_buffer/service/gles2_cmd_decoder_autogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698