Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 1 | // |
| 2 | // Copyright 2015 The ANGLE Project Authors. All rights reserved. |
| 3 | // Use of this source code is governed by a BSD-style license that can be |
| 4 | // found in the LICENSE file. |
| 5 | // |
| 6 | |
Corentin Wallez | d3970de | 2015-05-14 11:07:48 -0400 | [diff] [blame] | 7 | #include "test_utils/ANGLETest.h" |
Geoff Lang | 44ff5a7 | 2017-02-03 15:15:43 -0500 | [diff] [blame] | 8 | #include "test_utils/gl_raii.h" |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 9 | |
Geoff Lang | d701ea1 | 2014-01-10 15:53:35 -0500 | [diff] [blame] | 10 | #include "media/pixel.inl" |
Geoff Lang | 066230a | 2013-10-30 12:59:30 -0400 | [diff] [blame] | 11 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 12 | using namespace angle; |
Austin Kinross | 18b931d | 2014-09-29 12:58:31 -0700 | [diff] [blame] | 13 | |
Yuly Novikov | fea6e95 | 2016-06-23 16:29:20 -0400 | [diff] [blame] | 14 | class DXT1CompressedTextureTest : public ANGLETest |
Geoff Lang | 066230a | 2013-10-30 12:59:30 -0400 | [diff] [blame] | 15 | { |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 16 | protected: |
Yuly Novikov | fea6e95 | 2016-06-23 16:29:20 -0400 | [diff] [blame] | 17 | DXT1CompressedTextureTest() |
Geoff Lang | 066230a | 2013-10-30 12:59:30 -0400 | [diff] [blame] | 18 | { |
| 19 | setWindowWidth(512); |
| 20 | setWindowHeight(512); |
| 21 | setConfigRedBits(8); |
| 22 | setConfigGreenBits(8); |
| 23 | setConfigBlueBits(8); |
| 24 | setConfigAlphaBits(8); |
| 25 | } |
| 26 | |
| 27 | virtual void SetUp() |
| 28 | { |
| 29 | ANGLETest::SetUp(); |
| 30 | |
| 31 | const std::string vsSource = SHADER_SOURCE |
| 32 | ( |
| 33 | precision highp float; |
| 34 | attribute vec4 position; |
| 35 | varying vec2 texcoord; |
| 36 | |
| 37 | void main() |
| 38 | { |
| 39 | gl_Position = position; |
| 40 | texcoord = (position.xy * 0.5) + 0.5; |
| 41 | texcoord.y = 1.0 - texcoord.y; |
| 42 | } |
| 43 | ); |
| 44 | |
| 45 | const std::string textureFSSource = SHADER_SOURCE |
| 46 | ( |
| 47 | precision highp float; |
| 48 | uniform sampler2D tex; |
| 49 | varying vec2 texcoord; |
| 50 | |
| 51 | void main() |
| 52 | { |
| 53 | gl_FragColor = texture2D(tex, texcoord); |
| 54 | } |
| 55 | ); |
| 56 | |
Jamie Madill | 5599c8f | 2014-08-26 13:16:39 -0400 | [diff] [blame] | 57 | mTextureProgram = CompileProgram(vsSource, textureFSSource); |
Geoff Lang | 066230a | 2013-10-30 12:59:30 -0400 | [diff] [blame] | 58 | if (mTextureProgram == 0) |
| 59 | { |
| 60 | FAIL() << "shader compilation failed."; |
| 61 | } |
| 62 | |
| 63 | mTextureUniformLocation = glGetUniformLocation(mTextureProgram, "tex"); |
| 64 | |
| 65 | ASSERT_GL_NO_ERROR(); |
| 66 | } |
| 67 | |
| 68 | virtual void TearDown() |
| 69 | { |
| 70 | glDeleteProgram(mTextureProgram); |
| 71 | |
| 72 | ANGLETest::TearDown(); |
| 73 | } |
| 74 | |
| 75 | GLuint mTextureProgram; |
| 76 | GLint mTextureUniformLocation; |
| 77 | }; |
| 78 | |
Yuly Novikov | fea6e95 | 2016-06-23 16:29:20 -0400 | [diff] [blame] | 79 | TEST_P(DXT1CompressedTextureTest, CompressedTexImage) |
Geoff Lang | 066230a | 2013-10-30 12:59:30 -0400 | [diff] [blame] | 80 | { |
Geoff Lang | a809165 | 2015-04-27 10:53:55 -0400 | [diff] [blame] | 81 | if (!extensionEnabled("GL_EXT_texture_compression_dxt1")) |
Geoff Lang | 066230a | 2013-10-30 12:59:30 -0400 | [diff] [blame] | 82 | { |
Geoff Lang | a809165 | 2015-04-27 10:53:55 -0400 | [diff] [blame] | 83 | std::cout << "Test skipped because GL_EXT_texture_compression_dxt1 is not available." << std::endl; |
Geoff Lang | 066230a | 2013-10-30 12:59:30 -0400 | [diff] [blame] | 84 | return; |
| 85 | } |
| 86 | |
| 87 | GLuint texture; |
| 88 | glGenTextures(1, &texture); |
| 89 | glBindTexture(GL_TEXTURE_2D, texture); |
| 90 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
| 91 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
| 92 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| 93 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| 94 | |
Geoff Lang | d701ea1 | 2014-01-10 15:53:35 -0500 | [diff] [blame] | 95 | glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_0_width, pixel_0_height, 0, pixel_0_size, pixel_0_data); |
| 96 | glCompressedTexImage2D(GL_TEXTURE_2D, 1, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_1_width, pixel_1_height, 0, pixel_1_size, pixel_1_data); |
| 97 | glCompressedTexImage2D(GL_TEXTURE_2D, 2, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_2_width, pixel_2_height, 0, pixel_2_size, pixel_2_data); |
| 98 | glCompressedTexImage2D(GL_TEXTURE_2D, 3, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_3_width, pixel_3_height, 0, pixel_3_size, pixel_3_data); |
| 99 | glCompressedTexImage2D(GL_TEXTURE_2D, 4, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_4_width, pixel_4_height, 0, pixel_4_size, pixel_4_data); |
| 100 | glCompressedTexImage2D(GL_TEXTURE_2D, 5, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_5_width, pixel_5_height, 0, pixel_5_size, pixel_5_data); |
| 101 | glCompressedTexImage2D(GL_TEXTURE_2D, 6, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_6_width, pixel_6_height, 0, pixel_6_size, pixel_6_data); |
| 102 | glCompressedTexImage2D(GL_TEXTURE_2D, 7, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_7_width, pixel_7_height, 0, pixel_7_size, pixel_7_data); |
| 103 | glCompressedTexImage2D(GL_TEXTURE_2D, 8, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_8_width, pixel_8_height, 0, pixel_8_size, pixel_8_data); |
| 104 | glCompressedTexImage2D(GL_TEXTURE_2D, 9, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_9_width, pixel_9_height, 0, pixel_9_size, pixel_9_data); |
Geoff Lang | 066230a | 2013-10-30 12:59:30 -0400 | [diff] [blame] | 105 | |
| 106 | EXPECT_GL_NO_ERROR(); |
| 107 | |
| 108 | glUseProgram(mTextureProgram); |
| 109 | glUniform1i(mTextureUniformLocation, 0); |
| 110 | |
| 111 | drawQuad(mTextureProgram, "position", 0.5f); |
| 112 | |
| 113 | EXPECT_GL_NO_ERROR(); |
| 114 | |
| 115 | glDeleteTextures(1, &texture); |
| 116 | |
| 117 | EXPECT_GL_NO_ERROR(); |
| 118 | } |
| 119 | |
Yuly Novikov | fea6e95 | 2016-06-23 16:29:20 -0400 | [diff] [blame] | 120 | TEST_P(DXT1CompressedTextureTest, CompressedTexStorage) |
Geoff Lang | 066230a | 2013-10-30 12:59:30 -0400 | [diff] [blame] | 121 | { |
Geoff Lang | a809165 | 2015-04-27 10:53:55 -0400 | [diff] [blame] | 122 | if (!extensionEnabled("GL_EXT_texture_compression_dxt1")) |
Geoff Lang | 066230a | 2013-10-30 12:59:30 -0400 | [diff] [blame] | 123 | { |
Geoff Lang | a809165 | 2015-04-27 10:53:55 -0400 | [diff] [blame] | 124 | std::cout << "Test skipped due to missing GL_EXT_texture_compression_dxt1" << std::endl; |
Geoff Lang | 066230a | 2013-10-30 12:59:30 -0400 | [diff] [blame] | 125 | return; |
| 126 | } |
| 127 | |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 128 | if (getClientMajorVersion() < 3 && |
| 129 | (!extensionEnabled("GL_EXT_texture_storage") || !extensionEnabled("GL_OES_rgb8_rgba8"))) |
Geoff Lang | 066230a | 2013-10-30 12:59:30 -0400 | [diff] [blame] | 130 | { |
Geoff Lang | a809165 | 2015-04-27 10:53:55 -0400 | [diff] [blame] | 131 | std::cout << "Test skipped due to missing ES3 or GL_EXT_texture_storage or GL_OES_rgb8_rgba8" << std::endl; |
Geoff Lang | 066230a | 2013-10-30 12:59:30 -0400 | [diff] [blame] | 132 | return; |
| 133 | } |
| 134 | |
| 135 | GLuint texture; |
| 136 | glGenTextures(1, &texture); |
| 137 | glBindTexture(GL_TEXTURE_2D, texture); |
| 138 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
| 139 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
| 140 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| 141 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| 142 | |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 143 | if (getClientMajorVersion() < 3) |
Geoff Lang | 066230a | 2013-10-30 12:59:30 -0400 | [diff] [blame] | 144 | { |
Geoff Lang | a836e48 | 2014-04-28 10:08:27 -0400 | [diff] [blame] | 145 | glTexStorage2DEXT(GL_TEXTURE_2D, pixel_levels, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_0_width, pixel_0_height); |
Geoff Lang | 066230a | 2013-10-30 12:59:30 -0400 | [diff] [blame] | 146 | } |
| 147 | else |
| 148 | { |
Geoff Lang | a836e48 | 2014-04-28 10:08:27 -0400 | [diff] [blame] | 149 | glTexStorage2D(GL_TEXTURE_2D, pixel_levels, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_0_width, pixel_0_height); |
Geoff Lang | 066230a | 2013-10-30 12:59:30 -0400 | [diff] [blame] | 150 | } |
| 151 | EXPECT_GL_NO_ERROR(); |
| 152 | |
Geoff Lang | d701ea1 | 2014-01-10 15:53:35 -0500 | [diff] [blame] | 153 | glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, pixel_0_width, pixel_0_height, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_0_size, pixel_0_data); |
Geoff Lang | a836e48 | 2014-04-28 10:08:27 -0400 | [diff] [blame] | 154 | glCompressedTexSubImage2D(GL_TEXTURE_2D, 1, 0, 0, pixel_1_width, pixel_1_height, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_1_size, pixel_1_data); |
| 155 | glCompressedTexSubImage2D(GL_TEXTURE_2D, 2, 0, 0, pixel_2_width, pixel_2_height, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_2_size, pixel_2_data); |
| 156 | glCompressedTexSubImage2D(GL_TEXTURE_2D, 3, 0, 0, pixel_3_width, pixel_3_height, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_3_size, pixel_3_data); |
| 157 | glCompressedTexSubImage2D(GL_TEXTURE_2D, 4, 0, 0, pixel_4_width, pixel_4_height, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_4_size, pixel_4_data); |
| 158 | glCompressedTexSubImage2D(GL_TEXTURE_2D, 5, 0, 0, pixel_5_width, pixel_5_height, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_5_size, pixel_5_data); |
| 159 | glCompressedTexSubImage2D(GL_TEXTURE_2D, 6, 0, 0, pixel_6_width, pixel_6_height, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_6_size, pixel_6_data); |
| 160 | glCompressedTexSubImage2D(GL_TEXTURE_2D, 7, 0, 0, pixel_7_width, pixel_7_height, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_7_size, pixel_7_data); |
| 161 | glCompressedTexSubImage2D(GL_TEXTURE_2D, 8, 0, 0, pixel_8_width, pixel_8_height, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_8_size, pixel_8_data); |
| 162 | glCompressedTexSubImage2D(GL_TEXTURE_2D, 9, 0, 0, pixel_9_width, pixel_9_height, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_9_size, pixel_9_data); |
Geoff Lang | 066230a | 2013-10-30 12:59:30 -0400 | [diff] [blame] | 163 | |
| 164 | EXPECT_GL_NO_ERROR(); |
| 165 | |
| 166 | glUseProgram(mTextureProgram); |
| 167 | glUniform1i(mTextureUniformLocation, 0); |
| 168 | |
| 169 | drawQuad(mTextureProgram, "position", 0.5f); |
| 170 | |
| 171 | EXPECT_GL_NO_ERROR(); |
| 172 | |
| 173 | glDeleteTextures(1, &texture); |
| 174 | |
| 175 | EXPECT_GL_NO_ERROR(); |
| 176 | } |
Jamie Madill | c751d1e | 2014-10-21 17:46:29 -0400 | [diff] [blame] | 177 | |
Geoff Lang | 44ff5a7 | 2017-02-03 15:15:43 -0500 | [diff] [blame] | 178 | // Test validation of glCompressedTexSubImage2D with DXT formats |
| 179 | TEST_P(DXT1CompressedTextureTest, CompressedTexSubImageValidation) |
| 180 | { |
| 181 | if (!extensionEnabled("GL_EXT_texture_compression_dxt1")) |
| 182 | { |
| 183 | std::cout << "Test skipped due to missing GL_EXT_texture_compression_dxt1" << std::endl; |
| 184 | return; |
| 185 | } |
| 186 | |
| 187 | GLTexture texture; |
| 188 | glBindTexture(GL_TEXTURE_2D, texture.get()); |
| 189 | |
| 190 | // Size mip 0 to a large size |
| 191 | glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_0_width, |
| 192 | pixel_0_height, 0, pixel_0_size, nullptr); |
| 193 | ASSERT_GL_NO_ERROR(); |
| 194 | |
| 195 | // Set a sub image with an offset that isn't a multiple of the block size |
| 196 | glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 1, 3, pixel_1_width, pixel_1_height, |
| 197 | GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_1_size, pixel_1_data); |
| 198 | ASSERT_GL_ERROR(GL_INVALID_OPERATION); |
| 199 | } |
| 200 | |
Yuly Novikov | fea6e95 | 2016-06-23 16:29:20 -0400 | [diff] [blame] | 201 | class DXT1CompressedTextureTestES3 : public DXT1CompressedTextureTest { }; |
Jamie Madill | c751d1e | 2014-10-21 17:46:29 -0400 | [diff] [blame] | 202 | |
Yuly Novikov | fea6e95 | 2016-06-23 16:29:20 -0400 | [diff] [blame] | 203 | class DXT1CompressedTextureTestD3D11 : public DXT1CompressedTextureTest { }; |
Jamie Madill | c751d1e | 2014-10-21 17:46:29 -0400 | [diff] [blame] | 204 | |
Yuly Novikov | fea6e95 | 2016-06-23 16:29:20 -0400 | [diff] [blame] | 205 | TEST_P(DXT1CompressedTextureTestES3, PBOCompressedTexImage) |
Jamie Madill | c751d1e | 2014-10-21 17:46:29 -0400 | [diff] [blame] | 206 | { |
Yuly Novikov | fea6e95 | 2016-06-23 16:29:20 -0400 | [diff] [blame] | 207 | if (!extensionEnabled("GL_EXT_texture_compression_dxt1")) |
| 208 | { |
| 209 | std::cout << "Test skipped because GL_EXT_texture_compression_dxt1 is not available." |
| 210 | << std::endl; |
| 211 | return; |
| 212 | } |
| 213 | |
Jamie Madill | c751d1e | 2014-10-21 17:46:29 -0400 | [diff] [blame] | 214 | GLuint texture; |
| 215 | glGenTextures(1, &texture); |
| 216 | glBindTexture(GL_TEXTURE_2D, texture); |
| 217 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
| 218 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
| 219 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| 220 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| 221 | |
| 222 | GLuint buffer; |
| 223 | glGenBuffers(1, &buffer); |
| 224 | glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buffer); |
Yunchao He | f81ce4a | 2017-04-24 10:49:17 +0800 | [diff] [blame] | 225 | glBufferData(GL_PIXEL_UNPACK_BUFFER, pixel_0_size, nullptr, GL_STREAM_DRAW); |
Jamie Madill | c751d1e | 2014-10-21 17:46:29 -0400 | [diff] [blame] | 226 | EXPECT_GL_NO_ERROR(); |
| 227 | |
| 228 | glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_0_size, pixel_0_data); |
Yunchao He | f81ce4a | 2017-04-24 10:49:17 +0800 | [diff] [blame] | 229 | glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_0_width, |
| 230 | pixel_0_height, 0, pixel_0_size, nullptr); |
Jamie Madill | c751d1e | 2014-10-21 17:46:29 -0400 | [diff] [blame] | 231 | glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_1_size, pixel_1_data); |
Yunchao He | f81ce4a | 2017-04-24 10:49:17 +0800 | [diff] [blame] | 232 | glCompressedTexImage2D(GL_TEXTURE_2D, 1, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_1_width, |
| 233 | pixel_1_height, 0, pixel_1_size, nullptr); |
Jamie Madill | c751d1e | 2014-10-21 17:46:29 -0400 | [diff] [blame] | 234 | glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_2_size, pixel_2_data); |
Yunchao He | f81ce4a | 2017-04-24 10:49:17 +0800 | [diff] [blame] | 235 | glCompressedTexImage2D(GL_TEXTURE_2D, 2, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_2_width, |
| 236 | pixel_2_height, 0, pixel_2_size, nullptr); |
Jamie Madill | c751d1e | 2014-10-21 17:46:29 -0400 | [diff] [blame] | 237 | glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_3_size, pixel_3_data); |
Yunchao He | f81ce4a | 2017-04-24 10:49:17 +0800 | [diff] [blame] | 238 | glCompressedTexImage2D(GL_TEXTURE_2D, 3, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_3_width, |
| 239 | pixel_3_height, 0, pixel_3_size, nullptr); |
Jamie Madill | c751d1e | 2014-10-21 17:46:29 -0400 | [diff] [blame] | 240 | glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_4_size, pixel_4_data); |
Yunchao He | f81ce4a | 2017-04-24 10:49:17 +0800 | [diff] [blame] | 241 | glCompressedTexImage2D(GL_TEXTURE_2D, 4, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_4_width, |
| 242 | pixel_4_height, 0, pixel_4_size, nullptr); |
Jamie Madill | c751d1e | 2014-10-21 17:46:29 -0400 | [diff] [blame] | 243 | glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_5_size, pixel_5_data); |
Yunchao He | f81ce4a | 2017-04-24 10:49:17 +0800 | [diff] [blame] | 244 | glCompressedTexImage2D(GL_TEXTURE_2D, 5, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_5_width, |
| 245 | pixel_5_height, 0, pixel_5_size, nullptr); |
Jamie Madill | c751d1e | 2014-10-21 17:46:29 -0400 | [diff] [blame] | 246 | glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_6_size, pixel_6_data); |
Yunchao He | f81ce4a | 2017-04-24 10:49:17 +0800 | [diff] [blame] | 247 | glCompressedTexImage2D(GL_TEXTURE_2D, 6, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_6_width, |
| 248 | pixel_6_height, 0, pixel_6_size, nullptr); |
Jamie Madill | c751d1e | 2014-10-21 17:46:29 -0400 | [diff] [blame] | 249 | glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_7_size, pixel_7_data); |
Yunchao He | f81ce4a | 2017-04-24 10:49:17 +0800 | [diff] [blame] | 250 | glCompressedTexImage2D(GL_TEXTURE_2D, 7, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_7_width, |
| 251 | pixel_7_height, 0, pixel_7_size, nullptr); |
Jamie Madill | c751d1e | 2014-10-21 17:46:29 -0400 | [diff] [blame] | 252 | glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_8_size, pixel_8_data); |
Yunchao He | f81ce4a | 2017-04-24 10:49:17 +0800 | [diff] [blame] | 253 | glCompressedTexImage2D(GL_TEXTURE_2D, 8, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_8_width, |
| 254 | pixel_8_height, 0, pixel_8_size, nullptr); |
Jamie Madill | c751d1e | 2014-10-21 17:46:29 -0400 | [diff] [blame] | 255 | glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_9_size, pixel_9_data); |
Yunchao He | f81ce4a | 2017-04-24 10:49:17 +0800 | [diff] [blame] | 256 | glCompressedTexImage2D(GL_TEXTURE_2D, 9, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_9_width, |
| 257 | pixel_9_height, 0, pixel_9_size, nullptr); |
Jamie Madill | c751d1e | 2014-10-21 17:46:29 -0400 | [diff] [blame] | 258 | |
| 259 | EXPECT_GL_NO_ERROR(); |
| 260 | |
| 261 | glUseProgram(mTextureProgram); |
| 262 | glUniform1i(mTextureUniformLocation, 0); |
| 263 | |
| 264 | drawQuad(mTextureProgram, "position", 0.5f); |
| 265 | |
| 266 | EXPECT_GL_NO_ERROR(); |
| 267 | |
| 268 | glDeleteTextures(1, &buffer); |
| 269 | glDeleteTextures(1, &texture); |
| 270 | |
| 271 | EXPECT_GL_NO_ERROR(); |
| 272 | } |
| 273 | |
| 274 | |
Yuly Novikov | fea6e95 | 2016-06-23 16:29:20 -0400 | [diff] [blame] | 275 | TEST_P(DXT1CompressedTextureTestD3D11, PBOCompressedTexStorage) |
Jamie Madill | c751d1e | 2014-10-21 17:46:29 -0400 | [diff] [blame] | 276 | { |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 277 | if (getClientMajorVersion() < 3 && !extensionEnabled("GL_EXT_texture_compression_dxt1")) |
Jamie Madill | c751d1e | 2014-10-21 17:46:29 -0400 | [diff] [blame] | 278 | { |
| 279 | return; |
| 280 | } |
| 281 | |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 282 | if (getClientMajorVersion() < 3 && |
| 283 | (!extensionEnabled("GL_EXT_texture_storage") || !extensionEnabled("GL_OES_rgb8_rgba8"))) |
Jamie Madill | c751d1e | 2014-10-21 17:46:29 -0400 | [diff] [blame] | 284 | { |
| 285 | return; |
| 286 | } |
| 287 | |
| 288 | GLuint texture; |
| 289 | glGenTextures(1, &texture); |
| 290 | glBindTexture(GL_TEXTURE_2D, texture); |
| 291 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
| 292 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
| 293 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| 294 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| 295 | |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 296 | if (getClientMajorVersion() < 3) |
Jamie Madill | c751d1e | 2014-10-21 17:46:29 -0400 | [diff] [blame] | 297 | { |
| 298 | glTexStorage2DEXT(GL_TEXTURE_2D, pixel_levels, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_0_width, pixel_0_height); |
| 299 | } |
| 300 | else |
| 301 | { |
| 302 | glTexStorage2D(GL_TEXTURE_2D, pixel_levels, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_0_width, pixel_0_height); |
| 303 | } |
| 304 | EXPECT_GL_NO_ERROR(); |
| 305 | |
| 306 | GLuint buffer; |
| 307 | glGenBuffers(1, &buffer); |
| 308 | glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buffer); |
Yunchao He | f81ce4a | 2017-04-24 10:49:17 +0800 | [diff] [blame] | 309 | glBufferData(GL_PIXEL_UNPACK_BUFFER, pixel_0_size, nullptr, GL_STREAM_DRAW); |
Jamie Madill | c751d1e | 2014-10-21 17:46:29 -0400 | [diff] [blame] | 310 | EXPECT_GL_NO_ERROR(); |
| 311 | |
| 312 | glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_0_size, pixel_0_data); |
Yunchao He | f81ce4a | 2017-04-24 10:49:17 +0800 | [diff] [blame] | 313 | glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, pixel_0_width, pixel_0_height, |
| 314 | GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_0_size, nullptr); |
Jamie Madill | c751d1e | 2014-10-21 17:46:29 -0400 | [diff] [blame] | 315 | glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_1_size, pixel_1_data); |
Yunchao He | f81ce4a | 2017-04-24 10:49:17 +0800 | [diff] [blame] | 316 | glCompressedTexSubImage2D(GL_TEXTURE_2D, 1, 0, 0, pixel_1_width, pixel_1_height, |
| 317 | GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_1_size, nullptr); |
Jamie Madill | c751d1e | 2014-10-21 17:46:29 -0400 | [diff] [blame] | 318 | glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_2_size, pixel_2_data); |
Yunchao He | f81ce4a | 2017-04-24 10:49:17 +0800 | [diff] [blame] | 319 | glCompressedTexSubImage2D(GL_TEXTURE_2D, 2, 0, 0, pixel_2_width, pixel_2_height, |
| 320 | GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_2_size, nullptr); |
Jamie Madill | c751d1e | 2014-10-21 17:46:29 -0400 | [diff] [blame] | 321 | glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_3_size, pixel_3_data); |
Yunchao He | f81ce4a | 2017-04-24 10:49:17 +0800 | [diff] [blame] | 322 | glCompressedTexSubImage2D(GL_TEXTURE_2D, 3, 0, 0, pixel_3_width, pixel_3_height, |
| 323 | GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_3_size, nullptr); |
Jamie Madill | c751d1e | 2014-10-21 17:46:29 -0400 | [diff] [blame] | 324 | glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_4_size, pixel_4_data); |
Yunchao He | f81ce4a | 2017-04-24 10:49:17 +0800 | [diff] [blame] | 325 | glCompressedTexSubImage2D(GL_TEXTURE_2D, 4, 0, 0, pixel_4_width, pixel_4_height, |
| 326 | GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_4_size, nullptr); |
Jamie Madill | c751d1e | 2014-10-21 17:46:29 -0400 | [diff] [blame] | 327 | glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_5_size, pixel_5_data); |
Yunchao He | f81ce4a | 2017-04-24 10:49:17 +0800 | [diff] [blame] | 328 | glCompressedTexSubImage2D(GL_TEXTURE_2D, 5, 0, 0, pixel_5_width, pixel_5_height, |
| 329 | GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_5_size, nullptr); |
Jamie Madill | c751d1e | 2014-10-21 17:46:29 -0400 | [diff] [blame] | 330 | glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_6_size, pixel_6_data); |
Yunchao He | f81ce4a | 2017-04-24 10:49:17 +0800 | [diff] [blame] | 331 | glCompressedTexSubImage2D(GL_TEXTURE_2D, 6, 0, 0, pixel_6_width, pixel_6_height, |
| 332 | GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_6_size, nullptr); |
Jamie Madill | c751d1e | 2014-10-21 17:46:29 -0400 | [diff] [blame] | 333 | glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_7_size, pixel_7_data); |
Yunchao He | f81ce4a | 2017-04-24 10:49:17 +0800 | [diff] [blame] | 334 | glCompressedTexSubImage2D(GL_TEXTURE_2D, 7, 0, 0, pixel_7_width, pixel_7_height, |
| 335 | GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_7_size, nullptr); |
Jamie Madill | c751d1e | 2014-10-21 17:46:29 -0400 | [diff] [blame] | 336 | glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_8_size, pixel_8_data); |
Yunchao He | f81ce4a | 2017-04-24 10:49:17 +0800 | [diff] [blame] | 337 | glCompressedTexSubImage2D(GL_TEXTURE_2D, 8, 0, 0, pixel_8_width, pixel_8_height, |
| 338 | GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_8_size, nullptr); |
Jamie Madill | c751d1e | 2014-10-21 17:46:29 -0400 | [diff] [blame] | 339 | glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_9_size, pixel_9_data); |
Yunchao He | f81ce4a | 2017-04-24 10:49:17 +0800 | [diff] [blame] | 340 | glCompressedTexSubImage2D(GL_TEXTURE_2D, 9, 0, 0, pixel_9_width, pixel_9_height, |
| 341 | GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_9_size, nullptr); |
Jamie Madill | c751d1e | 2014-10-21 17:46:29 -0400 | [diff] [blame] | 342 | |
| 343 | EXPECT_GL_NO_ERROR(); |
| 344 | |
| 345 | glUseProgram(mTextureProgram); |
| 346 | glUniform1i(mTextureUniformLocation, 0); |
| 347 | |
| 348 | drawQuad(mTextureProgram, "position", 0.5f); |
| 349 | |
| 350 | EXPECT_GL_NO_ERROR(); |
| 351 | |
| 352 | glDeleteTextures(1, &texture); |
| 353 | |
| 354 | EXPECT_GL_NO_ERROR(); |
| 355 | } |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 356 | |
| 357 | // Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against. |
Yuly Novikov | fea6e95 | 2016-06-23 16:29:20 -0400 | [diff] [blame] | 358 | ANGLE_INSTANTIATE_TEST(DXT1CompressedTextureTest, |
Geoff Lang | e0cc2a4 | 2016-01-20 10:58:17 -0500 | [diff] [blame] | 359 | ES2_D3D9(), |
| 360 | ES2_D3D11(), |
| 361 | ES2_D3D11_FL9_3(), |
| 362 | ES2_OPENGL(), |
| 363 | ES3_OPENGL(), |
| 364 | ES2_OPENGLES(), |
| 365 | ES3_OPENGLES()); |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 366 | |
| 367 | // Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against. |
Yuly Novikov | fea6e95 | 2016-06-23 16:29:20 -0400 | [diff] [blame] | 368 | ANGLE_INSTANTIATE_TEST(DXT1CompressedTextureTestES3, ES3_D3D11(), ES3_OPENGL(), ES3_OPENGLES()); |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 369 | |
Yuly Novikov | fea6e95 | 2016-06-23 16:29:20 -0400 | [diff] [blame] | 370 | ANGLE_INSTANTIATE_TEST(DXT1CompressedTextureTestD3D11, ES2_D3D11(), ES3_D3D11(), ES2_D3D11_FL9_3()); |