1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
7 #include "gpu/command_buffer/common/gles2_cmd_format.h"
8 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
9 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h"
10 #include "gpu/command_buffer/service/cmd_buffer_engine.h"
11 #include "gpu/command_buffer/service/context_group.h"
12 #include "gpu/command_buffer/service/program_manager.h"
13 #include "gpu/command_buffer/service/test_helper.h"
14 #include "testing/gtest/include/gtest/gtest.h"
15 #include "ui/gl/gl_mock.h"
17 using ::gfx::MockGLInterface
;
19 using ::testing::AnyNumber
;
20 using ::testing::DoAll
;
21 using ::testing::InSequence
;
22 using ::testing::MatcherCast
;
23 using ::testing::Pointee
;
24 using ::testing::Return
;
25 using ::testing::SetArrayArgument
;
26 using ::testing::SetArgumentPointee
;
27 using ::testing::StrEq
;
33 void ShaderCacheCb(const std::string
& key
, const std::string
& shader
) {
37 class GLES2DecoderTest2
: public GLES2DecoderTestBase
{
39 GLES2DecoderTest2() { }
41 void TestAcceptedUniform(
42 GLenum uniform_type
, uint32 accepts_apis
, bool es3_enabled
) {
43 decoder_
->set_unsafe_es3_apis_enabled(es3_enabled
);
45 SetupShaderForUniform(uniform_type
);
46 bool valid_uniform
= false;
48 EXPECT_CALL(*gl_
, Uniform1i(1, _
)).Times(AnyNumber());
49 EXPECT_CALL(*gl_
, Uniform1iv(1, _
, _
)).Times(AnyNumber());
50 EXPECT_CALL(*gl_
, Uniform2iv(1, _
, _
)).Times(AnyNumber());
51 EXPECT_CALL(*gl_
, Uniform3iv(1, _
, _
)).Times(AnyNumber());
52 EXPECT_CALL(*gl_
, Uniform4iv(1, _
, _
)).Times(AnyNumber());
53 EXPECT_CALL(*gl_
, Uniform1f(1, _
)).Times(AnyNumber());
54 EXPECT_CALL(*gl_
, Uniform1fv(1, _
, _
)).Times(AnyNumber());
55 EXPECT_CALL(*gl_
, Uniform2fv(1, _
, _
)).Times(AnyNumber());
56 EXPECT_CALL(*gl_
, Uniform3fv(1, _
, _
)).Times(AnyNumber());
57 EXPECT_CALL(*gl_
, Uniform4fv(1, _
, _
)).Times(AnyNumber());
58 EXPECT_CALL(*gl_
, UniformMatrix2fv(1, _
, _
, _
)).Times(AnyNumber());
59 EXPECT_CALL(*gl_
, UniformMatrix3fv(1, _
, _
, _
)).Times(AnyNumber());
60 EXPECT_CALL(*gl_
, UniformMatrix4fv(1, _
, _
, _
)).Times(AnyNumber());
62 EXPECT_CALL(*gl_
, Uniform1uiv(1, _
, _
)).Times(AnyNumber());
63 EXPECT_CALL(*gl_
, Uniform2uiv(1, _
, _
)).Times(AnyNumber());
64 EXPECT_CALL(*gl_
, Uniform3uiv(1, _
, _
)).Times(AnyNumber());
65 EXPECT_CALL(*gl_
, Uniform4uiv(1, _
, _
)).Times(AnyNumber());
66 EXPECT_CALL(*gl_
, UniformMatrix2x3fv(1, _
, _
, _
)).Times(AnyNumber());
67 EXPECT_CALL(*gl_
, UniformMatrix2x4fv(1, _
, _
, _
)).Times(AnyNumber());
68 EXPECT_CALL(*gl_
, UniformMatrix3x2fv(1, _
, _
, _
)).Times(AnyNumber());
69 EXPECT_CALL(*gl_
, UniformMatrix3x4fv(1, _
, _
, _
)).Times(AnyNumber());
70 EXPECT_CALL(*gl_
, UniformMatrix4x2fv(1, _
, _
, _
)).Times(AnyNumber());
71 EXPECT_CALL(*gl_
, UniformMatrix4x3fv(1, _
, _
, _
)).Times(AnyNumber());
75 valid_uniform
= accepts_apis
& Program::kUniform1i
;
78 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
79 EXPECT_EQ(valid_uniform
? GL_NO_ERROR
: GL_INVALID_OPERATION
,
84 valid_uniform
= accepts_apis
& Program::kUniform1i
;
85 cmds::Uniform1ivImmediate
& cmd
=
86 *GetImmediateAs
<cmds::Uniform1ivImmediate
>();
87 GLint data
[2][1] = {{0}};
88 cmd
.Init(1, 2, &data
[0][0]);
89 EXPECT_EQ(error::kNoError
, ExecuteImmediateCmd(cmd
, sizeof(data
)));
90 EXPECT_EQ(valid_uniform
? GL_NO_ERROR
: GL_INVALID_OPERATION
,
95 valid_uniform
= accepts_apis
& Program::kUniform2i
;
98 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
99 EXPECT_EQ(valid_uniform
? GL_NO_ERROR
: GL_INVALID_OPERATION
,
104 valid_uniform
= accepts_apis
& Program::kUniform2i
;
105 cmds::Uniform2ivImmediate
& cmd
=
106 *GetImmediateAs
<cmds::Uniform2ivImmediate
>();
107 GLint data
[2][2] = {{0}};
108 cmd
.Init(1, 2, &data
[0][0]);
109 EXPECT_EQ(error::kNoError
, ExecuteImmediateCmd(cmd
, sizeof(data
)));
110 EXPECT_EQ(valid_uniform
? GL_NO_ERROR
: GL_INVALID_OPERATION
,
115 valid_uniform
= accepts_apis
& Program::kUniform3i
;
117 cmd
.Init(1, 2, 3, 4);
118 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
119 EXPECT_EQ(valid_uniform
? GL_NO_ERROR
: GL_INVALID_OPERATION
,
124 valid_uniform
= accepts_apis
& Program::kUniform3i
;
125 cmds::Uniform3ivImmediate
& cmd
=
126 *GetImmediateAs
<cmds::Uniform3ivImmediate
>();
127 GLint data
[2][3] = {{0}};
128 cmd
.Init(1, 2, &data
[0][0]);
129 EXPECT_EQ(error::kNoError
, ExecuteImmediateCmd(cmd
, sizeof(data
)));
130 EXPECT_EQ(valid_uniform
? GL_NO_ERROR
: GL_INVALID_OPERATION
,
135 valid_uniform
= accepts_apis
& Program::kUniform4i
;
137 cmd
.Init(1, 2, 3, 4, 5);
138 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
139 EXPECT_EQ(valid_uniform
? GL_NO_ERROR
: GL_INVALID_OPERATION
,
144 valid_uniform
= accepts_apis
& Program::kUniform4i
;
145 cmds::Uniform4ivImmediate
& cmd
=
146 *GetImmediateAs
<cmds::Uniform4ivImmediate
>();
147 GLint data
[2][4] = {{0}};
148 cmd
.Init(1, 2, &data
[0][0]);
149 EXPECT_EQ(error::kNoError
, ExecuteImmediateCmd(cmd
, sizeof(data
)));
150 EXPECT_EQ(valid_uniform
? GL_NO_ERROR
: GL_INVALID_OPERATION
,
157 valid_uniform
= accepts_apis
& Program::kUniform1f
;
160 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
161 EXPECT_EQ(valid_uniform
? GL_NO_ERROR
: GL_INVALID_OPERATION
,
166 valid_uniform
= accepts_apis
& Program::kUniform1f
;
167 cmds::Uniform1fvImmediate
& cmd
=
168 *GetImmediateAs
<cmds::Uniform1fvImmediate
>();
169 GLfloat data
[2][1] = {{0.0f
}};
170 cmd
.Init(1, 2, &data
[0][0]);
171 EXPECT_EQ(error::kNoError
, ExecuteImmediateCmd(cmd
, sizeof(data
)));
172 EXPECT_EQ(valid_uniform
? GL_NO_ERROR
: GL_INVALID_OPERATION
,
177 valid_uniform
= accepts_apis
& Program::kUniform2f
;
180 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
181 EXPECT_EQ(valid_uniform
? GL_NO_ERROR
: GL_INVALID_OPERATION
,
186 valid_uniform
= accepts_apis
& Program::kUniform2f
;
187 cmds::Uniform2fvImmediate
& cmd
=
188 *GetImmediateAs
<cmds::Uniform2fvImmediate
>();
189 GLfloat data
[2][2] = {{0.0f
}};
190 cmd
.Init(1, 2, &data
[0][0]);
191 EXPECT_EQ(error::kNoError
, ExecuteImmediateCmd(cmd
, sizeof(data
)));
192 EXPECT_EQ(valid_uniform
? GL_NO_ERROR
: GL_INVALID_OPERATION
,
197 valid_uniform
= accepts_apis
& Program::kUniform3f
;
199 cmd
.Init(1, 2, 3, 4);
200 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
201 EXPECT_EQ(valid_uniform
? GL_NO_ERROR
: GL_INVALID_OPERATION
,
206 valid_uniform
= accepts_apis
& Program::kUniform3f
;
207 cmds::Uniform3fvImmediate
& cmd
=
208 *GetImmediateAs
<cmds::Uniform3fvImmediate
>();
209 GLfloat data
[2][3] = {{0.0f
}};
210 cmd
.Init(1, 2, &data
[0][0]);
211 EXPECT_EQ(error::kNoError
, ExecuteImmediateCmd(cmd
, sizeof(data
)));
212 EXPECT_EQ(valid_uniform
? GL_NO_ERROR
: GL_INVALID_OPERATION
,
217 valid_uniform
= accepts_apis
& Program::kUniform4f
;
219 cmd
.Init(1, 2, 3, 4, 5);
220 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
221 EXPECT_EQ(valid_uniform
? GL_NO_ERROR
: GL_INVALID_OPERATION
,
226 valid_uniform
= accepts_apis
& Program::kUniform4f
;
227 cmds::Uniform4fvImmediate
& cmd
=
228 *GetImmediateAs
<cmds::Uniform4fvImmediate
>();
229 GLfloat data
[2][4] = {{0.0f
}};
230 cmd
.Init(1, 2, &data
[0][0]);
231 EXPECT_EQ(error::kNoError
, ExecuteImmediateCmd(cmd
, sizeof(data
)));
232 EXPECT_EQ(valid_uniform
? GL_NO_ERROR
: GL_INVALID_OPERATION
,
237 valid_uniform
= accepts_apis
& Program::kUniformMatrix2f
;
238 cmds::UniformMatrix2fvImmediate
& cmd
=
239 *GetImmediateAs
<cmds::UniformMatrix2fvImmediate
>();
240 GLfloat data
[2][2 * 2] = {{0.0f
}};
242 cmd
.Init(1, 2, &data
[0][0]);
243 EXPECT_EQ(error::kNoError
, ExecuteImmediateCmd(cmd
, sizeof(data
)));
244 EXPECT_EQ(valid_uniform
? GL_NO_ERROR
: GL_INVALID_OPERATION
,
249 valid_uniform
= accepts_apis
& Program::kUniformMatrix3f
;
250 cmds::UniformMatrix3fvImmediate
& cmd
=
251 *GetImmediateAs
<cmds::UniformMatrix3fvImmediate
>();
252 GLfloat data
[2][3 * 3] = {{0.0f
}};
253 cmd
.Init(1, 2, &data
[0][0]);
254 EXPECT_EQ(error::kNoError
, ExecuteImmediateCmd(cmd
, sizeof(data
)));
255 EXPECT_EQ(valid_uniform
? GL_NO_ERROR
: GL_INVALID_OPERATION
,
260 valid_uniform
= accepts_apis
& Program::kUniformMatrix4f
;
261 cmds::UniformMatrix4fvImmediate
& cmd
=
262 *GetImmediateAs
<cmds::UniformMatrix4fvImmediate
>();
263 GLfloat data
[2][4 * 4] = {{0.0f
}};
264 cmd
.Init(1, 2, &data
[0][0]);
265 EXPECT_EQ(error::kNoError
, ExecuteImmediateCmd(cmd
, sizeof(data
)));
266 EXPECT_EQ(valid_uniform
? GL_NO_ERROR
: GL_INVALID_OPERATION
,
272 valid_uniform
= accepts_apis
& Program::kUniform1ui
;
273 cmds::Uniform1ui cmd
;
275 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
276 EXPECT_EQ(valid_uniform
? GL_NO_ERROR
: GL_INVALID_OPERATION
,
281 valid_uniform
= accepts_apis
& Program::kUniform1ui
;
282 cmds::Uniform1uivImmediate
& cmd
=
283 *GetImmediateAs
<cmds::Uniform1uivImmediate
>();
284 GLuint data
[2][1] = {{0}};
285 cmd
.Init(1, 2, &data
[0][0]);
286 EXPECT_EQ(error::kNoError
, ExecuteImmediateCmd(cmd
, sizeof(data
)));
287 EXPECT_EQ(valid_uniform
? GL_NO_ERROR
: GL_INVALID_OPERATION
,
292 valid_uniform
= accepts_apis
& Program::kUniform2ui
;
293 cmds::Uniform2ui cmd
;
295 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
296 EXPECT_EQ(valid_uniform
? GL_NO_ERROR
: GL_INVALID_OPERATION
,
301 valid_uniform
= accepts_apis
& Program::kUniform2ui
;
302 cmds::Uniform2uivImmediate
& cmd
=
303 *GetImmediateAs
<cmds::Uniform2uivImmediate
>();
304 GLuint data
[2][2] = {{0}};
305 cmd
.Init(1, 2, &data
[0][0]);
306 EXPECT_EQ(error::kNoError
, ExecuteImmediateCmd(cmd
, sizeof(data
)));
307 EXPECT_EQ(valid_uniform
? GL_NO_ERROR
: GL_INVALID_OPERATION
,
312 valid_uniform
= accepts_apis
& Program::kUniform3ui
;
313 cmds::Uniform3ui cmd
;
314 cmd
.Init(1, 2, 3, 4);
315 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
316 EXPECT_EQ(valid_uniform
? GL_NO_ERROR
: GL_INVALID_OPERATION
,
321 valid_uniform
= accepts_apis
& Program::kUniform3ui
;
322 cmds::Uniform3uivImmediate
& cmd
=
323 *GetImmediateAs
<cmds::Uniform3uivImmediate
>();
324 GLuint data
[2][3] = {{0}};
325 cmd
.Init(1, 2, &data
[0][0]);
326 EXPECT_EQ(error::kNoError
, ExecuteImmediateCmd(cmd
, sizeof(data
)));
327 EXPECT_EQ(valid_uniform
? GL_NO_ERROR
: GL_INVALID_OPERATION
,
332 valid_uniform
= accepts_apis
& Program::kUniform4ui
;
333 cmds::Uniform4ui cmd
;
334 cmd
.Init(1, 2, 3, 4, 5);
335 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
336 EXPECT_EQ(valid_uniform
? GL_NO_ERROR
: GL_INVALID_OPERATION
,
341 valid_uniform
= accepts_apis
& Program::kUniform4ui
;
342 cmds::Uniform4uivImmediate
& cmd
=
343 *GetImmediateAs
<cmds::Uniform4uivImmediate
>();
344 GLuint data
[2][4] = {{0}};
345 cmd
.Init(1, 2, &data
[0][0]);
346 EXPECT_EQ(error::kNoError
, ExecuteImmediateCmd(cmd
, sizeof(data
)));
347 EXPECT_EQ(valid_uniform
? GL_NO_ERROR
: GL_INVALID_OPERATION
,
352 valid_uniform
= accepts_apis
& Program::kUniformMatrix2x3f
;
353 cmds::UniformMatrix2x3fvImmediate
& cmd
=
354 *GetImmediateAs
<cmds::UniformMatrix2x3fvImmediate
>();
355 GLfloat data
[2][2 * 3] = {{0.0f
}};
357 cmd
.Init(1, 2, &data
[0][0]);
358 EXPECT_EQ(error::kNoError
, ExecuteImmediateCmd(cmd
, sizeof(data
)));
359 EXPECT_EQ(valid_uniform
? GL_NO_ERROR
: GL_INVALID_OPERATION
,
364 valid_uniform
= accepts_apis
& Program::kUniformMatrix2x4f
;
365 cmds::UniformMatrix2x4fvImmediate
& cmd
=
366 *GetImmediateAs
<cmds::UniformMatrix2x4fvImmediate
>();
367 GLfloat data
[2][2 * 4] = {{0.0f
}};
369 cmd
.Init(1, 2, &data
[0][0]);
370 EXPECT_EQ(error::kNoError
, ExecuteImmediateCmd(cmd
, sizeof(data
)));
371 EXPECT_EQ(valid_uniform
? GL_NO_ERROR
: GL_INVALID_OPERATION
,
376 valid_uniform
= accepts_apis
& Program::kUniformMatrix3x2f
;
377 cmds::UniformMatrix3x2fvImmediate
& cmd
=
378 *GetImmediateAs
<cmds::UniformMatrix3x2fvImmediate
>();
379 GLfloat data
[2][3 * 2] = {{0.0f
}};
381 cmd
.Init(1, 2, &data
[0][0]);
382 EXPECT_EQ(error::kNoError
, ExecuteImmediateCmd(cmd
, sizeof(data
)));
383 EXPECT_EQ(valid_uniform
? GL_NO_ERROR
: GL_INVALID_OPERATION
,
388 valid_uniform
= accepts_apis
& Program::kUniformMatrix3x4f
;
389 cmds::UniformMatrix3x4fvImmediate
& cmd
=
390 *GetImmediateAs
<cmds::UniformMatrix3x4fvImmediate
>();
391 GLfloat data
[2][3 * 4] = {{0.0f
}};
393 cmd
.Init(1, 2, &data
[0][0]);
394 EXPECT_EQ(error::kNoError
, ExecuteImmediateCmd(cmd
, sizeof(data
)));
395 EXPECT_EQ(valid_uniform
? GL_NO_ERROR
: GL_INVALID_OPERATION
,
400 valid_uniform
= accepts_apis
& Program::kUniformMatrix4x2f
;
401 cmds::UniformMatrix4x2fvImmediate
& cmd
=
402 *GetImmediateAs
<cmds::UniformMatrix4x2fvImmediate
>();
403 GLfloat data
[2][4 * 2] = {{0.0f
}};
405 cmd
.Init(1, 2, &data
[0][0]);
406 EXPECT_EQ(error::kNoError
, ExecuteImmediateCmd(cmd
, sizeof(data
)));
407 EXPECT_EQ(valid_uniform
? GL_NO_ERROR
: GL_INVALID_OPERATION
,
412 valid_uniform
= accepts_apis
& Program::kUniformMatrix4x3f
;
413 cmds::UniformMatrix4x3fvImmediate
& cmd
=
414 *GetImmediateAs
<cmds::UniformMatrix4x3fvImmediate
>();
415 GLfloat data
[2][4 * 3] = {{0.0f
}};
417 cmd
.Init(1, 2, &data
[0][0]);
418 EXPECT_EQ(error::kNoError
, ExecuteImmediateCmd(cmd
, sizeof(data
)));
419 EXPECT_EQ(valid_uniform
? GL_NO_ERROR
: GL_INVALID_OPERATION
,
426 INSTANTIATE_TEST_CASE_P(Service
, GLES2DecoderTest2
, ::testing::Bool());
429 void GLES2DecoderTestBase::SpecializedSetup
<cmds::GetProgramInfoLog
, 0>(
431 const GLuint kClientVertexShaderId
= 5001;
432 const GLuint kServiceVertexShaderId
= 6001;
433 const GLuint kClientFragmentShaderId
= 5002;
434 const GLuint kServiceFragmentShaderId
= 6002;
435 const char* log
= "hello"; // Matches auto-generated unit test.
437 GL_VERTEX_SHADER
, kClientVertexShaderId
, kServiceVertexShaderId
);
439 GL_FRAGMENT_SHADER
, kClientFragmentShaderId
, kServiceFragmentShaderId
);
441 TestHelper::SetShaderStates(
442 gl_
.get(), GetShader(kClientVertexShaderId
), true);
443 TestHelper::SetShaderStates(
444 gl_
.get(), GetShader(kClientFragmentShaderId
), true);
448 AttachShader(kServiceProgramId
, kServiceVertexShaderId
))
450 .RetiresOnSaturation();
452 AttachShader(kServiceProgramId
, kServiceFragmentShaderId
))
454 .RetiresOnSaturation();
455 EXPECT_CALL(*gl_
, LinkProgram(kServiceProgramId
))
457 .RetiresOnSaturation();
458 EXPECT_CALL(*gl_
, GetProgramiv(kServiceProgramId
, GL_LINK_STATUS
, _
))
459 .WillOnce(SetArgumentPointee
<2>(1));
461 GetProgramiv(kServiceProgramId
, GL_INFO_LOG_LENGTH
, _
))
462 .WillOnce(SetArgumentPointee
<2>(strlen(log
) + 1))
463 .RetiresOnSaturation();
465 GetProgramInfoLog(kServiceProgramId
, strlen(log
) + 1, _
, _
))
467 SetArgumentPointee
<2>(strlen(log
)),
468 SetArrayArgument
<3>(log
, log
+ strlen(log
) + 1)))
469 .RetiresOnSaturation();
470 EXPECT_CALL(*gl_
, GetProgramiv(kServiceProgramId
, GL_ACTIVE_ATTRIBUTES
, _
))
471 .WillOnce(SetArgumentPointee
<2>(0));
474 GetProgramiv(kServiceProgramId
, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH
, _
))
475 .WillOnce(SetArgumentPointee
<2>(0));
476 EXPECT_CALL(*gl_
, GetProgramiv(kServiceProgramId
, GL_ACTIVE_UNIFORMS
, _
))
477 .WillOnce(SetArgumentPointee
<2>(0));
480 GetProgramiv(kServiceProgramId
, GL_ACTIVE_UNIFORM_MAX_LENGTH
, _
))
481 .WillOnce(SetArgumentPointee
<2>(0));
483 Program
* program
= GetProgram(client_program_id_
);
484 ASSERT_TRUE(program
!= NULL
);
486 cmds::AttachShader attach_cmd
;
487 attach_cmd
.Init(client_program_id_
, kClientVertexShaderId
);
488 EXPECT_EQ(error::kNoError
, ExecuteCmd(attach_cmd
));
490 attach_cmd
.Init(client_program_id_
, kClientFragmentShaderId
);
491 EXPECT_EQ(error::kNoError
, ExecuteCmd(attach_cmd
));
493 program
->Link(NULL
, Program::kCountOnlyStaticallyUsed
,
494 base::Bind(&ShaderCacheCb
));
498 void GLES2DecoderTestBase::SpecializedSetup
<
499 cmds::GetRenderbufferParameteriv
, 0>(
501 DoBindRenderbuffer(GL_RENDERBUFFER
, client_renderbuffer_id_
,
502 kServiceRenderbufferId
);
506 void GLES2DecoderTestBase::SpecializedSetup
<cmds::RenderbufferStorage
, 0>(
508 DoBindRenderbuffer(GL_RENDERBUFFER
, client_renderbuffer_id_
,
509 kServiceRenderbufferId
);
511 EnsureRenderbufferBound(false);
512 EXPECT_CALL(*gl_
, GetError())
513 .WillOnce(Return(GL_NO_ERROR
))
514 .RetiresOnSaturation();
516 RenderbufferStorageEXT(GL_RENDERBUFFER
, _
, 3, 4))
518 .RetiresOnSaturation();
519 EXPECT_CALL(*gl_
, GetError())
520 .WillOnce(Return(GL_NO_ERROR
))
521 .RetiresOnSaturation();
526 void GLES2DecoderTestBase::SpecializedSetup
<cmds::GenQueriesEXTImmediate
, 0>(
529 // Make the client_query_id_ so that trying to make it again
531 cmds::GenQueriesEXTImmediate
& cmd
=
532 *GetImmediateAs
<cmds::GenQueriesEXTImmediate
>();
533 cmd
.Init(1, &client_query_id_
);
534 EXPECT_EQ(error::kNoError
,
535 ExecuteImmediateCmd(cmd
, sizeof(client_query_id_
)));
540 void GLES2DecoderTestBase::SpecializedSetup
<cmds::DeleteQueriesEXTImmediate
, 0>(
543 // Make the client_query_id_ so that trying to delete it will succeed.
544 cmds::GenQueriesEXTImmediate
& cmd
=
545 *GetImmediateAs
<cmds::GenQueriesEXTImmediate
>();
546 cmd
.Init(1, &client_query_id_
);
547 EXPECT_EQ(error::kNoError
,
548 ExecuteImmediateCmd(cmd
, sizeof(client_query_id_
)));
553 void GLES2DecoderTestBase::SpecializedSetup
<cmds::LinkProgram
, 0>(
555 const GLuint kClientVertexShaderId
= 5001;
556 const GLuint kServiceVertexShaderId
= 6001;
557 const GLuint kClientFragmentShaderId
= 5002;
558 const GLuint kServiceFragmentShaderId
= 6002;
560 GL_VERTEX_SHADER
, kClientVertexShaderId
, kServiceVertexShaderId
);
562 GL_FRAGMENT_SHADER
, kClientFragmentShaderId
, kServiceFragmentShaderId
);
564 TestHelper::SetShaderStates(
565 gl_
.get(), GetShader(kClientVertexShaderId
), true);
566 TestHelper::SetShaderStates(
567 gl_
.get(), GetShader(kClientFragmentShaderId
), true);
571 AttachShader(kServiceProgramId
, kServiceVertexShaderId
))
573 .RetiresOnSaturation();
575 AttachShader(kServiceProgramId
, kServiceFragmentShaderId
))
577 .RetiresOnSaturation();
578 EXPECT_CALL(*gl_
, GetProgramiv(kServiceProgramId
, GL_LINK_STATUS
, _
))
579 .WillOnce(SetArgumentPointee
<2>(1));
581 GetProgramiv(kServiceProgramId
, GL_INFO_LOG_LENGTH
, _
))
582 .WillOnce(SetArgumentPointee
<2>(0))
583 .RetiresOnSaturation();
584 EXPECT_CALL(*gl_
, GetProgramiv(kServiceProgramId
, GL_ACTIVE_ATTRIBUTES
, _
))
585 .WillOnce(SetArgumentPointee
<2>(0));
588 GetProgramiv(kServiceProgramId
, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH
, _
))
589 .WillOnce(SetArgumentPointee
<2>(0));
590 EXPECT_CALL(*gl_
, GetProgramiv(kServiceProgramId
, GL_ACTIVE_UNIFORMS
, _
))
591 .WillOnce(SetArgumentPointee
<2>(0));
594 GetProgramiv(kServiceProgramId
, GL_ACTIVE_UNIFORM_MAX_LENGTH
, _
))
595 .WillOnce(SetArgumentPointee
<2>(0));
597 cmds::AttachShader attach_cmd
;
598 attach_cmd
.Init(client_program_id_
, kClientVertexShaderId
);
599 EXPECT_EQ(error::kNoError
, ExecuteCmd(attach_cmd
));
601 attach_cmd
.Init(client_program_id_
, kClientFragmentShaderId
);
602 EXPECT_EQ(error::kNoError
, ExecuteCmd(attach_cmd
));
606 void GLES2DecoderTestBase::SpecializedSetup
<cmds::Uniform1f
, 0>(
608 SetupShaderForUniform(GL_FLOAT
);
612 void GLES2DecoderTestBase::SpecializedSetup
<cmds::Uniform1fvImmediate
, 0>(
614 SetupShaderForUniform(GL_FLOAT
);
618 void GLES2DecoderTestBase::SpecializedSetup
<cmds::Uniform1ivImmediate
, 0>(
620 SetupShaderForUniform(GL_INT
);
624 void GLES2DecoderTestBase::SpecializedSetup
<cmds::Uniform2f
, 0>(
626 SetupShaderForUniform(GL_FLOAT_VEC2
);
630 void GLES2DecoderTestBase::SpecializedSetup
<cmds::Uniform2i
, 0>(
632 SetupShaderForUniform(GL_INT_VEC2
);
636 void GLES2DecoderTestBase::SpecializedSetup
<cmds::Uniform2fvImmediate
, 0>(
638 SetupShaderForUniform(GL_FLOAT_VEC2
);
642 void GLES2DecoderTestBase::SpecializedSetup
<cmds::Uniform2ivImmediate
, 0>(
644 SetupShaderForUniform(GL_INT_VEC2
);
648 void GLES2DecoderTestBase::SpecializedSetup
<cmds::Uniform3f
, 0>(
650 SetupShaderForUniform(GL_FLOAT_VEC3
);
654 void GLES2DecoderTestBase::SpecializedSetup
<cmds::Uniform3i
, 0>(
656 SetupShaderForUniform(GL_INT_VEC3
);
660 void GLES2DecoderTestBase::SpecializedSetup
<cmds::Uniform3fvImmediate
, 0>(
662 SetupShaderForUniform(GL_FLOAT_VEC3
);
666 void GLES2DecoderTestBase::SpecializedSetup
<cmds::Uniform3ivImmediate
, 0>(
668 SetupShaderForUniform(GL_INT_VEC3
);
672 void GLES2DecoderTestBase::SpecializedSetup
<cmds::Uniform4f
, 0>(
674 SetupShaderForUniform(GL_FLOAT_VEC4
);
678 void GLES2DecoderTestBase::SpecializedSetup
<cmds::Uniform4i
, 0>(
680 SetupShaderForUniform(GL_INT_VEC4
);
684 void GLES2DecoderTestBase::SpecializedSetup
<cmds::Uniform4fvImmediate
, 0>(
686 SetupShaderForUniform(GL_FLOAT_VEC4
);
690 void GLES2DecoderTestBase::SpecializedSetup
<cmds::Uniform4ivImmediate
, 0>(
692 SetupShaderForUniform(GL_INT_VEC4
);
696 void GLES2DecoderTestBase::SpecializedSetup
<cmds::UniformMatrix2fvImmediate
, 0>(
698 SetupShaderForUniform(GL_FLOAT_MAT2
);
702 void GLES2DecoderTestBase::SpecializedSetup
<
703 cmds::UniformMatrix2x3fvImmediate
, 0>(bool /* valid */) {
704 SetupShaderForUniform(GL_FLOAT_MAT2x3
);
708 void GLES2DecoderTestBase::SpecializedSetup
<cmds::TexParameterf
, 0>(
710 DoBindTexture(GL_TEXTURE_2D
, client_texture_id_
, kServiceTextureId
);
714 void GLES2DecoderTestBase::SpecializedSetup
<cmds::TexParameteri
, 0>(
716 DoBindTexture(GL_TEXTURE_2D
, client_texture_id_
, kServiceTextureId
);
720 void GLES2DecoderTestBase::SpecializedSetup
<cmds::TexParameterfvImmediate
, 0>(
722 DoBindTexture(GL_TEXTURE_2D
, client_texture_id_
, kServiceTextureId
);
726 void GLES2DecoderTestBase::SpecializedSetup
<cmds::TexParameterivImmediate
, 0>(
728 DoBindTexture(GL_TEXTURE_2D
, client_texture_id_
, kServiceTextureId
);
732 void GLES2DecoderTestBase::SpecializedSetup
<cmds::GetVertexAttribiv
, 0>(
734 DoBindBuffer(GL_ARRAY_BUFFER
, client_buffer_id_
, kServiceBufferId
);
735 DoVertexAttribPointer(1, 1, GL_FLOAT
, 0, 0);
737 EXPECT_CALL(*gl_
, GetError())
738 .WillOnce(Return(GL_NO_ERROR
))
739 .WillOnce(Return(GL_NO_ERROR
))
740 .RetiresOnSaturation();
745 void GLES2DecoderTestBase::SpecializedSetup
<cmds::GetVertexAttribfv
, 0>(
747 DoBindBuffer(GL_ARRAY_BUFFER
, client_buffer_id_
, kServiceBufferId
);
748 DoVertexAttribPointer(1, 1, GL_FLOAT
, 0, 0);
750 EXPECT_CALL(*gl_
, GetError())
751 .WillOnce(Return(GL_NO_ERROR
))
752 .WillOnce(Return(GL_NO_ERROR
))
753 .RetiresOnSaturation();
758 void GLES2DecoderTestBase::SpecializedSetup
<cmds::GetVertexAttribIiv
, 0>(
760 DoBindBuffer(GL_ARRAY_BUFFER
, client_buffer_id_
, kServiceBufferId
);
761 DoVertexAttribPointer(1, 1, GL_FLOAT
, 0, 0);
763 EXPECT_CALL(*gl_
, GetError())
764 .WillOnce(Return(GL_NO_ERROR
))
765 .WillOnce(Return(GL_NO_ERROR
))
766 .RetiresOnSaturation();
771 void GLES2DecoderTestBase::SpecializedSetup
<cmds::GetVertexAttribIuiv
, 0>(
773 DoBindBuffer(GL_ARRAY_BUFFER
, client_buffer_id_
, kServiceBufferId
);
774 DoVertexAttribPointer(1, 1, GL_FLOAT
, 0, 0);
776 EXPECT_CALL(*gl_
, GetError())
777 .WillOnce(Return(GL_NO_ERROR
))
778 .WillOnce(Return(GL_NO_ERROR
))
779 .RetiresOnSaturation();
784 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_2_autogen.h"
786 TEST_P(GLES2DecoderTest2
, AcceptsUniform_GL_INT
) {
787 TestAcceptedUniform(GL_INT
, Program::kUniform1i
, false);
790 TEST_P(GLES2DecoderTest2
, AcceptsUniform_GL_INT_VEC2
) {
791 TestAcceptedUniform(GL_INT_VEC2
, Program::kUniform2i
, false);
794 TEST_P(GLES2DecoderTest2
, AcceptsUniform_GL_INT_VEC3
) {
795 TestAcceptedUniform(GL_INT_VEC3
, Program::kUniform3i
, false);
798 TEST_P(GLES2DecoderTest2
, AcceptsUniform_GL_INT_VEC4
) {
799 TestAcceptedUniform(GL_INT_VEC4
, Program::kUniform4i
, false);
802 TEST_P(GLES2DecoderTest2
, AcceptsUniform_GL_BOOL
) {
804 GL_BOOL
, Program::kUniform1i
| Program::kUniform1f
, false);
807 TEST_P(GLES2DecoderTest2
, AcceptsUniformES3_GL_BOOL
) {
810 Program::kUniform1i
| Program::kUniform1f
| Program::kUniform1ui
,
814 TEST_P(GLES2DecoderTest2
, AcceptsUniform_GL_BOOL_VEC2
) {
816 GL_BOOL_VEC2
, Program::kUniform2i
| Program::kUniform2f
, false);
819 TEST_P(GLES2DecoderTest2
, AcceptsUniformES3_GL_BOOL_VEC2
) {
822 Program::kUniform2i
| Program::kUniform2f
| Program::kUniform2ui
,
826 TEST_P(GLES2DecoderTest2
, AcceptsUniform_GL_BOOL_VEC3
) {
828 GL_BOOL_VEC3
, Program::kUniform3i
| Program::kUniform3f
, false);
831 TEST_P(GLES2DecoderTest2
, AcceptsUniformES3_GL_BOOL_VEC3
) {
834 Program::kUniform3i
| Program::kUniform3f
| Program::kUniform3ui
,
838 TEST_P(GLES2DecoderTest2
, AcceptsUniform_GL_BOOL_VEC4
) {
840 GL_BOOL_VEC4
, Program::kUniform4i
| Program::kUniform4f
, false);
843 TEST_P(GLES2DecoderTest2
, AcceptsUniformES3_GL_BOOL_VEC4
) {
846 Program::kUniform4i
| Program::kUniform4f
| Program::kUniform4ui
,
850 TEST_P(GLES2DecoderTest2
, AcceptsUniformTypeFLOAT
) {
851 TestAcceptedUniform(GL_FLOAT
, Program::kUniform1f
, false);
854 TEST_P(GLES2DecoderTest2
, AcceptsUniform_GL_FLOAT_VEC2
) {
855 TestAcceptedUniform(GL_FLOAT_VEC2
, Program::kUniform2f
, false);
858 TEST_P(GLES2DecoderTest2
, AcceptsUniform_GL_FLOAT_VEC3
) {
859 TestAcceptedUniform(GL_FLOAT_VEC3
, Program::kUniform3f
, false);
862 TEST_P(GLES2DecoderTest2
, AcceptsUniform_GL_FLOAT_VEC4
) {
863 TestAcceptedUniform(GL_FLOAT_VEC4
, Program::kUniform4f
, false);
866 TEST_P(GLES2DecoderTest2
, AcceptsUniform_GL_FLOAT_MAT2
) {
867 TestAcceptedUniform(GL_FLOAT_MAT2
, Program::kUniformMatrix2f
, false);
870 TEST_P(GLES2DecoderTest2
, AcceptsUniform_GL_FLOAT_MAT3
) {
871 TestAcceptedUniform(GL_FLOAT_MAT3
, Program::kUniformMatrix3f
, false);
874 TEST_P(GLES2DecoderTest2
, AcceptsUniform_GL_FLOAT_MAT4
) {
875 TestAcceptedUniform(GL_FLOAT_MAT4
, Program::kUniformMatrix4f
, false);
878 TEST_P(GLES2DecoderTest2
, AcceptsUniform_GL_UNSIGNED_INT
) {
879 TestAcceptedUniform(GL_UNSIGNED_INT
, Program::kUniform1ui
, true);
882 TEST_P(GLES2DecoderTest2
, AcceptsUniform_GL_UNSIGNED_INT_VEC2
) {
883 TestAcceptedUniform(GL_UNSIGNED_INT_VEC2
, Program::kUniform2ui
, true);
886 TEST_P(GLES2DecoderTest2
, AcceptsUniform_GL_UNSIGNED_INT_VEC3
) {
887 TestAcceptedUniform(GL_UNSIGNED_INT_VEC3
, Program::kUniform3ui
, true);
890 TEST_P(GLES2DecoderTest2
, AcceptsUniform_GL_UNSIGNED_INT_VEC4
) {
891 TestAcceptedUniform(GL_UNSIGNED_INT_VEC4
, Program::kUniform4ui
, true);
894 TEST_P(GLES2DecoderTest2
, AcceptsUniform_GL_FLOAT_MAT2x3
) {
895 TestAcceptedUniform(GL_FLOAT_MAT2x3
, Program::kUniformMatrix2x3f
, true);
898 TEST_P(GLES2DecoderTest2
, AcceptsUniform_GL_FLOAT_MAT2x4
) {
899 TestAcceptedUniform(GL_FLOAT_MAT2x4
, Program::kUniformMatrix2x4f
, true);
902 TEST_P(GLES2DecoderTest2
, AcceptsUniform_GL_FLOAT_MAT3x2
) {
903 TestAcceptedUniform(GL_FLOAT_MAT3x2
, Program::kUniformMatrix3x2f
, true);
906 TEST_P(GLES2DecoderTest2
, AcceptsUniform_GL_FLOAT_MAT3x4
) {
907 TestAcceptedUniform(GL_FLOAT_MAT3x4
, Program::kUniformMatrix3x4f
, true);
910 TEST_P(GLES2DecoderTest2
, AcceptsUniform_GL_FLOAT_MAT4x2
) {
911 TestAcceptedUniform(GL_FLOAT_MAT4x2
, Program::kUniformMatrix4x2f
, true);
914 TEST_P(GLES2DecoderTest2
, AcceptsUniform_GL_FLOAT_MAT4x3
) {
915 TestAcceptedUniform(GL_FLOAT_MAT4x3
, Program::kUniformMatrix4x3f
, true);