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

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

Issue 2190543005: Command buffer: feedback loop detection for CopyTexSubImage3D (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix bot failure: split tests, previous calls to CopyTexSubImage3D may make framebuffer incomplete 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) 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 1335 matching lines...) Expand 10 before | Expand all | Expand 10 after
1346 void RestoreClearState(); 1346 void RestoreClearState();
1347 1347
1348 // Remembers the state of some capabilities. 1348 // Remembers the state of some capabilities.
1349 // Returns: true if glEnable/glDisable should actually be called. 1349 // Returns: true if glEnable/glDisable should actually be called.
1350 bool SetCapabilityState(GLenum cap, bool enabled); 1350 bool SetCapabilityState(GLenum cap, bool enabled);
1351 1351
1352 // Infer color encoding from internalformat 1352 // Infer color encoding from internalformat
1353 static GLint GetColorEncodingFromInternalFormat(GLenum internalformat); 1353 static GLint GetColorEncodingFromInternalFormat(GLenum internalformat);
1354 1354
1355 // Check that the currently bound read framebuffer's color image 1355 // Check that the currently bound read framebuffer's color image
1356 // isn't the target texture of the glCopyTex{Sub}Image2D. 1356 // isn't the target texture of the glCopyTex{Sub}Image{2D|3D}.
1357 bool FormsTextureCopyingFeedbackLoop(TextureRef* texture, GLint level); 1357 bool FormsTextureCopyingFeedbackLoop(
1358 TextureRef* texture,
1359 GLint level,
1360 GLint layer);
1358 1361
1359 // Check if a framebuffer meets our requirements. 1362 // Check if a framebuffer meets our requirements.
1360 // Generates |gl_error| if the framebuffer is incomplete. 1363 // Generates |gl_error| if the framebuffer is incomplete.
1361 bool CheckFramebufferValid( 1364 bool CheckFramebufferValid(
1362 Framebuffer* framebuffer, 1365 Framebuffer* framebuffer,
1363 GLenum target, 1366 GLenum target,
1364 GLenum gl_error, 1367 GLenum gl_error,
1365 const char* func_name); 1368 const char* func_name);
1366 1369
1367 bool CheckBoundDrawFramebufferValid(const char* func_name); 1370 bool CheckBoundDrawFramebufferValid(const char* func_name);
(...skipping 2912 matching lines...) Expand 10 before | Expand all | Expand 10 after
4280 case GL_SRGB_ALPHA_EXT: 4283 case GL_SRGB_ALPHA_EXT:
4281 case GL_SRGB8: 4284 case GL_SRGB8:
4282 case GL_SRGB8_ALPHA8: 4285 case GL_SRGB8_ALPHA8:
4283 return GL_SRGB; 4286 return GL_SRGB;
4284 default: 4287 default:
4285 return GL_LINEAR; 4288 return GL_LINEAR;
4286 } 4289 }
4287 } 4290 }
4288 4291
4289 bool GLES2DecoderImpl::FormsTextureCopyingFeedbackLoop( 4292 bool GLES2DecoderImpl::FormsTextureCopyingFeedbackLoop(
4290 TextureRef* texture, GLint level) { 4293 TextureRef* texture, GLint level, GLint layer) {
4291 Framebuffer* framebuffer = features().chromium_framebuffer_multisample ? 4294 Framebuffer* framebuffer = features().chromium_framebuffer_multisample ?
4292 framebuffer_state_.bound_read_framebuffer.get() : 4295 framebuffer_state_.bound_read_framebuffer.get() :
4293 framebuffer_state_.bound_draw_framebuffer.get(); 4296 framebuffer_state_.bound_draw_framebuffer.get();
4294 if (!framebuffer) 4297 if (!framebuffer)
4295 return false; 4298 return false;
4296 const Framebuffer::Attachment* attachment = framebuffer->GetAttachment( 4299 const Framebuffer::Attachment* attachment =
4297 GL_COLOR_ATTACHMENT0); 4300 framebuffer->GetReadBufferAttachment();
4298 if (!attachment) 4301 if (!attachment)
4299 return false; 4302 return false;
4300 return attachment->FormsFeedbackLoop(texture, level); 4303 return attachment->FormsFeedbackLoop(texture, level, layer);
4301 } 4304 }
4302 4305
4303 gfx::Size GLES2DecoderImpl::GetBoundReadFrameBufferSize() { 4306 gfx::Size GLES2DecoderImpl::GetBoundReadFrameBufferSize() {
4304 Framebuffer* framebuffer = 4307 Framebuffer* framebuffer =
4305 GetFramebufferInfoForTarget(GL_READ_FRAMEBUFFER_EXT); 4308 GetFramebufferInfoForTarget(GL_READ_FRAMEBUFFER_EXT);
4306 if (framebuffer != NULL) { 4309 if (framebuffer != NULL) {
4307 const Framebuffer::Attachment* attachment = 4310 const Framebuffer::Attachment* attachment =
4308 framebuffer->GetReadBufferAttachment(); 4311 framebuffer->GetReadBufferAttachment();
4309 if (attachment) { 4312 if (attachment) {
4310 return gfx::Size(attachment->width(), attachment->height()); 4313 return gfx::Size(attachment->width(), attachment->height());
(...skipping 8694 matching lines...) Expand 10 before | Expand all | Expand 10 after
13005 state_.unpack_alignment, &pixels_size, NULL, NULL)) { 13008 state_.unpack_alignment, &pixels_size, NULL, NULL)) {
13006 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, func_name, "dimensions too large"); 13009 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, func_name, "dimensions too large");
13007 return; 13010 return;
13008 } 13011 }
13009 13012
13010 if (!EnsureGPUMemoryAvailable(pixels_size)) { 13013 if (!EnsureGPUMemoryAvailable(pixels_size)) {
13011 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, func_name, "out of memory"); 13014 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, func_name, "out of memory");
13012 return; 13015 return;
13013 } 13016 }
13014 13017
13015 if (FormsTextureCopyingFeedbackLoop(texture_ref, level)) { 13018 if (FormsTextureCopyingFeedbackLoop(texture_ref, level, 0)) {
13016 LOCAL_SET_GL_ERROR( 13019 LOCAL_SET_GL_ERROR(
13017 GL_INVALID_OPERATION, 13020 GL_INVALID_OPERATION,
13018 func_name, "source and destination textures are the same"); 13021 func_name, "source and destination textures are the same");
13019 return; 13022 return;
13020 } 13023 }
13021 13024
13022 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(func_name); 13025 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(func_name);
13023 ScopedResolvedFrameBufferBinder binder(this, false, true); 13026 ScopedResolvedFrameBufferBinder binder(this, false, true);
13024 gfx::Size size = GetBoundReadFrameBufferSize(); 13027 gfx::Size size = GetBoundReadFrameBufferSize();
13025 13028
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
13179 return; 13182 return;
13180 } 13183 }
13181 13184
13182 GLenum read_format = GetBoundReadFrameBufferInternalFormat(); 13185 GLenum read_format = GetBoundReadFrameBufferInternalFormat();
13183 GLenum read_type = GetBoundReadFrameBufferTextureType(); 13186 GLenum read_type = GetBoundReadFrameBufferTextureType();
13184 if (!ValidateCopyTexFormat(func_name, internal_format, 13187 if (!ValidateCopyTexFormat(func_name, internal_format,
13185 read_format, read_type)) { 13188 read_format, read_type)) {
13186 return; 13189 return;
13187 } 13190 }
13188 13191
13189 if (FormsTextureCopyingFeedbackLoop(texture_ref, level)) { 13192 if (FormsTextureCopyingFeedbackLoop(texture_ref, level, 0)) {
13190 LOCAL_SET_GL_ERROR( 13193 LOCAL_SET_GL_ERROR(
13191 GL_INVALID_OPERATION, 13194 GL_INVALID_OPERATION,
13192 func_name, "source and destination textures are the same"); 13195 func_name, "source and destination textures are the same");
13193 return; 13196 return;
13194 } 13197 }
13195 13198
13196 ScopedResolvedFrameBufferBinder binder(this, false, true); 13199 ScopedResolvedFrameBufferBinder binder(this, false, true);
13197 gfx::Size size = GetBoundReadFrameBufferSize(); 13200 gfx::Size size = GetBoundReadFrameBufferSize();
13198 GLint copyX = 0; 13201 GLint copyX = 0;
13199 GLint copyY = 0; 13202 GLint copyY = 0;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
13286 return; 13289 return;
13287 } 13290 }
13288 13291
13289 GLenum read_format = GetBoundReadFrameBufferInternalFormat(); 13292 GLenum read_format = GetBoundReadFrameBufferInternalFormat();
13290 GLenum read_type = GetBoundReadFrameBufferTextureType(); 13293 GLenum read_type = GetBoundReadFrameBufferTextureType();
13291 if (!ValidateCopyTexFormat(func_name, internal_format, 13294 if (!ValidateCopyTexFormat(func_name, internal_format,
13292 read_format, read_type)) { 13295 read_format, read_type)) {
13293 return; 13296 return;
13294 } 13297 }
13295 13298
13296 // TODO(yunchao): Follow-up CLs are necessary. For instance, feedback loop 13299 if (FormsTextureCopyingFeedbackLoop(texture_ref, level, zoffset)) {
13297 // detection, emulation of unsized formats in core profile, clear the 3d 13300 LOCAL_SET_GL_ERROR(
13298 // textures if it is uncleared, out-of-bounds reading, etc. 13301 GL_INVALID_OPERATION,
13302 func_name, "source and destination textures are the same");
13303 return;
13304 }
13305
13306 // TODO(yunchao): Follow-up CLs are necessary. For instance:
13307 // 1. emulation of unsized formats in core profile
13308 // 2. clear the 3d textures if it is uncleared.
13309 // 3. out-of-bounds reading, etc.
13299 13310
13300 glCopyTexSubImage3D(target, level, xoffset, yoffset, zoffset, x, y, width, 13311 glCopyTexSubImage3D(target, level, xoffset, yoffset, zoffset, x, y, width,
13301 height); 13312 height);
13302 13313
13303 // This may be a slow command. Exit command processing to allow for 13314 // This may be a slow command. Exit command processing to allow for
13304 // context preemption and GPU watchdog checks. 13315 // context preemption and GPU watchdog checks.
13305 ExitCommandProcessingEarly(); 13316 ExitCommandProcessingEarly();
13306 } 13317 }
13307 13318
13308 error::Error GLES2DecoderImpl::HandleTexSubImage2D(uint32_t immediate_data_size, 13319 error::Error GLES2DecoderImpl::HandleTexSubImage2D(uint32_t immediate_data_size,
(...skipping 4444 matching lines...) Expand 10 before | Expand all | Expand 10 after
17753 } 17764 }
17754 17765
17755 // Include the auto-generated part of this file. We split this because it means 17766 // Include the auto-generated part of this file. We split this because it means
17756 // we can easily edit the non-auto generated parts right here in this file 17767 // we can easily edit the non-auto generated parts right here in this file
17757 // instead of having to edit some template or the code generator. 17768 // instead of having to edit some template or the code generator.
17758 #include "base/macros.h" 17769 #include "base/macros.h"
17759 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 17770 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
17760 17771
17761 } // namespace gles2 17772 } // namespace gles2
17762 } // namespace gpu 17773 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/framebuffer_manager.cc ('k') | gpu/command_buffer/service/gles2_cmd_decoder_unittest_textures.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698