Commit e1fe4245 authored by Jonathan Backer's avatar Jonathan Backer Committed by Commit Bot

Check sized internal format

Check if sized internal format is supported before making the
glTexStorage2DEXT call. This was called by autogen code for GLES2Decoder
and was not ported over to RasterDecoder.

Also remove some dead autogen code that is not compiled in anywhere.

Bug: 862376
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel
Change-Id: I116aa08ac6d381c95650ab8fad9d984ea19af109
Reviewed-on: https://chromium-review.googlesource.com/1140358
Commit-Queue: Jonathan Backer <backer@chromium.org>
Reviewed-by: default avatarAntoine Labour <piman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#576498}
parent e1bfc30e
...@@ -2425,11 +2425,18 @@ bool RasterDecoderImpl::TexStorage2D(gles2::TextureRef* texture_ref, ...@@ -2425,11 +2425,18 @@ bool RasterDecoderImpl::TexStorage2D(gles2::TextureRef* texture_ref,
return false; return false;
} }
unsigned int internal_format =
viz::TextureStorageFormat(texture_metadata.format());
if (!feature_info_->validators()->texture_internal_format_storage.IsValid(
internal_format)) {
LOCAL_SET_GL_ERROR_INVALID_ENUM("glTexStorage2D", internal_format,
"internal_format");
return error::kNoError;
}
ScopedTextureBinder binder(&state_, texture_manager(), texture_ref, ScopedTextureBinder binder(&state_, texture_manager(), texture_ref,
texture_metadata.target(), gr_context()); texture_metadata.target(), gr_context());
unsigned int internal_format =
viz::TextureStorageFormat(texture_metadata.format());
GLenum format = GLenum format =
gles2::TextureManager::ExtractFormatFromStorageFormat(internal_format); gles2::TextureManager::ExtractFormatFromStorageFormat(internal_format);
GLenum type = GLenum type =
......
...@@ -486,6 +486,29 @@ TEST_P(RasterDecoderManualInitTest, CopyTexSubImage2DValidateColorFormat) { ...@@ -486,6 +486,29 @@ TEST_P(RasterDecoderManualInitTest, CopyTexSubImage2DValidateColorFormat) {
EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
} }
TEST_P(RasterDecoderManualInitTest, TexStorage2DValidateColorFormat) {
// GL_EXT_texture_norm16 disabled by default, so glTexStorage2DEXT with
// viz::ResourceFormat::R16_EXT fails validation.
InitState init;
init.extensions.push_back("GL_EXT_texture_storage");
InitDecoder(init);
GLuint texture_id = kNewClientId;
EXPECT_CALL(*gl_, GenTextures(1, _))
.WillOnce(SetArgPointee<1>(kNewServiceId))
.RetiresOnSaturation();
cmds::CreateTexture create_cmd;
create_cmd.Init(false /* use_buffer */, gfx::BufferUsage::GPU_READ,
viz::ResourceFormat::R16_EXT, texture_id);
EXPECT_EQ(error::kNoError, ExecuteCmd(create_cmd));
cmds::TexStorage2D storage_cmd;
storage_cmd.Init(texture_id, /*width=*/2, /*height=*/2);
EXPECT_EQ(error::kNoError, ExecuteCmd(storage_cmd));
EXPECT_EQ(GL_INVALID_ENUM, GetGLError());
}
TEST_P(RasterDecoderTest, GLImageAttachedAfterClearLevel) { TEST_P(RasterDecoderTest, GLImageAttachedAfterClearLevel) {
scoped_refptr<gl::GLImage> image(new gl::GLImageStub); scoped_refptr<gl::GLImage> image(new gl::GLImageStub);
GetImageManagerForTest()->AddImage(image.get(), kImageId); GetImageManagerForTest()->AddImage(image.get(), kImageId);
......
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