Commit 171769f6 authored by Geoff Lang's avatar Geoff Lang Committed by Commit Bot

Validate texture target before updating texture size.

The target was validated that it was one of the TextureTarget types but
not that the type was valid for the current context.  This generated GL
errors when querying the size of a 3D texture in an ES2 context.

BUG=897453
BUG=892288

Change-Id: Ia6cafaf021751876148acdaf0ee96dc51353e98a
Reviewed-on: https://chromium-review.googlesource.com/c/1293754Reviewed-by: default avatarAntoine Labour <piman@chromium.org>
Commit-Queue: Geoff Lang <geofflang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#601663}
parent 6a6efca9
...@@ -2273,9 +2273,7 @@ void GLES2DecoderPassthroughImpl::UpdateTextureSizeFromTexturePassthrough( ...@@ -2273,9 +2273,7 @@ void GLES2DecoderPassthroughImpl::UpdateTextureSizeFromTexturePassthrough(
void GLES2DecoderPassthroughImpl::UpdateTextureSizeFromTarget(GLenum target) { void GLES2DecoderPassthroughImpl::UpdateTextureSizeFromTarget(GLenum target) {
GLenum texture_type = TextureTargetToTextureType(target); GLenum texture_type = TextureTargetToTextureType(target);
TextureTarget internal_texture_type = GLenumToTextureTarget(texture_type); TextureTarget internal_texture_type = GLenumToTextureTarget(texture_type);
if (internal_texture_type == TextureTarget::kUnkown) { DCHECK(internal_texture_type != TextureTarget::kUnkown);
return;
}
BoundTexture& bound_texture = BoundTexture& bound_texture =
bound_textures_[static_cast<size_t>(internal_texture_type)] bound_textures_[static_cast<size_t>(internal_texture_type)]
[active_texture_unit_]; [active_texture_unit_];
...@@ -2324,6 +2322,7 @@ error::Error GLES2DecoderPassthroughImpl::BindTexImage2DCHROMIUMImpl( ...@@ -2324,6 +2322,7 @@ error::Error GLES2DecoderPassthroughImpl::BindTexImage2DCHROMIUMImpl(
} }
} }
// Target is already validated
UpdateTextureSizeFromTarget(target); UpdateTextureSizeFromTarget(target);
DCHECK(bound_texture.texture != nullptr); DCHECK(bound_texture.texture != nullptr);
......
...@@ -694,9 +694,13 @@ error::Error GLES2DecoderPassthroughImpl::DoCompressedTexImage2D( ...@@ -694,9 +694,13 @@ error::Error GLES2DecoderPassthroughImpl::DoCompressedTexImage2D(
GLsizei image_size, GLsizei image_size,
GLsizei data_size, GLsizei data_size,
const void* data) { const void* data) {
CheckErrorCallbackState();
api()->glCompressedTexImage2DRobustANGLEFn(target, level, internalformat, api()->glCompressedTexImage2DRobustANGLEFn(target, level, internalformat,
width, height, border, image_size, width, height, border, image_size,
data_size, data); data_size, data);
if (CheckErrorCallbackState()) {
return error::kNoError;
}
UpdateTextureSizeFromTarget(target); UpdateTextureSizeFromTarget(target);
...@@ -740,9 +744,13 @@ error::Error GLES2DecoderPassthroughImpl::DoCompressedTexImage3D( ...@@ -740,9 +744,13 @@ error::Error GLES2DecoderPassthroughImpl::DoCompressedTexImage3D(
GLsizei image_size, GLsizei image_size,
GLsizei data_size, GLsizei data_size,
const void* data) { const void* data) {
CheckErrorCallbackState();
api()->glCompressedTexImage3DRobustANGLEFn(target, level, internalformat, api()->glCompressedTexImage3DRobustANGLEFn(target, level, internalformat,
width, height, depth, border, width, height, depth, border,
image_size, data_size, data); image_size, data_size, data);
if (CheckErrorCallbackState()) {
return error::kNoError;
}
UpdateTextureSizeFromTarget(target); UpdateTextureSizeFromTarget(target);
...@@ -797,8 +805,12 @@ error::Error GLES2DecoderPassthroughImpl::DoCopyTexImage2D( ...@@ -797,8 +805,12 @@ error::Error GLES2DecoderPassthroughImpl::DoCopyTexImage2D(
GLsizei width, GLsizei width,
GLsizei height, GLsizei height,
GLint border) { GLint border) {
CheckErrorCallbackState();
api()->glCopyTexImage2DFn(target, level, internalformat, x, y, width, height, api()->glCopyTexImage2DFn(target, level, internalformat, x, y, width, height,
border); border);
if (CheckErrorCallbackState()) {
return error::kNoError;
}
UpdateTextureSizeFromTarget(target); UpdateTextureSizeFromTarget(target);
...@@ -2398,8 +2410,13 @@ error::Error GLES2DecoderPassthroughImpl::DoTexImage2D(GLenum target, ...@@ -2398,8 +2410,13 @@ error::Error GLES2DecoderPassthroughImpl::DoTexImage2D(GLenum target,
const void* pixels) { const void* pixels) {
ScopedUnpackStateButAlignmentReset reset_unpack( ScopedUnpackStateButAlignmentReset reset_unpack(
api(), image_size != 0 && feature_info_->gl_version_info().is_es3, false); api(), image_size != 0 && feature_info_->gl_version_info().is_es3, false);
CheckErrorCallbackState();
api()->glTexImage2DRobustANGLEFn(target, level, internalformat, width, height, api()->glTexImage2DRobustANGLEFn(target, level, internalformat, width, height,
border, format, type, image_size, pixels); border, format, type, image_size, pixels);
if (CheckErrorCallbackState()) {
return error::kNoError;
}
UpdateTextureSizeFromTarget(target); UpdateTextureSizeFromTarget(target);
...@@ -2423,9 +2440,14 @@ error::Error GLES2DecoderPassthroughImpl::DoTexImage3D(GLenum target, ...@@ -2423,9 +2440,14 @@ error::Error GLES2DecoderPassthroughImpl::DoTexImage3D(GLenum target,
const void* pixels) { const void* pixels) {
ScopedUnpackStateButAlignmentReset reset_unpack( ScopedUnpackStateButAlignmentReset reset_unpack(
api(), image_size != 0 && feature_info_->gl_version_info().is_es3, true); api(), image_size != 0 && feature_info_->gl_version_info().is_es3, true);
CheckErrorCallbackState();
api()->glTexImage3DRobustANGLEFn(target, level, internalformat, width, height, api()->glTexImage3DRobustANGLEFn(target, level, internalformat, width, height,
depth, border, format, type, image_size, depth, border, format, type, image_size,
pixels); pixels);
if (CheckErrorCallbackState()) {
return error::kNoError;
}
UpdateTextureSizeFromTarget(target); UpdateTextureSizeFromTarget(target);
...@@ -2478,7 +2500,12 @@ error::Error GLES2DecoderPassthroughImpl::DoTexStorage3D(GLenum target, ...@@ -2478,7 +2500,12 @@ error::Error GLES2DecoderPassthroughImpl::DoTexStorage3D(GLenum target,
GLsizei width, GLsizei width,
GLsizei height, GLsizei height,
GLsizei depth) { GLsizei depth) {
CheckErrorCallbackState();
api()->glTexStorage3DFn(target, levels, internalFormat, width, height, depth); api()->glTexStorage3DFn(target, levels, internalFormat, width, height, depth);
if (CheckErrorCallbackState()) {
return error::kNoError;
}
UpdateTextureSizeFromTarget(target); UpdateTextureSizeFromTarget(target);
return error::kNoError; return error::kNoError;
} }
...@@ -3021,7 +3048,11 @@ error::Error GLES2DecoderPassthroughImpl::DoTexStorage2DEXT( ...@@ -3021,7 +3048,11 @@ error::Error GLES2DecoderPassthroughImpl::DoTexStorage2DEXT(
GLenum internalFormat, GLenum internalFormat,
GLsizei width, GLsizei width,
GLsizei height) { GLsizei height) {
CheckErrorCallbackState();
api()->glTexStorage2DEXTFn(target, levels, internalFormat, width, height); api()->glTexStorage2DEXTFn(target, levels, internalFormat, width, height);
if (CheckErrorCallbackState()) {
return error::kNoError;
}
UpdateTextureSizeFromTarget(target); UpdateTextureSizeFromTarget(target);
return error::kNoError; return error::kNoError;
} }
...@@ -4184,6 +4215,7 @@ error::Error GLES2DecoderPassthroughImpl::DoReleaseTexImage2DCHROMIUM( ...@@ -4184,6 +4215,7 @@ error::Error GLES2DecoderPassthroughImpl::DoReleaseTexImage2DCHROMIUM(
bound_texture.texture->SetLevelImage(target, 0, nullptr); bound_texture.texture->SetLevelImage(target, 0, nullptr);
} }
// Target is already validated
UpdateTextureSizeFromTarget(target); UpdateTextureSizeFromTarget(target);
return error::kNoError; return error::kNoError;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment