Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder_unittest_context_state.cc

Issue 245923008: Optimize GLES2DecoderImpl::ApplyDirtyState. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase on refactored gles2_cmd_decoder_unittest.cc Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "gpu/command_buffer/common/gles2_cmd_format.h" 9 #include "gpu/command_buffer/common/gles2_cmd_format.h"
10 #include "gpu/command_buffer/common/gles2_cmd_utils.h" 10 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 GLES2DecoderRestoreStateTest() {} 59 GLES2DecoderRestoreStateTest() {}
60 60
61 protected: 61 protected:
62 void AddExpectationsForActiveTexture(GLenum unit); 62 void AddExpectationsForActiveTexture(GLenum unit);
63 void AddExpectationsForBindTexture(GLenum target, GLuint id); 63 void AddExpectationsForBindTexture(GLenum target, GLuint id);
64 void InitializeContextState(ContextState* state, 64 void InitializeContextState(ContextState* state,
65 uint32 non_default_unit, 65 uint32 non_default_unit,
66 uint32 active_unit); 66 uint32 active_unit);
67 }; 67 };
68 68
69 INSTANTIATE_TEST_CASE_P(Service,
70 GLES2DecoderRestoreStateTest,
71 ::testing::Bool());
72
69 void GLES2DecoderRestoreStateTest::AddExpectationsForActiveTexture( 73 void GLES2DecoderRestoreStateTest::AddExpectationsForActiveTexture(
70 GLenum unit) { 74 GLenum unit) {
71 EXPECT_CALL(*gl_, ActiveTexture(unit)).Times(1).RetiresOnSaturation(); 75 EXPECT_CALL(*gl_, ActiveTexture(unit)).Times(1).RetiresOnSaturation();
72 } 76 }
73 77
74 void GLES2DecoderRestoreStateTest::AddExpectationsForBindTexture(GLenum target, 78 void GLES2DecoderRestoreStateTest::AddExpectationsForBindTexture(GLenum target,
75 GLuint id) { 79 GLuint id) {
76 EXPECT_CALL(*gl_, BindTexture(target, id)).Times(1).RetiresOnSaturation(); 80 EXPECT_CALL(*gl_, BindTexture(target, id)).Times(1).RetiresOnSaturation();
77 } 81 }
78 82
79 void GLES2DecoderRestoreStateTest::InitializeContextState( 83 void GLES2DecoderRestoreStateTest::InitializeContextState(
80 ContextState* state, 84 ContextState* state,
81 uint32 non_default_unit, 85 uint32 non_default_unit,
82 uint32 active_unit) { 86 uint32 active_unit) {
83 state->texture_units.resize(group().max_texture_units()); 87 state->texture_units.resize(group().max_texture_units());
84 for (uint32 tt = 0; tt < state->texture_units.size(); ++tt) { 88 for (uint32 tt = 0; tt < state->texture_units.size(); ++tt) {
85 TextureRef* ref_cube_map = 89 TextureRef* ref_cube_map =
86 group().texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_CUBE_MAP); 90 group().texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_CUBE_MAP);
87 state->texture_units[tt].bound_texture_cube_map = ref_cube_map; 91 state->texture_units[tt].bound_texture_cube_map = ref_cube_map;
88 TextureRef* ref_2d = 92 TextureRef* ref_2d =
89 (tt == non_default_unit) 93 (tt == non_default_unit)
90 ? group().texture_manager()->GetTexture(client_texture_id_) 94 ? group().texture_manager()->GetTexture(client_texture_id_)
91 : group().texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_2D); 95 : group().texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_2D);
92 state->texture_units[tt].bound_texture_2d = ref_2d; 96 state->texture_units[tt].bound_texture_2d = ref_2d;
93 } 97 }
94 state->active_texture_unit = active_unit; 98 state->active_texture_unit = active_unit;
95 } 99 }
96 100
97 TEST_F(GLES2DecoderRestoreStateTest, NullPreviousStateBGR) { 101 TEST_P(GLES2DecoderRestoreStateTest, NullPreviousStateBGR) {
98 InitState init; 102 InitState init;
99 init.gl_version = "3.0"; 103 init.gl_version = "3.0";
100 init.bind_generates_resource = true; 104 init.bind_generates_resource = true;
101 InitDecoder(init); 105 InitDecoder(init);
102 SetupTexture(); 106 SetupTexture();
103 107
104 InSequence sequence; 108 InSequence sequence;
105 // Expect to restore texture bindings for unit GL_TEXTURE0. 109 // Expect to restore texture bindings for unit GL_TEXTURE0.
106 AddExpectationsForActiveTexture(GL_TEXTURE0); 110 AddExpectationsForActiveTexture(GL_TEXTURE0);
107 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId); 111 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId);
108 AddExpectationsForBindTexture(GL_TEXTURE_CUBE_MAP, 112 AddExpectationsForBindTexture(GL_TEXTURE_CUBE_MAP,
109 TestHelper::kServiceDefaultTextureCubemapId); 113 TestHelper::kServiceDefaultTextureCubemapId);
110 114
111 // Expect to restore texture bindings for remaining units. 115 // Expect to restore texture bindings for remaining units.
112 for (uint32 i = 1; i < group().max_texture_units(); ++i) { 116 for (uint32 i = 1; i < group().max_texture_units(); ++i) {
113 AddExpectationsForActiveTexture(GL_TEXTURE0 + i); 117 AddExpectationsForActiveTexture(GL_TEXTURE0 + i);
114 AddExpectationsForBindTexture(GL_TEXTURE_2D, 118 AddExpectationsForBindTexture(GL_TEXTURE_2D,
115 TestHelper::kServiceDefaultTexture2dId); 119 TestHelper::kServiceDefaultTexture2dId);
116 AddExpectationsForBindTexture(GL_TEXTURE_CUBE_MAP, 120 AddExpectationsForBindTexture(GL_TEXTURE_CUBE_MAP,
117 TestHelper::kServiceDefaultTextureCubemapId); 121 TestHelper::kServiceDefaultTextureCubemapId);
118 } 122 }
119 123
120 // Expect to restore the active texture unit to GL_TEXTURE0. 124 // Expect to restore the active texture unit to GL_TEXTURE0.
121 AddExpectationsForActiveTexture(GL_TEXTURE0); 125 AddExpectationsForActiveTexture(GL_TEXTURE0);
122 126
123 GetDecoder()->RestoreAllTextureUnitBindings(NULL); 127 GetDecoder()->RestoreAllTextureUnitBindings(NULL);
124 } 128 }
125 129
126 TEST_F(GLES2DecoderRestoreStateTest, NullPreviousState) { 130 TEST_P(GLES2DecoderRestoreStateTest, NullPreviousState) {
127 InitState init; 131 InitState init;
128 init.gl_version = "3.0"; 132 init.gl_version = "3.0";
129 InitDecoder(init); 133 InitDecoder(init);
130 SetupTexture(); 134 SetupTexture();
131 135
132 InSequence sequence; 136 InSequence sequence;
133 // Expect to restore texture bindings for unit GL_TEXTURE0. 137 // Expect to restore texture bindings for unit GL_TEXTURE0.
134 AddExpectationsForActiveTexture(GL_TEXTURE0); 138 AddExpectationsForActiveTexture(GL_TEXTURE0);
135 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId); 139 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId);
136 AddExpectationsForBindTexture(GL_TEXTURE_CUBE_MAP, 0); 140 AddExpectationsForBindTexture(GL_TEXTURE_CUBE_MAP, 0);
137 141
138 // Expect to restore texture bindings for remaining units. 142 // Expect to restore texture bindings for remaining units.
139 for (uint32 i = 1; i < group().max_texture_units(); ++i) { 143 for (uint32 i = 1; i < group().max_texture_units(); ++i) {
140 AddExpectationsForActiveTexture(GL_TEXTURE0 + i); 144 AddExpectationsForActiveTexture(GL_TEXTURE0 + i);
141 AddExpectationsForBindTexture(GL_TEXTURE_2D, 0); 145 AddExpectationsForBindTexture(GL_TEXTURE_2D, 0);
142 AddExpectationsForBindTexture(GL_TEXTURE_CUBE_MAP, 0); 146 AddExpectationsForBindTexture(GL_TEXTURE_CUBE_MAP, 0);
143 } 147 }
144 148
145 // Expect to restore the active texture unit to GL_TEXTURE0. 149 // Expect to restore the active texture unit to GL_TEXTURE0.
146 AddExpectationsForActiveTexture(GL_TEXTURE0); 150 AddExpectationsForActiveTexture(GL_TEXTURE0);
147 151
148 GetDecoder()->RestoreAllTextureUnitBindings(NULL); 152 GetDecoder()->RestoreAllTextureUnitBindings(NULL);
149 } 153 }
150 154
151 TEST_F(GLES2DecoderRestoreStateTest, WithPreviousStateBGR) { 155 TEST_P(GLES2DecoderRestoreStateTest, WithPreviousStateBGR) {
152 InitState init; 156 InitState init;
153 init.gl_version = "3.0"; 157 init.gl_version = "3.0";
154 init.bind_generates_resource = true; 158 init.bind_generates_resource = true;
155 InitDecoder(init); 159 InitDecoder(init);
156 SetupTexture(); 160 SetupTexture();
157 161
158 // Construct a previous ContextState with all texture bindings 162 // Construct a previous ContextState with all texture bindings
159 // set to default textures. 163 // set to default textures.
160 ContextState prev_state(NULL, NULL, NULL); 164 ContextState prev_state(NULL, NULL, NULL);
161 InitializeContextState(&prev_state, std::numeric_limits<uint32>::max(), 0); 165 InitializeContextState(&prev_state, std::numeric_limits<uint32>::max(), 0);
162 166
163 InSequence sequence; 167 InSequence sequence;
164 // Expect to restore only GL_TEXTURE_2D binding for GL_TEXTURE0 unit, 168 // Expect to restore only GL_TEXTURE_2D binding for GL_TEXTURE0 unit,
165 // since the rest of the bindings haven't changed between the current 169 // since the rest of the bindings haven't changed between the current
166 // state and the |prev_state|. 170 // state and the |prev_state|.
167 AddExpectationsForActiveTexture(GL_TEXTURE0); 171 AddExpectationsForActiveTexture(GL_TEXTURE0);
168 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId); 172 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId);
169 173
170 // Expect to restore active texture unit to GL_TEXTURE0. 174 // Expect to restore active texture unit to GL_TEXTURE0.
171 AddExpectationsForActiveTexture(GL_TEXTURE0); 175 AddExpectationsForActiveTexture(GL_TEXTURE0);
172 176
173 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state); 177 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state);
174 } 178 }
175 179
176 TEST_F(GLES2DecoderRestoreStateTest, WithPreviousState) { 180 TEST_P(GLES2DecoderRestoreStateTest, WithPreviousState) {
177 InitState init; 181 InitState init;
178 init.gl_version = "3.0"; 182 init.gl_version = "3.0";
179 InitDecoder(init); 183 InitDecoder(init);
180 SetupTexture(); 184 SetupTexture();
181 185
182 // Construct a previous ContextState with all texture bindings 186 // Construct a previous ContextState with all texture bindings
183 // set to default textures. 187 // set to default textures.
184 ContextState prev_state(NULL, NULL, NULL); 188 ContextState prev_state(NULL, NULL, NULL);
185 InitializeContextState(&prev_state, std::numeric_limits<uint32>::max(), 0); 189 InitializeContextState(&prev_state, std::numeric_limits<uint32>::max(), 0);
186 190
187 InSequence sequence; 191 InSequence sequence;
188 // Expect to restore only GL_TEXTURE_2D binding for GL_TEXTURE0 unit, 192 // Expect to restore only GL_TEXTURE_2D binding for GL_TEXTURE0 unit,
189 // since the rest of the bindings haven't changed between the current 193 // since the rest of the bindings haven't changed between the current
190 // state and the |prev_state|. 194 // state and the |prev_state|.
191 AddExpectationsForActiveTexture(GL_TEXTURE0); 195 AddExpectationsForActiveTexture(GL_TEXTURE0);
192 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId); 196 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId);
193 197
194 // Expect to restore active texture unit to GL_TEXTURE0. 198 // Expect to restore active texture unit to GL_TEXTURE0.
195 AddExpectationsForActiveTexture(GL_TEXTURE0); 199 AddExpectationsForActiveTexture(GL_TEXTURE0);
196 200
197 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state); 201 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state);
198 } 202 }
199 203
200 TEST_F(GLES2DecoderRestoreStateTest, ActiveUnit1) { 204 TEST_P(GLES2DecoderRestoreStateTest, ActiveUnit1) {
201 InitState init; 205 InitState init;
202 init.gl_version = "3.0"; 206 init.gl_version = "3.0";
203 InitDecoder(init); 207 InitDecoder(init);
204 208
205 // Bind a non-default texture to GL_TEXTURE1 unit. 209 // Bind a non-default texture to GL_TEXTURE1 unit.
206 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE1)); 210 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE1));
207 ActiveTexture cmd; 211 ActiveTexture cmd;
208 cmd.Init(GL_TEXTURE1); 212 cmd.Init(GL_TEXTURE1);
209 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 213 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
210 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 214 EXPECT_EQ(GL_NO_ERROR, GetGLError());
(...skipping 10 matching lines...) Expand all
221 // state and the |prev_state|. 225 // state and the |prev_state|.
222 AddExpectationsForActiveTexture(GL_TEXTURE1); 226 AddExpectationsForActiveTexture(GL_TEXTURE1);
223 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId); 227 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId);
224 228
225 // Expect to restore active texture unit to GL_TEXTURE1. 229 // Expect to restore active texture unit to GL_TEXTURE1.
226 AddExpectationsForActiveTexture(GL_TEXTURE1); 230 AddExpectationsForActiveTexture(GL_TEXTURE1);
227 231
228 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state); 232 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state);
229 } 233 }
230 234
231 TEST_F(GLES2DecoderRestoreStateTest, NonDefaultUnit0BGR) { 235 TEST_P(GLES2DecoderRestoreStateTest, NonDefaultUnit0BGR) {
232 InitState init; 236 InitState init;
233 init.gl_version = "3.0"; 237 init.gl_version = "3.0";
234 init.bind_generates_resource = true; 238 init.bind_generates_resource = true;
235 InitDecoder(init); 239 InitDecoder(init);
236 240
237 // Bind a non-default texture to GL_TEXTURE1 unit. 241 // Bind a non-default texture to GL_TEXTURE1 unit.
238 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE1)); 242 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE1));
239 SpecializedSetup<ActiveTexture, 0>(true); 243 SpecializedSetup<ActiveTexture, 0>(true);
240 ActiveTexture cmd; 244 ActiveTexture cmd;
241 cmd.Init(GL_TEXTURE1); 245 cmd.Init(GL_TEXTURE1);
(...skipping 18 matching lines...) Expand all
260 // non-default. 264 // non-default.
261 AddExpectationsForActiveTexture(GL_TEXTURE1); 265 AddExpectationsForActiveTexture(GL_TEXTURE1);
262 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId); 266 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId);
263 267
264 // Expect to restore active texture unit to GL_TEXTURE1. 268 // Expect to restore active texture unit to GL_TEXTURE1.
265 AddExpectationsForActiveTexture(GL_TEXTURE1); 269 AddExpectationsForActiveTexture(GL_TEXTURE1);
266 270
267 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state); 271 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state);
268 } 272 }
269 273
270 TEST_F(GLES2DecoderRestoreStateTest, NonDefaultUnit1BGR) { 274 TEST_P(GLES2DecoderRestoreStateTest, NonDefaultUnit1BGR) {
271 InitState init; 275 InitState init;
272 init.gl_version = "3.0"; 276 init.gl_version = "3.0";
273 init.bind_generates_resource = true; 277 init.bind_generates_resource = true;
274 InitDecoder(init); 278 InitDecoder(init);
275 279
276 // Bind a non-default texture to GL_TEXTURE0 unit. 280 // Bind a non-default texture to GL_TEXTURE0 unit.
277 SetupTexture(); 281 SetupTexture();
278 282
279 // Construct a previous ContextState with GL_TEXTURE_2D target in 283 // Construct a previous ContextState with GL_TEXTURE_2D target in
280 // GL_TEXTURE1 unit bound to a non-default texture and the rest 284 // GL_TEXTURE1 unit bound to a non-default texture and the rest
(...skipping 12 matching lines...) Expand all
293 AddExpectationsForActiveTexture(GL_TEXTURE1); 297 AddExpectationsForActiveTexture(GL_TEXTURE1);
294 AddExpectationsForBindTexture(GL_TEXTURE_2D, 298 AddExpectationsForBindTexture(GL_TEXTURE_2D,
295 TestHelper::kServiceDefaultTexture2dId); 299 TestHelper::kServiceDefaultTexture2dId);
296 300
297 // Expect to restore active texture unit to GL_TEXTURE0. 301 // Expect to restore active texture unit to GL_TEXTURE0.
298 AddExpectationsForActiveTexture(GL_TEXTURE0); 302 AddExpectationsForActiveTexture(GL_TEXTURE0);
299 303
300 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state); 304 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state);
301 } 305 }
302 306
303 TEST_F(GLES2DecoderRestoreStateTest, DefaultUnit0) { 307 TEST_P(GLES2DecoderRestoreStateTest, DefaultUnit0) {
304 InitState init; 308 InitState init;
305 init.gl_version = "3.0"; 309 init.gl_version = "3.0";
306 InitDecoder(init); 310 InitDecoder(init);
307 311
308 // Bind a non-default texture to GL_TEXTURE1 unit. 312 // Bind a non-default texture to GL_TEXTURE1 unit.
309 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE1)); 313 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE1));
310 SpecializedSetup<ActiveTexture, 0>(true); 314 SpecializedSetup<ActiveTexture, 0>(true);
311 ActiveTexture cmd; 315 ActiveTexture cmd;
312 cmd.Init(GL_TEXTURE1); 316 cmd.Init(GL_TEXTURE1);
313 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 317 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
(...skipping 16 matching lines...) Expand all
330 // non-default. 334 // non-default.
331 AddExpectationsForActiveTexture(GL_TEXTURE1); 335 AddExpectationsForActiveTexture(GL_TEXTURE1);
332 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId); 336 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId);
333 337
334 // Expect to restore active texture unit to GL_TEXTURE1. 338 // Expect to restore active texture unit to GL_TEXTURE1.
335 AddExpectationsForActiveTexture(GL_TEXTURE1); 339 AddExpectationsForActiveTexture(GL_TEXTURE1);
336 340
337 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state); 341 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state);
338 } 342 }
339 343
340 TEST_F(GLES2DecoderRestoreStateTest, DefaultUnit1) { 344 TEST_P(GLES2DecoderRestoreStateTest, DefaultUnit1) {
341 InitState init; 345 InitState init;
342 init.gl_version = "3.0"; 346 init.gl_version = "3.0";
343 InitDecoder(init); 347 InitDecoder(init);
344 348
345 // Bind a non-default texture to GL_TEXTURE0 unit. 349 // Bind a non-default texture to GL_TEXTURE0 unit.
346 SetupTexture(); 350 SetupTexture();
347 351
348 // Construct a previous ContextState with GL_TEXTURE_2D target in 352 // Construct a previous ContextState with GL_TEXTURE_2D target in
349 // GL_TEXTURE1 unit bound to a non-default texture and the rest 353 // GL_TEXTURE1 unit bound to a non-default texture and the rest
350 // set to default textures. 354 // set to default textures.
(...skipping 10 matching lines...) Expand all
361 // for GL_TEXTURE1 unit. 365 // for GL_TEXTURE1 unit.
362 AddExpectationsForActiveTexture(GL_TEXTURE1); 366 AddExpectationsForActiveTexture(GL_TEXTURE1);
363 AddExpectationsForBindTexture(GL_TEXTURE_2D, 0); 367 AddExpectationsForBindTexture(GL_TEXTURE_2D, 0);
364 368
365 // Expect to restore active texture unit to GL_TEXTURE0. 369 // Expect to restore active texture unit to GL_TEXTURE0.
366 AddExpectationsForActiveTexture(GL_TEXTURE0); 370 AddExpectationsForActiveTexture(GL_TEXTURE0);
367 371
368 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state); 372 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state);
369 } 373 }
370 374
375 TEST_P(GLES2DecoderManualInitTest, ContextStateCapabilityCaching) {
376 struct TestInfo {
377 GLenum gl_enum;
378 bool default_state;
379 bool expect_set;
380 };
381
382 // TODO(vmiura): Should autogen this to match build_gles2_cmd_buffer.py.
383 TestInfo test[] = {{GL_BLEND, false, true},
384 {GL_CULL_FACE, false, true},
385 {GL_DEPTH_TEST, false, false},
386 {GL_DITHER, true, true},
387 {GL_POLYGON_OFFSET_FILL, false, true},
388 {GL_SAMPLE_ALPHA_TO_COVERAGE, false, true},
389 {GL_SAMPLE_COVERAGE, false, true},
390 {GL_SCISSOR_TEST, false, true},
391 {GL_STENCIL_TEST, false, false},
392 {0, false, false}};
393
394 InitState init;
395 init.gl_version = "2.1";
396 InitDecoder(init);
397
398 for (int i = 0; test[i].gl_enum; i++) {
399 bool enable_state = test[i].default_state;
400
401 // Test setting default state initially is ignored.
402 EnableDisableTest(test[i].gl_enum, enable_state, test[i].expect_set);
403
404 // Test new and cached state changes.
405 for (int n = 0; n < 3; n++) {
406 enable_state = !enable_state;
407 EnableDisableTest(test[i].gl_enum, enable_state, test[i].expect_set);
408 EnableDisableTest(test[i].gl_enum, enable_state, test[i].expect_set);
409 }
410 }
411 }
412
371 // TODO(vmiura): Tests for VAO restore. 413 // TODO(vmiura): Tests for VAO restore.
372 414
373 // TODO(vmiura): Tests for ContextState::RestoreAttribute(). 415 // TODO(vmiura): Tests for ContextState::RestoreAttribute().
374 416
375 // TODO(vmiura): Tests for ContextState::RestoreBufferBindings(). 417 // TODO(vmiura): Tests for ContextState::RestoreBufferBindings().
376 418
377 // TODO(vmiura): Tests for ContextState::RestoreProgramBindings(). 419 // TODO(vmiura): Tests for ContextState::RestoreProgramBindings().
378 420
379 // TODO(vmiura): Tests for ContextState::RestoreRenderbufferBindings(). 421 // TODO(vmiura): Tests for ContextState::RestoreRenderbufferBindings().
380 422
381 // TODO(vmiura): Tests for ContextState::RestoreProgramBindings(). 423 // TODO(vmiura): Tests for ContextState::RestoreProgramBindings().
382 424
383 // TODO(vmiura): Tests for ContextState::RestoreGlobalState(). 425 // TODO(vmiura): Tests for ContextState::RestoreGlobalState().
384 426
385 } // namespace gles2 427 } // namespace gles2
386 } // namespace gpu 428 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698