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

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

Issue 2241593003: [Command buffer] CopyTexSubImage3D: emulate unsized format in desktop core profile (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed zmo@'s feedback Created 4 years, 4 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
OLDNEW
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 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_copy_tex_image.h" 5 #include "gpu/command_buffer/service/gles2_cmd_copy_tex_image.h"
6 6
7 #include "gpu/command_buffer/service/texture_manager.h" 7 #include "gpu/command_buffer/service/texture_manager.h"
8 #include "ui/gl/gl_version_info.h" 8 #include "ui/gl/gl_version_info.h"
9 9
10 namespace { 10 namespace {
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 GLuint source_framebuffer, 155 GLuint source_framebuffer,
156 GLenum source_framebuffer_internal_format) { 156 GLenum source_framebuffer_internal_format) {
157 GLenum adjusted_internal_format = 157 GLenum adjusted_internal_format =
158 gles2::TextureManager::AdjustTexInternalFormat(feature_info_.get(), 158 gles2::TextureManager::AdjustTexInternalFormat(feature_info_.get(),
159 internal_format); 159 internal_format);
160 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); 160 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
161 GLenum adjusted_format = gles2::TextureManager::AdjustTexFormat( 161 GLenum adjusted_format = gles2::TextureManager::AdjustTexFormat(
162 feature_info_.get(), internal_format); 162 feature_info_.get(), internal_format);
163 glTexImage2D(dest_target, level, adjusted_internal_format, width, height, 0, 163 glTexImage2D(dest_target, level, adjusted_internal_format, width, height, 0,
164 adjusted_format, luma_type, nullptr); 164 adjusted_format, luma_type, nullptr);
165 DoCopyTexSubImage2DToLUMACompatibilityTexture( 165 DoCopyTexSubImageToLUMACompatibilityTexture(
166 decoder, dest_texture, dest_texture_target, dest_target, luma_format, 166 decoder, dest_texture, dest_texture_target, dest_target, luma_format,
167 luma_type, level, 0, 0, x, y, width, height, source_framebuffer, 167 luma_type, level, 0, 0, 0, x, y, width, height, source_framebuffer,
168 source_framebuffer_internal_format); 168 source_framebuffer_internal_format);
169 } 169 }
170 170
171 void CopyTexImageResourceManager::DoCopyTexSubImage2DToLUMACompatibilityTexture( 171 void CopyTexImageResourceManager::DoCopyTexSubImageToLUMACompatibilityTexture(
172 const gles2::GLES2Decoder* decoder, 172 const gles2::GLES2Decoder* decoder,
173 GLuint dest_texture, 173 GLuint dest_texture,
174 GLenum dest_texture_target, 174 GLenum dest_texture_target,
175 GLenum dest_target, 175 GLenum dest_target,
176 GLenum luma_format, 176 GLenum luma_format,
177 GLenum luma_type, 177 GLenum luma_type,
178 GLint level, 178 GLint level,
179 GLint xoffset, 179 GLint xoffset,
180 GLint yoffset, 180 GLint yoffset,
181 GLint zoffset,
181 GLint x, 182 GLint x,
182 GLint y, 183 GLint y,
183 GLsizei width, 184 GLsizei width,
184 GLsizei height, 185 GLsizei height,
185 GLuint source_framebuffer, 186 GLuint source_framebuffer,
186 GLenum source_framebuffer_internal_format) { 187 GLenum source_framebuffer_internal_format) {
187 DCHECK(initialized_); 188 DCHECK(initialized_);
188 189
189 // Copy the framebuffer to the first scratch texture 190 // Copy the framebuffer to the first scratch texture
190 // TODO(geofflang): This could be optimized further by detecting if the source 191 // TODO(geofflang): This could be optimized further by detecting if the source
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 glDisable(GL_BLEND); 235 glDisable(GL_BLEND);
235 glDisable(GL_DITHER); 236 glDisable(GL_DITHER);
236 237
237 glBindTexture(GL_TEXTURE_2D, scratch_textures_[0]); 238 glBindTexture(GL_TEXTURE_2D, scratch_textures_[0]);
238 glBindVertexArrayOES(vao_); 239 glBindVertexArrayOES(vao_);
239 240
240 glDrawArrays(GL_TRIANGLES, 0, 6); 241 glDrawArrays(GL_TRIANGLES, 0, 6);
241 242
242 // Finally, copy the swizzled texture to the destination texture 243 // Finally, copy the swizzled texture to the destination texture
243 glBindTexture(dest_texture_target, dest_texture); 244 glBindTexture(dest_texture_target, dest_texture);
244 glCopyTexSubImage2D(dest_target, level, xoffset, yoffset, 0, 0, width, 245 if (dest_target == GL_TEXTURE_3D || dest_target == GL_TEXTURE_2D_ARRAY) {
245 height); 246 glCopyTexSubImage3D(dest_target, level, xoffset, yoffset, zoffset,
247 0, 0, width, height);
248 } else {
249 glCopyTexSubImage2D(dest_target, level, xoffset, yoffset,
250 0, 0, width, height);
251 }
246 252
247 // Restore state 253 // Restore state
248 decoder->RestoreAllAttributes(); 254 decoder->RestoreAllAttributes();
249 decoder->RestoreTextureUnitBindings(0); 255 decoder->RestoreTextureUnitBindings(0);
250 decoder->RestoreActiveTexture(); 256 decoder->RestoreActiveTexture();
251 decoder->RestoreProgramBindings(); 257 decoder->RestoreProgramBindings();
252 decoder->RestoreBufferBindings(); 258 decoder->RestoreBufferBindings();
253 decoder->RestoreFramebufferBindings(); 259 decoder->RestoreFramebufferBindings();
254 decoder->RestoreGlobalState(); 260 decoder->RestoreGlobalState();
255 } 261 }
256 262
257 // static 263 // static
258 bool CopyTexImageResourceManager::CopyTexImageRequiresBlit( 264 bool CopyTexImageResourceManager::CopyTexImageRequiresBlit(
259 const gles2::FeatureInfo* feature_info, 265 const gles2::FeatureInfo* feature_info,
260 GLenum dest_texture_format) { 266 GLenum dest_texture_format) {
261 if (feature_info->gl_version_info().is_desktop_core_profile) { 267 if (feature_info->gl_version_info().is_desktop_core_profile) {
262 switch (dest_texture_format) { 268 switch (dest_texture_format) {
263 case GL_LUMINANCE: 269 case GL_LUMINANCE:
264 case GL_ALPHA: 270 case GL_ALPHA:
265 case GL_LUMINANCE_ALPHA: 271 case GL_LUMINANCE_ALPHA:
266 return true; 272 return true;
267 } 273 }
268 } 274 }
269 275
270 return false; 276 return false;
271 } 277 }
272 278
273 } // namespace gpu 279 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_copy_tex_image.h ('k') | gpu/command_buffer/service/gles2_cmd_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698