1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
gpu / command_buffer / common / raster_cmd_format_test_autogen.h [blame]
// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This file is auto-generated from
// gpu/command_buffer/build_raster_cmd_buffer.py
// It's formatted by clang-format using chromium coding style:
// clang-format -i -style=chromium filename
// DO NOT EDIT!
// This file contains unit tests for raster commands
// It is included by raster_cmd_format_test.cc
#ifndef GPU_COMMAND_BUFFER_COMMON_RASTER_CMD_FORMAT_TEST_AUTOGEN_H_
#define GPU_COMMAND_BUFFER_COMMON_RASTER_CMD_FORMAT_TEST_AUTOGEN_H_
TEST_F(RasterFormatTest, Finish) {
cmds::Finish& cmd = *GetBufferAs<cmds::Finish>();
void* next_cmd = cmd.Set(&cmd);
EXPECT_EQ(static_cast<uint32_t>(cmds::Finish::kCmdId), cmd.header.command);
EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
}
TEST_F(RasterFormatTest, Flush) {
cmds::Flush& cmd = *GetBufferAs<cmds::Flush>();
void* next_cmd = cmd.Set(&cmd);
EXPECT_EQ(static_cast<uint32_t>(cmds::Flush::kCmdId), cmd.header.command);
EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
}
TEST_F(RasterFormatTest, GetError) {
cmds::GetError& cmd = *GetBufferAs<cmds::GetError>();
void* next_cmd =
cmd.Set(&cmd, static_cast<uint32_t>(11), static_cast<uint32_t>(12));
EXPECT_EQ(static_cast<uint32_t>(cmds::GetError::kCmdId), cmd.header.command);
EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
EXPECT_EQ(static_cast<uint32_t>(11), cmd.result_shm_id);
EXPECT_EQ(static_cast<uint32_t>(12), cmd.result_shm_offset);
CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
}
TEST_F(RasterFormatTest, GenQueriesEXTImmediate) {
static GLuint ids[] = {
12,
23,
34,
};
cmds::GenQueriesEXTImmediate& cmd =
*GetBufferAs<cmds::GenQueriesEXTImmediate>();
void* next_cmd = cmd.Set(&cmd, static_cast<GLsizei>(std::size(ids)), ids);
EXPECT_EQ(static_cast<uint32_t>(cmds::GenQueriesEXTImmediate::kCmdId),
cmd.header.command);
EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(cmd.n * 4u),
cmd.header.size * 4u);
EXPECT_EQ(static_cast<GLsizei>(std::size(ids)), cmd.n);
CheckBytesWrittenMatchesExpectedSize(
next_cmd,
sizeof(cmd) + RoundSizeToMultipleOfEntries(std::size(ids) * 4u));
EXPECT_EQ(0, memcmp(ids, ImmediateDataAddress(&cmd), sizeof(ids)));
}
TEST_F(RasterFormatTest, DeleteQueriesEXTImmediate) {
static GLuint ids[] = {
12,
23,
34,
};
cmds::DeleteQueriesEXTImmediate& cmd =
*GetBufferAs<cmds::DeleteQueriesEXTImmediate>();
void* next_cmd = cmd.Set(&cmd, static_cast<GLsizei>(std::size(ids)), ids);
EXPECT_EQ(static_cast<uint32_t>(cmds::DeleteQueriesEXTImmediate::kCmdId),
cmd.header.command);
EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(cmd.n * 4u),
cmd.header.size * 4u);
EXPECT_EQ(static_cast<GLsizei>(std::size(ids)), cmd.n);
CheckBytesWrittenMatchesExpectedSize(
next_cmd,
sizeof(cmd) + RoundSizeToMultipleOfEntries(std::size(ids) * 4u));
EXPECT_EQ(0, memcmp(ids, ImmediateDataAddress(&cmd), sizeof(ids)));
}
TEST_F(RasterFormatTest, QueryCounterEXT) {
cmds::QueryCounterEXT& cmd = *GetBufferAs<cmds::QueryCounterEXT>();
void* next_cmd = cmd.Set(&cmd, static_cast<GLuint>(11),
static_cast<GLenum>(12), static_cast<uint32_t>(13),
static_cast<uint32_t>(14), static_cast<GLuint>(15));
EXPECT_EQ(static_cast<uint32_t>(cmds::QueryCounterEXT::kCmdId),
cmd.header.command);
EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
EXPECT_EQ(static_cast<GLuint>(11), cmd.id);
EXPECT_EQ(static_cast<GLenum>(12), cmd.target);
EXPECT_EQ(static_cast<uint32_t>(13), cmd.sync_data_shm_id);
EXPECT_EQ(static_cast<uint32_t>(14), cmd.sync_data_shm_offset);
EXPECT_EQ(static_cast<GLuint>(15), cmd.submit_count);
CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
}
TEST_F(RasterFormatTest, BeginQueryEXT) {
cmds::BeginQueryEXT& cmd = *GetBufferAs<cmds::BeginQueryEXT>();
void* next_cmd =
cmd.Set(&cmd, static_cast<GLenum>(11), static_cast<GLuint>(12),
static_cast<uint32_t>(13), static_cast<uint32_t>(14));
EXPECT_EQ(static_cast<uint32_t>(cmds::BeginQueryEXT::kCmdId),
cmd.header.command);
EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
EXPECT_EQ(static_cast<GLenum>(11), cmd.target);
EXPECT_EQ(static_cast<GLuint>(12), cmd.id);
EXPECT_EQ(static_cast<uint32_t>(13), cmd.sync_data_shm_id);
EXPECT_EQ(static_cast<uint32_t>(14), cmd.sync_data_shm_offset);
CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
}
TEST_F(RasterFormatTest, EndQueryEXT) {
cmds::EndQueryEXT& cmd = *GetBufferAs<cmds::EndQueryEXT>();
void* next_cmd =
cmd.Set(&cmd, static_cast<GLenum>(11), static_cast<GLuint>(12));
EXPECT_EQ(static_cast<uint32_t>(cmds::EndQueryEXT::kCmdId),
cmd.header.command);
EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
EXPECT_EQ(static_cast<GLenum>(11), cmd.target);
EXPECT_EQ(static_cast<GLuint>(12), cmd.submit_count);
CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
}
TEST_F(RasterFormatTest, LoseContextCHROMIUM) {
cmds::LoseContextCHROMIUM& cmd = *GetBufferAs<cmds::LoseContextCHROMIUM>();
void* next_cmd =
cmd.Set(&cmd, static_cast<GLenum>(11), static_cast<GLenum>(12));
EXPECT_EQ(static_cast<uint32_t>(cmds::LoseContextCHROMIUM::kCmdId),
cmd.header.command);
EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
EXPECT_EQ(static_cast<GLenum>(11), cmd.current);
EXPECT_EQ(static_cast<GLenum>(12), cmd.other);
CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
}
TEST_F(RasterFormatTest, BeginRasterCHROMIUMImmediate) {
const int kSomeBaseValueToTestWith = 51;
static GLbyte data[] = {
static_cast<GLbyte>(kSomeBaseValueToTestWith + 0),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 1),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 2),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 3),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 4),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 5),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 6),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 7),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 8),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 9),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 10),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 11),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 12),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 13),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 14),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 15),
};
cmds::BeginRasterCHROMIUMImmediate& cmd =
*GetBufferAs<cmds::BeginRasterCHROMIUMImmediate>();
void* next_cmd = cmd.Set(
&cmd, static_cast<GLfloat>(11), static_cast<GLfloat>(12),
static_cast<GLfloat>(13), static_cast<GLfloat>(14),
static_cast<GLboolean>(15), static_cast<GLuint>(16),
static_cast<gpu::raster::MsaaMode>(17), static_cast<GLboolean>(18),
static_cast<GLboolean>(19), static_cast<GLfloat>(20), data);
EXPECT_EQ(static_cast<uint32_t>(cmds::BeginRasterCHROMIUMImmediate::kCmdId),
cmd.header.command);
EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)),
cmd.header.size * 4u);
EXPECT_EQ(static_cast<GLfloat>(11), cmd.r);
EXPECT_EQ(static_cast<GLfloat>(12), cmd.g);
EXPECT_EQ(static_cast<GLfloat>(13), cmd.b);
EXPECT_EQ(static_cast<GLfloat>(14), cmd.a);
EXPECT_EQ(static_cast<GLboolean>(15), cmd.needs_clear);
EXPECT_EQ(static_cast<GLuint>(16), cmd.msaa_sample_count);
EXPECT_EQ(static_cast<gpu::raster::MsaaMode>(17), cmd.msaa_mode);
EXPECT_EQ(static_cast<GLboolean>(18), cmd.can_use_lcd_text);
EXPECT_EQ(static_cast<GLboolean>(19), cmd.visible);
EXPECT_EQ(static_cast<GLfloat>(20), cmd.hdr_headroom);
CheckBytesWrittenMatchesExpectedSize(
next_cmd, sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)));
}
TEST_F(RasterFormatTest, RasterCHROMIUM) {
cmds::RasterCHROMIUM& cmd = *GetBufferAs<cmds::RasterCHROMIUM>();
void* next_cmd =
cmd.Set(&cmd, static_cast<GLuint>(11), static_cast<GLuint>(12),
static_cast<GLsizeiptr>(13), static_cast<GLuint>(14),
static_cast<GLuint>(15), static_cast<GLsizeiptr>(16));
EXPECT_EQ(static_cast<uint32_t>(cmds::RasterCHROMIUM::kCmdId),
cmd.header.command);
EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
EXPECT_EQ(static_cast<GLuint>(11), cmd.raster_shm_id);
EXPECT_EQ(static_cast<GLuint>(12), cmd.raster_shm_offset);
EXPECT_EQ(static_cast<GLsizeiptr>(13), cmd.raster_shm_size);
EXPECT_EQ(static_cast<GLuint>(14), cmd.font_shm_id);
EXPECT_EQ(static_cast<GLuint>(15), cmd.font_shm_offset);
EXPECT_EQ(static_cast<GLsizeiptr>(16), cmd.font_shm_size);
CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
}
TEST_F(RasterFormatTest, EndRasterCHROMIUM) {
cmds::EndRasterCHROMIUM& cmd = *GetBufferAs<cmds::EndRasterCHROMIUM>();
void* next_cmd = cmd.Set(&cmd);
EXPECT_EQ(static_cast<uint32_t>(cmds::EndRasterCHROMIUM::kCmdId),
cmd.header.command);
EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
}
TEST_F(RasterFormatTest, CreateTransferCacheEntryINTERNAL) {
cmds::CreateTransferCacheEntryINTERNAL& cmd =
*GetBufferAs<cmds::CreateTransferCacheEntryINTERNAL>();
void* next_cmd = cmd.Set(&cmd, static_cast<GLuint>(11),
static_cast<GLuint>(12), static_cast<GLuint>(13),
static_cast<GLuint>(14), static_cast<GLuint>(15),
static_cast<GLuint>(16), static_cast<GLuint>(17));
EXPECT_EQ(
static_cast<uint32_t>(cmds::CreateTransferCacheEntryINTERNAL::kCmdId),
cmd.header.command);
EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
EXPECT_EQ(static_cast<GLuint>(11), cmd.entry_type);
EXPECT_EQ(static_cast<GLuint>(12), cmd.entry_id);
EXPECT_EQ(static_cast<GLuint>(13), cmd.handle_shm_id);
EXPECT_EQ(static_cast<GLuint>(14), cmd.handle_shm_offset);
EXPECT_EQ(static_cast<GLuint>(15), cmd.data_shm_id);
EXPECT_EQ(static_cast<GLuint>(16), cmd.data_shm_offset);
EXPECT_EQ(static_cast<GLuint>(17), cmd.data_size);
CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
}
TEST_F(RasterFormatTest, DeleteTransferCacheEntryINTERNAL) {
cmds::DeleteTransferCacheEntryINTERNAL& cmd =
*GetBufferAs<cmds::DeleteTransferCacheEntryINTERNAL>();
void* next_cmd =
cmd.Set(&cmd, static_cast<GLuint>(11), static_cast<GLuint>(12));
EXPECT_EQ(
static_cast<uint32_t>(cmds::DeleteTransferCacheEntryINTERNAL::kCmdId),
cmd.header.command);
EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
EXPECT_EQ(static_cast<GLuint>(11), cmd.entry_type);
EXPECT_EQ(static_cast<GLuint>(12), cmd.entry_id);
CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
}
TEST_F(RasterFormatTest, UnlockTransferCacheEntryINTERNAL) {
cmds::UnlockTransferCacheEntryINTERNAL& cmd =
*GetBufferAs<cmds::UnlockTransferCacheEntryINTERNAL>();
void* next_cmd =
cmd.Set(&cmd, static_cast<GLuint>(11), static_cast<GLuint>(12));
EXPECT_EQ(
static_cast<uint32_t>(cmds::UnlockTransferCacheEntryINTERNAL::kCmdId),
cmd.header.command);
EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
EXPECT_EQ(static_cast<GLuint>(11), cmd.entry_type);
EXPECT_EQ(static_cast<GLuint>(12), cmd.entry_id);
CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
}
TEST_F(RasterFormatTest, DeletePaintCachePathsINTERNALImmediate) {
static GLuint ids[] = {
12,
23,
34,
};
cmds::DeletePaintCachePathsINTERNALImmediate& cmd =
*GetBufferAs<cmds::DeletePaintCachePathsINTERNALImmediate>();
void* next_cmd = cmd.Set(&cmd, static_cast<GLsizei>(std::size(ids)), ids);
EXPECT_EQ(static_cast<uint32_t>(
cmds::DeletePaintCachePathsINTERNALImmediate::kCmdId),
cmd.header.command);
EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(cmd.n * 4u),
cmd.header.size * 4u);
EXPECT_EQ(static_cast<GLsizei>(std::size(ids)), cmd.n);
CheckBytesWrittenMatchesExpectedSize(
next_cmd,
sizeof(cmd) + RoundSizeToMultipleOfEntries(std::size(ids) * 4u));
EXPECT_EQ(0, memcmp(ids, ImmediateDataAddress(&cmd), sizeof(ids)));
}
TEST_F(RasterFormatTest, DeletePaintCachePathsINTERNAL) {
cmds::DeletePaintCachePathsINTERNAL& cmd =
*GetBufferAs<cmds::DeletePaintCachePathsINTERNAL>();
void* next_cmd =
cmd.Set(&cmd, static_cast<GLsizei>(11), static_cast<uint32_t>(12),
static_cast<uint32_t>(13));
EXPECT_EQ(static_cast<uint32_t>(cmds::DeletePaintCachePathsINTERNAL::kCmdId),
cmd.header.command);
EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
EXPECT_EQ(static_cast<GLsizei>(11), cmd.n);
EXPECT_EQ(static_cast<uint32_t>(12), cmd.ids_shm_id);
EXPECT_EQ(static_cast<uint32_t>(13), cmd.ids_shm_offset);
CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
}
TEST_F(RasterFormatTest, ClearPaintCacheINTERNAL) {
cmds::ClearPaintCacheINTERNAL& cmd =
*GetBufferAs<cmds::ClearPaintCacheINTERNAL>();
void* next_cmd = cmd.Set(&cmd);
EXPECT_EQ(static_cast<uint32_t>(cmds::ClearPaintCacheINTERNAL::kCmdId),
cmd.header.command);
EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
}
TEST_F(RasterFormatTest, CopySharedImageINTERNALImmediate) {
const int kSomeBaseValueToTestWith = 51;
static GLbyte data[] = {
static_cast<GLbyte>(kSomeBaseValueToTestWith + 0),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 1),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 2),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 3),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 4),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 5),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 6),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 7),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 8),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 9),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 10),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 11),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 12),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 13),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 14),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 15),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 16),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 17),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 18),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 19),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 20),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 21),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 22),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 23),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 24),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 25),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 26),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 27),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 28),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 29),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 30),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 31),
};
cmds::CopySharedImageINTERNALImmediate& cmd =
*GetBufferAs<cmds::CopySharedImageINTERNALImmediate>();
void* next_cmd =
cmd.Set(&cmd, static_cast<GLint>(11), static_cast<GLint>(12),
static_cast<GLint>(13), static_cast<GLint>(14),
static_cast<GLsizei>(15), static_cast<GLsizei>(16), data);
EXPECT_EQ(
static_cast<uint32_t>(cmds::CopySharedImageINTERNALImmediate::kCmdId),
cmd.header.command);
EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)),
cmd.header.size * 4u);
EXPECT_EQ(static_cast<GLint>(11), cmd.xoffset);
EXPECT_EQ(static_cast<GLint>(12), cmd.yoffset);
EXPECT_EQ(static_cast<GLint>(13), cmd.x);
EXPECT_EQ(static_cast<GLint>(14), cmd.y);
EXPECT_EQ(static_cast<GLsizei>(15), cmd.width);
EXPECT_EQ(static_cast<GLsizei>(16), cmd.height);
CheckBytesWrittenMatchesExpectedSize(
next_cmd, sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)));
}
TEST_F(RasterFormatTest, WritePixelsINTERNALImmediate) {
const int kSomeBaseValueToTestWith = 51;
static GLbyte data[] = {
static_cast<GLbyte>(kSomeBaseValueToTestWith + 0),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 1),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 2),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 3),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 4),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 5),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 6),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 7),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 8),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 9),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 10),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 11),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 12),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 13),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 14),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 15),
};
cmds::WritePixelsINTERNALImmediate& cmd =
*GetBufferAs<cmds::WritePixelsINTERNALImmediate>();
void* next_cmd = cmd.Set(
&cmd, static_cast<GLint>(11), static_cast<GLint>(12),
static_cast<GLuint>(13), static_cast<GLuint>(14), static_cast<GLuint>(15),
static_cast<GLuint>(16), static_cast<GLuint>(17), static_cast<GLint>(18),
static_cast<GLuint>(19), static_cast<GLuint>(20), data);
EXPECT_EQ(static_cast<uint32_t>(cmds::WritePixelsINTERNALImmediate::kCmdId),
cmd.header.command);
EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)),
cmd.header.size * 4u);
EXPECT_EQ(static_cast<GLint>(11), cmd.x_offset);
EXPECT_EQ(static_cast<GLint>(12), cmd.y_offset);
EXPECT_EQ(static_cast<GLuint>(13), cmd.src_width);
EXPECT_EQ(static_cast<GLuint>(14), cmd.src_height);
EXPECT_EQ(static_cast<GLuint>(15), cmd.src_row_bytes);
EXPECT_EQ(static_cast<GLuint>(16), cmd.src_sk_color_type);
EXPECT_EQ(static_cast<GLuint>(17), cmd.src_sk_alpha_type);
EXPECT_EQ(static_cast<GLint>(18), cmd.shm_id);
EXPECT_EQ(static_cast<GLuint>(19), cmd.shm_offset);
EXPECT_EQ(static_cast<GLuint>(20), cmd.pixels_offset);
CheckBytesWrittenMatchesExpectedSize(
next_cmd, sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)));
}
TEST_F(RasterFormatTest, WritePixelsYUVINTERNALImmediate) {
const int kSomeBaseValueToTestWith = 51;
static GLbyte data[] = {
static_cast<GLbyte>(kSomeBaseValueToTestWith + 0),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 1),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 2),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 3),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 4),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 5),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 6),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 7),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 8),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 9),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 10),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 11),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 12),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 13),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 14),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 15),
};
cmds::WritePixelsYUVINTERNALImmediate& cmd =
*GetBufferAs<cmds::WritePixelsYUVINTERNALImmediate>();
void* next_cmd = cmd.Set(
&cmd, static_cast<GLuint>(11), static_cast<GLuint>(12),
static_cast<GLuint>(13), static_cast<GLuint>(14), static_cast<GLuint>(15),
static_cast<GLuint>(16), static_cast<GLuint>(17), static_cast<GLuint>(18),
static_cast<GLuint>(19), static_cast<GLint>(20), static_cast<GLuint>(21),
static_cast<GLuint>(22), static_cast<GLuint>(23), static_cast<GLuint>(24),
data);
EXPECT_EQ(
static_cast<uint32_t>(cmds::WritePixelsYUVINTERNALImmediate::kCmdId),
cmd.header.command);
EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)),
cmd.header.size * 4u);
EXPECT_EQ(static_cast<GLuint>(11), cmd.src_width);
EXPECT_EQ(static_cast<GLuint>(12), cmd.src_height);
EXPECT_EQ(static_cast<GLuint>(13), cmd.src_row_bytes_plane1);
EXPECT_EQ(static_cast<GLuint>(14), cmd.src_row_bytes_plane2);
EXPECT_EQ(static_cast<GLuint>(15), cmd.src_row_bytes_plane3);
EXPECT_EQ(static_cast<GLuint>(16), cmd.src_row_bytes_plane4);
EXPECT_EQ(static_cast<GLuint>(17), cmd.src_yuv_plane_config);
EXPECT_EQ(static_cast<GLuint>(18), cmd.src_yuv_subsampling);
EXPECT_EQ(static_cast<GLuint>(19), cmd.src_yuv_datatype);
EXPECT_EQ(static_cast<GLint>(20), cmd.shm_id);
EXPECT_EQ(static_cast<GLuint>(21), cmd.shm_offset);
EXPECT_EQ(static_cast<GLuint>(22), cmd.plane2_offset);
EXPECT_EQ(static_cast<GLuint>(23), cmd.plane3_offset);
EXPECT_EQ(static_cast<GLuint>(24), cmd.plane4_offset);
CheckBytesWrittenMatchesExpectedSize(
next_cmd, sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)));
}
TEST_F(RasterFormatTest, ReadbackARGBImagePixelsINTERNALImmediate) {
const int kSomeBaseValueToTestWith = 51;
static GLbyte data[] = {
static_cast<GLbyte>(kSomeBaseValueToTestWith + 0),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 1),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 2),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 3),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 4),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 5),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 6),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 7),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 8),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 9),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 10),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 11),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 12),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 13),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 14),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 15),
};
cmds::ReadbackARGBImagePixelsINTERNALImmediate& cmd =
*GetBufferAs<cmds::ReadbackARGBImagePixelsINTERNALImmediate>();
void* next_cmd = cmd.Set(
&cmd, static_cast<GLint>(11), static_cast<GLint>(12),
static_cast<GLint>(13), static_cast<GLuint>(14), static_cast<GLuint>(15),
static_cast<GLuint>(16), static_cast<GLuint>(17), static_cast<GLuint>(18),
static_cast<GLint>(19), static_cast<GLuint>(20), static_cast<GLuint>(21),
static_cast<GLuint>(22), data);
EXPECT_EQ(static_cast<uint32_t>(
cmds::ReadbackARGBImagePixelsINTERNALImmediate::kCmdId),
cmd.header.command);
EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)),
cmd.header.size * 4u);
EXPECT_EQ(static_cast<GLint>(11), cmd.src_x);
EXPECT_EQ(static_cast<GLint>(12), cmd.src_y);
EXPECT_EQ(static_cast<GLint>(13), cmd.plane_index);
EXPECT_EQ(static_cast<GLuint>(14), cmd.dst_width);
EXPECT_EQ(static_cast<GLuint>(15), cmd.dst_height);
EXPECT_EQ(static_cast<GLuint>(16), cmd.row_bytes);
EXPECT_EQ(static_cast<GLuint>(17), cmd.dst_sk_color_type);
EXPECT_EQ(static_cast<GLuint>(18), cmd.dst_sk_alpha_type);
EXPECT_EQ(static_cast<GLint>(19), cmd.shm_id);
EXPECT_EQ(static_cast<GLuint>(20), cmd.shm_offset);
EXPECT_EQ(static_cast<GLuint>(21), cmd.color_space_offset);
EXPECT_EQ(static_cast<GLuint>(22), cmd.pixels_offset);
CheckBytesWrittenMatchesExpectedSize(
next_cmd, sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)));
}
TEST_F(RasterFormatTest, ReadbackYUVImagePixelsINTERNALImmediate) {
const int kSomeBaseValueToTestWith = 51;
static GLbyte data[] = {
static_cast<GLbyte>(kSomeBaseValueToTestWith + 0),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 1),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 2),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 3),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 4),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 5),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 6),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 7),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 8),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 9),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 10),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 11),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 12),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 13),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 14),
static_cast<GLbyte>(kSomeBaseValueToTestWith + 15),
};
cmds::ReadbackYUVImagePixelsINTERNALImmediate& cmd =
*GetBufferAs<cmds::ReadbackYUVImagePixelsINTERNALImmediate>();
void* next_cmd = cmd.Set(
&cmd, static_cast<GLuint>(11), static_cast<GLuint>(12),
static_cast<GLint>(13), static_cast<GLuint>(14), static_cast<GLuint>(15),
static_cast<GLuint>(16), static_cast<GLuint>(17), static_cast<GLuint>(18),
static_cast<GLuint>(19), static_cast<GLuint>(20), data);
EXPECT_EQ(static_cast<uint32_t>(
cmds::ReadbackYUVImagePixelsINTERNALImmediate::kCmdId),
cmd.header.command);
EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)),
cmd.header.size * 4u);
EXPECT_EQ(static_cast<GLuint>(11), cmd.dst_width);
EXPECT_EQ(static_cast<GLuint>(12), cmd.dst_height);
EXPECT_EQ(static_cast<GLint>(13), cmd.shm_id);
EXPECT_EQ(static_cast<GLuint>(14), cmd.shm_offset);
EXPECT_EQ(static_cast<GLuint>(15), cmd.y_offset);
EXPECT_EQ(static_cast<GLuint>(16), cmd.y_stride);
EXPECT_EQ(static_cast<GLuint>(17), cmd.u_offset);
EXPECT_EQ(static_cast<GLuint>(18), cmd.u_stride);
EXPECT_EQ(static_cast<GLuint>(19), cmd.v_offset);
EXPECT_EQ(static_cast<GLuint>(20), cmd.v_stride);
CheckBytesWrittenMatchesExpectedSize(
next_cmd, sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)));
}
TEST_F(RasterFormatTest, TraceBeginCHROMIUM) {
cmds::TraceBeginCHROMIUM& cmd = *GetBufferAs<cmds::TraceBeginCHROMIUM>();
void* next_cmd =
cmd.Set(&cmd, static_cast<GLuint>(11), static_cast<GLuint>(12));
EXPECT_EQ(static_cast<uint32_t>(cmds::TraceBeginCHROMIUM::kCmdId),
cmd.header.command);
EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
EXPECT_EQ(static_cast<GLuint>(11), cmd.category_bucket_id);
EXPECT_EQ(static_cast<GLuint>(12), cmd.name_bucket_id);
CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
}
TEST_F(RasterFormatTest, TraceEndCHROMIUM) {
cmds::TraceEndCHROMIUM& cmd = *GetBufferAs<cmds::TraceEndCHROMIUM>();
void* next_cmd = cmd.Set(&cmd);
EXPECT_EQ(static_cast<uint32_t>(cmds::TraceEndCHROMIUM::kCmdId),
cmd.header.command);
EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
}
TEST_F(RasterFormatTest, SetActiveURLCHROMIUM) {
cmds::SetActiveURLCHROMIUM& cmd = *GetBufferAs<cmds::SetActiveURLCHROMIUM>();
void* next_cmd = cmd.Set(&cmd, static_cast<GLuint>(11));
EXPECT_EQ(static_cast<uint32_t>(cmds::SetActiveURLCHROMIUM::kCmdId),
cmd.header.command);
EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
EXPECT_EQ(static_cast<GLuint>(11), cmd.url_bucket_id);
CheckBytesWrittenMatchesExpectedSize(next_cmd, sizeof(cmd));
}
#endif // GPU_COMMAND_BUFFER_COMMON_RASTER_CMD_FORMAT_TEST_AUTOGEN_H_