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

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

Issue 1403483002: Update CopyTexImage2D to do internal format validation in ES3 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove unused function Created 5 years, 2 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 <stdio.h> 7 #include <stdio.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
(...skipping 1549 matching lines...) Expand 10 before | Expand all | Expand 10 after
1560 bool SetCapabilityState(GLenum cap, bool enabled); 1560 bool SetCapabilityState(GLenum cap, bool enabled);
1561 1561
1562 // Check that the currently bound framebuffers are valid. 1562 // Check that the currently bound framebuffers are valid.
1563 // Generates GL error if not. 1563 // Generates GL error if not.
1564 bool CheckBoundFramebuffersValid(const char* func_name); 1564 bool CheckBoundFramebuffersValid(const char* func_name);
1565 1565
1566 // Check that the currently bound read framebuffer has a color image 1566 // Check that the currently bound read framebuffer has a color image
1567 // attached. Generates GL error if not. 1567 // attached. Generates GL error if not.
1568 bool CheckBoundReadFramebufferColorAttachment(const char* func_name); 1568 bool CheckBoundReadFramebufferColorAttachment(const char* func_name);
1569 1569
1570 // Infer color encoding from internalformat
1571 static GLint GetColorEncodingFromInternalFormat(GLenum internalformat);
1572
1570 // Check that the currently bound read framebuffer's color image 1573 // Check that the currently bound read framebuffer's color image
1571 // isn't the target texture of the glCopyTex{Sub}Image2D. 1574 // isn't the target texture of the glCopyTex{Sub}Image2D.
1572 bool FormsTextureCopyingFeedbackLoop(TextureRef* texture, GLint level); 1575 bool FormsTextureCopyingFeedbackLoop(TextureRef* texture, GLint level);
1573 1576
1574 // Check if a framebuffer meets our requirements. 1577 // Check if a framebuffer meets our requirements.
1575 bool CheckFramebufferValid( 1578 bool CheckFramebufferValid(
1576 Framebuffer* framebuffer, 1579 Framebuffer* framebuffer,
1577 GLenum target, 1580 GLenum target,
1578 const char* func_name); 1581 const char* func_name);
1579 1582
(...skipping 2432 matching lines...) Expand 10 before | Expand all | Expand 10 after
4012 if (!framebuffer) 4015 if (!framebuffer)
4013 return true; 4016 return true;
4014 if (framebuffer->GetAttachment(GL_COLOR_ATTACHMENT0) == NULL) { 4017 if (framebuffer->GetAttachment(GL_COLOR_ATTACHMENT0) == NULL) {
4015 LOCAL_SET_GL_ERROR( 4018 LOCAL_SET_GL_ERROR(
4016 GL_INVALID_OPERATION, func_name, "no color image attached"); 4019 GL_INVALID_OPERATION, func_name, "no color image attached");
4017 return false; 4020 return false;
4018 } 4021 }
4019 return true; 4022 return true;
4020 } 4023 }
4021 4024
4025 GLint GLES2DecoderImpl::GetColorEncodingFromInternalFormat(
4026 GLenum internalformat) {
4027 switch (internalformat) {
4028 case GL_SRGB_EXT:
4029 case GL_SRGB_ALPHA_EXT:
4030 case GL_SRGB8:
4031 case GL_SRGB8_ALPHA8:
4032 return GL_SRGB;
4033 default:
4034 return GL_LINEAR;
4035 }
4036 }
4037
4022 bool GLES2DecoderImpl::FormsTextureCopyingFeedbackLoop( 4038 bool GLES2DecoderImpl::FormsTextureCopyingFeedbackLoop(
4023 TextureRef* texture, GLint level) { 4039 TextureRef* texture, GLint level) {
4024 Framebuffer* framebuffer = features().chromium_framebuffer_multisample ? 4040 Framebuffer* framebuffer = features().chromium_framebuffer_multisample ?
4025 framebuffer_state_.bound_read_framebuffer.get() : 4041 framebuffer_state_.bound_read_framebuffer.get() :
4026 framebuffer_state_.bound_draw_framebuffer.get(); 4042 framebuffer_state_.bound_draw_framebuffer.get();
4027 if (!framebuffer) 4043 if (!framebuffer)
4028 return false; 4044 return false;
4029 const Framebuffer::Attachment* attachment = framebuffer->GetAttachment( 4045 const Framebuffer::Attachment* attachment = framebuffer->GetAttachment(
4030 GL_COLOR_ATTACHMENT0); 4046 GL_COLOR_ATTACHMENT0);
4031 if (!attachment) 4047 if (!attachment)
(...skipping 6964 matching lines...) Expand 10 before | Expand all | Expand 10 after
10996 GLenum read_format = GetBoundReadFrameBufferInternalFormat(); 11012 GLenum read_format = GetBoundReadFrameBufferInternalFormat();
10997 uint32 channels_exist = GLES2Util::GetChannelsForFormat(read_format); 11013 uint32 channels_exist = GLES2Util::GetChannelsForFormat(read_format);
10998 uint32 channels_needed = GLES2Util::GetChannelsForFormat(internal_format); 11014 uint32 channels_needed = GLES2Util::GetChannelsForFormat(internal_format);
10999 11015
11000 if ((channels_needed & channels_exist) != channels_needed) { 11016 if ((channels_needed & channels_exist) != channels_needed) {
11001 LOCAL_SET_GL_ERROR( 11017 LOCAL_SET_GL_ERROR(
11002 GL_INVALID_OPERATION, "glCopyTexImage2D", "incompatible format"); 11018 GL_INVALID_OPERATION, "glCopyTexImage2D", "incompatible format");
11003 return; 11019 return;
11004 } 11020 }
11005 11021
11022 if (feature_info_->IsES3Enabled()) {
11023 GLint color_encoding = GetColorEncodingFromInternalFormat(read_format);
11024 if (color_encoding != GetColorEncodingFromInternalFormat(internal_format) ||
11025 GLES2Util::IsFloatFormat(internal_format) ||
11026 (GLES2Util::IsSignedIntegerFormat(internal_format) !=
11027 GLES2Util::IsSignedIntegerFormat(read_format)) ||
11028 (GLES2Util::IsUnsignedIntegerFormat(internal_format) !=
11029 GLES2Util::IsUnsignedIntegerFormat(read_format))) {
11030 LOCAL_SET_GL_ERROR(
11031 GL_INVALID_OPERATION, "glCopyTexImage2D", "incompatible format");
11032 return;
11033 }
11034 }
11035
11006 if ((channels_needed & (GLES2Util::kDepth | GLES2Util::kStencil)) != 0) { 11036 if ((channels_needed & (GLES2Util::kDepth | GLES2Util::kStencil)) != 0) {
11007 LOCAL_SET_GL_ERROR( 11037 LOCAL_SET_GL_ERROR(
11008 GL_INVALID_OPERATION, 11038 GL_INVALID_OPERATION,
11009 "glCopyTexImage2D", "can not be used with depth or stencil textures"); 11039 "glCopyTexImage2D", "can not be used with depth or stencil textures");
11010 return; 11040 return;
11011 } 11041 }
11012 11042
11013 uint32 pixels_size = 0; 11043 uint32 pixels_size = 0;
11014 GLenum format = ExtractFormatFromStorageFormat(internal_format); 11044 GLenum format = ExtractFormatFromStorageFormat(internal_format);
11015 GLenum type = ExtractTypeFromStorageFormat(internal_format); 11045 GLenum type = ExtractTypeFromStorageFormat(internal_format);
(...skipping 4050 matching lines...) Expand 10 before | Expand all | Expand 10 after
15066 return error::kNoError; 15096 return error::kNoError;
15067 } 15097 }
15068 15098
15069 // Include the auto-generated part of this file. We split this because it means 15099 // Include the auto-generated part of this file. We split this because it means
15070 // we can easily edit the non-auto generated parts right here in this file 15100 // we can easily edit the non-auto generated parts right here in this file
15071 // instead of having to edit some template or the code generator. 15101 // instead of having to edit some template or the code generator.
15072 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 15102 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
15073 15103
15074 } // namespace gles2 15104 } // namespace gles2
15075 } // namespace gpu 15105 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/common/gles2_cmd_utils.cc ('k') | gpu/command_buffer/service/gles2_cmd_decoder_unittest_framebuffers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698