1 // Copyright 2014 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 "base/command_line.h"
8 #include "base/strings/string_number_conversions.h"
9 #include "gpu/command_buffer/common/gles2_cmd_format.h"
10 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
11 #include "gpu/command_buffer/service/async_pixel_transfer_delegate_mock.h"
12 #include "gpu/command_buffer/service/async_pixel_transfer_manager.h"
13 #include "gpu/command_buffer/service/async_pixel_transfer_manager_mock.h"
14 #include "gpu/command_buffer/service/cmd_buffer_engine.h"
15 #include "gpu/command_buffer/service/context_group.h"
16 #include "gpu/command_buffer/service/context_state.h"
17 #include "gpu/command_buffer/service/gl_surface_mock.h"
18 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest.h"
20 #include "gpu/command_buffer/service/image_manager.h"
21 #include "gpu/command_buffer/service/mailbox_manager.h"
22 #include "gpu/command_buffer/service/mocks.h"
23 #include "gpu/command_buffer/service/program_manager.h"
24 #include "gpu/command_buffer/service/test_helper.h"
25 #include "gpu/config/gpu_switches.h"
26 #include "testing/gtest/include/gtest/gtest.h"
27 #include "ui/gl/gl_implementation.h"
28 #include "ui/gl/gl_mock.h"
29 #include "ui/gl/gl_surface_stub.h"
31 #if !defined(GL_DEPTH24_STENCIL8)
32 #define GL_DEPTH24_STENCIL8 0x88F0
35 using ::gfx::MockGLInterface
;
37 using ::testing::DoAll
;
38 using ::testing::InSequence
;
39 using ::testing::Invoke
;
40 using ::testing::MatcherCast
;
41 using ::testing::Mock
;
42 using ::testing::Pointee
;
43 using ::testing::Return
;
44 using ::testing::SaveArg
;
45 using ::testing::SetArrayArgument
;
46 using ::testing::SetArgumentPointee
;
47 using ::testing::SetArgPointee
;
48 using ::testing::StrEq
;
49 using ::testing::StrictMock
;
56 class GLES2DecoderGeometryInstancingTest
: public GLES2DecoderWithShaderTest
{
58 GLES2DecoderGeometryInstancingTest() : GLES2DecoderWithShaderTest() {}
60 void SetUp() override
{
62 init
.extensions
= "GL_ANGLE_instanced_arrays";
63 // Most of the tests in this file assume they're running on
64 // desktop OpenGL, and large portions of the tests will become
65 // no-ops if they aren't.
66 init
.gl_version
= "opengl 2.1";
67 init
.has_alpha
= true;
68 init
.has_depth
= true;
69 init
.request_alpha
= true;
70 init
.request_depth
= true;
71 init
.bind_generates_resource
= true;
73 SetupDefaultProgram();
77 INSTANTIATE_TEST_CASE_P(Service
,
78 GLES2DecoderGeometryInstancingTest
,
81 void GLES2DecoderManualInitTest::DirtyStateMaskTest(GLuint color_bits
,
83 GLuint front_stencil_mask
,
84 GLuint back_stencil_mask
) {
85 ColorMask color_mask_cmd
;
86 color_mask_cmd
.Init((color_bits
& 0x1000) != 0,
87 (color_bits
& 0x0100) != 0,
88 (color_bits
& 0x0010) != 0,
89 (color_bits
& 0x0001) != 0);
90 EXPECT_EQ(error::kNoError
, ExecuteCmd(color_mask_cmd
));
91 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
93 DepthMask depth_mask_cmd
;
94 depth_mask_cmd
.Init(depth_mask
);
95 EXPECT_EQ(error::kNoError
, ExecuteCmd(depth_mask_cmd
));
96 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
98 StencilMaskSeparate front_stencil_mask_cmd
;
99 front_stencil_mask_cmd
.Init(GL_FRONT
, front_stencil_mask
);
100 EXPECT_EQ(error::kNoError
, ExecuteCmd(front_stencil_mask_cmd
));
101 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
103 StencilMaskSeparate back_stencil_mask_cmd
;
104 back_stencil_mask_cmd
.Init(GL_BACK
, back_stencil_mask
);
105 EXPECT_EQ(error::kNoError
, ExecuteCmd(back_stencil_mask_cmd
));
106 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
108 SetupExpectationsForApplyingDirtyState(
109 false, // Framebuffer is RGB
110 true, // Framebuffer has depth
111 true, // Framebuffer has stencil
112 color_bits
, // color bits
113 depth_mask
, // depth mask
114 false, // depth enabled
115 front_stencil_mask
, // front stencil mask
116 back_stencil_mask
, // back stencil mask
117 false); // stencil enabled
119 EXPECT_CALL(*gl_
, DrawArrays(GL_TRIANGLES
, 0, kNumVertices
))
121 .RetiresOnSaturation();
123 draw_cmd
.Init(GL_TRIANGLES
, 0, kNumVertices
);
124 EXPECT_EQ(error::kNoError
, ExecuteCmd(draw_cmd
));
125 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
128 // Test that with an RGB backbuffer if we set the color mask to 1,1,1,1 it is
129 // set to 1,1,1,0 at Draw time but is 1,1,1,1 at query time.
130 TEST_P(GLES2DecoderRGBBackbufferTest
, RGBBackbufferColorMask
) {
132 cmd
.Init(true, true, true, true);
133 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
134 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
137 AddExpectationsForSimulatedAttrib0(kNumVertices
, 0);
138 SetupExpectationsForApplyingDirtyState(true, // Framebuffer is RGB
139 false, // Framebuffer has depth
140 false, // Framebuffer has stencil
141 0x1110, // color bits
143 false, // depth enabled
144 0, // front stencil mask
145 0, // back stencil mask
146 false); // stencil enabled
148 EXPECT_CALL(*gl_
, DrawArrays(GL_TRIANGLES
, 0, kNumVertices
))
150 .RetiresOnSaturation();
152 draw_cmd
.Init(GL_TRIANGLES
, 0, kNumVertices
);
153 EXPECT_EQ(error::kNoError
, ExecuteCmd(draw_cmd
));
154 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
156 EXPECT_CALL(*gl_
, GetError())
157 .WillOnce(Return(GL_NO_ERROR
))
158 .WillOnce(Return(GL_NO_ERROR
))
159 .RetiresOnSaturation();
160 typedef GetIntegerv::Result Result
;
161 Result
* result
= static_cast<Result
*>(shared_memory_address_
);
162 EXPECT_CALL(*gl_
, GetIntegerv(GL_COLOR_WRITEMASK
, result
->GetData()))
166 cmd2
.Init(GL_COLOR_WRITEMASK
, shared_memory_id_
, shared_memory_offset_
);
167 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd2
));
169 decoder_
->GetGLES2Util()->GLGetNumValuesReturned(GL_COLOR_WRITEMASK
),
170 result
->GetNumResults());
171 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
172 EXPECT_EQ(1, result
->GetData()[0]);
173 EXPECT_EQ(1, result
->GetData()[1]);
174 EXPECT_EQ(1, result
->GetData()[2]);
175 EXPECT_EQ(1, result
->GetData()[3]);
178 // Test that with no depth if we set DepthMask true that it's set to false at
179 // draw time but querying it returns true.
180 TEST_P(GLES2DecoderRGBBackbufferTest
, RGBBackbufferDepthMask
) {
181 EXPECT_CALL(*gl_
, DepthMask(true)).Times(0).RetiresOnSaturation();
184 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
185 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
188 AddExpectationsForSimulatedAttrib0(kNumVertices
, 0);
189 SetupExpectationsForApplyingDirtyState(true, // Framebuffer is RGB
190 false, // Framebuffer has depth
191 false, // Framebuffer has stencil
192 0x1110, // color bits
194 false, // depth enabled
195 0, // front stencil mask
196 0, // back stencil mask
197 false); // stencil enabled
199 EXPECT_CALL(*gl_
, DrawArrays(GL_TRIANGLES
, 0, kNumVertices
))
201 .RetiresOnSaturation();
203 draw_cmd
.Init(GL_TRIANGLES
, 0, kNumVertices
);
204 EXPECT_EQ(error::kNoError
, ExecuteCmd(draw_cmd
));
205 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
207 EXPECT_CALL(*gl_
, GetError())
208 .WillOnce(Return(GL_NO_ERROR
))
209 .WillOnce(Return(GL_NO_ERROR
))
210 .RetiresOnSaturation();
211 typedef GetIntegerv::Result Result
;
212 Result
* result
= static_cast<Result
*>(shared_memory_address_
);
213 EXPECT_CALL(*gl_
, GetIntegerv(GL_DEPTH_WRITEMASK
, result
->GetData()))
217 cmd2
.Init(GL_DEPTH_WRITEMASK
, shared_memory_id_
, shared_memory_offset_
);
218 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd2
));
220 decoder_
->GetGLES2Util()->GLGetNumValuesReturned(GL_DEPTH_WRITEMASK
),
221 result
->GetNumResults());
222 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
223 EXPECT_EQ(1, result
->GetData()[0]);
226 // Test that with no stencil if we set the stencil mask it's still set to 0 at
227 // draw time but gets our value if we query.
228 TEST_P(GLES2DecoderRGBBackbufferTest
, RGBBackbufferStencilMask
) {
229 const GLint kMask
= 123;
230 EXPECT_CALL(*gl_
, StencilMask(kMask
)).Times(0).RetiresOnSaturation();
233 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
234 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
237 AddExpectationsForSimulatedAttrib0(kNumVertices
, 0);
238 SetupExpectationsForApplyingDirtyState(true, // Framebuffer is RGB
239 false, // Framebuffer has depth
240 false, // Framebuffer has stencil
241 0x1110, // color bits
243 false, // depth enabled
244 0, // front stencil mask
245 0, // back stencil mask
246 false); // stencil enabled
248 EXPECT_CALL(*gl_
, DrawArrays(GL_TRIANGLES
, 0, kNumVertices
))
250 .RetiresOnSaturation();
252 draw_cmd
.Init(GL_TRIANGLES
, 0, kNumVertices
);
253 EXPECT_EQ(error::kNoError
, ExecuteCmd(draw_cmd
));
254 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
256 EXPECT_CALL(*gl_
, GetError())
257 .WillOnce(Return(GL_NO_ERROR
))
258 .WillOnce(Return(GL_NO_ERROR
))
259 .RetiresOnSaturation();
260 typedef GetIntegerv::Result Result
;
261 Result
* result
= static_cast<Result
*>(shared_memory_address_
);
262 EXPECT_CALL(*gl_
, GetIntegerv(GL_STENCIL_WRITEMASK
, result
->GetData()))
266 cmd2
.Init(GL_STENCIL_WRITEMASK
, shared_memory_id_
, shared_memory_offset_
);
267 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd2
));
269 decoder_
->GetGLES2Util()->GLGetNumValuesReturned(GL_STENCIL_WRITEMASK
),
270 result
->GetNumResults());
271 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
272 EXPECT_EQ(kMask
, result
->GetData()[0]);
275 // Test that if an FBO is bound we get the correct masks.
276 TEST_P(GLES2DecoderRGBBackbufferTest
, RGBBackbufferColorMaskFBO
) {
278 cmd
.Init(true, true, true, true);
279 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
280 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
284 DoEnableVertexAttribArray(0);
285 DoVertexAttribPointer(0, 2, GL_FLOAT
, 0, 0);
286 DoEnableVertexAttribArray(1);
287 DoVertexAttribPointer(1, 2, GL_FLOAT
, 0, 0);
288 DoEnableVertexAttribArray(2);
289 DoVertexAttribPointer(2, 2, GL_FLOAT
, 0, 0);
290 SetupExpectationsForApplyingDirtyState(true, // Framebuffer is RGB
291 false, // Framebuffer has depth
292 false, // Framebuffer has stencil
293 0x1110, // color bits
295 false, // depth enabled
296 0, // front stencil mask
297 0, // back stencil mask
298 false); // stencil enabled
300 EXPECT_CALL(*gl_
, DrawArrays(GL_TRIANGLES
, 0, kNumVertices
))
302 .RetiresOnSaturation();
304 draw_cmd
.Init(GL_TRIANGLES
, 0, kNumVertices
);
305 EXPECT_EQ(error::kNoError
, ExecuteCmd(draw_cmd
));
306 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
308 // Check that no extra calls are made on the next draw.
309 EXPECT_CALL(*gl_
, DrawArrays(GL_TRIANGLES
, 0, kNumVertices
))
311 .RetiresOnSaturation();
312 EXPECT_EQ(error::kNoError
, ExecuteCmd(draw_cmd
));
313 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
315 // Setup Frame buffer.
316 // needs to be 1x1 or else it's not renderable.
317 const GLsizei kWidth
= 1;
318 const GLsizei kHeight
= 1;
319 const GLenum kFormat
= GL_RGB
;
320 // Use a different texture for framebuffer to avoid drawing feedback loops.
321 EXPECT_CALL(*gl_
, GenTextures(_
, _
))
322 .WillOnce(SetArgumentPointee
<1>(kNewServiceId
))
323 .RetiresOnSaturation();
324 GenHelper
<cmds::GenTexturesImmediate
>(kNewClientId
);
325 DoBindTexture(GL_TEXTURE_2D
, kNewClientId
, kNewServiceId
);
326 // Pass some data so the texture will be marked as cleared.
327 DoTexImage2D(GL_TEXTURE_2D
,
336 kSharedMemoryOffset
);
338 GL_FRAMEBUFFER
, client_framebuffer_id_
, kServiceFramebufferId
);
339 DoFramebufferTexture2D(GL_FRAMEBUFFER
,
340 GL_COLOR_ATTACHMENT0
,
346 DoBindTexture(GL_TEXTURE_2D
, client_texture_id_
, kServiceTextureId
);
347 EXPECT_CALL(*gl_
, CheckFramebufferStatusEXT(GL_FRAMEBUFFER
))
348 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE
))
349 .RetiresOnSaturation();
351 // This time state needs to be set.
352 SetupExpectationsForApplyingDirtyState(false, // Framebuffer is RGB
353 false, // Framebuffer has depth
354 false, // Framebuffer has stencil
355 0x1110, // color bits
357 false, // depth enabled
358 0, // front stencil mask
359 0, // back stencil mask
360 false); // stencil enabled
362 EXPECT_CALL(*gl_
, DrawArrays(GL_TRIANGLES
, 0, kNumVertices
))
364 .RetiresOnSaturation();
365 EXPECT_EQ(error::kNoError
, ExecuteCmd(draw_cmd
));
366 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
368 // Check that no extra calls are made on the next draw.
369 EXPECT_CALL(*gl_
, DrawArrays(GL_TRIANGLES
, 0, kNumVertices
))
371 .RetiresOnSaturation();
372 EXPECT_EQ(error::kNoError
, ExecuteCmd(draw_cmd
));
373 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
376 DoBindFramebuffer(GL_FRAMEBUFFER
, 0, 0);
378 SetupExpectationsForApplyingDirtyState(true, // Framebuffer is RGB
379 false, // Framebuffer has depth
380 false, // Framebuffer has stencil
381 0x1110, // color bits
383 false, // depth enabled
384 0, // front stencil mask
385 0, // back stencil mask
386 false); // stencil enabled
388 EXPECT_CALL(*gl_
, DrawArrays(GL_TRIANGLES
, 0, kNumVertices
))
390 .RetiresOnSaturation();
391 EXPECT_EQ(error::kNoError
, ExecuteCmd(draw_cmd
));
392 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
395 TEST_P(GLES2DecoderManualInitTest
, DepthEnableWithDepth
) {
397 init
.has_depth
= true;
398 init
.request_depth
= true;
399 init
.bind_generates_resource
= true;
403 cmd
.Init(GL_DEPTH_TEST
);
404 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
405 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
407 SetupDefaultProgram();
409 AddExpectationsForSimulatedAttrib0(kNumVertices
, 0);
410 SetupExpectationsForApplyingDirtyState(true, // Framebuffer is RGB
411 true, // Framebuffer has depth
412 false, // Framebuffer has stencil
413 0x1110, // color bits
415 true, // depth enabled
416 0, // front stencil mask
417 0, // back stencil mask
418 false); // stencil enabled
420 EXPECT_CALL(*gl_
, DrawArrays(GL_TRIANGLES
, 0, kNumVertices
))
422 .RetiresOnSaturation();
424 draw_cmd
.Init(GL_TRIANGLES
, 0, kNumVertices
);
425 EXPECT_EQ(error::kNoError
, ExecuteCmd(draw_cmd
));
426 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
428 EXPECT_CALL(*gl_
, GetError())
429 .WillOnce(Return(GL_NO_ERROR
))
430 .WillOnce(Return(GL_NO_ERROR
))
431 .RetiresOnSaturation();
432 typedef GetIntegerv::Result Result
;
433 Result
* result
= static_cast<Result
*>(shared_memory_address_
);
434 EXPECT_CALL(*gl_
, GetIntegerv(GL_DEPTH_TEST
, _
))
436 .RetiresOnSaturation();
439 cmd2
.Init(GL_DEPTH_TEST
, shared_memory_id_
, shared_memory_offset_
);
440 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd2
));
441 EXPECT_EQ(decoder_
->GetGLES2Util()->GLGetNumValuesReturned(GL_DEPTH_TEST
),
442 result
->GetNumResults());
443 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
444 EXPECT_EQ(1, result
->GetData()[0]);
447 TEST_P(GLES2DecoderManualInitTest
, DepthEnableWithoutRequestedDepth
) {
449 init
.has_depth
= true;
450 init
.bind_generates_resource
= true;
454 cmd
.Init(GL_DEPTH_TEST
);
455 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
456 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
458 SetupDefaultProgram();
460 AddExpectationsForSimulatedAttrib0(kNumVertices
, 0);
461 SetupExpectationsForApplyingDirtyState(true, // Framebuffer is RGB
462 false, // Framebuffer has depth
463 false, // Framebuffer has stencil
464 0x1110, // color bits
466 false, // depth enabled
467 0, // front stencil mask
468 0, // back stencil mask
469 false); // stencil enabled
471 EXPECT_CALL(*gl_
, DrawArrays(GL_TRIANGLES
, 0, kNumVertices
))
473 .RetiresOnSaturation();
475 draw_cmd
.Init(GL_TRIANGLES
, 0, kNumVertices
);
476 EXPECT_EQ(error::kNoError
, ExecuteCmd(draw_cmd
));
477 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
479 EXPECT_CALL(*gl_
, GetError())
480 .WillOnce(Return(GL_NO_ERROR
))
481 .WillOnce(Return(GL_NO_ERROR
))
482 .RetiresOnSaturation();
483 typedef GetIntegerv::Result Result
;
484 Result
* result
= static_cast<Result
*>(shared_memory_address_
);
485 EXPECT_CALL(*gl_
, GetIntegerv(GL_DEPTH_TEST
, _
))
487 .RetiresOnSaturation();
490 cmd2
.Init(GL_DEPTH_TEST
, shared_memory_id_
, shared_memory_offset_
);
491 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd2
));
492 EXPECT_EQ(decoder_
->GetGLES2Util()->GLGetNumValuesReturned(GL_DEPTH_TEST
),
493 result
->GetNumResults());
494 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
495 EXPECT_EQ(1, result
->GetData()[0]);
498 TEST_P(GLES2DecoderManualInitTest
, StencilEnableWithStencil
) {
500 init
.has_stencil
= true;
501 init
.request_stencil
= true;
502 init
.bind_generates_resource
= true;
506 cmd
.Init(GL_STENCIL_TEST
);
507 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
508 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
510 SetupDefaultProgram();
512 AddExpectationsForSimulatedAttrib0(kNumVertices
, 0);
513 SetupExpectationsForApplyingDirtyState(
514 true, // Framebuffer is RGB
515 false, // Framebuffer has depth
516 true, // Framebuffer has stencil
517 0x1110, // color bits
519 false, // depth enabled
520 GLES2Decoder::kDefaultStencilMask
, // front stencil mask
521 GLES2Decoder::kDefaultStencilMask
, // back stencil mask
522 true); // stencil enabled
524 EXPECT_CALL(*gl_
, DrawArrays(GL_TRIANGLES
, 0, kNumVertices
))
526 .RetiresOnSaturation();
528 draw_cmd
.Init(GL_TRIANGLES
, 0, kNumVertices
);
529 EXPECT_EQ(error::kNoError
, ExecuteCmd(draw_cmd
));
530 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
532 EXPECT_CALL(*gl_
, GetError())
533 .WillOnce(Return(GL_NO_ERROR
))
534 .WillOnce(Return(GL_NO_ERROR
))
535 .RetiresOnSaturation();
536 typedef GetIntegerv::Result Result
;
537 Result
* result
= static_cast<Result
*>(shared_memory_address_
);
538 EXPECT_CALL(*gl_
, GetIntegerv(GL_STENCIL_TEST
, _
))
540 .RetiresOnSaturation();
543 cmd2
.Init(GL_STENCIL_TEST
, shared_memory_id_
, shared_memory_offset_
);
544 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd2
));
545 EXPECT_EQ(decoder_
->GetGLES2Util()->GLGetNumValuesReturned(GL_STENCIL_TEST
),
546 result
->GetNumResults());
547 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
548 EXPECT_EQ(1, result
->GetData()[0]);
551 TEST_P(GLES2DecoderManualInitTest
, StencilEnableWithoutRequestedStencil
) {
553 init
.has_stencil
= true;
554 init
.bind_generates_resource
= true;
558 cmd
.Init(GL_STENCIL_TEST
);
559 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
560 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
562 SetupDefaultProgram();
564 AddExpectationsForSimulatedAttrib0(kNumVertices
, 0);
565 SetupExpectationsForApplyingDirtyState(true, // Framebuffer is RGB
566 false, // Framebuffer has depth
567 false, // Framebuffer has stencil
568 0x1110, // color bits
570 false, // depth enabled
571 0, // front stencil mask
572 0, // back stencil mask
573 false); // stencil enabled
575 EXPECT_CALL(*gl_
, DrawArrays(GL_TRIANGLES
, 0, kNumVertices
))
577 .RetiresOnSaturation();
579 draw_cmd
.Init(GL_TRIANGLES
, 0, kNumVertices
);
580 EXPECT_EQ(error::kNoError
, ExecuteCmd(draw_cmd
));
581 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
583 EXPECT_CALL(*gl_
, GetError())
584 .WillOnce(Return(GL_NO_ERROR
))
585 .WillOnce(Return(GL_NO_ERROR
))
586 .RetiresOnSaturation();
587 typedef GetIntegerv::Result Result
;
588 Result
* result
= static_cast<Result
*>(shared_memory_address_
);
589 EXPECT_CALL(*gl_
, GetIntegerv(GL_STENCIL_TEST
, _
))
591 .RetiresOnSaturation();
594 cmd2
.Init(GL_STENCIL_TEST
, shared_memory_id_
, shared_memory_offset_
);
595 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd2
));
596 EXPECT_EQ(decoder_
->GetGLES2Util()->GLGetNumValuesReturned(GL_STENCIL_TEST
),
597 result
->GetNumResults());
598 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
599 EXPECT_EQ(1, result
->GetData()[0]);
602 TEST_P(GLES2DecoderManualInitTest
, CachedColorMask
) {
604 init
.has_alpha
= true;
605 init
.has_depth
= true;
606 init
.has_stencil
= true;
607 init
.request_alpha
= true;
608 init
.request_depth
= true;
609 init
.request_stencil
= true;
610 init
.bind_generates_resource
= true;
613 SetupDefaultProgram();
614 SetupAllNeededVertexBuffers();
617 // Test all color_bits combinations twice.
618 for (int i
= 0; i
< 32; i
++) {
619 GLuint color_bits
= (i
& 1 ? 0x0001 : 0x0000) | (i
& 2 ? 0x0010 : 0x0000) |
620 (i
& 4 ? 0x0100 : 0x0000) | (i
& 8 ? 0x1000 : 0x0000);
622 // Toggle depth_test to force ApplyDirtyState each time.
623 DirtyStateMaskTest(color_bits
, false, 0xffffffff, 0xffffffff);
624 DirtyStateMaskTest(color_bits
, true, 0xffffffff, 0xffffffff);
625 DirtyStateMaskTest(color_bits
, false, 0xffffffff, 0xffffffff);
629 TEST_P(GLES2DecoderManualInitTest
, CachedDepthMask
) {
631 init
.has_alpha
= true;
632 init
.has_depth
= true;
633 init
.has_stencil
= true;
634 init
.request_alpha
= true;
635 init
.request_depth
= true;
636 init
.request_stencil
= true;
637 init
.bind_generates_resource
= true;
640 SetupDefaultProgram();
641 SetupAllNeededVertexBuffers();
644 // Test all depth_mask combinations twice.
645 for (int i
= 0; i
< 4; i
++) {
646 bool depth_mask
= (i
& 1) == 1;
648 // Toggle color masks to force ApplyDirtyState each time.
649 DirtyStateMaskTest(0x1010, depth_mask
, 0xffffffff, 0xffffffff);
650 DirtyStateMaskTest(0x0101, depth_mask
, 0xffffffff, 0xffffffff);
651 DirtyStateMaskTest(0x1010, depth_mask
, 0xffffffff, 0xffffffff);
655 TEST_P(GLES2DecoderManualInitTest
, CachedStencilMask
) {
657 init
.has_alpha
= true;
658 init
.has_depth
= true;
659 init
.has_stencil
= true;
660 init
.request_alpha
= true;
661 init
.request_depth
= true;
662 init
.request_stencil
= true;
663 init
.bind_generates_resource
= true;
666 SetupDefaultProgram();
667 SetupAllNeededVertexBuffers();
670 // Test all stencil_mask combinations twice.
671 for (int i
= 0; i
< 4; i
++) {
672 GLuint stencil_mask
= (i
& 1) ? 0xf0f0f0f0 : 0x0f0f0f0f;
674 // Toggle color masks to force ApplyDirtyState each time.
675 DirtyStateMaskTest(0x1010, true, stencil_mask
, 0xffffffff);
676 DirtyStateMaskTest(0x0101, true, stencil_mask
, 0xffffffff);
677 DirtyStateMaskTest(0x1010, true, stencil_mask
, 0xffffffff);
680 for (int i
= 0; i
< 4; i
++) {
681 GLuint stencil_mask
= (i
& 1) ? 0xf0f0f0f0 : 0x0f0f0f0f;
683 // Toggle color masks to force ApplyDirtyState each time.
684 DirtyStateMaskTest(0x1010, true, 0xffffffff, stencil_mask
);
685 DirtyStateMaskTest(0x0101, true, 0xffffffff, stencil_mask
);
686 DirtyStateMaskTest(0x1010, true, 0xffffffff, stencil_mask
);
690 TEST_P(GLES2DecoderWithShaderTest
, DrawArraysNoAttributesSucceeds
) {
692 AddExpectationsForSimulatedAttrib0(kNumVertices
, 0);
693 SetupExpectationsForApplyingDefaultDirtyState();
695 EXPECT_CALL(*gl_
, DrawArrays(GL_TRIANGLES
, 0, kNumVertices
))
697 .RetiresOnSaturation();
699 cmd
.Init(GL_TRIANGLES
, 0, kNumVertices
);
700 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
701 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
704 // Tests when the math overflows (0x40000000 * sizeof GLfloat)
705 TEST_P(GLES2DecoderWithShaderTest
, DrawArraysSimulatedAttrib0OverflowFails
) {
706 const GLsizei kLargeCount
= 0x40000000;
708 EXPECT_CALL(*gl_
, DrawArrays(_
, _
, _
)).Times(0).RetiresOnSaturation();
710 cmd
.Init(GL_TRIANGLES
, 0, kLargeCount
);
711 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
712 EXPECT_EQ(GL_OUT_OF_MEMORY
, GetGLError());
713 EXPECT_FALSE(GetDecoder()->WasContextLost());
716 // Tests when the math overflows (0x7FFFFFFF + 1 = 0x8000000 verts)
717 TEST_P(GLES2DecoderWithShaderTest
, DrawArraysSimulatedAttrib0PosToNegFails
) {
718 const GLsizei kLargeCount
= 0x7FFFFFFF;
720 EXPECT_CALL(*gl_
, DrawArrays(_
, _
, _
)).Times(0).RetiresOnSaturation();
722 cmd
.Init(GL_TRIANGLES
, 0, kLargeCount
);
723 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
724 EXPECT_EQ(GL_OUT_OF_MEMORY
, GetGLError());
725 EXPECT_FALSE(GetDecoder()->WasContextLost());
728 // Tests when the driver returns an error
729 TEST_P(GLES2DecoderWithShaderTest
, DrawArraysSimulatedAttrib0OOMFails
) {
730 const GLsizei kFakeLargeCount
= 0x1234;
732 AddExpectationsForSimulatedAttrib0WithError(
733 kFakeLargeCount
, 0, GL_OUT_OF_MEMORY
);
734 EXPECT_CALL(*gl_
, DrawArrays(_
, _
, _
)).Times(0).RetiresOnSaturation();
736 cmd
.Init(GL_TRIANGLES
, 0, kFakeLargeCount
);
737 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
738 EXPECT_EQ(GL_OUT_OF_MEMORY
, GetGLError());
739 EXPECT_FALSE(GetDecoder()->WasContextLost());
742 TEST_P(GLES2DecoderWithShaderTest
, DrawArraysBadTextureUsesBlack
) {
743 DoBindTexture(GL_TEXTURE_2D
, client_texture_id_
, kServiceTextureId
);
744 // This is an NPOT texture. As the default filtering requires mips
745 // this should trigger replacing with black textures before rendering.
746 DoTexImage2D(GL_TEXTURE_2D
,
755 kSharedMemoryOffset
);
756 AddExpectationsForSimulatedAttrib0(kNumVertices
, 0);
759 EXPECT_CALL(*gl_
, ActiveTexture(GL_TEXTURE0
))
761 .RetiresOnSaturation();
763 *gl_
, BindTexture(GL_TEXTURE_2D
, TestHelper::kServiceBlackTexture2dId
))
765 .RetiresOnSaturation();
766 EXPECT_CALL(*gl_
, DrawArrays(GL_TRIANGLES
, 0, kNumVertices
))
768 .RetiresOnSaturation();
769 EXPECT_CALL(*gl_
, ActiveTexture(GL_TEXTURE0
))
771 .RetiresOnSaturation();
772 EXPECT_CALL(*gl_
, BindTexture(GL_TEXTURE_2D
, kServiceTextureId
))
774 .RetiresOnSaturation();
775 EXPECT_CALL(*gl_
, ActiveTexture(GL_TEXTURE0
))
777 .RetiresOnSaturation();
779 SetupExpectationsForApplyingDefaultDirtyState();
781 cmd
.Init(GL_TRIANGLES
, 0, kNumVertices
);
782 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
783 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
786 TEST_P(GLES2DecoderWithShaderTest
, DrawArraysMissingAttributesFails
) {
787 DoEnableVertexAttribArray(1);
789 EXPECT_CALL(*gl_
, DrawArrays(_
, _
, _
)).Times(0);
791 cmd
.Init(GL_TRIANGLES
, 0, kNumVertices
);
792 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
793 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
796 TEST_P(GLES2DecoderWithShaderTest
,
797 DrawArraysMissingAttributesZeroCountSucceeds
) {
798 DoEnableVertexAttribArray(1);
800 EXPECT_CALL(*gl_
, DrawArrays(_
, _
, _
)).Times(0);
802 cmd
.Init(GL_TRIANGLES
, 0, 0);
803 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
804 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
807 TEST_P(GLES2DecoderWithShaderTest
, DrawArraysValidAttributesSucceeds
) {
810 DoEnableVertexAttribArray(1);
811 DoVertexAttribPointer(1, 2, GL_FLOAT
, 0, 0);
812 AddExpectationsForSimulatedAttrib0(kNumVertices
, kServiceBufferId
);
813 SetupExpectationsForApplyingDefaultDirtyState();
815 EXPECT_CALL(*gl_
, DrawArrays(GL_TRIANGLES
, 0, kNumVertices
))
817 .RetiresOnSaturation();
819 cmd
.Init(GL_TRIANGLES
, 0, kNumVertices
);
820 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
821 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
824 // Same as DrawArraysValidAttributesSucceeds, but with workaround
825 // |init_vertex_attributes|.
826 TEST_P(GLES2DecoderManualInitTest
, InitVertexAttributes
) {
827 base::CommandLine
command_line(0, NULL
);
828 command_line
.AppendSwitchASCII(
829 switches::kGpuDriverBugWorkarounds
,
830 base::IntToString(gpu::INIT_VERTEX_ATTRIBUTES
));
832 init
.has_alpha
= true;
833 init
.has_depth
= true;
834 init
.request_alpha
= true;
835 init
.request_depth
= true;
836 init
.bind_generates_resource
= true;
837 InitDecoderWithCommandLine(init
, &command_line
);
838 SetupDefaultProgram();
841 DoEnableVertexAttribArray(1);
842 DoVertexAttribPointer(1, 2, GL_FLOAT
, 0, 0);
843 AddExpectationsForSimulatedAttrib0(kNumVertices
, kServiceBufferId
);
844 SetupExpectationsForApplyingDefaultDirtyState();
846 EXPECT_CALL(*gl_
, DrawArrays(GL_TRIANGLES
, 0, kNumVertices
))
848 .RetiresOnSaturation();
850 cmd
.Init(GL_TRIANGLES
, 0, kNumVertices
);
851 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
852 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
855 TEST_P(GLES2DecoderWithShaderTest
, DrawArraysDeletedBufferFails
) {
857 DoVertexAttribPointer(1, 2, GL_FLOAT
, 0, 0);
858 DeleteVertexBuffer();
860 EXPECT_CALL(*gl_
, DrawArrays(_
, _
, _
)).Times(0);
862 cmd
.Init(GL_TRIANGLES
, 0, kNumVertices
);
863 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
864 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
867 TEST_P(GLES2DecoderWithShaderTest
, DrawArraysDeletedProgramSucceeds
) {
869 AddExpectationsForSimulatedAttrib0(kNumVertices
, 0);
870 SetupExpectationsForApplyingDefaultDirtyState();
871 DoDeleteProgram(client_program_id_
, kServiceProgramId
);
873 EXPECT_CALL(*gl_
, DrawArrays(_
, _
, _
)).Times(1).RetiresOnSaturation();
874 EXPECT_CALL(*gl_
, DeleteProgram(kServiceProgramId
)).Times(1);
876 cmd
.Init(GL_TRIANGLES
, 0, kNumVertices
);
877 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
878 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
881 TEST_P(GLES2DecoderWithShaderTest
, DrawArraysWithInvalidModeFails
) {
883 DoVertexAttribPointer(1, 2, GL_FLOAT
, 0, 0);
885 EXPECT_CALL(*gl_
, DrawArrays(_
, _
, _
)).Times(0);
887 cmd
.Init(GL_QUADS
, 0, 1);
888 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
889 EXPECT_EQ(GL_INVALID_ENUM
, GetGLError());
890 cmd
.Init(GL_POLYGON
, 0, 1);
891 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
892 EXPECT_EQ(GL_INVALID_ENUM
, GetGLError());
895 TEST_P(GLES2DecoderWithShaderTest
, DrawArraysInvalidCountFails
) {
897 DoVertexAttribPointer(1, 2, GL_FLOAT
, 0, 0);
900 EXPECT_CALL(*gl_
, DrawArrays(_
, _
, _
)).Times(0);
902 cmd
.Init(GL_TRIANGLES
, 1, kNumVertices
);
903 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
904 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
905 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
907 // Try with count > size
908 cmd
.Init(GL_TRIANGLES
, 0, kNumVertices
+ 1);
909 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
910 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
911 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
913 // Try with attrib offset > 0
914 cmd
.Init(GL_TRIANGLES
, 0, kNumVertices
);
915 DoVertexAttribPointer(1, 2, GL_FLOAT
, 0, 4);
916 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
917 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
918 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
920 // Try with size > 2 (ie, vec3 instead of vec2)
921 DoVertexAttribPointer(1, 3, GL_FLOAT
, 0, 0);
922 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
923 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
924 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
926 // Try with stride > 8 (vec2 + vec2 byte)
927 DoVertexAttribPointer(1, 2, GL_FLOAT
, sizeof(GLfloat
) * 3, 0);
928 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
929 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
930 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
933 TEST_P(GLES2DecoderWithShaderTest
, DrawArraysInstancedANGLEFails
) {
936 DoEnableVertexAttribArray(1);
937 DoVertexAttribPointer(1, 2, GL_FLOAT
, 0, 0);
939 EXPECT_CALL(*gl_
, DrawArraysInstancedANGLE(_
, _
, _
, _
))
941 .RetiresOnSaturation();
942 DrawArraysInstancedANGLE cmd
;
943 cmd
.Init(GL_TRIANGLES
, 0, kNumVertices
, 1);
944 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
945 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
948 TEST_P(GLES2DecoderWithShaderTest
, VertexAttribDivisorANGLEFails
) {
951 DoEnableVertexAttribArray(1);
952 DoVertexAttribPointer(1, 2, GL_FLOAT
, 0, 0);
954 EXPECT_CALL(*gl_
, VertexAttribDivisorANGLE(_
, _
))
956 .RetiresOnSaturation();
958 VertexAttribDivisorANGLE cmd
;
960 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
961 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
964 TEST_P(GLES2DecoderGeometryInstancingTest
,
965 DrawArraysInstancedANGLENoAttributesFails
) {
968 EXPECT_CALL(*gl_
, DrawArraysInstancedANGLE(_
, _
, _
, _
))
970 .RetiresOnSaturation();
971 DrawArraysInstancedANGLE cmd
;
972 cmd
.Init(GL_TRIANGLES
, 0, kNumVertices
, 1);
973 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
974 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
977 TEST_P(GLES2DecoderGeometryInstancingTest
,
978 DrawArraysInstancedANGLESimulatedAttrib0
) {
981 DoVertexAttribPointer(1, 2, GL_FLOAT
, 0, 0);
983 AddExpectationsForSimulatedAttrib0(kNumVertices
, kServiceBufferId
);
984 SetupExpectationsForApplyingDefaultDirtyState();
986 DoVertexAttribDivisorANGLE(0, 1);
987 EXPECT_CALL(*gl_
, DrawArraysInstancedANGLE(GL_TRIANGLES
, 0, kNumVertices
, 3))
989 .RetiresOnSaturation();
990 EXPECT_CALL(*gl_
, VertexAttribDivisorANGLE(0, 0))
992 .RetiresOnSaturation();
993 EXPECT_CALL(*gl_
, VertexAttribDivisorANGLE(0, 1))
995 .RetiresOnSaturation();
996 DrawArraysInstancedANGLE cmd
;
997 cmd
.Init(GL_TRIANGLES
, 0, kNumVertices
, 3);
998 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
999 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1002 TEST_P(GLES2DecoderGeometryInstancingTest
,
1003 DrawArraysInstancedANGLEMissingAttributesFails
) {
1004 DoEnableVertexAttribArray(1);
1006 EXPECT_CALL(*gl_
, DrawArraysInstancedANGLE(_
, _
, _
, _
)).Times(0);
1007 DrawArraysInstancedANGLE cmd
;
1008 cmd
.Init(GL_TRIANGLES
, 0, kNumVertices
, 1);
1009 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1010 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
1013 TEST_P(GLES2DecoderGeometryInstancingTest
,
1014 DrawArraysInstancedANGLEMissingAttributesZeroCountSucceeds
) {
1015 DoEnableVertexAttribArray(1);
1017 EXPECT_CALL(*gl_
, DrawArraysInstancedANGLE(_
, _
, _
, _
)).Times(0);
1018 DrawArraysInstancedANGLE cmd
;
1019 cmd
.Init(GL_TRIANGLES
, 0, 0, 1);
1020 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1021 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1024 TEST_P(GLES2DecoderGeometryInstancingTest
,
1025 DrawArraysInstancedANGLEValidAttributesSucceeds
) {
1027 SetupVertexBuffer();
1028 DoEnableVertexAttribArray(1);
1029 DoVertexAttribPointer(1, 2, GL_FLOAT
, 0, 0);
1030 AddExpectationsForSimulatedAttrib0(kNumVertices
, kServiceBufferId
);
1031 SetupExpectationsForApplyingDefaultDirtyState();
1033 EXPECT_CALL(*gl_
, DrawArraysInstancedANGLE(GL_TRIANGLES
, 0, kNumVertices
, 1))
1035 .RetiresOnSaturation();
1036 DrawArraysInstancedANGLE cmd
;
1037 cmd
.Init(GL_TRIANGLES
, 0, kNumVertices
, 1);
1038 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1039 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1042 TEST_P(GLES2DecoderGeometryInstancingTest
,
1043 DrawArraysInstancedANGLEWithInvalidModeFails
) {
1044 SetupVertexBuffer();
1045 DoVertexAttribPointer(1, 2, GL_FLOAT
, 0, 0);
1047 EXPECT_CALL(*gl_
, DrawArraysInstancedANGLE(_
, _
, _
, _
)).Times(0);
1048 DrawArraysInstancedANGLE cmd
;
1049 cmd
.Init(GL_QUADS
, 0, 1, 1);
1050 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1051 EXPECT_EQ(GL_INVALID_ENUM
, GetGLError());
1052 cmd
.Init(GL_POLYGON
, 0, 1, 1);
1053 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1054 EXPECT_EQ(GL_INVALID_ENUM
, GetGLError());
1057 TEST_P(GLES2DecoderGeometryInstancingTest
,
1058 DrawArraysInstancedANGLEInvalidPrimcountFails
) {
1059 SetupVertexBuffer();
1060 DoVertexAttribPointer(1, 2, GL_FLOAT
, 0, 0);
1062 EXPECT_CALL(*gl_
, DrawArraysInstancedANGLE(_
, _
, _
, _
)).Times(0);
1063 DrawArraysInstancedANGLE cmd
;
1064 cmd
.Init(GL_TRIANGLES
, 0, 1, -1);
1065 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1066 EXPECT_EQ(GL_INVALID_VALUE
, GetGLError());
1069 // Per-instance data is twice as large, but number of instances is half
1070 TEST_P(GLES2DecoderGeometryInstancingTest
,
1071 DrawArraysInstancedANGLELargeInstanceSucceeds
) {
1073 SetupVertexBuffer();
1074 SetupExpectationsForApplyingDefaultDirtyState();
1075 DoVertexAttribPointer(1, 2, GL_FLOAT
, 0, 0);
1077 DoEnableVertexAttribArray(0);
1078 DoVertexAttribPointer(0, 4, GL_FLOAT
, 0, 0);
1079 DoVertexAttribDivisorANGLE(0, 1);
1082 DrawArraysInstancedANGLE(GL_TRIANGLES
, 0, kNumVertices
, kNumVertices
/ 2))
1084 .RetiresOnSaturation();
1085 DrawArraysInstancedANGLE cmd
;
1086 cmd
.Init(GL_TRIANGLES
, 0, kNumVertices
, kNumVertices
/ 2);
1087 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1088 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1091 // Regular drawArrays takes the divisor into account
1092 TEST_P(GLES2DecoderGeometryInstancingTest
,
1093 DrawArraysWithDivisorSucceeds
) {
1095 SetupVertexBuffer();
1096 SetupExpectationsForApplyingDefaultDirtyState();
1097 DoVertexAttribPointer(1, 2, GL_FLOAT
, 0, 0);
1099 DoEnableVertexAttribArray(0);
1100 // Access the data right at the end of the buffer.
1101 DoVertexAttribPointer(
1102 0, 2, GL_FLOAT
, 0, (kNumVertices
- 1) * 2 * sizeof(GLfloat
));
1103 DoVertexAttribDivisorANGLE(0, 1);
1106 DrawArrays(GL_TRIANGLES
, 0, kNumVertices
))
1108 .RetiresOnSaturation();
1110 cmd
.Init(GL_TRIANGLES
, 0, kNumVertices
);
1111 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1112 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1115 // Per-instance data is twice as large, but divisor is twice
1116 TEST_P(GLES2DecoderGeometryInstancingTest
,
1117 DrawArraysInstancedANGLELargeDivisorSucceeds
) {
1119 SetupVertexBuffer();
1120 SetupExpectationsForApplyingDefaultDirtyState();
1121 DoVertexAttribPointer(1, 2, GL_FLOAT
, 0, 0);
1123 DoEnableVertexAttribArray(0);
1124 DoVertexAttribPointer(0, 4, GL_FLOAT
, 0, 0);
1125 DoVertexAttribDivisorANGLE(0, 2);
1128 DrawArraysInstancedANGLE(GL_TRIANGLES
, 0, kNumVertices
, kNumVertices
))
1130 .RetiresOnSaturation();
1131 DrawArraysInstancedANGLE cmd
;
1132 cmd
.Init(GL_TRIANGLES
, 0, kNumVertices
, kNumVertices
);
1133 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1134 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1137 TEST_P(GLES2DecoderGeometryInstancingTest
, DrawArraysInstancedANGLELargeFails
) {
1139 SetupVertexBuffer();
1140 DoVertexAttribPointer(1, 2, GL_FLOAT
, 0, 0);
1142 DoEnableVertexAttribArray(0);
1143 DoVertexAttribPointer(0, 2, GL_FLOAT
, 0, 0);
1144 DoVertexAttribDivisorANGLE(0, 1);
1145 EXPECT_CALL(*gl_
, DrawArraysInstancedANGLE(_
, _
, _
, _
))
1147 .RetiresOnSaturation();
1148 DrawArraysInstancedANGLE cmd
;
1149 cmd
.Init(GL_TRIANGLES
, 0, kNumVertices
, kNumVertices
+ 1);
1150 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1151 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
1152 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1154 EXPECT_CALL(*gl_
, DrawArraysInstancedANGLE(_
, _
, _
, _
))
1156 .RetiresOnSaturation();
1157 cmd
.Init(GL_TRIANGLES
, 0, kNumVertices
+ 1, kNumVertices
);
1158 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1159 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
1160 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1163 // Per-index data is twice as large, but number of indices is half
1164 TEST_P(GLES2DecoderGeometryInstancingTest
,
1165 DrawArraysInstancedANGLELargeIndexSucceeds
) {
1167 SetupVertexBuffer();
1168 SetupExpectationsForApplyingDefaultDirtyState();
1169 DoVertexAttribPointer(1, 4, GL_FLOAT
, 0, 0);
1171 DoEnableVertexAttribArray(0);
1172 DoVertexAttribPointer(0, 2, GL_FLOAT
, 0, 0);
1173 DoVertexAttribDivisorANGLE(0, 1);
1176 DrawArraysInstancedANGLE(GL_TRIANGLES
, 0, kNumVertices
/ 2, kNumVertices
))
1178 .RetiresOnSaturation();
1179 DrawArraysInstancedANGLE cmd
;
1180 cmd
.Init(GL_TRIANGLES
, 0, kNumVertices
/ 2, kNumVertices
);
1181 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1182 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1185 TEST_P(GLES2DecoderGeometryInstancingTest
,
1186 DrawArraysInstancedANGLENoDivisor0Fails
) {
1188 SetupVertexBuffer();
1189 DoVertexAttribPointer(1, 2, GL_FLOAT
, 0, 0);
1191 DoEnableVertexAttribArray(0);
1192 DoVertexAttribPointer(0, 2, GL_FLOAT
, 0, 0);
1193 DoVertexAttribDivisorANGLE(0, 1);
1194 DoVertexAttribDivisorANGLE(1, 1);
1195 EXPECT_CALL(*gl_
, DrawArraysInstancedANGLE(_
, _
, _
, _
))
1197 .RetiresOnSaturation();
1198 DrawArraysInstancedANGLE cmd
;
1199 cmd
.Init(GL_TRIANGLES
, 0, kNumVertices
, 1);
1200 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1201 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
1202 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1205 TEST_P(GLES2DecoderGeometryInstancingTest
,
1206 DrawArraysNoDivisor0Fails
) {
1208 SetupVertexBuffer();
1209 DoVertexAttribPointer(1, 2, GL_FLOAT
, 0, 0);
1211 DoEnableVertexAttribArray(0);
1212 DoVertexAttribPointer(0, 2, GL_FLOAT
, 0, 0);
1213 DoVertexAttribDivisorANGLE(0, 1);
1214 DoVertexAttribDivisorANGLE(1, 1);
1215 EXPECT_CALL(*gl_
, DrawArrays(_
, _
, _
))
1217 .RetiresOnSaturation();
1219 cmd
.Init(GL_TRIANGLES
, 0, kNumVertices
);
1220 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1221 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
1222 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1225 TEST_P(GLES2DecoderWithShaderTest
, DrawElementsNoAttributesSucceeds
) {
1228 AddExpectationsForSimulatedAttrib0(kMaxValidIndex
+ 1, 0);
1229 SetupExpectationsForApplyingDefaultDirtyState();
1231 DrawElements(GL_TRIANGLES
,
1232 kValidIndexRangeCount
,
1234 BufferOffset(kValidIndexRangeStart
* 2)))
1236 .RetiresOnSaturation();
1238 cmd
.Init(GL_TRIANGLES
,
1239 kValidIndexRangeCount
,
1241 kValidIndexRangeStart
* 2);
1242 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1243 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1246 TEST_P(GLES2DecoderWithShaderTest
, DrawElementsMissingAttributesFails
) {
1248 DoEnableVertexAttribArray(1);
1250 EXPECT_CALL(*gl_
, DrawElements(_
, _
, _
, _
)).Times(0);
1252 cmd
.Init(GL_TRIANGLES
,
1253 kValidIndexRangeCount
,
1255 kValidIndexRangeStart
* 2);
1256 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1257 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
1260 TEST_P(GLES2DecoderWithShaderTest
,
1261 DrawElementsMissingAttributesZeroCountSucceeds
) {
1263 DoEnableVertexAttribArray(1);
1265 EXPECT_CALL(*gl_
, DrawElements(_
, _
, _
, _
)).Times(0);
1267 cmd
.Init(GL_TRIANGLES
, 0, GL_UNSIGNED_SHORT
, kValidIndexRangeStart
* 2);
1268 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1269 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1272 TEST_P(GLES2DecoderWithShaderTest
, DrawElementsExtraAttributesFails
) {
1274 DoEnableVertexAttribArray(6);
1276 EXPECT_CALL(*gl_
, DrawElements(_
, _
, _
, _
)).Times(0);
1278 cmd
.Init(GL_TRIANGLES
,
1279 kValidIndexRangeCount
,
1281 kValidIndexRangeStart
* 2);
1282 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1283 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
1286 TEST_P(GLES2DecoderWithShaderTest
, DrawElementsValidAttributesSucceeds
) {
1288 SetupVertexBuffer();
1290 DoVertexAttribPointer(1, 2, GL_FLOAT
, 0, 0);
1291 AddExpectationsForSimulatedAttrib0(kMaxValidIndex
+ 1, kServiceBufferId
);
1292 SetupExpectationsForApplyingDefaultDirtyState();
1295 DrawElements(GL_TRIANGLES
,
1296 kValidIndexRangeCount
,
1298 BufferOffset(kValidIndexRangeStart
* 2)))
1300 .RetiresOnSaturation();
1302 cmd
.Init(GL_TRIANGLES
,
1303 kValidIndexRangeCount
,
1305 kValidIndexRangeStart
* 2);
1306 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1307 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1310 TEST_P(GLES2DecoderWithShaderTest
, DrawElementsDeletedBufferFails
) {
1311 SetupVertexBuffer();
1313 DoVertexAttribPointer(1, 2, GL_FLOAT
, 0, 0);
1314 DeleteIndexBuffer();
1316 EXPECT_CALL(*gl_
, DrawElements(_
, _
, _
, _
)).Times(0);
1318 cmd
.Init(GL_TRIANGLES
,
1319 kValidIndexRangeCount
,
1321 kValidIndexRangeStart
* 2);
1322 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1323 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
1326 TEST_P(GLES2DecoderWithShaderTest
, DrawElementsDeletedProgramSucceeds
) {
1329 AddExpectationsForSimulatedAttrib0(kMaxValidIndex
+ 1, 0);
1330 SetupExpectationsForApplyingDefaultDirtyState();
1331 DoDeleteProgram(client_program_id_
, kServiceProgramId
);
1333 EXPECT_CALL(*gl_
, DrawElements(_
, _
, _
, _
)).Times(1);
1334 EXPECT_CALL(*gl_
, DeleteProgram(kServiceProgramId
)).Times(1);
1336 cmd
.Init(GL_TRIANGLES
,
1337 kValidIndexRangeCount
,
1339 kValidIndexRangeStart
* 2);
1340 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1341 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1344 TEST_P(GLES2DecoderWithShaderTest
, DrawElementsWithInvalidModeFails
) {
1345 SetupVertexBuffer();
1347 DoVertexAttribPointer(1, 2, GL_FLOAT
, 0, 0);
1349 EXPECT_CALL(*gl_
, DrawElements(_
, _
, _
, _
)).Times(0);
1352 kValidIndexRangeCount
,
1354 kValidIndexRangeStart
* 2);
1355 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1356 EXPECT_EQ(GL_INVALID_ENUM
, GetGLError());
1357 cmd
.Init(GL_POLYGON
,
1358 kValidIndexRangeCount
,
1360 kValidIndexRangeStart
);
1361 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1362 EXPECT_EQ(GL_INVALID_ENUM
, GetGLError());
1365 TEST_P(GLES2DecoderWithShaderTest
, DrawElementsInvalidCountFails
) {
1366 SetupVertexBuffer();
1368 DoVertexAttribPointer(1, 2, GL_FLOAT
, 0, 0);
1371 EXPECT_CALL(*gl_
, DrawElements(_
, _
, _
, _
)).Times(0);
1373 cmd
.Init(GL_TRIANGLES
, kNumIndices
, GL_UNSIGNED_SHORT
, 2);
1374 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1375 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
1376 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1378 // Try with count > size
1379 cmd
.Init(GL_TRIANGLES
, kNumIndices
+ 1, GL_UNSIGNED_SHORT
, 0);
1380 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1381 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
1382 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1385 TEST_P(GLES2DecoderWithShaderTest
, DrawElementsOutOfRangeIndicesFails
) {
1386 SetupVertexBuffer();
1388 DoVertexAttribPointer(1, 2, GL_FLOAT
, 0, 0);
1390 EXPECT_CALL(*gl_
, DrawElements(_
, _
, _
, _
)).Times(0);
1392 cmd
.Init(GL_TRIANGLES
,
1393 kInvalidIndexRangeCount
,
1395 kInvalidIndexRangeStart
* 2);
1396 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1397 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
1398 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1401 TEST_P(GLES2DecoderWithShaderTest
, DrawElementsOddOffsetForUint16Fails
) {
1402 SetupVertexBuffer();
1404 DoVertexAttribPointer(1, 2, GL_FLOAT
, 0, 0);
1406 EXPECT_CALL(*gl_
, DrawElements(_
, _
, _
, _
)).Times(0);
1408 cmd
.Init(GL_TRIANGLES
, kInvalidIndexRangeCount
, GL_UNSIGNED_SHORT
, 1);
1409 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1410 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
1411 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1414 TEST_P(GLES2DecoderWithShaderTest
, DrawElementsInstancedANGLEFails
) {
1416 SetupVertexBuffer();
1418 DoEnableVertexAttribArray(1);
1419 DoVertexAttribPointer(1, 2, GL_FLOAT
, 0, 0);
1421 EXPECT_CALL(*gl_
, DrawElementsInstancedANGLE(_
, _
, _
, _
, _
))
1423 .RetiresOnSaturation();
1424 DrawElementsInstancedANGLE cmd
;
1425 cmd
.Init(GL_TRIANGLES
,
1426 kValidIndexRangeCount
,
1428 kValidIndexRangeStart
* 2,
1430 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1431 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
1434 TEST_P(GLES2DecoderGeometryInstancingTest
,
1435 DrawElementsInstancedANGLENoAttributesFails
) {
1439 EXPECT_CALL(*gl_
, DrawElementsInstancedANGLE(_
, _
, _
, _
, _
))
1441 .RetiresOnSaturation();
1442 DrawElementsInstancedANGLE cmd
;
1443 cmd
.Init(GL_TRIANGLES
,
1444 kValidIndexRangeCount
,
1446 kValidIndexRangeStart
* 2,
1448 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1449 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
1452 TEST_P(GLES2DecoderGeometryInstancingTest
,
1453 DrawElementsInstancedANGLESimulatedAttrib0
) {
1455 SetupVertexBuffer();
1457 DoVertexAttribPointer(1, 2, GL_FLOAT
, 0, 0);
1459 AddExpectationsForSimulatedAttrib0(kMaxValidIndex
+ 1, kServiceBufferId
);
1460 SetupExpectationsForApplyingDefaultDirtyState();
1462 DoVertexAttribDivisorANGLE(0, 1);
1465 DrawElementsInstancedANGLE(GL_TRIANGLES
,
1466 kValidIndexRangeCount
,
1468 BufferOffset(kValidIndexRangeStart
* 2),
1471 .RetiresOnSaturation();
1472 EXPECT_CALL(*gl_
, VertexAttribDivisorANGLE(0, 0))
1474 .RetiresOnSaturation();
1475 EXPECT_CALL(*gl_
, VertexAttribDivisorANGLE(0, 1))
1477 .RetiresOnSaturation();
1478 DrawElementsInstancedANGLE cmd
;
1479 cmd
.Init(GL_TRIANGLES
,
1480 kValidIndexRangeCount
,
1482 kValidIndexRangeStart
* 2,
1484 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1485 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1488 TEST_P(GLES2DecoderGeometryInstancingTest
,
1489 DrawElementsInstancedANGLEMissingAttributesFails
) {
1491 DoEnableVertexAttribArray(1);
1493 EXPECT_CALL(*gl_
, DrawElementsInstancedANGLE(_
, _
, _
, _
, _
)).Times(0);
1494 DrawElementsInstancedANGLE cmd
;
1495 cmd
.Init(GL_TRIANGLES
,
1496 kValidIndexRangeCount
,
1498 kValidIndexRangeStart
* 2,
1500 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1501 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
1504 TEST_P(GLES2DecoderGeometryInstancingTest
,
1505 DrawElementsInstancedANGLEMissingAttributesZeroCountSucceeds
) {
1507 DoEnableVertexAttribArray(1);
1509 EXPECT_CALL(*gl_
, DrawElementsInstancedANGLE(_
, _
, _
, _
, _
)).Times(0);
1510 DrawElementsInstancedANGLE cmd
;
1511 cmd
.Init(GL_TRIANGLES
, 0, GL_UNSIGNED_SHORT
, kValidIndexRangeStart
* 2, 1);
1512 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1513 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1516 TEST_P(GLES2DecoderGeometryInstancingTest
,
1517 DrawElementsInstancedANGLEValidAttributesSucceeds
) {
1520 SetupVertexBuffer();
1521 DoEnableVertexAttribArray(1);
1522 DoVertexAttribPointer(1, 2, GL_FLOAT
, 0, 0);
1523 AddExpectationsForSimulatedAttrib0(kMaxValidIndex
+ 1, kServiceBufferId
);
1524 SetupExpectationsForApplyingDefaultDirtyState();
1528 DrawElementsInstancedANGLE(GL_TRIANGLES
,
1529 kValidIndexRangeCount
,
1531 BufferOffset(kValidIndexRangeStart
* 2),
1534 .RetiresOnSaturation();
1535 DrawElementsInstancedANGLE cmd
;
1536 cmd
.Init(GL_TRIANGLES
,
1537 kValidIndexRangeCount
,
1539 kValidIndexRangeStart
* 2,
1541 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1542 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1545 TEST_P(GLES2DecoderGeometryInstancingTest
,
1546 DrawElementsInstancedANGLEWithInvalidModeFails
) {
1548 SetupVertexBuffer();
1549 DoVertexAttribPointer(1, 2, GL_FLOAT
, 0, 0);
1551 EXPECT_CALL(*gl_
, DrawElementsInstancedANGLE(_
, _
, _
, _
, _
)).Times(0);
1552 DrawElementsInstancedANGLE cmd
;
1554 kValidIndexRangeCount
,
1556 kValidIndexRangeStart
* 2,
1558 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1559 EXPECT_EQ(GL_INVALID_ENUM
, GetGLError());
1560 cmd
.Init(GL_INVALID_ENUM
,
1561 kValidIndexRangeCount
,
1563 kValidIndexRangeStart
* 2,
1565 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1566 EXPECT_EQ(GL_INVALID_ENUM
, GetGLError());
1569 // Per-instance data is twice as large, but number of instances is half
1570 TEST_P(GLES2DecoderGeometryInstancingTest
,
1571 DrawElementsInstancedANGLELargeInstanceSucceeds
) {
1574 SetupVertexBuffer();
1575 SetupExpectationsForApplyingDefaultDirtyState();
1576 // Add offset so we're sure we're accessing data near the end of the buffer.
1577 DoVertexAttribPointer(
1582 (kNumVertices
- kMaxValidIndex
- 1) * 2 * sizeof(GLfloat
));
1584 DoEnableVertexAttribArray(0);
1585 DoVertexAttribPointer(0, 4, GL_FLOAT
, 0, 0);
1586 DoVertexAttribDivisorANGLE(0, 1);
1589 DrawElementsInstancedANGLE(GL_TRIANGLES
,
1590 kValidIndexRangeCount
,
1592 BufferOffset(kValidIndexRangeStart
* 2),
1595 .RetiresOnSaturation();
1596 DrawElementsInstancedANGLE cmd
;
1597 cmd
.Init(GL_TRIANGLES
,
1598 kValidIndexRangeCount
,
1600 kValidIndexRangeStart
* 2,
1602 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1603 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1606 // Regular drawElements takes the divisor into account
1607 TEST_P(GLES2DecoderGeometryInstancingTest
,
1608 DrawElementsWithDivisorSucceeds
) {
1611 SetupVertexBuffer();
1612 SetupExpectationsForApplyingDefaultDirtyState();
1613 // Add offset so we're sure we're accessing data near the end of the buffer.
1614 DoVertexAttribPointer(
1619 (kNumVertices
- kMaxValidIndex
- 1) * 2 * sizeof(GLfloat
));
1621 DoEnableVertexAttribArray(0);
1622 // Access the data right at the end of the buffer.
1623 DoVertexAttribPointer(
1624 0, 2, GL_FLOAT
, 0, (kNumVertices
- 1) * 2 * sizeof(GLfloat
));
1625 DoVertexAttribDivisorANGLE(0, 1);
1628 DrawElements(GL_TRIANGLES
,
1629 kValidIndexRangeCount
,
1631 BufferOffset(kValidIndexRangeStart
* 2)))
1633 .RetiresOnSaturation();
1635 cmd
.Init(GL_TRIANGLES
,
1636 kValidIndexRangeCount
,
1638 kValidIndexRangeStart
* 2);
1639 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1640 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1643 // Per-instance data is twice as large, but divisor is twice
1644 TEST_P(GLES2DecoderGeometryInstancingTest
,
1645 DrawElementsInstancedANGLELargeDivisorSucceeds
) {
1648 SetupVertexBuffer();
1649 SetupExpectationsForApplyingDefaultDirtyState();
1650 DoVertexAttribPointer(1, 2, GL_FLOAT
, 0, 0);
1652 DoEnableVertexAttribArray(0);
1653 DoVertexAttribPointer(0, 4, GL_FLOAT
, 0, 0);
1654 DoVertexAttribDivisorANGLE(0, 2);
1657 DrawElementsInstancedANGLE(GL_TRIANGLES
,
1658 kValidIndexRangeCount
,
1660 BufferOffset(kValidIndexRangeStart
* 2),
1663 .RetiresOnSaturation();
1664 DrawElementsInstancedANGLE cmd
;
1665 cmd
.Init(GL_TRIANGLES
,
1666 kValidIndexRangeCount
,
1668 kValidIndexRangeStart
* 2,
1670 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1671 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1674 TEST_P(GLES2DecoderGeometryInstancingTest
,
1675 DrawElementsInstancedANGLELargeFails
) {
1678 SetupVertexBuffer();
1679 DoVertexAttribPointer(1, 2, GL_FLOAT
, 0, 0);
1681 DoEnableVertexAttribArray(0);
1682 DoVertexAttribPointer(0, 2, GL_FLOAT
, 0, 0);
1683 DoVertexAttribDivisorANGLE(0, 1);
1684 EXPECT_CALL(*gl_
, DrawElementsInstancedANGLE(_
, _
, _
, _
, _
))
1686 .RetiresOnSaturation();
1687 DrawElementsInstancedANGLE cmd
;
1688 cmd
.Init(GL_TRIANGLES
,
1689 kValidIndexRangeCount
,
1691 kValidIndexRangeStart
* 2,
1693 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1694 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
1695 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1697 EXPECT_CALL(*gl_
, DrawElementsInstancedANGLE(_
, _
, _
, _
, _
))
1699 .RetiresOnSaturation();
1700 cmd
.Init(GL_TRIANGLES
,
1701 kInvalidIndexRangeCount
,
1703 kInvalidIndexRangeStart
* 2,
1705 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1706 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
1707 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1710 TEST_P(GLES2DecoderGeometryInstancingTest
,
1711 DrawElementsInstancedANGLEInvalidPrimcountFails
) {
1714 SetupVertexBuffer();
1715 DoVertexAttribPointer(1, 2, GL_FLOAT
, 0, 0);
1717 DoEnableVertexAttribArray(0);
1718 DoVertexAttribPointer(0, 2, GL_FLOAT
, 0, 0);
1719 DoVertexAttribDivisorANGLE(0, 1);
1720 EXPECT_CALL(*gl_
, DrawElementsInstancedANGLE(_
, _
, _
, _
, _
))
1722 .RetiresOnSaturation();
1723 DrawElementsInstancedANGLE cmd
;
1724 cmd
.Init(GL_TRIANGLES
,
1725 kValidIndexRangeCount
,
1727 kValidIndexRangeStart
* 2,
1729 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1730 EXPECT_EQ(GL_INVALID_VALUE
, GetGLError());
1731 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1734 // Per-index data is twice as large, but values of indices are smaller
1735 TEST_P(GLES2DecoderGeometryInstancingTest
,
1736 DrawElementsInstancedANGLELargeIndexSucceeds
) {
1739 SetupVertexBuffer();
1740 SetupExpectationsForApplyingDefaultDirtyState();
1741 DoVertexAttribPointer(1, 4, GL_FLOAT
, 0, 0);
1743 DoEnableVertexAttribArray(0);
1744 DoVertexAttribPointer(0, 2, GL_FLOAT
, 0, 0);
1745 DoVertexAttribDivisorANGLE(0, 1);
1748 DrawElementsInstancedANGLE(GL_TRIANGLES
,
1749 kValidIndexRangeCount
,
1751 BufferOffset(kValidIndexRangeStart
* 2),
1754 .RetiresOnSaturation();
1755 DrawElementsInstancedANGLE cmd
;
1756 cmd
.Init(GL_TRIANGLES
,
1757 kValidIndexRangeCount
,
1759 kValidIndexRangeStart
* 2,
1761 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1762 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1765 TEST_P(GLES2DecoderGeometryInstancingTest
,
1766 DrawElementsInstancedANGLENoDivisor0Fails
) {
1769 SetupVertexBuffer();
1770 DoVertexAttribPointer(1, 2, GL_FLOAT
, 0, 0);
1772 DoEnableVertexAttribArray(0);
1773 DoVertexAttribPointer(0, 2, GL_FLOAT
, 0, 0);
1774 DoVertexAttribDivisorANGLE(0, 1);
1775 DoVertexAttribDivisorANGLE(1, 1);
1776 EXPECT_CALL(*gl_
, DrawElementsInstancedANGLE(_
, _
, _
, _
, _
))
1778 .RetiresOnSaturation();
1779 DrawElementsInstancedANGLE cmd
;
1780 cmd
.Init(GL_TRIANGLES
,
1781 kValidIndexRangeCount
,
1783 kValidIndexRangeStart
* 2,
1785 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1786 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
1787 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1790 TEST_P(GLES2DecoderGeometryInstancingTest
,
1791 DrawElementsNoDivisor0Fails
) {
1794 SetupVertexBuffer();
1795 DoVertexAttribPointer(1, 2, GL_FLOAT
, 0, 0);
1797 DoEnableVertexAttribArray(0);
1798 DoVertexAttribPointer(0, 2, GL_FLOAT
, 0, 0);
1799 DoVertexAttribDivisorANGLE(0, 1);
1800 DoVertexAttribDivisorANGLE(1, 1);
1801 EXPECT_CALL(*gl_
, DrawElements(_
, _
, _
, _
))
1803 .RetiresOnSaturation();
1805 cmd
.Init(GL_TRIANGLES
,
1806 kValidIndexRangeCount
,
1808 kValidIndexRangeStart
* 2);
1809 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1810 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
1811 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1814 TEST_P(GLES2DecoderWithShaderTest
, DrawArraysClearsAfterTexImage2DNULL
) {
1815 SetupAllNeededVertexBuffers();
1816 DoBindTexture(GL_TEXTURE_2D
, client_texture_id_
, kServiceTextureId
);
1817 // Create an uncleared texture with 2 levels.
1819 GL_TEXTURE_2D
, 0, GL_RGBA
, 2, 2, 0, GL_RGBA
, GL_UNSIGNED_BYTE
, 0, 0);
1821 GL_TEXTURE_2D
, 1, GL_RGBA
, 1, 1, 0, GL_RGBA
, GL_UNSIGNED_BYTE
, 0, 0);
1822 // Expect 2 levels will be cleared.
1823 SetupClearTextureExpectations(kServiceTextureId
,
1833 SetupClearTextureExpectations(kServiceTextureId
,
1843 SetupExpectationsForApplyingDefaultDirtyState();
1844 EXPECT_CALL(*gl_
, DrawArrays(GL_TRIANGLES
, 0, kNumVertices
))
1846 .RetiresOnSaturation();
1848 cmd
.Init(GL_TRIANGLES
, 0, kNumVertices
);
1849 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1850 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1853 EXPECT_CALL(*gl_
, DrawArrays(GL_TRIANGLES
, 0, kNumVertices
))
1855 .RetiresOnSaturation();
1856 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1857 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1860 TEST_P(GLES2DecoderWithShaderTest
, DrawElementsClearsAfterTexImage2DNULL
) {
1861 SetupAllNeededVertexBuffers();
1863 DoBindTexture(GL_TEXTURE_2D
, client_texture_id_
, kServiceTextureId
);
1864 // Create an uncleared texture with 2 levels.
1866 GL_TEXTURE_2D
, 0, GL_RGBA
, 2, 2, 0, GL_RGBA
, GL_UNSIGNED_BYTE
, 0, 0);
1868 GL_TEXTURE_2D
, 1, GL_RGBA
, 1, 1, 0, GL_RGBA
, GL_UNSIGNED_BYTE
, 0, 0);
1869 // Expect 2 levels will be cleared.
1870 SetupClearTextureExpectations(kServiceTextureId
,
1880 SetupClearTextureExpectations(kServiceTextureId
,
1890 SetupExpectationsForApplyingDefaultDirtyState();
1893 DrawElements(GL_TRIANGLES
,
1894 kValidIndexRangeCount
,
1896 BufferOffset(kValidIndexRangeStart
* 2)))
1898 .RetiresOnSaturation();
1900 cmd
.Init(GL_TRIANGLES
,
1901 kValidIndexRangeCount
,
1903 kValidIndexRangeStart
* 2);
1904 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1905 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1909 DrawElements(GL_TRIANGLES
,
1910 kValidIndexRangeCount
,
1912 BufferOffset(kValidIndexRangeStart
* 2)))
1914 .RetiresOnSaturation();
1915 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1916 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1919 TEST_P(GLES2DecoderWithShaderTest
, DrawClearsAfterTexImage2DNULLInFBO
) {
1920 const GLuint kFBOClientTextureId
= 4100;
1921 const GLuint kFBOServiceTextureId
= 4101;
1923 SetupAllNeededVertexBuffers();
1924 // Register a texture id.
1925 EXPECT_CALL(*gl_
, GenTextures(_
, _
))
1926 .WillOnce(SetArgumentPointee
<1>(kFBOServiceTextureId
))
1927 .RetiresOnSaturation();
1928 GenHelper
<GenTexturesImmediate
>(kFBOClientTextureId
);
1930 // Setup "render to" texture.
1931 DoBindTexture(GL_TEXTURE_2D
, kFBOClientTextureId
, kFBOServiceTextureId
);
1933 GL_TEXTURE_2D
, 0, GL_RGBA
, 1, 1, 0, GL_RGBA
, GL_UNSIGNED_BYTE
, 0, 0);
1935 GL_FRAMEBUFFER
, client_framebuffer_id_
, kServiceFramebufferId
);
1936 DoFramebufferTexture2D(GL_FRAMEBUFFER
,
1937 GL_COLOR_ATTACHMENT0
,
1939 kFBOClientTextureId
,
1940 kFBOServiceTextureId
,
1944 // Setup "render from" texture.
1947 SetupExpectationsForFramebufferClearing(GL_FRAMEBUFFER
, // target
1948 GL_COLOR_BUFFER_BIT
, // clear bits
1955 false); // scissor test
1957 SetupExpectationsForApplyingDirtyState(false, // Framebuffer is RGB
1958 false, // Framebuffer has depth
1959 false, // Framebuffer has stencil
1960 0x1111, // color bits
1961 false, // depth mask
1962 false, // depth enabled
1963 0, // front stencil mask
1964 0, // back stencil mask
1965 false); // stencil enabled
1967 EXPECT_CALL(*gl_
, DrawArrays(GL_TRIANGLES
, 0, kNumVertices
))
1969 .RetiresOnSaturation();
1971 cmd
.Init(GL_TRIANGLES
, 0, kNumVertices
);
1972 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1973 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1976 EXPECT_CALL(*gl_
, DrawArrays(GL_TRIANGLES
, 0, kNumVertices
))
1978 .RetiresOnSaturation();
1979 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1980 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1983 TEST_P(GLES2DecoderWithShaderTest
, DrawWitFBOThatCantClearDoesNotDraw
) {
1984 const GLuint kFBOClientTextureId
= 4100;
1985 const GLuint kFBOServiceTextureId
= 4101;
1987 // Register a texture id.
1988 EXPECT_CALL(*gl_
, GenTextures(_
, _
))
1989 .WillOnce(SetArgumentPointee
<1>(kFBOServiceTextureId
))
1990 .RetiresOnSaturation();
1991 GenHelper
<GenTexturesImmediate
>(kFBOClientTextureId
);
1993 // Setup "render to" texture.
1994 DoBindTexture(GL_TEXTURE_2D
, kFBOClientTextureId
, kFBOServiceTextureId
);
1996 GL_TEXTURE_2D
, 0, GL_RGBA
, 1, 1, 0, GL_RGBA
, GL_UNSIGNED_BYTE
, 0, 0);
1998 GL_FRAMEBUFFER
, client_framebuffer_id_
, kServiceFramebufferId
);
1999 DoFramebufferTexture2D(GL_FRAMEBUFFER
,
2000 GL_COLOR_ATTACHMENT0
,
2002 kFBOClientTextureId
,
2003 kFBOServiceTextureId
,
2007 // Setup "render from" texture.
2010 EXPECT_CALL(*gl_
, CheckFramebufferStatusEXT(GL_FRAMEBUFFER
))
2011 .WillOnce(Return(GL_FRAMEBUFFER_UNSUPPORTED
))
2012 .RetiresOnSaturation();
2013 EXPECT_CALL(*gl_
, DrawArrays(_
, _
, _
)).Times(0).RetiresOnSaturation();
2015 cmd
.Init(GL_TRIANGLES
, 0, kNumVertices
);
2016 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
2017 EXPECT_EQ(GL_INVALID_FRAMEBUFFER_OPERATION
, GetGLError());
2020 TEST_P(GLES2DecoderWithShaderTest
, DrawClearsAfterRenderbufferStorageInFBO
) {
2023 GL_RENDERBUFFER
, client_renderbuffer_id_
, kServiceRenderbufferId
);
2025 GL_FRAMEBUFFER
, client_framebuffer_id_
, kServiceFramebufferId
);
2026 DoRenderbufferStorage(
2027 GL_RENDERBUFFER
, GL_RGBA4
, GL_RGBA
, 100, 50, GL_NO_ERROR
);
2028 DoFramebufferRenderbuffer(GL_FRAMEBUFFER
,
2029 GL_COLOR_ATTACHMENT0
,
2031 client_renderbuffer_id_
,
2032 kServiceRenderbufferId
,
2035 SetupExpectationsForFramebufferClearing(GL_FRAMEBUFFER
, // target
2036 GL_COLOR_BUFFER_BIT
, // clear bits
2043 false); // scissor test
2045 AddExpectationsForSimulatedAttrib0(kNumVertices
, 0);
2046 SetupExpectationsForApplyingDirtyState(false, // Framebuffer is RGB
2047 false, // Framebuffer has depth
2048 false, // Framebuffer has stencil
2049 0x1111, // color bits
2050 false, // depth mask
2051 false, // depth enabled
2052 0, // front stencil mask
2053 0, // back stencil mask
2054 false); // stencil enabled
2056 EXPECT_CALL(*gl_
, DrawArrays(GL_TRIANGLES
, 0, kNumVertices
))
2058 .RetiresOnSaturation();
2060 cmd
.Init(GL_TRIANGLES
, 0, kNumVertices
);
2061 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
2062 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
2065 TEST_P(GLES2DecoderManualInitTest
, DrawArraysClearsAfterTexImage2DNULLCubemap
) {
2067 init
.gl_version
= "opengl es 2.0";
2068 init
.has_alpha
= true;
2069 init
.has_depth
= true;
2070 init
.request_alpha
= true;
2071 init
.request_depth
= true;
2074 static const GLenum faces
[] = {
2075 GL_TEXTURE_CUBE_MAP_POSITIVE_X
, GL_TEXTURE_CUBE_MAP_NEGATIVE_X
,
2076 GL_TEXTURE_CUBE_MAP_POSITIVE_Y
, GL_TEXTURE_CUBE_MAP_NEGATIVE_Y
,
2077 GL_TEXTURE_CUBE_MAP_POSITIVE_Z
, GL_TEXTURE_CUBE_MAP_NEGATIVE_Z
,
2079 SetupCubemapProgram();
2080 DoBindTexture(GL_TEXTURE_CUBE_MAP
, client_texture_id_
, kServiceTextureId
);
2081 // Fill out all the faces for 2 levels, leave 2 uncleared.
2082 for (int ii
= 0; ii
< 6; ++ii
) {
2083 GLenum face
= faces
[ii
];
2085 (face
== GL_TEXTURE_CUBE_MAP_NEGATIVE_Y
) ? 0 : kSharedMemoryId
;
2087 (face
== GL_TEXTURE_CUBE_MAP_NEGATIVE_Y
) ? 0 : kSharedMemoryOffset
;
2109 // Expect 2 levels will be cleared.
2110 SetupClearTextureExpectations(kServiceTextureId
,
2112 GL_TEXTURE_CUBE_MAP
,
2113 GL_TEXTURE_CUBE_MAP_NEGATIVE_Y
,
2120 SetupClearTextureExpectations(kServiceTextureId
,
2122 GL_TEXTURE_CUBE_MAP
,
2123 GL_TEXTURE_CUBE_MAP_NEGATIVE_Y
,
2130 AddExpectationsForSimulatedAttrib0(kNumVertices
, 0);
2131 SetupExpectationsForApplyingDefaultDirtyState();
2132 EXPECT_CALL(*gl_
, DrawArrays(GL_TRIANGLES
, 0, kNumVertices
))
2134 .RetiresOnSaturation();
2136 cmd
.Init(GL_TRIANGLES
, 0, kNumVertices
);
2137 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
2140 TEST_P(GLES2DecoderWithShaderTest
,
2141 DrawClearsAfterRenderbuffersWithMultipleAttachments
) {
2142 const GLuint kFBOClientTextureId
= 4100;
2143 const GLuint kFBOServiceTextureId
= 4101;
2145 // Register a texture id.
2146 EXPECT_CALL(*gl_
, GenTextures(_
, _
))
2147 .WillOnce(SetArgumentPointee
<1>(kFBOServiceTextureId
))
2148 .RetiresOnSaturation();
2149 GenHelper
<GenTexturesImmediate
>(kFBOClientTextureId
);
2151 // Setup "render to" texture.
2152 DoBindTexture(GL_TEXTURE_2D
, kFBOClientTextureId
, kFBOServiceTextureId
);
2154 GL_TEXTURE_2D
, 0, GL_RGBA
, 1, 1, 0, GL_RGBA
, GL_UNSIGNED_BYTE
, 0, 0);
2156 GL_FRAMEBUFFER
, client_framebuffer_id_
, kServiceFramebufferId
);
2157 DoFramebufferTexture2D(GL_FRAMEBUFFER
,
2158 GL_COLOR_ATTACHMENT0
,
2160 kFBOClientTextureId
,
2161 kFBOServiceTextureId
,
2166 GL_RENDERBUFFER
, client_renderbuffer_id_
, kServiceRenderbufferId
);
2168 GL_FRAMEBUFFER
, client_framebuffer_id_
, kServiceFramebufferId
);
2169 DoRenderbufferStorage(GL_RENDERBUFFER
,
2170 GL_DEPTH_COMPONENT16
,
2175 DoFramebufferRenderbuffer(GL_FRAMEBUFFER
,
2176 GL_DEPTH_ATTACHMENT
,
2178 client_renderbuffer_id_
,
2179 kServiceRenderbufferId
,
2183 SetupExpectationsForFramebufferClearing(
2184 GL_FRAMEBUFFER
, // target
2185 GL_COLOR_BUFFER_BIT
| GL_DEPTH_BUFFER_BIT
, // clear bits
2192 false); // scissor test
2194 AddExpectationsForSimulatedAttrib0(kNumVertices
, 0);
2195 SetupExpectationsForApplyingDirtyState(false, // Framebuffer is RGB
2196 true, // Framebuffer has depth
2197 false, // Framebuffer has stencil
2198 0x1111, // color bits
2200 false, // depth enabled
2201 0, // front stencil mask
2202 0, // back stencil mask
2203 false); // stencil enabled
2205 EXPECT_CALL(*gl_
, DrawArrays(GL_TRIANGLES
, 0, kNumVertices
))
2207 .RetiresOnSaturation();
2209 cmd
.Init(GL_TRIANGLES
, 0, kNumVertices
);
2210 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
2211 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
2214 TEST_P(GLES2DecoderWithShaderTest
,
2215 DrawingWithFBOTwiceChecksForFBOCompleteOnce
) {
2216 const GLuint kFBOClientTextureId
= 4100;
2217 const GLuint kFBOServiceTextureId
= 4101;
2219 SetupAllNeededVertexBuffers();
2221 // Register a texture id.
2222 EXPECT_CALL(*gl_
, GenTextures(_
, _
))
2223 .WillOnce(SetArgumentPointee
<1>(kFBOServiceTextureId
))
2224 .RetiresOnSaturation();
2225 GenHelper
<GenTexturesImmediate
>(kFBOClientTextureId
);
2227 // Setup "render to" texture that is cleared.
2228 DoBindTexture(GL_TEXTURE_2D
, kFBOClientTextureId
, kFBOServiceTextureId
);
2229 DoTexImage2D(GL_TEXTURE_2D
,
2238 kSharedMemoryOffset
);
2240 GL_FRAMEBUFFER
, client_framebuffer_id_
, kServiceFramebufferId
);
2241 DoFramebufferTexture2D(GL_FRAMEBUFFER
,
2242 GL_COLOR_ATTACHMENT0
,
2244 kFBOClientTextureId
,
2245 kFBOServiceTextureId
,
2249 // Setup "render from" texture.
2252 // Make sure we check for framebuffer complete.
2253 EXPECT_CALL(*gl_
, CheckFramebufferStatusEXT(GL_FRAMEBUFFER
))
2254 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE
))
2255 .RetiresOnSaturation();
2257 SetupExpectationsForApplyingDirtyState(false, // Framebuffer is RGB
2258 false, // Framebuffer has depth
2259 false, // Framebuffer has stencil
2260 0x1111, // color bits
2261 false, // depth mask
2262 false, // depth enabled
2263 0, // front stencil mask
2264 0, // back stencil mask
2265 false); // stencil enabled
2267 EXPECT_CALL(*gl_
, DrawArrays(GL_TRIANGLES
, 0, kNumVertices
))
2269 .RetiresOnSaturation();
2271 cmd
.Init(GL_TRIANGLES
, 0, kNumVertices
);
2272 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
2273 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
2276 EXPECT_CALL(*gl_
, DrawArrays(GL_TRIANGLES
, 0, kNumVertices
))
2278 .RetiresOnSaturation();
2279 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
2280 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
2283 TEST_P(GLES2DecoderManualInitTest
, DrawClearsDepthTexture
) {
2285 init
.extensions
= "GL_ANGLE_depth_texture";
2286 init
.gl_version
= "opengl es 2.0";
2287 init
.has_alpha
= true;
2288 init
.has_depth
= true;
2289 init
.request_alpha
= true;
2290 init
.request_depth
= true;
2291 init
.bind_generates_resource
= true;
2294 SetupDefaultProgram();
2295 SetupAllNeededVertexBuffers();
2296 const GLenum attachment
= GL_DEPTH_ATTACHMENT
;
2297 const GLenum target
= GL_TEXTURE_2D
;
2298 const GLint level
= 0;
2299 DoBindTexture(target
, client_texture_id_
, kServiceTextureId
);
2301 // Create a depth texture.
2302 DoTexImage2D(target
,
2313 // Enable GL_SCISSOR_TEST to make sure we disable it in the clear,
2314 // then re-enable it.
2315 DoEnableDisable(GL_SCISSOR_TEST
, true);
2317 EXPECT_CALL(*gl_
, GenFramebuffersEXT(1, _
)).Times(1).RetiresOnSaturation();
2318 EXPECT_CALL(*gl_
, BindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT
, _
))
2320 .RetiresOnSaturation();
2323 FramebufferTexture2DEXT(GL_DRAW_FRAMEBUFFER_EXT
,
2329 .RetiresOnSaturation();
2330 EXPECT_CALL(*gl_
, CheckFramebufferStatusEXT(GL_DRAW_FRAMEBUFFER_EXT
))
2331 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE
))
2332 .RetiresOnSaturation();
2334 EXPECT_CALL(*gl_
, ClearStencil(0)).Times(1).RetiresOnSaturation();
2335 SetupExpectationsForStencilMask(GLES2Decoder::kDefaultStencilMask
,
2336 GLES2Decoder::kDefaultStencilMask
);
2337 EXPECT_CALL(*gl_
, ClearDepth(1.0f
)).Times(1).RetiresOnSaturation();
2338 SetupExpectationsForDepthMask(true);
2339 SetupExpectationsForEnableDisable(GL_SCISSOR_TEST
, false);
2341 EXPECT_CALL(*gl_
, Clear(GL_DEPTH_BUFFER_BIT
)).Times(1).RetiresOnSaturation();
2343 SetupExpectationsForRestoreClearState(0.0f
, 0.0f
, 0.0f
, 0.0f
, 0, 1.0f
, true);
2345 EXPECT_CALL(*gl_
, DeleteFramebuffersEXT(1, _
)).Times(1).RetiresOnSaturation();
2346 EXPECT_CALL(*gl_
, BindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT
, 0))
2348 .RetiresOnSaturation();
2350 SetupExpectationsForApplyingDefaultDirtyState();
2351 EXPECT_CALL(*gl_
, DrawArrays(GL_TRIANGLES
, 0, kNumVertices
))
2353 .RetiresOnSaturation();
2355 cmd
.Init(GL_TRIANGLES
, 0, kNumVertices
);
2356 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
2357 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
2360 } // namespace gles2