Path: blob/main_old/src/tests/gl_tests/DXT1CompressedTextureTest.cpp
1693 views
//1// Copyright 2015 The ANGLE Project Authors. All rights reserved.2// Use of this source code is governed by a BSD-style license that can be3// found in the LICENSE file.4//56#include "test_utils/ANGLETest.h"7#include "test_utils/gl_raii.h"89#include "media/pixel.inc"1011using namespace angle;1213class DXT1CompressedTextureTest : public ANGLETest14{15protected:16DXT1CompressedTextureTest()17{18setWindowWidth(512);19setWindowHeight(512);20setConfigRedBits(8);21setConfigGreenBits(8);22setConfigBlueBits(8);23setConfigAlphaBits(8);24}2526void testSetUp() override27{28constexpr char kVS[] = R"(precision highp float;29attribute vec4 position;30varying vec2 texcoord;3132void main()33{34gl_Position = position;35texcoord = (position.xy * 0.5) + 0.5;36texcoord.y = 1.0 - texcoord.y;37})";3839constexpr char kFS[] = R"(precision highp float;40uniform sampler2D tex;41varying vec2 texcoord;4243void main()44{45gl_FragColor = texture2D(tex, texcoord);46})";4748mTextureProgram = CompileProgram(kVS, kFS);49if (mTextureProgram == 0)50{51FAIL() << "shader compilation failed.";52}5354mTextureUniformLocation = glGetUniformLocation(mTextureProgram, "tex");5556ASSERT_GL_NO_ERROR();57}5859void testTearDown() override { glDeleteProgram(mTextureProgram); }6061GLuint mTextureProgram;62GLint mTextureUniformLocation;63};6465TEST_P(DXT1CompressedTextureTest, CompressedTexImage)66{67ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_texture_compression_dxt1"));6869GLuint texture;70glGenTextures(1, &texture);71glBindTexture(GL_TEXTURE_2D, texture);72glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);73glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);74glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);75glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);7677glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_0_width,78pixel_0_height, 0, pixel_0_size, pixel_0_data);79glCompressedTexImage2D(GL_TEXTURE_2D, 1, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_1_width,80pixel_1_height, 0, pixel_1_size, pixel_1_data);81glCompressedTexImage2D(GL_TEXTURE_2D, 2, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_2_width,82pixel_2_height, 0, pixel_2_size, pixel_2_data);83glCompressedTexImage2D(GL_TEXTURE_2D, 3, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_3_width,84pixel_3_height, 0, pixel_3_size, pixel_3_data);85glCompressedTexImage2D(GL_TEXTURE_2D, 4, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_4_width,86pixel_4_height, 0, pixel_4_size, pixel_4_data);87glCompressedTexImage2D(GL_TEXTURE_2D, 5, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_5_width,88pixel_5_height, 0, pixel_5_size, pixel_5_data);89glCompressedTexImage2D(GL_TEXTURE_2D, 6, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_6_width,90pixel_6_height, 0, pixel_6_size, pixel_6_data);91glCompressedTexImage2D(GL_TEXTURE_2D, 7, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_7_width,92pixel_7_height, 0, pixel_7_size, pixel_7_data);93glCompressedTexImage2D(GL_TEXTURE_2D, 8, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_8_width,94pixel_8_height, 0, pixel_8_size, pixel_8_data);95glCompressedTexImage2D(GL_TEXTURE_2D, 9, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_9_width,96pixel_9_height, 0, pixel_9_size, pixel_9_data);9798EXPECT_GL_NO_ERROR();99100glUseProgram(mTextureProgram);101glUniform1i(mTextureUniformLocation, 0);102103drawQuad(mTextureProgram, "position", 0.5f);104105EXPECT_GL_NO_ERROR();106107glDeleteTextures(1, &texture);108109EXPECT_GL_NO_ERROR();110}111112// Verify that DXT1 RGB textures have 1.0 alpha when sampled113TEST_P(DXT1CompressedTextureTest, DXT1Alpha)114{115ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_texture_compression_dxt1"));116117// On Intel Metal, results would depend on the GPU Family.118ANGLE_SKIP_TEST_IF(IsMetal() && IsIntel());119120// On platforms without native support for DXT1 RGB or texture swizzling (such as D3D or some121// Metal configurations), this test is allowed to succeed with transparent black instead of122// opaque black.123const bool opaque = !IsD3D() && !(IsMetal() && !IsMetalTextureSwizzleAvailable());124125GLTexture texture;126glBindTexture(GL_TEXTURE_2D, texture);127glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);128glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);129130// Image using pixels with the code for transparent black:131// "BLACK, if color0 <= color1 and code(x,y) == 3"132constexpr uint8_t CompressedImageDXT1[] = {0, 0, 0, 0, 255, 255, 255, 255};133glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, 4, 4, 0,134sizeof(CompressedImageDXT1), CompressedImageDXT1);135136EXPECT_GL_NO_ERROR();137138glUseProgram(mTextureProgram);139glUniform1i(mTextureUniformLocation, 0);140141constexpr GLint kDrawSize = 4;142// The image is one 4x4 block, make the viewport only 4x4.143glViewport(0, 0, kDrawSize, kDrawSize);144145drawQuad(mTextureProgram, "position", 0.5f);146147EXPECT_GL_NO_ERROR();148149for (GLint y = 0; y < kDrawSize; y++)150{151for (GLint x = 0; x < kDrawSize; x++)152{153EXPECT_PIXEL_EQ(x, y, 0, 0, 0, opaque ? 255 : 0) << "at (" << x << ", " << y << ")";154}155}156}157158TEST_P(DXT1CompressedTextureTest, CompressedTexStorage)159{160ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_texture_compression_dxt1"));161162ANGLE_SKIP_TEST_IF(getClientMajorVersion() < 3 &&163(!IsGLExtensionEnabled("GL_EXT_texture_storage") ||164!IsGLExtensionEnabled("GL_OES_rgb8_rgba8")));165166GLuint texture;167glGenTextures(1, &texture);168glBindTexture(GL_TEXTURE_2D, texture);169glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);170glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);171glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);172glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);173174if (getClientMajorVersion() < 3)175{176glTexStorage2DEXT(GL_TEXTURE_2D, pixel_levels, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,177pixel_0_width, pixel_0_height);178}179else180{181glTexStorage2D(GL_TEXTURE_2D, pixel_levels, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_0_width,182pixel_0_height);183}184EXPECT_GL_NO_ERROR();185186glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, pixel_0_width, pixel_0_height,187GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_0_size, pixel_0_data);188glCompressedTexSubImage2D(GL_TEXTURE_2D, 1, 0, 0, pixel_1_width, pixel_1_height,189GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_1_size, pixel_1_data);190glCompressedTexSubImage2D(GL_TEXTURE_2D, 2, 0, 0, pixel_2_width, pixel_2_height,191GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_2_size, pixel_2_data);192glCompressedTexSubImage2D(GL_TEXTURE_2D, 3, 0, 0, pixel_3_width, pixel_3_height,193GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_3_size, pixel_3_data);194glCompressedTexSubImage2D(GL_TEXTURE_2D, 4, 0, 0, pixel_4_width, pixel_4_height,195GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_4_size, pixel_4_data);196glCompressedTexSubImage2D(GL_TEXTURE_2D, 5, 0, 0, pixel_5_width, pixel_5_height,197GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_5_size, pixel_5_data);198glCompressedTexSubImage2D(GL_TEXTURE_2D, 6, 0, 0, pixel_6_width, pixel_6_height,199GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_6_size, pixel_6_data);200glCompressedTexSubImage2D(GL_TEXTURE_2D, 7, 0, 0, pixel_7_width, pixel_7_height,201GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_7_size, pixel_7_data);202glCompressedTexSubImage2D(GL_TEXTURE_2D, 8, 0, 0, pixel_8_width, pixel_8_height,203GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_8_size, pixel_8_data);204glCompressedTexSubImage2D(GL_TEXTURE_2D, 9, 0, 0, pixel_9_width, pixel_9_height,205GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_9_size, pixel_9_data);206207EXPECT_GL_NO_ERROR();208209glUseProgram(mTextureProgram);210glUniform1i(mTextureUniformLocation, 0);211212drawQuad(mTextureProgram, "position", 0.5f);213214EXPECT_GL_NO_ERROR();215216glDeleteTextures(1, &texture);217218EXPECT_GL_NO_ERROR();219}220221// Test validation of glCompressedTexSubImage2D with DXT formats222TEST_P(DXT1CompressedTextureTest, CompressedTexSubImageValidation)223{224ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_texture_compression_dxt1"));225226GLTexture texture;227glBindTexture(GL_TEXTURE_2D, texture.get());228229// Size mip 0 to a large size230glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_0_width,231pixel_0_height, 0, pixel_0_size, nullptr);232ASSERT_GL_NO_ERROR();233234// Set a sub image with an offset that isn't a multiple of the block size235glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 1, 3, pixel_1_width, pixel_1_height,236GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_1_size, pixel_1_data);237ASSERT_GL_ERROR(GL_INVALID_OPERATION);238239// Set a sub image with a negative offset240glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, -1, 0, 4, 4, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, 8,241pixel_1_data);242ASSERT_GL_ERROR(GL_INVALID_VALUE);243244glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, -1, 4, 4, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, 8,245pixel_1_data);246ASSERT_GL_ERROR(GL_INVALID_VALUE);247}248249// Test that it's not possible to call CopyTexSubImage2D on a compressed texture250TEST_P(DXT1CompressedTextureTest, CopyTexSubImage2DDisallowed)251{252ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_texture_compression_dxt1"));253254GLTexture texture;255glBindTexture(GL_TEXTURE_2D, texture.get());256257glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_0_width,258pixel_0_height, 0, pixel_0_size, nullptr);259ASSERT_GL_NO_ERROR();260261glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 4, 4);262ASSERT_GL_ERROR(GL_INVALID_OPERATION);263}264265TEST_P(DXT1CompressedTextureTest, PBOCompressedTexStorage)266{267ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_texture_compression_dxt1"));268269ANGLE_SKIP_TEST_IF(getClientMajorVersion() < 3 &&270!IsGLExtensionEnabled("GL_NV_pixel_buffer_object"));271272ANGLE_SKIP_TEST_IF(getClientMajorVersion() < 3 &&273(!IsGLExtensionEnabled("GL_EXT_texture_storage") ||274!IsGLExtensionEnabled("GL_OES_rgb8_rgba8")));275276GLuint texture;277glGenTextures(1, &texture);278glBindTexture(GL_TEXTURE_2D, texture);279glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);280glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);281glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);282glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);283284if (getClientMajorVersion() < 3)285{286glTexStorage2DEXT(GL_TEXTURE_2D, pixel_levels, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,287pixel_0_width, pixel_0_height);288}289else290{291glTexStorage2D(GL_TEXTURE_2D, pixel_levels, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_0_width,292pixel_0_height);293}294EXPECT_GL_NO_ERROR();295296GLuint buffer;297glGenBuffers(1, &buffer);298glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buffer);299glBufferData(GL_PIXEL_UNPACK_BUFFER, pixel_0_size, nullptr, GL_STREAM_DRAW);300EXPECT_GL_NO_ERROR();301302glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_0_size, pixel_0_data);303glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, pixel_0_width, pixel_0_height,304GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_0_size, nullptr);305glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_1_size, pixel_1_data);306glCompressedTexSubImage2D(GL_TEXTURE_2D, 1, 0, 0, pixel_1_width, pixel_1_height,307GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_1_size, nullptr);308glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_2_size, pixel_2_data);309glCompressedTexSubImage2D(GL_TEXTURE_2D, 2, 0, 0, pixel_2_width, pixel_2_height,310GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_2_size, nullptr);311glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_3_size, pixel_3_data);312glCompressedTexSubImage2D(GL_TEXTURE_2D, 3, 0, 0, pixel_3_width, pixel_3_height,313GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_3_size, nullptr);314glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_4_size, pixel_4_data);315glCompressedTexSubImage2D(GL_TEXTURE_2D, 4, 0, 0, pixel_4_width, pixel_4_height,316GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_4_size, nullptr);317glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_5_size, pixel_5_data);318glCompressedTexSubImage2D(GL_TEXTURE_2D, 5, 0, 0, pixel_5_width, pixel_5_height,319GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_5_size, nullptr);320glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_6_size, pixel_6_data);321glCompressedTexSubImage2D(GL_TEXTURE_2D, 6, 0, 0, pixel_6_width, pixel_6_height,322GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_6_size, nullptr);323glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_7_size, pixel_7_data);324glCompressedTexSubImage2D(GL_TEXTURE_2D, 7, 0, 0, pixel_7_width, pixel_7_height,325GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_7_size, nullptr);326glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_8_size, pixel_8_data);327glCompressedTexSubImage2D(GL_TEXTURE_2D, 8, 0, 0, pixel_8_width, pixel_8_height,328GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_8_size, nullptr);329glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_9_size, pixel_9_data);330glCompressedTexSubImage2D(GL_TEXTURE_2D, 9, 0, 0, pixel_9_width, pixel_9_height,331GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_9_size, nullptr);332333EXPECT_GL_NO_ERROR();334335glUseProgram(mTextureProgram);336glUniform1i(mTextureUniformLocation, 0);337338drawQuad(mTextureProgram, "position", 0.5f);339340EXPECT_GL_NO_ERROR();341342glDeleteTextures(1, &texture);343344EXPECT_GL_NO_ERROR();345}346347class DXT1CompressedTextureTestES3 : public DXT1CompressedTextureTest348{};349350TEST_P(DXT1CompressedTextureTestES3, PBOCompressedTexImage)351{352ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_texture_compression_dxt1"));353354GLuint texture;355glGenTextures(1, &texture);356glBindTexture(GL_TEXTURE_2D, texture);357glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);358glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);359glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);360glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);361362GLuint buffer;363glGenBuffers(1, &buffer);364glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buffer);365glBufferData(GL_PIXEL_UNPACK_BUFFER, pixel_0_size, nullptr, GL_STREAM_DRAW);366EXPECT_GL_NO_ERROR();367368glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_0_size, pixel_0_data);369glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_0_width,370pixel_0_height, 0, pixel_0_size, nullptr);371glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_1_size, pixel_1_data);372glCompressedTexImage2D(GL_TEXTURE_2D, 1, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_1_width,373pixel_1_height, 0, pixel_1_size, nullptr);374glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_2_size, pixel_2_data);375glCompressedTexImage2D(GL_TEXTURE_2D, 2, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_2_width,376pixel_2_height, 0, pixel_2_size, nullptr);377glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_3_size, pixel_3_data);378glCompressedTexImage2D(GL_TEXTURE_2D, 3, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_3_width,379pixel_3_height, 0, pixel_3_size, nullptr);380glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_4_size, pixel_4_data);381glCompressedTexImage2D(GL_TEXTURE_2D, 4, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_4_width,382pixel_4_height, 0, pixel_4_size, nullptr);383glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_5_size, pixel_5_data);384glCompressedTexImage2D(GL_TEXTURE_2D, 5, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_5_width,385pixel_5_height, 0, pixel_5_size, nullptr);386glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_6_size, pixel_6_data);387glCompressedTexImage2D(GL_TEXTURE_2D, 6, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_6_width,388pixel_6_height, 0, pixel_6_size, nullptr);389glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_7_size, pixel_7_data);390glCompressedTexImage2D(GL_TEXTURE_2D, 7, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_7_width,391pixel_7_height, 0, pixel_7_size, nullptr);392glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_8_size, pixel_8_data);393glCompressedTexImage2D(GL_TEXTURE_2D, 8, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_8_width,394pixel_8_height, 0, pixel_8_size, nullptr);395glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_9_size, pixel_9_data);396glCompressedTexImage2D(GL_TEXTURE_2D, 9, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_9_width,397pixel_9_height, 0, pixel_9_size, nullptr);398399EXPECT_GL_NO_ERROR();400401glUseProgram(mTextureProgram);402glUniform1i(mTextureUniformLocation, 0);403404drawQuad(mTextureProgram, "position", 0.5f);405406EXPECT_GL_NO_ERROR();407408glDeleteTextures(1, &buffer);409glDeleteTextures(1, &texture);410411EXPECT_GL_NO_ERROR();412}413414// Test validation of glCompressedTexSubImage3D with DXT formats415TEST_P(DXT1CompressedTextureTestES3, CompressedTexSubImageValidation)416{417ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_texture_compression_dxt1"));418419GLTexture texture;420glBindTexture(GL_TEXTURE_2D_ARRAY, texture.get());421422// Size mip 0 to a large size423glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_0_width,424pixel_0_height, 1, 0, pixel_0_size, nullptr);425ASSERT_GL_NO_ERROR();426427// Set a sub image with a negative offset428glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, -1, 0, 0, 4, 4, 1,429GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, 8, pixel_1_data);430ASSERT_GL_ERROR(GL_INVALID_VALUE);431432glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, -1, 0, 4, 4, 1,433GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, 8, pixel_1_data);434ASSERT_GL_ERROR(GL_INVALID_VALUE);435436glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, -1, 4, 4, 1,437GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, 8, pixel_1_data);438ASSERT_GL_ERROR(GL_INVALID_VALUE);439}440441// Test validation of glCompressedTexSubImage3D with DXT formats442TEST_P(DXT1CompressedTextureTestES3, CopyTexSubImage3DDisallowed)443{444ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_texture_compression_dxt1"));445446GLTexture texture;447glBindTexture(GL_TEXTURE_2D_ARRAY, texture.get());448449GLsizei depth = 4;450glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_0_width,451pixel_0_height, depth, 0, pixel_0_size * depth, nullptr);452ASSERT_GL_NO_ERROR();453454glCopyTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 0, 0, 4, 4);455ASSERT_GL_ERROR(GL_INVALID_OPERATION);456}457458ANGLE_INSTANTIATE_TEST_ES2_AND_ES3(DXT1CompressedTextureTest);459460GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(DXT1CompressedTextureTestES3);461ANGLE_INSTANTIATE_TEST_ES3(DXT1CompressedTextureTestES3);462463464