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

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

Issue 477623004: command_buffer: Support instanced path rendering in gpu command buffer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@new-03-path-funcs
Patch Set: fix msvc signedness warning in an unittest Created 5 years, 1 month 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 "gpu/command_buffer/common/gles2_cmd_format.h" 8 #include "gpu/command_buffer/common/gles2_cmd_format.h"
9 #include "gpu/command_buffer/common/gles2_cmd_utils.h" 9 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
10 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest.h" 10 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 { 104 {
105 cmds::StencilThenCoverFillPathCHROMIUM cmd; 105 cmds::StencilThenCoverFillPathCHROMIUM cmd;
106 cmd.Init(kClientPathId, GL_COUNT_UP_CHROMIUM, 1, GL_BOUNDING_BOX_CHROMIUM); 106 cmd.Init(kClientPathId, GL_COUNT_UP_CHROMIUM, 1, GL_BOUNDING_BOX_CHROMIUM);
107 EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd)); 107 EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd));
108 } 108 }
109 { 109 {
110 cmds::StencilThenCoverStrokePathCHROMIUM cmd; 110 cmds::StencilThenCoverStrokePathCHROMIUM cmd;
111 cmd.Init(kClientPathId, 1, 2, GL_BOUNDING_BOX_CHROMIUM); 111 cmd.Init(kClientPathId, 1, 2, GL_BOUNDING_BOX_CHROMIUM);
112 EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd)); 112 EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd));
113 } 113 }
114 {
115 cmds::StencilFillPathInstancedCHROMIUM cmd;
116 GLuint* paths = GetSharedMemoryAs<GLuint*>();
117 paths[0] = kClientPathId;
118 cmd.Init(1, GL_UNSIGNED_INT, shared_memory_id_, shared_memory_offset_, 0,
119 GL_COUNT_UP_CHROMIUM, 1, GL_NONE, 0, 0);
120 EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd));
121 }
122 {
123 cmds::StencilStrokePathInstancedCHROMIUM cmd;
124 GLuint* paths = GetSharedMemoryAs<GLuint*>();
125 paths[0] = kClientPathId;
126 cmd.Init(1, GL_UNSIGNED_INT, shared_memory_id_, shared_memory_offset_, 0,
127 0x80, 0x80, GL_NONE, 0, 0);
128 EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd));
129 }
130 {
131 cmds::CoverFillPathInstancedCHROMIUM cmd;
132 GLuint* paths = GetSharedMemoryAs<GLuint*>();
133 paths[0] = kClientPathId;
134 cmd.Init(1, GL_UNSIGNED_INT, shared_memory_id_, shared_memory_offset_, 0,
135 GL_BOUNDING_BOX_OF_BOUNDING_BOXES_CHROMIUM, GL_NONE, 0, 0);
136 EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd));
137 }
138 {
139 cmds::CoverStrokePathInstancedCHROMIUM cmd;
140 GLuint* paths = GetSharedMemoryAs<GLuint*>();
141 paths[0] = kClientPathId;
142 cmd.Init(1, GL_UNSIGNED_INT, shared_memory_id_, shared_memory_offset_, 0,
143 GL_BOUNDING_BOX_OF_BOUNDING_BOXES_CHROMIUM, GL_NONE, 0, 0);
144 EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd));
145 }
146 {
147 cmds::StencilThenCoverFillPathInstancedCHROMIUM cmd;
148 GLuint* paths = GetSharedMemoryAs<GLuint*>();
149 paths[0] = kClientPathId;
150 cmd.Init(1, GL_UNSIGNED_INT, shared_memory_id_, shared_memory_offset_, 0,
151 GL_COUNT_UP_CHROMIUM, 1,
152 GL_BOUNDING_BOX_OF_BOUNDING_BOXES_CHROMIUM, GL_NONE, 0, 0);
153 EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd));
154 }
155 {
156 cmds::StencilThenCoverStrokePathInstancedCHROMIUM cmd;
157 GLuint* paths = GetSharedMemoryAs<GLuint*>();
158 paths[0] = kClientPathId;
159 cmd.Init(1, GL_UNSIGNED_INT, shared_memory_id_, shared_memory_offset_, 0,
160 0x80, 0x80, GL_BOUNDING_BOX_OF_BOUNDING_BOXES_CHROMIUM, GL_NONE, 0,
161 0);
162 EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd));
163 }
114 } 164 }
115 165
116 class GLES2DecoderTestWithCHROMIUMPathRendering : public GLES2DecoderTest { 166 class GLES2DecoderTestWithCHROMIUMPathRendering : public GLES2DecoderTest {
117 public: 167 public:
118 GLES2DecoderTestWithCHROMIUMPathRendering() : client_path_id_(125) {} 168 GLES2DecoderTestWithCHROMIUMPathRendering() : client_path_id_(125) {}
119 169
120 void SetUp() override { 170 void SetUp() override {
121 InitState init; 171 InitState init;
122 init.gl_version = "opengl es 3.1"; 172 init.gl_version = "opengl es 3.1";
123 init.has_alpha = true; 173 init.has_alpha = true;
124 init.has_depth = true; 174 init.has_depth = true;
125 init.request_alpha = true; 175 init.request_alpha = true;
126 init.request_depth = true; 176 init.request_depth = true;
127 init.bind_generates_resource = true; 177 init.bind_generates_resource = true;
128 init.extensions = "GL_NV_path_rendering"; 178 init.extensions = "GL_NV_path_rendering";
129 base::CommandLine command_line(0, NULL); 179 base::CommandLine command_line(0, NULL);
130 command_line.AppendSwitch(switches::kEnableGLPathRendering); 180 command_line.AppendSwitch(switches::kEnableGLPathRendering);
131 InitDecoderWithCommandLine(init, &command_line); 181 InitDecoderWithCommandLine(init, &command_line);
132 182
133 EXPECT_CALL(*gl_, GenPathsNV(1)) 183 EXPECT_CALL(*gl_, GenPathsNV(1))
134 .WillOnce(Return(kServicePathId)) 184 .WillOnce(Return(kServicePathId))
135 .RetiresOnSaturation(); 185 .RetiresOnSaturation();
136 cmds::GenPathsCHROMIUM cmd; 186 cmds::GenPathsCHROMIUM cmd;
137 cmd.Init(client_path_id_, 1); 187 cmd.Init(client_path_id_, 1);
138 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 188 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
189
190 // The tests use client_path_id_ to test all sorts of drawing. The NVPR API
191 // behaves differently with a path name that is "used" but not which does
192 // not "allocate path object state" and a path name that is a name of a real
193 // path object. The drawing with former causes GL error while latter works
194 // ok, even if there is nothing in the actual path object. To remain
195 // compatible with the API, we allocate path object state even when using
196 // the mock API.
197 EXPECT_CALL(*gl_,
198 PathCommandsNV(kServicePathId, 0, NULL, 0, GL_FLOAT, NULL))
199 .RetiresOnSaturation();
200 cmds::PathCommandsCHROMIUM pcmd;
201 pcmd.Init(client_path_id_, 0, 0, 0, 0, GL_FLOAT, 0, 0);
202 EXPECT_EQ(error::kNoError, ExecuteCmd(pcmd));
139 } 203 }
140 204
141 protected: 205 protected:
142 template <typename TypeParam> 206 template <typename TypeParam>
143 void TestPathCommandsCHROMIUMCoordTypes(); 207 void TestPathCommandsCHROMIUMCoordTypes();
144 208
209 struct InstancedTestcase {
210 GLsizei num_paths;
211 GLenum path_name_type;
212 const void* paths;
213 GLuint path_base;
214 GLenum fill_mode;
215 GLuint reference;
216 GLuint mask;
217 GLenum transform_type;
218 const GLfloat* transform_values;
219 size_t sizeof_paths; // Used for copying to shm buffer.
220 size_t sizeof_transform_values; // Used for copying to shm buffer.
221 error::Error expected_error;
222 GLint expected_gl_error;
223 bool expect_gl_call;
224 };
225
226 void CallAllInstancedCommands(const InstancedTestcase& testcase) {
227 // Note: for testcases that expect a call, We do not compare the 'paths'
228 // array during EXPECT_CALL due to it being void*. Instead, we rely on the
229 // fact that if the path base was not added correctly, the paths wouldn't
230 // exists and the call wouldn't come through.
231
232 bool copy_paths = false; // Paths are copied for each call that has paths,
233 // since the implementation modifies the memory
234 // area.
235 void* paths = NULL;
236 uint32 paths_shm_id = 0;
237 uint32 paths_shm_offset = 0;
238 GLfloat* transforms = NULL;
239 uint32 transforms_shm_id = 0;
240 uint32 transforms_shm_offset = 0;
241
242 if (testcase.transform_values) {
243 transforms = GetSharedMemoryAs<GLfloat*>();
244 transforms_shm_id = shared_memory_id_;
245 transforms_shm_offset = shared_memory_offset_;
246 memcpy(transforms, testcase.transform_values,
247 testcase.sizeof_transform_values);
248 } else {
249 DCHECK(testcase.sizeof_transform_values == 0);
250 }
251 if (testcase.paths) {
252 paths =
253 GetSharedMemoryAsWithOffset<void*>(testcase.sizeof_transform_values);
254 paths_shm_id = shared_memory_id_;
255 paths_shm_offset =
256 shared_memory_offset_ + testcase.sizeof_transform_values;
257 copy_paths = true;
258 } else {
259 DCHECK(testcase.sizeof_paths == 0);
260 }
261
262 if (testcase.expect_gl_call) {
263 EXPECT_CALL(*gl_, StencilFillPathInstancedNV(
264 testcase.num_paths, GL_UNSIGNED_INT, _, 0,
265 testcase.fill_mode, testcase.mask,
266 testcase.transform_type, transforms))
267 .RetiresOnSaturation();
268 }
269 if (copy_paths) {
270 memcpy(paths, testcase.paths, testcase.sizeof_paths);
271 }
272 {
273 cmds::StencilFillPathInstancedCHROMIUM sfi_cmd;
274 sfi_cmd.Init(testcase.num_paths, testcase.path_name_type, paths_shm_id,
275 paths_shm_offset, testcase.path_base, testcase.fill_mode,
276 testcase.mask, testcase.transform_type, transforms_shm_id,
277 transforms_shm_offset);
278 EXPECT_EQ(testcase.expected_error, ExecuteCmd(sfi_cmd));
279 EXPECT_EQ(testcase.expected_gl_error, GetGLError());
280 }
281
282 if (testcase.expect_gl_call) {
283 EXPECT_CALL(*gl_, StencilStrokePathInstancedNV(
284 testcase.num_paths, GL_UNSIGNED_INT, _, 0,
285 testcase.reference, testcase.mask,
286 testcase.transform_type, transforms))
287 .RetiresOnSaturation();
288 }
289 if (copy_paths) {
290 memcpy(paths, testcase.paths, testcase.sizeof_paths);
291 }
292 {
293 cmds::StencilStrokePathInstancedCHROMIUM ssi_cmd;
294 ssi_cmd.Init(testcase.num_paths, testcase.path_name_type, paths_shm_id,
295 paths_shm_offset, testcase.path_base, testcase.reference,
296 testcase.mask, testcase.transform_type, transforms_shm_id,
297 transforms_shm_offset);
298 EXPECT_EQ(testcase.expected_error, ExecuteCmd(ssi_cmd));
299 EXPECT_EQ(testcase.expected_gl_error, GetGLError());
300 }
301
302 if (testcase.expect_gl_call) {
303 EXPECT_CALL(*gl_, CoverFillPathInstancedNV(
304 testcase.num_paths, GL_UNSIGNED_INT, _, 0,
305 GL_BOUNDING_BOX_OF_BOUNDING_BOXES_NV,
306 testcase.transform_type, transforms))
307 .RetiresOnSaturation();
308 }
309 if (copy_paths) {
310 memcpy(paths, testcase.paths, testcase.sizeof_paths);
311 }
312 {
313 cmds::CoverFillPathInstancedCHROMIUM cfi_cmd;
314 cfi_cmd.Init(testcase.num_paths, testcase.path_name_type, paths_shm_id,
315 paths_shm_offset, testcase.path_base,
316 GL_BOUNDING_BOX_OF_BOUNDING_BOXES_CHROMIUM,
317 testcase.transform_type, transforms_shm_id,
318 transforms_shm_offset);
319 EXPECT_EQ(testcase.expected_error, ExecuteCmd(cfi_cmd));
320 EXPECT_EQ(testcase.expected_gl_error, GetGLError());
321 }
322 if (testcase.expect_gl_call) {
323 EXPECT_CALL(*gl_, CoverStrokePathInstancedNV(
324 testcase.num_paths, GL_UNSIGNED_INT, _, 0,
325 GL_BOUNDING_BOX_OF_BOUNDING_BOXES_NV,
326 testcase.transform_type, transforms))
327 .RetiresOnSaturation();
328 }
329 if (copy_paths) {
330 memcpy(paths, testcase.paths, testcase.sizeof_paths);
331 }
332
333 {
334 cmds::CoverStrokePathInstancedCHROMIUM csi_cmd;
335 csi_cmd.Init(testcase.num_paths, testcase.path_name_type, paths_shm_id,
336 paths_shm_offset, testcase.path_base,
337 GL_BOUNDING_BOX_OF_BOUNDING_BOXES_CHROMIUM,
338 testcase.transform_type, transforms_shm_id,
339 transforms_shm_offset);
340 EXPECT_EQ(testcase.expected_error, ExecuteCmd(csi_cmd));
341 EXPECT_EQ(testcase.expected_gl_error, GetGLError());
342 }
343
344 if (testcase.expect_gl_call) {
345 EXPECT_CALL(*gl_, StencilThenCoverFillPathInstancedNV(
346 testcase.num_paths, GL_UNSIGNED_INT, _, 0,
347 testcase.fill_mode, testcase.mask,
348 GL_BOUNDING_BOX_OF_BOUNDING_BOXES_NV,
349 testcase.transform_type, transforms))
350 .RetiresOnSaturation();
351 }
352 if (copy_paths) {
353 memcpy(paths, testcase.paths, testcase.sizeof_paths);
354 }
355 {
356 cmds::StencilThenCoverFillPathInstancedCHROMIUM stcfi_cmd;
357 stcfi_cmd.Init(testcase.num_paths, testcase.path_name_type, paths_shm_id,
358 paths_shm_offset, testcase.path_base, testcase.fill_mode,
359 testcase.mask, GL_BOUNDING_BOX_OF_BOUNDING_BOXES_CHROMIUM,
360 testcase.transform_type, transforms_shm_id,
361 transforms_shm_offset);
362 EXPECT_EQ(testcase.expected_error, ExecuteCmd(stcfi_cmd));
363 EXPECT_EQ(testcase.expected_gl_error, GetGLError());
364 }
365
366 if (testcase.expect_gl_call) {
367 EXPECT_CALL(*gl_, StencilThenCoverStrokePathInstancedNV(
368 testcase.num_paths, GL_UNSIGNED_INT, _, 0,
369 testcase.reference, testcase.mask,
370 GL_BOUNDING_BOX_OF_BOUNDING_BOXES_NV,
371 testcase.transform_type, transforms))
372 .RetiresOnSaturation();
373 }
374 if (copy_paths) {
375 memcpy(paths, testcase.paths, testcase.sizeof_paths);
376 }
377 {
378 cmds::StencilThenCoverStrokePathInstancedCHROMIUM stcsi_cmd;
379 stcsi_cmd.Init(testcase.num_paths, testcase.path_name_type, paths_shm_id,
380 paths_shm_offset, testcase.path_base, testcase.reference,
381 testcase.mask, GL_BOUNDING_BOX_OF_BOUNDING_BOXES_CHROMIUM,
382 testcase.transform_type, transforms_shm_id,
383 transforms_shm_offset);
384 EXPECT_EQ(testcase.expected_error, ExecuteCmd(stcsi_cmd));
385 EXPECT_EQ(testcase.expected_gl_error, GetGLError());
386 }
387 }
388
389 void CallAllInstancedCommandsWithInvalidSHM(GLsizei num_paths,
390 const GLuint* paths,
391 GLuint* paths_shm,
392 uint32 paths_shm_id,
393 uint32 paths_shm_offset,
394 uint32 transforms_shm_id,
395 uint32 transforms_shm_offset) {
396 const GLuint kPathBase = 0;
397 const GLenum kFillMode = GL_INVERT;
398 const GLuint kMask = 0x80;
399 const GLuint kReference = 0xFF;
400 const GLuint kTransformType = GL_AFFINE_3D_CHROMIUM;
401 memcpy(paths_shm, paths, sizeof(GLuint) * num_paths);
402 {
403 cmds::StencilFillPathInstancedCHROMIUM sfi_cmd;
404 sfi_cmd.Init(num_paths, GL_UNSIGNED_INT, paths_shm_id, paths_shm_offset,
405 kPathBase, kFillMode, kMask, kTransformType,
406 transforms_shm_id, transforms_shm_offset);
407 EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(sfi_cmd));
408 EXPECT_EQ(GL_NO_ERROR, GetGLError());
409 }
410 memcpy(paths_shm, paths, sizeof(GLuint) * num_paths);
411 {
412 cmds::StencilStrokePathInstancedCHROMIUM ssi_cmd;
413 ssi_cmd.Init(num_paths, GL_UNSIGNED_INT, paths_shm_id, paths_shm_offset,
414 kPathBase, kReference, kMask, kTransformType,
415 transforms_shm_id, transforms_shm_offset);
416 EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(ssi_cmd));
417 EXPECT_EQ(GL_NO_ERROR, GetGLError());
418 }
419 memcpy(paths_shm, paths, sizeof(GLuint) * num_paths);
420 {
421 cmds::CoverFillPathInstancedCHROMIUM cfi_cmd;
422 cfi_cmd.Init(num_paths, GL_UNSIGNED_INT, paths_shm_id, paths_shm_offset,
423 kPathBase, GL_BOUNDING_BOX_OF_BOUNDING_BOXES_CHROMIUM,
424 kTransformType, transforms_shm_id, transforms_shm_offset);
425 EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cfi_cmd));
426 EXPECT_EQ(GL_NO_ERROR, GetGLError());
427 }
428 memcpy(paths_shm, paths, sizeof(GLuint) * num_paths);
429 {
430 cmds::CoverStrokePathInstancedCHROMIUM csi_cmd;
431 csi_cmd.Init(num_paths, GL_UNSIGNED_INT, paths_shm_id, paths_shm_offset,
432 kPathBase, GL_BOUNDING_BOX_OF_BOUNDING_BOXES_CHROMIUM,
433 kTransformType, transforms_shm_id, transforms_shm_offset);
434 EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(csi_cmd));
435 EXPECT_EQ(GL_NO_ERROR, GetGLError());
436 }
437 memcpy(paths_shm, paths, sizeof(GLuint) * num_paths);
438 {
439 cmds::StencilThenCoverFillPathInstancedCHROMIUM stcfi_cmd;
440 stcfi_cmd.Init(num_paths, GL_UNSIGNED_INT, paths_shm_id, paths_shm_offset,
441 kPathBase, kFillMode, kMask,
442 GL_BOUNDING_BOX_OF_BOUNDING_BOXES_CHROMIUM, kTransformType,
443 transforms_shm_id, transforms_shm_offset);
444 EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(stcfi_cmd));
445 EXPECT_EQ(GL_NO_ERROR, GetGLError());
446 }
447 memcpy(paths_shm, paths, sizeof(GLuint) * num_paths);
448 {
449 cmds::StencilThenCoverStrokePathInstancedCHROMIUM stcsi_cmd;
450 stcsi_cmd.Init(num_paths, GL_UNSIGNED_INT, paths_shm_id, paths_shm_offset,
451 kPathBase, kReference, kMask,
452 GL_BOUNDING_BOX_OF_BOUNDING_BOXES_CHROMIUM, kTransformType,
453 transforms_shm_id, transforms_shm_offset);
454 EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(stcsi_cmd));
455 EXPECT_EQ(GL_NO_ERROR, GetGLError());
456 }
457 }
458
145 GLuint client_path_id_; 459 GLuint client_path_id_;
146 static const GLuint kServicePathId = 311; 460 static const GLuint kServicePathId = 311;
147 }; 461 };
148 462
149 INSTANTIATE_TEST_CASE_P(Service, 463 INSTANTIATE_TEST_CASE_P(Service,
150 GLES2DecoderTestWithCHROMIUMPathRendering, 464 GLES2DecoderTestWithCHROMIUMPathRendering,
151 ::testing::Bool()); 465 ::testing::Bool());
152 466
153 class GLES2DecoderTestWithBlendEquationAdvanced : public GLES2DecoderTest { 467 class GLES2DecoderTestWithBlendEquationAdvanced : public GLES2DecoderTest {
154 public: 468 public:
(...skipping 25 matching lines...) Expand all
180 gen_cmd.Init(kFirstClientID, 0); 494 gen_cmd.Init(kFirstClientID, 0);
181 EXPECT_EQ(error::kNoError, ExecuteCmd(gen_cmd)); 495 EXPECT_EQ(error::kNoError, ExecuteCmd(gen_cmd));
182 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 496 EXPECT_EQ(GL_NO_ERROR, GetGLError());
183 497
184 // DeletePaths range 0 causes no calls. 498 // DeletePaths range 0 causes no calls.
185 cmds::DeletePathsCHROMIUM delete_cmd; 499 cmds::DeletePathsCHROMIUM delete_cmd;
186 delete_cmd.Init(kFirstClientID, 0); 500 delete_cmd.Init(kFirstClientID, 0);
187 EXPECT_EQ(error::kNoError, ExecuteCmd(delete_cmd)); 501 EXPECT_EQ(error::kNoError, ExecuteCmd(delete_cmd));
188 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 502 EXPECT_EQ(GL_NO_ERROR, GetGLError());
189 503
190 // DeletePaths client 0 causes no calls and no errors. 504 // DeletePaths client id 0 causes no calls and no errors.
191 delete_cmd.Init(0, 1); 505 delete_cmd.Init(0, 1);
192 EXPECT_EQ(error::kNoError, ExecuteCmd(delete_cmd)); 506 EXPECT_EQ(error::kNoError, ExecuteCmd(delete_cmd));
193 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 507 EXPECT_EQ(GL_NO_ERROR, GetGLError());
194 508
195 // DeletePaths with a big range should not cause any deletes. 509 // DeletePaths with a big range should not cause any deletes.
196 delete_cmd.Init(client_path_id_ + 1, 510 delete_cmd.Init(client_path_id_ + 1,
197 std::numeric_limits<GLsizei>::max() - client_path_id_ - 1); 511 std::numeric_limits<GLsizei>::max() - client_path_id_ - 1);
198 EXPECT_EQ(error::kNoError, ExecuteCmd(delete_cmd)); 512 EXPECT_EQ(error::kNoError, ExecuteCmd(delete_cmd));
199 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 513 EXPECT_EQ(GL_NO_ERROR, GetGLError());
200 514
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 PathCommandsCHROMIUMCoordTypes) { 1285 PathCommandsCHROMIUMCoordTypes) {
972 // Not using a typed test case, because the base class is already parametrized 1286 // Not using a typed test case, because the base class is already parametrized
973 // test case and uses GetParam. 1287 // test case and uses GetParam.
974 TestPathCommandsCHROMIUMCoordTypes<GLbyte>(); 1288 TestPathCommandsCHROMIUMCoordTypes<GLbyte>();
975 TestPathCommandsCHROMIUMCoordTypes<GLubyte>(); 1289 TestPathCommandsCHROMIUMCoordTypes<GLubyte>();
976 TestPathCommandsCHROMIUMCoordTypes<GLshort>(); 1290 TestPathCommandsCHROMIUMCoordTypes<GLshort>();
977 TestPathCommandsCHROMIUMCoordTypes<GLushort>(); 1291 TestPathCommandsCHROMIUMCoordTypes<GLushort>();
978 TestPathCommandsCHROMIUMCoordTypes<GLfloat>(); 1292 TestPathCommandsCHROMIUMCoordTypes<GLfloat>();
979 } 1293 }
980 1294
1295 TEST_P(GLES2DecoderTestWithCHROMIUMPathRendering,
1296 StencilXFillPathInstancedCHROMIUMInvalidArgs) {
1297 cmds::StencilFillPathInstancedCHROMIUM sfi_cmd;
1298 cmds::StencilThenCoverFillPathInstancedCHROMIUM stcfi_cmd;
1299
1300 const GLuint kPaths[] = {client_path_id_, client_path_id_ + 5,
1301 client_path_id_, client_path_id_ + 18};
1302 const GLsizei kPathCount = arraysize(kPaths);
1303
1304 struct {
1305 GLenum fill_mode;
1306 GLuint mask;
1307 GLint expected_error;
1308 } testcases[] = {
1309 // Using invalid fill mode produces invalid enum.
1310 {GL_COUNT_UP_CHROMIUM - 1, 0x7F, GL_INVALID_ENUM},
1311 {GL_COUNT_DOWN_CHROMIUM + 1, 0x7F, GL_INVALID_ENUM},
1312 // Using /mask/+1 which is not power of two produces invalid value.
1313 {GL_COUNT_UP_CHROMIUM, 0x80, GL_INVALID_VALUE},
1314 {GL_COUNT_DOWN_CHROMIUM, 4, GL_INVALID_VALUE}};
1315
1316 GLuint* paths = GetSharedMemoryAs<GLuint*>();
1317
1318 for (size_t i = 0; i < arraysize(testcases); ++i) {
1319 memcpy(paths, kPaths, sizeof(kPaths));
1320 sfi_cmd.Init(kPathCount, GL_UNSIGNED_INT, shared_memory_id_,
1321 shared_memory_offset_, 0, testcases[i].fill_mode,
1322 testcases[i].mask, GL_NONE, 0, 0);
1323 EXPECT_EQ(error::kNoError, ExecuteCmd(sfi_cmd));
1324 EXPECT_EQ(testcases[i].expected_error, GetGLError());
1325
1326 memcpy(paths, kPaths, sizeof(kPaths));
1327 stcfi_cmd.Init(kPathCount, GL_UNSIGNED_INT, shared_memory_id_,
1328 shared_memory_offset_, 0, testcases[i].fill_mode,
1329 testcases[i].mask,
1330 GL_BOUNDING_BOX_OF_BOUNDING_BOXES_CHROMIUM, GL_NONE, 0, 0);
1331 EXPECT_EQ(error::kNoError, ExecuteCmd(stcfi_cmd));
1332 EXPECT_EQ(testcases[i].expected_error, GetGLError());
1333 }
1334 }
1335
1336 TEST_P(GLES2DecoderTestWithCHROMIUMPathRendering,
1337 StencilXFillPathInstancedCHROMIUMFillMode) {
1338 SetupExpectationsForApplyingDefaultDirtyState();
1339
1340 // Test different fill modes.
1341 cmds::StencilFillPathInstancedCHROMIUM sfi_cmd;
1342 cmds::StencilThenCoverFillPathInstancedCHROMIUM stcfi_cmd;
1343
1344 const GLuint kPaths[] = {client_path_id_, client_path_id_ + 5,
1345 client_path_id_, client_path_id_ + 18};
1346 const GLsizei kPathCount = arraysize(kPaths);
1347
1348 static const GLenum kFillModes[] = {GL_INVERT, GL_COUNT_UP_CHROMIUM,
1349 GL_COUNT_DOWN_CHROMIUM};
1350 const GLuint kMask = 0x7F;
1351
1352 GLuint* paths = GetSharedMemoryAs<GLuint*>();
1353
1354 for (size_t i = 0; i < arraysize(kFillModes); ++i) {
1355 memcpy(paths, kPaths, sizeof(kPaths));
1356 EXPECT_CALL(
1357 *gl_, StencilFillPathInstancedNV(kPathCount, GL_UNSIGNED_INT, paths, 0,
1358 kFillModes[i], kMask, GL_NONE, NULL))
1359 .RetiresOnSaturation();
1360 sfi_cmd.Init(kPathCount, GL_UNSIGNED_INT, shared_memory_id_,
1361 shared_memory_offset_, 0, kFillModes[i], kMask, GL_NONE, 0, 0);
1362 EXPECT_EQ(error::kNoError, ExecuteCmd(sfi_cmd));
1363 EXPECT_EQ(GL_NO_ERROR, GetGLError());
1364
1365 memcpy(paths, kPaths, sizeof(kPaths));
1366 EXPECT_CALL(*gl_,
1367 StencilThenCoverFillPathInstancedNV(
1368 kPathCount, GL_UNSIGNED_INT, paths, 0, kFillModes[i], kMask,
1369 GL_BOUNDING_BOX_OF_BOUNDING_BOXES_NV, GL_NONE, NULL))
1370 .RetiresOnSaturation();
1371 stcfi_cmd.Init(kPathCount, GL_UNSIGNED_INT, shared_memory_id_,
1372 shared_memory_offset_, 0, kFillModes[i], kMask,
1373 GL_BOUNDING_BOX_OF_BOUNDING_BOXES_CHROMIUM, GL_NONE, 0, 0);
1374 EXPECT_EQ(error::kNoError, ExecuteCmd(stcfi_cmd));
1375 EXPECT_EQ(GL_NO_ERROR, GetGLError());
1376 }
1377 }
1378
1379 TEST_P(GLES2DecoderTestWithCHROMIUMPathRendering, InstancedCalls) {
1380 SetupExpectationsForApplyingDefaultDirtyState();
1381
1382 const GLuint kPaths[] = {0, client_path_id_, 15, client_path_id_};
1383 const GLsizei kPathCount = arraysize(kPaths);
1384
1385 // The path base will be client_path_id_, and so 0 is a
1386 // valid path.
1387 const GLuint kPathBase = client_path_id_;
1388 const GLuint kPathsWithBase[] = {0, 5, 0, 18};
1389
1390 const GLshort kShortPathBase = client_path_id_ * 2;
1391 const GLshort kShortPathsWithBase[] = {
1392 -static_cast<GLshort>(client_path_id_), 5,
1393 -static_cast<GLshort>(client_path_id_), 18};
1394
1395 const GLenum kFillMode = GL_INVERT;
1396 const GLuint kMask = 0x80;
1397 const GLuint kReference = 0xFF;
1398
1399 GLfloat transform_values[12 * kPathCount];
1400 for (GLsizei i = 0; i < kPathCount; ++i) {
1401 for (int j = 0; j < 12; ++j) {
1402 transform_values[i * 12 + j] = 0.1f * j + i;
1403 }
1404 }
1405
1406 // Path name overflows to correct path.
1407 const GLuint kBigPathBase = std::numeric_limits<GLuint>::max();
1408 const GLuint kPathsWithBigBase[] = {client_path_id_ + 1, 5,
1409 client_path_id_ + 1, 18};
1410
1411 // Path name underflows. As a technical limitation, we can not get to correct
1412 // path,
1413 // so test just tests that there is no GL error.
1414 const GLuint kNegativePathBase = 1;
1415 const GLbyte kNegativePathsWithBaseByte[] = {-1, -2, -5, -18};
1416 const GLint kNegativePathsWithBaseInt[] = {-2, -3, -4, -5};
1417
1418 InstancedTestcase testcases[] = {
1419 // Test a normal call.
1420 {kPathCount, GL_UNSIGNED_INT, kPaths, 0, kFillMode, kReference, kMask,
1421 GL_NONE, NULL, sizeof(kPaths), 0, error::kNoError, GL_NO_ERROR, true},
1422 // Test that the path base is applied correctly for each instanced call.
1423 {kPathCount, GL_UNSIGNED_INT, kPathsWithBase, kPathBase, kFillMode,
1424 kReference, kMask, GL_NONE, NULL, sizeof(kPaths), 0, error::kNoError,
1425 GL_NO_ERROR, true},
1426 {kPathCount, GL_UNSIGNED_INT, kPathsWithBase, kPathBase, kFillMode,
1427 kReference, kMask,
1428
1429 // Test all possible transform types. The float array is big enough for
1430 // all the variants. The contents of the array in call is not checked,
1431 // though.
1432 GL_TRANSLATE_X_CHROMIUM, transform_values, sizeof(kPaths),
1433 sizeof(transform_values), error::kNoError, GL_NO_ERROR, true},
1434 {kPathCount, GL_UNSIGNED_INT, kPathsWithBase, kPathBase, kFillMode,
1435 kReference, kMask, GL_TRANSLATE_Y_CHROMIUM, transform_values,
1436 sizeof(kPaths), sizeof(transform_values), error::kNoError, GL_NO_ERROR,
1437 true},
1438 {kPathCount, GL_UNSIGNED_INT, kPathsWithBase, kPathBase, kFillMode,
1439 kReference, kMask, GL_TRANSLATE_2D_CHROMIUM, transform_values,
1440 sizeof(kPaths), sizeof(transform_values), error::kNoError, GL_NO_ERROR,
1441 true},
1442 {kPathCount, GL_UNSIGNED_INT, kPathsWithBase, kPathBase, kFillMode,
1443 kReference, kMask, GL_TRANSLATE_3D_CHROMIUM, transform_values,
1444 sizeof(kPaths), sizeof(transform_values), error::kNoError, GL_NO_ERROR,
1445 true},
1446 {kPathCount, GL_UNSIGNED_INT, kPathsWithBase, kPathBase, kFillMode,
1447 kReference, kMask, GL_AFFINE_2D_CHROMIUM, transform_values,
1448 sizeof(kPaths), sizeof(transform_values), error::kNoError, GL_NO_ERROR,
1449 true},
1450 {kPathCount, GL_UNSIGNED_INT, kPathsWithBase, kPathBase, kFillMode,
1451 kReference, kMask, GL_AFFINE_3D_CHROMIUM, transform_values,
1452 sizeof(kPaths), sizeof(transform_values), error::kNoError, GL_NO_ERROR,
1453 true},
1454 {kPathCount, GL_UNSIGNED_INT, kPathsWithBase, kPathBase, kFillMode,
1455 kReference, kMask, GL_TRANSPOSE_AFFINE_2D_CHROMIUM, transform_values,
1456 sizeof(kPaths), sizeof(transform_values), error::kNoError, GL_NO_ERROR,
1457 true},
1458 {kPathCount, GL_UNSIGNED_INT, kPathsWithBase, kPathBase, kFillMode,
1459 kReference, kMask, GL_TRANSPOSE_AFFINE_3D_CHROMIUM, transform_values,
1460 sizeof(kPaths), sizeof(transform_values), error::kNoError, GL_NO_ERROR,
1461 true},
1462 {kPathCount, GL_SHORT, kShortPathsWithBase, kShortPathBase, kFillMode,
1463 kReference, kMask, GL_TRANSPOSE_AFFINE_3D_CHROMIUM, transform_values,
1464 sizeof(kShortPathsWithBase), sizeof(transform_values), error::kNoError,
1465 GL_NO_ERROR, true},
1466
1467 // Test that if using path base causes path id to overflow, we get no
1468 // error.
1469 {kPathCount, GL_UNSIGNED_INT, kPathsWithBigBase, kBigPathBase, kFillMode,
1470 kReference, kMask, GL_TRANSLATE_X_CHROMIUM, transform_values,
1471 sizeof(kPathsWithBigBase), sizeof(transform_values), error::kNoError,
1472 GL_NO_ERROR, true},
1473 // Test that if using path base causes path id to underflow, we get no
1474 // error.
1475 {kPathCount, GL_BYTE, kNegativePathsWithBaseByte, kNegativePathBase,
1476 kFillMode, kReference, kMask, GL_TRANSLATE_X_CHROMIUM, transform_values,
1477 sizeof(kNegativePathsWithBaseByte), sizeof(transform_values),
1478 error::kNoError, GL_NO_ERROR, false},
1479 {kPathCount, GL_INT, kNegativePathsWithBaseInt, kNegativePathBase,
1480 kFillMode, kReference, kMask, GL_TRANSLATE_X_CHROMIUM, transform_values,
1481 sizeof(kNegativePathsWithBaseInt), sizeof(transform_values),
1482 error::kNoError, GL_NO_ERROR, false},
1483
1484 };
1485
1486 for (size_t i = 0; i < arraysize(testcases); ++i) {
1487 SCOPED_TRACE(testing::Message() << "InstancedCalls testcase " << i);
1488 CallAllInstancedCommands(testcases[i]);
1489 }
1490 }
1491
1492 TEST_P(GLES2DecoderTestWithCHROMIUMPathRendering, InstancedNoCalls) {
1493 const GLuint kPaths[] = {1, client_path_id_, 5, client_path_id_};
1494 const GLsizei kPathCount = arraysize(kPaths);
1495
1496 const GLenum kFillMode = GL_INVERT;
1497 const GLuint kMask = 0x80;
1498 const GLuint kReference = 0xFF;
1499 GLfloat transform_values[12 * kPathCount];
1500 for (GLsizei i = 0; i < kPathCount; ++i) {
1501 for (int j = 0; j < 12; ++j) {
1502 transform_values[i * 12 + j] = 0.1f * j + i;
1503 }
1504 }
1505
1506 // The path base will be client_path_id_, and so 0 is a valid path and others
1507 // should be invalid.
1508 const GLuint kInvalidPathBase = client_path_id_;
1509 const GLuint kInvalidPathsWithBase[] = {1, client_path_id_, 5, 18};
1510
1511 InstancedTestcase testcases[] = {
1512 // Zero path count produces no error, no call.
1513 {0, GL_UNSIGNED_INT, NULL, 0, kFillMode, kReference, kMask, GL_NONE, NULL,
1514 0, 0, error::kNoError, GL_NO_ERROR, false},
1515
1516 // Zero path count, even with path data, produces no error, no call.
1517 {0, GL_UNSIGNED_INT, kPaths, 0, kFillMode, kReference, kMask,
1518 GL_TRANSLATE_X_CHROMIUM, transform_values, sizeof(kPaths),
1519 sizeof(transform_values), error::kNoError, GL_NO_ERROR, false},
1520
1521 // Negative path count produces error.
1522 {-1, GL_UNSIGNED_INT, kPaths, 0, kFillMode, kReference, kMask,
1523 GL_TRANSLATE_X_CHROMIUM, transform_values, sizeof(kPaths),
1524 sizeof(transform_values), error::kNoError, GL_INVALID_VALUE, false},
1525
1526 // Passing paths count but not having the shm data is a connection error.
1527 {kPathCount, GL_UNSIGNED_INT, NULL, 0, kFillMode, kReference, kMask,
1528 GL_TRANSLATE_X_CHROMIUM, transform_values, 0, sizeof(transform_values),
1529 error::kOutOfBounds, GL_NO_ERROR, false},
1530
1531 // Huge path count would cause huge transfer buffer, it does not go
1532 // through.
1533 {std::numeric_limits<GLsizei>::max() - 3, GL_UNSIGNED_INT, kPaths, 0,
1534 kFillMode, kReference, kMask, GL_TRANSLATE_X_CHROMIUM, transform_values,
1535 sizeof(kPaths), sizeof(transform_values), error::kOutOfBounds,
1536 GL_NO_ERROR, false},
1537
1538 // Test that the path base is applied correctly for each instanced call.
1539 // In this case no path is marked as used, and so no GL function should be
1540 // called and no error should be generated.
1541 {kPathCount, GL_UNSIGNED_INT, kInvalidPathsWithBase, kInvalidPathBase,
1542 kFillMode, kReference, kMask, GL_TRANSLATE_X_CHROMIUM, transform_values,
1543 sizeof(kInvalidPathsWithBase), sizeof(transform_values), error::kNoError,
1544 GL_NO_ERROR, false},
1545
1546 // Test that using correct paths but invalid transform type produces
1547 // invalid enum.
1548 {kPathCount, GL_UNSIGNED_INT, kPaths, 0, kFillMode, kReference, kMask,
1549 GL_TRANSLATE_X_CHROMIUM - 1, transform_values, sizeof(kPaths),
1550 sizeof(transform_values), error::kNoError, GL_INVALID_ENUM, false},
1551
1552 // Test that if we have transform, not having the shm data is a connection
1553 // error.
1554 {kPathCount, GL_UNSIGNED_INT, kPaths, 0, kFillMode, kReference, kMask,
1555 GL_TRANSLATE_X_CHROMIUM, NULL, sizeof(kPaths), 0, error::kOutOfBounds,
1556 GL_NO_ERROR, false},
1557
1558 };
1559 for (size_t i = 0; i < arraysize(testcases); ++i) {
1560 SCOPED_TRACE(testing::Message() << "InstancedNoCalls testcase " << i);
1561 CallAllInstancedCommands(testcases[i]);
1562 }
1563 }
1564
1565 TEST_P(GLES2DecoderTestWithCHROMIUMPathRendering, InstancedInvalidSHMValues) {
1566 const GLuint kPaths[] = {1, client_path_id_, 5, client_path_id_};
1567 const GLsizei kPathCount = arraysize(kPaths);
1568 GLfloat transform_values[12 * kPathCount];
1569 for (GLsizei i = 0; i < kPathCount; ++i) {
1570 for (int j = 0; j < 12; ++j) {
1571 transform_values[i * 12 + j] = 0.1f * j + i;
1572 }
1573 }
1574 enum {
1575 kPathsSHMIdInvalid = 1,
1576 kPathsSHMOffsetInvalid = 1 << 1,
1577 kTransformsHMIdInvalid = 1 << 2,
1578 kTransformsHMOffsetInvalid = 1 << 3,
1579 kFirstTestcase = kPathsSHMIdInvalid,
1580 kLastTestcase = kTransformsHMOffsetInvalid
1581 };
1582
1583 for (int testcase = kFirstTestcase; testcase <= kLastTestcase; ++testcase) {
1584 GLfloat* transforms = GetSharedMemoryAs<GLfloat*>();
1585 uint32 transforms_shm_id = shared_memory_id_;
1586 uint32 transforms_shm_offset = shared_memory_offset_;
1587 memcpy(transforms, transform_values, sizeof(transform_values));
1588
1589 GLuint* paths =
1590 GetSharedMemoryAsWithOffset<GLuint*>(sizeof(transform_values));
1591 uint32 paths_shm_id = shared_memory_id_;
1592 uint32 paths_shm_offset = shared_memory_offset_ + sizeof(transform_values);
1593
1594 if (testcase & kPathsSHMIdInvalid) {
1595 paths_shm_id = kInvalidSharedMemoryId;
1596 }
1597 if (testcase & kPathsSHMOffsetInvalid) {
1598 paths_shm_offset = kInvalidSharedMemoryOffset;
1599 }
1600 if (testcase & kTransformsHMIdInvalid) {
1601 transforms_shm_id = kInvalidSharedMemoryId;
1602 }
1603 if (testcase & kTransformsHMOffsetInvalid) {
1604 transforms_shm_offset = kInvalidSharedMemoryOffset;
1605 }
1606 SCOPED_TRACE(testing::Message() << "InstancedInvalidSHMValues testcase "
1607 << testcase);
1608 CallAllInstancedCommandsWithInvalidSHM(
1609 kPathCount, kPaths, paths, paths_shm_id, paths_shm_offset,
1610 transforms_shm_id, transforms_shm_offset);
1611 }
1612 }
1613
981 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_extensions_autog en.h" 1614 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_extensions_autog en.h"
982 1615
983 } // namespace gles2 1616 } // namespace gles2
984 } // namespace gpu 1617 } // namespace gpu
985 1618
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698