Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / gpu / command_buffer / service / gles2_cmd_decoder_unittest_2.cc
blob4901ba1577a0c1f94694101d5a1bf456cfe3dca9
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;
18 using ::testing::_;
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;
29 namespace gpu {
30 namespace gles2 {
32 namespace {
33 void ShaderCacheCb(const std::string& key, const std::string& shader) {
35 } // namespace
37 class GLES2DecoderTest2 : public GLES2DecoderTestBase {
38 public:
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());
61 if (es3_enabled) {
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;
76 cmds::Uniform1i cmd;
77 cmd.Init(1, 2);
78 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
79 EXPECT_EQ(valid_uniform ? GL_NO_ERROR : GL_INVALID_OPERATION,
80 GetGLError());
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,
91 GetGLError());
95 valid_uniform = accepts_apis & Program::kUniform2i;
96 cmds::Uniform2i cmd;
97 cmd.Init(1, 2, 3);
98 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
99 EXPECT_EQ(valid_uniform ? GL_NO_ERROR : GL_INVALID_OPERATION,
100 GetGLError());
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,
111 GetGLError());
115 valid_uniform = accepts_apis & Program::kUniform3i;
116 cmds::Uniform3i cmd;
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,
120 GetGLError());
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,
131 GetGLError());
135 valid_uniform = accepts_apis & Program::kUniform4i;
136 cmds::Uniform4i cmd;
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,
140 GetGLError());
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,
151 GetGLError());
154 ////////////////////
157 valid_uniform = accepts_apis & Program::kUniform1f;
158 cmds::Uniform1f cmd;
159 cmd.Init(1, 2);
160 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
161 EXPECT_EQ(valid_uniform ? GL_NO_ERROR : GL_INVALID_OPERATION,
162 GetGLError());
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,
173 GetGLError());
177 valid_uniform = accepts_apis & Program::kUniform2f;
178 cmds::Uniform2f cmd;
179 cmd.Init(1, 2, 3);
180 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
181 EXPECT_EQ(valid_uniform ? GL_NO_ERROR : GL_INVALID_OPERATION,
182 GetGLError());
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,
193 GetGLError());
197 valid_uniform = accepts_apis & Program::kUniform3f;
198 cmds::Uniform3f cmd;
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,
202 GetGLError());
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,
213 GetGLError());
217 valid_uniform = accepts_apis & Program::kUniform4f;
218 cmds::Uniform4f cmd;
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,
222 GetGLError());
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,
233 GetGLError());
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,
245 GetGLError());
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,
256 GetGLError());
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,
267 GetGLError());
270 if (es3_enabled) {
272 valid_uniform = accepts_apis & Program::kUniform1ui;
273 cmds::Uniform1ui cmd;
274 cmd.Init(1, 2);
275 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
276 EXPECT_EQ(valid_uniform ? GL_NO_ERROR : GL_INVALID_OPERATION,
277 GetGLError());
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,
288 GetGLError());
292 valid_uniform = accepts_apis & Program::kUniform2ui;
293 cmds::Uniform2ui cmd;
294 cmd.Init(1, 2, 3);
295 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
296 EXPECT_EQ(valid_uniform ? GL_NO_ERROR : GL_INVALID_OPERATION,
297 GetGLError());
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,
308 GetGLError());
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,
317 GetGLError());
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,
328 GetGLError());
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,
337 GetGLError());
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,
348 GetGLError());
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,
360 GetGLError());
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,
372 GetGLError());
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,
384 GetGLError());
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,
396 GetGLError());
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,
408 GetGLError());
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,
420 GetGLError());
426 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderTest2, ::testing::Bool());
428 template <>
429 void GLES2DecoderTestBase::SpecializedSetup<cmds::GetProgramInfoLog, 0>(
430 bool /* valid */) {
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.
436 DoCreateShader(
437 GL_VERTEX_SHADER, kClientVertexShaderId, kServiceVertexShaderId);
438 DoCreateShader(
439 GL_FRAGMENT_SHADER, kClientFragmentShaderId, kServiceFragmentShaderId);
441 TestHelper::SetShaderStates(
442 gl_.get(), GetShader(kClientVertexShaderId), true);
443 TestHelper::SetShaderStates(
444 gl_.get(), GetShader(kClientFragmentShaderId), true);
446 InSequence dummy;
447 EXPECT_CALL(*gl_,
448 AttachShader(kServiceProgramId, kServiceVertexShaderId))
449 .Times(1)
450 .RetiresOnSaturation();
451 EXPECT_CALL(*gl_,
452 AttachShader(kServiceProgramId, kServiceFragmentShaderId))
453 .Times(1)
454 .RetiresOnSaturation();
455 EXPECT_CALL(*gl_, LinkProgram(kServiceProgramId))
456 .Times(1)
457 .RetiresOnSaturation();
458 EXPECT_CALL(*gl_, GetProgramiv(kServiceProgramId, GL_LINK_STATUS, _))
459 .WillOnce(SetArgumentPointee<2>(1));
460 EXPECT_CALL(*gl_,
461 GetProgramiv(kServiceProgramId, GL_INFO_LOG_LENGTH, _))
462 .WillOnce(SetArgumentPointee<2>(strlen(log) + 1))
463 .RetiresOnSaturation();
464 EXPECT_CALL(*gl_,
465 GetProgramInfoLog(kServiceProgramId, strlen(log) + 1, _, _))
466 .WillOnce(DoAll(
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));
472 EXPECT_CALL(
473 *gl_,
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));
478 EXPECT_CALL(
479 *gl_,
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));
497 template <>
498 void GLES2DecoderTestBase::SpecializedSetup<
499 cmds::GetRenderbufferParameteriv, 0>(
500 bool /* valid */) {
501 DoBindRenderbuffer(GL_RENDERBUFFER, client_renderbuffer_id_,
502 kServiceRenderbufferId);
505 template <>
506 void GLES2DecoderTestBase::SpecializedSetup<cmds::RenderbufferStorage, 0>(
507 bool valid) {
508 DoBindRenderbuffer(GL_RENDERBUFFER, client_renderbuffer_id_,
509 kServiceRenderbufferId);
510 if (valid) {
511 EnsureRenderbufferBound(false);
512 EXPECT_CALL(*gl_, GetError())
513 .WillOnce(Return(GL_NO_ERROR))
514 .RetiresOnSaturation();
515 EXPECT_CALL(*gl_,
516 RenderbufferStorageEXT(GL_RENDERBUFFER, _, 3, 4))
517 .Times(1)
518 .RetiresOnSaturation();
519 EXPECT_CALL(*gl_, GetError())
520 .WillOnce(Return(GL_NO_ERROR))
521 .RetiresOnSaturation();
525 template <>
526 void GLES2DecoderTestBase::SpecializedSetup<cmds::GenQueriesEXTImmediate, 0>(
527 bool valid) {
528 if (!valid) {
529 // Make the client_query_id_ so that trying to make it again
530 // will fail.
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_)));
539 template <>
540 void GLES2DecoderTestBase::SpecializedSetup<cmds::DeleteQueriesEXTImmediate, 0>(
541 bool valid) {
542 if (valid) {
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_)));
552 template <>
553 void GLES2DecoderTestBase::SpecializedSetup<cmds::LinkProgram, 0>(
554 bool /* valid */) {
555 const GLuint kClientVertexShaderId = 5001;
556 const GLuint kServiceVertexShaderId = 6001;
557 const GLuint kClientFragmentShaderId = 5002;
558 const GLuint kServiceFragmentShaderId = 6002;
559 DoCreateShader(
560 GL_VERTEX_SHADER, kClientVertexShaderId, kServiceVertexShaderId);
561 DoCreateShader(
562 GL_FRAGMENT_SHADER, kClientFragmentShaderId, kServiceFragmentShaderId);
564 TestHelper::SetShaderStates(
565 gl_.get(), GetShader(kClientVertexShaderId), true);
566 TestHelper::SetShaderStates(
567 gl_.get(), GetShader(kClientFragmentShaderId), true);
569 InSequence dummy;
570 EXPECT_CALL(*gl_,
571 AttachShader(kServiceProgramId, kServiceVertexShaderId))
572 .Times(1)
573 .RetiresOnSaturation();
574 EXPECT_CALL(*gl_,
575 AttachShader(kServiceProgramId, kServiceFragmentShaderId))
576 .Times(1)
577 .RetiresOnSaturation();
578 EXPECT_CALL(*gl_, GetProgramiv(kServiceProgramId, GL_LINK_STATUS, _))
579 .WillOnce(SetArgumentPointee<2>(1));
580 EXPECT_CALL(*gl_,
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));
586 EXPECT_CALL(
587 *gl_,
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));
592 EXPECT_CALL(
593 *gl_,
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));
605 template <>
606 void GLES2DecoderTestBase::SpecializedSetup<cmds::Uniform1f, 0>(
607 bool /* valid */) {
608 SetupShaderForUniform(GL_FLOAT);
611 template <>
612 void GLES2DecoderTestBase::SpecializedSetup<cmds::Uniform1fvImmediate, 0>(
613 bool /* valid */) {
614 SetupShaderForUniform(GL_FLOAT);
617 template <>
618 void GLES2DecoderTestBase::SpecializedSetup<cmds::Uniform1ivImmediate, 0>(
619 bool /* valid */) {
620 SetupShaderForUniform(GL_INT);
623 template <>
624 void GLES2DecoderTestBase::SpecializedSetup<cmds::Uniform2f, 0>(
625 bool /* valid */) {
626 SetupShaderForUniform(GL_FLOAT_VEC2);
629 template <>
630 void GLES2DecoderTestBase::SpecializedSetup<cmds::Uniform2i, 0>(
631 bool /* valid */) {
632 SetupShaderForUniform(GL_INT_VEC2);
635 template <>
636 void GLES2DecoderTestBase::SpecializedSetup<cmds::Uniform2fvImmediate, 0>(
637 bool /* valid */) {
638 SetupShaderForUniform(GL_FLOAT_VEC2);
641 template <>
642 void GLES2DecoderTestBase::SpecializedSetup<cmds::Uniform2ivImmediate, 0>(
643 bool /* valid */) {
644 SetupShaderForUniform(GL_INT_VEC2);
647 template <>
648 void GLES2DecoderTestBase::SpecializedSetup<cmds::Uniform3f, 0>(
649 bool /* valid */) {
650 SetupShaderForUniform(GL_FLOAT_VEC3);
653 template <>
654 void GLES2DecoderTestBase::SpecializedSetup<cmds::Uniform3i, 0>(
655 bool /* valid */) {
656 SetupShaderForUniform(GL_INT_VEC3);
659 template <>
660 void GLES2DecoderTestBase::SpecializedSetup<cmds::Uniform3fvImmediate, 0>(
661 bool /* valid */) {
662 SetupShaderForUniform(GL_FLOAT_VEC3);
665 template <>
666 void GLES2DecoderTestBase::SpecializedSetup<cmds::Uniform3ivImmediate, 0>(
667 bool /* valid */) {
668 SetupShaderForUniform(GL_INT_VEC3);
671 template <>
672 void GLES2DecoderTestBase::SpecializedSetup<cmds::Uniform4f, 0>(
673 bool /* valid */) {
674 SetupShaderForUniform(GL_FLOAT_VEC4);
677 template <>
678 void GLES2DecoderTestBase::SpecializedSetup<cmds::Uniform4i, 0>(
679 bool /* valid */) {
680 SetupShaderForUniform(GL_INT_VEC4);
683 template <>
684 void GLES2DecoderTestBase::SpecializedSetup<cmds::Uniform4fvImmediate, 0>(
685 bool /* valid */) {
686 SetupShaderForUniform(GL_FLOAT_VEC4);
689 template <>
690 void GLES2DecoderTestBase::SpecializedSetup<cmds::Uniform4ivImmediate, 0>(
691 bool /* valid */) {
692 SetupShaderForUniform(GL_INT_VEC4);
695 template <>
696 void GLES2DecoderTestBase::SpecializedSetup<cmds::UniformMatrix2fvImmediate, 0>(
697 bool /* valid */) {
698 SetupShaderForUniform(GL_FLOAT_MAT2);
701 template <>
702 void GLES2DecoderTestBase::SpecializedSetup<
703 cmds::UniformMatrix2x3fvImmediate, 0>(bool /* valid */) {
704 SetupShaderForUniform(GL_FLOAT_MAT2x3);
707 template <>
708 void GLES2DecoderTestBase::SpecializedSetup<cmds::TexParameterf, 0>(
709 bool /* valid */) {
710 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
713 template <>
714 void GLES2DecoderTestBase::SpecializedSetup<cmds::TexParameteri, 0>(
715 bool /* valid */) {
716 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
719 template <>
720 void GLES2DecoderTestBase::SpecializedSetup<cmds::TexParameterfvImmediate, 0>(
721 bool /* valid */) {
722 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
725 template <>
726 void GLES2DecoderTestBase::SpecializedSetup<cmds::TexParameterivImmediate, 0>(
727 bool /* valid */) {
728 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
731 template <>
732 void GLES2DecoderTestBase::SpecializedSetup<cmds::GetVertexAttribiv, 0>(
733 bool valid) {
734 DoBindBuffer(GL_ARRAY_BUFFER, client_buffer_id_, kServiceBufferId);
735 DoVertexAttribPointer(1, 1, GL_FLOAT, 0, 0);
736 if (valid) {
737 EXPECT_CALL(*gl_, GetError())
738 .WillOnce(Return(GL_NO_ERROR))
739 .WillOnce(Return(GL_NO_ERROR))
740 .RetiresOnSaturation();
744 template <>
745 void GLES2DecoderTestBase::SpecializedSetup<cmds::GetVertexAttribfv, 0>(
746 bool valid) {
747 DoBindBuffer(GL_ARRAY_BUFFER, client_buffer_id_, kServiceBufferId);
748 DoVertexAttribPointer(1, 1, GL_FLOAT, 0, 0);
749 if (valid) {
750 EXPECT_CALL(*gl_, GetError())
751 .WillOnce(Return(GL_NO_ERROR))
752 .WillOnce(Return(GL_NO_ERROR))
753 .RetiresOnSaturation();
757 template <>
758 void GLES2DecoderTestBase::SpecializedSetup<cmds::GetVertexAttribIiv, 0>(
759 bool valid) {
760 DoBindBuffer(GL_ARRAY_BUFFER, client_buffer_id_, kServiceBufferId);
761 DoVertexAttribPointer(1, 1, GL_FLOAT, 0, 0);
762 if (valid) {
763 EXPECT_CALL(*gl_, GetError())
764 .WillOnce(Return(GL_NO_ERROR))
765 .WillOnce(Return(GL_NO_ERROR))
766 .RetiresOnSaturation();
770 template <>
771 void GLES2DecoderTestBase::SpecializedSetup<cmds::GetVertexAttribIuiv, 0>(
772 bool valid) {
773 DoBindBuffer(GL_ARRAY_BUFFER, client_buffer_id_, kServiceBufferId);
774 DoVertexAttribPointer(1, 1, GL_FLOAT, 0, 0);
775 if (valid) {
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) {
803 TestAcceptedUniform(
804 GL_BOOL, Program::kUniform1i | Program::kUniform1f, false);
807 TEST_P(GLES2DecoderTest2, AcceptsUniformES3_GL_BOOL) {
808 TestAcceptedUniform(
809 GL_BOOL,
810 Program::kUniform1i | Program::kUniform1f | Program::kUniform1ui,
811 true);
814 TEST_P(GLES2DecoderTest2, AcceptsUniform_GL_BOOL_VEC2) {
815 TestAcceptedUniform(
816 GL_BOOL_VEC2, Program::kUniform2i | Program::kUniform2f, false);
819 TEST_P(GLES2DecoderTest2, AcceptsUniformES3_GL_BOOL_VEC2) {
820 TestAcceptedUniform(
821 GL_BOOL_VEC2,
822 Program::kUniform2i | Program::kUniform2f | Program::kUniform2ui,
823 true);
826 TEST_P(GLES2DecoderTest2, AcceptsUniform_GL_BOOL_VEC3) {
827 TestAcceptedUniform(
828 GL_BOOL_VEC3, Program::kUniform3i | Program::kUniform3f, false);
831 TEST_P(GLES2DecoderTest2, AcceptsUniformES3_GL_BOOL_VEC3) {
832 TestAcceptedUniform(
833 GL_BOOL_VEC3,
834 Program::kUniform3i | Program::kUniform3f | Program::kUniform3ui,
835 true);
838 TEST_P(GLES2DecoderTest2, AcceptsUniform_GL_BOOL_VEC4) {
839 TestAcceptedUniform(
840 GL_BOOL_VEC4, Program::kUniform4i | Program::kUniform4f, false);
843 TEST_P(GLES2DecoderTest2, AcceptsUniformES3_GL_BOOL_VEC4) {
844 TestAcceptedUniform(
845 GL_BOOL_VEC4,
846 Program::kUniform4i | Program::kUniform4f | Program::kUniform4ui,
847 true);
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);
918 } // namespace gles2
919 } // namespace gpu