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

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

Issue 893213002: Revert of Make GL bindings conditional (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 (tt == non_default_unit) 92 (tt == non_default_unit)
93 ? group().texture_manager()->GetTexture(client_texture_id_) 93 ? group().texture_manager()->GetTexture(client_texture_id_)
94 : group().texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_2D); 94 : group().texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_2D);
95 state->texture_units[tt].bound_texture_2d = ref_2d; 95 state->texture_units[tt].bound_texture_2d = ref_2d;
96 } 96 }
97 state->active_texture_unit = active_unit; 97 state->active_texture_unit = active_unit;
98 } 98 }
99 99
100 TEST_P(GLES2DecoderRestoreStateTest, NullPreviousStateBGR) { 100 TEST_P(GLES2DecoderRestoreStateTest, NullPreviousStateBGR) {
101 InitState init; 101 InitState init;
102 init.gl_version = "3.0";
102 init.bind_generates_resource = true; 103 init.bind_generates_resource = true;
103 InitDecoder(init); 104 InitDecoder(init);
104 SetupTexture(); 105 SetupTexture();
105 106
106 InSequence sequence; 107 InSequence sequence;
107 // Expect to restore texture bindings for unit GL_TEXTURE0. 108 // Expect to restore texture bindings for unit GL_TEXTURE0.
108 AddExpectationsForActiveTexture(GL_TEXTURE0); 109 AddExpectationsForActiveTexture(GL_TEXTURE0);
109 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId); 110 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId);
110 AddExpectationsForBindTexture(GL_TEXTURE_CUBE_MAP, 111 AddExpectationsForBindTexture(GL_TEXTURE_CUBE_MAP,
111 TestHelper::kServiceDefaultTextureCubemapId); 112 TestHelper::kServiceDefaultTextureCubemapId);
112 113
113 // Expect to restore texture bindings for remaining units. 114 // Expect to restore texture bindings for remaining units.
114 for (uint32 i = 1; i < group().max_texture_units(); ++i) { 115 for (uint32 i = 1; i < group().max_texture_units(); ++i) {
115 AddExpectationsForActiveTexture(GL_TEXTURE0 + i); 116 AddExpectationsForActiveTexture(GL_TEXTURE0 + i);
116 AddExpectationsForBindTexture(GL_TEXTURE_2D, 117 AddExpectationsForBindTexture(GL_TEXTURE_2D,
117 TestHelper::kServiceDefaultTexture2dId); 118 TestHelper::kServiceDefaultTexture2dId);
118 AddExpectationsForBindTexture(GL_TEXTURE_CUBE_MAP, 119 AddExpectationsForBindTexture(GL_TEXTURE_CUBE_MAP,
119 TestHelper::kServiceDefaultTextureCubemapId); 120 TestHelper::kServiceDefaultTextureCubemapId);
120 } 121 }
121 122
122 // Expect to restore the active texture unit to GL_TEXTURE0. 123 // Expect to restore the active texture unit to GL_TEXTURE0.
123 AddExpectationsForActiveTexture(GL_TEXTURE0); 124 AddExpectationsForActiveTexture(GL_TEXTURE0);
124 125
125 GetDecoder()->RestoreAllTextureUnitBindings(NULL); 126 GetDecoder()->RestoreAllTextureUnitBindings(NULL);
126 } 127 }
127 128
128 TEST_P(GLES2DecoderRestoreStateTest, NullPreviousState) { 129 TEST_P(GLES2DecoderRestoreStateTest, NullPreviousState) {
129 InitState init; 130 InitState init;
131 init.gl_version = "3.0";
130 InitDecoder(init); 132 InitDecoder(init);
131 SetupTexture(); 133 SetupTexture();
132 134
133 InSequence sequence; 135 InSequence sequence;
134 // Expect to restore texture bindings for unit GL_TEXTURE0. 136 // Expect to restore texture bindings for unit GL_TEXTURE0.
135 AddExpectationsForActiveTexture(GL_TEXTURE0); 137 AddExpectationsForActiveTexture(GL_TEXTURE0);
136 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId); 138 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId);
137 AddExpectationsForBindTexture(GL_TEXTURE_CUBE_MAP, 0); 139 AddExpectationsForBindTexture(GL_TEXTURE_CUBE_MAP, 0);
138 140
139 // Expect to restore texture bindings for remaining units. 141 // Expect to restore texture bindings for remaining units.
140 for (uint32 i = 1; i < group().max_texture_units(); ++i) { 142 for (uint32 i = 1; i < group().max_texture_units(); ++i) {
141 AddExpectationsForActiveTexture(GL_TEXTURE0 + i); 143 AddExpectationsForActiveTexture(GL_TEXTURE0 + i);
142 AddExpectationsForBindTexture(GL_TEXTURE_2D, 0); 144 AddExpectationsForBindTexture(GL_TEXTURE_2D, 0);
143 AddExpectationsForBindTexture(GL_TEXTURE_CUBE_MAP, 0); 145 AddExpectationsForBindTexture(GL_TEXTURE_CUBE_MAP, 0);
144 } 146 }
145 147
146 // Expect to restore the active texture unit to GL_TEXTURE0. 148 // Expect to restore the active texture unit to GL_TEXTURE0.
147 AddExpectationsForActiveTexture(GL_TEXTURE0); 149 AddExpectationsForActiveTexture(GL_TEXTURE0);
148 150
149 GetDecoder()->RestoreAllTextureUnitBindings(NULL); 151 GetDecoder()->RestoreAllTextureUnitBindings(NULL);
150 } 152 }
151 153
152 TEST_P(GLES2DecoderRestoreStateTest, WithPreviousStateBGR) { 154 TEST_P(GLES2DecoderRestoreStateTest, WithPreviousStateBGR) {
153 InitState init; 155 InitState init;
156 init.gl_version = "3.0";
154 init.bind_generates_resource = true; 157 init.bind_generates_resource = true;
155 InitDecoder(init); 158 InitDecoder(init);
156 SetupTexture(); 159 SetupTexture();
157 160
158 // Construct a previous ContextState with all texture bindings 161 // Construct a previous ContextState with all texture bindings
159 // set to default textures. 162 // set to default textures.
160 ContextState prev_state(NULL, NULL, NULL); 163 ContextState prev_state(NULL, NULL, NULL);
161 InitializeContextState(&prev_state, std::numeric_limits<uint32>::max(), 0); 164 InitializeContextState(&prev_state, std::numeric_limits<uint32>::max(), 0);
162 165
163 InSequence sequence; 166 InSequence sequence;
164 // Expect to restore only GL_TEXTURE_2D binding for GL_TEXTURE0 unit, 167 // 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 168 // since the rest of the bindings haven't changed between the current
166 // state and the |prev_state|. 169 // state and the |prev_state|.
167 AddExpectationsForActiveTexture(GL_TEXTURE0); 170 AddExpectationsForActiveTexture(GL_TEXTURE0);
168 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId); 171 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId);
169 172
170 // Expect to restore active texture unit to GL_TEXTURE0. 173 // Expect to restore active texture unit to GL_TEXTURE0.
171 AddExpectationsForActiveTexture(GL_TEXTURE0); 174 AddExpectationsForActiveTexture(GL_TEXTURE0);
172 175
173 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state); 176 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state);
174 } 177 }
175 178
176 TEST_P(GLES2DecoderRestoreStateTest, WithPreviousState) { 179 TEST_P(GLES2DecoderRestoreStateTest, WithPreviousState) {
177 InitState init; 180 InitState init;
181 init.gl_version = "3.0";
178 InitDecoder(init); 182 InitDecoder(init);
179 SetupTexture(); 183 SetupTexture();
180 184
181 // Construct a previous ContextState with all texture bindings 185 // Construct a previous ContextState with all texture bindings
182 // set to default textures. 186 // set to default textures.
183 ContextState prev_state(NULL, NULL, NULL); 187 ContextState prev_state(NULL, NULL, NULL);
184 InitializeContextState(&prev_state, std::numeric_limits<uint32>::max(), 0); 188 InitializeContextState(&prev_state, std::numeric_limits<uint32>::max(), 0);
185 189
186 InSequence sequence; 190 InSequence sequence;
187 // Expect to restore only GL_TEXTURE_2D binding for GL_TEXTURE0 unit, 191 // Expect to restore only GL_TEXTURE_2D binding for GL_TEXTURE0 unit,
188 // since the rest of the bindings haven't changed between the current 192 // since the rest of the bindings haven't changed between the current
189 // state and the |prev_state|. 193 // state and the |prev_state|.
190 AddExpectationsForActiveTexture(GL_TEXTURE0); 194 AddExpectationsForActiveTexture(GL_TEXTURE0);
191 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId); 195 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId);
192 196
193 // Expect to restore active texture unit to GL_TEXTURE0. 197 // Expect to restore active texture unit to GL_TEXTURE0.
194 AddExpectationsForActiveTexture(GL_TEXTURE0); 198 AddExpectationsForActiveTexture(GL_TEXTURE0);
195 199
196 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state); 200 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state);
197 } 201 }
198 202
199 TEST_P(GLES2DecoderRestoreStateTest, ActiveUnit1) { 203 TEST_P(GLES2DecoderRestoreStateTest, ActiveUnit1) {
200 InitState init; 204 InitState init;
205 init.gl_version = "3.0";
201 InitDecoder(init); 206 InitDecoder(init);
202 207
203 // Bind a non-default texture to GL_TEXTURE1 unit. 208 // Bind a non-default texture to GL_TEXTURE1 unit.
204 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE1)); 209 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE1));
205 ActiveTexture cmd; 210 ActiveTexture cmd;
206 cmd.Init(GL_TEXTURE1); 211 cmd.Init(GL_TEXTURE1);
207 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 212 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
208 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 213 EXPECT_EQ(GL_NO_ERROR, GetGLError());
209 SetupTexture(); 214 SetupTexture();
210 215
(...skipping 10 matching lines...) Expand all
221 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId); 226 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId);
222 227
223 // Expect to restore active texture unit to GL_TEXTURE1. 228 // Expect to restore active texture unit to GL_TEXTURE1.
224 AddExpectationsForActiveTexture(GL_TEXTURE1); 229 AddExpectationsForActiveTexture(GL_TEXTURE1);
225 230
226 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state); 231 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state);
227 } 232 }
228 233
229 TEST_P(GLES2DecoderRestoreStateTest, NonDefaultUnit0BGR) { 234 TEST_P(GLES2DecoderRestoreStateTest, NonDefaultUnit0BGR) {
230 InitState init; 235 InitState init;
236 init.gl_version = "3.0";
231 init.bind_generates_resource = true; 237 init.bind_generates_resource = true;
232 InitDecoder(init); 238 InitDecoder(init);
233 239
234 // Bind a non-default texture to GL_TEXTURE1 unit. 240 // Bind a non-default texture to GL_TEXTURE1 unit.
235 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE1)); 241 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE1));
236 SpecializedSetup<ActiveTexture, 0>(true); 242 SpecializedSetup<ActiveTexture, 0>(true);
237 ActiveTexture cmd; 243 ActiveTexture cmd;
238 cmd.Init(GL_TEXTURE1); 244 cmd.Init(GL_TEXTURE1);
239 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 245 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
240 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 246 EXPECT_EQ(GL_NO_ERROR, GetGLError());
(...skipping 18 matching lines...) Expand all
259 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId); 265 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId);
260 266
261 // Expect to restore active texture unit to GL_TEXTURE1. 267 // Expect to restore active texture unit to GL_TEXTURE1.
262 AddExpectationsForActiveTexture(GL_TEXTURE1); 268 AddExpectationsForActiveTexture(GL_TEXTURE1);
263 269
264 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state); 270 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state);
265 } 271 }
266 272
267 TEST_P(GLES2DecoderRestoreStateTest, NonDefaultUnit1BGR) { 273 TEST_P(GLES2DecoderRestoreStateTest, NonDefaultUnit1BGR) {
268 InitState init; 274 InitState init;
275 init.gl_version = "3.0";
269 init.bind_generates_resource = true; 276 init.bind_generates_resource = true;
270 InitDecoder(init); 277 InitDecoder(init);
271 278
272 // Bind a non-default texture to GL_TEXTURE0 unit. 279 // Bind a non-default texture to GL_TEXTURE0 unit.
273 SetupTexture(); 280 SetupTexture();
274 281
275 // Construct a previous ContextState with GL_TEXTURE_2D target in 282 // Construct a previous ContextState with GL_TEXTURE_2D target in
276 // GL_TEXTURE1 unit bound to a non-default texture and the rest 283 // GL_TEXTURE1 unit bound to a non-default texture and the rest
277 // set to default textures. 284 // set to default textures.
278 ContextState prev_state(NULL, NULL, NULL); 285 ContextState prev_state(NULL, NULL, NULL);
(...skipping 12 matching lines...) Expand all
291 TestHelper::kServiceDefaultTexture2dId); 298 TestHelper::kServiceDefaultTexture2dId);
292 299
293 // Expect to restore active texture unit to GL_TEXTURE0. 300 // Expect to restore active texture unit to GL_TEXTURE0.
294 AddExpectationsForActiveTexture(GL_TEXTURE0); 301 AddExpectationsForActiveTexture(GL_TEXTURE0);
295 302
296 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state); 303 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state);
297 } 304 }
298 305
299 TEST_P(GLES2DecoderRestoreStateTest, DefaultUnit0) { 306 TEST_P(GLES2DecoderRestoreStateTest, DefaultUnit0) {
300 InitState init; 307 InitState init;
308 init.gl_version = "3.0";
301 InitDecoder(init); 309 InitDecoder(init);
302 310
303 // Bind a non-default texture to GL_TEXTURE1 unit. 311 // Bind a non-default texture to GL_TEXTURE1 unit.
304 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE1)); 312 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE1));
305 SpecializedSetup<ActiveTexture, 0>(true); 313 SpecializedSetup<ActiveTexture, 0>(true);
306 ActiveTexture cmd; 314 ActiveTexture cmd;
307 cmd.Init(GL_TEXTURE1); 315 cmd.Init(GL_TEXTURE1);
308 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 316 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
309 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 317 EXPECT_EQ(GL_NO_ERROR, GetGLError());
310 SetupTexture(); 318 SetupTexture();
(...skipping 16 matching lines...) Expand all
327 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId); 335 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId);
328 336
329 // Expect to restore active texture unit to GL_TEXTURE1. 337 // Expect to restore active texture unit to GL_TEXTURE1.
330 AddExpectationsForActiveTexture(GL_TEXTURE1); 338 AddExpectationsForActiveTexture(GL_TEXTURE1);
331 339
332 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state); 340 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state);
333 } 341 }
334 342
335 TEST_P(GLES2DecoderRestoreStateTest, DefaultUnit1) { 343 TEST_P(GLES2DecoderRestoreStateTest, DefaultUnit1) {
336 InitState init; 344 InitState init;
345 init.gl_version = "3.0";
337 InitDecoder(init); 346 InitDecoder(init);
338 347
339 // Bind a non-default texture to GL_TEXTURE0 unit. 348 // Bind a non-default texture to GL_TEXTURE0 unit.
340 SetupTexture(); 349 SetupTexture();
341 350
342 // Construct a previous ContextState with GL_TEXTURE_2D target in 351 // Construct a previous ContextState with GL_TEXTURE_2D target in
343 // GL_TEXTURE1 unit bound to a non-default texture and the rest 352 // GL_TEXTURE1 unit bound to a non-default texture and the rest
344 // set to default textures. 353 // set to default textures.
345 ContextState prev_state(NULL, NULL, NULL); 354 ContextState prev_state(NULL, NULL, NULL);
346 InitializeContextState(&prev_state, 1, kServiceTextureId); 355 InitializeContextState(&prev_state, 1, kServiceTextureId);
(...skipping 28 matching lines...) Expand all
375 {GL_DEPTH_TEST, false, false}, 384 {GL_DEPTH_TEST, false, false},
376 {GL_DITHER, true, true}, 385 {GL_DITHER, true, true},
377 {GL_POLYGON_OFFSET_FILL, false, true}, 386 {GL_POLYGON_OFFSET_FILL, false, true},
378 {GL_SAMPLE_ALPHA_TO_COVERAGE, false, true}, 387 {GL_SAMPLE_ALPHA_TO_COVERAGE, false, true},
379 {GL_SAMPLE_COVERAGE, false, true}, 388 {GL_SAMPLE_COVERAGE, false, true},
380 {GL_SCISSOR_TEST, false, true}, 389 {GL_SCISSOR_TEST, false, true},
381 {GL_STENCIL_TEST, false, false}, 390 {GL_STENCIL_TEST, false, false},
382 {0, false, false}}; 391 {0, false, false}};
383 392
384 InitState init; 393 InitState init;
394 init.gl_version = "2.1";
385 InitDecoder(init); 395 InitDecoder(init);
386 396
387 for (int i = 0; test[i].gl_enum; i++) { 397 for (int i = 0; test[i].gl_enum; i++) {
388 bool enable_state = test[i].default_state; 398 bool enable_state = test[i].default_state;
389 399
390 // Test setting default state initially is ignored. 400 // Test setting default state initially is ignored.
391 EnableDisableTest(test[i].gl_enum, enable_state, test[i].expect_set); 401 EnableDisableTest(test[i].gl_enum, enable_state, test[i].expect_set);
392 402
393 // Test new and cached state changes. 403 // Test new and cached state changes.
394 for (int n = 0; n < 3; n++) { 404 for (int n = 0; n < 3; n++) {
(...skipping 13 matching lines...) Expand all
408 // TODO(vmiura): Tests for ContextState::RestoreProgramBindings(). 418 // TODO(vmiura): Tests for ContextState::RestoreProgramBindings().
409 419
410 // TODO(vmiura): Tests for ContextState::RestoreRenderbufferBindings(). 420 // TODO(vmiura): Tests for ContextState::RestoreRenderbufferBindings().
411 421
412 // TODO(vmiura): Tests for ContextState::RestoreProgramBindings(). 422 // TODO(vmiura): Tests for ContextState::RestoreProgramBindings().
413 423
414 // TODO(vmiura): Tests for ContextState::RestoreGlobalState(). 424 // TODO(vmiura): Tests for ContextState::RestoreGlobalState().
415 425
416 } // namespace gles2 426 } // namespace gles2
417 } // namespace gpu 427 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698