blob: accb1c9830b3da04aebb0fb3c22532f35a45179b [file] [log] [blame]
Avi Drissman05dfbc822022-09-13 21:25:341// Copyright 2012 The Chromium Authors
gman@chromium.org00f893d2010-08-24 18:55:492// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Arthur Sonzogni720f1c952024-07-25 16:17:515#ifdef UNSAFE_BUFFERS_BUILD
6// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
7#pragma allow_unsafe_buffers
8#endif
9
gman@chromium.org00f893d2010-08-24 18:55:4910#include "gpu/command_buffer/service/test_helper.h"
thakis@chromium.orga36c7b412010-10-14 21:17:0611
avif15d60a2015-12-21 17:06:3312#include <stddef.h>
13#include <stdint.h>
14
dmurph@chromium.org65dfc602012-07-23 20:39:3915#include <algorithm>
Kalvin Lee9e2c2e82025-04-16 22:37:4216#include <array>
Stephen Nuskof4e53402025-07-23 13:39:4417#include <cstdint>
brettw@chromium.orgf4ebe772013-02-02 00:21:3918#include <string>
dmurph@chromium.org65dfc602012-07-23 20:39:3919
Stephen Nuskof4e53402025-07-23 13:39:4420#include "base/containers/span.h"
21#include "base/numerics/safe_conversions.h"
zmo@chromium.org185de2a2013-04-04 22:57:1122#include "base/strings/string_number_conversions.h"
Sunny Sachanandanieb4c2a92021-06-04 23:00:3823#include "build/build_config.h"
gman@chromium.org17cfbe0e2013-03-07 01:26:0824#include "gpu/command_buffer/service/buffer_manager.h"
kloveless@chromium.orgd3eba342013-04-18 21:11:5025#include "gpu/command_buffer/service/error_state_mock.h"
kkinnunenc8b449e1582015-11-02 07:57:5126#include "gpu/command_buffer/service/feature_info.h"
bulach@chromium.org61eeb33f2011-07-26 15:30:3127#include "gpu/command_buffer/service/gl_utils.h"
zmo@chromium.org185de2a2013-04-04 22:57:1128#include "gpu/command_buffer/service/gpu_switches.h"
zmo576a0492014-09-13 01:12:3229#include "gpu/command_buffer/service/mocks.h"
gman@chromium.org0abf43e32012-05-10 23:36:2330#include "gpu/command_buffer/service/program_manager.h"
gman@chromium.org02965c22013-03-09 02:40:0731#include "gpu/command_buffer/service/texture_manager.h"
gman@chromium.org00f893d2010-08-24 18:55:4932#include "testing/gtest/include/gtest/gtest.h"
gman@chromium.orge16b0252012-12-07 09:07:4933#include "ui/gl/gl_mock.h"
kbrc9f0e10c2015-03-31 19:49:1234#include "ui/gl/gl_version_info.h"
gman@chromium.org00f893d2010-08-24 18:55:4935
36using ::testing::_;
37using ::testing::DoAll;
38using ::testing::InSequence;
39using ::testing::MatcherCast;
40using ::testing::Pointee;
zmo576a0492014-09-13 01:12:3241using ::testing::NotNull;
gman@chromium.org00f893d2010-08-24 18:55:4942using ::testing::Return;
43using ::testing::SetArrayArgument;
thestige147d682017-05-05 07:31:3144using ::testing::SetArgPointee;
kainino803bcd7b2016-08-31 02:52:2945using ::testing::SetArgPointee;
gman@chromium.org00f893d2010-08-24 18:55:4946using ::testing::StrEq;
47using ::testing::StrictMock;
48
49namespace gpu {
50namespace gles2 {
51
zmo88043c082014-10-09 20:38:5552namespace {
53
54template<typename T>
55T ConstructShaderVariable(
56 GLenum type, GLint array_size, GLenum precision,
57 bool static_use, const std::string& name) {
58 T var;
59 var.type = type;
Olli Etuaho263298eb2017-10-19 20:06:1860 var.setArraySize(array_size);
zmo88043c082014-10-09 20:38:5561 var.precision = precision;
62 var.staticUse = static_use;
63 var.name = name;
64 var.mappedName = name; // No name hashing.
65 return var;
66}
67
68} // namespace anonymous
69
gman@chromium.org00f893d2010-08-24 18:55:4970// GCC requires these declarations, but MSVC requires they not be present
71#ifndef COMPILER_MSVC
72const GLuint TestHelper::kServiceBlackTexture2dId;
gman@chromium.org00f893d2010-08-24 18:55:4973const GLuint TestHelper::kServiceDefaultTexture2dId;
qiankun.miao4e2f0d02015-09-18 03:34:4874const GLuint TestHelper::kServiceBlackTexture3dId;
75const GLuint TestHelper::kServiceDefaultTexture3dId;
76const GLuint TestHelper::kServiceBlackTexture2dArrayId;
77const GLuint TestHelper::kServiceDefaultTexture2dArrayId;
kbr@chromium.orge51bdf32011-11-23 22:21:4678const GLuint TestHelper::kServiceBlackTextureCubemapId;
gman@chromium.org00f893d2010-08-24 18:55:4979const GLuint TestHelper::kServiceDefaultTextureCubemapId;
bulach@chromium.org61eeb33f2011-07-26 15:30:3180const GLuint TestHelper::kServiceBlackExternalTextureId;
kbr@chromium.orge51bdf32011-11-23 22:21:4681const GLuint TestHelper::kServiceDefaultExternalTextureId;
82const GLuint TestHelper::kServiceBlackRectangleTextureId;
83const GLuint TestHelper::kServiceDefaultRectangleTextureId;
gman@chromium.org00f893d2010-08-24 18:55:4984
gman@chromium.org84afefa2011-10-19 21:45:5385const GLint TestHelper::kMaxSamples;
gman@chromium.org5094b0f2010-11-09 19:45:2486const GLint TestHelper::kMaxRenderbufferSize;
gman@chromium.org00f893d2010-08-24 18:55:4987const GLint TestHelper::kMaxTextureSize;
88const GLint TestHelper::kMaxCubeMapTextureSize;
sandersd9d0bb832014-12-17 01:24:5589const GLint TestHelper::kMaxRectangleTextureSize;
zmoea06a6f2015-04-30 01:15:4690const GLint TestHelper::kMax3DTextureSize;
zmo9bdab5d2016-05-05 04:35:2791const GLint TestHelper::kMaxArrayTextureLayers;
gman@chromium.org00f893d2010-08-24 18:55:4992const GLint TestHelper::kNumVertexAttribs;
93const GLint TestHelper::kNumTextureUnits;
94const GLint TestHelper::kMaxTextureImageUnits;
95const GLint TestHelper::kMaxVertexTextureImageUnits;
96const GLint TestHelper::kMaxFragmentUniformVectors;
gman@chromium.org915a59a12010-09-30 21:29:1197const GLint TestHelper::kMaxFragmentUniformComponents;
gman@chromium.org00f893d2010-08-24 18:55:4998const GLint TestHelper::kMaxVaryingVectors;
gman@chromium.org915a59a12010-09-30 21:29:1199const GLint TestHelper::kMaxVaryingFloats;
gman@chromium.org00f893d2010-08-24 18:55:49100const GLint TestHelper::kMaxVertexUniformVectors;
gman@chromium.org915a59a12010-09-30 21:29:11101const GLint TestHelper::kMaxVertexUniformComponents;
cwalleze96e24b2016-03-15 00:18:48102const GLint TestHelper::kMaxVertexOutputComponents;
103const GLint TestHelper::kMaxFragmentInputComponents;
104const GLint TestHelper::kMaxProgramTexelOffset;
105const GLint TestHelper::kMinProgramTexelOffset;
zmo706399be2016-04-21 00:01:08106const GLint TestHelper::kMaxTransformFeedbackSeparateAttribs;
107const GLint TestHelper::kMaxUniformBufferBindings;
108const GLint TestHelper::kUniformBufferOffsetAlignment;
gman@chromium.org00f893d2010-08-24 18:55:49109#endif
110
kbrc9f0e10c2015-03-31 19:49:12111std::vector<std::string> TestHelper::split_extensions_;
112
kbr@chromium.orge51bdf32011-11-23 22:21:46113void TestHelper::SetupTextureInitializationExpectations(
kylechar7a463842016-05-26 14:46:12114 ::gl::MockGLInterface* gl,
vmiura@chromium.org5ebf59f2014-04-08 03:51:57115 GLenum target,
116 bool use_default_textures) {
kbr@chromium.orge51bdf32011-11-23 22:21:46117 InSequence sequence;
118
119 bool needs_initialization = (target != GL_TEXTURE_EXTERNAL_OES);
120 bool needs_faces = (target == GL_TEXTURE_CUBE_MAP);
qiankun.miao4e2f0d02015-09-18 03:34:48121 bool is_3d_or_2d_array_target = (target == GL_TEXTURE_3D ||
122 target == GL_TEXTURE_2D_ARRAY);
kbr@chromium.orge51bdf32011-11-23 22:21:46123
124 static GLuint texture_2d_ids[] = {
125 kServiceBlackTexture2dId,
126 kServiceDefaultTexture2dId };
qiankun.miao4e2f0d02015-09-18 03:34:48127 static GLuint texture_3d_ids[] = {
128 kServiceBlackTexture3dId,
129 kServiceDefaultTexture3dId };
130 static GLuint texture_2d_array_ids[] = {
131 kServiceBlackTexture2dArrayId,
132 kServiceDefaultTexture2dArrayId };
kbr@chromium.orge51bdf32011-11-23 22:21:46133 static GLuint texture_cube_map_ids[] = {
134 kServiceBlackTextureCubemapId,
135 kServiceDefaultTextureCubemapId };
136 static GLuint texture_external_oes_ids[] = {
137 kServiceBlackExternalTextureId,
138 kServiceDefaultExternalTextureId };
139 static GLuint texture_rectangle_arb_ids[] = {
140 kServiceBlackRectangleTextureId,
141 kServiceDefaultRectangleTextureId };
142
Stephen Nuskof4e53402025-07-23 13:39:44143 base::span<const GLuint> texture_ids = {};
kbr@chromium.orge51bdf32011-11-23 22:21:46144 switch (target) {
145 case GL_TEXTURE_2D:
Stephen Nuskof4e53402025-07-23 13:39:44146 texture_ids = texture_2d_ids;
kbr@chromium.orge51bdf32011-11-23 22:21:46147 break;
qiankun.miao4e2f0d02015-09-18 03:34:48148 case GL_TEXTURE_3D:
Stephen Nuskof4e53402025-07-23 13:39:44149 texture_ids = texture_3d_ids;
qiankun.miao4e2f0d02015-09-18 03:34:48150 break;
151 case GL_TEXTURE_2D_ARRAY:
Stephen Nuskof4e53402025-07-23 13:39:44152 texture_ids = texture_2d_array_ids;
qiankun.miao4e2f0d02015-09-18 03:34:48153 break;
kbr@chromium.orge51bdf32011-11-23 22:21:46154 case GL_TEXTURE_CUBE_MAP:
Stephen Nuskof4e53402025-07-23 13:39:44155 texture_ids = texture_cube_map_ids;
kbr@chromium.orge51bdf32011-11-23 22:21:46156 break;
157 case GL_TEXTURE_EXTERNAL_OES:
Stephen Nuskof4e53402025-07-23 13:39:44158 texture_ids = texture_external_oes_ids;
kbr@chromium.orge51bdf32011-11-23 22:21:46159 break;
Geoff Lang8fc21cd2025-05-26 13:13:29160 case GL_TEXTURE_RECTANGLE_ANGLE:
Stephen Nuskof4e53402025-07-23 13:39:44161 texture_ids = texture_rectangle_arb_ids;
kbr@chromium.orge51bdf32011-11-23 22:21:46162 break;
163 default:
Peter BostrÃļma11556e2024-10-31 04:49:10164 NOTREACHED();
kbr@chromium.orge51bdf32011-11-23 22:21:46165 }
166
vmiura@chromium.org5ebf59f2014-04-08 03:51:57167 int array_size = use_default_textures ? 2 : 1;
kbr@chromium.orge51bdf32011-11-23 22:21:46168
169 EXPECT_CALL(*gl, GenTextures(array_size, _))
Stephen Nuskof4e53402025-07-23 13:39:44170 .WillOnce(SetArrayArgument<1>(
171 texture_ids.data(),
172 texture_ids.subspan(base::checked_cast<size_t>(array_size)).data()))
173 .RetiresOnSaturation();
kbr@chromium.orge51bdf32011-11-23 22:21:46174 for (int ii = 0; ii < array_size; ++ii) {
175 EXPECT_CALL(*gl, BindTexture(target, texture_ids[ii]))
176 .Times(1)
177 .RetiresOnSaturation();
178 if (needs_initialization) {
179 if (needs_faces) {
Kalvin Lee9e2c2e82025-04-16 22:37:42180 static auto faces = std::to_array<GLenum>({
181 GL_TEXTURE_CUBE_MAP_POSITIVE_X,
182 GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
183 GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
184 GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
185 GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
186 GL_TEXTURE_CUBE_MAP_NEGATIVE_Z,
187 });
Daniel Chengadafb3a2022-02-28 07:38:22188 for (size_t face = 0; face < std::size(faces); ++face) {
Peter Kasting905a2a92021-08-24 21:53:34189 EXPECT_CALL(*gl, TexImage2D(faces[face], 0, GL_RGBA, 1, 1, 0, GL_RGBA,
kbr@chromium.orge51bdf32011-11-23 22:21:46190 GL_UNSIGNED_BYTE, _))
191 .Times(1)
192 .RetiresOnSaturation();
193 }
194 } else {
qiankun.miao4e2f0d02015-09-18 03:34:48195 if (is_3d_or_2d_array_target) {
196 EXPECT_CALL(*gl, TexImage3D(target, 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA,
197 GL_UNSIGNED_BYTE, _))
198 .Times(1)
199 .RetiresOnSaturation();
200 } else {
201 EXPECT_CALL(*gl, TexImage2D(target, 0, GL_RGBA, 1, 1, 0, GL_RGBA,
202 GL_UNSIGNED_BYTE, _))
203 .Times(1)
204 .RetiresOnSaturation();
205 }
kbr@chromium.orge51bdf32011-11-23 22:21:46206 }
207 }
208 }
209 EXPECT_CALL(*gl, BindTexture(target, 0))
210 .Times(1)
211 .RetiresOnSaturation();
212}
213
gman@chromium.org00f893d2010-08-24 18:55:49214void TestHelper::SetupTextureManagerInitExpectations(
kylechar7a463842016-05-26 14:46:12215 ::gl::MockGLInterface* gl,
qiankun.miao4e2f0d02015-09-18 03:34:48216 bool is_es3_enabled,
qiankun.miao17ad0f1c2016-09-09 20:14:05217 bool is_es3_capable,
Michael Spangbe9d9eb2018-06-21 20:02:04218 const gfx::ExtensionSet& extensions,
vmiura@chromium.org5ebf59f2014-04-08 03:51:57219 bool use_default_textures) {
kbr@chromium.orge51bdf32011-11-23 22:21:46220 InSequence sequence;
221
qiankun.miao17ad0f1c2016-09-09 20:14:05222 if (is_es3_capable) {
223 EXPECT_CALL(*gl, BindBuffer(GL_PIXEL_UNPACK_BUFFER, 0))
224 .Times(1)
225 .RetiresOnSaturation();
226 }
227
vmiura@chromium.org5ebf59f2014-04-08 03:51:57228 SetupTextureInitializationExpectations(
229 gl, GL_TEXTURE_2D, use_default_textures);
230 SetupTextureInitializationExpectations(
231 gl, GL_TEXTURE_CUBE_MAP, use_default_textures);
bulach@chromium.org61eeb33f2011-07-26 15:30:31232
qiankun.miao4e2f0d02015-09-18 03:34:48233 if (is_es3_enabled) {
234 SetupTextureInitializationExpectations(
235 gl, GL_TEXTURE_3D, use_default_textures);
236 SetupTextureInitializationExpectations(
237 gl, GL_TEXTURE_2D_ARRAY, use_default_textures);
238 }
239
Antoine Labour20d16202017-09-05 23:05:29240 bool ext_image_external =
Michael Spangbe9d9eb2018-06-21 20:02:04241 gfx::HasExtension(extensions, "GL_OES_EGL_image_external");
Zhenyao Mocdfc4cc2024-07-03 18:15:26242 bool angle_texture_rectangle =
243 gfx::HasExtension(extensions, "GL_ANGLE_texture_rectangle");
bulach@chromium.org61eeb33f2011-07-26 15:30:31244
245 if (ext_image_external) {
vmiura@chromium.org5ebf59f2014-04-08 03:51:57246 SetupTextureInitializationExpectations(
247 gl, GL_TEXTURE_EXTERNAL_OES, use_default_textures);
kbr@chromium.orge51bdf32011-11-23 22:21:46248 }
Zhenyao Mocdfc4cc2024-07-03 18:15:26249 if (angle_texture_rectangle) {
Geoff Lang8fc21cd2025-05-26 13:13:29250 SetupTextureInitializationExpectations(gl, GL_TEXTURE_RECTANGLE_ANGLE,
251 use_default_textures);
bulach@chromium.org61eeb33f2011-07-26 15:30:31252 }
gman@chromium.org00f893d2010-08-24 18:55:49253}
254
gman@chromium.org1075a532012-06-13 00:52:33255void TestHelper::SetupTextureDestructionExpectations(
kylechar7a463842016-05-26 14:46:12256 ::gl::MockGLInterface* gl,
vmiura@chromium.org5ebf59f2014-04-08 03:51:57257 GLenum target,
258 bool use_default_textures) {
259 if (!use_default_textures)
260 return;
261
gman@chromium.org1075a532012-06-13 00:52:33262 GLuint texture_id = 0;
263 switch (target) {
264 case GL_TEXTURE_2D:
265 texture_id = kServiceDefaultTexture2dId;
266 break;
qiankun.miao4e2f0d02015-09-18 03:34:48267 case GL_TEXTURE_3D:
268 texture_id = kServiceDefaultTexture3dId;
269 break;
270 case GL_TEXTURE_2D_ARRAY:
271 texture_id = kServiceDefaultTexture2dArrayId;
272 break;
gman@chromium.org1075a532012-06-13 00:52:33273 case GL_TEXTURE_CUBE_MAP:
274 texture_id = kServiceDefaultTextureCubemapId;
275 break;
276 case GL_TEXTURE_EXTERNAL_OES:
277 texture_id = kServiceDefaultExternalTextureId;
278 break;
Geoff Lang8fc21cd2025-05-26 13:13:29279 case GL_TEXTURE_RECTANGLE_ANGLE:
gman@chromium.org1075a532012-06-13 00:52:33280 texture_id = kServiceDefaultRectangleTextureId;
281 break;
282 default:
Peter BostrÃļma11556e2024-10-31 04:49:10283 NOTREACHED();
gman@chromium.org1075a532012-06-13 00:52:33284 }
285
286 EXPECT_CALL(*gl, DeleteTextures(1, Pointee(texture_id)))
287 .Times(1)
288 .RetiresOnSaturation();
289}
290
291void TestHelper::SetupTextureManagerDestructionExpectations(
kylechar7a463842016-05-26 14:46:12292 ::gl::MockGLInterface* gl,
qiankun.miao4e2f0d02015-09-18 03:34:48293 bool is_es3_enabled,
Michael Spangbe9d9eb2018-06-21 20:02:04294 const gfx::ExtensionSet& extensions,
vmiura@chromium.org5ebf59f2014-04-08 03:51:57295 bool use_default_textures) {
296 SetupTextureDestructionExpectations(gl, GL_TEXTURE_2D, use_default_textures);
297 SetupTextureDestructionExpectations(
298 gl, GL_TEXTURE_CUBE_MAP, use_default_textures);
gman@chromium.org1075a532012-06-13 00:52:33299
qiankun.miao4e2f0d02015-09-18 03:34:48300 if (is_es3_enabled) {
301 SetupTextureDestructionExpectations(
302 gl, GL_TEXTURE_3D, use_default_textures);
303 SetupTextureDestructionExpectations(
304 gl, GL_TEXTURE_2D_ARRAY,use_default_textures);
305 }
306
Antoine Labour20d16202017-09-05 23:05:29307 bool ext_image_external =
Michael Spangbe9d9eb2018-06-21 20:02:04308 gfx::HasExtension(extensions, "GL_OES_EGL_image_external");
Geoff Lang8fc21cd2025-05-26 13:13:29309 bool angle_texture_rectangle =
310 gfx::HasExtension(extensions, "GL_ANGLE_texture_rectangle");
gman@chromium.org1075a532012-06-13 00:52:33311
312 if (ext_image_external) {
vmiura@chromium.org5ebf59f2014-04-08 03:51:57313 SetupTextureDestructionExpectations(
314 gl, GL_TEXTURE_EXTERNAL_OES, use_default_textures);
gman@chromium.org1075a532012-06-13 00:52:33315 }
Geoff Lang8fc21cd2025-05-26 13:13:29316 if (angle_texture_rectangle) {
317 SetupTextureDestructionExpectations(gl, GL_TEXTURE_RECTANGLE_ANGLE,
318 use_default_textures);
gman@chromium.org1075a532012-06-13 00:52:33319 }
320
qiankun.miao4e2f0d02015-09-18 03:34:48321 EXPECT_CALL(*gl, DeleteTextures(TextureManager::kNumDefaultTextures, _))
gman@chromium.org1075a532012-06-13 00:52:33322 .Times(1)
323 .RetiresOnSaturation();
324}
325
gman@chromium.org00f893d2010-08-24 18:55:49326void TestHelper::SetupContextGroupInitExpectations(
kylechar7a463842016-05-26 14:46:12327 ::gl::MockGLInterface* gl,
vmiura@chromium.org5ebf59f2014-04-08 03:51:57328 const DisallowedFeatures& disallowed_features,
329 const char* extensions,
330 const char* gl_version,
kylechar933c6fc2025-09-04 17:29:47331 ContextType context_type) {
gman@chromium.org00f893d2010-08-24 18:55:49332 InSequence sequence;
333
kaininoe20d23ac2016-11-03 01:03:45334 bool enable_es3 = !(context_type == CONTEXT_TYPE_OPENGLES2 ||
335 context_type == CONTEXT_TYPE_WEBGL1);
336
Michael Spangbe9d9eb2018-06-21 20:02:04337 gfx::ExtensionSet extension_set(gfx::MakeExtensionSet(extensions));
Antoine Labour20d16202017-09-05 23:05:29338 gl::GLVersionInfo gl_info(gl_version, "", extension_set);
gman@chromium.org915a59a12010-09-30 21:29:11339
kainino803bcd7b2016-08-31 02:52:29340 SetupFeatureInfoInitExpectationsWithGLVersion(gl, extensions, "", gl_version,
kaininoe20d23ac2016-11-03 01:03:45341 context_type);
gman@chromium.org5094b0f2010-11-09 19:45:24342 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_RENDERBUFFER_SIZE, _))
thestige147d682017-05-05 07:31:31343 .WillOnce(SetArgPointee<1>(kMaxRenderbufferSize))
gman@chromium.org5094b0f2010-11-09 19:45:24344 .RetiresOnSaturation();
Zhenyao Mo08f60e832024-07-09 19:12:23345 if (gfx::HasExtension(extension_set, "GL_EXT_framebuffer_multisample") ||
Michael Spangbe9d9eb2018-06-21 20:02:04346 gfx::HasExtension(extension_set,
347 "GL_EXT_multisampled_render_to_texture") ||
Zhenyao Mofadb61562024-06-17 19:40:58348 gl_info.is_es3) {
gman@chromium.org84afefa2011-10-19 21:45:53349 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_SAMPLES, _))
thestige147d682017-05-05 07:31:31350 .WillOnce(SetArgPointee<1>(kMaxSamples))
gman@chromium.org84afefa2011-10-19 21:45:53351 .RetiresOnSaturation();
Michael Spangbe9d9eb2018-06-21 20:02:04352 } else if (gfx::HasExtension(extension_set,
353 "GL_IMG_multisampled_render_to_texture")) {
sievers@chromium.org49cabed2013-11-13 18:15:18354 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_SAMPLES_IMG, _))
thestige147d682017-05-05 07:31:31355 .WillOnce(SetArgPointee<1>(kMaxSamples))
sievers@chromium.org49cabed2013-11-13 18:15:18356 .RetiresOnSaturation();
gman@chromium.org84afefa2011-10-19 21:45:53357 }
kkinnunen8cefb232015-12-04 09:36:31358
kainino313016a2017-02-17 19:55:22359 if (enable_es3 ||
360 (!enable_es3 &&
Zhenyao Mofadb61562024-06-17 19:40:58361 (gfx::HasExtension(extension_set, "GL_EXT_draw_buffers") ||
Antoine Labour20d16202017-09-05 23:05:29362 (gl_info.is_es3 &&
Michael Spangbe9d9eb2018-06-21 20:02:04363 gfx::HasExtension(extension_set, "GL_NV_draw_buffers"))))) {
cwallezdc1c9eb2016-05-26 03:11:56364 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, _))
thestige147d682017-05-05 07:31:31365 .WillOnce(SetArgPointee<1>(8))
cwallezdc1c9eb2016-05-26 03:11:56366 .RetiresOnSaturation();
Geoff Lang8fc21cd2025-05-26 13:13:29367 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_DRAW_BUFFERS, _))
thestige147d682017-05-05 07:31:31368 .WillOnce(SetArgPointee<1>(8))
cwallezdc1c9eb2016-05-26 03:11:56369 .RetiresOnSaturation();
370 }
371
Zhenyao Moe531bb322024-07-09 17:34:02372 if (gfx::HasExtension(extension_set, "GL_EXT_blend_func_extended")) {
kkinnunen8cefb232015-12-04 09:36:31373 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_DUAL_SOURCE_DRAW_BUFFERS_EXT, _))
thestige147d682017-05-05 07:31:31374 .WillOnce(SetArgPointee<1>(8))
kkinnunen8cefb232015-12-04 09:36:31375 .RetiresOnSaturation();
376 }
377
Zhenyao Mof3028282024-07-03 17:31:43378 if (gl_info.IsAtLeastGLES(3, 0)) {
zmo706399be2016-04-21 00:01:08379 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, _))
thestige147d682017-05-05 07:31:31380 .WillOnce(SetArgPointee<1>(kMaxTransformFeedbackSeparateAttribs))
zmo706399be2016-04-21 00:01:08381 .RetiresOnSaturation();
382 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, _))
thestige147d682017-05-05 07:31:31383 .WillOnce(SetArgPointee<1>(kMaxUniformBufferBindings))
zmo706399be2016-04-21 00:01:08384 .RetiresOnSaturation();
385 EXPECT_CALL(*gl, GetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, _))
thestige147d682017-05-05 07:31:31386 .WillOnce(SetArgPointee<1>(kUniformBufferOffsetAlignment))
zmo706399be2016-04-21 00:01:08387 .RetiresOnSaturation();
388 }
389
gman@chromium.org00f893d2010-08-24 18:55:49390 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_VERTEX_ATTRIBS, _))
thestige147d682017-05-05 07:31:31391 .WillOnce(SetArgPointee<1>(kNumVertexAttribs))
gman@chromium.org00f893d2010-08-24 18:55:49392 .RetiresOnSaturation();
393 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, _))
thestige147d682017-05-05 07:31:31394 .WillOnce(SetArgPointee<1>(kNumTextureUnits))
gman@chromium.org00f893d2010-08-24 18:55:49395 .RetiresOnSaturation();
396 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_TEXTURE_SIZE, _))
thestige147d682017-05-05 07:31:31397 .WillOnce(SetArgPointee<1>(kMaxTextureSize))
gman@chromium.org00f893d2010-08-24 18:55:49398 .RetiresOnSaturation();
399 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, _))
thestige147d682017-05-05 07:31:31400 .WillOnce(SetArgPointee<1>(kMaxCubeMapTextureSize))
gman@chromium.org00f893d2010-08-24 18:55:49401 .RetiresOnSaturation();
Zhenyao Mof3028282024-07-03 17:31:43402 if (gl_info.IsAtLeastGLES(3, 0)) {
zmoea06a6f2015-04-30 01:15:46403 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_3D_TEXTURE_SIZE, _))
thestige147d682017-05-05 07:31:31404 .WillOnce(SetArgPointee<1>(kMax3DTextureSize))
zmoea06a6f2015-04-30 01:15:46405 .RetiresOnSaturation();
406 }
Zhenyao Mof3028282024-07-03 17:31:43407 if (gl_info.IsAtLeastGLES(3, 0)) {
zmo9bdab5d2016-05-05 04:35:27408 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, _))
thestige147d682017-05-05 07:31:31409 .WillOnce(SetArgPointee<1>(kMaxArrayTextureLayers))
zmo9bdab5d2016-05-05 04:35:27410 .RetiresOnSaturation();
411 }
Zhenyao Mocdfc4cc2024-07-03 18:15:26412 if (gfx::HasExtension(extension_set, "GL_ANGLE_texture_rectangle")) {
Geoff Lang8fc21cd2025-05-26 13:13:29413 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_RECTANGLE_TEXTURE_SIZE_ANGLE, _))
thestige147d682017-05-05 07:31:31414 .WillOnce(SetArgPointee<1>(kMaxRectangleTextureSize))
sandersd9d0bb832014-12-17 01:24:55415 .RetiresOnSaturation();
416 }
gman@chromium.org00f893d2010-08-24 18:55:49417 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, _))
thestige147d682017-05-05 07:31:31418 .WillOnce(SetArgPointee<1>(kMaxTextureImageUnits))
gman@chromium.org00f893d2010-08-24 18:55:49419 .RetiresOnSaturation();
420 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, _))
thestige147d682017-05-05 07:31:31421 .WillOnce(SetArgPointee<1>(kMaxVertexTextureImageUnits))
gman@chromium.org00f893d2010-08-24 18:55:49422 .RetiresOnSaturation();
kbrc9f0e10c2015-03-31 19:49:12423
Zhenyao Mo4dff3bd92024-06-28 15:21:04424 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_FRAGMENT_UNIFORM_VECTORS, _))
425 .WillOnce(SetArgPointee<1>(kMaxFragmentUniformVectors))
426 .RetiresOnSaturation();
427 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_VARYING_VECTORS, _))
428 .WillOnce(SetArgPointee<1>(kMaxVaryingVectors))
429 .RetiresOnSaturation();
430 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_VERTEX_UNIFORM_VECTORS, _))
431 .WillOnce(SetArgPointee<1>(kMaxVertexUniformVectors))
432 .RetiresOnSaturation();
gman@chromium.org00f893d2010-08-24 18:55:49433
cwalleze96e24b2016-03-15 00:18:48434 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_VERTEX_OUTPUT_COMPONENTS, _))
435 .Times(testing::Between(0, 1))
thestige147d682017-05-05 07:31:31436 .WillRepeatedly(SetArgPointee<1>(kMaxVertexOutputComponents))
cwalleze96e24b2016-03-15 00:18:48437 .RetiresOnSaturation();
438 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_FRAGMENT_INPUT_COMPONENTS, _))
439 .Times(testing::Between(0, 1))
thestige147d682017-05-05 07:31:31440 .WillRepeatedly(SetArgPointee<1>(kMaxFragmentInputComponents))
cwalleze96e24b2016-03-15 00:18:48441 .RetiresOnSaturation();
442 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_PROGRAM_TEXEL_OFFSET, _))
443 .Times(testing::Between(0, 1))
thestige147d682017-05-05 07:31:31444 .WillRepeatedly(SetArgPointee<1>(kMaxProgramTexelOffset))
cwalleze96e24b2016-03-15 00:18:48445 .RetiresOnSaturation();
446 EXPECT_CALL(*gl, GetIntegerv(GL_MIN_PROGRAM_TEXEL_OFFSET, _))
447 .Times(testing::Between(0, 1))
thestige147d682017-05-05 07:31:31448 .WillRepeatedly(SetArgPointee<1>(kMinProgramTexelOffset))
cwalleze96e24b2016-03-15 00:18:48449 .RetiresOnSaturation();
450
kylechar933c6fc2025-09-04 17:29:47451 bool use_default_textures = false;
Zhenyao Mof3028282024-07-03 17:31:43452 SetupTextureManagerInitExpectations(gl, enable_es3,
453 gl_info.IsAtLeastGLES(3, 0),
Antoine Labour20d16202017-09-05 23:05:29454 extension_set, use_default_textures);
gman@chromium.org00f893d2010-08-24 18:55:49455}
456
kylechar7a463842016-05-26 14:46:12457void TestHelper::SetupFeatureInfoInitExpectations(::gl::MockGLInterface* gl,
458 const char* extensions) {
Zhenyao Mo130817442024-07-10 20:41:09459 SetupFeatureInfoInitExpectationsWithGLVersion(
460 gl, extensions, "ANGLE", "OpenGL ES 2.0", CONTEXT_TYPE_OPENGLES2);
gman@chromium.org5c67c7032012-05-15 18:21:22461}
462
zmo@chromium.org185de2a2013-04-04 22:57:11463void TestHelper::SetupFeatureInfoInitExpectationsWithGLVersion(
kylechar7a463842016-05-26 14:46:12464 ::gl::MockGLInterface* gl,
465 const char* extensions,
466 const char* gl_renderer,
467 const char* gl_version,
kaininoe20d23ac2016-11-03 01:03:45468 ContextType context_type) {
gman@chromium.org915a59a12010-09-30 21:29:11469 InSequence sequence;
470
kaininoe20d23ac2016-11-03 01:03:45471 bool enable_es3 = context_type == CONTEXT_TYPE_WEBGL2 ||
472 context_type == CONTEXT_TYPE_OPENGLES3;
473
Michael Spangbe9d9eb2018-06-21 20:02:04474 gfx::ExtensionSet extension_set(gfx::MakeExtensionSet(extensions));
kbrc9f0e10c2015-03-31 19:49:12475 // Persistent storage is needed for the split extension string.
Antoine Labour20d16202017-09-05 23:05:29476 split_extensions_ =
477 std::vector<std::string>(extension_set.begin(), extension_set.end());
478 gl::GLVersionInfo gl_info(gl_version, gl_renderer, extension_set);
Zhenyao Mo08f60e832024-07-09 19:12:23479 EXPECT_CALL(*gl, GetString(GL_EXTENSIONS))
480 .WillOnce(Return(reinterpret_cast<const uint8_t*>(extensions)))
481 .RetiresOnSaturation();
kbrc9f0e10c2015-03-31 19:49:12482
kbr53edb992015-08-06 01:16:29483 EXPECT_CALL(*gl, GetString(GL_VERSION))
avif15d60a2015-12-21 17:06:33484 .WillOnce(Return(reinterpret_cast<const uint8_t*>(gl_version)))
kbr53edb992015-08-06 01:16:29485 .RetiresOnSaturation();
kbrc9f0e10c2015-03-31 19:49:12486 EXPECT_CALL(*gl, GetString(GL_RENDERER))
avif15d60a2015-12-21 17:06:33487 .WillOnce(Return(reinterpret_cast<const uint8_t*>(gl_renderer)))
kbrc9f0e10c2015-03-31 19:49:12488 .RetiresOnSaturation();
oetuaho@nvidia.com17a961192014-02-14 15:20:52489
Zhenyao Mofadb61562024-06-17 19:40:58490 if (gl_info.is_es3 ||
Antoine Labourae9d975a2018-11-17 00:47:45491 gfx::HasExtension(extension_set, "GL_ARB_pixel_buffer_object") ||
Michael Spangbe9d9eb2018-06-21 20:02:04492 gfx::HasExtension(extension_set, "GL_NV_pixel_buffer_object")) {
kainino803bcd7b2016-08-31 02:52:29493 EXPECT_CALL(*gl, GetIntegerv(GL_PIXEL_UNPACK_BUFFER_BINDING, _))
494 .WillOnce(SetArgPointee<1>(0))
495 .RetiresOnSaturation();
496 }
497
Zhenyao Mofadb61562024-06-17 19:40:58498 if (gfx::HasExtension(extension_set, "GL_ARB_texture_float") ||
Antoine Labour20d16202017-09-05 23:05:29499 (gl_info.is_es3 &&
Michael Spangbe9d9eb2018-06-21 20:02:04500 gfx::HasExtension(extension_set, "GL_OES_texture_float") &&
501 gfx::HasExtension(extension_set, "GL_EXT_color_buffer_float"))) {
Stephen Nuskof4e53402025-07-23 13:39:44502 static const auto tx_ids = std::to_array<GLuint>({101, 102});
503 static const auto fb_ids = std::to_array<GLuint>({103, 104});
oetuaho@nvidia.com17a961192014-02-14 15:20:52504 const GLsizei width = 16;
505 EXPECT_CALL(*gl, GetIntegerv(GL_FRAMEBUFFER_BINDING, _))
thestige147d682017-05-05 07:31:31506 .WillOnce(SetArgPointee<1>(fb_ids[0]))
oetuaho@nvidia.com17a961192014-02-14 15:20:52507 .RetiresOnSaturation();
508 EXPECT_CALL(*gl, GetIntegerv(GL_TEXTURE_BINDING_2D, _))
thestige147d682017-05-05 07:31:31509 .WillOnce(SetArgPointee<1>(tx_ids[0]))
oetuaho@nvidia.com17a961192014-02-14 15:20:52510 .RetiresOnSaturation();
511 EXPECT_CALL(*gl, GenTextures(1, _))
Stephen Nuskof4e53402025-07-23 13:39:44512 .WillOnce(SetArrayArgument<1>(
513 base::span<const GLuint>(tx_ids).subspan(1u).data(),
514 base::span<const GLuint>(tx_ids).subspan(2u).data()))
oetuaho@nvidia.com17a961192014-02-14 15:20:52515 .RetiresOnSaturation();
516 EXPECT_CALL(*gl, GenFramebuffersEXT(1, _))
Stephen Nuskof4e53402025-07-23 13:39:44517 .WillOnce(SetArrayArgument<1>(
518 base::span<const GLuint>(fb_ids).subspan(1u).data(),
519 base::span<const GLuint>(fb_ids).subspan(2u).data()))
oetuaho@nvidia.com17a961192014-02-14 15:20:52520 .RetiresOnSaturation();
hendrikw83f2fb52014-12-02 03:30:40521 EXPECT_CALL(*gl, BindTexture(GL_TEXTURE_2D, tx_ids[1]))
oetuaho@nvidia.com17a961192014-02-14 15:20:52522 .Times(1)
523 .RetiresOnSaturation();
524 EXPECT_CALL(*gl, TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
525 GL_NEAREST))
526 .Times(1)
527 .RetiresOnSaturation();
528 EXPECT_CALL(*gl, TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, width, width, 0,
529 GL_RGBA, GL_FLOAT, _))
530 .Times(1)
531 .RetiresOnSaturation();
hendrikw83f2fb52014-12-02 03:30:40532 EXPECT_CALL(*gl, BindFramebufferEXT(GL_FRAMEBUFFER, fb_ids[1]))
oetuaho@nvidia.com17a961192014-02-14 15:20:52533 .Times(1)
534 .RetiresOnSaturation();
535 EXPECT_CALL(*gl, FramebufferTexture2DEXT(GL_FRAMEBUFFER,
hendrikw83f2fb52014-12-02 03:30:40536 GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tx_ids[1], 0))
oetuaho@nvidia.com17a961192014-02-14 15:20:52537 .Times(1)
538 .RetiresOnSaturation();
539 EXPECT_CALL(*gl, CheckFramebufferStatusEXT(GL_FRAMEBUFFER))
540 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE))
541 .RetiresOnSaturation();
qiankun.miaobd9c6582016-11-03 15:26:55542 GLenum status_rgba = GL_FRAMEBUFFER_COMPLETE;
oetuaho@nvidia.com17a961192014-02-14 15:20:52543 EXPECT_CALL(*gl, TexImage2D(GL_TEXTURE_2D, 0, GL_RGB32F, width, width, 0,
544 GL_RGB, GL_FLOAT, _))
545 .Times(1)
546 .RetiresOnSaturation();
kbrc9f0e10c2015-03-31 19:49:12547 if (gl_info.is_es3) {
oetuaho@nvidia.com17a961192014-02-14 15:20:52548 EXPECT_CALL(*gl, CheckFramebufferStatusEXT(GL_FRAMEBUFFER))
549 .WillOnce(Return(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT))
550 .RetiresOnSaturation();
551 } else {
552 EXPECT_CALL(*gl, CheckFramebufferStatusEXT(GL_FRAMEBUFFER))
553 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE))
554 .RetiresOnSaturation();
kaininoe20d23ac2016-11-03 01:03:45555 }
bajones2c9d7182016-03-11 18:16:28556
kbr75c64262017-02-05 00:34:11557 if (status_rgba == GL_FRAMEBUFFER_COMPLETE && enable_es3) {
kaininoe20d23ac2016-11-03 01:03:45558 EXPECT_CALL(*gl, TexImage2D(GL_TEXTURE_2D, 0, GL_R16F, width, width,
559 0, GL_RED, GL_FLOAT, _))
560 .Times(1)
561 .RetiresOnSaturation();
562 EXPECT_CALL(*gl, CheckFramebufferStatusEXT(GL_FRAMEBUFFER))
563 .Times(1)
564 .RetiresOnSaturation();
565 EXPECT_CALL(*gl, TexImage2D(GL_TEXTURE_2D, 0, GL_RG16F, width, width,
566 0, GL_RG, GL_FLOAT, _))
567 .Times(1)
568 .RetiresOnSaturation();
569 EXPECT_CALL(*gl, CheckFramebufferStatusEXT(GL_FRAMEBUFFER))
570 .Times(1)
571 .RetiresOnSaturation();
572 EXPECT_CALL(*gl, TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, width, width,
573 0, GL_RGBA, GL_FLOAT, _))
574 .Times(1)
575 .RetiresOnSaturation();
576 EXPECT_CALL(*gl, CheckFramebufferStatusEXT(GL_FRAMEBUFFER))
577 .Times(1)
578 .RetiresOnSaturation();
579 EXPECT_CALL(*gl, TexImage2D(GL_TEXTURE_2D, 0, GL_R32F, width, width,
580 0, GL_RED, GL_FLOAT, _))
581 .Times(1)
582 .RetiresOnSaturation();
583 EXPECT_CALL(*gl, CheckFramebufferStatusEXT(GL_FRAMEBUFFER))
584 .Times(1)
585 .RetiresOnSaturation();
586 EXPECT_CALL(*gl, TexImage2D(GL_TEXTURE_2D, 0, GL_RG32F, width, width,
587 0, GL_RG, GL_FLOAT, _))
588 .Times(1)
589 .RetiresOnSaturation();
590 EXPECT_CALL(*gl, CheckFramebufferStatusEXT(GL_FRAMEBUFFER))
591 .Times(1)
592 .RetiresOnSaturation();
593 EXPECT_CALL(*gl, TexImage2D(GL_TEXTURE_2D, 0, GL_R11F_G11F_B10F,
594 width, width, 0, GL_RGB, GL_FLOAT, _))
595 .Times(1)
596 .RetiresOnSaturation();
597 EXPECT_CALL(*gl, CheckFramebufferStatusEXT(GL_FRAMEBUFFER))
598 .Times(1)
599 .RetiresOnSaturation();
oetuaho@nvidia.com17a961192014-02-14 15:20:52600 }
Antoine Labour20d16202017-09-05 23:05:29601 if (!enable_es3 &&
Michael Spangbe9d9eb2018-06-21 20:02:04602 !gfx::HasExtension(extension_set, "GL_EXT_color_buffer_half_float") &&
Zhenyao Moe531bb322024-07-09 17:34:02603 gl_info.IsAtLeastGLES(3, 0)) {
Zhenyao Moc82b9b9a2017-09-26 01:27:03604 EXPECT_CALL(*gl, TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, width, width, 0,
605 GL_RGBA, GL_HALF_FLOAT, nullptr))
ccameron85072152017-02-24 19:53:23606 .Times(1)
607 .RetiresOnSaturation();
608 EXPECT_CALL(*gl, CheckFramebufferStatusEXT(GL_FRAMEBUFFER))
609 .Times(1)
610 .RetiresOnSaturation();
611 }
bajones2c9d7182016-03-11 18:16:28612
oetuaho@nvidia.com17a961192014-02-14 15:20:52613 EXPECT_CALL(*gl, DeleteFramebuffersEXT(1, _))
614 .Times(1)
615 .RetiresOnSaturation();
616 EXPECT_CALL(*gl, DeleteTextures(1, _))
617 .Times(1)
618 .RetiresOnSaturation();
hendrikw83f2fb52014-12-02 03:30:40619 EXPECT_CALL(*gl, BindFramebufferEXT(GL_FRAMEBUFFER, fb_ids[0]))
oetuaho@nvidia.com17a961192014-02-14 15:20:52620 .Times(1)
621 .RetiresOnSaturation();
hendrikw83f2fb52014-12-02 03:30:40622 EXPECT_CALL(*gl, BindTexture(GL_TEXTURE_2D, tx_ids[0]))
oetuaho@nvidia.com17a961192014-02-14 15:20:52623 .Times(1)
624 .RetiresOnSaturation();
danakje649f572015-01-08 23:35:58625#if DCHECK_IS_ON()
wangxianzhu@chromium.orgc02cb8012014-03-14 18:39:53626 EXPECT_CALL(*gl, GetError())
627 .WillOnce(Return(GL_NO_ERROR))
628 .RetiresOnSaturation();
629#endif
oetuaho@nvidia.com17a961192014-02-14 15:20:52630 }
oetuaho0decd442014-10-13 08:40:46631
kainino313016a2017-02-17 19:55:22632 if (enable_es3 ||
633 (!enable_es3 &&
Zhenyao Mofadb61562024-06-17 19:40:58634 (gfx::HasExtension(extension_set, "GL_EXT_draw_buffers") ||
Michael Spangbe9d9eb2018-06-21 20:02:04635 gfx::HasExtension(extension_set, "GL_ARB_draw_buffers") ||
Antoine Labour20d16202017-09-05 23:05:29636 (gl_info.is_es3 &&
Michael Spangbe9d9eb2018-06-21 20:02:04637 gfx::HasExtension(extension_set, "GL_NV_draw_buffers"))))) {
oetuaho0decd442014-10-13 08:40:46638 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, _))
thestige147d682017-05-05 07:31:31639 .WillOnce(SetArgPointee<1>(8))
oetuaho0decd442014-10-13 08:40:46640 .RetiresOnSaturation();
Geoff Lang8fc21cd2025-05-26 13:13:29641 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_DRAW_BUFFERS, _))
thestige147d682017-05-05 07:31:31642 .WillOnce(SetArgPointee<1>(8))
oetuaho0decd442014-10-13 08:40:46643 .RetiresOnSaturation();
644 }
hendrikw83f2fb52014-12-02 03:30:40645
Kenneth Russell47d9ef72023-07-18 01:17:03646 // These expectations are for IsGL_REDSupportedOnFBOs(), which is
647 // skipped universally on macOS, and by default (with a Finch
648 // kill-switch) on Android.
649#if !BUILDFLAG(IS_MAC) && !BUILDFLAG(IS_ANDROID)
Zhenyao Mofadb61562024-06-17 19:40:58650 if (gl_info.is_es3 || gfx::HasExtension(extension_set, "GL_EXT_texture_rg") ||
Michael Spangbe9d9eb2018-06-21 20:02:04651 (gfx::HasExtension(extension_set, "GL_ARB_texture_rg"))) {
Antoine Labour5e48f902017-11-06 21:46:21652#if DCHECK_IS_ON()
653 EXPECT_CALL(*gl, GetError())
654 .WillOnce(Return(GL_NO_ERROR))
655 .RetiresOnSaturation();
656#endif
Stephen Nuskof4e53402025-07-23 13:39:44657 static const auto tx_ids = std::to_array<GLuint>({101, 102});
658 static const auto fb_ids = std::to_array<GLuint>({103, 104});
Kenneth Russell734c5f12023-01-22 19:42:51659 const GLsizei width = 8;
hendrikw83f2fb52014-12-02 03:30:40660 EXPECT_CALL(*gl, GetIntegerv(GL_FRAMEBUFFER_BINDING, _))
thestige147d682017-05-05 07:31:31661 .WillOnce(SetArgPointee<1>(fb_ids[0]))
hendrikw83f2fb52014-12-02 03:30:40662 .RetiresOnSaturation();
663 EXPECT_CALL(*gl, GetIntegerv(GL_TEXTURE_BINDING_2D, _))
thestige147d682017-05-05 07:31:31664 .WillOnce(SetArgPointee<1>(tx_ids[0]))
hendrikw83f2fb52014-12-02 03:30:40665 .RetiresOnSaturation();
666 EXPECT_CALL(*gl, GenTextures(1, _))
Stephen Nuskof4e53402025-07-23 13:39:44667 .WillOnce(SetArrayArgument<1>(
668 base::span<const GLuint>(tx_ids).subspan(1u).data(),
669 base::span<const GLuint>(tx_ids).subspan(2u).data()))
hendrikw83f2fb52014-12-02 03:30:40670 .RetiresOnSaturation();
671 EXPECT_CALL(*gl, BindTexture(GL_TEXTURE_2D, tx_ids[1]))
672 .Times(1)
673 .RetiresOnSaturation();
hendrikwbef24f5c2014-12-05 01:01:42674 EXPECT_CALL(*gl, TexImage2D(GL_TEXTURE_2D, 0, _, width, width, 0,
hendrikw83f2fb52014-12-02 03:30:40675 GL_RED_EXT, GL_UNSIGNED_BYTE, _))
676 .Times(1)
677 .RetiresOnSaturation();
678 EXPECT_CALL(*gl, GenFramebuffersEXT(1, _))
Stephen Nuskof4e53402025-07-23 13:39:44679 .WillOnce(SetArrayArgument<1>(
680 base::span<const GLuint>(fb_ids).subspan(1u).data(),
681 base::span<const GLuint>(fb_ids).subspan(2u).data()))
hendrikw83f2fb52014-12-02 03:30:40682 .RetiresOnSaturation();
683 EXPECT_CALL(*gl, BindFramebufferEXT(GL_FRAMEBUFFER, fb_ids[1]))
684 .Times(1)
685 .RetiresOnSaturation();
686 EXPECT_CALL(*gl, FramebufferTexture2DEXT(GL_FRAMEBUFFER,
687 GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tx_ids[1], 0))
688 .Times(1)
689 .RetiresOnSaturation();
690 EXPECT_CALL(*gl, CheckFramebufferStatusEXT(GL_FRAMEBUFFER))
691 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE))
692 .RetiresOnSaturation();
693 EXPECT_CALL(*gl, DeleteFramebuffersEXT(1, _))
694 .Times(1)
695 .RetiresOnSaturation();
696 EXPECT_CALL(*gl, DeleteTextures(1, _))
697 .Times(1)
698 .RetiresOnSaturation();
699 EXPECT_CALL(*gl, BindFramebufferEXT(GL_FRAMEBUFFER, fb_ids[0]))
700 .Times(1)
701 .RetiresOnSaturation();
702 EXPECT_CALL(*gl, BindTexture(GL_TEXTURE_2D, tx_ids[0]))
703 .Times(1)
704 .RetiresOnSaturation();
danakje649f572015-01-08 23:35:58705#if DCHECK_IS_ON()
hendrikw83f2fb52014-12-02 03:30:40706 EXPECT_CALL(*gl, GetError())
707 .WillOnce(Return(GL_NO_ERROR))
708 .RetiresOnSaturation();
709#endif
710 }
Xiaohan Wangfa22d3e2022-01-15 02:02:43711#endif // !BUILDFLAG(IS_MAC)
gman@chromium.org915a59a12010-09-30 21:29:11712}
713
dmurph@chromium.org65dfc602012-07-23 20:39:39714void TestHelper::SetupProgramSuccessExpectations(
kylechar7a463842016-05-26 14:46:12715 ::gl::MockGLInterface* gl,
kkinnunenc8b449e1582015-11-02 07:57:51716 const FeatureInfo* feature_info,
717 AttribInfo* attribs,
718 size_t num_attribs,
719 UniformInfo* uniforms,
720 size_t num_uniforms,
721 VaryingInfo* varyings,
722 size_t num_varyings,
Stephen Nuskof4e53402025-07-23 13:39:44723 base::span<ProgramOutputInfo> program_outputs,
724 size_t spanification_suspected_redundant_num_program_outputs,
gman@chromium.org0abf43e32012-05-10 23:36:23725 GLuint service_id) {
Stephen Nuskof4e53402025-07-23 13:39:44726 // TODO(crbug.com/431824301): Remove unneeded parameter once validated to be
727 // redundant in M143.
728 CHECK(spanification_suspected_redundant_num_program_outputs ==
729 program_outputs.size(),
730 base::NotFatalUntil::M143);
thestige147d682017-05-05 07:31:31731 EXPECT_CALL(*gl, GetProgramiv(service_id, GL_LINK_STATUS, _))
732 .WillOnce(SetArgPointee<2>(1))
gman@chromium.org0abf43e32012-05-10 23:36:23733 .RetiresOnSaturation();
thestige147d682017-05-05 07:31:31734 EXPECT_CALL(*gl, GetProgramiv(service_id, GL_INFO_LOG_LENGTH, _))
735 .WillOnce(SetArgPointee<2>(0))
gman@chromium.org0abf43e32012-05-10 23:36:23736 .RetiresOnSaturation();
thestige147d682017-05-05 07:31:31737 EXPECT_CALL(*gl, GetProgramiv(service_id, GL_ACTIVE_ATTRIBUTES, _))
738 .WillOnce(SetArgPointee<2>(num_attribs))
gman@chromium.org0abf43e32012-05-10 23:36:23739 .RetiresOnSaturation();
740 size_t max_attrib_len = 0;
741 for (size_t ii = 0; ii < num_attribs; ++ii) {
742 size_t len = strlen(attribs[ii].name) + 1;
743 max_attrib_len = std::max(max_attrib_len, len);
744 }
thestige147d682017-05-05 07:31:31745 EXPECT_CALL(*gl, GetProgramiv(service_id, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, _))
746 .WillOnce(SetArgPointee<2>(max_attrib_len))
gman@chromium.org0abf43e32012-05-10 23:36:23747 .RetiresOnSaturation();
gman@chromium.org3f00df92012-06-19 00:44:58748
gman@chromium.org0abf43e32012-05-10 23:36:23749 for (size_t ii = 0; ii < num_attribs; ++ii) {
750 const AttribInfo& info = attribs[ii];
751 EXPECT_CALL(*gl,
thestige147d682017-05-05 07:31:31752 GetActiveAttrib(service_id, ii, max_attrib_len, _, _, _, _))
gman@chromium.org0abf43e32012-05-10 23:36:23753 .WillOnce(DoAll(
thestige147d682017-05-05 07:31:31754 SetArgPointee<3>(strlen(info.name)), SetArgPointee<4>(info.size),
755 SetArgPointee<5>(info.type),
756 SetArrayArgument<6>(info.name, info.name + strlen(info.name) + 1)))
gman@chromium.org0abf43e32012-05-10 23:36:23757 .RetiresOnSaturation();
kkinnunen8cefb232015-12-04 09:36:31758 if (!ProgramManager::HasBuiltInPrefix(info.name)) {
gman@chromium.org0abf43e32012-05-10 23:36:23759 EXPECT_CALL(*gl, GetAttribLocation(service_id, StrEq(info.name)))
760 .WillOnce(Return(info.location))
761 .RetiresOnSaturation();
762 }
763 }
thestige147d682017-05-05 07:31:31764 EXPECT_CALL(*gl, GetProgramiv(service_id, GL_ACTIVE_UNIFORMS, _))
765 .WillOnce(SetArgPointee<2>(num_uniforms))
gman@chromium.org0abf43e32012-05-10 23:36:23766 .RetiresOnSaturation();
gman@chromium.org3f00df92012-06-19 00:44:58767
kkinnunen8fbcba142015-11-23 08:25:25768 if (num_uniforms > 0) {
769 size_t max_uniform_len = 0;
770 for (size_t ii = 0; ii < num_uniforms; ++ii) {
771 size_t len = strlen(uniforms[ii].name) + 1;
772 max_uniform_len = std::max(max_uniform_len, len);
773 }
774 EXPECT_CALL(*gl, GetProgramiv(service_id, GL_ACTIVE_UNIFORM_MAX_LENGTH, _))
thestige147d682017-05-05 07:31:31775 .WillOnce(SetArgPointee<2>(max_uniform_len))
gman@chromium.org0abf43e32012-05-10 23:36:23776 .RetiresOnSaturation();
gman@chromium.org2be6abf32012-06-26 00:28:33777 for (size_t ii = 0; ii < num_uniforms; ++ii) {
778 const UniformInfo& info = uniforms[ii];
kkinnunen8fbcba142015-11-23 08:25:25779 EXPECT_CALL(*gl,
780 GetActiveUniform(service_id, ii, max_uniform_len, _, _, _, _))
thestige147d682017-05-05 07:31:31781 .WillOnce(DoAll(SetArgPointee<3>(strlen(info.name)),
782 SetArgPointee<4>(info.size),
783 SetArgPointee<5>(info.type),
kkinnunen8fbcba142015-11-23 08:25:25784 SetArrayArgument<6>(
785 info.name, info.name + strlen(info.name) + 1)))
786 .RetiresOnSaturation();
787
Bo Liu3d66a60a2017-06-26 22:26:35788 // Corresponds to early out in Program::UpdateUniforms
789 if (!info.size)
790 return;
791
kkinnunen8fbcba142015-11-23 08:25:25792 if (info.real_location != -1) {
gman@chromium.org2be6abf32012-06-26 00:28:33793 EXPECT_CALL(*gl, GetUniformLocation(service_id, StrEq(info.name)))
794 .WillOnce(Return(info.real_location))
gman@chromium.org3f00df92012-06-19 00:44:58795 .RetiresOnSaturation();
gman@chromium.org0abf43e32012-05-10 23:36:23796 }
kkinnunen8fbcba142015-11-23 08:25:25797 if (info.size > 1) {
798 std::string base_name = info.name;
799 size_t array_pos = base_name.rfind("[0]");
800 if (base_name.size() > 3 && array_pos == base_name.size() - 3) {
801 base_name = base_name.substr(0, base_name.size() - 3);
802 }
803 for (GLsizei jj = 1; jj < info.size; ++jj) {
804 std::string element_name(std::string(base_name) + "[" +
Raul Tambre36584542019-02-07 23:42:08805 base::NumberToString(jj) + "]");
kkinnunen8fbcba142015-11-23 08:25:25806 EXPECT_CALL(*gl, GetUniformLocation(service_id, StrEq(element_name)))
807 .WillOnce(Return(info.real_location + jj * 2))
808 .RetiresOnSaturation();
gman@chromium.org2be6abf32012-06-26 00:28:33809 }
810 }
gman@chromium.org0abf43e32012-05-10 23:36:23811 }
812 }
kkinnunenc8b449e1582015-11-02 07:57:51813
Zhenyao Mof3028282024-07-03 17:31:43814 if (feature_info->gl_version_info().IsAtLeastGLES(3, 0) &&
kkinnunen8cefb232015-12-04 09:36:31815 !feature_info->disable_shader_translator()) {
Stephen Nuskof4e53402025-07-23 13:39:44816 for (size_t ii = 0;
817 ii < spanification_suspected_redundant_num_program_outputs; ++ii) {
kkinnunen8cefb232015-12-04 09:36:31818 ProgramOutputInfo& info = program_outputs[ii];
819 if (ProgramManager::HasBuiltInPrefix(info.name))
820 continue;
821
822 EXPECT_CALL(*gl, GetFragDataLocation(service_id, StrEq(info.name)))
823 .WillOnce(Return(info.color_name))
824 .RetiresOnSaturation();
825 if (feature_info->feature_flags().ext_blend_func_extended) {
826 EXPECT_CALL(*gl, GetFragDataIndex(service_id, StrEq(info.name)))
827 .WillOnce(Return(info.index))
828 .RetiresOnSaturation();
829 } else {
830 // Test case must not use indices, or the context of the testcase has to
831 // support the dual source blending.
832 DCHECK(info.index == 0);
833 }
kkinnunenc8b449e1582015-11-02 07:57:51834 }
835 }
gman@chromium.org0abf43e32012-05-10 23:36:23836}
837
kylechar7a463842016-05-26 14:46:12838void TestHelper::SetupShaderExpectations(::gl::MockGLInterface* gl,
kkinnunenc8b449e1582015-11-02 07:57:51839 const FeatureInfo* feature_info,
840 AttribInfo* attribs,
841 size_t num_attribs,
842 UniformInfo* uniforms,
843 size_t num_uniforms,
844 GLuint service_id) {
845 InSequence s;
846
847 EXPECT_CALL(*gl, LinkProgram(service_id)).Times(1).RetiresOnSaturation();
848
849 SetupProgramSuccessExpectations(gl, feature_info, attribs, num_attribs,
Stephen Nuskof4e53402025-07-23 13:39:44850 uniforms, num_uniforms, nullptr, 0, {}, 0,
851 service_id);
kkinnunenc8b449e1582015-11-02 07:57:51852}
853
854void TestHelper::SetupShaderExpectationsWithVaryings(
kylechar7a463842016-05-26 14:46:12855 ::gl::MockGLInterface* gl,
kkinnunenc8b449e1582015-11-02 07:57:51856 const FeatureInfo* feature_info,
857 AttribInfo* attribs,
858 size_t num_attribs,
859 UniformInfo* uniforms,
860 size_t num_uniforms,
861 VaryingInfo* varyings,
862 size_t num_varyings,
Stephen Nuskof4e53402025-07-23 13:39:44863 base::span<ProgramOutputInfo> program_outputs,
864 size_t spanification_suspected_redundant_num_program_outputs,
dmurph@chromium.org65dfc602012-07-23 20:39:39865 GLuint service_id) {
Stephen Nuskof4e53402025-07-23 13:39:44866 // TODO(crbug.com/431824301): Remove unneeded parameter once validated to be
867 // redundant in M143.
868 CHECK(spanification_suspected_redundant_num_program_outputs ==
869 program_outputs.size(),
870 base::NotFatalUntil::M143);
dmurph@chromium.org65dfc602012-07-23 20:39:39871 InSequence s;
872
873 EXPECT_CALL(*gl,
874 LinkProgram(service_id))
875 .Times(1)
876 .RetiresOnSaturation();
877
kkinnunen8cefb232015-12-04 09:36:31878 SetupProgramSuccessExpectations(
879 gl, feature_info, attribs, num_attribs, uniforms, num_uniforms, varyings,
Stephen Nuskof4e53402025-07-23 13:39:44880 num_varyings, program_outputs,
881 spanification_suspected_redundant_num_program_outputs, service_id);
dmurph@chromium.org65dfc602012-07-23 20:39:39882}
883
kylechar7a463842016-05-26 14:46:12884void TestHelper::DoBufferData(::gl::MockGLInterface* gl,
885 MockErrorState* error_state,
886 BufferManager* manager,
887 Buffer* buffer,
888 GLenum target,
889 GLsizeiptr size,
890 GLenum usage,
891 const GLvoid* data,
892 GLenum error) {
kloveless@chromium.orgd3eba342013-04-18 21:11:50893 EXPECT_CALL(*error_state, CopyRealGLErrorsToWrapper(_, _, _))
gman@chromium.org17cfbe0e2013-03-07 01:26:08894 .Times(1)
895 .RetiresOnSaturation();
896 if (manager->IsUsageClientSideArray(usage)) {
zmo4c0c3532015-05-22 20:04:48897 EXPECT_CALL(*gl, BufferData(target, 0, _, usage))
gman@chromium.org17cfbe0e2013-03-07 01:26:08898 .Times(1)
899 .RetiresOnSaturation();
900 } else {
zmo4c0c3532015-05-22 20:04:48901 EXPECT_CALL(*gl, BufferData(target, size, _, usage))
gman@chromium.org17cfbe0e2013-03-07 01:26:08902 .Times(1)
903 .RetiresOnSaturation();
904 }
kloveless@chromium.orgd3eba342013-04-18 21:11:50905 EXPECT_CALL(*error_state, PeekGLError(_, _, _))
gman@chromium.org17cfbe0e2013-03-07 01:26:08906 .WillOnce(Return(error))
907 .RetiresOnSaturation();
zmo4c0c3532015-05-22 20:04:48908 manager->DoBufferData(error_state, buffer, target, size, usage, data);
gman@chromium.org17cfbe0e2013-03-07 01:26:08909}
910
kylechar7a463842016-05-26 14:46:12911void TestHelper::SetTexParameteriWithExpectations(::gl::MockGLInterface* gl,
912 MockErrorState* error_state,
913 TextureManager* manager,
914 TextureRef* texture_ref,
915 GLenum pname,
916 GLint value,
917 GLenum error) {
gman@chromium.org02965c22013-03-09 02:40:07918 if (error == GL_NO_ERROR) {
ccamerondfb2f202015-10-09 23:17:59919 EXPECT_CALL(*gl, TexParameteri(texture_ref->texture()->target(),
920 pname, value))
921 .Times(1)
922 .RetiresOnSaturation();
gman@chromium.org02965c22013-03-09 02:40:07923 } else if (error == GL_INVALID_ENUM) {
kloveless@chromium.orgd3eba342013-04-18 21:11:50924 EXPECT_CALL(*error_state, SetGLErrorInvalidEnum(_, _, _, value, _))
gman@chromium.org02965c22013-03-09 02:40:07925 .Times(1)
926 .RetiresOnSaturation();
927 } else {
zmo@chromium.org737191ee72014-03-09 08:02:42928 EXPECT_CALL(*error_state, SetGLErrorInvalidParami(_, _, error, _, _, _))
gman@chromium.org02965c22013-03-09 02:40:07929 .Times(1)
930 .RetiresOnSaturation();
931 }
zmo@chromium.org737191ee72014-03-09 08:02:42932 manager->SetParameteri("", error_state, texture_ref, pname, value);
gman@chromium.org02965c22013-03-09 02:40:07933}
934
zmo576a0492014-09-13 01:12:32935// static
936void TestHelper::SetShaderStates(
kylechar7a463842016-05-26 14:46:12937 ::gl::MockGLInterface* gl,
kkinnunen8cefb232015-12-04 09:36:31938 Shader* shader,
939 bool expected_valid,
940 const std::string* const expected_log_info,
941 const std::string* const expected_translated_source,
942 const int* const expected_shader_version,
943 const AttributeMap* const expected_attrib_map,
944 const UniformMap* const expected_uniform_map,
945 const VaryingMap* const expected_varying_map,
946 const InterfaceBlockMap* const expected_interface_block_map,
Geoff Lang30efb7b2017-08-09 14:59:23947 const OutputVariableList* const expected_output_variable_list,
948 OptionsAffectingCompilationString* options_affecting_compilation) {
zmo576a0492014-09-13 01:12:32949 const std::string empty_log_info;
950 const std::string* log_info = (expected_log_info && !expected_valid) ?
951 expected_log_info : &empty_log_info;
952 const std::string empty_translated_source;
953 const std::string* translated_source =
954 (expected_translated_source && expected_valid) ?
955 expected_translated_source : &empty_translated_source;
oetuahoe6bdcf32015-05-07 16:45:25956 int default_shader_version = 100;
957 const int* shader_version = (expected_shader_version && expected_valid) ?
958 expected_shader_version : &default_shader_version;
zmo88043c082014-10-09 20:38:55959 const AttributeMap empty_attrib_map;
960 const AttributeMap* attrib_map = (expected_attrib_map && expected_valid) ?
961 expected_attrib_map : &empty_attrib_map;
962 const UniformMap empty_uniform_map;
963 const UniformMap* uniform_map = (expected_uniform_map && expected_valid) ?
964 expected_uniform_map : &empty_uniform_map;
965 const VaryingMap empty_varying_map;
966 const VaryingMap* varying_map = (expected_varying_map && expected_valid) ?
967 expected_varying_map : &empty_varying_map;
yunchao.hee4edccd2015-11-06 00:45:18968 const InterfaceBlockMap empty_interface_block_map;
969 const InterfaceBlockMap* interface_block_map =
970 (expected_interface_block_map && expected_valid) ?
971 expected_interface_block_map : &empty_interface_block_map;
kkinnunen8cefb232015-12-04 09:36:31972 const OutputVariableList empty_output_variable_list;
973 const OutputVariableList* output_variable_list =
974 (expected_output_variable_list && expected_valid)
975 ? expected_output_variable_list
976 : &empty_output_variable_list;
zmo576a0492014-09-13 01:12:32977
dyen0ff9e4402015-02-12 22:27:43978 MockShaderTranslator* mock_translator = new MockShaderTranslator;
979 scoped_refptr<ShaderTranslatorInterface> translator(mock_translator);
980 EXPECT_CALL(*mock_translator, Translate(_,
kkinnunen8cefb232015-12-04 09:36:31981 NotNull(), // log_info
982 NotNull(), // translated_source
983 NotNull(), // shader_version
984 NotNull(), // attrib_map
985 NotNull(), // uniform_map
986 NotNull(), // varying_map
987 NotNull(), // interface_block_map
kainino78c79d22017-05-04 18:45:30988 NotNull())) // output_variable_list
thestige147d682017-05-05 07:31:31989 .WillOnce(DoAll(
990 SetArgPointee<1>(*log_info), SetArgPointee<2>(*translated_source),
991 SetArgPointee<3>(*shader_version), SetArgPointee<4>(*attrib_map),
992 SetArgPointee<5>(*uniform_map), SetArgPointee<6>(*varying_map),
993 SetArgPointee<7>(*interface_block_map),
994 SetArgPointee<8>(*output_variable_list), Return(expected_valid)))
zmo576a0492014-09-13 01:12:32995 .RetiresOnSaturation();
Geoff Lang30efb7b2017-08-09 14:59:23996 EXPECT_CALL(*mock_translator, GetStringForOptionsThatWouldAffectCompilation())
997 .WillOnce(Return(options_affecting_compilation))
998 .RetiresOnSaturation();
zmo576a0492014-09-13 01:12:32999 if (expected_valid) {
tzikddef02182018-08-14 07:08:331000 EXPECT_CALL(*gl, ShaderSource(shader->service_id(), 1, _, nullptr))
zmo576a0492014-09-13 01:12:321001 .Times(1)
1002 .RetiresOnSaturation();
1003 EXPECT_CALL(*gl, CompileShader(shader->service_id()))
1004 .Times(1)
1005 .RetiresOnSaturation();
thestige147d682017-05-05 07:31:311006 EXPECT_CALL(*gl, GetShaderiv(shader->service_id(), GL_COMPILE_STATUS,
zmo576a0492014-09-13 01:12:321007 NotNull())) // status
thestige147d682017-05-05 07:31:311008 .WillOnce(SetArgPointee<2>(GL_TRUE))
zmo576a0492014-09-13 01:12:321009 .RetiresOnSaturation();
1010 }
dyen0ff9e4402015-02-12 22:27:431011 shader->RequestCompile(translator, Shader::kGL);
1012 shader->DoCompile();
zmo576a0492014-09-13 01:12:321013}
1014
1015// static
kylechar7a463842016-05-26 14:46:121016void TestHelper::SetShaderStates(::gl::MockGLInterface* gl,
1017 Shader* shader,
1018 bool valid) {
kkinnunen8cefb232015-12-04 09:36:311019 SetShaderStates(gl, shader, valid, nullptr, nullptr, nullptr, nullptr,
Geoff Lang30efb7b2017-08-09 14:59:231020 nullptr, nullptr, nullptr, nullptr, nullptr);
1021}
1022
1023// static
1024void TestHelper::SetShaderStates(
1025 ::gl::MockGLInterface* gl,
1026 Shader* shader,
1027 bool valid,
1028 const std::string& options_affecting_compilation) {
1029 scoped_refptr<OptionsAffectingCompilationString> options =
1030 base::MakeRefCounted<OptionsAffectingCompilationString>(
1031 options_affecting_compilation);
1032 SetShaderStates(gl, shader, valid, nullptr, nullptr, nullptr, nullptr,
1033 nullptr, nullptr, nullptr, nullptr, options.get());
zmo576a0492014-09-13 01:12:321034}
1035
zmo88043c082014-10-09 20:38:551036// static
1037sh::Attribute TestHelper::ConstructAttribute(
1038 GLenum type, GLint array_size, GLenum precision,
1039 bool static_use, const std::string& name) {
1040 return ConstructShaderVariable<sh::Attribute>(
1041 type, array_size, precision, static_use, name);
1042}
1043
1044// static
1045sh::Uniform TestHelper::ConstructUniform(
1046 GLenum type, GLint array_size, GLenum precision,
1047 bool static_use, const std::string& name) {
1048 return ConstructShaderVariable<sh::Uniform>(
1049 type, array_size, precision, static_use, name);
1050}
1051
1052// static
1053sh::Varying TestHelper::ConstructVarying(
1054 GLenum type, GLint array_size, GLenum precision,
1055 bool static_use, const std::string& name) {
1056 return ConstructShaderVariable<sh::Varying>(
1057 type, array_size, precision, static_use, name);
1058}
1059
Kai Ninomiyae9cc6302017-05-19 21:49:131060// static
1061sh::InterfaceBlockField TestHelper::ConstructInterfaceBlockField(
1062 GLenum type,
1063 GLint array_size,
1064 GLenum precision,
1065 bool static_use,
1066 const std::string& name) {
1067 return ConstructShaderVariable<sh::InterfaceBlockField>(
1068 type, array_size, precision, static_use, name);
1069}
1070
1071// static
1072sh::InterfaceBlock TestHelper::ConstructInterfaceBlock(
1073 GLint array_size,
1074 sh::BlockLayoutType layout,
1075 bool is_row_major_layout,
1076 bool static_use,
1077 const std::string& name,
1078 const std::string& instance_name,
1079 const std::vector<sh::InterfaceBlockField>& fields) {
1080 sh::InterfaceBlock var;
1081 var.arraySize = array_size;
1082 var.layout = layout;
1083 var.isRowMajorLayout = is_row_major_layout;
1084 var.staticUse = static_use;
1085 var.name = name;
1086 var.mappedName = name; // No name hashing.
1087 var.instanceName = instance_name;
1088 var.fields = fields;
1089 return var;
1090}
1091
kkinnunen8cefb232015-12-04 09:36:311092sh::OutputVariable TestHelper::ConstructOutputVariable(
1093 GLenum type,
1094 GLint array_size,
1095 GLenum precision,
1096 bool static_use,
1097 const std::string& name) {
1098 return ConstructShaderVariable<sh::OutputVariable>(
1099 type, array_size, precision, static_use, name);
1100}
1101
gman@chromium.org00f893d2010-08-24 18:55:491102} // namespace gles2
1103} // namespace gpu