| Index: gpu/command_buffer/service/texture_manager.cc
|
| diff --git a/gpu/command_buffer/service/texture_manager.cc b/gpu/command_buffer/service/texture_manager.cc
|
| index 72d3b4c9681a51c7830d1dc3f1d303298889618a..a0a60c130983f9df9d53b1570312cdf003fa4991 100644
|
| --- a/gpu/command_buffer/service/texture_manager.cc
|
| +++ b/gpu/command_buffer/service/texture_manager.cc
|
| @@ -517,7 +517,6 @@ bool Texture::ValidForTexture(
|
| GLint yoffset,
|
| GLsizei width,
|
| GLsizei height,
|
| - GLenum format,
|
| GLenum type) const {
|
| size_t face_index = GLTargetToFaceIndex(target);
|
| if (level >= 0 && face_index < level_infos_.size() &&
|
| @@ -531,7 +530,6 @@ bool Texture::ValidForTexture(
|
| yoffset >= 0 &&
|
| right <= info.width &&
|
| top <= info.height &&
|
| - format == info.internal_format &&
|
| type == info.type;
|
| }
|
| return false;
|
| @@ -1259,20 +1257,10 @@ void TextureManager::IncFramebufferStateChangeCount() {
|
| framebuffer_manager_->IncFramebufferStateChangeCount();
|
| }
|
|
|
| -bool TextureManager::ValidateTextureParameters(
|
| - ErrorState* error_state, const char* function_name,
|
| - GLenum target, GLenum format, GLenum type, GLint level) {
|
| +bool TextureManager::ValidateFormatAndTypeCombination(
|
| + ErrorState* error_state, const char* function_name, GLenum format,
|
| + GLenum type) {
|
| if (!feature_info_->GetTextureFormatValidator(format).IsValid(type)) {
|
| - ERRORSTATE_SET_GL_ERROR(
|
| - error_state, GL_INVALID_OPERATION, function_name,
|
| - (std::string("invalid type ") +
|
| - GLES2Util::GetStringEnum(type) + " for format " +
|
| - GLES2Util::GetStringEnum(format)).c_str());
|
| - return false;
|
| - }
|
| -
|
| - uint32 channels = GLES2Util::GetChannelsForFormat(format);
|
| - if ((channels & (GLES2Util::kDepth | GLES2Util::kStencil)) != 0 && level) {
|
| ERRORSTATE_SET_GL_ERROR(
|
| error_state, GL_INVALID_OPERATION, function_name,
|
| (std::string("invalid type ") +
|
| @@ -1283,6 +1271,40 @@ bool TextureManager::ValidateTextureParameters(
|
| return true;
|
| }
|
|
|
| +bool TextureManager::ValidateTextureParameters(
|
| + ErrorState* error_state, const char* function_name,
|
| + GLenum format, GLenum type, GLenum internal_format, GLint level) {
|
| + const Validators* validators = feature_info_->validators();
|
| + if (!validators->texture_format.IsValid(format)) {
|
| + ERRORSTATE_SET_GL_ERROR_INVALID_ENUM(
|
| + error_state, function_name, format, "format");
|
| + return false;
|
| + }
|
| + if (!validators->pixel_type.IsValid(type)) {
|
| + ERRORSTATE_SET_GL_ERROR_INVALID_ENUM(
|
| + error_state, function_name, type, "type");
|
| + return false;
|
| + }
|
| + if (format != internal_format &&
|
| + !((internal_format == GL_RGBA32F && format == GL_RGBA) ||
|
| + (internal_format == GL_RGB32F && format == GL_RGB))) {
|
| + ERRORSTATE_SET_GL_ERROR(
|
| + error_state, GL_INVALID_OPERATION, function_name,
|
| + "format != internalformat");
|
| + return false;
|
| + }
|
| + uint32 channels = GLES2Util::GetChannelsForFormat(format);
|
| + if ((channels & (GLES2Util::kDepth | GLES2Util::kStencil)) != 0 && level) {
|
| + ERRORSTATE_SET_GL_ERROR(
|
| + error_state, GL_INVALID_OPERATION, function_name,
|
| + (std::string("invalid format ") + GLES2Util::GetStringEnum(format) +
|
| + " for level != 0").c_str());
|
| + return false;
|
| + }
|
| + return ValidateFormatAndTypeCombination(error_state, function_name,
|
| + format, type);
|
| +}
|
| +
|
| // Gets the texture id for a given target.
|
| TextureRef* TextureManager::GetTextureInfoForTarget(
|
| ContextState* state, GLenum target) {
|
| @@ -1336,31 +1358,15 @@ bool TextureManager::ValidateTexImage2D(
|
| error_state, function_name, args.target, "target");
|
| return false;
|
| }
|
| - if (!validators->texture_format.IsValid(args.internal_format)) {
|
| + if (!validators->texture_internal_format.IsValid(args.internal_format)) {
|
| ERRORSTATE_SET_GL_ERROR_INVALID_ENUM(
|
| error_state, function_name, args.internal_format,
|
| - "internal_format");
|
| - return false;
|
| - }
|
| - if (!validators->texture_format.IsValid(args.format)) {
|
| - ERRORSTATE_SET_GL_ERROR_INVALID_ENUM(
|
| - error_state, function_name, args.format, "format");
|
| - return false;
|
| - }
|
| - if (!validators->pixel_type.IsValid(args.type)) {
|
| - ERRORSTATE_SET_GL_ERROR_INVALID_ENUM(
|
| - error_state, function_name, args.type, "type");
|
| - return false;
|
| - }
|
| - if (args.format != args.internal_format) {
|
| - ERRORSTATE_SET_GL_ERROR(
|
| - error_state, GL_INVALID_OPERATION, function_name,
|
| - "format != internalFormat");
|
| + "internalformat");
|
| return false;
|
| }
|
| if (!ValidateTextureParameters(
|
| - error_state, function_name, args.target, args.format, args.type,
|
| - args.level)) {
|
| + error_state, function_name, args.format, args.type,
|
| + args.internal_format, args.level)) {
|
| return false;
|
| }
|
| if (!ValidForTarget(args.target, args.level, args.width, args.height, 1) ||
|
| @@ -1396,7 +1402,7 @@ bool TextureManager::ValidateTexImage2D(
|
| // They both use the same MemoryTracker, and this call just re-routes
|
| // to it.
|
| if (!memory_tracker_managed_->EnsureGPUMemoryAvailable(args.pixels_size)) {
|
| - ERRORSTATE_SET_GL_ERROR(error_state, GL_OUT_OF_MEMORY, "glTexImage2D",
|
| + ERRORSTATE_SET_GL_ERROR(error_state, GL_OUT_OF_MEMORY, function_name,
|
| "out of memory");
|
| return false;
|
| }
|
|
|