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

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

Issue 139013008: Implement support for rendering to 32-bit float textures on ES3 (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Make TexSubImage validation agree with TexImage validation Created 6 years, 10 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 <list> 10 #include <list>
(...skipping 8120 matching lines...) Expand 10 before | Expand all | Expand 10 after
8131 "glCompressedTexSubImage2D", "level does not exist."); 8131 "glCompressedTexSubImage2D", "level does not exist.");
8132 return; 8132 return;
8133 } 8133 }
8134 if (internal_format != format) { 8134 if (internal_format != format) {
8135 LOCAL_SET_GL_ERROR( 8135 LOCAL_SET_GL_ERROR(
8136 GL_INVALID_OPERATION, 8136 GL_INVALID_OPERATION,
8137 "glCompressedTexSubImage2D", "format does not match internal format."); 8137 "glCompressedTexSubImage2D", "format does not match internal format.");
8138 return; 8138 return;
8139 } 8139 }
8140 if (!texture->ValidForTexture( 8140 if (!texture->ValidForTexture(
8141 target, level, xoffset, yoffset, width, height, format, type)) { 8141 target, level, xoffset, yoffset, width, height, type)) {
oetuaho-nv 2014/02/13 14:03:58 Comparing with the texture's format here was redun
8142 LOCAL_SET_GL_ERROR( 8142 LOCAL_SET_GL_ERROR(
8143 GL_INVALID_VALUE, "glCompressedTexSubImage2D", "bad dimensions."); 8143 GL_INVALID_VALUE, "glCompressedTexSubImage2D", "bad dimensions.");
8144 return; 8144 return;
8145 } 8145 }
8146 8146
8147 if (!ValidateCompressedTexFuncData( 8147 if (!ValidateCompressedTexFuncData(
8148 "glCompressedTexSubImage2D", width, height, format, image_size) || 8148 "glCompressedTexSubImage2D", width, height, format, image_size) ||
8149 !ValidateCompressedTexSubDimensions( 8149 !ValidateCompressedTexSubDimensions(
8150 "glCompressedTexSubImage2D", 8150 "glCompressedTexSubImage2D",
8151 target, level, xoffset, yoffset, width, height, format, texture)) { 8151 target, level, xoffset, yoffset, width, height, format, texture)) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
8200 if (texture->IsImmutable()) { 8200 if (texture->IsImmutable()) {
8201 LOCAL_SET_GL_ERROR( 8201 LOCAL_SET_GL_ERROR(
8202 GL_INVALID_OPERATION, "glCopyTexImage2D", "texture is immutable"); 8202 GL_INVALID_OPERATION, "glCopyTexImage2D", "texture is immutable");
8203 } 8203 }
8204 if (!texture_manager()->ValidForTarget(target, level, width, height, 1) || 8204 if (!texture_manager()->ValidForTarget(target, level, width, height, 1) ||
8205 border != 0) { 8205 border != 0) {
8206 LOCAL_SET_GL_ERROR( 8206 LOCAL_SET_GL_ERROR(
8207 GL_INVALID_VALUE, "glCopyTexImage2D", "dimensions out of range"); 8207 GL_INVALID_VALUE, "glCopyTexImage2D", "dimensions out of range");
8208 return; 8208 return;
8209 } 8209 }
8210 if (!texture_manager()->ValidateTextureParameters( 8210 if (!texture_manager()->ValidateFormatAndTypeCombination(
8211 state_.GetErrorState(), "glCopyTexImage2D", target, internal_format, 8211 state_.GetErrorState(), "glCopyTexImage2D", internal_format,
8212 GL_UNSIGNED_BYTE, level)) { 8212 GL_UNSIGNED_BYTE)) {
oetuaho-nv 2014/02/13 14:03:58 Here the check for the depth/stencil format was ev
8213 return; 8213 return;
8214 } 8214 }
8215 8215
8216 // Check we have compatible formats. 8216 // Check we have compatible formats.
8217 GLenum read_format = GetBoundReadFrameBufferInternalFormat(); 8217 GLenum read_format = GetBoundReadFrameBufferInternalFormat();
8218 uint32 channels_exist = GLES2Util::GetChannelsForFormat(read_format); 8218 uint32 channels_exist = GLES2Util::GetChannelsForFormat(read_format);
8219 uint32 channels_needed = GLES2Util::GetChannelsForFormat(internal_format); 8219 uint32 channels_needed = GLES2Util::GetChannelsForFormat(internal_format);
8220 8220
8221 if ((channels_needed & channels_exist) != channels_needed) { 8221 if ((channels_needed & channels_exist) != channels_needed) {
8222 LOCAL_SET_GL_ERROR( 8222 LOCAL_SET_GL_ERROR(
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
8315 LOCAL_SET_GL_ERROR( 8315 LOCAL_SET_GL_ERROR(
8316 GL_INVALID_OPERATION, 8316 GL_INVALID_OPERATION,
8317 "glCopyTexSubImage2D", "unknown texture for target"); 8317 "glCopyTexSubImage2D", "unknown texture for target");
8318 return; 8318 return;
8319 } 8319 }
8320 Texture* texture = texture_ref->texture(); 8320 Texture* texture = texture_ref->texture();
8321 GLenum type = 0; 8321 GLenum type = 0;
8322 GLenum format = 0; 8322 GLenum format = 0;
8323 if (!texture->GetLevelType(target, level, &type, &format) || 8323 if (!texture->GetLevelType(target, level, &type, &format) ||
8324 !texture->ValidForTexture( 8324 !texture->ValidForTexture(
8325 target, level, xoffset, yoffset, width, height, format, type)) { 8325 target, level, xoffset, yoffset, width, height, type)) {
8326 LOCAL_SET_GL_ERROR( 8326 LOCAL_SET_GL_ERROR(
8327 GL_INVALID_VALUE, "glCopyTexSubImage2D", "bad dimensions."); 8327 GL_INVALID_VALUE, "glCopyTexSubImage2D", "bad dimensions.");
8328 return; 8328 return;
8329 } 8329 }
8330 if (async_pixel_transfer_manager_->AsyncTransferIsInProgress(texture_ref)) { 8330 if (async_pixel_transfer_manager_->AsyncTransferIsInProgress(texture_ref)) {
8331 LOCAL_SET_GL_ERROR( 8331 LOCAL_SET_GL_ERROR(
8332 GL_INVALID_OPERATION, 8332 GL_INVALID_OPERATION,
8333 "glCopyTexSubImage2D", "async upload pending for texture"); 8333 "glCopyTexSubImage2D", "async upload pending for texture");
8334 return; 8334 return;
8335 } 8335 }
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
8421 return false; 8421 return false;
8422 } 8422 }
8423 if (width < 0) { 8423 if (width < 0) {
8424 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "width < 0"); 8424 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "width < 0");
8425 return false; 8425 return false;
8426 } 8426 }
8427 if (height < 0) { 8427 if (height < 0) {
8428 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "height < 0"); 8428 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "height < 0");
8429 return false; 8429 return false;
8430 } 8430 }
8431 if (!validators_->texture_format.IsValid(format)) {
8432 LOCAL_SET_GL_ERROR_INVALID_ENUM(function_name, format, "format");
8433 return false;
8434 }
8435 if (!validators_->pixel_type.IsValid(type)) {
8436 LOCAL_SET_GL_ERROR_INVALID_ENUM(function_name, type, "type");
8437 return false;
8438 }
8439 TextureRef* texture_ref = texture_manager()->GetTextureInfoForTarget( 8431 TextureRef* texture_ref = texture_manager()->GetTextureInfoForTarget(
8440 &state_, target); 8432 &state_, target);
8441 if (!texture_ref) { 8433 if (!texture_ref) {
8442 LOCAL_SET_GL_ERROR( 8434 LOCAL_SET_GL_ERROR(
8443 GL_INVALID_OPERATION, 8435 GL_INVALID_OPERATION,
8444 function_name, "unknown texture for target"); 8436 function_name, "unknown texture for target");
8445 return false; 8437 return false;
8446 } 8438 }
8447 Texture* texture = texture_ref->texture(); 8439 Texture* texture = texture_ref->texture();
8448 GLenum current_type = 0; 8440 GLenum current_type = 0;
8449 GLenum internal_format = 0; 8441 GLenum internal_format = 0;
8450 if (!texture->GetLevelType(target, level, &current_type, &internal_format)) { 8442 if (!texture->GetLevelType(target, level, &current_type, &internal_format)) {
8451 LOCAL_SET_GL_ERROR( 8443 LOCAL_SET_GL_ERROR(
8452 GL_INVALID_OPERATION, function_name, "level does not exist."); 8444 GL_INVALID_OPERATION, function_name, "level does not exist.");
8453 return false; 8445 return false;
8454 } 8446 }
8455 if (format != internal_format) { 8447 if (!texture_manager()->ValidateTextureParameters(state_.GetErrorState(),
8456 LOCAL_SET_GL_ERROR( 8448 function_name, format, type, internal_format, level)) {
8457 GL_INVALID_OPERATION,
8458 function_name, "format does not match internal format.");
8459 return false; 8449 return false;
8460 } 8450 }
8461 if (type != current_type) { 8451 if (type != current_type) {
8462 LOCAL_SET_GL_ERROR( 8452 LOCAL_SET_GL_ERROR(
8463 GL_INVALID_OPERATION, 8453 GL_INVALID_OPERATION,
8464 function_name, "type does not match type of texture."); 8454 function_name, "type does not match type of texture.");
8465 return false; 8455 return false;
8466 } 8456 }
8467 if (async_pixel_transfer_manager_->AsyncTransferIsInProgress(texture_ref)) { 8457 if (async_pixel_transfer_manager_->AsyncTransferIsInProgress(texture_ref)) {
8468 LOCAL_SET_GL_ERROR( 8458 LOCAL_SET_GL_ERROR(
8469 GL_INVALID_OPERATION, 8459 GL_INVALID_OPERATION,
8470 function_name, "async upload pending for texture"); 8460 function_name, "async upload pending for texture");
8471 return false; 8461 return false;
8472 } 8462 }
8473 if (!texture->ValidForTexture( 8463 if (!texture->ValidForTexture(
8474 target, level, xoffset, yoffset, width, height, format, type)) { 8464 target, level, xoffset, yoffset, width, height, type)) {
8475 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "bad dimensions."); 8465 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "bad dimensions.");
8476 return false; 8466 return false;
8477 } 8467 }
8478 if ((GLES2Util::GetChannelsForFormat(format) & 8468 if ((GLES2Util::GetChannelsForFormat(format) &
8479 (GLES2Util::kDepth | GLES2Util::kStencil)) != 0) { 8469 (GLES2Util::kDepth | GLES2Util::kStencil)) != 0) {
8480 LOCAL_SET_GL_ERROR( 8470 LOCAL_SET_GL_ERROR(
8481 GL_INVALID_OPERATION, 8471 GL_INVALID_OPERATION,
8482 function_name, "can not supply data for depth or stencil textures"); 8472 function_name, "can not supply data for depth or stencil textures");
8483 return false; 8473 return false;
8484 } 8474 }
(...skipping 2041 matching lines...) Expand 10 before | Expand all | Expand 10 after
10526 DoDidUseTexImageIfNeeded(texture, texture->target()); 10516 DoDidUseTexImageIfNeeded(texture, texture->target());
10527 } 10517 }
10528 10518
10529 // Include the auto-generated part of this file. We split this because it means 10519 // Include the auto-generated part of this file. We split this because it means
10530 // we can easily edit the non-auto generated parts right here in this file 10520 // we can easily edit the non-auto generated parts right here in this file
10531 // instead of having to edit some template or the code generator. 10521 // instead of having to edit some template or the code generator.
10532 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 10522 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
10533 10523
10534 } // namespace gles2 10524 } // namespace gles2
10535 } // namespace gpu 10525 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/framebuffer_manager_unittest.cc ('k') | gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698