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(
void GLES2DecoderPassthroughImpl::UpdateTextureSizeFromTarget(GLenum target) {
GLenum texture_type = TextureTargetToTextureType(target);
TextureTarget internal_texture_type = GLenumToTextureTarget(texture_type);
if (internal_texture_type == TextureTarget::kUnkown) {
return;
}
DCHECK(internal_texture_type != TextureTarget::kUnkown);
BoundTexture& bound_texture =
bound_textures_[static_cast<size_t>(internal_texture_type)]
[active_texture_unit_];
......@@ -2324,6 +2322,7 @@ error::Error GLES2DecoderPassthroughImpl::BindTexImage2DCHROMIUMImpl(
}
}
// Target is already validated
UpdateTextureSizeFromTarget(target);
DCHECK(bound_texture.texture != nullptr);
......
......@@ -694,9 +694,13 @@ error::Error GLES2DecoderPassthroughImpl::DoCompressedTexImage2D(
GLsizei image_size,
GLsizei data_size,
const void* data) {
CheckErrorCallbackState();
api()->glCompressedTexImage2DRobustANGLEFn(target, level, internalformat,
width, height, border, image_size,
data_size, data);
if (CheckErrorCallbackState()) {
return error::kNoError;
}
UpdateTextureSizeFromTarget(target);
......@@ -740,9 +744,13 @@ error::Error GLES2DecoderPassthroughImpl::DoCompressedTexImage3D(
GLsizei image_size,
GLsizei data_size,
const void* data) {
CheckErrorCallbackState();
api()->glCompressedTexImage3DRobustANGLEFn(target, level, internalformat,
width, height, depth, border,
image_size, data_size, data);
if (CheckErrorCallbackState()) {
return error::kNoError;
}
UpdateTextureSizeFromTarget(target);
......@@ -797,8 +805,12 @@ error::Error GLES2DecoderPassthroughImpl::DoCopyTexImage2D(
GLsizei width,
GLsizei height,
GLint border) {
CheckErrorCallbackState();
api()->glCopyTexImage2DFn(target, level, internalformat, x, y, width, height,
border);
if (CheckErrorCallbackState()) {
return error::kNoError;
}
UpdateTextureSizeFromTarget(target);
......@@ -2398,8 +2410,13 @@ error::Error GLES2DecoderPassthroughImpl::DoTexImage2D(GLenum target,
const void* pixels) {
ScopedUnpackStateButAlignmentReset reset_unpack(
api(), image_size != 0 && feature_info_->gl_version_info().is_es3, false);
CheckErrorCallbackState();
api()->glTexImage2DRobustANGLEFn(target, level, internalformat, width, height,
border, format, type, image_size, pixels);
if (CheckErrorCallbackState()) {
return error::kNoError;
}
UpdateTextureSizeFromTarget(target);
......@@ -2423,9 +2440,14 @@ error::Error GLES2DecoderPassthroughImpl::DoTexImage3D(GLenum target,
const void* pixels) {
ScopedUnpackStateButAlignmentReset reset_unpack(
api(), image_size != 0 && feature_info_->gl_version_info().is_es3, true);
CheckErrorCallbackState();
api()->glTexImage3DRobustANGLEFn(target, level, internalformat, width, height,
depth, border, format, type, image_size,
pixels);
if (CheckErrorCallbackState()) {
return error::kNoError;
}
UpdateTextureSizeFromTarget(target);
......@@ -2478,7 +2500,12 @@ error::Error GLES2DecoderPassthroughImpl::DoTexStorage3D(GLenum target,
GLsizei width,
GLsizei height,
GLsizei depth) {
CheckErrorCallbackState();
api()->glTexStorage3DFn(target, levels, internalFormat, width, height, depth);
if (CheckErrorCallbackState()) {
return error::kNoError;
}
UpdateTextureSizeFromTarget(target);
return error::kNoError;
}
......@@ -3021,7 +3048,11 @@ error::Error GLES2DecoderPassthroughImpl::DoTexStorage2DEXT(
GLenum internalFormat,
GLsizei width,
GLsizei height) {
CheckErrorCallbackState();
api()->glTexStorage2DEXTFn(target, levels, internalFormat, width, height);
if (CheckErrorCallbackState()) {
return error::kNoError;
}
UpdateTextureSizeFromTarget(target);
return error::kNoError;
}
......@@ -4184,6 +4215,7 @@ error::Error GLES2DecoderPassthroughImpl::DoReleaseTexImage2DCHROMIUM(
bound_texture.texture->SetLevelImage(target, 0, nullptr);
}
// Target is already validated
UpdateTextureSizeFromTarget(target);
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