Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/angle
Path: blob/main_old/src/tests/gl_tests/DXT1CompressedTextureTest.cpp
1693 views
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
7
#include "test_utils/ANGLETest.h"
8
#include "test_utils/gl_raii.h"
9
10
#include "media/pixel.inc"
11
12
using namespace angle;
13
14
class DXT1CompressedTextureTest : public ANGLETest
15
{
16
protected:
17
DXT1CompressedTextureTest()
18
{
19
setWindowWidth(512);
20
setWindowHeight(512);
21
setConfigRedBits(8);
22
setConfigGreenBits(8);
23
setConfigBlueBits(8);
24
setConfigAlphaBits(8);
25
}
26
27
void testSetUp() override
28
{
29
constexpr char kVS[] = R"(precision highp float;
30
attribute vec4 position;
31
varying vec2 texcoord;
32
33
void main()
34
{
35
gl_Position = position;
36
texcoord = (position.xy * 0.5) + 0.5;
37
texcoord.y = 1.0 - texcoord.y;
38
})";
39
40
constexpr char kFS[] = R"(precision highp float;
41
uniform sampler2D tex;
42
varying vec2 texcoord;
43
44
void main()
45
{
46
gl_FragColor = texture2D(tex, texcoord);
47
})";
48
49
mTextureProgram = CompileProgram(kVS, kFS);
50
if (mTextureProgram == 0)
51
{
52
FAIL() << "shader compilation failed.";
53
}
54
55
mTextureUniformLocation = glGetUniformLocation(mTextureProgram, "tex");
56
57
ASSERT_GL_NO_ERROR();
58
}
59
60
void testTearDown() override { glDeleteProgram(mTextureProgram); }
61
62
GLuint mTextureProgram;
63
GLint mTextureUniformLocation;
64
};
65
66
TEST_P(DXT1CompressedTextureTest, CompressedTexImage)
67
{
68
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_texture_compression_dxt1"));
69
70
GLuint texture;
71
glGenTextures(1, &texture);
72
glBindTexture(GL_TEXTURE_2D, texture);
73
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
74
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
75
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
76
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
77
78
glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_0_width,
79
pixel_0_height, 0, pixel_0_size, pixel_0_data);
80
glCompressedTexImage2D(GL_TEXTURE_2D, 1, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_1_width,
81
pixel_1_height, 0, pixel_1_size, pixel_1_data);
82
glCompressedTexImage2D(GL_TEXTURE_2D, 2, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_2_width,
83
pixel_2_height, 0, pixel_2_size, pixel_2_data);
84
glCompressedTexImage2D(GL_TEXTURE_2D, 3, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_3_width,
85
pixel_3_height, 0, pixel_3_size, pixel_3_data);
86
glCompressedTexImage2D(GL_TEXTURE_2D, 4, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_4_width,
87
pixel_4_height, 0, pixel_4_size, pixel_4_data);
88
glCompressedTexImage2D(GL_TEXTURE_2D, 5, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_5_width,
89
pixel_5_height, 0, pixel_5_size, pixel_5_data);
90
glCompressedTexImage2D(GL_TEXTURE_2D, 6, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_6_width,
91
pixel_6_height, 0, pixel_6_size, pixel_6_data);
92
glCompressedTexImage2D(GL_TEXTURE_2D, 7, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_7_width,
93
pixel_7_height, 0, pixel_7_size, pixel_7_data);
94
glCompressedTexImage2D(GL_TEXTURE_2D, 8, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_8_width,
95
pixel_8_height, 0, pixel_8_size, pixel_8_data);
96
glCompressedTexImage2D(GL_TEXTURE_2D, 9, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_9_width,
97
pixel_9_height, 0, pixel_9_size, pixel_9_data);
98
99
EXPECT_GL_NO_ERROR();
100
101
glUseProgram(mTextureProgram);
102
glUniform1i(mTextureUniformLocation, 0);
103
104
drawQuad(mTextureProgram, "position", 0.5f);
105
106
EXPECT_GL_NO_ERROR();
107
108
glDeleteTextures(1, &texture);
109
110
EXPECT_GL_NO_ERROR();
111
}
112
113
// Verify that DXT1 RGB textures have 1.0 alpha when sampled
114
TEST_P(DXT1CompressedTextureTest, DXT1Alpha)
115
{
116
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_texture_compression_dxt1"));
117
118
// On Intel Metal, results would depend on the GPU Family.
119
ANGLE_SKIP_TEST_IF(IsMetal() && IsIntel());
120
121
// On platforms without native support for DXT1 RGB or texture swizzling (such as D3D or some
122
// Metal configurations), this test is allowed to succeed with transparent black instead of
123
// opaque black.
124
const bool opaque = !IsD3D() && !(IsMetal() && !IsMetalTextureSwizzleAvailable());
125
126
GLTexture texture;
127
glBindTexture(GL_TEXTURE_2D, texture);
128
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
129
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
130
131
// Image using pixels with the code for transparent black:
132
// "BLACK, if color0 <= color1 and code(x,y) == 3"
133
constexpr uint8_t CompressedImageDXT1[] = {0, 0, 0, 0, 255, 255, 255, 255};
134
glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, 4, 4, 0,
135
sizeof(CompressedImageDXT1), CompressedImageDXT1);
136
137
EXPECT_GL_NO_ERROR();
138
139
glUseProgram(mTextureProgram);
140
glUniform1i(mTextureUniformLocation, 0);
141
142
constexpr GLint kDrawSize = 4;
143
// The image is one 4x4 block, make the viewport only 4x4.
144
glViewport(0, 0, kDrawSize, kDrawSize);
145
146
drawQuad(mTextureProgram, "position", 0.5f);
147
148
EXPECT_GL_NO_ERROR();
149
150
for (GLint y = 0; y < kDrawSize; y++)
151
{
152
for (GLint x = 0; x < kDrawSize; x++)
153
{
154
EXPECT_PIXEL_EQ(x, y, 0, 0, 0, opaque ? 255 : 0) << "at (" << x << ", " << y << ")";
155
}
156
}
157
}
158
159
TEST_P(DXT1CompressedTextureTest, CompressedTexStorage)
160
{
161
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_texture_compression_dxt1"));
162
163
ANGLE_SKIP_TEST_IF(getClientMajorVersion() < 3 &&
164
(!IsGLExtensionEnabled("GL_EXT_texture_storage") ||
165
!IsGLExtensionEnabled("GL_OES_rgb8_rgba8")));
166
167
GLuint texture;
168
glGenTextures(1, &texture);
169
glBindTexture(GL_TEXTURE_2D, texture);
170
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
171
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
172
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
173
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
174
175
if (getClientMajorVersion() < 3)
176
{
177
glTexStorage2DEXT(GL_TEXTURE_2D, pixel_levels, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
178
pixel_0_width, pixel_0_height);
179
}
180
else
181
{
182
glTexStorage2D(GL_TEXTURE_2D, pixel_levels, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_0_width,
183
pixel_0_height);
184
}
185
EXPECT_GL_NO_ERROR();
186
187
glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, pixel_0_width, pixel_0_height,
188
GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_0_size, pixel_0_data);
189
glCompressedTexSubImage2D(GL_TEXTURE_2D, 1, 0, 0, pixel_1_width, pixel_1_height,
190
GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_1_size, pixel_1_data);
191
glCompressedTexSubImage2D(GL_TEXTURE_2D, 2, 0, 0, pixel_2_width, pixel_2_height,
192
GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_2_size, pixel_2_data);
193
glCompressedTexSubImage2D(GL_TEXTURE_2D, 3, 0, 0, pixel_3_width, pixel_3_height,
194
GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_3_size, pixel_3_data);
195
glCompressedTexSubImage2D(GL_TEXTURE_2D, 4, 0, 0, pixel_4_width, pixel_4_height,
196
GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_4_size, pixel_4_data);
197
glCompressedTexSubImage2D(GL_TEXTURE_2D, 5, 0, 0, pixel_5_width, pixel_5_height,
198
GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_5_size, pixel_5_data);
199
glCompressedTexSubImage2D(GL_TEXTURE_2D, 6, 0, 0, pixel_6_width, pixel_6_height,
200
GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_6_size, pixel_6_data);
201
glCompressedTexSubImage2D(GL_TEXTURE_2D, 7, 0, 0, pixel_7_width, pixel_7_height,
202
GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_7_size, pixel_7_data);
203
glCompressedTexSubImage2D(GL_TEXTURE_2D, 8, 0, 0, pixel_8_width, pixel_8_height,
204
GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_8_size, pixel_8_data);
205
glCompressedTexSubImage2D(GL_TEXTURE_2D, 9, 0, 0, pixel_9_width, pixel_9_height,
206
GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_9_size, pixel_9_data);
207
208
EXPECT_GL_NO_ERROR();
209
210
glUseProgram(mTextureProgram);
211
glUniform1i(mTextureUniformLocation, 0);
212
213
drawQuad(mTextureProgram, "position", 0.5f);
214
215
EXPECT_GL_NO_ERROR();
216
217
glDeleteTextures(1, &texture);
218
219
EXPECT_GL_NO_ERROR();
220
}
221
222
// Test validation of glCompressedTexSubImage2D with DXT formats
223
TEST_P(DXT1CompressedTextureTest, CompressedTexSubImageValidation)
224
{
225
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_texture_compression_dxt1"));
226
227
GLTexture texture;
228
glBindTexture(GL_TEXTURE_2D, texture.get());
229
230
// Size mip 0 to a large size
231
glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_0_width,
232
pixel_0_height, 0, pixel_0_size, nullptr);
233
ASSERT_GL_NO_ERROR();
234
235
// Set a sub image with an offset that isn't a multiple of the block size
236
glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 1, 3, pixel_1_width, pixel_1_height,
237
GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_1_size, pixel_1_data);
238
ASSERT_GL_ERROR(GL_INVALID_OPERATION);
239
240
// Set a sub image with a negative offset
241
glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, -1, 0, 4, 4, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, 8,
242
pixel_1_data);
243
ASSERT_GL_ERROR(GL_INVALID_VALUE);
244
245
glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, -1, 4, 4, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, 8,
246
pixel_1_data);
247
ASSERT_GL_ERROR(GL_INVALID_VALUE);
248
}
249
250
// Test that it's not possible to call CopyTexSubImage2D on a compressed texture
251
TEST_P(DXT1CompressedTextureTest, CopyTexSubImage2DDisallowed)
252
{
253
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_texture_compression_dxt1"));
254
255
GLTexture texture;
256
glBindTexture(GL_TEXTURE_2D, texture.get());
257
258
glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_0_width,
259
pixel_0_height, 0, pixel_0_size, nullptr);
260
ASSERT_GL_NO_ERROR();
261
262
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 4, 4);
263
ASSERT_GL_ERROR(GL_INVALID_OPERATION);
264
}
265
266
TEST_P(DXT1CompressedTextureTest, PBOCompressedTexStorage)
267
{
268
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_texture_compression_dxt1"));
269
270
ANGLE_SKIP_TEST_IF(getClientMajorVersion() < 3 &&
271
!IsGLExtensionEnabled("GL_NV_pixel_buffer_object"));
272
273
ANGLE_SKIP_TEST_IF(getClientMajorVersion() < 3 &&
274
(!IsGLExtensionEnabled("GL_EXT_texture_storage") ||
275
!IsGLExtensionEnabled("GL_OES_rgb8_rgba8")));
276
277
GLuint texture;
278
glGenTextures(1, &texture);
279
glBindTexture(GL_TEXTURE_2D, texture);
280
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
281
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
282
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
283
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
284
285
if (getClientMajorVersion() < 3)
286
{
287
glTexStorage2DEXT(GL_TEXTURE_2D, pixel_levels, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
288
pixel_0_width, pixel_0_height);
289
}
290
else
291
{
292
glTexStorage2D(GL_TEXTURE_2D, pixel_levels, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_0_width,
293
pixel_0_height);
294
}
295
EXPECT_GL_NO_ERROR();
296
297
GLuint buffer;
298
glGenBuffers(1, &buffer);
299
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buffer);
300
glBufferData(GL_PIXEL_UNPACK_BUFFER, pixel_0_size, nullptr, GL_STREAM_DRAW);
301
EXPECT_GL_NO_ERROR();
302
303
glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_0_size, pixel_0_data);
304
glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, pixel_0_width, pixel_0_height,
305
GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_0_size, nullptr);
306
glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_1_size, pixel_1_data);
307
glCompressedTexSubImage2D(GL_TEXTURE_2D, 1, 0, 0, pixel_1_width, pixel_1_height,
308
GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_1_size, nullptr);
309
glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_2_size, pixel_2_data);
310
glCompressedTexSubImage2D(GL_TEXTURE_2D, 2, 0, 0, pixel_2_width, pixel_2_height,
311
GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_2_size, nullptr);
312
glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_3_size, pixel_3_data);
313
glCompressedTexSubImage2D(GL_TEXTURE_2D, 3, 0, 0, pixel_3_width, pixel_3_height,
314
GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_3_size, nullptr);
315
glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_4_size, pixel_4_data);
316
glCompressedTexSubImage2D(GL_TEXTURE_2D, 4, 0, 0, pixel_4_width, pixel_4_height,
317
GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_4_size, nullptr);
318
glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_5_size, pixel_5_data);
319
glCompressedTexSubImage2D(GL_TEXTURE_2D, 5, 0, 0, pixel_5_width, pixel_5_height,
320
GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_5_size, nullptr);
321
glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_6_size, pixel_6_data);
322
glCompressedTexSubImage2D(GL_TEXTURE_2D, 6, 0, 0, pixel_6_width, pixel_6_height,
323
GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_6_size, nullptr);
324
glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_7_size, pixel_7_data);
325
glCompressedTexSubImage2D(GL_TEXTURE_2D, 7, 0, 0, pixel_7_width, pixel_7_height,
326
GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_7_size, nullptr);
327
glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_8_size, pixel_8_data);
328
glCompressedTexSubImage2D(GL_TEXTURE_2D, 8, 0, 0, pixel_8_width, pixel_8_height,
329
GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_8_size, nullptr);
330
glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_9_size, pixel_9_data);
331
glCompressedTexSubImage2D(GL_TEXTURE_2D, 9, 0, 0, pixel_9_width, pixel_9_height,
332
GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_9_size, nullptr);
333
334
EXPECT_GL_NO_ERROR();
335
336
glUseProgram(mTextureProgram);
337
glUniform1i(mTextureUniformLocation, 0);
338
339
drawQuad(mTextureProgram, "position", 0.5f);
340
341
EXPECT_GL_NO_ERROR();
342
343
glDeleteTextures(1, &texture);
344
345
EXPECT_GL_NO_ERROR();
346
}
347
348
class DXT1CompressedTextureTestES3 : public DXT1CompressedTextureTest
349
{};
350
351
TEST_P(DXT1CompressedTextureTestES3, PBOCompressedTexImage)
352
{
353
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_texture_compression_dxt1"));
354
355
GLuint texture;
356
glGenTextures(1, &texture);
357
glBindTexture(GL_TEXTURE_2D, texture);
358
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
359
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
360
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
361
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
362
363
GLuint buffer;
364
glGenBuffers(1, &buffer);
365
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buffer);
366
glBufferData(GL_PIXEL_UNPACK_BUFFER, pixel_0_size, nullptr, GL_STREAM_DRAW);
367
EXPECT_GL_NO_ERROR();
368
369
glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_0_size, pixel_0_data);
370
glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_0_width,
371
pixel_0_height, 0, pixel_0_size, nullptr);
372
glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_1_size, pixel_1_data);
373
glCompressedTexImage2D(GL_TEXTURE_2D, 1, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_1_width,
374
pixel_1_height, 0, pixel_1_size, nullptr);
375
glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_2_size, pixel_2_data);
376
glCompressedTexImage2D(GL_TEXTURE_2D, 2, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_2_width,
377
pixel_2_height, 0, pixel_2_size, nullptr);
378
glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_3_size, pixel_3_data);
379
glCompressedTexImage2D(GL_TEXTURE_2D, 3, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_3_width,
380
pixel_3_height, 0, pixel_3_size, nullptr);
381
glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_4_size, pixel_4_data);
382
glCompressedTexImage2D(GL_TEXTURE_2D, 4, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_4_width,
383
pixel_4_height, 0, pixel_4_size, nullptr);
384
glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_5_size, pixel_5_data);
385
glCompressedTexImage2D(GL_TEXTURE_2D, 5, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_5_width,
386
pixel_5_height, 0, pixel_5_size, nullptr);
387
glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_6_size, pixel_6_data);
388
glCompressedTexImage2D(GL_TEXTURE_2D, 6, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_6_width,
389
pixel_6_height, 0, pixel_6_size, nullptr);
390
glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_7_size, pixel_7_data);
391
glCompressedTexImage2D(GL_TEXTURE_2D, 7, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_7_width,
392
pixel_7_height, 0, pixel_7_size, nullptr);
393
glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_8_size, pixel_8_data);
394
glCompressedTexImage2D(GL_TEXTURE_2D, 8, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_8_width,
395
pixel_8_height, 0, pixel_8_size, nullptr);
396
glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, pixel_9_size, pixel_9_data);
397
glCompressedTexImage2D(GL_TEXTURE_2D, 9, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_9_width,
398
pixel_9_height, 0, pixel_9_size, nullptr);
399
400
EXPECT_GL_NO_ERROR();
401
402
glUseProgram(mTextureProgram);
403
glUniform1i(mTextureUniformLocation, 0);
404
405
drawQuad(mTextureProgram, "position", 0.5f);
406
407
EXPECT_GL_NO_ERROR();
408
409
glDeleteTextures(1, &buffer);
410
glDeleteTextures(1, &texture);
411
412
EXPECT_GL_NO_ERROR();
413
}
414
415
// Test validation of glCompressedTexSubImage3D with DXT formats
416
TEST_P(DXT1CompressedTextureTestES3, CompressedTexSubImageValidation)
417
{
418
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_texture_compression_dxt1"));
419
420
GLTexture texture;
421
glBindTexture(GL_TEXTURE_2D_ARRAY, texture.get());
422
423
// Size mip 0 to a large size
424
glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_0_width,
425
pixel_0_height, 1, 0, pixel_0_size, nullptr);
426
ASSERT_GL_NO_ERROR();
427
428
// Set a sub image with a negative offset
429
glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, -1, 0, 0, 4, 4, 1,
430
GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, 8, pixel_1_data);
431
ASSERT_GL_ERROR(GL_INVALID_VALUE);
432
433
glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, -1, 0, 4, 4, 1,
434
GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, 8, pixel_1_data);
435
ASSERT_GL_ERROR(GL_INVALID_VALUE);
436
437
glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, -1, 4, 4, 1,
438
GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, 8, pixel_1_data);
439
ASSERT_GL_ERROR(GL_INVALID_VALUE);
440
}
441
442
// Test validation of glCompressedTexSubImage3D with DXT formats
443
TEST_P(DXT1CompressedTextureTestES3, CopyTexSubImage3DDisallowed)
444
{
445
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_texture_compression_dxt1"));
446
447
GLTexture texture;
448
glBindTexture(GL_TEXTURE_2D_ARRAY, texture.get());
449
450
GLsizei depth = 4;
451
glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, pixel_0_width,
452
pixel_0_height, depth, 0, pixel_0_size * depth, nullptr);
453
ASSERT_GL_NO_ERROR();
454
455
glCopyTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 0, 0, 4, 4);
456
ASSERT_GL_ERROR(GL_INVALID_OPERATION);
457
}
458
459
ANGLE_INSTANTIATE_TEST_ES2_AND_ES3(DXT1CompressedTextureTest);
460
461
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(DXT1CompressedTextureTestES3);
462
ANGLE_INSTANTIATE_TEST_ES3(DXT1CompressedTextureTestES3);
463
464